Reword the copyright notices to match what's suggested in GPLv3.
[autoconf/tsuna.git] / tests / torture.at
blob1c30e9e763957bd06613723526df4691585276aa
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 3 of the License, or
9 # (at your option) 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, see <http://www.gnu.org/licenses/>.
20 AT_BANNER([[Testing config.status.]])
23 ## ---------------------------------------- ##
24 ## AC_CONFIG_COMMANDS with empty commands.  ##
25 ## ---------------------------------------- ##
27 AT_CHECK_MACRO([AC_CONFIG_COMMANDS with empty commands],
28 [[AC_CONFIG_COMMANDS([foo], [], [:])
29 ]])
32 ## -------------------------- ##
33 ## Multiple AC_CONFIG_FILES.  ##
34 ## -------------------------- ##
36 AT_SETUP([Multiple AC_CONFIG_FILES])
38 AT_CONFIGURE_AC([[AC_CONFIG_FILES([foo foo])]])
39 AT_CHECK_AUTOCONF([], 1, [], [ignore])
41 AT_CLEANUP
45 ## ------------ ##
46 ## AC_ARG_VAR.  ##
47 ## ------------ ##
49 # AT_CHECK_AC_ARG_VAR(FIRST-VALUE, SECOND-VALUE)
50 # ----------------------------------------------
51 # Check that AC_ARG_VAR caches the latest values, diagnoses
52 # inconsistencies, and arms config.status.
53 m4_define([AT_CHECK_AC_ARG_VAR],
54 [rm -f config.cache
56 # Initial value.
57 m4_ifval([$1],
58          [precious='m4_bpatsubst($1, [[']], ['\\''])'; export precious],
59          [unset precious])
60 AT_CHECK_CONFIGURE([--config-cache -q])
61 AT_CHECK([cat file], [], [`$1'
64 # Testing --recheck: 1. have the environment `forget' about PRECIOUS.
65 unset precious
66 # 2. Rerun config.status to recreate `file'.
67 AT_CHECK([./config.status --recheck], [], [ignore])
68 AT_CHECK([./config.status], [], [ignore])
69 # 3. Check that file contains the old value of PRECIOUS.
70 AT_CHECK([cat file], [], [`$1'
73 # Second value: we should issue an error here: the value
74 # has changed!
75 m4_ifval([$2],
76          [precious='$2'; export precious],
77          [unset precious])
78 AT_CHECK_CONFIGURE([--config-cache], [1], [], [ignore])
80 ])# AT_CHECK_AC_ARG_VAR
83 AT_SETUP([AC_ARG_VAR])
85 # We don't want to run this test if this shell doesn't support
86 # `unset'.
87 AT_CHECK([
88 if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
89   exit 0
90 else
91   exit 77
95 AT_DATA([configure.ac],
96 [[AC_INIT
97 AC_ARG_VAR([precious], [this variable costs a lot])
98 echo "precious:$precious"
99 AC_OUTPUT(file)
102 AT_DATA([file.in],
103 [[`@precious@'
106 AT_CHECK_AUTOCONF
108 # Set a precious variable
109 AT_CHECK_AC_ARG_VAR([], [apple of my eye])
111 # Unset a precious variable
112 AT_CHECK_AC_ARG_VAR([apple of my eye], [])
114 # Change a precious variable
115 AT_CHECK_AC_ARG_VAR([apple of my eye], [orange of my eye])
117 # Change a precious variable that contains braces
118 AT_CHECK_AC_ARG_VAR([apple of my {eye}], [orange of my eye])
120 # Change a precious variable that contains all kinds of fun
121 AT_CHECK_AC_ARG_VAR(['p  r      ec"iou$], [orange of my eye])
123 AT_CLEANUP
128 ## ---------------------------------------------- ##
129 ## AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS.  ##
130 ## ---------------------------------------------- ##
132 AT_SETUP([AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS])
134 AT_DATA([configure.ac],
135 [[AC_INIT
136 rm -f -r header var-header file var-file link var-link command var-command
137 echo 'OK' >input
139 # Be sure to also stress the associated INIT-CMDS.
140 case $what_to_test in
141  header)
142    AC_CONFIG_HEADERS(header:input);;
143  var-header)
144    AC_CONFIG_HEADERS(var-header:$header_in, [], [header_in=input]);;
146  file)
147    AC_CONFIG_FILES(file:input);;
148  var-file)
149    AC_CONFIG_FILES(var-file:$file_in, [], [file_in=input]);;
151  command)
152    AC_CONFIG_COMMANDS(command,
153                       [cp input command]);;
154  var-command)
155    AC_CONFIG_COMMANDS(var-command,
156                       [cp $command_in var-command], [command_in=input]);;
158  link)
159    AC_CONFIG_LINKS(link:input);;
160  var-link)
161    AC_CONFIG_LINKS(var-link:$link_in, [], [link_in=input]);;
162 esac
163 AC_OUTPUT
166 AT_CHECK_AUTOCONF
169 # AT_CHECK_CONFIG_CREATION(THING = (header | link | file | command))
170 # ------------------------------------------------------------------
171 # Check that THING and var-THING (which uses variables in AC_CONFIG_THING)
172 # are properly created, with the right content.
173 # Use `grep OK' instead of a simple `cat' to avoid banners such as in
174 # AC_CONFIG_HEADERS.
175 m4_define([AT_CHECK_CONFIG_CREATION],
176 [AT_CHECK_CONFIGURE([what_to_test=$1])
177 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
178          [ignore], [$1
180 AT_CHECK([grep OK $1], [], [OK
183 AT_CHECK_CONFIGURE([what_to_test=var-$1 --no-create])
184 # config.status might be stupidly expecting data on stdin, if it's
185 # really broken...
186 AT_CHECK([./config.status var-$1 </dev/null], [], [ignore])
187 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
188          [ignore], [var-$1
190 AT_CHECK([grep OK var-$1], [], [OK
192 ])# AT_CHECK_CONFIG_CREATION
195 # Create a file
196 AT_CHECK_CONFIG_CREATION(file)
198 # Create a header
199 AT_CHECK_CONFIG_CREATION(header)
201 # Execute a command
202 AT_CHECK_CONFIG_CREATION(command)
204 # Create a link
205 AT_CHECK_CONFIG_CREATION(link)
207 AT_CLEANUP
211 ## ---------------------------------------- ##
212 ## Macro calls in AC_CONFIG_COMMANDS tags.  ##
213 ## ---------------------------------------- ##
215 AT_SETUP([Macro calls in AC_CONFIG_COMMANDS tags])
217 AT_DATA_M4SUGAR([configure.ac],
218 [[AC_INIT
219 AC_CONFIG_COMMANDS([m4_if(1,1,mytag)])
220 AC_OUTPUT
223 AT_CHECK_AUTOCONF
224 AT_CHECK_CONFIGURE
226 AT_CLEANUP
230 ## ------------------- ##
231 ## Missing templates.  ##
232 ## ------------------- ##
234 # Check that config.status detects missing input files
235 AT_SETUP([Missing templates])
237 AT_DATA([configure.ac],
238 [[AC_INIT
239 AC_CONFIG_FILES([nonexistent])
240 AC_OUTPUT
243 AT_CHECK_AUTOCONF
244 AT_CHECK_CONFIGURE([], [1], [],
245 [[config.status: error: cannot find input file: nonexistent.in
247 # Make sure that the output file doesn't exist
248 AT_CHECK([test -f nonexistent], 1)
250 AT_CLEANUP
255 ## ---------------------- ##
256 ## configure invocation.  ##
257 ## ---------------------- ##
259 # Check that `configure' and `config.status' honor their interface.
261 # We run `./configure one=val1 --enable-two=val2 --with-three=val3'
262 # and verify that (i) `configure' correctly receives the arguments,
263 # (ii) correctly passes them to `config.status', which we check by
264 # running `config.status --recheck', and (iii) correctly passes them
265 # to sub-configure scripts.
267 AT_SETUP([configure invocation])
269 mkdir sub
271 AT_DATA([configure.ac],
272 [[AC_INIT
273 AC_CONFIG_SUBDIRS([sub])
274 echo "result=$one$enable_two$with_three"
275 AC_OUTPUT
278 AT_DATA([sub/configure.ac],
279 [[AC_INIT
280 echo "result=$one$enable_two$with_three"
281 AC_OUTPUT
284 echo fake install-sh script >install-sh
286 AT_CHECK_AUTOCONF
287 cd sub
288 AT_CHECK_AUTOCONF
289 cd ..
291 AT_CHECK_CONFIGURE([one=one --enable-two=two --with-three=three |
292                      sed -n -e 's/^result=//p'], 0,
293                    [m4_do([onetwothree
294 ],                        [onetwothree
295 ])])
296 AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
297          [onetwothree
300 AT_CHECK_CONFIGURE([one="\"'$ " --enable-two="\" '  $" --with-three="   \"'$"|
301                       sed -n -e 's/^result=//p'], 0,
302                    [m4_do(["'$ " '  $   "'$
303 ],                        ["'$ " '  $   "'$
304 ])])
305 AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
306          ["'$ " '  $    "'$
309 AT_CLEANUP
313 ## -------------------------------------------- ##
314 ## Check that `#define' templates are honored.  ##
315 ## -------------------------------------------- ##
317 # Use various forms of `#define' templates, and make sure there are no
318 # problems when a symbol is prefix of another.
320 AT_SETUP([[#define header templates]])
322 AT_DATA([configure.ac],
323 [[AC_INIT
324 AC_CONFIG_HEADERS(config.h:config.hin)
326 # I18n of dummy variables: their French translations.
327 AC_DEFINE(foo, toto)
328 AC_DEFINE(bar, tata)
329 AC_DEFINE(baz, titi)
330 AC_DEFINE(fubar, tutu)
332 # Symbols which are prefixes of another.
333 AC_DEFINE(a, A)
334 AC_DEFINE(aaa, AAA)
335 AC_DEFINE(aa, AA)
336 AC_CONFIG_FILES(defs)
338 # Things included in confdefs.h, but which make no sense in
339 # config.h, nor in $DEFS.
340 cat <<\EOF >>confdefs.h
341 /* Hi Mum! Look, I am doing C++! */
342 #ifdef __cplusplus
343 void exit (int status);
344 #endif
347 # In addition of config.h output a full DEFS
348 AC_OUTPUT_MAKE_DEFS
349 DEFS_SAVED=$DEFS
350 AC_SUBST(DEFS_SAVED)
351 AC_OUTPUT
354 AT_DATA([defs.in],
355 [[@DEFS_SAVED@
358 AT_DATA([config.hin],
359 [[#define foo   0
360 #  define bar bar
361 #  define baz   "Archimedes was sinking in his baz"
362 #  define fubar                         tutu
363 #define a B
364 #define aa BB
365 #define aaa BBB
366 #undef a
367 #undef aa
368 #undef aaa
371 AT_CHECK_AUTOCONF
372 AT_CHECK_CONFIGURE
374 AT_DATA([expout],
375 [[/* config.h.  Generated from config.hin by configure.  */
376 #define foo toto
377 #  define bar tata
378 #  define baz titi
379 #  define fubar tutu
380 #define a A
381 #define aa AA
382 #define aaa AAA
383 #define a A
384 #define aa AA
385 #define aaa AAA
387 AT_CHECK([cat config.h], 0, expout)
389 # Check the value of DEFS.
390 AT_DATA([expout],
391 [[-DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -Dfoo=toto -Dbar=tata -Dbaz=titi -Dfubar=tutu -Da=A -Daaa=AAA -Daa=AA
394 # Because we strip trailing spaces in `testsuite' we can't leave one in
395 # expout, hence nuke the one left by AC_OUTPUT_MAKE_DEFS.
396 AT_CHECK([sed -e 's/ $//' defs], 0, expout)
398 AT_CLEANUP
402 ## ------------------------- ##
403 ## Torturing config.status.  ##
404 ## ------------------------- ##
406 ## Require 100 AC_DEFINE and AC_SUBST and AC_SUBST_FILE with a significantly
407 ## big value.  This is mostly to check that Autoconf produces portable sed
408 ## scripts in config.status.  sed is used to skip the first two lines
409 ## `Generated by...'.
411 # We use m4_for many times.
412 m4_pattern_allow([^m4_for$])
414 AT_SETUP([Torturing config.status])
416 dnl The value used as a big value for AC_DEFINE.
417 dnl Don't use sh active chars here, below it is also used in a sh
418 dnl assignment.
419 m4_define([AT_BIG_VALUE],
420 [This value should be long enough to torture the various limits of sed and other tools used by Autoconf.])
422 m4_define([AT_DESCRIPTION],
423 [Define to a long string if your `Autoconf' works properly.])
426 # AT_DUMMY_VAR(NUMBER)
427 # --------------------
428 # Build a name used for AC_SUBST and AC_DEFINE.  Put ac_ in it
429 # so that the check for user name space invasion does not complain
430 # of the new variables defined.
432 # Note that you should not use the name ac_dummy, because it will be
433 # turned into ac_uummy during the construction of config.status.  Yes,
434 # this is admittedly a bug, but it would be too hard to fix this.
435 # There is really no point in AC_DEFINE a var named ac_d.*.
436 m4_pattern_allow([^m4_bpatsubst$])
437 m4_define([AT_DUMMY_VAR],
438 [ac_Dummy_[]m4_bpatsubst([000$1], [.*\(...\)$], [\1])])
442 AT_DATA([dummy.in],
443 [m4_for([AT_Count], 1, 100, 1,
444 [@AT_DUMMY_VAR(AT_Count)@
445 @[f]AT_Count@
446 ])])
450 while test $i != 101; do
451   echo "content of file $i" > file_$i
452   i=`expr $i + 1`
453 done
456 # ------------ #
457 # configure.ac #
458 # ------------ #
460 m4_pattern_allow([^m4_(define|defun)$])
461 AT_DATA([configure.ac],
462 dnl The following lines transfer AT_DUMMY_VAR, AT_DESCRIPTION, and
463 dnl AT_BIG_VALUE into the configure.ac as AC_DUMMY_VAR etc.
464 [[m4_define([AC_DUMMY_VAR],]
465 m4_dquote(m4_defn([AT_DUMMY_VAR]))[)]]
467 [[m4_define([AC_DESCRIPTION],]
468 m4_dquote(m4_defn([AT_DESCRIPTION]))[)]]
470 [[m4_define([AC_BIG_VALUE],]
471 m4_dquote(m4_defn([AT_BIG_VALUE]))[)]]
473 [[# AC_DEFUBST(NAME)
474 # ----------------
475 # Related VALUE to NAME both with AC_SUBST and AC_DEFINE.  This is
476 # used in the torture tests.
477 m4_defun([AC_DEFUBST],
478 [AC_DUMMY_VAR($1)="AC_BIG_VALUE"
479 AC_DEFINE_UNQUOTED(AC_DUMMY_VAR($1), "$AC_DUMMY_VAR($1)",
480                    AC_DESCRIPTION)
481 AC_SUBST(AC_DUMMY_VAR($1))
482 AC_SUBST_FILE([f]$1)
483 f$1=file_$1
486 AC_INIT
487 AC_CONFIG_HEADERS(config.h:config.hin)
488 AC_CONFIG_FILES(dummy)
489 m4_for(AC_Count, 1, 100, 1,
490        [AC_DEFUBST(AC_Count)])
491 AC_PROG_AWK
492 AC_OUTPUT
493 ]])# configure.ac
495 AT_CHECK_AUTOCONF
496 AT_CHECK_AUTOHEADER
497 # Check both awk and the result of AC_PROG_AWK
498 for awk_arg in FOO= AWK=awk; do
499   AT_CHECK_CONFIGURE([$awk_arg])
501   # Checking that AC_DEFINE worked properly.
502   AT_DATA([expout],
503 [/* Define to the address where bug reports for this package should be sent. */
504 #define PACKAGE_BUGREPORT ""
506 /* Define to the full name of this package. */
507 #define PACKAGE_NAME ""
509 /* Define to the full name and version of this package. */
510 #define PACKAGE_STRING ""
512 /* Define to the one symbol short name of this package. */
513 #define PACKAGE_TARNAME ""
515 /* Define to the version of this package. */
516 #define PACKAGE_VERSION ""
517 m4_for(AT_Count, 1, 100, 1,
519 /* AT_DESCRIPTION */
520 [#define] AT_DUMMY_VAR(AT_Count) "AT_BIG_VALUE"
521 ])])
523   AT_CHECK([sed -n '4,$ p' config.h], 0, expout)
525   # Checking that AC_SUBST worked properly.
526   AT_DATA([expout],
527 [m4_for(AT_Count, 1, 100, 1,
528 [AT_BIG_VALUE
529 content of file AT_Count
530 ])])
532   AT_CHECK([cat dummy], 0, expout)
533 done
535 AT_CLEANUP
538 ## ------------------------------- ##
539 ## Substitute a 2000-byte string.  ##
540 ## ------------------------------- ##
542 # Solaris 9 /usr/ucb/sed that rejects commands longer than 4000 bytes.  HP/UX
543 # sed dumps core around 8 KiB.  However, POSIX says that sed need not
544 # handle lines longer than 2048 bytes (including the trailing newline).
545 # So we'll just test a 2000-byte value, and for awk, we test a line with
546 # almost 1000 words, and one variable with 5 lines of 2000 bytes each:
547 # multi-line values should allow to get around the limitations.
549 AT_SETUP([Substitute a 2000-byte string])
551 AT_DATA([Foo.in], [@foo@
553 AT_DATA([Bar.in], [@bar@
555 AT_DATA([Baz.in], [@baz@
558 AT_DATA([configure.ac],
559 [[AC_INIT
560 AC_CONFIG_AUX_DIR($top_srcdir/build-aux)
561 AC_SUBST([foo], ]m4_for([n], 1, 100,, ....................)[)
562 AC_SUBST([bar], "]m4_for([n], 1, 100,, @ @ @ @ @ @ @ @ @ @@)[")
563 baz="]m4_for([m], 1, 100,, ... ... ... ... ....)[
565 baz=$baz$baz$baz$baz$baz
566 AC_SUBST([baz])
567 AC_PROG_AWK
568 AC_CONFIG_FILES([Foo Bar Baz])
569 AC_OUTPUT
572 AT_CHECK_AUTOCONF
573 # Check both awk and the result of AC_PROG_AWK
574 for awk_arg in Foo= AWK=awk; do
575   AT_CHECK_CONFIGURE([$awk_arg])
576   AT_CHECK([cat Foo], 0, m4_for([n], 1, 100,, ....................)
578   AT_CHECK([cat Bar], 0, m4_for([n], 1, 100,, @ @ @ @ @ @ @ @ @ @@)
580   AT_DATA([stdout],
581   [m4_for([n], 1, 5,, m4_for([m], 1, 100,, ... ... ... ... ....)
583   AT_CHECK([cat Baz], 0, [stdout])
584 done
585 AT_CLEANUP
588 ## ------------------------------ ##
589 ## Define to a 2000-byte string.  ##
590 ## ------------------------------ ##
592 AT_SETUP([Define to a 2000-byte string])
594 AT_CONFIGURE_AC(
596 AC_DEFINE([foo], ]m4_for([n], 1, 100,, ....................)[, [desc])
599 AT_CHECK_AUTOCONF
600 AT_CHECK_AUTOHEADER
601 AT_CHECK_CONFIGURE
602 AT_CHECK_DEFINES([@%:@define foo m4_for([n], 1, 100,, ....................)
604 AT_CLEANUP
607 ## ------------------------------------------ ##
608 ## Substitute and define special characters.  ##
609 ## ------------------------------------------ ##
611 # Use characters special to the shell, sed, awk, and M4.
613 AT_SETUP([Substitute and define special characters])
615 AT_DATA([Foo.in], [@foo@
616 @bar@@notsubsted@@baz@ stray @ and more@@@baz@
617 abc@bar@baz@baz
618 abc@bar@@baz@baz
619 abc@bar@@baz@baz@
620 abc@bar @baz@baz
621 abc@bar @baz@baz@
622 abc@bar @baz@@baz@
623 @file@
624          @file@
625 X@file@
626 @file@X
629 AT_DATA([File],
630 [@foo@@bar@
633 AT_DATA([Zardoz.in], [@zardoz@
636 AT_CONFIGURE_AC(
637 [[foo="AS@&t@_ESCAPE([[X*'[]+ ",& &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !]])"
638 bar="@foo@ @baz@"
639 baz=bla
640 ( for i in 0 1 2 3; do
641     for j in 0 1 2 3 4 5 6 7; do
642       for k in 0 1 2 3 4 5 6 7; do
643         case $i$j$k in #(
644         000) ;; #(
645         *) printf \\$i$j$k's' ;; # The 's' works around a Solaris 8 /bin/bash bug.
646         esac
647       done
648     done
649   done
650   printf \\n
651 ) >allowed-chars
652 zardoz=`cat allowed-chars`
653 AC_SUBST([foo])
654 AC_SUBST([bar])
655 AC_SUBST([baz])
656 AC_SUBST([zardoz])
657 file=File
658 AC_SUBST_FILE([file])
659 AC_DEFINE([foo], [[X*'[]+ ",& &`\($foo !]], [Awful value.])
660 AC_PROG_AWK
661 AC_CONFIG_FILES([Foo Zardoz])]])
663 AT_CHECK_AUTOCONF
664 AT_CHECK_AUTOHEADER
665 # Check both awk and the result of AC_PROG_AWK
666 for awk_arg in FOO= AWK=awk; do
667   AT_CHECK_CONFIGURE([$awk_arg])
668   AT_CHECK([cat Foo], 0, [[X*'[]+ ",& &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !
669 @foo@ @baz@@notsubsted@bla stray @ and more@@bla
670 abc@foo@ @baz@baz@baz
671 abc@foo@ @baz@blabaz
672 abc@foo@ @baz@blabaz@
673 abc@bar blabaz
674 abc@bar blabaz@
675 abc@bar blabla
676 @foo@@bar@
677 @foo@@bar@
678 X@file@
679 @file@X
681   AT_CHECK([cmp allowed-chars Zardoz])
682   AT_CHECK_DEFINES([[#define foo X*'[]+ ",& &`\($foo !
684 done
685 AT_CLEANUP
688 ## ---------------------- ##
689 ## Substitute a newline.  ##
690 ## ---------------------- ##
692 AT_SETUP([Substitute a newline])
694 AT_DATA([Foo.in],
695 [@foo@
696 @bar@
699 AT_DATA([configure.ac],
700 [[AC_INIT
701 AC_CONFIG_AUX_DIR($top_srcdir/build-aux)
702 foo='one
703 two'
704 bar='%!_!# ''
706 AC_SUBST([foo])
707 AC_SUBST([bar])
708 AC_CONFIG_FILES([Foo])
709 AC_PROG_AWK
710 AC_OUTPUT
713 echo 'one
715 %!_!# ''
716 x' >expout
718 AT_CHECK_AUTOCONF
719 # Check both awk and the result of AC_PROG_AWK
720 for awk_arg in FOO= AWK=awk; do
721   AT_CHECK_CONFIGURE([$awk_arg])
722   AT_CHECK([cat Foo], 0, [expout])
723 done
724 AT_CLEANUP
727 ## ------------------ ##
728 ## Define a newline.  ##
729 ## ------------------ ##
731 AT_SETUP([Define a newline])
732 AT_XFAIL_IF(:)
733 AT_CONFIGURE_AC([[AC_DEFINE([foo], [one
734 two], [This spans two lines.])
736 AT_CHECK_AUTOCONF
737 AT_CHECK_AUTOHEADER
738 AT_CHECK_CONFIGURE
739 AT_CHECK_DEFINES([[#define foo one
742 AT_CLEANUP
745 ## ------------------------------------ ##
746 ## AC_SUBST: variable name validation.  ##
747 ## ------------------------------------ ##
749 AT_SETUP([AC_SUBST: variable name validation])
751 AT_CONFIGURE_AC([[AC_SUBST(, [])
752 AC_CONFIG_FILES([Makefile])
754 AT_DATA([Makefile.in], [[
756 mv -f configure.ac configure.tmpl
758 # Invalid names.
759 for var in ['' ab\~ ab\( ab[] ab\' ab\" ab\\\\]; do
760   sed ["s/AC_SUBST(/&[$var]/"] <configure.tmpl >configure.ac
761   AT_CHECK_AUTOCONF([], [1], [], [ignore])
762 done
764 # Valid names.
765 for var in ab a4 'a@@&t@\&t@b'; do
766   sed ["s/AC_SUBST(/&[$var]/"] <configure.tmpl >configure.ac
767   AT_CHECK_AUTOCONF
768   AT_CHECK_AUTOHEADER
769   AT_CHECK_CONFIGURE
770 done
772 AT_CLEANUP
775 ## ------------------------ ##
776 ## datarootdir workaround.  ##
777 ## ------------------------ ##
779 AT_SETUP([datarootdir workaround])
781 AT_DATA([Foo.in],
782 [@datadir@
783 @docdir@
784 @infodir@
785 @localedir@
786 @mandir@
789 AT_DATA([Bar.in],
790 [@mydatadir@
793 AT_DATA([configure.ac],
794 [[AC_INIT
795 d@&t@nl The following line silences the warnings, if uncommented:
796 d@&t@nl AC_DEFUN([AC_DATAROOTDIR_CHECKED])
797 AC_CONFIG_AUX_DIR($top_srcdir/build-aux)
799 # This substitution is wrong and bogus!  Don't use it in your own code!
800 # Read `info Autoconf "Defining Directories"'!
801 AC_SUBST([mydatadir], [${datadir}/my])
803 AC_CONFIG_FILES([Foo Bar])
804 AC_OUTPUT
807 AT_CHECK_AUTOCONF
808 AT_CHECK_CONFIGURE([], [], [],
809   [config.status: WARNING:  Foo.in seems to ignore the --datarootdir setting
810 config.status: WARNING: Bar contains a reference to the variable `datarootdir'
811 which seems to be undefined.  Please make sure it is defined.
813 AT_CHECK([grep datarootdir Foo], 1, [])
815 rm configure
816 sed '/AC_DEFUN/s/^d@&t@nl //' configure.ac >t
817 mv t configure.ac
819 AT_CHECK_AUTOCONF
820 AT_CHECK_CONFIGURE
822 AT_CLEANUP
825 ## -------- ##
826 ## srcdir.  ##
827 ## -------- ##
829 AT_SETUP([srcdir])
831 rm -f -r at-dir
832 mkdir at-dir
833 : >at-dir/bar.in
834 : >foo.in
836 AT_DATA([configure.ac],
837 [[AC_INIT
839 AC_CONFIG_FILES([foo at-dir/bar])
841 AC_CONFIG_COMMANDS([report],
842 [test -f $srcdir/configure.ac ||
843    AC_MSG_ERROR([cannot find $srcdir/configure.ac])],
844                    [srcdir=$srcdir])
846 AC_OUTPUT
847 rm -f -r foo at-dir/bar
850 AT_CHECK_AUTOCONF
852 # In place.
853 AT_CHECK([./configure], [], [ignore])
855 # Relative name.
856 AT_CHECK([cd at-dir && ../configure], [], [ignore])
858 # Absolute name.
859 at_here=`pwd`
860 AT_CHECK([cd at-dir && "$at_here/configure"], [], [ignore])
862 AT_CLEANUP
865 ## ----------------- ##
866 ## Signal handling.  ##
867 ## ----------------- ##
869 AT_SETUP([Signal handling])
871 AT_DATA([configure.ac],
872 [[AC_INIT
873 kill -2 $$
874 exit 77
877 AT_CHECK_AUTOCONF
878 AT_CHECK_CONFIGURE([], 1, ignore, ignore)
880 AT_CLEANUP
884 AT_BANNER([autoreconf.])
886 ## ---------------------------- ##
887 ## Configuring subdirectories.  ##
888 ## ---------------------------- ##
890 # .
891 # |-- builddir
892 # |   |-- config.log
893 # |   |-- config.status
894 # |   `-- inner
895 # |       |-- config.log
896 # |       |-- config.status
897 # |       `-- innermost
898 # |           `-- config
899 # |-- configure
900 # |-- configure.ac
901 # |-- inner
902 # |   |-- configure
903 # |   |-- configure.ac
904 # |   `-- innermost
905 # |       `-- config.in
906 # `-- install-sh
908 AT_SETUP([Configuring subdirectories])
909 AT_KEYWORDS(autoreconf)
911 # We use aclocal (via autoreconf).
912 AT_CHECK([aclocal --version || exit 77], [], [stdout], [ignore])
913 # It should understand configure.ac.
914 AT_CHECK([[grep '[^0-9]1.[01234][^0-9]' stdout && exit 77]], [1], [ignore])
916 # Set CONFIG_SITE to a nonexistent file, so that there are
917 # no worries about nonstandard values for 'prefix'.
918 CONFIG_SITE=no-such-file
919 export CONFIG_SITE
921 # The contents of `inner/', and `inner/innermost/'.
922 AS_MKDIR_P([inner/innermost])
924 # We have to use configure.in, not configure.ac, if we still want to
925 # be compatible with Automake 1.4: aclocal (run by autoreconf) would
926 # die because it can't find configure.in.
927 AT_DATA([inner/configure.in],
928 [[AC_INIT(GNU Inner, 1.0)
929 AC_CONFIG_SRCDIR([innermost/config.in])
930 AC_ARG_VAR([INNER], [an inner variable])
931 AC_SUBST([INNER])
932 if test "x$INNER" = x; then
933   INNER=inner
935 AC_CONFIG_FILES([innermost/config])
936 AC_OUTPUT
939 AT_DATA([inner/innermost/config.in],
940 [INNER=@INNER@
941 srcdir=@srcdir@
942 top_srcdir=@top_srcdir@
943 prefix=@prefix@
946 # The contents of `.'
947 AT_DATA([install-sh], [])
949 # nonexistent is allowed not to exist.
950 AT_DATA([configure.in],
951 [[AC_INIT(GNU Outer, 1.0)
952 AC_ARG_VAR([OUTER], [an outer variable])
953 if false; then
954   AC_CONFIG_SUBDIRS([nonexistent])
956 AC_CONFIG_SUBDIRS([inner])
957 AC_OUTPUT
960 # If there are improperly quoted AC_DEFUN installed in share/aclocal,
961 # they trigger warnings from aclocal 1.8, so ignore stderr.
962 AT_CHECK([autoreconf], [], [], [ignore])
963 AT_CHECK([test -f inner/configure])
965 # Running the outer configure recursively should provide the innermost
966 # help strings.
967 AT_CHECK([./configure --help=recursive | grep INNER], 0, [ignore])
969 # Running the outer configure should trigger the inner.
970 AT_CHECK_CONFIGURE
971 AT_CHECK([cat inner/innermost/config], 0,
972 [INNER=inner
973 srcdir=.
974 top_srcdir=..
975 prefix=/usr/local
978 # The same, but from a builddir.
979 AS_MKDIR_P([builddir])
980 AT_CHECK([cd builddir && ../configure], 0, [ignore])
981 AT_CHECK([cat builddir/inner/innermost/config], 0,
982 [INNER=inner
983 srcdir=../../../inner/innermost
984 top_srcdir=../../../inner
985 prefix=/usr/local
988 # Make sure precious variables and command line options are properly
989 # passed, even when there are duplicates.
990 AT_CHECK([cd builddir && ../configure --prefix /bad --prefix /good INNER=bad INNER=good], 0, [ignore])
991 AT_CHECK([cat builddir/inner/innermost/config], 0,
992 [INNER=good
993 srcdir=../../../inner/innermost
994 top_srcdir=../../../inner
995 prefix=/good
998 # Make sure --prefix is properly quoted
999 AT_CHECK([cd builddir && ../configure --prefix "/a  b c$ 'd"], 0, [ignore])
1000 AT_CHECK([cat builddir/inner/innermost/config], 0,
1001 [INNER=inner
1002 srcdir=../../../inner/innermost
1003 top_srcdir=../../../inner
1004 prefix=/a  b c$ 'd
1007 # Make sure --silent is properly passed...
1008 AT_CHECK([cd builddir && ../configure --silent], 0, [])
1009 # ...but not stored in config.status.
1010 AT_CHECK([cd builddir && ./config.status --recheck], 0, [stdout])
1011 AT_CHECK([grep 'creating \./config.status' stdout], 0, [ignore])
1013 # Make sure we can run autoreconf on a subdirectory
1014 rm -f configure configure.in
1015 AT_CHECK([autoreconf inner], [], [], [ignore])
1017 # Make sure we can pass a configure.ac name
1018 AT_CHECK([cd inner && autoreconf configure.in], [], [], [ignore])
1019 AT_CHECK([autoreconf inner/configure.in], [], [], [ignore])
1021 AT_CLEANUP
1025 ## -------------- ##
1026 ## Deep Package.  ##
1027 ## -------------- ##
1029 AT_SETUP([Deep Package])
1030 AT_KEYWORDS(autoreconf)
1032 # We use aclocal (via autoreconf).
1033 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
1035 # The contents of `.'
1036 AT_DATA([install-sh], [])
1037 AT_DATA([configure.in],
1038 [[AC_INIT(GNU Outer, 1.0)
1039 AC_ARG_VAR([OUTER], [an outer variable])
1040 AC_CONFIG_SUBDIRS([inner])
1041 AC_OUTPUT
1044 # The contents of `inner/', and `inner/innermost/'.
1045 AS_MKDIR_P([inner/innermost])
1047 AT_DATA([inner/configure.in],
1048 [[AC_INIT(GNU Inner, 1.0)
1049 AC_ARG_VAR([INNER], [an inner variable])
1050 AC_CONFIG_SUBDIRS(innermost)
1051 AC_OUTPUT
1054 AT_DATA([inner/innermost/configure.in],
1055 [[AC_INIT(GNU Innermost, 1.0)
1056 AC_ARG_VAR([INNERMOST], [an innermost variable])
1057 AC_CONFIG_HEADERS(config.h:config.hin)
1058 AC_DEFINE_UNQUOTED([INNERMOST], [$INNERMOST], [an innermost variable])
1059 AC_OUTPUT
1062 AT_CHECK([autoreconf -Wall -v], [0], [ignore], [ignore])
1063 AT_CHECK([test -f inner/configure])
1064 AT_CHECK([test -f inner/innermost/configure])
1065 AT_CHECK([test -f inner/innermost/config.hin])
1067 # Running the outer configure recursively should provide the innermost
1068 # help strings.
1069 AT_CHECK([./configure --help=recursive | grep " INNER "],     0, [ignore])
1070 AT_CHECK([./configure --help=recursive | grep " INNERMOST "], 0, [ignore])
1072 # Running the outer configure should trigger the inner.
1073 AT_CHECK_CONFIGURE([INNERMOST=tsomrenni])
1074 AT_CHECK([grep INNERMOST inner/innermost/config.h], 0,
1075 [[#define INNERMOST tsomrenni
1078 # The same, but from a builddir.
1079 AS_MKDIR_P([builddir])
1080 AT_CHECK([cd builddir && ../configure INNERMOST=build/tsomrenni], 0, [ignore])
1081 AT_CHECK([grep INNERMOST builddir/inner/innermost/config.h], 0,
1082 [[#define INNERMOST build/tsomrenni
1085 AT_CLEANUP
1089 ## -------------------------------- ##
1090 ## Non-Autoconf AC_CONFIG_SUBDIRS.  ##
1091 ## -------------------------------- ##
1093 AT_SETUP([Non-Autoconf AC_CONFIG_SUBDIRS])
1094 AT_KEYWORDS([autoreconf])
1096 # We use aclocal (via autoreconf).
1097 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
1099 AT_DATA([install-sh], [])
1100 AT_DATA([configure.in],
1101 [[AC_INIT(GNU Outer, 1.0)
1102 AC_CONFIG_SUBDIRS([inner])
1103 AC_OUTPUT
1106 AS_MKDIR_P([inner])
1108 AT_DATA([inner/configure],
1109 [[#! /bin/sh
1110 case "$*" in
1111     *--help*) echo 'No Autoconf here, folks!' ;;
1112     *)        echo got_it >myfile ;;
1113 esac
1114 exit 0
1116 chmod +x inner/configure
1118 AT_CHECK([autoreconf -Wall -v], 0, [ignore], [ignore])
1120 # Running the outer configure recursively should provide the innermost
1121 # help strings.
1122 AT_CHECK([./configure --help=recursive | grep "folks"], 0, [ignore])
1124 # Running the outer configure should trigger the inner.
1125 AT_CHECK([./configure], 0, [ignore])
1126 AT_CHECK([test -f inner/myfile], 0)
1128 AT_CLEANUP
1132 ## ----------------- ##
1133 ## Empty directory.  ##
1134 ## ----------------- ##
1136 AT_SETUP([Empty directory])
1137 AT_KEYWORDS([autoreconf])
1139 # We use aclocal (via autoreconf).
1140 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
1142 # The test group directory is not necessarily _empty_, but it does not contain
1143 # files meaningful to `autoreconf'.
1145 AT_CHECK([autoreconf -Wall -v], 1, [ignore], [ignore])
1147 AT_CLEANUP
1151 ## ------------------------------ ##
1152 ## Unusual Automake input files.  ##
1153 ## ------------------------------ ##
1155 # This parallels gnumake.test in Automake.
1157 AT_SETUP([Unusual Automake input files])
1158 AT_KEYWORDS([autoreconf])
1160 # We use aclocal and automake via autoreconf.
1161 AT_CHECK([automake --version || exit 77], [], [ignore], [ignore])
1163 AT_DATA([configure.in],
1164 [[AC_INIT(GNU foo, 1.0)
1165 AM_INIT_AUTOMAKE
1166 AC_CONFIG_FILES([HeeHee])
1167 AC_OUTPUT
1170 AT_DATA([HeeHee.am],
1171 [[# Humans do no worse than `GNUmakefile.am'.
1172 AUTOMAKE_OPTIONS = foreign 1.8
1175 AT_CHECK([autoreconf -Wall -v -i], 0, [ignore], [stderr],
1176          [AT_CHECK([grep 'require.*1\.8' stderr && exit 77], [1])])
1177 AT_CHECK([test -f HeeHee.in])
1179 AT_CLEANUP