Debian Codegraph @

tests/semantics.at

raw
1 # -*- Autotest -*-
2
3 AT_BANNER([Semantics.])
4
5 # Copyright (C) 2000-2002, 2004-2007, 2009-2017, 2020-2026 Free Software
6 # Foundation, Inc.
7 #
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.
12 #
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.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <https://www.gnu.org/licenses/>.
20
21
22 ## -------------------------------- ##
23 ## Members of the AC_CHECK family. ##
24 ## -------------------------------- ##
25
26
27 # AC_CHECK_LIB
28 # ------------
29 # Test for symbols in a library that is very likely to be available
30 # and can be used from both C and C++: zlib, which we assume is
31 # available unless <zlib.h> doesn't exist.
32 # We used to use math library symbols for this, but that no longer
33 # works, because some C++ compilers pull in libm by default when the
34 # matching C compiler doesn't, breaking AT_CHECK_MACRO's expectations.
35 AT_CHECK_MACRO([AC_CHECK_LIB], [[
36 AC_CHECK_HEADER([zlib.h], [], [
37 AC_MSG_NOTICE([zlib not available, skipping test])
38 AS_EXIT(77)
39 ])
40
41 # Using : for the ACTION-IF-FOUND in each call to AC_CHECK_LIB
42 # prevents LIBS from accumulating copies of "-lz".
43
44 AC_CHECK_LIB([z], [zlibVersion], [:], [
45 AC_MSG_ERROR([cannot find zlibVersion in libz])
46 ])
47 if test "${ac_cv_lib_z_zlibVersion+set}" != set; then
48 AC_MSG_ERROR([ac_cv_lib_z_zlibVersion not set])
49 fi
50
51
52 # No kidding, using variables was broken in 2.50 :(
53 ac_deflate=deflate
54 AC_CHECK_LIB([z], [$ac_deflate], [:], [
55 AC_MSG_ERROR([cannot find \$ac_deflate (= $ac_deflate) in libz])
56 ])
57 if test "${ac_cv_lib_z_deflate+set}" != set; then
58 AC_MSG_ERROR([ac_cv_lib_z_deflate not set])
59 fi
60
61 ac_z=z
62 AC_CHECK_LIB([$ac_z], [deflateEnd], [:], [
63 AC_MSG_ERROR([cannot find deflateEnd in lib\$ac_z (= lib$ac_z)])
64 ])
65 if test "${ac_cv_lib_z_deflateEnd+set}" != set; then
66 AC_MSG_ERROR([ac_cv_lib_z_deflateEnd not set])
67 fi
68
69 ac_inflate=inflate
70 AC_CHECK_LIB([$ac_z], [$ac_inflate], [:], [
71 AC_MSG_ERROR(
72 [cannot find \$ac_inflate (= $ac_inflate) in lib\$ac_z (= lib$ac_z)])
73 ])
74 if test "${ac_cv_lib_z_inflate+set}" != set; then
75 AC_MSG_ERROR([ac_cv_lib_z_inflate not set])
76 fi
77
78 # Also test for symbols that don't (well, shouldn't) exist.
79 # These should still set their cache variables!
80 AC_CHECK_LIB([z], [deflagrate], [
81 AC_MSG_ERROR([found deflagrate in libz])
82 ], [:])
83 if test "${ac_cv_lib_z_deflagrate+set}" != set; then
84 AC_MSG_ERROR([ac_cv_lib_z_zlibVersion not set])
85 fi
86
87 ac_defenestrate=defenestrate
88 AC_CHECK_LIB([z], [$ac_defenestrate], [
89 AC_MSG_ERROR([found \$ac_defenestrate (= $ac_defenestrate) in libz])
90 ], [:])
91 if test "${ac_cv_lib_z_defenestrate+set}" != set; then
92 AC_MSG_ERROR([ac_cv_lib_z_defenestrate not set])
93 fi
94
95 AC_CHECK_LIB([$ac_z], [defoliate], [
96 AC_MSG_ERROR([found defoliate in lib\$ac_z (= lib$ac_z)])
97 ], [:])
98 if test "${ac_cv_lib_z_defoliate+set}" != set; then
99 AC_MSG_ERROR([ac_cv_lib_z_defoliate not set])
100 fi
101
102 ac_infiltrate=infiltrate
103 AC_CHECK_LIB([$ac_z], [$ac_infiltrate], [
104 AC_MSG_ERROR(
105 [found \$ac_infiltrate (= $ac_infiltrate) in lib\$ac_z (= lib$ac_z)])
106 ], [:])
107 if test "${ac_cv_lib_z_infiltrate+set}" != set; then
108 AC_MSG_ERROR([ac_cv_lib_z_infiltrate not set])
109 fi
110 ]])
111
112
113 # AC_SEARCH_LIBS
114 # --------------
115 # Like AC_CHECK_LIBS, we use zlib here because we need the behavior to
116 # be consistent between the C and C++ compilers.
117 AT_CHECK_MACRO([AC_SEARCH_LIBS (needed)], [[
118 AC_CHECK_HEADER([zlib.h], [], [
119 AC_MSG_NOTICE([zlib not available, skipping test])
120 AS_EXIT(77)
121 ])
122
123 # Unlike AC_CHECK_LIBS, AC_SEARCH_LIBS sets $LIBS *even if*
124 # ACTION-IF-FOUND is given, so we need to reset it after each test.
125 ac_at_save_LIBS="$LIBS"
126
127 AC_SEARCH_LIBS([zlibVersion], [z], [:], [:])
128 if test x"$ac_cv_search_zlibVersion" != x-lz; then
129 AC_MSG_ERROR([wrong zlibVersion search result: $ac_cv_search_zlibVersion])
130 fi
131 LIBS="$ac_at_save_LIBS"
132
133 # No kidding, using variables was broken in 2.50 :(
134 ac_deflate=deflate
135 AC_SEARCH_LIBS([$ac_deflate], [z], [:], [:])
136 if test x"$ac_cv_search_deflate" != x-lz; then
137 AC_MSG_ERROR([wrong deflate search result: $ac_cv_search_deflate])
138 fi
139 LIBS="$ac_at_save_LIBS"
140
141 ac_z=z
142 AC_SEARCH_LIBS([deflateEnd], [$ac_z], [:], [:])
143 if test x"$ac_cv_search_deflateEnd" != x-lz; then
144 AC_MSG_ERROR([wrong deflateEnd search result: $ac_cv_search_deflateEnd])
145 fi
146 LIBS="$ac_at_save_LIBS"
147
148 ac_inflate=inflate
149 AC_SEARCH_LIBS([$ac_inflate], [$ac_z], [:], [:])
150 if test x"$ac_cv_search_inflate" != x-lz; then
151 AC_MSG_ERROR([wrong inflate search result: $ac_cv_search_inflate])
152 fi
153 LIBS="$ac_at_save_LIBS"
154
155 # Also test for symbols that don't (well, shouldn't) exist.
156 # These should still set their cache variables!
157 AC_SEARCH_LIBS([deflagrate], [z], [:], [:])
158 if test x"$ac_cv_search_deflagrate" != xno; then
159 AC_MSG_ERROR([wrong deflagrate search result: $ac_cv_search_deflagrate])
160 fi
161 LIBS="$ac_at_save_LIBS"
162
163 ac_defenestrate=defenestrate
164 AC_SEARCH_LIBS([$ac_defenestrate], [z], [:], [:])
165 if test x"$ac_cv_search_defenestrate" != xno; then
166 AC_MSG_ERROR([wrong defenestrate search result: $ac_cv_search_defenestrate])
167 fi
168 LIBS="$ac_at_save_LIBS"
169
170 AC_SEARCH_LIBS([defoliate], [$ac_z], [:], [:])
171 if test x"$ac_cv_search_defoliate" != xno; then
172 AC_MSG_ERROR([wrong defoliate search result: $ac_cv_search_defoliate])
173 fi
174 LIBS="$ac_at_save_LIBS"
175
176 ac_infiltrate=infiltrate
177 AC_SEARCH_LIBS([$ac_infiltrate], [$ac_z], [:], [:])
178 if test x"$ac_cv_search_infiltrate" != xno; then
179 AC_MSG_ERROR([wrong infiltrate search result: $ac_cv_search_infiltrate])
180 fi
181 LIBS="$ac_at_save_LIBS"
182 ]])
183
184
185 # AC_SEARCH_LIBS (none needed)
186 # ----------------------------
187 # This test doesn't need to be nearly as thorough as the above; its
188 # purpose is simply to ensure that when no library is needed,
189 # AC_SEARCH_LIBS really does produce "none needed" as its result.
190 AT_CHECK_MACRO([AC_SEARCH_LIBS (none needed)], [[
191 # No library should be required to link with printf, but we throw
192 # -lc in the search list so that it includes both libraries that
193 # don't exist and libraries that probably do.
194 AC_SEARCH_LIBS([printf], [oser c ust], [:], [:])
195
196 if test x"$ac_cv_search_printf" != "xnone required"; then
197 AC_MSG_ERROR([wrong printf search result: $ac_cv_search_printf])
198 fi
199 ]])
200
201
202 # AC_CHECK_DECLS
203 # --------------
204 # Check that it performs the correct actions:
205 AT_CHECK_MACRO([AC_CHECK_DECLS],
206 [[AC_CHECK_DECLS([yes, no, myenum, mystruct, myfunc, mymacro1, mymacro2],,,
207 [[extern int yes;
208 enum { myenum };
209 extern struct mystruct_s { int x[20]; } mystruct;
210 extern int myfunc (int);
211 #define mymacro1(arg) arg
212 #define mymacro2]])
213 # Ensure we can detect missing declarations of functions whose
214 # signature may be built into the compiler.
215 AC_CHECK_DECLS([memcpy, strchr, strerror],,, [[]])
216 # The difference in space-before-open-paren is intentional.
217 AC_CHECK_DECLS([basenam (char *), dirnam(char *),
218 moreargs (char, short, int, long, void *, char *, float, double)],,,
219 [[#ifdef __cplusplus
220 extern "C++" char *basenam (char *);
221 extern "C++" const char *basenam (const char *);
222 #else
223 extern char *basenam (const char *);
224 #endif
225 #ifdef __cplusplus
226 extern "C" {
227 #endif
228 extern int moreargs (char, short, int, long, void *,
229 char [], float, double);
230 #ifdef __cplusplus
231 }
232 #endif
233 ]])
234 AC_CHECK_DECL([declared (char *)],, [AS_EXIT([1])],
235 [[#ifdef __cplusplus
236 extern "C++" char *declared (char *);
237 extern "C++" const char *declared (const char *);
238 #else
239 extern char *declared (const char *);
240 #endif
241 ]])
242 AC_LANG_WERROR
243 AC_CHECK_DECL([undeclared (char *)], [AS_EXIT([1])],, [[]])
244 if test -z "$ac_[]_AC_LANG_ABBREV[]_werror_flag"; then
245 AC_MSG_ERROR([ac_]_AC_LANG_ABBREV[_werror_flag overwritten])
246 fi
247 ]],
248 [AT_CHECK_DEFINES(
249 [#define HAVE_DECL_BASENAM 1
250 #define HAVE_DECL_DIRNAM 0
251 #define HAVE_DECL_MEMCPY 0
252 #define HAVE_DECL_MOREARGS 1
253 #define HAVE_DECL_MYENUM 1
254 #define HAVE_DECL_MYFUNC 1
255 #define HAVE_DECL_MYMACRO1 1
256 #define HAVE_DECL_MYMACRO2 1
257 #define HAVE_DECL_MYSTRUCT 1
258 #define HAVE_DECL_NO 0
259 #define HAVE_DECL_STRCHR 0
260 #define HAVE_DECL_STRERROR 0
261 #define HAVE_DECL_YES 1
262 ])])
263
264
265 # AC_CHECK_FUNCS
266 # --------------
267 # Check that it performs the correct actions:
268 # Must define HAVE_PRINTF, but not HAVE_AUTOCONF_FTNIRP
269 AT_CHECK_MACRO([AC_CHECK_FUNCS],
270 [AC_CHECK_FUNCS(printf autoconf_ftnirp)],
271 [AT_CHECK_DEFINES(
272 [/* #undef HAVE_AUTOCONF_FTNIRP */
273 #define HAVE_PRINTF 1
274 ])])
275
276
277 # AC_REPLACE_FUNCS
278 # ----------------
279 # Check that it performs the correct actions: autoconf_ftnirp.c must
280 # be compiled, and must define HAVE_PRINTF, but not HAVE_AUTOCONF_FTNIRP
281 # FIXME: Maybe check the traces?
282 AT_SETUP([AC_REPLACE_FUNCS])
283
284 AT_DATA([config.in],
285 [@LIBOBJS@
286 ])
287
288 # AC_REPLACE_FUNCS has an AS_LITERAL_IF optimization; test both paths.
289 # Manual invocation of AH_TEMPLATE should only be necessary for functions
290 # whose names are hidden inside a shell variable at m4 expansion time.
291 AT_CONFIGURE_AC(
292 [[AC_CONFIG_FILES([config.libobjs:config.in])
293 AC_REPLACE_FUNCS([printf autoconf_ftnirp])
294 funcs='fprintf autoconf_ftnirpf'
295 AH_TEMPLATE([HAVE_FPRINTF], [])
296 AH_TEMPLATE([HAVE_AUTOCONF_FTNIRPF], [])
297 AC_REPLACE_FUNCS([\
298 $funcs \
299 fopen \
300 autoconf_nepof])
301 AS@&t@_UNSET([funcs])]])
302
303 AT_CHECK_AUTOCONF([], [], [],
304 [[configure.ac:9: warning: AC_REPLACE_FUNCS($funcs): you should use literals
305 functions.m4: AC_REPLACE_FUNCS is expanded from...
306 configure.ac:9: the top level
307 ]])
308 AT_CHECK_AUTOHEADER([], [
309 HAVE_AUTOCONF_FTNIRP
310 HAVE_AUTOCONF_FTNIRPF
311 HAVE_AUTOCONF_NEPOF
312 HAVE_FOPEN
313 HAVE_FPRINTF
314 HAVE_PRINTF
315 ])
316 AT_CHECK_CONFIGURE
317 AT_CHECK_ENV
318 AT_CHECK_DEFINES(
319 [/* #undef HAVE_AUTOCONF_FTNIRP */
320 /* #undef HAVE_AUTOCONF_FTNIRPF */
321 /* #undef HAVE_AUTOCONF_NEPOF */
322 #define HAVE_FOPEN 1
323 #define HAVE_FPRINTF 1
324 #define HAVE_PRINTF 1
325 ])
326
327 AT_CHECK([sed 's/ */ /g;s/^ //;s/ $//' config.libobjs | tr ' ' '
328 ' | sort], [],
329 [${LIBOBJDIR}autoconf_ftnirp$U.o
330 ${LIBOBJDIR}autoconf_ftnirpf$U.o
331 ${LIBOBJDIR}autoconf_nepof$U.o
332 ])
333
334 AT_CLEANUP
335
336
337 # AC_CHECK_HEADERS
338 # ----------------
339 # Check that it performs the correct actions:
340 # Must define HAVE_FLOAT_H, but not HAVE_AUTOCONF_IO_H.
341 AT_SETUP([AC_CHECK_HEADERS])
342
343 AT_DATA([autoconf_io.h],
344 [blah blah
345 ])
346
347 AT_CONFIGURE_AC([AC_CHECK_HEADERS([float.h autoconf_io.h])])
348 AT_CHECK_AUTOCONF
349 AT_CHECK_AUTOHEADER([], [
350 HAVE_AUTOCONF_IO_H
351 HAVE_FLOAT_H
352 HAVE_INTTYPES_H
353 HAVE_STDINT_H
354 HAVE_STDIO_H
355 HAVE_STDLIB_H
356 HAVE_STRINGS_H
357 HAVE_STRING_H
358 HAVE_SYS_STAT_H
359 HAVE_SYS_TYPES_H
360 HAVE_UNISTD_H
361 STDC_HEADERS
362 ])
363 AT_CHECK_CONFIGURE([CPPFLAGS=-I.])
364 AT_CHECK_ENV
365 AT_CHECK_DEFINES(
366 [/* #undef HAVE_AUTOCONF_IO_H */
367 #define HAVE_FLOAT_H 1
368 ])
369
370 AT_CLEANUP
371
372
373 # AC_CHECK_HEADERS_OLD
374 # --------------------
375 # Check that it performs the correct actions:
376 # Must not check prerequisites, hence define header2.h
377 AT_SETUP([AC_CHECK_HEADERS (preprocessor test)])
378
379 AT_DATA([header1.h],
380 [typedef int foo;
381 ])
382
383 AT_DATA([header2.h],
384 [typedef foo bar;
385 ])
386
387 AT_CONFIGURE_AC([[AC_CHECK_HEADERS([header2.h], [], [], [-])]])
388
389 AT_CHECK_AUTOCONF([], 0, [],
390 [[configure.ac:4: warning: Checking for headers with the preprocessor is
391 configure.ac:4: deprecated. Specify prerequisite code to AC_CHECK_HEADER
392 configure.ac:4: instead of using fourth argument '-'. (Many headers need
393 configure.ac:4: no prerequisites. If you truly need to test whether
394 configure.ac:4: something passes the preprocessor but not the compiler,
395 configure.ac:4: use AC_PREPROC_IFELSE.)
396 headers.m4: _AC_CHECK_HEADER_PREPROC is expanded from...
397 headers.m4: AC_CHECK_HEADER is expanded from...
398 headers.m4: AC_CHECK_HEADERS is expanded from...
399 configure.ac:4: the top level
400 ]])
401 AT_CHECK_AUTOHEADER([-W no-obsolete], [HAVE_HEADER2_H])
402 AT_CHECK_CONFIGURE([CPPFLAGS=-I.])
403 AT_CHECK_ENV
404 AT_CHECK_DEFINES(
405 [#define HAVE_HEADER2_H 1
406 ])
407
408 AT_CLEANUP
409
410
411 # AC_CHECK_HEADERS_NEW
412 # --------------------
413 # Check that it performs the correct actions:
414 # Must check prerequisites, hence define header2.h but not header3.h
415 AT_SETUP([AC_CHECK_HEADERS (compiler test)])
416
417 AT_DATA([header1.h],
418 [typedef int foo;
419 ])
420
421 AT_DATA([header2.h],
422 [typedef foo bar;
423 ])
424
425 AT_DATA([header3.h],
426 [typedef bar wow;
427 ])
428
429 AT_CONFIGURE_AC(
430 [AC_CHECK_HEADERS(header2.h header3.h, [], [], [[@%:@include "header1.h"]])])
431
432 AT_CHECK_AUTOCONF
433 AT_CHECK_AUTOHEADER([], [
434 HAVE_HEADER2_H
435 HAVE_HEADER3_H
436 ])
437 AT_CHECK_CONFIGURE([CPPFLAGS=-I.])
438 AT_CHECK_ENV
439 AT_CHECK_DEFINES(
440 [#define HAVE_HEADER2_H 1
441 /* #undef HAVE_HEADER3_H */
442 ])
443
444 AT_CLEANUP
445
446
447 # AC_CHECK_MEMBER
448 # ---------------
449 # Check that it performs the correct actions.
450 # Must define HAVE_STRUCT_YES_S_YES, but not HAVE_STRUCT_YES_S_NO.
451 AT_CHECK_MACRO([AC_CHECK_MEMBER],
452 [[AC_CHECK_MEMBER([struct yes_s.yes],
453 [AC_DEFINE([HAVE_STRUCT_YES_S_YES], [1],
454 [Define to 1 if 'yes' is a member of 'struct yes_s'.])],,
455 [struct sub { int x; };
456 struct yes_s { int yes; struct sub substruct; };])
457 AC_CHECK_MEMBER([struct yes_s.no],
458 [AC_DEFINE([HAVE_STRUCT_YES_S_NO], [1],
459 [Define to 1 if 'no' is a member of 'struct yes_s'.])],,
460 [struct sub { int x; };
461 struct yes_s { int yes; struct sub substruct; };])
462 AC_CHECK_MEMBER([struct yes_s.substruct],
463 [AC_DEFINE([HAVE_STRUCT_YES_S_SUBSTRUCT], [1],
464 [Define to 1 if 'substruct' is a member of 'struct yes_s'.])],,
465 [struct sub { int x; };
466 struct yes_s { int yes; struct sub substruct; };])]],
467 [AT_CHECK_DEFINES(
468 [/* #undef HAVE_STRUCT_YES_S_NO */
469 #define HAVE_STRUCT_YES_S_SUBSTRUCT 1
470 #define HAVE_STRUCT_YES_S_YES 1
471 ])])
472
473 # AC_CHECK_MEMBERS
474 # ----------------
475 # Check that it performs the correct actions.
476 # Must define HAVE_STRUCT_YES_S_YES, but not HAVE_STRUCT_YES_S_NO.
477 AT_CHECK_MACRO([AC_CHECK_MEMBERS],
478 [[AC_CHECK_MEMBERS([struct yes_s.yes, struct yes_s.no, struct yes_s.substruct],,,
479 [struct sub { int x; };
480 struct yes_s { int yes; struct sub substruct; };])]],
481 [AT_CHECK_DEFINES(
482 [/* #undef HAVE_STRUCT_YES_S_NO */
483 #define HAVE_STRUCT_YES_S_SUBSTRUCT 1
484 #define HAVE_STRUCT_YES_S_YES 1
485 ])
486 AT_CHECK([grep 'yes.*member of.*yes_s' config.h], [], [ignore])
487 ])
488
489
490 # AC_CHECK_ALIGNOF
491 # ----------------
492 AT_CHECK_MACRO([AC_CHECK_ALIGNOF],
493 [[AC_CHECK_ALIGNOF(char)
494 AC_CHECK_ALIGNOF(charchar,
495 [[#include <stddef.h>
496 #include <stdio.h>
497 typedef char charchar[2];]])
498 AC_CHECK_ALIGNOF(charcharchar)
499 ]],
500 [AT_CHECK_DEFINES(
501 [#define ALIGNOF_CHAR 1
502 #define ALIGNOF_CHARCHAR 1
503 #define ALIGNOF_CHARCHARCHAR 0
504 ])])
505
506
507 # AC_CHECK_ALIGNOF struct
508 # -----------------------
509 AT_CHECK_MACRO([AC_CHECK_ALIGNOF struct],
510 [[AC_CHECK_ALIGNOF([struct { char c; }])
511 AC_CHECK_ALIGNOF([struct nosuchstruct])
512 ]],
513 [AT_CHECK([[grep "#define ALIGNOF_STRUCT___CHAR_C___ [1-9]" config.h]],
514 0, ignore)
515 AT_CHECK([[grep "#define ALIGNOF_STRUCT_NOSUCHSTRUCT 0" config.h]],
516 0, ignore)
517 ])
518
519 # AC_CHECK_SIZEOF
520 # ---------------
521 AT_CHECK_MACRO([AC_CHECK_SIZEOF],
522 [[AC_CHECK_SIZEOF(char)
523 AC_CHECK_SIZEOF(charchar,,
524 [[#include <stdio.h>
525 typedef char charchar[2];]])
526 AC_CHECK_SIZEOF(charcharchar)
527 ]],
528 [AT_CHECK_DEFINES(
529 [#define SIZEOF_CHAR 1
530 #define SIZEOF_CHARCHAR 2
531 #define SIZEOF_CHARCHARCHAR 0
532 ])])
533
534
535 # AC_CHECK_SIZEOF struct
536 # ----------------------
537 AT_CHECK_MACRO([AC_CHECK_SIZEOF struct],
538 [[AC_C_CONST
539 AC_CHECK_SIZEOF([struct x], [], [struct x { char c; int x; };])
540 AC_CHECK_SIZEOF([const struct x], [], [struct x { const char *p; int x; };])
541 AC_CHECK_SIZEOF([struct nosuchstruct])
542 # Taken from autoconf.texi:Generic Compiler Characteristics.
543 AC_CHECK_SIZEOF([int *])
544 ]],
545 [AT_CHECK([[grep "#define SIZEOF_STRUCT_X [1-9]" config.h]],
546 0, ignore)
547 AT_CHECK([[grep "#define SIZEOF_CONST_STRUCT_X [1-9]" config.h]],
548 0, ignore)
549 AT_CHECK([[grep "#define SIZEOF_STRUCT_NOSUCHSTRUCT 0" config.h]],
550 0, ignore)
551 AT_CHECK([[grep "#define SIZEOF_INT_P [1-9]" config.h]],
552 0, ignore)
553 ])
554
555
556 # AC_CHECK_TYPES
557 # --------------
558 # Check that it performs the correct actions.
559 # Must define HAVE_STRUCT_YES_S, HAVE_INT, but not HAVE_STRUCT_NO_S.
560 # 'int' and 'struct yes_s' are both checked to test both the compiler
561 # builtin types, and defined types.
562 AT_CHECK_MACRO([AC_CHECK_TYPES],
563 [[AC_CHECK_TYPES([int, struct yes_s, struct no_s],,,
564 [struct yes_s { int yes ;} ;])]],
565 [AT_CHECK_DEFINES(
566 [#define HAVE_INT 1
567 /* #undef HAVE_STRUCT_NO_S */
568 #define HAVE_STRUCT_YES_S 1
569 ])])
570
571
572 # AC_CHECK_TYPES
573 # --------------
574 # Check that we properly dispatch properly to the old implementation
575 # or to the new one.
576 AT_SETUP([AC_CHECK_TYPES: backward compatibility])
577
578 AT_DATA([configure.ac],
579 [[AC_INIT
580 define([_AC_CHECK_TYPE_NEW], [NEW])
581 define([_AC_CHECK_TYPE_OLD], [OLD])
582 #(cut-from-here
583 AC_CHECK_TYPE(ptrdiff_t)
584 AC_CHECK_TYPE(ptrdiff_t, int)
585 AC_CHECK_TYPE(quad, long long int)
586 AC_CHECK_TYPE(table_42, [int[42]])
587 # Nice machine!
588 AC_CHECK_TYPE(uint8_t, uint65536_t)
589 AC_CHECK_TYPE(a,b,c,d)
590 #to-here)
591 AC_OUTPUT
592 ]])
593
594 AT_CHECK_AUTOCONF
595 AT_CHECK([[sed -e '/^#(cut-from-here/,/^#to-here)/!d' -e '/^#/d' configure]],
596 0,
597 [NEW
598 OLD
599 OLD
600 OLD
601 OLD
602 NEW
603 ])
604
605 AT_CLEANUP
606
607
608 # AC_CHECK_FILES
609 # --------------
610 # FIXME: To really test HAVE_AC_EXISTS2 and HAVE_AC_MISSING2 we need to
611 # open AH_TEMPLATE to 'configure.ac', which is not yet the case.
612 # Don't use AT_CHECK_MACRO for this one because AC_CHECK_FILES can't be
613 # used when cross compiling.
614
615 AT_CHECK_CONFIGURE_AC([AC_CHECK_FILES],
616 [[touch at-exists1 at-exists2
617 ac_exists2=at-exists2
618 ac_missing2=at-missing2
619 AC_CHECK_FILES(at-exists1 at-missing1 $ac_exists2 $ac_missing2)
620 rm at-exists1 at-exists2]],
621 [], [],
622 [AT_CHECK_DEFINES(
623 [#define HAVE_AT_EXISTS1 1
624 /* #undef HAVE_AT_MISSING1 */
625 ])])
626
627
628
629 ## ------------------------------ ##
630 ## AC_CHECK_PROG & AC_PATH_PROG. ##
631 ## ------------------------------ ##
632
633
634 # AT_CHECK_PROGS_PREPARE
635 # ----------------------
636 # Create a sub directory 'path' with 6 subdirs which all 7 contain
637 # an executable 'tool'. '6' contains a 'better' tool.
638 m4_define([AT_CHECK_PROGS_PREPARE],
639 [mkdir path
640
641 cat >path/tool <<\EOF
642 #! /bin/sh
643 exit 0
644 EOF
645 chmod +x path/tool
646
647 for i in 1 2 3 4 5 6
648 do
649 mkdir path/$i
650 cp path/tool path/$i
651 done
652 cp path/tool path/6/better])
653
654
655 # -------------------------------- #
656 # AC_CHECK_PROG & AC_CHECK_PROGS. #
657 # -------------------------------- #
658
659 AT_SETUP([AC_CHECK_PROG & AC_CHECK_PROGS])
660
661 AT_CHECK_PROGS_PREPARE
662
663 AT_DATA([configure.ac],
664 [[AC_INIT
665 pwd=`pwd`
666 p="1${PATH_SEPARATOR}2${PATH_SEPARATOR}3${PATH_SEPARATOR}4${PATH_SEPARATOR}5${PATH_SEPARATOR}6"
667 path=`echo $p | sed -e 's,\([[0-9]]\),'"$pwd"'/path/\1,g'`
668 fail=false
669
670 AC_CHECK_PROG(TOOL1, tool, found, not-found, $path)
671 test "$TOOL1" = found || fail=:
672
673 # Yes, the semantics of this macro is weird.
674 AC_CHECK_PROG(TOOL2, tool,, not-found, $path)
675 test "$TOOL2" = not-found || fail=:
676
677 AC_CHECK_PROG(TOOL3, tool, tool, not-found, $path, $pwd/path/1/tool)
678 test "$TOOL3" = "$pwd/path/2/tool" || fail=:
679
680 AC_CHECK_PROG(TOOL4, better, better, not-found, $path, $pwd/path/1/tool)
681 test "$TOOL4" = better || fail=:
682
683 # When a tool is not found, and no value is given for not-found,
684 # the variable is left empty.
685 AC_CHECK_PROGS(TOOL5, missing,, $path)
686 test -z "$TOOL5" || fail=:
687
688 AC_CHECK_PROGS(TOOL6, missing tool better,, $path)
689 test "$TOOL6" = tool || fail=:
690
691 $fail &&
692 AC_MSG_ERROR([[CHECK_PROG failed]])
693
694 AC_OUTPUT
695 ]])
696
697 AT_CHECK_AUTOCONF
698 AT_CHECK_CONFIGURE
699
700 AT_CLEANUP
701
702
703
704 ## ---------------- ##
705 ## AC_C_BIGENDIAN. ##
706 ## ---------------- ##
707
708 AT_SETUP([AC_C_BIGENDIAN])
709 AT_KEYWORDS([cross])
710
711 # Make sure that AC_C_BIGENDIAN behave the same whether we are
712 # cross-compiling or not.
713
714 _AT_CHECK_AC_MACRO(
715 [[AC_C_BIGENDIAN(
716 [ac_endian=big],
717 [ac_endian=little],
718 [ac_endian=unknown],
719 [ac_endian=universal])
720 echo $ac_endian > at-endian
721 ]])
722
723 rm -f config.hin # So that next run of autoheader is quiet.
724 _AT_CHECK_AC_MACRO(
725 [[# Force cross compiling.
726 cross_compiling=yes
727 ac_tool_warned=yes
728 AC_C_BIGENDIAN(
729 [ac_endian=big],
730 [ac_endian=little],
731 [ac_endian=unknown],
732 [ac_endian=universal])
733 ac_prevendian=`cat at-endian`
734 # Check that we have found the same result as in the previous run
735 # or unknown (because the cross-compiling check is allowed to fail;
736 # although it might be interesting to suppress this comparison, just
737 # to know on which system it fails if it ever does).
738 if test $ac_endian != $ac_prevendian && test $ac_endian != unknown; then
739 AC_MSG_ERROR([unexpected endianness: first run found '$ac_prevendian' but second run found '$ac_endian'])
740 fi
741 ]])
742
743 # Make sure AC_C_BIGENDIAN with no argument will create a config.h template
744 # containing "WORDS_BIGENDIAN".
745 AT_CONFIGURE_AC([[AC_C_BIGENDIAN]])
746 # --force is necessary, the computer might be too fast.
747 AT_CHECK_AUTOHEADER([--force], [
748 AC_APPLE_UNIVERSAL_BUILD
749 HAVE_INTTYPES_H
750 HAVE_STDINT_H
751 HAVE_STDIO_H
752 HAVE_STDLIB_H
753 HAVE_STRINGS_H
754 HAVE_STRING_H
755 HAVE_SYS_STAT_H
756 HAVE_SYS_TYPES_H
757 HAVE_UNISTD_H
758 STDC_HEADERS
759 WORDS_BIGENDIAN
760 ])
761 AT_CHECK([grep WORDS_BIGENDIAN config.hin], [], [ignore])
762
763 AT_CLEANUP
764
765
766 # ------------------------------ #
767 # AC_PATH_PROG & AC_PATH_PROGS. #
768 # ------------------------------ #
769
770 AT_SETUP([AC_PATH_PROG & AC_PATH_PROGS])
771
772 AT_CHECK_PROGS_PREPARE
773
774 AT_DATA([configure.ac],
775 [[AC_INIT
776 pwd=`pwd`
777 p="1${PATH_SEPARATOR}2${PATH_SEPARATOR}3${PATH_SEPARATOR}4${PATH_SEPARATOR}5${PATH_SEPARATOR}6"
778 path=`echo $p | sed -e 's,\([[0-9]]\),'"$pwd"'/path/\1,g'`
779 fail=false
780
781 AC_PATH_PROG(TOOL1, tool, not-found, $path)
782 test "$TOOL1" = "$pwd/path/1/tool" || fail=:
783
784 AC_PATH_PROG(TOOL2, better, not-found, $path)
785 test "$TOOL2" = "$pwd/path/6/better" || fail=:
786
787 # When a tool is not found, and no value is given for not-found,
788 # the variable is left empty.
789 AC_PATH_PROGS(TOOL3, missing,, $path)
790 test -z "$TOOL3" || fail=:
791
792 AC_PATH_PROGS(TOOL4, missing tool better,, $path)
793 test "$TOOL4" = "$pwd/path/1/tool" || fail=:
794
795 $fail &&
796 AC_MSG_ERROR([[PATH_PROG failed]])
797
798 AC_OUTPUT
799 ]])
800
801 AT_CHECK_AUTOCONF
802 AT_CHECK_CONFIGURE
803
804 AT_CLEANUP
805
806
807
808 # ----------------------------- #
809 # AC_PATH_PROGS_FEATURE_CHECK. #
810 # ----------------------------- #
811
812 AT_SETUP([AC_PATH_PROGS_FEATURE_CHECK])
813
814 # This test doesn't work if `pwd` contains white space
815 case `pwd` in
816 *\ * | *\ *) AT_CHECK([exit 77]) ;;
817 esac
818
819 AT_CHECK_PROGS_PREPARE
820
821 AT_DATA([configure.ac],
822 [[AC_INIT
823 pwd=`pwd`
824 p="1${PATH_SEPARATOR}2${PATH_SEPARATOR}3${PATH_SEPARATOR}4${PATH_SEPARATOR}5${PATH_SEPARATOR}6"
825 path=`echo $p | sed -e 's,\([[0-9]]\),'"$pwd"'/path/\1,g'`
826 fail=false
827
828 # Find first candidate and stop search
829 AC_PATH_PROGS_FEATURE_CHECK(TOOL1, [tool better],
830 [$ac_path_TOOL1 && ac_cv_path_TOOL1=$ac_path_TOOL1 ac_path_TOOL1_found=:],
831 fail=:, $path)
832 test -z "$TOOL1" || fail=:
833 test "$ac_cv_path_TOOL1" = "$pwd/path/1/tool" || fail=:
834
835 # Keep searching each candidate
836 AC_PATH_PROGS_FEATURE_CHECK(TOOL2, [tool better],
837 [$ac_path_TOOL2 && ac_cv_path_TOOL2=$ac_path_TOOL2],
838 fail=:, $path)
839 test "$ac_cv_path_TOOL2" = "$pwd/path/6/better" || fail=:
840
841 # Only accept better candidate
842 AC_PATH_PROGS_FEATURE_CHECK(TOOL3, [tool better],
843 [case "$ac_path_TOOL3" in #(
844 *better) ac_cv_path_TOOL3=$ac_path_TOOL3;;
845 esac],
846 fail=:, $path)
847 test "$ac_cv_path_TOOL3" = "$pwd/path/6/better" || fail=:
848
849 # When a tool is not found, and no action is given for not-found,
850 # the variable is left empty.
851 AC_PATH_PROGS_FEATURE_CHECK(TOOL4, missing,
852 [ac_cv_path_TOOL4=$ac_path_TOOL4], [], $path)
853 test -z "$ac_cv_path_TOOL4" || fail=:
854
855 # Test action when tool is not found
856 AC_PATH_PROGS_FEATURE_CHECK(TOOL5, missing, [],
857 [ac_cv_path_TOOL5='not found'], $path)
858 test "$ac_cv_path_TOOL5" = "not found" || fail=:
859
860 # Test that pre-set tool bypasses feature test
861 TOOL6=$pwd/path/6/better
862 AC_PATH_PROGS_FEATURE_CHECK(TOOL6, tool, fail=:, fail=:, $path)
863 test "$ac_cv_path_TOOL6" = "$pwd/path/6/better" || fail=:
864
865 # A blank pre-set does not bypass feature test
866 TOOL7=
867 AC_PATH_PROGS_FEATURE_CHECK(TOOL7, [tool better],
868 [$ac_path_TOOL7 && ac_cv_path_TOOL7=$ac_path_TOOL7 ac_path_TOOL7_found=:],
869 fail=:, $path)
870 test -z "$TOOL7" || fail=:
871 test "$ac_cv_path_TOOL7" = "$pwd/path/1/tool" || fail=:
872
873 $fail &&
874 AC_MSG_ERROR([[PATH_PROG failed]])
875
876 AC_OUTPUT
877 ]])
878
879 AT_CHECK_AUTOCONF
880 AT_CHECK_CONFIGURE
881
882 AT_CLEANUP
883
884
885
886
887 ## -------------- ##
888 ## AC_PATH_XTRA. ##
889 ## -------------- ##
890
891
892 AT_SETUP([AC_PATH_XTRA])
893
894 _AT_CHECK_AC_MACRO([AC_PATH_XTRA])
895
896 # Check X_DISPLAY_MISSING.
897 AT_CHECK_CONFIGURE([--without-x])
898 AT_CHECK_DEFINES(
899 [#define X_DISPLAY_MISSING 1
900 ])
901
902 AT_CLEANUP
903
904 ## -------------------------------------------------------------------- ##
905 ## AC_SYS_LARGEFILE, AC_SYS_YEAR2038, and AC_SYS_YEAR2038_RECOMMENDED. ##
906 ## -------------------------------------------------------------------- ##
907
908 AT_CHECK_MACRO([AC_SYS_LARGEFILE], [],
909 [AT_CHECK([./configure --help |
910 $EGREP -e '-(dis|en)able-(largefile|year2038)\>'],
911 [0],
912 [ --disable-largefile omit support for large files
913 --enable-year2038 support timestamps after 2038
914 ],
915 [])])
916
917 AT_CHECK_MACRO([AC_SYS_YEAR2038], [],
918 [AT_CHECK([./configure --help |
919 $EGREP -e '-(dis|en)able-(largefile|year2038)\>'],
920 [0],
921 [ --disable-largefile omit support for large files
922 --disable-year2038 don't support timestamps after 2038
923 ],
924 [])])
925
926 AT_CHECK_MACRO([AC_SYS_YEAR2038_RECOMMENDED], [],
927 [AT_CHECK([./configure --help |
928 $EGREP -e '-(dis|en)able-(largefile|year2038)\>'],
929 [0],
930 [ --disable-largefile omit support for large files
931 --disable-year2038 don't support timestamps after 2038
932 ],
933 [])],
934 [], [],
935 [dnl Skip this test on systems that do not support 64-bit time_t at
936 dnl all. AC_SYS_YEAR2038_RECOMMENDED will make configure fail on
937 dnl those systems. I'd like to make this be a test that it *does*
938 dnl make configure fail on those systems, but that would require
939 dnl adding features to AT_CHECK_MACRO.
940 AT_DATA([configure.ac],
941 [[AC_INIT
942 AC_PROG_CC
943 AC_SYS_YEAR2038
944 AC_COMPUTE_INT([sizeof_time_t], [sizeof(time_t)],
945 [@%:@include <time.h>],
946 [sizeof_time_t=0])
947 AS@&t@_IF([test $sizeof_time_t -lt 8],
948 [AC_MSG_FAILURE([could not widen time_t])])
949 AC_OUTPUT
950 ]])
951 AT_CHECK_AUTOCONF
952 AT_CAPTURE_FILE([config.log])
953 AT_CHECK([./configure $configure_options || exit 77], [0], [ignore], [])
954 ])
955
956
957 AT_SETUP([AC_SYS_YEAR2038_RECOMMENDED config.site override])
958
959 AT_CONFIGURE_AC([AC_SYS_YEAR2038_RECOMMENDED])
960
961 AT_CHECK_AUTOCONF
962 AT_CHECK_AUTOHEADER([], [ignore])
963
964 AT_DATA([config.site],
965 [enable_year2038=no
966 ])
967 CONFIG_SITE=`pwd`/config.site
968 export CONFIG_SITE
969
970 AT_CHECK_CONFIGURE
971 AT_CHECK_ENV
972
973 AT_CHECK([$EGREP -e '#undef _TIME_BITS' config.h], [0], [ignore])
974 AT_CHECK([$EGREP -e '#undef __MINGW_USE_VC2005_COMPAT' config.h], [0], [ignore])
975
976 AT_CLEANUP
977
978
979 AT_SETUP([AC_SYS_YEAR2038_RECOMMENDED environment override])
980
981 AT_CONFIGURE_AC([AC_SYS_YEAR2038_RECOMMENDED])
982
983 AT_CHECK_AUTOCONF
984 AT_CHECK_AUTOHEADER([], [ignore])
985
986 enable_year2038=no
987 export enable_year2038
988
989 AT_CHECK_CONFIGURE
990 AT_CHECK_ENV
991
992 AT_CHECK([$EGREP -e '#undef _TIME_BITS' config.h], [0], [ignore])
993 AT_CHECK([$EGREP -e '#undef __MINGW_USE_VC2005_COMPAT' config.h], [0], [ignore])
994
995 AT_CLEANUP
996
997 ## ------------------------------- ##
998 ## Obsolete non-updatable macros. ##
999 ## ------------------------------- ##
1000
1001
1002 AT_CHECK_MACRO([AC_SYS_RESTARTABLE_SYSCALLS], , ,[-W no-obsolete], [no-cross])
1003 AT_CHECK_MACRO([AC_FUNC_SETVBUF_REVERSED], , ,[-W no-obsolete])
1004 AT_CHECK_MACRO([AC_FUNC_WAIT3], , ,[-W no-obsolete], [no-cross])
1005
1006
1007 ## ------------------------------------- ##
1008 ## Obsolete macros requiring arguments. ##
1009 ## ------------------------------------- ##
1010
1011 # These all wrap the macro under test in an AC_CACHE_CHECK and an
1012 # AC_DEFINE so the full verification machinery of AT_CHECK_MACRO is
1013 # effective. Caution: AT_CHECK_AU_MACRO expects that after an
1014 # autoupdate run, a naive grep will not find the old macro name
1015 # anywhere in the updated configure.ac, not even as part of a
1016 # longer identifier. (But it's case sensitive.)
1017
1018 AT_CHECK_AU_MACRO([AC_TRY_CPP],
1019 [[AC_CACHE_CHECK([working ac_try_cpp], [ac_cv_ac_try_cpp_works], [
1020 AC_TRY_CPP([
1021 @%:@if 2 + 2 != 4
1022 @%:@error "SEVEN!" /* in memory of Stanislaw Lem */
1023 @%:@endif
1024 ], [ac_cv_ac_try_cpp_works=yes],
1025 [ac_cv_ac_try_cpp_works=no])
1026 ])
1027 if test $ac_cv_ac_try_cpp_works = yes; then
1028 AC_DEFINE([ac_try_cpp_works], [1], [label])
1029 fi
1030 ]])
1031
1032
1033 AT_CHECK_AU_MACRO([AC_TRY_COMPILE],
1034 [[AC_CACHE_CHECK([working ac_try_compile], [ac_cv_ac_try_compile_works], [
1035 AC_TRY_COMPILE([int variable;], [return variable;],
1036 [ac_cv_ac_try_compile_works=yes],
1037 [ac_cv_ac_try_compile_works=no])
1038 ])
1039 if test $ac_cv_ac_try_compile_works = yes; then
1040 AC_DEFINE([ac_try_compile_works], [1], [label])
1041 fi
1042 ]])
1043
1044
1045 AT_CHECK_AU_MACRO([AC_TRY_LINK],
1046 [[AC_CACHE_CHECK([working ac_try_link], [ac_cv_ac_try_link_works], [
1047 AC_TRY_LINK([@%:@include <stdio.h>], [return !feof(stdin);],
1048 [ac_cv_ac_try_link_works=yes],
1049 [ac_cv_ac_try_link_works=no])
1050 ])
1051 if test $ac_cv_ac_try_link_works = yes; then
1052 AC_DEFINE([ac_try_link_works], [1], [label])
1053 fi
1054 ]])
1055
1056
1057 # Oddly enough, AC_COMPILE_CHECK was shorthand for AC_MSG_CHECKING +
1058 # AC_TRY_LINK, not AC_TRY_COMPILE. When not cached, this will print
1059 # checking for working ac_compile_check... checking for feof ... yes
1060 # but whatever.
1061 AT_CHECK_AU_MACRO([AC_COMPILE_CHECK],
1062 [[AC_CACHE_CHECK([working ac_compile_check], [ac_cv_ac_compile_check_works], [
1063 AC_COMPILE_CHECK([feof], [@%:@include <stdio.h>], [return !feof(stdin);],
1064 [ac_cv_ac_compile_check_works=yes],
1065 [ac_cv_ac_compile_check_works=no])
1066 ])
1067 if test $ac_cv_ac_compile_check_works = yes; then
1068 AC_DEFINE([ac_compile_check_works], [1], [label])
1069 fi
1070 ]])
1071
1072
1073 AT_CHECK_AU_MACRO([AC_TRY_RUN],
1074 [[AC_CACHE_CHECK([working ac_try_run], [ac_cv_ac_try_run_works], [
1075 AC_TRY_RUN([int main(void) { return 0; }],
1076 [ac_cv_ac_try_run_works=yes],
1077 [ac_cv_ac_try_run_works=no],
1078 [ac_cv_ac_try_run_works=yes]) # cross compile, assume it works
1079 ])
1080 if test $ac_cv_ac_try_run_works = yes; then
1081 AC_DEFINE([ac_try_run_works], [1], [label])
1082 fi
1083 ]])
1084
1085
1086 # For purpose of this test, we don't care whether these libraries
1087 # exist (as long as the result is consistent between C and C++)
1088 # but we _do_ need to make sure that autoupdate correctly handles
1089 # AC_HAVE_LIBRARY's acceptance of "-lfoo" and "libfoo.a" as the
1090 # LIBRARY argument, where AC_CHECK_LIB only takes "foo".
1091 AT_CHECK_AU_MACRO([AC_HAVE_LIBRARY],
1092 [[AC_HAVE_LIBRARY([alice])
1093 AC_HAVE_LIBRARY([-lbob])
1094 AC_HAVE_LIBRARY([libmallory.a])
1095 ]])
1096
1097
1098 ## ----------------------------------------- ##
1099 ## Expansion of whitespace-separated lists. ##
1100 ## ----------------------------------------- ##
1101
1102
1103 m4_define([AT_CHECK_EXPANSION_IN_FUNCS],
1104 [AT_SETUP([Macro expansion in $1]m4_if([$2],[literal],[],[ (literal)]))
1105
1106 AT_CONFIGURE_AC([[
1107 m4@&t@_define([fn_bar],[fn_quux])
1108 $1([dn@&t@l
1109 fn_foo dn@&t@l
1110 fn_nocomment
1111 fn_bar dn@&t@l Ordinary comment
1112 fn_blurf dn@&t@l Apos'trophed comment
1113 ])
1114 ]])
1115 AT_CHECK_AUTOCONF([], [0], [],
1116 [configure.ac:6: warning: whitespace-separated list contains macros;
1117 configure.ac:6: in a future version of Autoconf they will not be expanded
1118 configure.ac:6: note: 'dn@&t@l' is a macro
1119 functions.m4: $1 is expanded from...
1120 configure.ac:6: the top level
1121 ])
1122 AT_CHECK_AUTOHEADER([-W no-obsolete], [
1123 HAVE_FN_BLURF
1124 HAVE_FN_FOO
1125 HAVE_FN_NOCOMMENT
1126 HAVE_FN_QUUX
1127 ])
1128 AT_CHECK_CONFIGURE
1129 AT_CLEANUP
1130
1131 m4_if([$2], [literal], [], [
1132 AT_SETUP([Macro expansion in $1 (variable)])
1133
1134 AT_CONFIGURE_AC([[
1135 m4@&t@_define([fn_bar],[fn_quux])
1136 fns="fn_foo" _AH_CHECK_FUNC([fn_foo])
1137 fns="$fns fn_nocomment" _AH_CHECK_FUNC([fn_nocomment])
1138 $1([dn@&t@l
1139 $[]fns
1140 fn_bar dn@&t@l Ordinary comment
1141 fn_blurf dn@&t@l Apos'trophed comment
1142 ])
1143 ]])
1144 AT_CHECK_AUTOCONF([], [0], [],
1145 [configure.ac:8: warning: whitespace-separated list contains macros;
1146 configure.ac:8: in a future version of Autoconf they will not be expanded
1147 configure.ac:8: note: 'dn@&t@l' is a macro
1148 functions.m4: $1 is expanded from...
1149 configure.ac:8: the top level
1150 configure.ac:8: warning: $1($fns): you should use literals
1151 functions.m4: $1 is expanded from...
1152 configure.ac:8: the top level
1153 ])
1154 AT_CHECK_AUTOHEADER([-W no-obsolete], [
1155 HAVE_FN_BLURF
1156 HAVE_FN_FOO
1157 HAVE_FN_NOCOMMENT
1158 HAVE_FN_QUUX
1159 ])
1160 AT_CHECK_CONFIGURE
1161 AT_CLEANUP
1162 ])])
1163
1164 m4_define([AT_CHECK_EXPANSION_IN_HEADERS],
1165 [AT_SETUP([Macro expansion in $1]m4_if([$2],[literal],[],[ (literal)]))
1166
1167 AT_CONFIGURE_AC([[
1168 m4@&t@_define([bar],[quux])
1169 $1([dn@&t@l
1170 foo.h dn@&t@l
1171 nocomment.h
1172 bar.h dn@&t@l Ordinary comment
1173 blurf.h dn@&t@l Apos'trophed comment
1174 ])
1175 ]])
1176 AT_CHECK_AUTOCONF([], [0], [],
1177 [configure.ac:6: warning: whitespace-separated list contains macros;
1178 configure.ac:6: in a future version of Autoconf they will not be expanded
1179 configure.ac:6: note: 'dn@&t@l' is a macro
1180 headers.m4: $1 is expanded from...
1181 configure.ac:6: the top level
1182 ])
1183 AT_CHECK_AUTOHEADER([-W no-obsolete], [
1184 HAVE_BLURF_H
1185 HAVE_FOO_H
1186 HAVE_INTTYPES_H
1187 HAVE_NOCOMMENT_H
1188 HAVE_QUUX_H
1189 HAVE_STDINT_H
1190 HAVE_STDIO_H
1191 HAVE_STDLIB_H
1192 HAVE_STRINGS_H
1193 HAVE_STRING_H
1194 HAVE_SYS_STAT_H
1195 HAVE_SYS_TYPES_H
1196 HAVE_UNISTD_H
1197 STDC_HEADERS
1198 ])
1199 AT_CHECK_CONFIGURE
1200 AT_CLEANUP
1201
1202 m4_if([$2], [literal], [], [
1203 AT_SETUP([Macro expansion in $1 (variable)])
1204
1205 AT_CONFIGURE_AC([[
1206 m4@&t@_define([bar],[quux])
1207 hs="foo.h" _AH_CHECK_HEADER([foo.h])
1208 hs="$hs nocomment.h" _AH_CHECK_HEADER([nocomment.h])
1209 $1([dn@&t@l
1210 $[]hs
1211 bar.h dn@&t@l Ordinary comment
1212 blurf.h dn@&t@l Apos'trophed comment
1213 ])
1214 ]])
1215 AT_CHECK_AUTOCONF([], [0], [],
1216 [configure.ac:8: warning: whitespace-separated list contains macros;
1217 configure.ac:8: in a future version of Autoconf they will not be expanded
1218 configure.ac:8: note: 'dn@&t@l' is a macro
1219 headers.m4: $1 is expanded from...
1220 configure.ac:8: the top level
1221 configure.ac:8: warning: $1($hs): you should use literals
1222 headers.m4: $1 is expanded from...
1223 configure.ac:8: the top level
1224 ])
1225 AT_CHECK_AUTOHEADER([-W no-obsolete], [
1226 HAVE_BLURF_H
1227 HAVE_FOO_H
1228 HAVE_INTTYPES_H
1229 HAVE_NOCOMMENT_H
1230 HAVE_QUUX_H
1231 HAVE_STDINT_H
1232 HAVE_STDIO_H
1233 HAVE_STDLIB_H
1234 HAVE_STRINGS_H
1235 HAVE_STRING_H
1236 HAVE_SYS_STAT_H
1237 HAVE_SYS_TYPES_H
1238 HAVE_UNISTD_H
1239 STDC_HEADERS
1240 ])
1241 AT_CHECK_CONFIGURE
1242 AT_CLEANUP
1243 ])])
1244
1245 AT_CHECK_EXPANSION_IN_FUNCS([AC_CHECK_FUNCS])
1246 AT_CHECK_EXPANSION_IN_FUNCS([AC_CHECK_FUNCS_ONCE], [literal])
1247 AT_CHECK_EXPANSION_IN_FUNCS([AC_REPLACE_FUNCS])
1248
1249 AT_CHECK_EXPANSION_IN_HEADERS([AC_CHECK_HEADERS])
1250 AT_CHECK_EXPANSION_IN_HEADERS([AC_CHECK_HEADERS_ONCE], [literal])
1251
1252 AT_SETUP([Macro expansion in AC_CHECK_FILES])
1253
1254 AT_CONFIGURE_AC([[
1255 m4@&t@_define([f_bar], [f_quux])
1256 AC_CHECK_FILES([dn@&t@l
1257 /nonex/f_foo
1258 /nonex/f_bar dn@&t@l Ordinary comment
1259 /nonex/f_blurf dn@&t@l Apos'trophed comment
1260 ])
1261 ]])
1262 AT_CHECK_AUTOCONF([], [0], [],
1263 [configure.ac:6: warning: whitespace-separated list contains macros;
1264 configure.ac:6: in a future version of Autoconf they will not be expanded
1265 configure.ac:6: note: 'dn@&t@l' is a macro
1266 general.m4: AC_CHECK_FILES is expanded from...
1267 configure.ac:6: the top level
1268 ])
1269 AT_CHECK_AUTOHEADER([-W no-obsolete], [
1270 HAVE__NONEX_F_BLURF
1271 HAVE__NONEX_F_FOO
1272 HAVE__NONEX_F_QUUX
1273 ])
1274
1275 AT_CHECK_CONFIGURE
1276 AT_CLEANUP
1277
1278 AT_SETUP([Macro expansion in AC_CONFIG_MACRO_DIRS])
1279
1280 AT_CONFIGURE_AC([[
1281 m4@&t@_define([d_bar], [d_quux])
1282 AC_CONFIG_MACRO_DIRS([dn@&t@l
1283 d_foo
1284 d_bar dn@&t@l Ordinary comment
1285 d_blurf dn@&t@l Apos'trophed comment
1286 ])
1287 ]])
1288 AT_CHECK_AUTOCONF([-t AC_CONFIG_MACRO_DIR_TRACE], [0],
1289 [configure.ac:6:AC_CONFIG_MACRO_DIR_TRACE:d_foo
1290 configure.ac:6:AC_CONFIG_MACRO_DIR_TRACE:d_quux
1291 configure.ac:6:AC_CONFIG_MACRO_DIR_TRACE:d_blurf
1292 ],
1293 [configure.ac:6: warning: whitespace-separated list contains macros;
1294 configure.ac:6: in a future version of Autoconf they will not be expanded
1295 configure.ac:6: note: 'dn@&t@l' is a macro
1296 general.m4: AC_CONFIG_MACRO_DIRS is expanded from...
1297 configure.ac:6: the top level
1298 ])
1299
1300 AT_CLEANUP
1301
1302 AT_SETUP([Macro expansion in AC_CONFIG_SUBDIRS])
1303
1304 (set -ex
1305 for d in d_foo d_bar d_blurf d_quux; do
1306 mkdir $d
1307 printf '%s\n%s\n' '#! /bin/sh' "echo entered $d/configure" \
1308 > $d/configure
1309 chmod +x $d/configure
1310 done)
1311
1312 AT_CONFIGURE_AC([[
1313 m4@&t@_define([d_bar], [d_quux])
1314 AC_CONFIG_SUBDIRS([dn@&t@l
1315 d_foo
1316 d_bar dn@&t@l Ordinary comment
1317 d_blurf dn@&t@l Apos'trophed comment
1318 ])
1319 ]])
1320 AT_CHECK_AUTOCONF([], [0], [],
1321 [configure.ac:6: warning: whitespace-separated list contains macros;
1322 configure.ac:6: in a future version of Autoconf they will not be expanded
1323 configure.ac:6: note: 'dn@&t@l' is a macro
1324 status.m4: AC_CONFIG_SUBDIRS is expanded from...
1325 configure.ac:6: the top level
1326 ])
1327 AT_CHECK_AUTOHEADER([-W no-obsolete])
1328 AT_CHECK_CONFIGURE([], [0], [stdout])
1329 AT_CHECK([grep '^entered' stdout], [0],
1330 [[entered d_foo/configure
1331 entered d_quux/configure
1332 entered d_blurf/configure
1333 ]])
1334
1335 AT_CLEANUP
1336
1337
1338 ## ------------------------------------- ##
1339 ## AC_PROG_LEX with and without yywrap. ##
1340 ## ------------------------------------- ##
1341
1342 # We don't currently have a good way of verifying that each mode
1343 # does what it's supposed to, but we can at least put them through
1344 # their paces as much as the autogenerated AT_CHECK_MACRO invocation
1345 # used to, back when AC_PROG_LEX took no arguments.
1346
1347 AT_CHECK_MACRO([AC_PROG_LEX with noyywrap], [AC_PROG_LEX([noyywrap])])
1348
1349 AT_CHECK_MACRO([AC_PROG_LEX with yywrap], [AC_PROG_LEX([yywrap])],
1350 [], [], [],
1351 [# Skip this test on OSes where there is no -ll nor -lfl.
1352
1353 AT_DATA([configure.ac],
1354 [[AC_INIT([lexlib-probe], [1])
1355 AC_PROG_CC
1356 AC_SEARCH_LIBS([yywrap], [l fl], [], [AS_EXIT(77)])
1357 AC_OUTPUT
1358 ]])
1359 AT_CHECK_AUTOCONF
1360 AT_CHECK_CONFIGURE
1361 ])
1362
1363
1364 AT_SETUP([AC_PROG_LEX in legacy mode])
1365
1366 AT_CONFIGURE_AC([[AC_PROG_LEX]])
1367 AT_CHECK_AUTOHEADER([], [ignore])
1368 AT_CHECK_AUTOCONF([], [], [],
1369 [[configure.ac:4: warning: AC_PROG_LEX without either yywrap or noyywrap is obsolete
1370 programs.m4: _AC_PROG_LEX is expanded from...
1371 programs.m4: AC_PROG_LEX is expanded from...
1372 configure.ac:4: the top level
1373 ]])
1374
1375 AT_CHECK_CONFIGURE
1376
1377 AT_CLEANUP
1378
1379
1380 ## ---------------------------------- ##
1381 ## Invalid arguments to AC_PROG_LEX. ##
1382 ## ---------------------------------- ##
1383
1384 AT_SETUP([Invalid arguments to AC_PROG_LEX])
1385
1386 AT_CONFIGURE_AC(
1387 [[AC_PROG_LEX([nonsense])
1388 ]])
1389 AT_CHECK_AUTOCONF([], [1], [],
1390 [[configure.ac:4: error: AC_PROG_LEX: unrecognized argument: nonsense
1391 programs.m4: _AC_PROG_LEX is expanded from...
1392 programs.m4: AC_PROG_LEX is expanded from...
1393 configure.ac:4: the top level
1394 autom4te: error: m4 failed with exit status: 1
1395 ]])
1396
1397 AT_CONFIGURE_AC(
1398 [[AC_PROG_LEX([too],[many])
1399 ]])
1400 AT_CHECK_AUTOCONF([], [1], [],
1401 [[configure.ac:4: error: too many arguments to AC_PROG_LEX
1402 programs.m4: AC_PROG_LEX is expanded from...
1403 configure.ac:4: the top level
1404 autom4te: error: m4 failed with exit status: 1
1405 ]])
1406
1407 AT_CONFIGURE_AC(
1408 [[AC_PROG_LEX([yywrap noyywrap])
1409 ]])
1410 AT_CHECK_AUTOCONF([], [1], [],
1411 [[configure.ac:4: error: AC_PROG_LEX: yywrap and noyywrap are mutually exclusive
1412 programs.m4: _AC_PROG_LEX is expanded from...
1413 programs.m4: AC_PROG_LEX is expanded from...
1414 configure.ac:4: the top level
1415 autom4te: error: m4 failed with exit status: 1
1416 ]])
1417
1418 AT_CONFIGURE_AC(
1419 [[AC_PROG_LEX([noyywrap yywrap])
1420 ]])
1421 AT_CHECK_AUTOCONF([], [1], [],
1422 [[configure.ac:4: error: AC_PROG_LEX: yywrap and noyywrap are mutually exclusive
1423 programs.m4: _AC_PROG_LEX is expanded from...
1424 programs.m4: AC_PROG_LEX is expanded from...
1425 configure.ac:4: the top level
1426 autom4te: error: m4 failed with exit status: 1
1427 ]])
1428
1429 AT_CONFIGURE_AC(
1430 [[AC_PROG_LEX([yywrap nonsense])
1431 ]])
1432 AT_CHECK_AUTOCONF([], [1], [],
1433 [[configure.ac:4: error: AC_PROG_LEX: unrecognized argument: yywrap nonsense
1434 programs.m4: _AC_PROG_LEX is expanded from...
1435 programs.m4: AC_PROG_LEX is expanded from...
1436 configure.ac:4: the top level
1437 autom4te: error: m4 failed with exit status: 1
1438 ]])
1439
1440 AT_CONFIGURE_AC(
1441 [[AC_PROG_LEX([nonsense noyywrap])
1442 ]])
1443 AT_CHECK_AUTOCONF([], [1], [],
1444 [[configure.ac:4: error: AC_PROG_LEX: unrecognized argument: nonsense noyywrap
1445 programs.m4: _AC_PROG_LEX is expanded from...
1446 programs.m4: AC_PROG_LEX is expanded from...
1447 configure.ac:4: the top level
1448 autom4te: error: m4 failed with exit status: 1
1449 ]])
1450
1451 # A double invocation with matching arguments should be accepted
1452 # without complaint. FIXME: verify that it runs the test only once.
1453 AT_CONFIGURE_AC(
1454 [[AC_PROG_LEX([noyywrap])
1455 AC_PROG_LEX([noyywrap])
1456 ]])
1457 AT_CHECK_AUTOCONF
1458
1459 # A double invocation with matching arguments should trigger a warning.
1460 AT_CONFIGURE_AC(
1461 [[AC_PROG_LEX([yywrap])
1462 AC_PROG_LEX([noyywrap])
1463 ]])
1464 AT_CHECK_AUTOCONF([], [0], [],
1465 [[configure.ac:5: warning: AC_PROG_LEX used twice with mismatched options
1466 programs.m4: _AC_PROG_LEX is expanded from...
1467 programs.m4: AC_PROG_LEX is expanded from...
1468 configure.ac:5: the top level
1469 ]])
1470
1471 AT_CLEANUP