Hi Roland,
Cced to you, because according to the ChangeLog you are the one who
worked most on this macro. Tracing the history of the macro is
difficult, but once you understood it was named AC_MINUS_C_MINUS_O,
you see it has this double checking since the beginning, `initial
revision'.
See
http://subversions.gnu.org/cgi-bin/cvsweb/autoconf/acspecific.m4?annotate=1.1
The macro AC_PROG_CC_C_O (appended below for convenience), according
to the documentation, is expected to check whether the C compiler
supports -c and -o together. But if you read the code, you can see
that it's checking that $CC *and* cc support -c -o.
I don't understand the point. Since it's been added after the
creation of the macro, I guess there is one, but personally I don't
really like what does this test. It's lying to us. If such a test is
needed, it seems to me it should be named something else than this.
Well, I can guess one use: if you're compiling something which
launches a compiler when run, but then, it's a completely different
matter and we should not have a single macro which tests both the
compiler we use to build the project, and the compiler which might be
used by the project. Let's equip this macro with an argument then.
Anyway, does anybody see a problem in having this macro test a single
compiler, $CC by default?
Akim
# AC_PROG_CC_C_O
# --------------
AC_DEFUN(AC_PROG_CC_C_O,
[if test "x$CC" != xcc; then
AC_MSG_CHECKING(whether $CC and cc understand -c and -o together)
else
AC_MSG_CHECKING(whether cc understands -c and -o together)
fi
set dummy $CC; ac_cc=`echo [$]2 |
sed -e 's/[[^a-zA-Z0-9_]]/_/g' -e 's/^[[0-9]]/_/'`
AC_CACHE_VAL(ac_cv_prog_cc_${ac_cc}_c_o,
[echo 'foo(){}' >conftest.c
# 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-cc} -c conftest.c -o conftest.o 1>&AC_FD_CC'
if AC_TRY_EVAL(ac_try) &&
test -f conftest.o && AC_TRY_EVAL(ac_try);
then
eval ac_cv_prog_cc_${ac_cc}_c_o=yes
if test "x$CC" != xcc; then
# Test first that cc exists at all.
if AC_TRY_COMMAND(cc -c conftest.c 1>&AC_FD_CC); then
ac_try='cc -c conftest.c -o conftest.o 1>&AC_FD_CC'
if AC_TRY_EVAL(ac_try) &&
test -f conftest.o && AC_TRY_EVAL(ac_try);
then
# cc works too.
:
else
# cc exists but doesn't like -o.
eval ac_cv_prog_cc_${ac_cc}_c_o=no
fi
fi
fi
else
eval ac_cv_prog_cc_${ac_cc}_c_o=no
fi
rm -f conftest*
])dnl
if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = yes"; then
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
AC_DEFINE(NO_MINUS_C_MINUS_O, 1,
[Define if your C compiler doesn't accept -c and -o together.])
fi
])# AC_PROG_CC_C_O
The original code was:
define(AC_MINUS_C_MINUS_O,
[echo checking whether $CC and cc understand -c and -o together
echo 'foo(){}' > conftest.c
# 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.
if ${CC-cc} -c conftest.c -o conftest.o >/dev/null 2>&1 \
&& test -f conftest.o && ${CC-cc} -c conftest.c -o conftest.o >/dev/null 2>&1
then
# Test first that cc exists at all.
if cc -c conftest.c >/dev/null 2>&1
then
if cc -c conftest.c -o conftest2.o >/dev/null 2>&1 && \
test -f conftest2.o && cc -c conftest.c -o conftest2.o >/dev/null 2>&1
then
:
else
AC_DEFINE(NO_MINUS_C_MINUS_O)
fi
fi
else
AC_DEFINE(NO_MINUS_C_MINUS_O)
fi
rm -f conftest*
])dnl