1 ## ----------------------------------------- ##
2 ## ANSIfy the C compiler whenever possible. ##
3 ## From Franc,ois Pinard ##
4 ## ----------------------------------------- ##
6 # Copyright 1996, 1997, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2, or (at your option)
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 # @defmac AC_PROG_CC_STDC
26 # @maindex PROG_CC_STDC
28 # If the C compiler in not in ANSI C mode by default, try to add an option
29 # to output variable @code{CC} to make it so. This macro tries various
30 # options that select ANSI C on some system or another. It considers the
31 # compiler to be in ANSI C mode if it handles function prototypes correctly.
33 # If you use this macro, you should check after calling it whether the C
34 # compiler has been set to accept ANSI C; if not, the shell variable
35 # @code{am_cv_prog_cc_stdc} is set to @samp{no}. If you wrote your source
36 # code in ANSI C, you can make an un-ANSIfied copy of it by using the
37 # program @code{ansi2knr}, which comes with Ghostscript.
40 AC_DEFUN([AM_PROG_CC_STDC],
41 [AC_REQUIRE([AC_PROG_CC])
42 AC_BEFORE([$0], [AC_C_INLINE])
43 AC_BEFORE([$0], [AC_C_CONST])
44 dnl Force this before AC_PROG_CPP. Some cpp's, eg on HPUX, require
45 dnl a magic option to avoid problems with ANSI preprocessor commands
47 dnl FIXME: can't do this because then AC_AIX won't work due to a
48 dnl circular dependency.
49 dnl AC_BEFORE([$0], [AC_PROG_CPP])
50 AC_MSG_CHECKING([for ${CC-cc} option to accept ANSI C])
51 AC_CACHE_VAL(am_cv_prog_cc_stdc,
52 [am_cv_prog_cc_stdc=no
54 # Don't try gcc -ansi; that turns off useful extensions and
55 # breaks some systems' header files.
57 # Ultrix and OSF/1 -std1
58 # HP-UX 10.20 and later -Ae
59 # HP-UX older versions -Aa -D_HPUX_SOURCE
60 # SVR4 -Xc -D__EXTENSIONS__
61 for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
63 CC="$ac_save_CC $ac_arg"
67 #include <sys/types.h>
69 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
70 struct buf { int x; };
71 FILE * (*rcsopen) (struct buf *, struct stat *, int);
78 static char *f (char * (*g) (char **, int), char **p, ...)
83 s = g (p, va_arg (v,int));
87 int test (int i, double x);
88 struct s1 {int (*f) (int a);};
89 struct s2 {int (*f) (double a);};
90 int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
94 return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
96 [am_cv_prog_cc_stdc="$ac_arg"; break])
100 if test -z "$am_cv_prog_cc_stdc"; then
101 AC_MSG_RESULT([none needed])
103 AC_MSG_RESULT([$am_cv_prog_cc_stdc])
105 case "x$am_cv_prog_cc_stdc" in
107 *) CC="$CC $am_cv_prog_cc_stdc" ;;
111 AU_DEFUN([fp_PROG_CC_STDC], [AM_PROG_CC_STDC])