Be nice with file systems that don't handle unusual characters.
[autoconf.git] / tests / tools.at
blob1b3dca59e6861cb1eb60de44b0b568a0c47ab61e
1 #                                                       -*- Autotest -*-
3 AT_BANNER([Executables (autoheader, autoupdate...).])
5 # Copyright (C) 2000, 2001, 2003, 2004, 2006, 2007 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 3 of the License, or
11 # (at your option) 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, see <http://www.gnu.org/licenses/>.
22 ## ----------------------------- ##
23 ## Syntax of the shell scripts.  ##
24 ## ----------------------------- ##
26 # We use `/bin/sh -n script' to check that there are no syntax errors
27 # in the scripts.  Although incredible, there are /bin/sh that go into
28 # endless loops with `-n', e.g., SunOS's:
30 #   $ uname -a
31 #   SunOS ondine 4.1.3 2 sun4m unknown
32 #   $ cat endless.sh
33 #   while false
34 #   do
35 #     :
36 #   done
37 #   exit 0
38 #   $ time sh endless.sh
39 #   sh endless.sh  0,02s user 0,03s system 78% cpu 0,064 total
40 #   $ time sh -nx endless.sh
41 #   ^Csh -nx endless.sh  3,67s user 0,03s system 63% cpu 5,868 total
43 # So before using `/bin/sh -n' to check our scripts, we first check
44 # that `/bin/sh -n' is not broken to death.
46 AT_SETUP([Syntax of the shell scripts])
48 AT_CHECK([test "$ac_cv_sh_n_works" = yes || exit 77])
50 # Specify the absolute name of the tool, as some shells don't honor PATH when
51 # running `sh PROG'.
53 AT_CHECK_SHELL_SYNTAX(["$abs_top_builddir/bin/autoconf"])
54 AT_CHECK_SHELL_SYNTAX(["$abs_top_builddir/tests/autoconf"])
55 AT_CHECK_SHELL_SYNTAX(["$abs_top_builddir/tests/testsuite"])
57 # These are not built, they are in the src tree.
58 AT_CHECK_SHELL_SYNTAX(["$abs_top_srcdir/build-aux/install-sh"])
59 AT_CHECK_SHELL_SYNTAX(["$abs_top_srcdir/build-aux/missing"])
61 AT_CLEANUP
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])
79 AT_CLEANUP
84 ## ------------------ ##
85 ## autom4te's cache.  ##
86 ## ------------------ ##
88 AT_SETUP([autom4te cache])
90 AT_DATA_M4SUGAR([[script.4s]],
91 [[m4_include([foo])
92 ]])
94 # Everything is OK.
95 touch foo
96 AT_CHECK_M4SUGAR
98 # We moved a file: it should fail
99 mkdir sub
100 mv foo sub
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
107 # missing files.
108 AT_DATA_M4SUGAR([[script.4s]],
109 [[m4_include([sub/foo])
111 AT_CHECK_M4SUGAR
113 AT_CLEANUP
116 # autom4te --force
117 # ----------------
119 AT_SETUP([autom4te --force])
121 AT_DATA([file.m4],
122 [[right
124 AT_CHECK_AUTOM4TE([-o file file.m4])
126 # Create a file whose time stamp is in the future.
127 # (next year)-01-01 00:01 UTC should always be in the future,
128 # even on slow machines.
129 echo BAD >file
130 this_year=`TZ=UTC0 date +%Y`
131 TZ=UTC0 touch -t `expr $this_year + 1`01010001 file
133 AT_CHECK_AUTOM4TE([--force -o file file.m4])
134 AT_CHECK([cat file], 0,
135 [[right
138 AT_CLEANUP
141 # autom4te and file names containing whitespace
142 # ---------------------------------------------
144 AT_SETUP([autom4te and whitespace in file names])
147 export x
148 rm -f a b
149 for funny in \
150   'with  funny '\'' $x & #! name' \
151   'with  funny \ '\'' \'\'' " <a >b * ? name ' # "restore font-lock
153   funny=`func_sanitize_file_name "$funny"`
154   file=" file $funny"
155   outfile="$file out "
156   dir=`func_sanitize_dir_name " dir $funny"`
157   cachedir=" cache$dir"
158   TMPDIR=" tmp$dir"
159   export TMPDIR
161   # skip if we cannot create such a file or directory
162   AT_CHECK([mkdir "$dir" "$cachedir" "$TMPDIR" && touch "$file" || exit 77])
164   cat >"$file" <<'END'
165 [m4@&t@_include(foo.m4)
166 m4@&t@_divert(0)d@&t@nl
167 FOO]
169   cat >"$dir"/foo.m4 <<'END'
170 [m4@&t@_define([FOO], [bar])]
173   AT_CHECK_AUTOM4TE([-C "$cachedir" -B "$dir" --language=m4sugar -o "$outfile" "$file"])
174   AT_CHECK([cat "$outfile"], [],
175   [[bar
177   rm -rf "$outfile" "$cachedir"
178   AT_CHECK_AUTOM4TE([-C "$cachedir" -I "$dir" --language=m4sugar -o "$outfile" "$file"])
179   AT_CHECK([cat "$outfile"], [],
180   [[bar
183   # This exercises a slightly different code path and will catch an open with
184   # trailing whitespace:
185   cat >"$file" <<'END'
186 [m4@&t@_include(foo.m4)
187 m4@&t@_pattern_forbid([^bar$])
188 m4@&t@_divert(0)d@&t@nl
189 FOO]
191   rm -rf "$outfile" "$cachedir"
192   AT_CHECK_AUTOM4TE([-C "$cachedir" -I "$dir" --language=m4sugar -o "$outfile" "$file"],
193                     [1], [], [stderr])
194   AT_CHECK([grep 'possibly undefined macro' stderr], [], [ignore])
196   cat >"$file" <<'END'
197 [m4@&t@_include(foo.m4)
198 m4@&t@_divert(0)d@&t@nl]
200   rm -rf "$file.m4f"
201   AT_CHECK_AUTOM4TE([-C "$cachedir" -I "$dir" --language=m4sugar --freeze -o "$file.m4f" "$file"])
202   AT_CHECK([test -s "$file.m4f"])
204   # Check --reload-state
205   AT_CHECK_AUTOM4TE([-C "$cachedir" --language=m4sugar -o "$outfile" "$file.m4f" /dev/null])
207   test ! -f b
208 done
210 AT_CLEANUP
213 ## ------------------ ##
214 ## autoconf --trace.  ##
215 ## ------------------ ##
218 # autoconf --trace: user macros
219 # -----------------------------
220 AT_SETUP([autoconf --trace: user macros])
222 AT_DATA([configure.ac],
223 [[m4_define([active], [ACTIVE])
224 m4_define([TRACE1], [TRACE2(m4_shift($@))])
225 m4_define([TRACE2], [[$2], $1])
227 # No arguments.
228 TRACE1
229 TRACE2
231 # With arguments, single line.
232 TRACE1(foo, @bar, @baz)
233 TRACE1(foo, TRACE1(bar, baz))
234 TRACE1(foo, active, baz)
235 TRACE1(foo, [active], TRACE1(active, [active]))
238 # Several --traces.
239 AT_CHECK_AUTOCONF([-t TRACE1 -t TRACE2], 0,
240 [[configure.ac:6:TRACE1:
241 configure.ac:6:TRACE2:
242 configure.ac:7:TRACE2:
243 configure.ac:10:TRACE1:foo:@bar:@baz
244 configure.ac:10:TRACE2:@bar:@baz
245 configure.ac:11:TRACE1:bar:baz
246 configure.ac:11:TRACE2:baz
247 configure.ac:11:TRACE1:foo::baz
248 configure.ac:11:TRACE2::baz
249 configure.ac:12:TRACE1:foo:ACTIVE:baz
250 configure.ac:12:TRACE2:ACTIVE:baz
251 configure.ac:13:TRACE1:ACTIVE:active
252 configure.ac:13:TRACE2:active
253 configure.ac:13:TRACE1:foo:active::ACTIVE
254 configure.ac:13:TRACE2:active::ACTIVE
257 # Several line requests.
258 AT_CHECK_AUTOCONF([[-t TRACE1:'
259 [$1], [$2], [$3].']], 0,
261 [], [], [].
263 [foo], [@bar], [@baz].
265 [bar], [baz], [].
267 [foo], [], [baz].
269 [foo], [ACTIVE], [baz].
271 [ACTIVE], [active], [].
273 [foo], [active], [].
276 # ${sep}@.
277 AT_CHECK_AUTOCONF([-t TRACE2:'${)===(}@'], 0,
278 [[[]
280 [@bar])===([@baz]
281 [baz]
282 [])===([baz]
283 [ACTIVE])===([baz]
284 [active]
285 [active])===([])===([ACTIVE]
288 # Arguments spanning multiple lines.
289 AT_DATA([configure.ac],
290 [[m4_define([TRACE], [])
291 TRACE(foo
292 bar,
294 foo)
297 AT_CHECK_AUTOCONF([-t TRACE:'$%'], 0,
298 [[foo bar:bar foo
301 AT_CLEANUP
304 # autoconf --trace: builtins
305 # --------------------------
306 AT_SETUP([autoconf --trace: builtins])
308 AT_DATA([configure.ac],
309 [[define([active], [ACTIVE])
312 AT_CHECK_AUTOCONF([[-t define | sed -n '$p']],
313          0,
314 [[configure.ac:1:define:active:ACTIVE
317 # FIXME: Without `$1' the following test dies.  Groumphf, once again to
318 # dive into obscure feature interaction...
319 # Note that using `-i' means we need the *.m4 files, not the *.m4f files,
320 # hence we need srcdir, not builddir.
321 AT_CHECK_AUTOCONF([[-t define:'$1' -i| sed -n '$p']],
322          0,
323 [[active
326 AT_CLEANUP
330 ## ---------------------------- ##
331 ## autoconf: forbidden tokens.  ##
332 ## ---------------------------- ##
335 # autoconf: forbidden tokens, basic
336 # ---------------------------------
337 AT_SETUP([autoconf: forbidden tokens,[] basic])
339 AT_DATA_M4SH([configure.ac],
340 [[AS_INIT
341 m4_foo
342 _m4_bar
343 AS_FOO
344 _AS_BAR
345 [dnl]
348 AT_CHECK_AUTOCONF([], 1, [],
349 [[configure.ac:2: error: possibly undefined macro: m4@&t@_foo
350       If this token and others are legitimate, please use m4@&t@_pattern_allow.
351       See the Autoconf documentation.
352 configure.ac:3: error: possibly undefined macro: _m4@&t@_bar
353 configure.ac:4: error: possibly undefined macro: AS@&t@_FOO
354 configure.ac:5: error: possibly undefined macro: _AS@&t@_BAR
355 configure.ac:6: error: possibly undefined macro: d@&t@nl
357 # Second run should succeed and yield no output.
358 AT_CHECK([autoconf])
360 AT_CLEANUP
363 # autoconf: forbidden tokens, exceptions
364 # --------------------------------------
365 AT_SETUP([autoconf: forbidden tokens,[] exceptions])
367 AT_DATA_M4SH([configure.ac],
368 [[AS_INIT
370 # This is allowed in spite of the name.
371 # It is on purpose that we check the case where there are several
372 # tokens on the same line.
373 m4_pattern_allow([^AS_ALLOWED$])
374 NOT_AS_ALLOWED AS_ALLOWED AS_ALLOWED_NOT
376 # Test forbidding.
377 m4_pattern_forbid([^FORBIDDEN$])
378 NOT_FORBIDDEN FORBIDDEN FORBIDDEN_NOT
380 # Test Autoconf's patterns.
381 AS_THIS_IS_INVALID and _AS_THIS_IS_INVALID_TOO
382 BUT_AZ_THIS_IS_NOT ALTHOUGH_AS_THIS_IS
383 # This is legal, although there is `AS_DEFINE' in there.
384 BAS_DEFINE
385 # AS_THIS_IS_A_COMMENT so just shut up.
386 It would be very bad if Autoconf forgot to expand [AS_]INIT!
389 AT_CHECK_AUTOCONF([], 1, [],
390 [[configure.ac:1: error: possibly undefined macro: AS@&t@_INIT
391       If this token and others are legitimate, please use m4@&t@_pattern_allow.
392       See the Autoconf documentation.
393 configure.ac:7: error: possibly undefined macro: AS@&t@_ALLOWED_NOT
394 configure.ac:10: error: possibly undefined macro: FORBIDDEN
395 configure.ac:14: error: possibly undefined macro: AS@&t@_THIS_IS_INVALID
396 configure.ac:14: error: possibly undefined macro: _AS@&t@_THIS_IS_INVALID_TOO
399 AT_CLEANUP
402 # autoconf: automatically allowed tokens
403 # --------------------------------------
404 AT_SETUP([autoconf: automatically allowed tokens])
406 AT_DATA_M4SH([configure.ac],
407 [[AC_INIT
408 m4_pattern_forbid([^FB_])
409 AC_DEFINE([FB_ONE])
410 AC_SUBST([FB_TWO])
411 AC_OUTPUT
414 AT_CHECK_AUTOCONF
416 AT_CLEANUP
419 # autoconf: do not forbid the empty token
420 # ---------------------------------------
421 AT_SETUP([autoconf: the empty token])
423 AT_DATA_M4SH([configure.ac],
424 [[m4_pattern_allow([^foo$])
425 m4_divert([0])dnl
426  line that begins with a space
429 AT_CHECK_AUTOCONF
431 AT_CLEANUP
434 # autoconf: subdirectories
435 # ------------------------
436 AT_SETUP([autoconf: subdirectories])
438 AT_DATA([configure.ac],
439 [[AC_INIT
440 AC_PROG_MKDIR_P
441 AC_CONFIG_FILES(sub/foo)
442 AC_OUTPUT
445 mkdir sub
447 AT_DATA([sub/foo.in],
448 [[@MKDIR_P@
451 AT_DATA([install-sh])
453 AT_CHECK_AUTOCONF
454 AT_CHECK_CONFIGURE
455 AT_CHECK([[grep '^[^/].*/mkdir -p' sub/foo]], 1)
457 AT_CLEANUP
460 # autoconf: input from stdin
461 # --------------------------
462 AT_SETUP([autoconf: input from stdin])
464 # Past Autoconf versions failed to read from stdin when other, non-frozen input
465 # files were present.
466 AT_DATA([aclocal.m4])
468 AT_CHECK([echo 'AC_INIT(X, 1.0, bug-autoconf@gnu.org)' | autoconf -t AC_INIT -],
469          0, [stdin:1:AC_INIT:X:1.0:bug-autoconf@gnu.org
471 AT_CHECK([echo 'AC_INIT(X, 2.0, bug-autoconf@gnu.org)' | autoconf -t AC_INIT -],
472          0, [stdin:1:AC_INIT:X:2.0:bug-autoconf@gnu.org
475 AT_CLEANUP
478 # autoconf: AC_AUTOCONF_VERSION
479 # --------------------------------------
480 AT_SETUP([autoconf: AC_AUTOCONF_VERSION])
482 AT_DATA([configure.ac],
483 [[AC_INIT
484 version AC_AUTOCONF_VERSION version
485 AC_OUTPUT
488 AT_CHECK_AUTOCONF
489 AT_CHECK([[grep 'version ]]AT_PACKAGE_VERSION[[ version' configure]],
490 0, [ignore])
492 AT_CLEANUP
496 ## --------- ##
497 ## ifnames.  ##
498 ## --------- ##
500 AT_SETUP([ifnames])
502 AT_DATA([iftest1.c],
503 [[#ifdef DEF1
504 #ifndef DEF2
505 #if ! defined DEF3 && defined DEF4 /* but not defined DEF5 */
506     # if SPACES
507         #       if      TABS
508 /* #if C_COMMENTS */
509 // #if CXX_COMMENTS
510 #if LINE1 = \
511 LINE2
512 #if (VAL1*VAL2)==VAL3+VAL4 /* Not VAL5 !!! */
515 AT_DATA([iftest2.c],
516 [[#ifdef IFTEST2
517 #if VAL1
520 AT_CHECK([ifnames iftest1.c iftest2.c], 0,
521 [DEF1 iftest1.c
522 DEF2 iftest1.c
523 DEF3 iftest1.c
524 DEF4 iftest1.c
525 IFTEST2 iftest2.c
526 LINE1 iftest1.c
527 LINE2 iftest1.c
528 SPACES iftest1.c
529 TABS iftest1.c
530 VAL1 iftest1.c iftest2.c
531 VAL2 iftest1.c
532 VAL3 iftest1.c
533 VAL4 iftest1.c
534 ], [])
536 AT_CLEANUP
540 ## ------------ ##
541 ## autoheader.  ##
542 ## ------------ ##
544 # autoheader is intensively used in its modern form throughout this
545 # test suite.  But we also have to check that acconfig.h still works.
546 # autoheader uses autoconf --trace, so traces first.
548 AT_SETUP([autoheader])
550 AT_DATA([acconfig.h],
551 [[/* Define this to whatever you want. */
552 #undef this
556 # 1. Check that `acconfig.h' is still honored.
557 AT_DATA([configure.ac],
558 [[AC_INIT
559 AC_CONFIG_HEADERS(config.h:config.hin)
560 AC_DEFINE(this, "whatever you want.")
563 AT_CHECK_AUTOHEADER([], [], [], [ignore])
564 AT_CHECK([cat config.hin], 0,
565 [[/* config.hin.  Generated from configure.ac by autoheader.  */
566 /* Define this to whatever you want. */
567 #undef this
569 /* Define to the address where bug reports for this package should be sent. */
570 #undef PACKAGE_BUGREPORT
572 /* Define to the full name of this package. */
573 #undef PACKAGE_NAME
575 /* Define to the full name and version of this package. */
576 #undef PACKAGE_STRING
578 /* Define to the one symbol short name of this package. */
579 #undef PACKAGE_TARNAME
581 /* Define to the version of this package. */
582 #undef PACKAGE_VERSION
586 # 2. Check that missing templates are a fatal error.
587 AT_DATA([configure.ac],
588 [[AC_INIT
589 AC_CONFIG_HEADERS(config.h:config.hin)
590 AC_DEFINE(that, "whatever you want.")
593 # The test suite goes too fast for the cache time stamps...
594 # Pass --force.
595 AT_CHECK_AUTOHEADER([--force], [1], [], [ignore])
598 # 3. Check TOP and BOTTOM.
599 AT_DATA([acconfig.h],
600 [[/* Top from acconfig.h. */
601 @TOP@
602 /* Middle from acconfig.h. */
603 @BOTTOM@
604 /* Bottom from acconfig.h. */
607 AT_DATA([configure.ac],
608 [[AC_INIT
609 AC_CONFIG_HEADERS(config.h:config.hin)
610 AH_TOP([Top1 from configure.ac.])
611 AH_TOP([Top2 from configure.ac.])
612 AH_TOP([The Cat in a h@t.])
613 AH_VERBATIM([Middle], [Middle from configure.ac.])
614 AH_VERBATIM([Mouse],  [The Mouse in a h@t.])
615 AH_BOTTOM([Bottom1 from configure.ac.])
616 AH_BOTTOM([Bottom2 from configure.ac.])
617 AH_BOTTOM([The Dog in a h@t.])
619 AC_DEFINE([ANT], [@], [The Ant in a h@t.])
623 # Yes, that's right: the `middle' part of `acconfig.h' is still before
624 # the AH_TOP part.  But so what, you're not supposed to use the two
625 # together.
626 # Ignore STDERR which is the longuish complaint against autoheader junk
627 # files.
628 AT_CHECK_AUTOHEADER([--force], [], [], [ignore])
629 AT_CHECK([cat config.hin], 0,
630 [[/* config.hin.  Generated from configure.ac by autoheader.  */
631 /* Top from acconfig.h. */
632 /* Middle from acconfig.h. */
634 Top1 from configure.ac.
636 Top2 from configure.ac.
638 The Cat in a h@t.
640 /* The Ant in a h@t. */
641 #undef ANT
643 Middle from configure.ac.
645 The Mouse in a h@t.
647 /* Define to the address where bug reports for this package should be sent. */
648 #undef PACKAGE_BUGREPORT
650 /* Define to the full name of this package. */
651 #undef PACKAGE_NAME
653 /* Define to the full name and version of this package. */
654 #undef PACKAGE_STRING
656 /* Define to the one symbol short name of this package. */
657 #undef PACKAGE_TARNAME
659 /* Define to the version of this package. */
660 #undef PACKAGE_VERSION
662 Bottom1 from configure.ac.
664 Bottom2 from configure.ac.
666 The Dog in a h@t.
667 /* Bottom from acconfig.h. */
670 AT_CLEANUP
675 ## ------------ ##
676 ## autoupdate.  ##
677 ## ------------ ##
679 # Check that AC_CANONICAL_SYSTEM and AC_OUTPUT are properly updated.
680 AT_SETUP([autoupdate])
682 AT_DATA([configure.ac],
683 [[AC_INIT(Test, 1.0)
684 AC_CANONICAL_SYSTEM
685 # The doc says 27 is a valid fubar.
686 fubar=27
687 AC_OUTPUT(Makefile, echo $fubar, fubar=$fubar)
690 AT_DATA([expout],
691 [[AC_INIT([Test],[1.0])
692 AC_CANONICAL_TARGET
693 # The doc says 27 is a valid fubar.
694 fubar=27
695 AC_CONFIG_FILES([Makefile])
696 AC_CONFIG_COMMANDS([default],[echo $fubar],[fubar=$fubar])
697 AC_OUTPUT
700 # Checking `autoupdate'.
701 AT_CHECK_AUTOUPDATE
702 AT_CHECK([cat configure.ac], 0, [expout])
703 # Checking that `autoupdate' is idempotent
704 AT_CHECK_AUTOUPDATE
705 AT_CHECK([cat configure.ac], 0, [expout])
707 AT_CLEANUP
710 # autoupdating AC_LINK_FILES
711 # --------------------------
712 AT_SETUP([autoupdating AC_LINK_FILES])
714 AT_DATA([configure.ac],
715 [[AC_INIT
716 AC_LINK_FILES(dst1 dst2, src1 src2)
717 AC_OUTPUT
720 AT_DATA([dst1], dst1
722 AT_DATA([dst2], dst2
725 # Checking `autoupdate'.
726 AT_CHECK_AUTOUPDATE([], 0, [], ignore)
727 AT_CHECK_AUTOCONF
728 AT_CHECK_CONFIGURE
729 AT_CHECK([cat src1], 0, [dst1
731 AT_CHECK([cat src2], 0, [dst2
734 AT_CLEANUP
737 # autoupdating AC_PREREQ
738 # ----------------------
739 AT_SETUP([autoupdating AC_PREREQ])
741 # Produce `AC_PREREQ(<AUTOUPDATE VERSION>)'.
742 AT_CHECK([autoupdate --version | sed 's/.*) //;q'], 0, [stdout])
743 autoupdate_version=`cat stdout`
744 echo "AC_PREREQ($autoupdate_version)" >expout
746 AT_CHECK([echo "AC_PREREQ(1.0)" | autoupdate -],
747          0, [expout], [])
749 AT_CHECK([echo "AC_PREREQ($autoupdate_version)" | autoupdate -],
750          0, [expout], [])
752 AT_CHECK([echo "AC_PREREQ(999.99)" | autoupdate -],
753          63, [], [ignore])
755 AT_CLEANUP
758 # autoupdating AU_ALIAS
759 # ---------------------
760 AT_SETUP([autoupdating AU_ALIAS])
762 AT_DATA([configure.ac],
763 [[AC_INIT
764 AC_DEFUN([FOO], [$#])
765 AU_ALIAS([BAZ],[FOO])
766 test "FOO:FOO():FOO(x) BAZ:BAZ():BAZ(x)" = "0:1:1 0:1:1" || exit 1
767 AC_PROG_CC
768 AC_STDC_HEADERS
769 AC_OUTPUT
772 # Checking `autoupdate'.
773 AT_CHECK_AUTOUPDATE
774 AT_CHECK_AUTOCONF
775 AT_CHECK_CONFIGURE
776 AT_CHECK([grep 'AC_HEADER_STDC(' configure.ac], 1, [ignore], [ignore])
777 AT_CHECK([grep 'AC_HEADER_STDC' configure.ac], 0, [ignore], [ignore])
779 AT_CLEANUP
782 # autoupdating OLD to NEW
783 # -----------------------
785 # The example taken from the code comments.
786 AT_SETUP([autoupdating OLD to NEW])
788 AT_DATA([aclocal.m4],
789 [[AU_DEFUN([OLD], [NEW([$1, $2], m4@&t@_eval([$1 + $2]))])
790 AC_DEFUN([NEW], [echo "sum($1) = $2"])
793 AT_DATA([configure.ac],
794 [[AC_INIT
795 OLD(1, 2)
796 NEW([0, 0], [0])
799 # Checking `autoupdate'.
800 AT_CHECK_AUTOUPDATE
801 AT_CHECK_AUTOCONF
802 AT_CHECK_CONFIGURE
803 AT_CHECK([[grep 'NEW(\[1, 2], *\[3])' configure.ac]], 0, [ignore], [ignore])
804 AT_CHECK([[grep 'NEW(\[0, 0], *\[0])' configure.ac]], 0, [ignore], [ignore])
806 AT_CLEANUP
809 # autoupdating AC_HELP_STRING
810 # ---------------------------
811 AT_SETUP([autoupdating AC_HELP_STRING])
813 AT_DATA([configure.ac],
814 [[AC_INIT
815 AC_ARG_ENABLE([foo], [AC_HELP_STRING([--enable-foo], [foo bar])], [:], [:])
818 # Checking `autoupdate'.
819 AT_CHECK_AUTOUPDATE([], [], [], [ignore])
820 AT_CHECK_AUTOCONF
821 AT_CHECK_CONFIGURE([], [], [], [ignore])
822 AT_CHECK([[grep '\[--enable-foo], *\[foo bar]' configure.ac]], 0, [ignore], [ignore])
824 AT_CLEANUP
827 # autoupdating with m4sugar
828 # -------------------------
829 AT_SETUP([autoupdating with m4sugar])
831 AT_DATA([aclocal.m4],
832 [[AU_DEFUN([OLD],
833 [m4@&t@_pushdef([foo], [bar])dn@&t@l
834 echo "foo $1 foo"
835 m4@&t@_popdef([foo])dn@&t@l
839 touch foo.in
841 AT_DATA([configure.ac],
842 [[AC_PREREQ(2.54)
843 m4_define([gnumeric_version_epoch], [1])
844 AC_INIT
845 OLD([ bla  bla ])
846 AC_FOREACH([name], [n1 n2],
847            [echo name
849 AC_CHECKING([for feature])
850 AC_MSG_RESULT_UNQUOTED([`echo done`])
852 AC_OUTPUT([foo])
855 # Checking `autoupdate'.
856 AT_CHECK_AUTOUPDATE([], [], [], [ignore])
857 AT_CHECK_AUTOCONF
858 AT_CHECK_CONFIGURE([], [], [], [ignore])
860 AT_CLEANUP
863 # autoupdating AC_LANG_SAVE
864 # -------------------------
865 AT_SETUP([autoupdating AC_LANG_SAVE])
867 AT_DATA([configure.ac],
868 [[AC_INIT
869 AC_LANG_SAVE
870 AC_LANG_RESTORE
871 AC_LANG_SAVE
872 AC_LANG_RESTORE
875 # Checking `autoupdate'.
876 AT_CHECK_AUTOUPDATE([], [], [], [ignore])
877 AT_CHECK_AUTOCONF
878 AT_CHECK_CONFIGURE([], [], [], [ignore])
880 AT_CLEANUP
883 # autoupdating AC_FOREACH
884 # -----------------------
885 AT_SETUP([autoupdating AC_FOREACH])
887 AT_DATA([aclocal.m4],
888 [[AU_DEFUN([OLD], [AC_FOREACH([myvar], [4 5 6], [' myvar'])])
891 AT_DATA([configure.ac],
892 [[AC_INIT
893 echo AC_FOREACH([myvar], [1 2 3], [' myvar'])OLD
896 # Checking `autoupdate'.
897 AT_CHECK_AUTOUPDATE
898 AT_CHECK([[grep 'echo 1 2 3 4 5 6' configure.ac]], 1, [ignore], [ignore])
899 AT_CHECK([[grep 'm4@&t@_foreach_w' configure.ac]], 0, [ignore], [ignore])
900 AT_CHECK_AUTOCONF
901 AT_CHECK_CONFIGURE([], [0], [stdout])
902 AT_CHECK([[grep ' 1 2 3 4 5 6' stdout]], 0, [ignore], [ignore])
904 AT_CLEANUP
907 # autoupdating with aclocal and m4_include
908 # ----------------------------------------
909 AT_SETUP([autoupdating with aclocal and m4@&t@_include])
911 # We use aclocal.
912 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
914 mkdir m4 aclocal
915 AT_DATA([configure.in],
916 [[AC_INIT(x,0)
917 AC_UNCHANGED_MACRO
918 AC_OLD_MACRO
919 AC_OUTPUT
921 AT_DATA([m4/stuff.m4],
922 [[AU_ALIAS([AC_OLD_MACRO], [AC_NEW_MACRO])
923 AC_DEFUN([AC_NEW_MACRO], [echo hi])
924 AC_DEFUN([AC_UNCHANGED_MACRO], [echo one])
926 cp m4/stuff.m4 aclocal/stuff.m4
927 AT_CHECK([aclocal -I aclocal], [0], [ignore], [ignore])
928 # Checking `autoupdate'.
929 AT_CHECK_AUTOUPDATE
930 AT_CHECK([aclocal -I m4], [0], [ignore], [ignore])
931 AT_CHECK_AUTOUPDATE
933 AT_CLEANUP
936 # Keeping autom4te.cfg complete
937 # -----------------------------
939 AT_SETUP([autom4te preselections])
940 : ${sleep='sleep 1'}    # Command to force different time stamps.
941 # If this test should run on FAT file systems and older w32,
942 # then setting $sleep correctly needs to be revisited.
944 # We use aclocal and automake.
945 AT_CHECK([automake --version || exit 77], [], [ignore], [ignore])
946 AT_CHECK([test ! -f $HOME/.autom4te.cfg || exit 77], [], [ignore], [ignore])
948 AT_DATA([configure.in],
949 [[AC_INIT(GNU foo, 1.0)
950 AM_INIT_AUTOMAKE
951 AC_CONFIG_FILES([Makefile])
952 AC_OUTPUT
955 AT_DATA([Makefile.am],
956 [[AUTOMAKE_OPTIONS = foreign
959 $sleep # `aclocal.m4' should be strictly younger than its inputs
961 # If Autoconf is too old, or the user has turned caching off, skip:
962 AT_CHECK([aclocal || { ret=$?; test $ret -eq 63 && ret=77; exit $ret; }],
963          [], [], [ignore])
964 AT_CHECK([test -d autom4te.cache || exit 77])
965 AT_CHECK([autoconf])
967 # If this test fails due to missing entries in lib/autom4te.in, then
968 # comparing the old and new requests is a good place to start debugging:
969 cp autom4te.cache/requests old-requests
970 echo newer >newer
971 $sleep # if `configure' is regenerated, we want it to be strictly newer,
972        # to catch the error consistently.
973 AT_CHECK([aclocal], [], [], [ignore])
974 AT_CHECK([automake --no-force --add-missing], [], [], [ignore])
975 AT_CHECK([autoconf])
976 AT_CHECK([test "`find configure -newer newer`" = "" ||
977           { diff old-requests autom4te.cache/requests; exit 1; }])
979 AT_CLEANUP
982 # autotools and file names containing whitespace
983 # ---------------------------------------------
985 AT_SETUP([autotools and whitespace in file names])
988 export x
989 rm -f a b
990 for funny in \
991   'with  funny '\'' $x & #! name ' \
992   'with  funny \ '\'' \'\'' " <a >b * ? name '
994   funny=`func_sanitize_file_name "$funny"`
995   file=" file $funny"
996   dir=`func_sanitize_dir_name " dir $funny"`
997   TMPDIR=" tmp$dir"
998   export TMPDIR
1000   cat >"$file.in" <<'END'
1001 [AC_INIT(x,0)
1002 m4@&t@_include([foo.m4])
1003 AC_CONFIG_HEADERS([config.h:config.hin])
1004 AC_MACRO
1005 AC_OUTPUT]
1007   # skip if we cannot create such a file or directory
1008   AT_CHECK([mkdir "$dir" "$TMPDIR" && test -f "$file.in" || exit 77])
1009   cat >"$dir"/foo.m4 <<'END'
1010 [AC_DEFUN([AC_MACRO], [echo hi])]
1013   AT_CHECK_AUTOHEADER([-B "$dir" "$file.in"])
1014   AT_CHECK_AUTOHEADER([-I "$dir" "$file.in"])
1015   AT_CHECK_AUTOUPDATE([-B "$dir" "$file.in"])
1016   AT_CHECK_AUTOUPDATE([-I "$dir" "$file.in"])
1017   AT_CHECK_AUTOUPDATE([-B "$dir" - < "$file.in"], [], [ignore])
1018   AT_CHECK_AUTOCONF([-B "$dir" -o "$file" "$file.in"])
1019   AT_CHECK_AUTOCONF([-I "$dir" -o "$file" "$file.in"])
1020   # In autoconf, these exercise a slightly different code path:
1021   AT_CHECK_AUTOCONF([--prepend-include="$dir" -o "$file" "$file.in"])
1022   AT_CHECK_AUTOCONF([--include="$dir" -o "$file" "$file.in"])
1023   AT_CHECK([autoscan -B "$dir"], [], [], [ignore])
1024   AT_CHECK([autoscan -I "$dir"], [], [], [ignore])
1025   # autoreconf requires a sane input file name.  Also, disable aclocal.
1026   mv -f "$file.in" configure.in
1027   AT_DATA([aclocal.m4])
1028   AT_CHECK([autoreconf -B "$dir"])
1029   AT_CHECK([autoreconf -I "$dir"])
1031   cat >"$file.c" <<'END'
1032 #if FOO
1033 #endif
1035   AT_CHECK([ifnames "$file.c"], [], [ignore])
1037   test ! -f b
1038 done
1040 AT_CLEANUP