3 AT_BANNER([Executables (autoheader, autoupdate...).])
5 # Copyright (C) 2000, 2001, 2003, 2004, 2006 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 AT_CHECK([test "$ac_cv_sh_n_works" = yes || exit 77])
51 # Specify the absolute name of the tool, as some shells don't honor PATH when
54 AT_CHECK_SHELL_SYNTAX([$abs_top_builddir/bin/autoconf])
55 AT_CHECK_SHELL_SYNTAX([$abs_top_builddir/tests/autoconf])
56 AT_CHECK_SHELL_SYNTAX([$abs_top_builddir/tests/testsuite])
58 # These are not built, they are in the src tree.
59 AT_CHECK_SHELL_SYNTAX([$abs_top_srcdir/build-aux/install-sh])
60 AT_CHECK_SHELL_SYNTAX([$abs_top_srcdir/build-aux/missing])
67 ## ---------------------------- ##
68 ## Syntax of the Perl scripts. ##
69 ## ---------------------------- ##
71 AT_SETUP([Syntax of the Perl scripts])
73 AT_CHECK_PERL_SYNTAX([autoheader])
74 AT_CHECK_PERL_SYNTAX([autom4te])
75 AT_CHECK_PERL_SYNTAX([autoreconf])
76 AT_CHECK_PERL_SYNTAX([autoscan])
77 AT_CHECK_PERL_SYNTAX([autoupdate])
78 AT_CHECK_PERL_SYNTAX([ifnames])
85 ## ------------------ ##
86 ## autom4te's cache. ##
87 ## ------------------ ##
89 AT_SETUP([autom4te cache])
91 AT_DATA_M4SUGAR([[script.4s]],
99 # We moved a file: it should fail
102 AT_CHECK_M4SUGAR([], [1], [],
103 [m4:script.4s:1: cannot open `foo': No such file or directory
104 autom4te: m4 failed with exit status: 1
107 # But if we change the main file, then we should no longer complain of
109 AT_DATA_M4SUGAR([[script.4s]],
110 [[m4_include([sub/foo])
119 ## ------------------ ##
120 ## autoconf --trace. ##
121 ## ------------------ ##
124 # autoconf --trace: user macros
125 # -----------------------------
126 AT_SETUP([autoconf --trace: user macros])
128 AT_DATA([configure.ac],
129 [[m4_define([active], [ACTIVE])
130 m4_define([TRACE1], [TRACE2(m4_shift($@))])
131 m4_define([TRACE2], [[$2], $1])
137 # With arguments, single line.
138 TRACE1(foo, @bar, @baz)
139 TRACE1(foo, TRACE1(bar, baz))
140 TRACE1(foo, active, baz)
141 TRACE1(foo, [active], TRACE1(active, [active]))
143 # With arguments, multiple lines.
151 AT_CHECK_AUTOCONF([-t TRACE1 -t TRACE2], 0,
152 [[configure.ac:6:TRACE1:
153 configure.ac:6:TRACE2:
154 configure.ac:7:TRACE2:
155 configure.ac:10:TRACE1:foo:@bar:@baz
156 configure.ac:10:TRACE2:@bar:@baz
157 configure.ac:11:TRACE1:bar:baz
158 configure.ac:11:TRACE2:baz
159 configure.ac:11:TRACE1:foo::baz
160 configure.ac:11:TRACE2::baz
161 configure.ac:12:TRACE1:foo:ACTIVE:baz
162 configure.ac:12:TRACE2:ACTIVE:baz
163 configure.ac:13:TRACE1:ACTIVE:active
164 configure.ac:13:TRACE2:active
165 configure.ac:13:TRACE1:foo:active::ACTIVE
166 configure.ac:13:TRACE2:active::ACTIVE
167 configure.ac:19:TRACE1:foo bar:bar foo
168 configure.ac:19:TRACE2:bar foo
171 # Several line requests.
172 AT_CHECK_AUTOCONF([[-t TRACE1:'
173 [$1], [$2], [$3].']], 0,
177 [foo], [@bar], [@baz].
183 [foo], [ACTIVE], [baz].
185 [ACTIVE], [active], [].
195 AT_CHECK_AUTOCONF([-t TRACE2:'${)===(}@'], 0,
203 [active])===([])===([ACTIVE]
211 # autoconf --trace: builtins
212 # --------------------------
213 AT_SETUP([autoconf --trace: builtins])
215 AT_DATA([configure.ac],
216 [[define([active], [ACTIVE])
219 AT_CHECK_AUTOCONF([[-t define | sed -n '$p']],
221 [[configure.ac:1:define:active:ACTIVE
224 # FIXME: Without `$1' the following test dies. Groumphf, once again to
225 # dive into obscure feature interaction...
226 # Note that using `-i' means we need the *.m4 files, not the *.m4f files,
227 # hence we need srcdir, not builddir.
228 AT_CHECK_AUTOCONF([[-t define:'$1' -i| sed -n '$p']],
237 ## ---------------------------- ##
238 ## autoconf: forbidden tokens. ##
239 ## ---------------------------- ##
242 # autoconf: forbidden tokens, basic
243 # ---------------------------------
244 AT_SETUP([autoconf: forbidden tokens, basic])
246 AT_DATA_M4SH([configure.ac],
255 AT_CHECK_AUTOCONF([], 1, [],
256 [[configure.ac:2: error: possibly undefined macro: m4@&t@_foo
257 If this token and others are legitimate, please use m4@&t@_pattern_allow.
258 See the Autoconf documentation.
259 configure.ac:3: error: possibly undefined macro: _m4@&t@_bar
260 configure.ac:4: error: possibly undefined macro: AS@&t@_FOO
261 configure.ac:5: error: possibly undefined macro: _AS@&t@_BAR
262 configure.ac:6: error: possibly undefined macro: d@&t@nl
268 # autoconf: forbidden tokens, exceptions
269 # --------------------------------------
270 AT_SETUP([autoconf: forbidden tokens, exceptions])
272 AT_DATA_M4SH([configure.ac],
275 # This is allowed in spite of the name.
276 # It is on purpose that we check the case where there are several
277 # tokens on the same line.
278 m4_pattern_allow([^AS_ALLOWED$])
279 NOT_AS_ALLOWED AS_ALLOWED AS_ALLOWED_NOT
282 m4_pattern_forbid([^FORBIDDEN$])
283 NOT_FORBIDDEN FORBIDDEN FORBIDDEN_NOT
285 # Test Autoconf's patterns.
286 AS_THIS_IS_INVALID and _AS_THIS_IS_INVALID_TOO
287 BUT_AZ_THIS_IS_NOT ALTHOUGH_AS_THIS_IS
288 # This is legal, although there is `AS_DEFINE' in there.
290 # AS_THIS_IS_A_COMMENT so just shut up.
291 It would be very bad if Autoconf forgot to expand [AS_]INIT!
294 AT_CHECK_AUTOCONF([], 1, [],
295 [[configure.ac:1: error: possibly undefined macro: AS@&t@_INIT
296 If this token and others are legitimate, please use m4@&t@_pattern_allow.
297 See the Autoconf documentation.
298 configure.ac:7: error: possibly undefined macro: AS@&t@_ALLOWED_NOT
299 configure.ac:10: error: possibly undefined macro: FORBIDDEN
300 configure.ac:14: error: possibly undefined macro: AS@&t@_THIS_IS_INVALID
301 configure.ac:14: error: possibly undefined macro: _AS@&t@_THIS_IS_INVALID_TOO
307 # autoconf: automatically allowed tokens
308 # --------------------------------------
309 AT_SETUP([autoconf: automatically allowed tokens])
311 AT_DATA_M4SH([configure.ac],
313 m4_pattern_forbid([^FB_])
324 # autoconf: do not forbid the empty token
325 # ---------------------------------------
326 AT_SETUP([autoconf: the empty token])
328 AT_DATA_M4SH([configure.ac],
329 [[m4_pattern_allow([^foo$])
331 line that begins with a space
339 # autoconf: subdirectories
340 # ------------------------
341 AT_SETUP([autoconf: subdirectories])
343 AT_DATA([configure.ac],
346 AC_CONFIG_FILES(sub/foo)
352 AT_DATA([sub/foo.in],
356 AT_DATA([install-sh])
360 AT_CHECK([[grep '^[^/].*/mkdir -p' sub/foo]], 1)
377 #if ! defined DEF3 && defined DEF4 /* but not defined DEF5 */
384 #if (VAL1*VAL2)==VAL3+VAL4 /* Not VAL5 !!! */
392 AT_CHECK([ifnames iftest1.c iftest2.c], 0,
402 VAL1 iftest1.c iftest2.c
416 # autoheader is intensively used in its modern form throughout this
417 # test suite. But we also have to check that acconfig.h still works.
418 # autoheader uses autoconf --trace, so traces first.
420 AT_SETUP([autoheader])
422 AT_DATA([acconfig.h],
423 [[/* Define this to whatever you want. */
428 # 1. Check that `acconfig.h' is still honored.
429 AT_DATA([configure.ac],
431 AC_CONFIG_HEADERS(config.h:config.hin)
432 AC_DEFINE(this, "whatever you want.")
435 AT_CHECK_AUTOHEADER([], [], [], [ignore])
436 AT_CHECK([cat config.hin], 0,
437 [[/* config.hin. Generated from configure.ac by autoheader. */
438 /* Define this to whatever you want. */
441 /* Define to the address where bug reports for this package should be sent. */
442 #undef PACKAGE_BUGREPORT
444 /* Define to the full name of this package. */
447 /* Define to the full name and version of this package. */
448 #undef PACKAGE_STRING
450 /* Define to the one symbol short name of this package. */
451 #undef PACKAGE_TARNAME
453 /* Define to the version of this package. */
454 #undef PACKAGE_VERSION
458 # 2. Check that missing templates are a fatal error.
459 AT_DATA([configure.ac],
461 AC_CONFIG_HEADERS(config.h:config.hin)
462 AC_DEFINE(that, "whatever you want.")
465 # The test suite goes too fast for the cache time stamps...
467 AT_CHECK_AUTOHEADER([--force], [1], [], [ignore])
470 # 3. Check TOP and BOTTOM.
471 AT_DATA([acconfig.h],
472 [[/* Top from acconfig.h. */
474 /* Middle from acconfig.h. */
476 /* Bottom from acconfig.h. */
479 AT_DATA([configure.ac],
481 AC_CONFIG_HEADERS(config.h:config.hin)
482 AH_TOP([Top1 from configure.ac.])
483 AH_TOP([Top2 from configure.ac.])
484 AH_TOP([The Cat in a h@t.])
485 AH_VERBATIM([Middle], [Middle from configure.ac.])
486 AH_VERBATIM([Mouse], [The Mouse in a h@t.])
487 AH_BOTTOM([Bottom1 from configure.ac.])
488 AH_BOTTOM([Bottom2 from configure.ac.])
489 AH_BOTTOM([The Dog in a h@t.])
491 AC_DEFINE([ANT], [@], [The Ant in a h@t.])
495 # Yes, that's right: the `middle' part of `acconfig.h' is still before
496 # the AH_TOP part. But so what, you're not supposed to use the two
498 # Ignore STDERR which is the longuish complaint against autoheader junk
500 AT_CHECK_AUTOHEADER([--force], [], [], [ignore])
501 AT_CHECK([cat config.hin], 0,
502 [[/* config.hin. Generated from configure.ac by autoheader. */
503 /* Top from acconfig.h. */
504 /* Middle from acconfig.h. */
506 Top1 from configure.ac.
508 Top2 from configure.ac.
512 /* The Ant in a h@t. */
515 Middle from configure.ac.
519 /* Define to the address where bug reports for this package should be sent. */
520 #undef PACKAGE_BUGREPORT
522 /* Define to the full name of this package. */
525 /* Define to the full name and version of this package. */
526 #undef PACKAGE_STRING
528 /* Define to the one symbol short name of this package. */
529 #undef PACKAGE_TARNAME
531 /* Define to the version of this package. */
532 #undef PACKAGE_VERSION
534 Bottom1 from configure.ac.
536 Bottom2 from configure.ac.
539 /* Bottom from acconfig.h. */
551 # Check that AC_CANONICAL_SYSTEM and AC_OUTPUT are properly updated.
552 AT_SETUP([autoupdate])
554 AT_DATA([configure.ac],
557 # The doc says 27 is a valid fubar.
559 AC_OUTPUT(Makefile, echo $fubar, fubar=$fubar)
563 [[AC_INIT([Test],[1.0])
565 # The doc says 27 is a valid fubar.
567 AC_CONFIG_FILES([Makefile])
568 AC_CONFIG_COMMANDS([default],[echo $fubar],[fubar=$fubar])
572 # Checking `autoupdate'.
574 AT_CHECK([cat configure.ac], 0, [expout])
575 # Checking that `autoupdate' is idempotent
577 AT_CHECK([cat configure.ac], 0, [expout])
579 AT_CLEANUP(configure.ac~)
582 # autoupdating AC_LINK_FILES
583 # --------------------------
584 AT_SETUP([autoupdating AC_LINK_FILES])
586 AT_DATA([configure.ac],
588 AC_LINK_FILES(dst1 dst2, src1 src2)
597 # Checking `autoupdate'.
598 AT_CHECK_AUTOUPDATE([], 0, [], ignore)
601 AT_CHECK([cat src1], 0, [dst1
603 AT_CHECK([cat src2], 0, [dst2
606 AT_CLEANUP(src1 src2 configure.ac~)
609 # autoupdating AC_PREREQ
610 # ----------------------
611 AT_SETUP([autoupdating AC_PREREQ])
613 # Produce `AC_PREREQ(<AUTOUPDATE VERSION>)'.
614 AT_CHECK([autoupdate --version | sed 's/.*) //;q'], 0, [stdout])
615 autoupdate_version=`cat stdout`
616 echo "AC_PREREQ($autoupdate_version)" >expout
618 AT_CHECK([echo "AC_PREREQ(1.0)" | autoupdate -],
621 AT_CHECK([echo "AC_PREREQ($autoupdate_version)" | autoupdate -],
624 AT_CHECK([echo "AC_PREREQ(999.99)" | autoupdate -],
630 # autoupdating AU_ALIAS
631 # ---------------------
632 AT_SETUP([autoupdating AU_ALIAS])
634 AT_DATA([configure.ac],
636 AC_DEFUN([FOO], [$#])
637 AU_ALIAS([BAZ],[FOO])
638 test "FOO:FOO():FOO(x) BAZ:BAZ():BAZ(x)" = "0:1:1 0:1:1" || exit 1
644 # Checking `autoupdate'.
648 AT_CHECK([grep 'AC_HEADER_STDC(' configure.ac], 1, [ignore], [ignore])
649 AT_CHECK([grep 'AC_HEADER_STDC' configure.ac], 0, [ignore], [ignore])
654 # autoupdating OLD to NEW
655 # -----------------------
657 # The example taken from the code comments.
658 AT_SETUP([autoupdating OLD to NEW])
660 AT_DATA([aclocal.m4],
661 [[AU_DEFUN([OLD], [NEW([$1, $2], m4@&t@_eval([$1 + $2]))])
662 AC_DEFUN([NEW], [echo "sum($1) = $2"])
665 AT_DATA([configure.ac],
671 # Checking `autoupdate'.
675 AT_CHECK([[grep 'NEW(\[1, 2], *\[3])' configure.ac]], 0, [ignore], [ignore])
676 AT_CHECK([[grep 'NEW(\[0, 0], *\[0])' configure.ac]], 0, [ignore], [ignore])
681 # autoupdating AC_HELP_STRING
682 # ---------------------------
683 AT_SETUP([autoupdating AC_HELP_STRING])
685 AT_DATA([configure.ac],
687 AC_ARG_ENABLE([foo], [AC_HELP_STRING([--enable-foo], [foo bar])], [:], [:])
690 # Checking `autoupdate'.
691 AT_CHECK_AUTOUPDATE([], [], [], [ignore])
693 AT_CHECK_CONFIGURE([], [], [], [ignore])
694 AT_CHECK([[grep '\[--enable-foo], *\[foo bar]' configure.ac]], 0, [ignore], [ignore])
699 # autoupdating with m4sugar
700 # -------------------------
701 AT_SETUP([autoupdating with m4sugar])
703 AT_DATA([aclocal.m4],
705 [m4@&t@_pushdef([foo], [bar])dn@&t@l
707 m4@&t@_popdef([foo])dn@&t@l
713 AT_DATA([configure.ac],
715 m4_define([gnumeric_version_epoch], [1])
718 AC_FOREACH([name], [n1 n2],
721 AC_CHECKING([for feature])
722 AC_MSG_RESULT_UNQUOTED([`echo done`])
727 # Checking `autoupdate'.
728 AT_CHECK_AUTOUPDATE([], [], [], [ignore])
730 AT_CHECK_CONFIGURE([], [], [], [ignore])
735 # autoupdating AC_LANG_SAVE
736 # -------------------------
737 AT_SETUP([autoupdating AC_LANG_SAVE])
739 AT_DATA([configure.ac],
747 # Checking `autoupdate'.
748 AT_CHECK_AUTOUPDATE([], [], [], [ignore])
750 AT_CHECK_CONFIGURE([], [], [], [ignore])
755 # autoupdating AC_FOREACH
756 # -----------------------
757 AT_SETUP([autoupdating AC_FOREACH])
759 AT_DATA([aclocal.m4],
760 [[AU_DEFUN([OLD], [AC_FOREACH([myvar], [4 5 6], [' myvar'])])
763 AT_DATA([configure.ac],
765 echo AC_FOREACH([myvar], [1 2 3], [' myvar'])OLD
768 # Checking `autoupdate'.
770 AT_CHECK([[grep 'echo 1 2 3 4 5 6' configure.ac]], 1, [ignore], [ignore])
771 AT_CHECK([[grep 'm4@&t@_foreach_w' configure.ac]], 0, [ignore], [ignore])
773 AT_CHECK_CONFIGURE([], [0], [stdout])
774 AT_CHECK([[grep ' 1 2 3 4 5 6' stdout]], 0, [ignore], [ignore])
779 # autoupdating with aclocal and m4_include
780 # ----------------------------------------
781 AT_SETUP([autoupdating with aclocal and m4@&t@_include])
784 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
787 AT_DATA([configure.in],
793 AT_DATA([m4/stuff.m4],
794 [[AU_ALIAS([AC_OLD_MACRO], [AC_NEW_MACRO])
795 AC_DEFUN([AC_NEW_MACRO], [echo hi])
796 AC_DEFUN([AC_UNCHANGED_MACRO], [echo one])
798 cp m4/stuff.m4 aclocal/stuff.m4
799 AT_CHECK([aclocal -I aclocal], [0], [ignore], [ignore])
800 # Checking `autoupdate'.
802 AT_CHECK([aclocal -I m4], [0], [ignore], [ignore])