summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorArnavion <arnavion@gmail.com>2014-01-13 18:27:32 -0800
committerArnavion <arnavion@gmail.com>2014-01-13 18:27:32 -0800
commit599b9b0379a45bd542c399759c244bcbc6ca077c (patch)
tree3ddec5c6358082b28026f5d97c210f85d26f925a
parenta87b61c73f08df3a3b0afa17b903a6e03a31faff (diff)
configure.ac: Actually check the CFLAGS and LDFLAGS returned by ExtUtils::Embed before deciding to compile the Perl plugin.
- openSUSE has ExtUtils::Embed, EXTERN.h and perl.so in the base perl package.
- Fedora has ExtUtils::Embed in a separate perl-devel package.
- Mageia has ExtUtils::Embed in the base perl package but EXTERN.h in a separate perl-devel package. Without this package, the compiler complains about the missing header.
- Debian has ExtUtils::Embed and EXTERN.h in the base perl package but perl.so in a separate libperl-dev package. Without this package, gcc compiles successfully but complains at link-time about -lperl (ExtUtils::Embed returns '-lperl' in ldopts but it's not actually installed).

configure.ac already requires ExtUtil::Embed to enable perl. To handle the case of Mageia and Debian, this change uses AC_TRY_LINK to verify that the flags returned by ExtUtils::Embed can actually be used to compile before deciding to enable the perl plugin.
-rw-r--r--configure.ac31
1 files changed, 19 insertions, 12 deletions
diff --git a/configure.ac b/configure.ac
index 9046be6a..085fbed4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -228,22 +228,29 @@ if test "$perl" = yes; then
 		PERL_LDFLAGS=`echo $PERL_LDFLAGS |$sedpath 's/-lc //'`
 		AC_MSG_RESULT(ok)
 
-#		oldLIBS=$LIBS
-#		LIBS="$LIBS $PERL_LDFLAGS"
-#		AC_CHECK_FUNC(eval_pv)
-#		AC_CHECK_FUNC(call_pv)
-#		LIBS=$oldLIBS
-
 		AC_MSG_CHECKING(for perl >= 5.8.0)
 		PERL_VER=`$perlpath -e 'print $]>= 5.008?"yes":"no"'`
 		if test "$PERL_VER" = "yes"; then
-			AC_MSG_RESULT(yes)
-			AC_MSG_CHECKING(if perl plugin will be backward compatible)
-			if test "$perl_old" = "yes"; then
-					  AC_MSG_RESULT(yes)
-					  AC_DEFINE(OLD_PERL)
+			original_cflags="$CFLAGS"
+			original_ldflags="$LDFLAGS"
+			CFLAGS="$PERL_CFLAGS"
+			LDFLAGS="$PERL_LDFLAGS"
+			AC_TRY_LINK([#include <EXTERN.h>
+#include <perl.h>], [], perl_is_usable=yes, perl_is_usable=no)
+			CFLAGS="$original_cflags"
+			LDFLAGS="$original_ldflags"
+			if test x$perl_is_usable = xno ; then
+				AC_MSG_RESULT(no)
+				perl=no
 			else
-					  AC_MSG_RESULT(no)
+				AC_MSG_RESULT(yes)
+				AC_MSG_CHECKING(if perl plugin will be backward compatible)
+				if test "$perl_old" = "yes"; then
+						  AC_MSG_RESULT(yes)
+						  AC_DEFINE(OLD_PERL)
+				else
+						  AC_MSG_RESULT(no)
+				fi
 			fi
 		else
 			AC_MSG_RESULT(no)