From: Ben Elliston Date: Sun, 31 Oct 1999 00:56:04 +0000 (+0000) Subject: 1999-10-31 Ben Elliston X-Git-Tag: autoconf-2.50~1322 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c645272f5f16f2bddc0b8ce9170e5e3a663a2177;p=thirdparty%2Fautoconf.git 1999-10-31 Ben Elliston * acspecific.m4 (AC_PROG_CC_STDC, AC_C_PROTOTYPES): Inherit from Automake. From Franc,ois Pinard. * autoconf.texi (Particular Programs): Document AC_PROG_CC_STDC. (C Compiler Characteristics): Document AC_C_PROTOTYPES. --- diff --git a/ChangeLog b/ChangeLog index 70cb513b..6eefbb9c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 1999-10-31 Ben Elliston + * acspecific.m4 (AC_PROG_CC_STDC, AC_C_PROTOTYPES): Inherit from + Automake. From Franc,ois Pinard. + * autoconf.texi (Particular Programs): Document AC_PROG_CC_STDC. + (C Compiler Characteristics): Document AC_C_PROTOTYPES. + * testsuite/autoconf.s/defines.exp: Changed `fail' and `pass' in `xfail' and `xpass'. The testsuite checks that acconfig.h templates the AC_DEFINEs. Since we no longer rely on acconfig.h, @@ -10,8 +15,6 @@ 1999-10-27 Ben Elliston - * THANKS: Updated Alexandre's address. - * autoconf.texi (Generic Programs): @defmac for AC_PATH_TOOL may not span multiple lines. diff --git a/NEWS b/NEWS index 9b9a7c64..3f2ec858 100644 --- a/NEWS +++ b/NEWS @@ -23,6 +23,10 @@ Major changes in release 2.15: Document and ask for the registration of an envvar. - AC_CONFIG_LINKS Replaces the now obsolete AC_LINK_FILES. + - AC_PROG_CC_STDC + Checks if the compiler supports ISO C, included when needs special + options. + * Environment variables are kept when reconfiguring. The previous scheme to set envvar before running configure was ENV=VAL ./configure diff --git a/TODO b/TODO index 915f37cb..e929843b 100644 --- a/TODO +++ b/TODO @@ -28,6 +28,8 @@ so that we can run ./config.status name-of-the command. ** Move AM_PROG_CC_STDC into Autoconf. Autoconf should provide the means to determine the ANSIsm of the compiler, not Automake. +I've done it, but this is the last opportunity to change this macro +name: AC_PROG_CC_ISO? Or even more specific for the ISO version? ** Provide means to provides commands to run before AC_OUTPUT. This is what is needed for LTLIBOBJS and others. diff --git a/acspecific.m4 b/acspecific.m4 index b25c5a37..1401d9c5 100644 --- a/acspecific.m4 +++ b/acspecific.m4 @@ -203,6 +203,7 @@ else fi ]) + dnl AC_PROG_CC_WORKS dnl ---------------- AC_DEFUN(AC_PROG_CC_WORKS, @@ -221,6 +222,7 @@ AC_MSG_RESULT($ac_cv_prog_cc_cross) cross_compiling=$ac_cv_prog_cc_cross ]) + dnl AC_PROG_CXX_WORKS dnl ----------------- AC_DEFUN(AC_PROG_CXX_WORKS, @@ -239,6 +241,7 @@ AC_MSG_RESULT($ac_cv_prog_cxx_cross) cross_compiling=$ac_cv_prog_cxx_cross ]) + dnl AC_PROG_F77_WORKS dnl ----------------- dnl Test whether the Fortran 77 compiler can compile and link a trivial @@ -263,6 +266,7 @@ AC_MSG_RESULT($ac_cv_prog_f77_cross) cross_compiling=$ac_cv_prog_f77_cross ]) + dnl AC_PROG_CC_GNU dnl -------------- AC_DEFUN(AC_PROG_CC_GNU, @@ -279,6 +283,7 @@ else ac_cv_prog_gcc=no fi])]) + dnl AC_PROG_CXX_GNU dnl --------------- AC_DEFUN(AC_PROG_CXX_GNU, @@ -295,6 +300,7 @@ else ac_cv_prog_gxx=no fi])]) + dnl AC_PROG_F77_GNU dnl --------------- dnl Test whether for Fortran 77 compiler is `g77' (the GNU Fortran 77 @@ -360,6 +366,9 @@ fi rm -f conftest* ])]) + +dnl AC_PROG_GCC_TRADITIONAL +dnl ----------------------- AC_DEFUN(AC_PROG_GCC_TRADITIONAL, [AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_PROG_CPP])dnl @@ -380,7 +389,8 @@ Autoconf TCGETA], CC="$CC -traditional" fi fi -]) +])dnl AC_PROG_GCC_TRADITIONAL + dnl AC_PROG_CC_C_O dnl -------------- @@ -434,14 +444,14 @@ fi ])dnl AC_PROG_CC_C_O +dnl AC_PROG_F77_C_O +dnl --------------- dnl Test if the Fortran 77 compiler accepts the options `-c' and `-o' dnl simultaneously, and define `F77_NO_MINUS_C_MINUS_O' if it does not. dnl dnl The usefulness of this macro is questionable, as I can't really see dnl why anyone would use it. The only reason I include it is for dnl completeness, since a similar test exists for the C compiler. -dnl -dnl AC_PROG_F77_C_O AC_DEFUN(AC_PROG_F77_C_O, [AC_BEFORE([$0], [AC_PROG_F77])dnl AC_MSG_CHECKING(whether $F77 understand -c and -o together) @@ -472,7 +482,87 @@ else AC_DEFINE(F77_NO_MINUS_C_MINUS_O, 1, [Define if your Fortran 77 compiler doesn't accept -c and -o together.]) fi +])dnl AC_PROG_F77_C_O + + +dnl AC_PROG_CC_STDC +dnl --------------- +dnl If the C compiler in not in ANSI C mode by default, try to add an +dnl option to output variable @code{CC} to make it so. This macro tries +dnl various options that select ANSI C on some system or another. It +dnl considers the compiler to be in ANSI C mode if it handles function +dnl prototypes correctly. +AC_DEFUN(AC_PROG_CC_STDC, +[AC_REQUIRE([AC_PROG_CC])dnl +AC_BEFORE([$0], [AC_C_INLINE])dnl +AC_BEFORE([$0], [AC_C_CONST])dnl +dnl Force this before AC_PROG_CPP. Some cpp's, eg on HPUX, require +dnl a magic option to avoid problems with ANSI preprocessor commands +dnl like #elif. +dnl FIXME: can't do this because then AC_AIX won't work due to a +dnl circular dependency. +dnl AC_BEFORE([$0], [AC_PROG_CPP]) +AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C) +AC_CACHE_VAL(ac_cv_prog_cc_stdc, +[ac_cv_prog_cc_stdc=no +ac_save_CC="$CC" +# Don't try gcc -ansi; that turns off useful extensions and +# breaks some systems' header files. +# AIX -qlanglvl=ansi +# Ultrix and OSF/1 -std1 +# HP-UX 10.20 and later -Ae +# HP-UX older versions -Aa -D_HPUX_SOURCE +# SVR4 -Xc -D__EXTENSIONS__ +for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + AC_TRY_COMPILE( +[#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +], [ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; +], +[ac_cv_prog_cc_stdc="$ac_arg"; break]) +done +CC="$ac_save_CC" ]) +if test -z "$ac_cv_prog_cc_stdc"; then + AC_MSG_RESULT([none needed]) +else + AC_MSG_RESULT($ac_cv_prog_cc_stdc) +fi +case "x$ac_cv_prog_cc_stdc" in + x|xno) ;; + *) CC="$CC $ac_cv_prog_cc_stdc" ;; +esac +])dnl AC_PROG_CC_STDC + dnl AC_PROG_MAKE_SET dnl ---------------- @@ -2202,6 +2292,8 @@ if test $ac_cv_c_bigendian = yes; then fi ]) +dnl AC_C_INLINE +dnl ----------- dnl Do nothing if the compiler accepts the inline keyword. dnl Otherwise define inline to __inline__ or __inline if one of those work, dnl otherwise define inline to be empty. @@ -2223,6 +2315,9 @@ case "$ac_cv_c_inline" in esac ]) + +dnl AC_C_CONST +dnl ---------- AC_DEFUN(AC_C_CONST, [dnl This message is consistent in form with the other checking messages, dnl and with the result message. @@ -2278,7 +2373,8 @@ if test $ac_cv_c_const = no; then AC_DEFINE(const,, [Define to empty if the keyword `const' does not work.]) fi -]) +])dnl AC_C_CONST + dnl AC_C_VOLATILE dnl ------------- @@ -2302,6 +2398,7 @@ if test $ac_cv_c_volatile = no; then fi ]) + dnl AC_C_STRINGIZE dnl -------------- dnl Checks if `#' can be used to glue strings together at the CPP level. @@ -2320,7 +2417,26 @@ if test "${ac_cv_c_stringize}" = yes; then [Define if you have the ANSI # stringizing operator in cpp.]) fi AC_MSG_RESULT([${ac_cv_c_stringize}]) -])dnl +])dnl AC_C_STRINGIZE + + +dnl AC_C_PROTOTYPES +dnl --------------- +dnl Check if the C compiler supports prototypes, included if it needs +dnl options. +AC_DEFUN(AC_C_PROTOTYPES, +[AC_REQUIRE([AC_PROG_CC_STDC])dnl +AC_REQUIRE([AC_PROG_CPP])dnl +AC_MSG_CHECKING([for function prototypes]) +if test "$ac_cv_prog_cc_stdc" != no; then + AC_MSG_RESULT(yes) + AC_DEFINE(PROTOTYPES, 1, + [Define if the compiler supports function prototypes.]) +else + AC_MSG_RESULT(no) +fi +])dnl AC_C_PROTOTYPES + define(AC_ARG_ARRAY, [AC_FATAL([$0 has been removed; don't do non-portable things with arguments], 4)]) diff --git a/autoconf.texi b/autoconf.texi index a36de69d..9c87fbd3 100644 --- a/autoconf.texi +++ b/autoconf.texi @@ -1637,6 +1637,23 @@ If the C compiler does not accept the @samp{-c} and @samp{-o} options simultaneously, define @code{NO_MINUS_C_MINUS_O}. @end defmac +@defmac AC_PROG_CC_STDC +@maindex PROG_CC_STDC +@ovindex CC +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. + +If you use this macro, you should check after calling it whether the C +compiler has been set to accept ANSI C; if not, the shell variable +@code{ac_cv_prog_cc_stdc} is set to @samp{no}. If you wrote your source +code in ANSI C, you can make an un-ANSIfied copy of it by using the +program @code{ansi2knr}, which comes with Ghostscript. +@end defmac + + @defmac AC_PROG_CPP @maindex PROG_CPP @ovindex CPP @@ -2844,7 +2861,6 @@ is defined. However, Ultrix 4.3's native compiler does support volatile, but does not defined @code{__STDC__}. @end defmac - @defmac AC_C_INLINE @maindex C_INLINE @cvindex inline @@ -2881,6 +2897,32 @@ found in macros such as this: @end example @end defmac +@defmac AC_C_PROTOTYPES +@maindex C_PROTOTYPES +@cvindex PROTOTYPES +@cvindex PARAMS +Check to see if function prototypes are understood by the compiler. If +so, define @samp{PROTOTYPES}. In the case the compiler does not handle +prototypes, you should use @code{ansi2knr}, which comes with the +Ghostscript distribution, to unprotoize function definitions. For +function prototypes, you should first define @code{PARAMS}: +@example +#ifndef PARAMS +# if PROTOTYPES +# define PARAMS(protos) protos +# else /* no PROTOTYPES */ +# define PARAMS(protos) () +# endif /* no PROTOTYPES */ +#endif +@end example +then use it this way: +@example +size_t my_strlen PARAMS ((const char *)); +@end example +@end defmac + +@c FIXME: What the heck is this macro doing here? Move it out of +@c the way, in its proper section!!! @defmac AC_CHECK_SIZEOF (@var{type} @r{[}, @var{cross-size}@r{[}, @var{includes}@r{]]}) @maindex CHECK_SIZEOF Define @code{SIZEOF_@var{uctype}} to be the size in bytes of the C (or diff --git a/doc/autoconf.texi b/doc/autoconf.texi index a36de69d..9c87fbd3 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -1637,6 +1637,23 @@ If the C compiler does not accept the @samp{-c} and @samp{-o} options simultaneously, define @code{NO_MINUS_C_MINUS_O}. @end defmac +@defmac AC_PROG_CC_STDC +@maindex PROG_CC_STDC +@ovindex CC +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. + +If you use this macro, you should check after calling it whether the C +compiler has been set to accept ANSI C; if not, the shell variable +@code{ac_cv_prog_cc_stdc} is set to @samp{no}. If you wrote your source +code in ANSI C, you can make an un-ANSIfied copy of it by using the +program @code{ansi2knr}, which comes with Ghostscript. +@end defmac + + @defmac AC_PROG_CPP @maindex PROG_CPP @ovindex CPP @@ -2844,7 +2861,6 @@ is defined. However, Ultrix 4.3's native compiler does support volatile, but does not defined @code{__STDC__}. @end defmac - @defmac AC_C_INLINE @maindex C_INLINE @cvindex inline @@ -2881,6 +2897,32 @@ found in macros such as this: @end example @end defmac +@defmac AC_C_PROTOTYPES +@maindex C_PROTOTYPES +@cvindex PROTOTYPES +@cvindex PARAMS +Check to see if function prototypes are understood by the compiler. If +so, define @samp{PROTOTYPES}. In the case the compiler does not handle +prototypes, you should use @code{ansi2knr}, which comes with the +Ghostscript distribution, to unprotoize function definitions. For +function prototypes, you should first define @code{PARAMS}: +@example +#ifndef PARAMS +# if PROTOTYPES +# define PARAMS(protos) protos +# else /* no PROTOTYPES */ +# define PARAMS(protos) () +# endif /* no PROTOTYPES */ +#endif +@end example +then use it this way: +@example +size_t my_strlen PARAMS ((const char *)); +@end example +@end defmac + +@c FIXME: What the heck is this macro doing here? Move it out of +@c the way, in its proper section!!! @defmac AC_CHECK_SIZEOF (@var{type} @r{[}, @var{cross-size}@r{[}, @var{includes}@r{]]}) @maindex CHECK_SIZEOF Define @code{SIZEOF_@var{uctype}} to be the size in bytes of the C (or diff --git a/lib/autoconf/specific.m4 b/lib/autoconf/specific.m4 index b25c5a37..1401d9c5 100644 --- a/lib/autoconf/specific.m4 +++ b/lib/autoconf/specific.m4 @@ -203,6 +203,7 @@ else fi ]) + dnl AC_PROG_CC_WORKS dnl ---------------- AC_DEFUN(AC_PROG_CC_WORKS, @@ -221,6 +222,7 @@ AC_MSG_RESULT($ac_cv_prog_cc_cross) cross_compiling=$ac_cv_prog_cc_cross ]) + dnl AC_PROG_CXX_WORKS dnl ----------------- AC_DEFUN(AC_PROG_CXX_WORKS, @@ -239,6 +241,7 @@ AC_MSG_RESULT($ac_cv_prog_cxx_cross) cross_compiling=$ac_cv_prog_cxx_cross ]) + dnl AC_PROG_F77_WORKS dnl ----------------- dnl Test whether the Fortran 77 compiler can compile and link a trivial @@ -263,6 +266,7 @@ AC_MSG_RESULT($ac_cv_prog_f77_cross) cross_compiling=$ac_cv_prog_f77_cross ]) + dnl AC_PROG_CC_GNU dnl -------------- AC_DEFUN(AC_PROG_CC_GNU, @@ -279,6 +283,7 @@ else ac_cv_prog_gcc=no fi])]) + dnl AC_PROG_CXX_GNU dnl --------------- AC_DEFUN(AC_PROG_CXX_GNU, @@ -295,6 +300,7 @@ else ac_cv_prog_gxx=no fi])]) + dnl AC_PROG_F77_GNU dnl --------------- dnl Test whether for Fortran 77 compiler is `g77' (the GNU Fortran 77 @@ -360,6 +366,9 @@ fi rm -f conftest* ])]) + +dnl AC_PROG_GCC_TRADITIONAL +dnl ----------------------- AC_DEFUN(AC_PROG_GCC_TRADITIONAL, [AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_PROG_CPP])dnl @@ -380,7 +389,8 @@ Autoconf TCGETA], CC="$CC -traditional" fi fi -]) +])dnl AC_PROG_GCC_TRADITIONAL + dnl AC_PROG_CC_C_O dnl -------------- @@ -434,14 +444,14 @@ fi ])dnl AC_PROG_CC_C_O +dnl AC_PROG_F77_C_O +dnl --------------- dnl Test if the Fortran 77 compiler accepts the options `-c' and `-o' dnl simultaneously, and define `F77_NO_MINUS_C_MINUS_O' if it does not. dnl dnl The usefulness of this macro is questionable, as I can't really see dnl why anyone would use it. The only reason I include it is for dnl completeness, since a similar test exists for the C compiler. -dnl -dnl AC_PROG_F77_C_O AC_DEFUN(AC_PROG_F77_C_O, [AC_BEFORE([$0], [AC_PROG_F77])dnl AC_MSG_CHECKING(whether $F77 understand -c and -o together) @@ -472,7 +482,87 @@ else AC_DEFINE(F77_NO_MINUS_C_MINUS_O, 1, [Define if your Fortran 77 compiler doesn't accept -c and -o together.]) fi +])dnl AC_PROG_F77_C_O + + +dnl AC_PROG_CC_STDC +dnl --------------- +dnl If the C compiler in not in ANSI C mode by default, try to add an +dnl option to output variable @code{CC} to make it so. This macro tries +dnl various options that select ANSI C on some system or another. It +dnl considers the compiler to be in ANSI C mode if it handles function +dnl prototypes correctly. +AC_DEFUN(AC_PROG_CC_STDC, +[AC_REQUIRE([AC_PROG_CC])dnl +AC_BEFORE([$0], [AC_C_INLINE])dnl +AC_BEFORE([$0], [AC_C_CONST])dnl +dnl Force this before AC_PROG_CPP. Some cpp's, eg on HPUX, require +dnl a magic option to avoid problems with ANSI preprocessor commands +dnl like #elif. +dnl FIXME: can't do this because then AC_AIX won't work due to a +dnl circular dependency. +dnl AC_BEFORE([$0], [AC_PROG_CPP]) +AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C) +AC_CACHE_VAL(ac_cv_prog_cc_stdc, +[ac_cv_prog_cc_stdc=no +ac_save_CC="$CC" +# Don't try gcc -ansi; that turns off useful extensions and +# breaks some systems' header files. +# AIX -qlanglvl=ansi +# Ultrix and OSF/1 -std1 +# HP-UX 10.20 and later -Ae +# HP-UX older versions -Aa -D_HPUX_SOURCE +# SVR4 -Xc -D__EXTENSIONS__ +for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + AC_TRY_COMPILE( +[#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +], [ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; +], +[ac_cv_prog_cc_stdc="$ac_arg"; break]) +done +CC="$ac_save_CC" ]) +if test -z "$ac_cv_prog_cc_stdc"; then + AC_MSG_RESULT([none needed]) +else + AC_MSG_RESULT($ac_cv_prog_cc_stdc) +fi +case "x$ac_cv_prog_cc_stdc" in + x|xno) ;; + *) CC="$CC $ac_cv_prog_cc_stdc" ;; +esac +])dnl AC_PROG_CC_STDC + dnl AC_PROG_MAKE_SET dnl ---------------- @@ -2202,6 +2292,8 @@ if test $ac_cv_c_bigendian = yes; then fi ]) +dnl AC_C_INLINE +dnl ----------- dnl Do nothing if the compiler accepts the inline keyword. dnl Otherwise define inline to __inline__ or __inline if one of those work, dnl otherwise define inline to be empty. @@ -2223,6 +2315,9 @@ case "$ac_cv_c_inline" in esac ]) + +dnl AC_C_CONST +dnl ---------- AC_DEFUN(AC_C_CONST, [dnl This message is consistent in form with the other checking messages, dnl and with the result message. @@ -2278,7 +2373,8 @@ if test $ac_cv_c_const = no; then AC_DEFINE(const,, [Define to empty if the keyword `const' does not work.]) fi -]) +])dnl AC_C_CONST + dnl AC_C_VOLATILE dnl ------------- @@ -2302,6 +2398,7 @@ if test $ac_cv_c_volatile = no; then fi ]) + dnl AC_C_STRINGIZE dnl -------------- dnl Checks if `#' can be used to glue strings together at the CPP level. @@ -2320,7 +2417,26 @@ if test "${ac_cv_c_stringize}" = yes; then [Define if you have the ANSI # stringizing operator in cpp.]) fi AC_MSG_RESULT([${ac_cv_c_stringize}]) -])dnl +])dnl AC_C_STRINGIZE + + +dnl AC_C_PROTOTYPES +dnl --------------- +dnl Check if the C compiler supports prototypes, included if it needs +dnl options. +AC_DEFUN(AC_C_PROTOTYPES, +[AC_REQUIRE([AC_PROG_CC_STDC])dnl +AC_REQUIRE([AC_PROG_CPP])dnl +AC_MSG_CHECKING([for function prototypes]) +if test "$ac_cv_prog_cc_stdc" != no; then + AC_MSG_RESULT(yes) + AC_DEFINE(PROTOTYPES, 1, + [Define if the compiler supports function prototypes.]) +else + AC_MSG_RESULT(no) +fi +])dnl AC_C_PROTOTYPES + define(AC_ARG_ARRAY, [AC_FATAL([$0 has been removed; don't do non-portable things with arguments], 4)])