1 # This file is part of Autoconf. -*- Autoconf -*-
2 # Checking for headers.
4 # Copyright (C) 1988, 1999-2004, 2006, 2008-2012 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 # We are slowly moving to checking headers with the compiler instead
50 # of the preproc, so that we actually learn about the usability of a
51 # header instead of its mere presence. But since users are used to
52 # the old semantics, they check for headers in random order and
53 # without providing prerequisite headers. This macro implements the
54 # transition phase, and should be cleaned up latter to use compilation
57 # If INCLUDES is empty, then check both via the compiler and preproc.
58 # If the results are different, issue a warning, but keep the preproc
61 # If INCLUDES is `-', keep only the old semantics.
63 # If INCLUDES is specified and different from `-', then use the new
66 # The m4_indir allows for fewer expansions of $@.
67 AC_DEFUN([AC_CHECK_HEADER],
68 [m4_indir(m4_case([$4],
69 [], [[_AC_CHECK_HEADER_MONGREL]],
70 [-], [[_AC_CHECK_HEADER_PREPROC]],
71 [[_AC_CHECK_HEADER_COMPILE]]), $@)
75 # _AC_CHECK_HEADER_MONGREL_BODY
76 # -----------------------------
77 # Shell function body for _AC_CHECK_HEADER_MONGREL
78 m4_define([_AC_CHECK_HEADER_MONGREL_BODY],
79 [ AS_LINENO_PUSH([$[]1])
81 [AC_CACHE_CHECK([for $[]2], [$[]3], [])],
82 [# Is the header compilable?
83 AC_MSG_CHECKING([$[]2 usability])
84 AC_COMPILE_IFELSE([AC_LANG_SOURCE([$[]4
85 @%:@include <$[]2>])],
86 [ac_header_compiler=yes],
87 [ac_header_compiler=no])
88 AC_MSG_RESULT([$ac_header_compiler])
90 # Is the header present?
91 AC_MSG_CHECKING([$[]2 presence])
92 AC_PREPROC_IFELSE([AC_LANG_SOURCE([@%:@include <$[]2>])],
93 [ac_header_preproc=yes],
94 [ac_header_preproc=no])
95 AC_MSG_RESULT([$ac_header_preproc])
97 # So? What about this header?
98 case $ac_header_compiler:$ac_header_preproc:$ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag in #((
100 AC_MSG_WARN([$[]2: accepted by the compiler, rejected by the preprocessor!])
101 AC_MSG_WARN([$[]2: proceeding with the compiler's result])
104 AC_MSG_WARN([$[]2: present but cannot be compiled])
105 AC_MSG_WARN([$[]2: check for missing prerequisite headers?])
106 AC_MSG_WARN([$[]2: see the Autoconf documentation])
107 AC_MSG_WARN([$[]2: section "Present But Cannot Be Compiled"])
108 AC_MSG_WARN([$[]2: proceeding with the compiler's result])
109 m4_ifset([AC_PACKAGE_BUGREPORT],
110 [m4_n([( AS_BOX([Report this to ]AC_PACKAGE_BUGREPORT)
111 ) | sed "s/^/$as_me: WARNING: /" >&2])])dnl
114 AC_CACHE_CHECK([for $[]2], [$[]3],
115 [AS_VAR_SET([$[]3], [$ac_header_compiler])])])
117 ])#_AC_CHECK_HEADER_MONGREL_BODY
119 # _AC_CHECK_HEADER_MONGREL(HEADER-FILE,
120 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
121 # [INCLUDES = DEFAULT-INCLUDES])
122 # ------------------------------------------------------------------
123 # Check using both the compiler and the preprocessor. If they disagree,
124 # warn, and the preproc wins.
126 # This is not based on _AC_CHECK_HEADER_COMPILE and _AC_CHECK_HEADER_PREPROC
127 # because it obfuscate the code to try to factor everything, in particular
128 # because of the cache variables, and the `checking ...' messages.
129 AC_DEFUN([_AC_CHECK_HEADER_MONGREL],
130 [AC_REQUIRE_SHELL_FN([ac_fn_]_AC_LANG_ABBREV[_check_header_mongrel],
131 [AS_FUNCTION_DESCRIBE([ac_fn_]_AC_LANG_ABBREV[_check_header_mongrel],
132 [LINENO HEADER VAR INCLUDES],
133 [Tests whether HEADER exists, giving a warning if it cannot be compiled
134 using the include files in INCLUDES and setting the cache variable VAR
137 [AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])]dnl
138 [ac_fn_[]_AC_LANG_ABBREV[]_check_header_mongrel ]dnl
139 ["$LINENO" "$1" "ac_Header" "AS_ESCAPE([AC_INCLUDES_DEFAULT([$4])], [""])"
140 AS_VAR_IF([ac_Header], [yes], [$2], [$3])
141 AS_VAR_POPDEF([ac_Header])])# _AC_CHECK_HEADER_MONGREL
144 # _AC_CHECK_HEADER_COMPILE_BODY
145 # -----------------------------
146 # Shell function body for _AC_CHECK_HEADER_COMPILE
147 m4_define([_AC_CHECK_HEADER_COMPILE_BODY],
148 [ AS_LINENO_PUSH([$[]1])
149 AC_CACHE_CHECK([for $[]2], [$[]3],
150 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([$[]4
151 @%:@include <$[]2>])],
152 [AS_VAR_SET([$[]3], [yes])],
153 [AS_VAR_SET([$[]3], [no])])])
155 ])# _AC_CHECK_HEADER_COMPILE_BODY
157 # _AC_CHECK_HEADER_COMPILE(HEADER-FILE,
158 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
159 # [INCLUDES = DEFAULT-INCLUDES])
160 # --------------------------------------------------------------
161 # Check the compiler accepts HEADER-FILE. The INCLUDES are defaulted.
162 AC_DEFUN([_AC_CHECK_HEADER_COMPILE],
163 [AC_REQUIRE_SHELL_FN([ac_fn_]_AC_LANG_ABBREV[_check_header_compile],
164 [AS_FUNCTION_DESCRIBE([ac_fn_]_AC_LANG_ABBREV[_check_header_compile],
165 [LINENO HEADER VAR INCLUDES],
166 [Tests whether HEADER exists and can be compiled using the include files
167 in INCLUDES, setting the cache variable VAR accordingly.])],
169 [AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])]dnl
170 [ac_fn_[]_AC_LANG_ABBREV[]_check_header_compile ]dnl
171 ["$LINENO" "$1" "ac_Header" "AS_ESCAPE([AC_INCLUDES_DEFAULT([$4])], [""])"
172 AS_VAR_IF([ac_Header], [yes], [$2], [$3])
173 AS_VAR_POPDEF([ac_Header])])# _AC_CHECK_HEADER_COMPILE
175 # _AC_CHECK_HEADER_PREPROC_BODY
176 # -----------------------------
177 # Shell function body for _AC_CHECK_HEADER_PREPROC.
178 m4_define([_AC_CHECK_HEADER_PREPROC_BODY],
179 [ AS_LINENO_PUSH([$[]1])
180 AC_CACHE_CHECK([for $[]2], [$[]3],
181 [AC_PREPROC_IFELSE([AC_LANG_SOURCE([@%:@include <$[]2>])],
182 [AS_VAR_SET([$[]3], [yes])],
183 [AS_VAR_SET([$[]3], [no])])])
185 ])# _AC_CHECK_HEADER_PREPROC_BODY
189 # _AC_CHECK_HEADER_PREPROC(HEADER-FILE,
190 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
191 # --------------------------------------------------------------
192 # Check the preprocessor accepts HEADER-FILE.
193 AC_DEFUN([_AC_CHECK_HEADER_PREPROC],
194 [AC_REQUIRE_SHELL_FN([ac_fn_]_AC_LANG_ABBREV[_check_header_preproc],
195 [AS_FUNCTION_DESCRIBE([ac_fn_]_AC_LANG_ABBREV[_check_header_preproc],
197 [Tests whether HEADER is present, setting the cache variable VAR accordingly.])],
199 [AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])]dnl
200 [ac_fn_[]_AC_LANG_ABBREV[]_check_header_preproc "$LINENO" "$1" "ac_Header"
201 AS_VAR_IF([ac_Header], [yes], [$2], [$3])
202 AS_VAR_POPDEF([ac_Header])dnl
203 ])# _AC_CHECK_HEADER_PREPROC
205 # _AC_CHECK_HEADER_OLD(HEADER-FILE, [ACTION-IF-FOUND],
206 # [ACTION-IF-NOT-FOUND])
207 # _AC_CHECK_HEADER_NEW(HEADER-FILE, [ACTION-IF-FOUND],
208 # [ACTION-IF-NOT-FOUND])
209 # ----------------------------------------------------
210 # Some packages used these undocumented macros. Even worse, gcc
211 # redefined AC_CHECK_HEADER in terms of _AC_CHECK_HEADER_OLD, so we
212 # can't do the simpler:
213 # AU_DEFUN([_AC_CHECK_HEADER_OLD],
214 # [AC_CHECK_HEADER([$1], [$2], [$3], [-])])
215 AC_DEFUN([_AC_CHECK_HEADER_OLD],
216 [AC_DIAGNOSE([obsolete], [The macro `$0' is obsolete.
217 You should use AC_CHECK_HEADER with a fourth argument.])]dnl
218 [_AC_CHECK_HEADER_PREPROC($@)])
220 AC_DEFUN([_AC_CHECK_HEADER_NEW],
221 [AC_DIAGNOSE([obsolete], [The macro `$0' is obsolete.
222 You should use AC_CHECK_HEADER with a fourth argument.])]dnl
223 [_AC_CHECK_HEADER_COMPILE($@)])
226 # _AH_CHECK_HEADER(HEADER-FILE)
227 # -----------------------------
228 # Prepare the autoheader snippet for HEADER-FILE.
229 m4_define([_AH_CHECK_HEADER],
230 [AH_TEMPLATE(AS_TR_CPP([HAVE_$1]),
231 [Define to 1 if you have the <$1> header file.])])
234 # AH_CHECK_HEADERS(HEADER-FILE...)
235 # --------------------------------
236 m4_define([AH_CHECK_HEADERS],
237 [m4_foreach_w([AC_Header], [$1], [_AH_CHECK_HEADER(m4_defn([AC_Header]))])])
240 # AC_CHECK_HEADERS(HEADER-FILE...,
241 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
243 # ----------------------------------------------------------
244 # Check for each whitespace-separated HEADER-FILE (omitting the <> or
245 # ""), and perform ACTION-IF-FOUND or ACTION-IF-NOT-FOUND for each
246 # header. INCLUDES is as for AC_CHECK_HEADER. Additionally, make the
247 # preprocessor definition HAVE_HEADER_FILE available for each found
248 # header. Either ACTION may include `break' to stop the search.
249 AC_DEFUN([AC_CHECK_HEADERS],
250 [m4_map_args_w([$1], [_AH_CHECK_HEADER(], [)])]dnl
251 [AS_FOR([AC_header], [ac_header], [$1],
252 [AC_CHECK_HEADER(AC_header,
253 [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_]AC_header)) $2],
258 # _AC_CHECK_HEADER_ONCE(HEADER-FILE)
259 # ----------------------------------
260 # Check for a single HEADER-FILE once.
261 m4_define([_AC_CHECK_HEADER_ONCE],
262 [_AH_CHECK_HEADER([$1])AC_DEFUN([_AC_Header_]m4_translit([[$1]],
264 [m4_divert_text([INIT_PREPARE], [AS_VAR_APPEND([ac_header_list], [" $1"])])
265 _AC_HEADERS_EXPANSION])AC_REQUIRE([_AC_Header_]m4_translit([[$1]],
269 # AC_CHECK_HEADERS_ONCE(HEADER-FILE...)
270 # -------------------------------------
271 # Add each whitespace-separated name in HEADER-FILE to the list of
272 # headers to check once.
273 AC_DEFUN([AC_CHECK_HEADERS_ONCE],
274 [m4_map_args_w([$1], [_AC_CHECK_HEADER_ONCE(], [)])])
276 m4_define([_AC_HEADERS_EXPANSION],
278 m4_divert_text([DEFAULTS], [ac_header_list=])
279 AC_CHECK_HEADERS([$ac_header_list], [], [], [AC_INCLUDES_DEFAULT])
280 m4_define([_AC_HEADERS_EXPANSION], [])
286 ## --------------------- ##
287 ## 2. Default includes. ##
288 ## --------------------- ##
290 # Always use the same set of default headers for all the generic
291 # macros. It is easier to document, to extend, and to understand than
292 # having specific defaults for each macro.
294 # _AC_INCLUDES_DEFAULT_REQUIREMENTS
295 # ---------------------------------
296 # Required when AC_INCLUDES_DEFAULT uses its default branch.
297 AC_DEFUN([_AC_INCLUDES_DEFAULT_REQUIREMENTS],
298 [m4_divert_text([DEFAULTS],
299 [# Factoring default headers for most tests.
300 dnl If ever you change this variable, please keep autoconf.texi in sync.
301 ac_includes_default="\
303 #ifdef HAVE_SYS_TYPES_H
304 # include <sys/types.h>
306 #ifdef HAVE_SYS_STAT_H
307 # include <sys/stat.h>
313 # ifdef HAVE_STDLIB_H
318 # if !defined STDC_HEADERS && defined HAVE_MEMORY_H
323 #ifdef HAVE_STRINGS_H
324 # include <strings.h>
326 #ifdef HAVE_INTTYPES_H
327 # include <inttypes.h>
336 AC_REQUIRE([AC_HEADER_STDC])dnl
337 # On IRIX 5.3, sys/types and inttypes.h are conflicting.
338 AC_CHECK_HEADERS([sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
339 inttypes.h stdint.h unistd.h],
340 [], [], $ac_includes_default)
341 ])# _AC_INCLUDES_DEFAULT_REQUIREMENTS
344 # AC_INCLUDES_DEFAULT([INCLUDES])
345 # -------------------------------
346 # If INCLUDES is empty, expand in default includes, otherwise in
348 # In most cases INCLUDES is not double quoted as it should, and if
349 # for instance INCLUDES = `#include <stdio.h>' then unless we force
350 # a newline, the hash will swallow the closing paren etc. etc.
352 # Take no risk: for the newline.
353 AC_DEFUN([AC_INCLUDES_DEFAULT],
356 [AC_REQUIRE([_AC_INCLUDES_DEFAULT_REQUIREMENTS])dnl
357 $ac_includes_default])])
363 ## ------------------------------------------- ##
364 ## 3. Headers to check with AC_CHECK_HEADERS. ##
365 ## ------------------------------------------- ##
367 # errno.h is portable.
369 AN_HEADER([OS.h], [AC_CHECK_HEADERS])
370 AN_HEADER([argz.h], [AC_CHECK_HEADERS])
371 AN_HEADER([arpa/inet.h], [AC_CHECK_HEADERS])
372 AN_HEADER([fcntl.h], [AC_CHECK_HEADERS])
373 AN_HEADER([fenv.h], [AC_CHECK_HEADERS])
374 AN_HEADER([float.h], [AC_CHECK_HEADERS])
375 AN_HEADER([fs_info.h], [AC_CHECK_HEADERS])
376 AN_HEADER([inttypes.h], [AC_CHECK_HEADERS])
377 AN_HEADER([langinfo.h], [AC_CHECK_HEADERS])
378 AN_HEADER([libintl.h], [AC_CHECK_HEADERS])
379 AN_HEADER([limits.h], [AC_CHECK_HEADERS])
380 AN_HEADER([locale.h], [AC_CHECK_HEADERS])
381 AN_HEADER([mach/mach.h], [AC_CHECK_HEADERS])
382 AN_HEADER([malloc.h], [AC_CHECK_HEADERS])
383 AN_HEADER([memory.h], [AC_CHECK_HEADERS])
384 AN_HEADER([mntent.h], [AC_CHECK_HEADERS])
385 AN_HEADER([mnttab.h], [AC_CHECK_HEADERS])
386 AN_HEADER([netdb.h], [AC_CHECK_HEADERS])
387 AN_HEADER([netinet/in.h], [AC_CHECK_HEADERS])
388 AN_HEADER([nl_types.h], [AC_CHECK_HEADERS])
389 AN_HEADER([nlist.h], [AC_CHECK_HEADERS])
390 AN_HEADER([paths.h], [AC_CHECK_HEADERS])
391 AN_HEADER([sgtty.h], [AC_CHECK_HEADERS])
392 AN_HEADER([shadow.h], [AC_CHECK_HEADERS])
393 AN_HEADER([stddef.h], [AC_CHECK_HEADERS])
394 AN_HEADER([stdint.h], [AC_CHECK_HEADERS])
395 AN_HEADER([stdio_ext.h], [AC_CHECK_HEADERS])
396 AN_HEADER([stdlib.h], [AC_CHECK_HEADERS])
397 AN_HEADER([string.h], [AC_CHECK_HEADERS])
398 AN_HEADER([strings.h], [AC_CHECK_HEADERS])
399 AN_HEADER([sys/acl.h], [AC_CHECK_HEADERS])
400 AN_HEADER([sys/file.h], [AC_CHECK_HEADERS])
401 AN_HEADER([sys/filsys.h], [AC_CHECK_HEADERS])
402 AN_HEADER([sys/fs/s5param.h], [AC_CHECK_HEADERS])
403 AN_HEADER([sys/fs_types.h], [AC_CHECK_HEADERS])
404 AN_HEADER([sys/fstyp.h], [AC_CHECK_HEADERS])
405 AN_HEADER([sys/ioctl.h], [AC_CHECK_HEADERS])
406 AN_HEADER([sys/mntent.h], [AC_CHECK_HEADERS])
407 AN_HEADER([sys/mount.h], [AC_CHECK_HEADERS])
408 AN_HEADER([sys/param.h], [AC_CHECK_HEADERS])
409 AN_HEADER([sys/socket.h], [AC_CHECK_HEADERS])
410 AN_HEADER([sys/statfs.h], [AC_CHECK_HEADERS])
411 AN_HEADER([sys/statvfs.h], [AC_CHECK_HEADERS])
412 AN_HEADER([sys/systeminfo.h], [AC_CHECK_HEADERS])
413 AN_HEADER([sys/time.h], [AC_CHECK_HEADERS])
414 AN_HEADER([sys/timeb.h], [AC_CHECK_HEADERS])
415 AN_HEADER([sys/vfs.h], [AC_CHECK_HEADERS])
416 AN_HEADER([sys/window.h], [AC_CHECK_HEADERS])
417 AN_HEADER([syslog.h], [AC_CHECK_HEADERS])
418 AN_HEADER([termio.h], [AC_CHECK_HEADERS])
419 AN_HEADER([termios.h], [AC_CHECK_HEADERS])
420 AN_HEADER([unistd.h], [AC_CHECK_HEADERS])
421 AN_HEADER([utime.h], [AC_CHECK_HEADERS])
422 AN_HEADER([utmp.h], [AC_CHECK_HEADERS])
423 AN_HEADER([utmpx.h], [AC_CHECK_HEADERS])
424 AN_HEADER([values.h], [AC_CHECK_HEADERS])
425 AN_HEADER([wchar.h], [AC_CHECK_HEADERS])
426 AN_HEADER([wctype.h], [AC_CHECK_HEADERS])
430 ## ------------------------------- ##
431 ## 4. Tests for specific headers. ##
432 ## ------------------------------- ##
436 # Check whether to enable assertions.
437 AC_DEFUN_ONCE([AC_HEADER_ASSERT],
439 AC_MSG_CHECKING([whether to enable assertions])
440 AC_ARG_ENABLE([assert],
441 [AS_HELP_STRING([--disable-assert], [turn off assertions])],
442 [ac_enable_assert=$enableval
444 [test "x$enableval" = xno],
445 [AC_DEFINE([NDEBUG], [1],
446 [Define to 1 if assertions should be disabled.])],
447 [test "x$enableval" != xyes],
448 [AC_MSG_WARN([invalid argument supplied to --enable-assert])
449 ac_enable_assert=yes])],
450 [ac_enable_assert=yes])
451 AC_MSG_RESULT([$ac_enable_assert])
455 # _AC_CHECK_HEADER_DIRENT(HEADER-FILE,
456 # [ACTION-IF-FOUND], [ACTION-IF-NOT_FOUND])
457 # -----------------------------------------------------------------
458 # Like AC_CHECK_HEADER, except also make sure that HEADER-FILE
459 # defines the type `DIR'. dirent.h on NextStep 3.2 doesn't.
460 m4_define([_AC_CHECK_HEADER_DIRENT],
461 [AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_dirent_$1])dnl
462 AC_CACHE_CHECK([for $1 that defines DIR], [ac_Header],
463 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
468 [AS_VAR_SET([ac_Header], [yes])],
469 [AS_VAR_SET([ac_Header], [no])])])
470 AS_VAR_IF([ac_Header], [yes], [$2], [$3])
471 AS_VAR_POPDEF([ac_Header])dnl
472 ])# _AC_CHECK_HEADER_DIRENT
475 # _AH_CHECK_HEADER_DIRENT(HEADERS)
476 # --------------------------------
477 # Like _AH_CHECK_HEADER, but tuned to a dirent provider.
478 m4_define([_AH_CHECK_HEADER_DIRENT],
479 [AH_TEMPLATE(AS_TR_CPP([HAVE_$1]),
480 [Define to 1 if you have the <$1> header file, and it defines `DIR'.])])
485 AC_DEFUN([AC_HEADER_DIRENT],
486 [m4_map_args([_AH_CHECK_HEADER_DIRENT], [dirent.h], [sys/ndir.h],
487 [sys/dir.h], [ndir.h])]dnl
489 for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
490 _AC_CHECK_HEADER_DIRENT($ac_hdr,
491 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$ac_hdr), 1)
492 ac_header_dirent=$ac_hdr; break])
494 # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
495 if test $ac_header_dirent = dirent.h; then
496 AC_SEARCH_LIBS(opendir, dir)
498 AC_SEARCH_LIBS(opendir, x)
505 AN_FUNCTION([major], [AC_HEADER_MAJOR])
506 AN_FUNCTION([makedev], [AC_HEADER_MAJOR])
507 AN_FUNCTION([minor], [AC_HEADER_MAJOR])
508 AN_HEADER([sys/mkdev.h], [AC_HEADER_MAJOR])
509 AC_DEFUN([AC_HEADER_MAJOR],
510 [AC_CACHE_CHECK(whether sys/types.h defines makedev,
511 ac_cv_header_sys_types_h_makedev,
512 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include <sys/types.h>]],
513 [[return makedev(0, 0);]])],
514 [ac_cv_header_sys_types_h_makedev=yes],
515 [ac_cv_header_sys_types_h_makedev=no])
518 if test $ac_cv_header_sys_types_h_makedev = no; then
519 AC_CHECK_HEADER(sys/mkdev.h,
520 [AC_DEFINE(MAJOR_IN_MKDEV, 1,
521 [Define to 1 if `major', `minor', and `makedev' are
522 declared in <mkdev.h>.])])
524 if test $ac_cv_header_sys_mkdev_h = no; then
525 AC_CHECK_HEADER(sys/sysmacros.h,
526 [AC_DEFINE(MAJOR_IN_SYSMACROS, 1,
527 [Define to 1 if `major', `minor', and `makedev'
528 are declared in <sysmacros.h>.])])
536 # According to http://www.mcsr.olemiss.edu/cgi-bin/man-cgi?resolver+3
537 # (or http://www.chemie.fu-berlin.de/cgi-bin/man/sgi_irix?resolver+3),
538 # sys/types.h, netinet/in.h and arpa/nameser.h are required on IRIX.
539 # netinet/in.h is needed on Cygwin, too.
540 # With Solaris 9, netdb.h is required, to get symbols like HOST_NOT_FOUND.
542 AN_HEADER(resolv.h, [AC_HEADER_RESOLV])
543 AC_DEFUN([AC_HEADER_RESOLV],
544 [AC_CHECK_HEADERS(sys/types.h netinet/in.h arpa/nameser.h netdb.h resolv.h,
546 [[#ifdef HAVE_SYS_TYPES_H
547 # include <sys/types.h>
549 #ifdef HAVE_NETINET_IN_H
550 # include <netinet/in.h> /* inet_ functions / structs */
552 #ifdef HAVE_ARPA_NAMESER_H
553 # include <arpa/nameser.h> /* DNS HEADER struct */
563 # FIXME: Shouldn't this be named AC_HEADER_SYS_STAT?
564 AC_DEFUN([AC_HEADER_STAT],
565 [AC_CACHE_CHECK(whether stat file-mode macros are broken,
566 ac_cv_header_stat_broken,
567 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <sys/types.h>
568 #include <sys/stat.h>
570 #if defined S_ISBLK && defined S_IFDIR
571 extern char c1[S_ISBLK (S_IFDIR) ? -1 : 1];
574 #if defined S_ISBLK && defined S_IFCHR
575 extern char c2[S_ISBLK (S_IFCHR) ? -1 : 1];
578 #if defined S_ISLNK && defined S_IFREG
579 extern char c3[S_ISLNK (S_IFREG) ? -1 : 1];
582 #if defined S_ISSOCK && defined S_IFREG
583 extern char c4[S_ISSOCK (S_IFREG) ? -1 : 1];
585 ]])], ac_cv_header_stat_broken=no, ac_cv_header_stat_broken=yes)])
586 if test $ac_cv_header_stat_broken = yes; then
587 AC_DEFINE(STAT_MACROS_BROKEN, 1,
588 [Define to 1 if the `S_IS*' macros in <sys/stat.h> do not
594 # AC_CHECK_HEADER_STDBOOL
596 # Check for stdbool.h that conforms to C99.
597 AN_IDENTIFIER([bool], [AC_CHECK_HEADER_STDBOOL])
598 AN_IDENTIFIER([true], [AC_CHECK_HEADER_STDBOOL])
599 AN_IDENTIFIER([false],[AC_CHECK_HEADER_STDBOOL])
600 AC_DEFUN([AC_CHECK_HEADER_STDBOOL],
601 [AC_CACHE_CHECK([for stdbool.h that conforms to C99],
602 [ac_cv_header_stdbool_h],
608 "error: bool is not defined"
611 "error: false is not defined"
614 "error: false is not 0"
617 "error: true is not defined"
620 "error: true is not 1"
622 #ifndef __bool_true_false_are_defined
623 "error: __bool_true_false_are_defined is not defined"
626 struct s { _Bool s: 1; _Bool t; } s;
628 char a[true == 1 ? 1 : -1];
629 char b[false == 0 ? 1 : -1];
630 char c[__bool_true_false_are_defined == 1 ? 1 : -1];
631 char d[(bool) 0.5 == true ? 1 : -1];
632 /* See body of main program for 'e'. */
633 char f[(_Bool) 0.0 == false ? 1 : -1];
635 char h[sizeof (_Bool)];
637 enum { j = false, k = true, l = false * true, m = true * 256 };
638 /* The following fails for
639 HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */
641 char o[sizeof n == m * sizeof n[0] ? 1 : -1];
642 char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
643 /* Catch a bug in an HP-UX C compiler. See
644 http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
645 http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
654 /* Refer to every declared value, to avoid compiler optimizations. */
655 return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
656 + !m + !n + !o + !p + !q + !pq);
658 [ac_cv_header_stdbool_h=yes],
659 [ac_cv_header_stdbool_h=no])])
660 AC_CHECK_TYPES([_Bool])
661 ])# AC_CHECK_HEADER_STDBOOL
666 # Define HAVE_STDBOOL_H if tdbool.h that conforms to C99.
667 AC_DEFUN([AC_HEADER_STDBOOL],
668 [AC_CHECK_HEADER_STDBOOL
669 if test $ac_cv_header_stdbool_h = yes; then
670 AC_DEFINE(HAVE_STDBOOL_H, 1, [Define to 1 if stdbool.h conforms to C99.])
672 ])# AC_HEADER_STDBOOL
677 AC_DEFUN([AC_HEADER_STDC],
678 [AC_CACHE_CHECK(for ANSI C header files, ac_cv_header_stdc,
679 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
684 [ac_cv_header_stdc=yes],
685 [ac_cv_header_stdc=no])
687 if test $ac_cv_header_stdc = yes; then
688 # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
689 AC_EGREP_HEADER(memchr, string.h, , ac_cv_header_stdc=no)
692 if test $ac_cv_header_stdc = yes; then
693 # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
694 AC_EGREP_HEADER(free, stdlib.h, , ac_cv_header_stdc=no)
697 if test $ac_cv_header_stdc = yes; then
698 # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
699 AC_RUN_IFELSE([AC_LANG_SOURCE(
702 #if ((' ' & 0x0FF) == 0x020)
703 # define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
704 # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
706 # define ISLOWER(c) \
707 (('a' <= (c) && (c) <= 'i') \
708 || ('j' <= (c) && (c) <= 'r') \
709 || ('s' <= (c) && (c) <= 'z'))
710 # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
713 #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
718 for (i = 0; i < 256; i++)
719 if (XOR (islower (i), ISLOWER (i))
720 || toupper (i) != TOUPPER (i))
723 }]])], , ac_cv_header_stdc=no, :)
725 if test $ac_cv_header_stdc = yes; then
726 AC_DEFINE(STDC_HEADERS, 1,
727 [Define to 1 if you have the ANSI C header files.])
734 AC_DEFUN([AC_HEADER_SYS_WAIT],
735 [AC_CACHE_CHECK([for sys/wait.h that is POSIX.1 compatible],
736 ac_cv_header_sys_wait_h,
738 [AC_LANG_PROGRAM([#include <sys/types.h>
739 #include <sys/wait.h>
741 # define WEXITSTATUS(stat_val) ((unsigned int) (stat_val) >> 8)
744 # define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
749 s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;])],
750 [ac_cv_header_sys_wait_h=yes],
751 [ac_cv_header_sys_wait_h=no])])
752 if test $ac_cv_header_sys_wait_h = yes; then
753 AC_DEFINE(HAVE_SYS_WAIT_H, 1,
754 [Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible.])
756 ])# AC_HEADER_SYS_WAIT
761 AC_DEFUN([AC_HEADER_TIME],
762 [AC_CACHE_CHECK([whether time.h and sys/time.h may both be included],
764 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
765 #include <sys/time.h>
768 [if ((struct tm *) 0)
770 [ac_cv_header_time=yes],
771 [ac_cv_header_time=no])])
772 if test $ac_cv_header_time = yes; then
773 AC_DEFINE(TIME_WITH_SYS_TIME, 1,
774 [Define to 1 if you can safely include both <sys/time.h>
780 # _AC_HEADER_TIOCGWINSZ_IN_TERMIOS_H
781 # ----------------------------------
782 m4_define([_AC_HEADER_TIOCGWINSZ_IN_TERMIOS_H],
783 [AC_CACHE_CHECK([whether termios.h defines TIOCGWINSZ],
784 ac_cv_sys_tiocgwinsz_in_termios_h,
786 [#include <sys/types.h>
792 ac_cv_sys_tiocgwinsz_in_termios_h=yes,
793 ac_cv_sys_tiocgwinsz_in_termios_h=no)])
794 ])# _AC_HEADER_TIOCGWINSZ_IN_TERMIOS_H
797 # _AC_HEADER_TIOCGWINSZ_IN_SYS_IOCTL
798 # ----------------------------------
799 m4_define([_AC_HEADER_TIOCGWINSZ_IN_SYS_IOCTL],
800 [AC_CACHE_CHECK([whether sys/ioctl.h defines TIOCGWINSZ],
801 ac_cv_sys_tiocgwinsz_in_sys_ioctl_h,
803 [#include <sys/types.h>
804 #include <sys/ioctl.h>
809 ac_cv_sys_tiocgwinsz_in_sys_ioctl_h=yes,
810 ac_cv_sys_tiocgwinsz_in_sys_ioctl_h=no)])
811 ])# _AC_HEADER_TIOCGWINSZ_IN_SYS_IOCTL
814 # AC_HEADER_TIOCGWINSZ
815 # --------------------
816 # Look for a header that defines TIOCGWINSZ.
817 # FIXME: Is this the proper name? Is this the proper implementation?
819 AC_DEFUN([AC_HEADER_TIOCGWINSZ],
820 [_AC_HEADER_TIOCGWINSZ_IN_TERMIOS_H
821 if test $ac_cv_sys_tiocgwinsz_in_termios_h != yes; then
822 _AC_HEADER_TIOCGWINSZ_IN_SYS_IOCTL
823 if test $ac_cv_sys_tiocgwinsz_in_sys_ioctl_h = yes; then
824 AC_DEFINE(GWINSZ_IN_SYS_IOCTL,1,
825 [Define to 1 if `TIOCGWINSZ' requires <sys/ioctl.h>.])
828 ])# AC_HEADER_TIOCGWINSZ
833 AU_DEFUN([AC_UNISTD_H],
834 [AC_CHECK_HEADERS(unistd.h)])
839 # Define `USG' if string functions are in strings.h.
841 [AC_MSG_CHECKING([for BSD string and memory functions])
842 AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include <strings.h>]],
843 [[rindex(0, 0); bzero(0, 0);]])],
844 [AC_MSG_RESULT(yes)],
847 [Define to 1 if you do not have <strings.h>, index,
848 bzero, etc... This symbol is obsolete, you should
849 not depend upon it.])])
850 AC_CHECK_HEADERS(string.h)],
851 [Remove `AC_MSG_CHECKING', `AC_LINK_IFELSE' and this warning
852 when you adjust your code to use HAVE_STRING_H.])
857 # To be precise this macro used to be:
859 # | AC_MSG_CHECKING(whether string.h declares mem functions)
860 # | AC_EGREP_HEADER(memchr, string.h, ac_found=yes, ac_found=no)
861 # | AC_MSG_RESULT($ac_found)
862 # | if test $ac_found = no; then
863 # | AC_CHECK_HEADER(memory.h, [AC_DEFINE(NEED_MEMORY_H)])
866 # But it is better to check for both headers, and alias NEED_MEMORY_H to
868 AU_DEFUN([AC_MEMORY_H],
869 [AC_CHECK_HEADER(memory.h,
870 [AC_DEFINE([NEED_MEMORY_H], 1,
871 [Same as `HAVE_MEMORY_H', don't depend on me.])])
872 AC_CHECK_HEADERS(string.h memory.h)],
873 [Remove this warning and
874 `AC_CHECK_HEADER(memory.h, AC_DEFINE(...))' when you adjust your code to
875 use HAVE_STRING_H and HAVE_MEMORY_H, not NEED_MEMORY_H.])
880 # Like calling `AC_HEADER_DIRENT' and `AC_FUNC_CLOSEDIR_VOID', but
881 # defines a different set of C preprocessor macros to indicate which
882 # header file is found.
883 AU_DEFUN([AC_DIR_HEADER],
885 AC_FUNC_CLOSEDIR_VOID
886 test ac_cv_header_dirent_dirent_h &&
887 AC_DEFINE([DIRENT], 1, [Same as `HAVE_DIRENT_H', don't depend on me.])
888 test ac_cv_header_dirent_sys_ndir_h &&
889 AC_DEFINE([SYSNDIR], 1, [Same as `HAVE_SYS_NDIR_H', don't depend on me.])
890 test ac_cv_header_dirent_sys_dir_h &&
891 AC_DEFINE([SYSDIR], 1, [Same as `HAVE_SYS_DIR_H', don't depend on me.])
892 test ac_cv_header_dirent_ndir_h &&
893 AC_DEFINE([NDIR], 1, [Same as `HAVE_NDIR_H', don't depend on me.])],
894 [Remove this warning and the four `AC_DEFINE' when you
895 adjust your code to use `AC_HEADER_DIRENT'.])