Install msysDTK-1.0.1
[msysgit.git] / share / autoconf / autoconf / headers.m4
blobd8e0e1a83270408c85b0d7b76d6c71d7fb95f2ce
1 # This file is part of Autoconf.                       -*- Autoconf -*-
2 # Checking for headers.
4 # Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2, or (at your option)
9 # any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 # 02111-1307, USA.
21 # As a special exception, the Free Software Foundation gives unlimited
22 # permission to copy, distribute and modify the configure scripts that
23 # are the output of Autoconf.  You need not follow the terms of the GNU
24 # General Public License when using or distributing such scripts, even
25 # though portions of the text of Autoconf appear in them.  The GNU
26 # General Public License (GPL) does govern all other use of the material
27 # that constitutes the Autoconf program.
29 # Certain portions of the Autoconf source text are designed to be copied
30 # (in certain cases, depending on the input) into the output of
31 # Autoconf.  We call these the "data" portions.  The rest of the Autoconf
32 # source text consists of comments plus executable code that decides which
33 # of the data portions to output in any given case.  We call these
34 # comments and executable code the "non-data" portions.  Autoconf never
35 # copies any of the non-data portions into its output.
37 # This special exception to the GPL applies to versions of Autoconf
38 # released by the Free Software Foundation.  When you make and
39 # distribute a modified version of Autoconf, you may extend this special
40 # exception to the GPL to apply to your modified version as well, *unless*
41 # your modified version has the potential to copy into its output some
42 # of the text that was the non-data portion of the version that you started
43 # with.  (In other words, unless your change moves or copies text from
44 # the non-data portions to the data portions.)  If your modification has
45 # such potential, you must delete any notice of this special exception
46 # to the GPL from your modified version.
48 # Written by David MacKenzie, with help from
49 # Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor,
50 # Roland McGrath, Noah Friedman, david d zuhn, and many others.
53 # Table of contents
55 # 1. Generic tests for headers
56 # 2. Default includes
57 # 3. Headers to tests with AC_CHECK_HEADERS
58 # 4. Tests for specific headers
61 ## ------------------------------ ##
62 ## 1. Generic tests for headers.  ##
63 ## ------------------------------ ##
66 # AC_CHECK_HEADER(HEADER-FILE,
67 #                 [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
68 #                 [INCLUDES])
69 # ---------------------------------------------------------
70 # We are slowly moving to checking headers with the compiler instead
71 # of the preproc, so that we actually learn about the usability of a
72 # header instead of its mere presence.  But since users are used to
73 # the old semantics, they check for headers in random order and
74 # without providing prerequisite headers.  This macro implements the
75 # transition phase, and should be cleaned up latter to use compilation
76 # only.
78 # If INCLUDES is empty, then check both via the compiler and preproc.
79 # If the results are different, issue a warning, but keep the preproc
80 # result.
82 # If INCLUDES is `-', keep only the old semantics.
84 # If INCLUDES is specified and different from `-', then use the new
85 # semantics only.
86 AC_DEFUN([AC_CHECK_HEADER],
87 [m4_case([$4],
88          [],  [_AC_CHECK_HEADER_MONGREL($@)],
89          [-], [_AC_CHECK_HEADER_OLD($@)],
90               [_AC_CHECK_HEADER_NEW($@)])
91 ])# AC_CHECK_HEADER
94 # _AC_CHECK_HEADER_MONGREL(HEADER-FILE,
95 #                          [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND],
96 #                          [INCLUDES])
97 # --------------------------------------------------------------
98 # Check using both the compiler and the preprocessor.  If they disagree,
99 # warn, and the preproc wins.
101 # This is not based on _AC_CHECK_HEADER_NEW and _AC_CHECK_HEADER_OLD
102 # because it obfuscate the code to try to factor everything, in particular
103 # because of the cache variables, and the `checking...' messages.
104 m4_define([_AC_CHECK_HEADER_MONGREL],
105 [AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_$1])dnl
106 AS_VAR_SET_IF(ac_Header,
107               [AC_CACHE_CHECK([for $1], ac_Header, [])],
108               [# Is the header compilable?
109 AC_MSG_CHECKING([$1 usability])
110 AC_COMPILE_IFELSE([AC_LANG_SOURCE([AC_INCLUDES_DEFAULT([$4])
111 @%:@include <$1>])],
112                   [ac_header_compiler=yes],
113                   [ac_header_compiler=no])
114 AC_MSG_RESULT([$ac_header_compiler])
116 # Is the header present?
117 AC_MSG_CHECKING([$1 presence])
118 AC_PREPROC_IFELSE([AC_LANG_SOURCE([@%:@include <$1>])],
119                   [ac_header_preproc=yes],
120                   [ac_header_preproc=no])
121 AC_MSG_RESULT([$ac_header_preproc])
123 # So?  What about this header?
124 case $ac_header_compiler:$ac_header_preproc in
125   yes:no )
126     AC_MSG_WARN([$1: accepted by the compiler, rejected by the preprocessor!])
127     AC_MSG_WARN([$1: proceeding with the preprocessor's result])
128     (
129       AS_BOX([Report this to bug-autoconf@gnu.org.])
130     ) |
131       sed "s/^/$as_me: WARNING:     /" >&2
132     ;;
133   no:yes )
134     AC_MSG_WARN([$1: present but cannot be compiled])
135     AC_MSG_WARN([$1: check for missing prerequisite headers?])
136     AC_MSG_WARN([$1: proceeding with the preprocessor's result])
137     (
138       AS_BOX([Report this to bug-autoconf@gnu.org.])
139     ) |
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])
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 [AC_FOREACH([AC_Header], [$1],
187   [AH_TEMPLATE(AS_TR_CPP(HAVE_[]AC_Header),
188                [Define to 1 if you have the <]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
209 ## --------------------- ##
210 ## 2. Default includes.  ##
211 ## --------------------- ##
213 # Always use the same set of default headers for all the generic
214 # macros.  It is easier to document, to extend, and to understand than
215 # having specific defaults for each macro.
217 # _AC_INCLUDES_DEFAULT_REQUIREMENTS
218 # ---------------------------------
219 # Required when AC_INCLUDES_DEFAULT uses its default branch.
220 AC_DEFUN([_AC_INCLUDES_DEFAULT_REQUIREMENTS],
221 [m4_divert_text([DEFAULTS],
222 [# Factoring default headers for most tests.
223 dnl If ever you change this variable, please keep autoconf.texi in sync.
224 ac_includes_default="\
225 #include <stdio.h>
226 #if HAVE_SYS_TYPES_H
227 # include <sys/types.h>
228 #endif
229 #if HAVE_SYS_STAT_H
230 # include <sys/stat.h>
231 #endif
232 #if STDC_HEADERS
233 # include <stdlib.h>
234 # include <stddef.h>
235 #else
236 # if HAVE_STDLIB_H
237 #  include <stdlib.h>
238 # endif
239 #endif
240 #if HAVE_STRING_H
241 # if !STDC_HEADERS && HAVE_MEMORY_H
242 #  include <memory.h>
243 # endif
244 # include <string.h>
245 #endif
246 #if HAVE_STRINGS_H
247 # include <strings.h>
248 #endif
249 #if HAVE_INTTYPES_H
250 # include <inttypes.h>
251 #else
252 # if HAVE_STDINT_H
253 #  include <stdint.h>
254 # endif
255 #endif
256 #if HAVE_UNISTD_H
257 # include <unistd.h>
258 #endif"
259 ])dnl
260 AC_REQUIRE([AC_HEADER_STDC])dnl
261 # On IRIX 5.3, sys/types and inttypes.h are conflicting.
262 AC_CHECK_HEADERS([sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
263                   inttypes.h stdint.h unistd.h],
264                  [], [], $ac_includes_default)
265 ])# _AC_INCLUDES_DEFAULT_REQUIREMENTS
268 # AC_INCLUDES_DEFAULT([INCLUDES])
269 # -------------------------------
270 # If INCLUDES is empty, expand in default includes, otherwise in
271 # INCLUDES.
272 # In most cases INCLUDES is not double quoted as it should, and if
273 # for instance INCLUDES = `#include <stdio.h>' then unless we force
274 # a newline, the hash will swallow the closing paren etc. etc.
275 # The usual failure.
276 # Take no risk: for the newline.
277 AC_DEFUN([AC_INCLUDES_DEFAULT],
278 [m4_ifval([$1], [$1
280           [AC_REQUIRE([_AC_INCLUDES_DEFAULT_REQUIREMENTS])dnl
281 $ac_includes_default])])
287 ## ------------------------------------------- ##
288 ## 3. Headers to check with AC_CHECK_HEADERS.  ##
289 ## ------------------------------------------- ##
291 # errno.h is portable.
293 AN_HEADER([OS.h],               [AC_CHECK_HEADERS])
294 AN_HEADER([argz.h],             [AC_CHECK_HEADERS])
295 AN_HEADER([arpa/inet.h],        [AC_CHECK_HEADERS])
296 AN_HEADER([fcntl.h],            [AC_CHECK_HEADERS])
297 AN_HEADER([fenv.h],             [AC_CHECK_HEADERS])
298 AN_HEADER([float.h],            [AC_CHECK_HEADERS])
299 AN_HEADER([fs_info.h],          [AC_CHECK_HEADERS])
300 AN_HEADER([inttypes.h],         [AC_CHECK_HEADERS])
301 AN_HEADER([langinfo.h],         [AC_CHECK_HEADERS])
302 AN_HEADER([libintl.h],          [AC_CHECK_HEADERS])
303 AN_HEADER([limits.h],           [AC_CHECK_HEADERS])
304 AN_HEADER([locale.h],           [AC_CHECK_HEADERS])
305 AN_HEADER([mach/mach.h],        [AC_CHECK_HEADERS])
306 AN_HEADER([malloc.h],           [AC_CHECK_HEADERS])
307 AN_HEADER([memory.h],           [AC_CHECK_HEADERS])
308 AN_HEADER([mntent.h],           [AC_CHECK_HEADERS])
309 AN_HEADER([mnttab.h],           [AC_CHECK_HEADERS])
310 AN_HEADER([netdb.h],            [AC_CHECK_HEADERS])
311 AN_HEADER([netinet/in.h],       [AC_CHECK_HEADERS])
312 AN_HEADER([nl_types.h],         [AC_CHECK_HEADERS])
313 AN_HEADER([nlist.h],            [AC_CHECK_HEADERS])
314 AN_HEADER([paths.h],            [AC_CHECK_HEADERS])
315 AN_HEADER([sgtty.h],            [AC_CHECK_HEADERS])
316 AN_HEADER([shadow.h],           [AC_CHECK_HEADERS])
317 AN_HEADER([stddef.h],           [AC_CHECK_HEADERS])
318 AN_HEADER([stdint.h],           [AC_CHECK_HEADERS])
319 AN_HEADER([stdio_ext.h],        [AC_CHECK_HEADERS])
320 AN_HEADER([stdlib.h],           [AC_CHECK_HEADERS])
321 AN_HEADER([string.h],           [AC_CHECK_HEADERS])
322 AN_HEADER([strings.h],          [AC_CHECK_HEADERS])
323 AN_HEADER([sys/acl.h],          [AC_CHECK_HEADERS])
324 AN_HEADER([sys/file.h],         [AC_CHECK_HEADERS])
325 AN_HEADER([sys/filsys.h],       [AC_CHECK_HEADERS])
326 AN_HEADER([sys/fs/s5param.h],   [AC_CHECK_HEADERS])
327 AN_HEADER([sys/fs_types.h],     [AC_CHECK_HEADERS])
328 AN_HEADER([sys/fstyp.h],        [AC_CHECK_HEADERS])
329 AN_HEADER([sys/ioctl.h],        [AC_CHECK_HEADERS])
330 AN_HEADER([sys/mntent.h],       [AC_CHECK_HEADERS])
331 AN_HEADER([sys/mount.h],        [AC_CHECK_HEADERS])
332 AN_HEADER([sys/param.h],        [AC_CHECK_HEADERS])
333 AN_HEADER([sys/socket.h],       [AC_CHECK_HEADERS])
334 AN_HEADER([sys/statfs.h],       [AC_CHECK_HEADERS])
335 AN_HEADER([sys/statvfs.h],      [AC_CHECK_HEADERS])
336 AN_HEADER([sys/systeminfo.h],   [AC_CHECK_HEADERS])
337 AN_HEADER([sys/time.h],         [AC_CHECK_HEADERS])
338 AN_HEADER([sys/timeb.h],        [AC_CHECK_HEADERS])
339 AN_HEADER([sys/vfs.h],          [AC_CHECK_HEADERS])
340 AN_HEADER([sys/window.h],       [AC_CHECK_HEADERS])
341 AN_HEADER([syslog.h],           [AC_CHECK_HEADERS])
342 AN_HEADER([termio.h],           [AC_CHECK_HEADERS])
343 AN_HEADER([termios.h],          [AC_CHECK_HEADERS])
344 AN_HEADER([unistd.h],           [AC_CHECK_HEADERS])
345 AN_HEADER([utime.h],            [AC_CHECK_HEADERS])
346 AN_HEADER([utmp.h],             [AC_CHECK_HEADERS])
347 AN_HEADER([utmpx.h],            [AC_CHECK_HEADERS])
348 AN_HEADER([values.h],           [AC_CHECK_HEADERS])
349 AN_HEADER([wchar.h],            [AC_CHECK_HEADERS])
350 AN_HEADER([wctype.h],           [AC_CHECK_HEADERS])
354 ## ------------------------------- ##
355 ## 4. Tests for specific headers.  ##
356 ## ------------------------------- ##
359 # _AC_CHECK_HEADER_DIRENT(HEADER-FILE,
360 #                         [ACTION-IF-FOUND], [ACTION-IF-NOT_FOUND])
361 # -----------------------------------------------------------------
362 # Like AC_CHECK_HEADER, except also make sure that HEADER-FILE
363 # defines the type `DIR'.  dirent.h on NextStep 3.2 doesn't.
364 m4_define([_AC_CHECK_HEADER_DIRENT],
365 [AS_VAR_PUSHDEF([ac_Header], [ac_cv_header_dirent_$1])dnl
366 AC_CACHE_CHECK([for $1 that defines DIR], ac_Header,
367 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
368 #include <$1>
370                                     [if ((DIR *) 0)
371 return 0;])],
372                    [AS_VAR_SET(ac_Header, yes)],
373                    [AS_VAR_SET(ac_Header, no)])])
374 AS_IF([test AS_VAR_GET(ac_Header) = yes], [$2], [$3])[]dnl
375 AS_VAR_POPDEF([ac_Header])dnl
376 ])# _AC_CHECK_HEADER_DIRENT
379 # AH_CHECK_HEADERS_DIRENT(HEADERS...)
380 # -----------------------------------
381 m4_define([AH_CHECK_HEADERS_DIRENT],
382 [AC_FOREACH([AC_Header], [$1],
383   [AH_TEMPLATE(AS_TR_CPP(HAVE_[]AC_Header),
384                [Define to 1 if you have the <]AC_Header[> header file, and
385                 it defines `DIR'.])])])
388 # AC_HEADER_DIRENT
389 # ----------------
390 AN_HEADER([dirent.h],   [AC_HEADER_DIRENT])
391 AN_HEADER([ndir.h],     [AC_HEADER_DIRENT])
392 AN_HEADER([sys/dir.h],  [AC_HEADER_DIRENT])
393 AN_HEADER([sys/ndir.h], [AC_HEADER_DIRENT])
394 AC_DEFUN([AC_HEADER_DIRENT],
395 [AH_CHECK_HEADERS_DIRENT(dirent.h sys/ndir.h sys/dir.h ndir.h)
396 ac_header_dirent=no
397 for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
398   _AC_CHECK_HEADER_DIRENT($ac_hdr,
399                           [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$ac_hdr), 1)
400 ac_header_dirent=$ac_hdr; break])
401 done
402 # Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
403 if test $ac_header_dirent = dirent.h; then
404   AC_SEARCH_LIBS(opendir, dir)
405 else
406   AC_SEARCH_LIBS(opendir, x)
408 ])# AC_HEADER_DIRENT
411 # AC_HEADER_MAJOR
412 # ---------------
413 AN_FUNCTION([major],     [AC_HEADER_MAJOR])
414 AN_FUNCTION([makedev],   [AC_HEADER_MAJOR])
415 AN_FUNCTION([minor],     [AC_HEADER_MAJOR])
416 AN_HEADER([sys/mkdev.h], [AC_HEADER_MAJOR])
417 AC_DEFUN([AC_HEADER_MAJOR],
418 [AC_CACHE_CHECK(whether sys/types.h defines makedev,
419                 ac_cv_header_sys_types_h_makedev,
420 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include <sys/types.h>]],
421                                  [[return makedev(0, 0);]])],
422                 [ac_cv_header_sys_types_h_makedev=yes],
423                 [ac_cv_header_sys_types_h_makedev=no])
426 if test $ac_cv_header_sys_types_h_makedev = no; then
427 AC_CHECK_HEADER(sys/mkdev.h,
428                 [AC_DEFINE(MAJOR_IN_MKDEV, 1,
429                            [Define to 1 if `major', `minor', and `makedev' are
430                             declared in <mkdev.h>.])])
432   if test $ac_cv_header_sys_mkdev_h = no; then
433     AC_CHECK_HEADER(sys/sysmacros.h,
434                     [AC_DEFINE(MAJOR_IN_SYSMACROS, 1,
435                                [Define to 1 if `major', `minor', and `makedev'
436                                 are declared in <sysmacros.h>.])])
437   fi
439 ])# AC_HEADER_MAJOR
442 # AC_HEADER_STAT
443 # --------------
444 # FIXME: Shouldn't this be named AC_HEADER_SYS_STAT?
445 AN_IDENTIFIER([S_ISBLK], [AC_HEADER_STAT])
446 AN_IDENTIFIER([S_ISCHR], [AC_HEADER_STAT])
447 AN_IDENTIFIER([S_ISDIR], [AC_HEADER_STAT])
448 AN_IDENTIFIER([S_ISFIFO], [AC_HEADER_STAT])
449 AN_IDENTIFIER([S_ISLNK], [AC_HEADER_STAT])
450 AN_IDENTIFIER([S_ISREG], [AC_HEADER_STAT])
451 AN_IDENTIFIER([S_ISSOCK], [AC_HEADER_STAT])
452 AC_DEFUN([AC_HEADER_STAT],
453 [AC_CACHE_CHECK(whether stat file-mode macros are broken,
454   ac_cv_header_stat_broken,
455 [AC_EGREP_CPP([You lose], [#include <sys/types.h>
456 #include <sys/stat.h>
458 #if defined(S_ISBLK) && defined(S_IFDIR)
459 # if S_ISBLK (S_IFDIR)
460 You lose.
461 # endif
462 #endif
464 #if defined(S_ISBLK) && defined(S_IFCHR)
465 # if S_ISBLK (S_IFCHR)
466 You lose.
467 # endif
468 #endif
470 #if defined(S_ISLNK) && defined(S_IFREG)
471 # if S_ISLNK (S_IFREG)
472 You lose.
473 # endif
474 #endif
476 #if defined(S_ISSOCK) && defined(S_IFREG)
477 # if S_ISSOCK (S_IFREG)
478 You lose.
479 # endif
480 #endif
481 ], ac_cv_header_stat_broken=yes, ac_cv_header_stat_broken=no)])
482 if test $ac_cv_header_stat_broken = yes; then
483   AC_DEFINE(STAT_MACROS_BROKEN, 1,
484             [Define to 1 if the `S_IS*' macros in <sys/stat.h> do not
485              work properly.])
487 ])# AC_HEADER_STAT
490 # AC_HEADER_STDBOOL
491 # -----------------
492 # Check for stdbool.h that conforms to C99.
493 AN_IDENTIFIER([bool], [AC_HEADER_STDBOOL])
494 AN_IDENTIFIER([true], [AC_HEADER_STDBOOL])
495 AN_IDENTIFIER([false],[AC_HEADER_STDBOOL])
496 AC_DEFUN([AC_HEADER_STDBOOL],
497 [AC_CACHE_CHECK([for stdbool.h that conforms to C99],
498    [ac_cv_header_stdbool_h],
499    [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
500       [[
501 #include <stdbool.h>
502 #ifndef bool
503 # error bool is not defined
504 #endif
505 #ifndef false
506 # error false is not defined
507 #endif
508 #if false
509 # error false is not 0
510 #endif
511 #ifndef true
512 # error true is not defined
513 #endif
514 #if true != 1
515 # error true is not 1
516 #endif
517 #ifndef __bool_true_false_are_defined
518 # error __bool_true_false_are_defined is not defined
519 #endif
521         struct s { _Bool s: 1; _Bool t; } s;
523         char a[true == 1 ? 1 : -1];
524         char b[false == 0 ? 1 : -1];
525         char c[__bool_true_false_are_defined == 1 ? 1 : -1];
526         char d[(bool) -0.5 == true ? 1 : -1];
527         bool e = &s;
528         char f[(_Bool) -0.0 == false ? 1 : -1];
529         char g[true];
530         char h[sizeof (_Bool)];
531         char i[sizeof s.t];
532       ]],
533       [[ return !a + !b + !c + !d + !e + !f + !g + !h + !i; ]])],
534       [ac_cv_header_stdbool_h=yes],
535       [ac_cv_header_stdbool_h=no])])
536 AC_CHECK_TYPES([_Bool])
537 if test $ac_cv_header_stdbool_h = yes; then
538   AC_DEFINE(HAVE_STDBOOL_H, 1, [Define to 1 if stdbool.h conforms to C99.])
540 ])# AC_HEADER_STDBOOL
543 # AC_HEADER_STDC
544 # --------------
545 # FIXME: I find this list very strange.  It comes from the original
546 # autoscan list, but I don't think it is useful for the same reason
547 # that we don't bind AC_PROG_CC to finding a C function calls: if the
548 # user uses bcmp, then she will certainly have the `#include', and
549 # therefore, we will trigger AC_HEADER_STDC elsewhere.  --akim 2002-09-28
550 # FIXME: Err... index and rindex are _not_ to be used... --akim 2002-09-28
551 AN_FUNCTION([bcmp],     [AC_HEADER_STDC])
552 AN_FUNCTION([bcopy],    [AC_HEADER_STDC])
553 AN_FUNCTION([bzero],    [AC_HEADER_STDC])
554 AN_FUNCTION([index],    [AC_HEADER_STDC])
555 AN_FUNCTION([memchr],   [AC_HEADER_STDC])
556 AN_FUNCTION([memcpy],   [AC_HEADER_STDC])
557 AN_FUNCTION([memmove],  [AC_HEADER_STDC])
558 AN_FUNCTION([memset],   [AC_HEADER_STDC])
559 AN_FUNCTION([rindex],   [AC_HEADER_STDC])
561 AN_HEADER([float.h],    [AC_HEADER_STDC])
562 AN_HEADER([stdarg.h],   [AC_HEADER_STDC])
563 AN_HEADER([stddef.h],   [AC_HEADER_STDC])
564 AN_HEADER([stdlib.h],   [AC_HEADER_STDC])
565 AN_HEADER([string.h],   [AC_HEADER_STDC])
567 AC_DEFUN([AC_HEADER_STDC],
568 [AC_CACHE_CHECK(for ANSI C header files, ac_cv_header_stdc,
569 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>
570 #include <stdarg.h>
571 #include <string.h>
572 #include <float.h>
573 ]])],
574                     [ac_cv_header_stdc=yes],
575                     [ac_cv_header_stdc=no])
577 if test $ac_cv_header_stdc = yes; then
578   # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
579   AC_EGREP_HEADER(memchr, string.h, , ac_cv_header_stdc=no)
582 if test $ac_cv_header_stdc = yes; then
583   # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
584   AC_EGREP_HEADER(free, stdlib.h, , ac_cv_header_stdc=no)
587 if test $ac_cv_header_stdc = yes; then
588   # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
589   AC_RUN_IFELSE([AC_LANG_SOURCE(
590 [[#include <ctype.h>
591 #if ((' ' & 0x0FF) == 0x020)
592 # define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
593 # define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
594 #else
595 # define ISLOWER(c) \
596                    (('a' <= (c) && (c) <= 'i') \
597                      || ('j' <= (c) && (c) <= 'r') \
598                      || ('s' <= (c) && (c) <= 'z'))
599 # define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
600 #endif
602 #define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
604 main ()
606   int i;
607   for (i = 0; i < 256; i++)
608     if (XOR (islower (i), ISLOWER (i))
609         || toupper (i) != TOUPPER (i))
610       exit(2);
611   exit (0);
612 }]])], , ac_cv_header_stdc=no, :)
613 fi])
614 if test $ac_cv_header_stdc = yes; then
615   AC_DEFINE(STDC_HEADERS, 1,
616             [Define to 1 if you have the ANSI C header files.])
618 ])# AC_HEADER_STDC
621 # AC_HEADER_SYS_WAIT
622 # ------------------
623 AN_HEADER([sys/wait.h], [AC_HEADER_SYS_WAIT])
624 AC_DEFUN([AC_HEADER_SYS_WAIT],
625 [AC_CACHE_CHECK([for sys/wait.h that is POSIX.1 compatible],
626   ac_cv_header_sys_wait_h,
627 [AC_COMPILE_IFELSE(
628 [AC_LANG_PROGRAM([#include <sys/types.h>
629 #include <sys/wait.h>
630 #ifndef WEXITSTATUS
631 # define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
632 #endif
633 #ifndef WIFEXITED
634 # define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
635 #endif
637 [  int s;
638   wait (&s);
639   s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;])],
640                  [ac_cv_header_sys_wait_h=yes],
641                  [ac_cv_header_sys_wait_h=no])])
642 if test $ac_cv_header_sys_wait_h = yes; then
643   AC_DEFINE(HAVE_SYS_WAIT_H, 1,
644             [Define to 1 if you have <sys/wait.h> that is POSIX.1 compatible.])
646 ])# AC_HEADER_SYS_WAIT
649 # AC_HEADER_TIME
650 # --------------
651 AN_IDENTIFIER([timeval],  [AC_HEADER_TIME])
652 AC_DEFUN([AC_HEADER_TIME],
653 [AC_CACHE_CHECK([whether time.h and sys/time.h may both be included],
654   ac_cv_header_time,
655 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <sys/types.h>
656 #include <sys/time.h>
657 #include <time.h>
659 [if ((struct tm *) 0)
660 return 0;])],
661                    [ac_cv_header_time=yes],
662                    [ac_cv_header_time=no])])
663 if test $ac_cv_header_time = yes; then
664   AC_DEFINE(TIME_WITH_SYS_TIME, 1,
665             [Define to 1 if you can safely include both <sys/time.h>
666              and <time.h>.])
668 ])# AC_HEADER_TIME
671 # _AC_HEADER_TIOCGWINSZ_IN_TERMIOS_H
672 # ----------------------------------
673 m4_define([_AC_HEADER_TIOCGWINSZ_IN_TERMIOS_H],
674 [AC_CACHE_CHECK([whether termios.h defines TIOCGWINSZ],
675                 ac_cv_sys_tiocgwinsz_in_termios_h,
676 [AC_EGREP_CPP([yes],
677               [#include <sys/types.h>
678 #include <termios.h>
679 #ifdef TIOCGWINSZ
680   yes
681 #endif
683                 ac_cv_sys_tiocgwinsz_in_termios_h=yes,
684                 ac_cv_sys_tiocgwinsz_in_termios_h=no)])
685 ])# _AC_HEADER_TIOCGWINSZ_IN_TERMIOS_H
688 # _AC_HEADER_TIOCGWINSZ_IN_SYS_IOCTL
689 # ----------------------------------
690 m4_define([_AC_HEADER_TIOCGWINSZ_IN_SYS_IOCTL],
691 [AC_CACHE_CHECK([whether sys/ioctl.h defines TIOCGWINSZ],
692                 ac_cv_sys_tiocgwinsz_in_sys_ioctl_h,
693 [AC_EGREP_CPP([yes],
694               [#include <sys/types.h>
695 #include <sys/ioctl.h>
696 #ifdef TIOCGWINSZ
697   yes
698 #endif
700                 ac_cv_sys_tiocgwinsz_in_sys_ioctl_h=yes,
701                 ac_cv_sys_tiocgwinsz_in_sys_ioctl_h=no)])
702 ])# _AC_HEADER_TIOCGWINSZ_IN_SYS_IOCTL
705 # AC_HEADER_TIOCGWINSZ
706 # --------------------
707 # Look for a header that defines TIOCGWINSZ.
708 # FIXME: Is this the proper name?  Is this the proper implementation?
709 # I need more help.
710 AC_DEFUN([AC_HEADER_TIOCGWINSZ],
711 [_AC_HEADER_TIOCGWINSZ_IN_TERMIOS_H
712 if test $ac_cv_sys_tiocgwinsz_in_termios_h != yes; then
713   _AC_HEADER_TIOCGWINSZ_IN_SYS_IOCTL
714   if test $ac_cv_sys_tiocgwinsz_in_sys_ioctl_h = yes; then
715     AC_DEFINE(GWINSZ_IN_SYS_IOCTL,1,
716               [Define to 1 if `TIOCGWINSZ' requires <sys/ioctl.h>.])
717   fi
719 ])# AC_HEADER_TIOCGWINSZ
722 # AU::AC_UNISTD_H
723 # ---------------
724 AU_DEFUN([AC_UNISTD_H],
725 [AC_CHECK_HEADERS(unistd.h)])
728 # AU::AC_USG
729 # ----------
730 # Define `USG' if string functions are in strings.h.
731 AU_DEFUN([AC_USG],
732 [AC_DIAGNOSE([obsolete],
733 [$0: Remove `AC_MSG_CHECKING', `AC_LINK_IFELSE' and this `AC_WARNING'
734 when you adjust your code to use HAVE_STRING_H.])dnl
735 AC_MSG_CHECKING([for BSD string and memory functions])
736 AC_LINK_IFELSE([AC_LANG_PROGRAM([[@%:@include <strings.h>]],
737                                 [[rindex(0, 0); bzero(0, 0);]])],
738                [AC_MSG_RESULT(yes)],
739                [AC_MSG_RESULT(no)
740                 AC_DEFINE(USG, 1,
741                           [Define to 1 if you do not have <strings.h>, index,
742                            bzero, etc... This symbol is obsolete, you should
743                            not depend upon it.])])
744 AC_CHECK_HEADERS(string.h)
745 ])# AU::AC_USG
748 # AU::AC_MEMORY_H
749 # ---------------
750 # To be precise this macro used to be:
752 #   | AC_MSG_CHECKING(whether string.h declares mem functions)
753 #   | AC_EGREP_HEADER(memchr, string.h, ac_found=yes, ac_found=no)
754 #   | AC_MSG_RESULT($ac_found)
755 #   | if test $ac_found = no; then
756 #   |   AC_CHECK_HEADER(memory.h, [AC_DEFINE(NEED_MEMORY_H)])
757 #   | fi
759 # But it is better to check for both headers, and alias NEED_MEMORY_H to
760 # HAVE_MEMORY_H.
761 AU_DEFUN([AC_MEMORY_H],
762 [AC_DIAGNOSE([obsolete], [$0: Remove this warning and
763 `AC_CHECK_HEADER(memory.h, AC_DEFINE(...))' when you adjust your code to
764 use and HAVE_STRING_H and HAVE_MEMORY_H, not NEED_MEMORY_H.])dnl
765 AC_CHECK_HEADER(memory.h,
766                 [AC_DEFINE([NEED_MEMORY_H], 1,
767                            [Same as `HAVE_MEMORY_H', don't depend on me.])])
768 AC_CHECK_HEADERS(string.h memory.h)
772 # AU::AC_DIR_HEADER
773 # -----------------
774 # Like calling `AC_HEADER_DIRENT' and `AC_FUNC_CLOSEDIR_VOID', but
775 # defines a different set of C preprocessor macros to indicate which
776 # header file is found.
777 AU_DEFUN([AC_DIR_HEADER],
778 [AC_HEADER_DIRENT
779 AC_FUNC_CLOSEDIR_VOID
780 AC_DIAGNOSE([obsolete],
781 [$0: Remove this warning and the four `AC_DEFINE' when you
782 adjust your code to use `AC_HEADER_DIRENT'.])
783 test ac_cv_header_dirent_dirent_h &&
784   AC_DEFINE([DIRENT], 1, [Same as `HAVE_DIRENT_H', don't depend on me.])
785 test ac_cv_header_dirent_sys_ndir_h &&
786   AC_DEFINE([SYSNDIR], 1, [Same as `HAVE_SYS_NDIR_H', don't depend on me.])
787 test ac_cv_header_dirent_sys_dir_h &&
788   AC_DEFINE([SYSDIR], 1, [Same as `HAVE_SYS_DIR_H', don't depend on me.])
789 test ac_cv_header_dirent_ndir_h &&
790   AC_DEFINE([NDIR], 1, [Same as `HAVE_NDIR_H', don't depend on me.])