[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] AC_PROG_CC: also check whether $CC supports "-c -o" together

From: Stefano Lattarini
Subject: [PATCH] AC_PROG_CC: also check whether $CC supports "-c -o" together
Date: Thu, 10 Jan 2013 15:23:32 +0100

This is for Automake and its 'subdir-object' mode (see automake bug#13378,
in particular <>), so
we only make the behavior available only if the special witness macro
'_AM_PROG_CC_C_O_HELPME' is defined (future Automake versions will define
it).  We might decide, at a later date, to make this behaviour public;
but then we'll have to discuss its usefulness and design more in depth,
and if they are agreed upon, adjust the documentation to match, and also
decide what to do with the macro AC_PROG_CC_C_O, with it's similar (but
slightly incompatible) semantics; since doing so right would bring us
off-track (and Automake needs this change *today*, or better, yesterday),
we proceed with this simpler hack.

* lib/autoconf/c.m4 (AC_PROG_CC): Adjust.

Signed-off-by: Stefano Lattarini <address@hidden>

This should ideally go in autoconf 2.70, so that Automake from master
can start relying on it right away.

What I don't like about this patch is the lack of tests.  Since
automake will be the only user for now, that is no big deal (as
long as you delay the 2.70 some days release to give me time to
properly test this change in combination with the planned but not
yet written changes to Automake master).  But should be fixed if
we ever want to make this new interface public.



 lib/autoconf/c.m4 | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4
index edc663b..929e21d 100644
--- a/lib/autoconf/c.m4
+++ b/lib/autoconf/c.m4
@@ -490,7 +490,31 @@ _AC_PROG_CC_C11([ac_prog_cc_stdc=c11
+dnl This is a hook for Automake and its 'subdir-objects' mode, which
+dnl needs to know whether $CC supports "-c -o" together or not.  See
+dnl automake bug#13378, in particular <>.
+dnl FIXME: there is some code duplication with AC_PROG_CC_C_O here.
+[set dummy $CC; ac_cc=`AS_ECHO(["$[2]"]) | \
+                       sed 's/[[^a-zA-Z0-9_]]/_/g;s/^[[0-9]]/_/'`
+AC_MSG_CHECKING([whether $CC understands -c and -o together])
+# Make sure it works both with $CC and with simple cc.
+# We do the test twice because some compilers refuse to overwrite an
+# existing .o file with -o, though they will create one.
+ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&AS_MESSAGE_LOG_FD'
+rm -f conftest2.*
+if _AC_DO_VAR(ac_try) && test -f conftest2.$ac_objext
+  AC_MSG_RESULT([yes])
+  eval ac_cv_prog_cc_${ac_cc}_c_o=yes
+  AC_MSG_RESULT([no])
+  eval ac_cv_prog_cc_${ac_cc}_c_o=no
+rm -f core conftest*

reply via email to

[Prev in Thread] Current Thread [Next in Thread]