1 # This file is part of Autoconf. -*- Autoconf -*-
2 # Checking for headers.
4 # Copyright (C) 1988, 1999, 2000, 2001, 2002, 2003, 2004, 2006 Free Software
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 3 of the License, or
10 # (at your option) any later version.
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, see <http://www.gnu.org/licenses/>.
20 # As a special exception, the Free Software Foundation gives unlimited
21 # permission to copy, distribute and modify the configure scripts that
22 # are the output of Autoconf. You need not follow the terms of the GNU
23 # General Public License when using or distributing such scripts, even
24 # though portions of the text of Autoconf appear in them. The GNU
25 # General Public License (GPL) does govern all other use of the material
26 # that constitutes the Autoconf program.
28 # Certain portions of the Autoconf source text are designed to be copied
29 # (in certain cases, depending on the input) into the output of
30 # Autoconf. We call these the "data" portions. The rest of the Autoconf
31 # source text consists of comments plus executable code that decides which
32 # of the data portions to output in any given case. We call these
33 # comments and executable code the "non-data" portions. Autoconf never
34 # copies any of the non-data portions into its output.
36 # This special exception to the GPL applies to versions of Autoconf
37 # released by the Free Software Foundation. When you make and
38 # distribute a modified version of Autoconf, you may extend this special
39 # exception to the GPL to apply to your modified version as well, *unless*
40 # your modified version has the potential to copy into its output some
41 # of the text that was the non-data portion of the version that you started
42 # with. (In other words, unless your change moves or copies text from
43 # the non-data portions to the data portions.) If your modification has
44 # such potential, you must delete any notice of this special exception
45 # to the GPL from your modified version.
47 # Written by David MacKenzie, with help from
48 # Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
49 # Roland McGrath, Noah Friedman, david d zuhn, and many others.
54 # 1. Generic tests for headers
56 # 3. Headers to tests with AC_CHECK_HEADERS
57 # 4. Tests for specific headers
60 ## ------------------------------ ##
61 ## 1. Generic tests for headers. ##
62 ## ------------------------------ ##
65 # AC_CHECK_HEADER(HEADER-FILE,
66 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
68 # ---------------------------------------------------------
69 # We are slowly moving to checking headers with the compiler instead
70 # of the preproc, so that we actually learn about the usability of a
71 # header instead of its mere presence. But since users are used to
72 # the old semantics, they check for headers in random order and
73 # without providing prerequisite headers. This macro implements the
74 # transition phase, and should be cleaned up latter to use compilation
77 # If INCLUDES is empty, then check both via the compiler and preproc.
78 # If the results are different, issue a warning, but keep the preproc
81 # If INCLUDES is `-', keep only the old semantics.
83 # If INCLUDES is specified and different from `-', then use the new
85 AC_DEFUN([AC_CHECK_HEADER],
87 [], [_AC_CHECK_HEADER_MONGREL($@)],
88 [-], [_AC_CHECK_HEADER_OLD($@)],
89 [_AC_CHECK_HEADER_NEW($@)])
93 # _AC_CHECK_HEADER_MONGREL(HEADER-FILE,
94 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
95 # [INCLUDES = DEFAULT-INCLUDES])
96 # ------------------------------------------------------------------
97 # Check using both the compiler and the preprocessor. If they disagree,
98 # warn, and the preproc wins.
100 # This is not based on _AC_CHECK_HEADER_NEW and _AC_CHECK_HEADER_OLD
101 # because it obfuscate the code to try to factor everything, in particular
102 # because of the cache variables, and the `checking...' messages.
103 m4_define([_AC_CHECK_HEADER_MONGREL],
104 [AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])dnl
105 AS_VAR_SET_IF([ac_Header],
106 [AC_CACHE_CHECK([for $1], [ac_Header], [])],
107 [# Is the header compilable?
108 AC_MSG_CHECKING([$1 usability])
109 AC_COMPILE_IFELSE([AC_LANG_SOURCE([AC_INCLUDES_DEFAULT([$4])
111 [ac_header_compiler=yes],
112 [ac_header_compiler=no])
113 AC_MSG_RESULT([$ac_header_compiler])
115 # Is the header present?
116 AC_MSG_CHECKING([$1 presence])
117 AC_PREPROC_IFELSE([AC_LANG_SOURCE([@%:@include <$1>])],
118 [ac_header_preproc=yes],
119 [ac_header_preproc=no])
120 AC_MSG_RESULT([$ac_header_preproc])
122 # So? What about this header?
123 case $ac_header_compiler:$ac_header_preproc:$ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag in
125 AC_MSG_WARN([$1: accepted by the compiler, rejected by the preprocessor!])
126 AC_MSG_WARN([$1: proceeding with the compiler's result])
127 ac_header_preproc=yes
130 AC_MSG_WARN([$1: present but cannot be compiled])
131 AC_MSG_WARN([$1: check for missing prerequisite headers?])
132 AC_MSG_WARN([$1: see the Autoconf documentation])
133 AC_MSG_WARN([$1: section "Present But Cannot Be Compiled"])
134 AC_MSG_WARN([$1: proceeding with the preprocessor's result])
135 AC_MSG_WARN([$1: in the future, the compiler will take precedence])
136 m4_ifset([AC_PACKAGE_BUGREPORT],
137 [( AS_BOX([Report this to ]AC_PACKAGE_BUGREPORT)
138 ) | sed "s/^/$as_me: WARNING: /" >&2])
141 AC_CACHE_CHECK([for $1], [ac_Header],
142 [AS_VAR_SET([ac_Header], [$ac_header_preproc])])
143 ])dnl ! set ac_HEADER
144 AS_IF([test AS_VAR_GET([ac_Header]) = yes], [$2], [$3])[]dnl
145 AS_VAR_POPDEF([ac_Header])dnl
146 ])# _AC_CHECK_HEADER_MONGREL
149 # _AC_CHECK_HEADER_NEW(HEADER-FILE,
150 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
151 # [INCLUDES = DEFAULT-INCLUDES])
152 # --------------------------------------------------------------
153 # Check the compiler accepts HEADER-FILE. The INCLUDES are defaulted.
154 m4_define([_AC_CHECK_HEADER_NEW],
155 [AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])dnl
156 AC_CACHE_CHECK([for $1], [ac_Header],
157 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([AC_INCLUDES_DEFAULT([$4])
159 [AS_VAR_SET([ac_Header], [yes])],
160 [AS_VAR_SET([ac_Header], [no])])])
161 AS_IF([test AS_VAR_GET([ac_Header]) = yes], [$2], [$3])[]dnl
162 AS_VAR_POPDEF([ac_Header])dnl
163 ])# _AC_CHECK_HEADER_NEW
166 # _AC_CHECK_HEADER_OLD(HEADER-FILE,
167 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
168 # --------------------------------------------------------------
169 # Check the preprocessor accepts HEADER-FILE.
170 m4_define([_AC_CHECK_HEADER_OLD],
171 [AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])dnl
172 AC_CACHE_CHECK([for $1], [ac_Header],
173 [AC_PREPROC_IFELSE([AC_LANG_SOURCE([@%:@include <$1>])],
174 [AS_VAR_SET([ac_Header], [yes])],
175 [AS_VAR_SET([ac_Header], [no])])])
176 AS_IF([test AS_VAR_GET([ac_Header]) = yes], [$2], [$3])[]dnl
177 AS_VAR_POPDEF([ac_Header])dnl
178 ])# _AC_CHECK_HEADER_OLD
181 # AH_CHECK_HEADERS(HEADER-FILE...)
182 # --------------------------------
183 m4_define([AH_CHECK_HEADERS],
184 [m4_foreach_w([AC_Header], [$1],
185 [AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([AC_Header])),
186 [Define to 1 if you have the <]m4_defn([AC_Header])[> header file.])])])
189 # AC_CHECK_HEADERS(HEADER-FILE...,
190 # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
192 # ----------------------------------------------------------
193 AC_DEFUN([AC_CHECK_HEADERS],
194 [AH_CHECK_HEADERS([$1])dnl
197 AC_CHECK_HEADER($ac_header,
198 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$ac_header)) $2],
205 # AC_CHECK_HEADERS_ONCE(HEADER-FILE...)
206 # -------------------------------------
207 AC_DEFUN([AC_CHECK_HEADERS_ONCE],
209 AH_CHECK_HEADERS([$1])
210 m4_foreach_w([AC_Header], [$1],
211 [AC_DEFUN([_AC_Header_]m4_quote(m4_translit(AC_Header, [./-], [___])),
212 [m4_divert_text([INIT_PREPARE],
213 [ac_header_list="$ac_header_list AC_Header"])
214 _AC_HEADERS_EXPANSION])
215 AC_REQUIRE([_AC_Header_]m4_quote(m4_translit(AC_Header, [./-], [___])))])
217 m4_define([_AC_HEADERS_EXPANSION],
219 m4_divert_text([DEFAULTS], [ac_header_list=])
220 AC_CHECK_HEADERS([$ac_header_list])
221 m4_define([_AC_HEADERS_EXPANSION], [])
227 ## --------------------- ##
228 ## 2. Default includes. ##
229 ## --------------------- ##
231 # Always use the same set of default headers for all the generic
232 # macros. It is easier to document, to extend, and to understand than
233 # having specific defaults for each macro.
235 # _AC_INCLUDES_DEFAULT_REQUIREMENTS
236 # ---------------------------------
237 # Required when AC_INCLUDES_DEFAULT uses its default branch.
238 AC_DEFUN([_AC_INCLUDES_DEFAULT_REQUIREMENTS],
239 [m4_divert_text([DEFAULTS],
240 [# Factoring default headers for most tests.
241 dnl If ever you change this variable, please keep autoconf.texi in sync.
242 ac_includes_default="\
244 #ifdef HAVE_SYS_TYPES_H
245 # include <sys/types.h>
247 #ifdef HAVE_SYS_STAT_H
248 # include <sys/stat.h>
254 # ifdef HAVE_STDLIB_H
259 # if !defined STDC_HEADERS && defined HAVE_MEMORY_H
264 #ifdef HAVE_STRINGS_H
265 # include <strings.h>
267 #ifdef HAVE_INTTYPES_H
268 # include <inttypes.h>
277 AC_REQUIRE([AC_HEADER_STDC])dnl
278 # On IRIX 5.3, sys/types and inttypes.h are conflicting.
279 AC_CHECK_HEADERS([sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
280 inttypes.h stdint.h unistd.h],
281 [], [], $ac_includes_default)
282 ])# _AC_INCLUDES_DEFAULT_REQUIREMENTS
285 # AC_INCLUDES_DEFAULT([INCLUDES])
286 # -------------------------------
287 # If INCLUDES is empty, expand in default includes, otherwise in
289 # In most cases INCLUDES is not double quoted as it should, and if
290 # for instance INCLUDES = `#include <stdio.h>' then unless we force
291 # a newline, the hash will swallow the closing paren etc. etc.
293 # Take no risk: for the newline.
294 AC_DEFUN([AC_INCLUDES_DEFAULT],
297 [AC_REQUIRE([_AC_INCLUDES_DEFAULT_REQUIREMENTS])dnl
298 $ac_includes_default])])
304 ## ------------------------------------------- ##
305 ## 3. Headers to check with AC_CHECK_HEADERS. ##
306 ## ------------------------------------------- ##
308 # errno.h is portable.
310 AN_HEADER([OS.h], [AC_CHECK_HEADERS])
311 AN_HEADER([argz.h], [AC_CHECK_HEADERS])
312 AN_HEADER([arpa/inet.h], [AC_CHECK_HEADERS])
313 AN_HEADER([fcntl.h], [AC_CHECK_HEADERS])
314 AN_HEADER([fenv.h], [AC_CHECK_HEADERS])
315 AN_HEADER([float.h], [AC_CHECK_HEADERS])
316 AN_HEADER([fs_info.h], [AC_CHECK_HEADERS])
317 AN_HEADER([inttypes.h], [AC_CHECK_HEADERS])
318 AN_HEADER([langinfo.h], [AC_CHECK_HEADERS])
319 AN_HEADER([libintl.h], [AC_CHECK_HEADERS])
320 AN_HEADER([limits.h], [AC_CHECK_HEADERS])
321 AN_HEADER([locale.h], [AC_CHECK_HEADERS])
322 AN_HEADER([mach/mach.h], [AC_CHECK_HEADERS])
323 AN_HEADER([malloc.h], [AC_CHECK_HEADERS])
324 AN_HEADER([memory.h], [AC_CHECK_HEADERS])
325 AN_HEADER([mntent.h], [AC_CHECK_HEADERS])
326 AN_HEADER([mnttab.h], [AC_CHECK_HEADERS])
327 AN_HEADER([netdb.h], [AC_CHECK_HEADERS])
328 AN_HEADER([netinet/in.h], [AC_CHECK_HEADERS])
329 AN_HEADER([nl_types.h], [AC_CHECK_HEADERS])
330 AN_HEADER([nlist.h], [AC_CHECK_HEADERS])
331 AN_HEADER([paths.h], [AC_CHECK_HEADERS])
332 AN_HEADER([sgtty.h], [AC_CHECK_HEADERS])
333 AN_HEADER([shadow.h], [AC_CHECK_HEADERS])
334 AN_HEADER([stddef.h], [AC_CHECK_HEADERS])
335 AN_HEADER([stdint.h], [AC_CHECK_HEADERS])
336 AN_HEADER([stdio_ext.h], [AC_CHECK_HEADERS])
337 AN_HEADER([stdlib.h], [AC_CHECK_HEADERS])
338 AN_HEADER([string.h], [AC_CHECK_HEADERS])
339 AN_HEADER([strings.h], [AC_CHECK_HEADERS])
340 AN_HEADER([sys/acl.h], [AC_CHECK_HEADERS])
341 AN_HEADER([sys/file.h], [AC_CHECK_HEADERS])
342 AN_HEADER([sys/filsys.h], [AC_CHECK_HEADERS])
343 AN_HEADER([sys/fs/s5param.h], [AC_CHECK_HEADERS])
344 AN_HEADER([sys/fs_types.h], [AC_CHECK_HEADERS])
345 AN_HEADER([sys/fstyp.h], [AC_CHECK_HEADERS])
346 AN_HEADER([sys/ioctl.h], [AC_CHECK_HEADERS])
347 AN_HEADER([sys/mntent.h], [AC_CHECK_HEADERS])
348 AN_HEADER([sys/mount.h], [AC_CHECK_HEADERS])
349 AN_HEADER([sys/param.h], [AC_CHECK_HEADERS])
350 AN_HEADER([sys/socket.h], [AC_CHECK_HEADERS])
351 AN_HEADER([sys/statfs.h], [AC_CHECK_HEADERS])
352 AN_HEADER([sys/statvfs.h], [AC_CHECK_HEADERS])
353 AN_HEADER([sys/systeminfo.h], [AC_CHECK_HEADERS])
354 AN_HEADER([sys/time.h], [AC_CHECK_HEADERS])
355 AN_HEADER([sys/timeb.h], [AC_CHECK_HEADERS])
356 AN_HEADER([sys/vfs.h], [AC_CHECK_HEADERS])
357 AN_HEADER([sys/window.h], [AC_CHECK_HEADERS])
358 AN_HEADER([syslog.h], [AC_CHECK_HEADERS])
359 AN_HEADER([termio.h], [AC_CHECK_HEADERS])
360 AN_HEADER([termios.h], [AC_CHECK_HEADERS])
361 AN_HEADER([unistd.h], [AC_CHECK_HEADERS])
362 AN_HEADER([utime.h], [AC_CHECK_HEADERS])
363 AN_HEADER([utmp.h], [AC_CHECK_HEADERS])
364 AN_HEADER([utmpx.h], [AC_CHECK_HEADERS])
365 AN_HEADER([values.h], [AC_CHECK_HEADERS])
366 AN_HEADER([wchar.h], [AC_CHECK_HEADERS])
367 AN_HEADER([wctype.h], [AC_CHECK_HEADERS])
371 ## ------------------------------- ##
372 ## 4. Tests for specific headers. ##
373 ## ------------------------------- ##
377 # Check whether to enable assertions.
378 AC_DEFUN([AC_HEADER_ASSERT],
380 AC_MSG_CHECKING([whether to enable assertions])
381 AC_ARG_ENABLE([assert],
382 [ --disable-assert turn off assertions],
384 AC_DEFINE(NDEBUG, 1, [Define to 1 if assertions should be disabled.])],
385 [AC_MSG_RESULT(yes)])
389 # _AC_CHECK_HEADER_DIRENT(HEADER-FILE,
390 # [ACTION-IF-FOUND], [ACTION-IF-NOT_FOUND])
391 # -----------------------------------------------------------------
392 # Like AC_CHECK_HEADER, except also make sure that HEADER-FILE
393 # defines the type `DIR'. dirent.h on NextStep 3.2 doesn't.
394 m4_define([_AC_CHECK_HEADER_DIRENT],
395 [AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_dirent_$1])dnl
396 AC_CACHE_CHECK([for $1 that defines DIR], [ac_Header],
397 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
402 [AS_VAR_SET([ac_Header], [yes])],
403 [AS_VAR_SET([ac_Header], [no])])])
404 AS_IF([test AS_VAR_GET([ac_Header]) = yes], [$2], [$3])[]dnl
405 AS_VAR_POPDEF([ac_Header])dnl
406 ])# _AC_CHECK_HEADER_DIRENT
409 # AH_CHECK_HEADERS_DIRENT(HEADERS...)
410 # -----------------------------------
411 m4_define([AH_CHECK_HEADERS_DIRENT],
412 [m4_foreach_w([AC_Header], [$1],
413 [AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([AC_Header])),
414 [Define to 1 if you have the <]m4_defn([AC_Header])[> header file, and
415 it defines `DIR'.])])])
420 AC_DEFUN([AC_HEADER_DIRENT],
421 [AH_CHECK_HEADERS_DIRENT(dirent.h sys/ndir.h sys/dir.h ndir.h)
423 for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
424 _AC_CHECK_HEADER_DIRENT($ac_hdr,
425 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$ac_hdr), 1)
426 ac_header_dirent=$ac_hdr; break])
428 # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
429 if test $ac_header_dirent = dirent.h; then
430 AC_SEARCH_LIBS(opendir, dir)
432 AC_SEARCH_LIBS(opendir, x)
439 AN_FUNCTION([major], [AC_HEADER_MAJOR])
440 AN_FUNCTION([makedev], [AC_HEADER_MAJOR])
441 AN_FUNCTION([minor], [AC_HEADER_MAJOR])
442 AN_HEADER([sys/mkdev.h], [AC_HEADER_MAJOR])
443 AC_DEFUN([AC_HEADER_MAJOR],
444 [AC_CACHE_CHECK(whether sys/types.h defines makedev,
445 ac_cv_header_sys_types_h_makedev,
446 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include <sys/types.h>]],
447 [[return makedev(0, 0);]])],
448 [ac_cv_header_sys_types_h_makedev=yes],
449 [ac_cv_header_sys_types_h_makedev=no])
452 if test $ac_cv_header_sys_types_h_makedev = no; then
453 AC_CHECK_HEADER(sys/mkdev.h,
454 [AC_DEFINE(MAJOR_IN_MKDEV, 1,
455 [Define to 1 if `major', `minor', and `makedev' are
456 declared in <mkdev.h>.])])
458 if test $ac_cv_header_sys_mkdev_h = no; then
459 AC_CHECK_HEADER(sys/sysmacros.h,
460 [AC_DEFINE(MAJOR_IN_SYSMACROS, 1,
461 [Define to 1 if `major', `minor', and `makedev'
462 are declared in <sysmacros.h>.])])
470 # According to http://www.mcsr.olemiss.edu/cgi-bin/man-cgi?resolver+3
471 # (or http://www.chemie.fu-berlin.de/cgi-bin/man/sgi_irix?resolver+3),
472 # sys/types.h, netinet/in.h and arpa/nameser.h are required on IRIX.
473 # netinet/in.h is needed on Cygwin, too.
474 # With Solaris 9, netdb.h is required, to get symbols like HOST_NOT_FOUND.
476 AN_HEADER(resolv.h, [AC_HEADER_RESOLV])
477 AC_DEFUN([AC_HEADER_RESOLV],
478 [AC_CHECK_HEADERS(sys/types.h netinet/in.h arpa/nameser.h netdb.h resolv.h,
480 [[#ifdef HAVE_SYS_TYPES_H
481 # include <sys/types.h>
483 #ifdef HAVE_NETINET_IN_H
484 # include <netinet/in.h> /* inet_ functions / structs */
486 #ifdef HAVE_ARPA_NAMESER_H
487 # include <arpa/nameser.h> /* DNS HEADER struct */
497 # FIXME: Shouldn't this be named AC_HEADER_SYS_STAT?
498 AC_DEFUN([AC_HEADER_STAT],
499 [AC_CACHE_CHECK(whether stat file-mode macros are broken,
500 ac_cv_header_stat_broken,
501 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <sys/types.h>
502 #include <sys/stat.h>
504 #if defined S_ISBLK && defined S_IFDIR
505 extern char c1[S_ISBLK (S_IFDIR) ? -1 : 1];
508 #if defined S_ISBLK && defined S_IFCHR
509 extern char c2[S_ISBLK (S_IFCHR) ? -1 : 1];
512 #if defined S_ISLNK && defined S_IFREG
513 extern char c3[S_ISLNK (S_IFREG) ? -1 : 1];
516 #if defined S_ISSOCK && defined S_IFREG
517 extern char c4[S_ISSOCK (S_IFREG) ? -1 : 1];
519 ]])], ac_cv_header_stat_broken=no, ac_cv_header_stat_broken=yes)])
520 if test $ac_cv_header_stat_broken = yes; then
521 AC_DEFINE(STAT_MACROS_BROKEN, 1,
522 [Define to 1 if the `S_IS*' macros in <sys/stat.h> do not
530 # Check for stdbool.h that conforms to C99.
531 AN_IDENTIFIER([bool], [AC_HEADER_STDBOOL])
532 AN_IDENTIFIER([true], [AC_HEADER_STDBOOL])
533 AN_IDENTIFIER([false],[AC_HEADER_STDBOOL])
534 AC_DEFUN([AC_HEADER_STDBOOL],
535 [AC_CACHE_CHECK([for stdbool.h that conforms to C99],
536 [ac_cv_header_stdbool_h],
537 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
541 "error: bool is not defined"
544 "error: false is not defined"
547 "error: false is not 0"
550 "error: true is not defined"
553 "error: true is not 1"
555 #ifndef __bool_true_false_are_defined
556 "error: __bool_true_false_are_defined is not defined"
559 struct s { _Bool s: 1; _Bool t; } s;
561 char a[true == 1 ? 1 : -1];
562 char b[false == 0 ? 1 : -1];
563 char c[__bool_true_false_are_defined == 1 ? 1 : -1];
564 char d[(bool) 0.5 == true ? 1 : -1];
566 char f[(_Bool) 0.0 == false ? 1 : -1];
568 char h[sizeof (_Bool)];
570 enum { j = false, k = true, l = false * true, m = true * 256 };
572 char o[sizeof n == m * sizeof n[0] ? 1 : -1];
573 char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
574 # if defined __xlc__ || defined __GNUC__
575 /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0
576 reported by James Lemley on 2005-10-05; see
577 http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
578 This test is not quite right, since xlc is allowed to
579 reject this program, as the initializer for xlcbug is
580 not one of the forms that C requires support for.
581 However, doing the test right would require a runtime
582 test, and that would make cross-compilation harder.
583 Let us hope that IBM fixes the xlc bug, and also adds
584 support for this kind of constant expression. In the
585 meantime, this test will reject xlc, which is OK, since
586 our stdbool.h substitute should suffice. We also test
587 this with GCC, where it should work, to detect more
588 quickly whether someone messes up the test in the
590 char digs[] = "0123456789";
591 int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1);
593 /* Catch a bug in an HP-UX C compiler. See
594 http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
595 http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
603 /* Refer to every declared value, to avoid compiler optimizations. */
604 return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
605 + !m + !n + !o + !p + !q + !pq);
607 [ac_cv_header_stdbool_h=yes],
608 [ac_cv_header_stdbool_h=no])])
609 AC_CHECK_TYPES([_Bool])
610 if test $ac_cv_header_stdbool_h = yes; then
611 AC_DEFINE(HAVE_STDBOOL_H, 1, [Define to 1 if stdbool.h conforms to C99.])
613 ])# AC_HEADER_STDBOOL
618 AC_DEFUN([AC_HEADER_STDC],
619 [AC_CACHE_CHECK(for ANSI C header files, ac_cv_header_stdc,
620 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
625 [ac_cv_header_stdc=yes],
626 [ac_cv_header_stdc=no])
628 if test $ac_cv_header_stdc = yes; then
629 # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
630 AC_EGREP_HEADER(memchr, string.h, , ac_cv_header_stdc=no)
633 if test $ac_cv_header_stdc = yes; then
634 # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
635 AC_EGREP_HEADER(free, stdlib.h, , ac_cv_header_stdc=no)
638 if test $ac_cv_header_stdc = yes; then
639 # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
640 AC_RUN_IFELSE([AC_LANG_SOURCE(
643 #if ((' ' & 0x0FF) == 0x020)
644 # define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
645 # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
647 # define ISLOWER(c) \
648 (('a' <= (c) && (c) <= 'i') \
649 || ('j' <= (c) && (c) <= 'r') \
650 || ('s' <= (c) && (c) <= 'z'))
651 # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
654 #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
659 for (i = 0; i < 256; i++)
660 if (XOR (islower (i), ISLOWER (i))
661 || toupper (i) != TOUPPER (i))
664 }]])], , ac_cv_header_stdc=no, :)
666 if test $ac_cv_header_stdc = yes; then
667 AC_DEFINE(STDC_HEADERS, 1,
668 [Define to 1 if you have the ANSI C header files.])
675 AC_DEFUN([AC_HEADER_SYS_WAIT],
676 [AC_CACHE_CHECK([for sys/wait.h that is POSIX.1 compatible],
677 ac_cv_header_sys_wait_h,
679 [AC_LANG_PROGRAM([#include <sys/types.h>
680 #include <sys/wait.h>
682 # define WEXITSTATUS(stat_val) ((unsigned int) (stat_val) >> 8)
685 # define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
690 s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;])],
691 [ac_cv_header_sys_wait_h=yes],
692 [ac_cv_header_sys_wait_h=no])])
693 if test $ac_cv_header_sys_wait_h = yes; then
694 AC_DEFINE(HAVE_SYS_WAIT_H, 1,
695 [Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible.])
697 ])# AC_HEADER_SYS_WAIT
702 AC_DEFUN([AC_HEADER_TIME],
703 [AC_CACHE_CHECK([whether time.h and sys/time.h may both be included],
705 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
706 #include <sys/time.h>
709 [if ((struct tm *) 0)
711 [ac_cv_header_time=yes],
712 [ac_cv_header_time=no])])
713 if test $ac_cv_header_time = yes; then
714 AC_DEFINE(TIME_WITH_SYS_TIME, 1,
715 [Define to 1 if you can safely include both <sys/time.h>
721 # _AC_HEADER_TIOCGWINSZ_IN_TERMIOS_H
722 # ----------------------------------
723 m4_define([_AC_HEADER_TIOCGWINSZ_IN_TERMIOS_H],
724 [AC_CACHE_CHECK([whether termios.h defines TIOCGWINSZ],
725 ac_cv_sys_tiocgwinsz_in_termios_h,
727 [#include <sys/types.h>
733 ac_cv_sys_tiocgwinsz_in_termios_h=yes,
734 ac_cv_sys_tiocgwinsz_in_termios_h=no)])
735 ])# _AC_HEADER_TIOCGWINSZ_IN_TERMIOS_H
738 # _AC_HEADER_TIOCGWINSZ_IN_SYS_IOCTL
739 # ----------------------------------
740 m4_define([_AC_HEADER_TIOCGWINSZ_IN_SYS_IOCTL],
741 [AC_CACHE_CHECK([whether sys/ioctl.h defines TIOCGWINSZ],
742 ac_cv_sys_tiocgwinsz_in_sys_ioctl_h,
744 [#include <sys/types.h>
745 #include <sys/ioctl.h>
750 ac_cv_sys_tiocgwinsz_in_sys_ioctl_h=yes,
751 ac_cv_sys_tiocgwinsz_in_sys_ioctl_h=no)])
752 ])# _AC_HEADER_TIOCGWINSZ_IN_SYS_IOCTL
755 # AC_HEADER_TIOCGWINSZ
756 # --------------------
757 # Look for a header that defines TIOCGWINSZ.
758 # FIXME: Is this the proper name? Is this the proper implementation?
760 AC_DEFUN([AC_HEADER_TIOCGWINSZ],
761 [_AC_HEADER_TIOCGWINSZ_IN_TERMIOS_H
762 if test $ac_cv_sys_tiocgwinsz_in_termios_h != yes; then
763 _AC_HEADER_TIOCGWINSZ_IN_SYS_IOCTL
764 if test $ac_cv_sys_tiocgwinsz_in_sys_ioctl_h = yes; then
765 AC_DEFINE(GWINSZ_IN_SYS_IOCTL,1,
766 [Define to 1 if `TIOCGWINSZ' requires <sys/ioctl.h>.])
769 ])# AC_HEADER_TIOCGWINSZ
774 AU_DEFUN([AC_UNISTD_H],
775 [AC_CHECK_HEADERS(unistd.h)])
780 # Define `USG' if string functions are in strings.h.
782 [AC_MSG_CHECKING([for BSD string and memory functions])
783 AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include <strings.h>]],
784 [[rindex(0, 0); bzero(0, 0);]])],
785 [AC_MSG_RESULT(yes)],
788 [Define to 1 if you do not have <strings.h>, index,
789 bzero, etc... This symbol is obsolete, you should
790 not depend upon it.])])
791 AC_CHECK_HEADERS(string.h)],
792 [Remove `AC_MSG_CHECKING', `AC_LINK_IFELSE' and this warning
793 when you adjust your code to use HAVE_STRING_H.])
798 # To be precise this macro used to be:
800 # | AC_MSG_CHECKING(whether string.h declares mem functions)
801 # | AC_EGREP_HEADER(memchr, string.h, ac_found=yes, ac_found=no)
802 # | AC_MSG_RESULT($ac_found)
803 # | if test $ac_found = no; then
804 # | AC_CHECK_HEADER(memory.h, [AC_DEFINE(NEED_MEMORY_H)])
807 # But it is better to check for both headers, and alias NEED_MEMORY_H to
809 AU_DEFUN([AC_MEMORY_H],
810 [AC_CHECK_HEADER(memory.h,
811 [AC_DEFINE([NEED_MEMORY_H], 1,
812 [Same as `HAVE_MEMORY_H', don't depend on me.])])
813 AC_CHECK_HEADERS(string.h memory.h)],
814 [Remove this warning and
815 `AC_CHECK_HEADER(memory.h, AC_DEFINE(...))' when you adjust your code to
816 use HAVE_STRING_H and HAVE_MEMORY_H, not NEED_MEMORY_H.])
821 # Like calling `AC_HEADER_DIRENT' and `AC_FUNC_CLOSEDIR_VOID', but
822 # defines a different set of C preprocessor macros to indicate which
823 # header file is found.
824 AU_DEFUN([AC_DIR_HEADER],
826 AC_FUNC_CLOSEDIR_VOID
827 test ac_cv_header_dirent_dirent_h &&
828 AC_DEFINE([DIRENT], 1, [Same as `HAVE_DIRENT_H', don't depend on me.])
829 test ac_cv_header_dirent_sys_ndir_h &&
830 AC_DEFINE([SYSNDIR], 1, [Same as `HAVE_SYS_NDIR_H', don't depend on me.])
831 test ac_cv_header_dirent_sys_dir_h &&
832 AC_DEFINE([SYSDIR], 1, [Same as `HAVE_SYS_DIR_H', don't depend on me.])
833 test ac_cv_header_dirent_ndir_h &&
834 AC_DEFINE([NDIR], 1, [Same as `HAVE_NDIR_H', don't depend on me.])],
835 [Remove this warning and the four `AC_DEFINE' when you
836 adjust your code to use `AC_HEADER_DIRENT'.])