3 AT_BANNER([Executables (autoheader, autoupdate...).])
5 ## -------------------------------------------------------- ##
6 ## Check that the shell scripts are syntactically correct. ##
7 ## -------------------------------------------------------- ##
9 # We use `/bin/sh -n script' to check that there are no syntax errors
10 # in the scripts. Although incredible, there are /bin/sh that go into
11 # endless loops with `-n', e.g., SunOS's:
14 # SunOS ondine 4.1.3 2 sun4m unknown
21 # $ time sh endless.sh
22 # sh endless.sh 0,02s user 0,03s system 78% cpu 0,064 total
23 # $ time sh -nx endless.sh
24 # ^Csh -nx endless.sh 3,67s user 0,03s system 63% cpu 5,868 total
26 # So before using `/bin/sh -n' to check our scripts, we first check
27 # that `/bin/sh -n' is not broken to death.
29 AT_SETUP([Syntax of the scripts])
31 # A script that never returns. We don't care that it never returns,
32 # broken /bin/sh loop equally with `false', but it makes it easier to
33 # test the robusteness in a good environment: just remove the `-n'.
41 # A script in charge of testing `/bin/sh -n'.
43 [[(/bin/sh -n endless.sh) &
45 if kill $! >/dev/null 2>&1; then
46 # We managed to kill the child, which means that we probably
47 # can't trust `/bin/sh -n', hence the test failed.
52 # If we can't trust sh, just skip.
53 AT_CHECK([/bin/sh ./syntax.sh])
55 # Specify the path to the tool, some shells don't honor PATH when
58 AT_CHECK([/bin/sh -n ../autoconf], 0)
59 AT_CHECK([/bin/sh -n ../autoreconf], 0)
60 AT_CHECK([/bin/sh -n ../ifnames], 0)
62 # These are not built, they are in the src tree.
63 AT_CHECK([/bin/sh -n $top_srcdir/config/install-sh], 0)
64 AT_CHECK([/bin/sh -n $top_srcdir/config/mkinstalldirs], 0)
65 AT_CHECK([/bin/sh -n $top_srcdir/config/missing], 0)
72 ## ----------------- ##
73 ## AWK portability. ##
74 ## ----------------- ##
76 AT_SETUP([AWK portability])
78 AT_DATA([configure.ac],
81 # Skip if we don't have GNU Awk.
82 AT_CHECK([gawk --version || exit 77], 0, ignore, ignore)
84 # Generation of the script.
85 AT_CHECK([AWK='gawk --posix' autoconf --autoconf-dir .. -l $at_srcdir], 0,
88 AT_CHECK([AWK='gawk --posix' autoconf --autoconf-dir .. -l $at_srcdir -t AC_INIT], 0,
90 # Syntax correctness of ifnames.
91 AT_CHECK([AWK='gawk --posix' ifnames /dev/null], 0,
101 ## ------------------ ##
102 ## autoconf --trace. ##
103 ## ------------------ ##
106 # autoconf --trace: user macros
107 # -----------------------------
108 AT_SETUP([autoconf --trace: user macros])
110 AT_DATA(configure.ac,
111 [[m4_define([active], [ACTIVE])
112 m4_define([TRACE1], [TRACE2(m4_shift($@))])
113 m4_define([TRACE2], [[$2], $1])
114 TRACE1(foo, bar, baz)
115 TRACE1(foo, TRACE1(bar, baz))
116 TRACE1(foo, active, baz)
117 TRACE1(foo, [active], TRACE1(active, [active]))
121 AT_CHECK([autoconf --autoconf-dir .. -l $at_srcdir -t TRACE1 -t TRACE2], 0,
122 [[configure.ac:4:TRACE1:foo:bar:baz
123 configure.ac:4:TRACE2:bar:baz
124 configure.ac:5:TRACE1:bar:baz
125 configure.ac:5:TRACE2:baz
126 configure.ac:5:TRACE1:foo::baz
127 configure.ac:5:TRACE2::baz
128 configure.ac:6:TRACE1:foo:ACTIVE:baz
129 configure.ac:6:TRACE2:ACTIVE:baz
130 configure.ac:7:TRACE1:ACTIVE:active
131 configure.ac:7:TRACE2:active
132 configure.ac:7:TRACE1:foo:active::ACTIVE
133 configure.ac:7:TRACE2:active::ACTIVE
136 # Several line requests.
137 AT_CHECK([[autoconf --autoconf-dir .. -l $at_srcdir -t TRACE1:'
138 [$1], [$2], [$3].']], 0,
146 [foo], [ACTIVE], [baz].
148 [ACTIVE], [active], [].
154 AT_CHECK([autoconf --autoconf-dir .. -l $at_srcdir -t TRACE2:'${)===(}@'], 0,
160 [active])===([])===([ACTIVE]
166 # autoconf --trace: builtins
167 # --------------------------
168 AT_SETUP([autoconf --trace: builtins])
170 AT_DATA(configure.ac,
171 [[define([active], [ACTIVE])
174 AT_CHECK([[autoconf --autoconf-dir .. -l $at_srcdir -t define |
177 [[configure.ac:1:define:active:ACTIVE
180 # FIXME: Without `$1' the following test dies. Groumphf, once again to
181 # dive into obscure feature interaction...
182 # Note that using `-i' means we need the *.m4 files, not the *.m4f files,
183 # hence we need srcdir, not builddir.
184 AT_CHECK([[autoconf --autoconf-dir $top_srcdir -l $at_srcdir -t define:'$1' -i|
195 ## ---------------------------- ##
196 ## autoconf: forbidden tokens. ##
197 ## ---------------------------- ##
199 # autoconf: forbidden tokens, basic
200 # ---------------------------------
201 AT_SETUP([autoconf: forbidden tokens, basic])
203 AT_DATA([configure.ac],
204 [[AC_PLAIN_SCRIPT()dnl
215 AT_CHECK([autoconf --autoconf-dir .. -l $at_srcdir], 1, [], [stderr])
216 # The output of autoconf is not deterministic here because it
217 # uses `for (ind in array)'. So be sure to have a unique representation.
218 AT_CHECK([sort stderr], 0,
219 [[configure.ac:2: error: possibly undefined macro: AC_FOO
220 configure.ac:3: error: possibly undefined macro: _AC_BAR
221 configure.ac:4: error: possibly undefined macro: m4_foo
222 configure.ac:7: error: possibly undefined macro: B_AC_FOO
223 configure.ac:8: error: possibly undefined macro: AS_FOO
224 configure.ac:9: error: possibly undefined macro: _AS_BAR
227 AT_CLEANUP(configure)
230 # autoconf: forbidden tokens, exceptions
231 # --------------------------------------
232 AT_SETUP([autoconf: forbidden tokens, exceptions])
234 AT_DATA([configure.ac],
235 [[AC_PLAIN_SCRIPT()dnl
237 # This is allowed in spite of the name.
238 # It is on purpose that we check the case where there are several
239 # tokens on the same line.
240 m4_pattern_allow([^AC_ALLOWED$])
241 NOT_AC_ALLOWED AC_ALLOWED AC_ALLOWED_NOT
244 m4_pattern_forbid([^FORBIDDEN$])
245 NOT_FORBIDDEN FORBIDDEN FORBIDDEN_NOT
247 # Test Autoconf's patterns.
248 AC_THIS_IS_INVALID and _AC_THIS_IS_INVALID_TOO
249 BUT_AZ_THIS_IS_NOT ALTHOUGH_AC_THIS_IS
250 # This is legal, although there is `AC_DEFINE' in there.
252 # AC_THIS_IS_A_COMMENT so just shut up.
253 It would be very bad if Autoconf forgot to expand [AC_]OUTPUT!
256 AT_CHECK([autoconf --autoconf-dir .. -l $at_srcdir], 1, [], [stderr])
257 # The output of autoconf is not deterministic here because it
258 # uses `for (ind in array)'. So be sure to have a unique representation.
259 AT_CHECK([sort stderr], 0,
260 [[configure.ac:10: error: possibly undefined macro: FORBIDDEN
261 configure.ac:14: error: possibly undefined macro: AC_THIS_IS_INVALID
262 configure.ac:14: error: possibly undefined macro: _AC_THIS_IS_INVALID_TOO
263 configure.ac:15: error: possibly undefined macro: ALTHOUGH_AC_THIS_IS
264 configure.ac:7: error: possibly undefined macro: AC_ALLOWED_NOT
265 configure.ac:7: error: possibly undefined macro: NOT_AC_ALLOWED
266 configure:18: error: possibly undefined macro: AC_OUTPUT
269 AT_CLEANUP(configure err)
284 #if !defined(DEF3) && defined(DEF4) /* but not defined(DEF5) */
291 #if (VAL1*VAL2)==VAL3+VAL4 /* Not VAL5 !!! */
299 AT_CHECK([ifnames iftest1.c iftest2.c], 0,
309 VAL1 iftest1.c iftest2.c
323 # autoheader is intensively used in its modern form throught this
324 # test suite. But we also have to check that acconfig.h still works.
325 # autoheader uses autoconf --trace, so traces first.
327 AT_SETUP([autoheader])
330 [[/* Define this to whatever you want. */
335 # 1. Check that `acconfig.h' is still honored.
336 AT_DATA(configure.ac,
338 AC_CONFIG_HEADERS(config.h)
339 AC_DEFINE(this, "whatever you want.")
342 AT_CHECK([autoheader --autoconf-dir .. -<configure.ac], 0,
343 [[/* config.h.in. Generated automatically from - by autoheader. */
344 /* Define this to whatever you want. */
349 # 2. Check that missing templates are a fatal error.
350 AT_DATA(configure.ac,
352 AC_CONFIG_HEADERS(config.h)
353 AC_DEFINE(that, "whatever you want.")
356 AT_CHECK([autoheader --autoconf-dir .. -<configure.ac], 1, [],
357 [autoheader: No template for symbol `that'
361 # 3. Check TOP and BOTTOM.
363 [[/* Top from acconfig.h. */
365 /* Middle from acconfig.h. */
367 /* Bottom from acconfig.h. */
370 AT_DATA(configure.ac,
372 AC_CONFIG_HEADERS(config.h)
373 AH_TOP([Top1 from configure.ac.])
374 AH_TOP([Top2 from configure.ac.])
375 AH_VERBATIM([Middle], [Middle from configure.ac.])
376 AH_BOTTOM([Bottom1 from configure.ac.])
377 AH_BOTTOM([Bottom2 from configure.ac.])
381 # Yes, that's right: the `middle' part of `acconfig.h' is still before
382 # the AH_TOP part. But so what, you're not supposed to use the two
384 AT_CHECK([autoheader --autoconf-dir .. -<configure.ac], 0,
385 [[/* config.h.in. Generated automatically from - by autoheader. */
386 /* Top from acconfig.h. */
388 /* Middle from acconfig.h. */
390 Top1 from configure.ac.
392 Top2 from configure.ac.
394 Middle from configure.ac.
396 Bottom1 from configure.ac.
398 Bottom2 from configure.ac.
399 /* Bottom from acconfig.h. */
412 # Check that AC_CANONICAL_SYSTEM and AC_OUTPUT are properly updated.
413 AT_SETUP([autoupdate])
415 AT_DATA(configure.ac,
418 dnl The doc says 27 is a valid fubar.
420 AC_OUTPUT(Makefile, echo $fubar, fubar=$fubar)
424 [[AC_INIT([Test],[1.0])
425 AC_CANONICAL_TARGET([])
426 dnl The doc says 27 is a valid fubar.
428 AC_CONFIG_FILES([Makefile])
429 AC_CONFIG_COMMANDS([default],[[echo $fubar]],[[fubar=$fubar]])
433 # Checking `autoupdate'.
435 AT_CHECK([cat configure.ac], 0, [expout])
436 # Checking that `autoupdate' is idempotent
437 AT_CHECK([autoupdate --autoconf-dir $top_srcdir], 0, [],
438 [autoupdate: `configure.ac' is unchanged
440 AT_CHECK([cat configure.ac], 0, [expout])
442 AT_CLEANUP(configure.ac~)
445 # autoupdating AC_LINK_FILES
446 # --------------------------
447 AT_SETUP([autoupdating AC_LINK_FILES])
449 AT_DATA(configure.ac,
451 AC_LINK_FILES(dst1 dst2, src1 src2)
460 # Checking `autoupdate'.
464 AT_CHECK([cat src1], 0, [dst1
466 AT_CHECK([cat src2], 0, [dst2
469 AT_CLEANUP(src1 src2 configure.ac~)
472 # autoupdating AC_PREREQ
473 # ----------------------
474 AT_SETUP([autoupdating AC_PREREQ])
477 AC_PREREQ($at_version)
480 AT_CHECK([autoupdate --version || exit 77], ignore, ignore, ignore)
481 AT_CHECK([echo "AC_PREREQ(1.0)" |
482 autoupdate --autoconf-dir $top_srcdir -],
485 AT_CHECK([echo "AC_PREREQ($at_version)" |
486 autoupdate --autoconf-dir $top_srcdir -],
489 AT_CHECK([echo "AC_PREREQ(999.99)" |
490 autoupdate --autoconf-dir $top_srcdir -],