diff options
author | Stefano Lattarini <stefano.lattarini@gmail.com> | 2013-05-26 13:30:52 +0200 |
---|---|---|
committer | Stefano Lattarini <stefano.lattarini@gmail.com> | 2013-05-26 13:30:52 +0200 |
commit | e5b40a3ee2c6fbc0cec34b0a96ac2dc74401205f (patch) | |
tree | 1c9a2ce62bbdaff247fe889912a51d42890d33a4 /m4 | |
parent | 6f109602762dbb9648de169de01e6aaddd78a9ec (diff) | |
parent | b2b6269fca6f7bb7adac2d09c02adf0c6b701d48 (diff) | |
download | automake-e5b40a3ee2c6fbc0cec34b0a96ac2dc74401205f.tar.gz |
Merge branch 'prog-cc-c-o-work' into maint
* prog-cc-c-o-work:
tests: some tests make no sense if "$CC -c -o" doesn't work
AM_PROG_CC_C_O: don't rely on AC_PROG_CC_C_O, re-implement similar logic
compile: rewrite AC_PROG_CC with AM_PROG_CC_C_O contents
Diffstat (limited to 'm4')
-rw-r--r-- | m4/ar-lib.m4 | 5 | ||||
-rw-r--r-- | m4/init.m4 | 12 | ||||
-rw-r--r-- | m4/prog-cc-c-o.m4 | 49 |
3 files changed, 41 insertions, 25 deletions
diff --git a/m4/ar-lib.m4 b/m4/ar-lib.m4 index f895f6bd2..58726d0b0 100644 --- a/m4/ar-lib.m4 +++ b/m4/ar-lib.m4 @@ -19,7 +19,8 @@ AC_CHECK_TOOLS([AR], [ar lib "link -lib"], [false]) : ${AR=ar} AC_CACHE_CHECK([the archiver ($AR) interface], [am_cv_ar_interface], - [am_cv_ar_interface=ar + [AC_LANG_PUSH([C]) + am_cv_ar_interface=ar AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int some_variable = 0;]])], [am_ar_try='$AR cru libconftest.a conftest.$ac_objext >&AS_MESSAGE_LOG_FD' AC_TRY_EVAL([am_ar_try]) @@ -36,7 +37,7 @@ AC_CACHE_CHECK([the archiver ($AR) interface], [am_cv_ar_interface], fi rm -f conftest.lib libconftest.a ]) - ]) + AC_LANG_POP([C])]) case $am_cv_ar_interface in ar) diff --git a/m4/init.m4 b/m4/init.m4 index a6f27339d..432ff200c 100644 --- a/m4/init.m4 +++ b/m4/init.m4 @@ -9,6 +9,12 @@ # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. +dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. +m4_define([AC_PROG_CC], +m4_defn([AC_PROG_CC]) +[_AM_PROG_CC_C_O +]) + # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- @@ -110,12 +116,6 @@ AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], [m4_define([AC_PROG_OBJCXX], m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl ]) -dnl Automatically invoke AM_PROG_CC_C_O as necessary. Since AC_PROG_CC is -dnl usually called after AM_INIT_AUTOMAKE, we arrange for the test to be -dnl done later by AC_CONFIG_COMMANDS_PRE. -AC_CONFIG_COMMANDS_PRE([AC_PROVIDE_IFELSE( - [AC_PROG_CC], - [AC_LANG_PUSH([C]) AM_PROG_CC_C_O AC_LANG_POP([C])])])dnl AC_REQUIRE([AM_SILENT_RULES])dnl dnl The testsuite driver may need to know about EXEEXT, so add the dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This diff --git a/m4/prog-cc-c-o.m4 b/m4/prog-cc-c-o.m4 index 06f74c906..3b2a849b0 100644 --- a/m4/prog-cc-c-o.m4 +++ b/m4/prog-cc-c-o.m4 @@ -5,19 +5,35 @@ # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# AM_PROG_CC_C_O -# -------------- -# Like AC_PROG_CC_C_O, but changed for automake. -AC_DEFUN_ONCE([AM_PROG_CC_C_O], -[AC_REQUIRE([AC_PROG_CC_C_O])dnl -AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl +# _AM_PROG_CC_C_O +# --------------- +# Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC +# to automatically call this. +AC_DEFUN([_AM_PROG_CC_C_O], +[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([compile])dnl -# FIXME: we rely on the cache variable name because -# there is no other way. -set dummy $CC -am_cc=`echo $[2] | sed ['s/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/']` -eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o -if test "$am_t" != yes; then +AC_LANG_PUSH([C])dnl +AC_CACHE_CHECK( + [whether $CC understands -c and -o together], + [am_cv_prog_cc_c_o], + [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) + # Make sure it works both with $CC and with simple cc. + # Following AC_PROG_CC_C_O, we do the test twice because some + # compilers refuse to overwrite an existing .o file with -o, + # though they will create one. + am_cv_prog_cc_c_o=yes + for am_i in 1 2; do + if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ + && test -f conftest2.$ac_objext; then + : OK + else + am_cv_prog_cc_c_o=no + break + fi + done + rm -f core conftest* + unset am_i]) +if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. @@ -25,8 +41,7 @@ if test "$am_t" != yes; then # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi -dnl Make sure AC_PROG_CC is never called again, or it will override our -dnl setting of CC. -m4_define([AC_PROG_CC], - [m4_fatal([AC_PROG_CC cannot be called after AM_PROG_CC_C_O])]) -]) +AC_LANG_POP([C])]) + +# For backward compatibility. +AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) |