Reduce vertical whitespace in configure.
[autoconf.git] / tests / tools.at
blob0123f825e0356cae6400a4a76a675638490a092b
1 #                                                       -*- Autotest -*-
3 AT_BANNER([Executables (autoheader, autoupdate...).])
5 # Copyright (C) 2000, 2001, 2003, 2004, 2006, 2007, 2008 Free Software
6 # Foundation, Inc.
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 2, or (at your option)
11 # any later version.
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.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 # 02110-1301, USA.
24 ## ----------------------------- ##
25 ## Syntax of the shell scripts.  ##
26 ## ----------------------------- ##
28 # We use `/bin/sh -n script' to check that there are no syntax errors
29 # in the scripts.  Although incredible, there are /bin/sh that go into
30 # endless loops with `-n', e.g., SunOS's:
32 #   $ uname -a
33 #   SunOS ondine 4.1.3 2 sun4m unknown
34 #   $ cat endless.sh
35 #   while false
36 #   do
37 #     :
38 #   done
39 #   exit 0
40 #   $ time sh endless.sh
41 #   sh endless.sh  0,02s user 0,03s system 78% cpu 0,064 total
42 #   $ time sh -nx endless.sh
43 #   ^Csh -nx endless.sh  3,67s user 0,03s system 63% cpu 5,868 total
45 # So before using `/bin/sh -n' to check our scripts, we first check
46 # that `/bin/sh -n' is not broken to death.
48 AT_SETUP([Syntax of the shell scripts])
50 AT_CHECK([test "$ac_cv_sh_n_works" = yes || exit 77])
52 # Specify the absolute name of the tool, as some shells don't honor PATH when
53 # running `sh PROG'.
55 AT_CHECK_SHELL_SYNTAX(["$abs_top_builddir/bin/autoconf"])
56 AT_CHECK_SHELL_SYNTAX(["$abs_top_builddir/tests/autoconf"])
57 AT_CHECK_SHELL_SYNTAX(["$abs_top_builddir/tests/testsuite"])
59 # These are not built, they are in the src tree.
60 AT_CHECK_SHELL_SYNTAX(["$abs_top_srcdir/build-aux/install-sh"])
61 AT_CHECK_SHELL_SYNTAX(["$abs_top_srcdir/build-aux/missing"])
63 AT_CLEANUP
68 ## ---------------------------- ##
69 ## Syntax of the Perl scripts.  ##
70 ## ---------------------------- ##
72 AT_SETUP([Syntax of the Perl scripts])
74 AT_CHECK_PERL_SYNTAX([autoheader])
75 AT_CHECK_PERL_SYNTAX([autom4te])
76 AT_CHECK_PERL_SYNTAX([autoreconf])
77 AT_CHECK_PERL_SYNTAX([autoscan])
78 AT_CHECK_PERL_SYNTAX([autoupdate])
79 AT_CHECK_PERL_SYNTAX([ifnames])
81 AT_CLEANUP
86 ## ------------------ ##
87 ## autom4te's cache.  ##
88 ## ------------------ ##
90 AT_SETUP([autom4te cache])
92 AT_DATA_M4SUGAR([[script.4s]],
93 [[m4_include([foo])
94 ]])
96 # Everything is OK.
97 touch foo
98 AT_CHECK_M4SUGAR
100 # We moved a file: it should fail
101 mkdir sub
102 mv foo sub
103 AT_CHECK_M4SUGAR([], [1], [],
104 [m4:script.4s:1: cannot open `foo': No such file or directory
105 autom4te: m4 failed with exit status: 1
108 # But if we change the main file, then we should no longer complain of
109 # missing files.
110 AT_DATA_M4SUGAR([[script.4s]],
111 [[m4_include([sub/foo])
113 AT_CHECK_M4SUGAR
115 AT_CLEANUP
118 # autom4te --force
119 # ----------------
121 AT_SETUP([autom4te --force])
123 AT_DATA([file.m4],
124 [[right
126 AT_CHECK_AUTOM4TE([-o file file.m4])
128 # Create a file whose time stamp is in the future.
129 # (next year)-01-01 00:01 UTC should always be in the future,
130 # even on slow machines.
131 echo BAD >file
132 this_year=`TZ=UTC0 date +%Y`
133 TZ=UTC0 touch -t `expr $this_year + 1`01010001 file
135 AT_CHECK_AUTOM4TE([--force -o file file.m4])
136 AT_CHECK([cat file], 0,
137 [[right
140 AT_CLEANUP
143 # autom4te and file names containing whitespace
144 # ---------------------------------------------
146 AT_SETUP([autom4te and whitespace in file names])
149 export x
150 rm -f a b
151 for funny in \
152   'with  funny '\'' $x & #! name' \
153   'with  funny \ '\'' \'\'' " <a >b * ? name ' # "restore font-lock
155   funny=`func_sanitize_file_name "$funny"`
156   file=" file $funny"
157   outfile="$file out "
158   dir=`func_sanitize_dir_name " dir $funny"`
159   cachedir=" cache$dir"
160   TMPDIR=" tmp$dir"
161   export TMPDIR
163   # skip if we cannot create such a file or directory
164   AT_CHECK([mkdir "$dir" "$cachedir" "$TMPDIR" && touch "$file" || exit 77])
166   cat >"$file" <<'END'
167 [m4@&t@_include(foo.m4)
168 m4@&t@_divert(0)d@&t@nl
169 FOO]
171   cat >"$dir"/foo.m4 <<'END'
172 [m4@&t@_define([FOO], [bar])]
175   AT_CHECK_AUTOM4TE([-C "$cachedir" -B "$dir" --language=m4sugar -o "$outfile" "$file"])
176   AT_CHECK([cat "$outfile"], [],
177   [[bar
179   rm -rf "$outfile" "$cachedir"
180   AT_CHECK_AUTOM4TE([-C "$cachedir" -I "$dir" --language=m4sugar -o "$outfile" "$file"])
181   AT_CHECK([cat "$outfile"], [],
182   [[bar
185   # This exercises a slightly different code path and will catch an open with
186   # trailing whitespace:
187   cat >"$file" <<'END'
188 [m4@&t@_include(foo.m4)
189 m4@&t@_pattern_forbid([^bar$])
190 m4@&t@_divert(0)d@&t@nl
191 FOO]
193   rm -rf "$outfile" "$cachedir"
194   AT_CHECK_AUTOM4TE([-C "$cachedir" -I "$dir" --language=m4sugar -o "$outfile" "$file"],
195                     [1], [], [stderr])
196   AT_CHECK([grep 'possibly undefined macro' stderr], [], [ignore])
198   cat >"$file" <<'END'
199 [m4@&t@_include(foo.m4)
200 m4@&t@_divert(0)d@&t@nl]
202   rm -rf "$file.m4f"
203   AT_CHECK_AUTOM4TE([-C "$cachedir" -I "$dir" --language=m4sugar --freeze -o "$file.m4f" "$file"])
204   AT_CHECK([test -s "$file.m4f"])
206   # Check --reload-state
207   AT_CHECK_AUTOM4TE([-C "$cachedir" --language=m4sugar -o "$outfile" "$file.m4f" /dev/null])
209   test ! -f b
210 done
212 AT_CLEANUP
215 ## ------------------ ##
216 ## autoconf --trace.  ##
217 ## ------------------ ##
220 # autoconf --trace: user macros
221 # -----------------------------
222 AT_SETUP([autoconf --trace: user macros])
224 AT_DATA([configure.ac],
225 [[m4_define([active], [ACTIVE])
226 m4_define([TRACE1], [TRACE2(m4_shift($@))])
227 m4_define([TRACE2], [[$2], $1])
229 # No arguments.
230 TRACE1
231 TRACE2
233 # With arguments, single line.
234 TRACE1(foo, @bar, @baz)
235 TRACE1(foo, TRACE1(bar, baz))
236 TRACE1(foo, active, baz)
237 TRACE1(foo, [active], TRACE1(active, [active]))
240 # Several --traces.
241 AT_CHECK_AUTOCONF([-t TRACE1 -t TRACE2], 0,
242 [[configure.ac:6:TRACE1:
243 configure.ac:6:TRACE2:
244 configure.ac:7:TRACE2:
245 configure.ac:10:TRACE1:foo:@bar:@baz
246 configure.ac:10:TRACE2:@bar:@baz
247 configure.ac:11:TRACE1:bar:baz
248 configure.ac:11:TRACE2:baz
249 configure.ac:11:TRACE1:foo::baz
250 configure.ac:11:TRACE2::baz
251 configure.ac:12:TRACE1:foo:ACTIVE:baz
252 configure.ac:12:TRACE2:ACTIVE:baz
253 configure.ac:13:TRACE1:ACTIVE:active
254 configure.ac:13:TRACE2:active
255 configure.ac:13:TRACE1:foo:active::ACTIVE
256 configure.ac:13:TRACE2:active::ACTIVE
259 # Several line requests.
260 AT_CHECK_AUTOCONF([[-t TRACE1:'
261 [$1], [$2], [$3].']], 0,
263 [], [], [].
265 [foo], [@bar], [@baz].
267 [bar], [baz], [].
269 [foo], [], [baz].
271 [foo], [ACTIVE], [baz].
273 [ACTIVE], [active], [].
275 [foo], [active], [].
278 # ${sep}@.
279 AT_CHECK_AUTOCONF([-t TRACE2:'${)===(}@'], 0,
280 [[[]
282 [@bar])===([@baz]
283 [baz]
284 [])===([baz]
285 [ACTIVE])===([baz]
286 [active]
287 [active])===([])===([ACTIVE]
290 # Arguments spanning multiple lines.
291 AT_DATA([configure.ac],
292 [[m4_define([TRACE], [])
293 TRACE(foo
294 bar,
296 foo)
299 AT_CHECK_AUTOCONF([-t TRACE:'$%'], 0,
300 [[foo bar:bar foo
303 AT_CLEANUP
306 # autoconf --trace: builtins
307 # --------------------------
308 AT_SETUP([autoconf --trace: builtins])
310 AT_DATA([configure.ac],
311 [[define([active], [ACTIVE])
314 AT_CHECK_AUTOCONF([[-t define | sed -n '$p']],
315          0,
316 [[configure.ac:1:define:active:ACTIVE
319 # FIXME: Without `$1' the following test dies.  Groumphf, once again to
320 # dive into obscure feature interaction...
321 # Note that using `-i' means we need the *.m4 files, not the *.m4f files,
322 # hence we need srcdir, not builddir.
323 AT_CHECK_AUTOCONF([[-t define:'$1' -i| sed -n '$p']],
324          0,
325 [[active
328 AT_CLEANUP
332 ## ---------------------------- ##
333 ## autoconf: forbidden tokens.  ##
334 ## ---------------------------- ##
337 # autoconf: forbidden tokens, basic
338 # ---------------------------------
339 AT_SETUP([autoconf: forbidden tokens,[] basic])
341 AT_DATA_M4SH([configure.ac],
342 [[AS_INIT
343 m4_foo
344 _m4_bar
345 AS_FOO
346 _AS_BAR
347 [dnl]
350 dnl This test needs autom4te's cache, in spite of any ~/.autom4te.cfg.
351 AT_DATA([.autom4te.cfg], [[
352 begin-language: "Autoconf"
353 args: --cache=autom4te.cache
354 end-language: "Autoconf"
355 begin-language: "Autoconf-without-aclocal-m4"
356 args: --cache=autom4te.cache
357 end-language: "Autoconf-without-aclocal-m4"
360 AT_CHECK_AUTOCONF([], 1, [],
361 [[configure.ac:2: error: possibly undefined macro: m4@&t@_foo
362       If this token and others are legitimate, please use m4@&t@_pattern_allow.
363       See the Autoconf documentation.
364 configure.ac:3: error: possibly undefined macro: _m4@&t@_bar
365 configure.ac:4: error: possibly undefined macro: AS@&t@_FOO
366 configure.ac:5: error: possibly undefined macro: _AS@&t@_BAR
367 configure.ac:6: error: possibly undefined macro: d@&t@nl
369 # Second run should succeed and yield no output.
370 AT_CHECK([autoconf])
372 AT_CLEANUP
375 # autoconf: forbidden tokens, exceptions
376 # --------------------------------------
377 AT_SETUP([autoconf: forbidden tokens,[] exceptions])
379 AT_DATA_M4SH([configure.ac],
380 [[AS_INIT
382 # This is allowed in spite of the name.
383 # It is on purpose that we check the case where there are several
384 # tokens on the same line.
385 m4_pattern_allow([^AS_ALLOWED$])
386 NOT_AS_ALLOWED AS_ALLOWED AS_ALLOWED_NOT
388 # Test forbidding.
389 m4_pattern_forbid([^FORBIDDEN$])
390 NOT_FORBIDDEN FORBIDDEN FORBIDDEN_NOT
392 # Test Autoconf's patterns.
393 AS_THIS_IS_INVALID and _AS_THIS_IS_INVALID_TOO
394 BUT_AZ_THIS_IS_NOT ALTHOUGH_AS_THIS_IS
395 # This is legal, although there is `AS_DEFINE' in there.
396 BAS_DEFINE
397 # AS_THIS_IS_A_COMMENT so just shut up.
398 It would be very bad if Autoconf forgot to expand [AS_]INIT!
401 AT_CHECK_AUTOCONF([], 1, [],
402 [[configure.ac:1: error: possibly undefined macro: AS@&t@_INIT
403       If this token and others are legitimate, please use m4@&t@_pattern_allow.
404       See the Autoconf documentation.
405 configure.ac:7: error: possibly undefined macro: AS@&t@_ALLOWED_NOT
406 configure.ac:10: error: possibly undefined macro: FORBIDDEN
407 configure.ac:14: error: possibly undefined macro: AS@&t@_THIS_IS_INVALID
408 configure.ac:14: error: possibly undefined macro: _AS@&t@_THIS_IS_INVALID_TOO
411 AT_CLEANUP
414 # autoconf: automatically allowed tokens
415 # --------------------------------------
416 AT_SETUP([autoconf: automatically allowed tokens])
418 AT_DATA_M4SH([configure.ac],
419 [[AC_INIT
420 m4_pattern_forbid([^FB_])
421 AC_DEFINE([FB_ONE])
422 AC_SUBST([FB_TWO])
423 AC_OUTPUT
426 AT_CHECK_AUTOCONF
428 AT_CLEANUP
431 # autoconf: do not forbid the empty token
432 # ---------------------------------------
433 AT_SETUP([autoconf: the empty token])
435 AT_DATA_M4SH([configure.ac],
436 [[m4_pattern_allow([^foo$])
437 m4_divert([0])dnl
438  line that begins with a space
441 AT_CHECK_AUTOCONF
443 AT_CLEANUP
446 # autoconf: subdirectories
447 # ------------------------
448 AT_SETUP([autoconf: subdirectories])
450 AT_DATA([configure.ac],
451 [[AC_INIT
452 AC_PROG_MKDIR_P
453 AC_CONFIG_FILES(sub/foo)
454 AC_OUTPUT
457 mkdir sub
459 AT_DATA([sub/foo.in],
460 [[@MKDIR_P@
463 AT_DATA([install-sh])
465 AT_CHECK_AUTOCONF
466 AT_CHECK_CONFIGURE
467 AT_CHECK([[grep '^[^/].*/mkdir -p' sub/foo]], 1)
469 AT_CLEANUP
472 # autoconf: input from stdin
473 # --------------------------
474 AT_SETUP([autoconf: input from stdin])
476 # Past Autoconf versions failed to read from stdin when other, non-frozen input
477 # files were present.
478 AT_DATA([aclocal.m4])
480 AT_CHECK([echo 'AC_INIT(X, 1.0, bug-autoconf@gnu.org)' | autoconf -t AC_INIT -],
481          0, [stdin:1:AC_INIT:X:1.0:bug-autoconf@gnu.org
483 AT_CHECK([echo 'AC_INIT(X, 2.0, bug-autoconf@gnu.org)' | autoconf -t AC_INIT -],
484          0, [stdin:1:AC_INIT:X:2.0:bug-autoconf@gnu.org
487 AT_CLEANUP
490 # autoconf: AC_AUTOCONF_VERSION
491 # --------------------------------------
492 AT_SETUP([autoconf: AC_AUTOCONF_VERSION])
494 AT_DATA([configure.ac],
495 [[AC_INIT
496 version m4@&t@_defn([AC_AUTOCONF_VERSION]) version
497 AC_OUTPUT
500 AT_CHECK_AUTOCONF
501 AT_CHECK([[grep 'version ]]AT_PACKAGE_VERSION[[ version' configure]],
502 0, [ignore])
504 AT_CLEANUP
508 ## --------- ##
509 ## ifnames.  ##
510 ## --------- ##
512 AT_SETUP([ifnames])
514 AT_DATA([iftest1.c],
515 [[#ifdef DEF1
516 #ifndef DEF2
517 #if ! defined DEF3 && defined DEF4 /* but not defined DEF5 */
518     # if SPACES
519         #       if      TABS
520 /* #if C_COMMENTS */
521 // #if CXX_COMMENTS
522 #if LINE1 = \
523 LINE2
524 #if (VAL1*VAL2)==VAL3+VAL4 /* Not VAL5 !!! */
527 AT_DATA([iftest2.c],
528 [[#ifdef IFTEST2
529 #if VAL1
532 AT_CHECK([ifnames iftest1.c iftest2.c], 0,
533 [DEF1 iftest1.c
534 DEF2 iftest1.c
535 DEF3 iftest1.c
536 DEF4 iftest1.c
537 IFTEST2 iftest2.c
538 LINE1 iftest1.c
539 LINE2 iftest1.c
540 SPACES iftest1.c
541 TABS iftest1.c
542 VAL1 iftest1.c iftest2.c
543 VAL2 iftest1.c
544 VAL3 iftest1.c
545 VAL4 iftest1.c
546 ], [])
548 AT_CLEANUP
552 ## ------------ ##
553 ## autoheader.  ##
554 ## ------------ ##
556 # autoheader is intensively used in its modern form throughout this
557 # test suite.  But we also have to check that acconfig.h still works.
558 # autoheader uses autoconf --trace, so traces first.
560 AT_SETUP([autoheader])
562 AT_DATA([acconfig.h],
563 [[/* Define this to whatever you want. */
564 #undef this
568 # 1. Check that `acconfig.h' is still honored.
569 AT_DATA([configure.ac],
570 [[AC_INIT
571 AC_CONFIG_HEADERS(config.h:config.hin)
572 AC_DEFINE(this, "whatever you want.")
575 AT_CHECK_AUTOHEADER([], [], [], [ignore])
576 AT_CHECK([cat config.hin], 0,
577 [[/* config.hin.  Generated from configure.ac by autoheader.  */
578 /* Define this to whatever you want. */
579 #undef this
581 /* Define to the address where bug reports for this package should be sent. */
582 #undef PACKAGE_BUGREPORT
584 /* Define to the full name of this package. */
585 #undef PACKAGE_NAME
587 /* Define to the full name and version of this package. */
588 #undef PACKAGE_STRING
590 /* Define to the one symbol short name of this package. */
591 #undef PACKAGE_TARNAME
593 /* Define to the version of this package. */
594 #undef PACKAGE_VERSION
598 # 2. Check that missing templates are a fatal error.
599 AT_DATA([configure.ac],
600 [[AC_INIT
601 AC_CONFIG_HEADERS(config.h:config.hin)
602 AC_DEFINE(that, "whatever you want.")
605 # The test suite goes too fast for the cache time stamps...
606 # Pass --force.
607 AT_CHECK_AUTOHEADER([--force], [1], [], [ignore])
610 # 3. Check TOP and BOTTOM.
611 AT_DATA([acconfig.h],
612 [[/* Top from acconfig.h. */
613 @TOP@
614 /* Middle from acconfig.h. */
615 @BOTTOM@
616 /* Bottom from acconfig.h. */
619 AT_DATA([configure.ac],
620 [[AC_INIT
621 AC_CONFIG_HEADERS(config.h:config.hin)
622 AH_TOP([Top1 from configure.ac.])
623 AH_TOP([Top2 from configure.ac.])
624 AH_TOP([The Cat in a h@t.])
625 AH_VERBATIM([Middle], [Middle from configure.ac.])
626 AH_VERBATIM([Mouse],  [The Mouse in a h@t.])
627 AH_BOTTOM([Bottom1 from configure.ac.])
628 AH_BOTTOM([Bottom2 from configure.ac.])
629 AH_BOTTOM([The Dog in a h@t.])
631 AC_DEFINE([ANT], [@], [The Ant in a h@t.])
635 # Yes, that's right: the `middle' part of `acconfig.h' is still before
636 # the AH_TOP part.  But so what, you're not supposed to use the two
637 # together.
638 # Ignore STDERR which is the longuish complaint against autoheader junk
639 # files.
640 AT_CHECK_AUTOHEADER([--force], [], [], [ignore])
641 AT_CHECK([cat config.hin], 0,
642 [[/* config.hin.  Generated from configure.ac by autoheader.  */
643 /* Top from acconfig.h. */
644 /* Middle from acconfig.h. */
646 Top1 from configure.ac.
648 Top2 from configure.ac.
650 The Cat in a h@t.
652 /* The Ant in a h@t. */
653 #undef ANT
655 Middle from configure.ac.
657 The Mouse in a h@t.
659 /* Define to the address where bug reports for this package should be sent. */
660 #undef PACKAGE_BUGREPORT
662 /* Define to the full name of this package. */
663 #undef PACKAGE_NAME
665 /* Define to the full name and version of this package. */
666 #undef PACKAGE_STRING
668 /* Define to the one symbol short name of this package. */
669 #undef PACKAGE_TARNAME
671 /* Define to the version of this package. */
672 #undef PACKAGE_VERSION
674 Bottom1 from configure.ac.
676 Bottom2 from configure.ac.
678 The Dog in a h@t.
679 /* Bottom from acconfig.h. */
682 AT_CLEANUP
687 ## ------------ ##
688 ## autoupdate.  ##
689 ## ------------ ##
691 # Check that AC_CANONICAL_SYSTEM and AC_OUTPUT are properly updated.
692 AT_SETUP([autoupdate])
694 AT_DATA([configure.ac],
695 [[AC_INIT(Test, 1.0)
696 AC_CANONICAL_SYSTEM
697 # The doc says 27 is a valid fubar.
698 fubar=27
699 AC_OUTPUT(Makefile, echo $fubar, fubar=$fubar)
702 AT_DATA([expout],
703 [[AC_INIT([Test],[1.0])
704 AC_CANONICAL_TARGET
705 # The doc says 27 is a valid fubar.
706 fubar=27
707 AC_CONFIG_FILES([Makefile])
708 AC_CONFIG_COMMANDS([default],[echo $fubar],[fubar=$fubar])
709 AC_OUTPUT
712 # Checking `autoupdate'.
713 AT_CHECK_AUTOUPDATE
714 AT_CHECK([cat configure.ac], 0, [expout])
715 # Checking that `autoupdate' is idempotent
716 AT_CHECK_AUTOUPDATE
717 AT_CHECK([cat configure.ac], 0, [expout])
719 AT_CLEANUP
722 # autoupdating AC_LINK_FILES
723 # --------------------------
724 AT_SETUP([autoupdating AC_LINK_FILES])
726 AT_DATA([configure.ac],
727 [[AC_INIT
728 AC_LINK_FILES(dst1 dst2, src1 src2)
729 AC_OUTPUT
732 AT_DATA([dst1], dst1
734 AT_DATA([dst2], dst2
737 # Checking `autoupdate'.
738 AT_CHECK_AUTOUPDATE([], 0, [], ignore)
739 AT_CHECK_AUTOCONF
740 AT_CHECK_CONFIGURE
741 AT_CHECK([cat src1], 0, [dst1
743 AT_CHECK([cat src2], 0, [dst2
746 AT_CLEANUP
749 # autoupdating AC_PREREQ
750 # ----------------------
751 AT_SETUP([autoupdating AC_PREREQ])
753 # Produce `AC_PREREQ(<AUTOUPDATE VERSION>)'.
754 AT_CHECK([autoupdate --version | sed 's/.*) //;q'], 0, [stdout])
755 autoupdate_version=`cat stdout`
756 echo "AC_PREREQ($autoupdate_version)" >expout
758 AT_CHECK([echo "AC_PREREQ(1.0)" | autoupdate -],
759          0, [expout], [])
761 AT_CHECK([echo "AC_PREREQ($autoupdate_version)" | autoupdate -],
762          0, [expout], [])
764 AT_CHECK([echo "AC_PREREQ(999.99)" | autoupdate -],
765          63, [], [ignore])
767 AT_CLEANUP
770 # autoupdating AU_ALIAS
771 # ---------------------
772 AT_SETUP([autoupdating AU_ALIAS])
774 AT_DATA([configure.ac],
775 [[AC_INIT
776 AC_DEFUN([FOO], [$#])
777 AU_ALIAS([BAZ],[FOO])
778 test "FOO:FOO():FOO(x) BAZ:BAZ():BAZ(x)" = "0:1:1 0:1:1" || exit 1
779 AC_PROG_CC
780 AC_STDC_HEADERS
781 AC_OUTPUT
784 # Checking `autoupdate'.
785 AT_CHECK_AUTOUPDATE
786 AT_CHECK_AUTOCONF
787 AT_CHECK_CONFIGURE
788 AT_CHECK([grep 'AC_HEADER_STDC(' configure.ac], 1, [ignore], [ignore])
789 AT_CHECK([grep 'AC_HEADER_STDC' configure.ac], 0, [ignore], [ignore])
791 AT_CLEANUP
794 # autoupdating OLD to NEW
795 # -----------------------
797 # The example taken from the code comments.
798 AT_SETUP([autoupdating OLD to NEW])
800 AT_DATA([aclocal.m4],
801 [[AU_DEFUN([OLD], [NEW([$1, $2], m4@&t@_eval([$1 + $2]))])
802 AC_DEFUN([NEW], [echo "sum($1) = $2"])
805 AT_DATA([configure.ac],
806 [[AC_INIT
807 OLD(1, 2)
808 NEW([0, 0], [0])
811 # Checking `autoupdate'.
812 AT_CHECK_AUTOUPDATE
813 AT_CHECK_AUTOCONF
814 AT_CHECK_CONFIGURE
815 AT_CHECK([[grep 'NEW(\[1, 2], *\[3])' configure.ac]], 0, [ignore], [ignore])
816 AT_CHECK([[grep 'NEW(\[0, 0], *\[0])' configure.ac]], 0, [ignore], [ignore])
818 AT_CLEANUP
821 # autoupdating AC_HELP_STRING
822 # ---------------------------
823 AT_SETUP([autoupdating AC_HELP_STRING])
825 AT_DATA([configure.ac],
826 [[AC_INIT
827 AC_ARG_ENABLE([foo], [AC_HELP_STRING([--enable-foo], [foo bar])], [:], [:])
830 # Checking `autoupdate'.
831 AT_CHECK_AUTOUPDATE([], [], [], [ignore])
832 AT_CHECK_AUTOCONF
833 AT_CHECK_CONFIGURE([], [], [], [ignore])
834 AT_CHECK([[grep '\[--enable-foo], *\[foo bar]' configure.ac]], 0, [ignore], [ignore])
836 AT_CLEANUP
839 # autoupdating with m4sugar
840 # -------------------------
841 AT_SETUP([autoupdating with m4sugar])
843 AT_DATA([aclocal.m4],
844 [[AU_DEFUN([OLD],
845 [m4@&t@_pushdef([foo], [bar])dn@&t@l
846 echo "foo $1 foo"
847 m4@&t@_popdef([foo])dn@&t@l
851 touch foo.in
853 AT_DATA([configure.ac],
854 [[AC_PREREQ(2.54)
855 m4_define([gnumeric_version_epoch], [1])
856 AC_INIT
857 OLD([ bla  bla ])
858 AC_FOREACH([name], [n1 n2],
859            [echo name
861 AC_CHECKING([for feature])
862 AC_MSG_RESULT_UNQUOTED([`echo done`])
864 AC_OUTPUT([foo])
867 # Checking `autoupdate'.
868 AT_CHECK_AUTOUPDATE([], [], [], [ignore])
869 AT_CHECK_AUTOCONF
870 AT_CHECK_CONFIGURE([], [], [], [ignore])
872 AT_CLEANUP
875 # autoupdating AC_LANG_SAVE
876 # -------------------------
877 AT_SETUP([autoupdating AC_LANG_SAVE])
879 AT_DATA([configure.ac],
880 [[AC_INIT
881 AC_LANG_SAVE
882 AC_LANG_RESTORE
883 AC_LANG_SAVE
884 AC_LANG_RESTORE
887 # Checking `autoupdate'.
888 AT_CHECK_AUTOUPDATE([], [], [], [ignore])
889 AT_CHECK_AUTOCONF
890 AT_CHECK_CONFIGURE([], [], [], [ignore])
892 AT_CLEANUP
895 # autoupdating AC_FOREACH
896 # -----------------------
897 AT_SETUP([autoupdating AC_FOREACH])
899 AT_DATA([aclocal.m4],
900 [[AU_DEFUN([OLD], [AC_FOREACH([myvar], [4 5 6], [' myvar'])])
903 AT_DATA([configure.ac],
904 [[AC_INIT
905 echo AC_FOREACH([myvar], [1 2 3], [' myvar'])OLD
908 # Checking `autoupdate'.
909 AT_CHECK_AUTOUPDATE
910 AT_CHECK([[grep 'echo 1 2 3 4 5 6' configure.ac]], 1, [ignore], [ignore])
911 AT_CHECK([[grep 'm4@&t@_foreach_w' configure.ac]], 0, [ignore], [ignore])
912 AT_CHECK_AUTOCONF
913 AT_CHECK_CONFIGURE([], [0], [stdout])
914 AT_CHECK([[grep ' 1 2 3 4 5 6' stdout]], 0, [ignore], [ignore])
916 AT_CLEANUP
919 # autoupdating with aclocal and m4_include
920 # ----------------------------------------
921 AT_SETUP([autoupdating with aclocal and m4@&t@_include])
923 # We use aclocal.
924 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
926 mkdir m4 aclocal
927 AT_DATA([configure.in],
928 [[AC_INIT(x,0)
929 AC_UNCHANGED_MACRO
930 AC_OLD_MACRO
931 AC_OUTPUT
933 AT_DATA([m4/stuff.m4],
934 [[AU_ALIAS([AC_OLD_MACRO], [AC_NEW_MACRO])
935 AC_DEFUN([AC_NEW_MACRO], [echo hi])
936 AC_DEFUN([AC_UNCHANGED_MACRO], [echo one])
938 cp m4/stuff.m4 aclocal/stuff.m4
939 AT_CHECK([aclocal -I aclocal], [0], [ignore], [ignore])
940 # Checking `autoupdate'.
941 AT_CHECK_AUTOUPDATE
942 AT_CHECK([aclocal -I m4], [0], [ignore], [ignore])
943 AT_CHECK_AUTOUPDATE
945 AT_CLEANUP
948 # Keeping autom4te.cfg complete
949 # -----------------------------
951 AT_SETUP([autom4te preselections])
952 : ${sleep='sleep 1'}    # Command to force different time stamps.
953 # If this test should run on FAT file systems and older w32,
954 # then setting $sleep correctly needs to be revisited.
956 # We use aclocal and automake.
957 AT_CHECK([automake --version || exit 77], [], [ignore], [ignore])
958 AT_CHECK([test ! -f $HOME/.autom4te.cfg || exit 77], [], [ignore], [ignore])
960 AT_DATA([configure.in],
961 [[AC_INIT(GNU foo, 1.0)
962 AM_INIT_AUTOMAKE
963 AC_CONFIG_FILES([Makefile])
964 AC_OUTPUT
967 AT_DATA([Makefile.am],
968 [[AUTOMAKE_OPTIONS = foreign
971 $sleep # `aclocal.m4' should be strictly younger than its inputs
973 # If Autoconf is too old, or the user has turned caching off, skip:
974 AT_CHECK([aclocal || { ret=$?; test $ret -eq 63 && ret=77; exit $ret; }],
975          [], [], [ignore])
976 AT_CHECK([test -d autom4te.cache || exit 77])
977 AT_CHECK([autoconf])
979 # If this test fails due to missing entries in lib/autom4te.in, then
980 # comparing the old and new requests is a good place to start debugging:
981 cp autom4te.cache/requests old-requests
982 echo newer >newer
983 $sleep # if `configure' is regenerated, we want it to be strictly newer,
984        # to catch the error consistently.
985 AT_CHECK([aclocal], [], [], [ignore])
986 AT_CHECK([automake --no-force --add-missing], [], [], [ignore])
987 AT_CHECK([autoconf])
988 AT_CHECK([test "`find configure -newer newer`" = "" ||
989           { diff old-requests autom4te.cache/requests; exit 1; }])
991 AT_CLEANUP
994 # autotools and file names containing whitespace
995 # ---------------------------------------------
997 AT_SETUP([autotools and whitespace in file names])
999 # We use aclocal.
1000 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
1003 export x
1004 rm -f a b
1005 for funny in \
1006   'with  funny '\'' $x & #! name ' \
1007   'with  funny \ '\'' \'\'' " <a >b * ? name '
1009   funny=`func_sanitize_file_name "$funny"`
1010   file=" file $funny"
1011   dir=`func_sanitize_dir_name " dir $funny"`
1012   TMPDIR=" tmp$dir"
1013   export TMPDIR
1015   cat >"$file.in" <<'END'
1016 [AC_INIT(x,0)
1017 m4@&t@_include([foo.m4])
1018 AC_CONFIG_HEADERS([config.h:config.hin])
1019 AC_MACRO
1020 AC_OUTPUT]
1022   # skip if we cannot create such a file or directory
1023   AT_CHECK([mkdir "$dir" "$TMPDIR" && test -f "$file.in" || exit 77])
1024   cat >"$dir"/foo.m4 <<'END'
1025 [AC_DEFUN([AC_MACRO], [echo hi])]
1028   AT_CHECK_AUTOHEADER([-B "$dir" "$file.in"])
1029   AT_CHECK_AUTOHEADER([--force -I "$dir" "$file.in"])
1030   AT_CHECK_AUTOUPDATE([-B "$dir" "$file.in"])
1031   AT_CHECK_AUTOUPDATE([--force -I "$dir" "$file.in"])
1032   AT_CHECK_AUTOUPDATE([-B "$dir" - < "$file.in"], [], [ignore])
1033   AT_CHECK_AUTOCONF([-B "$dir" -o "$file" "$file.in"])
1034   AT_CHECK_AUTOCONF([-I "$dir" -o "$file" "$file.in"])
1035   # In autoconf, these exercise a slightly different code path:
1036   AT_CHECK_AUTOCONF([--prepend-include="$dir" -o "$file" "$file.in"])
1037   AT_CHECK_AUTOCONF([--include="$dir" -o "$file" "$file.in"])
1038   AT_CHECK([autoscan -B "$dir"], [], [], [ignore])
1039   AT_CHECK([autoscan --force -I "$dir"], [], [], [ignore])
1040   # autoreconf requires a sane input file name.  Also, disable aclocal.
1041   mv -f "$file.in" configure.in
1042   AT_DATA([aclocal.m4])
1043   AT_CHECK([autoreconf -B "$dir"])
1044   AT_CHECK([autoreconf --force -I "$dir"])
1046   cat >"$file.c" <<'END'
1047 #if FOO
1048 #endif
1050   AT_CHECK([ifnames "$file.c"], [], [ignore])
1052   test ! -f b
1053 done
1055 AT_CLEANUP