Index: lang/perl5.18/Makefile
===================================================================
--- lang/perl5.18/Makefile
+++ lang/perl5.18/Makefile
@@ -175,12 +175,18 @@
 BSDPAN_VERSION=	20111107
 BSDPAN_WRKSRC=	${WRKDIR}/BSDPAN-${BSDPAN_VERSION}
 
+# Put a symlink to the future libperl.so.x.yy so that -lperl works.
+post-extract:
+	${LN} -s libperl.so.${PERL_VER} ${WRKSRC}/libperl.so
+
 post-patch:
 	${SED} -i '' -e 's|%%PERL_PKGNAME%%|${PKGNAME}|g; s|%%PERL_VER%%|${PERL_VER}|g;' \
 		-e 's!%%BSDPAN_VERSION%%!${BSDPAN_VERSION}!g;' \
 		${BSDPAN_WRKSRC}/ExtUtils/*.pm
 	${REINPLACE_CMD} -e 's|/usr/local|${LOCALBASE}|g' \
 		${WRKSRC}/Configure ${WRKSRC}/hints/freebsd.sh
+	${REINPLACE_CMD} -e 's|lddlflags="-shared "|lddlflags="-shared -L${WRKSRC} -L${PREFIX}/lib/perl5/${PERL_VER}/${PERL_ARCH}/CORE -Wl,-rpath=${PREFIX}/lib/perl5/${PERL_VER}/${PERL_ARCH}/CORE -lperl "|' \
+		${WRKSRC}/hints/freebsd.sh
 .if ${PORT_OPTIONS:MPTHREAD}
 	${REINPLACE_CMD} -e 's|%%PTHREAD_LIBS%%|${PTHREAD_LIBS}|g;' \
 		-e 's|%%PTHREAD_CFLAGS%%|${PTHREAD_CFLAGS}|g;' \
@@ -196,8 +202,8 @@
 	${MKDIR} ${STAGEDIR}${SITE_ARCH}/auto
 	${MKDIR} ${STAGEDIR}${SITE_PERL}/auto
 	${LN} ${STAGEDIR}${PREFIX}/bin/perl${PERL_VERSION} ${STAGEDIR}${PREFIX}/bin/perl5
-	${LN} -s libperl.so.${PERL_VER} ${STAGEDIR}${PREFIX}/lib/perl5/${PERL_VER}/${PERL_ARCH}/CORE/libperl.so
-	${LN} -s libperl.so.${PERL_VER} ${STAGEDIR}${PREFIX}/lib/perl5/${PERL_VER}/${PERL_ARCH}/CORE/libperl.so.${PERL_VERSION}
+	${LN} -sf libperl.so.${PERL_VER} ${STAGEDIR}${PREFIX}/lib/perl5/${PERL_VER}/${PERL_ARCH}/CORE/libperl.so
+	${LN} -sf libperl.so.${PERL_VER} ${STAGEDIR}${PREFIX}/lib/perl5/${PERL_VER}/${PERL_ARCH}/CORE/libperl.so.${PERL_VERSION}
 	${STRIP_CMD} ${STAGEDIR}${PREFIX}/bin/perl${PERL_VERSION}
 	${INSTALL_DATA} ${WRKDIR}/perl5_version ${STAGEDIR}${PREFIX}/etc
 	${FIND} ${STAGEDIR} -name '*.bs' -size 0 -delete
Index: lang/perl5.18/files/patch-Makefile.SH
===================================================================
--- lang/perl5.18/files/patch-Makefile.SH
+++ lang/perl5.18/files/patch-Makefile.SH
@@ -1,11 +1,11 @@
 --- Makefile.SH.orig	2014-10-01 15:23:34 UTC
 +++ Makefile.SH
-@@ -805,7 +808,7 @@ $(LIBPERL): $& $(obj) $(DYNALOADER) $(LI
+@@ -805,7 +805,7 @@ $(LIBPERL): $& $(obj) $(DYNALOADER) $(LI
  	true)
  		$spitshell >>$Makefile <<'!NO!SUBS!'
  	rm -f $@
 -	$(LD) -o $@ $(SHRPLDFLAGS) $(obj) $(DYNALOADER) $(libs)
-+	$(LD) -o $@ $(SHRPLDFLAGS) -Wl,-soname,$(LIBPERL) $(obj) $(DYNALOADER) $(libs)
++	$(LD) -o $@ -shared -L/usr/local/lib -fstack-protector -Wl,-soname,$(LIBPERL) $(obj) $(DYNALOADER) $(libs)
  !NO!SUBS!
  		case "$osname" in
  		aix)