diff options
Diffstat (limited to 'lib/make/aclocal.m4')
-rw-r--r-- | lib/make/aclocal.m4 | 54 |
1 files changed, 50 insertions, 4 deletions
diff --git a/lib/make/aclocal.m4 b/lib/make/aclocal.m4 index 803d1b0e..45f03234 100644 --- a/lib/make/aclocal.m4 +++ b/lib/make/aclocal.m4 @@ -46,6 +46,43 @@ changequote([, ])dnl done ]) +dnl A version of AC_TRY_COMPILER(TEST-PROGRAM, WORKING-VAR, CROSS-VAR) which, +dnl if the TEST-PROGRAM could not be executed, does not throw away the stderr +dnl but redirects it into the config.log logfile instead. +dnl +dnl Try to compile, link and execute TEST-PROGRAM. Set WORKING-VAR to +dnl `yes' if the current compiler works, otherwise set it ti `no'. Set +dnl CROSS-VAR to `yes' if the compiler and linker produce non-native +dnl executables, otherwise set it to `no'. Before calling +dnl `AC_TRY_COMPILER()', call `AC_LANG_*' to set-up for the right +dnl language. +dnl +dnl CCTK_TRY_COMPILER(TEST-PROGRAM, WORKING-VAR, CROSS-VAR) +AC_DEFUN(CCTK_TRY_COMPILER, +[cat > conftest.$ac_ext << EOF +ifelse(AC_LANG, [FORTRAN77], , +[ +[#]line __oline__ "configure" +#include "confdefs.h" +]) +[$1] +EOF +if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then + [$2]=yes + # If we can't run a trivial program, we are probably using a cross compiler. + if (./conftest; exit) 2>&AC_FD_CC; then + [$3]=no + else + [$3]=yes + fi +else + echo "configure: failed program was:" >&AC_FD_CC + cat conftest.$ac_ext >&AC_FD_CC + [$2]=no +fi +rm -fr conftest*]) + + dnl CCTK_TRY_LINK_2(INCLUDES, FUNCTION-BODY, OTHER-FUNCTION_BODY, dnl [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) AC_DEFUN(CCTK_TRY_LINK_2, @@ -202,14 +239,20 @@ AC_DEFUN(CCTK_PROG_CC_WORKS, AC_LANG_SAVE AC_LANG_C rm -fr conftest* -AC_TRY_COMPILER([main(){return(0);} int PilotMain(){return(0);}], ac_cv_prog_cc_works, ac_cv_prog_cc_cross) +CCTK_TRY_COMPILER([main(){return(0);} int PilotMain(){return(0);}], ac_cv_prog_cc_works, ac_cv_prog_cc_cross) AC_LANG_RESTORE AC_MSG_RESULT($ac_cv_prog_cc_works) if test $ac_cv_prog_cc_works = no; then - AC_MSG_ERROR([installation or configuration problem: C compiler cannot create executables.]) + AC_MSG_ERROR([installation or configuration problem: C compiler cannot create executables (see configs/<configname>/config-data/config.log for details).]) fi +changequote({, }) +CROSS_COMPILE=`echo $CROSS_COMPILE | tr '[:upper:]' '[:lower:]'` +changequote([, ]) AC_MSG_CHECKING([whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler]) AC_MSG_RESULT($ac_cv_prog_cc_cross) +if test $ac_cv_prog_cc_cross = yes -a "x$CROSS_COMPILE" != xyes; then + AC_MSG_ERROR([Could not run executable generated by C compiler (see configs/<configname>/config-data/config.log for details). If this is a cross configuration please set CROSS_COMPILE=yes.]) +fi cross_compiling=$ac_cv_prog_cc_cross ]) @@ -218,14 +261,17 @@ AC_DEFUN(CCTK_PROG_CXX_WORKS, AC_LANG_SAVE AC_LANG_CPLUSPLUS rm -fr conftest* -AC_TRY_COMPILER([int main(){return(0);} extern "C" int PilotMain(){return(0);}], ac_cv_prog_cxx_works, ac_cv_prog_cxx_cross) +CCTK_TRY_COMPILER([int main(){return(0);} extern "C" int PilotMain(){return(0);}], ac_cv_prog_cxx_works, ac_cv_prog_cxx_cross) AC_LANG_RESTORE AC_MSG_RESULT($ac_cv_prog_cxx_works) if test $ac_cv_prog_cxx_works = no; then - AC_MSG_ERROR([installation or configuration problem: C++ compiler cannot create executables.]) + AC_MSG_ERROR([installation or configuration problem: C++ compiler cannot create executables (see configs/<configname>/config-data/config.log for details).]) fi AC_MSG_CHECKING([whether the C++ compiler ($CXX $CXXFLAGS $LDFLAGS) is a cross-compiler]) AC_MSG_RESULT($ac_cv_prog_cxx_cross) +if test $ac_cv_prog_cxx_cross = yes -a "x$CROSS_COMPILE" != xyes; then + AC_MSG_ERROR([Could not run executable generated by C++ compiler (see configs/<configname>/config-data/config.log for details). If this is a cross configuration please set CROSS_COMPILE=yes.]) +fi cross_compiling=$ac_cv_prog_cxx_cross ]) |