** Macros
-- New macro AC_PROG_CC_C11.
+- AC_PROG_CC now prefers C11 if available, falling back on C99 and
+ then on C89 as before. (There is no AC_PROG_CC_C11 macro, as no
+ need for one has been identified.)
-- AC_PROG_CC_STDC now prefers C11 if available, falling back on C99
- and then on C89 as before.
+- It is now documented that AC_PROG_CC_C89 and AC_PROG_CC_C99
+ interfere with each other and with AC_PROG_CC. Applications should
+ normally use AC_PROG_CC.
- AC_FUNC_VFORK now checks for the signal-handling bug in Solaris 2.4 'vfork'.
Formerly, it ignored this bug, so that Emacs could use some tricky
used for config.h generation, but not used in configure's own tests.
** AC_PROG_CC
-Currently it tries to put the C compiler in ANSI C mode by default.
-We should change this spec so that AC_PROG_CC tries to change the
-compiler to be the "nicest" mode, i.e. support for the latest standard
-features (currently ISO C99) plus support for all vendor extensions,
-even if they are slightly incompatible with C99. The basic idea here
-is that AC_PROG_CC should disable pedanticisms and should enable
-extensions.
-
Have a way to specify different default flags to try; see this thread
for more information:
<http://lists.gnu.org/archive/html/bug-autoconf/2008-08/msg00009.html>.
In fact, this macro is also probably the right place to check for
objext and exeext.
-** AC_PROG_CC_STDC
+** AC_PROG_CC
+How should the desired ISO version be specified? AC_PROG_CC_C89
+do not play well with each other, or with AC_PROG_CC.
Should be: AC_PROG_CC_ISO? Or even more specific for the ISO version?
Should include more tests (e.g., AC_C_CONST etc.)? See Peter for very
useful comments on the technology. Should we make this a new
@code{#line} directives.
@end table
+@anchor{AC_PROG_CC}
@defmac AC_PROG_CC (@ovar{compiler-search-list})
@acindex{PROG_CC}
@evindex CC
@evindex CFLAGS
@ovindex CC
@ovindex CFLAGS
-@caindex prog_cc_c89
+@caindex prog_cc_stdc
Determine a C compiler to use. If @code{CC} is not already set in the
environment, check for @code{gcc} and @code{cc}, then for other C
compilers. Set output variable @code{CC} to the name of the compiler
AC_PROG_CC([gcc cl cc])
@end example
-If the C compiler does not handle function prototypes correctly by
-default, try to add an option to output variable @code{CC} to make it
-so. This macro tries various options that select standard-conformance
-modes on various systems.
-
+If the C compiler cannot compile ISO Standard C (currently
+C11), try to add an option to output variable @code{CC} to make it work.
+If the compiler does not support C11, fall back to supporting
+ISO C99; if C99 does not work, fall back to ANSI C89 (ISO C90).
+When testing for ISO C versions, use GNU extensions if available.
After calling this macro you can check whether the C compiler has been
-set to accept ANSI C89 (ISO C90); if not, the shell
-variable
-@code{ac_cv_prog_cc_c89} is set to @samp{no}. See also
-@code{AC_C_PROTOTYPES} below.
+set to accept Standard C; if not, the shell variable
+@code{ac_cv_prog_cc_stdc} is set to @samp{no}.
If using the GNU C compiler, set shell variable @code{GCC} to
@samp{yes}. If output variable @code{CFLAGS} was not already set, set
@code{AC_COMPILE_IFELSE} (@pxref{Running the Compiler}) or
@code{AC_RUN_IFELSE} (@pxref{Runtime}).
-@defmac AC_PROG_CC_STDC
-@acindex{PROG_CC_STDC}
-@caindex prog_cc_stdc
-If the C compiler cannot compile ISO Standard C (currently
-C11), try to add an option to output variable @code{CC} to make it work.
-If the compiler does not support C11, fall back to supporting
-ISO C99; if C99 does not work, fall back to ANSI C89 (ISO C90).
-
-After calling this macro you can check whether the C compiler has been
-set to accept Standard C; if not, the shell variable
-@code{ac_cv_prog_cc_stdc} is set to @samp{no}.
-@end defmac
-
@defmac AC_PROG_CC_C89
@acindex{PROG_CC_C89}
@caindex prog_cc_c89
set to accept ANSI C89; if not, the shell variable
@code{ac_cv_prog_cc_c89} is set to @samp{no}.
-This macro is called automatically by @code{AC_PROG_CC}.
+This macro is rarely needed. It should be used only if your application
+requires C89 and will not work in later C versions. Typical applications
+should use @code{AC_PROG_CC} instead.
@end defmac
@defmac AC_PROG_CC_C99
After calling this macro you can check whether the C compiler has been
set to accept C99; if not, the shell variable
@code{ac_cv_prog_cc_c99} is set to @samp{no}.
-@end defmac
-@defmac AC_PROG_CC_C11
-@acindex{PROG_CC_C11}
-@caindex prog_cc_c11
-If the C compiler is not in C11 mode by default, try to add an
-option to output variable @code{CC} to make it so. This macro tries
-various options that select C11 on some system or another, preferring
-extended functionality modes over strict conformance modes. Currently it
-considers the compiler to be in C11 mode if it handles @code{_Alignas},
-@code{_Alignof}, @code{_Noreturn}, @code{_Static_assert}, UTF-8 string
-literals, duplicate @code{typedef}s, and anonymous structures and
-unions.
+This macro is rarely needed. It should be used only if your application
+requires C99 and will not work in later C versions. Typical applications
+should use @code{AC_PROG_CC} instead.
-After calling this macro you can check whether the C compiler has been
-set to accept C11; if not, the shell variable
-@code{ac_cv_prog_cc_c11} is set to @samp{no}.
+There is no @code{AC_PROG_CC_C11} macro, as no need for one has been
+identified.
@end defmac
@defmac AC_C_BACKSLASH_A
After the category comes the name of the particular feature being
tested. Any further words in the macro name indicate particular aspects
-of the feature. For example, @code{AC_PROG_CC_STDC} checks whether the
-C compiler supports ISO Standard C.
+of the feature. For example, @code{AC_PROG_MAKE_SET} checks whether
+@command{make} sets a variable to its own name.
An internal macro should have a name that starts with an underscore;
Autoconf internals should therefore start with @samp{_AC_}.
Replaced by @code{AC_PREFIX_PROGRAM} (@pxref{AC_PREFIX_PROGRAM}).
@end defmac
+@defmac AC_PROG_CC_STDC
+@acindex{PROG_CC_STDC}
+Now done by @code{AC_PROG_CC} (@pxref{AC_PROG_CC}).
+@end defmac
+
@defmac AC_PROGRAMS_CHECK
@acindex{PROGRAMS_CHECK}
Replaced by @code{AC_CHECK_PROGS} (@pxref{AC_CHECK_PROGS}).
GCC=
fi
_AC_PROG_CC_G
-_AC_PROG_CC_C89
+dnl
+dnl Set ac_prog_cc_stdc to the supported C version.
+dnl Also set the documented variable ac_cv_prog_cc_stdc;
+dnl its name was chosen when it was cached, but it is no longer cached.
+_AC_PROG_CC_C11([ac_prog_cc_stdc=c11
+ ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11],
+ [_AC_PROG_CC_C99([ac_prog_cc_stdc=c99
+ ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99],
+ [_AC_PROG_CC_C89([ac_prog_cc_stdc=c89
+ ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89],
+ [ac_prog_cc_stdc=no
+ ac_cv_prog_cc_stdc=no])])])
+dnl
AC_LANG_POP(C)dnl
])# AC_PROG_CC
rm -f conftest.$ac_ext
CC=$ac_save_CC
])# AC_CACHE_VAL
+ac_prog_cc_stdc_options=
case "x$ac_cv_prog_cc_$1" in
x)
AC_MSG_RESULT([none needed]) ;;
xno)
AC_MSG_RESULT([unsupported]) ;;
*)
- CC="$CC $ac_cv_prog_cc_$1"
+ ac_prog_cc_stdc_options=" $ac_cv_prog_cc_$1"
+ CC=$CC$ac_prog_cc_stdc_options
AC_MSG_RESULT([$ac_cv_prog_cc_$1]) ;;
esac
AS_IF([test "x$ac_cv_prog_cc_$1" != xno], [$5], [$6])
])# _AC_PROG_CC_C11
-# AC_PROG_CC_C89
-# --------------
-AC_DEFUN([AC_PROG_CC_C89],
+# _AC_PROG_CC_FORCE_VERSION(LOWER-VERSION, UPPER-VERSION)
+# -------------------------------------------------------
+# Require a compiler for a particular version of C, either C89 or C99.
+# LOWER-VERSION uses lower-case c, UPPER-VERSION uses upper-case.
+AC_DEFUN([_AC_PROG_CC_FORCE_VERSION],
[ AC_REQUIRE([AC_PROG_CC])dnl
- _AC_PROG_CC_C89
+ if test $ac_prog_cc_stdc != $1; then
+ ac_save_std_CC=$CC
+ if test -n "$ac_prog_cc_stdc_options"; then
+ CC=`expr "X$CC" : 'X\(.*\)'"$ac_prog_cc_stdc_options"
+ ``expr "X$CC" : ".*$ac_prog_cc_stdc_options"'\(.*\)'
+ `
+ fi
+ _AC_PROG_CC_$2(
+ [ac_prog_cc_stdc=$1
+ ac_cv_prog_cc_stdc=$ac_cv_prog_cc_$1],
+ [CC=$ac_save_std_CC
+ AC_MSG_WARN([$2 compiler not available; falling back on $CC])])
+ fi
])
+# AC_PROG_CC_C89
+# --------------
+AC_DEFUN([AC_PROG_CC_C89], [_AC_PROG_CC_FORCE_VERSION([c89], [C89])])
# AC_PROG_CC_C99
# --------------
-AC_DEFUN([AC_PROG_CC_C99],
-[ AC_REQUIRE([AC_PROG_CC])dnl
- _AC_PROG_CC_C99
-])
+AC_DEFUN([AC_PROG_CC_C99], [_AC_PROG_CC_FORCE_VERSION([c99], [C99])])
-
-# AC_PROG_CC_C11
-# --------------
-AC_DEFUN([AC_PROG_CC_C11],
-[ AC_REQUIRE([AC_PROG_CC])dnl
- _AC_PROG_CC_C11
-])
+# There is no AC_PROG_CC_C11, as we have not identified a need for it.
+# Applications should use AC_PROG_CC instead.
# AC_PROG_CC_STDC
# ---------------
-AC_DEFUN([AC_PROG_CC_STDC],
-[ AC_REQUIRE([AC_PROG_CC])dnl
- AS_CASE([$ac_cv_prog_cc_stdc],
- [no], [ac_cv_prog_cc_c11=no; ac_cv_prog_cc_c99=no; ac_cv_prog_cc_c89=no],
- [_AC_PROG_CC_C11([ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11],
- [_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])])])])
- AC_MSG_CHECKING([for $CC option to accept ISO Standard C])
- AC_CACHE_VAL([ac_cv_prog_cc_stdc], [])
- 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])])
-])
+# This has been folded into AC_PROG_CC.
+AU_ALIAS([AC_PROG_CC_STDC], [AC_PROG_CC])
# AC_C_BACKSLASH_A
# options.
AC_DEFUN([AC_C_PROTOTYPES],
[AC_REQUIRE([AC_PROG_CC])dnl
-AC_MSG_CHECKING([for function prototypes])
-if test "$ac_cv_prog_cc_c89" != no; then
- AC_MSG_RESULT([yes])
+if test "$ac_prog_cc_stdc" != no; then
AC_DEFINE(PROTOTYPES, 1,
[Define to 1 if the C compiler supports function prototypes.])
AC_DEFINE(__PROTOTYPES, 1,
[Define like PROTOTYPES; this can be used by system headers.])
-else
- AC_MSG_RESULT([no])
fi
])# AC_C_PROTOTYPES
AC_REQUIRE([AC_TYPE_UNSIGNED_LONG_LONG_INT])
AC_CACHE_CHECK([for long long int], [ac_cv_type_long_long_int],
[ac_cv_type_long_long_int=yes
- if test "x${ac_cv_prog_cc_c99-no}" = xno; then
- ac_cv_type_long_long_int=$ac_cv_type_unsigned_long_long_int
- if test $ac_cv_type_long_long_int = yes; then
- dnl Catch a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004.
- dnl If cross compiling, assume the bug is not important, since
- dnl nobody cross compiles for this platform as far as we know.
- AC_RUN_IFELSE(
- [AC_LANG_PROGRAM(
- [[@%:@include <limits.h>
- @%:@ifndef LLONG_MAX
- @%:@ define HALF \
- (1LL << (sizeof (long long int) * CHAR_BIT - 2))
- @%:@ define LLONG_MAX (HALF - 1 + HALF)
- @%:@endif]],
- [[long long int n = 1;
- int i;
- for (i = 0; ; i++)
- {
- long long int m = n << i;
- if (m >> i != n)
- return 1;
- if (LLONG_MAX / 2 < m)
- break;
- }
- return 0;]])],
- [],
- [ac_cv_type_long_long_int=no],
- [:])
- fi
- fi])
+ case $ac_prog_cc_stdc in
+ no | c89) ;;
+ *)
+ ac_cv_type_long_long_int=$ac_cv_type_unsigned_long_long_int
+ if test $ac_cv_type_long_long_int = yes; then
+ dnl Catch a bug in Tandem NonStop Kernel (OSS) cc -O circa 2004.
+ dnl If cross compiling, assume the bug is not important, since
+ dnl nobody cross compiles for this platform as far as we know.
+ AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[@%:@include <limits.h>
+ @%:@ifndef LLONG_MAX
+ @%:@ define HALF \
+ (1LL << (sizeof (long long int) * CHAR_BIT - 2))
+ @%:@ define LLONG_MAX (HALF - 1 + HALF)
+ @%:@endif]],
+ [[long long int n = 1;
+ int i;
+ for (i = 0; ; i++)
+ {
+ long long int m = n << i;
+ if (m >> i != n)
+ return 1;
+ if (LLONG_MAX / 2 < m)
+ break;
+ }
+ return 0;]])],
+ [],
+ [ac_cv_type_long_long_int=no],
+ [:])
+ fi;;
+ esac])
if test $ac_cv_type_long_long_int = yes; then
AC_DEFINE([HAVE_LONG_LONG_INT], [1],
[Define to 1 if the system has the type `long long int'.])
AC_CACHE_CHECK([for unsigned long long int],
[ac_cv_type_unsigned_long_long_int],
[ac_cv_type_unsigned_long_long_int=yes
- if test "x${ac_cv_prog_cc_c99-no}" = xno; then
- AC_LINK_IFELSE(
- [_AC_TYPE_LONG_LONG_SNIPPET],
- [],
- [ac_cv_type_unsigned_long_long_int=no])
- fi])
+ case $ac_prog_cc_stdc in
+ no | c89) ;;
+ *)
+ AC_LINK_IFELSE(
+ [_AC_TYPE_LONG_LONG_SNIPPET],
+ [],
+ [ac_cv_type_unsigned_long_long_int=no]);;
+ esac])
if test $ac_cv_type_unsigned_long_long_int = yes; then
AC_DEFINE([HAVE_UNSIGNED_LONG_LONG_INT], [1],
[Define to 1 if the system has the type `unsigned long long int'.])