3 AT_BANNER([Semantics.])
5 # Copyright (C) 2000, 2001, 2002, 2004, 2005 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., 59 Temple Place - Suite 330, Boston, MA
23 ## -------------------------------- ##
24 ## Members of the AC_CHECK family. ##
25 ## -------------------------------- ##
30 # Well, I can't imagine a system where `cos' is neither in libc, nor
31 # in libm. Nor can I imagine a lib more likely to exists than libm.
32 # But there are systems without libm, on which we don't want to have
33 # this test fail, so exit successfully if `cos' is in libc.
34 AT_CHECK_MACRO([AC_CHECK_LIB],
35 [AC_TRY_LINK_FUNC(cos,
36 [AC_MSG_ERROR([`cos' is in `libc'], 77)])
39 [AC_MSG_ERROR([cannot find `cos' in `libm'])])
41 # No kidding, using variables was broken in 2.50 :(
43 AC_CHECK_LIB(m, $ac_sin,,
44 [AC_MSG_ERROR([cannot find `\$ac_sin' (= `$ac_sin') in `libm'])])
47 AC_CHECK_LIB($ac_m, acos,,
48 [AC_MSG_ERROR([cannot find `acos' in `\$ac_m' (= `$ac_m')])])
51 AC_CHECK_LIB($ac_m, $ac_asin,,
52 [AC_MSG_ERROR([cannot find `\$ac_asin' (= `$ac_asin') in `\$ac_m' (= `$at_m')])])
54 # But if the bug is in the caching mechanism, then be sure we
55 # correctly detect failures.
57 AC_CHECK_LIB(m, cossack,
58 [AC_MSG_ERROR([found `cossack' in `libm'])])
60 # No kidding, using variables was broken in 2.50 :(
62 AC_CHECK_LIB(m, $ac_sinner,
63 [AC_MSG_ERROR([found `\$ac_sinner' (= `$ac_sinner') in `libm'])])
66 AC_CHECK_LIB($ac_m, acossack,
67 [AC_MSG_ERROR([found `acossack' in `\$ac_m' (= `$ac_m')])])
70 AC_CHECK_LIB($ac_m, $ac_asinner,
71 [AC_MSG_ERROR([found `\$ac_asinner' (= `$ac_asinner') in `\$ac_m' (= `$at_m')])])
78 AT_CHECK_MACRO([AC_SEARCH_LIBS],
80 AC_SEARCH_LIBS(cos, oser m ust,,
81 [AC_MSG_ERROR([cannot find `cos'])])
83 case "$ac_cv_search_cos" in
84 -loser|-lust) AC_MSG_ERROR([jeez, $ac_cv_search_cos must be a cool library!]) ;;
87 AC_SEARCH_LIBS(printf, oser c ust,,
88 [AC_MSG_ERROR([cannot find `printf'])])
90 case "$ac_cv_search_printf" in
91 -loser|-lust) AC_MSG_ERROR([jeez, $ac_cv_search_printf must be a cool library!]) ;;
92 -lc) AC_MSG_ERROR([huh, you need to give -lc?])
100 # Check that it performs the correct actions:
101 # Must define NEED_NO_DECL, but not NEED_YES_DECL.
102 AT_CHECK_MACRO([AC_CHECK_DECLS],
103 [[AC_CHECK_DECLS([yes, no],,,
106 [#define HAVE_DECL_NO 0
107 #define HAVE_DECL_YES 1
113 # Check that it performs the correct actions:
114 # Must define HAVE_PRINTF, but not HAVE_AUTOCONF_FTNIRP
115 AT_CHECK_MACRO([AC_CHECK_FUNCS],
116 [AC_CHECK_FUNCS(printf autoconf_ftnirp)],
118 [/* #undef HAVE_AUTOCONF_FTNIRP */
119 #define HAVE_PRINTF 1
125 # Check that it performs the correct actions: autoconf_ftnirp.c must
126 # be compiled, and must define HAVE_PRINTF, but not HAVE_AUTOCONF_FTNIRP
127 # FIXME: Maybe check the traces?
128 AT_SETUP([AC_REPLACE_FUNCS])
135 [AC_CONFIG_FILES(config.libobjs:config.in)
136 AC_REPLACE_FUNCS(printf autoconf_ftnirp)])
138 AT_CHECK_AUTOCONF([-W obsolete])
143 [/* #undef HAVE_AUTOCONF_FTNIRP */
144 #define HAVE_PRINTF 1
147 AT_CHECK([sed 's/ */ /g;s/^ //;s/ $//' config.libobjs], [],
151 AT_CLEANUP([config.libobjs])
156 # Check that it performs the correct actions:
157 # Must define HAVE_STDIO_H, but not HAVE_AUTOCONF_IO_H.
158 AT_CHECK_MACRO([AC_CHECK_HEADERS],
159 [AC_CHECK_HEADERS(stdio.h autoconf_io.h)],
161 [/* #undef HAVE_AUTOCONF_IO_H */
162 #define HAVE_STDIO_H 1
166 # AC_CHECK_HEADERS_OLD
167 # --------------------
168 # Check that it performs the correct actions:
169 # Must not check prerequisites, hence define header2.h
170 AT_SETUP([AC_CHECK_HEADERS_OLD])
180 AT_CONFIGURE_AC([AC_CHECK_HEADERS(header2.h, [], [], -)])
182 AT_CHECK_AUTOCONF([-W obsolete])
184 AT_CHECK_CONFIGURE([CPPFLAGS=-I.])
187 [#define HAVE_HEADER2_H 1
190 AT_CLEANUP([header1.h header2.h])
193 # AC_CHECK_HEADERS_NEW
194 # --------------------
195 # Check that it performs the correct actions:
196 # Must check prerequisites, hence define header2.h but not header3.h
197 AT_SETUP([AC_CHECK_HEADERS_NEW])
212 [AC_CHECK_HEADERS(header2.h header3.h, [], [], [[@%:@include "header1.h"]])])
214 AT_CHECK_AUTOCONF([-W obsolete])
216 AT_CHECK_CONFIGURE([CPPFLAGS=-I.])
219 [#define HAVE_HEADER2_H 1
220 /* #undef HAVE_HEADER3_H */
223 AT_CLEANUP([header1.h header2.h header3.h])
228 # Check that it performs the correct actions.
229 # Must define HAVE_STRUCT_YES_S_YES, but not HAVE_STRUCT_YES_S_NO.
230 AT_CHECK_MACRO([AC_CHECK_MEMBERS],
231 [[AC_CHECK_MEMBERS([struct yes_s.yes, struct yes_s.no],,,
232 [struct yes_s { int yes ;} ;])]],
234 [/* #undef HAVE_STRUCT_YES_S_NO */
235 #define HAVE_STRUCT_YES_S_YES 1
241 # Not cross-compiling.
242 AT_CHECK_MACRO([AC_CHECK_ALIGNOF],
243 [[AC_CHECK_ALIGNOF(char)
244 AC_CHECK_ALIGNOF(charchar,
245 [[#include <stddef.h>
247 typedef char charchar[2];]])
248 AC_CHECK_ALIGNOF(charcharchar)
251 [#define ALIGNOF_CHAR 1
252 #define ALIGNOF_CHARCHAR 1
253 #define ALIGNOF_CHARCHARCHAR 0
259 AT_CHECK_MACRO([AC_CHECK_ALIGNOF],
260 [[# Exercise the code used when cross-compiling
262 AC_CHECK_ALIGNOF(char)
263 AC_CHECK_ALIGNOF(charchar,
264 [[#include <stddef.h>
266 typedef char charchar[2];]])
267 AC_CHECK_ALIGNOF(charcharchar)
270 [#define ALIGNOF_CHAR 1
271 #define ALIGNOF_CHARCHAR 1
272 #define ALIGNOF_CHARCHARCHAR 0
278 # Not cross-compiling.
279 AT_CHECK_MACRO([AC_CHECK_SIZEOF],
280 [[AC_CHECK_SIZEOF(char)
281 AC_CHECK_SIZEOF(charchar,,
283 typedef char charchar[2];]])
284 AC_CHECK_SIZEOF(charcharchar)
287 [#define SIZEOF_CHAR 1
288 #define SIZEOF_CHARCHAR 2
289 #define SIZEOF_CHARCHARCHAR 0
295 AT_CHECK_MACRO([AC_CHECK_SIZEOF],
296 [[# Exercise the code used when cross-compiling
298 AC_CHECK_SIZEOF(char)
299 AC_CHECK_SIZEOF(charchar,,
301 typedef char charchar[2];]])
302 AC_CHECK_SIZEOF(charcharchar)
305 [#define SIZEOF_CHAR 1
306 #define SIZEOF_CHARCHAR 2
307 #define SIZEOF_CHARCHARCHAR 0
313 # Check that it performs the correct actions.
314 # Must define HAVE_STRUCT_YES_S, HAVE_INT, but not HAVE_STRUCT_NO_S.
315 # `int' and `struct yes_s' are both checked to test both the compiler
316 # builtin types, and defined types.
317 AT_CHECK_MACRO([AC_CHECK_TYPES],
318 [[AC_CHECK_TYPES([int, struct yes_s, struct no_s],,,
319 [struct yes_s { int yes ;} ;])]],
322 /* #undef HAVE_STRUCT_NO_S */
323 #define HAVE_STRUCT_YES_S 1
329 # Check that we properly dispatch properly to the old implementation
331 AT_SETUP([AC_CHECK_TYPES: backward compatibility])
333 AT_DATA([configure.ac],
335 define([_AC_CHECK_TYPE_NEW], [NEW])
336 define([_AC_CHECK_TYPE_OLD], [OLD])
338 AC_CHECK_TYPE(ptrdiff_t)
339 AC_CHECK_TYPE(ptrdiff_t, int)
340 AC_CHECK_TYPE(quad, long long int)
341 AC_CHECK_TYPE(table_42, [int[42]])
343 AC_CHECK_TYPE(uint8_t, uint65536_t)
344 AC_CHECK_TYPE(a,b,c,d)
350 AT_CHECK([[sed -e '/^#(cut-from-here/,/^#to-here)/!d' -e '/^#/d' configure]],
365 # FIXME: To really test HAVE_AC_EXISTS2 and HAVE_AC_MISSING2 we need to
366 # open AH_TEMPLATE to `configure.ac', which is not yet the case.
367 AT_CHECK_MACRO([AC_CHECK_FILES],
368 [touch at-exists1 at-exists2
369 ac_exists2=at-exists2
370 ac_missing2=at-missing2
371 AC_CHECK_FILES(at-exists1 at-missing1 $ac_exists2 $ac_missing2)
372 rm at-exists1 at-exists2],
374 [#define HAVE_AT_EXISTS1 1
375 /* #undef HAVE_AT_MISSING1 */
380 ## ------------------------------ ##
381 ## AC_CHECK_PROG & AC_PATH_PROG. ##
382 ## ------------------------------ ##
385 # AT_CHECK_PROGS_PREPARE
386 # ----------------------
387 # Create a sub directory `path' with 6 subdirs which all 7 contain
388 # an executable `tool'. `6' contains a `better' tool.
389 m4_define([AT_CHECK_PROGS_PREPARE],
392 cat >path/tool <<\EOF
403 cp path/tool path/6/better])
406 # -------------------------------- #
407 # AC_CHECK_PROG & AC_CHECK_PROGS. #
408 # -------------------------------- #
410 AT_SETUP([AC_CHECK_PROG & AC_CHECK_PROGS])
412 AT_CHECK_PROGS_PREPARE
414 AT_DATA([configure.ac],
417 p="1${PATH_SEPARATOR}2${PATH_SEPARATOR}3${PATH_SEPARATOR}4${PATH_SEPARATOR}5${PATH_SEPARATOR}6"
418 path=`echo $p | sed -e 's,\([[0-9]]\),'"$pwd"'/path/\1,g'`
421 AC_CHECK_PROG(TOOL1, tool, found, not-found, $path)
422 test "$TOOL1" = found || fail=:
424 # Yes, the semantics of this macro is weird.
425 AC_CHECK_PROG(TOOL2, tool,, not-found, $path)
426 test "$TOOL2" = not-found || fail=:
428 AC_CHECK_PROG(TOOL3, tool, tool, not-found, $path, $pwd/path/1/tool)
429 test "$TOOL3" = $pwd/path/2/tool || fail=:
431 AC_CHECK_PROG(TOOL4, better, better, not-found, $path, $pwd/path/1/tool)
432 test "$TOOL4" = better || fail=:
434 # When a tool is not found, and no value is given for not-found,
435 # the variable is left empty.
436 AC_CHECK_PROGS(TOOL5, missing,, $path)
437 test -z "$TOOL5" || fail=:
439 AC_CHECK_PROGS(TOOL6, missing tool better,, $path)
440 test "$TOOL6" = tool || fail=:
442 # No AC-OUTPUT, we don't need config.status.
444 AC_MSG_ERROR([[CHECK_PROG failed]])
455 ## ---------------- ##
456 ## AC_C_BIGENDIAN. ##
457 ## ---------------- ##
459 AT_SETUP([[AC_C_BIGENDIAN]])
462 # Make sure that AC_C_BIGENDIAN behave the same whether we are
463 # cross-compiling or not.
466 [AC_C_BIGENDIAN([ac_endian=big],[ac_endian=little],[ac_endian=unknown])
467 echo $ac_endian > at-endian
470 rm -f config.hin # So that next run of autoheader is quiet.
473 AC_C_BIGENDIAN([ac_endian=big],[ac_endian=little],[ac_endian=unknown])
474 ac_prevendian=`cat at-endian`
475 # Check that we have found the same result as in the previous run
476 # or unknown (because the cross-compiling check is allowed to fail;
477 # although it might be interesting to suppress this comparison, just
478 # to know on which system it fails if it ever does).
479 if test $ac_endian != $ac_prevendian && test $ac_endian != unknown; then
480 AC_MSG_ERROR([unexpected endianness: first run found '$ac_prevendian' but second run found '$ac_endian'])
484 # Make sure AC_C_BIGENDIAN with no argument will define WORDS_BIGENDIAN
485 AT_CONFIGURE_AC([AC_C_BIGENDIAN])
487 AT_CHECK([grep WORDS_BIGENDIAN config.hin], [], [ignore])
489 AT_CLEANUP(at-endian)
492 # ------------------------------ #
493 # AC_PATH_PROG & AC_PATH_PROGS. #
494 # ------------------------------ #
496 AT_SETUP([[AC_PATH_PROG & AC_PATH_PROGS]])
498 AT_CHECK_PROGS_PREPARE
500 AT_DATA([configure.ac],
503 p="1${PATH_SEPARATOR}2${PATH_SEPARATOR}3${PATH_SEPARATOR}4${PATH_SEPARATOR}5${PATH_SEPARATOR}6"
504 path=`echo $p | sed -e 's,\([[0-9]]\),'"$pwd"'/path/\1,g'`
507 AC_PATH_PROG(TOOL1, tool, not-found, $path)
508 test "$TOOL1" = $pwd/path/1/tool || fail=:
510 AC_PATH_PROG(TOOL2, better, not-found, $path)
511 test "$TOOL2" = $pwd/path/6/better || fail=:
513 # When a tool is not found, and no value is given for not-found,
514 # the variable is left empty.
515 AC_PATH_PROGS(TOOL3, missing,, $path)
516 test -z "$TOOL3" || fail=:
518 AC_PATH_PROGS(TOOL4, missing tool better,, $path)
519 test "$TOOL4" = $pwd/path/1/tool || fail=:
521 # No AC-OUTPUT, we don't need config.status.
523 AC_MSG_ERROR([[PATH_PROG failed]])
540 AT_SETUP([AC_PATH_XTRA])
542 _AT_CHECK_AC_MACRO([AC_PATH_XTRA])
544 # Check X_DISPLAY_MISSING.
545 AT_CHECK_CONFIGURE([--without-x])
547 [#define X_DISPLAY_MISSING 1
553 ## ------------------------------- ##
554 ## Obsolete non-updatable macros. ##
555 ## ------------------------------- ##
558 AT_CHECK_MACRO([AC_SYS_RESTARTABLE_SYSCALLS], , ,[-W no-obsolete])
559 AT_CHECK_MACRO([AC_FUNC_WAIT3], , ,[-W no-obsolete])