docs: avoid first person, and credit history to David MacKenzie
[autoconf.git] / tests / torture.at
blob511834df688ff6a93ad7d79fb2366bda65c0cab2
1 #                                                       -*- Autotest -*-
3 # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
4 # 2009, 2010 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 ## AC_CONFIG_COMMANDS with temporary directory.  ##
34 ## --------------------------------------------- ##
36 AT_CHECK_MACRO([AC_CONFIG_COMMANDS with temporary directory],
37 [[AC_CONFIG_COMMANDS([foo], [
38 case $ACTION in
39   use)
40     echo "$tmp" > tmpdir
41     test -d "$tmp" || AC_MSG_ERROR([No $tmp directory])
42     echo garbage-in > "$tmp/garbage-out"
43     ;;
44   corrupt)
45     echo "$tmp" > tmpdir
46     tmp=./nosuch
47     ;;
48   *) ;;
49 esac
51 ]], [
52 AT_CHECK([test ! -f tmpdir])
53 AT_CHECK([ACTION=use ./config.status], [], [ignore])
54 AT_CHECK([test -s tmpdir && test ! -d "`cat tmpdir`"])
55 AT_CHECK([ACTION=corrupt ./config.status], [], [ignore])
56 AT_CHECK([test -s tmpdir && test ! -d "`cat tmpdir`"])
60 ## -------------------------- ##
61 ## Multiple AC_CONFIG_FILES.  ##
62 ## -------------------------- ##
64 AT_SETUP([Multiple AC_CONFIG_FILES])
66 AT_CONFIGURE_AC([[AC_CONFIG_FILES([foo foo])]])
67 AT_CHECK_AUTOCONF([], 1, [], [ignore])
69 AT_CLEANUP
72 ## ------------------------------- ##
73 ## parameterized AC_CONFIG_FILES.  ##
74 ## ------------------------------- ##
76 AT_SETUP([Parameterized AC_CONFIG_FILES])
78 AT_CONFIGURE_AC([[
79 files="foo
80 bar"
81 AC_CONFIG_FILES([$files])]])
82 AT_CHECK_AUTOCONF([], [], [], [ignore])
83 touch foo.in bar.in config.hin
84 AT_CHECK_CONFIGURE
86 AT_CLEANUP
90 ## ------------ ##
91 ## AC_ARG_VAR.  ##
92 ## ------------ ##
94 # AT_CHECK_AC_ARG_VAR(FIRST-VALUE, SECOND-VALUE, [STATUS = 1])
95 # ------------------------------------------------------------
96 # Check that AC_ARG_VAR caches the latest values, diagnoses
97 # inconsistencies, and arms config.status.  Check that recheck
98 # returns STATUS, save configure output in files 'stdout' and 'stderr'
99 # for further inspection.
100 m4_define([AT_CHECK_AC_ARG_VAR],
101 [rm -f config.cache
103 # Initial value.
104 m4_ifval([$1],
105          [precious='m4_bpatsubst([$1], [[']], ['\\''])'; export precious],
106          [unset precious])
107 AT_CHECK_CONFIGURE([--config-cache -q])
108 AT_CHECK([cat file], [], [`$1'
111 # Testing --recheck: 1. have the environment `forget' about PRECIOUS.
112 unset precious
113 # 2. Rerun config.status to recreate `file'.
114 AT_CHECK([./config.status --recheck], [], [ignore])
115 AT_CHECK([./config.status], [], [ignore])
116 # 3. Check that file contains the old value of PRECIOUS.
117 AT_CHECK([cat file], [], [`$1'
120 # Second value: we should issue an error here: the value
121 # has changed!
122 m4_ifval([$2],
123          [precious='$2'; export precious],
124          [unset precious])
125 AT_CHECK_CONFIGURE([--config-cache], [m4_default([$3], [1])], [stdout], [stderr])
127 ])# AT_CHECK_AC_ARG_VAR
130 AT_SETUP([AC_ARG_VAR])
132 # We don't want to run this test if this shell doesn't support
133 # `unset'.
134 AT_CHECK([
135 if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
136   exit 0
137 else
138   exit 77
142 AT_DATA([configure.ac],
143 [[AC_INIT
144 AC_ARG_VAR([precious], [this variable costs a lot])
145 echo "precious:$precious"
146 AC_OUTPUT(file)
149 AT_DATA([file.in],
150 [[`@precious@'
153 AT_CHECK_AUTOCONF
155 # Set a precious variable
156 AT_CHECK_AC_ARG_VAR([], [apple of my eye])
158 # Unset a precious variable
159 AT_CHECK_AC_ARG_VAR([apple of my eye], [])
161 # Change a precious variable
162 AT_CHECK_AC_ARG_VAR([apple of my eye], [orange of my eye])
164 # Change a precious variable that contains braces
165 AT_CHECK_AC_ARG_VAR([apple of my {eye}], [orange of my eye])
167 # Change a precious variable that contains all kinds of fun
168 AT_CHECK_AC_ARG_VAR(['p  r      ec"iou$], [orange of my eye])
169 dnl restore font-lock: "
171 # Warn (but do not fail) about a whitespace-only change
172 AT_CHECK_AC_ARG_VAR([    apple  of       my eye  ], [apple of my eye],
173                     [0], ["has whitespace changes"])
174 mv stdout configure-output
175 AT_CHECK([grep "ignoring whitespace changes" stderr], [], [ignore])
176 AT_CHECK([grep "precious:        apple" configure-output], [], [ignore])
178 AT_CLEANUP
183 ## ---------------------------------------------- ##
184 ## AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS.  ##
185 ## ---------------------------------------------- ##
187 AT_SETUP([[AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS]])
189 AT_DATA([configure.ac],
190 [[AC_INIT
191 AC_PROG_FGREP
192 rm -f -r header var-header file var-file link var-link command var-command
193 echo 'OK' >input
195 # Be sure to also stress the associated INIT-CMDS.
196 case $what_to_test in
197  header)
198    AC_CONFIG_HEADERS(header:input);;
199  var-header)
200    AC_CONFIG_HEADERS(var-header:$header_in, [], [header_in=input]);;
202  file)
203    AC_CONFIG_FILES(file:input);;
204  var-file)
205    AC_CONFIG_FILES(var-file:$file_in, [], [file_in=input]);;
207  command)
208    AC_CONFIG_COMMANDS(command,
209                       [cp input command]);;
210  var-command)
211    AC_CONFIG_COMMANDS(var-command,
212                       [cp $command_in var-command], [command_in=input]);;
214  link)
215    AC_CONFIG_LINKS(link:input);;
216  var-link)
217    AC_CONFIG_LINKS(var-link:$link_in, [], [link_in=input]);;
218 esac
219 AC_OUTPUT
222 AT_CHECK_AUTOCONF
225 # AT_CHECK_CONFIG_CREATION(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],
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 AT_CHECK([./config.status var-$1 </dev/null], [], [ignore])
243 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
244          [ignore], [var-$1
246 AT_CHECK([grep OK var-$1], [], [OK
248 ])# AT_CHECK_CONFIG_CREATION
251 # AT_CHECK_CONFIG_CREATION_NOWRITE(THING = (header | link | file | command))
252 # --------------------------------------------------------------------------
253 # Check that THING and var-THING (which uses variables in AC_CONFIG_THING)
254 # are properly created, with the right content.
255 # Use `grep OK' instead of a simple `cat' to avoid banners such as in
256 # AC_CONFIG_HEADERS.
257 m4_define([AT_CHECK_CONFIG_CREATION_NOWRITE],
258 [AT_CHECK_CONFIGURE([what_to_test=$1])
259 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
260          [ignore], [$1
262 AT_CHECK([grep OK $1], [], [OK
265 AT_CHECK_CONFIGURE([what_to_test=var-$1 --no-create])
266 # config.status might be stupidly expecting data on stdin, if it's
267 # really broken...
268 # Skip check if user can rename files into a read-only directory (when
269 # run by root or on w32).
270 touch t
271 chmod a-w .
272 mv t t1 >/dev/null 2>&1 \
273   || AT_CHECK([./config.status var-$1 </dev/null || exit 1],
274    [1], [ignore], [ignore])
275 chmod u+w .
276 rm -rf t t1
277 ])# AT_CHECK_CONFIG_CREATION_NOWRITE
280 # Create a file
281 AT_CHECK_CONFIG_CREATION(file)
283 # Create a header
284 AT_CHECK_CONFIG_CREATION(header)
286 # Execute a command
287 AT_CHECK_CONFIG_CREATION(command)
289 # Create a link
290 AT_CHECK_CONFIG_CREATION(link)
292 # Now check for write errors
294 # Create a file
295 AT_CHECK_CONFIG_CREATION_NOWRITE(file)
296 # Create a file with bits from stdin
297 AT_CHECK([echo from-stdin | ./config.status --file=file:-],
298          [0], [ignore])
299 AT_CHECK([grep from-stdin file], [], [from-stdin
301 # Force write error creating a file on stdout
302 if test -w /dev/full && test -c /dev/full; then
303   AT_CHECK([./config.status --file=-:input </dev/null >/dev/full || exit 1],
304            [1], [ignore], [ignore])
307 # Validate that --file requires an argument
308 AT_CHECK([./config.status --file], [1], [ignore], [stderr])
309 AT_CHECK([grep 'missing file argument' stderr], [0], [ignore])
310 AT_CHECK([./config.status --file=], [1], [ignore], [stderr])
311 AT_CHECK([grep 'missing file argument' stderr], [0], [ignore])
313 # Create a header
314 AT_CHECK_CONFIG_CREATION_NOWRITE(header)
315 # Create a header on stdout
316 AT_CHECK([./config.status --header=-:input </dev/null],
317          [0], [stdout], [ignore])
318 AT_CHECK([grep OK stdout], [], [OK
320 # Force write error creating a header on stdout
321 if test -w /dev/full && test -c /dev/full; then
322   AT_CHECK([./config.status --header=-:input </dev/null >/dev/full || exit 1],
323            [1], [ignore], [ignore])
326 # Execute a command
327 AT_CHECK_CONFIG_CREATION_NOWRITE(command)
329 # Create a link
330 AT_CHECK_CONFIG_CREATION_NOWRITE(link)
332 # Check that no use of `ac_write_fail' escaped into config.status
333 AT_CHECK([grep ac_write_fail config.status], [1])
335 # Check that --file and --header accept funny file names
336 AT_DATA([fgrep.in],
337 [[FGREP="@FGREP@"
339 ./config.status --file=fgrep:fgrep.in
340 . ./fgrep
343 export x
344 for file in \
345   'with  funny '\'' $x & #! name' \
346   'file with  funny \ '\'' \'\'' $ & #!*? name' \
347   'with  funny \ '\'' \'\'' " | <a >b & * ? name ' # "restore font-lock
349   # The function func_sanitize_file_name comes from tools.at
350   file=`func_sanitize_file_name "$file"`
351   cat >"$file.in" <<'END'
352 @configure_input@
354   AT_CHECK([./config.status "--file=$file:$file.in"],
355            [0], [ignore])
356   AT_CHECK([$FGREP "$file" "$file"], [0], [ignore])
357   AT_CHECK([./config.status "--header=$file:$file.in"],
358            [0], [ignore])
359   # Run the same test a 2nd time to see that config.status does not recreate
360   # the header (regression test)
361   AT_CHECK_UNQUOTED([./config.status "--header=$file:$file.in"],
362                     [0], [config.status: creating $file
363 config.status: $file is unchanged
365   AT_CHECK_UNQUOTED([grep ' & ' "$file"], [],
366 [/* $file.  Generated from $file.in by configure.  */
368   AT_CHECK([$FGREP "$file" "$file"], [0], [ignore])
369 done
370 AT_CLEANUP
374 ## ---------------------------------------- ##
375 ## Macro calls in AC_CONFIG_COMMANDS tags.  ##
376 ## ---------------------------------------- ##
378 AT_SETUP([Macro calls in AC_CONFIG_COMMANDS tags])
380 AT_DATA_M4SUGAR([configure.ac],
381 [[AC_INIT
382 AC_CONFIG_COMMANDS([m4_if(1,1,mytag)])
383 AC_OUTPUT
386 AT_CHECK_AUTOCONF
387 AT_CHECK_CONFIGURE
389 AT_CLEANUP
393 ## ------------------- ##
394 ## Missing templates.  ##
395 ## ------------------- ##
397 # Check that config.status detects missing input files
398 AT_SETUP([Missing templates])
400 AT_DATA([configure.ac],
401 [[AC_INIT
402 AC_CONFIG_FILES([nonexistent])
403 AC_OUTPUT
406 AT_CHECK_AUTOCONF
407 mkdir build
408 AT_CAPTURE_FILE([build/config.log])[]dnl
409 cd build
410 AT_CHECK([../configure], [1], [ignore],
411 [[config.status: error: cannot find input file: `nonexistent.in'
413 # Make sure that the output file doesn't exist
414 AT_CHECK([test -f nonexistent], 1)
415 cd ..
416 AT_CHECK_CONFIGURE([], [1], [],
417 [[config.status: error: cannot find input file: `nonexistent.in'
419 # Make sure that the output file doesn't exist
420 AT_CHECK([test -f nonexistent], 1)
422 AT_CLEANUP
427 ## ---------------------- ##
428 ## configure invocation.  ##
429 ## ---------------------- ##
431 # Check that `configure' and `config.status' honor their interface.
433 # We run `./configure one=val1 --enable-two=val2 --with-three=val3'
434 # and verify that (i) `configure' correctly receives the arguments,
435 # (ii) correctly passes them to `config.status', which we check by
436 # running `config.status --recheck', (iii) correctly passes them
437 # to sub-configure scripts, and (iv) correctly reproduces them with
438 # `config.status --config'.
440 AT_SETUP([configure invocation])
442 mkdir sub
444 AT_DATA([configure.ac],
445 [[AC_INIT
446 AC_CONFIG_SUBDIRS([sub])
447 echo "result=$one$enable_two$with_three"
448 AC_OUTPUT
451 AT_DATA([sub/configure.ac],
452 [[AC_INIT
453 echo "result=$one$enable_two$with_three"
454 AC_OUTPUT
457 echo fake install-sh script >install-sh
459 AT_CHECK_AUTOCONF
460 cd sub
461 AT_CHECK_AUTOCONF
462 cd ..
464 AT_CHECK_CONFIGURE([one=one --enable-two=two --with-three=three |
465                      sed -n -e 's/^result=//p'], 0,
466                    [m4_do([onetwothree
467 ],                        [onetwothree
468 ])])
469 AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
470          [onetwothree
472 AT_CHECK([args=`./config.status --config` && eval ./configure \$configure_options "$args" |
473             sed -n -e 's/^result=//p'], 0,
474          [m4_do([onetwothree
475 ],              [onetwothree
476 ])])
478 AT_CHECK_CONFIGURE([one="\"'$ " --enable-two="\" '  $" --with-three="   \"'$"|
479                       sed -n -e 's/^result=//p'], 0,
480                    [m4_do(["'$ " '  $   "'$
481 ],                        ["'$ " '  $   "'$
482 ])])
483 AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
484          ["'$ " '  $    "'$
486 dnl restore font-lock: "
487 AT_CHECK([args=`./config.status --config` && eval ./configure \$configure_options "$args" |
488             sed -n -e 's/^result=//p'], 0,
489          [m4_do(["'$ " '  $     "'$
490 ],              ["'$ " '  $     "'$
491 ])])
493 AT_CLEANUP
497 ## -------------------------------------------- ##
498 ## Check that `#define' templates are honored.  ##
499 ## -------------------------------------------- ##
501 # Use various forms of `#define' templates, and make sure there are no
502 # problems when a symbol is prefix of another.
504 AT_SETUP([@%:@define header templates])
505 AT_KEYWORDS([AC@&t@_DEFINE])
507 AT_DATA([configure.ac],
508 [[AC_INIT
509 AC_CONFIG_HEADERS(config.h:config.hin)
511 # I18n of dummy variables: their French translations.
512 AC_DEFINE(foo, toto)
513 AC_DEFINE(bar, tata)
514 AC_DEFINE(baz, titi)
515 AC_DEFINE(fubar, tutu)
517 # Symbols which are prefixes of another.
518 AC_DEFINE(a, A)
519 AC_DEFINE(aaa, AAA)
520 AC_DEFINE(aa, AA)
522 # backslash-newline combinations
523 AC_DEFINE([multiline], [line1\
524 line2\
525 line3 \
526 line4])
527 AC_DEFINE([multiline_args(ARG1, ARG2)], [ARG2 \
528 ARG1])
529 AC_CONFIG_FILES(defs)
531 # underquoted #
532 AC_DEFINE([paste(a,b)], [a##b])
534 # Things included in confdefs.h, but which make no sense in
535 # config.h, nor in $DEFS.
536 cat <<\EOF >>confdefs.h
537 /* Hi Mum! Look, I am doing C++! */
538 #ifdef __cplusplus
539 void exit (int status);
540 #endif
543 # In addition of config.h output a full DEFS
544 AC_OUTPUT_MAKE_DEFS
545 DEFS_SAVED=$DEFS
546 AC_SUBST(DEFS_SAVED)
547 AC_OUTPUT
550 AT_DATA([defs.in],
551 [[@DEFS_SAVED@
554 AT_DATA([config.hin],
555 [[#define foo   0
556 #  define bar bar
557 #  define baz   "Archimedes was sinking in his baz"
558   #  define fubar                               tutu
559 #define a B
560  #define aa BB
561  #  define aaa BBB
562 #undef a
563  #  undef aa
564 #undef aaa
565 #define aaa(a, aa) aa a
566 #define aaab
567 #define aaac(a, aa) aa a
568 #undef multiline
569 #  undef multiline_args
570 #define paste(a,b) a##b
571 /* an ugly one: */
572 #define str(define) \
573 #define
574 #define stringify(arg) str(arg)
575 #undef aaa /* with comments */
576 #undef not_substed /* with comments */
579 AT_CHECK_AUTOCONF
580 AT_CHECK_CONFIGURE
582 AT_DATA([expout],
583 [[/* config.h.  Generated from config.hin by configure.  */
584 #define foo toto
585 #  define bar tata
586 #  define baz titi
587   #  define fubar tutu
588 #define a A
589  #define aa AA
590  #  define aaa AAA
591 #define a A
592  #  define aa AA
593 #define aaa AAA
594 #define aaa AAA
595 #define aaab
596 #define aaac(a, aa) aa a
597 #define multiline line1\
598 line2\
599 line3 \
600 line4
601 #  define multiline_args(ARG1, ARG2) ARG2 \
602 ARG1
603 #define paste(a,b) a##b
604 /* an ugly one: */
605 #define str(define) \
606 #define
607 #define stringify(arg) str(arg)
608 #define aaa AAA
609 /* #undef not_substed */
611 AT_CHECK([cat config.h], 0, expout)
613 # Check the value of DEFS.
614 AT_DATA([expout],
615 [[-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
618 # Because we strip trailing spaces in `testsuite' we can't leave one in
619 # expout, hence nuke the one left by AC_OUTPUT_MAKE_DEFS.
620 AT_CHECK([sed -e 's/ $//' defs], 0, expout)
622 AT_CLEANUP
626 ## ------------------------- ##
627 ## Torturing config.status.  ##
628 ## ------------------------- ##
630 ## Require 100 AC_DEFINE and AC_SUBST and AC_SUBST_FILE with a significantly
631 ## big value.  This is mostly to check that Autoconf produces portable sed
632 ## scripts in config.status.  sed is used to skip the first two lines
633 ## `Generated by ...'.
635 # We use m4_for many times.
636 m4_pattern_allow([^m4_for$])
638 AT_SETUP([Torturing config.status])
640 dnl The value used as a big value for AC_DEFINE.
641 dnl Don't use sh active chars here, below it is also used in a sh
642 dnl assignment.
643 m4_define([AT_BIG_VALUE],
644 [This value should be long enough to torture the various limits of sed and other tools used by Autoconf.])
646 m4_define([AT_DESCRIPTION],
647 [Define to a long string if your `Autoconf' works properly.])
650 # AT_DUMMY_VAR(NUMBER)
651 # --------------------
652 # Build a name used for AC_SUBST and AC_DEFINE.  Put ac_ in it
653 # so that the check for user name space invasion does not complain
654 # of the new variables defined.
656 # Note that you should not use the name ac_dummy, because it will be
657 # turned into ac_uummy during the construction of config.status.  Yes,
658 # this is admittedly a bug, but it would be too hard to fix this.
659 # There is really no point in AC_DEFINE a var named ac_d.*.
660 m4_pattern_allow([^m4_bpatsubst$])
661 m4_define([AT_DUMMY_VAR],
662 [ac_Dummy_[]m4_bpatsubst([000$1], [.*\(...\)$], [\1])])
666 AT_DATA([dummy.in],
667 [m4_for([AT_Count], 1, 100, 1,
668 [@AT_DUMMY_VAR(AT_Count)@
669 @[f]AT_Count@
670 ])])
674 while test $i != 101; do
675   echo "content of file $i" > file_$i
676   AS_VAR_ARITH([i], [$i + 1])
677 done
680 # ------------ #
681 # configure.ac #
682 # ------------ #
684 m4_pattern_allow([^m4_(define|defun)$])
685 AT_DATA([configure.ac],
686 dnl The following lines transfer AT_DUMMY_VAR, AT_DESCRIPTION, and
687 dnl AT_BIG_VALUE into the configure.ac as AC_DUMMY_VAR etc.
688 [[m4_define([AC_DUMMY_VAR],]
689 m4_dquote(m4_defn([AT_DUMMY_VAR]))[)]]
691 [[m4_define([AC_DESCRIPTION],]
692 m4_dquote(m4_defn([AT_DESCRIPTION]))[)]]
694 [[m4_define([AC_BIG_VALUE],]
695 m4_dquote(m4_defn([AT_BIG_VALUE]))[)]]
697 [[# AC_DEFUBST(NAME)
698 # ----------------
699 # Related VALUE to NAME both with AC_SUBST and AC_DEFINE.  This is
700 # used in the torture tests.
701 m4_defun([AC_DEFUBST],
702 [AC_DUMMY_VAR($1)="AC_BIG_VALUE"
703 AC_DEFINE_UNQUOTED(AC_DUMMY_VAR($1), "$AC_DUMMY_VAR($1) $AC_DUMMY_VAR($1)",
704                    AC_DESCRIPTION)
705 AC_SUBST(AC_DUMMY_VAR($1))
706 AC_SUBST_FILE([f]$1)
707 f$1=file_$1
710 AC_INIT
711 AC_CONFIG_HEADERS(config.h:config.hin)
712 AC_CONFIG_FILES(dummy)
713 m4_for(AC_Count, 1, 100, 1,
714        [AC_DEFUBST(AC_Count)])
715 AC_PROG_AWK
716 AC_OUTPUT
717 ]])# configure.ac
719 AT_CHECK_AUTOCONF
720 AT_CHECK_AUTOHEADER
721 # Check both awk and the result of AC_PROG_AWK.
722 # Quote the first word in the for list for Solaris sh.
723 for awk_arg in "FOO=" AWK=awk; do
724   AT_CHECK_CONFIGURE([$awk_arg])
726   # Checking that AC_DEFINE worked properly.
727   AT_DATA([expout],
728 [/* Define to the address where bug reports for this package should be sent. */
729 #define PACKAGE_BUGREPORT ""
731 /* Define to the full name of this package. */
732 #define PACKAGE_NAME ""
734 /* Define to the full name and version of this package. */
735 #define PACKAGE_STRING ""
737 /* Define to the one symbol short name of this package. */
738 #define PACKAGE_TARNAME ""
740 /* Define to the home page for this package. */
741 #define PACKAGE_URL ""
743 /* Define to the version of this package. */
744 #define PACKAGE_VERSION ""
745 m4_for(AT_Count, 1, 100, 1,
747 /* AT_DESCRIPTION */
748 [#define] AT_DUMMY_VAR(AT_Count) "AT_BIG_VALUE AT_BIG_VALUE"
749 ])])
751   AT_CHECK([sed -n '4,$ p' config.h], 0, expout)
753   # Checking that AC_SUBST worked properly.
754   AT_DATA([expout],
755 [m4_for(AT_Count, 1, 100, 1,
756 [AT_BIG_VALUE
757 content of file AT_Count
758 ])])
760   AT_CHECK([cat dummy], 0, expout)
761 done
763 AT_CLEANUP
766 ## ------------------------------- ##
767 ## Substitute a 2000-byte string.  ##
768 ## ------------------------------- ##
770 # Solaris 9 /usr/ucb/sed that rejects commands longer than 4000 bytes.  HP/UX
771 # sed dumps core around 8 KiB.  However, POSIX says that sed need not
772 # handle lines longer than 2048 bytes (including the trailing newline).
773 # So we'll just test a 2000-byte value, and for awk, we test a line with
774 # almost 1000 words, and one variable with 5 lines of 2000 bytes each:
775 # multi-line values should allow to get around the limitations.
776 # We also test runs of around 148 backslashes: they need to be escaped,
777 # and 148 is the portable limit for awk string literals.  config.status
778 # uses concatenation to generate longer strings.
780 AT_SETUP([Substitute a 2000-byte string])
782 AT_DATA([Foo.in], [@foo@
784 AT_DATA([Bar.in], [@bar@
786 AT_DATA([Baz.in], [@baz@
788 AT_DATA([Boo.in], [@b147@
789 @b148@
790 @b149@
791 @b295@
792 @b296@
793 @b297@
796 AT_DATA([configure.ac],
797 [[AC_INIT
798 AC_SUBST([foo], ]m4_for([n], 1, 100,, ....................)[)
799 AC_SUBST([bar], "]m4_for([n], 1, 100,, @ @ @ @ @ @ @ @ @ @@)[")
800 baz="]m4_for([m], 1, 100,, ... ... ... ... ....)[
802 baz=$baz$baz$baz$baz$baz
803 AC_SUBST([baz])
804 b29='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
805 b147=$b29$b29$b29$b29$b29'\\'
806 b148=$b147'\'
807 b149=$b148'\'
808 b295=$b147$b147'\'
809 b296=$b295'\'
810 b297=$b296'\'
811 AC_SUBST([b147])
812 AC_SUBST([b148])
813 AC_SUBST([b149])
814 AC_SUBST([b295])
815 AC_SUBST([b296])
816 AC_SUBST([b297])
817 AC_PROG_AWK
818 AC_CONFIG_FILES([Foo Bar Baz Boo])
819 AC_OUTPUT
822 cp "$abs_top_srcdir/build-aux/install-sh" .
824 b29='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
825 b147=$b29$b29$b29$b29$b29'\\'
826 b295=$b147$b147'\'
827 cat >Boo-exp <<EOF
828 $b147
829 $b147\\
830 $b147\\\\
831 $b295
832 $b295\\
833 $b295\\\\
836 AT_CHECK_AUTOCONF
837 # Check both awk and the result of AC_PROG_AWK
838 # Quote the first word in the for list for Solaris sh.
839 for awk_arg in "Foo=" AWK=awk; do
840   AT_CHECK_CONFIGURE([$awk_arg])
841   AT_CHECK([cat Foo], 0, m4_for([n], 1, 100,, ....................)
843   AT_CHECK([cat Bar], 0, m4_for([n], 1, 100,, @ @ @ @ @ @ @ @ @ @@)
845   AT_DATA([stdout],
846   [m4_for([n], 1, 5,, m4_for([m], 1, 100,, ... ... ... ... ....)
848   AT_CHECK([cat Baz], 0, [stdout])
849   AT_CHECK([diff Boo-exp Boo])
850 done
851 AT_CLEANUP
854 ## ------------------------------ ##
855 ## Define to a 2000-byte string.  ##
856 ## ------------------------------ ##
858 AT_SETUP([Define to a 2000-byte string])
859 AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
861 AT_CONFIGURE_AC(
863 AC_DEFINE_UNQUOTED([foo], ]m4_for([n], 1, 100,, ....................)[, [desc])
864 AC_DEFINE([fooq], ]m4_for([n], 1, 100,, ....................)[, [desc])
867 AT_CHECK_AUTOCONF
868 AT_CHECK_AUTOHEADER
869 AT_CHECK_CONFIGURE
870 AT_CHECK_DEFINES([@%:@define foo m4_for([n], 1, 100,, ....................)
871 @%:@define fooq m4_for([n], 1, 100,, ....................)
873 AT_CLEANUP
876 ## ------------------------------------------ ##
877 ## Substitute and define special characters.  ##
878 ## ------------------------------------------ ##
880 # Use characters special to the shell, sed, awk, and M4.
882 AT_SETUP([Substitute and define special characters])
883 AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
885 AT_XFAIL_IF([byte=\\200s; dnl
886 test `{ printf $byte; echo; } | sed -n '/^./p' | wc -l` = 0])
888 AT_DATA([Foo.in], [@foo@
889 @bar@@notsubsted@@baz@ stray @ and more@@@baz@
890 abc@bar@baz@baz
891 abc@bar@@baz@baz
892 abc@bar@@baz@baz@
893 abc@bar @baz@baz
894 abc@bar @baz@baz@
895 abc@bar @baz@@baz@
896 @file@
897          @file@
898 X@file@
899 @file@X
902 AT_DATA([File],
903 [@foo@@bar@
906 AT_DATA([Zardoz.in], [@zardoz@
909 AT_CONFIGURE_AC(
910 [[foo="AS@&t@_ESCAPE([[X*'[]+ ", & &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !]])"
912 bar="@foo@ @baz@"
913 baz=bla
914 ( for i in 0 1 2 3; do
915     for j in 0 1 2 3 4 5 6 7; do
916       for k in 0 1 2 3 4 5 6 7; do
917         case $i$j$k in #(
918         000 | 015 | 377) ;; # MinGW awk dislikes 0xFF, and the test does
919                             # the wrong thing for CR on MinGW.
920                             #(
921         *) printf \\$i$j$k's' ;; # The 's' works around a Solaris 8 /bin/bash bug.
922         esac
923       done
924     done
925   done
926   printf \\n
927 ) >allowed-chars
928 zardoz=`cat allowed-chars`
929 AC_SUBST([foo])
930 AC_SUBST([bar])
931 AC_SUBST([baz])
932 AC_SUBST([zardoz])
933 file=File
934 AC_SUBST_FILE([file])
935 AC_DEFINE([fooq], [[X*'[]+ ", & &`\($foo !]], [Awful value.])
936 AC_DEFINE([barq], [[%!_!# X]], [Value that is used as special delimiter.])
937 AC_DEFINE_UNQUOTED([foo], [[X*'[]+ ", & &\`\\(\$foo !]], [Awful value.])
938 AC_DEFINE_UNQUOTED([bar], [[%!_!# X]], [Value that is used as special delimiter.])
939 AC_DEFINE_UNQUOTED([unq1], [$baz], [unquoted, test 1])
940 AC_DEFINE_UNQUOTED([unq2], [\$baz], [unquoted, test 2])
941 AC_DEFINE_UNQUOTED([unq3], ["$baz"], [unquoted, test 3])
942 AC_DEFINE_UNQUOTED([unq4], [${baz+set}], [unquoted, test 4])
943 AC_DEFINE_UNQUOTED([unq5], ["${baz+`echo "a "' b'`}"], [unquoted, test 5])
944 AC_DEFINE_UNQUOTED([unq6], [`echo hi`], [unquoted, test 6])
945 AC_DEFINE_UNQUOTED([unq7], ['\\"'], [unquoted, test 7])
946 AC_PROG_AWK
947 AC_CONFIG_FILES([Foo Zardoz])]])
949 AT_CHECK_AUTOCONF
950 AT_CHECK_AUTOHEADER
951 # Check both awk and the result of AC_PROG_AWK
952 # Quote the first word in the for list for Solaris sh.
953 for awk_arg in "FOO=" AWK=awk; do
954   AT_CHECK_CONFIGURE([$awk_arg])
955   AT_CHECK([cat Foo], 0, [[X*'[]+ ", & &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !
956 @foo@ @baz@@notsubsted@bla stray @ and more@@bla
957 abc@foo@ @baz@baz@baz
958 abc@foo@ @baz@blabaz
959 abc@foo@ @baz@blabaz@
960 abc@bar blabaz
961 abc@bar blabaz@
962 abc@bar blabla
963 @foo@@bar@
964 @foo@@bar@
965 X@file@
966 @file@X
968   AT_CHECK([cmp allowed-chars Zardoz])
969   AT_CHECK_DEFINES([[#define bar %!_!# X
970 #define barq %!_!# X
971 #define foo X*'[]+ ", & &`\($foo !
972 #define fooq X*'[]+ ", & &`\($foo !
973 #define unq1 bla
974 #define unq2 $baz
975 #define unq3 "bla"
976 #define unq4 set
977 #define unq5 "a  b"
978 #define unq6 hi
979 #define unq7 '\"'
981 done
982 AT_CLEANUP
985 ## ---------------------- ##
986 ## Substitute a newline.  ##
987 ## ---------------------- ##
989 AT_SETUP([Substitute a newline])
991 AT_DATA([Foo.in],
992 [@foo@
993 @bar@
996 AT_DATA([configure.ac],
997 [[AC_INIT
998 foo='one
999 two'
1000 bar='%!_!# ''
1002 AC_SUBST([foo])
1003 AC_SUBST([bar])
1004 AC_CONFIG_FILES([Foo])
1005 AC_PROG_AWK
1006 AC_OUTPUT
1009 cp "$abs_top_srcdir/build-aux/install-sh" .
1011 echo 'one
1013 %!_!# ''
1014 x' >expout
1016 AT_CHECK_AUTOCONF
1017 # Check both awk and the result of AC_PROG_AWK
1018 # Quote the first word in the for list for Solaris sh.
1019 for awk_arg in "FOO=" AWK=awk; do
1020   AT_CHECK_CONFIGURE([$awk_arg])
1021   AT_CHECK([cat Foo], 0, [expout])
1022 done
1023 AT_CLEANUP
1026 ## ------------------ ##
1027 ## Define a newline.  ##
1028 ## ------------------ ##
1030 AT_SETUP([Define a newline])
1031 AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
1032 AT_CONFIGURE_AC([[AC_DEFINE([foo], [one
1033 two], [This spans two lines.])
1035 AT_CHECK_AUTOCONF([], [], [], [stderr])
1036 dnl Older versions of m4 report error at line 5 (end of macro);
1037 dnl newer versions report it at line 4 (start of macro).
1038 AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
1039 [[warning: AC_DEFINE: `one
1040 two' is not a valid preprocessor define value
1042 AT_CHECK_AUTOHEADER([], [], [], [stderr])
1043 AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
1044 [[warning: AC_DEFINE: `one
1045 two' is not a valid preprocessor define value
1047 AT_CHECK_CONFIGURE
1048 AT_CHECK_DEFINES([[#define foo one
1051 AT_CONFIGURE_AC([[AC_DEFINE_UNQUOTED([foo], [one
1052 two], [This spans two lines.])
1054 AT_CHECK_AUTOCONF([], [], [], [stderr])
1055 AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
1056 [[warning: AC_DEFINE_UNQUOTED: `one
1057 two' is not a valid preprocessor define value
1059 AT_CHECK_AUTOHEADER([], [], [], [stderr])
1060 AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
1061 [[warning: AC_DEFINE_UNQUOTED: `one
1062 two' is not a valid preprocessor define value
1064 AT_CHECK_CONFIGURE
1065 AT_CHECK_DEFINES([[#define foo one
1068 AT_CLEANUP
1071 ## ------------------------------------ ##
1072 ## AC_SUBST: variable name validation.  ##
1073 ## ------------------------------------ ##
1075 AT_SETUP([AC_SUBST: variable name validation])
1077 AT_CONFIGURE_AC([[AC_SUBST(, [])
1078 AC_CONFIG_FILES([Makefile])
1080 AT_DATA([Makefile.in], [[
1082 mv -f configure.ac configure.tmpl
1084 # Invalid names.
1085 for var in ['' ab\~ ab\( ab[] ab\' ab\" ab\\\\]; do
1086   sed ["s/AC_SUBST(/&[$var]/"] <configure.tmpl >configure.ac
1087   AT_CHECK_AUTOCONF([], [1], [], [ignore])
1088 done
1090 # Valid names.
1091 for var in ab a4 'a@@&t@\&t@b'; do
1092   sed ["s/AC_SUBST(/&[$var]/"] <configure.tmpl >configure.ac
1093   AT_CHECK_AUTOCONF
1094   AT_CHECK_AUTOHEADER
1095   AT_CHECK_CONFIGURE
1096 done
1098 AT_CLEANUP
1101 ## ------------------------ ##
1102 ## datarootdir workaround.  ##
1103 ## ------------------------ ##
1105 AT_SETUP([datarootdir workaround])
1107 AT_DATA([Foo.in],
1108 [@datadir@
1109 @docdir@
1110 @infodir@
1111 @localedir@
1112 @mandir@
1115 AT_DATA([Bar.in],
1116 [@mydatadir@
1119 AT_DATA([configure.ac],
1120 [[AC_INIT
1121 d@&t@nl The following line silences the warnings, if uncommented:
1122 d@&t@nl AC_DEFUN([AC_DATAROOTDIR_CHECKED])
1124 # This substitution is wrong and bogus!  Don't use it in your own code!
1125 # Read `info Autoconf "Defining Directories"'!
1126 AC_SUBST([mydatadir], [${datadir}/my])
1128 AC_CONFIG_FILES([Foo Bar])
1129 AC_OUTPUT
1132 cp "$abs_top_srcdir/build-aux/install-sh" .
1134 AT_CHECK_AUTOCONF
1135 AT_CHECK_CONFIGURE([], [], [],
1136   [config.status: WARNING:  'Foo.in' seems to ignore the --datarootdir setting
1137 config.status: WARNING: Bar contains a reference to the variable `datarootdir'
1138 which seems to be undefined.  Please make sure it is defined
1140 AT_CHECK([grep datarootdir Foo], 1, [])
1142 rm configure
1143 sed '/AC_DEFUN/s/^d@&t@nl //' configure.ac >t
1144 mv t configure.ac
1146 AT_CHECK_AUTOCONF
1147 AT_CHECK_CONFIGURE
1149 AT_CLEANUP
1152 ## -------- ##
1153 ## srcdir.  ##
1154 ## -------- ##
1156 AT_SETUP([srcdir])
1158 rm -f -r at-dir
1159 mkdir at-dir
1160 : >at-dir/bar.in
1161 : >foo.in
1163 AT_DATA([configure.ac],
1164 [[AC_INIT
1166 AC_CONFIG_FILES([foo at-dir/bar])
1168 # Use quotes in the INIT-COMMANDS to accommodate a value of $srcdir
1169 # containing e.g., spaces or shell meta-characters.
1170 # Use *single* quotes because the context is an unquoted here-doc.
1171 AC_CONFIG_COMMANDS([report],
1172 [test -f "$srcdir/configure.ac" ||
1173    AC_MSG_ERROR([cannot find $srcdir/configure.ac])],
1174                    [srcdir='$srcdir'])
1176 AC_OUTPUT
1177 rm -f -r foo at-dir/bar
1180 AT_CHECK_AUTOCONF
1182 # In place.
1183 AT_CHECK([./configure $configure_options], [], [ignore])
1185 # Relative name.
1186 AT_CHECK([cd at-dir && ../configure $configure_options], [], [ignore])
1188 # Absolute name.
1189 at_here=`pwd`
1190 AT_CHECK([cd at-dir && "$at_here/configure" $configure_options], [], [ignore])
1192 AT_CLEANUP
1195 ## ------- ##
1196 ## VPATH.  ##
1197 ## ------- ##
1199 AT_SETUP([VPATH])
1201 dirs='at paren brace space'
1202 for dir in $dirs; do
1203   mkdir $dir $dir/s1 $dir/s2
1204   touch $dir/f $dir/s1/f1 $dir/s2/f2
1205 done
1207 AT_DATA([configure.ac],
1208 [[AC_INIT
1209 AC_CONFIG_FILES([at/Makefile paren/Makefile brace/Makefile space/Makefile])
1210 AC_OUTPUT
1213 AT_DATA([at/Makefile.in],
1214 [[# This is what you should use in order to be portable to old makes.
1215 srcdir = @srcdir@
1216 VPATH = @srcdir@/s1:@srcdir@:@srcdir@/s2
1217 all: f f1 f2
1218         @echo ok
1221 AT_DATA([paren/Makefile.in],
1222 [[# This works with some makes but not with old ones.
1223 srcdir = @srcdir@
1224 VPATH = $(srcdir)/s1:$(srcdir):$(srcdir)/s2
1225 all: f f1 f2
1226         @echo ok
1229 AT_DATA([brace/Makefile.in],
1230 [[# This works with some makes but not with old ones.
1231 srcdir = @srcdir@
1232 VPATH = ${srcdir}/s1:${srcdir}:${srcdir}/s2
1233 all: f f1 f2
1234         @echo ok
1237 AT_DATA([space/Makefile.in],
1238 [[# This fails with FreeBSD make, for example.
1239 srcdir = @srcdir@
1240 VPATH = @srcdir@/s1 @srcdir@ @srcdir@/s2
1241 all: f f1 f2
1242         @echo ok
1245 AT_CHECK_AUTOCONF
1247 : "${MAKE=make}"
1249 # In place.
1250 AT_CHECK([./configure $configure_options], [], [ignore])
1251 # Treat BSD make separately, afterwards, for maximal coverage.
1252 dirs='at paren brace'
1253 for dir in $dirs; do
1254   AT_CHECK([cd $dir && $MAKE], [], [ignore], [ignore])
1255 done
1257 rm -f config.status
1258 mkdir build absbuild
1260 # Relative name.
1261 AT_CHECK([cd build && ../configure $configure_options], [], [ignore])
1262 for dir in $dirs; do
1263   AT_CHECK([cd build/$dir && $MAKE], [], [ignore], [ignore])
1264 done
1266 # Absolute name.
1267 at_here=`pwd`
1268 AT_CHECK([cd absbuild && "$at_here/configure" $configure_options], [], [ignore])
1269 for dir in $dirs; do
1270   AT_CHECK([cd absbuild/$dir && $MAKE], [], [ignore], [ignore])
1271 done
1273 # These will not pass with BSD make.
1274 AT_CHECK([cd space && { $MAKE || exit 77; }], [], [ignore], [ignore])
1275 AT_CHECK([cd build/space && $MAKE], [], [ignore], [ignore])
1276 AT_CHECK([cd absbuild/space && $MAKE], [], [ignore], [ignore])
1278 AT_CLEANUP
1281 ## ----------------- ##
1282 ## Signal handling.  ##
1283 ## ----------------- ##
1285 AT_SETUP([Signal handling])
1287 AT_DATA([configure.ac],
1288 [[AC_INIT
1289 kill -2 $$
1290 exit 77
1293 AT_CHECK_AUTOCONF
1294 AT_CHECK_CONFIGURE([], 1, ignore, ignore)
1296 AT_CLEANUP
1299 ## ----------------- ##
1300 ## AC_CONFIG_LINKS.  ##
1301 ## ----------------- ##
1303 AT_SETUP([AC_CONFIG_LINKS])
1305 AT_DATA([configure.ac],
1306 [[AC_INIT([config links to config files test], [1.0])
1307 AC_CONFIG_SRCDIR([sub1/file1.in])
1308 AC_CONFIG_FILES([sub1/file1 file2])
1309 AC_CONFIG_LINKS([file1:sub1/file1 sub2/file2:file2])
1310 AC_OUTPUT
1313 mkdir sub1
1315 AT_DATA([sub1/file1.in],
1316 [[/* @configure_input@ */
1317 #define PACKAGE_STRING "@PACKAGE_STRING@"
1320 AT_DATA([file2.in],
1321 [[/* @configure_input@ */
1322 #define PACKAGE_STRING "@PACKAGE_STRING@"
1325 mkdir build
1326 AT_CHECK_AUTOCONF
1327 cd build
1328 AT_CHECK([../configure && ../configure], 0, [ignore])
1329 AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
1331 AT_CHECK([../configure && ../configure], 0, [ignore])
1332 AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
1334 cd ..
1335 rm -rf build
1336 mkdir build
1337 cd build
1338 cwd=`pwd`
1339 AT_CHECK(["$cwd"/../configure && "$cwd"/../configure], 0, [ignore])
1340 AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
1342 cd ..
1343 AT_CHECK([./configure && ./configure], 0, [ignore], [stderr])
1344 AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
1346 cwd=`pwd`
1347 AT_CHECK(["$cwd"/configure && "$cwd"/configure], 0, [ignore], [ignore])
1348 AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
1351 AT_CLEANUP
1354 ## ------------------------------------- ##
1355 ## AC_CONFIG_LINKS and identical files.  ##
1356 ## ------------------------------------- ##
1357 AT_SETUP([AC_CONFIG_LINKS and identical files])
1359 AT_DATA([configure.ac],
1360 [[AC_INIT
1361 AC_CONFIG_LINKS([src/s:src/s])
1362 test "$srcdir" != '.' && AC_CONFIG_LINKS([src/t:src/t])
1363 AC_OUTPUT
1366 mkdir src build
1367 echo file1 > src/s
1368 echo file2 > src/t
1369 AT_CHECK_AUTOCONF
1370 cd build
1371 AT_CHECK([../configure $configure_options && ../configure $configure_options],
1372          0, [ignore])
1373 AT_CHECK([cat src/s src/t], 0, [file1
1374 file2
1377 cd ..
1378 rm -rf build
1379 mkdir build
1380 cd build
1381 cwd=`pwd`
1382 AT_CHECK(["$cwd"/../configure], 0, [ignore])
1383 AT_CHECK([cat src/s src/t], 0, [file1
1384 file2
1386 AT_CHECK(["$cwd"/../configure], 0, [ignore])
1387 AT_CHECK([cat src/s src/t], 0, [file1
1388 file2
1390 cd ..
1391 AT_CHECK([./configure $configure_options && ./configure $configure_options],
1392          0, [ignore], [stderr])
1393 AT_CHECK([grep src/t stderr], 1)
1394 AT_CHECK([cat src/s src/t], 0, [file1
1395 file2
1397 cwd=`pwd`
1398 AT_CHECK(["$cwd"/configure && "$cwd"/configure], 0, [ignore], [ignore])
1399 AT_CHECK([cat src/s src/t], 0, [file1
1400 file2
1403 AT_CLEANUP
1406 AT_BANNER([autoreconf.])
1408 ## ---------------------------- ##
1409 ## Configuring subdirectories.  ##
1410 ## ---------------------------- ##
1412 # .
1413 # |-- builddir
1414 # |   |-- config.log
1415 # |   |-- config.status
1416 # |   `-- inner
1417 # |       |-- config.log
1418 # |       |-- config.status
1419 # |       `-- innermost
1420 # |           `-- config
1421 # |-- configure
1422 # |-- configure.ac
1423 # |-- inner
1424 # |   |-- configure
1425 # |   |-- configure.ac
1426 # |   `-- innermost
1427 # |       `-- config.in
1428 # `-- install-sh
1430 AT_SETUP([Configuring subdirectories])
1431 AT_KEYWORDS(autoreconf)
1433 # We use aclocal (via autoreconf).
1434 AT_CHECK([aclocal --version || exit 77], [], [stdout], [ignore])
1435 AT_CHECK([[grep '[1-9]\.[0-9]' stdout || exit 77]], [], [ignore])
1437 # It should understand configure.ac.
1438 AT_CHECK([[grep '[^0-9]1\.[01234][^0-9]' stdout && exit 77]], [1], [ignore])
1440 # Set CONFIG_SITE to a nonexistent file, so that there are
1441 # no worries about nonstandard values for 'prefix'.
1442 CONFIG_SITE=no-such-file
1443 export CONFIG_SITE
1445 # The contents of `inner/', and `inner/innermost/'.
1446 AS_MKDIR_P([inner/innermost])
1448 # We have to use configure.in, not configure.ac, if we still want to
1449 # be compatible with Automake 1.4: aclocal (run by autoreconf) would
1450 # die because it can't find configure.in.
1451 AT_DATA([inner/configure.in],
1452 [[AC_INIT(GNU Inner, 1.0)
1453 AC_CONFIG_SRCDIR([innermost/config.in])
1454 AC_ARG_VAR([INNER], [an inner variable])
1455 AC_SUBST([INNER])
1456 if test "x$INNER" = x; then
1457   INNER=inner
1459 AC_CONFIG_FILES([innermost/config])
1460 AC_OUTPUT
1463 AT_DATA([inner/innermost/config.in],
1464 [INNER=@INNER@
1465 srcdir=@srcdir@
1466 top_srcdir=@top_srcdir@
1467 prefix=@prefix@
1470 # The contents of `.'
1471 AT_DATA([install-sh], [])
1473 # nonexistent is allowed not to exist.
1474 AT_DATA([configure.in],
1475 [[AC_INIT(GNU Outer, 1.0)
1476 AC_ARG_VAR([OUTER], [an outer variable])
1477 if false; then
1478   AC_CONFIG_SUBDIRS([nonexistent])
1480 AC_CONFIG_SUBDIRS([inner])
1481 AC_OUTPUT
1484 # If there are improperly quoted AC_DEFUN installed in share/aclocal,
1485 # they trigger warnings from aclocal 1.8, so ignore stderr.
1486 AT_CHECK([autoreconf], [], [], [ignore])
1487 AT_CHECK([test -f inner/configure])
1489 # Running the outer configure recursively should provide the innermost
1490 # help strings.
1491 chmod a-w inner/innermost inner .
1492 AT_CHECK([{ ./configure $configure_options --help=recursive; chmod u+w .; } | grep INNER], 0,
1493          [ignore], [stderr],
1494          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1495 chmod u+w . inner inner/innermost
1497 # Running the outer configure should trigger the inner.
1498 AT_CHECK_CONFIGURE
1499 AT_CHECK([cat inner/innermost/config], 0,
1500 [INNER=inner
1501 srcdir=.
1502 top_srcdir=..
1503 prefix=/usr/local
1506 # The same, but from a builddir.
1507 AS_MKDIR_P([builddir])
1508 AT_CHECK([cd builddir && ../configure $configure_options], 0, [ignore])
1509 AT_CHECK([cat builddir/inner/innermost/config], 0,
1510 [INNER=inner
1511 srcdir=../../../inner/innermost
1512 top_srcdir=../../../inner
1513 prefix=/usr/local
1516 # Make sure precious variables and command line options are properly
1517 # passed, even when there are duplicates.
1518 AT_CHECK([cd builddir && ../configure $configure_options --prefix /bad --prefix /good INNER=bad INNER=good],
1519          0, [ignore])
1520 AT_CHECK([cat builddir/inner/innermost/config], 0,
1521 [INNER=good
1522 srcdir=../../../inner/innermost
1523 top_srcdir=../../../inner
1524 prefix=/good
1527 # Make sure --prefix is properly quoted
1528 AT_CHECK([cd builddir && ../configure --prefix "/a  b c$ 'd"], 0, [ignore])
1529 AT_CHECK([cat builddir/inner/innermost/config], 0,
1530 [INNER=inner
1531 srcdir=../../../inner/innermost
1532 top_srcdir=../../../inner
1533 prefix=/a  b c$ 'd
1536 # Make sure --silent is properly passed...
1537 AT_CHECK([cd builddir && ../configure $configure_options --silent], 0, [])
1538 # ...but not stored in config.status.
1539 AT_CHECK([cd builddir && ./config.status --recheck], 0, [stdout])
1540 AT_CHECK([grep 'creating \./config.status' stdout], 0, [ignore])
1542 # --cache-file is adjusted for subdirectories, so the cache is shared.
1543 AT_CHECK([cd builddir && ../configure $configure_options --config-cache],
1544          [], [stdout])
1545 AT_CHECK([grep 'loading .*\.\./config.cache' stdout], [], [ignore])
1547 # Make sure we can run autoreconf on a subdirectory
1548 rm -f configure configure.in
1549 AT_CHECK([autoreconf inner], [], [], [ignore])
1551 # Make sure we can pass a configure.ac name
1552 AT_CHECK([cd inner && autoreconf configure.in], [], [], [ignore])
1553 AT_CHECK([autoreconf inner/configure.in], [], [], [ignore])
1555 AT_CLEANUP
1559 ## -------------- ##
1560 ## Deep Package.  ##
1561 ## -------------- ##
1563 AT_SETUP([Deep Package])
1564 AT_KEYWORDS(autoreconf)
1566 # We use aclocal (via autoreconf).
1567 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
1569 # The contents of `.'
1570 AT_DATA([install-sh], [])
1571 AT_DATA([configure.in],
1572 [[AC_INIT(GNU Outer, 1.0)
1573 AC_ARG_VAR([OUTER], [an outer variable])
1574 AC_CONFIG_SUBDIRS([
1575   inner
1576   inner2
1578 AC_OUTPUT
1581 # The contents of `inner/', and `inner/innermost/'.
1582 AS_MKDIR_P([inner/innermost])
1583 AS_MKDIR_P([inner2])
1585 AT_DATA([inner/configure.in],
1586 [[AC_INIT(GNU Inner, 1.0)
1587 AC_ARG_VAR([INNER], [an inner variable])
1588 AC_CONFIG_SUBDIRS(innermost)
1589 AC_OUTPUT
1592 AT_DATA([inner/innermost/configure.in],
1593 [[AC_INIT(GNU Innermost, 1.0)
1594 AC_ARG_VAR([INNERMOST], [an innermost variable])
1595 AC_CONFIG_HEADERS(config.h:config.hin)
1596 AC_DEFINE_UNQUOTED([INNERMOST], [$INNERMOST], [an innermost variable])
1597 if test -n "$innermost_error"; then
1598   AC_MSG_FAILURE([error in $PACKAGE_NAME])
1600 AC_OUTPUT
1603 AT_DATA([inner2/configure.in],
1604 [[AC_INIT(GNU Inner 2, 1.0)
1605 AC_ARG_VAR([INNER2], [an inner2 variable])
1606 AC_OUTPUT
1609 AT_CHECK([autoreconf -Wall -v], [0], [ignore], [stderr])
1610 # We should not warn about nonliteral argument to AC_CONFIG_SUBDIRS here.
1611 AT_CHECK([grep 'AC_CONFIG_SUBDIRS:.*literals' stderr], [1])
1612 AT_CHECK([test -f inner/configure])
1613 AT_CHECK([test -f inner/innermost/configure])
1614 AT_CHECK([test -f inner/innermost/config.hin])
1615 AT_CHECK([test -f inner2/configure])
1617 # Running the outer configure recursively should provide the innermost
1618 # help strings.
1619 chmod a-w inner/innermost inner
1620 AT_CHECK([{ ./configure $configure_options --help=recursive; chmod u+w .; } | grep " INNER "],
1621          0, [ignore], [stderr],
1622          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1623 chmod a-w .
1624 AT_CHECK([{ ./configure $configure_options --help=recursive; chmod u+w .; } | grep " INNER2 "],
1625          0, [ignore], [stderr],
1626          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1627 chmod a-w .
1628 AT_CHECK([{ ./configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1629          0, [ignore], [stderr],
1630          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1631 chmod a-w .
1632 AT_CHECK([{ /bin/sh ./configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1633          0, [ignore], [stderr],
1634          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1635 chmod a-w .
1636 AT_CHECK([PATH=.$PATH_SEPARATOR$PATH; export PATH; { /bin/sh configure $configure_options --help=recursive; chmod +w .; } | grep " INNERMOST "],
1637          0, [ignore], [stderr],
1638          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1639 chmod a-w .
1640 AT_CHECK([PATH=.$PATH_SEPARATOR$PATH; export PATH; { configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1641          0, [ignore], [stderr],
1642          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1643 chmod u+w inner inner/innermost
1645 # Running the outer configure should trigger the inner.
1646 AT_CHECK_CONFIGURE([INNERMOST=tsomrenni])
1647 AT_CHECK([grep INNERMOST inner/innermost/config.h], 0,
1648 [[#define INNERMOST tsomrenni
1651 # Ensure we point to the right config.log file for errors.
1652 AT_CHECK_CONFIGURE([innermost_error=:], [1], [], [stderr])
1653 AT_CHECK([grep 'inner/innermost' stderr], [], [ignore])
1654 cd inner
1655 AT_CHECK_CONFIGURE([innermost_error=:], [1], [], [stderr])
1656 AT_CHECK([grep 'innermost' stderr], [], [ignore])
1657 cd ..
1659 # The same, but from a builddir.
1660 AS_MKDIR_P([builddir])
1661 chmod a-w builddir inner/innermost inner
1662 AT_CHECK([cd builddir && { ../configure $configure_options --help=recursive; chmod u+w .; } | grep " INNER "],
1663          0, [ignore], [stderr],
1664          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1665 chmod a-w builddir
1666 AT_CHECK([cd builddir && { ../configure $configure_options --help=recursive; chmod u+w .; } | grep " INNER2 "],
1667          0, [ignore], [stderr],
1668          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1669 chmod a-w builddir
1670 AT_CHECK([cd builddir && { ../configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1671          0, [ignore], [stderr],
1672          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1673 chmod a-w builddir
1674 AT_CHECK([cd builddir && { /bin/sh ../configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1675          0, [ignore], [stderr],
1676          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1677 chmod a-w builddir
1678 # Not all shells search $PATH for scripts.
1679 if (cd builddir && PATH=`pwd`/..$PATH_SEPARATOR$PATH /bin/sh configure $configure_options --help) >/dev/null 2>&1; then
1680   AT_CHECK([cd builddir && PATH=`pwd`/..$PATH_SEPARATOR$PATH /bin/sh configure $configure_options --help=recursive | grep " INNERMOST "], 0, [ignore])
1682 AT_CHECK([PATH=`pwd`$PATH_SEPARATOR$PATH; export PATH; cd builddir && { configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1683          0, [ignore], [stderr],
1684          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1685 chmod u+w builddir inner inner/innermost
1686 AT_CHECK([cd builddir && ../configure $configure_options INNERMOST=build/tsomrenni], 0, [ignore])
1687 AT_CHECK([grep INNERMOST builddir/inner/innermost/config.h], 0,
1688 [[#define INNERMOST build/tsomrenni
1691 AT_CLEANUP
1695 ## -------------------------------- ##
1696 ## Non-Autoconf AC_CONFIG_SUBDIRS.  ##
1697 ## -------------------------------- ##
1699 AT_SETUP([Non-Autoconf AC_CONFIG_SUBDIRS])
1700 AT_KEYWORDS([autoreconf])
1702 # We use aclocal (via autoreconf).
1703 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
1705 AT_DATA([install-sh], [])
1706 AT_DATA([configure.in],
1707 [[AC_INIT(GNU Outer, 1.0)
1708 AC_CONFIG_SUBDIRS([inner])
1709 AC_OUTPUT
1712 AS_MKDIR_P([inner])
1714 AT_DATA([inner/configure],
1715 [[#! /bin/sh
1716 case "$*" in
1717     *--help*) echo 'No Autoconf here, folks!' ;;
1718     *)        echo got_it >myfile ;;
1719 esac
1720 exit 0
1722 chmod +x inner/configure
1724 AT_CHECK([autoreconf -Wall -v], 0, [ignore], [ignore])
1726 # Running the outer configure recursively should provide the innermost
1727 # help strings.
1728 AT_CHECK([./configure $configure_options --help=recursive | grep "folks"], 0, [ignore])
1730 # Running the outer configure should trigger the inner.
1731 AT_CHECK([./configure $configure_options], 0, [ignore])
1732 AT_CHECK([test -f inner/myfile], 0)
1734 AT_CLEANUP
1737 ## ------------------------------- ##
1738 ## Non-literal AC_CONFIG_SUBDIRS.  ##
1739 ## ------------------------------- ##
1741 AT_SETUP([Non-literal AC_CONFIG_SUBDIRS])
1742 AT_KEYWORDS([autoreconf])
1744 AT_DATA([install-sh], [])
1745 AT_DATA([configure.in],
1746 [[AC_INIT(GNU Outer, 1.0)
1748 my_subdirs=
1749 # Taken from autoconf.texi:Subdirectories.
1750 if test "x$package_foo_enabled" = xyes; then
1751   my_subdirs="$my_subdirs foo"
1753 AC_CONFIG_SUBDIRS([$my_subdirs])
1754 AC_OUTPUT
1757 # Hand-written aclocal.m4, so we don't invoke `aclocal -Werror' which
1758 # could barf over warnings in third-party macro files, or fail over
1759 # warnings with older aclocal which didn't yet understand -W*.
1760 AT_DATA([aclocal.m4])
1762 AS_MKDIR_P([foo])
1764 AT_DATA([foo/configure],
1765 [[#! /bin/sh
1766 touch innerfile
1767 exit 0
1769 chmod +x foo/configure
1771 # autoreconf should warn without -Wno-syntax, but should not fail without -Werror.
1772 AT_CHECK([autoreconf -Werror -v], [1], [ignore], [stderr])
1773 AT_CHECK([grep 'AC_CONFIG_SUBDIRS:.*literals' stderr], [0], [ignore])
1774 AT_CHECK([autoreconf -v], [0], [ignore], [stderr])
1775 AT_CHECK([grep 'AC_CONFIG_SUBDIRS:.*literals' stderr], [0], [ignore])
1776 AT_CHECK([autoreconf -v --force -Wno-syntax], 0, [ignore], [stderr])
1777 AT_CHECK([grep 'AC_CONFIG_SUBDIRS:.*literals' stderr], [1])
1779 AT_CHECK([./configure $configure_options], [0], [ignore])
1780 AT_CHECK([test ! -f foo/innerfile])
1781 # Running the outer configure should trigger the inner.
1782 AT_CHECK([./configure $configure_options package_foo_enabled=yes], [0], [ignore])
1783 AT_CHECK([test -f foo/innerfile])
1785 AT_CLEANUP
1788 ## ----------------- ##
1789 ## Empty directory.  ##
1790 ## ----------------- ##
1792 AT_SETUP([Empty directory])
1793 AT_KEYWORDS([autoreconf])
1795 # We use aclocal (via autoreconf).
1796 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
1798 # The test group directory is not necessarily _empty_, but it does not contain
1799 # files meaningful to `autoreconf'.
1801 AT_CHECK([autoreconf -Wall -v], 1, [ignore], [ignore])
1803 AT_CLEANUP
1807 ## ------------------------------ ##
1808 ## Unusual Automake input files.  ##
1809 ## ------------------------------ ##
1811 # This parallels gnumake.test in Automake.
1813 AT_SETUP([Unusual Automake input files])
1814 AT_KEYWORDS([autoreconf])
1816 # We use aclocal and automake via autoreconf.
1817 AT_CHECK([automake --version || exit 77], [], [stdout], [ignore])
1818 AT_CHECK([[grep '[1-9]\.[0-9]' stdout || exit 77]], [], [ignore])
1820 AT_DATA([configure.in],
1821 [[AC_INIT(GNU foo, 1.0)
1822 AM_INIT_AUTOMAKE
1823 AC_CONFIG_FILES([HeeHee])
1824 AC_OUTPUT
1827 AT_DATA([HeeHee.am],
1828 [[# Humans do no worse than `GNUmakefile.am'.
1829 AUTOMAKE_OPTIONS = foreign 1.8
1832 AT_CHECK([autoreconf -Wall -v -i], 0, [ignore], [stderr],
1833          [AT_CHECK([grep 'require.*1\.8' stderr && exit 77], [1])])
1834 AT_CHECK([test -f HeeHee.in])
1836 AT_CLEANUP