commit 1bf41a68050d04c57be42a5cb334294913684933 Author: Paolo Bonzini Date: Fri Aug 7 16:40:34 2009 +0200 use a separate program to test whether the compiler works * lib/autoconf/c.m4 (_AC_LANG_NULL_PROGRAM(C)): New. * lib/autoconf/erlang.m4 (_AC_LANG_NULL_PROGRAM(Erlang)): New. * lib/autoconf/lang.m4 (AC_LANG_DEFINE): Copy _AC_LANG_NULL_PROGRAM. (_AC_LANG_NULL_PROGRAM(), _AC_LANG_NULL_PROGRAM): New. (_AC_COMPILER_EXEEXT_DEFAULT): Print here "whether the xyz compiler works", before exiting. (_AC_COMPILER_EXEEXT_WORKS): Merge into _AC_COMPILER_EXEEXT_CROSS, remove the "whether the xyz compiler works" message, use conftest$ac_cv_exeext instead of $ac_file. (_AC_COMPILER_EXEEXT): Try _AC_COMPILER_EXEEXT_DEFAULT using the null program, and clean conftest.out only after _AC_COMPILER_EXEEXT_CROSS. diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4 index 33d1895..248af02 100644 --- a/lib/autoconf/c.m4 +++ b/lib/autoconf/c.m4 @@ -129,6 +129,13 @@ $2 }]) +# _AC_LANG_NULL_PROGRAM(C) +# ------------------------ +# Produce source that does nothing. +m4_define([_AC_LANG_NULL_PROGRAM(C)], +[AC_LANG_PROGRAM([], [return 0;])]) + + # _AC_LANG_IO_PROGRAM(C) # ---------------------- # Produce source that performs I/O, necessary for proper diff --git a/lib/autoconf/erlang.m4 b/lib/autoconf/erlang.m4 index 0c4504d..48ad838 100644 --- a/lib/autoconf/erlang.m4 +++ b/lib/autoconf/erlang.m4 @@ -152,6 +152,13 @@ $2 ]) +# _AC_LANG_NULL_PROGRAM(Erlang) +# ----------------------------- +# Produce source that does nothing. +m4_define([_AC_LANG_NULL_PROGRAM(Erlang)], +[AC_LANG_PROGRAM([], [halt(0)])]) + + # _AC_LANG_IO_PROGRAM(Erlang) # --------------------------- # Produce source that performs I/O. diff --git a/lib/autoconf/lang.m4 b/lib/autoconf/lang.m4 index efdcdd0..a347278 100644 --- a/lib/autoconf/lang.m4 +++ b/lib/autoconf/lang.m4 @@ -195,6 +195,7 @@ m4_define([AC_LANG_DEFINE], [m4_define([_AC_LANG_PREFIX($1)], [$3])] [m4_copy([AC_LANG_CONFTEST($4)], [AC_LANG_CONFTEST($1)])] [m4_copy([AC_LANG_SOURCE($4)], [AC_LANG_SOURCE($1)])] +[m4_copy([_AC_LANG_NULL_PROGRAM($4)], [_AC_LANG_NULL_PROGRAM($1)])] [m4_ifval([$4], [m4_copy([AC_LANG_PROGRAM($4)], [AC_LANG_PROGRAM($1)])] [m4_copy([AC_LANG_CALL($4)], [AC_LANG_CALL($1)])] @@ -249,6 +250,21 @@ AC_DEFUN([AC_LANG_PROGRAM], [AC_LANG_SOURCE([_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])]) +# _AC_LANG_NULL_PROGRAM()() +# ------------------------- +# Default implementation of AC_LANG_NULL_PROGRAM +m4_define([_AC_LANG_NULL_PROGRAM()], +[AC_LANG_PROGRAM([], [])]) + + +# _AC_LANG_NULL_PROGRAM +# ---------------------- +# Produce valid source for the current language that does +# nothing. +AC_DEFUN([_AC_LANG_NULL_PROGRAM], +[AC_LANG_SOURCE([_AC_LANG_DISPATCH([$0], _AC_LANG, $@)])]) + + # _AC_LANG_IO_PROGRAM # ----------------------------------- # Produce valid source for the current language that creates @@ -506,7 +522,7 @@ m4_define([_AC_COMPILER_EXEEXT_DEFAULT], [# Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. -AC_MSG_CHECKING([for _AC_LANG compiler default output file name]) +AC_MSG_CHECKING([whether the _AC_LANG compiler works]) ac_link_default=`AS_ECHO(["$ac_link"]) | sed ['s/ -o *conftest[^ ]*//']` # The possible output files: @@ -556,15 +572,18 @@ done test "$ac_cv_exeext" = no && ac_cv_exeext= ], [ac_file='']) -AC_MSG_RESULT([$ac_file]) AS_IF([test -z "$ac_file"], -[_AC_MSG_LOG_CONFTEST -AC_MSG_FAILURE([_AC_LANG compiler cannot create executables], 77)]) +[AC_MSG_RESULT([no]) +_AC_MSG_LOG_CONFTEST +AC_MSG_FAILURE([_AC_LANG compiler cannot create executables], 77)], +[AC_MSG_RESULT([yes])]) +AC_MSG_CHECKING([for _AC_LANG compiler default output file name]) +AC_MSG_RESULT([$ac_file]) ac_exeext=$ac_cv_exeext ])# _AC_COMPILER_EXEEXT_DEFAULT -# _AC_COMPILER_EXEEXT_WORKS +# _AC_COMPILER_EXEEXT_CROSS # ------------------------- # FIXME: These cross compiler hacks should be removed for Autoconf 3.0 # @@ -575,13 +594,13 @@ ac_exeext=$ac_cv_exeext # detect cross-compiling on Blue Gene. Note also that AC_COMPUTE_INT # requires programs that create files when not cross-compiling, so it # is safe and not a bad idea to check for this capability in general. -m4_define([_AC_COMPILER_EXEEXT_WORKS], +m4_define([_AC_COMPILER_EXEEXT_CROSS], [# Check that the compiler produces executables we can run. If not, either # the compiler is broken, or we cross compile. -AC_MSG_CHECKING([whether the _AC_LANG compiler works]) -# If not cross compiling, check that we can run a simple program. +AC_MSG_CHECKING([whether we are cross compiling]) if test "$cross_compiling" != yes; then - if _AC_DO_TOKENS([./$ac_file]); then + _AC_DO_VAR(ac_link) + if _AC_DO_TOKENS([./conftest$ac_cv_exeext]); then cross_compiling=no else if test "$cross_compiling" = maybe; then @@ -592,16 +611,6 @@ If you meant to cross compile, use `--host'.]) fi fi fi -AC_MSG_RESULT([yes]) -])# _AC_COMPILER_EXEEXT_WORKS - - -# _AC_COMPILER_EXEEXT_CROSS -# ------------------------- -m4_define([_AC_COMPILER_EXEEXT_CROSS], -[# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -AC_MSG_CHECKING([whether we are cross compiling]) AC_MSG_RESULT([$cross_compiling]) ])# _AC_COMPILER_EXEEXT_CROSS @@ -648,20 +657,23 @@ AC_MSG_RESULT([$ac_cv_exeext]) # Do not rename this macro; Automake decides whether EXEEXT is used # by checking whether `_AC_COMPILER_EXEEXT' has been expanded. # -# See _AC_COMPILER_EXEEXT_WORKS for why we call _AC_LANG_IO_PROGRAM. +# See _AC_COMPILER_EXEEXT_CROSS for why we need _AC_LANG_IO_PROGRAM. m4_define([_AC_COMPILER_EXEEXT], -[AC_LANG_CONFTEST([_AC_LANG_IO_PROGRAM]) +[AC_LANG_CONFTEST([_AC_LANG_NULL_PROGRAM]) ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out conftest.out" +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" _AC_COMPILER_EXEEXT_DEFAULT -_AC_COMPILER_EXEEXT_WORKS -rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out conftest.out +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save -_AC_COMPILER_EXEEXT_CROSS _AC_COMPILER_EXEEXT_O rm -f conftest.$ac_ext AC_SUBST([EXEEXT], [$ac_cv_exeext])dnl ac_exeext=$EXEEXT +AC_LANG_CONFTEST([_AC_LANG_IO_PROGRAM]) +ac_clean_files="$ac_clean_files conftest.out" +_AC_COMPILER_EXEEXT_CROSS +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out +ac_clean_files=$ac_clean_files_save ])# _AC_COMPILER_EXEEXT