]> Dogcows Code - chaz/tar/blob - m4/ccstdc.m4
Update
[chaz/tar] / m4 / ccstdc.m4
1 # The following is taken from automake 1.4,
2 # except that it prefers the compiler option -Ae to "-Aa -D_HPUX_SOURCE"
3 # because only the former supports 64-bit integral types on HP-UX 10.20.
4
5 ## ----------------------------------------- ##
6 ## ANSIfy the C compiler whenever possible. ##
7 ## From Franc,ois Pinard ##
8 ## ----------------------------------------- ##
9
10 # serial 2
11
12 # @defmac AC_PROG_CC_STDC
13 # @maindex PROG_CC_STDC
14 # @ovindex CC
15 # If the C compiler in not in ANSI C mode by default, try to add an option
16 # to output variable @code{CC} to make it so. This macro tries various
17 # options that select ANSI C on some system or another. It considers the
18 # compiler to be in ANSI C mode if it handles function prototypes correctly.
19 #
20 # If you use this macro, you should check after calling it whether the C
21 # compiler has been set to accept ANSI C; if not, the shell variable
22 # @code{am_cv_prog_cc_stdc} is set to @samp{no}. If you wrote your source
23 # code in ANSI C, you can make an un-ANSIfied copy of it by using the
24 # program @code{ansi2knr}, which comes with Ghostscript.
25 # @end defmac
26
27 AC_DEFUN(AM_PROG_CC_STDC,
28 [AC_REQUIRE([AC_PROG_CC])
29 AC_BEFORE([$0], [AC_C_INLINE])
30 AC_BEFORE([$0], [AC_C_CONST])
31 dnl Force this before AC_PROG_CPP. Some cpp's, eg on HPUX, require
32 dnl a magic option to avoid problems with ANSI preprocessor commands
33 dnl like #elif.
34 dnl FIXME: can't do this because then AC_AIX won't work due to a
35 dnl circular dependency.
36 dnl AC_BEFORE([$0], [AC_PROG_CPP])
37 AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
38 AC_CACHE_VAL(am_cv_prog_cc_stdc,
39 [am_cv_prog_cc_stdc=no
40 ac_save_CC="$CC"
41 # Don't try gcc -ansi; that turns off useful extensions and
42 # breaks some systems' header files.
43 # AIX -qlanglvl=ansi
44 # Ultrix and OSF/1 -std1
45 # HP-UX -Aa -D_HPUX_SOURCE
46 # SVR4 -Xc -D__EXTENSIONS__
47 for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
48 do
49 CC="$ac_save_CC $ac_arg"
50 AC_TRY_COMPILE(
51 [#include <stdarg.h>
52 #include <stdio.h>
53 #include <sys/types.h>
54 #include <sys/stat.h>
55 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
56 struct buf { int x; };
57 FILE * (*rcsopen) (struct buf *, struct stat *, int);
58 static char *e (p, i)
59 char **p;
60 int i;
61 {
62 return p[i];
63 }
64 static char *f (char * (*g) (char **, int), char **p, ...)
65 {
66 char *s;
67 va_list v;
68 va_start (v,p);
69 s = g (p, va_arg (v,int));
70 va_end (v);
71 return s;
72 }
73 int test (int i, double x);
74 struct s1 {int (*f) (int a);};
75 struct s2 {int (*f) (double a);};
76 int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
77 int argc;
78 char **argv;
79 ], [
80 return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
81 ],
82 [am_cv_prog_cc_stdc="$ac_arg"; break])
83 done
84 CC="$ac_save_CC"
85 ])
86 if test -z "$am_cv_prog_cc_stdc"; then
87 AC_MSG_RESULT([none needed])
88 else
89 AC_MSG_RESULT($am_cv_prog_cc_stdc)
90 fi
91 case "x$am_cv_prog_cc_stdc" in
92 x|xno) ;;
93 *) CC="$CC $am_cv_prog_cc_stdc" ;;
94 esac
95 ])
This page took 0.039002 seconds and 4 git commands to generate.