Document temporary directory `$tmp' for use in config.status.
[autoconf.git] / tests / torture.at
blob84eeda9bfb452d9a0820b2f247b6df9641559320
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 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
44 ## ------------------------------- ##
45 ## parameterized AC_CONFIG_FILES.  ##
46 ## ------------------------------- ##
48 AT_SETUP([Parameterized AC_CONFIG_FILES])
50 AT_CONFIGURE_AC([[
51 files="foo
52 bar"
53 AC_CONFIG_FILES([$files])]])
54 AT_CHECK_AUTOCONF([], [], [], [ignore])
55 touch foo.in bar.in config.hin
56 AT_CHECK_CONFIGURE
58 AT_CLEANUP
62 ## ------------ ##
63 ## AC_ARG_VAR.  ##
64 ## ------------ ##
66 # AT_CHECK_AC_ARG_VAR(FIRST-VALUE, SECOND-VALUE, [STATUS = 1])
67 # ------------------------------------------------------------
68 # Check that AC_ARG_VAR caches the latest values, diagnoses
69 # inconsistencies, and arms config.status.  Check that recheck
70 # returns STATUS, save configure output in files 'stdout' and 'stderr'
71 # for further inspection.
72 m4_define([AT_CHECK_AC_ARG_VAR],
73 [rm -f config.cache
75 # Initial value.
76 m4_ifval([$1],
77          [precious='m4_bpatsubst([$1], [[']], ['\\''])'; export precious],
78          [unset precious])
79 AT_CHECK_CONFIGURE([--config-cache -q])
80 AT_CHECK([cat file], [], [`$1'
83 # Testing --recheck: 1. have the environment `forget' about PRECIOUS.
84 unset precious
85 # 2. Rerun config.status to recreate `file'.
86 AT_CHECK([./config.status --recheck], [], [ignore])
87 AT_CHECK([./config.status], [], [ignore])
88 # 3. Check that file contains the old value of PRECIOUS.
89 AT_CHECK([cat file], [], [`$1'
92 # Second value: we should issue an error here: the value
93 # has changed!
94 m4_ifval([$2],
95          [precious='$2'; export precious],
96          [unset precious])
97 AT_CHECK_CONFIGURE([--config-cache], [m4_default([$3], [1])], [stdout], [stderr])
99 ])# AT_CHECK_AC_ARG_VAR
102 AT_SETUP([AC_ARG_VAR])
104 # We don't want to run this test if this shell doesn't support
105 # `unset'.
106 AT_CHECK([
107 if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
108   exit 0
109 else
110   exit 77
114 AT_DATA([configure.ac],
115 [[AC_INIT
116 AC_ARG_VAR([precious], [this variable costs a lot])
117 echo "precious:$precious"
118 AC_OUTPUT(file)
121 AT_DATA([file.in],
122 [[`@precious@'
125 AT_CHECK_AUTOCONF
127 # Set a precious variable
128 AT_CHECK_AC_ARG_VAR([], [apple of my eye])
130 # Unset a precious variable
131 AT_CHECK_AC_ARG_VAR([apple of my eye], [])
133 # Change a precious variable
134 AT_CHECK_AC_ARG_VAR([apple of my eye], [orange of my eye])
136 # Change a precious variable that contains braces
137 AT_CHECK_AC_ARG_VAR([apple of my {eye}], [orange of my eye])
139 # Change a precious variable that contains all kinds of fun
140 AT_CHECK_AC_ARG_VAR(['p  r      ec"iou$], [orange of my eye])
141 dnl restore font-lock: "
143 # Warn (but do not fail) about a whitespace-only change
144 AT_CHECK_AC_ARG_VAR([    apple  of       my eye  ], [apple of my eye],
145                     [0], ["has whitespace changes"])
146 mv stdout configure-output
147 AT_CHECK([grep "ignoring whitespace changes" stderr], [], [ignore])
148 AT_CHECK([grep "precious:        apple" configure-output], [], [ignore])
150 AT_CLEANUP
155 ## ---------------------------------------------- ##
156 ## AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS.  ##
157 ## ---------------------------------------------- ##
159 AT_SETUP([[AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS]])
161 AT_DATA([configure.ac],
162 [[AC_INIT
163 AC_PROG_FGREP
164 rm -f -r header var-header file var-file link var-link command var-command
165 echo 'OK' >input
167 # Be sure to also stress the associated INIT-CMDS.
168 case $what_to_test in
169  header)
170    AC_CONFIG_HEADERS(header:input);;
171  var-header)
172    AC_CONFIG_HEADERS(var-header:$header_in, [], [header_in=input]);;
174  file)
175    AC_CONFIG_FILES(file:input);;
176  var-file)
177    AC_CONFIG_FILES(var-file:$file_in, [], [file_in=input]);;
179  command)
180    AC_CONFIG_COMMANDS(command,
181                       [cp input command]);;
182  var-command)
183    AC_CONFIG_COMMANDS(var-command,
184                       [cp $command_in var-command], [command_in=input]);;
186  link)
187    AC_CONFIG_LINKS(link:input);;
188  var-link)
189    AC_CONFIG_LINKS(var-link:$link_in, [], [link_in=input]);;
190 esac
191 AC_OUTPUT
194 AT_CHECK_AUTOCONF
197 # AT_CHECK_CONFIG_CREATION(THING = (header | link | file | command))
198 # ------------------------------------------------------------------
199 # Check that THING and var-THING (which uses variables in AC_CONFIG_THING)
200 # are properly created, with the right content.
201 # Use `grep OK' instead of a simple `cat' to avoid banners such as in
202 # AC_CONFIG_HEADERS.
203 m4_define([AT_CHECK_CONFIG_CREATION],
204 [AT_CHECK_CONFIGURE([what_to_test=$1])
205 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
206          [ignore], [$1
208 AT_CHECK([grep OK $1], [], [OK
211 AT_CHECK_CONFIGURE([what_to_test=var-$1 --no-create])
212 # config.status might be stupidly expecting data on stdin, if it's
213 # really broken...
214 AT_CHECK([./config.status var-$1 </dev/null], [], [ignore])
215 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
216          [ignore], [var-$1
218 AT_CHECK([grep OK var-$1], [], [OK
220 ])# AT_CHECK_CONFIG_CREATION
223 # AT_CHECK_CONFIG_CREATION_NOWRITE(THING = (header | link | file | command))
224 # ------------------------------------------------------------------
225 # Check that THING and var-THING (which uses variables in AC_CONFIG_THING)
226 # are properly created, with the right content.
227 # Use `grep OK' instead of a simple `cat' to avoid banners such as in
228 # AC_CONFIG_HEADERS.
229 m4_define([AT_CHECK_CONFIG_CREATION_NOWRITE],
230 [AT_CHECK_CONFIGURE([what_to_test=$1])
231 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
232          [ignore], [$1
234 AT_CHECK([grep OK $1], [], [OK
237 AT_CHECK_CONFIGURE([what_to_test=var-$1 --no-create])
238 # config.status might be stupidly expecting data on stdin, if it's
239 # really broken...
240 # Skip check if user can rename files into a read-only directory (when
241 # run by root or on w32).
242 touch t
243 chmod a-w .
244 mv t t1 >/dev/null 2>&1 \
245   || AT_CHECK([./config.status var-$1 </dev/null || exit 1],
246    [1], [ignore], [ignore])
247 chmod u+w .
248 rm -rf t t1
249 ])# AT_CHECK_CONFIG_CREATION_NOWRITE
252 # Create a file
253 AT_CHECK_CONFIG_CREATION(file)
255 # Create a header
256 AT_CHECK_CONFIG_CREATION(header)
258 # Execute a command
259 AT_CHECK_CONFIG_CREATION(command)
261 # Create a link
262 AT_CHECK_CONFIG_CREATION(link)
264 # Now check for write errors
266 # Create a file
267 AT_CHECK_CONFIG_CREATION_NOWRITE(file)
268 # Create a file with bits from stdin
269 AT_CHECK([echo from-stdin | ./config.status --file=file:-],
270          [0], [ignore])
271 AT_CHECK([grep from-stdin file], [], [from-stdin
273 # Force write error creating a file on stdout
274 if test -w /dev/full && test -c /dev/full; then
275   AT_CHECK([./config.status --file=-:input </dev/null >/dev/full],
276            [1], [ignore], [ignore])
279 # Create a header
280 AT_CHECK_CONFIG_CREATION_NOWRITE(header)
281 # Create a header on stdout
282 AT_CHECK([./config.status --header=-:input </dev/null],
283          [0], [stdout], [ignore])
284 AT_CHECK([grep OK stdout], [], [OK
286 # Force write error creating a header on stdout
287 if test -w /dev/full && test -c /dev/full; then
288   AT_CHECK([./config.status --header=-:input </dev/null >/dev/full],
289            [1], [ignore], [ignore])
292 # Execute a command
293 AT_CHECK_CONFIG_CREATION_NOWRITE(command)
295 # Create a link
296 AT_CHECK_CONFIG_CREATION_NOWRITE(link)
298 # Check that no use of `ac_write_fail' escaped into config.status
299 AT_CHECK([grep ac_write_fail config.status], [1])
301 # Check that --file and --header accept funny file names
302 AT_DATA([fgrep.in],
303 [[FGREP="@FGREP@"
305 ./config.status --file=fgrep:fgrep.in
306 . ./fgrep
309 export x
310 for file in \
311   'with  funny '\'' $x & #! name' \
312   'file with  funny \ '\'' \'\'' $ & #!*? name' \
313   'with  funny \ '\'' \'\'' " | <a >b & * ? name ' # "restore font-lock
315   # The function func_sanitize_file_name comes from tools.at
316   file=`func_sanitize_file_name "$file"`
317   cat >"$file.in" <<'END'
318 @configure_input@
320   AT_CHECK([./config.status "--file=$file:$file.in"],
321            [0], [ignore])
322   AT_CHECK([$FGREP "$file" "$file"], [0], [ignore])
323   AT_CHECK([./config.status "--header=$file:$file.in"],
324            [0], [ignore])
325   # Run the same test a 2nd time to see that config.status does not recreate
326   # the header (regression test)
327   AT_CHECK_UNQUOTED([./config.status "--header=$file:$file.in"],
328                     [0], [config.status: creating $file
329 config.status: $file is unchanged
331   AT_CHECK_UNQUOTED([grep ' & ' "$file"], [],
332 [/* $file.  Generated from $file.in by configure.  */
334   AT_CHECK([$FGREP "$file" "$file"], [0], [ignore])
335 done
336 AT_CLEANUP
340 ## ---------------------------------------- ##
341 ## Macro calls in AC_CONFIG_COMMANDS tags.  ##
342 ## ---------------------------------------- ##
344 AT_SETUP([Macro calls in AC_CONFIG_COMMANDS tags])
346 AT_DATA_M4SUGAR([configure.ac],
347 [[AC_INIT
348 AC_CONFIG_COMMANDS([m4_if(1,1,mytag)])
349 AC_OUTPUT
352 AT_CHECK_AUTOCONF
353 AT_CHECK_CONFIGURE
355 AT_CLEANUP
359 ## ------------------- ##
360 ## Missing templates.  ##
361 ## ------------------- ##
363 # Check that config.status detects missing input files
364 AT_SETUP([Missing templates])
366 AT_DATA([configure.ac],
367 [[AC_INIT
368 AC_CONFIG_FILES([nonexistent])
369 AC_OUTPUT
372 AT_CHECK_AUTOCONF
373 AT_CHECK_CONFIGURE([], [1], [],
374 [[config.status: error: cannot find input file: `nonexistent.in'
376 # Make sure that the output file doesn't exist
377 AT_CHECK([test -f nonexistent], 1)
379 AT_CLEANUP
384 ## ---------------------- ##
385 ## configure invocation.  ##
386 ## ---------------------- ##
388 # Check that `configure' and `config.status' honor their interface.
390 # We run `./configure one=val1 --enable-two=val2 --with-three=val3'
391 # and verify that (i) `configure' correctly receives the arguments,
392 # (ii) correctly passes them to `config.status', which we check by
393 # running `config.status --recheck', and (iii) correctly passes them
394 # to sub-configure scripts.
396 AT_SETUP([configure invocation])
398 mkdir sub
400 AT_DATA([configure.ac],
401 [[AC_INIT
402 AC_CONFIG_SUBDIRS([sub])
403 echo "result=$one$enable_two$with_three"
404 AC_OUTPUT
407 AT_DATA([sub/configure.ac],
408 [[AC_INIT
409 echo "result=$one$enable_two$with_three"
410 AC_OUTPUT
413 echo fake install-sh script >install-sh
415 AT_CHECK_AUTOCONF
416 cd sub
417 AT_CHECK_AUTOCONF
418 cd ..
420 AT_CHECK_CONFIGURE([one=one --enable-two=two --with-three=three |
421                      sed -n -e 's/^result=//p'], 0,
422                    [m4_do([onetwothree
423 ],                        [onetwothree
424 ])])
425 AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
426          [onetwothree
429 AT_CHECK_CONFIGURE([one="\"'$ " --enable-two="\" '  $" --with-three="   \"'$"|
430                       sed -n -e 's/^result=//p'], 0,
431                    [m4_do(["'$ " '  $   "'$
432 ],                        ["'$ " '  $   "'$
433 ])])
434 AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
435          ["'$ " '  $    "'$
437 dnl restore font-lock: "
439 AT_CLEANUP
443 ## -------------------------------------------- ##
444 ## Check that `#define' templates are honored.  ##
445 ## -------------------------------------------- ##
447 # Use various forms of `#define' templates, and make sure there are no
448 # problems when a symbol is prefix of another.
450 AT_SETUP([@%:@define header templates])
451 AT_KEYWORDS([AC@&t@_DEFINE])
453 AT_DATA([configure.ac],
454 [[AC_INIT
455 AC_CONFIG_HEADERS(config.h:config.hin)
457 # I18n of dummy variables: their French translations.
458 AC_DEFINE(foo, toto)
459 AC_DEFINE(bar, tata)
460 AC_DEFINE(baz, titi)
461 AC_DEFINE(fubar, tutu)
463 # Symbols which are prefixes of another.
464 AC_DEFINE(a, A)
465 AC_DEFINE(aaa, AAA)
466 AC_DEFINE(aa, AA)
468 # backslash-newline combinations
469 AC_DEFINE([multiline], [line1\
470 line2\
471 line3 \
472 line4])
473 AC_DEFINE([multiline_args(ARG1, ARG2)], [ARG2 \
474 ARG1])
475 AC_CONFIG_FILES(defs)
477 # underquoted #
478 AC_DEFINE([paste(a,b)], [a##b])
480 # Things included in confdefs.h, but which make no sense in
481 # config.h, nor in $DEFS.
482 cat <<\EOF >>confdefs.h
483 /* Hi Mum! Look, I am doing C++! */
484 #ifdef __cplusplus
485 void exit (int status);
486 #endif
489 # In addition of config.h output a full DEFS
490 AC_OUTPUT_MAKE_DEFS
491 DEFS_SAVED=$DEFS
492 AC_SUBST(DEFS_SAVED)
493 AC_OUTPUT
496 AT_DATA([defs.in],
497 [[@DEFS_SAVED@
500 AT_DATA([config.hin],
501 [[#define foo   0
502 #  define bar bar
503 #  define baz   "Archimedes was sinking in his baz"
504   #  define fubar                               tutu
505 #define a B
506  #define aa BB
507  #  define aaa BBB
508 #undef a
509  #  undef aa
510 #undef aaa
511 #define aaa(a, aa) aa a
512 #define aaab
513 #define aaac(a, aa) aa a
514 #undef multiline
515 #  undef multiline_args
516 #define paste(a,b) a##b
517 /* an ugly one: */
518 #define str(define) \
519 #define
520 #define stringify(arg) str(arg)
521 #undef aaa /* with comments */
522 #undef not_substed /* with comments */
525 AT_CHECK_AUTOCONF
526 AT_CHECK_CONFIGURE
528 AT_DATA([expout],
529 [[/* config.h.  Generated from config.hin by configure.  */
530 #define foo toto
531 #  define bar tata
532 #  define baz titi
533   #  define fubar tutu
534 #define a A
535  #define aa AA
536  #  define aaa AAA
537 #define a A
538  #  define aa AA
539 #define aaa AAA
540 #define aaa AAA
541 #define aaab
542 #define aaac(a, aa) aa a
543 #define multiline line1\
544 line2\
545 line3 \
546 line4
547 #  define multiline_args(ARG1, ARG2) ARG2 \
548 ARG1
549 #define paste(a,b) a##b
550 /* an ugly one: */
551 #define str(define) \
552 #define
553 #define stringify(arg) str(arg)
554 #define aaa AAA
555 /* #undef not_substed */
557 AT_CHECK([cat config.h], 0, expout)
559 # Check the value of DEFS.
560 AT_DATA([expout],
561 [[-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
564 # Because we strip trailing spaces in `testsuite' we can't leave one in
565 # expout, hence nuke the one left by AC_OUTPUT_MAKE_DEFS.
566 AT_CHECK([sed -e 's/ $//' defs], 0, expout)
568 AT_CLEANUP
572 ## ------------------------- ##
573 ## Torturing config.status.  ##
574 ## ------------------------- ##
576 ## Require 100 AC_DEFINE and AC_SUBST and AC_SUBST_FILE with a significantly
577 ## big value.  This is mostly to check that Autoconf produces portable sed
578 ## scripts in config.status.  sed is used to skip the first two lines
579 ## `Generated by...'.
581 # We use m4_for many times.
582 m4_pattern_allow([^m4_for$])
584 AT_SETUP([Torturing config.status])
586 dnl The value used as a big value for AC_DEFINE.
587 dnl Don't use sh active chars here, below it is also used in a sh
588 dnl assignment.
589 m4_define([AT_BIG_VALUE],
590 [This value should be long enough to torture the various limits of sed and other tools used by Autoconf.])
592 m4_define([AT_DESCRIPTION],
593 [Define to a long string if your `Autoconf' works properly.])
596 # AT_DUMMY_VAR(NUMBER)
597 # --------------------
598 # Build a name used for AC_SUBST and AC_DEFINE.  Put ac_ in it
599 # so that the check for user name space invasion does not complain
600 # of the new variables defined.
602 # Note that you should not use the name ac_dummy, because it will be
603 # turned into ac_uummy during the construction of config.status.  Yes,
604 # this is admittedly a bug, but it would be too hard to fix this.
605 # There is really no point in AC_DEFINE a var named ac_d.*.
606 m4_pattern_allow([^m4_bpatsubst$])
607 m4_define([AT_DUMMY_VAR],
608 [ac_Dummy_[]m4_bpatsubst([000$1], [.*\(...\)$], [\1])])
612 AT_DATA([dummy.in],
613 [m4_for([AT_Count], 1, 100, 1,
614 [@AT_DUMMY_VAR(AT_Count)@
615 @[f]AT_Count@
616 ])])
620 while test $i != 101; do
621   echo "content of file $i" > file_$i
622   AS_VAR_ARITH([i], [$i + 1])
623 done
626 # ------------ #
627 # configure.ac #
628 # ------------ #
630 m4_pattern_allow([^m4_(define|defun)$])
631 AT_DATA([configure.ac],
632 dnl The following lines transfer AT_DUMMY_VAR, AT_DESCRIPTION, and
633 dnl AT_BIG_VALUE into the configure.ac as AC_DUMMY_VAR etc.
634 [[m4_define([AC_DUMMY_VAR],]
635 m4_dquote(m4_defn([AT_DUMMY_VAR]))[)]]
637 [[m4_define([AC_DESCRIPTION],]
638 m4_dquote(m4_defn([AT_DESCRIPTION]))[)]]
640 [[m4_define([AC_BIG_VALUE],]
641 m4_dquote(m4_defn([AT_BIG_VALUE]))[)]]
643 [[# AC_DEFUBST(NAME)
644 # ----------------
645 # Related VALUE to NAME both with AC_SUBST and AC_DEFINE.  This is
646 # used in the torture tests.
647 m4_defun([AC_DEFUBST],
648 [AC_DUMMY_VAR($1)="AC_BIG_VALUE"
649 AC_DEFINE_UNQUOTED(AC_DUMMY_VAR($1), "$AC_DUMMY_VAR($1) $AC_DUMMY_VAR($1)",
650                    AC_DESCRIPTION)
651 AC_SUBST(AC_DUMMY_VAR($1))
652 AC_SUBST_FILE([f]$1)
653 f$1=file_$1
656 AC_INIT
657 AC_CONFIG_HEADERS(config.h:config.hin)
658 AC_CONFIG_FILES(dummy)
659 m4_for(AC_Count, 1, 100, 1,
660        [AC_DEFUBST(AC_Count)])
661 AC_PROG_AWK
662 AC_OUTPUT
663 ]])# configure.ac
665 AT_CHECK_AUTOCONF
666 AT_CHECK_AUTOHEADER
667 # Check both awk and the result of AC_PROG_AWK
668 for awk_arg in FOO= AWK=awk; do
669   AT_CHECK_CONFIGURE([$awk_arg])
671   # Checking that AC_DEFINE worked properly.
672   AT_DATA([expout],
673 [/* Define to the address where bug reports for this package should be sent. */
674 #define PACKAGE_BUGREPORT ""
676 /* Define to the full name of this package. */
677 #define PACKAGE_NAME ""
679 /* Define to the full name and version of this package. */
680 #define PACKAGE_STRING ""
682 /* Define to the one symbol short name of this package. */
683 #define PACKAGE_TARNAME ""
685 /* Define to the home page for this package. */
686 #define PACKAGE_URL ""
688 /* Define to the version of this package. */
689 #define PACKAGE_VERSION ""
690 m4_for(AT_Count, 1, 100, 1,
692 /* AT_DESCRIPTION */
693 [#define] AT_DUMMY_VAR(AT_Count) "AT_BIG_VALUE AT_BIG_VALUE"
694 ])])
696   AT_CHECK([sed -n '4,$ p' config.h], 0, expout)
698   # Checking that AC_SUBST worked properly.
699   AT_DATA([expout],
700 [m4_for(AT_Count, 1, 100, 1,
701 [AT_BIG_VALUE
702 content of file AT_Count
703 ])])
705   AT_CHECK([cat dummy], 0, expout)
706 done
708 AT_CLEANUP
711 ## ------------------------------- ##
712 ## Substitute a 2000-byte string.  ##
713 ## ------------------------------- ##
715 # Solaris 9 /usr/ucb/sed that rejects commands longer than 4000 bytes.  HP/UX
716 # sed dumps core around 8 KiB.  However, POSIX says that sed need not
717 # handle lines longer than 2048 bytes (including the trailing newline).
718 # So we'll just test a 2000-byte value, and for awk, we test a line with
719 # almost 1000 words, and one variable with 5 lines of 2000 bytes each:
720 # multi-line values should allow to get around the limitations.
722 AT_SETUP([Substitute a 2000-byte string])
724 AT_DATA([Foo.in], [@foo@
726 AT_DATA([Bar.in], [@bar@
728 AT_DATA([Baz.in], [@baz@
731 AT_DATA([configure.ac],
732 [[AC_INIT
733 AC_SUBST([foo], ]m4_for([n], 1, 100,, ....................)[)
734 AC_SUBST([bar], "]m4_for([n], 1, 100,, @ @ @ @ @ @ @ @ @ @@)[")
735 baz="]m4_for([m], 1, 100,, ... ... ... ... ....)[
737 baz=$baz$baz$baz$baz$baz
738 AC_SUBST([baz])
739 AC_PROG_AWK
740 AC_CONFIG_FILES([Foo Bar Baz])
741 AC_OUTPUT
744 cp "$abs_top_srcdir/build-aux/install-sh" .
746 AT_CHECK_AUTOCONF
747 # Check both awk and the result of AC_PROG_AWK
748 for awk_arg in Foo= AWK=awk; do
749   AT_CHECK_CONFIGURE([$awk_arg])
750   AT_CHECK([cat Foo], 0, m4_for([n], 1, 100,, ....................)
752   AT_CHECK([cat Bar], 0, m4_for([n], 1, 100,, @ @ @ @ @ @ @ @ @ @@)
754   AT_DATA([stdout],
755   [m4_for([n], 1, 5,, m4_for([m], 1, 100,, ... ... ... ... ....)
757   AT_CHECK([cat Baz], 0, [stdout])
758 done
759 AT_CLEANUP
762 ## ------------------------------ ##
763 ## Define to a 2000-byte string.  ##
764 ## ------------------------------ ##
766 AT_SETUP([Define to a 2000-byte string])
767 AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
769 AT_CONFIGURE_AC(
771 AC_DEFINE_UNQUOTED([foo], ]m4_for([n], 1, 100,, ....................)[, [desc])
772 AC_DEFINE([fooq], ]m4_for([n], 1, 100,, ....................)[, [desc])
775 AT_CHECK_AUTOCONF
776 AT_CHECK_AUTOHEADER
777 AT_CHECK_CONFIGURE
778 AT_CHECK_DEFINES([@%:@define foo m4_for([n], 1, 100,, ....................)
779 @%:@define fooq m4_for([n], 1, 100,, ....................)
781 AT_CLEANUP
784 ## ------------------------------------------ ##
785 ## Substitute and define special characters.  ##
786 ## ------------------------------------------ ##
788 # Use characters special to the shell, sed, awk, and M4.
790 AT_SETUP([Substitute and define special characters])
791 AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
793 AT_DATA([Foo.in], [@foo@
794 @bar@@notsubsted@@baz@ stray @ and more@@@baz@
795 abc@bar@baz@baz
796 abc@bar@@baz@baz
797 abc@bar@@baz@baz@
798 abc@bar @baz@baz
799 abc@bar @baz@baz@
800 abc@bar @baz@@baz@
801 @file@
802          @file@
803 X@file@
804 @file@X
807 AT_DATA([File],
808 [@foo@@bar@
811 AT_DATA([Zardoz.in], [@zardoz@
814 AT_CONFIGURE_AC(
815 [[foo="AS@&t@_ESCAPE([[X*'[]+ ", & &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !]])"
817 bar="@foo@ @baz@"
818 baz=bla
819 ( for i in 0 1 2 3; do
820     for j in 0 1 2 3 4 5 6 7; do
821       for k in 0 1 2 3 4 5 6 7; do
822         case $i$j$k in #(
823         000 | 015 | 377) ;; # MinGW awk dislikes 0xFF, and the test does
824                             # the wrong thing for CR on MinGW.
825                             #(
826         *) printf \\$i$j$k's' ;; # The 's' works around a Solaris 8 /bin/bash bug.
827         esac
828       done
829     done
830   done
831   printf \\n
832 ) >allowed-chars
833 zardoz=`cat allowed-chars`
834 AC_SUBST([foo])
835 AC_SUBST([bar])
836 AC_SUBST([baz])
837 AC_SUBST([zardoz])
838 file=File
839 AC_SUBST_FILE([file])
840 AC_DEFINE([fooq], [[X*'[]+ ", & &`\($foo !]], [Awful value.])
841 AC_DEFINE([barq], [[%!_!# X]], [Value that is used as special delimiter.])
842 AC_DEFINE_UNQUOTED([foo], [[X*'[]+ ", & &\`\\(\$foo !]], [Awful value.])
843 AC_DEFINE_UNQUOTED([bar], [[%!_!# X]], [Value that is used as special delimiter.])
844 AC_DEFINE_UNQUOTED([unq1], [$baz], [unquoted, test 1])
845 AC_DEFINE_UNQUOTED([unq2], [\$baz], [unquoted, test 2])
846 AC_DEFINE_UNQUOTED([unq3], ["$baz"], [unquoted, test 3])
847 AC_DEFINE_UNQUOTED([unq4], [${baz+set}], [unquoted, test 4])
848 AC_DEFINE_UNQUOTED([unq5], ["${baz+`echo "a b"`}"], [unquoted, test 5])
849 AC_DEFINE_UNQUOTED([unq6], [`echo hi`], [unquoted, test 6])
850 AC_DEFINE_UNQUOTED([unq7], ['\"'], [unquoted, test 7])
851 AC_PROG_AWK
852 AC_CONFIG_FILES([Foo Zardoz])]])
854 AT_CHECK_AUTOCONF
855 AT_CHECK_AUTOHEADER
856 # Check both awk and the result of AC_PROG_AWK
857 for awk_arg in FOO= AWK=awk; do
858   AT_CHECK_CONFIGURE([$awk_arg])
859   AT_CHECK([cat Foo], 0, [[X*'[]+ ", & &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !
860 @foo@ @baz@@notsubsted@bla stray @ and more@@bla
861 abc@foo@ @baz@baz@baz
862 abc@foo@ @baz@blabaz
863 abc@foo@ @baz@blabaz@
864 abc@bar blabaz
865 abc@bar blabaz@
866 abc@bar blabla
867 @foo@@bar@
868 @foo@@bar@
869 X@file@
870 @file@X
872   AT_CHECK([cmp allowed-chars Zardoz])
873   AT_CHECK_DEFINES([[#define bar %!_!# X
874 #define barq %!_!# X
875 #define foo X*'[]+ ", & &`\($foo !
876 #define fooq X*'[]+ ", & &`\($foo !
877 #define unq1 bla
878 #define unq2 $baz
879 #define unq3 "bla"
880 #define unq4 set
881 #define unq5 "a b"
882 #define unq6 hi
883 #define unq7 '\"'
885 done
886 AT_CLEANUP
889 ## ---------------------- ##
890 ## Substitute a newline.  ##
891 ## ---------------------- ##
893 AT_SETUP([Substitute a newline])
895 AT_DATA([Foo.in],
896 [@foo@
897 @bar@
900 AT_DATA([configure.ac],
901 [[AC_INIT
902 foo='one
903 two'
904 bar='%!_!# ''
906 AC_SUBST([foo])
907 AC_SUBST([bar])
908 AC_CONFIG_FILES([Foo])
909 AC_PROG_AWK
910 AC_OUTPUT
913 cp "$abs_top_srcdir/build-aux/install-sh" .
915 echo 'one
917 %!_!# ''
918 x' >expout
920 AT_CHECK_AUTOCONF
921 # Check both awk and the result of AC_PROG_AWK
922 for awk_arg in FOO= AWK=awk; do
923   AT_CHECK_CONFIGURE([$awk_arg])
924   AT_CHECK([cat Foo], 0, [expout])
925 done
926 AT_CLEANUP
929 ## ------------------ ##
930 ## Define a newline.  ##
931 ## ------------------ ##
933 AT_SETUP([Define a newline])
934 AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
935 AT_CONFIGURE_AC([[AC_DEFINE([foo], [one
936 two], [This spans two lines.])
938 AT_CHECK_AUTOCONF([], [], [], [stderr])
939 dnl Older versions of m4 report error at line 5 (end of macro);
940 dnl newer versions report it at line 4 (start of macro).
941 AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
942 [[warning: AC_DEFINE: `one
943 two' is not a valid preprocessor define value
945 AT_CHECK_AUTOHEADER([], [], [], [stderr])
946 AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
947 [[warning: AC_DEFINE: `one
948 two' is not a valid preprocessor define value
950 AT_CHECK_CONFIGURE
951 AT_CHECK_DEFINES([[#define foo one
954 AT_CONFIGURE_AC([[AC_DEFINE_UNQUOTED([foo], [one
955 two], [This spans two lines.])
957 AT_CHECK_AUTOCONF([], [], [], [stderr])
958 AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
959 [[warning: AC_DEFINE_UNQUOTED: `one
960 two' is not a valid preprocessor define value
962 AT_CHECK_AUTOHEADER([], [], [], [stderr])
963 AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
964 [[warning: AC_DEFINE_UNQUOTED: `one
965 two' is not a valid preprocessor define value
967 AT_CHECK_CONFIGURE
968 AT_CHECK_DEFINES([[#define foo one
971 AT_CLEANUP
974 ## ------------------------------------ ##
975 ## AC_SUBST: variable name validation.  ##
976 ## ------------------------------------ ##
978 AT_SETUP([AC_SUBST: variable name validation])
980 AT_CONFIGURE_AC([[AC_SUBST(, [])
981 AC_CONFIG_FILES([Makefile])
983 AT_DATA([Makefile.in], [[
985 mv -f configure.ac configure.tmpl
987 # Invalid names.
988 for var in ['' ab\~ ab\( ab[] ab\' ab\" ab\\\\]; do
989   sed ["s/AC_SUBST(/&[$var]/"] <configure.tmpl >configure.ac
990   AT_CHECK_AUTOCONF([], [1], [], [ignore])
991 done
993 # Valid names.
994 for var in ab a4 'a@@&t@\&t@b'; do
995   sed ["s/AC_SUBST(/&[$var]/"] <configure.tmpl >configure.ac
996   AT_CHECK_AUTOCONF
997   AT_CHECK_AUTOHEADER
998   AT_CHECK_CONFIGURE
999 done
1001 AT_CLEANUP
1004 ## ------------------------ ##
1005 ## datarootdir workaround.  ##
1006 ## ------------------------ ##
1008 AT_SETUP([datarootdir workaround])
1010 AT_DATA([Foo.in],
1011 [@datadir@
1012 @docdir@
1013 @infodir@
1014 @localedir@
1015 @mandir@
1018 AT_DATA([Bar.in],
1019 [@mydatadir@
1022 AT_DATA([configure.ac],
1023 [[AC_INIT
1024 d@&t@nl The following line silences the warnings, if uncommented:
1025 d@&t@nl AC_DEFUN([AC_DATAROOTDIR_CHECKED])
1027 # This substitution is wrong and bogus!  Don't use it in your own code!
1028 # Read `info Autoconf "Defining Directories"'!
1029 AC_SUBST([mydatadir], [${datadir}/my])
1031 AC_CONFIG_FILES([Foo Bar])
1032 AC_OUTPUT
1035 cp "$abs_top_srcdir/build-aux/install-sh" .
1037 AT_CHECK_AUTOCONF
1038 AT_CHECK_CONFIGURE([], [], [],
1039   [config.status: WARNING:  'Foo.in' seems to ignore the --datarootdir setting
1040 config.status: WARNING: Bar contains a reference to the variable `datarootdir'
1041 which seems to be undefined.  Please make sure it is defined.
1043 AT_CHECK([grep datarootdir Foo], 1, [])
1045 rm configure
1046 sed '/AC_DEFUN/s/^d@&t@nl //' configure.ac >t
1047 mv t configure.ac
1049 AT_CHECK_AUTOCONF
1050 AT_CHECK_CONFIGURE
1052 AT_CLEANUP
1055 ## -------- ##
1056 ## srcdir.  ##
1057 ## -------- ##
1059 AT_SETUP([srcdir])
1061 rm -f -r at-dir
1062 mkdir at-dir
1063 : >at-dir/bar.in
1064 : >foo.in
1066 AT_DATA([configure.ac],
1067 [[AC_INIT
1069 AC_CONFIG_FILES([foo at-dir/bar])
1071 # Use quotes in the INIT-COMMANDS to accommodate a value of $srcdir
1072 # containing e.g., spaces or shell meta-characters.
1073 # Use *single* quotes because the context is an unquoted here-doc.
1074 AC_CONFIG_COMMANDS([report],
1075 [test -f "$srcdir/configure.ac" ||
1076    AC_MSG_ERROR([cannot find $srcdir/configure.ac])],
1077                    [srcdir='$srcdir'])
1079 AC_OUTPUT
1080 rm -f -r foo at-dir/bar
1083 AT_CHECK_AUTOCONF
1085 # In place.
1086 AT_CHECK([./configure], [], [ignore])
1088 # Relative name.
1089 AT_CHECK([cd at-dir && ../configure], [], [ignore])
1091 # Absolute name.
1092 at_here=`pwd`
1093 AT_CHECK([cd at-dir && "$at_here/configure"], [], [ignore])
1095 AT_CLEANUP
1098 ## ----------------- ##
1099 ## Signal handling.  ##
1100 ## ----------------- ##
1102 AT_SETUP([Signal handling])
1104 AT_DATA([configure.ac],
1105 [[AC_INIT
1106 kill -2 $$
1107 exit 77
1110 AT_CHECK_AUTOCONF
1111 AT_CHECK_CONFIGURE([], 1, ignore, ignore)
1113 AT_CLEANUP
1116 ## ------------------------------------- ##
1117 ## AC_CONFIG_LINKS and identical files.  ##
1118 ## ------------------------------------- ##
1119 AT_SETUP([AC_CONFIG_LINKS and identical files])
1121 AT_DATA([configure.ac],
1122 [[AC_INIT
1123 AC_CONFIG_LINKS([src/s:src/s])
1124 test "$srcdir" != '.' && AC_CONFIG_LINKS([src/t:src/t])
1125 AC_OUTPUT
1128 mkdir src build
1129 echo file1 > src/s
1130 echo file2 > src/t
1131 AT_CHECK_AUTOCONF
1132 cd build
1133 AT_CHECK([../configure && ../configure], 0, [ignore])
1134 AT_CHECK([cat src/s src/t], 0, [file1
1135 file2
1137 cd ..
1138 AT_CHECK([./configure && ./configure], 0, [ignore], [stderr])
1139 AT_CHECK([grep src/t stderr], 1)
1140 AT_CHECK([cat src/s src/t], 0, [file1
1141 file2
1143 AT_CHECK(["`pwd`"/configure && "`pwd`"/configure], 0, [ignore], [ignore])
1144 AT_CHECK([cat src/s src/t], 0, [file1
1145 file2
1148 AT_CLEANUP
1151 AT_BANNER([autoreconf.])
1153 ## ---------------------------- ##
1154 ## Configuring subdirectories.  ##
1155 ## ---------------------------- ##
1157 # .
1158 # |-- builddir
1159 # |   |-- config.log
1160 # |   |-- config.status
1161 # |   `-- inner
1162 # |       |-- config.log
1163 # |       |-- config.status
1164 # |       `-- innermost
1165 # |           `-- config
1166 # |-- configure
1167 # |-- configure.ac
1168 # |-- inner
1169 # |   |-- configure
1170 # |   |-- configure.ac
1171 # |   `-- innermost
1172 # |       `-- config.in
1173 # `-- install-sh
1175 AT_SETUP([Configuring subdirectories])
1176 AT_KEYWORDS(autoreconf)
1178 # We use aclocal (via autoreconf).
1179 AT_CHECK([aclocal --version || exit 77], [], [stdout], [ignore])
1180 # It should understand configure.ac.
1181 AT_CHECK([[grep '[^0-9]1.[01234][^0-9]' stdout && exit 77]], [1], [ignore])
1183 # Set CONFIG_SITE to a nonexistent file, so that there are
1184 # no worries about nonstandard values for 'prefix'.
1185 CONFIG_SITE=no-such-file
1186 export CONFIG_SITE
1188 # The contents of `inner/', and `inner/innermost/'.
1189 AS_MKDIR_P([inner/innermost])
1191 # We have to use configure.in, not configure.ac, if we still want to
1192 # be compatible with Automake 1.4: aclocal (run by autoreconf) would
1193 # die because it can't find configure.in.
1194 AT_DATA([inner/configure.in],
1195 [[AC_INIT(GNU Inner, 1.0)
1196 AC_CONFIG_SRCDIR([innermost/config.in])
1197 AC_ARG_VAR([INNER], [an inner variable])
1198 AC_SUBST([INNER])
1199 if test "x$INNER" = x; then
1200   INNER=inner
1202 AC_CONFIG_FILES([innermost/config])
1203 AC_OUTPUT
1206 AT_DATA([inner/innermost/config.in],
1207 [INNER=@INNER@
1208 srcdir=@srcdir@
1209 top_srcdir=@top_srcdir@
1210 prefix=@prefix@
1213 # The contents of `.'
1214 AT_DATA([install-sh], [])
1216 # nonexistent is allowed not to exist.
1217 AT_DATA([configure.in],
1218 [[AC_INIT(GNU Outer, 1.0)
1219 AC_ARG_VAR([OUTER], [an outer variable])
1220 if false; then
1221   AC_CONFIG_SUBDIRS([nonexistent])
1223 AC_CONFIG_SUBDIRS([inner])
1224 AC_OUTPUT
1227 # If there are improperly quoted AC_DEFUN installed in share/aclocal,
1228 # they trigger warnings from aclocal 1.8, so ignore stderr.
1229 AT_CHECK([autoreconf], [], [], [ignore])
1230 AT_CHECK([test -f inner/configure])
1232 # Running the outer configure recursively should provide the innermost
1233 # help strings.
1234 chmod a-w inner/innermost inner .
1235 AT_CHECK([{ ./configure --help=recursive; chmod u+w .; } | grep INNER], 0,
1236          [ignore], [stderr],
1237          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1238 chmod u+w . inner inner/innermost
1240 # Running the outer configure should trigger the inner.
1241 AT_CHECK_CONFIGURE
1242 AT_CHECK([cat inner/innermost/config], 0,
1243 [INNER=inner
1244 srcdir=.
1245 top_srcdir=..
1246 prefix=/usr/local
1249 # The same, but from a builddir.
1250 AS_MKDIR_P([builddir])
1251 AT_CHECK([cd builddir && ../configure], 0, [ignore])
1252 AT_CHECK([cat builddir/inner/innermost/config], 0,
1253 [INNER=inner
1254 srcdir=../../../inner/innermost
1255 top_srcdir=../../../inner
1256 prefix=/usr/local
1259 # Make sure precious variables and command line options are properly
1260 # passed, even when there are duplicates.
1261 AT_CHECK([cd builddir && ../configure --prefix /bad --prefix /good INNER=bad INNER=good], 0, [ignore])
1262 AT_CHECK([cat builddir/inner/innermost/config], 0,
1263 [INNER=good
1264 srcdir=../../../inner/innermost
1265 top_srcdir=../../../inner
1266 prefix=/good
1269 # Make sure --prefix is properly quoted
1270 AT_CHECK([cd builddir && ../configure --prefix "/a  b c$ 'd"], 0, [ignore])
1271 AT_CHECK([cat builddir/inner/innermost/config], 0,
1272 [INNER=inner
1273 srcdir=../../../inner/innermost
1274 top_srcdir=../../../inner
1275 prefix=/a  b c$ 'd
1278 # Make sure --silent is properly passed...
1279 AT_CHECK([cd builddir && ../configure --silent], 0, [])
1280 # ...but not stored in config.status.
1281 AT_CHECK([cd builddir && ./config.status --recheck], 0, [stdout])
1282 AT_CHECK([grep 'creating \./config.status' stdout], 0, [ignore])
1284 # Make sure we can run autoreconf on a subdirectory
1285 rm -f configure configure.in
1286 AT_CHECK([autoreconf inner], [], [], [ignore])
1288 # Make sure we can pass a configure.ac name
1289 AT_CHECK([cd inner && autoreconf configure.in], [], [], [ignore])
1290 AT_CHECK([autoreconf inner/configure.in], [], [], [ignore])
1292 AT_CLEANUP
1296 ## -------------- ##
1297 ## Deep Package.  ##
1298 ## -------------- ##
1300 AT_SETUP([Deep Package])
1301 AT_KEYWORDS(autoreconf)
1303 # We use aclocal (via autoreconf).
1304 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
1306 # The contents of `.'
1307 AT_DATA([install-sh], [])
1308 AT_DATA([configure.in],
1309 [[AC_INIT(GNU Outer, 1.0)
1310 AC_ARG_VAR([OUTER], [an outer variable])
1311 AC_CONFIG_SUBDIRS([inner inner2])
1312 AC_OUTPUT
1315 # The contents of `inner/', and `inner/innermost/'.
1316 AS_MKDIR_P([inner/innermost])
1317 AS_MKDIR_P([inner2])
1319 AT_DATA([inner/configure.in],
1320 [[AC_INIT(GNU Inner, 1.0)
1321 AC_ARG_VAR([INNER], [an inner variable])
1322 AC_CONFIG_SUBDIRS(innermost)
1323 AC_OUTPUT
1326 AT_DATA([inner/innermost/configure.in],
1327 [[AC_INIT(GNU Innermost, 1.0)
1328 AC_ARG_VAR([INNERMOST], [an innermost variable])
1329 AC_CONFIG_HEADERS(config.h:config.hin)
1330 AC_DEFINE_UNQUOTED([INNERMOST], [$INNERMOST], [an innermost variable])
1331 if test -n "$innermost_error"; then
1332   AC_MSG_FAILURE([error in $PACKAGE_NAME])
1334 AC_OUTPUT
1337 AT_DATA([inner2/configure.in],
1338 [[AC_INIT(GNU Inner 2, 1.0)
1339 AC_ARG_VAR([INNER2], [an inner2 variable])
1340 AC_OUTPUT
1343 AT_CHECK([autoreconf -Wall -v], [0], [ignore], [ignore])
1344 AT_CHECK([test -f inner/configure])
1345 AT_CHECK([test -f inner/innermost/configure])
1346 AT_CHECK([test -f inner/innermost/config.hin])
1347 AT_CHECK([test -f inner2/configure])
1349 # Running the outer configure recursively should provide the innermost
1350 # help strings.
1351 chmod a-w inner/innermost inner
1352 AT_CHECK([{ ./configure --help=recursive; chmod u+w .; } | grep " INNER "],
1353          0, [ignore], [stderr],
1354          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1355 chmod a-w .
1356 AT_CHECK([{ ./configure --help=recursive; chmod u+w .; } | grep " INNER2 "],
1357          0, [ignore], [stderr],
1358          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1359 chmod a-w .
1360 AT_CHECK([{ ./configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1361          0, [ignore], [stderr],
1362          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1363 chmod a-w .
1364 AT_CHECK([{ /bin/sh ./configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1365          0, [ignore], [stderr],
1366          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1367 chmod a-w .
1368 AT_CHECK([PATH=.$PATH_SEPARATOR$PATH; export PATH; { /bin/sh configure --help=recursive; chmod +w .; } | grep " INNERMOST "],
1369          0, [ignore], [stderr],
1370          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1371 chmod a-w .
1372 AT_CHECK([PATH=.$PATH_SEPARATOR$PATH; export PATH; { configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1373          0, [ignore], [stderr],
1374          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1375 chmod u+w inner inner/innermost
1377 # Running the outer configure should trigger the inner.
1378 AT_CHECK_CONFIGURE([INNERMOST=tsomrenni])
1379 AT_CHECK([grep INNERMOST inner/innermost/config.h], 0,
1380 [[#define INNERMOST tsomrenni
1383 # Ensure we point to the right config.log file for errors.
1384 AT_CHECK_CONFIGURE([innermost_error=:], [1], [], [stderr])
1385 AT_CHECK([grep 'inner/innermost' stderr], [], [ignore])
1386 cd inner
1387 AT_CHECK_CONFIGURE([innermost_error=:], [1], [], [stderr])
1388 AT_CHECK([grep 'innermost' stderr], [], [ignore])
1389 cd ..
1391 # The same, but from a builddir.
1392 AS_MKDIR_P([builddir])
1393 chmod a-w builddir inner/innermost inner
1394 AT_CHECK([cd builddir && { ../configure --help=recursive; chmod u+w .; } | grep " INNER "],
1395          0, [ignore], [stderr],
1396          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1397 chmod a-w builddir
1398 AT_CHECK([cd builddir && { ../configure --help=recursive; chmod u+w .; } | grep " INNER2 "],
1399          0, [ignore], [stderr],
1400          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1401 chmod a-w builddir
1402 AT_CHECK([cd builddir && { ../configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1403          0, [ignore], [stderr],
1404          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1405 chmod a-w builddir
1406 AT_CHECK([cd builddir && { /bin/sh ../configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1407          0, [ignore], [stderr],
1408          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1409 chmod a-w builddir
1410 # Not all shells search $PATH for scripts.
1411 if (cd builddir && PATH=`pwd`/..$PATH_SEPARATOR$PATH /bin/sh configure --help) >/dev/null 2>&1; then
1412   AT_CHECK([cd builddir && PATH=`pwd`/..$PATH_SEPARATOR$PATH /bin/sh configure --help=recursive | grep " INNERMOST "], 0, [ignore])
1414 AT_CHECK([PATH=`pwd`$PATH_SEPARATOR$PATH; export PATH; cd builddir && { configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1415          0, [ignore], [stderr],
1416          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1417 chmod u+w builddir inner inner/innermost
1418 AT_CHECK([cd builddir && ../configure INNERMOST=build/tsomrenni], 0, [ignore])
1419 AT_CHECK([grep INNERMOST builddir/inner/innermost/config.h], 0,
1420 [[#define INNERMOST build/tsomrenni
1423 AT_CLEANUP
1427 ## -------------------------------- ##
1428 ## Non-Autoconf AC_CONFIG_SUBDIRS.  ##
1429 ## -------------------------------- ##
1431 AT_SETUP([Non-Autoconf AC_CONFIG_SUBDIRS])
1432 AT_KEYWORDS([autoreconf])
1434 # We use aclocal (via autoreconf).
1435 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
1437 AT_DATA([install-sh], [])
1438 AT_DATA([configure.in],
1439 [[AC_INIT(GNU Outer, 1.0)
1440 AC_CONFIG_SUBDIRS([inner])
1441 AC_OUTPUT
1444 AS_MKDIR_P([inner])
1446 AT_DATA([inner/configure],
1447 [[#! /bin/sh
1448 case "$*" in
1449     *--help*) echo 'No Autoconf here, folks!' ;;
1450     *)        echo got_it >myfile ;;
1451 esac
1452 exit 0
1454 chmod +x inner/configure
1456 AT_CHECK([autoreconf -Wall -v], 0, [ignore], [ignore])
1458 # Running the outer configure recursively should provide the innermost
1459 # help strings.
1460 AT_CHECK([./configure --help=recursive | grep "folks"], 0, [ignore])
1462 # Running the outer configure should trigger the inner.
1463 AT_CHECK([./configure], 0, [ignore])
1464 AT_CHECK([test -f inner/myfile], 0)
1466 AT_CLEANUP
1470 ## ----------------- ##
1471 ## Empty directory.  ##
1472 ## ----------------- ##
1474 AT_SETUP([Empty directory])
1475 AT_KEYWORDS([autoreconf])
1477 # We use aclocal (via autoreconf).
1478 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
1480 # The test group directory is not necessarily _empty_, but it does not contain
1481 # files meaningful to `autoreconf'.
1483 AT_CHECK([autoreconf -Wall -v], 1, [ignore], [ignore])
1485 AT_CLEANUP
1489 ## ------------------------------ ##
1490 ## Unusual Automake input files.  ##
1491 ## ------------------------------ ##
1493 # This parallels gnumake.test in Automake.
1495 AT_SETUP([Unusual Automake input files])
1496 AT_KEYWORDS([autoreconf])
1498 # We use aclocal and automake via autoreconf.
1499 AT_CHECK([automake --version || exit 77], [], [ignore], [ignore])
1501 AT_DATA([configure.in],
1502 [[AC_INIT(GNU foo, 1.0)
1503 AM_INIT_AUTOMAKE
1504 AC_CONFIG_FILES([HeeHee])
1505 AC_OUTPUT
1508 AT_DATA([HeeHee.am],
1509 [[# Humans do no worse than `GNUmakefile.am'.
1510 AUTOMAKE_OPTIONS = foreign 1.8
1513 AT_CHECK([autoreconf -Wall -v -i], 0, [ignore], [stderr],
1514          [AT_CHECK([grep 'require.*1\.8' stderr && exit 77], [1])])
1515 AT_CHECK([test -f HeeHee.in])
1517 AT_CLEANUP