Add a `--clean' option for autoconf, autoheader, autoreconf and autom4te.
[autoconf/tsuna.git] / tests / torture.at
blob58ce32feb03289b18087cf8b6be1792d53a9a733
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])
122 dnl restore font-lock: "
124 AT_CLEANUP
129 ## ---------------------------------------------- ##
130 ## AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS.  ##
131 ## ---------------------------------------------- ##
133 AT_SETUP([[AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS]])
135 AT_DATA([configure.ac],
136 [[AC_INIT
137 rm -f -r header var-header file var-file link var-link command var-command
138 echo 'OK' >input
140 # Be sure to also stress the associated INIT-CMDS.
141 case $what_to_test in
142  header)
143    AC_CONFIG_HEADERS(header:input);;
144  var-header)
145    AC_CONFIG_HEADERS(var-header:$header_in, [], [header_in=input]);;
147  file)
148    AC_CONFIG_FILES(file:input);;
149  var-file)
150    AC_CONFIG_FILES(var-file:$file_in, [], [file_in=input]);;
152  command)
153    AC_CONFIG_COMMANDS(command,
154                       [cp input command]);;
155  var-command)
156    AC_CONFIG_COMMANDS(var-command,
157                       [cp $command_in var-command], [command_in=input]);;
159  link)
160    AC_CONFIG_LINKS(link:input);;
161  var-link)
162    AC_CONFIG_LINKS(var-link:$link_in, [], [link_in=input]);;
163 esac
164 AC_OUTPUT
167 AT_CHECK_AUTOCONF
170 # AT_CHECK_CONFIG_CREATION(THING = (header | link | file | command))
171 # ------------------------------------------------------------------
172 # Check that THING and var-THING (which uses variables in AC_CONFIG_THING)
173 # are properly created, with the right content.
174 # Use `grep OK' instead of a simple `cat' to avoid banners such as in
175 # AC_CONFIG_HEADERS.
176 m4_define([AT_CHECK_CONFIG_CREATION],
177 [AT_CHECK_CONFIGURE([what_to_test=$1])
178 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
179          [ignore], [$1
181 AT_CHECK([grep OK $1], [], [OK
184 AT_CHECK_CONFIGURE([what_to_test=var-$1 --no-create])
185 # config.status might be stupidly expecting data on stdin, if it's
186 # really broken...
187 AT_CHECK([./config.status var-$1 </dev/null], [], [ignore])
188 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
189          [ignore], [var-$1
191 AT_CHECK([grep OK var-$1], [], [OK
193 ])# AT_CHECK_CONFIG_CREATION
196 # Create a file
197 AT_CHECK_CONFIG_CREATION(file)
199 # Create a header
200 AT_CHECK_CONFIG_CREATION(header)
202 # Execute a command
203 AT_CHECK_CONFIG_CREATION(command)
205 # Create a link
206 AT_CHECK_CONFIG_CREATION(link)
208 AT_CLEANUP
212 ## ---------------------------------------- ##
213 ## Macro calls in AC_CONFIG_COMMANDS tags.  ##
214 ## ---------------------------------------- ##
216 AT_SETUP([Macro calls in AC_CONFIG_COMMANDS tags])
218 AT_DATA_M4SUGAR([configure.ac],
219 [[AC_INIT
220 AC_CONFIG_COMMANDS([m4_if(1,1,mytag)])
221 AC_OUTPUT
224 AT_CHECK_AUTOCONF
225 AT_CHECK_CONFIGURE
227 AT_CLEANUP
231 ## ------------------- ##
232 ## Missing templates.  ##
233 ## ------------------- ##
235 # Check that config.status detects missing input files
236 AT_SETUP([Missing templates])
238 AT_DATA([configure.ac],
239 [[AC_INIT
240 AC_CONFIG_FILES([nonexistent])
241 AC_OUTPUT
244 AT_CHECK_AUTOCONF
245 AT_CHECK_CONFIGURE([], [1], [],
246 [[config.status: error: cannot find input file: nonexistent.in
248 # Make sure that the output file doesn't exist
249 AT_CHECK([test -f nonexistent], 1)
251 AT_CLEANUP
256 ## ---------------------- ##
257 ## configure invocation.  ##
258 ## ---------------------- ##
260 # Check that `configure' and `config.status' honor their interface.
262 # We run `./configure one=val1 --enable-two=val2 --with-three=val3'
263 # and verify that (i) `configure' correctly receives the arguments,
264 # (ii) correctly passes them to `config.status', which we check by
265 # running `config.status --recheck', and (iii) correctly passes them
266 # to sub-configure scripts.
268 AT_SETUP([configure invocation])
270 mkdir sub
272 AT_DATA([configure.ac],
273 [[AC_INIT
274 AC_CONFIG_SUBDIRS([sub])
275 echo "result=$one$enable_two$with_three"
276 AC_OUTPUT
279 AT_DATA([sub/configure.ac],
280 [[AC_INIT
281 echo "result=$one$enable_two$with_three"
282 AC_OUTPUT
285 echo fake install-sh script >install-sh
287 AT_CHECK_AUTOCONF
288 cd sub
289 AT_CHECK_AUTOCONF
290 cd ..
292 AT_CHECK_CONFIGURE([one=one --enable-two=two --with-three=three |
293                      sed -n -e 's/^result=//p'], 0,
294                    [m4_do([onetwothree
295 ],                        [onetwothree
296 ])])
297 AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
298          [onetwothree
301 AT_CHECK_CONFIGURE([one="\"'$ " --enable-two="\" '  $" --with-three="   \"'$"|
302                       sed -n -e 's/^result=//p'], 0,
303                    [m4_do(["'$ " '  $   "'$
304 ],                        ["'$ " '  $   "'$
305 ])])
306 AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
307          ["'$ " '  $    "'$
309 dnl restore font-lock: "
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)
339 # backslash-newline combinations
340 AC_DEFINE([multiline], [line1\
341 line2\
342 line3 \
343 line4])
344 AC_DEFINE([multiline_args(ARG1, ARG2)], [ARG2 \
345 ARG1])
346 AC_CONFIG_FILES(defs)
348 # Things included in confdefs.h, but which make no sense in
349 # config.h, nor in $DEFS.
350 cat <<\EOF >>confdefs.h
351 /* Hi Mum! Look, I am doing C++! */
352 #ifdef __cplusplus
353 void exit (int status);
354 #endif
357 # In addition of config.h output a full DEFS
358 AC_OUTPUT_MAKE_DEFS
359 DEFS_SAVED=$DEFS
360 AC_SUBST(DEFS_SAVED)
361 AC_OUTPUT
364 AT_DATA([defs.in],
365 [[@DEFS_SAVED@
368 AT_DATA([config.hin],
369 [[#define foo   0
370 #  define bar bar
371 #  define baz   "Archimedes was sinking in his baz"
372   #  define fubar                               tutu
373 #define a B
374  #define aa BB
375  #  define aaa BBB
376 #undef a
377  #  undef aa
378 #undef aaa
379 #define aaa(a, aa) aa a
380 #define aaab
381 #define aaac(a, aa) aa a
382 #undef multiline
383 #  undef multiline_args
384 /* an ugly one: */
385 #define str(define) \
386 #define
387 #define stringify(arg) str(arg)
390 AT_CHECK_AUTOCONF
391 AT_CHECK_CONFIGURE
393 AT_DATA([expout],
394 [[/* config.h.  Generated from config.hin by configure.  */
395 #define foo toto
396 #  define bar tata
397 #  define baz titi
398   #  define fubar tutu
399 #define a A
400  #define aa AA
401  #  define aaa AAA
402 #define a A
403  #  define aa AA
404 #define aaa AAA
405 #define aaa AAA
406 #define aaab
407 #define aaac(a, aa) aa a
408 #define multiline line1\
409 line2\
410 line3 \
411 line4
412 #  define multiline_args(ARG1, ARG2) ARG2 \
413 ARG1
414 /* an ugly one: */
415 #define str(define) \
416 #define
417 #define stringify(arg) str(arg)
419 AT_CHECK([cat config.h], 0, expout)
421 # Check the value of DEFS.
422 AT_DATA([expout],
423 [[-DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -Dfoo=toto -Dbar=tata -Dbaz=titi -Dfubar=tutu -Da=A -Daaa=AAA -Daa=AA -Dmultiline=line1line2line3\ line4 -Dmultiline_args\(ARG1,\ ARG2\)=ARG2\ ARG1
426 # Because we strip trailing spaces in `testsuite' we can't leave one in
427 # expout, hence nuke the one left by AC_OUTPUT_MAKE_DEFS.
428 AT_CHECK([sed -e 's/ $//' defs], 0, expout)
430 AT_CLEANUP
434 ## ------------------------- ##
435 ## Torturing config.status.  ##
436 ## ------------------------- ##
438 ## Require 100 AC_DEFINE and AC_SUBST and AC_SUBST_FILE with a significantly
439 ## big value.  This is mostly to check that Autoconf produces portable sed
440 ## scripts in config.status.  sed is used to skip the first two lines
441 ## `Generated by...'.
443 # We use m4_for many times.
444 m4_pattern_allow([^m4_for$])
446 AT_SETUP([Torturing config.status])
448 dnl The value used as a big value for AC_DEFINE.
449 dnl Don't use sh active chars here, below it is also used in a sh
450 dnl assignment.
451 m4_define([AT_BIG_VALUE],
452 [This value should be long enough to torture the various limits of sed and other tools used by Autoconf.])
454 m4_define([AT_DESCRIPTION],
455 [Define to a long string if your `Autoconf' works properly.])
458 # AT_DUMMY_VAR(NUMBER)
459 # --------------------
460 # Build a name used for AC_SUBST and AC_DEFINE.  Put ac_ in it
461 # so that the check for user name space invasion does not complain
462 # of the new variables defined.
464 # Note that you should not use the name ac_dummy, because it will be
465 # turned into ac_uummy during the construction of config.status.  Yes,
466 # this is admittedly a bug, but it would be too hard to fix this.
467 # There is really no point in AC_DEFINE a var named ac_d.*.
468 m4_pattern_allow([^m4_bpatsubst$])
469 m4_define([AT_DUMMY_VAR],
470 [ac_Dummy_[]m4_bpatsubst([000$1], [.*\(...\)$], [\1])])
474 AT_DATA([dummy.in],
475 [m4_for([AT_Count], 1, 100, 1,
476 [@AT_DUMMY_VAR(AT_Count)@
477 @[f]AT_Count@
478 ])])
482 while test $i != 101; do
483   echo "content of file $i" > file_$i
484   i=`expr $i + 1`
485 done
488 # ------------ #
489 # configure.ac #
490 # ------------ #
492 m4_pattern_allow([^m4_(define|defun)$])
493 AT_DATA([configure.ac],
494 dnl The following lines transfer AT_DUMMY_VAR, AT_DESCRIPTION, and
495 dnl AT_BIG_VALUE into the configure.ac as AC_DUMMY_VAR etc.
496 [[m4_define([AC_DUMMY_VAR],]
497 m4_dquote(m4_defn([AT_DUMMY_VAR]))[)]]
499 [[m4_define([AC_DESCRIPTION],]
500 m4_dquote(m4_defn([AT_DESCRIPTION]))[)]]
502 [[m4_define([AC_BIG_VALUE],]
503 m4_dquote(m4_defn([AT_BIG_VALUE]))[)]]
505 [[# AC_DEFUBST(NAME)
506 # ----------------
507 # Related VALUE to NAME both with AC_SUBST and AC_DEFINE.  This is
508 # used in the torture tests.
509 m4_defun([AC_DEFUBST],
510 [AC_DUMMY_VAR($1)="AC_BIG_VALUE"
511 AC_DEFINE_UNQUOTED(AC_DUMMY_VAR($1), "$AC_DUMMY_VAR($1) $AC_DUMMY_VAR($1)",
512                    AC_DESCRIPTION)
513 AC_SUBST(AC_DUMMY_VAR($1))
514 AC_SUBST_FILE([f]$1)
515 f$1=file_$1
518 AC_INIT
519 AC_CONFIG_HEADERS(config.h:config.hin)
520 AC_CONFIG_FILES(dummy)
521 m4_for(AC_Count, 1, 100, 1,
522        [AC_DEFUBST(AC_Count)])
523 AC_PROG_AWK
524 AC_OUTPUT
525 ]])# configure.ac
527 AT_CHECK_AUTOCONF
528 AT_CHECK_AUTOHEADER
529 # Check both awk and the result of AC_PROG_AWK
530 for awk_arg in FOO= AWK=awk; do
531   AT_CHECK_CONFIGURE([$awk_arg])
533   # Checking that AC_DEFINE worked properly.
534   AT_DATA([expout],
535 [/* Define to the address where bug reports for this package should be sent. */
536 #define PACKAGE_BUGREPORT ""
538 /* Define to the full name of this package. */
539 #define PACKAGE_NAME ""
541 /* Define to the full name and version of this package. */
542 #define PACKAGE_STRING ""
544 /* Define to the one symbol short name of this package. */
545 #define PACKAGE_TARNAME ""
547 /* Define to the version of this package. */
548 #define PACKAGE_VERSION ""
549 m4_for(AT_Count, 1, 100, 1,
551 /* AT_DESCRIPTION */
552 [#define] AT_DUMMY_VAR(AT_Count) "AT_BIG_VALUE AT_BIG_VALUE"
553 ])])
555   AT_CHECK([sed -n '4,$ p' config.h], 0, expout)
557   # Checking that AC_SUBST worked properly.
558   AT_DATA([expout],
559 [m4_for(AT_Count, 1, 100, 1,
560 [AT_BIG_VALUE
561 content of file AT_Count
562 ])])
564   AT_CHECK([cat dummy], 0, expout)
565 done
567 AT_CLEANUP
570 ## ------------------------------- ##
571 ## Substitute a 2000-byte string.  ##
572 ## ------------------------------- ##
574 # Solaris 9 /usr/ucb/sed that rejects commands longer than 4000 bytes.  HP/UX
575 # sed dumps core around 8 KiB.  However, POSIX says that sed need not
576 # handle lines longer than 2048 bytes (including the trailing newline).
577 # So we'll just test a 2000-byte value, and for awk, we test a line with
578 # almost 1000 words, and one variable with 5 lines of 2000 bytes each:
579 # multi-line values should allow to get around the limitations.
581 AT_SETUP([Substitute a 2000-byte string])
583 AT_DATA([Foo.in], [@foo@
585 AT_DATA([Bar.in], [@bar@
587 AT_DATA([Baz.in], [@baz@
590 AT_DATA([configure.ac],
591 [[AC_INIT
592 AC_CONFIG_AUX_DIR($top_srcdir/build-aux)
593 AC_SUBST([foo], ]m4_for([n], 1, 100,, ....................)[)
594 AC_SUBST([bar], "]m4_for([n], 1, 100,, @ @ @ @ @ @ @ @ @ @@)[")
595 baz="]m4_for([m], 1, 100,, ... ... ... ... ....)[
597 baz=$baz$baz$baz$baz$baz
598 AC_SUBST([baz])
599 AC_PROG_AWK
600 AC_CONFIG_FILES([Foo Bar Baz])
601 AC_OUTPUT
604 AT_CHECK_AUTOCONF
605 # Check both awk and the result of AC_PROG_AWK
606 for awk_arg in Foo= AWK=awk; do
607   AT_CHECK_CONFIGURE([$awk_arg])
608   AT_CHECK([cat Foo], 0, m4_for([n], 1, 100,, ....................)
610   AT_CHECK([cat Bar], 0, m4_for([n], 1, 100,, @ @ @ @ @ @ @ @ @ @@)
612   AT_DATA([stdout],
613   [m4_for([n], 1, 5,, m4_for([m], 1, 100,, ... ... ... ... ....)
615   AT_CHECK([cat Baz], 0, [stdout])
616 done
617 AT_CLEANUP
620 ## ------------------------------ ##
621 ## Define to a 2000-byte string.  ##
622 ## ------------------------------ ##
624 AT_SETUP([Define to a 2000-byte string])
626 AT_CONFIGURE_AC(
628 AC_DEFINE([foo], ]m4_for([n], 1, 100,, ....................)[, [desc])
631 AT_CHECK_AUTOCONF
632 AT_CHECK_AUTOHEADER
633 AT_CHECK_CONFIGURE
634 AT_CHECK_DEFINES([@%:@define foo m4_for([n], 1, 100,, ....................)
636 AT_CLEANUP
639 ## ------------------------------------------ ##
640 ## Substitute and define special characters.  ##
641 ## ------------------------------------------ ##
643 # Use characters special to the shell, sed, awk, and M4.
645 AT_SETUP([Substitute and define special characters])
647 AT_DATA([Foo.in], [@foo@
648 @bar@@notsubsted@@baz@ stray @ and more@@@baz@
649 abc@bar@baz@baz
650 abc@bar@@baz@baz
651 abc@bar@@baz@baz@
652 abc@bar @baz@baz
653 abc@bar @baz@baz@
654 abc@bar @baz@@baz@
655 @file@
656          @file@
657 X@file@
658 @file@X
661 AT_DATA([File],
662 [@foo@@bar@
665 AT_DATA([Zardoz.in], [@zardoz@
668 AT_CONFIGURE_AC(
669 [[foo="AS@&t@_ESCAPE([[X*'[]+ ",& &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !]])"
670 bar="@foo@ @baz@"
671 baz=bla
672 ( for i in 0 1 2 3; do
673     for j in 0 1 2 3 4 5 6 7; do
674       for k in 0 1 2 3 4 5 6 7; do
675         case $i$j$k in #(
676         000) ;; #(
677         *) printf \\$i$j$k's' ;; # The 's' works around a Solaris 8 /bin/bash bug.
678         esac
679       done
680     done
681   done
682   printf \\n
683 ) >allowed-chars
684 zardoz=`cat allowed-chars`
685 AC_SUBST([foo])
686 AC_SUBST([bar])
687 AC_SUBST([baz])
688 AC_SUBST([zardoz])
689 file=File
690 AC_SUBST_FILE([file])
691 AC_DEFINE([foo], [[X*'[]+ ",& &`\($foo !]], [Awful value.])
692 AC_DEFINE([bar], [[%!_!# X]], [Value that is used as special delimiter.])
693 AC_PROG_AWK
694 AC_CONFIG_FILES([Foo Zardoz])]])
696 AT_CHECK_AUTOCONF
697 AT_CHECK_AUTOHEADER
698 # Check both awk and the result of AC_PROG_AWK
699 for awk_arg in FOO= AWK=awk; do
700   AT_CHECK_CONFIGURE([$awk_arg])
701   AT_CHECK([cat Foo], 0, [[X*'[]+ ",& &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !
702 @foo@ @baz@@notsubsted@bla stray @ and more@@bla
703 abc@foo@ @baz@baz@baz
704 abc@foo@ @baz@blabaz
705 abc@foo@ @baz@blabaz@
706 abc@bar blabaz
707 abc@bar blabaz@
708 abc@bar blabla
709 @foo@@bar@
710 @foo@@bar@
711 X@file@
712 @file@X
714   AT_CHECK([cmp allowed-chars Zardoz])
715   AT_CHECK_DEFINES([[#define bar %!_!# X
716 #define foo X*'[]+ ",& &`\($foo !
718 done
719 AT_CLEANUP
722 ## ---------------------- ##
723 ## Substitute a newline.  ##
724 ## ---------------------- ##
726 AT_SETUP([Substitute a newline])
728 AT_DATA([Foo.in],
729 [@foo@
730 @bar@
733 AT_DATA([configure.ac],
734 [[AC_INIT
735 AC_CONFIG_AUX_DIR($top_srcdir/build-aux)
736 foo='one
737 two'
738 bar='%!_!# ''
740 AC_SUBST([foo])
741 AC_SUBST([bar])
742 AC_CONFIG_FILES([Foo])
743 AC_PROG_AWK
744 AC_OUTPUT
747 echo 'one
749 %!_!# ''
750 x' >expout
752 AT_CHECK_AUTOCONF
753 # Check both awk and the result of AC_PROG_AWK
754 for awk_arg in FOO= AWK=awk; do
755   AT_CHECK_CONFIGURE([$awk_arg])
756   AT_CHECK([cat Foo], 0, [expout])
757 done
758 AT_CLEANUP
761 ## ------------------ ##
762 ## Define a newline.  ##
763 ## ------------------ ##
765 AT_SETUP([Define a newline])
766 AT_CONFIGURE_AC([[AC_DEFINE([foo], [one
767 two], [This spans two lines.])
769 AT_CHECK_AUTOCONF([], [], [], [stderr])
770 dnl Older versions of m4 report error at line 6 (end of macro);
771 dnl newer versions report it at line 5 (start of macro).
772 AT_CHECK([[sed 's/^configure.ac:[56]: //' stderr]], [],
773 [[warning: AC_DEFINE: `one
774 two' is not a valid preprocessor define value
776 AT_CHECK_AUTOHEADER([], [], [], [stderr])
777 AT_CHECK([[sed 's/^configure.ac:[56]: //' stderr]], [],
778 [[warning: AC_DEFINE: `one
779 two' is not a valid preprocessor define value
781 AT_CHECK_CONFIGURE
782 AT_CHECK_DEFINES([[#define foo one
785 AT_CONFIGURE_AC([[AC_DEFINE_UNQUOTED([foo], [one
786 two], [This spans two lines.])
788 AT_CHECK_AUTOCONF([], [], [], [stderr])
789 AT_CHECK([[sed 's/^configure.ac:[56]: //' stderr]], [],
790 [[warning: AC_DEFINE_UNQUOTED: `one
791 two' is not a valid preprocessor define value
793 AT_CHECK_AUTOHEADER([], [], [], [stderr])
794 AT_CHECK([[sed 's/^configure.ac:[56]: //' stderr]], [],
795 [[warning: AC_DEFINE_UNQUOTED: `one
796 two' is not a valid preprocessor define value
798 AT_CHECK_CONFIGURE
799 AT_CHECK_DEFINES([[#define foo one
802 AT_CLEANUP
805 ## ------------------------------------ ##
806 ## AC_SUBST: variable name validation.  ##
807 ## ------------------------------------ ##
809 AT_SETUP([AC_SUBST: variable name validation])
811 AT_CONFIGURE_AC([[AC_SUBST(, [])
812 AC_CONFIG_FILES([Makefile])
814 AT_DATA([Makefile.in], [[
816 mv -f configure.ac configure.tmpl
818 # Invalid names.
819 for var in ['' ab\~ ab\( ab[] ab\' ab\" ab\\\\]; do
820   sed ["s/AC_SUBST(/&[$var]/"] <configure.tmpl >configure.ac
821   AT_CHECK_AUTOCONF([], [1], [], [ignore])
822 done
824 # Valid names.
825 for var in ab a4 'a@@&t@\&t@b'; do
826   sed ["s/AC_SUBST(/&[$var]/"] <configure.tmpl >configure.ac
827   AT_CHECK_AUTOCONF
828   AT_CHECK_AUTOHEADER
829   AT_CHECK_CONFIGURE
830 done
832 AT_CLEANUP
835 ## ------------------------ ##
836 ## datarootdir workaround.  ##
837 ## ------------------------ ##
839 AT_SETUP([datarootdir workaround])
841 AT_DATA([Foo.in],
842 [@datadir@
843 @docdir@
844 @infodir@
845 @localedir@
846 @mandir@
849 AT_DATA([Bar.in],
850 [@mydatadir@
853 AT_DATA([configure.ac],
854 [[AC_INIT
855 d@&t@nl The following line silences the warnings, if uncommented:
856 d@&t@nl AC_DEFUN([AC_DATAROOTDIR_CHECKED])
857 AC_CONFIG_AUX_DIR($top_srcdir/build-aux)
859 # This substitution is wrong and bogus!  Don't use it in your own code!
860 # Read `info Autoconf "Defining Directories"'!
861 AC_SUBST([mydatadir], [${datadir}/my])
863 AC_CONFIG_FILES([Foo Bar])
864 AC_OUTPUT
867 AT_CHECK_AUTOCONF
868 AT_CHECK_CONFIGURE([], [], [],
869   [config.status: WARNING:  Foo.in seems to ignore the --datarootdir setting
870 config.status: WARNING: Bar contains a reference to the variable `datarootdir'
871 which seems to be undefined.  Please make sure it is defined.
873 AT_CHECK([grep datarootdir Foo], 1, [])
875 rm configure
876 sed '/AC_DEFUN/s/^d@&t@nl //' configure.ac >t
877 mv t configure.ac
879 AT_CHECK_AUTOCONF
880 AT_CHECK_CONFIGURE
882 AT_CLEANUP
885 ## -------- ##
886 ## srcdir.  ##
887 ## -------- ##
889 AT_SETUP([srcdir])
891 rm -f -r at-dir
892 mkdir at-dir
893 : >at-dir/bar.in
894 : >foo.in
896 AT_DATA([configure.ac],
897 [[AC_INIT
899 AC_CONFIG_FILES([foo at-dir/bar])
901 AC_CONFIG_COMMANDS([report],
902 [test -f $srcdir/configure.ac ||
903    AC_MSG_ERROR([cannot find $srcdir/configure.ac])],
904                    [srcdir=$srcdir])
906 AC_OUTPUT
907 rm -f -r foo at-dir/bar
910 AT_CHECK_AUTOCONF
912 # In place.
913 AT_CHECK([./configure], [], [ignore])
915 # Relative name.
916 AT_CHECK([cd at-dir && ../configure], [], [ignore])
918 # Absolute name.
919 at_here=`pwd`
920 AT_CHECK([cd at-dir && "$at_here/configure"], [], [ignore])
922 AT_CLEANUP
925 ## ----------------- ##
926 ## Signal handling.  ##
927 ## ----------------- ##
929 AT_SETUP([Signal handling])
931 AT_DATA([configure.ac],
932 [[AC_INIT
933 kill -2 $$
934 exit 77
937 AT_CHECK_AUTOCONF
938 AT_CHECK_CONFIGURE([], 1, ignore, ignore)
940 AT_CLEANUP
943 ## ------------------------------------- ##
944 ## AC_CONFIG_LINKS and identical files.  ##
945 ## ------------------------------------- ##
946 AT_SETUP([AC_CONFIG_LINKS and identical files])
948 AT_DATA([configure.ac],
949 [[AC_INIT
950 AC_CONFIG_LINKS([src/s:src/s])
951 test "$srcdir" != '.' && AC_CONFIG_LINKS([src/t:src/t])
952 AC_OUTPUT
955 mkdir src build
956 echo file1 > src/s
957 echo file2 > src/t
958 AT_CHECK_AUTOCONF
959 cd build
960 AT_CHECK([../configure && ../configure], 0, [ignore])
961 AT_CHECK([cat src/s src/t], 0, [file1
962 file2
964 cd ..
965 AT_CHECK([./configure && ./configure], 0, [ignore], [stderr])
966 AT_CHECK([grep src/t stderr], 1)
967 AT_CHECK([cat src/s src/t], 0, [file1
968 file2
970 AT_CHECK(["`pwd`"/configure && "`pwd`"/configure], 0, [ignore], [ignore])
971 AT_CHECK([cat src/s src/t], 0, [file1
972 file2
975 AT_CLEANUP
978 AT_BANNER([autoreconf.])
980 ## ---------------------------- ##
981 ## Configuring subdirectories.  ##
982 ## ---------------------------- ##
984 # .
985 # |-- builddir
986 # |   |-- config.log
987 # |   |-- config.status
988 # |   `-- inner
989 # |       |-- config.log
990 # |       |-- config.status
991 # |       `-- innermost
992 # |           `-- config
993 # |-- configure
994 # |-- configure.ac
995 # |-- inner
996 # |   |-- configure
997 # |   |-- configure.ac
998 # |   `-- innermost
999 # |       `-- config.in
1000 # `-- install-sh
1002 AT_SETUP([Configuring subdirectories])
1003 AT_KEYWORDS(autoreconf)
1005 # We use aclocal (via autoreconf).
1006 AT_CHECK([aclocal --version || exit 77], [], [stdout], [ignore])
1007 # It should understand configure.ac.
1008 AT_CHECK([[grep '[^0-9]1.[01234][^0-9]' stdout && exit 77]], [1], [ignore])
1010 # Set CONFIG_SITE to a nonexistent file, so that there are
1011 # no worries about nonstandard values for 'prefix'.
1012 CONFIG_SITE=no-such-file
1013 export CONFIG_SITE
1015 # The contents of `inner/', and `inner/innermost/'.
1016 AS_MKDIR_P([inner/innermost])
1018 # We have to use configure.in, not configure.ac, if we still want to
1019 # be compatible with Automake 1.4: aclocal (run by autoreconf) would
1020 # die because it can't find configure.in.
1021 AT_DATA([inner/configure.in],
1022 [[AC_INIT(GNU Inner, 1.0)
1023 AC_CONFIG_SRCDIR([innermost/config.in])
1024 AC_ARG_VAR([INNER], [an inner variable])
1025 AC_SUBST([INNER])
1026 if test "x$INNER" = x; then
1027   INNER=inner
1029 AC_CONFIG_FILES([innermost/config])
1030 AC_OUTPUT
1033 AT_DATA([inner/innermost/config.in],
1034 [INNER=@INNER@
1035 srcdir=@srcdir@
1036 top_srcdir=@top_srcdir@
1037 prefix=@prefix@
1040 # The contents of `.'
1041 AT_DATA([install-sh], [])
1043 # nonexistent is allowed not to exist.
1044 AT_DATA([configure.in],
1045 [[AC_INIT(GNU Outer, 1.0)
1046 AC_ARG_VAR([OUTER], [an outer variable])
1047 if false; then
1048   AC_CONFIG_SUBDIRS([nonexistent])
1050 AC_CONFIG_SUBDIRS([inner])
1051 AC_OUTPUT
1054 # If there are improperly quoted AC_DEFUN installed in share/aclocal,
1055 # they trigger warnings from aclocal 1.8, so ignore stderr.
1056 AT_CHECK([autoreconf], [], [], [ignore])
1057 AT_CHECK([test -f inner/configure])
1059 # Running the outer configure recursively should provide the innermost
1060 # help strings.
1061 chmod a-w inner/innermost inner .
1062 AT_CHECK([{ ./configure --help=recursive; chmod u+w .; } | grep INNER], 0,
1063          [ignore], [stderr],
1064          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1065 chmod u+w . inner inner/innermost
1067 # Running the outer configure should trigger the inner.
1068 AT_CHECK_CONFIGURE
1069 AT_CHECK([cat inner/innermost/config], 0,
1070 [INNER=inner
1071 srcdir=.
1072 top_srcdir=..
1073 prefix=/usr/local
1076 # The same, but from a builddir.
1077 AS_MKDIR_P([builddir])
1078 AT_CHECK([cd builddir && ../configure], 0, [ignore])
1079 AT_CHECK([cat builddir/inner/innermost/config], 0,
1080 [INNER=inner
1081 srcdir=../../../inner/innermost
1082 top_srcdir=../../../inner
1083 prefix=/usr/local
1086 # Make sure precious variables and command line options are properly
1087 # passed, even when there are duplicates.
1088 AT_CHECK([cd builddir && ../configure --prefix /bad --prefix /good INNER=bad INNER=good], 0, [ignore])
1089 AT_CHECK([cat builddir/inner/innermost/config], 0,
1090 [INNER=good
1091 srcdir=../../../inner/innermost
1092 top_srcdir=../../../inner
1093 prefix=/good
1096 # Make sure --prefix is properly quoted
1097 AT_CHECK([cd builddir && ../configure --prefix "/a  b c$ 'd"], 0, [ignore])
1098 AT_CHECK([cat builddir/inner/innermost/config], 0,
1099 [INNER=inner
1100 srcdir=../../../inner/innermost
1101 top_srcdir=../../../inner
1102 prefix=/a  b c$ 'd
1105 # Make sure --silent is properly passed...
1106 AT_CHECK([cd builddir && ../configure --silent], 0, [])
1107 # ...but not stored in config.status.
1108 AT_CHECK([cd builddir && ./config.status --recheck], 0, [stdout])
1109 AT_CHECK([grep 'creating \./config.status' stdout], 0, [ignore])
1111 # Make sure we can run autoreconf on a subdirectory
1112 rm -f configure configure.in
1113 AT_CHECK([autoreconf inner], [], [], [ignore])
1115 # Make sure we can pass a configure.ac name
1116 AT_CHECK([cd inner && autoreconf configure.in], [], [], [ignore])
1117 AT_CHECK([autoreconf inner/configure.in], [], [], [ignore])
1119 AT_CLEANUP
1123 ## -------------- ##
1124 ## Deep Package.  ##
1125 ## -------------- ##
1127 AT_SETUP([Deep Package])
1128 AT_KEYWORDS(autoreconf)
1130 # We use aclocal (via autoreconf).
1131 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
1133 # The contents of `.'
1134 AT_DATA([install-sh], [])
1135 AT_DATA([configure.in],
1136 [[AC_INIT(GNU Outer, 1.0)
1137 AC_ARG_VAR([OUTER], [an outer variable])
1138 AC_CONFIG_SUBDIRS([inner])
1139 AC_OUTPUT
1142 # The contents of `inner/', and `inner/innermost/'.
1143 AS_MKDIR_P([inner/innermost])
1145 AT_DATA([inner/configure.in],
1146 [[AC_INIT(GNU Inner, 1.0)
1147 AC_ARG_VAR([INNER], [an inner variable])
1148 AC_CONFIG_SUBDIRS(innermost)
1149 AC_OUTPUT
1152 AT_DATA([inner/innermost/configure.in],
1153 [[AC_INIT(GNU Innermost, 1.0)
1154 AC_ARG_VAR([INNERMOST], [an innermost variable])
1155 AC_CONFIG_HEADERS(config.h:config.hin)
1156 AC_DEFINE_UNQUOTED([INNERMOST], [$INNERMOST], [an innermost variable])
1157 AC_OUTPUT
1160 AT_CHECK([autoreconf -Wall -v], [0], [ignore], [ignore])
1161 AT_CHECK([test -f inner/configure])
1162 AT_CHECK([test -f inner/innermost/configure])
1163 AT_CHECK([test -f inner/innermost/config.hin])
1165 # Running the outer configure recursively should provide the innermost
1166 # help strings.
1167 chmod a-w inner/innermost inner
1168 AT_CHECK([{ ./configure --help=recursive; chmod u+w .; } | grep " INNER "],
1169          0, [ignore], [stderr],
1170          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1171 chmod a-w .
1172 AT_CHECK([{ ./configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1173          0, [ignore], [stderr],
1174          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1175 chmod a-w .
1176 AT_CHECK([{ /bin/sh ./configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1177          0, [ignore], [stderr],
1178          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1179 chmod a-w .
1180 AT_CHECK([PATH=.$PATH_SEPARATOR$PATH; export PATH; { /bin/sh configure --help=recursive; chmod +w .; } | grep " INNERMOST "],
1181          0, [ignore], [stderr],
1182          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1183 chmod a-w .
1184 AT_CHECK([PATH=.$PATH_SEPARATOR$PATH; export PATH; { configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1185          0, [ignore], [stderr],
1186          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1187 chmod u+w inner inner/innermost
1189 # Running the outer configure should trigger the inner.
1190 AT_CHECK_CONFIGURE([INNERMOST=tsomrenni])
1191 AT_CHECK([grep INNERMOST inner/innermost/config.h], 0,
1192 [[#define INNERMOST tsomrenni
1195 # The same, but from a builddir.
1196 AS_MKDIR_P([builddir])
1197 chmod a-w builddir inner/innermost inner
1198 AT_CHECK([cd builddir && { ../configure --help=recursive; chmod u+w .; } | grep " INNER "],
1199          0, [ignore], [stderr],
1200          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1201 chmod a-w builddir
1202 AT_CHECK([cd builddir && { ../configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1203          0, [ignore], [stderr],
1204          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1205 chmod a-w builddir
1206 AT_CHECK([cd builddir && { /bin/sh ../configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1207          0, [ignore], [stderr],
1208          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1209 chmod a-w builddir
1210 # Not all shells search $PATH for scripts.
1211 if (cd builddir && PATH=`pwd`/..$PATH_SEPARATOR$PATH /bin/sh configure --help) >/dev/null 2>&1; then
1212   AT_CHECK([cd builddir && PATH=`pwd`/..$PATH_SEPARATOR$PATH /bin/sh configure --help=recursive | grep " INNERMOST "], 0, [ignore])
1214 AT_CHECK([PATH=`pwd`$PATH_SEPARATOR$PATH; export PATH; cd builddir && { configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1215          0, [ignore], [stderr],
1216          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1217 chmod u+w builddir inner inner/innermost
1218 AT_CHECK([cd builddir && ../configure INNERMOST=build/tsomrenni], 0, [ignore])
1219 AT_CHECK([grep INNERMOST builddir/inner/innermost/config.h], 0,
1220 [[#define INNERMOST build/tsomrenni
1223 AT_CLEANUP
1227 ## -------------------------------- ##
1228 ## Non-Autoconf AC_CONFIG_SUBDIRS.  ##
1229 ## -------------------------------- ##
1231 AT_SETUP([Non-Autoconf AC_CONFIG_SUBDIRS])
1232 AT_KEYWORDS([autoreconf])
1234 # We use aclocal (via autoreconf).
1235 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
1237 AT_DATA([install-sh], [])
1238 AT_DATA([configure.in],
1239 [[AC_INIT(GNU Outer, 1.0)
1240 AC_CONFIG_SUBDIRS([inner])
1241 AC_OUTPUT
1244 AS_MKDIR_P([inner])
1246 AT_DATA([inner/configure],
1247 [[#! /bin/sh
1248 case "$*" in
1249     *--help*) echo 'No Autoconf here, folks!' ;;
1250     *)        echo got_it >myfile ;;
1251 esac
1252 exit 0
1254 chmod +x inner/configure
1256 AT_CHECK([autoreconf -Wall -v], 0, [ignore], [ignore])
1258 # Running the outer configure recursively should provide the innermost
1259 # help strings.
1260 AT_CHECK([./configure --help=recursive | grep "folks"], 0, [ignore])
1262 # Running the outer configure should trigger the inner.
1263 AT_CHECK([./configure], 0, [ignore])
1264 AT_CHECK([test -f inner/myfile], 0)
1266 AT_CLEANUP
1270 ## ----------------- ##
1271 ## Empty directory.  ##
1272 ## ----------------- ##
1274 AT_SETUP([Empty directory])
1275 AT_KEYWORDS([autoreconf])
1277 # We use aclocal (via autoreconf).
1278 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
1280 # The test group directory is not necessarily _empty_, but it does not contain
1281 # files meaningful to `autoreconf'.
1283 AT_CHECK([autoreconf -Wall -v], 1, [ignore], [ignore])
1285 AT_CLEANUP
1289 ## ------------------------------ ##
1290 ## Unusual Automake input files.  ##
1291 ## ------------------------------ ##
1293 # This parallels gnumake.test in Automake.
1295 AT_SETUP([Unusual Automake input files])
1296 AT_KEYWORDS([autoreconf])
1298 # We use aclocal and automake via autoreconf.
1299 AT_CHECK([automake --version || exit 77], [], [ignore], [ignore])
1301 AT_DATA([configure.in],
1302 [[AC_INIT(GNU foo, 1.0)
1303 AM_INIT_AUTOMAKE
1304 AC_CONFIG_FILES([HeeHee])
1305 AC_OUTPUT
1308 AT_DATA([HeeHee.am],
1309 [[# Humans do no worse than `GNUmakefile.am'.
1310 AUTOMAKE_OPTIONS = foreign 1.8
1313 AT_CHECK([autoreconf -Wall -v -i], 0, [ignore], [stderr],
1314          [AT_CHECK([grep 'require.*1\.8' stderr && exit 77], [1])])
1315 AT_CHECK([test -f HeeHee.in])
1317 AT_CLEANUP
1319 ## --------------------- ##
1320 ## Unbootstrap (--clean) ##
1321 ## --------------------- ##
1323 AT_SETUP([Unbootstrap with --clean])
1324 AT_KEYWORDS([autoreconf])
1326 # We use aclocal (via autoreconf).
1327 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
1328 # We need a version of aclocal that is recent enough to support --clean
1329 AT_CHECK([aclocal --help | grep ' --clean' || exit 77], [], [ignore], [ignore])
1331 AT_DATA([configure.ac],
1332 [[AC_INIT
1333 AC_CONFIG_HEADERS(config.h:config.hin)
1334 AC_OUTPUT
1338 AT_DATA([config.hin], [])
1340 # Save the result of `find' to see whether we properly cleaned everything.
1341 AT_DATA([list.after], [])
1342 AT_DATA([list.before], [])
1344 # Save the list of files in the current directory.
1345 find . | sort >list.before
1347 AT_CHECK([autoreconf], [0], [ignore], [ignore])
1349 AT_CHECK([autoreconf --clean], [0], [ignore], [ignore])
1350 find . | sort >list.after
1351 AT_CMP([list.before], [list.after])
1353 AT_CLEANUP