1 dnl The following are from prerelease autoconf 2.14a. When 2.14 is
2 dnl released, we should be able to zap them and just use AC_PREREQ(2.14).
7 # If the C compiler in not in ANSI C mode by default, try to add an
8 # option to output variable @code{CC} to make it so. This macro tries
9 # various options that select ANSI C on some system or another. It
10 # considers the compiler to be in ANSI C mode if it handles function
11 # prototypes correctly.
12 AC_DEFUN(AC_PROG_CC_STDC,
13 [AC_REQUIRE([AC_PROG_CC])dnl
14 AC_BEFORE([$0], [AC_C_INLINE])dnl
15 AC_BEFORE([$0], [AC_C_CONST])dnl
16 dnl Force this before AC_PROG_CPP. Some cpp's, eg on HPUX, require
17 dnl a magic option to avoid problems with ANSI preprocessor commands
19 dnl FIXME: can't do this because then AC_AIX won't work due to a
20 dnl circular dependency.
21 dnl AC_BEFORE([$0], [AC_PROG_CPP])
22 AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
23 AC_CACHE_VAL(ac_cv_prog_cc_stdc,
24 [ac_cv_prog_cc_stdc=no
26 # Don't try gcc -ansi; that turns off useful extensions and
27 # breaks some systems' header files.
29 # Ultrix and OSF/1 -std1
30 # HP-UX 10.20 and later -Ae
31 # HP-UX older versions -Aa -D_HPUX_SOURCE
32 # SVR4 -Xc -D__EXTENSIONS__
33 for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
35 CC="$ac_save_CC $ac_arg"
39 #include <sys/types.h>
41 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
42 struct buf { int x; };
43 FILE * (*rcsopen) (struct buf *, struct stat *, int);
50 static char *f (char * (*g) (char **, int), char **p, ...)
55 s = g (p, va_arg (v,int));
59 int test (int i, double x);
60 struct s1 {int (*f) (int a);};
61 struct s2 {int (*f) (double a);};
62 int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
65 [return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];],
66 [ac_cv_prog_cc_stdc="$ac_arg"; break])
70 case "x$ac_cv_prog_cc_stdc" in
72 AC_MSG_RESULT([none needed]) ;;
74 AC_MSG_RESULT($ac_cv_prog_cc_stdc)
75 CC="$CC $ac_cv_prog_cc_stdc" ;;
81 AC_DEFUN(AC_FUNC_MKTIME,
82 [AC_REQUIRE([AC_HEADER_TIME])dnl
83 AC_CHECK_HEADERS(sys/time.h unistd.h)
85 AC_CACHE_CHECK([for working mktime], ac_cv_func_working_mktime,
87 [/* Test program from Paul Eggert (eggert@twinsun.com)
88 and Tony Leneis (tony@plaza.ds.adp.com). */
89 #if TIME_WITH_SYS_TIME
90 # include <sys/time.h>
94 # include <sys/time.h>
105 # define alarm(X) /* empty */
108 /* Work around redefinition to rpl_putenv by other config tests. */
111 static time_t time_t_max;
113 /* Values we'll use to set the TZ environment variable. */
114 static const char *const tz_strings[] = {
115 (const char *) 0, "TZ=GMT0", "TZ=JST-9",
116 "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
118 #define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
120 /* Fail if mktime fails to convert a date in the spring-forward gap.
121 Based on a problem report from Andreas Jaeger. */
123 spring_forward_gap ()
125 /* glibc (up to about 1998-10-07) failed this test) */
128 /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
129 instead of "TZ=America/Vancouver" in order to detect the bug even
130 on systems that don't support the Olson extension, or don't have the
131 full zoneinfo tables installed. */
132 putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
141 if (mktime (&tm) == (time_t)-1)
150 if ((lt = localtime (&now)) && mktime (lt) != now)
152 now = time_t_max - now;
153 if ((lt = localtime (&now)) && mktime (lt) != now)
160 /* Based on code from Ariel Faigon. */
170 if (tm.tm_mon != 2 || tm.tm_mday != 31)
180 tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j;
182 if (now != (time_t) -1)
184 struct tm *lt = localtime (&now);
186 && lt->tm_year == tm.tm_year
187 && lt->tm_mon == tm.tm_mon
188 && lt->tm_mday == tm.tm_mday
189 && lt->tm_hour == tm.tm_hour
190 && lt->tm_min == tm.tm_min
191 && lt->tm_sec == tm.tm_sec
192 && lt->tm_yday == tm.tm_yday
193 && lt->tm_wday == tm.tm_wday
194 && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst)
195 == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst))))
206 /* This test makes some buggy mktime implementations loop.
207 Give up after 60 seconds; a mktime slower than that
208 isn't worth using anyway. */
211 for (time_t_max = 1; 0 < time_t_max; time_t_max *= 2)
214 delta = time_t_max / 997; /* a suitable prime number */
215 for (i = 0; i < N_STRINGS; i++)
218 putenv (tz_strings[i]);
220 for (t = 0; t <= time_t_max - delta; t += delta)
222 mktime_test ((time_t) 60 * 60);
223 mktime_test ((time_t) 60 * 60 * 24);
225 for (j = 1; 0 < j; j *= 2)
227 bigtime_test (j - 1);
230 spring_forward_gap ();
233 ac_cv_func_working_mktime=yes, ac_cv_func_working_mktime=no,
234 ac_cv_func_working_mktime=no)])
235 if test $ac_cv_func_working_mktime = no; then
236 LIBOBJS="$LIBOBJS mktime.${ac_objext}"
243 # Note that, unlike const, #defining volatile to be the empty string can
244 # actually turn a correct program into an incorrect one, since removing
245 # uses of volatile actually grants the compiler permission to perform
246 # optimizations that could break the user's code. So, do not #define
247 # volatile away unless it is really necessary to allow the user's code
248 # to compile cleanly. Benign compiler failures should be tolerated.
249 AC_DEFUN(AC_C_VOLATILE,
250 [AC_REQUIRE([AC_PROG_CC_STDC])dnl
251 AC_CACHE_CHECK([for working volatile], ac_cv_c_volatile,
255 ac_cv_c_volatile=yes, ac_cv_c_volatile=no)])
256 if test $ac_cv_c_volatile = no; then
258 [Define to empty if the keyword `volatile' does not work.
259 Warning: valid code using `volatile' can become incorrect
260 without. Disable with care.])
266 # Check if the C compiler supports prototypes, included if it needs
268 AC_DEFUN(AC_C_PROTOTYPES,
269 [AC_REQUIRE([AC_PROG_CC_STDC])dnl
270 AC_REQUIRE([AC_PROG_CPP])dnl
271 AC_MSG_CHECKING([for function prototypes])
272 if test "$ac_cv_prog_cc_stdc" != no; then
274 AC_DEFINE(PROTOTYPES, 1,
275 [Define if the compiler supports function prototypes.])