Add m4_blank and friends.
[autoconf.git] / tests / torture.at
blob9d58e51f6d30b6bc6395c2b7d23b057cda5e9b32
1 #                                                       -*- Autotest -*-
3 # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
4 # 2009 Free 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
46 ## ------------------------------- ##
47 ## parameterized AC_CONFIG_FILES.  ##
48 ## ------------------------------- ##
50 AT_SETUP([Parameterized AC_CONFIG_FILES])
52 AT_CONFIGURE_AC([[
53 files="foo
54 bar"
55 AC_CONFIG_FILES([$files])]])
56 AT_CHECK_AUTOCONF([], [], [], [ignore])
57 touch foo.in bar.in config.hin
58 AT_CHECK_CONFIGURE
60 AT_CLEANUP
64 ## ------------ ##
65 ## AC_ARG_VAR.  ##
66 ## ------------ ##
68 # AT_CHECK_AC_ARG_VAR(FIRST-VALUE, SECOND-VALUE, [STATUS = 1])
69 # ------------------------------------------------------------
70 # Check that AC_ARG_VAR caches the latest values, diagnoses
71 # inconsistencies, and arms config.status.  Check that recheck
72 # returns STATUS, save configure output in files 'stdout' and 'stderr'
73 # for further inspection.
74 m4_define([AT_CHECK_AC_ARG_VAR],
75 [rm -f config.cache
77 # Initial value.
78 m4_ifval([$1],
79          [precious='m4_bpatsubst([$1], [[']], ['\\''])'; export precious],
80          [unset precious])
81 AT_CHECK_CONFIGURE([--config-cache -q])
82 AT_CHECK([cat file], [], [`$1'
85 # Testing --recheck: 1. have the environment `forget' about PRECIOUS.
86 unset precious
87 # 2. Rerun config.status to recreate `file'.
88 AT_CHECK([./config.status --recheck], [], [ignore])
89 AT_CHECK([./config.status], [], [ignore])
90 # 3. Check that file contains the old value of PRECIOUS.
91 AT_CHECK([cat file], [], [`$1'
94 # Second value: we should issue an error here: the value
95 # has changed!
96 m4_ifval([$2],
97          [precious='$2'; export precious],
98          [unset precious])
99 AT_CHECK_CONFIGURE([--config-cache], [m4_default([$3], [1])], [stdout], [stderr])
101 ])# AT_CHECK_AC_ARG_VAR
104 AT_SETUP([AC_ARG_VAR])
106 # We don't want to run this test if this shell doesn't support
107 # `unset'.
108 AT_CHECK([
109 if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
110   exit 0
111 else
112   exit 77
116 AT_DATA([configure.ac],
117 [[AC_INIT
118 AC_ARG_VAR([precious], [this variable costs a lot])
119 echo "precious:$precious"
120 AC_OUTPUT(file)
123 AT_DATA([file.in],
124 [[`@precious@'
127 AT_CHECK_AUTOCONF
129 # Set a precious variable
130 AT_CHECK_AC_ARG_VAR([], [apple of my eye])
132 # Unset a precious variable
133 AT_CHECK_AC_ARG_VAR([apple of my eye], [])
135 # Change a precious variable
136 AT_CHECK_AC_ARG_VAR([apple of my eye], [orange of my eye])
138 # Change a precious variable that contains braces
139 AT_CHECK_AC_ARG_VAR([apple of my {eye}], [orange of my eye])
141 # Change a precious variable that contains all kinds of fun
142 AT_CHECK_AC_ARG_VAR(['p  r      ec"iou$], [orange of my eye])
143 dnl restore font-lock: "
145 # Warn (but do not fail) about a whitespace-only change
146 AT_CHECK_AC_ARG_VAR([    apple  of       my eye  ], [apple of my eye],
147                     [0], ["has whitespace changes"])
148 mv stdout configure-output
149 AT_CHECK([grep "ignoring whitespace changes" stderr], [], [ignore])
150 AT_CHECK([grep "precious:        apple" configure-output], [], [ignore])
152 AT_CLEANUP
157 ## ---------------------------------------------- ##
158 ## AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS.  ##
159 ## ---------------------------------------------- ##
161 AT_SETUP([[AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS]])
163 AT_DATA([configure.ac],
164 [[AC_INIT
165 AC_PROG_FGREP
166 rm -f -r header var-header file var-file link var-link command var-command
167 echo 'OK' >input
169 # Be sure to also stress the associated INIT-CMDS.
170 case $what_to_test in
171  header)
172    AC_CONFIG_HEADERS(header:input);;
173  var-header)
174    AC_CONFIG_HEADERS(var-header:$header_in, [], [header_in=input]);;
176  file)
177    AC_CONFIG_FILES(file:input);;
178  var-file)
179    AC_CONFIG_FILES(var-file:$file_in, [], [file_in=input]);;
181  command)
182    AC_CONFIG_COMMANDS(command,
183                       [cp input command]);;
184  var-command)
185    AC_CONFIG_COMMANDS(var-command,
186                       [cp $command_in var-command], [command_in=input]);;
188  link)
189    AC_CONFIG_LINKS(link:input);;
190  var-link)
191    AC_CONFIG_LINKS(var-link:$link_in, [], [link_in=input]);;
192 esac
193 AC_OUTPUT
196 AT_CHECK_AUTOCONF
199 # AT_CHECK_CONFIG_CREATION(THING = (header | link | file | command))
200 # ------------------------------------------------------------------
201 # Check that THING and var-THING (which uses variables in AC_CONFIG_THING)
202 # are properly created, with the right content.
203 # Use `grep OK' instead of a simple `cat' to avoid banners such as in
204 # AC_CONFIG_HEADERS.
205 m4_define([AT_CHECK_CONFIG_CREATION],
206 [AT_CHECK_CONFIGURE([what_to_test=$1])
207 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
208          [ignore], [$1
210 AT_CHECK([grep OK $1], [], [OK
213 AT_CHECK_CONFIGURE([what_to_test=var-$1 --no-create])
214 # config.status might be stupidly expecting data on stdin, if it's
215 # really broken...
216 AT_CHECK([./config.status var-$1 </dev/null], [], [ignore])
217 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
218          [ignore], [var-$1
220 AT_CHECK([grep OK var-$1], [], [OK
222 ])# AT_CHECK_CONFIG_CREATION
225 # AT_CHECK_CONFIG_CREATION_NOWRITE(THING = (header | link | file | command))
226 # ------------------------------------------------------------------
227 # Check that THING and var-THING (which uses variables in AC_CONFIG_THING)
228 # are properly created, with the right content.
229 # Use `grep OK' instead of a simple `cat' to avoid banners such as in
230 # AC_CONFIG_HEADERS.
231 m4_define([AT_CHECK_CONFIG_CREATION_NOWRITE],
232 [AT_CHECK_CONFIGURE([what_to_test=$1])
233 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
234          [ignore], [$1
236 AT_CHECK([grep OK $1], [], [OK
239 AT_CHECK_CONFIGURE([what_to_test=var-$1 --no-create])
240 # config.status might be stupidly expecting data on stdin, if it's
241 # really broken...
242 # Skip check if user can rename files into a read-only directory (when
243 # run by root or on w32).
244 touch t
245 chmod a-w .
246 mv t t1 >/dev/null 2>&1 \
247   || AT_CHECK([./config.status var-$1 </dev/null || exit 1],
248    [1], [ignore], [ignore])
249 chmod u+w .
250 rm -rf t t1
251 ])# AT_CHECK_CONFIG_CREATION_NOWRITE
254 # Create a file
255 AT_CHECK_CONFIG_CREATION(file)
257 # Create a header
258 AT_CHECK_CONFIG_CREATION(header)
260 # Execute a command
261 AT_CHECK_CONFIG_CREATION(command)
263 # Create a link
264 AT_CHECK_CONFIG_CREATION(link)
266 # Now check for write errors
268 # Create a file
269 AT_CHECK_CONFIG_CREATION_NOWRITE(file)
270 # Create a file with bits from stdin
271 AT_CHECK([echo from-stdin | ./config.status --file=file:-],
272          [0], [ignore])
273 AT_CHECK([grep from-stdin file], [], [from-stdin
275 # Force write error creating a file on stdout
276 if test -w /dev/full && test -c /dev/full; then
277   AT_CHECK([./config.status --file=-:input </dev/null >/dev/full],
278            [1], [ignore], [ignore])
281 # Create a header
282 AT_CHECK_CONFIG_CREATION_NOWRITE(header)
283 # Create a header on stdout
284 AT_CHECK([./config.status --header=-:input </dev/null],
285          [0], [stdout], [ignore])
286 AT_CHECK([grep OK stdout], [], [OK
288 # Force write error creating a header on stdout
289 if test -w /dev/full && test -c /dev/full; then
290   AT_CHECK([./config.status --header=-:input </dev/null >/dev/full],
291            [1], [ignore], [ignore])
294 # Execute a command
295 AT_CHECK_CONFIG_CREATION_NOWRITE(command)
297 # Create a link
298 AT_CHECK_CONFIG_CREATION_NOWRITE(link)
300 # Check that no use of `ac_write_fail' escaped into config.status
301 AT_CHECK([grep ac_write_fail config.status], [1])
303 # Check that --file and --header accept funny file names
304 AT_DATA([fgrep.in],
305 [[FGREP="@FGREP@"
307 ./config.status --file=fgrep:fgrep.in
308 . ./fgrep
311 export x
312 for file in \
313   'with  funny '\'' $x & #! name' \
314   'file with  funny \ '\'' \'\'' $ & #!*? name' \
315   'with  funny \ '\'' \'\'' " | <a >b & * ? name ' # "restore font-lock
317   # The function func_sanitize_file_name comes from tools.at
318   file=`func_sanitize_file_name "$file"`
319   cat >"$file.in" <<'END'
320 @configure_input@
322   AT_CHECK([./config.status "--file=$file:$file.in"],
323            [0], [ignore])
324   AT_CHECK([$FGREP "$file" "$file"], [0], [ignore])
325   AT_CHECK([./config.status "--header=$file:$file.in"],
326            [0], [ignore])
327   # Run the same test a 2nd time to see that config.status does not recreate
328   # the header (regression test)
329   AT_CHECK_NOESCAPE([./config.status "--header=$file:$file.in"],
330                     [0], [config.status: creating $file
331 config.status: $file is unchanged
333   AT_CHECK_NOESCAPE([grep ' & ' "$file"], [],
334 [/* $file.  Generated from $file.in by configure.  */
336   AT_CHECK([$FGREP "$file" "$file"], [0], [ignore])
337 done
338 AT_CLEANUP
342 ## ---------------------------------------- ##
343 ## Macro calls in AC_CONFIG_COMMANDS tags.  ##
344 ## ---------------------------------------- ##
346 AT_SETUP([Macro calls in AC_CONFIG_COMMANDS tags])
348 AT_DATA_M4SUGAR([configure.ac],
349 [[AC_INIT
350 AC_CONFIG_COMMANDS([m4_if(1,1,mytag)])
351 AC_OUTPUT
354 AT_CHECK_AUTOCONF
355 AT_CHECK_CONFIGURE
357 AT_CLEANUP
361 ## ------------------- ##
362 ## Missing templates.  ##
363 ## ------------------- ##
365 # Check that config.status detects missing input files
366 AT_SETUP([Missing templates])
368 AT_DATA([configure.ac],
369 [[AC_INIT
370 AC_CONFIG_FILES([nonexistent])
371 AC_OUTPUT
374 AT_CHECK_AUTOCONF
375 AT_CHECK_CONFIGURE([], [1], [],
376 [[config.status: error: cannot find input file: `nonexistent.in'
378 # Make sure that the output file doesn't exist
379 AT_CHECK([test -f nonexistent], 1)
381 AT_CLEANUP
386 ## ---------------------- ##
387 ## configure invocation.  ##
388 ## ---------------------- ##
390 # Check that `configure' and `config.status' honor their interface.
392 # We run `./configure one=val1 --enable-two=val2 --with-three=val3'
393 # and verify that (i) `configure' correctly receives the arguments,
394 # (ii) correctly passes them to `config.status', which we check by
395 # running `config.status --recheck', and (iii) correctly passes them
396 # to sub-configure scripts.
398 AT_SETUP([configure invocation])
400 mkdir sub
402 AT_DATA([configure.ac],
403 [[AC_INIT
404 AC_CONFIG_SUBDIRS([sub])
405 echo "result=$one$enable_two$with_three"
406 AC_OUTPUT
409 AT_DATA([sub/configure.ac],
410 [[AC_INIT
411 echo "result=$one$enable_two$with_three"
412 AC_OUTPUT
415 echo fake install-sh script >install-sh
417 AT_CHECK_AUTOCONF
418 cd sub
419 AT_CHECK_AUTOCONF
420 cd ..
422 AT_CHECK_CONFIGURE([one=one --enable-two=two --with-three=three |
423                      sed -n -e 's/^result=//p'], 0,
424                    [m4_do([onetwothree
425 ],                        [onetwothree
426 ])])
427 AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
428          [onetwothree
431 AT_CHECK_CONFIGURE([one="\"'$ " --enable-two="\" '  $" --with-three="   \"'$"|
432                       sed -n -e 's/^result=//p'], 0,
433                    [m4_do(["'$ " '  $   "'$
434 ],                        ["'$ " '  $   "'$
435 ])])
436 AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
437          ["'$ " '  $    "'$
439 dnl restore font-lock: "
441 AT_CLEANUP
445 ## -------------------------------------------- ##
446 ## Check that `#define' templates are honored.  ##
447 ## -------------------------------------------- ##
449 # Use various forms of `#define' templates, and make sure there are no
450 # problems when a symbol is prefix of another.
452 AT_SETUP([@%:@define header templates])
453 AT_KEYWORDS([AC@&t@_DEFINE])
455 AT_DATA([configure.ac],
456 [[AC_INIT
457 AC_CONFIG_HEADERS(config.h:config.hin)
459 # I18n of dummy variables: their French translations.
460 AC_DEFINE(foo, toto)
461 AC_DEFINE(bar, tata)
462 AC_DEFINE(baz, titi)
463 AC_DEFINE(fubar, tutu)
465 # Symbols which are prefixes of another.
466 AC_DEFINE(a, A)
467 AC_DEFINE(aaa, AAA)
468 AC_DEFINE(aa, AA)
470 # backslash-newline combinations
471 AC_DEFINE([multiline], [line1\
472 line2\
473 line3 \
474 line4])
475 AC_DEFINE([multiline_args(ARG1, ARG2)], [ARG2 \
476 ARG1])
477 AC_CONFIG_FILES(defs)
479 # underquoted #
480 AC_DEFINE([paste(a,b)], [a##b])
482 # Things included in confdefs.h, but which make no sense in
483 # config.h, nor in $DEFS.
484 cat <<\EOF >>confdefs.h
485 /* Hi Mum! Look, I am doing C++! */
486 #ifdef __cplusplus
487 void exit (int status);
488 #endif
491 # In addition of config.h output a full DEFS
492 AC_OUTPUT_MAKE_DEFS
493 DEFS_SAVED=$DEFS
494 AC_SUBST(DEFS_SAVED)
495 AC_OUTPUT
498 AT_DATA([defs.in],
499 [[@DEFS_SAVED@
502 AT_DATA([config.hin],
503 [[#define foo   0
504 #  define bar bar
505 #  define baz   "Archimedes was sinking in his baz"
506   #  define fubar                               tutu
507 #define a B
508  #define aa BB
509  #  define aaa BBB
510 #undef a
511  #  undef aa
512 #undef aaa
513 #define aaa(a, aa) aa a
514 #define aaab
515 #define aaac(a, aa) aa a
516 #undef multiline
517 #  undef multiline_args
518 #define paste(a,b) a##b
519 /* an ugly one: */
520 #define str(define) \
521 #define
522 #define stringify(arg) str(arg)
523 #undef aaa /* with comments */
524 #undef not_substed /* with comments */
527 AT_CHECK_AUTOCONF
528 AT_CHECK_CONFIGURE
530 AT_DATA([expout],
531 [[/* config.h.  Generated from config.hin by configure.  */
532 #define foo toto
533 #  define bar tata
534 #  define baz titi
535   #  define fubar tutu
536 #define a A
537  #define aa AA
538  #  define aaa AAA
539 #define a A
540  #  define aa AA
541 #define aaa AAA
542 #define aaa AAA
543 #define aaab
544 #define aaac(a, aa) aa a
545 #define multiline line1\
546 line2\
547 line3 \
548 line4
549 #  define multiline_args(ARG1, ARG2) ARG2 \
550 ARG1
551 #define paste(a,b) a##b
552 /* an ugly one: */
553 #define str(define) \
554 #define
555 #define stringify(arg) str(arg)
556 #define aaa AAA
557 /* #undef not_substed */
559 AT_CHECK([cat config.h], 0, expout)
561 # Check the value of DEFS.
562 AT_DATA([expout],
563 [[-DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -Dfoo=toto -Dbar=tata -Dbaz=titi -Dfubar=tutu -Da=A -Daaa=AAA -Daa=AA -Dmultiline=line1line2line3\ line4 -Dmultiline_args\(ARG1,\ ARG2\)=ARG2\ ARG1 -Dpaste\(a,b\)=a\#\#b
566 # Because we strip trailing spaces in `testsuite' we can't leave one in
567 # expout, hence nuke the one left by AC_OUTPUT_MAKE_DEFS.
568 AT_CHECK([sed -e 's/ $//' defs], 0, expout)
570 AT_CLEANUP
574 ## ------------------------- ##
575 ## Torturing config.status.  ##
576 ## ------------------------- ##
578 ## Require 100 AC_DEFINE and AC_SUBST and AC_SUBST_FILE with a significantly
579 ## big value.  This is mostly to check that Autoconf produces portable sed
580 ## scripts in config.status.  sed is used to skip the first two lines
581 ## `Generated by...'.
583 # We use m4_for many times.
584 m4_pattern_allow([^m4_for$])
586 AT_SETUP([Torturing config.status])
588 dnl The value used as a big value for AC_DEFINE.
589 dnl Don't use sh active chars here, below it is also used in a sh
590 dnl assignment.
591 m4_define([AT_BIG_VALUE],
592 [This value should be long enough to torture the various limits of sed and other tools used by Autoconf.])
594 m4_define([AT_DESCRIPTION],
595 [Define to a long string if your `Autoconf' works properly.])
598 # AT_DUMMY_VAR(NUMBER)
599 # --------------------
600 # Build a name used for AC_SUBST and AC_DEFINE.  Put ac_ in it
601 # so that the check for user name space invasion does not complain
602 # of the new variables defined.
604 # Note that you should not use the name ac_dummy, because it will be
605 # turned into ac_uummy during the construction of config.status.  Yes,
606 # this is admittedly a bug, but it would be too hard to fix this.
607 # There is really no point in AC_DEFINE a var named ac_d.*.
608 m4_pattern_allow([^m4_bpatsubst$])
609 m4_define([AT_DUMMY_VAR],
610 [ac_Dummy_[]m4_bpatsubst([000$1], [.*\(...\)$], [\1])])
614 AT_DATA([dummy.in],
615 [m4_for([AT_Count], 1, 100, 1,
616 [@AT_DUMMY_VAR(AT_Count)@
617 @[f]AT_Count@
618 ])])
622 while test $i != 101; do
623   echo "content of file $i" > file_$i
624   AS_VAR_ARITH([i], [$i + 1])
625 done
628 # ------------ #
629 # configure.ac #
630 # ------------ #
632 m4_pattern_allow([^m4_(define|defun)$])
633 AT_DATA([configure.ac],
634 dnl The following lines transfer AT_DUMMY_VAR, AT_DESCRIPTION, and
635 dnl AT_BIG_VALUE into the configure.ac as AC_DUMMY_VAR etc.
636 [[m4_define([AC_DUMMY_VAR],]
637 m4_dquote(m4_defn([AT_DUMMY_VAR]))[)]]
639 [[m4_define([AC_DESCRIPTION],]
640 m4_dquote(m4_defn([AT_DESCRIPTION]))[)]]
642 [[m4_define([AC_BIG_VALUE],]
643 m4_dquote(m4_defn([AT_BIG_VALUE]))[)]]
645 [[# AC_DEFUBST(NAME)
646 # ----------------
647 # Related VALUE to NAME both with AC_SUBST and AC_DEFINE.  This is
648 # used in the torture tests.
649 m4_defun([AC_DEFUBST],
650 [AC_DUMMY_VAR($1)="AC_BIG_VALUE"
651 AC_DEFINE_UNQUOTED(AC_DUMMY_VAR($1), "$AC_DUMMY_VAR($1) $AC_DUMMY_VAR($1)",
652                    AC_DESCRIPTION)
653 AC_SUBST(AC_DUMMY_VAR($1))
654 AC_SUBST_FILE([f]$1)
655 f$1=file_$1
658 AC_INIT
659 AC_CONFIG_HEADERS(config.h:config.hin)
660 AC_CONFIG_FILES(dummy)
661 m4_for(AC_Count, 1, 100, 1,
662        [AC_DEFUBST(AC_Count)])
663 AC_PROG_AWK
664 AC_OUTPUT
665 ]])# configure.ac
667 AT_CHECK_AUTOCONF
668 AT_CHECK_AUTOHEADER
669 # Check both awk and the result of AC_PROG_AWK
670 for awk_arg in FOO= AWK=awk; do
671   AT_CHECK_CONFIGURE([$awk_arg])
673   # Checking that AC_DEFINE worked properly.
674   AT_DATA([expout],
675 [/* Define to the address where bug reports for this package should be sent. */
676 #define PACKAGE_BUGREPORT ""
678 /* Define to the full name of this package. */
679 #define PACKAGE_NAME ""
681 /* Define to the full name and version of this package. */
682 #define PACKAGE_STRING ""
684 /* Define to the one symbol short name of this package. */
685 #define PACKAGE_TARNAME ""
687 /* Define to the home page for this package. */
688 #define PACKAGE_URL ""
690 /* Define to the version of this package. */
691 #define PACKAGE_VERSION ""
692 m4_for(AT_Count, 1, 100, 1,
694 /* AT_DESCRIPTION */
695 [#define] AT_DUMMY_VAR(AT_Count) "AT_BIG_VALUE AT_BIG_VALUE"
696 ])])
698   AT_CHECK([sed -n '4,$ p' config.h], 0, expout)
700   # Checking that AC_SUBST worked properly.
701   AT_DATA([expout],
702 [m4_for(AT_Count, 1, 100, 1,
703 [AT_BIG_VALUE
704 content of file AT_Count
705 ])])
707   AT_CHECK([cat dummy], 0, expout)
708 done
710 AT_CLEANUP
713 ## ------------------------------- ##
714 ## Substitute a 2000-byte string.  ##
715 ## ------------------------------- ##
717 # Solaris 9 /usr/ucb/sed that rejects commands longer than 4000 bytes.  HP/UX
718 # sed dumps core around 8 KiB.  However, POSIX says that sed need not
719 # handle lines longer than 2048 bytes (including the trailing newline).
720 # So we'll just test a 2000-byte value, and for awk, we test a line with
721 # almost 1000 words, and one variable with 5 lines of 2000 bytes each:
722 # multi-line values should allow to get around the limitations.
724 AT_SETUP([Substitute a 2000-byte string])
726 AT_DATA([Foo.in], [@foo@
728 AT_DATA([Bar.in], [@bar@
730 AT_DATA([Baz.in], [@baz@
733 AT_DATA([configure.ac],
734 [[AC_INIT
735 AC_SUBST([foo], ]m4_for([n], 1, 100,, ....................)[)
736 AC_SUBST([bar], "]m4_for([n], 1, 100,, @ @ @ @ @ @ @ @ @ @@)[")
737 baz="]m4_for([m], 1, 100,, ... ... ... ... ....)[
739 baz=$baz$baz$baz$baz$baz
740 AC_SUBST([baz])
741 AC_PROG_AWK
742 AC_CONFIG_FILES([Foo Bar Baz])
743 AC_OUTPUT
746 cp "$abs_top_srcdir/build-aux/install-sh" .
748 AT_CHECK_AUTOCONF
749 # Check both awk and the result of AC_PROG_AWK
750 for awk_arg in Foo= AWK=awk; do
751   AT_CHECK_CONFIGURE([$awk_arg])
752   AT_CHECK([cat Foo], 0, m4_for([n], 1, 100,, ....................)
754   AT_CHECK([cat Bar], 0, m4_for([n], 1, 100,, @ @ @ @ @ @ @ @ @ @@)
756   AT_DATA([stdout],
757   [m4_for([n], 1, 5,, m4_for([m], 1, 100,, ... ... ... ... ....)
759   AT_CHECK([cat Baz], 0, [stdout])
760 done
761 AT_CLEANUP
764 ## ------------------------------ ##
765 ## Define to a 2000-byte string.  ##
766 ## ------------------------------ ##
768 AT_SETUP([Define to a 2000-byte string])
769 AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
771 AT_CONFIGURE_AC(
773 AC_DEFINE_UNQUOTED([foo], ]m4_for([n], 1, 100,, ....................)[, [desc])
774 AC_DEFINE([fooq], ]m4_for([n], 1, 100,, ....................)[, [desc])
777 AT_CHECK_AUTOCONF
778 AT_CHECK_AUTOHEADER
779 AT_CHECK_CONFIGURE
780 AT_CHECK_DEFINES([@%:@define foo m4_for([n], 1, 100,, ....................)
781 @%:@define fooq m4_for([n], 1, 100,, ....................)
783 AT_CLEANUP
786 ## ------------------------------------------ ##
787 ## Substitute and define special characters.  ##
788 ## ------------------------------------------ ##
790 # Use characters special to the shell, sed, awk, and M4.
792 AT_SETUP([Substitute and define special characters])
793 AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
795 AT_DATA([Foo.in], [@foo@
796 @bar@@notsubsted@@baz@ stray @ and more@@@baz@
797 abc@bar@baz@baz
798 abc@bar@@baz@baz
799 abc@bar@@baz@baz@
800 abc@bar @baz@baz
801 abc@bar @baz@baz@
802 abc@bar @baz@@baz@
803 @file@
804          @file@
805 X@file@
806 @file@X
809 AT_DATA([File],
810 [@foo@@bar@
813 AT_DATA([Zardoz.in], [@zardoz@
816 AT_CONFIGURE_AC(
817 [[foo="AS@&t@_ESCAPE([[X*'[]+ ", & &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !]])"
819 bar="@foo@ @baz@"
820 baz=bla
821 ( for i in 0 1 2 3; do
822     for j in 0 1 2 3 4 5 6 7; do
823       for k in 0 1 2 3 4 5 6 7; do
824         case $i$j$k in #(
825         000 | 015 | 377) ;; # MinGW awk dislikes 0xFF, and the test does
826                             # the wrong thing for CR on MinGW.
827                             #(
828         *) printf \\$i$j$k's' ;; # The 's' works around a Solaris 8 /bin/bash bug.
829         esac
830       done
831     done
832   done
833   printf \\n
834 ) >allowed-chars
835 zardoz=`cat allowed-chars`
836 AC_SUBST([foo])
837 AC_SUBST([bar])
838 AC_SUBST([baz])
839 AC_SUBST([zardoz])
840 file=File
841 AC_SUBST_FILE([file])
842 AC_DEFINE([fooq], [[X*'[]+ ", & &`\($foo !]], [Awful value.])
843 AC_DEFINE([barq], [[%!_!# X]], [Value that is used as special delimiter.])
844 AC_DEFINE_UNQUOTED([foo], [[X*'[]+ ", & &\`\\(\$foo !]], [Awful value.])
845 AC_DEFINE_UNQUOTED([bar], [[%!_!# X]], [Value that is used as special delimiter.])
846 AC_DEFINE_UNQUOTED([unq1], [$baz], [unquoted, test 1])
847 AC_DEFINE_UNQUOTED([unq2], [\$baz], [unquoted, test 2])
848 AC_DEFINE_UNQUOTED([unq3], ["$baz"], [unquoted, test 3])
849 AC_DEFINE_UNQUOTED([unq4], [${baz+set}], [unquoted, test 4])
850 AC_DEFINE_UNQUOTED([unq5], ["${baz+`echo "a b"`}"], [unquoted, test 5])
851 AC_DEFINE_UNQUOTED([unq6], [`echo hi`], [unquoted, test 6])
852 AC_DEFINE_UNQUOTED([unq7], ['\"'], [unquoted, test 7])
853 AC_PROG_AWK
854 AC_CONFIG_FILES([Foo Zardoz])]])
856 AT_CHECK_AUTOCONF
857 AT_CHECK_AUTOHEADER
858 # Check both awk and the result of AC_PROG_AWK
859 for awk_arg in FOO= AWK=awk; do
860   AT_CHECK_CONFIGURE([$awk_arg])
861   AT_CHECK([cat Foo], 0, [[X*'[]+ ", & &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !
862 @foo@ @baz@@notsubsted@bla stray @ and more@@bla
863 abc@foo@ @baz@baz@baz
864 abc@foo@ @baz@blabaz
865 abc@foo@ @baz@blabaz@
866 abc@bar blabaz
867 abc@bar blabaz@
868 abc@bar blabla
869 @foo@@bar@
870 @foo@@bar@
871 X@file@
872 @file@X
874   AT_CHECK([cmp allowed-chars Zardoz])
875   AT_CHECK_DEFINES([[#define bar %!_!# X
876 #define barq %!_!# X
877 #define foo X*'[]+ ", & &`\($foo !
878 #define fooq X*'[]+ ", & &`\($foo !
879 #define unq1 bla
880 #define unq2 $baz
881 #define unq3 "bla"
882 #define unq4 set
883 #define unq5 "a b"
884 #define unq6 hi
885 #define unq7 '\"'
887 done
888 AT_CLEANUP
891 ## ---------------------- ##
892 ## Substitute a newline.  ##
893 ## ---------------------- ##
895 AT_SETUP([Substitute a newline])
897 AT_DATA([Foo.in],
898 [@foo@
899 @bar@
902 AT_DATA([configure.ac],
903 [[AC_INIT
904 foo='one
905 two'
906 bar='%!_!# ''
908 AC_SUBST([foo])
909 AC_SUBST([bar])
910 AC_CONFIG_FILES([Foo])
911 AC_PROG_AWK
912 AC_OUTPUT
915 cp "$abs_top_srcdir/build-aux/install-sh" .
917 echo 'one
919 %!_!# ''
920 x' >expout
922 AT_CHECK_AUTOCONF
923 # Check both awk and the result of AC_PROG_AWK
924 for awk_arg in FOO= AWK=awk; do
925   AT_CHECK_CONFIGURE([$awk_arg])
926   AT_CHECK([cat Foo], 0, [expout])
927 done
928 AT_CLEANUP
931 ## ------------------ ##
932 ## Define a newline.  ##
933 ## ------------------ ##
935 AT_SETUP([Define a newline])
936 AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
937 AT_CONFIGURE_AC([[AC_DEFINE([foo], [one
938 two], [This spans two lines.])
940 AT_CHECK_AUTOCONF([], [], [], [stderr])
941 dnl Older versions of m4 report error at line 5 (end of macro);
942 dnl newer versions report it at line 4 (start of macro).
943 AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
944 [[warning: AC_DEFINE: `one
945 two' is not a valid preprocessor define value
947 AT_CHECK_AUTOHEADER([], [], [], [stderr])
948 AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
949 [[warning: AC_DEFINE: `one
950 two' is not a valid preprocessor define value
952 AT_CHECK_CONFIGURE
953 AT_CHECK_DEFINES([[#define foo one
956 AT_CONFIGURE_AC([[AC_DEFINE_UNQUOTED([foo], [one
957 two], [This spans two lines.])
959 AT_CHECK_AUTOCONF([], [], [], [stderr])
960 AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
961 [[warning: AC_DEFINE_UNQUOTED: `one
962 two' is not a valid preprocessor define value
964 AT_CHECK_AUTOHEADER([], [], [], [stderr])
965 AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
966 [[warning: AC_DEFINE_UNQUOTED: `one
967 two' is not a valid preprocessor define value
969 AT_CHECK_CONFIGURE
970 AT_CHECK_DEFINES([[#define foo one
973 AT_CLEANUP
976 ## ------------------------------------ ##
977 ## AC_SUBST: variable name validation.  ##
978 ## ------------------------------------ ##
980 AT_SETUP([AC_SUBST: variable name validation])
982 AT_CONFIGURE_AC([[AC_SUBST(, [])
983 AC_CONFIG_FILES([Makefile])
985 AT_DATA([Makefile.in], [[
987 mv -f configure.ac configure.tmpl
989 # Invalid names.
990 for var in ['' ab\~ ab\( ab[] ab\' ab\" ab\\\\]; do
991   sed ["s/AC_SUBST(/&[$var]/"] <configure.tmpl >configure.ac
992   AT_CHECK_AUTOCONF([], [1], [], [ignore])
993 done
995 # Valid names.
996 for var in ab a4 'a@@&t@\&t@b'; do
997   sed ["s/AC_SUBST(/&[$var]/"] <configure.tmpl >configure.ac
998   AT_CHECK_AUTOCONF
999   AT_CHECK_AUTOHEADER
1000   AT_CHECK_CONFIGURE
1001 done
1003 AT_CLEANUP
1006 ## ------------------------ ##
1007 ## datarootdir workaround.  ##
1008 ## ------------------------ ##
1010 AT_SETUP([datarootdir workaround])
1012 AT_DATA([Foo.in],
1013 [@datadir@
1014 @docdir@
1015 @infodir@
1016 @localedir@
1017 @mandir@
1020 AT_DATA([Bar.in],
1021 [@mydatadir@
1024 AT_DATA([configure.ac],
1025 [[AC_INIT
1026 d@&t@nl The following line silences the warnings, if uncommented:
1027 d@&t@nl AC_DEFUN([AC_DATAROOTDIR_CHECKED])
1029 # This substitution is wrong and bogus!  Don't use it in your own code!
1030 # Read `info Autoconf "Defining Directories"'!
1031 AC_SUBST([mydatadir], [${datadir}/my])
1033 AC_CONFIG_FILES([Foo Bar])
1034 AC_OUTPUT
1037 cp "$abs_top_srcdir/build-aux/install-sh" .
1039 AT_CHECK_AUTOCONF
1040 AT_CHECK_CONFIGURE([], [], [],
1041   [config.status: WARNING:  'Foo.in' seems to ignore the --datarootdir setting
1042 config.status: WARNING: Bar contains a reference to the variable `datarootdir'
1043 which seems to be undefined.  Please make sure it is defined.
1045 AT_CHECK([grep datarootdir Foo], 1, [])
1047 rm configure
1048 sed '/AC_DEFUN/s/^d@&t@nl //' configure.ac >t
1049 mv t configure.ac
1051 AT_CHECK_AUTOCONF
1052 AT_CHECK_CONFIGURE
1054 AT_CLEANUP
1057 ## -------- ##
1058 ## srcdir.  ##
1059 ## -------- ##
1061 AT_SETUP([srcdir])
1063 rm -f -r at-dir
1064 mkdir at-dir
1065 : >at-dir/bar.in
1066 : >foo.in
1068 AT_DATA([configure.ac],
1069 [[AC_INIT
1071 AC_CONFIG_FILES([foo at-dir/bar])
1073 # Use quotes in the INIT-COMMANDS to accommodate a value of $srcdir
1074 # containing e.g., spaces or shell meta-characters.
1075 # Use *single* quotes because the context is an unquoted here-doc.
1076 AC_CONFIG_COMMANDS([report],
1077 [test -f "$srcdir/configure.ac" ||
1078    AC_MSG_ERROR([cannot find $srcdir/configure.ac])],
1079                    [srcdir='$srcdir'])
1081 AC_OUTPUT
1082 rm -f -r foo at-dir/bar
1085 AT_CHECK_AUTOCONF
1087 # In place.
1088 AT_CHECK([./configure], [], [ignore])
1090 # Relative name.
1091 AT_CHECK([cd at-dir && ../configure], [], [ignore])
1093 # Absolute name.
1094 at_here=`pwd`
1095 AT_CHECK([cd at-dir && "$at_here/configure"], [], [ignore])
1097 AT_CLEANUP
1100 ## ----------------- ##
1101 ## Signal handling.  ##
1102 ## ----------------- ##
1104 AT_SETUP([Signal handling])
1106 AT_DATA([configure.ac],
1107 [[AC_INIT
1108 kill -2 $$
1109 exit 77
1112 AT_CHECK_AUTOCONF
1113 AT_CHECK_CONFIGURE([], 1, ignore, ignore)
1115 AT_CLEANUP
1118 ## ------------------------------------- ##
1119 ## AC_CONFIG_LINKS and identical files.  ##
1120 ## ------------------------------------- ##
1121 AT_SETUP([AC_CONFIG_LINKS and identical files])
1123 AT_DATA([configure.ac],
1124 [[AC_INIT
1125 AC_CONFIG_LINKS([src/s:src/s])
1126 test "$srcdir" != '.' && AC_CONFIG_LINKS([src/t:src/t])
1127 AC_OUTPUT
1130 mkdir src build
1131 echo file1 > src/s
1132 echo file2 > src/t
1133 AT_CHECK_AUTOCONF
1134 cd build
1135 AT_CHECK([../configure && ../configure], 0, [ignore])
1136 AT_CHECK([cat src/s src/t], 0, [file1
1137 file2
1139 cd ..
1140 AT_CHECK([./configure && ./configure], 0, [ignore], [stderr])
1141 AT_CHECK([grep src/t stderr], 1)
1142 AT_CHECK([cat src/s src/t], 0, [file1
1143 file2
1145 AT_CHECK(["`pwd`"/configure && "`pwd`"/configure], 0, [ignore], [ignore])
1146 AT_CHECK([cat src/s src/t], 0, [file1
1147 file2
1150 AT_CLEANUP
1153 AT_BANNER([autoreconf.])
1155 ## ---------------------------- ##
1156 ## Configuring subdirectories.  ##
1157 ## ---------------------------- ##
1159 # .
1160 # |-- builddir
1161 # |   |-- config.log
1162 # |   |-- config.status
1163 # |   `-- inner
1164 # |       |-- config.log
1165 # |       |-- config.status
1166 # |       `-- innermost
1167 # |           `-- config
1168 # |-- configure
1169 # |-- configure.ac
1170 # |-- inner
1171 # |   |-- configure
1172 # |   |-- configure.ac
1173 # |   `-- innermost
1174 # |       `-- config.in
1175 # `-- install-sh
1177 AT_SETUP([Configuring subdirectories])
1178 AT_KEYWORDS(autoreconf)
1180 # We use aclocal (via autoreconf).
1181 AT_CHECK([aclocal --version || exit 77], [], [stdout], [ignore])
1182 # It should understand configure.ac.
1183 AT_CHECK([[grep '[^0-9]1.[01234][^0-9]' stdout && exit 77]], [1], [ignore])
1185 # Set CONFIG_SITE to a nonexistent file, so that there are
1186 # no worries about nonstandard values for 'prefix'.
1187 CONFIG_SITE=no-such-file
1188 export CONFIG_SITE
1190 # The contents of `inner/', and `inner/innermost/'.
1191 AS_MKDIR_P([inner/innermost])
1193 # We have to use configure.in, not configure.ac, if we still want to
1194 # be compatible with Automake 1.4: aclocal (run by autoreconf) would
1195 # die because it can't find configure.in.
1196 AT_DATA([inner/configure.in],
1197 [[AC_INIT(GNU Inner, 1.0)
1198 AC_CONFIG_SRCDIR([innermost/config.in])
1199 AC_ARG_VAR([INNER], [an inner variable])
1200 AC_SUBST([INNER])
1201 if test "x$INNER" = x; then
1202   INNER=inner
1204 AC_CONFIG_FILES([innermost/config])
1205 AC_OUTPUT
1208 AT_DATA([inner/innermost/config.in],
1209 [INNER=@INNER@
1210 srcdir=@srcdir@
1211 top_srcdir=@top_srcdir@
1212 prefix=@prefix@
1215 # The contents of `.'
1216 AT_DATA([install-sh], [])
1218 # nonexistent is allowed not to exist.
1219 AT_DATA([configure.in],
1220 [[AC_INIT(GNU Outer, 1.0)
1221 AC_ARG_VAR([OUTER], [an outer variable])
1222 if false; then
1223   AC_CONFIG_SUBDIRS([nonexistent])
1225 AC_CONFIG_SUBDIRS([inner])
1226 AC_OUTPUT
1229 # If there are improperly quoted AC_DEFUN installed in share/aclocal,
1230 # they trigger warnings from aclocal 1.8, so ignore stderr.
1231 AT_CHECK([autoreconf], [], [], [ignore])
1232 AT_CHECK([test -f inner/configure])
1234 # Running the outer configure recursively should provide the innermost
1235 # help strings.
1236 chmod a-w inner/innermost inner .
1237 AT_CHECK([{ ./configure --help=recursive; chmod u+w .; } | grep INNER], 0,
1238          [ignore], [stderr],
1239          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1240 chmod u+w . inner inner/innermost
1242 # Running the outer configure should trigger the inner.
1243 AT_CHECK_CONFIGURE
1244 AT_CHECK([cat inner/innermost/config], 0,
1245 [INNER=inner
1246 srcdir=.
1247 top_srcdir=..
1248 prefix=/usr/local
1251 # The same, but from a builddir.
1252 AS_MKDIR_P([builddir])
1253 AT_CHECK([cd builddir && ../configure], 0, [ignore])
1254 AT_CHECK([cat builddir/inner/innermost/config], 0,
1255 [INNER=inner
1256 srcdir=../../../inner/innermost
1257 top_srcdir=../../../inner
1258 prefix=/usr/local
1261 # Make sure precious variables and command line options are properly
1262 # passed, even when there are duplicates.
1263 AT_CHECK([cd builddir && ../configure --prefix /bad --prefix /good INNER=bad INNER=good], 0, [ignore])
1264 AT_CHECK([cat builddir/inner/innermost/config], 0,
1265 [INNER=good
1266 srcdir=../../../inner/innermost
1267 top_srcdir=../../../inner
1268 prefix=/good
1271 # Make sure --prefix is properly quoted
1272 AT_CHECK([cd builddir && ../configure --prefix "/a  b c$ 'd"], 0, [ignore])
1273 AT_CHECK([cat builddir/inner/innermost/config], 0,
1274 [INNER=inner
1275 srcdir=../../../inner/innermost
1276 top_srcdir=../../../inner
1277 prefix=/a  b c$ 'd
1280 # Make sure --silent is properly passed...
1281 AT_CHECK([cd builddir && ../configure --silent], 0, [])
1282 # ...but not stored in config.status.
1283 AT_CHECK([cd builddir && ./config.status --recheck], 0, [stdout])
1284 AT_CHECK([grep 'creating \./config.status' stdout], 0, [ignore])
1286 # Make sure we can run autoreconf on a subdirectory
1287 rm -f configure configure.in
1288 AT_CHECK([autoreconf inner], [], [], [ignore])
1290 # Make sure we can pass a configure.ac name
1291 AT_CHECK([cd inner && autoreconf configure.in], [], [], [ignore])
1292 AT_CHECK([autoreconf inner/configure.in], [], [], [ignore])
1294 AT_CLEANUP
1298 ## -------------- ##
1299 ## Deep Package.  ##
1300 ## -------------- ##
1302 AT_SETUP([Deep Package])
1303 AT_KEYWORDS(autoreconf)
1305 # We use aclocal (via autoreconf).
1306 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
1308 # The contents of `.'
1309 AT_DATA([install-sh], [])
1310 AT_DATA([configure.in],
1311 [[AC_INIT(GNU Outer, 1.0)
1312 AC_ARG_VAR([OUTER], [an outer variable])
1313 AC_CONFIG_SUBDIRS([inner inner2])
1314 AC_OUTPUT
1317 # The contents of `inner/', and `inner/innermost/'.
1318 AS_MKDIR_P([inner/innermost])
1319 AS_MKDIR_P([inner2])
1321 AT_DATA([inner/configure.in],
1322 [[AC_INIT(GNU Inner, 1.0)
1323 AC_ARG_VAR([INNER], [an inner variable])
1324 AC_CONFIG_SUBDIRS(innermost)
1325 AC_OUTPUT
1328 AT_DATA([inner/innermost/configure.in],
1329 [[AC_INIT(GNU Innermost, 1.0)
1330 AC_ARG_VAR([INNERMOST], [an innermost variable])
1331 AC_CONFIG_HEADERS(config.h:config.hin)
1332 AC_DEFINE_UNQUOTED([INNERMOST], [$INNERMOST], [an innermost variable])
1333 if test -n "$innermost_error"; then
1334   AC_MSG_FAILURE([error in $PACKAGE_NAME])
1336 AC_OUTPUT
1339 AT_DATA([inner2/configure.in],
1340 [[AC_INIT(GNU Inner 2, 1.0)
1341 AC_ARG_VAR([INNER2], [an inner2 variable])
1342 AC_OUTPUT
1345 AT_CHECK([autoreconf -Wall -v], [0], [ignore], [ignore])
1346 AT_CHECK([test -f inner/configure])
1347 AT_CHECK([test -f inner/innermost/configure])
1348 AT_CHECK([test -f inner/innermost/config.hin])
1349 AT_CHECK([test -f inner2/configure])
1351 # Running the outer configure recursively should provide the innermost
1352 # help strings.
1353 chmod a-w inner/innermost inner
1354 AT_CHECK([{ ./configure --help=recursive; chmod u+w .; } | grep " INNER "],
1355          0, [ignore], [stderr],
1356          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1357 chmod a-w .
1358 AT_CHECK([{ ./configure --help=recursive; chmod u+w .; } | grep " INNER2 "],
1359          0, [ignore], [stderr],
1360          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1361 chmod a-w .
1362 AT_CHECK([{ ./configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1363          0, [ignore], [stderr],
1364          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1365 chmod a-w .
1366 AT_CHECK([{ /bin/sh ./configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1367          0, [ignore], [stderr],
1368          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1369 chmod a-w .
1370 AT_CHECK([PATH=.$PATH_SEPARATOR$PATH; export PATH; { /bin/sh configure --help=recursive; chmod +w .; } | grep " INNERMOST "],
1371          0, [ignore], [stderr],
1372          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1373 chmod a-w .
1374 AT_CHECK([PATH=.$PATH_SEPARATOR$PATH; export PATH; { configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1375          0, [ignore], [stderr],
1376          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1377 chmod u+w inner inner/innermost
1379 # Running the outer configure should trigger the inner.
1380 AT_CHECK_CONFIGURE([INNERMOST=tsomrenni])
1381 AT_CHECK([grep INNERMOST inner/innermost/config.h], 0,
1382 [[#define INNERMOST tsomrenni
1385 # Ensure we point to the right config.log file for errors.
1386 AT_CHECK_CONFIGURE([innermost_error=:], [1], [], [stderr])
1387 AT_CHECK([grep 'inner/innermost' stderr], [], [ignore])
1388 cd inner
1389 AT_CHECK_CONFIGURE([innermost_error=:], [1], [], [stderr])
1390 AT_CHECK([grep 'innermost' stderr], [], [ignore])
1391 cd ..
1393 # The same, but from a builddir.
1394 AS_MKDIR_P([builddir])
1395 chmod a-w builddir inner/innermost inner
1396 AT_CHECK([cd builddir && { ../configure --help=recursive; chmod u+w .; } | grep " INNER "],
1397          0, [ignore], [stderr],
1398          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1399 chmod a-w builddir
1400 AT_CHECK([cd builddir && { ../configure --help=recursive; chmod u+w .; } | grep " INNER2 "],
1401          0, [ignore], [stderr],
1402          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1403 chmod a-w builddir
1404 AT_CHECK([cd builddir && { ../configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1405          0, [ignore], [stderr],
1406          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1407 chmod a-w builddir
1408 AT_CHECK([cd builddir && { /bin/sh ../configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1409          0, [ignore], [stderr],
1410          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1411 chmod a-w builddir
1412 # Not all shells search $PATH for scripts.
1413 if (cd builddir && PATH=`pwd`/..$PATH_SEPARATOR$PATH /bin/sh configure --help) >/dev/null 2>&1; then
1414   AT_CHECK([cd builddir && PATH=`pwd`/..$PATH_SEPARATOR$PATH /bin/sh configure --help=recursive | grep " INNERMOST "], 0, [ignore])
1416 AT_CHECK([PATH=`pwd`$PATH_SEPARATOR$PATH; export PATH; cd builddir && { configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1417          0, [ignore], [stderr],
1418          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1419 chmod u+w builddir inner inner/innermost
1420 AT_CHECK([cd builddir && ../configure INNERMOST=build/tsomrenni], 0, [ignore])
1421 AT_CHECK([grep INNERMOST builddir/inner/innermost/config.h], 0,
1422 [[#define INNERMOST build/tsomrenni
1425 AT_CLEANUP
1429 ## -------------------------------- ##
1430 ## Non-Autoconf AC_CONFIG_SUBDIRS.  ##
1431 ## -------------------------------- ##
1433 AT_SETUP([Non-Autoconf AC_CONFIG_SUBDIRS])
1434 AT_KEYWORDS([autoreconf])
1436 # We use aclocal (via autoreconf).
1437 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
1439 AT_DATA([install-sh], [])
1440 AT_DATA([configure.in],
1441 [[AC_INIT(GNU Outer, 1.0)
1442 AC_CONFIG_SUBDIRS([inner])
1443 AC_OUTPUT
1446 AS_MKDIR_P([inner])
1448 AT_DATA([inner/configure],
1449 [[#! /bin/sh
1450 case "$*" in
1451     *--help*) echo 'No Autoconf here, folks!' ;;
1452     *)        echo got_it >myfile ;;
1453 esac
1454 exit 0
1456 chmod +x inner/configure
1458 AT_CHECK([autoreconf -Wall -v], 0, [ignore], [ignore])
1460 # Running the outer configure recursively should provide the innermost
1461 # help strings.
1462 AT_CHECK([./configure --help=recursive | grep "folks"], 0, [ignore])
1464 # Running the outer configure should trigger the inner.
1465 AT_CHECK([./configure], 0, [ignore])
1466 AT_CHECK([test -f inner/myfile], 0)
1468 AT_CLEANUP
1472 ## ----------------- ##
1473 ## Empty directory.  ##
1474 ## ----------------- ##
1476 AT_SETUP([Empty directory])
1477 AT_KEYWORDS([autoreconf])
1479 # We use aclocal (via autoreconf).
1480 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
1482 # The test group directory is not necessarily _empty_, but it does not contain
1483 # files meaningful to `autoreconf'.
1485 AT_CHECK([autoreconf -Wall -v], 1, [ignore], [ignore])
1487 AT_CLEANUP
1491 ## ------------------------------ ##
1492 ## Unusual Automake input files.  ##
1493 ## ------------------------------ ##
1495 # This parallels gnumake.test in Automake.
1497 AT_SETUP([Unusual Automake input files])
1498 AT_KEYWORDS([autoreconf])
1500 # We use aclocal and automake via autoreconf.
1501 AT_CHECK([automake --version || exit 77], [], [ignore], [ignore])
1503 AT_DATA([configure.in],
1504 [[AC_INIT(GNU foo, 1.0)
1505 AM_INIT_AUTOMAKE
1506 AC_CONFIG_FILES([HeeHee])
1507 AC_OUTPUT
1510 AT_DATA([HeeHee.am],
1511 [[# Humans do no worse than `GNUmakefile.am'.
1512 AUTOMAKE_OPTIONS = foreign 1.8
1515 AT_CHECK([autoreconf -Wall -v -i], 0, [ignore], [stderr],
1516          [AT_CHECK([grep 'require.*1\.8' stderr && exit 77], [1])])
1517 AT_CHECK([test -f HeeHee.in])
1519 AT_CLEANUP