From 1493b688025766c1f1120801a7f5618a7b75b53d Mon Sep 17 00:00:00 2001 From: Fish <> Date: Thu, 6 Mar 2008 06:34:23 +0000 Subject: [PATCH] update configure so its more robust in checking for Perl --- ChangeLog | 1 + autotools/ccdv.m4 | 2 +- configure | 134 ++++++++++++++++++++++++++++++++++++---------- configure.in | 53 +++++++++--------- 4 files changed, 138 insertions(+), 52 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9b1293de..bea8d040 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,7 @@ Fish (F), Mark (M), DeadNotBuried (D) =============================================================================== * NeoStats * Version 3.0.1 (F) - Bump Version (F) + - A much more robust checking if Perl is available in configure (F) * NeoStats * Version 3.0.0 - Finish the Update Module (F) diff --git a/autotools/ccdv.m4 b/autotools/ccdv.m4 index 01d78a92..3b4bb552 100644 --- a/autotools/ccdv.m4 +++ b/autotools/ccdv.m4 @@ -89,7 +89,7 @@ if test "x$CCDV" != x ; then wi_cv_path_ccdv="$CCDV" CC="$CCDV $CC" # trailing space needed USECCDV="#" - AC_MSG_RESULT($ccdv) + AC_MSG_RESULT($CCDV) else wi_cv_path_ccdv="" USECCDV="" diff --git a/configure b/configure index af6258ce..c178c8d2 100755 --- a/configure +++ b/configure @@ -24901,6 +24901,14 @@ echo $ECHO_N "checking for Perl compile flags... $ECHO_C" >&6; } echo "${ECHO_T}not found, building without perl." >&6; } perl=no else + { echo "$as_me:$LINENO: result: ok" >&5 +echo "${ECHO_T}ok" >&6; } + { echo "$as_me:$LINENO: checking Checking for perl includes directory" >&5 +echo $ECHO_N "checking Checking for perl includes directory... $ECHO_C" >&6; } + PERL_INCLUDES=`$perlpath -MExtUtils::Embed -e perl_inc 2>/dev/null` + { echo "$as_me:$LINENO: result: $PERL_INCLUDES" >&5 +echo "${ECHO_T}$PERL_INCLUDES" >&6; } + CFLAGS="$CFLAGS "$PERL_INCLUDES PERL_LDFLAGS=`$perlpath -MExtUtils::Embed -e ldopts |$sedpath 's/-lgdbm //'` PERL_LDFLAGS=`echo $PERL_LDFLAGS |$sedpath 's/-ldb //'` PERL_LDFLAGS=`echo $PERL_LDFLAGS |$sedpath 's/-lndbm //'` @@ -24909,8 +24917,6 @@ echo "${ECHO_T}not found, building without perl." >&6; } PERL_LDFLAGS=`echo $PERL_LDFLAGS |$sedpath 's/-lposix //'` fi PERL_LDFLAGS=`echo $PERL_LDFLAGS |$sedpath 's/-lc //'` - { echo "$as_me:$LINENO: result: ok" >&5 -echo "${ECHO_T}ok" >&6; } { echo "$as_me:$LINENO: checking for $perlpath >= 5.8.0" >&5 echo $ECHO_N "checking for $perlpath >= 5.8.0... $ECHO_C" >&6; } @@ -24919,37 +24925,105 @@ echo $ECHO_N "checking for $perlpath >= 5.8.0... $ECHO_C" >&6; } if test "$PERL_VER" = "yes"; then { echo "$as_me:$LINENO: result: yes" >&5 echo "${ECHO_T}yes" >&6; } - { echo "$as_me:$LINENO: checking Checking for perl compiler, linker, libraries and headers" >&5 -echo $ECHO_N "checking Checking for perl compiler, linker, libraries and headers... $ECHO_C" >&6; } - PERL_CC=`$perlpath -MConfig -e 'print $Config{cc},"\n";'` - PERL_LD=`$perlpath -MConfig -e 'print $Config{ld},"\n";'` + perl=no - rm -f testperl$ac_exeext testperl.$ac_objext testperl.c testperl.err - cat > testperl.c <&5 && - $PERL_LD -o testperl testperl.o $PERL_LDFLAGS 2>&5 && - test -x testperl && - have_perl=yes - if test "$have_perl" = "yes"; then - { echo "$as_me:$LINENO: result: ok" >&5 -echo "${ECHO_T}ok" >&6; } -cat >>confdefs.h <<_ACEOF -#define USE_PERL 1 + +for ac_header in EXTERN.h perl.h XSUB.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + + #ifdef HAVE_EXTERN_H + #include + #endif + #ifdef HAVE_PERL_H + #include + #endif + #ifdef HAVE_XSUB_H + #include + #endif + + + +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -z "$ac_c_werror_flag" || test ! -s conftest.err' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; } && + { ac_try='test -s conftest.$ac_objext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_Header=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF - else + perl=yes + +else + + perl=no PERL_LDFLAGS="" PERL_CFLAGS="" { echo "$as_me:$LINENO: result: Failed. Perl Support Disabled. See the RELNOTES file" >&5 echo "${ECHO_T}Failed. Perl Support Disabled. See the RELNOTES file" >&6; } - fi - rm -f testperl$ac_exeext testperl.$ac_objext testperl.c testperl.err + break + +fi + +done else { echo "$as_me:$LINENO: result: no" >&5 @@ -24974,7 +25048,13 @@ else DO_PERL_FALSE= fi +if test "x$perl" = "xyes"; then +cat >>confdefs.h <<_ACEOF +#define USE_PERL 1 +_ACEOF + +fi @@ -25133,8 +25213,8 @@ unset wi_resolved_path wi_path wi_cv_path_ccdv="$CCDV" CC="$CCDV $CC" # trailing space needed USECCDV="#" - { echo "$as_me:$LINENO: result: $ccdv" >&5 -echo "${ECHO_T}$ccdv" >&6; } + { echo "$as_me:$LINENO: result: $CCDV" >&5 +echo "${ECHO_T}$CCDV" >&6; } else wi_cv_path_ccdv="" USECCDV="" diff --git a/configure.in b/configure.in index 76e0d527..f6b9ba35 100644 --- a/configure.in +++ b/configure.in @@ -307,6 +307,11 @@ dnl PERL_CFLAGS=`echo $PERL_CFLAGS |$sedpath 's/-Wdeclaration-after-statement / AC_MSG_RESULT([not found, building without perl.]) perl=no else + AC_MSG_RESULT(ok) + AC_MSG_CHECKING([Checking for perl includes directory]) + PERL_INCLUDES=`$perlpath -MExtUtils::Embed -e perl_inc 2>/dev/null` + AC_MSG_RESULT($PERL_INCLUDES) + CFLAGS="$CFLAGS "$PERL_INCLUDES PERL_LDFLAGS=`$perlpath -MExtUtils::Embed -e ldopts |$sedpath 's/-lgdbm //'` PERL_LDFLAGS=`echo $PERL_LDFLAGS |$sedpath 's/-ldb //'` PERL_LDFLAGS=`echo $PERL_LDFLAGS |$sedpath 's/-lndbm //'` @@ -315,38 +320,36 @@ dnl PERL_CFLAGS=`echo $PERL_CFLAGS |$sedpath 's/-Wdeclaration-after-statement / PERL_LDFLAGS=`echo $PERL_LDFLAGS |$sedpath 's/-lposix //'` fi PERL_LDFLAGS=`echo $PERL_LDFLAGS |$sedpath 's/-lc //'` - AC_MSG_RESULT(ok) AC_MSG_CHECKING(for $perlpath >= 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([Checking for perl compiler, linker, libraries and headers]) - PERL_CC=`$perlpath -MConfig -e 'print $Config{cc},"\n";'` - PERL_LD=`$perlpath -MConfig -e 'print $Config{ld},"\n";'` - - rm -f testperl$ac_exeext testperl.$ac_objext testperl.c testperl.err - cat > testperl.c <&5 && - $PERL_LD -o testperl testperl.o $PERL_LDFLAGS 2>&5 && - test -x testperl && - have_perl=yes - if test "$have_perl" = "yes"; then - AC_MSG_RESULT(ok) - AC_DEFINE_UNQUOTED(USE_PERL, 1, 'Enable Perl Support') - else + perl=no +dnl AC_MSG_CHECKING([Checking for perl compiler, linker, libraries and headers]) + AC_CHECK_HEADERS([EXTERN.h perl.h XSUB.h], [ + perl=yes + ], + [ + perl=no PERL_LDFLAGS="" PERL_CFLAGS="" AC_MSG_RESULT([Failed. Perl Support Disabled. See the RELNOTES file]) - fi - rm -f testperl$ac_exeext testperl.$ac_objext testperl.c testperl.err - + break + ], + [ + #ifdef HAVE_EXTERN_H + #include + #endif + #ifdef HAVE_PERL_H + #include + #endif + #ifdef HAVE_XSUB_H + #include + #endif + ] + ) else AC_MSG_RESULT(no) PERL_LDFLAGS="" @@ -360,7 +363,9 @@ EOF AC_SUBST(PERL_CFLAGS) AC_SUBST(PERL_LDFLAGS) AM_CONDITIONAL(DO_PERL, test "x$perl" = "xyes") - +if test "x$perl" = "xyes"; then + AC_DEFINE_UNQUOTED(USE_PERL, 1, 'Enable Perl Support') +fi