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.])
281 dnl The following isn't in the prerelease autoconf at this time, but
282 dnl eggert expects it to go in eventually.
284 dnl By default, many hosts won't let programs access large files;
285 dnl one must use special compiler options to get large-file access to work.
286 dnl For more details about this brain damage please see:
287 dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
289 dnl Written by Paul Eggert <eggert@twinsun.com>.
291 dnl Internal subroutine of AC_SYS_LARGEFILE.
292 dnl AC_SYS_LARGEFILE_TEST_INCLUDES
293 AC_DEFUN(AC_SYS_LARGEFILE_TEST_INCLUDES,
294 [[#include <sys/types.h>
295 int a[(off_t) 9223372036854775807 == 9223372036854775807 ? 1 : -1];
298 dnl Internal subroutine of AC_SYS_LARGEFILE.
299 dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR, COMMENT, INCLUDES, FUNCTION-BODY)
300 AC_DEFUN(AC_SYS_LARGEFILE_MACRO_VALUE,
301 [AC_CACHE_CHECK([for $1 value needed for large files], $3,
303 AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES
308 [AC_TRY_COMPILE([#define $1 $2]
309 AC_SYS_LARGEFILE_TEST_INCLUDES
314 if test "[$]$3" != no; then
315 AC_DEFINE_UNQUOTED([$1], [$]$3, [$4])
318 AC_DEFUN(AC_SYS_LARGEFILE,
319 [AC_ARG_ENABLE(largefile,
320 [ --disable-largefile omit support for large files])
321 if test "$enable_largefile" != no; then
323 AC_CACHE_CHECK([for special C compiler options needed for large files],
324 ac_cv_sys_largefile_CC,
325 [ac_cv_sys_largefile_CC=no
326 if test "$GCC" != yes; then
327 # IRIX 6.2 and later do not support large files by default,
328 # so use the C compiler's -n32 option if that helps.
329 AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, , ,
332 AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, ,
333 ac_cv_sys_largefile_CC=' -n32')
336 if test "$ac_cv_sys_largefile_CC" != no; then
337 CC="$CC$ac_cv_sys_largefile_CC"
340 AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64,
341 ac_cv_sys_file_offset_bits,
342 [Number of bits in a file offset, on hosts where this is settable.])
343 AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1,
344 ac_cv_sys_largefile_source,
345 [Define to make ftello visible on some hosts (e.g. HP-UX 10.20).],
346 [#include <stdio.h>], [return !ftello;])
347 AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1,
348 ac_cv_sys_large_files,
349 [Define for large files, on AIX-style hosts.])
350 AC_SYS_LARGEFILE_MACRO_VALUE(_XOPEN_SOURCE, 500,
351 ac_cv_sys_xopen_source,
352 [Define to make ftello visible on some hosts (e.g. glibc 2.1.3).],
353 [#include <stdio.h>], [return !ftello;])