3 # Copyright (C) 2000-2017, 2020-2024 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <https://www.gnu.org/licenses/>.
19 AT_BANNER([[Testing config.status.]])
22 ## ---------------------------------------- ##
23 ## AC_CONFIG_COMMANDS with empty commands. ##
24 ## ---------------------------------------- ##
26 AT_CHECK_MACRO([AC_CONFIG_COMMANDS with empty commands],
27 [[AC_CONFIG_COMMANDS([foo], [], [:])
31 ## --------------------------------------------- ##
32 ## AC_CONFIG_COMMANDS with temporary directory. ##
33 ## --------------------------------------------- ##
35 AT_CHECK_MACRO([AC_CONFIG_COMMANDS with temporary directory],
36 [[AC_CONFIG_COMMANDS([foo], [
40 test -d "$tmp" || AC_MSG_ERROR([No $tmp directory])
41 echo garbage-in > "$tmp/garbage-out"
51 AT_CHECK([test ! -f tmpdir])
52 AT_CHECK([ACTION=use ./config.status], [], [ignore])
53 AT_CHECK([test -s tmpdir && test ! -d "`cat tmpdir`"])
54 AT_CHECK([ACTION=corrupt ./config.status], [], [ignore])
55 AT_CHECK([test -s tmpdir && test ! -d "`cat tmpdir`"])
59 ## -------------------------- ##
60 ## Multiple AC_CONFIG_FILES. ##
61 ## -------------------------- ##
63 AT_SETUP([Multiple AC_CONFIG_FILES])
65 AT_CONFIGURE_AC([[AC_CONFIG_FILES([foo foo])]])
66 AT_CHECK_AUTOCONF([], 1, [], [ignore])
71 ## ------------------------------- ##
72 ## parameterized AC_CONFIG_FILES. ##
73 ## ------------------------------- ##
75 AT_SETUP([Parameterized AC_CONFIG_FILES])
80 AC_CONFIG_FILES([$files])]])
81 AT_CHECK_AUTOCONF([], [], [], [ignore])
82 touch foo.in bar.in config.hin
93 # AT_CHECK_AC_ARG_VAR(FIRST-VALUE, SECOND-VALUE, [STATUS = 1])
94 # ------------------------------------------------------------
95 # Check that AC_ARG_VAR caches the latest values, diagnoses
96 # inconsistencies, and arms config.status. Check that recheck
97 # returns STATUS, save configure output in files 'stdout' and 'stderr'
98 # for further inspection.
99 m4_define([AT_CHECK_AC_ARG_VAR],
104 [precious='m4_bpatsubst([$1], [[']], ['\\''])'; export precious],
106 AT_CHECK_CONFIGURE([--config-cache -q])
107 AT_CHECK([cat file], [], [`$1'
110 # Testing --recheck: 1. have the environment 'forget' about PRECIOUS.
112 # 2. Rerun config.status to recreate 'file'.
113 AT_CHECK([./config.status --recheck], [], [ignore])
114 AT_CHECK([./config.status], [], [ignore])
115 # 3. Check that file contains the old value of PRECIOUS.
116 AT_CHECK([cat file], [], [`$1'
119 # Second value: we should issue an error here: the value
122 [precious='$2'; export precious],
124 AT_CHECK_CONFIGURE([--config-cache], [m4_default([$3], [1])], [stdout], [stderr])
126 ])# AT_CHECK_AC_ARG_VAR
129 AT_SETUP([AC_ARG_VAR])
131 # We don't want to run this test if this shell doesn't support
134 if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
141 AT_DATA([configure.ac],
143 AC_ARG_VAR([precious], [this variable costs a lot])
144 echo "precious:$precious"
152 AT_CHECK_AUTOCONF([], 0, [],
153 [[configure.ac:4: warning: AC_OUTPUT should be used without arguments.
154 configure.ac:4: You should run autoupdate.
157 # Set a precious variable
158 AT_CHECK_AC_ARG_VAR([], [apple of my eye])
160 # Unset a precious variable
161 AT_CHECK_AC_ARG_VAR([apple of my eye], [])
163 # Change a precious variable
164 AT_CHECK_AC_ARG_VAR([apple of my eye], [orange of my eye])
166 # Change a precious variable that contains braces
167 AT_CHECK_AC_ARG_VAR([apple of my {eye}], [orange of my eye])
169 # Change a precious variable that contains all kinds of fun
170 AT_CHECK_AC_ARG_VAR(['p r ec"iou$], [orange of my eye])
171 dnl restore font-lock: "
173 # Warn (but do not fail) about a whitespace-only change
174 AT_CHECK_AC_ARG_VAR([ apple of my eye ], [apple of my eye],
175 [0], ["has whitespace changes"])
176 mv stdout configure-output
177 AT_CHECK([grep "ignoring whitespace changes" stderr], [], [ignore])
178 AT_CHECK([grep "precious: apple" configure-output], [], [ignore])
185 ## ---------------------------------------------- ##
186 ## AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS. ##
187 ## ---------------------------------------------- ##
189 AT_SETUP([[AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS]])
191 AT_DATA([configure.ac],
194 rm -f -r header var-header file var-file link var-link command var-command
197 # Be sure to also stress the associated INIT-CMDS.
198 case $what_to_test in
200 AC_CONFIG_HEADERS(header:input);;
202 AC_CONFIG_HEADERS(var-header:$header_in, [], [header_in=input]);;
205 AC_CONFIG_FILES(file:input);;
207 AC_CONFIG_FILES(var-file:$file_in, [], [file_in=input]);;
210 AC_CONFIG_COMMANDS(command,
211 [cp input command]);;
213 AC_CONFIG_COMMANDS(var-command,
214 [cp $command_in var-command], [command_in=input]);;
217 AC_CONFIG_LINKS(link:input);;
219 AC_CONFIG_LINKS(var-link:$link_in, [], [link_in=input]);;
227 # AT_CHECK_CONFIG_CREATION(THING = (header | link | file | command))
228 # ------------------------------------------------------------------
229 # Check that THING and var-THING (which uses variables in AC_CONFIG_THING)
230 # are properly created, with the right content.
231 # Use 'grep OK' instead of a simple 'cat' to avoid banners such as in
233 m4_define([AT_CHECK_CONFIG_CREATION],
234 [AT_CHECK_CONFIGURE([what_to_test=$1])
235 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
238 AT_CHECK([grep OK $1], [], [OK
241 AT_CHECK_CONFIGURE([what_to_test=var-$1 --no-create])
242 # config.status might be stupidly expecting data on stdin, if it's
244 AT_CHECK([./config.status var-$1 </dev/null], [], [ignore])
245 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
248 AT_CHECK([grep OK var-$1], [], [OK
250 ])# AT_CHECK_CONFIG_CREATION
253 # AT_CHECK_CONFIG_CREATION_NOWRITE(THING = (header | link | file | command))
254 # --------------------------------------------------------------------------
255 # Check that THING and var-THING (which uses variables in AC_CONFIG_THING)
256 # are properly created, with the right content.
257 # Use 'grep OK' instead of a simple 'cat' to avoid banners such as in
259 m4_define([AT_CHECK_CONFIG_CREATION_NOWRITE],
260 [AT_CHECK_CONFIGURE([what_to_test=$1])
261 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
264 AT_CHECK([grep OK $1], [], [OK
267 AT_CHECK_CONFIGURE([what_to_test=var-$1 --no-create])
268 # config.status might be stupidly expecting data on stdin, if it's
270 # Skip check if user can rename files into a read-only directory (when
271 # run by root or on w32).
274 mv t t1 >/dev/null 2>&1 \
275 || AT_CHECK([./config.status var-$1 </dev/null || exit 1],
276 [1], [ignore], [ignore])
279 ])# AT_CHECK_CONFIG_CREATION_NOWRITE
283 AT_CHECK_CONFIG_CREATION(file)
286 AT_CHECK_CONFIG_CREATION(header)
289 AT_CHECK_CONFIG_CREATION(command)
292 AT_CHECK_CONFIG_CREATION(link)
294 # Now check for write errors.
295 # Depending on the shell, 'printf' might or might not report write
296 # errors on stdout. Check /bin/sh regardless of $SHELL, because
297 # config.status always uses /bin/sh.
298 # Note: another way to force a write error is with ulimit -f, but
299 # depending on the OS it might not be possible to set that limit
300 # lower than one disk block, so we'd have to make the tests below
301 # produce much more output.
302 test_write_errors=false
303 if test -w /dev/full && test -c /dev/full; then
304 if /bin/sh -c 'printf "write errors detected?\\n"' > /dev/full 2> /dev/null
306 else test_write_errors=:
311 AT_CHECK_CONFIG_CREATION_NOWRITE(file)
312 # Create a file with bits from stdin
313 AT_CHECK([echo from-stdin | ./config.status --file=file:-],
315 AT_CHECK([grep from-stdin file], [], [from-stdin
317 # Force write error creating a file on stdout
318 if $test_write_errors; then
319 AT_CHECK([./config.status --file=-:input </dev/null >/dev/full || exit 1],
320 [1], [ignore], [ignore])
323 # Validate that --file requires an argument
324 AT_CHECK([./config.status --file], [1], [ignore], [stderr])
325 AT_CHECK([grep 'missing file argument' stderr], [0], [ignore])
326 AT_CHECK([./config.status --file=], [1], [ignore], [stderr])
327 AT_CHECK([grep 'missing file argument' stderr], [0], [ignore])
330 AT_CHECK_CONFIG_CREATION_NOWRITE(header)
331 # Create a header on stdout
332 AT_CHECK([./config.status --header=-:input </dev/null],
333 [0], [stdout], [ignore])
334 AT_CHECK([grep OK stdout], [], [OK
336 # Force write error creating a header on stdout
337 if $test_write_errors; then
338 AT_CHECK([./config.status --header=-:input </dev/null >/dev/full || exit 1],
339 [1], [ignore], [ignore])
343 AT_CHECK_CONFIG_CREATION_NOWRITE(command)
346 AT_CHECK_CONFIG_CREATION_NOWRITE(link)
348 # Check that no use of 'ac_write_fail' escaped into config.status
349 AT_CHECK([grep ac_write_fail config.status], [1])
351 # Check that --file and --header accept funny file names
355 ./config.status --file=fgrep:fgrep.in
361 'with funny '\'' $x & #! name' \
362 'file with funny \ '\'' \'\'' $ & #!*? name' \
363 'with funny \ '\'' \'\'' " | <a >b & * ? name ' # "restore font-lock
365 # The function func_sanitize_file_name comes from tools.at
366 file=`func_sanitize_file_name "$file"`
367 cat >"$file.in" <<'END'
370 AT_CHECK([./config.status "--file=$file:$file.in"],
372 AT_CHECK([$FGREP "$file" "$file"], [0], [ignore])
373 AT_CHECK([./config.status "--header=$file:$file.in"],
375 # Run the same test a 2nd time to see that config.status does not recreate
376 # the header (regression test)
377 AT_CHECK_UNQUOTED([./config.status "--header=$file:$file.in"],
378 [0], [config.status: creating $file
379 config.status: $file is unchanged
381 AT_CHECK_UNQUOTED([grep ' & ' "$file"], [],
382 [/* $file. Generated from $file.in by configure. */
384 AT_CHECK([$FGREP "$file" "$file"], [0], [ignore])
390 ## ---------------------------------------- ##
391 ## Macro calls in AC_CONFIG_COMMANDS tags. ##
392 ## ---------------------------------------- ##
394 AT_SETUP([Macro calls in AC_CONFIG_COMMANDS tags])
396 AT_DATA_M4SUGAR([configure.ac],
398 AC_CONFIG_COMMANDS([m4_if(1,1,mytag)])
409 ## ------------------- ##
410 ## Missing templates. ##
411 ## ------------------- ##
413 # Check that config.status detects missing input files
414 AT_SETUP([Missing templates])
416 AT_DATA([configure.ac],
418 AC_CONFIG_FILES([nonexistent])
424 AT_CAPTURE_FILE([build/config.log])[]dnl
426 AT_CHECK([../configure], [1], [ignore],
427 [[config.status: error: cannot find input file: 'nonexistent.in'
429 # Make sure that the output file doesn't exist
430 AT_CHECK([test -f nonexistent], 1)
432 AT_CHECK_CONFIGURE([], [1], [],
433 [[config.status: error: cannot find input file: 'nonexistent.in'
435 # Make sure that the output file doesn't exist
436 AT_CHECK([test -f nonexistent], 1)
443 ## ---------------------- ##
444 ## configure invocation. ##
445 ## ---------------------- ##
447 # Check that 'configure' and 'config.status' honor their interface.
449 # We run './configure one=val1 --enable-two=val2 --with-three=val3'
450 # and verify that (i) 'configure' correctly receives the arguments,
451 # (ii) correctly passes them to 'config.status', which we check by
452 # running 'config.status --recheck', (iii) correctly passes them
453 # to sub-configure scripts, and (iv) correctly reproduces them with
454 # 'config.status --config'.
456 AT_SETUP([configure invocation])
460 AT_DATA([configure.ac],
462 AC_CONFIG_SUBDIRS([sub])
463 echo "result=$one$enable_two$with_three"
467 AT_DATA([sub/configure.ac],
469 echo "result=$one$enable_two$with_three"
473 echo fake install-sh script >install-sh
480 AT_CHECK_CONFIGURE([one=one --enable-two=two --with-three=three |
481 sed -n -e 's/^result=//p'], 0,
485 AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
488 AT_CHECK([args=`./config.status --config` && eval ./configure \$configure_options "$args" |
489 sed -n -e 's/^result=//p'], 0,
494 AT_CHECK_CONFIGURE([one="\"'$ " --enable-two="\" ' $" --with-three=" \"'$"|
495 sed -n -e 's/^result=//p'], 0,
496 [m4_do(["'$ " ' $ "'$
499 AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
502 dnl restore font-lock: "
503 AT_CHECK([args=`./config.status --config` && eval ./configure \$configure_options "$args" |
504 sed -n -e 's/^result=//p'], 0,
505 [m4_do(["'$ " ' $ "'$
513 ## ---------------------- ##
514 ## --help and --version. ##
515 ## ---------------------- ##
517 AT_SETUP([--help and --version in unwritable directory])
520 AT_DATA([inner/configure.ac],
525 AT_CHECK_M4([(cd inner && autoconf --force)])
526 AT_CHECK([test -s inner/configure])
527 if test "$SHELL_N" != none; then
528 AT_CHECK_SHELL_SYNTAX([inner/configure])
532 AT_CHECK([(cd inner && ./configure --help)], 0, [ignore], [ignore])
533 AT_CHECK([(cd inner && ./configure --version)], 0, [ignore], [ignore])
540 ## -------------------------------------------- ##
541 ## Check that '#define' templates are honored. ##
542 ## -------------------------------------------- ##
544 # Use various forms of '#define' templates, and make sure there are no
545 # problems when a symbol is prefix of another.
547 AT_SETUP([@%:@define header templates])
548 AT_KEYWORDS([AC@&t@_DEFINE])
550 AT_DATA([configure.ac],
552 AC_CONFIG_HEADERS(config.h:config.hin)
554 # I18n of dummy variables: their French translations.
558 AC_DEFINE(fubar, tutu)
560 # Symbols which are prefixes of another.
565 # backslash-newline combinations
566 AC_DEFINE([multiline], [line1\
570 AC_DEFINE([multiline_args(ARG1, ARG2)], [ARG2 \
572 AC_CONFIG_FILES(defs)
575 AC_DEFINE([paste(a,b)], [a##b])
577 # Things included in confdefs.h, but which make no sense in
578 # config.h, nor in $DEFS.
579 cat <<\EOF >>confdefs.h
580 /* Hi Mum! Look, I am doing C++! */
582 void exit (int status);
586 # In addition of config.h output a full DEFS
597 AT_DATA([config.hin],
600 # define baz "Archimedes was sinking in his baz"
608 #define aaa(a, aa) aa a
610 #define aaac(a, aa) aa a
612 # undef multiline_args
613 #define paste(a,b) a##b
615 #define str(define) \
617 #define stringify(arg) str(arg)
618 #undef aaa /* with comments */
619 #undef not_substed /* with comments */
626 [[/* config.h. Generated from config.hin by configure. */
639 #define aaac(a, aa) aa a
640 #define multiline line1\
644 # define multiline_args(ARG1, ARG2) ARG2 \
646 #define paste(a,b) a##b
648 #define str(define) \
650 #define stringify(arg) str(arg)
652 /* #undef not_substed */
654 AT_CHECK([cat config.h], 0, expout)
656 # Check the value of DEFS.
658 [[-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
661 # Because we strip trailing spaces in 'testsuite' we can't leave one in
662 # expout, hence nuke the one left by AC_OUTPUT_MAKE_DEFS.
663 AT_CHECK([sed -e 's/ $//' defs], 0, expout)
669 ## ------------------------- ##
670 ## Torturing config.status. ##
671 ## ------------------------- ##
673 ## Require 100 AC_DEFINE and AC_SUBST and AC_SUBST_FILE with a significantly
674 ## big value. This is mostly to check that Autoconf produces portable sed
675 ## scripts in config.status. sed is used to skip the first two lines
676 ## 'Generated by ...'.
678 # We use m4_for many times.
679 m4_pattern_allow([^m4_for$])
681 AT_SETUP([Torturing config.status])
683 dnl The value used as a big value for AC_DEFINE.
684 dnl Don't use sh active chars here, below it is also used in a sh
686 m4_define([AT_BIG_VALUE],
687 [This value should be long enough to torture the various limits of sed and other tools used by Autoconf.])
689 m4_define([AT_DESCRIPTION],
690 [Define to a long string if your 'Autoconf' works properly.])
693 # AT_DUMMY_VAR(NUMBER)
694 # --------------------
695 # Build a name used for AC_SUBST and AC_DEFINE. Put ac_ in it
696 # so that the check for user name space invasion does not complain
697 # of the new variables defined.
699 # Note that you should not use the name ac_dummy, because it will be
700 # turned into ac_uummy during the construction of config.status. Yes,
701 # this is admittedly a bug, but it would be too hard to fix this.
702 # There is really no point in AC_DEFINE a var named ac_d.*.
703 m4_pattern_allow([^m4_bpatsubst$])
704 m4_define([AT_DUMMY_VAR],
705 [ac_Dummy_[]m4_bpatsubst([000$1], [.*\(...\)$], [\1])])
710 [m4_for([AT_Count], 1, 100, 1,
711 [@AT_DUMMY_VAR(AT_Count)@
717 while test $i != 101; do
718 echo "content of file $i" > file_$i
719 AS_VAR_ARITH([i], [$i + 1])
727 m4_pattern_allow([^m4_(define|defun)$])
728 AT_DATA([configure.ac],
729 dnl The following lines transfer AT_DUMMY_VAR, AT_DESCRIPTION, and
730 dnl AT_BIG_VALUE into the configure.ac as AC_DUMMY_VAR etc.
731 [[m4_define([AC_DUMMY_VAR],]
732 m4_dquote(m4_defn([AT_DUMMY_VAR]))[)]]
734 [[m4_define([AC_DESCRIPTION],]
735 m4_dquote(m4_defn([AT_DESCRIPTION]))[)]]
737 [[m4_define([AC_BIG_VALUE],]
738 m4_dquote(m4_defn([AT_BIG_VALUE]))[)]]
742 # Related VALUE to NAME both with AC_SUBST and AC_DEFINE. This is
743 # used in the torture tests.
744 m4_defun([AC_DEFUBST],
745 [AC_DUMMY_VAR($1)="AC_BIG_VALUE"
746 AC_DEFINE_UNQUOTED(AC_DUMMY_VAR($1), "$AC_DUMMY_VAR($1) $AC_DUMMY_VAR($1)",
748 AC_SUBST(AC_DUMMY_VAR($1))
754 AC_CONFIG_HEADERS(config.h:config.hin)
755 AC_CONFIG_FILES(dummy)
756 m4_for(AC_Count, 1, 100, 1,
757 [AC_DEFUBST(AC_Count)])
763 AT_CHECK_AUTOHEADER([],
764 m4_for(AT_Count, 1, 100, 1, [ AT_DUMMY_VAR(AT_Count)]))
766 # Check both awk and the result of AC_PROG_AWK.
767 # Quote the first word in the for list for Solaris sh.
768 for awk_arg in "FOO=" AWK=awk; do
769 AT_CHECK_CONFIGURE([$awk_arg])
771 # Checking that AC_DEFINE worked properly.
773 [/* Define to the address where bug reports for this package should be sent. */
774 #define PACKAGE_BUGREPORT ""
776 /* Define to the full name of this package. */
777 #define PACKAGE_NAME ""
779 /* Define to the full name and version of this package. */
780 #define PACKAGE_STRING ""
782 /* Define to the one symbol short name of this package. */
783 #define PACKAGE_TARNAME ""
785 /* Define to the home page for this package. */
786 #define PACKAGE_URL ""
788 /* Define to the version of this package. */
789 #define PACKAGE_VERSION ""
790 m4_for(AT_Count, 1, 100, 1,
793 [#define] AT_DUMMY_VAR(AT_Count) "AT_BIG_VALUE AT_BIG_VALUE"
796 AT_CHECK([sed -n '4,$ p' config.h], 0, expout)
798 # Checking that AC_SUBST worked properly.
800 [m4_for(AT_Count, 1, 100, 1,
802 content of file AT_Count
805 AT_CHECK([cat dummy], 0, expout)
811 ## ------------------------------- ##
812 ## Substitute a 2000-byte string. ##
813 ## ------------------------------- ##
815 # Solaris 9 /usr/ucb/sed that rejects commands longer than 4000 bytes. HP/UX
816 # sed dumps core around 8 KiB. However, POSIX says that sed need not
817 # handle lines longer than 2048 bytes (including the trailing newline).
818 # So we'll just test a 2000-byte value, and for awk, we test a line with
819 # almost 1000 words, and one variable with 5 lines of 2000 bytes each:
820 # multi-line values should allow to get around the limitations.
821 # We also test runs of around 148 backslashes: they need to be escaped,
822 # and 148 is the portable limit for awk string literals. config.status
823 # uses concatenation to generate longer strings.
825 AT_SETUP([Substitute a 2000-byte string])
827 AT_DATA([Foo.in], [@foo@
829 AT_DATA([Bar.in], [@bar@
831 AT_DATA([Baz.in], [@baz@
833 AT_DATA([Boo.in], [@b147@
841 AT_DATA([configure.ac],
843 AC_SUBST([foo], ]m4_for([n], 1, 100,, ....................)[)
844 AC_SUBST([bar], "]m4_for([n], 1, 100,, @ @ @ @ @ @ @ @ @ @@)[")
845 baz="]m4_for([m], 1, 100,, ... ... ... ... ....)[
847 baz=$baz$baz$baz$baz$baz
849 b29='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
850 b147=$b29$b29$b29$b29$b29'\\'
863 AC_CONFIG_FILES([Foo Bar Baz Boo])
867 cp "$abs_top_srcdir/build-aux/install-sh" .
869 b29='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
870 b147=$b29$b29$b29$b29$b29'\\'
882 # Check both awk and the result of AC_PROG_AWK
883 # Quote the first word in the for list for Solaris sh.
884 for awk_arg in "Foo=" AWK=awk; do
885 AT_CHECK_CONFIGURE([$awk_arg])
886 AT_CHECK([cat Foo], 0, m4_for([n], 1, 100,, ....................)
888 AT_CHECK([cat Bar], 0, m4_for([n], 1, 100,, @ @ @ @ @ @ @ @ @ @@)
891 [m4_for([n], 1, 5,, m4_for([m], 1, 100,, ... ... ... ... ....)
893 AT_CHECK([cat Baz], 0, [stdout])
894 AT_CHECK([diff Boo-exp Boo])
899 ## ------------------------------ ##
900 ## Define to a 2000-byte string. ##
901 ## ------------------------------ ##
903 AT_SETUP([Define to a 2000-byte string])
904 AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
908 AC_DEFINE_UNQUOTED([foo], ]m4_for([n], 1, 100,, ....................)[, [desc])
909 AC_DEFINE([fooq], ]m4_for([n], 1, 100,, ....................)[, [desc])
913 AT_CHECK_AUTOHEADER([], [foo fooq])
915 AT_CHECK_DEFINES([@%:@define foo m4_for([n], 1, 100,, ....................)
916 @%:@define fooq m4_for([n], 1, 100,, ....................)
921 ## ------------------------------------------ ##
922 ## Substitute and define special characters. ##
923 ## ------------------------------------------ ##
925 # Use characters special to the shell, sed, awk, and M4.
927 AT_SETUP([Substitute and define special characters])
928 AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
930 AT_XFAIL_IF([byte=\\200s; dnl
931 test `{ printf $byte; echo; } | sed -n '/^./p' | wc -l` = 0])
933 AT_DATA([Foo.in], [@foo@
934 @bar@@notsubsted@@baz@ stray @ and more@@@baz@
951 AT_DATA([Zardoz.in], [@zardoz@
955 [[foo="AS@&t@_ESCAPE([[X*'[]+ ", & &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !]])"
959 ( for i in 0 1 2 3; do
960 for j in 0 1 2 3 4 5 6 7; do
961 for k in 0 1 2 3 4 5 6 7; do
963 000 | 015 | 377) ;; # MinGW awk dislikes 0xFF, and the test does
964 # the wrong thing for CR on MinGW.
966 *) printf \\$i$j$k's' ;; # The 's' works around a Solaris 8 /bin/bash bug.
973 zardoz=`cat allowed-chars`
979 AC_SUBST_FILE([file])
980 AC_DEFINE([fooq], [[X*'[]+ ", & &`\($foo !]], [Awful value.])
981 AC_DEFINE([barq], [[%!_!# X]], [Value that is used as special delimiter.])
982 AC_DEFINE_UNQUOTED([foo], [[X*'[]+ ", & &\`\\(\$foo !]], [Awful value.])
983 AC_DEFINE_UNQUOTED([bar], [[%!_!# X]], [Value that is used as special delimiter.])
984 AC_DEFINE_UNQUOTED([unq1], [$baz], [unquoted, test 1])
985 AC_DEFINE_UNQUOTED([unq2], [\$baz], [unquoted, test 2])
986 AC_DEFINE_UNQUOTED([unq3], ["$baz"], [unquoted, test 3])
987 AC_DEFINE_UNQUOTED([unq4], [${baz+set}], [unquoted, test 4])
988 AC_DEFINE_UNQUOTED([unq5], ["${baz+`echo "a "' b'`}"], [unquoted, test 5])
989 AC_DEFINE_UNQUOTED([unq6], [`echo hi`], [unquoted, test 6])
990 AC_DEFINE_UNQUOTED([unq7], ['\\"'], [unquoted, test 7])
992 AC_CONFIG_FILES([Foo Zardoz])]])
995 AT_CHECK_AUTOHEADER([],
996 [foo fooq bar barq unq1 unq2 unq2 unq3 unq4 unq5 unq6 unq7])
997 # Check both awk and the result of AC_PROG_AWK
998 # Quote the first word in the for list for Solaris sh.
999 for awk_arg in "FOO=" AWK=awk; do
1000 AT_CHECK_CONFIGURE([$awk_arg])
1001 AT_CHECK([cat Foo], 0, [[X*'[]+ ", & &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !
1002 @foo@ @baz@@notsubsted@bla stray @ and more@@bla
1003 abc@foo@ @baz@baz@baz
1004 abc@foo@ @baz@blabaz
1005 abc@foo@ @baz@blabaz@
1014 AT_CHECK([cmp allowed-chars Zardoz])
1015 AT_CHECK_DEFINES([[#define bar %!_!# X
1016 #define barq %!_!# X
1017 #define foo X*'[]+ ", & &`\($foo !
1018 #define fooq X*'[]+ ", & &`\($foo !
1031 ## ---------------------- ##
1032 ## Substitute a newline. ##
1033 ## ---------------------- ##
1035 AT_SETUP([Substitute a newline])
1042 AT_DATA([configure.ac],
1050 AC_CONFIG_FILES([Foo])
1055 cp "$abs_top_srcdir/build-aux/install-sh" .
1063 # Check both awk and the result of AC_PROG_AWK
1064 # Quote the first word in the for list for Solaris sh.
1065 for awk_arg in "FOO=" AWK=awk; do
1066 AT_CHECK_CONFIGURE([$awk_arg])
1067 AT_CHECK([cat Foo], 0, [expout])
1072 ## ------------------ ##
1073 ## Define a newline. ##
1074 ## ------------------ ##
1076 AT_SETUP([Define a newline])
1077 AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
1078 AT_CONFIGURE_AC([[AC_DEFINE([foo], [one
1079 two], [This spans two lines.])
1081 AT_CHECK_AUTOCONF([], [], [], [stderr])
1082 dnl Older versions of m4 report error at line 5 (end of macro);
1083 dnl newer versions report it at line 4 (start of macro).
1084 AT_CHECK([[sed '/trailer\.m4:/d; s/^configure\.ac:[45]: //' stderr]], [],
1085 [[warning: AC_DEFINE: 'one
1086 two' is not a valid preprocessor define value
1088 AT_CHECK_AUTOHEADER([], [foo])
1090 AT_CHECK_DEFINES([[#define foo one
1093 rm -rf autom4te.cache
1095 AT_CONFIGURE_AC([[AC_DEFINE_UNQUOTED([foo], [one
1096 two], [This spans two lines.])
1098 AT_CHECK_AUTOCONF([], [], [], [stderr])
1099 AT_CHECK([[sed '/trailer.m4:/d; s/^configure\.ac:[45]: //' stderr]], [],
1100 [[warning: AC_DEFINE_UNQUOTED: 'one
1101 two' is not a valid preprocessor define value
1103 AT_CHECK_AUTOHEADER([], [foo])
1105 AT_CHECK_DEFINES([[#define foo one
1111 ## ------------------------------------ ##
1112 ## AC_SUBST: variable name validation. ##
1113 ## ------------------------------------ ##
1115 AT_SETUP([AC_SUBST: variable name validation])
1117 AT_CONFIGURE_AC([[AC_SUBST(, [])
1118 AC_CONFIG_FILES([Makefile])
1120 AT_DATA([Makefile.in], [[
1122 mv -f configure.ac configure.tmpl
1125 for var in ['' ab\~ ab\( ab[] ab\' ab\" ab\\\\]; do
1126 sed ["s/AC_SUBST(/&[$var]/"] <configure.tmpl >configure.ac
1127 AT_CHECK_AUTOCONF([], [1], [], [ignore])
1131 for var in ab a4 'a@@&t@\&t@b'; do
1132 sed ["s/AC_SUBST(/&[$var]/"] <configure.tmpl >configure.ac
1141 ## ------------------------ ##
1142 ## datarootdir workaround. ##
1143 ## ------------------------ ##
1145 AT_SETUP([datarootdir workaround])
1159 AT_DATA([configure.ac],
1161 d@&t@nl The following line silences the warnings, if uncommented:
1162 d@&t@nl AC_DEFUN([AC_DATAROOTDIR_CHECKED])
1164 # This substitution is wrong and bogus! Don't use it in your own code!
1165 # Read 'info Autoconf "Defining Directories"'!
1166 AC_SUBST([mydatadir], [${datadir}/my])
1168 AC_CONFIG_FILES([Foo Bar])
1172 cp "$abs_top_srcdir/build-aux/install-sh" .
1175 AT_CHECK_CONFIGURE([], [], [],
1176 [config.status: WARNING: 'Foo.in' seems to ignore the --datarootdir setting
1177 config.status: WARNING: Bar contains a reference to the variable 'datarootdir'
1178 which seems to be undefined. Please make sure it is defined
1180 AT_CHECK([grep datarootdir Foo], 1, [])
1183 sed '/AC_DEFUN/s/^d@&t@nl //' configure.ac >t
1203 AT_DATA([configure.ac],
1206 AC_CONFIG_FILES([foo at-dir/bar])
1208 # Use quotes in the INIT-COMMANDS to accommodate a value of $srcdir
1209 # containing e.g., spaces or shell meta-characters.
1210 # Use *single* quotes because the context is an unquoted here-doc.
1211 AC_CONFIG_COMMANDS([report],
1212 [test -f "$srcdir/configure.ac" ||
1213 AC_MSG_ERROR([cannot find $srcdir/configure.ac])],
1217 rm -f -r foo at-dir/bar
1223 AT_CHECK([./configure $configure_options], [], [ignore])
1226 AT_CHECK([cd at-dir && ../configure $configure_options], [], [ignore])
1230 AT_CHECK([cd at-dir && "$at_here/configure" $configure_options], [], [ignore])
1241 dirs='at paren brace space'
1242 for dir in $dirs; do
1243 mkdir $dir $dir/s1 $dir/s2
1244 touch $dir/f $dir/s1/f1 $dir/s2/f2
1247 AT_DATA([configure.ac],
1249 AC_CONFIG_FILES([at/Makefile paren/Makefile brace/Makefile space/Makefile])
1253 AT_DATA([at/Makefile.in],
1254 [[# This is what you should use in order to be portable to old makes.
1256 VPATH = @srcdir@/s1:@srcdir@:@srcdir@/s2
1261 AT_DATA([paren/Makefile.in],
1262 [[# This works with some makes but not with old ones.
1264 VPATH = $(srcdir)/s1:$(srcdir):$(srcdir)/s2
1269 AT_DATA([brace/Makefile.in],
1270 [[# This works with some makes but not with old ones.
1272 VPATH = ${srcdir}/s1:${srcdir}:${srcdir}/s2
1277 AT_DATA([space/Makefile.in],
1278 [[# This fails with FreeBSD make, for example.
1280 VPATH = @srcdir@/s1 @srcdir@ @srcdir@/s2
1288 AT_CHECK([./configure $configure_options], [], [ignore])
1289 # Treat BSD make separately, afterwards, for maximal coverage.
1290 dirs='at paren brace'
1291 for dir in $dirs; do
1292 AT_CHECK_MAKE([], [$dir])
1296 mkdir build absbuild
1299 AT_CHECK([cd build && ../configure $configure_options], [], [ignore])
1300 for dir in $dirs; do
1301 AT_CHECK_MAKE([], [build/$dir])
1306 AT_CHECK([cd absbuild && "$at_here/configure" $configure_options], [], [ignore])
1307 for dir in $dirs; do
1308 AT_CHECK_MAKE([], [absbuild/$dir])
1311 # These will not pass with BSD make.
1312 AT_CHECK_MAKE([|| exit 77], [space])
1313 AT_CHECK_MAKE([], [build/space])
1314 AT_CHECK_MAKE([], [absbuild/space])
1320 ## ----------------- ##
1321 ## Signal handling. ##
1322 ## ----------------- ##
1324 AT_SETUP([Signal handling])
1326 AT_DATA([configure.ac],
1334 AT_CHECK_CONFIGURE([], [1], [ignore], [ignore])
1339 ## ----------------- ##
1340 ## AC_CONFIG_LINKS. ##
1341 ## ----------------- ##
1343 AT_SETUP([AC_CONFIG_LINKS])
1345 AT_DATA([configure.ac],
1346 [[AC_INIT([config links to config files test], [1.0])
1347 AC_CONFIG_SRCDIR([sub1/file1.in])
1348 AC_CONFIG_FILES([sub1/file1 file2])
1349 AC_CONFIG_LINKS([file1:sub1/file1 sub2/file2:file2])
1355 AT_DATA([sub1/file1.in],
1356 [[/* @configure_input@ */
1357 #define PACKAGE_STRING "@PACKAGE_STRING@"
1361 [[/* @configure_input@ */
1362 #define PACKAGE_STRING "@PACKAGE_STRING@"
1368 AT_CHECK([../configure && ../configure], 0, [ignore])
1369 AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
1371 AT_CHECK([../configure && ../configure], 0, [ignore])
1372 AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
1379 AT_CHECK(["$cwd"/../configure && "$cwd"/../configure], 0, [ignore])
1380 AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
1383 AT_CHECK([./configure && ./configure], 0, [ignore], [stderr])
1384 AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
1387 AT_CHECK(["$cwd"/configure && "$cwd"/configure], 0, [ignore], [ignore])
1388 AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
1394 ## ------------------------------------- ##
1395 ## AC_CONFIG_LINKS and identical files. ##
1396 ## ------------------------------------- ##
1397 AT_SETUP([AC_CONFIG_LINKS and identical files])
1399 AT_DATA([configure.ac],
1401 AC_CONFIG_LINKS([src/s:src/s])
1402 test "$srcdir" != '.' && AC_CONFIG_LINKS([src/t:src/t])
1411 AT_CHECK([../configure $configure_options && ../configure $configure_options],
1413 AT_CHECK([cat src/s src/t], 0, [file1
1422 AT_CHECK(["$cwd"/../configure], 0, [ignore])
1423 AT_CHECK([cat src/s src/t], 0, [file1
1426 AT_CHECK(["$cwd"/../configure], 0, [ignore])
1427 AT_CHECK([cat src/s src/t], 0, [file1
1431 AT_CHECK([./configure $configure_options && ./configure $configure_options],
1432 0, [ignore], [stderr])
1433 AT_CHECK([grep src/t stderr], 1)
1434 AT_CHECK([cat src/s src/t], 0, [file1
1438 AT_CHECK(["$cwd"/configure && "$cwd"/configure], 0, [ignore], [ignore])
1439 AT_CHECK([cat src/s src/t], 0, [file1
1446 AT_BANNER([autoreconf.])
1448 ## ---------------------------- ##
1449 ## Configuring subdirectories. ##
1450 ## ---------------------------- ##
1455 # | |-- config.status
1458 # | |-- config.status
1465 # | |-- configure.ac
1470 AT_SETUP([Configuring subdirectories])
1471 AT_KEYWORDS(autoreconf)
1475 # The contents of 'inner/', and 'inner/innermost/'.
1476 AS_MKDIR_P([inner/innermost])
1478 AT_DATA([inner/configure.ac],
1479 [[AC_INIT(GNU Inner, 1.0)
1480 AC_CONFIG_SRCDIR([innermost/config.in])
1481 AC_ARG_VAR([INNER], [an inner variable])
1483 if test "x$INNER" = x; then
1486 AC_CONFIG_FILES([innermost/config])
1490 AT_DATA([inner/innermost/config.in],
1493 top_srcdir=@top_srcdir@
1497 # The contents of '.'
1498 AT_DATA([install-sh], [])
1500 # nonexistent is allowed not to exist.
1501 AT_DATA([configure.ac],
1502 [[AC_INIT(GNU Outer, 1.0)
1503 AC_ARG_VAR([OUTER], [an outer variable])
1505 AC_CONFIG_SUBDIRS([nonexistent])
1507 AC_CONFIG_SUBDIRS([inner])
1511 AT_CHECK([autoreconf])
1512 AT_CHECK([test -f inner/configure])
1514 # Running the outer configure recursively should provide the innermost
1516 chmod a-w inner/innermost inner .
1517 AT_CHECK([{ ./configure $configure_options --help=recursive; chmod u+w .; } | grep INNER], 0,
1519 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1520 chmod u+w . inner inner/innermost
1522 # Running the outer configure should trigger the inner.
1524 AT_CHECK([cat inner/innermost/config], 0,
1531 # The same, but from a builddir.
1532 AS_MKDIR_P([builddir])
1533 AT_CHECK([cd builddir && ../configure $configure_options], 0, [ignore])
1534 AT_CHECK([cat builddir/inner/innermost/config], 0,
1536 srcdir=../../../inner/innermost
1537 top_srcdir=../../../inner
1541 # Make sure precious variables and command line options are properly
1542 # passed, even when there are duplicates.
1543 AT_CHECK([cd builddir && ../configure $configure_options --prefix /bad --prefix /good INNER=bad INNER=good],
1545 AT_CHECK([cat builddir/inner/innermost/config], 0,
1547 srcdir=../../../inner/innermost
1548 top_srcdir=../../../inner
1552 # Make sure --prefix is properly quoted
1553 AT_CHECK([cd builddir && ../configure --prefix "/a b c$ 'd"], 0, [ignore])
1554 AT_CHECK([cat builddir/inner/innermost/config], 0,
1556 srcdir=../../../inner/innermost
1557 top_srcdir=../../../inner
1561 # Make sure --silent is properly passed...
1562 AT_CHECK([cd builddir && ../configure $configure_options --silent], 0, [])
1563 # ...but not stored in config.status.
1564 AT_CHECK([cd builddir && ./config.status --recheck], 0, [stdout])
1565 AT_CHECK([grep 'creating \./config.status' stdout], 0, [ignore])
1567 # --cache-file is adjusted for subdirectories, so the cache is shared.
1568 AT_CHECK([cd builddir && ../configure $configure_options --config-cache],
1570 AT_CHECK([grep 'loading .*\.\./config.cache' stdout], [], [ignore])
1572 # Make sure we can run autoreconf on a subdirectory
1573 rm -f configure configure.ac
1574 AT_CHECK([autoreconf inner], [], [], [ignore])
1576 # Make sure we can pass a configure.ac name
1577 AT_CHECK([cd inner && autoreconf configure.ac], [], [], [ignore])
1578 AT_CHECK([autoreconf inner/configure.ac], [], [], [ignore])
1584 ## -------------- ##
1586 ## -------------- ##
1588 AT_SETUP([Deep Package])
1589 AT_KEYWORDS(autoreconf)
1593 # The contents of '.'
1594 AT_DATA([install-sh], [])
1595 AT_DATA([configure.ac],
1596 [[AC_INIT(GNU Outer, 1.0)
1597 AC_ARG_VAR([OUTER], [an outer variable])
1605 # The contents of 'inner/', and 'inner/innermost/'.
1606 AS_MKDIR_P([inner/innermost])
1607 AS_MKDIR_P([inner2])
1609 AT_DATA([inner/configure.ac],
1610 [[AC_INIT(GNU Inner, 1.0)
1611 AC_ARG_VAR([INNER], [an inner variable])
1612 AC_CONFIG_SUBDIRS(innermost)
1616 AT_DATA([inner/innermost/configure.ac],
1617 [[AC_INIT(GNU Innermost, 1.0)
1618 AC_ARG_VAR([INNERMOST], [an innermost variable])
1619 AC_CONFIG_HEADERS(config.h:config.hin)
1620 AC_DEFINE_UNQUOTED([INNERMOST], [$INNERMOST], [an innermost variable])
1621 if test -n "$innermost_error"; then
1622 AC_MSG_FAILURE([error in $PACKAGE_NAME])
1627 AT_DATA([inner2/configure.ac],
1628 [[AC_INIT(GNU Inner 2, 1.0)
1629 AC_ARG_VAR([INNER2], [an inner2 variable])
1633 AT_CHECK([autoreconf -Wall], [0], [ignore])
1634 AT_CHECK([test -f inner/configure])
1635 AT_CHECK([test -f inner/innermost/configure])
1636 AT_CHECK([test -f inner/innermost/config.hin])
1637 AT_CHECK([test -f inner2/configure])
1639 # Running the outer configure recursively should provide the innermost
1641 chmod a-w inner/innermost inner
1642 AT_CHECK([{ ./configure $configure_options --help=recursive; chmod u+w .; } | grep " INNER "],
1643 0, [ignore], [stderr],
1644 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1646 AT_CHECK([{ ./configure $configure_options --help=recursive; chmod u+w .; } | grep " INNER2 "],
1647 0, [ignore], [stderr],
1648 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1650 AT_CHECK([{ ./configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1651 0, [ignore], [stderr],
1652 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1654 AT_CHECK([{ /bin/sh ./configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1655 0, [ignore], [stderr],
1656 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1658 AT_CHECK([PATH=.$PATH_SEPARATOR$PATH; export PATH; { /bin/sh configure $configure_options --help=recursive; chmod +w .; } | grep " INNERMOST "],
1659 0, [ignore], [stderr],
1660 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1662 AT_CHECK([PATH=.$PATH_SEPARATOR$PATH; export PATH; { configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1663 0, [ignore], [stderr],
1664 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1665 chmod u+w inner inner/innermost
1667 # Running the outer configure should trigger the inner.
1668 AT_CHECK_CONFIGURE([INNERMOST=tsomrenni])
1669 AT_CHECK([grep INNERMOST inner/innermost/config.h], 0,
1670 [[#define INNERMOST tsomrenni
1673 # Ensure we point to the right config.log file for errors.
1674 AT_CHECK_CONFIGURE([innermost_error=:], [1], [], [stderr])
1675 AT_CHECK([grep 'inner/innermost' stderr], [], [ignore])
1677 AT_CHECK_CONFIGURE([innermost_error=:], [1], [], [stderr])
1678 AT_CHECK([grep 'innermost' stderr], [], [ignore])
1681 # The same, but from a builddir.
1682 AS_MKDIR_P([builddir])
1683 chmod a-w builddir inner/innermost inner
1684 AT_CHECK([cd builddir && { ../configure $configure_options --help=recursive; chmod u+w .; } | grep " INNER "],
1685 0, [ignore], [stderr],
1686 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1688 AT_CHECK([cd builddir && { ../configure $configure_options --help=recursive; chmod u+w .; } | grep " INNER2 "],
1689 0, [ignore], [stderr],
1690 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1692 AT_CHECK([cd builddir && { ../configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1693 0, [ignore], [stderr],
1694 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1696 AT_CHECK([cd builddir && { /bin/sh ../configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1697 0, [ignore], [stderr],
1698 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1700 # Not all shells search $PATH for scripts.
1701 if (cd builddir && PATH=`pwd`/..$PATH_SEPARATOR$PATH /bin/sh configure $configure_options --help) >/dev/null 2>&1; then
1702 AT_CHECK([cd builddir && PATH=`pwd`/..$PATH_SEPARATOR$PATH /bin/sh configure $configure_options --help=recursive | grep " INNERMOST "], 0, [ignore])
1704 AT_CHECK([PATH=`pwd`$PATH_SEPARATOR$PATH; export PATH; cd builddir && { configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1705 0, [ignore], [stderr],
1706 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1707 chmod u+w builddir inner inner/innermost
1708 AT_CHECK([cd builddir && ../configure $configure_options INNERMOST=build/tsomrenni], 0, [ignore])
1709 AT_CHECK([grep INNERMOST builddir/inner/innermost/config.h], 0,
1710 [[#define INNERMOST build/tsomrenni
1717 ## -------------------------------- ##
1718 ## Non-Autoconf AC_CONFIG_SUBDIRS. ##
1719 ## -------------------------------- ##
1721 AT_SETUP([Non-Autoconf AC_CONFIG_SUBDIRS])
1722 AT_KEYWORDS([autoreconf])
1724 # We use aclocal (via autoreconf).
1727 AT_DATA([install-sh], [])
1728 AT_DATA([configure.ac],
1729 [[AC_INIT(GNU Outer, 1.0)
1730 AC_CONFIG_SUBDIRS([inner])
1736 AT_DATA([inner/configure],
1739 *--help*) echo 'No Autoconf here, folks!' ;;
1740 *) echo got_it >myfile ;;
1744 chmod +x inner/configure
1746 AT_CHECK([autoreconf -Wall], 0, [ignore])
1748 # Running the outer configure recursively should provide the innermost
1750 AT_CHECK([./configure $configure_options --help=recursive | grep "folks"],
1753 # Running the outer configure should trigger the inner.
1754 AT_CHECK([./configure $configure_options], 0, [ignore])
1755 AT_CHECK([test -f inner/myfile], 0)
1760 ## ------------------------------- ##
1761 ## Non-literal AC_CONFIG_SUBDIRS. ##
1762 ## ------------------------------- ##
1764 AT_SETUP([Non-literal AC_CONFIG_SUBDIRS])
1765 AT_KEYWORDS([autoreconf])
1767 AT_DATA([install-sh], [])
1768 AT_DATA([configure.ac],
1769 [[AC_INIT(GNU Outer, 1.0)
1772 # Taken from autoconf.texi:Subdirectories.
1773 if test "x$package_foo_enabled" = xyes; then
1774 my_subdirs="$my_subdirs foo"
1776 AC_CONFIG_SUBDIRS([$my_subdirs])
1783 AT_DATA([foo/configure],
1788 chmod +x foo/configure
1790 # autoreconf should warn without -Wno-syntax, but should not fail without -Werror.
1791 AT_CHECK([autoreconf -Werror -v], [1], [ignore], [stderr])
1792 AT_CHECK([grep 'AC_CONFIG_SUBDIRS:.*literals' stderr], [0], [ignore])
1793 AT_CHECK([autoreconf -v], [0], [ignore], [stderr])
1794 AT_CHECK([grep 'AC_CONFIG_SUBDIRS:.*literals' stderr], [0], [ignore])
1795 AT_CHECK([autoreconf -v --force -Wno-syntax], 0, [ignore], [stderr])
1796 AT_CHECK([grep 'AC_CONFIG_SUBDIRS:.*literals' stderr], [1])
1798 AT_CHECK([./configure $configure_options], [0], [ignore])
1799 AT_CHECK([test ! -f foo/innerfile])
1800 # Running the outer configure should trigger the inner.
1801 AT_CHECK([./configure $configure_options package_foo_enabled=yes], [0], [ignore])
1802 AT_CHECK([test -f foo/innerfile])
1806 ## ------------------------- ##
1807 ## Empty AC_CONFIG_SUBDIRS. ##
1808 ## ------------------------- ##
1810 AT_SETUP([Empty AC_CONFIG_SUBDIRS])
1811 AT_KEYWORDS([autoreconf])
1813 AT_DATA([install-sh], [])
1814 AT_DATA([configure.ac],
1815 [[AC_INIT(GNU Outer, 1.0)
1822 # autoreconf should have no complaints, and the generated configure
1823 # script should run fine with or without --no-recursion.
1824 AT_CHECK([autoreconf -Werror], [0], [ignore])
1825 AT_CHECK_CONFIGURE()
1826 AT_CHECK_CONFIGURE([--no-recursion])
1830 ## ----------------- ##
1831 ## Empty directory. ##
1832 ## ----------------- ##
1834 AT_SETUP([Empty directory])
1835 AT_KEYWORDS([autoreconf])
1837 # Prevent autoreconf from running aclocal, which might not be available.
1838 dnl We can't use AT_SUPPRESS_ACLOCAL here because it creates an aclocal.m4.
1841 # The test group directory is not necessarily _empty_, but it does not contain
1842 # files meaningful to 'autoreconf'.
1844 AT_CHECK([autoreconf -Wall -v], 1, [ignore], [ignore])
1850 ## ------------------------------ ##
1851 ## Unusual Automake input files. ##
1852 ## ------------------------------ ##
1854 # This parallels gnumake.test in Automake.
1856 AT_SETUP([Unusual Automake input files])
1857 AT_KEYWORDS([autoreconf])
1862 AT_DATA([configure.ac],
1863 [[AC_INIT(GNU foo, 1.0)
1865 AC_CONFIG_FILES([HeeHee])
1869 AT_DATA([HeeHee.am],
1870 [[# Humans do no worse than 'GNUmakefile.am'.
1871 AUTOMAKE_OPTIONS = foreign 1.8
1874 AT_CHECK([autoreconf -Wall -v -i], 0, [ignore], [stderr],
1875 [AT_CHECK([grep 'require.*1\.8' stderr && exit 77], [1])])
1876 AT_CHECK([test -f HeeHee.in])
1880 ## ------------------------------ ##
1881 ## Specific warnings options. ##
1882 ## ------------------------------ ##
1884 AT_SETUP([Specific warnings options for autoreconf])
1885 AT_KEYWORDS([autoreconf])
1887 # If autoreconf is given a -W option that's mentioned in its own
1888 # --help output, that option should not cause errors, even if some
1889 # of the subsidiary programs don't support it.
1894 AT_DATA([configure.ac],
1895 [[AC_INIT(GNU foo, 1.0)
1897 AC_CONFIG_HEADERS([config.h])
1898 AC_CONFIG_FILES([Makefile])
1902 AT_DATA([Makefile.am],
1903 [[AUTOMAKE_OPTIONS = foreign
1906 # To silence complaints about required helper scripts from automake.
1907 # We aren't going to run the generated Makefile so we don't need the
1908 # real helper scripts.
1909 AT_DATA([install-sh], [])
1910 AT_DATA([missing], [])
1912 # In order to cut down the time this test takes, we do not test all
1913 # of the supported warning categories, just the most common case
1914 # (-Wall) and some specific categories that are known to have been a
1915 # problem in the past.
1916 AT_CHECK([autoreconf -Werror -Wall], 0, [], [])
1917 rm -rf configure config.h.in Makefile.in aclocal.m4 autom4te.cache
1919 AT_CHECK([autoreconf -Werror -Wcross], 0, [], [])
1920 rm -rf configure config.h.in Makefile.in aclocal.m4 autom4te.cache
1922 AT_CHECK([autoreconf -Werror -Wportability-recursive], 0, [], [])
1923 rm -rf configure config.h.in Makefile.in aclocal.m4 autom4te.cache
1927 ## ------------------------- ##
1928 ## Missing auxiliary files. ##
1929 ## ------------------------- ##
1931 AT_SETUP([Missing auxiliary files (config.*)])
1932 AT_KEYWORDS([autoreconf])
1935 AT_DATA([configure.ac],
1936 [[AC_INIT([GNU foo], [1.0])
1937 AC_CONFIG_AUX_DIR([build-aux])
1944 # Both configure and autoreconf should detect the missing files.
1945 AT_CHECK_CONFIGURE([], [1], [ignore],
1946 [configure: error: cannot find required auxiliary files: config.guess config.sub
1949 AT_CHECK([autoreconf], 1, [],
1950 [configure.ac: error: required file 'config.sub' not found
1951 configure.ac: error: required file 'config.guess' not found
1952 configure.ac: try running autoreconf --install
1955 # If only one file is missing, the error messages should only report
1956 # that one. Also, the above invocation of autoreconf should _not_
1957 # have created build-aux, because it wasn't called with --install.
1958 AT_CHECK([test ! -e build-aux])
1960 : > build-aux/config.guess
1962 AT_CHECK_CONFIGURE([], [1], [ignore],
1963 [configure: error: cannot find required auxiliary files: config.sub
1966 AT_CHECK([autoreconf], 1, [],
1967 [configure.ac: error: required file 'config.sub' not found
1968 configure.ac: try running autoreconf --install
1971 # Missing aux files should not interfere with --help and --version.
1972 AT_CHECK_CONFIGURE([--help], [0], [ignore], [ignore])
1973 AT_CHECK_CONFIGURE([--version], [0], [ignore], [ignore])
1975 # autoreconf --install should be able to install config.sub and config.guess.
1976 rm build-aux/config.guess
1977 AT_CHECK([autoreconf --install])
1979 AT_CHECK([test -x build-aux/config.guess])
1980 AT_CHECK([test -x build-aux/config.sub])
1981 AT_CHECK([test ! -e build-aux/install-sh])
1988 AT_SETUP([Missing auxiliary files (install-sh)])
1989 AT_KEYWORDS([autoreconf])
1991 # Same as "Missing auxiliary files (config.*)" except that the
1992 # configure script _doesn't_ need config.{sub,guess} but does need
1996 AT_DATA([configure.ac],
1997 [[AC_INIT([GNU foo], [1.0])
1998 AC_CONFIG_AUX_DIR([build-aux])
2005 # Both configure and autoreconf should detect the missing files.
2006 AT_CHECK_CONFIGURE([], [1], [ignore],
2007 [configure: error: cannot find required auxiliary files: install-sh
2010 AT_CHECK([autoreconf], 1, [],
2011 [configure.ac: error: required file 'install-sh' not found
2012 configure.ac: try running autoreconf --install
2014 AT_CHECK([test ! -e build-aux])
2016 AT_CHECK_CONFIGURE([--help], [0], [ignore], [ignore])
2017 AT_CHECK_CONFIGURE([--version], [0], [ignore], [ignore])
2019 AT_CHECK([autoreconf --install])
2021 AT_CHECK([test ! -e build-aux/config.guess])
2022 AT_CHECK([test ! -e build-aux/config.sub])
2023 AT_CHECK([test -x build-aux/install-sh])
2030 AT_SETUP([Missing auxiliary files (foreign)])
2031 AT_KEYWORDS([autoreconf])
2033 # If an aux file is required that autoreconf doesn't know how to install,
2034 # it shouldn't suggest autoreconf --install.
2035 # This also verifies that AC_REQUIRE_AUX_FILE can be used outside of a
2036 # macro definition, which was always the intent, and was recommended
2037 # usage in some automake recipes, but which was broken in autoconf
2038 # beta 2.69d (see https://savannah.gnu.org/support/?110363).
2041 AT_DATA([configure.ac],
2042 [[AC_INIT([GNU foo], [1.0])
2043 AC_CONFIG_AUX_DIR([build-aux])
2044 AC_REQUIRE_AUX_FILE([tap-driver.sh])
2049 AT_CHECK_CONFIGURE([], [1], [ignore],
2050 [configure: error: cannot find required auxiliary files: tap-driver.sh
2053 AT_CHECK([autoreconf], 1, [],
2054 [configure.ac: error: required file 'tap-driver.sh' not found
2056 AT_CHECK([test ! -e build-aux])
2058 AT_CHECK([autoreconf --install], 1, [],
2059 [configure.ac: error: required file 'tap-driver.sh' not found
2061 # autoreconf --install always creates the aux directory.
2062 AT_CHECK([test -e build-aux])
2064 touch build-aux/tap-driver.sh
2066 AT_CHECK([autoreconf])
2072 AT_SETUP([Missing auxiliary files (--force)])
2073 AT_KEYWORDS([autoreconf])
2075 # Aux files that already exist should not be overwritten, unless
2076 # --force is used, in which case they *should* be overwritten.
2077 # Additional wrinkle: in case automake got to the files we install
2078 # first, we need to *not* overwrite a newer copy supplied by them.
2081 AT_DATA([configure.ac],
2082 [[AC_INIT([GNU foo], [1.0])
2083 AC_CONFIG_AUX_DIR([build-aux])
2091 AT_DATA([build-aux/config-guess.old],
2093 timestamp='1970-01-01'
2094 printf '%s\n' 'frobozz-bogon-bogos1'
2097 AT_DATA([build-aux/config-sub.new],
2099 scriptversion='9999-12-31'
2103 AT_DATA([build-aux/install-sh.old],
2105 # Old versions of install-sh did not have a timestamp line.
2108 cp build-aux/config-guess.old build-aux/config.guess
2109 cp build-aux/config-sub.new build-aux/config.sub
2110 cp build-aux/install-sh.old build-aux/install-sh
2111 chmod +x build-aux/config.sub build-aux/config.guess build-aux/install-sh
2113 # This pass should not change any of the files.
2114 AT_CHECK([autoreconf --install])
2115 AT_CMP([build-aux/config-guess.old], [build-aux/config.guess])
2116 AT_CMP([build-aux/config-sub.new], [build-aux/config.sub])
2117 AT_CMP([build-aux/install-sh.old], [build-aux/install-sh])
2119 # This pass should change only config.guess and install-sh, not config.sub.
2120 AT_CHECK([autoreconf --install --force])
2122 [if cmp build-aux/config-guess.old build-aux/config.guess > /dev/null 2>&1
2125 AT_CMP([build-aux/config-sub.new], [build-aux/config.sub])
2127 [if cmp build-aux/install-sh.old build-aux/install-sh > /dev/null 2>&1
2134 ## ------------------------------ ##
2135 ## Files clobbered by AC_OPENMP. ##
2136 ## ------------------------------ ##
2138 AT_SETUP([Files clobbered by AC_OPENMP])
2147 # autoconf should bomb out if either 'mp' or 'openmp' exists in the
2150 AT_CHECK_AUTOCONF([], [1], [], [stderr])
2151 AT_CHECK([grep "clobbers files named 'mp' and 'penmp'" stderr],
2152 [0], [ignore], [ignore])
2156 AT_CHECK_AUTOCONF([], [1], [], [stderr])
2157 AT_CHECK([grep "clobbers files named 'mp' and 'penmp'" stderr],
2158 [0], [ignore], [ignore])
2161 # If neither of these files exist, autoconf should go through...
2164 # ... but configure should bomb out, and *not* delete the files,
2165 # if they are added after autoconf is run.
2167 AT_CHECK_CONFIGURE([], [1], [], [stderr])
2168 AT_CHECK([test -e mp])
2169 AT_CHECK([grep "clobbers files named 'mp' and 'penmp'" stderr],
2170 [0], [ignore], [ignore])
2174 AT_CHECK_CONFIGURE([], [1], [], [stderr])
2175 AT_CHECK([test -e penmp])
2176 AT_CHECK([grep "clobbers files named 'mp' and 'penmp'" stderr],
2177 [0], [ignore], [ignore])