]> git.saurik.com Git - wxWidgets.git/blob - build/autoconf_prepend-include/autoconf/functions.m4
No changes, just sort richtext files in files.bkl.
[wxWidgets.git] / build / autoconf_prepend-include / autoconf / functions.m4
1 # This file is part of Autoconf. -*- Autoconf -*-
2 # Checking for functions.
3 # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software
4 # Foundation, Inc.
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2, or (at your option)
9 # any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 # 02110-1301, USA.
20 #
21 # As a special exception, the Free Software Foundation gives unlimited
22 # permission to copy, distribute and modify the configure scripts that
23 # are the output of Autoconf. You need not follow the terms of the GNU
24 # General Public License when using or distributing such scripts, even
25 # though portions of the text of Autoconf appear in them. The GNU
26 # General Public License (GPL) does govern all other use of the material
27 # that constitutes the Autoconf program.
28 #
29 # Certain portions of the Autoconf source text are designed to be copied
30 # (in certain cases, depending on the input) into the output of
31 # Autoconf. We call these the "data" portions. The rest of the Autoconf
32 # source text consists of comments plus executable code that decides which
33 # of the data portions to output in any given case. We call these
34 # comments and executable code the "non-data" portions. Autoconf never
35 # copies any of the non-data portions into its output.
36 #
37 # This special exception to the GPL applies to versions of Autoconf
38 # released by the Free Software Foundation. When you make and
39 # distribute a modified version of Autoconf, you may extend this special
40 # exception to the GPL to apply to your modified version as well, *unless*
41 # your modified version has the potential to copy into its output some
42 # of the text that was the non-data portion of the version that you started
43 # with. (In other words, unless your change moves or copies text from
44 # the non-data portions to the data portions.) If your modification has
45 # such potential, you must delete any notice of this special exception
46 # to the GPL from your modified version.
47 #
48 # Written by David MacKenzie, with help from
49 # Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
50 # Roland McGrath, Noah Friedman, david d zuhn, and many others.
51
52
53 # Table of contents
54 #
55 # 1. Generic tests for functions.
56 # 2. Functions to check with AC_CHECK_FUNCS
57 # 3. Tests for specific functions.
58
59
60 ## -------------------------------- ##
61 ## 1. Generic tests for functions. ##
62 ## -------------------------------- ##
63
64
65 # AC_CHECK_FUNC(FUNCTION, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
66 # -----------------------------------------------------------------
67 AC_DEFUN([AC_CHECK_FUNC],
68 [AS_VAR_PUSHDEF([ac_var], [ac_cv_func_$1])dnl
69 AC_CACHE_CHECK([for $1], [ac_var],
70 [AC_LINK_IFELSE([AC_LANG_FUNC_LINK_TRY([$1])],
71 [AS_VAR_SET([ac_var], [yes])],
72 [AS_VAR_SET([ac_var], [no])])])
73 AS_IF([test AS_VAR_GET([ac_var]) = yes], [$2], [$3])dnl
74 AS_VAR_POPDEF([ac_var])dnl
75 ])# AC_CHECK_FUNC
76
77
78 # _AH_CHECK_FUNCS(FUNCTION...)
79 # ----------------------------
80 m4_define([_AH_CHECK_FUNCS],
81 [m4_foreach_w([AC_Func], [$1],
82 [AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([AC_Func])),
83 [Define to 1 if you have the `]m4_defn([AC_Func])[' function.])])])
84
85
86 # AC_CHECK_FUNCS(FUNCTION..., [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
87 # ---------------------------------------------------------------------
88 AC_DEFUN([AC_CHECK_FUNCS],
89 [_AH_CHECK_FUNCS([$1])dnl
90 for ac_func in $1
91 do
92 AC_CHECK_FUNC($ac_func,
93 [AC_DEFINE_UNQUOTED([AS_TR_CPP([HAVE_$ac_func])]) $2],
94 [$3])dnl
95 done
96 ])
97
98
99 # AC_CHECK_FUNCS_ONCE(FUNCTION...)
100 # --------------------------------
101 AC_DEFUN([AC_CHECK_FUNCS_ONCE],
102 [
103 _AH_CHECK_FUNCS([$1])
104 m4_foreach_w([AC_Func], [$1],
105 [AC_DEFUN([_AC_Func_]m4_defn([AC_Func]),
106 [m4_divert_text([INIT_PREPARE],
107 [ac_func_list="$ac_func_list AC_Func"])
108 _AC_FUNCS_EXPANSION])
109 AC_REQUIRE([_AC_Func_]m4_defn([AC_Func]))])
110 ])
111 m4_define([_AC_FUNCS_EXPANSION],
112 [
113 m4_divert_text([DEFAULTS], [ac_func_list=])
114 AC_CHECK_FUNCS([$ac_func_list])
115 m4_define([_AC_FUNCS_EXPANSION], [])
116 ])
117
118
119 # AC_REPLACE_FUNCS(FUNCTION...)
120 # -----------------------------
121 AC_DEFUN([AC_REPLACE_FUNCS],
122 [m4_foreach_w([AC_Func], [$1], [AC_LIBSOURCE(AC_Func.c)])dnl
123 AC_CHECK_FUNCS([$1], , [_AC_LIBOBJ($ac_func)])
124 ])
125
126
127 # AC_TRY_LINK_FUNC(FUNC, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
128 # ------------------------------------------------------------
129 # Try to link a program that calls FUNC, handling GCC builtins. If
130 # the link succeeds, execute ACTION-IF-FOUND; otherwise, execute
131 # ACTION-IF-NOT-FOUND.
132 AC_DEFUN([AC_TRY_LINK_FUNC],
133 [AC_LINK_IFELSE([AC_LANG_CALL([], [$1])], [$2], [$3])])
134
135
136 # AU::AC_FUNC_CHECK
137 # -----------------
138 AU_ALIAS([AC_FUNC_CHECK], [AC_CHECK_FUNC])
139
140
141 # AU::AC_HAVE_FUNCS
142 # -----------------
143 AU_ALIAS([AC_HAVE_FUNCS], [AC_CHECK_FUNCS])
144
145
146
147
148 ## ------------------------------------------- ##
149 ## 2. Functions to check with AC_CHECK_FUNCS. ##
150 ## ------------------------------------------- ##
151
152 AN_FUNCTION([__argz_count], [AC_CHECK_FUNCS])
153 AN_FUNCTION([__argz_next], [AC_CHECK_FUNCS])
154 AN_FUNCTION([__argz_stringify], [AC_CHECK_FUNCS])
155 AN_FUNCTION([__fpending], [AC_CHECK_FUNCS])
156 AN_FUNCTION([acl], [AC_CHECK_FUNCS])
157 AN_FUNCTION([alarm], [AC_CHECK_FUNCS])
158 AN_FUNCTION([atexit], [AC_CHECK_FUNCS])
159 AN_FUNCTION([btowc], [AC_CHECK_FUNCS])
160 AN_FUNCTION([bzero], [AC_CHECK_FUNCS])
161 AN_FUNCTION([clock_gettime], [AC_CHECK_FUNCS])
162 AN_FUNCTION([doprnt], [AC_CHECK_FUNCS])
163 AN_FUNCTION([dup2], [AC_CHECK_FUNCS])
164 AN_FUNCTION([endgrent], [AC_CHECK_FUNCS])
165 AN_FUNCTION([endpwent], [AC_CHECK_FUNCS])
166 AN_FUNCTION([euidaccess], [AC_CHECK_FUNCS])
167 AN_FUNCTION([fchdir], [AC_CHECK_FUNCS])
168 AN_FUNCTION([fdatasync], [AC_CHECK_FUNCS])
169 AN_FUNCTION([fesetround], [AC_CHECK_FUNCS])
170 AN_FUNCTION([floor], [AC_CHECK_FUNCS])
171 AN_FUNCTION([fs_stat_dev], [AC_CHECK_FUNCS])
172 AN_FUNCTION([ftime], [AC_CHECK_FUNCS])
173 AN_FUNCTION([ftruncate], [AC_CHECK_FUNCS])
174 AN_FUNCTION([getcwd], [AC_CHECK_FUNCS])
175 AN_FUNCTION([getdelim], [AC_CHECK_FUNCS])
176 AN_FUNCTION([gethostbyaddr], [AC_CHECK_FUNCS])
177 AN_FUNCTION([gethostbyname], [AC_CHECK_FUNCS])
178 AN_FUNCTION([gethostname], [AC_CHECK_FUNCS])
179 AN_FUNCTION([gethrtime], [AC_CHECK_FUNCS])
180 AN_FUNCTION([getmntent], [AC_CHECK_FUNCS])
181 AN_FUNCTION([getmntinfo], [AC_CHECK_FUNCS])
182 AN_FUNCTION([getpagesize], [AC_CHECK_FUNCS])
183 AN_FUNCTION([getpass], [AC_CHECK_FUNCS])
184 AN_FUNCTION([getspnam], [AC_CHECK_FUNCS])
185 AN_FUNCTION([gettimeofday], [AC_CHECK_FUNCS])
186 AN_FUNCTION([getusershell], [AC_CHECK_FUNCS])
187 AN_FUNCTION([hasmntopt], [AC_CHECK_FUNCS])
188 AN_FUNCTION([inet_ntoa], [AC_CHECK_FUNCS])
189 AN_FUNCTION([isascii], [AC_CHECK_FUNCS])
190 AN_FUNCTION([iswprint], [AC_CHECK_FUNCS])
191 AN_FUNCTION([lchown], [AC_CHECK_FUNCS])
192 AN_FUNCTION([listmntent], [AC_CHECK_FUNCS])
193 AN_FUNCTION([localeconv], [AC_CHECK_FUNCS])
194 AN_FUNCTION([localtime_r], [AC_CHECK_FUNCS])
195 AN_FUNCTION([mblen], [AC_CHECK_FUNCS])
196 AN_FUNCTION([mbrlen], [AC_CHECK_FUNCS])
197 AN_FUNCTION([memchr], [AC_CHECK_FUNCS])
198 AN_FUNCTION([memmove], [AC_CHECK_FUNCS])
199 AN_FUNCTION([mempcpy], [AC_CHECK_FUNCS])
200 AN_FUNCTION([memset], [AC_CHECK_FUNCS])
201 AN_FUNCTION([mkdir], [AC_CHECK_FUNCS])
202 AN_FUNCTION([mkfifo], [AC_CHECK_FUNCS])
203 AN_FUNCTION([modf], [AC_CHECK_FUNCS])
204 AN_FUNCTION([munmap], [AC_CHECK_FUNCS])
205 AN_FUNCTION([next_dev], [AC_CHECK_FUNCS])
206 AN_FUNCTION([nl_langinfo], [AC_CHECK_FUNCS])
207 AN_FUNCTION([pathconf], [AC_CHECK_FUNCS])
208 AN_FUNCTION([pow], [AC_CHECK_FUNCS])
209 AN_FUNCTION([pstat_getdynamic], [AC_CHECK_FUNCS])
210 AN_FUNCTION([putenv], [AC_CHECK_FUNCS])
211 AN_FUNCTION([re_comp], [AC_CHECK_FUNCS])
212 AN_FUNCTION([realpath], [AC_CHECK_FUNCS])
213 AN_FUNCTION([regcmp], [AC_CHECK_FUNCS])
214 AN_FUNCTION([regcomp], [AC_CHECK_FUNCS])
215 AN_FUNCTION([resolvepath], [AC_CHECK_FUNCS])
216 AN_FUNCTION([rint], [AC_CHECK_FUNCS])
217 AN_FUNCTION([rmdir], [AC_CHECK_FUNCS])
218 AN_FUNCTION([rpmatch], [AC_CHECK_FUNCS])
219 AN_FUNCTION([select], [AC_CHECK_FUNCS])
220 AN_FUNCTION([setenv], [AC_CHECK_FUNCS])
221 AN_FUNCTION([sethostname], [AC_CHECK_FUNCS])
222 AN_FUNCTION([setlocale], [AC_CHECK_FUNCS])
223 AN_FUNCTION([socket], [AC_CHECK_FUNCS])
224 AN_FUNCTION([sqrt], [AC_CHECK_FUNCS])
225 AN_FUNCTION([stime], [AC_CHECK_FUNCS])
226 AN_FUNCTION([stpcpy], [AC_CHECK_FUNCS])
227 AN_FUNCTION([strcasecmp], [AC_CHECK_FUNCS])
228 AN_FUNCTION([strchr], [AC_CHECK_FUNCS])
229 AN_FUNCTION([strcspn], [AC_CHECK_FUNCS])
230 AN_FUNCTION([strdup], [AC_CHECK_FUNCS])
231 AN_FUNCTION([strerror], [AC_CHECK_FUNCS])
232 AN_FUNCTION([strncasecmp], [AC_CHECK_FUNCS])
233 AN_FUNCTION([strndup], [AC_CHECK_FUNCS])
234 AN_FUNCTION([strpbrk], [AC_CHECK_FUNCS])
235 AN_FUNCTION([strrchr], [AC_CHECK_FUNCS])
236 AN_FUNCTION([strspn], [AC_CHECK_FUNCS])
237 AN_FUNCTION([strstr], [AC_CHECK_FUNCS])
238 AN_FUNCTION([strtol], [AC_CHECK_FUNCS])
239 AN_FUNCTION([strtoul], [AC_CHECK_FUNCS])
240 AN_FUNCTION([strtoull], [AC_CHECK_FUNCS])
241 AN_FUNCTION([strtoumax], [AC_CHECK_FUNCS])
242 AN_FUNCTION([strverscmp], [AC_CHECK_FUNCS])
243 AN_FUNCTION([sysinfo], [AC_CHECK_FUNCS])
244 AN_FUNCTION([tzset], [AC_CHECK_FUNCS])
245 AN_FUNCTION([uname], [AC_CHECK_FUNCS])
246 AN_FUNCTION([utime], [AC_CHECK_FUNCS])
247 AN_FUNCTION([utmpname], [AC_CHECK_FUNCS])
248 AN_FUNCTION([utmpxname], [AC_CHECK_FUNCS])
249 AN_FUNCTION([wcwidth], [AC_CHECK_FUNCS])
250
251
252 AN_FUNCTION([dcgettext], [AM_GNU_GETTEXT])
253 AN_FUNCTION([getwd], [warn: getwd is deprecated, use getcwd instead])
254
255
256 ## --------------------------------- ##
257 ## 3. Tests for specific functions. ##
258 ## --------------------------------- ##
259
260
261 # The macros are sorted:
262 #
263 # 1. AC_FUNC_* macros are sorted by alphabetical order.
264 #
265 # 2. Helping macros such as _AC_LIBOBJ_* are before the macro that
266 # uses it.
267 #
268 # 3. Obsolete macros are right after the modern macro.
269
270
271
272 # _AC_LIBOBJ_ALLOCA
273 # -----------------
274 # Set up the LIBOBJ replacement of `alloca'. Well, not exactly
275 # AC_LIBOBJ since we actually set the output variable `ALLOCA'.
276 # Nevertheless, for Automake, AC_LIBSOURCES it.
277 m4_define([_AC_LIBOBJ_ALLOCA],
278 [# The SVR3 libPW and SVR4 libucb both contain incompatible functions
279 # that cause trouble. Some versions do not even contain alloca or
280 # contain a buggy version. If you still want to use their alloca,
281 # use ar to extract alloca.o from them instead of compiling alloca.c.
282 AC_LIBSOURCES(alloca.c)
283 AC_SUBST([ALLOCA], [\${LIBOBJDIR}alloca.$ac_objext])dnl
284 AC_DEFINE(C_ALLOCA, 1, [Define to 1 if using `alloca.c'.])
285
286 AC_CACHE_CHECK(whether `alloca.c' needs Cray hooks, ac_cv_os_cray,
287 [AC_EGREP_CPP(webecray,
288 [#if defined CRAY && ! defined CRAY2
289 webecray
290 #else
291 wenotbecray
292 #endif
293 ], ac_cv_os_cray=yes, ac_cv_os_cray=no)])
294 if test $ac_cv_os_cray = yes; then
295 for ac_func in _getb67 GETB67 getb67; do
296 AC_CHECK_FUNC($ac_func,
297 [AC_DEFINE_UNQUOTED(CRAY_STACKSEG_END, $ac_func,
298 [Define to one of `_getb67', `GETB67',
299 `getb67' for Cray-2 and Cray-YMP
300 systems. This function is required for
301 `alloca.c' support on those systems.])
302 break])
303 done
304 fi
305
306 AC_CACHE_CHECK([stack direction for C alloca],
307 [ac_cv_c_stack_direction],
308 [AC_RUN_IFELSE([AC_LANG_SOURCE(
309 [AC_INCLUDES_DEFAULT
310 int
311 find_stack_direction ()
312 {
313 static char *addr = 0;
314 auto char dummy;
315 if (addr == 0)
316 {
317 addr = &dummy;
318 return find_stack_direction ();
319 }
320 else
321 return (&dummy > addr) ? 1 : -1;
322 }
323
324 int
325 main ()
326 {
327 return find_stack_direction () < 0;
328 }])],
329 [ac_cv_c_stack_direction=1],
330 [ac_cv_c_stack_direction=-1],
331 [ac_cv_c_stack_direction=0])])
332 AH_VERBATIM([STACK_DIRECTION],
333 [/* If using the C implementation of alloca, define if you know the
334 direction of stack growth for your system; otherwise it will be
335 automatically deduced at runtime.
336 STACK_DIRECTION > 0 => grows toward higher addresses
337 STACK_DIRECTION < 0 => grows toward lower addresses
338 STACK_DIRECTION = 0 => direction of growth unknown */
339 @%:@undef STACK_DIRECTION])dnl
340 AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction)
341 ])# _AC_LIBOBJ_ALLOCA
342
343
344 # AC_FUNC_ALLOCA
345 # --------------
346 AN_FUNCTION([alloca], [AC_FUNC_ALLOCA])
347 AN_HEADER([alloca.h], [AC_FUNC_ALLOCA])
348 AC_DEFUN([AC_FUNC_ALLOCA],
349 [# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works
350 # for constant arguments. Useless!
351 AC_CACHE_CHECK([for working alloca.h], ac_cv_working_alloca_h,
352 [AC_LINK_IFELSE(
353 [AC_LANG_PROGRAM([[@%:@include <alloca.h>]],
354 [[char *p = (char *) alloca (2 * sizeof (int));
355 if (p) return 0;]])],
356 [ac_cv_working_alloca_h=yes],
357 [ac_cv_working_alloca_h=no])])
358 if test $ac_cv_working_alloca_h = yes; then
359 AC_DEFINE(HAVE_ALLOCA_H, 1,
360 [Define to 1 if you have <alloca.h> and it should be used
361 (not on Ultrix).])
362 fi
363
364 AC_CACHE_CHECK([for alloca], ac_cv_func_alloca_works,
365 [AC_LINK_IFELSE([AC_LANG_PROGRAM(
366 [[#ifdef __GNUC__
367 # define alloca __builtin_alloca
368 #else
369 # ifdef _MSC_VER
370 # include <malloc.h>
371 # define alloca _alloca
372 # else
373 # ifdef HAVE_ALLOCA_H
374 # include <alloca.h>
375 # else
376 # ifdef _AIX
377 #pragma alloca
378 # else
379 # ifndef alloca /* predefined by HP cc +Olibcalls */
380 char *alloca ();
381 # endif
382 # endif
383 # endif
384 # endif
385 #endif
386 ]], [[char *p = (char *) alloca (1);
387 if (p) return 0;]])],
388 [ac_cv_func_alloca_works=yes],
389 [ac_cv_func_alloca_works=no])])
390
391 if test $ac_cv_func_alloca_works = yes; then
392 AC_DEFINE(HAVE_ALLOCA, 1,
393 [Define to 1 if you have `alloca', as a function or macro.])
394 else
395 _AC_LIBOBJ_ALLOCA
396 fi
397 ])# AC_FUNC_ALLOCA
398
399
400 # AU::AC_ALLOCA
401 # -------------
402 AU_ALIAS([AC_ALLOCA], [AC_FUNC_ALLOCA])
403
404
405 # AC_FUNC_CHOWN
406 # -------------
407 # Determine whether chown accepts arguments of -1 for uid and gid.
408 AN_FUNCTION([chown], [AC_FUNC_CHOWN])
409 AC_DEFUN([AC_FUNC_CHOWN],
410 [AC_REQUIRE([AC_TYPE_UID_T])dnl
411 AC_CHECK_HEADERS(unistd.h)
412 AC_CACHE_CHECK([for working chown], ac_cv_func_chown_works,
413 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
414 #include <fcntl.h>
415 ],
416 [[ char *f = "conftest.chown";
417 struct stat before, after;
418
419 if (creat (f, 0600) < 0)
420 return 1;
421 if (stat (f, &before) < 0)
422 return 1;
423 if (chown (f, (uid_t) -1, (gid_t) -1) == -1)
424 return 1;
425 if (stat (f, &after) < 0)
426 return 1;
427 return ! (before.st_uid == after.st_uid && before.st_gid == after.st_gid);
428 ]])],
429 [ac_cv_func_chown_works=yes],
430 [ac_cv_func_chown_works=no],
431 [ac_cv_func_chown_works=no])
432 rm -f conftest.chown
433 ])
434 if test $ac_cv_func_chown_works = yes; then
435 AC_DEFINE(HAVE_CHOWN, 1,
436 [Define to 1 if your system has a working `chown' function.])
437 fi
438 ])# AC_FUNC_CHOWN
439
440
441 # AC_FUNC_CLOSEDIR_VOID
442 # ---------------------
443 # Check whether closedir returns void, and #define CLOSEDIR_VOID in
444 # that case.
445 AN_FUNCTION([closedir], [AC_FUNC_CLOSEDIR_VOID])
446 AC_DEFUN([AC_FUNC_CLOSEDIR_VOID],
447 [AC_REQUIRE([AC_HEADER_DIRENT])dnl
448 AC_CACHE_CHECK([whether closedir returns void],
449 [ac_cv_func_closedir_void],
450 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
451 #include <$ac_header_dirent>
452 #ifndef __cplusplus
453 int closedir ();
454 #endif
455 ],
456 [[return closedir (opendir (".")) != 0;]])],
457 [ac_cv_func_closedir_void=no],
458 [ac_cv_func_closedir_void=yes],
459 [ac_cv_func_closedir_void=yes])])
460 if test $ac_cv_func_closedir_void = yes; then
461 AC_DEFINE(CLOSEDIR_VOID, 1,
462 [Define to 1 if the `closedir' function returns void instead
463 of `int'.])
464 fi
465 ])
466
467
468 # AC_FUNC_ERROR_AT_LINE
469 # ---------------------
470 AN_FUNCTION([error], [AC_FUNC_ERROR_AT_LINE])
471 AN_FUNCTION([error_at_line], [AC_FUNC_ERROR_AT_LINE])
472 AC_DEFUN([AC_FUNC_ERROR_AT_LINE],
473 [AC_LIBSOURCES([error.h, error.c])dnl
474 AC_CACHE_CHECK([for error_at_line], ac_cv_lib_error_at_line,
475 [AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <error.h>],
476 [error_at_line (0, 0, "", 0, "an error occurred");])],
477 [ac_cv_lib_error_at_line=yes],
478 [ac_cv_lib_error_at_line=no])])
479 if test $ac_cv_lib_error_at_line = no; then
480 AC_LIBOBJ(error)
481 fi
482 ])
483
484
485 # AU::AM_FUNC_ERROR_AT_LINE
486 # -------------------------
487 AU_ALIAS([AM_FUNC_ERROR_AT_LINE], [AC_FUNC_ERROR_AT_LINE])
488
489
490 # _AC_FUNC_FNMATCH_IF(STANDARD = GNU | POSIX, CACHE_VAR, IF-TRUE, IF-FALSE)
491 # -------------------------------------------------------------------------
492 # If a STANDARD compliant fnmatch is found, run IF-TRUE, otherwise
493 # IF-FALSE. Use CACHE_VAR.
494 AC_DEFUN([_AC_FUNC_FNMATCH_IF],
495 [AC_CACHE_CHECK(
496 [for working $1 fnmatch],
497 [$2],
498 [# Some versions of Solaris, SCO, and the GNU C Library
499 # have a broken or incompatible fnmatch.
500 # So we run a test program. If we are cross-compiling, take no chance.
501 # Thanks to John Oleynick, Franc,ois Pinard, and Paul Eggert for this test.
502 AC_RUN_IFELSE(
503 [AC_LANG_PROGRAM(
504 [#include <fnmatch.h>
505 # define y(a, b, c) (fnmatch (a, b, c) == 0)
506 # define n(a, b, c) (fnmatch (a, b, c) == FNM_NOMATCH)
507 ],
508 [return
509 (!(y ("a*", "abc", 0)
510 && n ("d*/*1", "d/s/1", FNM_PATHNAME)
511 && y ("a\\\\bc", "abc", 0)
512 && n ("a\\\\bc", "abc", FNM_NOESCAPE)
513 && y ("*x", ".x", 0)
514 && n ("*x", ".x", FNM_PERIOD)
515 && m4_if([$1], [GNU],
516 [y ("xxXX", "xXxX", FNM_CASEFOLD)
517 && y ("a++(x|yy)b", "a+xyyyyxb", FNM_EXTMATCH)
518 && n ("d*/*1", "d/s/1", FNM_FILE_NAME)
519 && y ("*", "x", FNM_FILE_NAME | FNM_LEADING_DIR)
520 && y ("x*", "x/y/z", FNM_FILE_NAME | FNM_LEADING_DIR)
521 && y ("*c*", "c/x", FNM_FILE_NAME | FNM_LEADING_DIR)],
522 1)));])],
523 [$2=yes],
524 [$2=no],
525 [$2=cross])])
526 AS_IF([test $$2 = yes], [$3], [$4])
527 ])# _AC_FUNC_FNMATCH_IF
528
529
530 # AC_FUNC_FNMATCH
531 # ---------------
532 AC_DEFUN([AC_FUNC_FNMATCH],
533 [_AC_FUNC_FNMATCH_IF([POSIX], [ac_cv_func_fnmatch_works],
534 [AC_DEFINE([HAVE_FNMATCH], 1,
535 [Define to 1 if your system has a working POSIX `fnmatch'
536 function.])])
537 ])# AC_FUNC_FNMATCH
538
539
540 # _AC_LIBOBJ_FNMATCH
541 # ------------------
542 # Prepare the replacement of fnmatch.
543 AC_DEFUN([_AC_LIBOBJ_FNMATCH],
544 [AC_REQUIRE([AC_C_CONST])dnl
545 AC_REQUIRE([AC_FUNC_ALLOCA])dnl
546 AC_REQUIRE([AC_TYPE_MBSTATE_T])dnl
547 AC_CHECK_DECLS([getenv])
548 AC_CHECK_FUNCS([btowc mbsrtowcs mempcpy wmempcpy])
549 AC_CHECK_HEADERS([wchar.h wctype.h])
550 AC_LIBOBJ([fnmatch])
551 AC_CONFIG_LINKS([$ac_config_libobj_dir/fnmatch.h:$ac_config_libobj_dir/fnmatch_.h])
552 AC_DEFINE(fnmatch, rpl_fnmatch,
553 [Define to rpl_fnmatch if the replacement function should be used.])
554 ])# _AC_LIBOBJ_FNMATCH
555
556
557 # AC_REPLACE_FNMATCH
558 # ------------------
559 AN_FUNCTION([fnmatch], [AC_REPLACE_FNMATCH])
560 AC_DEFUN([AC_REPLACE_FNMATCH],
561 [_AC_FUNC_FNMATCH_IF([POSIX], [ac_cv_func_fnmatch_works],
562 [rm -f "$ac_config_libobj_dir/fnmatch.h"],
563 [_AC_LIBOBJ_FNMATCH])
564 ])# AC_REPLACE_FNMATCH
565
566
567 # AC_FUNC_FNMATCH_GNU
568 # -------------------
569 AC_DEFUN([AC_FUNC_FNMATCH_GNU],
570 [AC_REQUIRE([AC_GNU_SOURCE])
571 _AC_FUNC_FNMATCH_IF([GNU], [ac_cv_func_fnmatch_gnu],
572 [rm -f "$ac_config_libobj_dir/fnmatch.h"],
573 [_AC_LIBOBJ_FNMATCH])
574 ])# AC_FUNC_FNMATCH_GNU
575
576
577 # AU::AM_FUNC_FNMATCH
578 # AU::fp_FUNC_FNMATCH
579 # -------------------
580 AU_ALIAS([AM_FUNC_FNMATCH], [AC_FUNC_FNMATCH])
581 AU_ALIAS([fp_FUNC_FNMATCH], [AC_FUNC_FNMATCH])
582
583
584 # AC_FUNC_FSEEKO
585 # --------------
586 AN_FUNCTION([ftello], [AC_FUNC_FSEEKO])
587 AN_FUNCTION([fseeko], [AC_FUNC_FSEEKO])
588 AC_DEFUN([AC_FUNC_FSEEKO],
589 [_AC_SYS_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE, 1,
590 [ac_cv_sys_largefile_source],
591 [Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2).],
592 [[#include <sys/types.h> /* for off_t */
593 #include <stdio.h>]],
594 [[int (*fp) (FILE *, off_t, int) = fseeko;
595 return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);]])
596
597 # We used to try defining _XOPEN_SOURCE=500 too, to work around a bug
598 # in glibc 2.1.3, but that breaks too many other things.
599 # If you want fseeko and ftello with glibc, upgrade to a fixed glibc.
600 if test $ac_cv_sys_largefile_source != unknown; then
601 AC_DEFINE(HAVE_FSEEKO, 1,
602 [Define to 1 if fseeko (and presumably ftello) exists and is declared.])
603 fi
604 ])# AC_FUNC_FSEEKO
605
606
607 # AC_FUNC_GETGROUPS
608 # -----------------
609 # Try to find `getgroups', and check that it works.
610 # When cross-compiling, assume getgroups is broken.
611 AN_FUNCTION([getgroups], [AC_FUNC_GETGROUPS])
612 AC_DEFUN([AC_FUNC_GETGROUPS],
613 [AC_REQUIRE([AC_TYPE_GETGROUPS])dnl
614 AC_REQUIRE([AC_TYPE_SIZE_T])dnl
615 AC_CHECK_FUNC(getgroups)
616
617 # If we don't yet have getgroups, see if it's in -lbsd.
618 # This is reported to be necessary on an ITOS 3000WS running SEIUX 3.1.
619 ac_save_LIBS=$LIBS
620 if test $ac_cv_func_getgroups = no; then
621 AC_CHECK_LIB(bsd, getgroups, [GETGROUPS_LIB=-lbsd])
622 fi
623
624 # Run the program to test the functionality of the system-supplied
625 # getgroups function only if there is such a function.
626 if test $ac_cv_func_getgroups = yes; then
627 AC_CACHE_CHECK([for working getgroups], ac_cv_func_getgroups_works,
628 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
629 [[/* On Ultrix 4.3, getgroups (0, 0) always fails. */
630 return getgroups (0, 0) == -1;]])],
631 [ac_cv_func_getgroups_works=yes],
632 [ac_cv_func_getgroups_works=no],
633 [ac_cv_func_getgroups_works=no])
634 ])
635 if test $ac_cv_func_getgroups_works = yes; then
636 AC_DEFINE(HAVE_GETGROUPS, 1,
637 [Define to 1 if your system has a working `getgroups' function.])
638 fi
639 fi
640 LIBS=$ac_save_LIBS
641 ])# AC_FUNC_GETGROUPS
642
643
644 # _AC_LIBOBJ_GETLOADAVG
645 # ---------------------
646 # Set up the AC_LIBOBJ replacement of `getloadavg'.
647 m4_define([_AC_LIBOBJ_GETLOADAVG],
648 [AC_LIBOBJ(getloadavg)
649 AC_DEFINE(C_GETLOADAVG, 1, [Define to 1 if using `getloadavg.c'.])
650 # Figure out what our getloadavg.c needs.
651 ac_have_func=no
652 AC_CHECK_HEADER(sys/dg_sys_info.h,
653 [ac_have_func=yes
654 AC_DEFINE(DGUX, 1, [Define to 1 for DGUX with <sys/dg_sys_info.h>.])
655 AC_CHECK_LIB(dgc, dg_sys_info)])
656
657 AC_CHECK_HEADER(locale.h)
658 AC_CHECK_FUNCS(setlocale)
659
660 # We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it
661 # uses stabs), but it is still SVR4. We cannot check for <elf.h> because
662 # Irix 4.0.5F has the header but not the library.
663 if test $ac_have_func = no && test "$ac_cv_lib_elf_elf_begin" = yes; then
664 ac_have_func=yes
665 AC_DEFINE(SVR4, 1, [Define to 1 on System V Release 4.])
666 fi
667
668 if test $ac_have_func = no; then
669 AC_CHECK_HEADER(inq_stats/cpustats.h,
670 [ac_have_func=yes
671 AC_DEFINE(UMAX, 1, [Define to 1 for Encore UMAX.])
672 AC_DEFINE(UMAX4_3, 1,
673 [Define to 1 for Encore UMAX 4.3 that has <inq_status/cpustats.h>
674 instead of <sys/cpustats.h>.])])
675 fi
676
677 if test $ac_have_func = no; then
678 AC_CHECK_HEADER(sys/cpustats.h,
679 [ac_have_func=yes; AC_DEFINE(UMAX)])
680 fi
681
682 if test $ac_have_func = no; then
683 AC_CHECK_HEADERS(mach/mach.h)
684 fi
685
686 AC_CHECK_HEADERS(nlist.h,
687 [AC_CHECK_MEMBERS([struct nlist.n_un.n_name],
688 [AC_DEFINE(NLIST_NAME_UNION, 1,
689 [Define to 1 if your `struct nlist' has an
690 `n_un' member. Obsolete, depend on
691 `HAVE_STRUCT_NLIST_N_UN_N_NAME])], [],
692 [@%:@include <nlist.h>])
693 ])dnl
694 ])# _AC_LIBOBJ_GETLOADAVG
695
696
697 # AC_FUNC_GETLOADAVG
698 # ------------------
699 AN_FUNCTION([getloadavg], [AC_FUNC_GETLOADAVG])
700 AC_DEFUN([AC_FUNC_GETLOADAVG],
701 [ac_have_func=no # yes means we've found a way to get the load average.
702
703 # Make sure getloadavg.c is where it belongs, at configure-time.
704 test -f "$srcdir/$ac_config_libobj_dir/getloadavg.c" ||
705 AC_MSG_ERROR([$srcdir/$ac_config_libobj_dir/getloadavg.c is missing])
706
707 ac_save_LIBS=$LIBS
708
709 # Check for getloadavg, but be sure not to touch the cache variable.
710 (AC_CHECK_FUNC(getloadavg, exit 0, exit 1)) && ac_have_func=yes
711
712 # On HPUX9, an unprivileged user can get load averages through this function.
713 AC_CHECK_FUNCS(pstat_getdynamic)
714
715 # Solaris has libkstat which does not require root.
716 AC_CHECK_LIB(kstat, kstat_open)
717 test $ac_cv_lib_kstat_kstat_open = yes && ac_have_func=yes
718
719 # Some systems with -lutil have (and need) -lkvm as well, some do not.
720 # On Solaris, -lkvm requires nlist from -lelf, so check that first
721 # to get the right answer into the cache.
722 # For kstat on solaris, we need libelf to force the definition of SVR4 below.
723 if test $ac_have_func = no; then
724 AC_CHECK_LIB(elf, elf_begin, LIBS="-lelf $LIBS")
725 fi
726 if test $ac_have_func = no; then
727 AC_CHECK_LIB(kvm, kvm_open, LIBS="-lkvm $LIBS")
728 # Check for the 4.4BSD definition of getloadavg.
729 AC_CHECK_LIB(util, getloadavg,
730 [LIBS="-lutil $LIBS" ac_have_func=yes ac_cv_func_getloadavg_setgid=yes])
731 fi
732
733 if test $ac_have_func = no; then
734 # There is a commonly available library for RS/6000 AIX.
735 # Since it is not a standard part of AIX, it might be installed locally.
736 ac_getloadavg_LIBS=$LIBS
737 LIBS="-L/usr/local/lib $LIBS"
738 AC_CHECK_LIB(getloadavg, getloadavg,
739 [LIBS="-lgetloadavg $LIBS"], [LIBS=$ac_getloadavg_LIBS])
740 fi
741
742 # Make sure it is really in the library, if we think we found it,
743 # otherwise set up the replacement function.
744 AC_CHECK_FUNCS(getloadavg, [],
745 [_AC_LIBOBJ_GETLOADAVG])
746
747 # Some definitions of getloadavg require that the program be installed setgid.
748 AC_CACHE_CHECK(whether getloadavg requires setgid,
749 ac_cv_func_getloadavg_setgid,
750 [AC_EGREP_CPP([Yowza Am I SETGID yet],
751 [#include "$srcdir/$ac_config_libobj_dir/getloadavg.c"
752 #ifdef LDAV_PRIVILEGED
753 Yowza Am I SETGID yet
754 @%:@endif],
755 ac_cv_func_getloadavg_setgid=yes,
756 ac_cv_func_getloadavg_setgid=no)])
757 if test $ac_cv_func_getloadavg_setgid = yes; then
758 NEED_SETGID=true
759 AC_DEFINE(GETLOADAVG_PRIVILEGED, 1,
760 [Define to 1 if the `getloadavg' function needs to be run setuid
761 or setgid.])
762 else
763 NEED_SETGID=false
764 fi
765 AC_SUBST(NEED_SETGID)dnl
766
767 if test $ac_cv_func_getloadavg_setgid = yes; then
768 AC_CACHE_CHECK(group of /dev/kmem, ac_cv_group_kmem,
769 [ # On Solaris, /dev/kmem is a symlink. Get info on the real file.
770 ac_ls_output=`ls -lgL /dev/kmem 2>/dev/null`
771 # If we got an error (system does not support symlinks), try without -L.
772 test -z "$ac_ls_output" && ac_ls_output=`ls -lg /dev/kmem`
773 ac_cv_group_kmem=`echo $ac_ls_output \
774 | sed -ne ['s/[ ][ ]*/ /g;
775 s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\) *.*/\1/;
776 / /s/.* //;p;']`
777 ])
778 AC_SUBST(KMEM_GROUP, $ac_cv_group_kmem)dnl
779 fi
780 if test "x$ac_save_LIBS" = x; then
781 GETLOADAVG_LIBS=$LIBS
782 else
783 GETLOADAVG_LIBS=`echo "$LIBS" | sed "s!$ac_save_LIBS!!"`
784 fi
785 LIBS=$ac_save_LIBS
786
787 AC_SUBST(GETLOADAVG_LIBS)dnl
788 ])# AC_FUNC_GETLOADAVG
789
790
791 # AU::AC_GETLOADAVG
792 # -----------------
793 AU_ALIAS([AC_GETLOADAVG], [AC_FUNC_GETLOADAVG])
794
795
796 # AC_FUNC_GETMNTENT
797 # -----------------
798 AN_FUNCTION([getmntent], [AC_FUNC_GETMNTENT])
799 AC_DEFUN([AC_FUNC_GETMNTENT],
800 [# getmntent is in the standard C library on UNICOS, in -lsun on Irix 4,
801 # -lseq on Dynix/PTX, -lgen on Unixware.
802 AC_SEARCH_LIBS(getmntent, [sun seq gen],
803 [ac_cv_func_getmntent=yes
804 AC_DEFINE([HAVE_GETMNTENT], [1],
805 [Define to 1 if you have the `getmntent' function.])],
806 [ac_cv_func_getmntent=no])
807 ])
808
809
810 # AC_FUNC_GETPGRP
811 # ---------------
812 # Figure out whether getpgrp requires zero arguments.
813 AN_FUNCTION([getpgrp], [AC_FUNC_GETPGRP])
814 AC_DEFUN([AC_FUNC_GETPGRP],
815 [AC_CACHE_CHECK(whether getpgrp requires zero arguments,
816 ac_cv_func_getpgrp_void,
817 [# Use it with a single arg.
818 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [getpgrp (0);])],
819 [ac_cv_func_getpgrp_void=no],
820 [ac_cv_func_getpgrp_void=yes])
821 ])
822 if test $ac_cv_func_getpgrp_void = yes; then
823 AC_DEFINE(GETPGRP_VOID, 1,
824 [Define to 1 if the `getpgrp' function requires zero arguments.])
825 fi
826 ])# AC_FUNC_GETPGRP
827
828
829 # AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
830 # -------------------------------------
831 # When cross-compiling, be pessimistic so we will end up using the
832 # replacement version of lstat that checks for trailing slashes and
833 # calls lstat a second time when necessary.
834 AN_FUNCTION([lstat], [AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])
835 AC_DEFUN([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK],
836 [AC_CACHE_CHECK(
837 [whether lstat dereferences a symlink specified with a trailing slash],
838 [ac_cv_func_lstat_dereferences_slashed_symlink],
839 [rm -f conftest.sym conftest.file
840 echo >conftest.file
841 if test "$as_ln_s" = "ln -s" && ln -s conftest.file conftest.sym; then
842 AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
843 [struct stat sbuf;
844 /* Linux will dereference the symlink and fail.
845 That is better in the sense that it means we will not
846 have to compile and use the lstat wrapper. */
847 return lstat ("conftest.sym/", &sbuf) == 0;])],
848 [ac_cv_func_lstat_dereferences_slashed_symlink=yes],
849 [ac_cv_func_lstat_dereferences_slashed_symlink=no],
850 [ac_cv_func_lstat_dereferences_slashed_symlink=no])
851 else
852 # If the `ln -s' command failed, then we probably don't even
853 # have an lstat function.
854 ac_cv_func_lstat_dereferences_slashed_symlink=no
855 fi
856 rm -f conftest.sym conftest.file
857 ])
858
859 test $ac_cv_func_lstat_dereferences_slashed_symlink = yes &&
860 AC_DEFINE_UNQUOTED(LSTAT_FOLLOWS_SLASHED_SYMLINK, 1,
861 [Define to 1 if `lstat' dereferences a symlink specified
862 with a trailing slash.])
863
864 if test $ac_cv_func_lstat_dereferences_slashed_symlink = no; then
865 AC_LIBOBJ(lstat)
866 fi
867 ])
868
869
870 # _AC_FUNC_MALLOC_IF(IF-WORKS, IF-NOT)
871 # ------------------------------------
872 # If `malloc (0)' properly handled, run IF-WORKS, otherwise, IF-NOT.
873 AC_DEFUN([_AC_FUNC_MALLOC_IF],
874 [AC_REQUIRE([AC_HEADER_STDC])dnl
875 AC_CHECK_HEADERS(stdlib.h)
876 AC_CACHE_CHECK([for GNU libc compatible malloc], ac_cv_func_malloc_0_nonnull,
877 [AC_RUN_IFELSE(
878 [AC_LANG_PROGRAM(
879 [[#if defined STDC_HEADERS || defined HAVE_STDLIB_H
880 # include <stdlib.h>
881 #else
882 char *malloc ();
883 #endif
884 ]],
885 [return ! malloc (0);])],
886 [ac_cv_func_malloc_0_nonnull=yes],
887 [ac_cv_func_malloc_0_nonnull=no],
888 [ac_cv_func_malloc_0_nonnull=no])])
889 AS_IF([test $ac_cv_func_malloc_0_nonnull = yes], [$1], [$2])
890 ])# AC_FUNC_MALLOC
891
892
893 # AC_FUNC_MALLOC
894 # --------------
895 # Report whether `malloc (0)' properly handled, and replace malloc if
896 # needed.
897 AN_FUNCTION([malloc], [AC_FUNC_MALLOC])
898 AC_DEFUN([AC_FUNC_MALLOC],
899 [_AC_FUNC_MALLOC_IF(
900 [AC_DEFINE([HAVE_MALLOC], 1,
901 [Define to 1 if your system has a GNU libc compatible `malloc'
902 function, and to 0 otherwise.])],
903 [AC_DEFINE([HAVE_MALLOC], 0)
904 AC_LIBOBJ(malloc)
905 AC_DEFINE([malloc], [rpl_malloc],
906 [Define to rpl_malloc if the replacement function should be used.])])
907 ])# AC_FUNC_MALLOC
908
909
910 # AC_FUNC_MBRTOWC
911 # ---------------
912 AN_FUNCTION([mbrtowc], [AC_FUNC_MBRTOWC])
913 AC_DEFUN([AC_FUNC_MBRTOWC],
914 [
915 AC_CACHE_CHECK([whether mbrtowc and mbstate_t are properly declared],
916 ac_cv_func_mbrtowc,
917 [AC_LINK_IFELSE(
918 [AC_LANG_PROGRAM(
919 [[@%:@include <wchar.h>]],
920 [[wchar_t wc;
921 char const s[] = "";
922 size_t n = 1;
923 mbstate_t state;
924 return ! (sizeof state && (mbrtowc) (&wc, s, n, &state));]])],
925 ac_cv_func_mbrtowc=yes,
926 ac_cv_func_mbrtowc=no)])
927 if test $ac_cv_func_mbrtowc = yes; then
928 AC_DEFINE([HAVE_MBRTOWC], 1,
929 [Define to 1 if mbrtowc and mbstate_t are properly declared.])
930 fi
931 ])
932
933
934 # AC_FUNC_MEMCMP
935 # --------------
936 AN_FUNCTION([memcmp], [AC_FUNC_MEMCMP])
937 AC_DEFUN([AC_FUNC_MEMCMP],
938 [AC_CACHE_CHECK([for working memcmp], ac_cv_func_memcmp_working,
939 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [[
940 /* Some versions of memcmp are not 8-bit clean. */
941 char c0 = '\100', c1 = '\200', c2 = '\201';
942 if (memcmp(&c0, &c2, 1) >= 0 || memcmp(&c1, &c2, 1) >= 0)
943 return 1;
944
945 /* The Next x86 OpenStep bug shows up only when comparing 16 bytes
946 or more and with at least one buffer not starting on a 4-byte boundary.
947 William Lewis provided this test program. */
948 {
949 char foo[21];
950 char bar[21];
951 int i;
952 for (i = 0; i < 4; i++)
953 {
954 char *a = foo + i;
955 char *b = bar + i;
956 strcpy (a, "--------01111111");
957 strcpy (b, "--------10000000");
958 if (memcmp (a, b, 16) >= 0)
959 return 1;
960 }
961 return 0;
962 }
963 ]])],
964 [ac_cv_func_memcmp_working=yes],
965 [ac_cv_func_memcmp_working=no],
966 [ac_cv_func_memcmp_working=no])])
967 test $ac_cv_func_memcmp_working = no && AC_LIBOBJ([memcmp])
968 ])# AC_FUNC_MEMCMP
969
970
971 # AC_FUNC_MKTIME
972 # --------------
973 AN_FUNCTION([mktime], [AC_FUNC_MKTIME])
974 AC_DEFUN([AC_FUNC_MKTIME],
975 [AC_REQUIRE([AC_HEADER_TIME])dnl
976 AC_CHECK_HEADERS_ONCE(sys/time.h unistd.h)
977 AC_CHECK_FUNCS_ONCE(alarm)
978 AC_CACHE_CHECK([for working mktime], ac_cv_func_working_mktime,
979 [AC_RUN_IFELSE([AC_LANG_SOURCE(
980 [[/* Test program from Paul Eggert and Tony Leneis. */
981 #ifdef TIME_WITH_SYS_TIME
982 # include <sys/time.h>
983 # include <time.h>
984 #else
985 # ifdef HAVE_SYS_TIME_H
986 # include <sys/time.h>
987 # else
988 # include <time.h>
989 # endif
990 #endif
991
992 #include <stdlib.h>
993
994 #ifdef HAVE_UNISTD_H
995 # include <unistd.h>
996 #endif
997
998 #ifndef HAVE_ALARM
999 # define alarm(X) /* empty */
1000 #endif
1001
1002 /* Work around redefinition to rpl_putenv by other config tests. */
1003 #undef putenv
1004
1005 static time_t time_t_max;
1006 static time_t time_t_min;
1007
1008 /* Values we'll use to set the TZ environment variable. */
1009 static char *tz_strings[] = {
1010 (char *) 0, "TZ=GMT0", "TZ=JST-9",
1011 "TZ=EST+3EDT+2,M10.1.0/00:00:00,M2.3.0/00:00:00"
1012 };
1013 #define N_STRINGS (sizeof (tz_strings) / sizeof (tz_strings[0]))
1014
1015 /* Return 0 if mktime fails to convert a date in the spring-forward gap.
1016 Based on a problem report from Andreas Jaeger. */
1017 static int
1018 spring_forward_gap ()
1019 {
1020 /* glibc (up to about 1998-10-07) failed this test. */
1021 struct tm tm;
1022
1023 /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
1024 instead of "TZ=America/Vancouver" in order to detect the bug even
1025 on systems that don't support the Olson extension, or don't have the
1026 full zoneinfo tables installed. */
1027 putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
1028
1029 tm.tm_year = 98;
1030 tm.tm_mon = 3;
1031 tm.tm_mday = 5;
1032 tm.tm_hour = 2;
1033 tm.tm_min = 0;
1034 tm.tm_sec = 0;
1035 tm.tm_isdst = -1;
1036 return mktime (&tm) != (time_t) -1;
1037 }
1038
1039 static int
1040 mktime_test1 (now)
1041 time_t now;
1042 {
1043 struct tm *lt;
1044 return ! (lt = localtime (&now)) || mktime (lt) == now;
1045 }
1046
1047 static int
1048 mktime_test (now)
1049 time_t now;
1050 {
1051 return (mktime_test1 (now)
1052 && mktime_test1 ((time_t) (time_t_max - now))
1053 && mktime_test1 ((time_t) (time_t_min + now)));
1054 }
1055
1056 static int
1057 irix_6_4_bug ()
1058 {
1059 /* Based on code from Ariel Faigon. */
1060 struct tm tm;
1061 tm.tm_year = 96;
1062 tm.tm_mon = 3;
1063 tm.tm_mday = 0;
1064 tm.tm_hour = 0;
1065 tm.tm_min = 0;
1066 tm.tm_sec = 0;
1067 tm.tm_isdst = -1;
1068 mktime (&tm);
1069 return tm.tm_mon == 2 && tm.tm_mday == 31;
1070 }
1071
1072 static int
1073 bigtime_test (j)
1074 int j;
1075 {
1076 struct tm tm;
1077 time_t now;
1078 tm.tm_year = tm.tm_mon = tm.tm_mday = tm.tm_hour = tm.tm_min = tm.tm_sec = j;
1079 now = mktime (&tm);
1080 if (now != (time_t) -1)
1081 {
1082 struct tm *lt = localtime (&now);
1083 if (! (lt
1084 && lt->tm_year == tm.tm_year
1085 && lt->tm_mon == tm.tm_mon
1086 && lt->tm_mday == tm.tm_mday
1087 && lt->tm_hour == tm.tm_hour
1088 && lt->tm_min == tm.tm_min
1089 && lt->tm_sec == tm.tm_sec
1090 && lt->tm_yday == tm.tm_yday
1091 && lt->tm_wday == tm.tm_wday
1092 && ((lt->tm_isdst < 0 ? -1 : 0 < lt->tm_isdst)
1093 == (tm.tm_isdst < 0 ? -1 : 0 < tm.tm_isdst))))
1094 return 0;
1095 }
1096 return 1;
1097 }
1098
1099 static int
1100 year_2050_test ()
1101 {
1102 /* The correct answer for 2050-02-01 00:00:00 in Pacific time,
1103 ignoring leap seconds. */
1104 unsigned long int answer = 2527315200UL;
1105
1106 struct tm tm;
1107 time_t t;
1108 tm.tm_year = 2050 - 1900;
1109 tm.tm_mon = 2 - 1;
1110 tm.tm_mday = 1;
1111 tm.tm_hour = tm.tm_min = tm.tm_sec = 0;
1112 tm.tm_isdst = -1;
1113
1114 /* Use the portable POSIX.1 specification "TZ=PST8PDT,M4.1.0,M10.5.0"
1115 instead of "TZ=America/Vancouver" in order to detect the bug even
1116 on systems that don't support the Olson extension, or don't have the
1117 full zoneinfo tables installed. */
1118 putenv ("TZ=PST8PDT,M4.1.0,M10.5.0");
1119
1120 t = mktime (&tm);
1121
1122 /* Check that the result is either a failure, or close enough
1123 to the correct answer that we can assume the discrepancy is
1124 due to leap seconds. */
1125 return (t == (time_t) -1
1126 || (0 < t && answer - 120 <= t && t <= answer + 120));
1127 }
1128
1129 int
1130 main ()
1131 {
1132 time_t t, delta;
1133 int i, j;
1134
1135 /* This test makes some buggy mktime implementations loop.
1136 Give up after 60 seconds; a mktime slower than that
1137 isn't worth using anyway. */
1138 alarm (60);
1139
1140 for (time_t_max = 1; 0 < time_t_max; time_t_max *= 2)
1141 continue;
1142 time_t_max--;
1143 if ((time_t) -1 < 0)
1144 for (time_t_min = -1; (time_t) (time_t_min * 2) < 0; time_t_min *= 2)
1145 continue;
1146 delta = time_t_max / 997; /* a suitable prime number */
1147 for (i = 0; i < N_STRINGS; i++)
1148 {
1149 if (tz_strings[i])
1150 putenv (tz_strings[i]);
1151
1152 for (t = 0; t <= time_t_max - delta; t += delta)
1153 if (! mktime_test (t))
1154 return 1;
1155 if (! (mktime_test ((time_t) 1)
1156 && mktime_test ((time_t) (60 * 60))
1157 && mktime_test ((time_t) (60 * 60 * 24))))
1158 return 1;
1159
1160 for (j = 1; 0 < j; j *= 2)
1161 if (! bigtime_test (j))
1162 return 1;
1163 if (! bigtime_test (j - 1))
1164 return 1;
1165 }
1166 return ! (irix_6_4_bug () && spring_forward_gap () && year_2050_test ());
1167 }]])],
1168 [ac_cv_func_working_mktime=yes],
1169 [ac_cv_func_working_mktime=no],
1170 [ac_cv_func_working_mktime=no])])
1171 if test $ac_cv_func_working_mktime = no; then
1172 AC_LIBOBJ([mktime])
1173 fi
1174 ])# AC_FUNC_MKTIME
1175
1176
1177 # AU::AM_FUNC_MKTIME
1178 # ------------------
1179 AU_ALIAS([AM_FUNC_MKTIME], [AC_FUNC_MKTIME])
1180
1181
1182 # AC_FUNC_MMAP
1183 # ------------
1184 AN_FUNCTION([mmap], [AC_FUNC_MMAP])
1185 AC_DEFUN([AC_FUNC_MMAP],
1186 [AC_CHECK_HEADERS(stdlib.h unistd.h)
1187 AC_CHECK_FUNCS(getpagesize)
1188 AC_CACHE_CHECK(for working mmap, ac_cv_func_mmap_fixed_mapped,
1189 [AC_RUN_IFELSE([AC_LANG_SOURCE([AC_INCLUDES_DEFAULT]
1190 [[/* malloc might have been renamed as rpl_malloc. */
1191 #undef malloc
1192
1193 /* Thanks to Mike Haertel and Jim Avera for this test.
1194 Here is a matrix of mmap possibilities:
1195 mmap private not fixed
1196 mmap private fixed at somewhere currently unmapped
1197 mmap private fixed at somewhere already mapped
1198 mmap shared not fixed
1199 mmap shared fixed at somewhere currently unmapped
1200 mmap shared fixed at somewhere already mapped
1201 For private mappings, we should verify that changes cannot be read()
1202 back from the file, nor mmap's back from the file at a different
1203 address. (There have been systems where private was not correctly
1204 implemented like the infamous i386 svr4.0, and systems where the
1205 VM page cache was not coherent with the file system buffer cache
1206 like early versions of FreeBSD and possibly contemporary NetBSD.)
1207 For shared mappings, we should conversely verify that changes get
1208 propagated back to all the places they're supposed to be.
1209
1210 Grep wants private fixed already mapped.
1211 The main things grep needs to know about mmap are:
1212 * does it exist and is it safe to write into the mmap'd area
1213 * how to use it (BSD variants) */
1214
1215 #include <fcntl.h>
1216 #include <sys/mman.h>
1217
1218 #if !defined STDC_HEADERS && !defined HAVE_STDLIB_H
1219 char *malloc ();
1220 #endif
1221
1222 /* This mess was copied from the GNU getpagesize.h. */
1223 #ifndef HAVE_GETPAGESIZE
1224 /* Assume that all systems that can run configure have sys/param.h. */
1225 # ifndef HAVE_SYS_PARAM_H
1226 # define HAVE_SYS_PARAM_H 1
1227 # endif
1228
1229 # ifdef _SC_PAGESIZE
1230 # define getpagesize() sysconf(_SC_PAGESIZE)
1231 # else /* no _SC_PAGESIZE */
1232 # ifdef HAVE_SYS_PARAM_H
1233 # include <sys/param.h>
1234 # ifdef EXEC_PAGESIZE
1235 # define getpagesize() EXEC_PAGESIZE
1236 # else /* no EXEC_PAGESIZE */
1237 # ifdef NBPG
1238 # define getpagesize() NBPG * CLSIZE
1239 # ifndef CLSIZE
1240 # define CLSIZE 1
1241 # endif /* no CLSIZE */
1242 # else /* no NBPG */
1243 # ifdef NBPC
1244 # define getpagesize() NBPC
1245 # else /* no NBPC */
1246 # ifdef PAGESIZE
1247 # define getpagesize() PAGESIZE
1248 # endif /* PAGESIZE */
1249 # endif /* no NBPC */
1250 # endif /* no NBPG */
1251 # endif /* no EXEC_PAGESIZE */
1252 # else /* no HAVE_SYS_PARAM_H */
1253 # define getpagesize() 8192 /* punt totally */
1254 # endif /* no HAVE_SYS_PARAM_H */
1255 # endif /* no _SC_PAGESIZE */
1256
1257 #endif /* no HAVE_GETPAGESIZE */
1258
1259 int
1260 main ()
1261 {
1262 char *data, *data2, *data3;
1263 int i, pagesize;
1264 int fd;
1265
1266 pagesize = getpagesize ();
1267
1268 /* First, make a file with some known garbage in it. */
1269 data = (char *) malloc (pagesize);
1270 if (!data)
1271 return 1;
1272 for (i = 0; i < pagesize; ++i)
1273 *(data + i) = rand ();
1274 umask (0);
1275 fd = creat ("conftest.mmap", 0600);
1276 if (fd < 0)
1277 return 1;
1278 if (write (fd, data, pagesize) != pagesize)
1279 return 1;
1280 close (fd);
1281
1282 /* Next, try to mmap the file at a fixed address which already has
1283 something else allocated at it. If we can, also make sure that
1284 we see the same garbage. */
1285 fd = open ("conftest.mmap", O_RDWR);
1286 if (fd < 0)
1287 return 1;
1288 data2 = (char *) malloc (2 * pagesize);
1289 if (!data2)
1290 return 1;
1291 data2 += (pagesize - ((long int) data2 & (pagesize - 1))) & (pagesize - 1);
1292 if (data2 != mmap (data2, pagesize, PROT_READ | PROT_WRITE,
1293 MAP_PRIVATE | MAP_FIXED, fd, 0L))
1294 return 1;
1295 for (i = 0; i < pagesize; ++i)
1296 if (*(data + i) != *(data2 + i))
1297 return 1;
1298
1299 /* Finally, make sure that changes to the mapped area do not
1300 percolate back to the file as seen by read(). (This is a bug on
1301 some variants of i386 svr4.0.) */
1302 for (i = 0; i < pagesize; ++i)
1303 *(data2 + i) = *(data2 + i) + 1;
1304 data3 = (char *) malloc (pagesize);
1305 if (!data3)
1306 return 1;
1307 if (read (fd, data3, pagesize) != pagesize)
1308 return 1;
1309 for (i = 0; i < pagesize; ++i)
1310 if (*(data + i) != *(data3 + i))
1311 return 1;
1312 close (fd);
1313 return 0;
1314 }]])],
1315 [ac_cv_func_mmap_fixed_mapped=yes],
1316 [ac_cv_func_mmap_fixed_mapped=no],
1317 [ac_cv_func_mmap_fixed_mapped=no])])
1318 if test $ac_cv_func_mmap_fixed_mapped = yes; then
1319 AC_DEFINE(HAVE_MMAP, 1,
1320 [Define to 1 if you have a working `mmap' system call.])
1321 fi
1322 rm -f conftest.mmap
1323 ])# AC_FUNC_MMAP
1324
1325
1326 # AU::AC_MMAP
1327 # -----------
1328 AU_ALIAS([AC_MMAP], [AC_FUNC_MMAP])
1329
1330
1331 # AC_FUNC_OBSTACK
1332 # ---------------
1333 # Ensure obstack support. Yeah, this is not exactly a `FUNC' check.
1334 AN_FUNCTION([obstack_init], [AC_FUNC_OBSTACK])
1335 AN_IDENTIFIER([obstack], [AC_FUNC_OBSTACK])
1336 AC_DEFUN([AC_FUNC_OBSTACK],
1337 [AC_LIBSOURCES([obstack.h, obstack.c])dnl
1338 AC_CACHE_CHECK([for obstacks], ac_cv_func_obstack,
1339 [AC_LINK_IFELSE(
1340 [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
1341 [@%:@include "obstack.h"]],
1342 [[struct obstack mem;
1343 @%:@define obstack_chunk_alloc malloc
1344 @%:@define obstack_chunk_free free
1345 obstack_init (&mem);
1346 obstack_free (&mem, 0);]])],
1347 [ac_cv_func_obstack=yes],
1348 [ac_cv_func_obstack=no])])
1349 if test $ac_cv_func_obstack = yes; then
1350 AC_DEFINE(HAVE_OBSTACK, 1, [Define to 1 if libc includes obstacks.])
1351 else
1352 AC_LIBOBJ(obstack)
1353 fi
1354 ])# AC_FUNC_OBSTACK
1355
1356
1357 # AU::AM_FUNC_OBSTACK
1358 # -------------------
1359 AU_ALIAS([AM_FUNC_OBSTACK], [AC_FUNC_OBSTACK])
1360
1361
1362
1363 # _AC_FUNC_REALLOC_IF(IF-WORKS, IF-NOT)
1364 # -------------------------------------
1365 # If `realloc (0, 0)' is properly handled, run IF-WORKS, otherwise, IF-NOT.
1366 AC_DEFUN([_AC_FUNC_REALLOC_IF],
1367 [AC_REQUIRE([AC_HEADER_STDC])dnl
1368 AC_CHECK_HEADERS(stdlib.h)
1369 AC_CACHE_CHECK([for GNU libc compatible realloc], ac_cv_func_realloc_0_nonnull,
1370 [AC_RUN_IFELSE(
1371 [AC_LANG_PROGRAM(
1372 [[#if defined STDC_HEADERS || defined HAVE_STDLIB_H
1373 # include <stdlib.h>
1374 #else
1375 char *realloc ();
1376 #endif
1377 ]],
1378 [return ! realloc (0, 0);])],
1379 [ac_cv_func_realloc_0_nonnull=yes],
1380 [ac_cv_func_realloc_0_nonnull=no],
1381 [ac_cv_func_realloc_0_nonnull=no])])
1382 AS_IF([test $ac_cv_func_realloc_0_nonnull = yes], [$1], [$2])
1383 ])# AC_FUNC_REALLOC
1384
1385
1386 # AC_FUNC_REALLOC
1387 # ---------------
1388 # Report whether `realloc (0, 0)' is properly handled, and replace realloc if
1389 # needed.
1390 AN_FUNCTION([realloc], [AC_FUNC_REALLOC])
1391 AC_DEFUN([AC_FUNC_REALLOC],
1392 [_AC_FUNC_REALLOC_IF(
1393 [AC_DEFINE([HAVE_REALLOC], 1,
1394 [Define to 1 if your system has a GNU libc compatible `realloc'
1395 function, and to 0 otherwise.])],
1396 [AC_DEFINE([HAVE_REALLOC], 0)
1397 AC_LIBOBJ([realloc])
1398 AC_DEFINE([realloc], [rpl_realloc],
1399 [Define to rpl_realloc if the replacement function should be used.])])
1400 ])# AC_FUNC_REALLOC
1401
1402
1403 # AC_FUNC_SELECT_ARGTYPES
1404 # -----------------------
1405 # Determine the correct type to be passed to each of the `select'
1406 # function's arguments, and define those types in `SELECT_TYPE_ARG1',
1407 # `SELECT_TYPE_ARG234', and `SELECT_TYPE_ARG5'.
1408 AN_FUNCTION([select], [AC_FUNC_SELECT_ARGTYPES])
1409 AC_DEFUN([AC_FUNC_SELECT_ARGTYPES],
1410 [AC_CHECK_HEADERS(sys/select.h sys/socket.h)
1411 AC_CACHE_CHECK([types of arguments for select],
1412 [ac_cv_func_select_args],
1413 [for ac_arg234 in 'fd_set *' 'int *' 'void *'; do
1414 for ac_arg1 in 'int' 'size_t' 'unsigned long int' 'unsigned int'; do
1415 for ac_arg5 in 'struct timeval *' 'const struct timeval *'; do
1416 AC_COMPILE_IFELSE(
1417 [AC_LANG_PROGRAM(
1418 [AC_INCLUDES_DEFAULT
1419 #ifdef HAVE_SYS_SELECT_H
1420 # include <sys/select.h>
1421 #endif
1422 #ifdef HAVE_SYS_SOCKET_H
1423 # include <sys/socket.h>
1424 #endif
1425 ],
1426 [extern int select ($ac_arg1,
1427 $ac_arg234, $ac_arg234, $ac_arg234,
1428 $ac_arg5);])],
1429 [ac_cv_func_select_args="$ac_arg1,$ac_arg234,$ac_arg5"; break 3])
1430 done
1431 done
1432 done
1433 # Provide a safe default value.
1434 : ${ac_cv_func_select_args='int,int *,struct timeval *'}
1435 ])
1436 ac_save_IFS=$IFS; IFS=','
1437 set dummy `echo "$ac_cv_func_select_args" | sed 's/\*/\*/g'`
1438 IFS=$ac_save_IFS
1439 shift
1440 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG1, $[1],
1441 [Define to the type of arg 1 for `select'.])
1442 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG234, ($[2]),
1443 [Define to the type of args 2, 3 and 4 for `select'.])
1444 AC_DEFINE_UNQUOTED(SELECT_TYPE_ARG5, ($[3]),
1445 [Define to the type of arg 5 for `select'.])
1446 rm -f conftest*
1447 ])# AC_FUNC_SELECT_ARGTYPES
1448
1449
1450 # AC_FUNC_SETPGRP
1451 # ---------------
1452 AN_FUNCTION([setpgrp], [AC_FUNC_SETPGRP])
1453 AC_DEFUN([AC_FUNC_SETPGRP],
1454 [AC_CACHE_CHECK(whether setpgrp takes no argument, ac_cv_func_setpgrp_void,
1455 [AC_RUN_IFELSE(
1456 [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1457 [/* If this system has a BSD-style setpgrp which takes arguments,
1458 setpgrp(1, 1) will fail with ESRCH and return -1, in that case
1459 exit successfully. */
1460 return setpgrp (1,1) != -1;])],
1461 [ac_cv_func_setpgrp_void=no],
1462 [ac_cv_func_setpgrp_void=yes],
1463 [AC_MSG_ERROR([cannot check setpgrp when cross compiling])])])
1464 if test $ac_cv_func_setpgrp_void = yes; then
1465 AC_DEFINE(SETPGRP_VOID, 1,
1466 [Define to 1 if the `setpgrp' function takes no argument.])
1467 fi
1468 ])# AC_FUNC_SETPGRP
1469
1470
1471 # _AC_FUNC_STAT(STAT | LSTAT)
1472 # ---------------------------
1473 # Determine whether stat or lstat have the bug that it succeeds when
1474 # given the zero-length file name argument. The stat and lstat from
1475 # SunOS4.1.4 and the Hurd (as of 1998-11-01) do this.
1476 #
1477 # If it does, then define HAVE_STAT_EMPTY_STRING_BUG (or
1478 # HAVE_LSTAT_EMPTY_STRING_BUG) and arrange to compile the wrapper
1479 # function.
1480 m4_define([_AC_FUNC_STAT],
1481 [AC_REQUIRE([AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK])dnl
1482 AC_CACHE_CHECK([whether $1 accepts an empty string],
1483 [ac_cv_func_$1_empty_string_bug],
1484 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1485 [[struct stat sbuf;
1486 return $1 ("", &sbuf) == 0;]])],
1487 [ac_cv_func_$1_empty_string_bug=no],
1488 [ac_cv_func_$1_empty_string_bug=yes],
1489 [ac_cv_func_$1_empty_string_bug=yes])])
1490 if test $ac_cv_func_$1_empty_string_bug = yes; then
1491 AC_LIBOBJ([$1])
1492 AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1_EMPTY_STRING_BUG]), 1,
1493 [Define to 1 if `$1' has the bug that it succeeds when
1494 given the zero-length file name argument.])
1495 fi
1496 ])# _AC_FUNC_STAT
1497
1498
1499 # AC_FUNC_STAT & AC_FUNC_LSTAT
1500 # ----------------------------
1501 AN_FUNCTION([stat], [AC_FUNC_STAT])
1502 AC_DEFUN([AC_FUNC_STAT], [_AC_FUNC_STAT(stat)])
1503 AN_FUNCTION([lstat], [AC_FUNC_LSTAT])
1504 AC_DEFUN([AC_FUNC_LSTAT], [_AC_FUNC_STAT(lstat)])
1505
1506
1507 # _AC_LIBOBJ_STRTOD
1508 # -----------------
1509 m4_define([_AC_LIBOBJ_STRTOD],
1510 [AC_LIBOBJ(strtod)
1511 AC_CHECK_FUNC(pow)
1512 if test $ac_cv_func_pow = no; then
1513 AC_CHECK_LIB(m, pow,
1514 [POW_LIB=-lm],
1515 [AC_MSG_WARN([cannot find library containing definition of pow])])
1516 fi
1517 ])# _AC_LIBOBJ_STRTOD
1518
1519
1520 # AC_FUNC_STRTOD
1521 # --------------
1522 AN_FUNCTION([strtod], [AC_FUNC_STRTOD])
1523 AC_DEFUN([AC_FUNC_STRTOD],
1524 [AC_SUBST(POW_LIB)dnl
1525 AC_CACHE_CHECK(for working strtod, ac_cv_func_strtod,
1526 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
1527 ]AC_INCLUDES_DEFAULT[
1528 #ifndef strtod
1529 double strtod ();
1530 #endif
1531 int
1532 main()
1533 {
1534 {
1535 /* Some versions of Linux strtod mis-parse strings with leading '+'. */
1536 char *string = " +69";
1537 char *term;
1538 double value;
1539 value = strtod (string, &term);
1540 if (value != 69 || term != (string + 4))
1541 return 1;
1542 }
1543
1544 {
1545 /* Under Solaris 2.4, strtod returns the wrong value for the
1546 terminating character under some conditions. */
1547 char *string = "NaN";
1548 char *term;
1549 strtod (string, &term);
1550 if (term != string && *(term - 1) == 0)
1551 return 1;
1552 }
1553 return 0;
1554 }
1555 ]])],
1556 ac_cv_func_strtod=yes,
1557 ac_cv_func_strtod=no,
1558 ac_cv_func_strtod=no)])
1559 if test $ac_cv_func_strtod = no; then
1560 _AC_LIBOBJ_STRTOD
1561 fi
1562 ])
1563
1564
1565 # AC_FUNC_STRTOLD
1566 # ---------------
1567 AC_DEFUN([AC_FUNC_STRTOLD],
1568 [
1569 AC_CACHE_CHECK([whether strtold conforms to C99],
1570 [ac_cv_func_strtold],
1571 [AC_COMPILE_IFELSE(
1572 [AC_LANG_PROGRAM(
1573 [[/* On HP-UX before 11.23, strtold returns a struct instead of
1574 long double. Reject implementations like that, by requiring
1575 compatibility with the C99 prototype. */
1576 # include <stdlib.h>
1577 static long double (*p) (char const *, char **) = strtold;
1578 static long double
1579 test (char const *nptr, char **endptr)
1580 {
1581 long double r;
1582 r = strtold (nptr, endptr);
1583 return r;
1584 }]],
1585 [[return test ("1.0", NULL) != 1 || p ("1.0", NULL) != 1;]])],
1586 [ac_cv_func_strtold=yes],
1587 [ac_cv_func_strtold=no])])
1588 if test $ac_cv_func_strtold = yes; then
1589 AC_DEFINE([HAVE_STRTOLD], 1,
1590 [Define to 1 if strtold exists and conforms to C99.])
1591 fi
1592 ])# AC_FUNC_STRTOLD
1593
1594
1595 # AU::AM_FUNC_STRTOD
1596 # ------------------
1597 AU_ALIAS([AM_FUNC_STRTOD], [AC_FUNC_STRTOD])
1598
1599
1600 # AC_FUNC_STRERROR_R
1601 # ------------------
1602 AN_FUNCTION([strerror_r], [AC_FUNC_STRERROR_R])
1603 AC_DEFUN([AC_FUNC_STRERROR_R],
1604 [AC_CHECK_DECLS([strerror_r])
1605 AC_CHECK_FUNCS([strerror_r])
1606 AC_CACHE_CHECK([whether strerror_r returns char *],
1607 ac_cv_func_strerror_r_char_p,
1608 [
1609 ac_cv_func_strerror_r_char_p=no
1610 if test $ac_cv_have_decl_strerror_r = yes; then
1611 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1612 [[
1613 char buf[100];
1614 char x = *strerror_r (0, buf, sizeof buf);
1615 char *p = strerror_r (0, buf, sizeof buf);
1616 return !p || x;
1617 ]])],
1618 ac_cv_func_strerror_r_char_p=yes)
1619 else
1620 # strerror_r is not declared. Choose between
1621 # systems that have relatively inaccessible declarations for the
1622 # function. BeOS and DEC UNIX 4.0 fall in this category, but the
1623 # former has a strerror_r that returns char*, while the latter
1624 # has a strerror_r that returns `int'.
1625 # This test should segfault on the DEC system.
1626 AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
1627 extern char *strerror_r ();],
1628 [[char buf[100];
1629 char x = *strerror_r (0, buf, sizeof buf);
1630 return ! isalpha (x);]])],
1631 ac_cv_func_strerror_r_char_p=yes, , :)
1632 fi
1633 ])
1634 if test $ac_cv_func_strerror_r_char_p = yes; then
1635 AC_DEFINE([STRERROR_R_CHAR_P], 1,
1636 [Define to 1 if strerror_r returns char *.])
1637 fi
1638 ])# AC_FUNC_STRERROR_R
1639
1640
1641 # AC_FUNC_STRFTIME
1642 # ----------------
1643 AN_FUNCTION([strftime], [AC_FUNC_STRFTIME])
1644 AC_DEFUN([AC_FUNC_STRFTIME],
1645 [AC_CHECK_FUNCS(strftime, [],
1646 [# strftime is in -lintl on SCO UNIX.
1647 AC_CHECK_LIB(intl, strftime,
1648 [AC_DEFINE(HAVE_STRFTIME)
1649 LIBS="-lintl $LIBS"])])dnl
1650 ])# AC_FUNC_STRFTIME
1651
1652
1653 # AC_FUNC_STRNLEN
1654 # ---------------
1655 AN_FUNCTION([strnlen], [AC_FUNC_STRNLEN])
1656 AC_DEFUN([AC_FUNC_STRNLEN],
1657 [AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])dnl
1658 AC_CACHE_CHECK([for working strnlen], ac_cv_func_strnlen_working,
1659 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [[
1660 #define S "foobar"
1661 #define S_LEN (sizeof S - 1)
1662
1663 /* At least one implementation is buggy: that of AIX 4.3 would
1664 give strnlen (S, 1) == 3. */
1665
1666 int i;
1667 for (i = 0; i < S_LEN + 1; ++i)
1668 {
1669 int expected = i <= S_LEN ? i : S_LEN;
1670 if (strnlen (S, i) != expected)
1671 return 1;
1672 }
1673 return 0;
1674 ]])],
1675 [ac_cv_func_strnlen_working=yes],
1676 [ac_cv_func_strnlen_working=no],
1677 [ac_cv_func_strnlen_working=no])])
1678 test $ac_cv_func_strnlen_working = no && AC_LIBOBJ([strnlen])
1679 ])# AC_FUNC_STRNLEN
1680
1681
1682 # AC_FUNC_SETVBUF_REVERSED
1683 # ------------------------
1684 AN_FUNCTION([setvbuf], [AC_FUNC_SETVBUF_REVERSED])
1685 AC_DEFUN([AC_FUNC_SETVBUF_REVERSED],
1686 [AC_REQUIRE([AC_C_PROTOTYPES])dnl
1687 AC_CACHE_CHECK(whether setvbuf arguments are reversed,
1688 ac_cv_func_setvbuf_reversed,
1689 [ac_cv_func_setvbuf_reversed=no
1690 AC_LINK_IFELSE(
1691 [AC_LANG_PROGRAM(
1692 [[#include <stdio.h>
1693 # ifdef PROTOTYPES
1694 int (setvbuf) (FILE *, int, char *, size_t);
1695 # endif]],
1696 [[char buf; return setvbuf (stdout, _IOLBF, &buf, 1);]])],
1697 [AC_LINK_IFELSE(
1698 [AC_LANG_PROGRAM(
1699 [[#include <stdio.h>
1700 # ifdef PROTOTYPES
1701 int (setvbuf) (FILE *, int, char *, size_t);
1702 # endif]],
1703 [[char buf; return setvbuf (stdout, &buf, _IOLBF, 1);]])],
1704 [# It compiles and links either way, so it must not be declared
1705 # with a prototype and most likely this is a K&R C compiler.
1706 # Try running it.
1707 AC_RUN_IFELSE(
1708 [AC_LANG_PROGRAM(
1709 [AC_INCLUDES_DEFAULT],
1710 [[/* This call has the arguments reversed.
1711 A reversed system may check and see that the address of buf
1712 is not _IOLBF, _IONBF, or _IOFBF, and return nonzero. */
1713 char buf;
1714 if (setvbuf (stdout, _IOLBF, &buf, 1) != 0)
1715 return 1;
1716 putchar ('\r');
1717 return 0; /* Non-reversed systems SEGV here. */]])],
1718 [ac_cv_func_setvbuf_reversed=yes],
1719 [],
1720 [[: # Assume setvbuf is not reversed when cross-compiling.]])]
1721 ac_cv_func_setvbuf_reversed=yes)])])
1722 if test $ac_cv_func_setvbuf_reversed = yes; then
1723 AC_DEFINE(SETVBUF_REVERSED, 1,
1724 [Define to 1 if the `setvbuf' function takes the buffering type as
1725 its second argument and the buffer pointer as the third, as on
1726 System V before release 3.])
1727 fi
1728 ])# AC_FUNC_SETVBUF_REVERSED
1729
1730
1731 # AU::AC_SETVBUF_REVERSED
1732 # -----------------------
1733 AU_ALIAS([AC_SETVBUF_REVERSED], [AC_FUNC_SETVBUF_REVERSED])
1734
1735
1736 # AC_FUNC_STRCOLL
1737 # ---------------
1738 AN_FUNCTION([strcoll], [AC_FUNC_STRCOLL])
1739 AC_DEFUN([AC_FUNC_STRCOLL],
1740 [AC_CACHE_CHECK(for working strcoll, ac_cv_func_strcoll_works,
1741 [AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1742 [[return (strcoll ("abc", "def") >= 0 ||
1743 strcoll ("ABC", "DEF") >= 0 ||
1744 strcoll ("123", "456") >= 0)]])],
1745 ac_cv_func_strcoll_works=yes,
1746 ac_cv_func_strcoll_works=no,
1747 ac_cv_func_strcoll_works=no)])
1748 if test $ac_cv_func_strcoll_works = yes; then
1749 AC_DEFINE(HAVE_STRCOLL, 1,
1750 [Define to 1 if you have the `strcoll' function and it is properly
1751 defined.])
1752 fi
1753 ])# AC_FUNC_STRCOLL
1754
1755
1756 # AU::AC_STRCOLL
1757 # --------------
1758 AU_ALIAS([AC_STRCOLL], [AC_FUNC_STRCOLL])
1759
1760
1761 # AC_FUNC_UTIME_NULL
1762 # ------------------
1763 AN_FUNCTION([utime], [AC_FUNC_UTIME_NULL])
1764 AC_DEFUN([AC_FUNC_UTIME_NULL],
1765 [AC_CHECK_HEADERS_ONCE(utime.h)
1766 AC_CACHE_CHECK(whether utime accepts a null argument, ac_cv_func_utime_null,
1767 [rm -f conftest.data; >conftest.data
1768 # Sequent interprets utime(file, 0) to mean use start of epoch. Wrong.
1769 AC_RUN_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
1770 #ifdef HAVE_UTIME_H
1771 # include <utime.h>
1772 #endif],
1773 [[struct stat s, t;
1774 return ! (stat ("conftest.data", &s) == 0
1775 && utime ("conftest.data", 0) == 0
1776 && stat ("conftest.data", &t) == 0
1777 && t.st_mtime >= s.st_mtime
1778 && t.st_mtime - s.st_mtime < 120);]])],
1779 ac_cv_func_utime_null=yes,
1780 ac_cv_func_utime_null=no,
1781 ac_cv_func_utime_null=no)])
1782 if test $ac_cv_func_utime_null = yes; then
1783 AC_DEFINE(HAVE_UTIME_NULL, 1,
1784 [Define to 1 if `utime(file, NULL)' sets file's timestamp to the
1785 present.])
1786 fi
1787 rm -f conftest.data
1788 ])# AC_FUNC_UTIME_NULL
1789
1790
1791 # AU::AC_UTIME_NULL
1792 # -----------------
1793 AU_ALIAS([AC_UTIME_NULL], [AC_FUNC_UTIME_NULL])
1794
1795
1796 # AC_FUNC_FORK
1797 # -------------
1798 AN_FUNCTION([fork], [AC_FUNC_FORK])
1799 AN_FUNCTION([vfork], [AC_FUNC_FORK])
1800 AC_DEFUN([AC_FUNC_FORK],
1801 [AC_REQUIRE([AC_TYPE_PID_T])dnl
1802 AC_CHECK_HEADERS(vfork.h)
1803 AC_CHECK_FUNCS(fork vfork)
1804 if test "x$ac_cv_func_fork" = xyes; then
1805 _AC_FUNC_FORK
1806 else
1807 ac_cv_func_fork_works=$ac_cv_func_fork
1808 fi
1809 if test "x$ac_cv_func_fork_works" = xcross; then
1810 case $host in
1811 *-*-amigaos* | *-*-msdosdjgpp*)
1812 # Override, as these systems have only a dummy fork() stub
1813 ac_cv_func_fork_works=no
1814 ;;
1815 *)
1816 ac_cv_func_fork_works=yes
1817 ;;
1818 esac
1819 AC_MSG_WARN([result $ac_cv_func_fork_works guessed because of cross compilation])
1820 fi
1821 ac_cv_func_vfork_works=$ac_cv_func_vfork
1822 if test "x$ac_cv_func_vfork" = xyes; then
1823 _AC_FUNC_VFORK
1824 fi;
1825 if test "x$ac_cv_func_fork_works" = xcross; then
1826 ac_cv_func_vfork_works=$ac_cv_func_vfork
1827 AC_MSG_WARN([result $ac_cv_func_vfork_works guessed because of cross compilation])
1828 fi
1829
1830 if test "x$ac_cv_func_vfork_works" = xyes; then
1831 AC_DEFINE(HAVE_WORKING_VFORK, 1, [Define to 1 if `vfork' works.])
1832 else
1833 AC_DEFINE(vfork, fork, [Define as `fork' if `vfork' does not work.])
1834 fi
1835 if test "x$ac_cv_func_fork_works" = xyes; then
1836 AC_DEFINE(HAVE_WORKING_FORK, 1, [Define to 1 if `fork' works.])
1837 fi
1838 ])# AC_FUNC_FORK
1839
1840
1841 # _AC_FUNC_FORK
1842 # -------------
1843 AC_DEFUN([_AC_FUNC_FORK],
1844 [AC_CACHE_CHECK(for working fork, ac_cv_func_fork_works,
1845 [AC_RUN_IFELSE(
1846 [AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT],
1847 [
1848 /* By Ruediger Kuhlmann. */
1849 return fork () < 0;
1850 ])],
1851 [ac_cv_func_fork_works=yes],
1852 [ac_cv_func_fork_works=no],
1853 [ac_cv_func_fork_works=cross])])]
1854 )# _AC_FUNC_FORK
1855
1856
1857 # _AC_FUNC_VFORK
1858 # -------------
1859 AC_DEFUN([_AC_FUNC_VFORK],
1860 [AC_CACHE_CHECK(for working vfork, ac_cv_func_vfork_works,
1861 [AC_RUN_IFELSE([AC_LANG_SOURCE([[/* Thanks to Paul Eggert for this test. */
1862 ]AC_INCLUDES_DEFAULT[
1863 #include <sys/wait.h>
1864 #ifdef HAVE_VFORK_H
1865 # include <vfork.h>
1866 #endif
1867 /* On some sparc systems, changes by the child to local and incoming
1868 argument registers are propagated back to the parent. The compiler
1869 is told about this with #include <vfork.h>, but some compilers
1870 (e.g. gcc -O) don't grok <vfork.h>. Test for this by using a
1871 static variable whose address is put into a register that is
1872 clobbered by the vfork. */
1873 static void
1874 #ifdef __cplusplus
1875 sparc_address_test (int arg)
1876 # else
1877 sparc_address_test (arg) int arg;
1878 #endif
1879 {
1880 static pid_t child;
1881 if (!child) {
1882 child = vfork ();
1883 if (child < 0) {
1884 perror ("vfork");
1885 _exit(2);
1886 }
1887 if (!child) {
1888 arg = getpid();
1889 write(-1, "", 0);
1890 _exit (arg);
1891 }
1892 }
1893 }
1894
1895 int
1896 main ()
1897 {
1898 pid_t parent = getpid ();
1899 pid_t child;
1900
1901 sparc_address_test (0);
1902
1903 child = vfork ();
1904
1905 if (child == 0) {
1906 /* Here is another test for sparc vfork register problems. This
1907 test uses lots of local variables, at least as many local
1908 variables as main has allocated so far including compiler
1909 temporaries. 4 locals are enough for gcc 1.40.3 on a Solaris
1910 4.1.3 sparc, but we use 8 to be safe. A buggy compiler should
1911 reuse the register of parent for one of the local variables,
1912 since it will think that parent can't possibly be used any more
1913 in this routine. Assigning to the local variable will thus
1914 munge parent in the parent process. */
1915 pid_t
1916 p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(),
1917 p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid();
1918 /* Convince the compiler that p..p7 are live; otherwise, it might
1919 use the same hardware register for all 8 local variables. */
1920 if (p != p1 || p != p2 || p != p3 || p != p4
1921 || p != p5 || p != p6 || p != p7)
1922 _exit(1);
1923
1924 /* On some systems (e.g. IRIX 3.3), vfork doesn't separate parent
1925 from child file descriptors. If the child closes a descriptor
1926 before it execs or exits, this munges the parent's descriptor
1927 as well. Test for this by closing stdout in the child. */
1928 _exit(close(fileno(stdout)) != 0);
1929 } else {
1930 int status;
1931 struct stat st;
1932
1933 while (wait(&status) != child)
1934 ;
1935 return (
1936 /* Was there some problem with vforking? */
1937 child < 0
1938
1939 /* Did the child fail? (This shouldn't happen.) */
1940 || status
1941
1942 /* Did the vfork/compiler bug occur? */
1943 || parent != getpid()
1944
1945 /* Did the file descriptor bug occur? */
1946 || fstat(fileno(stdout), &st) != 0
1947 );
1948 }
1949 }]])],
1950 [ac_cv_func_vfork_works=yes],
1951 [ac_cv_func_vfork_works=no],
1952 [ac_cv_func_vfork_works=cross])])
1953 ])# _AC_FUNC_VFORK
1954
1955
1956 # AU::AC_FUNC_VFORK
1957 # ------------
1958 AU_ALIAS([AC_FUNC_VFORK], [AC_FUNC_FORK])
1959
1960 # AU::AC_VFORK
1961 # ------------
1962 AU_ALIAS([AC_VFORK], [AC_FUNC_FORK])
1963
1964
1965 # AC_FUNC_VPRINTF
1966 # ---------------
1967 # Why the heck is that _doprnt does not define HAVE__DOPRNT???
1968 # That the logical name!
1969 AN_FUNCTION([vfprintf], [AC_FUNC_VPRINTF])
1970 AN_FUNCTION([vprintf], [AC_FUNC_VPRINTF])
1971 AN_FUNCTION([vsprintf], [AC_FUNC_VPRINTF])
1972 AN_FUNCTION([_doprnt], [AC_FUNC_VPRINTF])
1973 AC_DEFUN([AC_FUNC_VPRINTF],
1974 [AC_CHECK_FUNCS(vprintf, []
1975 [AC_CHECK_FUNC(_doprnt,
1976 [AC_DEFINE(HAVE_DOPRNT, 1,
1977 [Define to 1 if you don't have `vprintf' but do have
1978 `_doprnt.'])])])
1979 ])
1980
1981
1982 # AU::AC_VPRINTF
1983 # --------------
1984 AU_ALIAS([AC_VPRINTF], [AC_FUNC_VPRINTF])
1985
1986
1987 # AC_FUNC_WAIT3
1988 # -------------
1989 # Don't bother too hard maintaining this macro, as it's obsoleted.
1990 # We don't AU define it, since we don't have any alternative to propose,
1991 # any invocation should be removed, and the code adjusted.
1992 AN_FUNCTION([wait3], [AC_FUNC_WAIT3])
1993 AC_DEFUN([AC_FUNC_WAIT3],
1994 [AC_DIAGNOSE([obsolete],
1995 [$0: `wait3' has been removed from POSIX.
1996 Remove this `AC_FUNC_WAIT3' and adjust your code to use `waitpid' instead.])dnl
1997 AC_CACHE_CHECK([for wait3 that fills in rusage],
1998 [ac_cv_func_wait3_rusage],
1999 [AC_RUN_IFELSE([AC_LANG_SOURCE(
2000 [AC_INCLUDES_DEFAULT[
2001 #include <sys/time.h>
2002 #include <sys/resource.h>
2003 #include <sys/wait.h>
2004 /* HP-UX has wait3 but does not fill in rusage at all. */
2005 int
2006 main ()
2007 {
2008 struct rusage r;
2009 int i;
2010 /* Use a field that we can force nonzero --
2011 voluntary context switches.
2012 For systems like NeXT and OSF/1 that don't set it,
2013 also use the system CPU time. And page faults (I/O) for Linux. */
2014 r.ru_nvcsw = 0;
2015 r.ru_stime.tv_sec = 0;
2016 r.ru_stime.tv_usec = 0;
2017 r.ru_majflt = r.ru_minflt = 0;
2018 switch (fork ())
2019 {
2020 case 0: /* Child. */
2021 sleep(1); /* Give up the CPU. */
2022 _exit(0);
2023 break;
2024 case -1: /* What can we do? */
2025 _exit(0);
2026 break;
2027 default: /* Parent. */
2028 wait3(&i, 0, &r);
2029 /* Avoid "text file busy" from rm on fast HP-UX machines. */
2030 sleep(2);
2031 return (r.ru_nvcsw == 0 && r.ru_majflt == 0 && r.ru_minflt == 0
2032 && r.ru_stime.tv_sec == 0 && r.ru_stime.tv_usec == 0);
2033 }
2034 }]])],
2035 [ac_cv_func_wait3_rusage=yes],
2036 [ac_cv_func_wait3_rusage=no],
2037 [ac_cv_func_wait3_rusage=no])])
2038 if test $ac_cv_func_wait3_rusage = yes; then
2039 AC_DEFINE(HAVE_WAIT3, 1,
2040 [Define to 1 if you have the `wait3' system call.
2041 Deprecated, you should no longer depend upon `wait3'.])
2042 fi
2043 ])# AC_FUNC_WAIT3
2044
2045
2046 # AU::AC_WAIT3
2047 # ------------
2048 AU_ALIAS([AC_WAIT3], [AC_FUNC_WAIT3])