3 # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
4 # 2009 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2, or (at your option)
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 AT_BANNER([[Testing config.status.]])
25 ## ---------------------------------------- ##
26 ## AC_CONFIG_COMMANDS with empty commands. ##
27 ## ---------------------------------------- ##
29 AT_CHECK_MACRO([AC_CONFIG_COMMANDS with empty commands],
30 [[AC_CONFIG_COMMANDS([foo], [], [:])
34 ## -------------------------- ##
35 ## Multiple AC_CONFIG_FILES. ##
36 ## -------------------------- ##
38 AT_SETUP([Multiple AC_CONFIG_FILES])
40 AT_CONFIGURE_AC([[AC_CONFIG_FILES([foo foo])]])
41 AT_CHECK_AUTOCONF([], 1, [], [ignore])
46 ## ------------------------------- ##
47 ## parameterized AC_CONFIG_FILES. ##
48 ## ------------------------------- ##
50 AT_SETUP([Parameterized AC_CONFIG_FILES])
55 AC_CONFIG_FILES([$files])]])
56 AT_CHECK_AUTOCONF([], [], [], [ignore])
57 touch foo.in bar.in config.hin
68 # AT_CHECK_AC_ARG_VAR(FIRST-VALUE, SECOND-VALUE, [STATUS = 1])
69 # ------------------------------------------------------------
70 # Check that AC_ARG_VAR caches the latest values, diagnoses
71 # inconsistencies, and arms config.status. Check that recheck
72 # returns STATUS, save configure output in files 'stdout' and 'stderr'
73 # for further inspection.
74 m4_define([AT_CHECK_AC_ARG_VAR],
79 [precious='m4_bpatsubst([$1], [[']], ['\\''])'; export precious],
81 AT_CHECK_CONFIGURE([--config-cache -q])
82 AT_CHECK([cat file], [], [`$1'
85 # Testing --recheck: 1. have the environment `forget' about PRECIOUS.
87 # 2. Rerun config.status to recreate `file'.
88 AT_CHECK([./config.status --recheck], [], [ignore])
89 AT_CHECK([./config.status], [], [ignore])
90 # 3. Check that file contains the old value of PRECIOUS.
91 AT_CHECK([cat file], [], [`$1'
94 # Second value: we should issue an error here: the value
97 [precious='$2'; export precious],
99 AT_CHECK_CONFIGURE([--config-cache], [m4_default([$3], [1])], [stdout], [stderr])
101 ])# AT_CHECK_AC_ARG_VAR
104 AT_SETUP([AC_ARG_VAR])
106 # We don't want to run this test if this shell doesn't support
109 if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
116 AT_DATA([configure.ac],
118 AC_ARG_VAR([precious], [this variable costs a lot])
119 echo "precious:$precious"
129 # Set a precious variable
130 AT_CHECK_AC_ARG_VAR([], [apple of my eye])
132 # Unset a precious variable
133 AT_CHECK_AC_ARG_VAR([apple of my eye], [])
135 # Change a precious variable
136 AT_CHECK_AC_ARG_VAR([apple of my eye], [orange of my eye])
138 # Change a precious variable that contains braces
139 AT_CHECK_AC_ARG_VAR([apple of my {eye}], [orange of my eye])
141 # Change a precious variable that contains all kinds of fun
142 AT_CHECK_AC_ARG_VAR(['p r ec"iou$], [orange of my eye])
143 dnl restore font-lock: "
145 # Warn (but do not fail) about a whitespace-only change
146 AT_CHECK_AC_ARG_VAR([ apple of my eye ], [apple of my eye],
147 [0], ["has whitespace changes"])
148 mv stdout configure-output
149 AT_CHECK([grep "ignoring whitespace changes" stderr], [], [ignore])
150 AT_CHECK([grep "precious: apple" configure-output], [], [ignore])
157 ## ---------------------------------------------- ##
158 ## AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS. ##
159 ## ---------------------------------------------- ##
161 AT_SETUP([[AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS]])
163 AT_DATA([configure.ac],
166 rm -f -r header var-header file var-file link var-link command var-command
169 # Be sure to also stress the associated INIT-CMDS.
170 case $what_to_test in
172 AC_CONFIG_HEADERS(header:input);;
174 AC_CONFIG_HEADERS(var-header:$header_in, [], [header_in=input]);;
177 AC_CONFIG_FILES(file:input);;
179 AC_CONFIG_FILES(var-file:$file_in, [], [file_in=input]);;
182 AC_CONFIG_COMMANDS(command,
183 [cp input command]);;
185 AC_CONFIG_COMMANDS(var-command,
186 [cp $command_in var-command], [command_in=input]);;
189 AC_CONFIG_LINKS(link:input);;
191 AC_CONFIG_LINKS(var-link:$link_in, [], [link_in=input]);;
199 # AT_CHECK_CONFIG_CREATION(THING = (header | link | file | command))
200 # ------------------------------------------------------------------
201 # Check that THING and var-THING (which uses variables in AC_CONFIG_THING)
202 # are properly created, with the right content.
203 # Use `grep OK' instead of a simple `cat' to avoid banners such as in
205 m4_define([AT_CHECK_CONFIG_CREATION],
206 [AT_CHECK_CONFIGURE([what_to_test=$1])
207 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
210 AT_CHECK([grep OK $1], [], [OK
213 AT_CHECK_CONFIGURE([what_to_test=var-$1 --no-create])
214 # config.status might be stupidly expecting data on stdin, if it's
216 AT_CHECK([./config.status var-$1 </dev/null], [], [ignore])
217 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
220 AT_CHECK([grep OK var-$1], [], [OK
222 ])# AT_CHECK_CONFIG_CREATION
225 # AT_CHECK_CONFIG_CREATION_NOWRITE(THING = (header | link | file | command))
226 # ------------------------------------------------------------------
227 # Check that THING and var-THING (which uses variables in AC_CONFIG_THING)
228 # are properly created, with the right content.
229 # Use `grep OK' instead of a simple `cat' to avoid banners such as in
231 m4_define([AT_CHECK_CONFIG_CREATION_NOWRITE],
232 [AT_CHECK_CONFIGURE([what_to_test=$1])
233 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
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
242 # Skip check if user can rename files into a read-only directory (when
243 # run by root or on w32).
246 mv t t1 >/dev/null 2>&1 \
247 || AT_CHECK([./config.status var-$1 </dev/null || exit 1],
248 [1], [ignore], [ignore])
251 ])# AT_CHECK_CONFIG_CREATION_NOWRITE
255 AT_CHECK_CONFIG_CREATION(file)
258 AT_CHECK_CONFIG_CREATION(header)
261 AT_CHECK_CONFIG_CREATION(command)
264 AT_CHECK_CONFIG_CREATION(link)
266 # Now check for write errors
269 AT_CHECK_CONFIG_CREATION_NOWRITE(file)
270 # Create a file with bits from stdin
271 AT_CHECK([echo from-stdin | ./config.status --file=file:-],
273 AT_CHECK([grep from-stdin file], [], [from-stdin
275 # Force write error creating a file on stdout
276 if test -w /dev/full && test -c /dev/full; then
277 AT_CHECK([./config.status --file=-:input </dev/null >/dev/full],
278 [1], [ignore], [ignore])
282 AT_CHECK_CONFIG_CREATION_NOWRITE(header)
283 # Create a header on stdout
284 AT_CHECK([./config.status --header=-:input </dev/null],
285 [0], [stdout], [ignore])
286 AT_CHECK([grep OK stdout], [], [OK
288 # Force write error creating a header on stdout
289 if test -w /dev/full && test -c /dev/full; then
290 AT_CHECK([./config.status --header=-:input </dev/null >/dev/full],
291 [1], [ignore], [ignore])
295 AT_CHECK_CONFIG_CREATION_NOWRITE(command)
298 AT_CHECK_CONFIG_CREATION_NOWRITE(link)
300 # Check that no use of `ac_write_fail' escaped into config.status
301 AT_CHECK([grep ac_write_fail config.status], [1])
303 # Check that --file and --header accept funny file names
307 ./config.status --file=fgrep:fgrep.in
313 'with funny '\'' $x & #! name' \
314 'file with funny \ '\'' \'\'' $ & #!*? name' \
315 'with funny \ '\'' \'\'' " | <a >b & * ? name ' # "restore font-lock
317 # The function func_sanitize_file_name comes from tools.at
318 file=`func_sanitize_file_name "$file"`
319 cat >"$file.in" <<'END'
322 AT_CHECK([./config.status "--file=$file:$file.in"],
324 AT_CHECK([$FGREP "$file" "$file"], [0], [ignore])
325 AT_CHECK([./config.status "--header=$file:$file.in"],
327 # Run the same test a 2nd time to see that config.status does not recreate
328 # the header (regression test)
329 AT_CHECK_NOESCAPE([./config.status "--header=$file:$file.in"],
330 [0], [config.status: creating $file
331 config.status: $file is unchanged
333 AT_CHECK_NOESCAPE([grep ' & ' "$file"], [],
334 [/* $file. Generated from $file.in by configure. */
336 AT_CHECK([$FGREP "$file" "$file"], [0], [ignore])
342 ## ---------------------------------------- ##
343 ## Macro calls in AC_CONFIG_COMMANDS tags. ##
344 ## ---------------------------------------- ##
346 AT_SETUP([Macro calls in AC_CONFIG_COMMANDS tags])
348 AT_DATA_M4SUGAR([configure.ac],
350 AC_CONFIG_COMMANDS([m4_if(1,1,mytag)])
361 ## ------------------- ##
362 ## Missing templates. ##
363 ## ------------------- ##
365 # Check that config.status detects missing input files
366 AT_SETUP([Missing templates])
368 AT_DATA([configure.ac],
370 AC_CONFIG_FILES([nonexistent])
375 AT_CHECK_CONFIGURE([], [1], [],
376 [[config.status: error: cannot find input file: `nonexistent.in'
378 # Make sure that the output file doesn't exist
379 AT_CHECK([test -f nonexistent], 1)
386 ## ---------------------- ##
387 ## configure invocation. ##
388 ## ---------------------- ##
390 # Check that `configure' and `config.status' honor their interface.
392 # We run `./configure one=val1 --enable-two=val2 --with-three=val3'
393 # and verify that (i) `configure' correctly receives the arguments,
394 # (ii) correctly passes them to `config.status', which we check by
395 # running `config.status --recheck', and (iii) correctly passes them
396 # to sub-configure scripts.
398 AT_SETUP([configure invocation])
402 AT_DATA([configure.ac],
404 AC_CONFIG_SUBDIRS([sub])
405 echo "result=$one$enable_two$with_three"
409 AT_DATA([sub/configure.ac],
411 echo "result=$one$enable_two$with_three"
415 echo fake install-sh script >install-sh
422 AT_CHECK_CONFIGURE([one=one --enable-two=two --with-three=three |
423 sed -n -e 's/^result=//p'], 0,
427 AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
431 AT_CHECK_CONFIGURE([one="\"'$ " --enable-two="\" ' $" --with-three=" \"'$"|
432 sed -n -e 's/^result=//p'], 0,
433 [m4_do(["'$ " ' $ "'$
436 AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
439 dnl restore font-lock: "
445 ## -------------------------------------------- ##
446 ## Check that `#define' templates are honored. ##
447 ## -------------------------------------------- ##
449 # Use various forms of `#define' templates, and make sure there are no
450 # problems when a symbol is prefix of another.
452 AT_SETUP([@%:@define header templates])
453 AT_KEYWORDS([AC@&t@_DEFINE])
455 AT_DATA([configure.ac],
457 AC_CONFIG_HEADERS(config.h:config.hin)
459 # I18n of dummy variables: their French translations.
463 AC_DEFINE(fubar, tutu)
465 # Symbols which are prefixes of another.
470 # backslash-newline combinations
471 AC_DEFINE([multiline], [line1\
475 AC_DEFINE([multiline_args(ARG1, ARG2)], [ARG2 \
477 AC_CONFIG_FILES(defs)
480 AC_DEFINE([paste(a,b)], [a##b])
482 # Things included in confdefs.h, but which make no sense in
483 # config.h, nor in $DEFS.
484 cat <<\EOF >>confdefs.h
485 /* Hi Mum! Look, I am doing C++! */
487 void exit (int status);
491 # In addition of config.h output a full DEFS
502 AT_DATA([config.hin],
505 # define baz "Archimedes was sinking in his baz"
513 #define aaa(a, aa) aa a
515 #define aaac(a, aa) aa a
517 # undef multiline_args
518 #define paste(a,b) a##b
520 #define str(define) \
522 #define stringify(arg) str(arg)
523 #undef aaa /* with comments */
524 #undef not_substed /* with comments */
531 [[/* config.h. Generated from config.hin by configure. */
544 #define aaac(a, aa) aa a
545 #define multiline line1\
549 # define multiline_args(ARG1, ARG2) ARG2 \
551 #define paste(a,b) a##b
553 #define str(define) \
555 #define stringify(arg) str(arg)
557 /* #undef not_substed */
559 AT_CHECK([cat config.h], 0, expout)
561 # Check the value of DEFS.
563 [[-DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -Dfoo=toto -Dbar=tata -Dbaz=titi -Dfubar=tutu -Da=A -Daaa=AAA -Daa=AA -Dmultiline=line1line2line3\ line4 -Dmultiline_args\(ARG1,\ ARG2\)=ARG2\ ARG1 -Dpaste\(a,b\)=a\#\#b
566 # Because we strip trailing spaces in `testsuite' we can't leave one in
567 # expout, hence nuke the one left by AC_OUTPUT_MAKE_DEFS.
568 AT_CHECK([sed -e 's/ $//' defs], 0, expout)
574 ## ------------------------- ##
575 ## Torturing config.status. ##
576 ## ------------------------- ##
578 ## Require 100 AC_DEFINE and AC_SUBST and AC_SUBST_FILE with a significantly
579 ## big value. This is mostly to check that Autoconf produces portable sed
580 ## scripts in config.status. sed is used to skip the first two lines
581 ## `Generated by...'.
583 # We use m4_for many times.
584 m4_pattern_allow([^m4_for$])
586 AT_SETUP([Torturing config.status])
588 dnl The value used as a big value for AC_DEFINE.
589 dnl Don't use sh active chars here, below it is also used in a sh
591 m4_define([AT_BIG_VALUE],
592 [This value should be long enough to torture the various limits of sed and other tools used by Autoconf.])
594 m4_define([AT_DESCRIPTION],
595 [Define to a long string if your `Autoconf' works properly.])
598 # AT_DUMMY_VAR(NUMBER)
599 # --------------------
600 # Build a name used for AC_SUBST and AC_DEFINE. Put ac_ in it
601 # so that the check for user name space invasion does not complain
602 # of the new variables defined.
604 # Note that you should not use the name ac_dummy, because it will be
605 # turned into ac_uummy during the construction of config.status. Yes,
606 # this is admittedly a bug, but it would be too hard to fix this.
607 # There is really no point in AC_DEFINE a var named ac_d.*.
608 m4_pattern_allow([^m4_bpatsubst$])
609 m4_define([AT_DUMMY_VAR],
610 [ac_Dummy_[]m4_bpatsubst([000$1], [.*\(...\)$], [\1])])
615 [m4_for([AT_Count], 1, 100, 1,
616 [@AT_DUMMY_VAR(AT_Count)@
622 while test $i != 101; do
623 echo "content of file $i" > file_$i
624 AS_VAR_ARITH([i], [$i + 1])
632 m4_pattern_allow([^m4_(define|defun)$])
633 AT_DATA([configure.ac],
634 dnl The following lines transfer AT_DUMMY_VAR, AT_DESCRIPTION, and
635 dnl AT_BIG_VALUE into the configure.ac as AC_DUMMY_VAR etc.
636 [[m4_define([AC_DUMMY_VAR],]
637 m4_dquote(m4_defn([AT_DUMMY_VAR]))[)]]
639 [[m4_define([AC_DESCRIPTION],]
640 m4_dquote(m4_defn([AT_DESCRIPTION]))[)]]
642 [[m4_define([AC_BIG_VALUE],]
643 m4_dquote(m4_defn([AT_BIG_VALUE]))[)]]
647 # Related VALUE to NAME both with AC_SUBST and AC_DEFINE. This is
648 # used in the torture tests.
649 m4_defun([AC_DEFUBST],
650 [AC_DUMMY_VAR($1)="AC_BIG_VALUE"
651 AC_DEFINE_UNQUOTED(AC_DUMMY_VAR($1), "$AC_DUMMY_VAR($1) $AC_DUMMY_VAR($1)",
653 AC_SUBST(AC_DUMMY_VAR($1))
659 AC_CONFIG_HEADERS(config.h:config.hin)
660 AC_CONFIG_FILES(dummy)
661 m4_for(AC_Count, 1, 100, 1,
662 [AC_DEFUBST(AC_Count)])
669 # Check both awk and the result of AC_PROG_AWK
670 for awk_arg in FOO= AWK=awk; do
671 AT_CHECK_CONFIGURE([$awk_arg])
673 # Checking that AC_DEFINE worked properly.
675 [/* Define to the address where bug reports for this package should be sent. */
676 #define PACKAGE_BUGREPORT ""
678 /* Define to the full name of this package. */
679 #define PACKAGE_NAME ""
681 /* Define to the full name and version of this package. */
682 #define PACKAGE_STRING ""
684 /* Define to the one symbol short name of this package. */
685 #define PACKAGE_TARNAME ""
687 /* Define to the home page for this package. */
688 #define PACKAGE_URL ""
690 /* Define to the version of this package. */
691 #define PACKAGE_VERSION ""
692 m4_for(AT_Count, 1, 100, 1,
695 [#define] AT_DUMMY_VAR(AT_Count) "AT_BIG_VALUE AT_BIG_VALUE"
698 AT_CHECK([sed -n '4,$ p' config.h], 0, expout)
700 # Checking that AC_SUBST worked properly.
702 [m4_for(AT_Count, 1, 100, 1,
704 content of file AT_Count
707 AT_CHECK([cat dummy], 0, expout)
713 ## ------------------------------- ##
714 ## Substitute a 2000-byte string. ##
715 ## ------------------------------- ##
717 # Solaris 9 /usr/ucb/sed that rejects commands longer than 4000 bytes. HP/UX
718 # sed dumps core around 8 KiB. However, POSIX says that sed need not
719 # handle lines longer than 2048 bytes (including the trailing newline).
720 # So we'll just test a 2000-byte value, and for awk, we test a line with
721 # almost 1000 words, and one variable with 5 lines of 2000 bytes each:
722 # multi-line values should allow to get around the limitations.
724 AT_SETUP([Substitute a 2000-byte string])
726 AT_DATA([Foo.in], [@foo@
728 AT_DATA([Bar.in], [@bar@
730 AT_DATA([Baz.in], [@baz@
733 AT_DATA([configure.ac],
735 AC_SUBST([foo], ]m4_for([n], 1, 100,, ....................)[)
736 AC_SUBST([bar], "]m4_for([n], 1, 100,, @ @ @ @ @ @ @ @ @ @@)[")
737 baz="]m4_for([m], 1, 100,, ... ... ... ... ....)[
739 baz=$baz$baz$baz$baz$baz
742 AC_CONFIG_FILES([Foo Bar Baz])
746 cp "$abs_top_srcdir/build-aux/install-sh" .
749 # Check both awk and the result of AC_PROG_AWK
750 for awk_arg in Foo= AWK=awk; do
751 AT_CHECK_CONFIGURE([$awk_arg])
752 AT_CHECK([cat Foo], 0, m4_for([n], 1, 100,, ....................)
754 AT_CHECK([cat Bar], 0, m4_for([n], 1, 100,, @ @ @ @ @ @ @ @ @ @@)
757 [m4_for([n], 1, 5,, m4_for([m], 1, 100,, ... ... ... ... ....)
759 AT_CHECK([cat Baz], 0, [stdout])
764 ## ------------------------------ ##
765 ## Define to a 2000-byte string. ##
766 ## ------------------------------ ##
768 AT_SETUP([Define to a 2000-byte string])
769 AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
773 AC_DEFINE_UNQUOTED([foo], ]m4_for([n], 1, 100,, ....................)[, [desc])
774 AC_DEFINE([fooq], ]m4_for([n], 1, 100,, ....................)[, [desc])
780 AT_CHECK_DEFINES([@%:@define foo m4_for([n], 1, 100,, ....................)
781 @%:@define fooq m4_for([n], 1, 100,, ....................)
786 ## ------------------------------------------ ##
787 ## Substitute and define special characters. ##
788 ## ------------------------------------------ ##
790 # Use characters special to the shell, sed, awk, and M4.
792 AT_SETUP([Substitute and define special characters])
793 AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
795 AT_DATA([Foo.in], [@foo@
796 @bar@@notsubsted@@baz@ stray @ and more@@@baz@
813 AT_DATA([Zardoz.in], [@zardoz@
817 [[foo="AS@&t@_ESCAPE([[X*'[]+ ", & &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !]])"
821 ( for i in 0 1 2 3; do
822 for j in 0 1 2 3 4 5 6 7; do
823 for k in 0 1 2 3 4 5 6 7; do
825 000 | 015 | 377) ;; # MinGW awk dislikes 0xFF, and the test does
826 # the wrong thing for CR on MinGW.
828 *) printf \\$i$j$k's' ;; # The 's' works around a Solaris 8 /bin/bash bug.
835 zardoz=`cat allowed-chars`
841 AC_SUBST_FILE([file])
842 AC_DEFINE([fooq], [[X*'[]+ ", & &`\($foo !]], [Awful value.])
843 AC_DEFINE([barq], [[%!_!# X]], [Value that is used as special delimiter.])
844 AC_DEFINE_UNQUOTED([foo], [[X*'[]+ ", & &\`\\(\$foo !]], [Awful value.])
845 AC_DEFINE_UNQUOTED([bar], [[%!_!# X]], [Value that is used as special delimiter.])
846 AC_DEFINE_UNQUOTED([unq1], [$baz], [unquoted, test 1])
847 AC_DEFINE_UNQUOTED([unq2], [\$baz], [unquoted, test 2])
848 AC_DEFINE_UNQUOTED([unq3], ["$baz"], [unquoted, test 3])
849 AC_DEFINE_UNQUOTED([unq4], [${baz+set}], [unquoted, test 4])
850 AC_DEFINE_UNQUOTED([unq5], ["${baz+`echo "a b"`}"], [unquoted, test 5])
851 AC_DEFINE_UNQUOTED([unq6], [`echo hi`], [unquoted, test 6])
852 AC_DEFINE_UNQUOTED([unq7], ['\"'], [unquoted, test 7])
854 AC_CONFIG_FILES([Foo Zardoz])]])
858 # Check both awk and the result of AC_PROG_AWK
859 for awk_arg in FOO= AWK=awk; do
860 AT_CHECK_CONFIGURE([$awk_arg])
861 AT_CHECK([cat Foo], 0, [[X*'[]+ ", & &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !
862 @foo@ @baz@@notsubsted@bla stray @ and more@@bla
863 abc@foo@ @baz@baz@baz
865 abc@foo@ @baz@blabaz@
874 AT_CHECK([cmp allowed-chars Zardoz])
875 AT_CHECK_DEFINES([[#define bar %!_!# X
877 #define foo X*'[]+ ", & &`\($foo !
878 #define fooq X*'[]+ ", & &`\($foo !
891 ## ---------------------- ##
892 ## Substitute a newline. ##
893 ## ---------------------- ##
895 AT_SETUP([Substitute a newline])
902 AT_DATA([configure.ac],
910 AC_CONFIG_FILES([Foo])
915 cp "$abs_top_srcdir/build-aux/install-sh" .
923 # Check both awk and the result of AC_PROG_AWK
924 for awk_arg in FOO= AWK=awk; do
925 AT_CHECK_CONFIGURE([$awk_arg])
926 AT_CHECK([cat Foo], 0, [expout])
931 ## ------------------ ##
932 ## Define a newline. ##
933 ## ------------------ ##
935 AT_SETUP([Define a newline])
936 AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
937 AT_CONFIGURE_AC([[AC_DEFINE([foo], [one
938 two], [This spans two lines.])
940 AT_CHECK_AUTOCONF([], [], [], [stderr])
941 dnl Older versions of m4 report error at line 5 (end of macro);
942 dnl newer versions report it at line 4 (start of macro).
943 AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
944 [[warning: AC_DEFINE: `one
945 two' is not a valid preprocessor define value
947 AT_CHECK_AUTOHEADER([], [], [], [stderr])
948 AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
949 [[warning: AC_DEFINE: `one
950 two' is not a valid preprocessor define value
953 AT_CHECK_DEFINES([[#define foo one
956 AT_CONFIGURE_AC([[AC_DEFINE_UNQUOTED([foo], [one
957 two], [This spans two lines.])
959 AT_CHECK_AUTOCONF([], [], [], [stderr])
960 AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
961 [[warning: AC_DEFINE_UNQUOTED: `one
962 two' is not a valid preprocessor define value
964 AT_CHECK_AUTOHEADER([], [], [], [stderr])
965 AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
966 [[warning: AC_DEFINE_UNQUOTED: `one
967 two' is not a valid preprocessor define value
970 AT_CHECK_DEFINES([[#define foo one
976 ## ------------------------------------ ##
977 ## AC_SUBST: variable name validation. ##
978 ## ------------------------------------ ##
980 AT_SETUP([AC_SUBST: variable name validation])
982 AT_CONFIGURE_AC([[AC_SUBST(, [])
983 AC_CONFIG_FILES([Makefile])
985 AT_DATA([Makefile.in], [[
987 mv -f configure.ac configure.tmpl
990 for var in ['' ab\~ ab\( ab[] ab\' ab\" ab\\\\]; do
991 sed ["s/AC_SUBST(/&[$var]/"] <configure.tmpl >configure.ac
992 AT_CHECK_AUTOCONF([], [1], [], [ignore])
996 for var in ab a4 'a@@&t@\&t@b'; do
997 sed ["s/AC_SUBST(/&[$var]/"] <configure.tmpl >configure.ac
1006 ## ------------------------ ##
1007 ## datarootdir workaround. ##
1008 ## ------------------------ ##
1010 AT_SETUP([datarootdir workaround])
1024 AT_DATA([configure.ac],
1026 d@&t@nl The following line silences the warnings, if uncommented:
1027 d@&t@nl AC_DEFUN([AC_DATAROOTDIR_CHECKED])
1029 # This substitution is wrong and bogus! Don't use it in your own code!
1030 # Read `info Autoconf "Defining Directories"'!
1031 AC_SUBST([mydatadir], [${datadir}/my])
1033 AC_CONFIG_FILES([Foo Bar])
1037 cp "$abs_top_srcdir/build-aux/install-sh" .
1040 AT_CHECK_CONFIGURE([], [], [],
1041 [config.status: WARNING: 'Foo.in' seems to ignore the --datarootdir setting
1042 config.status: WARNING: Bar contains a reference to the variable `datarootdir'
1043 which seems to be undefined. Please make sure it is defined.
1045 AT_CHECK([grep datarootdir Foo], 1, [])
1048 sed '/AC_DEFUN/s/^d@&t@nl //' configure.ac >t
1068 AT_DATA([configure.ac],
1071 AC_CONFIG_FILES([foo at-dir/bar])
1073 # Use quotes in the INIT-COMMANDS to accommodate a value of $srcdir
1074 # containing e.g., spaces or shell meta-characters.
1075 # Use *single* quotes because the context is an unquoted here-doc.
1076 AC_CONFIG_COMMANDS([report],
1077 [test -f "$srcdir/configure.ac" ||
1078 AC_MSG_ERROR([cannot find $srcdir/configure.ac])],
1082 rm -f -r foo at-dir/bar
1088 AT_CHECK([./configure], [], [ignore])
1091 AT_CHECK([cd at-dir && ../configure], [], [ignore])
1095 AT_CHECK([cd at-dir && "$at_here/configure"], [], [ignore])
1100 ## ----------------- ##
1101 ## Signal handling. ##
1102 ## ----------------- ##
1104 AT_SETUP([Signal handling])
1106 AT_DATA([configure.ac],
1113 AT_CHECK_CONFIGURE([], 1, ignore, ignore)
1118 ## ------------------------------------- ##
1119 ## AC_CONFIG_LINKS and identical files. ##
1120 ## ------------------------------------- ##
1121 AT_SETUP([AC_CONFIG_LINKS and identical files])
1123 AT_DATA([configure.ac],
1125 AC_CONFIG_LINKS([src/s:src/s])
1126 test "$srcdir" != '.' && AC_CONFIG_LINKS([src/t:src/t])
1135 AT_CHECK([../configure && ../configure], 0, [ignore])
1136 AT_CHECK([cat src/s src/t], 0, [file1
1140 AT_CHECK([./configure && ./configure], 0, [ignore], [stderr])
1141 AT_CHECK([grep src/t stderr], 1)
1142 AT_CHECK([cat src/s src/t], 0, [file1
1145 AT_CHECK(["`pwd`"/configure && "`pwd`"/configure], 0, [ignore], [ignore])
1146 AT_CHECK([cat src/s src/t], 0, [file1
1153 AT_BANNER([autoreconf.])
1155 ## ---------------------------- ##
1156 ## Configuring subdirectories. ##
1157 ## ---------------------------- ##
1162 # | |-- config.status
1165 # | |-- config.status
1172 # | |-- configure.ac
1177 AT_SETUP([Configuring subdirectories])
1178 AT_KEYWORDS(autoreconf)
1180 # We use aclocal (via autoreconf).
1181 AT_CHECK([aclocal --version || exit 77], [], [stdout], [ignore])
1182 # It should understand configure.ac.
1183 AT_CHECK([[grep '[^0-9]1.[01234][^0-9]' stdout && exit 77]], [1], [ignore])
1185 # Set CONFIG_SITE to a nonexistent file, so that there are
1186 # no worries about nonstandard values for 'prefix'.
1187 CONFIG_SITE=no-such-file
1190 # The contents of `inner/', and `inner/innermost/'.
1191 AS_MKDIR_P([inner/innermost])
1193 # We have to use configure.in, not configure.ac, if we still want to
1194 # be compatible with Automake 1.4: aclocal (run by autoreconf) would
1195 # die because it can't find configure.in.
1196 AT_DATA([inner/configure.in],
1197 [[AC_INIT(GNU Inner, 1.0)
1198 AC_CONFIG_SRCDIR([innermost/config.in])
1199 AC_ARG_VAR([INNER], [an inner variable])
1201 if test "x$INNER" = x; then
1204 AC_CONFIG_FILES([innermost/config])
1208 AT_DATA([inner/innermost/config.in],
1211 top_srcdir=@top_srcdir@
1215 # The contents of `.'
1216 AT_DATA([install-sh], [])
1218 # nonexistent is allowed not to exist.
1219 AT_DATA([configure.in],
1220 [[AC_INIT(GNU Outer, 1.0)
1221 AC_ARG_VAR([OUTER], [an outer variable])
1223 AC_CONFIG_SUBDIRS([nonexistent])
1225 AC_CONFIG_SUBDIRS([inner])
1229 # If there are improperly quoted AC_DEFUN installed in share/aclocal,
1230 # they trigger warnings from aclocal 1.8, so ignore stderr.
1231 AT_CHECK([autoreconf], [], [], [ignore])
1232 AT_CHECK([test -f inner/configure])
1234 # Running the outer configure recursively should provide the innermost
1236 chmod a-w inner/innermost inner .
1237 AT_CHECK([{ ./configure --help=recursive; chmod u+w .; } | grep INNER], 0,
1239 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1240 chmod u+w . inner inner/innermost
1242 # Running the outer configure should trigger the inner.
1244 AT_CHECK([cat inner/innermost/config], 0,
1251 # The same, but from a builddir.
1252 AS_MKDIR_P([builddir])
1253 AT_CHECK([cd builddir && ../configure], 0, [ignore])
1254 AT_CHECK([cat builddir/inner/innermost/config], 0,
1256 srcdir=../../../inner/innermost
1257 top_srcdir=../../../inner
1261 # Make sure precious variables and command line options are properly
1262 # passed, even when there are duplicates.
1263 AT_CHECK([cd builddir && ../configure --prefix /bad --prefix /good INNER=bad INNER=good], 0, [ignore])
1264 AT_CHECK([cat builddir/inner/innermost/config], 0,
1266 srcdir=../../../inner/innermost
1267 top_srcdir=../../../inner
1271 # Make sure --prefix is properly quoted
1272 AT_CHECK([cd builddir && ../configure --prefix "/a b c$ 'd"], 0, [ignore])
1273 AT_CHECK([cat builddir/inner/innermost/config], 0,
1275 srcdir=../../../inner/innermost
1276 top_srcdir=../../../inner
1280 # Make sure --silent is properly passed...
1281 AT_CHECK([cd builddir && ../configure --silent], 0, [])
1282 # ...but not stored in config.status.
1283 AT_CHECK([cd builddir && ./config.status --recheck], 0, [stdout])
1284 AT_CHECK([grep 'creating \./config.status' stdout], 0, [ignore])
1286 # Make sure we can run autoreconf on a subdirectory
1287 rm -f configure configure.in
1288 AT_CHECK([autoreconf inner], [], [], [ignore])
1290 # Make sure we can pass a configure.ac name
1291 AT_CHECK([cd inner && autoreconf configure.in], [], [], [ignore])
1292 AT_CHECK([autoreconf inner/configure.in], [], [], [ignore])
1298 ## -------------- ##
1300 ## -------------- ##
1302 AT_SETUP([Deep Package])
1303 AT_KEYWORDS(autoreconf)
1305 # We use aclocal (via autoreconf).
1306 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
1308 # The contents of `.'
1309 AT_DATA([install-sh], [])
1310 AT_DATA([configure.in],
1311 [[AC_INIT(GNU Outer, 1.0)
1312 AC_ARG_VAR([OUTER], [an outer variable])
1313 AC_CONFIG_SUBDIRS([inner inner2])
1317 # The contents of `inner/', and `inner/innermost/'.
1318 AS_MKDIR_P([inner/innermost])
1319 AS_MKDIR_P([inner2])
1321 AT_DATA([inner/configure.in],
1322 [[AC_INIT(GNU Inner, 1.0)
1323 AC_ARG_VAR([INNER], [an inner variable])
1324 AC_CONFIG_SUBDIRS(innermost)
1328 AT_DATA([inner/innermost/configure.in],
1329 [[AC_INIT(GNU Innermost, 1.0)
1330 AC_ARG_VAR([INNERMOST], [an innermost variable])
1331 AC_CONFIG_HEADERS(config.h:config.hin)
1332 AC_DEFINE_UNQUOTED([INNERMOST], [$INNERMOST], [an innermost variable])
1333 if test -n "$innermost_error"; then
1334 AC_MSG_FAILURE([error in $PACKAGE_NAME])
1339 AT_DATA([inner2/configure.in],
1340 [[AC_INIT(GNU Inner 2, 1.0)
1341 AC_ARG_VAR([INNER2], [an inner2 variable])
1345 AT_CHECK([autoreconf -Wall -v], [0], [ignore], [ignore])
1346 AT_CHECK([test -f inner/configure])
1347 AT_CHECK([test -f inner/innermost/configure])
1348 AT_CHECK([test -f inner/innermost/config.hin])
1349 AT_CHECK([test -f inner2/configure])
1351 # Running the outer configure recursively should provide the innermost
1353 chmod a-w inner/innermost inner
1354 AT_CHECK([{ ./configure --help=recursive; chmod u+w .; } | grep " INNER "],
1355 0, [ignore], [stderr],
1356 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1358 AT_CHECK([{ ./configure --help=recursive; chmod u+w .; } | grep " INNER2 "],
1359 0, [ignore], [stderr],
1360 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1362 AT_CHECK([{ ./configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1363 0, [ignore], [stderr],
1364 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1366 AT_CHECK([{ /bin/sh ./configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1367 0, [ignore], [stderr],
1368 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1370 AT_CHECK([PATH=.$PATH_SEPARATOR$PATH; export PATH; { /bin/sh configure --help=recursive; chmod +w .; } | grep " INNERMOST "],
1371 0, [ignore], [stderr],
1372 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1374 AT_CHECK([PATH=.$PATH_SEPARATOR$PATH; export PATH; { configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1375 0, [ignore], [stderr],
1376 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1377 chmod u+w inner inner/innermost
1379 # Running the outer configure should trigger the inner.
1380 AT_CHECK_CONFIGURE([INNERMOST=tsomrenni])
1381 AT_CHECK([grep INNERMOST inner/innermost/config.h], 0,
1382 [[#define INNERMOST tsomrenni
1385 # Ensure we point to the right config.log file for errors.
1386 AT_CHECK_CONFIGURE([innermost_error=:], [1], [], [stderr])
1387 AT_CHECK([grep 'inner/innermost' stderr], [], [ignore])
1389 AT_CHECK_CONFIGURE([innermost_error=:], [1], [], [stderr])
1390 AT_CHECK([grep 'innermost' stderr], [], [ignore])
1393 # The same, but from a builddir.
1394 AS_MKDIR_P([builddir])
1395 chmod a-w builddir inner/innermost inner
1396 AT_CHECK([cd builddir && { ../configure --help=recursive; chmod u+w .; } | grep " INNER "],
1397 0, [ignore], [stderr],
1398 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1400 AT_CHECK([cd builddir && { ../configure --help=recursive; chmod u+w .; } | grep " INNER2 "],
1401 0, [ignore], [stderr],
1402 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1404 AT_CHECK([cd builddir && { ../configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1405 0, [ignore], [stderr],
1406 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1408 AT_CHECK([cd builddir && { /bin/sh ../configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1409 0, [ignore], [stderr],
1410 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1412 # Not all shells search $PATH for scripts.
1413 if (cd builddir && PATH=`pwd`/..$PATH_SEPARATOR$PATH /bin/sh configure --help) >/dev/null 2>&1; then
1414 AT_CHECK([cd builddir && PATH=`pwd`/..$PATH_SEPARATOR$PATH /bin/sh configure --help=recursive | grep " INNERMOST "], 0, [ignore])
1416 AT_CHECK([PATH=`pwd`$PATH_SEPARATOR$PATH; export PATH; cd builddir && { configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1417 0, [ignore], [stderr],
1418 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1419 chmod u+w builddir inner inner/innermost
1420 AT_CHECK([cd builddir && ../configure INNERMOST=build/tsomrenni], 0, [ignore])
1421 AT_CHECK([grep INNERMOST builddir/inner/innermost/config.h], 0,
1422 [[#define INNERMOST build/tsomrenni
1429 ## -------------------------------- ##
1430 ## Non-Autoconf AC_CONFIG_SUBDIRS. ##
1431 ## -------------------------------- ##
1433 AT_SETUP([Non-Autoconf AC_CONFIG_SUBDIRS])
1434 AT_KEYWORDS([autoreconf])
1436 # We use aclocal (via autoreconf).
1437 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
1439 AT_DATA([install-sh], [])
1440 AT_DATA([configure.in],
1441 [[AC_INIT(GNU Outer, 1.0)
1442 AC_CONFIG_SUBDIRS([inner])
1448 AT_DATA([inner/configure],
1451 *--help*) echo 'No Autoconf here, folks!' ;;
1452 *) echo got_it >myfile ;;
1456 chmod +x inner/configure
1458 AT_CHECK([autoreconf -Wall -v], 0, [ignore], [ignore])
1460 # Running the outer configure recursively should provide the innermost
1462 AT_CHECK([./configure --help=recursive | grep "folks"], 0, [ignore])
1464 # Running the outer configure should trigger the inner.
1465 AT_CHECK([./configure], 0, [ignore])
1466 AT_CHECK([test -f inner/myfile], 0)
1472 ## ----------------- ##
1473 ## Empty directory. ##
1474 ## ----------------- ##
1476 AT_SETUP([Empty directory])
1477 AT_KEYWORDS([autoreconf])
1479 # We use aclocal (via autoreconf).
1480 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
1482 # The test group directory is not necessarily _empty_, but it does not contain
1483 # files meaningful to `autoreconf'.
1485 AT_CHECK([autoreconf -Wall -v], 1, [ignore], [ignore])
1491 ## ------------------------------ ##
1492 ## Unusual Automake input files. ##
1493 ## ------------------------------ ##
1495 # This parallels gnumake.test in Automake.
1497 AT_SETUP([Unusual Automake input files])
1498 AT_KEYWORDS([autoreconf])
1500 # We use aclocal and automake via autoreconf.
1501 AT_CHECK([automake --version || exit 77], [], [ignore], [ignore])
1503 AT_DATA([configure.in],
1504 [[AC_INIT(GNU foo, 1.0)
1506 AC_CONFIG_FILES([HeeHee])
1510 AT_DATA([HeeHee.am],
1511 [[# Humans do no worse than `GNUmakefile.am'.
1512 AUTOMAKE_OPTIONS = foreign 1.8
1515 AT_CHECK([autoreconf -Wall -v -i], 0, [ignore], [stderr],
1516 [AT_CHECK([grep 'require.*1\.8' stderr && exit 77], [1])])
1517 AT_CHECK([test -f HeeHee.in])