* doc/autoconf.texi (Generic Compiler Characteristics): Fix typo
[autoconf/tsuna.git] / tests / torture.at
blob8a714a0ef9b284a603d460d16176a5f6d073740e
1 #                                                       -*- Autotest -*-
3 # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free
4 # Software Foundation, Inc.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2, or (at your option)
9 # any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 # 02110-1301, USA.
22 AT_BANNER([[Testing config.status.]])
25 ## ---------------------------------------- ##
26 ## AC_CONFIG_COMMANDS with empty commands.  ##
27 ## ---------------------------------------- ##
29 AT_CHECK_MACRO([AC_CONFIG_COMMANDS with empty commands],
30 [[AC_CONFIG_COMMANDS([foo], [], [:])
31 ]])
34 ## -------------------------- ##
35 ## Multiple AC_CONFIG_FILES.  ##
36 ## -------------------------- ##
38 AT_SETUP([Multiple AC_CONFIG_FILES])
40 AT_CONFIGURE_AC([[AC_CONFIG_FILES([foo foo])]])
41 AT_CHECK_AUTOCONF([], 1, [], [ignore])
43 AT_CLEANUP
47 ## ------------ ##
48 ## AC_ARG_VAR.  ##
49 ## ------------ ##
51 # AT_CHECK_AC_ARG_VAR(FIRST-VALUE, SECOND-VALUE)
52 # ----------------------------------------------
53 # Check that AC_ARG_VAR caches the latest values, diagnoses
54 # inconsistencies, and arms config.status.
55 m4_define([AT_CHECK_AC_ARG_VAR],
56 [rm -f config.cache
58 # Initial value.
59 m4_ifval([$1],
60          [precious='m4_bpatsubst($1, [[']], ['\\''])'; export precious],
61          [unset precious])
62 AT_CHECK_CONFIGURE([--config-cache -q])
63 AT_CHECK([cat file], [], [`$1'
66 # Testing --recheck: 1. have the environment `forget' about PRECIOUS.
67 unset precious
68 # 2. Rerun config.status to recreate `file'.
69 AT_CHECK([./config.status --recheck], [], [ignore])
70 AT_CHECK([./config.status], [], [ignore])
71 # 3. Check that file contains the old value of PRECIOUS.
72 AT_CHECK([cat file], [], [`$1'
75 # Second value: we should issue an error here: the value
76 # has changed!
77 m4_ifval([$2],
78          [precious='$2'; export precious],
79          [unset precious])
80 AT_CHECK_CONFIGURE([--config-cache], [1], [], [ignore])
82 ])# AT_CHECK_AC_ARG_VAR
85 AT_SETUP([AC_ARG_VAR])
87 # We don't want to run this test if this shell doesn't support
88 # `unset'.
89 AT_CHECK([
90 if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
91   exit 0
92 else
93   exit 77
97 AT_DATA([configure.ac],
98 [[AC_INIT
99 AC_ARG_VAR([precious], [this variable costs a lot])
100 echo "precious:$precious"
101 AC_OUTPUT(file)
104 AT_DATA([file.in],
105 [[`@precious@'
108 AT_CHECK_AUTOCONF
110 # Set a precious variable
111 AT_CHECK_AC_ARG_VAR([], [apple of my eye])
113 # Unset a precious variable
114 AT_CHECK_AC_ARG_VAR([apple of my eye], [])
116 # Change a precious variable
117 AT_CHECK_AC_ARG_VAR([apple of my eye], [orange of my eye])
119 # Change a precious variable that contains braces
120 AT_CHECK_AC_ARG_VAR([apple of my {eye}], [orange of my eye])
122 # Change a precious variable that contains all kinds of fun
123 AT_CHECK_AC_ARG_VAR(['p  r      ec"iou$], [orange of my eye])
125 AT_CLEANUP
130 ## ---------------------------------------------- ##
131 ## AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS.  ##
132 ## ---------------------------------------------- ##
134 AT_SETUP([AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS])
136 AT_DATA([configure.ac],
137 [[AC_INIT
138 rm -f -r header var-header file var-file link var-link command var-command
139 echo 'OK' >input
141 # Be sure to also stress the associated INIT-CMDS.
142 case $what_to_test in
143  header)
144    AC_CONFIG_HEADERS(header:input);;
145  var-header)
146    AC_CONFIG_HEADERS(var-header:$header_in, [], [header_in=input]);;
148  file)
149    AC_CONFIG_FILES(file:input);;
150  var-file)
151    AC_CONFIG_FILES(var-file:$file_in, [], [file_in=input]);;
153  command)
154    AC_CONFIG_COMMANDS(command,
155                       [cp input command]);;
156  var-command)
157    AC_CONFIG_COMMANDS(var-command,
158                       [cp $command_in var-command], [command_in=input]);;
160  link)
161    AC_CONFIG_LINKS(link:input);;
162  var-link)
163    AC_CONFIG_LINKS(var-link:$link_in, [], [link_in=input]);;
164 esac
165 AC_OUTPUT
168 AT_CHECK_AUTOCONF
171 # AT_CHECK_CONFIG_CREATION(THING = (header | link | file | command))
172 # ------------------------------------------------------------------
173 # Check that THING and var-THING (which uses variables in AC_CONFIG_THING)
174 # are properly created, with the right content.
175 # Use `grep OK' instead of a simple `cat' to avoid banners such as in
176 # AC_CONFIG_HEADERS.
177 m4_define([AT_CHECK_CONFIG_CREATION],
178 [AT_CHECK_CONFIGURE([what_to_test=$1])
179 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
180          [ignore], [$1
182 AT_CHECK([grep OK $1], [], [OK
185 AT_CHECK_CONFIGURE([what_to_test=var-$1 --no-create])
186 # config.status might be stupidly expecting data on stdin, if it's
187 # really broken...
188 AT_CHECK([./config.status var-$1 </dev/null], [], [ignore])
189 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
190          [ignore], [var-$1
192 AT_CHECK([grep OK var-$1], [], [OK
194 ])# AT_CHECK_CONFIG_CREATION
197 # Create a file
198 AT_CHECK_CONFIG_CREATION(file)
200 # Create a header
201 AT_CHECK_CONFIG_CREATION(header)
203 # Execute a command
204 AT_CHECK_CONFIG_CREATION(command)
206 # Create a link
207 AT_CHECK_CONFIG_CREATION(link)
209 AT_CLEANUP
213 ## ---------------------------------------- ##
214 ## Macro calls in AC_CONFIG_COMMANDS tags.  ##
215 ## ---------------------------------------- ##
217 AT_SETUP([Macro calls in AC_CONFIG_COMMANDS tags])
219 AT_DATA_M4SUGAR([configure.ac],
220 [[AC_INIT
221 AC_CONFIG_COMMANDS([m4_if(1,1,mytag)])
222 AC_OUTPUT
225 AT_CHECK_AUTOCONF
226 AT_CHECK_CONFIGURE
228 AT_CLEANUP
232 ## ------------------- ##
233 ## Missing templates.  ##
234 ## ------------------- ##
236 # Check that config.status detects missing input files
237 AT_SETUP([Missing templates])
239 AT_DATA([configure.ac],
240 [[AC_INIT
241 AC_CONFIG_FILES([nonexistent])
242 AC_OUTPUT
245 AT_CHECK_AUTOCONF
246 AT_CHECK_CONFIGURE([], [1], [],
247 [[config.status: error: cannot find input file: nonexistent.in
249 # Make sure that the output file doesn't exist
250 AT_CHECK([test -f nonexistent], 1)
252 AT_CLEANUP
257 ## ---------------------- ##
258 ## configure invocation.  ##
259 ## ---------------------- ##
261 # Check that `configure' and `config.status' honor their interface.
263 # We run `./configure one=val1 --enable-two=val2 --with-three=val3'
264 # and verify that (i) `configure' correctly receives the arguments,
265 # (ii) correctly passes them to `config.status', which we check by
266 # running `config.status --recheck', and (iii) correctly passes them
267 # to sub-configure scripts.
269 AT_SETUP([configure invocation])
271 mkdir sub
273 AT_DATA([configure.ac],
274 [[AC_INIT
275 AC_CONFIG_SUBDIRS([sub])
276 echo "result=$one$enable_two$with_three"
277 AC_OUTPUT
280 AT_DATA([sub/configure.ac],
281 [[AC_INIT
282 echo "result=$one$enable_two$with_three"
283 AC_OUTPUT
286 echo fake install-sh script >install-sh
288 AT_CHECK_AUTOCONF
289 cd sub
290 AT_CHECK_AUTOCONF
291 cd ..
293 AT_CHECK_CONFIGURE([one=one --enable-two=two --with-three=three |
294                      sed -n -e 's/^result=//p'], 0,
295                    [m4_do([onetwothree
296 ],                        [onetwothree
297 ])])
298 AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
299          [onetwothree
302 AT_CHECK_CONFIGURE([one="\"'$ " --enable-two="\" '  $" --with-three="   \"'$"|
303                       sed -n -e 's/^result=//p'], 0,
304                    [m4_do(["'$ " '  $   "'$
305 ],                        ["'$ " '  $   "'$
306 ])])
307 AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
308          ["'$ " '  $    "'$
311 AT_CLEANUP
315 ## -------------------------------------------- ##
316 ## Check that `#define' templates are honored.  ##
317 ## -------------------------------------------- ##
319 # Use various forms of `#define' templates, and make sure there are no
320 # problems when a symbol is prefix of another.
322 AT_SETUP([[#define header templates]])
324 AT_DATA([configure.ac],
325 [[AC_INIT
326 AC_CONFIG_HEADERS(config.h:config.hin)
328 # I18n of dummy variables: their French translations.
329 AC_DEFINE(foo, toto)
330 AC_DEFINE(bar, tata)
331 AC_DEFINE(baz, titi)
332 AC_DEFINE(fubar, tutu)
334 # Symbols which are prefixes of another.
335 AC_DEFINE(a, A)
336 AC_DEFINE(aaa, AAA)
337 AC_DEFINE(aa, AA)
338 AC_CONFIG_FILES(defs)
340 # Things included in confdefs.h, but which make no sense in
341 # config.h, nor in $DEFS.
342 cat <<\EOF >>confdefs.h
343 /* Hi Mum! Look, I am doing C++! */
344 #ifdef __cplusplus
345 void exit (int status);
346 #endif
349 # In addition of config.h output a full DEFS
350 AC_OUTPUT_MAKE_DEFS
351 DEFS_SAVED=$DEFS
352 AC_SUBST(DEFS_SAVED)
353 AC_OUTPUT
356 AT_DATA([defs.in],
357 [[@DEFS_SAVED@
360 AT_DATA([config.hin],
361 [[#define foo   0
362 #  define bar bar
363 #  define baz   "Archimedes was sinking in his baz"
364 #  define fubar                         tutu
365 #define a B
366 #define aa BB
367 #define aaa BBB
368 #undef a
369 #undef aa
370 #undef aaa
373 AT_CHECK_AUTOCONF
374 AT_CHECK_CONFIGURE
376 AT_DATA([expout],
377 [[/* config.h.  Generated from config.hin by configure.  */
378 #define foo toto
379 #  define bar tata
380 #  define baz titi
381 #  define fubar tutu
382 #define a A
383 #define aa AA
384 #define aaa AAA
385 #define a A
386 #define aa AA
387 #define aaa AAA
389 AT_CHECK([cat config.h], 0, expout)
391 # Check the value of DEFS.
392 AT_DATA([expout],
393 [[-DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -Dfoo=toto -Dbar=tata -Dbaz=titi -Dfubar=tutu -Da=A -Daaa=AAA -Daa=AA
396 # Because we strip trailing spaces in `testsuite' we can't leave one in
397 # expout, hence nuke the one left by AC_OUTPUT_MAKE_DEFS.
398 AT_CHECK([sed -e 's/ $//' defs], 0, expout)
400 AT_CLEANUP
404 ## ------------------------- ##
405 ## Torturing config.status.  ##
406 ## ------------------------- ##
408 ## Require 100 AC_DEFINE and AC_SUBST and AC_SUBST_FILE with a significantly
409 ## big value.  This is mostly to check that Autoconf produces portable sed
410 ## scripts in config.status.  sed is used to skip the first two lines
411 ## `Generated by...'.
413 # We use m4_for many times.
414 m4_pattern_allow([^m4_for$])
416 AT_SETUP([Torturing config.status])
418 dnl The value used as a big value for AC_DEFINE.
419 dnl Don't use sh active chars here, below it is also used in a sh
420 dnl assignment.
421 m4_define([AT_BIG_VALUE],
422 [This value should be long enough to torture the various limits of sed and other tools used by Autoconf.])
424 m4_define([AT_DESCRIPTION],
425 [Define to a long string if your `Autoconf' works properly.])
428 # AT_DUMMY_VAR(NUMBER)
429 # --------------------
430 # Build a name used for AC_SUBST and AC_DEFINE.  Put ac_ in it
431 # so that the check for user name space invasion does not complain
432 # of the new variables defined.
434 # Note that you should not use the name ac_dummy, because it will be
435 # turned into ac_uummy during the construction of config.status.  Yes,
436 # this is admittedly a bug, but it would be too hard to fix this.
437 # There is really no point in AC_DEFINE a var named ac_d.*.
438 m4_pattern_allow([^m4_bpatsubst$])
439 m4_define([AT_DUMMY_VAR],
440 [ac_Dummy_[]m4_bpatsubst([000$1], [.*\(...\)$], [\1])])
444 AT_DATA([dummy.in],
445 [m4_for([AT_Count], 1, 100, 1,
446 [@AT_DUMMY_VAR(AT_Count)@
447 @[f]AT_Count@
448 ])])
452 while test $i != 101; do
453   echo "content of file $i" > file_$i
454   i=`expr $i + 1`
455 done
458 # ------------ #
459 # configure.ac #
460 # ------------ #
462 m4_pattern_allow([^m4_(define|defun)$])
463 AT_DATA([configure.ac],
464 dnl The following lines transfer AT_DUMMY_VAR, AT_DESCRIPTION, and
465 dnl AT_BIG_VALUE into the configure.ac as AC_DUMMY_VAR etc.
466 [[m4_define([AC_DUMMY_VAR],]
467 m4_dquote(m4_defn([AT_DUMMY_VAR]))[)]]
469 [[m4_define([AC_DESCRIPTION],]
470 m4_dquote(m4_defn([AT_DESCRIPTION]))[)]]
472 [[m4_define([AC_BIG_VALUE],]
473 m4_dquote(m4_defn([AT_BIG_VALUE]))[)]]
475 [[# AC_DEFUBST(NAME)
476 # ----------------
477 # Related VALUE to NAME both with AC_SUBST and AC_DEFINE.  This is
478 # used in the torture tests.
479 m4_defun([AC_DEFUBST],
480 [AC_DUMMY_VAR($1)="AC_BIG_VALUE"
481 AC_DEFINE_UNQUOTED(AC_DUMMY_VAR($1), "$AC_DUMMY_VAR($1)",
482                    AC_DESCRIPTION)
483 AC_SUBST(AC_DUMMY_VAR($1))
484 AC_SUBST_FILE([f]$1)
485 f$1=file_$1
488 AC_INIT
489 AC_CONFIG_HEADERS(config.h:config.hin)
490 AC_CONFIG_FILES(dummy)
491 m4_for(AC_Count, 1, 100, 1,
492        [AC_DEFUBST(AC_Count)])
493 AC_PROG_AWK
494 AC_OUTPUT
495 ]])# configure.ac
497 AT_CHECK_AUTOCONF
498 AT_CHECK_AUTOHEADER
499 # Check both awk and the result of AC_PROG_AWK
500 for awk_arg in FOO= AWK=awk; do
501   AT_CHECK_CONFIGURE([$awk_arg])
503   # Checking that AC_DEFINE worked properly.
504   AT_DATA([expout],
505 [/* Define to the address where bug reports for this package should be sent. */
506 #define PACKAGE_BUGREPORT ""
508 /* Define to the full name of this package. */
509 #define PACKAGE_NAME ""
511 /* Define to the full name and version of this package. */
512 #define PACKAGE_STRING ""
514 /* Define to the one symbol short name of this package. */
515 #define PACKAGE_TARNAME ""
517 /* Define to the version of this package. */
518 #define PACKAGE_VERSION ""
519 m4_for(AT_Count, 1, 100, 1,
521 /* AT_DESCRIPTION */
522 [#define] AT_DUMMY_VAR(AT_Count) "AT_BIG_VALUE"
523 ])])
525   AT_CHECK([sed -n '4,$ p' config.h], 0, expout)
527   # Checking that AC_SUBST worked properly.
528   AT_DATA([expout],
529 [m4_for(AT_Count, 1, 100, 1,
530 [AT_BIG_VALUE
531 content of file AT_Count
532 ])])
534   AT_CHECK([cat dummy], 0, expout)
535 done
537 AT_CLEANUP
540 ## ------------------------------- ##
541 ## Substitute a 2000-byte string.  ##
542 ## ------------------------------- ##
544 # Solaris 9 /usr/ucb/sed that rejects commands longer than 4000 bytes.  HP/UX
545 # sed dumps core around 8 KiB.  However, POSIX says that sed need not
546 # handle lines longer than 2048 bytes (including the trailing newline).
547 # So we'll just test a 2000-byte value, and for awk, we test a line with
548 # almost 1000 words, and one variable with 5 lines of 2000 bytes each:
549 # multi-line values should allow to get around the limitations.
551 AT_SETUP([Substitute a 2000-byte string])
553 AT_DATA([Foo.in], [@foo@
555 AT_DATA([Bar.in], [@bar@
557 AT_DATA([Baz.in], [@baz@
560 AT_DATA([configure.ac],
561 [[AC_INIT
562 AC_CONFIG_AUX_DIR($top_srcdir/build-aux)
563 AC_SUBST([foo], ]m4_for([n], 1, 100,, ....................)[)
564 AC_SUBST([bar], "]m4_for([n], 1, 100,, @ @ @ @ @ @ @ @ @ @@)[")
565 baz="]m4_for([m], 1, 100,, ... ... ... ... ....)[
567 baz=$baz$baz$baz$baz$baz
568 AC_SUBST([baz])
569 AC_PROG_AWK
570 AC_CONFIG_FILES([Foo Bar Baz])
571 AC_OUTPUT
574 AT_CHECK_AUTOCONF
575 # Check both awk and the result of AC_PROG_AWK
576 for awk_arg in Foo= AWK=awk; do
577   AT_CHECK_CONFIGURE([$awk_arg])
578   AT_CHECK([cat Foo], 0, m4_for([n], 1, 100,, ....................)
580   AT_CHECK([cat Bar], 0, m4_for([n], 1, 100,, @ @ @ @ @ @ @ @ @ @@)
582   AT_DATA([stdout],
583   [m4_for([n], 1, 5,, m4_for([m], 1, 100,, ... ... ... ... ....)
585   AT_CHECK([cat Baz], 0, [stdout])
586 done
587 AT_CLEANUP
590 ## ------------------------------ ##
591 ## Define to a 2000-byte string.  ##
592 ## ------------------------------ ##
594 AT_SETUP([Define to a 2000-byte string])
596 AT_CONFIGURE_AC(
598 AC_DEFINE([foo], ]m4_for([n], 1, 100,, ....................)[, [desc])
601 AT_CHECK_AUTOCONF
602 AT_CHECK_AUTOHEADER
603 AT_CHECK_CONFIGURE
604 AT_CHECK_DEFINES([@%:@define foo m4_for([n], 1, 100,, ....................)
606 AT_CLEANUP
609 ## ------------------------------------------ ##
610 ## Substitute and define special characters.  ##
611 ## ------------------------------------------ ##
613 # Use characters special to the shell, sed, awk, and M4.
615 AT_SETUP([Substitute and define special characters])
617 AT_DATA([Foo.in], [@foo@
618 @bar@@notsubsted@@baz@ stray @ and more@@@baz@
619 abc@bar@baz@baz
620 abc@bar@@baz@baz
621 abc@bar@@baz@baz@
622 abc@bar @baz@baz
623 abc@bar @baz@baz@
624 abc@bar @baz@@baz@
625 @file@
626          @file@
627 X@file@
628 @file@X
631 AT_DATA([File],
632 [@foo@@bar@
635 AT_DATA([Zardoz.in], [@zardoz@
638 AT_CONFIGURE_AC(
639 [[foo="AS@&t@_ESCAPE([[X*'[]+ ",& &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !]])"
640 bar="@foo@ @baz@"
641 baz=bla
642 ( for i in 0 1 2 3; do
643     for j in 0 1 2 3 4 5 6 7; do
644       for k in 0 1 2 3 4 5 6 7; do
645         case $i$j$k in #(
646         000) ;; #(
647         *) printf \\$i$j$k's' ;; # The 's' works around a Solaris 8 /bin/bash bug.
648         esac
649       done
650     done
651   done
652   printf \\n
653 ) >allowed-chars
654 zardoz=`cat allowed-chars`
655 AC_SUBST([foo])
656 AC_SUBST([bar])
657 AC_SUBST([baz])
658 AC_SUBST([zardoz])
659 file=File
660 AC_SUBST_FILE([file])
661 AC_DEFINE([foo], [[X*'[]+ ",& &`\($foo !]], [Awful value.])
662 AC_PROG_AWK
663 AC_CONFIG_FILES([Foo Zardoz])]])
665 AT_CHECK_AUTOCONF
666 AT_CHECK_AUTOHEADER
667 # Check both awk and the result of AC_PROG_AWK
668 for awk_arg in FOO= AWK=awk; do
669   AT_CHECK_CONFIGURE([$awk_arg])
670   AT_CHECK([cat Foo], 0, [[X*'[]+ ",& &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !
671 @foo@ @baz@@notsubsted@bla stray @ and more@@bla
672 abc@foo@ @baz@baz@baz
673 abc@foo@ @baz@blabaz
674 abc@foo@ @baz@blabaz@
675 abc@bar blabaz
676 abc@bar blabaz@
677 abc@bar blabla
678 @foo@@bar@
679 @foo@@bar@
680 X@file@
681 @file@X
683   AT_CHECK([cmp allowed-chars Zardoz])
684   AT_CHECK_DEFINES([[#define foo X*'[]+ ",& &`\($foo !
686 done
687 AT_CLEANUP
690 ## ---------------------- ##
691 ## Substitute a newline.  ##
692 ## ---------------------- ##
694 AT_SETUP([Substitute a newline])
696 AT_DATA([Foo.in],
697 [@foo@
698 @bar@
701 AT_DATA([configure.ac],
702 [[AC_INIT
703 AC_CONFIG_AUX_DIR($top_srcdir/build-aux)
704 foo='one
705 two'
706 bar='%!_!# ''
708 AC_SUBST([foo])
709 AC_SUBST([bar])
710 AC_CONFIG_FILES([Foo])
711 AC_PROG_AWK
712 AC_OUTPUT
715 echo 'one
717 %!_!# ''
718 x' >expout
720 AT_CHECK_AUTOCONF
721 # Check both awk and the result of AC_PROG_AWK
722 for awk_arg in FOO= AWK=awk; do
723   AT_CHECK_CONFIGURE([$awk_arg])
724   AT_CHECK([cat Foo], 0, [expout])
725 done
726 AT_CLEANUP
729 ## ------------------ ##
730 ## Define a newline.  ##
731 ## ------------------ ##
733 AT_SETUP([Define a newline])
734 AT_XFAIL_IF(:)
735 AT_CONFIGURE_AC([[AC_DEFINE([foo], [one
736 two], [This spans two lines.])
738 AT_CHECK_AUTOCONF
739 AT_CHECK_AUTOHEADER
740 AT_CHECK_CONFIGURE
741 AT_CHECK_DEFINES([[#define foo one
744 AT_CLEANUP
747 ## ------------------------ ##
748 ## datarootdir workaround.  ##
749 ## ------------------------ ##
751 AT_SETUP([datarootdir workaround])
753 AT_DATA([Foo.in],
754 [@datadir@
755 @docdir@
756 @infodir@
757 @localedir@
758 @mandir@
761 AT_DATA([Bar.in],
762 [@mydatadir@
765 AT_DATA([configure.ac],
766 [[AC_INIT
767 d@&t@nl The following line silences the warnings, if uncommented:
768 d@&t@nl AC_DEFUN([AC_DATAROOTDIR_CHECKED])
769 AC_CONFIG_AUX_DIR($top_srcdir/build-aux)
771 # This substitution is wrong and bogus!  Don't use it in your own code!
772 # Read `info Autoconf "Defining Directories"'!
773 AC_SUBST([mydatadir], [${datadir}/my])
775 AC_CONFIG_FILES([Foo Bar])
776 AC_OUTPUT
779 AT_CHECK_AUTOCONF
780 AT_CHECK_CONFIGURE([], [], [],
781   [config.status: WARNING:  Foo.in seems to ignore the --datarootdir setting
782 config.status: WARNING: Bar contains a reference to the variable `datarootdir'
783 which seems to be undefined.  Please make sure it is defined.
785 AT_CHECK([grep datarootdir Foo], 1, [])
787 rm configure
788 sed '/AC_DEFUN/s/^d@&t@nl //' configure.ac >t
789 mv t configure.ac
791 AT_CHECK_AUTOCONF
792 AT_CHECK_CONFIGURE
794 AT_CLEANUP
797 ## -------- ##
798 ## srcdir.  ##
799 ## -------- ##
801 AT_SETUP([srcdir])
803 rm -f -r at-dir
804 mkdir at-dir
805 : >at-dir/bar.in
806 : >foo.in
808 AT_DATA([configure.ac],
809 [[AC_INIT
811 AC_CONFIG_FILES([foo at-dir/bar])
813 AC_CONFIG_COMMANDS([report],
814 [test -f $srcdir/configure.ac ||
815    AC_MSG_ERROR([cannot find $srcdir/configure.ac])],
816                    [srcdir=$srcdir])
818 AC_OUTPUT
819 rm -f -r foo at-dir/bar
822 AT_CHECK_AUTOCONF
824 # In place.
825 AT_CHECK([./configure], [], [ignore])
827 # Relative name.
828 AT_CHECK([cd at-dir && ../configure], [], [ignore])
830 # Absolute name.
831 at_here=`pwd`
832 AT_CHECK([cd at-dir && "$at_here/configure"], [], [ignore])
834 AT_CLEANUP
837 ## ----------------- ##
838 ## Signal handling.  ##
839 ## ----------------- ##
841 AT_SETUP([Signal handling])
843 AT_DATA([configure.ac],
844 [[AC_INIT
845 kill -2 $$
846 exit 77
849 AT_CHECK_AUTOCONF
850 AT_CHECK_CONFIGURE([], 1, ignore, ignore)
852 AT_CLEANUP
856 AT_BANNER([autoreconf.])
858 ## ---------------------------- ##
859 ## Configuring subdirectories.  ##
860 ## ---------------------------- ##
862 # .
863 # |-- builddir
864 # |   |-- config.log
865 # |   |-- config.status
866 # |   `-- inner
867 # |       |-- config.log
868 # |       |-- config.status
869 # |       `-- innermost
870 # |           `-- config
871 # |-- configure
872 # |-- configure.ac
873 # |-- inner
874 # |   |-- configure
875 # |   |-- configure.ac
876 # |   `-- innermost
877 # |       `-- config.in
878 # `-- install-sh
880 AT_SETUP([Configuring subdirectories])
881 AT_KEYWORDS(autoreconf)
883 # We use aclocal (via autoreconf).
884 AT_CHECK([aclocal --version || exit 77], [], [stdout], [ignore])
885 # It should understand configure.ac.
886 AT_CHECK([[grep '[^0-9]1.[01234][^0-9]' stdout && exit 77]], [1], [ignore])
888 # Set CONFIG_SITE to a nonexistent file, so that there are
889 # no worries about nonstandard values for 'prefix'.
890 CONFIG_SITE=no-such-file
891 export CONFIG_SITE
893 # The contents of `inner/', and `inner/innermost/'.
894 AS_MKDIR_P([inner/innermost])
896 # We have to use configure.in, not configure.ac, if we still want to
897 # be compatible with Automake 1.4: aclocal (run by autoreconf) would
898 # die because it can't find configure.in.
899 AT_DATA([inner/configure.in],
900 [[AC_INIT(GNU Inner, 1.0)
901 AC_CONFIG_SRCDIR([innermost/config.in])
902 AC_ARG_VAR([INNER], [an inner variable])
903 AC_SUBST([INNER])
904 if test "x$INNER" = x; then
905   INNER=inner
907 AC_CONFIG_FILES([innermost/config])
908 AC_OUTPUT
911 AT_DATA([inner/innermost/config.in],
912 [INNER=@INNER@
913 srcdir=@srcdir@
914 top_srcdir=@top_srcdir@
915 prefix=@prefix@
918 # The contents of `.'
919 AT_DATA([install-sh], [])
921 # nonexistent is allowed not to exist.
922 AT_DATA([configure.in],
923 [[AC_INIT(GNU Outer, 1.0)
924 AC_ARG_VAR([OUTER], [an outer variable])
925 if false; then
926   AC_CONFIG_SUBDIRS([nonexistent])
928 AC_CONFIG_SUBDIRS([inner])
929 AC_OUTPUT
932 # If there are improperly quoted AC_DEFUN installed in share/aclocal,
933 # they trigger warnings from aclocal 1.8, so ignore stderr.
934 AT_CHECK([autoreconf], [], [], [ignore])
935 AT_CHECK([test -f inner/configure])
937 # Running the outer configure recursively should provide the innermost
938 # help strings.
939 AT_CHECK([./configure --help=recursive | grep INNER], 0, [ignore])
941 # Running the outer configure should trigger the inner.
942 AT_CHECK_CONFIGURE
943 AT_CHECK([cat inner/innermost/config], 0,
944 [INNER=inner
945 srcdir=.
946 top_srcdir=..
947 prefix=/usr/local
950 # The same, but from a builddir.
951 AS_MKDIR_P([builddir])
952 AT_CHECK([cd builddir && ../configure], 0, [ignore])
953 AT_CHECK([cat builddir/inner/innermost/config], 0,
954 [INNER=inner
955 srcdir=../../../inner/innermost
956 top_srcdir=../../../inner
957 prefix=/usr/local
960 # Make sure precious variables and command line options are properly
961 # passed, even when there are duplicates.
962 AT_CHECK([cd builddir && ../configure --prefix /bad --prefix /good INNER=bad INNER=good], 0, [ignore])
963 AT_CHECK([cat builddir/inner/innermost/config], 0,
964 [INNER=good
965 srcdir=../../../inner/innermost
966 top_srcdir=../../../inner
967 prefix=/good
970 # Make sure --prefix is properly quoted
971 AT_CHECK([cd builddir && ../configure --prefix "/a  b c$ 'd"], 0, [ignore])
972 AT_CHECK([cat builddir/inner/innermost/config], 0,
973 [INNER=inner
974 srcdir=../../../inner/innermost
975 top_srcdir=../../../inner
976 prefix=/a  b c$ 'd
979 # Make sure --silent is properly passed...
980 AT_CHECK([cd builddir && ../configure --silent], 0, [])
981 # ...but not stored in config.status.
982 AT_CHECK([cd builddir && ./config.status --recheck], 0, [stdout])
983 AT_CHECK([grep 'creating \./config.status' stdout], 0, [ignore])
985 # Make sure we can run autoreconf on a subdirectory
986 rm -f configure configure.in
987 AT_CHECK([autoreconf inner], [], [], [ignore])
989 # Make sure we can pass a configure.ac name
990 AT_CHECK([cd inner && autoreconf configure.in], [], [], [ignore])
991 AT_CHECK([autoreconf inner/configure.in], [], [], [ignore])
993 AT_CLEANUP
997 ## -------------- ##
998 ## Deep Package.  ##
999 ## -------------- ##
1001 AT_SETUP([Deep Package])
1002 AT_KEYWORDS(autoreconf)
1004 # We use aclocal (via autoreconf).
1005 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
1007 # The contents of `.'
1008 AT_DATA([install-sh], [])
1009 AT_DATA([configure.in],
1010 [[AC_INIT(GNU Outer, 1.0)
1011 AC_ARG_VAR([OUTER], [an outer variable])
1012 AC_CONFIG_SUBDIRS([inner])
1013 AC_OUTPUT
1016 # The contents of `inner/', and `inner/innermost/'.
1017 AS_MKDIR_P([inner/innermost])
1019 AT_DATA([inner/configure.in],
1020 [[AC_INIT(GNU Inner, 1.0)
1021 AC_ARG_VAR([INNER], [an inner variable])
1022 AC_CONFIG_SUBDIRS(innermost)
1023 AC_OUTPUT
1026 AT_DATA([inner/innermost/configure.in],
1027 [[AC_INIT(GNU Innermost, 1.0)
1028 AC_ARG_VAR([INNERMOST], [an innermost variable])
1029 AC_CONFIG_HEADERS(config.h:config.hin)
1030 AC_DEFINE_UNQUOTED([INNERMOST], [$INNERMOST], [an innermost variable])
1031 AC_OUTPUT
1034 AT_CHECK([autoreconf -Wall -v], [0], [ignore], [ignore])
1035 AT_CHECK([test -f inner/configure])
1036 AT_CHECK([test -f inner/innermost/configure])
1037 AT_CHECK([test -f inner/innermost/config.hin])
1039 # Running the outer configure recursively should provide the innermost
1040 # help strings.
1041 AT_CHECK([./configure --help=recursive | grep " INNER "],     0, [ignore])
1042 AT_CHECK([./configure --help=recursive | grep " INNERMOST "], 0, [ignore])
1044 # Running the outer configure should trigger the inner.
1045 AT_CHECK_CONFIGURE([INNERMOST=tsomrenni])
1046 AT_CHECK([grep INNERMOST inner/innermost/config.h], 0,
1047 [[#define INNERMOST tsomrenni
1050 # The same, but from a builddir.
1051 AS_MKDIR_P([builddir])
1052 AT_CHECK([cd builddir && ../configure INNERMOST=build/tsomrenni], 0, [ignore])
1053 AT_CHECK([grep INNERMOST builddir/inner/innermost/config.h], 0,
1054 [[#define INNERMOST build/tsomrenni
1057 AT_CLEANUP
1061 ## -------------------------------- ##
1062 ## Non-Autoconf AC_CONFIG_SUBDIRS.  ##
1063 ## -------------------------------- ##
1065 AT_SETUP([Non-Autoconf AC_CONFIG_SUBDIRS])
1066 AT_KEYWORDS([autoreconf])
1068 # We use aclocal (via autoreconf).
1069 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
1071 AT_DATA([install-sh], [])
1072 AT_DATA([configure.in],
1073 [[AC_INIT(GNU Outer, 1.0)
1074 AC_CONFIG_SUBDIRS([inner])
1075 AC_OUTPUT
1078 AS_MKDIR_P([inner])
1080 AT_DATA([inner/configure],
1081 [[#! /bin/sh
1082 case "$*" in
1083     *--help*) echo 'No Autoconf here, folks!' ;;
1084     *)        echo got_it >myfile ;;
1085 esac
1086 exit 0
1088 chmod +x inner/configure
1090 AT_CHECK([autoreconf -Wall -v], 0, [ignore], [ignore])
1092 # Running the outer configure recursively should provide the innermost
1093 # help strings.
1094 AT_CHECK([./configure --help=recursive | grep "folks"], 0, [ignore])
1096 # Running the outer configure should trigger the inner.
1097 AT_CHECK([./configure], 0, [ignore])
1098 AT_CHECK([test -f inner/myfile], 0)
1100 AT_CLEANUP
1104 ## ----------------- ##
1105 ## Empty directory.  ##
1106 ## ----------------- ##
1108 AT_SETUP([Empty directory])
1109 AT_KEYWORDS([autoreconf])
1111 # We use aclocal (via autoreconf).
1112 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
1114 # The test group directory is not necessarily _empty_, but it does not contain
1115 # files meaningful to `autoreconf'.
1117 AT_CHECK([autoreconf -Wall -v], 1, [ignore], [ignore])
1119 AT_CLEANUP
1123 ## ------------------------------ ##
1124 ## Unusual Automake input files.  ##
1125 ## ------------------------------ ##
1127 # This parallels gnumake.test in Automake.
1129 AT_SETUP([Unusual Automake input files])
1130 AT_KEYWORDS([autoreconf])
1132 # We use aclocal and automake via autoreconf.
1133 AT_CHECK([automake --version || exit 77], [], [ignore], [ignore])
1135 AT_DATA([configure.in],
1136 [[AC_INIT(GNU foo, 1.0)
1137 AM_INIT_AUTOMAKE
1138 AC_CONFIG_FILES([HeeHee])
1139 AC_OUTPUT
1142 AT_DATA([HeeHee.am],
1143 [[# Humans do no worse than `GNUmakefile.am'.
1144 AUTOMAKE_OPTIONS = foreign 1.8
1147 AT_CHECK([autoreconf -Wall -v -i], 0, [ignore], [stderr],
1148          [AT_CHECK([grep 'require.*1\.8' stderr && exit 77], [1])])
1149 AT_CHECK([test -f HeeHee.in])
1151 AT_CLEANUP