From 175ecd58918b4cae28fb04c29c1eac4a231f6b98 Mon Sep 17 00:00:00 2001 From: Juan Jose Garcia Ripoll Date: Sun, 4 Jul 2010 22:53:35 +0200 Subject: [PATCH] Search for the ffi.h header in other locations. --- src/aclocal.m4 | 20 +++++--- src/c/ffi.d | 4 +- src/configure | 123 ++++++++++++++++++---------------------------- src/h/config.h.in | 4 ++ 4 files changed, 66 insertions(+), 85 deletions(-) diff --git a/src/aclocal.m4 b/src/aclocal.m4 index 9d751b6b0..dd1f722e5 100644 --- a/src/aclocal.m4 +++ b/src/aclocal.m4 @@ -795,15 +795,21 @@ dnl Do we have a non-portable implementation of calls to foreign dnl functions? dnl AC_DEFUN([ECL_FFI],[ +AC_SUBST(ECL_LIBFFI_HEADER) AC_CHECK_LIB( ffi, ffi_call, [has_ffi_lib=yes], [has_ffi_lib=no] ) -if test $has_ffi_lib = yes; then - AC_CHECK_HEADER( [ffi/ffi.h], [has_ffi_h=$has_ffi_lib], [has_ffi_h=no] ) -fi -if test $has_ffi_h = "yes"; then - AC_DEFINE(HAVE_LIBFFI) - LDFLAGS="$LDFLAGS -lffi" +if test $has_ffi_lib = "yes"; then + AC_CHECK_HEADER( [ffi/ffi.h], [ECL_LIBFFI_HEADER='ffi/ffi.h'], [], [] ) + if test -z "$ECL_LIBFFI_HEADER"; then + AC_CHECK_HEADER( [ffi.h], [ECL_LIBFFI_HEADER='ffi.h'], [], [] ) + fi + if test -z "$ECL_LIBFFI_HEADER"; then + AC_MSG_WARN([unable to find header file ffi.h; disabling dynamic FFI]) + else + AC_DEFINE(HAVE_LIBFFI) + LDFLAGS="$LDFLAGS -lffi" + fi else - AC_MSG_WARN([libffi is not installed; ECL will be built without the dynamic FFI]) + AC_MSG_WARN([libffi is not installed; disabling dynamic FFI]) fi ]) diff --git a/src/c/ffi.d b/src/c/ffi.d index 83f1e0e1b..21ff2ccdc 100644 --- a/src/c/ffi.d +++ b/src/c/ffi.d @@ -14,11 +14,9 @@ */ #include +#define ECL_INCLUDE_FFI_H #include #include -#ifdef HAVE_LIBFFI -# include -#endif static const cl_object ecl_aet_to_ffi_table[aet_bc+1] = { @':void', /* aet_object */ diff --git a/src/configure b/src/configure index a45587cda..86d6f8708 100755 --- a/src/configure +++ b/src/configure @@ -643,6 +643,7 @@ ECL_CC POW_LIB LIBOBJS ECL_FPE_CODE +ECL_LIBFFI_HEADER ECL_FILE_CNT ECL_LONGJMP ECL_SETJMP @@ -9737,6 +9738,7 @@ fi if test "x$with_dffi" != "xno"; then + { $as_echo "$as_me:$LINENO: checking for ffi_call in -lffi" >&5 $as_echo_n "checking for ffi_call in -lffi... " >&6; } if test "${ac_cv_lib_ffi_ffi_call+set}" = set; then @@ -9808,26 +9810,20 @@ else has_ffi_lib=no fi -if test $has_ffi_lib = yes; then - if test "${ac_cv_header_ffi_ffi_h+set}" = set; then +if test $has_ffi_lib = "yes"; then { $as_echo "$as_me:$LINENO: checking for ffi/ffi.h" >&5 $as_echo_n "checking for ffi/ffi.h... " >&6; } if test "${ac_cv_header_ffi_ffi_h+set}" = set; then $as_echo_n "(cached) " >&6 -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_ffi_ffi_h" >&5 -$as_echo "$ac_cv_header_ffi_ffi_h" >&6; } else - # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking ffi/ffi.h usability" >&5 -$as_echo_n "checking ffi/ffi.h usability... " >&6; } -cat >conftest.$ac_ext <<_ACEOF + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -$ac_includes_default + + #include _ACEOF rm -f conftest.$ac_objext @@ -9848,111 +9844,88 @@ $as_echo "$ac_try_echo") >&5 test -z "$ac_c_werror_flag" || test ! -s conftest.err } && test -s conftest.$ac_objext; then - ac_header_compiler=yes + ac_cv_header_ffi_ffi_h=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_header_compiler=no + ac_cv_header_ffi_ffi_h=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } +fi +{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_ffi_ffi_h" >&5 +$as_echo "$ac_cv_header_ffi_ffi_h" >&6; } +if test "x$ac_cv_header_ffi_ffi_h" = x""yes; then + ECL_LIBFFI_HEADER='ffi/ffi.h' +fi -# Is the header present? -{ $as_echo "$as_me:$LINENO: checking ffi/ffi.h presence" >&5 -$as_echo_n "checking ffi/ffi.h presence... " >&6; } -cat >conftest.$ac_ext <<_ACEOF + + if test -z "$ECL_LIBFFI_HEADER"; then + { $as_echo "$as_me:$LINENO: checking for ffi.h" >&5 +$as_echo_n "checking for ffi.h... " >&6; } +if test "${ac_cv_header_ffi_h+set}" = set; then + $as_echo_n "(cached) " >&6 +else + cat >conftest.$ac_ext <<_ACEOF /* confdefs.h. */ _ACEOF cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -#include + + +#include _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" +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 ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" $as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + (eval "$ac_compile") 2>conftest.er1 ac_status=$? grep -v '^ *+' conftest.er1 >conftest.err rm -f conftest.er1 cat conftest.err >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || test ! -s conftest.err - }; then - ac_header_preproc=yes + } && test -s conftest.$ac_objext; then + ac_cv_header_ffi_h=yes else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_header_preproc=no + ac_cv_header_ffi_h=no fi -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: ffi/ffi.h: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: ffi/ffi.h: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: ffi/ffi.h: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: ffi/ffi.h: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: ffi/ffi.h: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: ffi/ffi.h: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: ffi/ffi.h: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: ffi/ffi.h: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: ffi/ffi.h: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: ffi/ffi.h: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: ffi/ffi.h: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: ffi/ffi.h: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: ffi/ffi.h: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: ffi/ffi.h: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: ffi/ffi.h: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: ffi/ffi.h: in the future, the compiler will take precedence" >&2;} - - ;; -esac -{ $as_echo "$as_me:$LINENO: checking for ffi/ffi.h" >&5 -$as_echo_n "checking for ffi/ffi.h... " >&6; } -if test "${ac_cv_header_ffi_ffi_h+set}" = set; then - $as_echo_n "(cached) " >&6 -else - ac_cv_header_ffi_ffi_h=$ac_header_preproc +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_ffi_ffi_h" >&5 -$as_echo "$ac_cv_header_ffi_ffi_h" >&6; } - -fi -if test "x$ac_cv_header_ffi_ffi_h" = x""yes; then - has_ffi_h=$has_ffi_lib -else - has_ffi_h=no +{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_ffi_h" >&5 +$as_echo "$ac_cv_header_ffi_h" >&6; } +if test "x$ac_cv_header_ffi_h" = x""yes; then + ECL_LIBFFI_HEADER='ffi.h' fi -fi -if test $has_ffi_h = "yes"; then - cat >>confdefs.h <<\_ACEOF + fi + if test -z "$ECL_LIBFFI_HEADER"; then + { $as_echo "$as_me:$LINENO: WARNING: unable to find header file ffi.h; disabling dynamic FFI" >&5 +$as_echo "$as_me: WARNING: unable to find header file ffi.h; disabling dynamic FFI" >&2;} + else + cat >>confdefs.h <<\_ACEOF #define HAVE_LIBFFI 1 _ACEOF - LDFLAGS="$LDFLAGS -lffi" + LDFLAGS="$LDFLAGS -lffi" + fi else - { $as_echo "$as_me:$LINENO: WARNING: libffi is not installed; ECL will be built without the dynamic FFI" >&5 -$as_echo "$as_me: WARNING: libffi is not installed; ECL will be built without the dynamic FFI" >&2;} + { $as_echo "$as_me:$LINENO: WARNING: libffi is not installed; disabling dynamic FFI" >&5 +$as_echo "$as_me: WARNING: libffi is not installed; disabling dynamic FFI" >&2;} fi fi diff --git a/src/h/config.h.in b/src/h/config.h.in index 83fb8c749..67030d360 100644 --- a/src/h/config.h.in +++ b/src/h/config.h.in @@ -505,3 +505,7 @@ typedef unsigned @CL_FIXNUM_TYPE@ cl_hashkey; # define ECL_MATHERR_TEST # endif #endif + +#if defined(HAVE_LIBFFI) && defined(ECL_INCLUDE_FFI_H) +#include "@ECL_LIBFFI_HEADER@" +#endif