summaryrefslogtreecommitdiff
path: root/m4
diff options
context:
space:
mode:
authorStefano Lattarini <stefano.lattarini@gmail.com>2013-05-15 10:14:46 +0200
committerStefano Lattarini <stefano.lattarini@gmail.com>2013-05-24 17:35:30 +0200
commite90126cf20ab1bd848631fca5d4bc32433ca52e4 (patch)
tree7b3085164affd19344266f90bdc7f6e8154cdacb /m4
parent9877109c1f00e20f76a69ac656fc02a439ae318a (diff)
downloadautomake-e90126cf20ab1bd848631fca5d4bc32433ca52e4.tar.gz
AM_PROG_CC_C_O: don't rely on AC_PROG_CC_C_O, re-implement similar logic
** Theoretical problems of AC_PROG_CC_C_O: Both cc and $CC are checked to see if they support the '-c' and '-o' options together. This behaviour is highly inconsistent with that of the other macros related to C compiler checks -- which test only $CC. It can also cause unwarranted uses of the 'compile' script on systems where the default 'cc' is inferior, but the user is compiling with a proper, different compiler (e.g., gcc). ** Practical problems with our previous implementation of C support m4 macros in Automake: - AM_PROG_AR must now be called *before* AC_PROG_CC; this wasn't the case before, and it turns out there are packages in the wild that relied on the old behaviour. - The cross-referenced requirements and macro rewrites juggled among AC_PROG_CC, AC_PROG_CC_C_O and AM_PROG_CC_C_O caused warnings in autoconf; for example, in our test 't/libobj3.sh', we could see warnings like these (here slightly tweaked for legibility): configure.ac:5: AC_REQUIRE: `AC_PROG_CC' expanded before required autoconf/c.m4:567: AC_PROG_CC_C_O is expanded from... autoconf/c.m4:429: AC_LANG_COMPILER(C) is expanded from... autoconf/lang.m4:329: AC_LANG_COMPILER_REQUIRE is expanded from... autoconf/general.m4:2606: AC_COMPILE_IFELSE is expanded from... m4sugar/m4sh.m4:639: AS_IF is expanded from... autoconf/general.m4:2031: AC_CACHE_VAL is expanded from... autoconf/general.m4:2052: AC_CACHE_CHECK is expanded from... aclocal.m4:70: AM_PROG_AR is expanded from... configure.ac:5: the top level ** Fix all of that: We fix all of the described issues with a new internal m4 macro _AM_PROG_CC_C_O (inspired to, but not based on, AC_PROG_CC_C_O) that gets tacked on to AC_PROG_CC automatically (this is done in the Automake-generated aclocal.m4) and that takes care of checking and adjusting '$CC' for "-c -o" support. The macro AM_PROG_CC_C_O is still present, but is now just a thin wrapper around such Automake-enhanced AC_PROG_CC. It is worth noting that the present patch causes three slight *backward-incompatibilities*: 1. The name cache variable used by AM_PROG_CC_C_O is no longer computed (at configure runtime!) from the content of '$CC', but is statically defined as 'am_cv_prog_cc_c_o'. 2. 'cc' is no longer checked by AM_PROG_CC_C_O, only '$CC' is. 3. AM_PROG_CC_C_O no longer AC_DEFINE the C preprocessor symbol 'NO_MINUS_C_MINUS_O'. Given however that the third change can easily be worked around, that the first two changes can be legitimately seen as bug fixes, and that the new semantics introduced by such changes will simplify the transition to Automake 2.0 (when the 'subdir-objects' will always be enabled unconditionally), we believe they are acceptable to be shipped with Automake 1.14. With this patch, we also revert some of the testsuite adjustments done in previous commit v1.13.2-178-g9877109 of 2013-05-24 (compile: rewrite AC_PROG_CC with AM_PROG_CC_C_O contents). Such adjustments are no longer needed. * m4/minuso.m4 (_AM_PROG_CC_C_O): New internal macro, basically and adjusted version of a merge between Autoconf-provided AC_PROG_CC_C_O and our old implementation of AM_PROG_CC_C_O. (AM_PROG_CC_C_O): Redefine as a simple wrapper around AC_PROG_CC. * m4/init.m4 (AC_PROG_CC): Append _AM_PROG_CC_C_O, not AM_PROG_CC_C_O, to the pre-existing expansion of this macro. * m4/ar-lib.m4 (AM_PROG_AR): No longer require it to be expanded after AC_PROG_CC. * t/aclocal-deps.sh: Move AC_PROG_CC invocation after AC_PROG_RANLIB and AM_PROG_AR invocations. Things should work this way too (as they used to). * t/subobj-clean-lt-pr10697.sh: Likewise. * t/alloca.sh: Move AC_PROG_CC invocation after AM_PROG_AR invocation. * t/condlib.sh: Likewise. * t/aclocal-deps.sh: Move AC_PROG_CC invocation after LT_INIT and AM_PROG_AR invocations. Make autoconf and autoheader warnings fatal. * t/am-prog-cc-c-o.sh: Adjust to the new semantics, enhance a little, and reduce code duplication. * t/ccnoco.sh: Make autoconf warnings fatal. * t/subpkg.sh: Likewise. * t/ccnoco-lib.sh: Likewise, and fix a comment. * t/link_cond.sh: Enhance a couple of error messages. * configure.ac: Drop "nullification" of AM_PROG_CC_C_O. * NEWS: Adjust. Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
Diffstat (limited to 'm4')
-rw-r--r--m4/ar-lib.m41
-rw-r--r--m4/init.m46
-rw-r--r--m4/minuso.m451
3 files changed, 36 insertions, 22 deletions
diff --git a/m4/ar-lib.m4 b/m4/ar-lib.m4
index 53c8c2a7e..58726d0b0 100644
--- a/m4/ar-lib.m4
+++ b/m4/ar-lib.m4
@@ -13,7 +13,6 @@
AC_DEFUN([AM_PROG_AR],
[AC_BEFORE([$0], [LT_INIT])dnl
AC_BEFORE([$0], [AC_PROG_LIBTOOL])dnl
-AC_BEFORE([AC_PROG_CC])
AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
AC_REQUIRE_AUX_FILE([ar-lib])dnl
AC_CHECK_TOOLS([AR], [ar lib "link -lib"], [false])
diff --git a/m4/init.m4 b/m4/init.m4
index fb6ed5851..432ff200c 100644
--- a/m4/init.m4
+++ b/m4/init.m4
@@ -9,8 +9,10 @@
# 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
+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])
diff --git a/m4/minuso.m4 b/m4/minuso.m4
index 3e68f2b72..3b2a849b0 100644
--- a/m4/minuso.m4
+++ b/m4/minuso.m4
@@ -5,20 +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_LANG_PUSH([C])
-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.
@@ -26,9 +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
-AC_LANG_POP([C])
-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])])