3 # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
4 # 2009 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 AT_BANNER([[Testing config.status.]])
23 ## ---------------------------------------- ##
24 ## AC_CONFIG_COMMANDS with empty commands. ##
25 ## ---------------------------------------- ##
27 AT_CHECK_MACRO([AC_CONFIG_COMMANDS with empty commands],
28 [[AC_CONFIG_COMMANDS([foo], [], [:])
32 ## -------------------------- ##
33 ## Multiple AC_CONFIG_FILES. ##
34 ## -------------------------- ##
36 AT_SETUP([Multiple AC_CONFIG_FILES])
38 AT_CONFIGURE_AC([[AC_CONFIG_FILES([foo foo])]])
39 AT_CHECK_AUTOCONF([], 1, [], [ignore])
44 ## ------------------------------- ##
45 ## parameterized AC_CONFIG_FILES. ##
46 ## ------------------------------- ##
48 AT_SETUP([Parameterized AC_CONFIG_FILES])
53 AC_CONFIG_FILES([$files])]])
54 AT_CHECK_AUTOCONF([], [], [], [ignore])
55 touch foo.in bar.in config.hin
66 # AT_CHECK_AC_ARG_VAR(FIRST-VALUE, SECOND-VALUE, [STATUS = 1])
67 # ------------------------------------------------------------
68 # Check that AC_ARG_VAR caches the latest values, diagnoses
69 # inconsistencies, and arms config.status. Check that recheck
70 # returns STATUS, save configure output in files 'stdout' and 'stderr'
71 # for further inspection.
72 m4_define([AT_CHECK_AC_ARG_VAR],
77 [precious='m4_bpatsubst([$1], [[']], ['\\''])'; export precious],
79 AT_CHECK_CONFIGURE([--config-cache -q])
80 AT_CHECK([cat file], [], [`$1'
83 # Testing --recheck: 1. have the environment `forget' about PRECIOUS.
85 # 2. Rerun config.status to recreate `file'.
86 AT_CHECK([./config.status --recheck], [], [ignore])
87 AT_CHECK([./config.status], [], [ignore])
88 # 3. Check that file contains the old value of PRECIOUS.
89 AT_CHECK([cat file], [], [`$1'
92 # Second value: we should issue an error here: the value
95 [precious='$2'; export precious],
97 AT_CHECK_CONFIGURE([--config-cache], [m4_default([$3], [1])], [stdout], [stderr])
99 ])# AT_CHECK_AC_ARG_VAR
102 AT_SETUP([AC_ARG_VAR])
104 # We don't want to run this test if this shell doesn't support
107 if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
114 AT_DATA([configure.ac],
116 AC_ARG_VAR([precious], [this variable costs a lot])
117 echo "precious:$precious"
127 # Set a precious variable
128 AT_CHECK_AC_ARG_VAR([], [apple of my eye])
130 # Unset a precious variable
131 AT_CHECK_AC_ARG_VAR([apple of my eye], [])
133 # Change a precious variable
134 AT_CHECK_AC_ARG_VAR([apple of my eye], [orange of my eye])
136 # Change a precious variable that contains braces
137 AT_CHECK_AC_ARG_VAR([apple of my {eye}], [orange of my eye])
139 # Change a precious variable that contains all kinds of fun
140 AT_CHECK_AC_ARG_VAR(['p r ec"iou$], [orange of my eye])
141 dnl restore font-lock: "
143 # Warn (but do not fail) about a whitespace-only change
144 AT_CHECK_AC_ARG_VAR([ apple of my eye ], [apple of my eye],
145 [0], ["has whitespace changes"])
146 mv stdout configure-output
147 AT_CHECK([grep "ignoring whitespace changes" stderr], [], [ignore])
148 AT_CHECK([grep "precious: apple" configure-output], [], [ignore])
155 ## ---------------------------------------------- ##
156 ## AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS. ##
157 ## ---------------------------------------------- ##
159 AT_SETUP([[AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS]])
161 AT_DATA([configure.ac],
164 rm -f -r header var-header file var-file link var-link command var-command
167 # Be sure to also stress the associated INIT-CMDS.
168 case $what_to_test in
170 AC_CONFIG_HEADERS(header:input);;
172 AC_CONFIG_HEADERS(var-header:$header_in, [], [header_in=input]);;
175 AC_CONFIG_FILES(file:input);;
177 AC_CONFIG_FILES(var-file:$file_in, [], [file_in=input]);;
180 AC_CONFIG_COMMANDS(command,
181 [cp input command]);;
183 AC_CONFIG_COMMANDS(var-command,
184 [cp $command_in var-command], [command_in=input]);;
187 AC_CONFIG_LINKS(link:input);;
189 AC_CONFIG_LINKS(var-link:$link_in, [], [link_in=input]);;
197 # AT_CHECK_CONFIG_CREATION(THING = (header | link | file | command))
198 # ------------------------------------------------------------------
199 # Check that THING and var-THING (which uses variables in AC_CONFIG_THING)
200 # are properly created, with the right content.
201 # Use `grep OK' instead of a simple `cat' to avoid banners such as in
203 m4_define([AT_CHECK_CONFIG_CREATION],
204 [AT_CHECK_CONFIGURE([what_to_test=$1])
205 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
208 AT_CHECK([grep OK $1], [], [OK
211 AT_CHECK_CONFIGURE([what_to_test=var-$1 --no-create])
212 # config.status might be stupidly expecting data on stdin, if it's
214 AT_CHECK([./config.status var-$1 </dev/null], [], [ignore])
215 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
218 AT_CHECK([grep OK var-$1], [], [OK
220 ])# AT_CHECK_CONFIG_CREATION
223 # AT_CHECK_CONFIG_CREATION_NOWRITE(THING = (header | link | file | command))
224 # ------------------------------------------------------------------
225 # Check that THING and var-THING (which uses variables in AC_CONFIG_THING)
226 # are properly created, with the right content.
227 # Use `grep OK' instead of a simple `cat' to avoid banners such as in
229 m4_define([AT_CHECK_CONFIG_CREATION_NOWRITE],
230 [AT_CHECK_CONFIGURE([what_to_test=$1])
231 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
234 AT_CHECK([grep OK $1], [], [OK
237 AT_CHECK_CONFIGURE([what_to_test=var-$1 --no-create])
238 # config.status might be stupidly expecting data on stdin, if it's
240 # Skip check if user can rename files into a read-only directory (when
241 # run by root or on w32).
244 mv t t1 >/dev/null 2>&1 \
245 || AT_CHECK([./config.status var-$1 </dev/null || exit 1],
246 [1], [ignore], [ignore])
249 ])# AT_CHECK_CONFIG_CREATION_NOWRITE
253 AT_CHECK_CONFIG_CREATION(file)
256 AT_CHECK_CONFIG_CREATION(header)
259 AT_CHECK_CONFIG_CREATION(command)
262 AT_CHECK_CONFIG_CREATION(link)
264 # Now check for write errors
267 AT_CHECK_CONFIG_CREATION_NOWRITE(file)
268 # Create a file with bits from stdin
269 AT_CHECK([echo from-stdin | ./config.status --file=file:-],
271 AT_CHECK([grep from-stdin file], [], [from-stdin
273 # Force write error creating a file on stdout
274 if test -w /dev/full && test -c /dev/full; then
275 AT_CHECK([./config.status --file=-:input </dev/null >/dev/full],
276 [1], [ignore], [ignore])
280 AT_CHECK_CONFIG_CREATION_NOWRITE(header)
281 # Create a header on stdout
282 AT_CHECK([./config.status --header=-:input </dev/null],
283 [0], [stdout], [ignore])
284 AT_CHECK([grep OK stdout], [], [OK
286 # Force write error creating a header on stdout
287 if test -w /dev/full && test -c /dev/full; then
288 AT_CHECK([./config.status --header=-:input </dev/null >/dev/full],
289 [1], [ignore], [ignore])
293 AT_CHECK_CONFIG_CREATION_NOWRITE(command)
296 AT_CHECK_CONFIG_CREATION_NOWRITE(link)
298 # Check that no use of `ac_write_fail' escaped into config.status
299 AT_CHECK([grep ac_write_fail config.status], [1])
301 # Check that --file and --header accept funny file names
305 ./config.status --file=fgrep:fgrep.in
311 'with funny '\'' $x & #! name' \
312 'file with funny \ '\'' \'\'' $ & #!*? name' \
313 'with funny \ '\'' \'\'' " | <a >b & * ? name ' # "restore font-lock
315 # The function func_sanitize_file_name comes from tools.at
316 file=`func_sanitize_file_name "$file"`
317 cat >"$file.in" <<'END'
320 AT_CHECK([./config.status "--file=$file:$file.in"],
322 AT_CHECK([$FGREP "$file" "$file"], [0], [ignore])
323 AT_CHECK([./config.status "--header=$file:$file.in"],
325 # Run the same test a 2nd time to see that config.status does not recreate
326 # the header (regression test)
327 AT_CHECK_UNQUOTED([./config.status "--header=$file:$file.in"],
328 [0], [config.status: creating $file
329 config.status: $file is unchanged
331 AT_CHECK_UNQUOTED([grep ' & ' "$file"], [],
332 [/* $file. Generated from $file.in by configure. */
334 AT_CHECK([$FGREP "$file" "$file"], [0], [ignore])
340 ## ---------------------------------------- ##
341 ## Macro calls in AC_CONFIG_COMMANDS tags. ##
342 ## ---------------------------------------- ##
344 AT_SETUP([Macro calls in AC_CONFIG_COMMANDS tags])
346 AT_DATA_M4SUGAR([configure.ac],
348 AC_CONFIG_COMMANDS([m4_if(1,1,mytag)])
359 ## ------------------- ##
360 ## Missing templates. ##
361 ## ------------------- ##
363 # Check that config.status detects missing input files
364 AT_SETUP([Missing templates])
366 AT_DATA([configure.ac],
368 AC_CONFIG_FILES([nonexistent])
373 AT_CHECK_CONFIGURE([], [1], [],
374 [[config.status: error: cannot find input file: `nonexistent.in'
376 # Make sure that the output file doesn't exist
377 AT_CHECK([test -f nonexistent], 1)
384 ## ---------------------- ##
385 ## configure invocation. ##
386 ## ---------------------- ##
388 # Check that `configure' and `config.status' honor their interface.
390 # We run `./configure one=val1 --enable-two=val2 --with-three=val3'
391 # and verify that (i) `configure' correctly receives the arguments,
392 # (ii) correctly passes them to `config.status', which we check by
393 # running `config.status --recheck', and (iii) correctly passes them
394 # to sub-configure scripts.
396 AT_SETUP([configure invocation])
400 AT_DATA([configure.ac],
402 AC_CONFIG_SUBDIRS([sub])
403 echo "result=$one$enable_two$with_three"
407 AT_DATA([sub/configure.ac],
409 echo "result=$one$enable_two$with_three"
413 echo fake install-sh script >install-sh
420 AT_CHECK_CONFIGURE([one=one --enable-two=two --with-three=three |
421 sed -n -e 's/^result=//p'], 0,
425 AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
429 AT_CHECK_CONFIGURE([one="\"'$ " --enable-two="\" ' $" --with-three=" \"'$"|
430 sed -n -e 's/^result=//p'], 0,
431 [m4_do(["'$ " ' $ "'$
434 AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
437 dnl restore font-lock: "
443 ## -------------------------------------------- ##
444 ## Check that `#define' templates are honored. ##
445 ## -------------------------------------------- ##
447 # Use various forms of `#define' templates, and make sure there are no
448 # problems when a symbol is prefix of another.
450 AT_SETUP([@%:@define header templates])
451 AT_KEYWORDS([AC@&t@_DEFINE])
453 AT_DATA([configure.ac],
455 AC_CONFIG_HEADERS(config.h:config.hin)
457 # I18n of dummy variables: their French translations.
461 AC_DEFINE(fubar, tutu)
463 # Symbols which are prefixes of another.
468 # backslash-newline combinations
469 AC_DEFINE([multiline], [line1\
473 AC_DEFINE([multiline_args(ARG1, ARG2)], [ARG2 \
475 AC_CONFIG_FILES(defs)
478 AC_DEFINE([paste(a,b)], [a##b])
480 # Things included in confdefs.h, but which make no sense in
481 # config.h, nor in $DEFS.
482 cat <<\EOF >>confdefs.h
483 /* Hi Mum! Look, I am doing C++! */
485 void exit (int status);
489 # In addition of config.h output a full DEFS
500 AT_DATA([config.hin],
503 # define baz "Archimedes was sinking in his baz"
511 #define aaa(a, aa) aa a
513 #define aaac(a, aa) aa a
515 # undef multiline_args
516 #define paste(a,b) a##b
518 #define str(define) \
520 #define stringify(arg) str(arg)
521 #undef aaa /* with comments */
522 #undef not_substed /* with comments */
529 [[/* config.h. Generated from config.hin by configure. */
542 #define aaac(a, aa) aa a
543 #define multiline line1\
547 # define multiline_args(ARG1, ARG2) ARG2 \
549 #define paste(a,b) a##b
551 #define str(define) \
553 #define stringify(arg) str(arg)
555 /* #undef not_substed */
557 AT_CHECK([cat config.h], 0, expout)
559 # Check the value of DEFS.
561 [[-DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -Dfoo=toto -Dbar=tata -Dbaz=titi -Dfubar=tutu -Da=A -Daaa=AAA -Daa=AA -Dmultiline=line1line2line3\ line4 -Dmultiline_args\(ARG1,\ ARG2\)=ARG2\ ARG1 -Dpaste\(a,b\)=a\#\#b
564 # Because we strip trailing spaces in `testsuite' we can't leave one in
565 # expout, hence nuke the one left by AC_OUTPUT_MAKE_DEFS.
566 AT_CHECK([sed -e 's/ $//' defs], 0, expout)
572 ## ------------------------- ##
573 ## Torturing config.status. ##
574 ## ------------------------- ##
576 ## Require 100 AC_DEFINE and AC_SUBST and AC_SUBST_FILE with a significantly
577 ## big value. This is mostly to check that Autoconf produces portable sed
578 ## scripts in config.status. sed is used to skip the first two lines
579 ## `Generated by...'.
581 # We use m4_for many times.
582 m4_pattern_allow([^m4_for$])
584 AT_SETUP([Torturing config.status])
586 dnl The value used as a big value for AC_DEFINE.
587 dnl Don't use sh active chars here, below it is also used in a sh
589 m4_define([AT_BIG_VALUE],
590 [This value should be long enough to torture the various limits of sed and other tools used by Autoconf.])
592 m4_define([AT_DESCRIPTION],
593 [Define to a long string if your `Autoconf' works properly.])
596 # AT_DUMMY_VAR(NUMBER)
597 # --------------------
598 # Build a name used for AC_SUBST and AC_DEFINE. Put ac_ in it
599 # so that the check for user name space invasion does not complain
600 # of the new variables defined.
602 # Note that you should not use the name ac_dummy, because it will be
603 # turned into ac_uummy during the construction of config.status. Yes,
604 # this is admittedly a bug, but it would be too hard to fix this.
605 # There is really no point in AC_DEFINE a var named ac_d.*.
606 m4_pattern_allow([^m4_bpatsubst$])
607 m4_define([AT_DUMMY_VAR],
608 [ac_Dummy_[]m4_bpatsubst([000$1], [.*\(...\)$], [\1])])
613 [m4_for([AT_Count], 1, 100, 1,
614 [@AT_DUMMY_VAR(AT_Count)@
620 while test $i != 101; do
621 echo "content of file $i" > file_$i
622 AS_VAR_ARITH([i], [$i + 1])
630 m4_pattern_allow([^m4_(define|defun)$])
631 AT_DATA([configure.ac],
632 dnl The following lines transfer AT_DUMMY_VAR, AT_DESCRIPTION, and
633 dnl AT_BIG_VALUE into the configure.ac as AC_DUMMY_VAR etc.
634 [[m4_define([AC_DUMMY_VAR],]
635 m4_dquote(m4_defn([AT_DUMMY_VAR]))[)]]
637 [[m4_define([AC_DESCRIPTION],]
638 m4_dquote(m4_defn([AT_DESCRIPTION]))[)]]
640 [[m4_define([AC_BIG_VALUE],]
641 m4_dquote(m4_defn([AT_BIG_VALUE]))[)]]
645 # Related VALUE to NAME both with AC_SUBST and AC_DEFINE. This is
646 # used in the torture tests.
647 m4_defun([AC_DEFUBST],
648 [AC_DUMMY_VAR($1)="AC_BIG_VALUE"
649 AC_DEFINE_UNQUOTED(AC_DUMMY_VAR($1), "$AC_DUMMY_VAR($1) $AC_DUMMY_VAR($1)",
651 AC_SUBST(AC_DUMMY_VAR($1))
657 AC_CONFIG_HEADERS(config.h:config.hin)
658 AC_CONFIG_FILES(dummy)
659 m4_for(AC_Count, 1, 100, 1,
660 [AC_DEFUBST(AC_Count)])
667 # Check both awk and the result of AC_PROG_AWK
668 for awk_arg in FOO= AWK=awk; do
669 AT_CHECK_CONFIGURE([$awk_arg])
671 # Checking that AC_DEFINE worked properly.
673 [/* Define to the address where bug reports for this package should be sent. */
674 #define PACKAGE_BUGREPORT ""
676 /* Define to the full name of this package. */
677 #define PACKAGE_NAME ""
679 /* Define to the full name and version of this package. */
680 #define PACKAGE_STRING ""
682 /* Define to the one symbol short name of this package. */
683 #define PACKAGE_TARNAME ""
685 /* Define to the home page for this package. */
686 #define PACKAGE_URL ""
688 /* Define to the version of this package. */
689 #define PACKAGE_VERSION ""
690 m4_for(AT_Count, 1, 100, 1,
693 [#define] AT_DUMMY_VAR(AT_Count) "AT_BIG_VALUE AT_BIG_VALUE"
696 AT_CHECK([sed -n '4,$ p' config.h], 0, expout)
698 # Checking that AC_SUBST worked properly.
700 [m4_for(AT_Count, 1, 100, 1,
702 content of file AT_Count
705 AT_CHECK([cat dummy], 0, expout)
711 ## ------------------------------- ##
712 ## Substitute a 2000-byte string. ##
713 ## ------------------------------- ##
715 # Solaris 9 /usr/ucb/sed that rejects commands longer than 4000 bytes. HP/UX
716 # sed dumps core around 8 KiB. However, POSIX says that sed need not
717 # handle lines longer than 2048 bytes (including the trailing newline).
718 # So we'll just test a 2000-byte value, and for awk, we test a line with
719 # almost 1000 words, and one variable with 5 lines of 2000 bytes each:
720 # multi-line values should allow to get around the limitations.
722 AT_SETUP([Substitute a 2000-byte string])
724 AT_DATA([Foo.in], [@foo@
726 AT_DATA([Bar.in], [@bar@
728 AT_DATA([Baz.in], [@baz@
731 AT_DATA([configure.ac],
733 AC_SUBST([foo], ]m4_for([n], 1, 100,, ....................)[)
734 AC_SUBST([bar], "]m4_for([n], 1, 100,, @ @ @ @ @ @ @ @ @ @@)[")
735 baz="]m4_for([m], 1, 100,, ... ... ... ... ....)[
737 baz=$baz$baz$baz$baz$baz
740 AC_CONFIG_FILES([Foo Bar Baz])
744 cp "$abs_top_srcdir/build-aux/install-sh" .
747 # Check both awk and the result of AC_PROG_AWK
748 for awk_arg in Foo= AWK=awk; do
749 AT_CHECK_CONFIGURE([$awk_arg])
750 AT_CHECK([cat Foo], 0, m4_for([n], 1, 100,, ....................)
752 AT_CHECK([cat Bar], 0, m4_for([n], 1, 100,, @ @ @ @ @ @ @ @ @ @@)
755 [m4_for([n], 1, 5,, m4_for([m], 1, 100,, ... ... ... ... ....)
757 AT_CHECK([cat Baz], 0, [stdout])
762 ## ------------------------------ ##
763 ## Define to a 2000-byte string. ##
764 ## ------------------------------ ##
766 AT_SETUP([Define to a 2000-byte string])
767 AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
771 AC_DEFINE_UNQUOTED([foo], ]m4_for([n], 1, 100,, ....................)[, [desc])
772 AC_DEFINE([fooq], ]m4_for([n], 1, 100,, ....................)[, [desc])
778 AT_CHECK_DEFINES([@%:@define foo m4_for([n], 1, 100,, ....................)
779 @%:@define fooq m4_for([n], 1, 100,, ....................)
784 ## ------------------------------------------ ##
785 ## Substitute and define special characters. ##
786 ## ------------------------------------------ ##
788 # Use characters special to the shell, sed, awk, and M4.
790 AT_SETUP([Substitute and define special characters])
791 AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
793 AT_DATA([Foo.in], [@foo@
794 @bar@@notsubsted@@baz@ stray @ and more@@@baz@
811 AT_DATA([Zardoz.in], [@zardoz@
815 [[foo="AS@&t@_ESCAPE([[X*'[]+ ", & &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !]])"
819 ( for i in 0 1 2 3; do
820 for j in 0 1 2 3 4 5 6 7; do
821 for k in 0 1 2 3 4 5 6 7; do
823 000 | 015 | 377) ;; # MinGW awk dislikes 0xFF, and the test does
824 # the wrong thing for CR on MinGW.
826 *) printf \\$i$j$k's' ;; # The 's' works around a Solaris 8 /bin/bash bug.
833 zardoz=`cat allowed-chars`
839 AC_SUBST_FILE([file])
840 AC_DEFINE([fooq], [[X*'[]+ ", & &`\($foo !]], [Awful value.])
841 AC_DEFINE([barq], [[%!_!# X]], [Value that is used as special delimiter.])
842 AC_DEFINE_UNQUOTED([foo], [[X*'[]+ ", & &\`\\(\$foo !]], [Awful value.])
843 AC_DEFINE_UNQUOTED([bar], [[%!_!# X]], [Value that is used as special delimiter.])
844 AC_DEFINE_UNQUOTED([unq1], [$baz], [unquoted, test 1])
845 AC_DEFINE_UNQUOTED([unq2], [\$baz], [unquoted, test 2])
846 AC_DEFINE_UNQUOTED([unq3], ["$baz"], [unquoted, test 3])
847 AC_DEFINE_UNQUOTED([unq4], [${baz+set}], [unquoted, test 4])
848 AC_DEFINE_UNQUOTED([unq5], ["${baz+`echo "a b"`}"], [unquoted, test 5])
849 AC_DEFINE_UNQUOTED([unq6], [`echo hi`], [unquoted, test 6])
850 AC_DEFINE_UNQUOTED([unq7], ['\"'], [unquoted, test 7])
852 AC_CONFIG_FILES([Foo Zardoz])]])
856 # Check both awk and the result of AC_PROG_AWK
857 for awk_arg in FOO= AWK=awk; do
858 AT_CHECK_CONFIGURE([$awk_arg])
859 AT_CHECK([cat Foo], 0, [[X*'[]+ ", & &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !
860 @foo@ @baz@@notsubsted@bla stray @ and more@@bla
861 abc@foo@ @baz@baz@baz
863 abc@foo@ @baz@blabaz@
872 AT_CHECK([cmp allowed-chars Zardoz])
873 AT_CHECK_DEFINES([[#define bar %!_!# X
875 #define foo X*'[]+ ", & &`\($foo !
876 #define fooq X*'[]+ ", & &`\($foo !
889 ## ---------------------- ##
890 ## Substitute a newline. ##
891 ## ---------------------- ##
893 AT_SETUP([Substitute a newline])
900 AT_DATA([configure.ac],
908 AC_CONFIG_FILES([Foo])
913 cp "$abs_top_srcdir/build-aux/install-sh" .
921 # Check both awk and the result of AC_PROG_AWK
922 for awk_arg in FOO= AWK=awk; do
923 AT_CHECK_CONFIGURE([$awk_arg])
924 AT_CHECK([cat Foo], 0, [expout])
929 ## ------------------ ##
930 ## Define a newline. ##
931 ## ------------------ ##
933 AT_SETUP([Define a newline])
934 AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
935 AT_CONFIGURE_AC([[AC_DEFINE([foo], [one
936 two], [This spans two lines.])
938 AT_CHECK_AUTOCONF([], [], [], [stderr])
939 dnl Older versions of m4 report error at line 5 (end of macro);
940 dnl newer versions report it at line 4 (start of macro).
941 AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
942 [[warning: AC_DEFINE: `one
943 two' is not a valid preprocessor define value
945 AT_CHECK_AUTOHEADER([], [], [], [stderr])
946 AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
947 [[warning: AC_DEFINE: `one
948 two' is not a valid preprocessor define value
951 AT_CHECK_DEFINES([[#define foo one
954 AT_CONFIGURE_AC([[AC_DEFINE_UNQUOTED([foo], [one
955 two], [This spans two lines.])
957 AT_CHECK_AUTOCONF([], [], [], [stderr])
958 AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
959 [[warning: AC_DEFINE_UNQUOTED: `one
960 two' is not a valid preprocessor define value
962 AT_CHECK_AUTOHEADER([], [], [], [stderr])
963 AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
964 [[warning: AC_DEFINE_UNQUOTED: `one
965 two' is not a valid preprocessor define value
968 AT_CHECK_DEFINES([[#define foo one
974 ## ------------------------------------ ##
975 ## AC_SUBST: variable name validation. ##
976 ## ------------------------------------ ##
978 AT_SETUP([AC_SUBST: variable name validation])
980 AT_CONFIGURE_AC([[AC_SUBST(, [])
981 AC_CONFIG_FILES([Makefile])
983 AT_DATA([Makefile.in], [[
985 mv -f configure.ac configure.tmpl
988 for var in ['' ab\~ ab\( ab[] ab\' ab\" ab\\\\]; do
989 sed ["s/AC_SUBST(/&[$var]/"] <configure.tmpl >configure.ac
990 AT_CHECK_AUTOCONF([], [1], [], [ignore])
994 for var in ab a4 'a@@&t@\&t@b'; do
995 sed ["s/AC_SUBST(/&[$var]/"] <configure.tmpl >configure.ac
1004 ## ------------------------ ##
1005 ## datarootdir workaround. ##
1006 ## ------------------------ ##
1008 AT_SETUP([datarootdir workaround])
1022 AT_DATA([configure.ac],
1024 d@&t@nl The following line silences the warnings, if uncommented:
1025 d@&t@nl AC_DEFUN([AC_DATAROOTDIR_CHECKED])
1027 # This substitution is wrong and bogus! Don't use it in your own code!
1028 # Read `info Autoconf "Defining Directories"'!
1029 AC_SUBST([mydatadir], [${datadir}/my])
1031 AC_CONFIG_FILES([Foo Bar])
1035 cp "$abs_top_srcdir/build-aux/install-sh" .
1038 AT_CHECK_CONFIGURE([], [], [],
1039 [config.status: WARNING: 'Foo.in' seems to ignore the --datarootdir setting
1040 config.status: WARNING: Bar contains a reference to the variable `datarootdir'
1041 which seems to be undefined. Please make sure it is defined.
1043 AT_CHECK([grep datarootdir Foo], 1, [])
1046 sed '/AC_DEFUN/s/^d@&t@nl //' configure.ac >t
1066 AT_DATA([configure.ac],
1069 AC_CONFIG_FILES([foo at-dir/bar])
1071 # Use quotes in the INIT-COMMANDS to accommodate a value of $srcdir
1072 # containing e.g., spaces or shell meta-characters.
1073 # Use *single* quotes because the context is an unquoted here-doc.
1074 AC_CONFIG_COMMANDS([report],
1075 [test -f "$srcdir/configure.ac" ||
1076 AC_MSG_ERROR([cannot find $srcdir/configure.ac])],
1080 rm -f -r foo at-dir/bar
1086 AT_CHECK([./configure], [], [ignore])
1089 AT_CHECK([cd at-dir && ../configure], [], [ignore])
1093 AT_CHECK([cd at-dir && "$at_here/configure"], [], [ignore])
1098 ## ----------------- ##
1099 ## Signal handling. ##
1100 ## ----------------- ##
1102 AT_SETUP([Signal handling])
1104 AT_DATA([configure.ac],
1111 AT_CHECK_CONFIGURE([], 1, ignore, ignore)
1116 ## ------------------------------------- ##
1117 ## AC_CONFIG_LINKS and identical files. ##
1118 ## ------------------------------------- ##
1119 AT_SETUP([AC_CONFIG_LINKS and identical files])
1121 AT_DATA([configure.ac],
1123 AC_CONFIG_LINKS([src/s:src/s])
1124 test "$srcdir" != '.' && AC_CONFIG_LINKS([src/t:src/t])
1133 AT_CHECK([../configure && ../configure], 0, [ignore])
1134 AT_CHECK([cat src/s src/t], 0, [file1
1138 AT_CHECK([./configure && ./configure], 0, [ignore], [stderr])
1139 AT_CHECK([grep src/t stderr], 1)
1140 AT_CHECK([cat src/s src/t], 0, [file1
1143 AT_CHECK(["`pwd`"/configure && "`pwd`"/configure], 0, [ignore], [ignore])
1144 AT_CHECK([cat src/s src/t], 0, [file1
1151 AT_BANNER([autoreconf.])
1153 ## ---------------------------- ##
1154 ## Configuring subdirectories. ##
1155 ## ---------------------------- ##
1160 # | |-- config.status
1163 # | |-- config.status
1170 # | |-- configure.ac
1175 AT_SETUP([Configuring subdirectories])
1176 AT_KEYWORDS(autoreconf)
1178 # We use aclocal (via autoreconf).
1179 AT_CHECK([aclocal --version || exit 77], [], [stdout], [ignore])
1180 # It should understand configure.ac.
1181 AT_CHECK([[grep '[^0-9]1.[01234][^0-9]' stdout && exit 77]], [1], [ignore])
1183 # Set CONFIG_SITE to a nonexistent file, so that there are
1184 # no worries about nonstandard values for 'prefix'.
1185 CONFIG_SITE=no-such-file
1188 # The contents of `inner/', and `inner/innermost/'.
1189 AS_MKDIR_P([inner/innermost])
1191 # We have to use configure.in, not configure.ac, if we still want to
1192 # be compatible with Automake 1.4: aclocal (run by autoreconf) would
1193 # die because it can't find configure.in.
1194 AT_DATA([inner/configure.in],
1195 [[AC_INIT(GNU Inner, 1.0)
1196 AC_CONFIG_SRCDIR([innermost/config.in])
1197 AC_ARG_VAR([INNER], [an inner variable])
1199 if test "x$INNER" = x; then
1202 AC_CONFIG_FILES([innermost/config])
1206 AT_DATA([inner/innermost/config.in],
1209 top_srcdir=@top_srcdir@
1213 # The contents of `.'
1214 AT_DATA([install-sh], [])
1216 # nonexistent is allowed not to exist.
1217 AT_DATA([configure.in],
1218 [[AC_INIT(GNU Outer, 1.0)
1219 AC_ARG_VAR([OUTER], [an outer variable])
1221 AC_CONFIG_SUBDIRS([nonexistent])
1223 AC_CONFIG_SUBDIRS([inner])
1227 # If there are improperly quoted AC_DEFUN installed in share/aclocal,
1228 # they trigger warnings from aclocal 1.8, so ignore stderr.
1229 AT_CHECK([autoreconf], [], [], [ignore])
1230 AT_CHECK([test -f inner/configure])
1232 # Running the outer configure recursively should provide the innermost
1234 chmod a-w inner/innermost inner .
1235 AT_CHECK([{ ./configure --help=recursive; chmod u+w .; } | grep INNER], 0,
1237 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1238 chmod u+w . inner inner/innermost
1240 # Running the outer configure should trigger the inner.
1242 AT_CHECK([cat inner/innermost/config], 0,
1249 # The same, but from a builddir.
1250 AS_MKDIR_P([builddir])
1251 AT_CHECK([cd builddir && ../configure], 0, [ignore])
1252 AT_CHECK([cat builddir/inner/innermost/config], 0,
1254 srcdir=../../../inner/innermost
1255 top_srcdir=../../../inner
1259 # Make sure precious variables and command line options are properly
1260 # passed, even when there are duplicates.
1261 AT_CHECK([cd builddir && ../configure --prefix /bad --prefix /good INNER=bad INNER=good], 0, [ignore])
1262 AT_CHECK([cat builddir/inner/innermost/config], 0,
1264 srcdir=../../../inner/innermost
1265 top_srcdir=../../../inner
1269 # Make sure --prefix is properly quoted
1270 AT_CHECK([cd builddir && ../configure --prefix "/a b c$ 'd"], 0, [ignore])
1271 AT_CHECK([cat builddir/inner/innermost/config], 0,
1273 srcdir=../../../inner/innermost
1274 top_srcdir=../../../inner
1278 # Make sure --silent is properly passed...
1279 AT_CHECK([cd builddir && ../configure --silent], 0, [])
1280 # ...but not stored in config.status.
1281 AT_CHECK([cd builddir && ./config.status --recheck], 0, [stdout])
1282 AT_CHECK([grep 'creating \./config.status' stdout], 0, [ignore])
1284 # Make sure we can run autoreconf on a subdirectory
1285 rm -f configure configure.in
1286 AT_CHECK([autoreconf inner], [], [], [ignore])
1288 # Make sure we can pass a configure.ac name
1289 AT_CHECK([cd inner && autoreconf configure.in], [], [], [ignore])
1290 AT_CHECK([autoreconf inner/configure.in], [], [], [ignore])
1296 ## -------------- ##
1298 ## -------------- ##
1300 AT_SETUP([Deep Package])
1301 AT_KEYWORDS(autoreconf)
1303 # We use aclocal (via autoreconf).
1304 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
1306 # The contents of `.'
1307 AT_DATA([install-sh], [])
1308 AT_DATA([configure.in],
1309 [[AC_INIT(GNU Outer, 1.0)
1310 AC_ARG_VAR([OUTER], [an outer variable])
1311 AC_CONFIG_SUBDIRS([inner inner2])
1315 # The contents of `inner/', and `inner/innermost/'.
1316 AS_MKDIR_P([inner/innermost])
1317 AS_MKDIR_P([inner2])
1319 AT_DATA([inner/configure.in],
1320 [[AC_INIT(GNU Inner, 1.0)
1321 AC_ARG_VAR([INNER], [an inner variable])
1322 AC_CONFIG_SUBDIRS(innermost)
1326 AT_DATA([inner/innermost/configure.in],
1327 [[AC_INIT(GNU Innermost, 1.0)
1328 AC_ARG_VAR([INNERMOST], [an innermost variable])
1329 AC_CONFIG_HEADERS(config.h:config.hin)
1330 AC_DEFINE_UNQUOTED([INNERMOST], [$INNERMOST], [an innermost variable])
1331 if test -n "$innermost_error"; then
1332 AC_MSG_FAILURE([error in $PACKAGE_NAME])
1337 AT_DATA([inner2/configure.in],
1338 [[AC_INIT(GNU Inner 2, 1.0)
1339 AC_ARG_VAR([INNER2], [an inner2 variable])
1343 AT_CHECK([autoreconf -Wall -v], [0], [ignore], [ignore])
1344 AT_CHECK([test -f inner/configure])
1345 AT_CHECK([test -f inner/innermost/configure])
1346 AT_CHECK([test -f inner/innermost/config.hin])
1347 AT_CHECK([test -f inner2/configure])
1349 # Running the outer configure recursively should provide the innermost
1351 chmod a-w inner/innermost inner
1352 AT_CHECK([{ ./configure --help=recursive; chmod u+w .; } | grep " INNER "],
1353 0, [ignore], [stderr],
1354 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1356 AT_CHECK([{ ./configure --help=recursive; chmod u+w .; } | grep " INNER2 "],
1357 0, [ignore], [stderr],
1358 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1360 AT_CHECK([{ ./configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1361 0, [ignore], [stderr],
1362 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1364 AT_CHECK([{ /bin/sh ./configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1365 0, [ignore], [stderr],
1366 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1368 AT_CHECK([PATH=.$PATH_SEPARATOR$PATH; export PATH; { /bin/sh configure --help=recursive; chmod +w .; } | grep " INNERMOST "],
1369 0, [ignore], [stderr],
1370 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1372 AT_CHECK([PATH=.$PATH_SEPARATOR$PATH; export PATH; { configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1373 0, [ignore], [stderr],
1374 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1375 chmod u+w inner inner/innermost
1377 # Running the outer configure should trigger the inner.
1378 AT_CHECK_CONFIGURE([INNERMOST=tsomrenni])
1379 AT_CHECK([grep INNERMOST inner/innermost/config.h], 0,
1380 [[#define INNERMOST tsomrenni
1383 # Ensure we point to the right config.log file for errors.
1384 AT_CHECK_CONFIGURE([innermost_error=:], [1], [], [stderr])
1385 AT_CHECK([grep 'inner/innermost' stderr], [], [ignore])
1387 AT_CHECK_CONFIGURE([innermost_error=:], [1], [], [stderr])
1388 AT_CHECK([grep 'innermost' stderr], [], [ignore])
1391 # The same, but from a builddir.
1392 AS_MKDIR_P([builddir])
1393 chmod a-w builddir inner/innermost inner
1394 AT_CHECK([cd builddir && { ../configure --help=recursive; chmod u+w .; } | grep " INNER "],
1395 0, [ignore], [stderr],
1396 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1398 AT_CHECK([cd builddir && { ../configure --help=recursive; chmod u+w .; } | grep " INNER2 "],
1399 0, [ignore], [stderr],
1400 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1402 AT_CHECK([cd builddir && { ../configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1403 0, [ignore], [stderr],
1404 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1406 AT_CHECK([cd builddir && { /bin/sh ../configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1407 0, [ignore], [stderr],
1408 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1410 # Not all shells search $PATH for scripts.
1411 if (cd builddir && PATH=`pwd`/..$PATH_SEPARATOR$PATH /bin/sh configure --help) >/dev/null 2>&1; then
1412 AT_CHECK([cd builddir && PATH=`pwd`/..$PATH_SEPARATOR$PATH /bin/sh configure --help=recursive | grep " INNERMOST "], 0, [ignore])
1414 AT_CHECK([PATH=`pwd`$PATH_SEPARATOR$PATH; export PATH; cd builddir && { configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1415 0, [ignore], [stderr],
1416 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1417 chmod u+w builddir inner inner/innermost
1418 AT_CHECK([cd builddir && ../configure INNERMOST=build/tsomrenni], 0, [ignore])
1419 AT_CHECK([grep INNERMOST builddir/inner/innermost/config.h], 0,
1420 [[#define INNERMOST build/tsomrenni
1427 ## -------------------------------- ##
1428 ## Non-Autoconf AC_CONFIG_SUBDIRS. ##
1429 ## -------------------------------- ##
1431 AT_SETUP([Non-Autoconf AC_CONFIG_SUBDIRS])
1432 AT_KEYWORDS([autoreconf])
1434 # We use aclocal (via autoreconf).
1435 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
1437 AT_DATA([install-sh], [])
1438 AT_DATA([configure.in],
1439 [[AC_INIT(GNU Outer, 1.0)
1440 AC_CONFIG_SUBDIRS([inner])
1446 AT_DATA([inner/configure],
1449 *--help*) echo 'No Autoconf here, folks!' ;;
1450 *) echo got_it >myfile ;;
1454 chmod +x inner/configure
1456 AT_CHECK([autoreconf -Wall -v], 0, [ignore], [ignore])
1458 # Running the outer configure recursively should provide the innermost
1460 AT_CHECK([./configure --help=recursive | grep "folks"], 0, [ignore])
1462 # Running the outer configure should trigger the inner.
1463 AT_CHECK([./configure], 0, [ignore])
1464 AT_CHECK([test -f inner/myfile], 0)
1470 ## ----------------- ##
1471 ## Empty directory. ##
1472 ## ----------------- ##
1474 AT_SETUP([Empty directory])
1475 AT_KEYWORDS([autoreconf])
1477 # We use aclocal (via autoreconf).
1478 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
1480 # The test group directory is not necessarily _empty_, but it does not contain
1481 # files meaningful to `autoreconf'.
1483 AT_CHECK([autoreconf -Wall -v], 1, [ignore], [ignore])
1489 ## ------------------------------ ##
1490 ## Unusual Automake input files. ##
1491 ## ------------------------------ ##
1493 # This parallels gnumake.test in Automake.
1495 AT_SETUP([Unusual Automake input files])
1496 AT_KEYWORDS([autoreconf])
1498 # We use aclocal and automake via autoreconf.
1499 AT_CHECK([automake --version || exit 77], [], [ignore], [ignore])
1501 AT_DATA([configure.in],
1502 [[AC_INIT(GNU foo, 1.0)
1504 AC_CONFIG_FILES([HeeHee])
1508 AT_DATA([HeeHee.am],
1509 [[# Humans do no worse than `GNUmakefile.am'.
1510 AUTOMAKE_OPTIONS = foreign 1.8
1513 AT_CHECK([autoreconf -Wall -v -i], 0, [ignore], [stderr],
1514 [AT_CHECK([grep 'require.*1\.8' stderr && exit 77], [1])])
1515 AT_CHECK([test -f HeeHee.in])