--- c.m4.old 2004-12-01 21:51:25.000000000 +0000 +++ c.m4 2004-12-01 22:18:59.000000000 +0000 @@ -483,7 +483,7 @@ _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 @@ -785,17 +785,17 @@ # 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 in not in 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 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 C]) +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 @@ -848,26 +848,109 @@ 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 - x|xno) - AC_MSG_RESULT([none needed]) ;; +case "x$ac_cv_prog_cc_c89" in + xno) + AC_MSG_RESULT([unsupported]) + $2 ;; *) - AC_MSG_RESULT([$ac_cv_prog_cc_stdc]) - CC="$CC $ac_cv_prog_cc_stdc" ;; + if test "x$ac_cv_prog_cc_c89" = x; then + AC_MSG_RESULT([none needed]) + else + AC_MSG_RESULT([$ac_cv_prog_cc_c89]) + CC="$CC $ac_cv_prog_cc_c89" + fi + $1 ;; esac -])# _AC_PROG_CC_STDC +])# _AC_PROG_CC_C89 -# AC_PROG_CC_STDC -# --------------- -# Has been merged into AC_PROG_CC. -AU_DEFUN([AC_PROG_CC_STDC], []) +# _AC_PROG_CC_C99 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE]) +# ---------------------------------------------------------------- +# If the C compiler in not in ISO C99 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 ISO C99 C on some system or another. It +# considers the compiler to be in ISO C99 C 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 C]) +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 +static inline int +test(const char *restrict text) +{ + int i = 0; + // Iterate through items via the restricted pointer + // and see if C++-style comments work. + while (*(text+i) != '\0') + ++i; + return 0; +}]], +[[_Bool success = false; + if (test("String literal") != 0) + success = true; + char *restrict newvar = "Another string";]])]) +# Try +# GCC -std=gnu99 -std=c99 -std=iso9899:1999 +# AIX -qlanglvl=extc99 -qlanglvl=stdc99 +# Intel ICC -c99 +# IRIX -c99 +# Solaris -xc99 +# Tru64 -c99 +for ac_arg in "" -std=gnu99 -std=c99 -std=iso9899:1999 -c99 -xc99 -qlanglvl=extc99 -qlanglvl=stdc99 +do + CC="$ac_save_CC $ac_arg" + _AC_COMPILE_IFELSE([], + [ac_cv_prog_cc_c99=$ac_arg +break]) +done +rm -f conftest.$ac_ext conftest.$ac_objext +CC=$ac_save_CC +]) +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]) + CC="$CC $ac_cv_prog_cc_c99" + fi + $1 ;; +esac +])# _AC_PROG_CC_C99 + + +# AC_PROG_CC_C89 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE]) +# --------------------------------------------------------------- +AC_DEFUN([AC_PROG_CC_C89], +[ AC_REQUIRE([AC_PROG_CC])dnl + _AC_PROG_CC_C89([$1], [$2]) +]) + + +# AC_PROG_CC_C99 ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE]) +# --------------------------------------------------------------- +AC_DEFUN([AC_PROG_CC_C99], +[ AC_REQUIRE([AC_PROG_CC])dnl + _AC_PROG_CC_C99([$1], [$2])dnl +]) + + +# AC_PROG_CC_STDC ([ACTION-IF-AVAILABLE], [ACTION-IF-UNAVAILABLE]) +# ---------------------------------------------------------------- +AC_DEFUN([AC_PROG_CC_STDC], +[AC_PROG_CC_C99([$1], [$2])]) # AC_C_BACKSLASH_A @@ -1207,7 +1290,7 @@ 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.])