1 # This file is part of Autoconf. -*- Autoconf -*-
2 # Checking for headers.
4 # Copyright (C) 1988, 1999-2004, 2006, 2008-2017 Free Software
7 # This file is part of Autoconf. This program is free
8 # software; you can redistribute it and/or modify it under the
9 # terms of the GNU General Public License as published by the
10 # Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # Under Section 7 of GPL version 3, you are granted additional
19 # permissions described in the Autoconf Configure Script Exception,
20 # version 3.0, as published by the Free Software Foundation.
22 # You should have received a copy of the GNU General Public License
23 # and a copy of the Autoconf Configure Script Exception along with
24 # this program; see the files COPYINGv3 and COPYING.EXCEPTION
25 # respectively. If not, see <http://www.gnu.org/licenses/>.
27 # Written by David MacKenzie, with help from
28 # Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
29 # Roland McGrath, Noah Friedman, david d zuhn, and many others.
34 # 1. Generic tests for headers
36 # 3. Headers to tests with AC_CHECK_HEADERS
37 # 4. Tests for specific headers
40 ## ------------------------------ ##
41 ## 1. Generic tests for headers. ##
42 ## ------------------------------ ##
45 # AC_CHECK_HEADER(HEADER-FILE,
46 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
48 # ---------------------------------------------------------
49 # This used to check for headers using the preprocessor only, but we
50 # have now switched to running a full compilation, so that we learn
51 # about the usability of a header instead of its mere presence.
52 # The old behavior is still available by specifying `-' as the
53 # INCLUDES, but this triggers a deprecation warning.
55 # The m4_indir allows for fewer expansions of $@.
56 AC_DEFUN([AC_CHECK_HEADER],
57 [m4_indir(m4_if([$4], [-],
58 [[_AC_CHECK_HEADER_PREPROC]],
59 [[_AC_CHECK_HEADER_COMPILE]]), $@)])
62 # _AC_CHECK_HEADER_COMPILE_BODY
63 # -----------------------------
64 # Shell function body for _AC_CHECK_HEADER_COMPILE
65 m4_define([_AC_CHECK_HEADER_COMPILE_BODY],
66 [ AS_LINENO_PUSH([$[]1])
67 AC_CACHE_CHECK([for $[]2], [$[]3],
68 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([$[]4
69 @%:@include <$[]2>])],
70 [AS_VAR_SET([$[]3], [yes])],
71 [AS_VAR_SET([$[]3], [no])])])
73 ])# _AC_CHECK_HEADER_COMPILE_BODY
76 m4_define([_AC_CHECK_HEADER_COMPILE_FN],
77 [AC_REQUIRE_SHELL_FN([ac_fn_]_AC_LANG_ABBREV[_check_header_compile],
78 [AS_FUNCTION_DESCRIBE([ac_fn_]_AC_LANG_ABBREV[_check_header_compile],
79 [LINENO HEADER VAR INCLUDES],
80 [Tests whether HEADER exists and can be compiled using the include files
81 in INCLUDES, setting the cache variable VAR accordingly.])],
82 [_AC_CHECK_HEADER_COMPILE_BODY])])
84 # _AC_CHECK_HEADER_COMPILE(HEADER-FILE,
85 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
86 # [INCLUDES = DEFAULT-INCLUDES])
87 # --------------------------------------------------------------
88 # Check the compiler accepts HEADER-FILE. The INCLUDES are defaulted.
89 AC_DEFUN([_AC_CHECK_HEADER_COMPILE],
90 [_AC_CHECK_HEADER_COMPILE_FN()]dnl
91 [AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])]dnl
92 [ac_fn_[]_AC_LANG_ABBREV[]_check_header_compile ]dnl
93 ["$LINENO" "$1" "ac_Header" "AS_ESCAPE([AC_INCLUDES_DEFAULT([$4])], [""])"
94 AS_VAR_IF([ac_Header], [yes], [$2], [$3])
95 AS_VAR_POPDEF([ac_Header])])# _AC_CHECK_HEADER_COMPILE
98 # _AC_CHECK_HEADER_PREPROC_BODY
99 # -----------------------------
100 # Shell function body for _AC_CHECK_HEADER_PREPROC.
101 m4_define([_AC_CHECK_HEADER_PREPROC_BODY],
102 [ AS_LINENO_PUSH([$[]1])
103 AC_CACHE_CHECK([for $[]2], [$[]3],
104 [AC_PREPROC_IFELSE([AC_LANG_SOURCE([@%:@include <$[]2>])],
105 [AS_VAR_SET([$[]3], [yes])],
106 [AS_VAR_SET([$[]3], [no])])])
108 ])# _AC_CHECK_HEADER_PREPROC_BODY
111 # _AC_CHECK_HEADER_PREPROC(HEADER-FILE,
112 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
113 # --------------------------------------------------------------
114 # Check the preprocessor accepts HEADER-FILE.
115 AC_DEFUN([_AC_CHECK_HEADER_PREPROC],
116 [AC_DIAGNOSE([obsolete], [Checking for headers with the preprocessor is
117 deprecated. Specify prerequisite code to AC_CHECK_HEADER
118 instead of using fourth argument `-'. (Many headers need
119 no prerequisites. If you truly need to test whether
120 something passes the preprocessor but not the compiler,
121 use AC_PREPROC_IFELSE.)])]dnl
122 [AC_REQUIRE_SHELL_FN([ac_fn_]_AC_LANG_ABBREV[_check_header_preproc],
123 [AS_FUNCTION_DESCRIBE([ac_fn_]_AC_LANG_ABBREV[_check_header_preproc],
125 [Tests whether HEADER exists and can be preprocessed (in isolation),
126 setting the cache variable VAR accordingly.])],
128 [AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])]dnl
129 [ac_fn_[]_AC_LANG_ABBREV[]_check_header_preproc "$LINENO" "$1" "ac_Header"
130 AS_VAR_IF([ac_Header], [yes], [$2], [$3])
131 AS_VAR_POPDEF([ac_Header])])# _AC_CHECK_HEADER_PREPROC
134 # _AC_CHECK_HEADER_OLD(HEADER-FILE, [ACTION-IF-FOUND],
135 # [ACTION-IF-NOT-FOUND])
136 # _AC_CHECK_HEADER_NEW(HEADER-FILE, [ACTION-IF-FOUND],
137 # [ACTION-IF-NOT-FOUND])
138 # ----------------------------------------------------
139 # Some packages used these undocumented macros. Even worse, gcc
140 # redefined AC_CHECK_HEADER in terms of _AC_CHECK_HEADER_OLD, so we
141 # can't do the simpler:
142 # AU_DEFUN([_AC_CHECK_HEADER_OLD],
143 # [AC_CHECK_HEADER([$1], [$2], [$3], [-])])
144 AC_DEFUN([_AC_CHECK_HEADER_OLD],
145 [AC_DIAGNOSE([obsolete], [The macro `$0' is obsolete.
146 You should use AC_CHECK_HEADER with a fourth argument.])]dnl
147 [_AC_CHECK_HEADER_PREPROC($@)])
149 AC_DEFUN([_AC_CHECK_HEADER_NEW],
150 [AC_DIAGNOSE([obsolete], [The macro `$0' is obsolete.
151 You should use AC_CHECK_HEADER with a fourth argument.])]dnl
152 [_AC_CHECK_HEADER_COMPILE($@)])
154 # _AC_CHECK_HEADER_MONGREL(HEADER-FILE,
155 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
156 # ------------------------------------------------------------------
157 # In case anyone used this undocumented macro. Map to the _PREPROC
158 # semantics to minimize the chance of breaking anything.
159 AU_DEFUN([_AC_CHECK_HEADER_MONGREL],
160 [AC_CHECK_HEADER([$1], [$2], [$3], [-])])
163 # _AH_CHECK_HEADER(HEADER-FILE)
164 # -----------------------------
165 # Prepare the autoheader snippet for HEADER-FILE.
166 m4_define([_AH_CHECK_HEADER],
167 [AH_TEMPLATE(AS_TR_CPP([HAVE_$1]),
168 [Define to 1 if you have the <$1> header file.])])
171 # AH_CHECK_HEADERS(HEADER-FILE...)
172 # --------------------------------
173 m4_define([AH_CHECK_HEADERS],
174 [m4_foreach_w([AC_Header], [$1], [_AH_CHECK_HEADER(m4_defn([AC_Header]))])])
177 # AC_CHECK_HEADERS(HEADER-FILE...,
178 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
180 # ----------------------------------------------------------
181 # Check for each whitespace-separated HEADER-FILE (omitting the <> or
182 # ""), and perform ACTION-IF-FOUND or ACTION-IF-NOT-FOUND for each
183 # header. INCLUDES is as for AC_CHECK_HEADER. Additionally, make the
184 # preprocessor definition HAVE_HEADER_FILE available for each found
185 # header. Either ACTION may include `break' to stop the search.
186 AC_DEFUN([AC_CHECK_HEADERS],
187 [m4_map_args_w([$1], [_AH_CHECK_HEADER(], [)])]dnl
188 [m4_if([$2$3]AS_LITERAL_IF([$1], [[yes]], [[no]]), [yes],
189 [m4_map_args_w([$1], [_$0(], [, [], [], [$4])])],
190 [AS_FOR([AC_header], [ac_header], [$1], [_$0(AC_header, [$2], [$3], [$4])])])dnl
193 m4_define([_AC_CHECK_HEADERS],
194 [AC_CHECK_HEADER([$1],
195 [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_]$1)) $2],
200 # _AC_CHECK_HEADER_ONCE(HEADER-FILE)
201 # ----------------------------------
202 # Check for a single HEADER-FILE once.
203 m4_define([_AC_CHECK_HEADER_ONCE],
204 [_AH_CHECK_HEADER([$1])AC_DEFUN([_AC_Header_]m4_translit([[$1]],
205 [./-], [___]), [m4_divert_text([INIT_PREPARE],
206 [AS_VAR_APPEND([ac_header_]]_AC_LANG_ABBREV[[_list],
207 [" $1 ]AS_TR_SH([$1]) AS_TR_CPP([HAVE_$1])["])])]dnl
208 [_AC_HEADERS_EXPANSION(_AC_LANG_ABBREV)])AC_REQUIRE(
209 [_AC_Header_]m4_translit([[$1]], [./-], [___]))])
212 # AC_CHECK_HEADERS_ONCE(HEADER-FILE...)
213 # -------------------------------------
214 # Add each whitespace-separated name in HEADER-FILE to the list of
215 # headers to check once.
216 # Note: has intimate knowledge of how AC_INCLUDES_DEFAULT works,
218 AC_DEFUN([AC_CHECK_HEADERS_ONCE],
219 [AC_REQUIRE([AC_CHECK_INCLUDES_DEFAULT])]dnl
220 [_AC_CHECK_HEADERS_ONCE([$1])])
222 AC_DEFUN([_AC_CHECK_HEADERS_ONCE],
223 [m4_map_args_w([$1], [_AC_CHECK_HEADER_ONCE(], [)])])
225 # _AC_HEADERS_EXPANSION(LANG)
226 # ---------------------------
227 # One-shot code per language LANG for checking all headers registered by
228 # AC_CHECK_HEADERS_ONCE while that language was active. We have to inline
229 # portions of AC_CHECK_HEADER_COMPILE, because although we operate on shell
230 # variables, we know they represent literals at that point in time,
231 # where we don't want to trigger normal AS_VAR_PUSHDEF shell code.
232 m4_define([_AC_HEADERS_EXPANSION],
233 [m4_ifndef([$0($1)], [m4_define([$0($1)])m4_divert_text([DEFAULTS],
234 [ac_header_$1_list=])ac_header= ac_cache=
235 for ac_item in $ac_header_$1_list
237 if test $ac_cache; then
238 _AC_CHECK_HEADER_COMPILE_FN()ac_fn_$1_check_header_compile "$LINENO" ]dnl
239 [$ac_header ac_cv_header_$ac_cache "$ac_includes_default"
240 if eval test \"x\$ac_cv_header_$ac_cache\" = xyes; then
241 printf "%s\n" "[#]define $ac_item 1" >> confdefs.h
244 elif test $ac_header; then
253 ## --------------------- ##
254 ## 2. Default includes. ##
255 ## --------------------- ##
257 # Always use the same set of default headers for all the generic
258 # macros. It is easier to document, to extend, and to understand than
259 # having specific defaults for each macro.
261 # AC_CHECK_INCLUDES_DEFAULT
262 # -------------------------
263 # Required when AC_INCLUDES_DEFAULT uses its default branch.
264 AC_DEFUN_ONCE([AC_CHECK_INCLUDES_DEFAULT],
265 dnl If ever you change this variable, please keep autoconf.texi in sync.
266 [m4_divert_text([DEFAULTS],
267 [# Factoring default headers for most tests.
268 ac_includes_default="\
273 #ifdef HAVE_SYS_TYPES_H
274 # include <sys/types.h>
276 #ifdef HAVE_SYS_STAT_H
277 # include <sys/stat.h>
279 #ifdef HAVE_STRINGS_H
280 # include <strings.h>
282 #ifdef HAVE_INTTYPES_H
283 # include <inttypes.h>
292 [_AC_CHECK_HEADERS_ONCE(
293 [sys/types.h sys/stat.h strings.h inttypes.h stdint.h unistd.h])]dnl
294 dnl For backward compatibility, provide unconditional AC_DEFINEs of
295 dnl HAVE_STDLIB_H, HAVE_STRING_H, and STDC_HEADERS.
296 [AC_DEFINE([HAVE_STDLIB_H], [1],
297 [Always define to 1, for backward compatibility.
298 You can assume <stdlib.h> exists.])]dnl
299 [AC_DEFINE([HAVE_STRING_H], [1],
300 [Always define to 1, for backward compatibility.
301 You can assume <string.h> exists.])]dnl
302 [AC_DEFINE([STDC_HEADERS], [1],
303 [Always define to 1, for backward compatibility.
304 You can assume the C90 standard headers exist.])])
305 # AC_CHECK_INCLUDES_DEFAULT
308 # AC_INCLUDES_DEFAULT([INCLUDES])
309 # -------------------------------
310 # If INCLUDES is empty, expand in default includes, otherwise in
312 # In most cases INCLUDES is not double quoted as it should, and if
313 # for instance INCLUDES = `#include <stdio.h>' then unless we force
314 # a newline, the hash will swallow the closing paren etc. etc.
316 # Take no risk: for the newline.
317 AC_DEFUN([AC_INCLUDES_DEFAULT],
320 [AC_REQUIRE([AC_CHECK_INCLUDES_DEFAULT])]dnl
321 [$ac_includes_default])])
324 ## ------------------------------------------- ##
325 ## 3. Headers to check with AC_CHECK_HEADERS. ##
326 ## ------------------------------------------- ##
328 # There is no longer any need to check for headers that are part of
329 # ISO C90 (as amended): assert.h, ctype.h, errno.h, float.h, iso646.h,
330 # limits.h, locale.h, math.h, setjmp.h, signal.h, stdarg.h, stddef.h,
331 # stdio.h, stdlib.h, string.h, time.h, wchar.h, wctype.h.
333 AN_HEADER([OS.h], [AC_CHECK_HEADERS])
334 AN_HEADER([argz.h], [AC_CHECK_HEADERS])
335 AN_HEADER([arpa/inet.h], [AC_CHECK_HEADERS])
336 AN_HEADER([fcntl.h], [AC_CHECK_HEADERS])
337 AN_HEADER([fenv.h], [AC_CHECK_HEADERS])
338 AN_HEADER([fs_info.h], [AC_CHECK_HEADERS])
339 AN_HEADER([inttypes.h], [AC_CHECK_HEADERS])
340 AN_HEADER([langinfo.h], [AC_CHECK_HEADERS])
341 AN_HEADER([libintl.h], [AC_CHECK_HEADERS])
342 AN_HEADER([mach/mach.h], [AC_CHECK_HEADERS])
343 AN_HEADER([malloc.h], [AC_CHECK_HEADERS])
344 AN_HEADER([mntent.h], [AC_CHECK_HEADERS])
345 AN_HEADER([mnttab.h], [AC_CHECK_HEADERS])
346 AN_HEADER([netdb.h], [AC_CHECK_HEADERS])
347 AN_HEADER([netinet/in.h], [AC_CHECK_HEADERS])
348 AN_HEADER([nl_types.h], [AC_CHECK_HEADERS])
349 AN_HEADER([nlist.h], [AC_CHECK_HEADERS])
350 AN_HEADER([paths.h], [AC_CHECK_HEADERS])
351 AN_HEADER([sgtty.h], [AC_CHECK_HEADERS])
352 AN_HEADER([shadow.h], [AC_CHECK_HEADERS])
353 AN_HEADER([stdint.h], [AC_CHECK_HEADERS])
354 AN_HEADER([stdio_ext.h], [AC_CHECK_HEADERS])
355 AN_HEADER([strings.h], [AC_CHECK_HEADERS])
356 AN_HEADER([sys/acl.h], [AC_CHECK_HEADERS])
357 AN_HEADER([sys/file.h], [AC_CHECK_HEADERS])
358 AN_HEADER([sys/filsys.h], [AC_CHECK_HEADERS])
359 AN_HEADER([sys/fs/s5param.h], [AC_CHECK_HEADERS])
360 AN_HEADER([sys/fs_types.h], [AC_CHECK_HEADERS])
361 AN_HEADER([sys/fstyp.h], [AC_CHECK_HEADERS])
362 AN_HEADER([sys/ioctl.h], [AC_CHECK_HEADERS])
363 AN_HEADER([sys/mntent.h], [AC_CHECK_HEADERS])
364 AN_HEADER([sys/mount.h], [AC_CHECK_HEADERS])
365 AN_HEADER([sys/param.h], [AC_CHECK_HEADERS])
366 AN_HEADER([sys/socket.h], [AC_CHECK_HEADERS])
367 AN_HEADER([sys/statfs.h], [AC_CHECK_HEADERS])
368 AN_HEADER([sys/statvfs.h], [AC_CHECK_HEADERS])
369 AN_HEADER([sys/systeminfo.h], [AC_CHECK_HEADERS])
370 AN_HEADER([sys/time.h], [AC_CHECK_HEADERS])
371 AN_HEADER([sys/timeb.h], [AC_CHECK_HEADERS])
372 AN_HEADER([sys/vfs.h], [AC_CHECK_HEADERS])
373 AN_HEADER([sys/window.h], [AC_CHECK_HEADERS])
374 AN_HEADER([syslog.h], [AC_CHECK_HEADERS])
375 AN_HEADER([termio.h], [AC_CHECK_HEADERS])
376 AN_HEADER([termios.h], [AC_CHECK_HEADERS])
377 AN_HEADER([unistd.h], [AC_CHECK_HEADERS])
378 AN_HEADER([utime.h], [AC_CHECK_HEADERS])
379 AN_HEADER([utmp.h], [AC_CHECK_HEADERS])
380 AN_HEADER([utmpx.h], [AC_CHECK_HEADERS])
381 AN_HEADER([values.h], [AC_CHECK_HEADERS])
383 ## ------------------------------- ##
384 ## 4. Tests for specific headers. ##
385 ## ------------------------------- ##
389 # Check whether to enable assertions.
390 AC_DEFUN_ONCE([AC_HEADER_ASSERT],
392 AC_MSG_CHECKING([whether to enable assertions])
393 AC_ARG_ENABLE([assert],
394 [AS_HELP_STRING([--disable-assert], [turn off assertions])],
395 [ac_enable_assert=$enableval
397 [test "x$enableval" = xno],
398 [AC_DEFINE([NDEBUG], [1],
399 [Define to 1 if assertions should be disabled.])],
400 [test "x$enableval" != xyes],
401 [AC_MSG_WARN([invalid argument supplied to --enable-assert])
402 ac_enable_assert=yes])],
403 [ac_enable_assert=yes])
404 AC_MSG_RESULT([$ac_enable_assert])
408 # _AC_CHECK_HEADER_DIRENT(HEADER-FILE,
409 # [ACTION-IF-FOUND], [ACTION-IF-NOT_FOUND])
410 # -----------------------------------------------------------------
411 # Like AC_CHECK_HEADER, except also make sure that HEADER-FILE
412 # defines the type `DIR'. dirent.h on NextStep 3.2 doesn't.
413 m4_define([_AC_CHECK_HEADER_DIRENT],
414 [AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_dirent_$1])dnl
415 AC_CACHE_CHECK([for $1 that defines DIR], [ac_Header],
416 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
421 [AS_VAR_SET([ac_Header], [yes])],
422 [AS_VAR_SET([ac_Header], [no])])])
423 AS_VAR_IF([ac_Header], [yes], [$2], [$3])
424 AS_VAR_POPDEF([ac_Header])dnl
425 ])# _AC_CHECK_HEADER_DIRENT
428 # _AH_CHECK_HEADER_DIRENT(HEADERS)
429 # --------------------------------
430 # Like _AH_CHECK_HEADER, but tuned to a dirent provider.
431 m4_define([_AH_CHECK_HEADER_DIRENT],
432 [AH_TEMPLATE(AS_TR_CPP([HAVE_$1]),
433 [Define to 1 if you have the <$1> header file, and it defines `DIR'.])])
438 AC_DEFUN([AC_HEADER_DIRENT],
439 [m4_map_args([_AH_CHECK_HEADER_DIRENT], [dirent.h], [sys/ndir.h],
440 [sys/dir.h], [ndir.h])]dnl
442 for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
443 _AC_CHECK_HEADER_DIRENT($ac_hdr,
444 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$ac_hdr), 1)
445 ac_header_dirent=$ac_hdr; break])
447 # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
448 if test $ac_header_dirent = dirent.h; then
449 AC_SEARCH_LIBS(opendir, dir)
451 AC_SEARCH_LIBS(opendir, x)
458 # Thanks to glibc 2.25 deprecating macros in sys/types.h, coupled with
459 # back-compat to autoconf 2.69, we need the following logic:
460 # Check whether <sys/types.h> compiles.
461 # If <sys/mkdev.h> compiles, assume it provides major/minor/makedev.
462 # Otherwise, if <sys/sysmacros.h> compiles, assume it provides the macros.
463 # Otherwise, either the macros were provided by <sys/types.h>, or do
464 # not exist on the platform. Code trying to use these three macros is
465 # assumed to not care about platforms that lack the macros.
466 AN_FUNCTION([major], [AC_HEADER_MAJOR])
467 AN_FUNCTION([makedev], [AC_HEADER_MAJOR])
468 AN_FUNCTION([minor], [AC_HEADER_MAJOR])
469 AN_HEADER([sys/mkdev.h], [AC_HEADER_MAJOR])
470 AC_DEFUN([AC_HEADER_MAJOR],
471 [AC_CHECK_HEADERS_ONCE([sys/types.h])
472 AC_CHECK_HEADER(sys/mkdev.h,
473 [AC_DEFINE(MAJOR_IN_MKDEV, 1,
474 [Define to 1 if `major', `minor', and `makedev' are
475 declared in <mkdev.h>.])])
476 if test $ac_cv_header_sys_mkdev_h = no; then
477 AC_CHECK_HEADER(sys/sysmacros.h,
478 [AC_DEFINE(MAJOR_IN_SYSMACROS, 1,
479 [Define to 1 if `major', `minor', and `makedev'
480 are declared in <sysmacros.h>.])])
487 # According to http://www.mcsr.olemiss.edu/cgi-bin/man-cgi?resolver+3
488 # (or http://www.chemie.fu-berlin.de/cgi-bin/man/sgi_irix?resolver+3),
489 # sys/types.h, netinet/in.h and arpa/nameser.h are required on IRIX.
490 # netinet/in.h is needed on Cygwin, too.
491 # With Solaris 9, netdb.h is required, to get symbols like HOST_NOT_FOUND.
493 AN_HEADER(resolv.h, [AC_HEADER_RESOLV])
494 AC_DEFUN([AC_HEADER_RESOLV],
495 [AC_CHECK_HEADERS(sys/types.h netinet/in.h arpa/nameser.h netdb.h resolv.h,
497 [[#ifdef HAVE_SYS_TYPES_H
498 # include <sys/types.h>
500 #ifdef HAVE_NETINET_IN_H
501 # include <netinet/in.h> /* inet_ functions / structs */
503 #ifdef HAVE_ARPA_NAMESER_H
504 # include <arpa/nameser.h> /* DNS HEADER struct */
514 # FIXME: Shouldn't this be named AC_HEADER_SYS_STAT?
515 AC_DEFUN([AC_HEADER_STAT],
516 [AC_CACHE_CHECK(whether stat file-mode macros are broken,
517 ac_cv_header_stat_broken,
518 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <sys/types.h>
519 #include <sys/stat.h>
521 #if defined S_ISBLK && defined S_IFDIR
522 extern char c1[S_ISBLK (S_IFDIR) ? -1 : 1];
525 #if defined S_ISBLK && defined S_IFCHR
526 extern char c2[S_ISBLK (S_IFCHR) ? -1 : 1];
529 #if defined S_ISLNK && defined S_IFREG
530 extern char c3[S_ISLNK (S_IFREG) ? -1 : 1];
533 #if defined S_ISSOCK && defined S_IFREG
534 extern char c4[S_ISSOCK (S_IFREG) ? -1 : 1];
536 ]])], ac_cv_header_stat_broken=no, ac_cv_header_stat_broken=yes)])
537 if test $ac_cv_header_stat_broken = yes; then
538 AC_DEFINE(STAT_MACROS_BROKEN, 1,
539 [Define to 1 if the `S_IS*' macros in <sys/stat.h> do not
545 # AC_CHECK_HEADER_STDBOOL
547 # Check for stdbool.h that conforms to C99.
548 AN_IDENTIFIER([bool], [AC_CHECK_HEADER_STDBOOL])
549 AN_IDENTIFIER([true], [AC_CHECK_HEADER_STDBOOL])
550 AN_IDENTIFIER([false],[AC_CHECK_HEADER_STDBOOL])
551 AC_DEFUN([AC_CHECK_HEADER_STDBOOL],
552 [AC_CACHE_CHECK([for stdbool.h that conforms to C99],
553 [ac_cv_header_stdbool_h],
559 #if __cplusplus < 201103
561 "error: bool is not defined"
564 "error: false is not defined"
567 "error: false is not 0"
570 "error: true is not defined"
573 "error: true is not 1"
577 #ifndef __bool_true_false_are_defined
578 "error: __bool_true_false_are_defined is not defined"
581 struct s { _Bool s: 1; _Bool t; } s;
583 char a[true == 1 ? 1 : -1];
584 char b[false == 0 ? 1 : -1];
585 char c[__bool_true_false_are_defined == 1 ? 1 : -1];
586 char d[(bool) 0.5 == true ? 1 : -1];
587 /* See body of main program for 'e'. */
588 char f[(_Bool) 0.0 == false ? 1 : -1];
590 char h[sizeof (_Bool)];
592 enum { j = false, k = true, l = false * true, m = true * 256 };
593 /* The following fails for
594 HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */
596 char o[sizeof n == m * sizeof n[0] ? 1 : -1];
597 char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
598 /* Catch a bug in an HP-UX C compiler. See
599 http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
600 http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
609 /* Refer to every declared value, to avoid compiler optimizations. */
610 return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
611 + !m + !n + !o + !p + !q + !pq);
613 [ac_cv_header_stdbool_h=yes],
614 [ac_cv_header_stdbool_h=no])])
615 AC_CHECK_TYPES([_Bool])
616 ])# AC_CHECK_HEADER_STDBOOL
621 # Define HAVE_STDBOOL_H if the system provides stdbool.h that conforms to C99.
622 AC_DEFUN([AC_HEADER_STDBOOL],
623 [AC_CHECK_HEADER_STDBOOL
624 if test $ac_cv_header_stdbool_h = yes; then
625 AC_DEFINE(HAVE_STDBOOL_H, 1, [Define to 1 if stdbool.h conforms to C99.])
627 ])# AC_HEADER_STDBOOL
632 AU_DEFUN([AC_HEADER_STDC],
633 [# Autoupdate added the following line to ensure that your configure
634 # script's behavior did not change. It is probably safe to remove.
635 AC_CHECK_INCLUDES_DEFAULT],
636 [The preprocessor macro `STDC_HEADERS' is obsolete.
637 Except in unusual embedded environments, you can safely include all
638 ISO C90 headers unconditionally.])
642 AC_DEFUN([AC_HEADER_SYS_WAIT],
643 [AC_CACHE_CHECK([for sys/wait.h that is POSIX.1 compatible],
644 ac_cv_header_sys_wait_h,
646 [AC_LANG_PROGRAM([#include <sys/types.h>
647 #include <sys/wait.h>
649 # define WEXITSTATUS(stat_val) ((unsigned int) (stat_val) >> 8)
652 # define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
657 s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;])],
658 [ac_cv_header_sys_wait_h=yes],
659 [ac_cv_header_sys_wait_h=no])])
660 if test $ac_cv_header_sys_wait_h = yes; then
661 AC_DEFINE(HAVE_SYS_WAIT_H, 1,
662 [Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible.])
664 ])# AC_HEADER_SYS_WAIT
669 AU_DEFUN([AC_HEADER_TIME],
670 [AC_CHECK_HEADERS_ONCE([sys/time.h])
671 # Obsolete code to be removed.
672 if test $ac_cv_header_sys_time_h = yes; then
673 AC_DEFINE(TIME_WITH_SYS_TIME, 1,
674 [Define to 1 if you can safely include both <sys/time.h>
675 and <time.h>. This macro is obsolete.])
677 # End of obsolete code.
678 ], [Update your code to rely only on HAVE_SYS_TIME_H,
679 then remove this warning and the obsolete code below it.
680 All current systems provide time.h; it need not be checked for.
681 Not all systems provide sys/time.h, but those that do, all allow
682 you to include it and time.h simultaneously.])
686 # _AC_HEADER_TIOCGWINSZ_IN_TERMIOS_H
687 # ----------------------------------
688 m4_define([_AC_HEADER_TIOCGWINSZ_IN_TERMIOS_H],
689 [AC_CACHE_CHECK([whether termios.h defines TIOCGWINSZ],
690 ac_cv_sys_tiocgwinsz_in_termios_h,
692 [#include <sys/types.h>
698 ac_cv_sys_tiocgwinsz_in_termios_h=yes,
699 ac_cv_sys_tiocgwinsz_in_termios_h=no)])
700 ])# _AC_HEADER_TIOCGWINSZ_IN_TERMIOS_H
703 # _AC_HEADER_TIOCGWINSZ_IN_SYS_IOCTL
704 # ----------------------------------
705 m4_define([_AC_HEADER_TIOCGWINSZ_IN_SYS_IOCTL],
706 [AC_CACHE_CHECK([whether sys/ioctl.h defines TIOCGWINSZ],
707 ac_cv_sys_tiocgwinsz_in_sys_ioctl_h,
709 [#include <sys/types.h>
710 #include <sys/ioctl.h>
715 ac_cv_sys_tiocgwinsz_in_sys_ioctl_h=yes,
716 ac_cv_sys_tiocgwinsz_in_sys_ioctl_h=no)])
717 ])# _AC_HEADER_TIOCGWINSZ_IN_SYS_IOCTL
720 # AC_HEADER_TIOCGWINSZ
721 # --------------------
722 # Look for a header that defines TIOCGWINSZ.
723 # FIXME: Is this the proper name? Is this the proper implementation?
725 AC_DEFUN([AC_HEADER_TIOCGWINSZ],
726 [_AC_HEADER_TIOCGWINSZ_IN_TERMIOS_H
727 if test $ac_cv_sys_tiocgwinsz_in_termios_h != yes; then
728 _AC_HEADER_TIOCGWINSZ_IN_SYS_IOCTL
729 if test $ac_cv_sys_tiocgwinsz_in_sys_ioctl_h = yes; then
730 AC_DEFINE(GWINSZ_IN_SYS_IOCTL,1,
731 [Define to 1 if `TIOCGWINSZ' requires <sys/ioctl.h>.])
734 ])# AC_HEADER_TIOCGWINSZ
739 AU_DEFUN([AC_UNISTD_H],
740 [# Autoupdate added the following line to ensure that your configure
741 # script's behavior did not change. It is probably safe to remove.
742 AC_CHECK_INCLUDES_DEFAULT])
747 # Define `USG' if string functions are *not* in strings.h.
749 [# Obsolete code to be removed.
750 AC_MSG_CHECKING([for BSD string and memory functions])
751 AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include <strings.h>]],
752 [[rindex(0, 0); bzero(0, 0);]])],
753 [AC_MSG_RESULT(yes)],
756 [Define to 1 if you do not have <strings.h>, index,
757 bzero, etc... This symbol is obsolete, you should
758 not depend upon it.])])
759 # End of obsolete code.
761 [Update your code to use string.h, then remove this
762 warning and the code below it. It is not necessary
763 to check for string.h.])
768 # To be precise this macro used to be:
770 # | AC_MSG_CHECKING(whether string.h declares mem functions)
771 # | AC_EGREP_HEADER(memchr, string.h, ac_found=yes, ac_found=no)
772 # | AC_MSG_RESULT($ac_found)
773 # | if test $ac_found = no; then
774 # | AC_CHECK_HEADER(memory.h, [AC_DEFINE(NEED_MEMORY_H)])
777 # But it is better to check for both headers, and alias NEED_MEMORY_H to
779 AU_DEFUN([AC_MEMORY_H],
780 [# Obsolete code to be removed.
781 AC_CHECK_HEADERS_ONCE([memory.h])
782 if test $ac_cv_header_memory_h = yes; then
783 AC_DEFINE([NEED_MEMORY_H], [1],
784 [Same as `HAVE_MEMORY_H', don't depend on me.])
786 # End of obsolete code.
788 [Update your code to use string.h, then remove this
789 warning and the code below it. It is not necessary
790 to check for string.h.])
795 # Like calling `AC_HEADER_DIRENT' and `AC_FUNC_CLOSEDIR_VOID', but
796 # defines a different set of C preprocessor macros to indicate which
797 # header file is found.
798 AU_DEFUN([AC_DIR_HEADER],
800 AC_FUNC_CLOSEDIR_VOID
801 test ac_cv_header_dirent_dirent_h &&
802 AC_DEFINE([DIRENT], 1, [Same as `HAVE_DIRENT_H', don't depend on me.])
803 test ac_cv_header_dirent_sys_ndir_h &&
804 AC_DEFINE([SYSNDIR], 1, [Same as `HAVE_SYS_NDIR_H', don't depend on me.])
805 test ac_cv_header_dirent_sys_dir_h &&
806 AC_DEFINE([SYSDIR], 1, [Same as `HAVE_SYS_DIR_H', don't depend on me.])
807 test ac_cv_header_dirent_ndir_h &&
808 AC_DEFINE([NDIR], 1, [Same as `HAVE_NDIR_H', don't depend on me.])],
809 [Remove this warning and the four `AC_DEFINE' when you
810 adjust your code to use `AC_HEADER_DIRENT'.])