1 # This file is part of Autoconf. -*- Autoconf -*-
2 # Checking for headers.
4 # Copyright (C) 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2006, 2008
5 # Free Software Foundation, Inc.
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2, or (at your option)
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 # As a special exception, the Free Software Foundation gives unlimited
23 # permission to copy, distribute and modify the configure scripts that
24 # are the output of Autoconf. You need not follow the terms of the GNU
25 # General Public License when using or distributing such scripts, even
26 # though portions of the text of Autoconf appear in them. The GNU
27 # General Public License (GPL) does govern all other use of the material
28 # that constitutes the Autoconf program.
30 # Certain portions of the Autoconf source text are designed to be copied
31 # (in certain cases, depending on the input) into the output of
32 # Autoconf. We call these the "data" portions. The rest of the Autoconf
33 # source text consists of comments plus executable code that decides which
34 # of the data portions to output in any given case. We call these
35 # comments and executable code the "non-data" portions. Autoconf never
36 # copies any of the non-data portions into its output.
38 # This special exception to the GPL applies to versions of Autoconf
39 # released by the Free Software Foundation. When you make and
40 # distribute a modified version of Autoconf, you may extend this special
41 # exception to the GPL to apply to your modified version as well, *unless*
42 # your modified version has the potential to copy into its output some
43 # of the text that was the non-data portion of the version that you started
44 # with. (In other words, unless your change moves or copies text from
45 # the non-data portions to the data portions.) If your modification has
46 # such potential, you must delete any notice of this special exception
47 # to the GPL from your modified version.
49 # Written by David MacKenzie, with help from
50 # Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
51 # Roland McGrath, Noah Friedman, david d zuhn, and many others.
56 # 1. Generic tests for headers
58 # 3. Headers to tests with AC_CHECK_HEADERS
59 # 4. Tests for specific headers
62 ## ------------------------------ ##
63 ## 1. Generic tests for headers. ##
64 ## ------------------------------ ##
67 # AC_CHECK_HEADER(HEADER-FILE,
68 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
70 # ---------------------------------------------------------
71 # We are slowly moving to checking headers with the compiler instead
72 # of the preproc, so that we actually learn about the usability of a
73 # header instead of its mere presence. But since users are used to
74 # the old semantics, they check for headers in random order and
75 # without providing prerequisite headers. This macro implements the
76 # transition phase, and should be cleaned up latter to use compilation
79 # If INCLUDES is empty, then check both via the compiler and preproc.
80 # If the results are different, issue a warning, but keep the preproc
83 # If INCLUDES is `-', keep only the old semantics.
85 # If INCLUDES is specified and different from `-', then use the new
88 # The m4_indir allows for fewer expansions of $@.
89 AC_DEFUN([AC_CHECK_HEADER],
90 [m4_indir(m4_case([$4],
91 [], [[_AC_CHECK_HEADER_MONGREL]],
92 [-], [[_AC_CHECK_HEADER_PREPROC]],
93 [[_AC_CHECK_HEADER_COMPILE]]), $@)
97 # _AC_CHECK_HEADER_MONGREL_BODY
98 # -----------------------------
99 # Shell function body for _AC_CHECK_HEADER_MONGREL
100 m4_define([_AC_CHECK_HEADER_MONGREL_BODY],
101 [ AS_LINENO_PUSH([$[]1])
102 AS_VAR_SET_IF([$[]3],
103 [AC_CACHE_CHECK([for $[]2], [$[]3], [])],
104 [# Is the header compilable?
105 AC_MSG_CHECKING([$[]2 usability])
106 AC_COMPILE_IFELSE([AC_LANG_SOURCE([$[]4
107 @%:@include <$[]2>])],
108 [ac_header_compiler=yes],
109 [ac_header_compiler=no])
110 AC_MSG_RESULT([$ac_header_compiler])
112 # Is the header present?
113 AC_MSG_CHECKING([$[]2 presence])
114 AC_PREPROC_IFELSE([AC_LANG_SOURCE([@%:@include <$[]2>])],
115 [ac_header_preproc=yes],
116 [ac_header_preproc=no])
117 AC_MSG_RESULT([$ac_header_preproc])
119 # So? What about this header?
120 case $ac_header_compiler:$ac_header_preproc:$ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag in #((
122 AC_MSG_WARN([$[]2: accepted by the compiler, rejected by the preprocessor!])
123 AC_MSG_WARN([$[]2: proceeding with the compiler's result])
126 AC_MSG_WARN([$[]2: present but cannot be compiled])
127 AC_MSG_WARN([$[]2: check for missing prerequisite headers?])
128 AC_MSG_WARN([$[]2: see the Autoconf documentation])
129 AC_MSG_WARN([$[]2: section "Present But Cannot Be Compiled"])
130 AC_MSG_WARN([$[]2: proceeding with the compiler's result])
131 m4_ifset([AC_PACKAGE_BUGREPORT],
132 [m4_n([( AS_BOX([Report this to ]AC_PACKAGE_BUGREPORT)
133 ) | sed "s/^/$as_me: WARNING: /" >&2])])dnl
136 AC_CACHE_CHECK([for $[]2], [$[]3],
137 [AS_VAR_SET([$[]3], [$ac_header_compiler])])])
139 ])#_AC_CHECK_HEADER_MONGREL_BODY
141 # _AC_CHECK_HEADER_MONGREL(HEADER-FILE,
142 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
143 # [INCLUDES = DEFAULT-INCLUDES])
144 # ------------------------------------------------------------------
145 # Check using both the compiler and the preprocessor. If they disagree,
146 # warn, and the preproc wins.
148 # This is not based on _AC_CHECK_HEADER_COMPILE and _AC_CHECK_HEADER_PREPROC
149 # because it obfuscate the code to try to factor everything, in particular
150 # because of the cache variables, and the `checking...' messages.
151 AC_DEFUN([_AC_CHECK_HEADER_MONGREL],
152 [AC_REQUIRE_SHELL_FN([ac_fn_]_AC_LANG_ABBREV[_check_header_mongrel],
153 [AS_FUNCTION_DESCRIBE([ac_fn_]_AC_LANG_ABBREV[_check_header_mongrel],
154 [LINENO HEADER VAR INCLUDES],
155 [Tests whether HEADER exists, giving a warning if it cannot be compiled
156 using the include files in INCLUDES and setting the cache variable VAR
159 [AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])]dnl
160 [ac_fn_[]_AC_LANG_ABBREV[]_check_header_mongrel ]dnl
161 ["$LINENO" "$1" "ac_Header" "AS_ESCAPE([AC_INCLUDES_DEFAULT([$4])], [""])"
162 AS_VAR_IF([ac_Header], [yes], [$2], [$3])
163 AS_VAR_POPDEF([ac_Header])])# _AC_CHECK_HEADER_MONGREL
166 # _AC_CHECK_HEADER_COMPILE_BODY
167 # -----------------------------
168 # Shell function body for _AC_CHECK_HEADER_COMPILE
169 m4_define([_AC_CHECK_HEADER_COMPILE_BODY],
170 [ AS_LINENO_PUSH([$[]1])
171 AC_CACHE_CHECK([for $[]2], [$[]3],
172 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([$[]4
173 @%:@include <$[]2>])],
174 [AS_VAR_SET([$[]3], [yes])],
175 [AS_VAR_SET([$[]3], [no])])])
177 ])# _AC_CHECK_HEADER_COMPILE_BODY
179 # _AC_CHECK_HEADER_COMPILE(HEADER-FILE,
180 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
181 # [INCLUDES = DEFAULT-INCLUDES])
182 # --------------------------------------------------------------
183 # Check the compiler accepts HEADER-FILE. The INCLUDES are defaulted.
184 AC_DEFUN([_AC_CHECK_HEADER_COMPILE],
185 [AC_REQUIRE_SHELL_FN([ac_fn_]_AC_LANG_ABBREV[_check_header_compile],
186 [AS_FUNCTION_DESCRIBE([ac_fn_]_AC_LANG_ABBREV[_check_header_compile],
187 [LINENO HEADER VAR INCLUDES],
188 [Tests whether HEADER exists and can be compiled using the include files
189 in INCLUDES, setting the cache variable VAR accordingly.])],
191 [AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])]dnl
192 [ac_fn_[]_AC_LANG_ABBREV[]_check_header_compile ]dnl
193 ["$LINENO" "$1" "ac_Header" "AS_ESCAPE([AC_INCLUDES_DEFAULT([$4])], [""])"
194 AS_VAR_IF([ac_Header], [yes], [$2], [$3])
195 AS_VAR_POPDEF([ac_Header])])# _AC_CHECK_HEADER_COMPILE
198 # _AC_CHECK_HEADER_PREPROC_BODY
199 # -----------------------------
200 # Shell function body for _AC_CHECK_HEADER_PREPROC.
201 m4_define([_AC_CHECK_HEADER_PREPROC_BODY],
202 [ AS_LINENO_PUSH([$[]1])
203 AC_CACHE_CHECK([for $[]2], [$[]3],
204 [AC_PREPROC_IFELSE([AC_LANG_SOURCE([@%:@include <$[]2>])],
205 [AS_VAR_SET([$[]3], [yes])],
206 [AS_VAR_SET([$[]3], [no])])])
208 ])# _AC_CHECK_HEADER_PREPROC_BODY
212 # _AC_CHECK_HEADER_PREPROC(HEADER-FILE,
213 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
214 # --------------------------------------------------------------
215 # Check the preprocessor accepts HEADER-FILE.
216 AC_DEFUN([_AC_CHECK_HEADER_PREPROC],
217 [AC_REQUIRE_SHELL_FN([ac_fn_]_AC_LANG_ABBREV[_check_header_preproc],
218 [AS_FUNCTION_DESCRIBE([ac_fn_]_AC_LANG_ABBREV[_check_header_preproc],
220 [Tests whether HEADER is present, setting the cache variable VAR accordingly.])],
222 [AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])]dnl
223 [ac_fn_[]_AC_LANG_ABBREV[]_check_header_preproc "$LINENO" "$1" "ac_Header"
224 AS_VAR_IF([ac_Header], [yes], [$2], [$3])
225 AS_VAR_POPDEF([ac_Header])dnl
226 ])# _AC_CHECK_HEADER_PREPROC
229 # _AH_CHECK_HEADER(HEADER-FILE)
230 # -----------------------------
231 # Prepare the autoheader snippet for HEADER-FILE.
232 m4_define([_AH_CHECK_HEADER],
233 [AH_TEMPLATE(AS_TR_CPP([HAVE_$1]),
234 [Define to 1 if you have the <$1> header file.])])
237 # AC_CHECK_HEADERS(HEADER-FILE...,
238 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
240 # ----------------------------------------------------------
241 # Check for each whitespace-separated HEADER-FILE (omitting the <> or
242 # ""), and perform ACTION-IF-FOUND or ACTION-IF-NOT-FOUND for each
243 # header. INCLUDES is as for AC_CHECK_HEADER. Additionally, make the
244 # preprocessor definition HAVE_HEADER_FILE available for each found
245 # header. Either ACTION may include `break' to stop the search.
246 AC_DEFUN([AC_CHECK_HEADERS],
247 [m4_map_args_w([$1], [_AH_CHECK_HEADER(], [)])]dnl
248 [AS_FOR([AC_header], [ac_header], [$1],
249 [AC_CHECK_HEADER(AC_header,
250 [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_]AC_header)) $2],
255 # _AC_CHECK_HEADER_ONCE(HEADER-FILE)
256 # ----------------------------------
257 # Check for a single HEADER-FILE once.
258 m4_define([_AC_CHECK_HEADER_ONCE],
259 [_AH_CHECK_HEADER([$1])AC_DEFUN([_AC_Header_]m4_translit([[$1]],
261 [m4_divert_text([INIT_PREPARE], [AS_VAR_APPEND([ac_header_list], [" $1"])])
262 _AC_HEADERS_EXPANSION])AC_REQUIRE([_AC_Header_]m4_translit([[$1]],
266 # AC_CHECK_HEADERS_ONCE(HEADER-FILE...)
267 # -------------------------------------
268 # Add each whitespace-separated name in HEADER-FILE to the list of
269 # headers to check once.
270 AC_DEFUN([AC_CHECK_HEADERS_ONCE],
271 [m4_map_args_w([$1], [_AC_CHECK_HEADER_ONCE(], [)])])
273 m4_define([_AC_HEADERS_EXPANSION],
275 m4_divert_text([DEFAULTS], [ac_header_list=])
276 AC_CHECK_HEADERS([$ac_header_list], [], [], [AC_INCLUDES_DEFAULT])
277 m4_define([_AC_HEADERS_EXPANSION], [])
283 ## --------------------- ##
284 ## 2. Default includes. ##
285 ## --------------------- ##
287 # Always use the same set of default headers for all the generic
288 # macros. It is easier to document, to extend, and to understand than
289 # having specific defaults for each macro.
291 # _AC_INCLUDES_DEFAULT_REQUIREMENTS
292 # ---------------------------------
293 # Required when AC_INCLUDES_DEFAULT uses its default branch.
294 AC_DEFUN([_AC_INCLUDES_DEFAULT_REQUIREMENTS],
295 [m4_divert_text([DEFAULTS],
296 [# Factoring default headers for most tests.
297 dnl If ever you change this variable, please keep autoconf.texi in sync.
298 ac_includes_default="\
300 #ifdef HAVE_SYS_TYPES_H
301 # include <sys/types.h>
303 #ifdef HAVE_SYS_STAT_H
304 # include <sys/stat.h>
310 # ifdef HAVE_STDLIB_H
315 # if !defined STDC_HEADERS && defined HAVE_MEMORY_H
320 #ifdef HAVE_STRINGS_H
321 # include <strings.h>
323 #ifdef HAVE_INTTYPES_H
324 # include <inttypes.h>
333 AC_REQUIRE([AC_HEADER_STDC])dnl
334 # On IRIX 5.3, sys/types and inttypes.h are conflicting.
335 AC_CHECK_HEADERS([sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
336 inttypes.h stdint.h unistd.h],
337 [], [], $ac_includes_default)
338 ])# _AC_INCLUDES_DEFAULT_REQUIREMENTS
341 # AC_INCLUDES_DEFAULT([INCLUDES])
342 # -------------------------------
343 # If INCLUDES is empty, expand in default includes, otherwise in
345 # In most cases INCLUDES is not double quoted as it should, and if
346 # for instance INCLUDES = `#include <stdio.h>' then unless we force
347 # a newline, the hash will swallow the closing paren etc. etc.
349 # Take no risk: for the newline.
350 AC_DEFUN([AC_INCLUDES_DEFAULT],
353 [AC_REQUIRE([_AC_INCLUDES_DEFAULT_REQUIREMENTS])dnl
354 $ac_includes_default])])
360 ## ------------------------------------------- ##
361 ## 3. Headers to check with AC_CHECK_HEADERS. ##
362 ## ------------------------------------------- ##
364 # errno.h is portable.
366 AN_HEADER([OS.h], [AC_CHECK_HEADERS])
367 AN_HEADER([argz.h], [AC_CHECK_HEADERS])
368 AN_HEADER([arpa/inet.h], [AC_CHECK_HEADERS])
369 AN_HEADER([fcntl.h], [AC_CHECK_HEADERS])
370 AN_HEADER([fenv.h], [AC_CHECK_HEADERS])
371 AN_HEADER([float.h], [AC_CHECK_HEADERS])
372 AN_HEADER([fs_info.h], [AC_CHECK_HEADERS])
373 AN_HEADER([inttypes.h], [AC_CHECK_HEADERS])
374 AN_HEADER([langinfo.h], [AC_CHECK_HEADERS])
375 AN_HEADER([libintl.h], [AC_CHECK_HEADERS])
376 AN_HEADER([limits.h], [AC_CHECK_HEADERS])
377 AN_HEADER([locale.h], [AC_CHECK_HEADERS])
378 AN_HEADER([mach/mach.h], [AC_CHECK_HEADERS])
379 AN_HEADER([malloc.h], [AC_CHECK_HEADERS])
380 AN_HEADER([memory.h], [AC_CHECK_HEADERS])
381 AN_HEADER([mntent.h], [AC_CHECK_HEADERS])
382 AN_HEADER([mnttab.h], [AC_CHECK_HEADERS])
383 AN_HEADER([netdb.h], [AC_CHECK_HEADERS])
384 AN_HEADER([netinet/in.h], [AC_CHECK_HEADERS])
385 AN_HEADER([nl_types.h], [AC_CHECK_HEADERS])
386 AN_HEADER([nlist.h], [AC_CHECK_HEADERS])
387 AN_HEADER([paths.h], [AC_CHECK_HEADERS])
388 AN_HEADER([sgtty.h], [AC_CHECK_HEADERS])
389 AN_HEADER([shadow.h], [AC_CHECK_HEADERS])
390 AN_HEADER([stddef.h], [AC_CHECK_HEADERS])
391 AN_HEADER([stdint.h], [AC_CHECK_HEADERS])
392 AN_HEADER([stdio_ext.h], [AC_CHECK_HEADERS])
393 AN_HEADER([stdlib.h], [AC_CHECK_HEADERS])
394 AN_HEADER([string.h], [AC_CHECK_HEADERS])
395 AN_HEADER([strings.h], [AC_CHECK_HEADERS])
396 AN_HEADER([sys/acl.h], [AC_CHECK_HEADERS])
397 AN_HEADER([sys/file.h], [AC_CHECK_HEADERS])
398 AN_HEADER([sys/filsys.h], [AC_CHECK_HEADERS])
399 AN_HEADER([sys/fs/s5param.h], [AC_CHECK_HEADERS])
400 AN_HEADER([sys/fs_types.h], [AC_CHECK_HEADERS])
401 AN_HEADER([sys/fstyp.h], [AC_CHECK_HEADERS])
402 AN_HEADER([sys/ioctl.h], [AC_CHECK_HEADERS])
403 AN_HEADER([sys/mntent.h], [AC_CHECK_HEADERS])
404 AN_HEADER([sys/mount.h], [AC_CHECK_HEADERS])
405 AN_HEADER([sys/param.h], [AC_CHECK_HEADERS])
406 AN_HEADER([sys/socket.h], [AC_CHECK_HEADERS])
407 AN_HEADER([sys/statfs.h], [AC_CHECK_HEADERS])
408 AN_HEADER([sys/statvfs.h], [AC_CHECK_HEADERS])
409 AN_HEADER([sys/systeminfo.h], [AC_CHECK_HEADERS])
410 AN_HEADER([sys/time.h], [AC_CHECK_HEADERS])
411 AN_HEADER([sys/timeb.h], [AC_CHECK_HEADERS])
412 AN_HEADER([sys/vfs.h], [AC_CHECK_HEADERS])
413 AN_HEADER([sys/window.h], [AC_CHECK_HEADERS])
414 AN_HEADER([syslog.h], [AC_CHECK_HEADERS])
415 AN_HEADER([termio.h], [AC_CHECK_HEADERS])
416 AN_HEADER([termios.h], [AC_CHECK_HEADERS])
417 AN_HEADER([unistd.h], [AC_CHECK_HEADERS])
418 AN_HEADER([utime.h], [AC_CHECK_HEADERS])
419 AN_HEADER([utmp.h], [AC_CHECK_HEADERS])
420 AN_HEADER([utmpx.h], [AC_CHECK_HEADERS])
421 AN_HEADER([values.h], [AC_CHECK_HEADERS])
422 AN_HEADER([wchar.h], [AC_CHECK_HEADERS])
423 AN_HEADER([wctype.h], [AC_CHECK_HEADERS])
427 ## ------------------------------- ##
428 ## 4. Tests for specific headers. ##
429 ## ------------------------------- ##
433 # Check whether to enable assertions.
434 AC_DEFUN([AC_HEADER_ASSERT],
436 AC_MSG_CHECKING([whether to enable assertions])
437 AC_ARG_ENABLE([assert],
438 [AS_HELP_STRING([--disable-assert], [turn off assertions])],
439 [AS_IF([test "x$enableval" = xno],
440 [AC_DEFINE([NDEBUG], [1], [Define to 1 if assertions should be disabled.]),
441 [test "x$enableval" != xyes],
442 AC_MSG_WARN([invalid argument supplied to --enable-assert.])
445 AC_MSG_RESULT([$enable_assert])
449 # _AC_CHECK_HEADER_DIRENT(HEADER-FILE,
450 # [ACTION-IF-FOUND], [ACTION-IF-NOT_FOUND])
451 # -----------------------------------------------------------------
452 # Like AC_CHECK_HEADER, except also make sure that HEADER-FILE
453 # defines the type `DIR'. dirent.h on NextStep 3.2 doesn't.
454 m4_define([_AC_CHECK_HEADER_DIRENT],
455 [AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_dirent_$1])dnl
456 AC_CACHE_CHECK([for $1 that defines DIR], [ac_Header],
457 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
462 [AS_VAR_SET([ac_Header], [yes])],
463 [AS_VAR_SET([ac_Header], [no])])])
464 AS_VAR_IF([ac_Header], [yes], [$2], [$3])
465 AS_VAR_POPDEF([ac_Header])dnl
466 ])# _AC_CHECK_HEADER_DIRENT
469 # _AH_CHECK_HEADER_DIRENT(HEADERS)
470 # --------------------------------
471 # Like _AH_CHECK_HEADER, but tuned to a dirent provider.
472 m4_define([_AH_CHECK_HEADER_DIRENT],
473 [AH_TEMPLATE(AS_TR_CPP([HAVE_$1]),
474 [Define to 1 if you have the <$1> header file, and it defines `DIR'.])])
479 AC_DEFUN([AC_HEADER_DIRENT],
480 [m4_map_args([_AH_CHECK_HEADER_DIRENT], [dirent.h], [sys/ndir.h],
481 [sys/dir.h], [ndir.h])]dnl
483 for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
484 _AC_CHECK_HEADER_DIRENT($ac_hdr,
485 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$ac_hdr), 1)
486 ac_header_dirent=$ac_hdr; break])
488 # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
489 if test $ac_header_dirent = dirent.h; then
490 AC_SEARCH_LIBS(opendir, dir)
492 AC_SEARCH_LIBS(opendir, x)
499 AN_FUNCTION([major], [AC_HEADER_MAJOR])
500 AN_FUNCTION([makedev], [AC_HEADER_MAJOR])
501 AN_FUNCTION([minor], [AC_HEADER_MAJOR])
502 AN_HEADER([sys/mkdev.h], [AC_HEADER_MAJOR])
503 AC_DEFUN([AC_HEADER_MAJOR],
504 [AC_CACHE_CHECK(whether sys/types.h defines makedev,
505 ac_cv_header_sys_types_h_makedev,
506 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include <sys/types.h>]],
507 [[return makedev(0, 0);]])],
508 [ac_cv_header_sys_types_h_makedev=yes],
509 [ac_cv_header_sys_types_h_makedev=no])
512 if test $ac_cv_header_sys_types_h_makedev = no; then
513 AC_CHECK_HEADER(sys/mkdev.h,
514 [AC_DEFINE(MAJOR_IN_MKDEV, 1,
515 [Define to 1 if `major', `minor', and `makedev' are
516 declared in <mkdev.h>.])])
518 if test $ac_cv_header_sys_mkdev_h = no; then
519 AC_CHECK_HEADER(sys/sysmacros.h,
520 [AC_DEFINE(MAJOR_IN_SYSMACROS, 1,
521 [Define to 1 if `major', `minor', and `makedev'
522 are declared in <sysmacros.h>.])])
530 # According to http://www.mcsr.olemiss.edu/cgi-bin/man-cgi?resolver+3
531 # (or http://www.chemie.fu-berlin.de/cgi-bin/man/sgi_irix?resolver+3),
532 # sys/types.h, netinet/in.h and arpa/nameser.h are required on IRIX.
533 # netinet/in.h is needed on Cygwin, too.
534 # With Solaris 9, netdb.h is required, to get symbols like HOST_NOT_FOUND.
536 AN_HEADER(resolv.h, [AC_HEADER_RESOLV])
537 AC_DEFUN([AC_HEADER_RESOLV],
538 [AC_CHECK_HEADERS(sys/types.h netinet/in.h arpa/nameser.h netdb.h resolv.h,
540 [[#ifdef HAVE_SYS_TYPES_H
541 # include <sys/types.h>
543 #ifdef HAVE_NETINET_IN_H
544 # include <netinet/in.h> /* inet_ functions / structs */
546 #ifdef HAVE_ARPA_NAMESER_H
547 # include <arpa/nameser.h> /* DNS HEADER struct */
557 # FIXME: Shouldn't this be named AC_HEADER_SYS_STAT?
558 AC_DEFUN([AC_HEADER_STAT],
559 [AC_CACHE_CHECK(whether stat file-mode macros are broken,
560 ac_cv_header_stat_broken,
561 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <sys/types.h>
562 #include <sys/stat.h>
564 #if defined S_ISBLK && defined S_IFDIR
565 extern char c1[S_ISBLK (S_IFDIR) ? -1 : 1];
568 #if defined S_ISBLK && defined S_IFCHR
569 extern char c2[S_ISBLK (S_IFCHR) ? -1 : 1];
572 #if defined S_ISLNK && defined S_IFREG
573 extern char c3[S_ISLNK (S_IFREG) ? -1 : 1];
576 #if defined S_ISSOCK && defined S_IFREG
577 extern char c4[S_ISSOCK (S_IFREG) ? -1 : 1];
579 ]])], ac_cv_header_stat_broken=no, ac_cv_header_stat_broken=yes)])
580 if test $ac_cv_header_stat_broken = yes; then
581 AC_DEFINE(STAT_MACROS_BROKEN, 1,
582 [Define to 1 if the `S_IS*' macros in <sys/stat.h> do not
590 # Check for stdbool.h that conforms to C99.
591 AN_IDENTIFIER([bool], [AC_HEADER_STDBOOL])
592 AN_IDENTIFIER([true], [AC_HEADER_STDBOOL])
593 AN_IDENTIFIER([false],[AC_HEADER_STDBOOL])
594 AC_DEFUN([AC_HEADER_STDBOOL],
595 [AC_CACHE_CHECK([for stdbool.h that conforms to C99],
596 [ac_cv_header_stdbool_h],
597 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
601 "error: bool is not defined"
604 "error: false is not defined"
607 "error: false is not 0"
610 "error: true is not defined"
613 "error: true is not 1"
615 #ifndef __bool_true_false_are_defined
616 "error: __bool_true_false_are_defined is not defined"
619 struct s { _Bool s: 1; _Bool t; } s;
621 char a[true == 1 ? 1 : -1];
622 char b[false == 0 ? 1 : -1];
623 char c[__bool_true_false_are_defined == 1 ? 1 : -1];
624 char d[(bool) 0.5 == true ? 1 : -1];
626 char f[(_Bool) 0.0 == false ? 1 : -1];
628 char h[sizeof (_Bool)];
630 enum { j = false, k = true, l = false * true, m = true * 256 };
631 /* The following fails for
632 HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */
634 char o[sizeof n == m * sizeof n[0] ? 1 : -1];
635 char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
636 # if defined __xlc__ || defined __GNUC__
637 /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0
638 reported by James Lemley on 2005-10-05; see
639 http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
640 This test is not quite right, since xlc is allowed to
641 reject this program, as the initializer for xlcbug is
642 not one of the forms that C requires support for.
643 However, doing the test right would require a runtime
644 test, and that would make cross-compilation harder.
645 Let us hope that IBM fixes the xlc bug, and also adds
646 support for this kind of constant expression. In the
647 meantime, this test will reject xlc, which is OK, since
648 our stdbool.h substitute should suffice. We also test
649 this with GCC, where it should work, to detect more
650 quickly whether someone messes up the test in the
652 char digs[] = "0123456789";
653 int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1);
655 /* Catch a bug in an HP-UX C compiler. See
656 http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
657 http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
665 /* Refer to every declared value, to avoid compiler optimizations. */
666 return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
667 + !m + !n + !o + !p + !q + !pq);
669 [ac_cv_header_stdbool_h=yes],
670 [ac_cv_header_stdbool_h=no])])
671 AC_CHECK_TYPES([_Bool])
672 if test $ac_cv_header_stdbool_h = yes; then
673 AC_DEFINE(HAVE_STDBOOL_H, 1, [Define to 1 if stdbool.h conforms to C99.])
675 ])# AC_HEADER_STDBOOL
680 AC_DEFUN([AC_HEADER_STDC],
681 [AC_CACHE_CHECK(for ANSI C header files, ac_cv_header_stdc,
682 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
687 [ac_cv_header_stdc=yes],
688 [ac_cv_header_stdc=no])
690 if test $ac_cv_header_stdc = yes; then
691 # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
692 AC_EGREP_HEADER(memchr, string.h, , ac_cv_header_stdc=no)
695 if test $ac_cv_header_stdc = yes; then
696 # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
697 AC_EGREP_HEADER(free, stdlib.h, , ac_cv_header_stdc=no)
700 if test $ac_cv_header_stdc = yes; then
701 # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
702 AC_RUN_IFELSE([AC_LANG_SOURCE(
705 #if ((' ' & 0x0FF) == 0x020)
706 # define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
707 # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
709 # define ISLOWER(c) \
710 (('a' <= (c) && (c) <= 'i') \
711 || ('j' <= (c) && (c) <= 'r') \
712 || ('s' <= (c) && (c) <= 'z'))
713 # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
716 #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
721 for (i = 0; i < 256; i++)
722 if (XOR (islower (i), ISLOWER (i))
723 || toupper (i) != TOUPPER (i))
726 }]])], , ac_cv_header_stdc=no, :)
728 if test $ac_cv_header_stdc = yes; then
729 AC_DEFINE(STDC_HEADERS, 1,
730 [Define to 1 if you have the ANSI C header files.])
737 AC_DEFUN([AC_HEADER_SYS_WAIT],
738 [AC_CACHE_CHECK([for sys/wait.h that is POSIX.1 compatible],
739 ac_cv_header_sys_wait_h,
741 [AC_LANG_PROGRAM([#include <sys/types.h>
742 #include <sys/wait.h>
744 # define WEXITSTATUS(stat_val) ((unsigned int) (stat_val) >> 8)
747 # define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
752 s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;])],
753 [ac_cv_header_sys_wait_h=yes],
754 [ac_cv_header_sys_wait_h=no])])
755 if test $ac_cv_header_sys_wait_h = yes; then
756 AC_DEFINE(HAVE_SYS_WAIT_H, 1,
757 [Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible.])
759 ])# AC_HEADER_SYS_WAIT
764 AC_DEFUN([AC_HEADER_TIME],
765 [AC_CACHE_CHECK([whether time.h and sys/time.h may both be included],
767 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
768 #include <sys/time.h>
771 [if ((struct tm *) 0)
773 [ac_cv_header_time=yes],
774 [ac_cv_header_time=no])])
775 if test $ac_cv_header_time = yes; then
776 AC_DEFINE(TIME_WITH_SYS_TIME, 1,
777 [Define to 1 if you can safely include both <sys/time.h>
783 # _AC_HEADER_TIOCGWINSZ_IN_TERMIOS_H
784 # ----------------------------------
785 m4_define([_AC_HEADER_TIOCGWINSZ_IN_TERMIOS_H],
786 [AC_CACHE_CHECK([whether termios.h defines TIOCGWINSZ],
787 ac_cv_sys_tiocgwinsz_in_termios_h,
789 [#include <sys/types.h>
795 ac_cv_sys_tiocgwinsz_in_termios_h=yes,
796 ac_cv_sys_tiocgwinsz_in_termios_h=no)])
797 ])# _AC_HEADER_TIOCGWINSZ_IN_TERMIOS_H
800 # _AC_HEADER_TIOCGWINSZ_IN_SYS_IOCTL
801 # ----------------------------------
802 m4_define([_AC_HEADER_TIOCGWINSZ_IN_SYS_IOCTL],
803 [AC_CACHE_CHECK([whether sys/ioctl.h defines TIOCGWINSZ],
804 ac_cv_sys_tiocgwinsz_in_sys_ioctl_h,
806 [#include <sys/types.h>
807 #include <sys/ioctl.h>
812 ac_cv_sys_tiocgwinsz_in_sys_ioctl_h=yes,
813 ac_cv_sys_tiocgwinsz_in_sys_ioctl_h=no)])
814 ])# _AC_HEADER_TIOCGWINSZ_IN_SYS_IOCTL
817 # AC_HEADER_TIOCGWINSZ
818 # --------------------
819 # Look for a header that defines TIOCGWINSZ.
820 # FIXME: Is this the proper name? Is this the proper implementation?
822 AC_DEFUN([AC_HEADER_TIOCGWINSZ],
823 [_AC_HEADER_TIOCGWINSZ_IN_TERMIOS_H
824 if test $ac_cv_sys_tiocgwinsz_in_termios_h != yes; then
825 _AC_HEADER_TIOCGWINSZ_IN_SYS_IOCTL
826 if test $ac_cv_sys_tiocgwinsz_in_sys_ioctl_h = yes; then
827 AC_DEFINE(GWINSZ_IN_SYS_IOCTL,1,
828 [Define to 1 if `TIOCGWINSZ' requires <sys/ioctl.h>.])
831 ])# AC_HEADER_TIOCGWINSZ
836 AU_DEFUN([AC_UNISTD_H],
837 [AC_CHECK_HEADERS(unistd.h)])
842 # Define `USG' if string functions are in strings.h.
844 [AC_MSG_CHECKING([for BSD string and memory functions])
845 AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include <strings.h>]],
846 [[rindex(0, 0); bzero(0, 0);]])],
847 [AC_MSG_RESULT(yes)],
850 [Define to 1 if you do not have <strings.h>, index,
851 bzero, etc... This symbol is obsolete, you should
852 not depend upon it.])])
853 AC_CHECK_HEADERS(string.h)],
854 [Remove `AC_MSG_CHECKING', `AC_LINK_IFELSE' and this warning
855 when you adjust your code to use HAVE_STRING_H.])
860 # To be precise this macro used to be:
862 # | AC_MSG_CHECKING(whether string.h declares mem functions)
863 # | AC_EGREP_HEADER(memchr, string.h, ac_found=yes, ac_found=no)
864 # | AC_MSG_RESULT($ac_found)
865 # | if test $ac_found = no; then
866 # | AC_CHECK_HEADER(memory.h, [AC_DEFINE(NEED_MEMORY_H)])
869 # But it is better to check for both headers, and alias NEED_MEMORY_H to
871 AU_DEFUN([AC_MEMORY_H],
872 [AC_CHECK_HEADER(memory.h,
873 [AC_DEFINE([NEED_MEMORY_H], 1,
874 [Same as `HAVE_MEMORY_H', don't depend on me.])])
875 AC_CHECK_HEADERS(string.h memory.h)],
876 [Remove this warning and
877 `AC_CHECK_HEADER(memory.h, AC_DEFINE(...))' when you adjust your code to
878 use HAVE_STRING_H and HAVE_MEMORY_H, not NEED_MEMORY_H.])
883 # Like calling `AC_HEADER_DIRENT' and `AC_FUNC_CLOSEDIR_VOID', but
884 # defines a different set of C preprocessor macros to indicate which
885 # header file is found.
886 AU_DEFUN([AC_DIR_HEADER],
888 AC_FUNC_CLOSEDIR_VOID
889 test ac_cv_header_dirent_dirent_h &&
890 AC_DEFINE([DIRENT], 1, [Same as `HAVE_DIRENT_H', don't depend on me.])
891 test ac_cv_header_dirent_sys_ndir_h &&
892 AC_DEFINE([SYSNDIR], 1, [Same as `HAVE_SYS_NDIR_H', don't depend on me.])
893 test ac_cv_header_dirent_sys_dir_h &&
894 AC_DEFINE([SYSDIR], 1, [Same as `HAVE_SYS_DIR_H', don't depend on me.])
895 test ac_cv_header_dirent_ndir_h &&
896 AC_DEFINE([NDIR], 1, [Same as `HAVE_NDIR_H', don't depend on me.])],
897 [Remove this warning and the four `AC_DEFINE' when you
898 adjust your code to use `AC_HEADER_DIRENT'.])