[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
AC_PROG_CC_STDC and ac_cv_prog_cc_stdc
From: |
Ralf Wildenhues |
Subject: |
AC_PROG_CC_STDC and ac_cv_prog_cc_stdc |
Date: |
Sat, 6 May 2006 18:07:01 +0200 |
User-agent: |
Mutt/1.5.11+cvs20060403 |
Some Automake testsuite tests currently use
./configure ac_cv_prog_cc_stdc=no
to force use of ansi2knr. I know the topic is becoming more and more
obsolete, but since there already is some backward compatibility code
to /set/ `ac_cv_prog_cc_stdc', it may also be prudent to honor a `no'
in this setting from the cache, no?
(At the moment those tests seem to still work, but only by sheer luck:
not only do they override the cache variable, but they also fail to use
AC_PROG_CC_STDC, which contains some of the tests that were formerly
part of AC_PROG_CC, and would ignore the override and use the results of
the C89 and C99 tests. Relying on that, however, sounds rather fragile
to me.)
Unsure about this, so here are two alternative patches: one to fix
Autoconf to honor `ac_cv_prog_cc_stdc=no', another to make Automake
follow suit. If the Autoconf patch is acceptable, then the Automake
one can be made a lot smaller (but I'd still recommend adding
AC_PROG_CC_STDC, so that the tests do work more similarly to how they
did in earlier times). With an override like above, and the first patch
in place, the output will look a bit weird:
| checking for gcc option to accept ISO C89... (cached) none needed
| checking for gcc option to accept ISO Standard C... (cached) unsupported
but will otherwise work (i.e., cause ansi2knr to kick in, when that has
been enabled).
If the Autoconf patch is not acceptable, well, then we need to adjust
Automake by the time ac_cv_prog_cc_c09 becomes important, I guess. :-)
Thoughts? (I couldn't resist rewriting AC_PROG_CC_STDC with shiny new
AS_CASE; please complain if you prefer a minimal patch.)
(Another note to the Automake patch: overriding U and ANSI2KNR in the
Makefile.am in ansi9.test seems fragile to me, so ok to remove that?
In any case my pending depout.m4 rewrite intends to break that..)
Cheers,
Ralf
* lib/autoconf/c.m4 (AC_PROG_CC_STDC): If ac_cv_prog_cc_stdc
is set to `no', then that overrides and sets ac_cv_prog_cc_c89
and ac_cv_prog_cc_c99 to `no', for backward compatibility.
* NEWS: Update.
Index: NEWS
===================================================================
RCS file: /cvsroot/autoconf/autoconf/NEWS,v
retrieving revision 1.367
diff -u -r1.367 NEWS
--- NEWS 30 Apr 2006 17:06:13 -0000 1.367
+++ NEWS 6 May 2006 12:30:59 -0000
@@ -1,5 +1,9 @@
* Major changes in Autoconf 2.59d
+** AC_PROG_CC_STDC
+ A setting of `ac_cv_prog_cc_stdc=no' will cause ac_cv_prog_cc_c99 and
+ ac_cv_prog_cc_c89 to be set to `no' as well, for backward compatibility.
+
* Major changes in Autoconf 2.59c
Released 2006-04-12, by Ralf Wildenhues.
Index: lib/autoconf/c.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/c.m4,v
retrieving revision 1.223
diff -u -r1.223 c.m4
--- lib/autoconf/c.m4 23 Apr 2006 07:13:53 -0000 1.223
+++ lib/autoconf/c.m4 6 May 2006 12:30:38 -0000
@@ -1208,23 +1208,17 @@
# ---------------
AC_DEFUN([AC_PROG_CC_STDC],
[ AC_REQUIRE([AC_PROG_CC])dnl
- _AC_PROG_CC_C99([ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99],
- [_AC_PROG_CC_C89([ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89],
- [ac_cv_prog_cc_stdc=no])])dnl
+ AS_CASE([$ac_cv_prog_cc_stdc],
+ [no], [ac_cv_prog_cc_c99=no; ac_cv_prog_cc_c89=no],
+ [_AC_PROG_CC_C99([ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99],
+ [_AC_PROG_CC_C89([ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89],
+ [ac_cv_prog_cc_stdc=no])])])dnl
AC_MSG_CHECKING([for $CC option to accept ISO Standard C])
AC_CACHE_VAL([ac_cv_prog_cc_stdc], [])
- case "x$ac_cv_prog_cc_stdc" in
- xno)
- AC_MSG_RESULT([unsupported])
- ;;
- *)
- if test "x$ac_cv_prog_cc_stdc" = x; then
- AC_MSG_RESULT([none needed])
- else
- AC_MSG_RESULT([$ac_cv_prog_cc_stdc])
- fi
- ;;
- esac
+ AS_CASE([$ac_cv_prog_cc_stdc],
+ [no], [AC_MSG_RESULT([unsupported])],
+ [''], [AC_MSG_RESULT([none needed])],
+ [AC_MSG_RESULT([$ac_cv_prog_cc_stdc])])
])
* tests/ansi10.test: Use AC_PROG_CC_STDC. Fix test that
ac_cv_prog_cc_stdc isn't just used by Automake code in
`configure'. Also override `ac_cv_prog_cc_c89' and
`ac_cv_prog_cc_c99'.
* tests/ansi6.test, tests/ansi7.test: Likewise.
* tests/ansi9.test: Likewise. Do not override by setting
$U and $(ANSI2KNR) at `make' time; that will be fragile.
* tests/libobj8.test: Use AC_PROG_CC_STDC.
* tests/subobj3.test: Likewise. Use `set -e'.
Index: tests/ansi10.test
===================================================================
RCS file: /cvs/automake/automake/tests/ansi10.test,v
retrieving revision 1.4
diff -u -r1.4 ansi10.test
--- tests/ansi10.test 14 May 2005 20:28:54 -0000 1.4
+++ tests/ansi10.test 6 May 2006 11:39:38 -0000
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2002 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2006 Free Software Foundation, Inc.
#
# This file is part of GNU Automake.
#
@@ -27,6 +27,7 @@
cat >> configure.in << 'END'
AC_PROG_CC
+AC_PROG_CC_STDC
AM_C_PROTOTYPES
AC_PROG_RANLIB
AC_LIBOBJ([hello])
@@ -62,9 +63,11 @@
$AUTOMAKE -a
# Sanity check: make sure it's ok to set ac_cv_prog_cc_stdc as we do.
-grep ac_cv_prog_cc_stdc configure
+test `grep -c ac_cv_prog_cc_stdc configure` -gt 1
-./configure ac_cv_prog_cc_stdc=no
+./configure ac_cv_prog_cc_stdc=no \
+ ac_cv_prog_cc_c89=no \
+ ac_cv_prog_cc_c99=no
$MAKE
test -f dir/hello_.c
$MAKE distclean
Index: tests/ansi6.test
===================================================================
RCS file: /cvs/automake/automake/tests/ansi6.test,v
retrieving revision 1.7
diff -u -r1.7 ansi6.test
--- tests/ansi6.test 14 May 2005 20:28:54 -0000 1.7
+++ tests/ansi6.test 6 May 2006 11:39:38 -0000
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 2002 Free Software Foundation, Inc.
+# Copyright (C) 2002, 2006 Free Software Foundation, Inc.
#
# This file is part of GNU Automake.
#
@@ -28,6 +28,7 @@
AC_INIT(ansi6, 1.0)
AM_INIT_AUTOMAKE
AC_PROG_CC
+AC_PROG_CC_STDC
AM_C_PROTOTYPES
AC_EXEEXT
AC_OBJEXT
@@ -70,9 +71,11 @@
$AUTOMAKE -a
# Sanity check: make sure it's ok to set ac_cv_prog_cc_stdc as we do.
-grep ac_cv_prog_cc_stdc configure
+test `grep -c ac_cv_prog_cc_stdc configure` -gt 1
-./configure ac_cv_prog_cc_stdc=no
+./configure ac_cv_prog_cc_stdc=no \
+ ac_cv_prog_cc_c89=no \
+ ac_cv_prog_cc_c99=no
$MAKE
test -f hello_.c
Index: tests/ansi7.test
===================================================================
RCS file: /cvs/automake/automake/tests/ansi7.test,v
retrieving revision 1.6
diff -u -r1.6 ansi7.test
--- tests/ansi7.test 14 May 2005 20:28:54 -0000 1.6
+++ tests/ansi7.test 6 May 2006 11:39:38 -0000
@@ -29,6 +29,7 @@
AC_INIT(ansi6, 1.0)
AM_INIT_AUTOMAKE
AC_PROG_CC
+AC_PROG_CC_STDC
AM_PROG_CC_C_O
AM_C_PROTOTYPES
AC_EXEEXT
@@ -72,9 +73,11 @@
$AUTOMAKE -a
# Sanity check: make sure it's ok to set ac_cv_prog_cc_stdc as we do.
-grep ac_cv_prog_cc_stdc configure
+test `grep -c ac_cv_prog_cc_stdc configure` -gt 1
-./configure ac_cv_prog_cc_stdc=no
+./configure ac_cv_prog_cc_stdc=no \
+ ac_cv_prog_cc_c89=no \
+ ac_cv_prog_cc_c99=no
$MAKE
test -f hello_.c
Index: tests/ansi9.test
===================================================================
RCS file: /cvs/automake/automake/tests/ansi9.test,v
retrieving revision 1.4
diff -u -r1.4 ansi9.test
--- tests/ansi9.test 14 May 2005 20:28:54 -0000 1.4
+++ tests/ansi9.test 6 May 2006 11:39:38 -0000
@@ -40,9 +40,6 @@
loadavg_SOURCES = loadavg.c
loadavg_CFLAGS = -DTEST
sub_sub_SOURCES = sub/sub.c
-# Force ansi2knr's use, regardless of the compiler.
-U=_
-ANSI2KNR=./ansi2knr
END
cat > loadavg.c << 'END'
@@ -61,8 +58,11 @@
$AUTOMAKE --add-missing -Wno-override
$FGREP 'loadavg-loadavg$U.o: loadavg$U.c' Makefile.in
-# The following rule should not exists, because the
+# The following rule should not exist, because the
# default .o.c: inference rule is enough.
$FGREP 'sub/sub$U.o: sub/sub$U.c' Makefile.in && exit 1
-./configure
+# Force ansi2knr's use, regardless of the compiler.
+./configure ac_cv_prog_cc_stdc=no \
+ ac_cv_prog_cc_c89=no \
+ ac_cv_prog_cc_c99=no
$MAKE sub/sub_.c
Index: tests/libobj8.test
===================================================================
RCS file: /cvs/automake/automake/tests/libobj8.test,v
retrieving revision 1.10
diff -u -r1.10 libobj8.test
--- tests/libobj8.test 14 May 2005 20:28:55 -0000 1.10
+++ tests/libobj8.test 6 May 2006 11:39:38 -0000
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 1998, 2000, 2001, 2002 Free Software Foundation, Inc.
+# Copyright (C) 1998, 2000, 2001, 2002, 2006 Free Software Foundation, Inc.
#
# This file is part of GNU Automake.
#
@@ -27,6 +27,7 @@
AC_INIT
AM_INIT_AUTOMAKE(nonesuch, nonesuch)
AC_PROG_CC
+AC_PROG_CC_STDC
AC_PROG_RANLIB
AC_REPLACE_FUNCS(basename dirname strsignal)
AM_C_PROTOTYPES
Index: tests/subobj3.test
===================================================================
RCS file: /cvs/automake/automake/tests/subobj3.test,v
retrieving revision 1.17
diff -u -r1.17 subobj3.test
--- tests/subobj3.test 14 May 2005 20:28:56 -0000 1.17
+++ tests/subobj3.test 6 May 2006 11:39:38 -0000
@@ -1,5 +1,5 @@
#! /bin/sh
-# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Free Software
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2006 Free Software
# Foundation, Inc.
#
# This file is part of GNU Automake.
@@ -24,12 +24,15 @@
required=gcc
. ./defs || exit 1
+set -e
+
cat > configure.in << 'END'
AC_INIT(sub/hello.c)
dnl Prevent automake from looking in .. and ../..
AC_CONFIG_AUX_DIR(.)
AM_INIT_AUTOMAKE(hello,0.23)
AC_PROG_CC
+AC_PROG_CC_STDC
AM_PROG_CC_C_O
AM_C_PROTOTYPES
AC_OUTPUT(Makefile)
@@ -58,9 +61,9 @@
# We use gcc and not gcc -traditional as the latter fails on some
# Linux boxes (Red Hat 5.1 in particular).
-$ACLOCAL \
- && $AUTOCONF \
- && $AUTOMAKE -a \
- && ./configure \
- && ANSI2KNR=./ansi2knr U=_ $MAKE -e \
- && ./hello
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+./configure
+ANSI2KNR=./ansi2knr U=_ $MAKE -e
+./hello
- AC_PROG_CC_STDC and ac_cv_prog_cc_stdc,
Ralf Wildenhues <=