Patch from Roger Leigh (with some minor changes) as follows:

* NEWS: New macros AC_PROG_CC_C89, AC_PROG_CC_C99.
Resurrect AC_PROG_CC_STDC.
* doc/autoconf.texi (C Compiler): Add AC_PROG_CC_STDC,
AC_PROG_CC_C89, AC_PROG_CC_C99.
(Obsolete Macros): Remove AC_PROG_CC_STDC; it's no longer obsolete.
* lib/autoconf/c.m4 (_AC_PROG_CC_C89, _AC_PROG_CC_C99, AC_PROG_CC_C89,
AC_PROG_CC_C99): New macros.
(AC_PROG_CC_STDC): Use them.
(_AC_PROG_CC_STDC): Remove.
(AC_C_PROTOTYPES): Use ac_cv_prog_cc_c89, not ac_cv_prog_cc_stdc.
* THANKS: Add Roger Leigh.
This commit is contained in:
Paul Eggert 2005-01-03 07:35:21 +00:00
parent 50b293ba43
commit 3271f2121a
4 changed files with 278 additions and 35 deletions

13
NEWS
View File

@ -1,5 +1,16 @@
* Major changes in Autoconf 2.59c
** AC_PROG_CC_C89, AC_PROG_CC_C99
New macros for ISO C99 support. AC_PROG_CC_C89 and AC_PROG_CC_C99
check for ANSI C89 and ISO C99 support respectively.
** AC_PROG_CC_STDC
Has been unobsoleted, and will check if the compiler supports ISO
C99, falling back to ANSI C89 if not. ac_cv_prog_cc_stdc is
retained for backwards compatibility, assuming the value of
ac_cv_prog_cc_c99 or ac_cv_prog_cc_c89 (whichever is valid, in
that order).
* Major changes in Autoconf 2.59b
Released 2004-08-20, by Paul Eggert.
@ -1197,7 +1208,7 @@ Various bug fixes.
-----
Copyright (C) 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, 2002,
2003, 2004 Free Software Foundation, Inc.
2003, 2004, 2005 Free Software Foundation, Inc.
This file is part of GNU Autoconf.

1
THANKS
View File

@ -174,6 +174,7 @@ Richard Stallman rms@gnu.org
Robert Lipe robertlipe@usa.net
Robert S. Maier rsm@math.arizona.edu
Roberto Bagnara bagnara@cs.unipr.it
Roger Leigh rleigh@whinlatter.ukfsn.org
Roland McGrath roland@gnu.org
Ruediger Kuhlmann info@ruediger-kuhlmann.de
Russ Allbery rra@stanford.edu

View File

@ -181,7 +181,7 @@ a package for creating scripts to configure source code packages using
templates and an M4 macro package.
Copyright @copyright{} 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000,
2001, 2002, 2003, 2004 Free Software Foundation, Inc.
2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
@quotation
Permission is granted to copy, distribute and/or modify this document
@ -5597,15 +5597,15 @@ this:
AC_PROG_CC(cl egcs gcc cc)
@end example
If the C compiler is not in @acronym{ANSI} C mode by default, try to add an
If the C compiler is not in @acronym{ANSI} mode by default, try to add an
option to output variable @code{CC} to make it so. This macro tries
various options that select @acronym{ANSI} C on some system or another. It
considers the compiler to be in @acronym{ANSI} C mode if it handles function
considers the compiler to be in @acronym{ANSI} mode if it handles function
prototypes correctly.
After calling this macro you can check whether the C compiler has been
set to accept @acronym{ANSI} C; if not, the shell variable
@code{ac_cv_prog_cc_stdc} is set to @samp{no}. If you wrote your source
@code{ac_cv_prog_cc_c89} is set to @samp{no}. If you wrote your source
code in @acronym{ANSI} C, you can make an un-@acronym{ANSI}fied copy of it by
using the program @code{ansi2knr}, which comes with Automake. See also
under @code{AC_C_PROTOTYPES} below.
@ -5659,6 +5659,49 @@ features. To check for characteristics not listed here, use
@code{AC_COMPILE_IFELSE} (@pxref{Running the Compiler}) or
@code{AC_RUN_IFELSE} (@pxref{Run Time}).
@defmac AC_PROG_CC_STDC
@acindex{PROG_CC_STDC}
If the C compiler is not able to compile ISO Standard C (currently ISO
C99), try to add an option to output variable @code{CC} to make it so.
If the compiler does not support ISO C99, fall back to supporting
@acronym{ANSI} C89 (ISO C90).
After calling this macro you can check whether the C compiler has been
set to accept ISO 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}
If the C compiler is not in @acronym{ANSI} C89 (ISO C90) mode by
default, try to add an option to output variable @code{CC} to make it
so. This macro tries various options that select @acronym{ANSI} C89 on
some system or another. It considers the compiler to be in
@acronym{ANSI} C89 mode if it handles function prototypes correctly.
After calling this macro you can check whether the C compiler has been
set to accept @acronym{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}.
@end defmac
@defmac AC_PROG_CC_C99
@acindex{PROG_CC_C99}
If the C compiler is not in ISO C99 mode by default, try to add an
option to output variable @code{CC} to make it so. This macro tries
various options that select ISO C99 on some system or another. It
considers the compiler to be in ISO C99 mode if it handles @code{_Bool},
flexible arrays, @code{inline}, @code{long long}, mixed code and
declarations, named initialization of structs, @code{restrict}, varargs
macros, variable declarations in @code{for} loops and variable length
arrays.
After calling this macro you can check whether the C compiler has been
set to accept ISO C99; if not, the shell variable
@code{ac_cv_prog_cc_c99} is set to @samp{no}.
@end defmac
@defmac AC_C_BACKSLASH_A
@acindex{HAVE_C_BACKSLASH_A}
Define @samp{HAVE_C_BACKSLASH_A} to 1 if the C compiler understands
@ -14268,11 +14311,6 @@ AC_CONFIG_COMMANDS([default], [[echo "Square brackets: []"]])
@code{AC_PREFIX_PROGRAM}
@end defmac
@defmac AC_PROG_CC_STDC
@acindex{PROG_CC_STDC}
This macro has been integrated into @code{AC_PROG_CC}.
@end defmac
@defmac AC_PROGRAMS_CHECK
@acindex{PROGRAMS_CHECK}
@code{AC_CHECK_PROGS}

View File

@ -1,6 +1,6 @@
# This file is part of Autoconf. -*- Autoconf -*-
# Programming languages support.
# Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
# Copyright (C) 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@ -485,7 +485,7 @@ m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
_AC_LANG_COMPILER_GNU
GCC=`test $ac_compiler_gnu = yes && echo yes`
_AC_PROG_CC_G
_AC_PROG_CC_STDC
_AC_PROG_CC_C89
# Some people use a C++ compiler to compile C. Since we use `exit',
# in C++ we need to declare it. In case someone uses the same compiler
# for both compiling C and C++ we need to have the C++ compiler decide
@ -810,17 +810,17 @@ fi
# 4b. C compiler characteristics. #
# -------------------------------- #
# _AC_PROG_CC_STDC
# ----------------
# If the C compiler in not in ANSI C mode by default, try to add an
# option to output variable @code{CC} to make it so. This macro tries
# various options that select ANSI C on some system or another. It
# considers the compiler to be in ANSI C mode if it handles function
# prototypes correctly.
AC_DEFUN([_AC_PROG_CC_STDC],
[AC_MSG_CHECKING([for $CC option to accept ANSI C])
AC_CACHE_VAL(ac_cv_prog_cc_stdc,
[ac_cv_prog_cc_stdc=no
# _AC_PROG_CC_C89 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
# ----------------------------------------------------------------
# If the C compiler is not in ANSI C89 (ISO C90) mode by default, try
# to add an option to output variable CC to make it so. This macro
# tries various options that select ANSI C89 on some system or
# another. It considers the compiler to be in ANSI C89 mode if it
# handles function prototypes correctly.
AC_DEFUN([_AC_PROG_CC_C89],
[AC_MSG_CHECKING([for $CC option to accept ANSI C89])
AC_CACHE_VAL(ac_cv_prog_cc_c89,
[ac_cv_prog_cc_c89=no
ac_save_CC=$CC
AC_LANG_CONFTEST([AC_LANG_PROGRAM(
[[#include <stdarg.h>
@ -875,26 +875,219 @@ for ac_arg in "" -qlanglvl=extc89 -qlanglvl=ansi -std \
do
CC="$ac_save_CC $ac_arg"
_AC_COMPILE_IFELSE([],
[ac_cv_prog_cc_stdc=$ac_arg
[ac_cv_prog_cc_c89=$ac_arg
break])
done
rm -f conftest.$ac_ext conftest.$ac_objext
CC=$ac_save_CC
])
case "x$ac_cv_prog_cc_stdc" in
# Because of `break', _AC_COMPILE_IFELSE's cleaning code was skipped.
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
case "x$ac_cv_prog_cc_c89" in
x|xno)
AC_MSG_RESULT([none needed]) ;;
CC="$ac_save_CC" ;;
*)
AC_MSG_RESULT([$ac_cv_prog_cc_stdc])
CC="$CC $ac_cv_prog_cc_stdc" ;;
CC="$ac_save_CC $ac_cv_prog_cc_c89" ;;
esac
])# _AC_PROG_CC_STDC
])
case "x$ac_cv_prog_cc_c89" in
xno)
AC_MSG_RESULT([unsupported])
$2 ;;
*)
if test "x$ac_cv_prog_cc_c89" = x; then
AC_MSG_RESULT([none needed])
else
AC_MSG_RESULT([$ac_cv_prog_cc_c89])
fi
$1 ;;
esac
])# _AC_PROG_CC_C89
# _AC_PROG_CC_C99 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE])
# ----------------------------------------------------------------
# If the C compiler is not in ISO C99 mode by default, try to add an
# option to output variable CC to make it so. This macro tries
# various options that select ISO C99 on some system or another. It
# considers the compiler to be in ISO C99 mode if it handles mixed
# code and declarations, _Bool, inline and restrict.
AC_DEFUN([_AC_PROG_CC_C99],
[AC_MSG_CHECKING([for $CC option to accept ISO C99])
AC_CACHE_VAL(ac_cv_prog_cc_c99,
[ac_cv_prog_cc_c99=no
ac_save_CC=$CC
AC_LANG_CONFTEST([AC_LANG_PROGRAM(
[[#include <stdarg.h>
#include <stdbool.h>
#include <stdlib.h>
#include <wchar.h>
#include <stdio.h>
struct incomplete_array
{
int datasize;
double data[];
};
struct named_init {
int number;
const wchar_t *name;
double average;
};
static inline int
test_restrict(const char *restrict text)
{
// See if C++-style comments work.
// Iterate through items via the restricted pointer.
// Also check for declarations in for loops.
for (unsigned int i = 0; *(text+i) != '\0'; ++i)
continue;
return 0;
}
// Check varargs and va_copy work.
static void
test_varargs(const char *format, ...)
{
va_list args;
va_start(args, format);
va_list args_copy;
va_copy(args_copy, args);
const char *str;
int number;
float fnumber;
while (*format)
{
switch (*format++)
{
case 's': // string
str = va_arg(args_copy, const char *);
break;
case 'd': // int
number = va_arg(args_copy, int);
break;
case 'f': // float
fnumber = (float) va_arg(args_copy, double);
break;
default:
break;
}
}
va_end(args_copy);
va_end(args);
}
]],
[[
// Check bool and long long datatypes.
_Bool success = false;
long long int bignum = -1234567890LL;
unsigned long long int ubignum = 1234567890uLL;
// Check restrict.
if (test_restrict("String literal") != 0)
success = true;
char *restrict newvar = "Another string";
// Check varargs.
test_varargs("s, d' f .", "string", 65, 34.234);
// Check incomplete arrays work.
struct incomplete_array *ia =
malloc(sizeof(struct incomplete_array) + (sizeof(double) * 10));
ia->datasize = 10;
for (int i = 0; i < ia->datasize; ++i)
ia->data[i] = (double) i * 1.234;
// Check named initialisers.
struct named_init ni = {
.number = 34,
.name = L"Test wide string",
.average = 543.34343,
};
ni.number = 58;
int dynamic_array[ni.number];
dynamic_array[43] = 543;
]])])
# Try
# GCC -std=gnu99 (unused restrictive modes: -std=c99 -std=iso9899:1999)
# AIX -qlanglvl=extc99 (unused restrictive mode: -qlanglvl=stdc99)
# Intel ICC -c99
# IRIX -c99
# Solaris (unused because it causes the compiler to assume C99 semantics for
# library functions, and this is invalid before Solaris 10: -xc99)
# Tru64 -c99
# with extended modes being tried first.
for ac_arg in "" -std=gnu99 -c99 -qlanglvl=extc99
do
CC="$ac_save_CC $ac_arg"
_AC_COMPILE_IFELSE([],
[ac_cv_prog_cc_c99=$ac_arg
break])
done
# Because of `break', _AC_COMPILE_IFELSE's cleaning code was skipped.
rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
case "x$ac_cv_prog_cc_c99" in
x|xno)
CC="$ac_save_CC" ;;
*)
CC="$ac_save_CC $ac_cv_prog_cc_c99" ;;
esac
])
case "x$ac_cv_prog_cc_c99" in
xno)
AC_MSG_RESULT([unsupported])
$2 ;;
*)
if test "x$ac_cv_prog_cc_c99" = x; then
AC_MSG_RESULT([none needed])
else
AC_MSG_RESULT([$ac_cv_prog_cc_c99])
fi
$1 ;;
esac
])# _AC_PROG_CC_C99
# AC_PROG_CC_C89
# --------------
AC_DEFUN([AC_PROG_CC_C89],
[ AC_REQUIRE([AC_PROG_CC])dnl
_AC_PROG_CC_C89
])
# AC_PROG_CC_C99
# --------------
AC_DEFUN([AC_PROG_CC_C99],
[ AC_REQUIRE([AC_PROG_CC])dnl
_AC_PROG_CC_C99
])
# AC_PROG_CC_STDC
# ---------------
# Has been merged into AC_PROG_CC.
AU_DEFUN([AC_PROG_CC_STDC], [])
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], [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
])
# AC_C_BACKSLASH_A
@ -1246,7 +1439,7 @@ fi
AC_DEFUN([AC_C_PROTOTYPES],
[AC_REQUIRE([AC_PROG_CC])dnl
AC_MSG_CHECKING([for function prototypes])
if test "$ac_cv_prog_cc_stdc" != no; then
if test "$ac_cv_prog_cc_c89" != no; then
AC_MSG_RESULT([yes])
AC_DEFINE(PROTOTYPES, 1,
[Define to 1 if the C compiler supports function prototypes.])