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).
4 ifelse(_AC_VERSION_COMPARE(AC_ACVERSION, [2.14]), -1,
8 # If the C compiler in not in ANSI C mode by default, try to add an
9 # option to output variable @code{CC} to make it so. This macro tries
10 # various options that select ANSI C on some system or another. It
11 # considers the compiler to be in ANSI C mode if it handles function
12 # prototypes correctly.
13 AC_DEFUN(AC_PROG_CC_STDC,
14 [AC_REQUIRE([AC_PROG_CC])dnl
15 AC_BEFORE([$0], [AC_C_INLINE])dnl
16 AC_BEFORE([$0], [AC_C_CONST])dnl
17 dnl Force this before AC_PROG_CPP. Some cpp's, eg on HPUX, require
18 dnl a magic option to avoid problems with ANSI preprocessor commands
20 dnl FIXME: can't do this because then AC_AIX won't work due to a
21 dnl circular dependency.
22 dnl AC_BEFORE([$0], [AC_PROG_CPP])
23 AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
24 AC_CACHE_VAL(ac_cv_prog_cc_stdc,
25 [ac_cv_prog_cc_stdc=no
27 # Don't try gcc -ansi; that turns off useful extensions and
28 # breaks some systems' header files.
30 # Ultrix and OSF/1 -std1
31 # HP-UX 10.20 and later -Ae
32 # HP-UX older versions -Aa -D_HPUX_SOURCE
33 # SVR4 -Xc -D__EXTENSIONS__
34 for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
36 CC="$ac_save_CC $ac_arg"
40 #include <sys/types.h>
42 /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
43 struct buf { int x; };
44 FILE * (*rcsopen) (struct buf *, struct stat *, int);
51 static char *f (char * (*g) (char **, int), char **p, ...)
56 s = g (p, va_arg (v,int));
60 int test (int i, double x);
61 struct s1 {int (*f) (int a);};
62 struct s2 {int (*f) (double a);};
63 int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
66 [return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];],
67 [ac_cv_prog_cc_stdc="$ac_arg"; break])
71 case "x$ac_cv_prog_cc_stdc" in
73 AC_MSG_RESULT([none needed]) ;;
75 AC_MSG_RESULT($ac_cv_prog_cc_stdc)
76 CC="$CC $ac_cv_prog_cc_stdc" ;;
82 AC_DEFUN(AC_FUNC_MKTIME,
83 [AC_REQUIRE([AC_HEADER_TIME])dnl
84 AC_CHECK_HEADERS(sys/time.h unistd.h)
86 AC_CACHE_CHECK([for working mktime], ac_cv_func_working_mktime,
88 [/* Test program from Paul Eggert (eggert@twinsun.com)
89 and Tony Leneis (tony@plaza.ds.adp.com). */
90 #if TIME_WITH_SYS_TIME
91 # include <sys/time.h>
95 # include <sys/time.h>
106 # define alarm(X) /* empty */
109 /* Work around redefinition to rpl_putenv by other config tests. */
112 static time_t time_t_max;
114 /* Values we'll use to set the TZ environment variable. */
115 static const char *const tz_strings[] = {
116 (const char *) 0, "TZ=GMT0", "TZ=JST-9",
117 "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
119 #define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
121 /* Fail if mktime fails to convert a date in the spring-forward gap.
122 Based on a problem report from Andreas Jaeger. */
124 spring_forward_gap ()
126 /* glibc (up to about 1998-10-07) failed this test) */
129 /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
130 instead of "TZ=America/Vancouver" in order to detect the bug even
131 on systems that don't support the Olson extension, or don't have the
132 full zoneinfo tables installed. */
133 putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
142 if (mktime (&tm) == (time_t)-1)
151 if ((lt = localtime (&now)) && mktime (lt) != now)
153 now = time_t_max - now;
154 if ((lt = localtime (&now)) && mktime (lt) != now)
161 /* Based on code from Ariel Faigon. */
171 if (tm.tm_mon != 2 || tm.tm_mday != 31)
181 tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j;
183 if (now != (time_t) -1)
185 struct tm *lt = localtime (&now);
187 && lt->tm_year == tm.tm_year
188 && lt->tm_mon == tm.tm_mon
189 && lt->tm_mday == tm.tm_mday
190 && lt->tm_hour == tm.tm_hour
191 && lt->tm_min == tm.tm_min
192 && lt->tm_sec == tm.tm_sec
193 && lt->tm_yday == tm.tm_yday
194 && lt->tm_wday == tm.tm_wday
195 && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst)
196 == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst))))
207 /* This test makes some buggy mktime implementations loop.
208 Give up after 60 seconds; a mktime slower than that
209 isn't worth using anyway. */
212 for (time_t_max = 1; 0 < time_t_max; time_t_max *= 2)
215 delta = time_t_max / 997; /* a suitable prime number */
216 for (i = 0; i < N_STRINGS; i++)
219 putenv (tz_strings[i]);
221 for (t = 0; t <= time_t_max - delta; t += delta)
223 mktime_test ((time_t) 60 * 60);
224 mktime_test ((time_t) 60 * 60 * 24);
226 for (j = 1; 0 < j; j *= 2)
228 bigtime_test (j - 1);
231 spring_forward_gap ();
234 ac_cv_func_working_mktime=yes, ac_cv_func_working_mktime=no,
235 ac_cv_func_working_mktime=no)])
236 if test $ac_cv_func_working_mktime = no; then
237 LIBOBJS="$LIBOBJS mktime.${ac_objext}"
244 # Note that, unlike const, #defining volatile to be the empty string can
245 # actually turn a correct program into an incorrect one, since removing
246 # uses of volatile actually grants the compiler permission to perform
247 # optimizations that could break the user's code. So, do not #define
248 # volatile away unless it is really necessary to allow the user's code
249 # to compile cleanly. Benign compiler failures should be tolerated.
250 AC_DEFUN(AC_C_VOLATILE,
251 [AC_REQUIRE([AC_PROG_CC_STDC])dnl
252 AC_CACHE_CHECK([for working volatile], ac_cv_c_volatile,
256 ac_cv_c_volatile=yes, ac_cv_c_volatile=no)])
257 if test $ac_cv_c_volatile = no; then
259 [Define to empty if the keyword `volatile' does not work.
260 Warning: valid code using `volatile' can become incorrect
261 without. Disable with care.])
267 # Check if the C compiler supports prototypes, included if it needs
269 AC_DEFUN(AC_C_PROTOTYPES,
270 [AC_REQUIRE([AC_PROG_CC_STDC])dnl
271 AC_REQUIRE([AC_PROG_CPP])dnl
272 AC_MSG_CHECKING([for function prototypes])
273 if test "$ac_cv_prog_cc_stdc" != no; then
275 AC_DEFINE(PROTOTYPES, 1,
276 [Define if the compiler supports function prototypes.])
282 dnl The following is a bit different from the prerelease autoconf at
283 dnl this time since that requires extra definitions.
285 dnl By default, many hosts won't let programs access large files;
286 dnl one must use special compiler options to get large-file access to work.
287 dnl For more details about this brain damage please see:
288 dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
290 dnl Written by Paul Eggert <eggert@twinsun.com>.
292 dnl Internal subroutine of AC_SYS_LARGEFILE.
293 dnl AC_SYS_LARGEFILE_TEST_INCLUDES
294 AC_DEFUN(AC_SYS_LARGEFILE_TEST_INCLUDES,
295 [[#include <sys/types.h>
296 int a[(off_t) 9223372036854775807 == 9223372036854775807 ? 1 : -1];
299 dnl Internal subroutine of AC_SYS_LARGEFILE.
300 dnl AC_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR, COMMENT, INCLUDES, FUNCTION-BODY)
301 AC_DEFUN(AC_SYS_LARGEFILE_MACRO_VALUE,
302 [AC_CACHE_CHECK([for $1 value needed for large files], $3,
304 AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES
309 [AC_TRY_COMPILE([#define $1 $2]
310 AC_SYS_LARGEFILE_TEST_INCLUDES
315 if test "[$]$3" != no; then
316 AC_DEFINE_UNQUOTED([$1], [$]$3, [$4])
319 AC_DEFUN(AC_SYS_LARGEFILE,
320 [AC_ARG_ENABLE(largefile,
321 [ --disable-largefile omit support for large files])
322 if test "$enable_largefile" != no; then
324 AC_CACHE_CHECK([for special C compiler options needed for large files],
325 ac_cv_sys_largefile_CC,
326 [ac_cv_sys_largefile_CC=no
327 if test "$GCC" != yes; then
328 # IRIX 6.2 and later do not support large files by default,
329 # so use the C compiler's -n32 option if that helps.
330 AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, , ,
333 AC_TRY_COMPILE(AC_SYS_LARGEFILE_TEST_INCLUDES, ,
334 ac_cv_sys_largefile_CC=' -n32')
337 if test "$ac_cv_sys_largefile_CC" != no; then
338 CC="$CC$ac_cv_sys_largefile_CC"
341 AC_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64,
342 ac_cv_sys_file_offset_bits,
343 [Number of bits in a file offset, on hosts where this is settable.])
344 AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1,
345 ac_cv_sys_largefile_source,
346 [Define to make ftello visible on some hosts (e.g. HP-UX 10.20).],
347 [#include <stdio.h>], [return !ftello;])
348 AC_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1,
349 ac_cv_sys_large_files,
350 [Define for large files, on AIX-style hosts.])
351 AC_SYS_LARGEFILE_MACRO_VALUE(_XOPEN_SOURCE, 500,
352 ac_cv_sys_xopen_source,
353 [Define to make ftello visible on some hosts (e.g. glibc 2.1.3).],
354 [#include <stdio.h>], [return !ftello;])
358 undefine([AC_FUNC_MMAP])dnl
359 dnl The autoconf 2.13 version loses on OSF, at least,
360 dnl by messing up the declaration of malloc.
361 AC_DEFUN([AC_FUNC_MMAP],
362 [AC_CHECK_HEADERS(stdlib.h unistd.h sys/stat.h)
363 AC_CHECK_FUNCS(getpagesize)
364 AC_CACHE_CHECK(for working mmap, ac_cv_func_mmap_fixed_mapped,
366 [/* Thanks to Mike Haertel and Jim Avera for this test.
367 Here is a matrix of mmap possibilities:
368 mmap private not fixed
369 mmap private fixed at somewhere currently unmapped
370 mmap private fixed at somewhere already mapped
371 mmap shared not fixed
372 mmap shared fixed at somewhere currently unmapped
373 mmap shared fixed at somewhere already mapped
374 For private mappings, we should verify that changes cannot be read()
375 back from the file, nor mmap's back from the file at a different
376 address. (There have been systems where private was not correctly
377 implemented like the infamous i386 svr4.0, and systems where the
378 VM page cache was not coherent with the file system buffer cache
379 like early versions of FreeBSD and possibly contemporary NetBSD.)
380 For shared mappings, we should conversely verify that changes get
381 propogated back to all the places they're supposed to be.
383 Grep wants private fixed already mapped.
384 The main things grep needs to know about mmap are:
385 * does it exist and is it safe to write into the mmap'd area
386 * how to use it (BSD variants) */
387 #include <sys/types.h>
389 #include <sys/mman.h>
391 #if STDC_HEADERS || HAVE_STDLIB_H
400 # include <sys/stat.h>
403 /* This mess was copied from the GNU getpagesize.h. */
404 #if !HAVE_GETPAGESIZE
405 /* Assume that all systems that can run configure have sys/param.h. */
406 # if !HAVE_SYS_PARAM_H
407 # define HAVE_SYS_PARAM_H 1
411 # define getpagesize() sysconf(_SC_PAGESIZE)
412 # else /* no _SC_PAGESIZE */
413 # if HAVE_SYS_PARAM_H
414 # include <sys/param.h>
415 # ifdef EXEC_PAGESIZE
416 # define getpagesize() EXEC_PAGESIZE
417 # else /* no EXEC_PAGESIZE */
419 # define getpagesize() NBPG * CLSIZE
422 # endif /* no CLSIZE */
425 # define getpagesize() NBPC
428 # define getpagesize() PAGESIZE
429 # endif /* PAGESIZE */
430 # endif /* no NBPC */
431 # endif /* no NBPG */
432 # endif /* no EXEC_PAGESIZE */
433 # else /* no HAVE_SYS_PARAM_H */
434 # define getpagesize() 8192 /* punt totally */
435 # endif /* no HAVE_SYS_PARAM_H */
436 # endif /* no _SC_PAGESIZE */
438 #endif /* no HAVE_GETPAGESIZE */
443 char *data, *data2, *data3;
447 pagesize = getpagesize ();
449 /* First, make a file with some known garbage in it. */
450 data = (char *) malloc (pagesize);
453 for (i = 0; i < pagesize; ++i)
454 *(data + i) = rand ();
456 fd = creat ("conftestmmap", 0600);
459 if (write (fd, data, pagesize) != pagesize)
463 /* Next, try to mmap the file at a fixed address which already has
464 something else allocated at it. If we can, also make sure that
465 we see the same garbage. */
466 fd = open ("conftestmmap", O_RDWR);
469 data2 = (char *) malloc (2 * pagesize);
472 data2 += (pagesize - ((int) data2 & (pagesize - 1))) & (pagesize - 1);
473 if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE,
474 MAP_PRIVATE | MAP_FIXED, fd, 0L))
476 for (i = 0; i < pagesize; ++i)
477 if (*(data + i) != *(data2 + i))
480 /* Finally, make sure that changes to the mapped area do not
481 percolate back to the file as seen by read(). (This is a bug on
482 some variants of i386 svr4.0.) */
483 for (i = 0; i < pagesize; ++i)
484 *(data2 + i) = *(data2 + i) + 1;
485 data3 = (char *) malloc (pagesize);
488 if (read (fd, data3, pagesize) != pagesize)
490 for (i = 0; i < pagesize; ++i)
491 if (*(data + i) != *(data3 + i))
494 unlink ("conftestmmap");
496 }], ac_cv_func_mmap_fixed_mapped=yes, ac_cv_func_mmap_fixed_mapped=no,
497 ac_cv_func_mmap_fixed_mapped=no)])
498 if test $ac_cv_func_mmap_fixed_mapped = yes; then
499 AC_DEFINE(HAVE_MMAP, 1,
500 [Define if you have a working `mmap' system call.])