Support unbalanced () in AT_SETUP by adding two new quadrigraphs.
[autoconf.git] / tests / tools.at
blob9e136893e37141a572ffab611de06e33d052b4b8
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 AT_CHECK_AUTOCONF([], 1, [],
351 [[configure.ac:2: error: possibly undefined macro: m4@&t@_foo
352       If this token and others are legitimate, please use m4@&t@_pattern_allow.
353       See the Autoconf documentation.
354 configure.ac:3: error: possibly undefined macro: _m4@&t@_bar
355 configure.ac:4: error: possibly undefined macro: AS@&t@_FOO
356 configure.ac:5: error: possibly undefined macro: _AS@&t@_BAR
357 configure.ac:6: error: possibly undefined macro: d@&t@nl
359 # Second run should succeed and yield no output.
360 AT_CHECK([autoconf])
362 AT_CLEANUP
365 # autoconf: forbidden tokens, exceptions
366 # --------------------------------------
367 AT_SETUP([autoconf: forbidden tokens,[] exceptions])
369 AT_DATA_M4SH([configure.ac],
370 [[AS_INIT
372 # This is allowed in spite of the name.
373 # It is on purpose that we check the case where there are several
374 # tokens on the same line.
375 m4_pattern_allow([^AS_ALLOWED$])
376 NOT_AS_ALLOWED AS_ALLOWED AS_ALLOWED_NOT
378 # Test forbidding.
379 m4_pattern_forbid([^FORBIDDEN$])
380 NOT_FORBIDDEN FORBIDDEN FORBIDDEN_NOT
382 # Test Autoconf's patterns.
383 AS_THIS_IS_INVALID and _AS_THIS_IS_INVALID_TOO
384 BUT_AZ_THIS_IS_NOT ALTHOUGH_AS_THIS_IS
385 # This is legal, although there is `AS_DEFINE' in there.
386 BAS_DEFINE
387 # AS_THIS_IS_A_COMMENT so just shut up.
388 It would be very bad if Autoconf forgot to expand [AS_]INIT!
391 AT_CHECK_AUTOCONF([], 1, [],
392 [[configure.ac:1: error: possibly undefined macro: AS@&t@_INIT
393       If this token and others are legitimate, please use m4@&t@_pattern_allow.
394       See the Autoconf documentation.
395 configure.ac:7: error: possibly undefined macro: AS@&t@_ALLOWED_NOT
396 configure.ac:10: error: possibly undefined macro: FORBIDDEN
397 configure.ac:14: error: possibly undefined macro: AS@&t@_THIS_IS_INVALID
398 configure.ac:14: error: possibly undefined macro: _AS@&t@_THIS_IS_INVALID_TOO
401 AT_CLEANUP
404 # autoconf: automatically allowed tokens
405 # --------------------------------------
406 AT_SETUP([autoconf: automatically allowed tokens])
408 AT_DATA_M4SH([configure.ac],
409 [[AC_INIT
410 m4_pattern_forbid([^FB_])
411 AC_DEFINE([FB_ONE])
412 AC_SUBST([FB_TWO])
413 AC_OUTPUT
416 AT_CHECK_AUTOCONF
418 AT_CLEANUP
421 # autoconf: do not forbid the empty token
422 # ---------------------------------------
423 AT_SETUP([autoconf: the empty token])
425 AT_DATA_M4SH([configure.ac],
426 [[m4_pattern_allow([^foo$])
427 m4_divert([0])dnl
428  line that begins with a space
431 AT_CHECK_AUTOCONF
433 AT_CLEANUP
436 # autoconf: subdirectories
437 # ------------------------
438 AT_SETUP([autoconf: subdirectories])
440 AT_DATA([configure.ac],
441 [[AC_INIT
442 AC_PROG_MKDIR_P
443 AC_CONFIG_FILES(sub/foo)
444 AC_OUTPUT
447 mkdir sub
449 AT_DATA([sub/foo.in],
450 [[@MKDIR_P@
453 AT_DATA([install-sh])
455 AT_CHECK_AUTOCONF
456 AT_CHECK_CONFIGURE
457 AT_CHECK([[grep '^[^/].*/mkdir -p' sub/foo]], 1)
459 AT_CLEANUP
462 # autoconf: input from stdin
463 # --------------------------
464 AT_SETUP([autoconf: input from stdin])
466 # Past Autoconf versions failed to read from stdin when other, non-frozen input
467 # files were present.
468 AT_DATA([aclocal.m4])
470 AT_CHECK([echo 'AC_INIT(X, 1.0, bug-autoconf@gnu.org)' | autoconf -t AC_INIT -],
471          0, [stdin:1:AC_INIT:X:1.0:bug-autoconf@gnu.org
473 AT_CHECK([echo 'AC_INIT(X, 2.0, bug-autoconf@gnu.org)' | autoconf -t AC_INIT -],
474          0, [stdin:1:AC_INIT:X:2.0:bug-autoconf@gnu.org
477 AT_CLEANUP
480 # autoconf: AC_AUTOCONF_VERSION
481 # --------------------------------------
482 AT_SETUP([autoconf: AC_AUTOCONF_VERSION])
484 AT_DATA([configure.ac],
485 [[AC_INIT
486 version m4@&t@_defn([AC_AUTOCONF_VERSION]) version
487 AC_OUTPUT
490 AT_CHECK_AUTOCONF
491 AT_CHECK([[grep 'version ]]AT_PACKAGE_VERSION[[ version' configure]],
492 0, [ignore])
494 AT_CLEANUP
498 ## --------- ##
499 ## ifnames.  ##
500 ## --------- ##
502 AT_SETUP([ifnames])
504 AT_DATA([iftest1.c],
505 [[#ifdef DEF1
506 #ifndef DEF2
507 #if ! defined DEF3 && defined DEF4 /* but not defined DEF5 */
508     # if SPACES
509         #       if      TABS
510 /* #if C_COMMENTS */
511 // #if CXX_COMMENTS
512 #if LINE1 = \
513 LINE2
514 #if (VAL1*VAL2)==VAL3+VAL4 /* Not VAL5 !!! */
517 AT_DATA([iftest2.c],
518 [[#ifdef IFTEST2
519 #if VAL1
522 AT_CHECK([ifnames iftest1.c iftest2.c], 0,
523 [DEF1 iftest1.c
524 DEF2 iftest1.c
525 DEF3 iftest1.c
526 DEF4 iftest1.c
527 IFTEST2 iftest2.c
528 LINE1 iftest1.c
529 LINE2 iftest1.c
530 SPACES iftest1.c
531 TABS iftest1.c
532 VAL1 iftest1.c iftest2.c
533 VAL2 iftest1.c
534 VAL3 iftest1.c
535 VAL4 iftest1.c
536 ], [])
538 AT_CLEANUP
542 ## ------------ ##
543 ## autoheader.  ##
544 ## ------------ ##
546 # autoheader is intensively used in its modern form throughout this
547 # test suite.  But we also have to check that acconfig.h still works.
548 # autoheader uses autoconf --trace, so traces first.
550 AT_SETUP([autoheader])
552 AT_DATA([acconfig.h],
553 [[/* Define this to whatever you want. */
554 #undef this
558 # 1. Check that `acconfig.h' is still honored.
559 AT_DATA([configure.ac],
560 [[AC_INIT
561 AC_CONFIG_HEADERS(config.h:config.hin)
562 AC_DEFINE(this, "whatever you want.")
565 AT_CHECK_AUTOHEADER([], [], [], [ignore])
566 AT_CHECK([cat config.hin], 0,
567 [[/* config.hin.  Generated from configure.ac by autoheader.  */
568 /* Define this to whatever you want. */
569 #undef this
571 /* Define to the address where bug reports for this package should be sent. */
572 #undef PACKAGE_BUGREPORT
574 /* Define to the full name of this package. */
575 #undef PACKAGE_NAME
577 /* Define to the full name and version of this package. */
578 #undef PACKAGE_STRING
580 /* Define to the one symbol short name of this package. */
581 #undef PACKAGE_TARNAME
583 /* Define to the version of this package. */
584 #undef PACKAGE_VERSION
588 # 2. Check that missing templates are a fatal error.
589 AT_DATA([configure.ac],
590 [[AC_INIT
591 AC_CONFIG_HEADERS(config.h:config.hin)
592 AC_DEFINE(that, "whatever you want.")
595 # The test suite goes too fast for the cache time stamps...
596 # Pass --force.
597 AT_CHECK_AUTOHEADER([--force], [1], [], [ignore])
600 # 3. Check TOP and BOTTOM.
601 AT_DATA([acconfig.h],
602 [[/* Top from acconfig.h. */
603 @TOP@
604 /* Middle from acconfig.h. */
605 @BOTTOM@
606 /* Bottom from acconfig.h. */
609 AT_DATA([configure.ac],
610 [[AC_INIT
611 AC_CONFIG_HEADERS(config.h:config.hin)
612 AH_TOP([Top1 from configure.ac.])
613 AH_TOP([Top2 from configure.ac.])
614 AH_TOP([The Cat in a h@t.])
615 AH_VERBATIM([Middle], [Middle from configure.ac.])
616 AH_VERBATIM([Mouse],  [The Mouse in a h@t.])
617 AH_BOTTOM([Bottom1 from configure.ac.])
618 AH_BOTTOM([Bottom2 from configure.ac.])
619 AH_BOTTOM([The Dog in a h@t.])
621 AC_DEFINE([ANT], [@], [The Ant in a h@t.])
625 # Yes, that's right: the `middle' part of `acconfig.h' is still before
626 # the AH_TOP part.  But so what, you're not supposed to use the two
627 # together.
628 # Ignore STDERR which is the longuish complaint against autoheader junk
629 # files.
630 AT_CHECK_AUTOHEADER([--force], [], [], [ignore])
631 AT_CHECK([cat config.hin], 0,
632 [[/* config.hin.  Generated from configure.ac by autoheader.  */
633 /* Top from acconfig.h. */
634 /* Middle from acconfig.h. */
636 Top1 from configure.ac.
638 Top2 from configure.ac.
640 The Cat in a h@t.
642 /* The Ant in a h@t. */
643 #undef ANT
645 Middle from configure.ac.
647 The Mouse in a h@t.
649 /* Define to the address where bug reports for this package should be sent. */
650 #undef PACKAGE_BUGREPORT
652 /* Define to the full name of this package. */
653 #undef PACKAGE_NAME
655 /* Define to the full name and version of this package. */
656 #undef PACKAGE_STRING
658 /* Define to the one symbol short name of this package. */
659 #undef PACKAGE_TARNAME
661 /* Define to the version of this package. */
662 #undef PACKAGE_VERSION
664 Bottom1 from configure.ac.
666 Bottom2 from configure.ac.
668 The Dog in a h@t.
669 /* Bottom from acconfig.h. */
672 AT_CLEANUP
677 ## ------------ ##
678 ## autoupdate.  ##
679 ## ------------ ##
681 # Check that AC_CANONICAL_SYSTEM and AC_OUTPUT are properly updated.
682 AT_SETUP([autoupdate])
684 AT_DATA([configure.ac],
685 [[AC_INIT(Test, 1.0)
686 AC_CANONICAL_SYSTEM
687 # The doc says 27 is a valid fubar.
688 fubar=27
689 AC_OUTPUT(Makefile, echo $fubar, fubar=$fubar)
692 AT_DATA([expout],
693 [[AC_INIT([Test],[1.0])
694 AC_CANONICAL_TARGET
695 # The doc says 27 is a valid fubar.
696 fubar=27
697 AC_CONFIG_FILES([Makefile])
698 AC_CONFIG_COMMANDS([default],[echo $fubar],[fubar=$fubar])
699 AC_OUTPUT
702 # Checking `autoupdate'.
703 AT_CHECK_AUTOUPDATE
704 AT_CHECK([cat configure.ac], 0, [expout])
705 # Checking that `autoupdate' is idempotent
706 AT_CHECK_AUTOUPDATE
707 AT_CHECK([cat configure.ac], 0, [expout])
709 AT_CLEANUP
712 # autoupdating AC_LINK_FILES
713 # --------------------------
714 AT_SETUP([autoupdating AC_LINK_FILES])
716 AT_DATA([configure.ac],
717 [[AC_INIT
718 AC_LINK_FILES(dst1 dst2, src1 src2)
719 AC_OUTPUT
722 AT_DATA([dst1], dst1
724 AT_DATA([dst2], dst2
727 # Checking `autoupdate'.
728 AT_CHECK_AUTOUPDATE([], 0, [], ignore)
729 AT_CHECK_AUTOCONF
730 AT_CHECK_CONFIGURE
731 AT_CHECK([cat src1], 0, [dst1
733 AT_CHECK([cat src2], 0, [dst2
736 AT_CLEANUP
739 # autoupdating AC_PREREQ
740 # ----------------------
741 AT_SETUP([autoupdating AC_PREREQ])
743 # Produce `AC_PREREQ(<AUTOUPDATE VERSION>)'.
744 AT_CHECK([autoupdate --version | sed 's/.*) //;q'], 0, [stdout])
745 autoupdate_version=`cat stdout`
746 echo "AC_PREREQ($autoupdate_version)" >expout
748 AT_CHECK([echo "AC_PREREQ(1.0)" | autoupdate -],
749          0, [expout], [])
751 AT_CHECK([echo "AC_PREREQ($autoupdate_version)" | autoupdate -],
752          0, [expout], [])
754 AT_CHECK([echo "AC_PREREQ(999.99)" | autoupdate -],
755          63, [], [ignore])
757 AT_CLEANUP
760 # autoupdating AU_ALIAS
761 # ---------------------
762 AT_SETUP([autoupdating AU_ALIAS])
764 AT_DATA([configure.ac],
765 [[AC_INIT
766 AC_DEFUN([FOO], [$#])
767 AU_ALIAS([BAZ],[FOO])
768 test "FOO:FOO():FOO(x) BAZ:BAZ():BAZ(x)" = "0:1:1 0:1:1" || exit 1
769 AC_PROG_CC
770 AC_STDC_HEADERS
771 AC_OUTPUT
774 # Checking `autoupdate'.
775 AT_CHECK_AUTOUPDATE
776 AT_CHECK_AUTOCONF
777 AT_CHECK_CONFIGURE
778 AT_CHECK([grep 'AC_HEADER_STDC(' configure.ac], 1, [ignore], [ignore])
779 AT_CHECK([grep 'AC_HEADER_STDC' configure.ac], 0, [ignore], [ignore])
781 AT_CLEANUP
784 # autoupdating OLD to NEW
785 # -----------------------
787 # The example taken from the code comments.
788 AT_SETUP([autoupdating OLD to NEW])
790 AT_DATA([aclocal.m4],
791 [[AU_DEFUN([OLD], [NEW([$1, $2], m4@&t@_eval([$1 + $2]))])
792 AC_DEFUN([NEW], [echo "sum($1) = $2"])
795 AT_DATA([configure.ac],
796 [[AC_INIT
797 OLD(1, 2)
798 NEW([0, 0], [0])
801 # Checking `autoupdate'.
802 AT_CHECK_AUTOUPDATE
803 AT_CHECK_AUTOCONF
804 AT_CHECK_CONFIGURE
805 AT_CHECK([[grep 'NEW(\[1, 2], *\[3])' configure.ac]], 0, [ignore], [ignore])
806 AT_CHECK([[grep 'NEW(\[0, 0], *\[0])' configure.ac]], 0, [ignore], [ignore])
808 AT_CLEANUP
811 # autoupdating AC_HELP_STRING
812 # ---------------------------
813 AT_SETUP([autoupdating AC_HELP_STRING])
815 AT_DATA([configure.ac],
816 [[AC_INIT
817 AC_ARG_ENABLE([foo], [AC_HELP_STRING([--enable-foo], [foo bar])], [:], [:])
820 # Checking `autoupdate'.
821 AT_CHECK_AUTOUPDATE([], [], [], [ignore])
822 AT_CHECK_AUTOCONF
823 AT_CHECK_CONFIGURE([], [], [], [ignore])
824 AT_CHECK([[grep '\[--enable-foo], *\[foo bar]' configure.ac]], 0, [ignore], [ignore])
826 AT_CLEANUP
829 # autoupdating with m4sugar
830 # -------------------------
831 AT_SETUP([autoupdating with m4sugar])
833 AT_DATA([aclocal.m4],
834 [[AU_DEFUN([OLD],
835 [m4@&t@_pushdef([foo], [bar])dn@&t@l
836 echo "foo $1 foo"
837 m4@&t@_popdef([foo])dn@&t@l
841 touch foo.in
843 AT_DATA([configure.ac],
844 [[AC_PREREQ(2.54)
845 m4_define([gnumeric_version_epoch], [1])
846 AC_INIT
847 OLD([ bla  bla ])
848 AC_FOREACH([name], [n1 n2],
849            [echo name
851 AC_CHECKING([for feature])
852 AC_MSG_RESULT_UNQUOTED([`echo done`])
854 AC_OUTPUT([foo])
857 # Checking `autoupdate'.
858 AT_CHECK_AUTOUPDATE([], [], [], [ignore])
859 AT_CHECK_AUTOCONF
860 AT_CHECK_CONFIGURE([], [], [], [ignore])
862 AT_CLEANUP
865 # autoupdating AC_LANG_SAVE
866 # -------------------------
867 AT_SETUP([autoupdating AC_LANG_SAVE])
869 AT_DATA([configure.ac],
870 [[AC_INIT
871 AC_LANG_SAVE
872 AC_LANG_RESTORE
873 AC_LANG_SAVE
874 AC_LANG_RESTORE
877 # Checking `autoupdate'.
878 AT_CHECK_AUTOUPDATE([], [], [], [ignore])
879 AT_CHECK_AUTOCONF
880 AT_CHECK_CONFIGURE([], [], [], [ignore])
882 AT_CLEANUP
885 # autoupdating AC_FOREACH
886 # -----------------------
887 AT_SETUP([autoupdating AC_FOREACH])
889 AT_DATA([aclocal.m4],
890 [[AU_DEFUN([OLD], [AC_FOREACH([myvar], [4 5 6], [' myvar'])])
893 AT_DATA([configure.ac],
894 [[AC_INIT
895 echo AC_FOREACH([myvar], [1 2 3], [' myvar'])OLD
898 # Checking `autoupdate'.
899 AT_CHECK_AUTOUPDATE
900 AT_CHECK([[grep 'echo 1 2 3 4 5 6' configure.ac]], 1, [ignore], [ignore])
901 AT_CHECK([[grep 'm4@&t@_foreach_w' configure.ac]], 0, [ignore], [ignore])
902 AT_CHECK_AUTOCONF
903 AT_CHECK_CONFIGURE([], [0], [stdout])
904 AT_CHECK([[grep ' 1 2 3 4 5 6' stdout]], 0, [ignore], [ignore])
906 AT_CLEANUP
909 # autoupdating with aclocal and m4_include
910 # ----------------------------------------
911 AT_SETUP([autoupdating with aclocal and m4@&t@_include])
913 # We use aclocal.
914 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
916 mkdir m4 aclocal
917 AT_DATA([configure.in],
918 [[AC_INIT(x,0)
919 AC_UNCHANGED_MACRO
920 AC_OLD_MACRO
921 AC_OUTPUT
923 AT_DATA([m4/stuff.m4],
924 [[AU_ALIAS([AC_OLD_MACRO], [AC_NEW_MACRO])
925 AC_DEFUN([AC_NEW_MACRO], [echo hi])
926 AC_DEFUN([AC_UNCHANGED_MACRO], [echo one])
928 cp m4/stuff.m4 aclocal/stuff.m4
929 AT_CHECK([aclocal -I aclocal], [0], [ignore], [ignore])
930 # Checking `autoupdate'.
931 AT_CHECK_AUTOUPDATE
932 AT_CHECK([aclocal -I m4], [0], [ignore], [ignore])
933 AT_CHECK_AUTOUPDATE
935 AT_CLEANUP
938 # Keeping autom4te.cfg complete
939 # -----------------------------
941 AT_SETUP([autom4te preselections])
942 : ${sleep='sleep 1'}    # Command to force different time stamps.
943 # If this test should run on FAT file systems and older w32,
944 # then setting $sleep correctly needs to be revisited.
946 # We use aclocal and automake.
947 AT_CHECK([automake --version || exit 77], [], [ignore], [ignore])
948 AT_CHECK([test ! -f $HOME/.autom4te.cfg || exit 77], [], [ignore], [ignore])
950 AT_DATA([configure.in],
951 [[AC_INIT(GNU foo, 1.0)
952 AM_INIT_AUTOMAKE
953 AC_CONFIG_FILES([Makefile])
954 AC_OUTPUT
957 AT_DATA([Makefile.am],
958 [[AUTOMAKE_OPTIONS = foreign
961 $sleep # `aclocal.m4' should be strictly younger than its inputs
963 # If Autoconf is too old, or the user has turned caching off, skip:
964 AT_CHECK([aclocal || { ret=$?; test $ret -eq 63 && ret=77; exit $ret; }],
965          [], [], [ignore])
966 AT_CHECK([test -d autom4te.cache || exit 77])
967 AT_CHECK([autoconf])
969 # If this test fails due to missing entries in lib/autom4te.in, then
970 # comparing the old and new requests is a good place to start debugging:
971 cp autom4te.cache/requests old-requests
972 echo newer >newer
973 $sleep # if `configure' is regenerated, we want it to be strictly newer,
974        # to catch the error consistently.
975 AT_CHECK([aclocal], [], [], [ignore])
976 AT_CHECK([automake --no-force --add-missing], [], [], [ignore])
977 AT_CHECK([autoconf])
978 AT_CHECK([test "`find configure -newer newer`" = "" ||
979           { diff old-requests autom4te.cache/requests; exit 1; }])
981 AT_CLEANUP
984 # autotools and file names containing whitespace
985 # ---------------------------------------------
987 AT_SETUP([autotools and whitespace in file names])
989 # We use aclocal.
990 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
993 export x
994 rm -f a b
995 for funny in \
996   'with  funny '\'' $x & #! name ' \
997   'with  funny \ '\'' \'\'' " <a >b * ? name '
999   funny=`func_sanitize_file_name "$funny"`
1000   file=" file $funny"
1001   dir=`func_sanitize_dir_name " dir $funny"`
1002   TMPDIR=" tmp$dir"
1003   export TMPDIR
1005   cat >"$file.in" <<'END'
1006 [AC_INIT(x,0)
1007 m4@&t@_include([foo.m4])
1008 AC_CONFIG_HEADERS([config.h:config.hin])
1009 AC_MACRO
1010 AC_OUTPUT]
1012   # skip if we cannot create such a file or directory
1013   AT_CHECK([mkdir "$dir" "$TMPDIR" && test -f "$file.in" || exit 77])
1014   cat >"$dir"/foo.m4 <<'END'
1015 [AC_DEFUN([AC_MACRO], [echo hi])]
1018   AT_CHECK_AUTOHEADER([-B "$dir" "$file.in"])
1019   AT_CHECK_AUTOHEADER([-I "$dir" "$file.in"])
1020   AT_CHECK_AUTOUPDATE([-B "$dir" "$file.in"])
1021   AT_CHECK_AUTOUPDATE([-I "$dir" "$file.in"])
1022   AT_CHECK_AUTOUPDATE([-B "$dir" - < "$file.in"], [], [ignore])
1023   AT_CHECK_AUTOCONF([-B "$dir" -o "$file" "$file.in"])
1024   AT_CHECK_AUTOCONF([-I "$dir" -o "$file" "$file.in"])
1025   # In autoconf, these exercise a slightly different code path:
1026   AT_CHECK_AUTOCONF([--prepend-include="$dir" -o "$file" "$file.in"])
1027   AT_CHECK_AUTOCONF([--include="$dir" -o "$file" "$file.in"])
1028   AT_CHECK([autoscan -B "$dir"], [], [], [ignore])
1029   AT_CHECK([autoscan -I "$dir"], [], [], [ignore])
1030   # autoreconf requires a sane input file name.  Also, disable aclocal.
1031   mv -f "$file.in" configure.in
1032   AT_DATA([aclocal.m4])
1033   AT_CHECK([autoreconf -B "$dir"])
1034   AT_CHECK([autoreconf -I "$dir"])
1036   cat >"$file.c" <<'END'
1037 #if FOO
1038 #endif
1040   AT_CHECK([ifnames "$file.c"], [], [ignore])
1042   test ! -f b
1043 done
1045 AT_CLEANUP