3 AT_BANNER([Semantics.])
5 # Copyright (C) 2000, 2001, 2002 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])
181 [CPPFLAGS="$CPPFLAGS -I."
182 AC_CHECK_HEADERS(header2.h, [], [], -)])
184 AT_CHECK_AUTOCONF([-W obsolete])
189 [#define HAVE_HEADER2_H 1
192 AT_CLEANUP([header1.h header2.h])
195 # AC_CHECK_HEADERS_NEW
196 # --------------------
197 # Check that it performs the correct actions:
198 # Must check prerequisites, hence define header2.h but not header3.h
199 AT_SETUP([AC_CHECK_HEADERS_NEW])
214 [CPPFLAGS="$CPPFLAGS -I."
215 AC_CHECK_HEADERS(header2.h header3.h, [], [], [[@%:@include "header1.h"]])])
217 AT_CHECK_AUTOCONF([-W obsolete])
222 [#define HAVE_HEADER2_H 1
223 /* #undef HAVE_HEADER3_H */
226 AT_CLEANUP([header1.h header2.h header3.h])
231 # Check that it performs the correct actions.
232 # Must define HAVE_STRUCT_YES_S_YES, but not HAVE_STRUCT_YES_S_NO.
233 AT_CHECK_MACRO([AC_CHECK_MEMBERS],
234 [[AC_CHECK_MEMBERS([struct yes_s.yes, struct yes_s.no],,,
235 [struct yes_s { int yes ;} ;])]],
237 [/* #undef HAVE_STRUCT_YES_S_NO */
238 #define HAVE_STRUCT_YES_S_YES 1
244 # Not cross-compiling.
245 AT_CHECK_MACRO([AC_CHECK_SIZEOF],
246 [[AC_CHECK_SIZEOF(char)
247 AC_CHECK_SIZEOF(charchar,,
249 typedef char charchar[2];]])
250 AC_CHECK_SIZEOF(charcharchar)
253 [#define SIZEOF_CHAR 1
254 #define SIZEOF_CHARCHAR 2
255 #define SIZEOF_CHARCHARCHAR 0
261 AT_CHECK_MACRO([AC_CHECK_SIZEOF],
262 [[# Exercise the code used when cross-compiling
264 AC_CHECK_SIZEOF(char)
265 AC_CHECK_SIZEOF(charchar,,
267 typedef char charchar[2];]])
268 AC_CHECK_SIZEOF(charcharchar)
271 [#define SIZEOF_CHAR 1
272 #define SIZEOF_CHARCHAR 2
273 #define SIZEOF_CHARCHARCHAR 0
279 # Check that it performs the correct actions.
280 # Must define HAVE_STRUCT_YES_S, HAVE_INT, but not HAVE_STRUCT_NO_S.
281 # `int' and `struct yes_s' are both checked to test both the compiler
282 # builtin types, and defined types.
283 AT_CHECK_MACRO([AC_CHECK_TYPES],
284 [[AC_CHECK_TYPES([int, struct yes_s, struct no_s],,,
285 [struct yes_s { int yes ;} ;])]],
288 /* #undef HAVE_STRUCT_NO_S */
289 #define HAVE_STRUCT_YES_S 1
295 # Check that we properly dispatch properly to the old implementation
297 AT_SETUP([AC_CHECK_TYPES: backward compatibility])
299 AT_DATA([configure.ac],
301 define([_AC_CHECK_TYPE_NEW], [NEW])
302 define([_AC_CHECK_TYPE_OLD], [OLD])
304 AC_CHECK_TYPE(ptrdiff_t)
305 AC_CHECK_TYPE(ptrdiff_t, int)
306 AC_CHECK_TYPE(quad, long long)
307 AC_CHECK_TYPE(table_42, [int[42]])
309 AC_CHECK_TYPE(uint8_t, uint65536_t)
310 AC_CHECK_TYPE(a,b,c,d)
316 AT_CHECK([[sed -e '/^#(cut-from-here/,/^#to-here)/!d' -e '/^#/d' configure]],
331 # FIXME: To really test HAVE_AC_EXISTS2 and HAVE_AC_MISSING2 we need to
332 # open AH_TEMPLATE to `configure.ac', which is not yet the case.
333 AT_CHECK_MACRO([AC_CHECK_FILES],
334 [touch at-exists1 at-exists2
335 ac_exists2=at-exists2
336 ac_missing2=at-missing2
337 AC_CHECK_FILES(at-exists1 at-missing1 $ac_exists2 $ac_missing2)
338 rm at-exists1 at-exists2],
340 [#define HAVE_AT_EXISTS1 1
341 /* #undef HAVE_AT_MISSING1 */
346 ## ------------------------------ ##
347 ## AC_CHECK_PROG & AC_PATH_PROG. ##
348 ## ------------------------------ ##
351 # AT_CHECK_PROGS_PREPARE
352 # ----------------------
353 # Create a sub directory `path' with 6 subdirs which all 7 contain
354 # an executable `tool'. `6' contains a `better' tool.
355 m4_define([AT_CHECK_PROGS_PREPARE],
358 cat >path/tool <<\EOF
369 cp path/tool path/6/better])
372 # -------------------------------- #
373 # AC_CHECK_PROG & AC_CHECK_PROGS. #
374 # -------------------------------- #
376 AT_SETUP([AC_CHECK_PROG & AC_CHECK_PROGS])
378 AT_CHECK_PROGS_PREPARE
380 AT_DATA([configure.ac],
383 p="1${PATH_SEPARATOR}2${PATH_SEPARATOR}3${PATH_SEPARATOR}4${PATH_SEPARATOR}5${PATH_SEPARATOR}6"
384 path=`echo $p | sed -e 's,\([[0-9]]\),'"$pwd"'/path/\1,g'`
387 AC_CHECK_PROG(TOOL1, tool, found, not-found, $path)
388 test "$TOOL1" = found || fail=:
390 # Yes, the semantics of this macro is weird.
391 AC_CHECK_PROG(TOOL2, tool,, not-found, $path)
392 test "$TOOL2" = not-found || fail=:
394 AC_CHECK_PROG(TOOL3, tool, tool, not-found, $path, $pwd/path/1/tool)
395 test "$TOOL3" = $pwd/path/2/tool || fail=:
397 AC_CHECK_PROG(TOOL4, better, better, not-found, $path, $pwd/path/1/tool)
398 test "$TOOL4" = better || fail=:
400 # When a tool is not found, and no value is given for not-found,
401 # the variable is left empty.
402 AC_CHECK_PROGS(TOOL5, missing,, $path)
403 test -z "$TOOL5" || fail=:
405 AC_CHECK_PROGS(TOOL6, missing tool better,, $path)
406 test "$TOOL6" = tool || fail=:
408 # No AC-OUTPUT, we don't need config.status.
410 AC_MSG_ERROR([[CHECK_PROG failed]])
421 ## ---------------- ##
422 ## AC_C_BIGENDIAN. ##
423 ## ---------------- ##
425 AT_SETUP([[AC_C_BIGENDIAN]])
428 # Make sure that AC_C_BIGENDIAN behave the same whether we are
429 # cross-compiling or not.
432 [AC_C_BIGENDIAN([ac_endian=big],[ac_endian=little],[ac_endian=unknown])
433 echo $ac_endian > at-endian
436 rm -f config.hin # So that next run of autoheader is quiet.
439 AC_C_BIGENDIAN([ac_endian=big],[ac_endian=little],[ac_endian=unknown])
440 ac_prevendian=`cat at-endian`
441 # Check that we have found the same result as in the previous run
442 # or unknown (because the cross-compiling check is allowed to fail;
443 # although it might be interesting to suppress this comparison, just
444 # to know on which system it fails if it ever does).
445 if test $ac_endian != $ac_prevendian && test $ac_endian != unknown; then
446 AC_MSG_ERROR([unexpected endianness: first run found '$ac_prevendian' but second run found '$ac_endian'])
450 # Make sure AC_C_BIGENDIAN with no argument will define WORDS_BIGENDIAN
451 AT_CONFIGURE_AC([AC_C_BIGENDIAN])
453 AT_CHECK([grep WORDS_BIGENDIAN config.hin], [], [ignore])
455 AT_CLEANUP(at-endian)
458 # ------------------------------ #
459 # AC_PATH_PROG & AC_PATH_PROGS. #
460 # ------------------------------ #
462 AT_SETUP([[AC_PATH_PROG & AC_PATH_PROGS]])
464 AT_CHECK_PROGS_PREPARE
466 AT_DATA([configure.ac],
469 p="1${PATH_SEPARATOR}2${PATH_SEPARATOR}3${PATH_SEPARATOR}4${PATH_SEPARATOR}5${PATH_SEPARATOR}6"
470 path=`echo $p | sed -e 's,\([[0-9]]\),'"$pwd"'/path/\1,g'`
473 AC_PATH_PROG(TOOL1, tool, not-found, $path)
474 test "$TOOL1" = $pwd/path/1/tool || fail=:
476 AC_PATH_PROG(TOOL2, better, not-found, $path)
477 test "$TOOL2" = $pwd/path/6/better || fail=:
479 # When a tool is not found, and no value is given for not-found,
480 # the variable is left empty.
481 AC_PATH_PROGS(TOOL3, missing,, $path)
482 test -z "$TOOL3" || fail=:
484 AC_PATH_PROGS(TOOL4, missing tool better,, $path)
485 test "$TOOL4" = $pwd/path/1/tool || fail=:
487 # No AC-OUTPUT, we don't need config.status.
489 AC_MSG_ERROR([[PATH_PROG failed]])
506 AT_SETUP([AC_PATH_XTRA])
508 _AT_CHECK_AC_MACRO([AC_PATH_XTRA])
510 # Check X_DISPLAY_MISSING.
511 AT_CHECK_CONFIGURE([--without-x])
513 [#define X_DISPLAY_MISSING 1
519 ## ------------------------------- ##
520 ## Obsolete non-updatable macros. ##
521 ## ------------------------------- ##
524 AT_CHECK_MACRO([AC_SYS_RESTARTABLE_SYSCALLS], , ,[-W no-obsolete])
525 AT_CHECK_MACRO([AC_FUNC_WAIT3], , ,[-W no-obsolete])