3 AT_BANNER([Semantics.])
5 # Copyright (C) 2000, 2001, 2002, 2004, 2005, 2006, 2007 Free Software
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 ## -------------------------------- ##
23 ## Members of the AC_CHECK family. ##
24 ## -------------------------------- ##
29 # Well, I can't imagine a system where `cos' is neither in libc, nor
30 # in libm. Nor can I imagine a lib more likely to exists than libm.
31 # But there are systems without libm, on which we don't want to have
32 # this test fail, so exit successfully if `cos' is in libc.
33 AT_CHECK_MACRO([AC_CHECK_LIB],
34 [AC_TRY_LINK_FUNC(cos,
35 [AC_MSG_ERROR([`cos' is in `libc'], 77)])
38 [AC_MSG_ERROR([cannot find `cos' in `libm'])])
40 # No kidding, using variables was broken in 2.50 :(
42 AC_CHECK_LIB(m, $ac_sin,,
43 [AC_MSG_ERROR([cannot find `\$ac_sin' (= `$ac_sin') in `libm'])])
46 AC_CHECK_LIB($ac_m, acos,,
47 [AC_MSG_ERROR([cannot find `acos' in `\$ac_m' (= `$ac_m')])])
50 AC_CHECK_LIB($ac_m, $ac_asin,,
51 [AC_MSG_ERROR([cannot find `\$ac_asin' (= `$ac_asin') in `\$ac_m' (= `$at_m')])])
53 # But if the bug is in the caching mechanism, then be sure we
54 # correctly detect failures.
56 AC_CHECK_LIB(m, cossack,
57 [AC_MSG_ERROR([found `cossack' in `libm'])])
59 # No kidding, using variables was broken in 2.50 :(
61 AC_CHECK_LIB(m, $ac_sinner,
62 [AC_MSG_ERROR([found `\$ac_sinner' (= `$ac_sinner') in `libm'])])
65 AC_CHECK_LIB($ac_m, acossack,
66 [AC_MSG_ERROR([found `acossack' in `\$ac_m' (= `$ac_m')])])
69 AC_CHECK_LIB($ac_m, $ac_asinner,
70 [AC_MSG_ERROR([found `\$ac_asinner' (= `$ac_asinner') in `\$ac_m' (= `$at_m')])])
77 AT_CHECK_MACRO([AC_SEARCH_LIBS],
79 AC_SEARCH_LIBS(cos, oser m ust,,
80 [AC_MSG_ERROR([cannot find `cos'])])
82 case "$ac_cv_search_cos" in
83 -loser|-lust) AC_MSG_ERROR([jeez, $ac_cv_search_cos must be a cool library!]) ;;
88 # AC_SEARCH_LIBS (none needed)
89 # ----------------------------
90 AT_CHECK_MACRO([AC_SEARCH_LIBS (none needed)],
92 AC_SEARCH_LIBS(printf, oser c ust,,
93 [AC_MSG_ERROR([cannot find `printf'])])
95 case "$ac_cv_search_printf" in
96 -loser|-lust) AC_MSG_ERROR([jeez, $ac_cv_search_printf must be a cool library!]) ;;
97 -lc) AC_MSG_ERROR([huh, you need to give -lc?])
104 # Check that it performs the correct actions:
105 AT_CHECK_MACRO([AC_CHECK_DECLS],
106 [[AC_CHECK_DECLS([yes, no, myenum, mystruct, myfunc, mymacro1, mymacro2],,,
109 struct { int x[20]; } mystruct;
111 #define mymacro1(arg) arg
112 #define mymacro2]])]],
114 [#define HAVE_DECL_MYENUM 1
115 #define HAVE_DECL_MYFUNC 1
116 #define HAVE_DECL_MYMACRO1 1
117 #define HAVE_DECL_MYMACRO2 1
118 #define HAVE_DECL_MYSTRUCT 1
119 #define HAVE_DECL_NO 0
120 #define HAVE_DECL_YES 1
126 # Check that it performs the correct actions:
127 # Must define HAVE_PRINTF, but not HAVE_AUTOCONF_FTNIRP
128 AT_CHECK_MACRO([AC_CHECK_FUNCS],
129 [AC_CHECK_FUNCS(printf autoconf_ftnirp)],
131 [/* #undef HAVE_AUTOCONF_FTNIRP */
132 #define HAVE_PRINTF 1
138 # Check that it performs the correct actions: autoconf_ftnirp.c must
139 # be compiled, and must define HAVE_PRINTF, but not HAVE_AUTOCONF_FTNIRP
140 # FIXME: Maybe check the traces?
141 AT_SETUP([AC_REPLACE_FUNCS])
148 [AC_CONFIG_FILES(config.libobjs:config.in)
149 AC_REPLACE_FUNCS(printf autoconf_ftnirp)])
151 AT_CHECK_AUTOCONF([-W obsolete])
156 [/* #undef HAVE_AUTOCONF_FTNIRP */
157 #define HAVE_PRINTF 1
160 AT_CHECK([sed 's/ */ /g;s/^ //;s/ $//' config.libobjs], [],
161 [${LIBOBJDIR}autoconf_ftnirp$U.o
169 # Check that it performs the correct actions:
170 # Must define HAVE_STDIO_H, but not HAVE_AUTOCONF_IO_H.
171 AT_CHECK_MACRO([AC_CHECK_HEADERS],
172 [AC_CHECK_HEADERS(stdio.h autoconf_io.h)],
174 [/* #undef HAVE_AUTOCONF_IO_H */
175 #define HAVE_STDIO_H 1
179 # AC_CHECK_HEADERS_OLD
180 # --------------------
181 # Check that it performs the correct actions:
182 # Must not check prerequisites, hence define header2.h
183 AT_SETUP([AC_CHECK_HEADERS_OLD])
193 AT_CONFIGURE_AC([AC_CHECK_HEADERS(header2.h, [], [], -)])
195 AT_CHECK_AUTOCONF([-W obsolete])
197 AT_CHECK_CONFIGURE([CPPFLAGS=-I.])
200 [#define HAVE_HEADER2_H 1
206 # AC_CHECK_HEADERS_NEW
207 # --------------------
208 # Check that it performs the correct actions:
209 # Must check prerequisites, hence define header2.h but not header3.h
210 AT_SETUP([AC_CHECK_HEADERS_NEW])
225 [AC_CHECK_HEADERS(header2.h header3.h, [], [], [[@%:@include "header1.h"]])])
227 AT_CHECK_AUTOCONF([-W obsolete])
229 AT_CHECK_CONFIGURE([CPPFLAGS=-I.])
232 [#define HAVE_HEADER2_H 1
233 /* #undef HAVE_HEADER3_H */
241 # Check that it performs the correct actions.
242 # Must define HAVE_STRUCT_YES_S_YES, but not HAVE_STRUCT_YES_S_NO.
243 AT_CHECK_MACRO([AC_CHECK_MEMBERS],
244 [[AC_CHECK_MEMBERS([struct yes_s.yes, struct yes_s.no, struct yes_s.substruct],,,
245 [struct sub { int x; };
246 struct yes_s { int yes; struct sub substruct; };])]],
248 [/* #undef HAVE_STRUCT_YES_S_NO */
249 #define HAVE_STRUCT_YES_S_SUBSTRUCT 1
250 #define HAVE_STRUCT_YES_S_YES 1
256 AT_CHECK_MACRO_CROSS([AC_CHECK_ALIGNOF],
257 [[AC_CHECK_ALIGNOF(char)
258 AC_CHECK_ALIGNOF(charchar,
259 [[#include <stddef.h>
261 typedef char charchar[2];]])
262 AC_CHECK_ALIGNOF(charcharchar)
265 [#define ALIGNOF_CHAR 1
266 #define ALIGNOF_CHARCHAR 1
267 #define ALIGNOF_CHARCHARCHAR 0
271 # AC_CHECK_ALIGNOF struct
272 # -----------------------
273 AT_CHECK_MACRO_CROSS([AC_CHECK_ALIGNOF struct],
274 [[AC_CHECK_ALIGNOF([struct { char c; }])
275 AC_CHECK_ALIGNOF([struct nosuchstruct])
277 [AT_CHECK([[grep "#define ALIGNOF_STRUCT___CHAR_C___ [^0]" config.h]],
279 AT_CHECK([[grep "#define ALIGNOF_STRUCT_NOSUCHSTRUCT 0" config.h]],
285 AT_CHECK_MACRO_CROSS([AC_CHECK_SIZEOF],
286 [[AC_CHECK_SIZEOF(char)
287 AC_CHECK_SIZEOF(charchar,,
289 typedef char charchar[2];]])
290 AC_CHECK_SIZEOF(charcharchar)
293 [#define SIZEOF_CHAR 1
294 #define SIZEOF_CHARCHAR 2
295 #define SIZEOF_CHARCHARCHAR 0
299 # AC_CHECK_SIZEOF struct
300 # ----------------------
301 AT_CHECK_MACRO_CROSS([AC_CHECK_SIZEOF struct],
303 AC_CHECK_SIZEOF([struct x], [], [struct x { char c; int x; };])
304 AC_CHECK_SIZEOF([const struct x], [], [struct x { const char *p; int x; };])
305 AC_CHECK_SIZEOF([struct nosuchstruct])
307 [AT_CHECK([[grep "#define SIZEOF_STRUCT_X [^0]" config.h]],
309 AT_CHECK([[grep "#define SIZEOF_CONST_STRUCT_X [^0]" config.h]],
311 AT_CHECK([[grep "#define SIZEOF_STRUCT_NOSUCHSTRUCT 0" config.h]],
318 # Check that it performs the correct actions.
319 # Must define HAVE_STRUCT_YES_S, HAVE_INT, but not HAVE_STRUCT_NO_S.
320 # `int' and `struct yes_s' are both checked to test both the compiler
321 # builtin types, and defined types.
322 AT_CHECK_MACRO([AC_CHECK_TYPES],
323 [[AC_CHECK_TYPES([int, struct yes_s, struct no_s],,,
324 [struct yes_s { int yes ;} ;])]],
327 /* #undef HAVE_STRUCT_NO_S */
328 #define HAVE_STRUCT_YES_S 1
334 # Check that we properly dispatch properly to the old implementation
336 AT_SETUP([AC_CHECK_TYPES: backward compatibility])
338 AT_DATA([configure.ac],
340 define([_AC_CHECK_TYPE_NEW], [NEW])
341 define([_AC_CHECK_TYPE_OLD], [OLD])
343 AC_CHECK_TYPE(ptrdiff_t)
344 AC_CHECK_TYPE(ptrdiff_t, int)
345 AC_CHECK_TYPE(quad, long long int)
346 AC_CHECK_TYPE(table_42, [int[42]])
348 AC_CHECK_TYPE(uint8_t, uint65536_t)
349 AC_CHECK_TYPE(a,b,c,d)
355 AT_CHECK([[sed -e '/^#(cut-from-here/,/^#to-here)/!d' -e '/^#/d' configure]],
370 # FIXME: To really test HAVE_AC_EXISTS2 and HAVE_AC_MISSING2 we need to
371 # open AH_TEMPLATE to `configure.ac', which is not yet the case.
372 AT_CHECK_MACRO([AC_CHECK_FILES],
373 [touch at-exists1 at-exists2
374 ac_exists2=at-exists2
375 ac_missing2=at-missing2
376 AC_CHECK_FILES(at-exists1 at-missing1 $ac_exists2 $ac_missing2)
377 rm at-exists1 at-exists2],
379 [#define HAVE_AT_EXISTS1 1
380 /* #undef HAVE_AT_MISSING1 */
385 ## ------------------------------ ##
386 ## AC_CHECK_PROG & AC_PATH_PROG. ##
387 ## ------------------------------ ##
390 # AT_CHECK_PROGS_PREPARE
391 # ----------------------
392 # Create a sub directory `path' with 6 subdirs which all 7 contain
393 # an executable `tool'. `6' contains a `better' tool.
394 m4_define([AT_CHECK_PROGS_PREPARE],
397 cat >path/tool <<\EOF
408 cp path/tool path/6/better])
411 # -------------------------------- #
412 # AC_CHECK_PROG & AC_CHECK_PROGS. #
413 # -------------------------------- #
415 AT_SETUP([AC_CHECK_PROG & AC_CHECK_PROGS])
417 AT_CHECK_PROGS_PREPARE
419 AT_DATA([configure.ac],
422 p="1${PATH_SEPARATOR}2${PATH_SEPARATOR}3${PATH_SEPARATOR}4${PATH_SEPARATOR}5${PATH_SEPARATOR}6"
423 path=`echo $p | sed -e 's,\([[0-9]]\),'"$pwd"'/path/\1,g'`
426 AC_CHECK_PROG(TOOL1, tool, found, not-found, $path)
427 test "$TOOL1" = found || fail=:
429 # Yes, the semantics of this macro is weird.
430 AC_CHECK_PROG(TOOL2, tool,, not-found, $path)
431 test "$TOOL2" = not-found || fail=:
433 AC_CHECK_PROG(TOOL3, tool, tool, not-found, $path, $pwd/path/1/tool)
434 test "$TOOL3" = "$pwd/path/2/tool" || fail=:
436 AC_CHECK_PROG(TOOL4, better, better, not-found, $path, $pwd/path/1/tool)
437 test "$TOOL4" = better || fail=:
439 # When a tool is not found, and no value is given for not-found,
440 # the variable is left empty.
441 AC_CHECK_PROGS(TOOL5, missing,, $path)
442 test -z "$TOOL5" || fail=:
444 AC_CHECK_PROGS(TOOL6, missing tool better,, $path)
445 test "$TOOL6" = tool || fail=:
447 # No AC-OUTPUT, we don't need config.status.
449 AC_MSG_ERROR([[CHECK_PROG failed]])
460 ## ---------------- ##
461 ## AC_C_BIGENDIAN. ##
462 ## ---------------- ##
464 AT_SETUP([AC_C_BIGENDIAN])
467 # Make sure that AC_C_BIGENDIAN behave the same whether we are
468 # cross-compiling or not.
475 [ac_endian=universal])
476 echo $ac_endian > at-endian
479 rm -f config.hin # So that next run of autoheader is quiet.
481 [[# Force cross compiling.
488 [ac_endian=universal])
489 ac_prevendian=`cat at-endian`
490 # Check that we have found the same result as in the previous run
491 # or unknown (because the cross-compiling check is allowed to fail;
492 # although it might be interesting to suppress this comparison, just
493 # to know on which system it fails if it ever does).
494 if test $ac_endian != $ac_prevendian && test $ac_endian != unknown; then
495 AC_MSG_ERROR([unexpected endianness: first run found '$ac_prevendian' but second run found '$ac_endian'])
499 # Make sure AC_C_BIGENDIAN with no argument will create a config.h template
500 # containing "WORDS_BIGENDIAN".
501 AT_CONFIGURE_AC([[AC_C_BIGENDIAN]])
502 # --force is necessary, the computer might be too fast.
503 AT_CHECK_AUTOHEADER([--force])
504 AT_CHECK([grep WORDS_BIGENDIAN config.hin], [], [ignore])
509 # ------------------------------ #
510 # AC_PATH_PROG & AC_PATH_PROGS. #
511 # ------------------------------ #
513 AT_SETUP([AC_PATH_PROG & AC_PATH_PROGS])
515 AT_CHECK_PROGS_PREPARE
517 AT_DATA([configure.ac],
520 p="1${PATH_SEPARATOR}2${PATH_SEPARATOR}3${PATH_SEPARATOR}4${PATH_SEPARATOR}5${PATH_SEPARATOR}6"
521 path=`echo $p | sed -e 's,\([[0-9]]\),'"$pwd"'/path/\1,g'`
524 AC_PATH_PROG(TOOL1, tool, not-found, $path)
525 test "$TOOL1" = "$pwd/path/1/tool" || fail=:
527 AC_PATH_PROG(TOOL2, better, not-found, $path)
528 test "$TOOL2" = "$pwd/path/6/better" || fail=:
530 # When a tool is not found, and no value is given for not-found,
531 # the variable is left empty.
532 AC_PATH_PROGS(TOOL3, missing,, $path)
533 test -z "$TOOL3" || fail=:
535 AC_PATH_PROGS(TOOL4, missing tool better,, $path)
536 test "$TOOL4" = "$pwd/path/1/tool" || fail=:
538 # No AC-OUTPUT, we don't need config.status.
540 AC_MSG_ERROR([[PATH_PROG failed]])
557 AT_SETUP([AC_PATH_XTRA])
559 _AT_CHECK_AC_MACRO([AC_PATH_XTRA])
561 # Check X_DISPLAY_MISSING.
562 AT_CHECK_CONFIGURE([--without-x])
564 [#define X_DISPLAY_MISSING 1
570 ## ------------------------------- ##
571 ## Obsolete non-updatable macros. ##
572 ## ------------------------------- ##
575 AT_CHECK_MACRO([AC_SYS_RESTARTABLE_SYSCALLS], , ,[-W no-obsolete])
576 AT_CHECK_MACRO([AC_FUNC_SETVBUF_REVERSED], , ,[-W no-obsolete])
577 AT_CHECK_MACRO([AC_FUNC_WAIT3], , ,[-W no-obsolete])