3 AT_BANNER([Executables (autoheader, autoupdate...).])
5 # Copyright (C) 2000, 2001, 2003, 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
23 ## ----------------------------- ##
24 ## Syntax of the shell scripts. ##
25 ## ----------------------------- ##
27 # We use `/bin/sh -n script' to check that there are no syntax errors
28 # in the scripts. Although incredible, there are /bin/sh that go into
29 # endless loops with `-n', e.g., SunOS's:
32 # SunOS ondine 4.1.3 2 sun4m unknown
39 # $ time sh endless.sh
40 # sh endless.sh 0,02s user 0,03s system 78% cpu 0,064 total
41 # $ time sh -nx endless.sh
42 # ^Csh -nx endless.sh 3,67s user 0,03s system 63% cpu 5,868 total
44 # So before using `/bin/sh -n' to check our scripts, we first check
45 # that `/bin/sh -n' is not broken to death.
47 AT_SETUP([Syntax of the shell scripts])
49 # Specify the absolute name of the tool, as some shells don't honor PATH when
52 AT_CHECK_SHELL_SYNTAX([$abs_top_builddir/bin/autoconf], exit 77)
53 AT_CHECK_SHELL_SYNTAX([$abs_top_builddir/tests/autoconf], exit 77)
54 AT_CHECK_SHELL_SYNTAX([$abs_top_builddir/tests/testsuite], exit 77)
56 # These are not built, they are in the src tree.
57 AT_CHECK_SHELL_SYNTAX([$abs_top_srcdir/config/install-sh], exit 77)
58 AT_CHECK_SHELL_SYNTAX([$abs_top_srcdir/config/mkinstalldirs], exit 77)
59 AT_CHECK_SHELL_SYNTAX([$abs_top_srcdir/config/missing], exit 77)
66 ## ---------------------------- ##
67 ## Syntax of the Perl scripts. ##
68 ## ---------------------------- ##
70 AT_SETUP([Syntax of the Perl scripts])
72 AT_CHECK_PERL_SYNTAX([autoheader])
73 AT_CHECK_PERL_SYNTAX([autom4te])
74 AT_CHECK_PERL_SYNTAX([autoreconf])
75 AT_CHECK_PERL_SYNTAX([autoscan])
76 AT_CHECK_PERL_SYNTAX([autoupdate])
77 AT_CHECK_PERL_SYNTAX([ifnames])
84 ## ------------------ ##
85 ## autom4te's cache. ##
86 ## ------------------ ##
88 AT_SETUP([autom4te cache])
90 AT_DATA_M4SUGAR([[script.4s]],
98 # We moved a file: it should fail
101 AT_CHECK_M4SUGAR([], [1], [],
102 [m4: script.4s: 1: Cannot open foo: No such file or directory
103 autom4te: m4 failed with exit status: 1
106 # But if we change the main file, then we should no longer complain of
108 AT_DATA_M4SUGAR([[script.4s]],
109 [[m4_include([sub/foo])
118 ## ------------------ ##
119 ## autoconf --trace. ##
120 ## ------------------ ##
123 # autoconf --trace: user macros
124 # -----------------------------
125 AT_SETUP([autoconf --trace: user macros])
127 AT_DATA([configure.ac],
128 [[m4_define([active], [ACTIVE])
129 m4_define([TRACE1], [TRACE2(m4_shift($@))])
130 m4_define([TRACE2], [[$2], $1])
136 # With arguments, single line.
137 TRACE1(foo, @bar, @baz)
138 TRACE1(foo, TRACE1(bar, baz))
139 TRACE1(foo, active, baz)
140 TRACE1(foo, [active], TRACE1(active, [active]))
142 # With arguments, multiple lines.
150 AT_CHECK_AUTOCONF([-t TRACE1 -t TRACE2], 0,
151 [[configure.ac:6:TRACE1:
152 configure.ac:6:TRACE2:
153 configure.ac:7:TRACE2:
154 configure.ac:10:TRACE1:foo:@bar:@baz
155 configure.ac:10:TRACE2:@bar:@baz
156 configure.ac:11:TRACE1:bar:baz
157 configure.ac:11:TRACE2:baz
158 configure.ac:11:TRACE1:foo::baz
159 configure.ac:11:TRACE2::baz
160 configure.ac:12:TRACE1:foo:ACTIVE:baz
161 configure.ac:12:TRACE2:ACTIVE:baz
162 configure.ac:13:TRACE1:ACTIVE:active
163 configure.ac:13:TRACE2:active
164 configure.ac:13:TRACE1:foo:active::ACTIVE
165 configure.ac:13:TRACE2:active::ACTIVE
166 configure.ac:19:TRACE1:foo bar:bar foo
167 configure.ac:19:TRACE2:bar foo
170 # Several line requests.
171 AT_CHECK_AUTOCONF([[-t TRACE1:'
172 [$1], [$2], [$3].']], 0,
176 [foo], [@bar], [@baz].
182 [foo], [ACTIVE], [baz].
184 [ACTIVE], [active], [].
194 AT_CHECK_AUTOCONF([-t TRACE2:'${)===(}@'], 0,
202 [active])===([])===([ACTIVE]
210 # autoconf --trace: builtins
211 # --------------------------
212 AT_SETUP([autoconf --trace: builtins])
214 AT_DATA([configure.ac],
215 [[define([active], [ACTIVE])
218 AT_CHECK_AUTOCONF([[-t define | sed -n '$p']],
220 [[configure.ac:1:define:active:ACTIVE
223 # FIXME: Without `$1' the following test dies. Groumphf, once again to
224 # dive into obscure feature interaction...
225 # Note that using `-i' means we need the *.m4 files, not the *.m4f files,
226 # hence we need srcdir, not builddir.
227 AT_CHECK_AUTOCONF([[-t define:'$1' -i| sed -n '$p']],
236 ## ---------------------------- ##
237 ## autoconf: forbidden tokens. ##
238 ## ---------------------------- ##
241 # autoconf: forbidden tokens, basic
242 # ---------------------------------
243 AT_SETUP([autoconf: forbidden tokens, basic])
245 AT_DATA_M4SH([configure.ac],
254 AT_DATA_M4SH([experr],
255 [[configure.ac:2: error: possibly undefined macro: m4_foo
256 If this token and others are legitimate, please use m4_pattern_allow.
257 See the Autoconf documentation.
258 configure.ac:3: error: possibly undefined macro: _m4_bar
259 configure.ac:4: error: possibly undefined macro: AS_FOO
260 configure.ac:5: error: possibly undefined macro: _AS_BAR
261 configure.ac:6: error: possibly undefined macro: dnl
264 AT_CHECK_AUTOCONF([], 1, [], experr)
269 # autoconf: forbidden tokens, exceptions
270 # --------------------------------------
271 AT_SETUP([autoconf: forbidden tokens, exceptions])
273 AT_DATA_M4SH([configure.ac],
276 # This is allowed in spite of the name.
277 # It is on purpose that we check the case where there are several
278 # tokens on the same line.
279 m4_pattern_allow([^AS_ALLOWED$])
280 NOT_AS_ALLOWED AS_ALLOWED AS_ALLOWED_NOT
283 m4_pattern_forbid([^FORBIDDEN$])
284 NOT_FORBIDDEN FORBIDDEN FORBIDDEN_NOT
286 # Test Autoconf's patterns.
287 AS_THIS_IS_INVALID and _AS_THIS_IS_INVALID_TOO
288 BUT_AZ_THIS_IS_NOT ALTHOUGH_AS_THIS_IS
289 # This is legal, although there is `AS_DEFINE' in there.
291 # AS_THIS_IS_A_COMMENT so just shut up.
292 It would be very bad if Autoconf forgot to expand [AS_]INIT!
295 AT_DATA_M4SH([experr],
296 [[configure.ac:1: error: possibly undefined macro: AS_INIT
297 If this token and others are legitimate, please use m4_pattern_allow.
298 See the Autoconf documentation.
299 configure.ac:7: error: possibly undefined macro: AS_ALLOWED_NOT
300 configure.ac:10: error: possibly undefined macro: FORBIDDEN
301 configure.ac:14: error: possibly undefined macro: AS_THIS_IS_INVALID
302 configure.ac:14: error: possibly undefined macro: _AS_THIS_IS_INVALID_TOO
305 AT_CHECK_AUTOCONF([], 1, [], [experr])
322 #if !defined(DEF3) && defined(DEF4) /* but not defined(DEF5) */
329 #if (VAL1*VAL2)==VAL3+VAL4 /* Not VAL5 !!! */
337 AT_CHECK([ifnames iftest1.c iftest2.c], 0,
347 VAL1 iftest1.c iftest2.c
361 # autoheader is intensively used in its modern form throughout this
362 # test suite. But we also have to check that acconfig.h still works.
363 # autoheader uses autoconf --trace, so traces first.
365 AT_SETUP([autoheader])
367 AT_DATA([acconfig.h],
368 [[/* Define this to whatever you want. */
373 # 1. Check that `acconfig.h' is still honored.
374 AT_DATA([configure.ac],
376 AC_CONFIG_HEADERS(config.h:config.hin)
377 AC_DEFINE(this, "whatever you want.")
380 AT_CHECK_AUTOHEADER([], [], [], [ignore])
381 AT_CHECK([cat config.hin], 0,
382 [[/* config.hin. Generated from configure.ac by autoheader. */
383 /* Define this to whatever you want. */
386 /* Define to the address where bug reports for this package should be sent. */
387 #undef PACKAGE_BUGREPORT
389 /* Define to the full name of this package. */
392 /* Define to the full name and version of this package. */
393 #undef PACKAGE_STRING
395 /* Define to the one symbol short name of this package. */
396 #undef PACKAGE_TARNAME
398 /* Define to the version of this package. */
399 #undef PACKAGE_VERSION
403 # 2. Check that missing templates are a fatal error.
404 AT_DATA([configure.ac],
406 AC_CONFIG_HEADERS(config.h:config.hin)
407 AC_DEFINE(that, "whatever you want.")
410 # The test suite goes too fast for the cache time stamps...
412 AT_CHECK_AUTOHEADER([--force], [1], [], [ignore])
415 # 3. Check TOP and BOTTOM.
416 AT_DATA([acconfig.h],
417 [[/* Top from acconfig.h. */
419 /* Middle from acconfig.h. */
421 /* Bottom from acconfig.h. */
424 AT_DATA([configure.ac],
426 AC_CONFIG_HEADERS(config.h:config.hin)
427 AH_TOP([Top1 from configure.ac.])
428 AH_TOP([Top2 from configure.ac.])
429 AH_TOP([The Cat in a h@t.])
430 AH_VERBATIM([Middle], [Middle from configure.ac.])
431 AH_VERBATIM([Mouse], [The Mouse in a h@t.])
432 AH_BOTTOM([Bottom1 from configure.ac.])
433 AH_BOTTOM([Bottom2 from configure.ac.])
434 AH_BOTTOM([The Dog in a h@t.])
436 AC_DEFINE([ANT], [@], [The Ant in a h@t.])
440 # Yes, that's right: the `middle' part of `acconfig.h' is still before
441 # the AH_TOP part. But so what, you're not supposed to use the two
443 # Ignore STDERR which is the longuish complaint against autoheader junk
445 AT_CHECK_AUTOHEADER([--force], [], [], [ignore])
446 AT_CHECK([cat config.hin], 0,
447 [[/* config.hin. Generated from configure.ac by autoheader. */
448 /* Top from acconfig.h. */
449 /* Middle from acconfig.h. */
451 Top1 from configure.ac.
453 Top2 from configure.ac.
457 /* The Ant in a h@t. */
460 Middle from configure.ac.
464 /* Define to the address where bug reports for this package should be sent. */
465 #undef PACKAGE_BUGREPORT
467 /* Define to the full name of this package. */
470 /* Define to the full name and version of this package. */
471 #undef PACKAGE_STRING
473 /* Define to the one symbol short name of this package. */
474 #undef PACKAGE_TARNAME
476 /* Define to the version of this package. */
477 #undef PACKAGE_VERSION
479 Bottom1 from configure.ac.
481 Bottom2 from configure.ac.
484 /* Bottom from acconfig.h. */
496 # Check that AC_CANONICAL_SYSTEM and AC_OUTPUT are properly updated.
497 AT_SETUP([autoupdate])
499 AT_DATA([configure.ac],
502 # The doc says 27 is a valid fubar.
504 AC_OUTPUT(Makefile, echo $fubar, fubar=$fubar)
508 [[AC_INIT([Test],[1.0])
509 AC_CANONICAL_TARGET([])
510 # The doc says 27 is a valid fubar.
512 AC_CONFIG_FILES([Makefile])
513 AC_CONFIG_COMMANDS([default],[echo $fubar],[fubar=$fubar])
517 # Checking `autoupdate'.
519 AT_CHECK([cat configure.ac], 0, [expout])
520 # Checking that `autoupdate' is idempotent
522 AT_CHECK([cat configure.ac], 0, [expout])
524 AT_CLEANUP(configure.ac~)
527 # autoupdating AC_LINK_FILES
528 # --------------------------
529 AT_SETUP([autoupdating AC_LINK_FILES])
531 AT_DATA([configure.ac],
533 AC_LINK_FILES(dst1 dst2, src1 src2)
542 # Checking `autoupdate'.
543 AT_CHECK_AUTOUPDATE([], 0, [], ignore)
546 AT_CHECK([cat src1], 0, [dst1
548 AT_CHECK([cat src2], 0, [dst2
551 AT_CLEANUP(src1 src2 configure.ac~)
554 # autoupdating AC_PREREQ
555 # ----------------------
556 AT_SETUP([autoupdating AC_PREREQ])
558 # Produce `AC_PREREQ(<AUTOUPDATE VERSION>)'.
559 AT_CHECK([autoupdate --version | sed 's/.*) //;q'], 0, [stdout])
560 autoupdate_version=`cat stdout`
561 echo "AC_PREREQ($autoupdate_version)" >expout
563 AT_CHECK([echo "AC_PREREQ(1.0)" | autoupdate -],
566 AT_CHECK([echo "AC_PREREQ($autoupdate_version)" | autoupdate -],
569 AT_CHECK([echo "AC_PREREQ(999.99)" | autoupdate -],