Update autoconf to version 2.61
[msysgit.git] / share / autoconf / autoconf / headers.m4
blob85b580c21ad74408160e66e5eec19c1963c3f6b9
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
5 # 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)
10 # 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, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 # 02110-1301, USA.
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.
54 # Table of contents
56 # 1. Generic tests for headers
57 # 2. Default includes
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],
69 #                 [INCLUDES])
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
77 # only.
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
81 # result.
83 # If INCLUDES is `-', keep only the old semantics.
85 # If INCLUDES is specified and different from `-', then use the new
86 # semantics only.
87 AC_DEFUN([AC_CHECK_HEADER],
88 [m4_case([$4],
89          [],  [_AC_CHECK_HEADER_MONGREL($@)],
90          [-], [_AC_CHECK_HEADER_OLD($@)],
91               [_AC_CHECK_HEADER_NEW($@)])
92 ])# AC_CHECK_HEADER
95 # _AC_CHECK_HEADER_MONGREL(HEADER-FILE,
96 #                          [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
97 #                          [INCLUDES = DEFAULT-INCLUDES])
98 # ------------------------------------------------------------------
99 # Check using both the compiler and the preprocessor.  If they disagree,
100 # warn, and the preproc wins.
102 # This is not based on _AC_CHECK_HEADER_NEW and _AC_CHECK_HEADER_OLD
103 # because it obfuscate the code to try to factor everything, in particular
104 # because of the cache variables, and the `checking...' messages.
105 m4_define([_AC_CHECK_HEADER_MONGREL],
106 [AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])dnl
107 AS_VAR_SET_IF([ac_Header],
108               [AC_CACHE_CHECK([for $1], [ac_Header], [])],
109               [# Is the header compilable?
110 AC_MSG_CHECKING([$1 usability])
111 AC_COMPILE_IFELSE([AC_LANG_SOURCE([AC_INCLUDES_DEFAULT([$4])
112 @%:@include <$1>])],
113                   [ac_header_compiler=yes],
114                   [ac_header_compiler=no])
115 AC_MSG_RESULT([$ac_header_compiler])
117 # Is the header present?
118 AC_MSG_CHECKING([$1 presence])
119 AC_PREPROC_IFELSE([AC_LANG_SOURCE([@%:@include <$1>])],
120                   [ac_header_preproc=yes],
121                   [ac_header_preproc=no])
122 AC_MSG_RESULT([$ac_header_preproc])
124 # So?  What about this header?
125 case $ac_header_compiler:$ac_header_preproc:$ac_[]_AC_LANG_ABBREV[]_preproc_warn_flag in
126   yes:no: )
127     AC_MSG_WARN([$1: accepted by the compiler, rejected by the preprocessor!])
128     AC_MSG_WARN([$1: proceeding with the compiler's result])
129     ac_header_preproc=yes
130     ;;
131   no:yes:* )
132     AC_MSG_WARN([$1: present but cannot be compiled])
133     AC_MSG_WARN([$1:     check for missing prerequisite headers?])
134     AC_MSG_WARN([$1: see the Autoconf documentation])
135     AC_MSG_WARN([$1:     section "Present But Cannot Be Compiled"])
136     AC_MSG_WARN([$1: proceeding with the preprocessor's result])
137     AC_MSG_WARN([$1: in the future, the compiler will take precedence])
138     m4_ifset([AC_PACKAGE_BUGREPORT],
139     [( AS_BOX([Report this to ]AC_PACKAGE_BUGREPORT)
140      ) | sed "s/^/$as_me: WARNING:     /" >&2])
141     ;;
142 esac
143 AC_CACHE_CHECK([for $1], [ac_Header],
144                [AS_VAR_SET([ac_Header], [$ac_header_preproc])])
145 ])dnl ! set ac_HEADER
146 AS_IF([test AS_VAR_GET([ac_Header]) = yes], [$2], [$3])[]dnl
147 AS_VAR_POPDEF([ac_Header])dnl
148 ])# _AC_CHECK_HEADER_MONGREL
151 # _AC_CHECK_HEADER_NEW(HEADER-FILE,
152 #                      [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
153 #                      [INCLUDES = DEFAULT-INCLUDES])
154 # --------------------------------------------------------------
155 # Check the compiler accepts HEADER-FILE.  The INCLUDES are defaulted.
156 m4_define([_AC_CHECK_HEADER_NEW],
157 [AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])dnl
158 AC_CACHE_CHECK([for $1], [ac_Header],
159                [AC_COMPILE_IFELSE([AC_LANG_SOURCE([AC_INCLUDES_DEFAULT([$4])
160 @%:@include <$1>])],
161                                   [AS_VAR_SET([ac_Header], [yes])],
162                                   [AS_VAR_SET([ac_Header], [no])])])
163 AS_IF([test AS_VAR_GET([ac_Header]) = yes], [$2], [$3])[]dnl
164 AS_VAR_POPDEF([ac_Header])dnl
165 ])# _AC_CHECK_HEADER_NEW
168 # _AC_CHECK_HEADER_OLD(HEADER-FILE,
169 #                      [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
170 # --------------------------------------------------------------
171 # Check the preprocessor accepts HEADER-FILE.
172 m4_define([_AC_CHECK_HEADER_OLD],
173 [AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])dnl
174 AC_CACHE_CHECK([for $1], [ac_Header],
175                [AC_PREPROC_IFELSE([AC_LANG_SOURCE([@%:@include <$1>])],
176                                          [AS_VAR_SET([ac_Header], [yes])],
177                                          [AS_VAR_SET([ac_Header], [no])])])
178 AS_IF([test AS_VAR_GET([ac_Header]) = yes], [$2], [$3])[]dnl
179 AS_VAR_POPDEF([ac_Header])dnl
180 ])# _AC_CHECK_HEADER_OLD
183 # AH_CHECK_HEADERS(HEADER-FILE...)
184 # --------------------------------
185 m4_define([AH_CHECK_HEADERS],
186 [m4_foreach_w([AC_Header], [$1],
187   [AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([AC_Header])),
188      [Define to 1 if you have the <]m4_defn([AC_Header])[> header file.])])])
191 # AC_CHECK_HEADERS(HEADER-FILE...,
192 #                  [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
193 #                  [INCLUDES])
194 # ----------------------------------------------------------
195 AC_DEFUN([AC_CHECK_HEADERS],
196 [AH_CHECK_HEADERS([$1])dnl
197 for ac_header in $1
199 AC_CHECK_HEADER($ac_header,
200                 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$ac_header)) $2],
201                 [$3],
202                 [$4])dnl
203 done
204 ])# AC_CHECK_HEADERS
207 # AC_CHECK_HEADERS_ONCE(HEADER-FILE...)
208 # -------------------------------------
209 AC_DEFUN([AC_CHECK_HEADERS_ONCE],
211   AH_CHECK_HEADERS([$1])
212   m4_foreach_w([AC_Header], [$1],
213     [AC_DEFUN([_AC_Header_]m4_quote(m4_translit(AC_Header, [./-], [___])),
214        [m4_divert_text([INIT_PREPARE],
215           [ac_header_list="$ac_header_list AC_Header"])
216         _AC_HEADERS_EXPANSION])
217      AC_REQUIRE([_AC_Header_]m4_quote(m4_translit(AC_Header, [./-], [___])))])
219 m4_define([_AC_HEADERS_EXPANSION],
221   m4_divert_text([DEFAULTS], [ac_header_list=])
222   AC_CHECK_HEADERS([$ac_header_list])
223   m4_define([_AC_HEADERS_EXPANSION], [])
229 ## --------------------- ##
230 ## 2. Default includes.  ##
231 ## --------------------- ##
233 # Always use the same set of default headers for all the generic
234 # macros.  It is easier to document, to extend, and to understand than
235 # having specific defaults for each macro.
237 # _AC_INCLUDES_DEFAULT_REQUIREMENTS
238 # ---------------------------------
239 # Required when AC_INCLUDES_DEFAULT uses its default branch.
240 AC_DEFUN([_AC_INCLUDES_DEFAULT_REQUIREMENTS],
241 [m4_divert_text([DEFAULTS],
242 [# Factoring default headers for most tests.
243 dnl If ever you change this variable, please keep autoconf.texi in sync.
244 ac_includes_default="\
245 #include <stdio.h>
246 #ifdef HAVE_SYS_TYPES_H
247 # include <sys/types.h>
248 #endif
249 #ifdef HAVE_SYS_STAT_H
250 # include <sys/stat.h>
251 #endif
252 #ifdef STDC_HEADERS
253 # include <stdlib.h>
254 # include <stddef.h>
255 #else
256 # ifdef HAVE_STDLIB_H
257 #  include <stdlib.h>
258 # endif
259 #endif
260 #ifdef HAVE_STRING_H
261 # if !defined STDC_HEADERS && defined HAVE_MEMORY_H
262 #  include <memory.h>
263 # endif
264 # include <string.h>
265 #endif
266 #ifdef HAVE_STRINGS_H
267 # include <strings.h>
268 #endif
269 #ifdef HAVE_INTTYPES_H
270 # include <inttypes.h>
271 #endif
272 #ifdef HAVE_STDINT_H
273 # include <stdint.h>
274 #endif
275 #ifdef HAVE_UNISTD_H
276 # include <unistd.h>
277 #endif"
278 ])dnl
279 AC_REQUIRE([AC_HEADER_STDC])dnl
280 # On IRIX 5.3, sys/types and inttypes.h are conflicting.
281 AC_CHECK_HEADERS([sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
282                   inttypes.h stdint.h unistd.h],
283                  [], [], $ac_includes_default)
284 ])# _AC_INCLUDES_DEFAULT_REQUIREMENTS
287 # AC_INCLUDES_DEFAULT([INCLUDES])
288 # -------------------------------
289 # If INCLUDES is empty, expand in default includes, otherwise in
290 # INCLUDES.
291 # In most cases INCLUDES is not double quoted as it should, and if
292 # for instance INCLUDES = `#include <stdio.h>' then unless we force
293 # a newline, the hash will swallow the closing paren etc. etc.
294 # The usual failure.
295 # Take no risk: for the newline.
296 AC_DEFUN([AC_INCLUDES_DEFAULT],
297 [m4_ifval([$1], [$1
299           [AC_REQUIRE([_AC_INCLUDES_DEFAULT_REQUIREMENTS])dnl
300 $ac_includes_default])])
306 ## ------------------------------------------- ##
307 ## 3. Headers to check with AC_CHECK_HEADERS.  ##
308 ## ------------------------------------------- ##
310 # errno.h is portable.
312 AN_HEADER([OS.h],               [AC_CHECK_HEADERS])
313 AN_HEADER([argz.h],             [AC_CHECK_HEADERS])
314 AN_HEADER([arpa/inet.h],        [AC_CHECK_HEADERS])
315 AN_HEADER([fcntl.h],            [AC_CHECK_HEADERS])
316 AN_HEADER([fenv.h],             [AC_CHECK_HEADERS])
317 AN_HEADER([float.h],            [AC_CHECK_HEADERS])
318 AN_HEADER([fs_info.h],          [AC_CHECK_HEADERS])
319 AN_HEADER([inttypes.h],         [AC_CHECK_HEADERS])
320 AN_HEADER([langinfo.h],         [AC_CHECK_HEADERS])
321 AN_HEADER([libintl.h],          [AC_CHECK_HEADERS])
322 AN_HEADER([limits.h],           [AC_CHECK_HEADERS])
323 AN_HEADER([locale.h],           [AC_CHECK_HEADERS])
324 AN_HEADER([mach/mach.h],        [AC_CHECK_HEADERS])
325 AN_HEADER([malloc.h],           [AC_CHECK_HEADERS])
326 AN_HEADER([memory.h],           [AC_CHECK_HEADERS])
327 AN_HEADER([mntent.h],           [AC_CHECK_HEADERS])
328 AN_HEADER([mnttab.h],           [AC_CHECK_HEADERS])
329 AN_HEADER([netdb.h],            [AC_CHECK_HEADERS])
330 AN_HEADER([netinet/in.h],       [AC_CHECK_HEADERS])
331 AN_HEADER([nl_types.h],         [AC_CHECK_HEADERS])
332 AN_HEADER([nlist.h],            [AC_CHECK_HEADERS])
333 AN_HEADER([paths.h],            [AC_CHECK_HEADERS])
334 AN_HEADER([sgtty.h],            [AC_CHECK_HEADERS])
335 AN_HEADER([shadow.h],           [AC_CHECK_HEADERS])
336 AN_HEADER([stddef.h],           [AC_CHECK_HEADERS])
337 AN_HEADER([stdint.h],           [AC_CHECK_HEADERS])
338 AN_HEADER([stdio_ext.h],        [AC_CHECK_HEADERS])
339 AN_HEADER([stdlib.h],           [AC_CHECK_HEADERS])
340 AN_HEADER([string.h],           [AC_CHECK_HEADERS])
341 AN_HEADER([strings.h],          [AC_CHECK_HEADERS])
342 AN_HEADER([sys/acl.h],          [AC_CHECK_HEADERS])
343 AN_HEADER([sys/file.h],         [AC_CHECK_HEADERS])
344 AN_HEADER([sys/filsys.h],       [AC_CHECK_HEADERS])
345 AN_HEADER([sys/fs/s5param.h],   [AC_CHECK_HEADERS])
346 AN_HEADER([sys/fs_types.h],     [AC_CHECK_HEADERS])
347 AN_HEADER([sys/fstyp.h],        [AC_CHECK_HEADERS])
348 AN_HEADER([sys/ioctl.h],        [AC_CHECK_HEADERS])
349 AN_HEADER([sys/mntent.h],       [AC_CHECK_HEADERS])
350 AN_HEADER([sys/mount.h],        [AC_CHECK_HEADERS])
351 AN_HEADER([sys/param.h],        [AC_CHECK_HEADERS])
352 AN_HEADER([sys/socket.h],       [AC_CHECK_HEADERS])
353 AN_HEADER([sys/statfs.h],       [AC_CHECK_HEADERS])
354 AN_HEADER([sys/statvfs.h],      [AC_CHECK_HEADERS])
355 AN_HEADER([sys/systeminfo.h],   [AC_CHECK_HEADERS])
356 AN_HEADER([sys/time.h],         [AC_CHECK_HEADERS])
357 AN_HEADER([sys/timeb.h],        [AC_CHECK_HEADERS])
358 AN_HEADER([sys/vfs.h],          [AC_CHECK_HEADERS])
359 AN_HEADER([sys/window.h],       [AC_CHECK_HEADERS])
360 AN_HEADER([syslog.h],           [AC_CHECK_HEADERS])
361 AN_HEADER([termio.h],           [AC_CHECK_HEADERS])
362 AN_HEADER([termios.h],          [AC_CHECK_HEADERS])
363 AN_HEADER([unistd.h],           [AC_CHECK_HEADERS])
364 AN_HEADER([utime.h],            [AC_CHECK_HEADERS])
365 AN_HEADER([utmp.h],             [AC_CHECK_HEADERS])
366 AN_HEADER([utmpx.h],            [AC_CHECK_HEADERS])
367 AN_HEADER([values.h],           [AC_CHECK_HEADERS])
368 AN_HEADER([wchar.h],            [AC_CHECK_HEADERS])
369 AN_HEADER([wctype.h],           [AC_CHECK_HEADERS])
373 ## ------------------------------- ##
374 ## 4. Tests for specific headers.  ##
375 ## ------------------------------- ##
377 # AC_HEADER_ASSERT
378 # ----------------
379 # Check whether to enable assertions.
380 AC_DEFUN([AC_HEADER_ASSERT],
382   AC_MSG_CHECKING([whether to enable assertions])
383   AC_ARG_ENABLE([assert],
384     [  --disable-assert        turn off assertions],
385     [AC_MSG_RESULT([no])
386      AC_DEFINE(NDEBUG, 1, [Define to 1 if assertions should be disabled.])],
387     [AC_MSG_RESULT(yes)])
391 # _AC_CHECK_HEADER_DIRENT(HEADER-FILE,
392 #                         [ACTION-IF-FOUND], [ACTION-IF-NOT_FOUND])
393 # -----------------------------------------------------------------
394 # Like AC_CHECK_HEADER, except also make sure that HEADER-FILE
395 # defines the type `DIR'.  dirent.h on NextStep 3.2 doesn't.
396 m4_define([_AC_CHECK_HEADER_DIRENT],
397 [AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_dirent_$1])dnl
398 AC_CACHE_CHECK([for $1 that defines DIR], [ac_Header],
399 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
400 #include <$1>
402                                     [if ((DIR *) 0)
403 return 0;])],
404                    [AS_VAR_SET([ac_Header], [yes])],
405                    [AS_VAR_SET([ac_Header], [no])])])
406 AS_IF([test AS_VAR_GET([ac_Header]) = yes], [$2], [$3])[]dnl
407 AS_VAR_POPDEF([ac_Header])dnl
408 ])# _AC_CHECK_HEADER_DIRENT
411 # AH_CHECK_HEADERS_DIRENT(HEADERS...)
412 # -----------------------------------
413 m4_define([AH_CHECK_HEADERS_DIRENT],
414 [m4_foreach_w([AC_Header], [$1],
415   [AH_TEMPLATE(AS_TR_CPP([HAVE_]m4_defn([AC_Header])),
416                [Define to 1 if you have the <]m4_defn([AC_Header])[> header file, and
417                 it defines `DIR'.])])])
420 # AC_HEADER_DIRENT
421 # ----------------
422 AN_HEADER([dirent.h],   [AC_HEADER_DIRENT])
423 AN_HEADER([ndir.h],     [AC_HEADER_DIRENT])
424 AN_HEADER([sys/dir.h],  [AC_HEADER_DIRENT])
425 AN_HEADER([sys/ndir.h], [AC_HEADER_DIRENT])
426 AC_DEFUN([AC_HEADER_DIRENT],
427 [AH_CHECK_HEADERS_DIRENT(dirent.h sys/ndir.h sys/dir.h ndir.h)
428 ac_header_dirent=no
429 for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
430   _AC_CHECK_HEADER_DIRENT($ac_hdr,
431                           [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$ac_hdr), 1)
432 ac_header_dirent=$ac_hdr; break])
433 done
434 # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
435 if test $ac_header_dirent = dirent.h; then
436   AC_SEARCH_LIBS(opendir, dir)
437 else
438   AC_SEARCH_LIBS(opendir, x)
440 ])# AC_HEADER_DIRENT
443 # AC_HEADER_MAJOR
444 # ---------------
445 AN_FUNCTION([major],     [AC_HEADER_MAJOR])
446 AN_FUNCTION([makedev],   [AC_HEADER_MAJOR])
447 AN_FUNCTION([minor],     [AC_HEADER_MAJOR])
448 AN_HEADER([sys/mkdev.h], [AC_HEADER_MAJOR])
449 AC_DEFUN([AC_HEADER_MAJOR],
450 [AC_CACHE_CHECK(whether sys/types.h defines makedev,
451                 ac_cv_header_sys_types_h_makedev,
452 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include <sys/types.h>]],
453                                  [[return makedev(0, 0);]])],
454                 [ac_cv_header_sys_types_h_makedev=yes],
455                 [ac_cv_header_sys_types_h_makedev=no])
458 if test $ac_cv_header_sys_types_h_makedev = no; then
459 AC_CHECK_HEADER(sys/mkdev.h,
460                 [AC_DEFINE(MAJOR_IN_MKDEV, 1,
461                            [Define to 1 if `major', `minor', and `makedev' are
462                             declared in <mkdev.h>.])])
464   if test $ac_cv_header_sys_mkdev_h = no; then
465     AC_CHECK_HEADER(sys/sysmacros.h,
466                     [AC_DEFINE(MAJOR_IN_SYSMACROS, 1,
467                                [Define to 1 if `major', `minor', and `makedev'
468                                 are declared in <sysmacros.h>.])])
469   fi
471 ])# AC_HEADER_MAJOR
474 # AC_HEADER_RESOLV
475 # ----------------
476 # According to http://www.mcsr.olemiss.edu/cgi-bin/man-cgi?resolver+3
477 # (or http://www.chemie.fu-berlin.de/cgi-bin/man/sgi_irix?resolver+3),
478 # sys/types.h, netinet/in.h and arpa/nameser.h are required on IRIX.
479 # netinet/in.h is needed on Cygwin, too.
480 # With Solaris 9, netdb.h is required, to get symbols like HOST_NOT_FOUND.
482 AN_HEADER(resolv.h,     [AC_HEADER_RESOLV])
483 AC_DEFUN([AC_HEADER_RESOLV],
484 [AC_CHECK_HEADERS(sys/types.h netinet/in.h arpa/nameser.h netdb.h resolv.h,
485                   [], [],
486 [[#ifdef HAVE_SYS_TYPES_H
487 #  include <sys/types.h>
488 #endif
489 #ifdef HAVE_NETINET_IN_H
490 #  include <netinet/in.h>   /* inet_ functions / structs */
491 #endif
492 #ifdef HAVE_ARPA_NAMESER_H
493 #  include <arpa/nameser.h> /* DNS HEADER struct */
494 #endif
495 #ifdef HAVE_NETDB_H
496 #  include <netdb.h>
497 #endif]])
498 ])# AC_HEADER_RESOLV
501 # AC_HEADER_STAT
502 # --------------
503 # FIXME: Shouldn't this be named AC_HEADER_SYS_STAT?
504 AN_IDENTIFIER([S_ISBLK], [AC_HEADER_STAT])
505 AN_IDENTIFIER([S_ISCHR], [AC_HEADER_STAT])
506 AN_IDENTIFIER([S_ISDIR], [AC_HEADER_STAT])
507 AN_IDENTIFIER([S_ISFIFO], [AC_HEADER_STAT])
508 AN_IDENTIFIER([S_ISLNK], [AC_HEADER_STAT])
509 AN_IDENTIFIER([S_ISREG], [AC_HEADER_STAT])
510 AN_IDENTIFIER([S_ISSOCK], [AC_HEADER_STAT])
511 AC_DEFUN([AC_HEADER_STAT],
512 [AC_CACHE_CHECK(whether stat file-mode macros are broken,
513   ac_cv_header_stat_broken,
514 [AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <sys/types.h>
515 #include <sys/stat.h>
517 #if defined S_ISBLK && defined S_IFDIR
518 extern char c1[S_ISBLK (S_IFDIR) ? -1 : 1];
519 #endif
521 #if defined S_ISBLK && defined S_IFCHR
522 extern char c2[S_ISBLK (S_IFCHR) ? -1 : 1];
523 #endif
525 #if defined S_ISLNK && defined S_IFREG
526 extern char c3[S_ISLNK (S_IFREG) ? -1 : 1];
527 #endif
529 #if defined S_ISSOCK && defined S_IFREG
530 extern char c4[S_ISSOCK (S_IFREG) ? -1 : 1];
531 #endif
532 ]])], ac_cv_header_stat_broken=no, ac_cv_header_stat_broken=yes)])
533 if test $ac_cv_header_stat_broken = yes; then
534   AC_DEFINE(STAT_MACROS_BROKEN, 1,
535             [Define to 1 if the `S_IS*' macros in <sys/stat.h> do not
536              work properly.])
538 ])# AC_HEADER_STAT
541 # AC_HEADER_STDBOOL
542 # -----------------
543 # Check for stdbool.h that conforms to C99.
544 AN_IDENTIFIER([bool], [AC_HEADER_STDBOOL])
545 AN_IDENTIFIER([true], [AC_HEADER_STDBOOL])
546 AN_IDENTIFIER([false],[AC_HEADER_STDBOOL])
547 AC_DEFUN([AC_HEADER_STDBOOL],
548 [AC_CACHE_CHECK([for stdbool.h that conforms to C99],
549    [ac_cv_header_stdbool_h],
550    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
551       [[
552 #include <stdbool.h>
553 #ifndef bool
554  "error: bool is not defined"
555 #endif
556 #ifndef false
557  "error: false is not defined"
558 #endif
559 #if false
560  "error: false is not 0"
561 #endif
562 #ifndef true
563  "error: true is not defined"
564 #endif
565 #if true != 1
566  "error: true is not 1"
567 #endif
568 #ifndef __bool_true_false_are_defined
569  "error: __bool_true_false_are_defined is not defined"
570 #endif
572         struct s { _Bool s: 1; _Bool t; } s;
574         char a[true == 1 ? 1 : -1];
575         char b[false == 0 ? 1 : -1];
576         char c[__bool_true_false_are_defined == 1 ? 1 : -1];
577         char d[(bool) 0.5 == true ? 1 : -1];
578         bool e = &s;
579         char f[(_Bool) 0.0 == false ? 1 : -1];
580         char g[true];
581         char h[sizeof (_Bool)];
582         char i[sizeof s.t];
583         enum { j = false, k = true, l = false * true, m = true * 256 };
584         _Bool n[m];
585         char o[sizeof n == m * sizeof n[0] ? 1 : -1];
586         char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
587 #       if defined __xlc__ || defined __GNUC__
588          /* Catch a bug in IBM AIX xlc compiler version 6.0.0.0
589             reported by James Lemley on 2005-10-05; see
590             http://lists.gnu.org/archive/html/bug-coreutils/2005-10/msg00086.html
591             This test is not quite right, since xlc is allowed to
592             reject this program, as the initializer for xlcbug is
593             not one of the forms that C requires support for.
594             However, doing the test right would require a runtime
595             test, and that would make cross-compilation harder.
596             Let us hope that IBM fixes the xlc bug, and also adds
597             support for this kind of constant expression.  In the
598             meantime, this test will reject xlc, which is OK, since
599             our stdbool.h substitute should suffice.  We also test
600             this with GCC, where it should work, to detect more
601             quickly whether someone messes up the test in the
602             future.  */
603          char digs[] = "0123456789";
604          int xlcbug = 1 / (&(digs + 5)[-2 + (bool) 1] == &digs[4] ? 1 : -1);
605 #       endif
606         /* Catch a bug in an HP-UX C compiler.  See
607            http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
608            http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
609          */
610         _Bool q = true;
611         _Bool *pq = &q;
612       ]],
613       [[
614         *pq |= q;
615         *pq |= ! q;
616         /* Refer to every declared value, to avoid compiler optimizations.  */
617         return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
618                 + !m + !n + !o + !p + !q + !pq);
619       ]])],
620       [ac_cv_header_stdbool_h=yes],
621       [ac_cv_header_stdbool_h=no])])
622 AC_CHECK_TYPES([_Bool])
623 if test $ac_cv_header_stdbool_h = yes; then
624   AC_DEFINE(HAVE_STDBOOL_H, 1, [Define to 1 if stdbool.h conforms to C99.])
626 ])# AC_HEADER_STDBOOL
629 # AC_HEADER_STDC
630 # --------------
631 # FIXME: I find this list very strange.  It comes from the original
632 # autoscan list, but I don't think it is useful for the same reason
633 # that we don't bind AC_PROG_CC to finding a C function calls: if the
634 # user uses bcmp, then she will certainly have the `#include', and
635 # therefore, we will trigger AC_HEADER_STDC elsewhere.  --akim 2002-09-28
636 # FIXME: Err... index and rindex are _not_ to be used... --akim 2002-09-28
637 AN_FUNCTION([bcmp],     [AC_HEADER_STDC])
638 AN_FUNCTION([bcopy],    [AC_HEADER_STDC])
639 AN_FUNCTION([bzero],    [AC_HEADER_STDC])
640 AN_FUNCTION([index],    [AC_HEADER_STDC])
641 AN_FUNCTION([memchr],   [AC_HEADER_STDC])
642 AN_FUNCTION([memcpy],   [AC_HEADER_STDC])
643 AN_FUNCTION([memmove],  [AC_HEADER_STDC])
644 AN_FUNCTION([memset],   [AC_HEADER_STDC])
645 AN_FUNCTION([rindex],   [AC_HEADER_STDC])
647 AN_HEADER([float.h],    [AC_HEADER_STDC])
648 AN_HEADER([stdarg.h],   [AC_HEADER_STDC])
649 AN_HEADER([stddef.h],   [AC_HEADER_STDC])
650 AN_HEADER([stdlib.h],   [AC_HEADER_STDC])
651 AN_HEADER([string.h],   [AC_HEADER_STDC])
653 AC_DEFUN([AC_HEADER_STDC],
654 [AC_CACHE_CHECK(for ANSI C header files, ac_cv_header_stdc,
655 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
656 #include <stdarg.h>
657 #include <string.h>
658 #include <float.h>
659 ]])],
660                     [ac_cv_header_stdc=yes],
661                     [ac_cv_header_stdc=no])
663 if test $ac_cv_header_stdc = yes; then
664   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
665   AC_EGREP_HEADER(memchr, string.h, , ac_cv_header_stdc=no)
668 if test $ac_cv_header_stdc = yes; then
669   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
670   AC_EGREP_HEADER(free, stdlib.h, , ac_cv_header_stdc=no)
673 if test $ac_cv_header_stdc = yes; then
674   # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
675   AC_RUN_IFELSE([AC_LANG_SOURCE(
676 [[#include <ctype.h>
677 #include <stdlib.h>
678 #if ((' ' & 0x0FF) == 0x020)
679 # define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
680 # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
681 #else
682 # define ISLOWER(c) \
683                    (('a' <= (c) && (c) <= 'i') \
684                      || ('j' <= (c) && (c) <= 'r') \
685                      || ('s' <= (c) && (c) <= 'z'))
686 # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
687 #endif
689 #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
691 main ()
693   int i;
694   for (i = 0; i < 256; i++)
695     if (XOR (islower (i), ISLOWER (i))
696         || toupper (i) != TOUPPER (i))
697       return 2;
698   return 0;
699 }]])], , ac_cv_header_stdc=no, :)
700 fi])
701 if test $ac_cv_header_stdc = yes; then
702   AC_DEFINE(STDC_HEADERS, 1,
703             [Define to 1 if you have the ANSI C header files.])
705 ])# AC_HEADER_STDC
708 # AC_HEADER_SYS_WAIT
709 # ------------------
710 AN_HEADER([sys/wait.h], [AC_HEADER_SYS_WAIT])
711 AC_DEFUN([AC_HEADER_SYS_WAIT],
712 [AC_CACHE_CHECK([for sys/wait.h that is POSIX.1 compatible],
713   ac_cv_header_sys_wait_h,
714 [AC_COMPILE_IFELSE(
715 [AC_LANG_PROGRAM([#include <sys/types.h>
716 #include <sys/wait.h>
717 #ifndef WEXITSTATUS
718 # define WEXITSTATUS(stat_val) ((unsigned int) (stat_val) >> 8)
719 #endif
720 #ifndef WIFEXITED
721 # define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
722 #endif
724 [  int s;
725   wait (&s);
726   s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;])],
727                  [ac_cv_header_sys_wait_h=yes],
728                  [ac_cv_header_sys_wait_h=no])])
729 if test $ac_cv_header_sys_wait_h = yes; then
730   AC_DEFINE(HAVE_SYS_WAIT_H, 1,
731             [Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible.])
733 ])# AC_HEADER_SYS_WAIT
736 # AC_HEADER_TIME
737 # --------------
738 AN_IDENTIFIER([timeval],  [AC_HEADER_TIME])
739 AC_DEFUN([AC_HEADER_TIME],
740 [AC_CACHE_CHECK([whether time.h and sys/time.h may both be included],
741   ac_cv_header_time,
742 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
743 #include <sys/time.h>
744 #include <time.h>
746 [if ((struct tm *) 0)
747 return 0;])],
748                    [ac_cv_header_time=yes],
749                    [ac_cv_header_time=no])])
750 if test $ac_cv_header_time = yes; then
751   AC_DEFINE(TIME_WITH_SYS_TIME, 1,
752             [Define to 1 if you can safely include both <sys/time.h>
753              and <time.h>.])
755 ])# AC_HEADER_TIME
758 # _AC_HEADER_TIOCGWINSZ_IN_TERMIOS_H
759 # ----------------------------------
760 m4_define([_AC_HEADER_TIOCGWINSZ_IN_TERMIOS_H],
761 [AC_CACHE_CHECK([whether termios.h defines TIOCGWINSZ],
762                 ac_cv_sys_tiocgwinsz_in_termios_h,
763 [AC_EGREP_CPP([yes],
764               [#include <sys/types.h>
765 #include <termios.h>
766 #ifdef TIOCGWINSZ
767   yes
768 #endif
770                 ac_cv_sys_tiocgwinsz_in_termios_h=yes,
771                 ac_cv_sys_tiocgwinsz_in_termios_h=no)])
772 ])# _AC_HEADER_TIOCGWINSZ_IN_TERMIOS_H
775 # _AC_HEADER_TIOCGWINSZ_IN_SYS_IOCTL
776 # ----------------------------------
777 m4_define([_AC_HEADER_TIOCGWINSZ_IN_SYS_IOCTL],
778 [AC_CACHE_CHECK([whether sys/ioctl.h defines TIOCGWINSZ],
779                 ac_cv_sys_tiocgwinsz_in_sys_ioctl_h,
780 [AC_EGREP_CPP([yes],
781               [#include <sys/types.h>
782 #include <sys/ioctl.h>
783 #ifdef TIOCGWINSZ
784   yes
785 #endif
787                 ac_cv_sys_tiocgwinsz_in_sys_ioctl_h=yes,
788                 ac_cv_sys_tiocgwinsz_in_sys_ioctl_h=no)])
789 ])# _AC_HEADER_TIOCGWINSZ_IN_SYS_IOCTL
792 # AC_HEADER_TIOCGWINSZ
793 # --------------------
794 # Look for a header that defines TIOCGWINSZ.
795 # FIXME: Is this the proper name?  Is this the proper implementation?
796 # I need more help.
797 AC_DEFUN([AC_HEADER_TIOCGWINSZ],
798 [_AC_HEADER_TIOCGWINSZ_IN_TERMIOS_H
799 if test $ac_cv_sys_tiocgwinsz_in_termios_h != yes; then
800   _AC_HEADER_TIOCGWINSZ_IN_SYS_IOCTL
801   if test $ac_cv_sys_tiocgwinsz_in_sys_ioctl_h = yes; then
802     AC_DEFINE(GWINSZ_IN_SYS_IOCTL,1,
803               [Define to 1 if `TIOCGWINSZ' requires <sys/ioctl.h>.])
804   fi
806 ])# AC_HEADER_TIOCGWINSZ
809 # AU::AC_UNISTD_H
810 # ---------------
811 AU_DEFUN([AC_UNISTD_H],
812 [AC_CHECK_HEADERS(unistd.h)])
815 # AU::AC_USG
816 # ----------
817 # Define `USG' if string functions are in strings.h.
818 AU_DEFUN([AC_USG],
819 [AC_MSG_CHECKING([for BSD string and memory functions])
820 AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include <strings.h>]],
821                                 [[rindex(0, 0); bzero(0, 0);]])],
822                [AC_MSG_RESULT(yes)],
823                [AC_MSG_RESULT(no)
824                 AC_DEFINE(USG, 1,
825                           [Define to 1 if you do not have <strings.h>, index,
826                            bzero, etc... This symbol is obsolete, you should
827                            not depend upon it.])])
828 AC_CHECK_HEADERS(string.h)],
829 [Remove `AC_MSG_CHECKING', `AC_LINK_IFELSE' and this warning
830 when you adjust your code to use HAVE_STRING_H.])
833 # AU::AC_MEMORY_H
834 # ---------------
835 # To be precise this macro used to be:
837 #   | AC_MSG_CHECKING(whether string.h declares mem functions)
838 #   | AC_EGREP_HEADER(memchr, string.h, ac_found=yes, ac_found=no)
839 #   | AC_MSG_RESULT($ac_found)
840 #   | if test $ac_found = no; then
841 #   |   AC_CHECK_HEADER(memory.h, [AC_DEFINE(NEED_MEMORY_H)])
842 #   | fi
844 # But it is better to check for both headers, and alias NEED_MEMORY_H to
845 # HAVE_MEMORY_H.
846 AU_DEFUN([AC_MEMORY_H],
847 [AC_CHECK_HEADER(memory.h,
848                 [AC_DEFINE([NEED_MEMORY_H], 1,
849                            [Same as `HAVE_MEMORY_H', don't depend on me.])])
850 AC_CHECK_HEADERS(string.h memory.h)],
851 [Remove this warning and
852 `AC_CHECK_HEADER(memory.h, AC_DEFINE(...))' when you adjust your code to
853 use HAVE_STRING_H and HAVE_MEMORY_H, not NEED_MEMORY_H.])
856 # AU::AC_DIR_HEADER
857 # -----------------
858 # Like calling `AC_HEADER_DIRENT' and `AC_FUNC_CLOSEDIR_VOID', but
859 # defines a different set of C preprocessor macros to indicate which
860 # header file is found.
861 AU_DEFUN([AC_DIR_HEADER],
862 [AC_HEADER_DIRENT
863 AC_FUNC_CLOSEDIR_VOID
864 test ac_cv_header_dirent_dirent_h &&
865   AC_DEFINE([DIRENT], 1, [Same as `HAVE_DIRENT_H', don't depend on me.])
866 test ac_cv_header_dirent_sys_ndir_h &&
867   AC_DEFINE([SYSNDIR], 1, [Same as `HAVE_SYS_NDIR_H', don't depend on me.])
868 test ac_cv_header_dirent_sys_dir_h &&
869   AC_DEFINE([SYSDIR], 1, [Same as `HAVE_SYS_DIR_H', don't depend on me.])
870 test ac_cv_header_dirent_ndir_h &&
871   AC_DEFINE([NDIR], 1, [Same as `HAVE_NDIR_H', don't depend on me.])],
872 [Remove this warning and the four `AC_DEFINE' when you
873 adjust your code to use `AC_HEADER_DIRENT'.])