3 # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
4 # 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])
51 # AT_CHECK_AC_ARG_VAR(FIRST-VALUE, SECOND-VALUE, [STATUS = 1])
52 # ------------------------------------------------------------
53 # Check that AC_ARG_VAR caches the latest values, diagnoses
54 # inconsistencies, and arms config.status. Check that recheck
55 # returns STATUS, save configure output in files 'stdout' and 'stderr'
56 # for further inspection.
57 m4_define([AT_CHECK_AC_ARG_VAR],
62 [precious='m4_bpatsubst([$1], [[']], ['\\''])'; export precious],
64 AT_CHECK_CONFIGURE([--config-cache -q])
65 AT_CHECK([cat file], [], [`$1'
68 # Testing --recheck: 1. have the environment `forget' about PRECIOUS.
70 # 2. Rerun config.status to recreate `file'.
71 AT_CHECK([./config.status --recheck], [], [ignore])
72 AT_CHECK([./config.status], [], [ignore])
73 # 3. Check that file contains the old value of PRECIOUS.
74 AT_CHECK([cat file], [], [`$1'
77 # Second value: we should issue an error here: the value
80 [precious='$2'; export precious],
82 AT_CHECK_CONFIGURE([--config-cache], [m4_default([$3], [1])], [stdout], [stderr])
84 ])# AT_CHECK_AC_ARG_VAR
87 AT_SETUP([AC_ARG_VAR])
89 # We don't want to run this test if this shell doesn't support
92 if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
99 AT_DATA([configure.ac],
101 AC_ARG_VAR([precious], [this variable costs a lot])
102 echo "precious:$precious"
112 # Set a precious variable
113 AT_CHECK_AC_ARG_VAR([], [apple of my eye])
115 # Unset a precious variable
116 AT_CHECK_AC_ARG_VAR([apple of my eye], [])
118 # Change a precious variable
119 AT_CHECK_AC_ARG_VAR([apple of my eye], [orange of my eye])
121 # Change a precious variable that contains braces
122 AT_CHECK_AC_ARG_VAR([apple of my {eye}], [orange of my eye])
124 # Change a precious variable that contains all kinds of fun
125 AT_CHECK_AC_ARG_VAR(['p r ec"iou$], [orange of my eye])
126 dnl restore font-lock: "
128 # Warn (but do not fail) about a whitespace-only change
129 AT_CHECK_AC_ARG_VAR([ apple of my eye ], [apple of my eye],
130 [0], ["has whitespace changes"])
131 mv stdout configure-output
132 AT_CHECK([grep "ignoring whitespace changes" stderr], [], [ignore])
133 AT_CHECK([grep "precious: apple" configure-output], [], [ignore])
140 ## ---------------------------------------------- ##
141 ## AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS. ##
142 ## ---------------------------------------------- ##
144 AT_SETUP([[AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS]])
146 AT_DATA([configure.ac],
149 rm -f -r header var-header file var-file link var-link command var-command
152 # Be sure to also stress the associated INIT-CMDS.
153 case $what_to_test in
155 AC_CONFIG_HEADERS(header:input);;
157 AC_CONFIG_HEADERS(var-header:$header_in, [], [header_in=input]);;
160 AC_CONFIG_FILES(file:input);;
162 AC_CONFIG_FILES(var-file:$file_in, [], [file_in=input]);;
165 AC_CONFIG_COMMANDS(command,
166 [cp input command]);;
168 AC_CONFIG_COMMANDS(var-command,
169 [cp $command_in var-command], [command_in=input]);;
172 AC_CONFIG_LINKS(link:input);;
174 AC_CONFIG_LINKS(var-link:$link_in, [], [link_in=input]);;
182 # AT_CHECK_CONFIG_CREATION(THING = (header | link | file | command))
183 # ------------------------------------------------------------------
184 # Check that THING and var-THING (which uses variables in AC_CONFIG_THING)
185 # are properly created, with the right content.
186 # Use `grep OK' instead of a simple `cat' to avoid banners such as in
188 m4_define([AT_CHECK_CONFIG_CREATION],
189 [AT_CHECK_CONFIGURE([what_to_test=$1])
190 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
193 AT_CHECK([grep OK $1], [], [OK
196 AT_CHECK_CONFIGURE([what_to_test=var-$1 --no-create])
197 # config.status might be stupidly expecting data on stdin, if it's
199 AT_CHECK([./config.status var-$1 </dev/null], [], [ignore])
200 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
203 AT_CHECK([grep OK var-$1], [], [OK
205 ])# AT_CHECK_CONFIG_CREATION
208 # AT_CHECK_CONFIG_CREATION_NOWRITE(THING = (header | link | file | command))
209 # ------------------------------------------------------------------
210 # Check that THING and var-THING (which uses variables in AC_CONFIG_THING)
211 # are properly created, with the right content.
212 # Use `grep OK' instead of a simple `cat' to avoid banners such as in
214 m4_define([AT_CHECK_CONFIG_CREATION_NOWRITE],
215 [AT_CHECK_CONFIGURE([what_to_test=$1])
216 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
219 AT_CHECK([grep OK $1], [], [OK
222 AT_CHECK_CONFIGURE([what_to_test=var-$1 --no-create])
223 # config.status might be stupidly expecting data on stdin, if it's
225 # Skip check if user can rename files into a read-only directory (when
226 # run by root or on w32).
229 mv t t1 >/dev/null 2>&1 \
230 || AT_CHECK([./config.status var-$1 </dev/null], [1], [ignore], [ignore])
233 ])# AT_CHECK_CONFIG_CREATION_NOWRITE
237 AT_CHECK_CONFIG_CREATION(file)
240 AT_CHECK_CONFIG_CREATION(header)
243 AT_CHECK_CONFIG_CREATION(command)
246 AT_CHECK_CONFIG_CREATION(link)
248 # Now check for write errors
251 AT_CHECK_CONFIG_CREATION_NOWRITE(file)
252 # Create a file with bits from stdin
253 AT_CHECK([echo from-stdin | ./config.status --file=file:-],
255 AT_CHECK([grep from-stdin file], [], [from-stdin
257 # Force write error creating a file on stdout
258 if test -w /dev/full && test -c /dev/full; then
259 AT_CHECK([./config.status --file=-:input </dev/null >/dev/full],
260 [1], [ignore], [ignore])
264 AT_CHECK_CONFIG_CREATION_NOWRITE(header)
265 # Create a header on stdout
266 AT_CHECK([./config.status --header=-:input </dev/null],
267 [0], [stdout], [ignore])
268 AT_CHECK([grep OK stdout], [], [OK
270 # Force write error creating a header on stdout
271 if test -w /dev/full && test -c /dev/full; then
272 AT_CHECK([./config.status --header=-:input </dev/null >/dev/full],
273 [1], [ignore], [ignore])
277 AT_CHECK_CONFIG_CREATION_NOWRITE(command)
280 AT_CHECK_CONFIG_CREATION_NOWRITE(link)
282 # Check that no use of `ac_write_fail' escaped into config.status
283 AT_CHECK([grep ac_write_fail config.status], [1])
285 # Check that --file and --header accept funny file names
289 ./config.status --file=fgrep:fgrep.in
295 'with funny '\'' $x & #! name' \
296 'file with funny \ '\'' \'\'' $ & #!*? name' \
297 'with funny \ '\'' \'\'' " | <a >b & * ? name ' # "restore font-lock
299 # The function func_sanitize_file_name comes from tools.at
300 file=`func_sanitize_file_name "$file"`
301 cat >"$file.in" <<'END'
304 AT_CHECK([./config.status "--file=$file:$file.in"],
306 AT_CHECK([$FGREP "$file" "$file"], [0], [ignore])
307 AT_CHECK([./config.status "--header=$file:$file.in"],
309 # Run the same test a 2nd time to see that config.status does not recreate
310 # the header (regression test)
311 AT_CHECK_NOESCAPE([./config.status "--header=$file:$file.in"],
312 [0], [config.status: creating $file
313 config.status: $file is unchanged
315 AT_CHECK_NOESCAPE([grep ' & ' "$file"], [],
316 [/* $file. Generated from $file.in by configure. */
318 AT_CHECK([$FGREP "$file" "$file"], [0], [ignore])
324 ## ---------------------------------------- ##
325 ## Macro calls in AC_CONFIG_COMMANDS tags. ##
326 ## ---------------------------------------- ##
328 AT_SETUP([Macro calls in AC_CONFIG_COMMANDS tags])
330 AT_DATA_M4SUGAR([configure.ac],
332 AC_CONFIG_COMMANDS([m4_if(1,1,mytag)])
343 ## ------------------- ##
344 ## Missing templates. ##
345 ## ------------------- ##
347 # Check that config.status detects missing input files
348 AT_SETUP([Missing templates])
350 AT_DATA([configure.ac],
352 AC_CONFIG_FILES([nonexistent])
357 AT_CHECK_CONFIGURE([], [1], [],
358 [[config.status: error: cannot find input file: nonexistent.in
360 # Make sure that the output file doesn't exist
361 AT_CHECK([test -f nonexistent], 1)
368 ## ---------------------- ##
369 ## configure invocation. ##
370 ## ---------------------- ##
372 # Check that `configure' and `config.status' honor their interface.
374 # We run `./configure one=val1 --enable-two=val2 --with-three=val3'
375 # and verify that (i) `configure' correctly receives the arguments,
376 # (ii) correctly passes them to `config.status', which we check by
377 # running `config.status --recheck', and (iii) correctly passes them
378 # to sub-configure scripts.
380 AT_SETUP([configure invocation])
384 AT_DATA([configure.ac],
386 AC_CONFIG_SUBDIRS([sub])
387 echo "result=$one$enable_two$with_three"
391 AT_DATA([sub/configure.ac],
393 echo "result=$one$enable_two$with_three"
397 echo fake install-sh script >install-sh
404 AT_CHECK_CONFIGURE([one=one --enable-two=two --with-three=three |
405 sed -n -e 's/^result=//p'], 0,
409 AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
413 AT_CHECK_CONFIGURE([one="\"'$ " --enable-two="\" ' $" --with-three=" \"'$"|
414 sed -n -e 's/^result=//p'], 0,
415 [m4_do(["'$ " ' $ "'$
418 AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
421 dnl restore font-lock: "
427 ## -------------------------------------------- ##
428 ## Check that `#define' templates are honored. ##
429 ## -------------------------------------------- ##
431 # Use various forms of `#define' templates, and make sure there are no
432 # problems when a symbol is prefix of another.
434 AT_SETUP([@%:@define header templates])
436 AT_DATA([configure.ac],
438 AC_CONFIG_HEADERS(config.h:config.hin)
440 # I18n of dummy variables: their French translations.
444 AC_DEFINE(fubar, tutu)
446 # Symbols which are prefixes of another.
451 # backslash-newline combinations
452 AC_DEFINE([multiline], [line1\
456 AC_DEFINE([multiline_args(ARG1, ARG2)], [ARG2 \
458 AC_CONFIG_FILES(defs)
460 # Things included in confdefs.h, but which make no sense in
461 # config.h, nor in $DEFS.
462 cat <<\EOF >>confdefs.h
463 /* Hi Mum! Look, I am doing C++! */
465 void exit (int status);
469 # In addition of config.h output a full DEFS
480 AT_DATA([config.hin],
483 # define baz "Archimedes was sinking in his baz"
491 #define aaa(a, aa) aa a
493 #define aaac(a, aa) aa a
495 # undef multiline_args
497 #define str(define) \
499 #define stringify(arg) str(arg)
500 #undef aaa /* with comments */
501 #undef not_substed /* with comments */
508 [[/* config.h. Generated from config.hin by configure. */
521 #define aaac(a, aa) aa a
522 #define multiline line1\
526 # define multiline_args(ARG1, ARG2) ARG2 \
529 #define str(define) \
531 #define stringify(arg) str(arg)
533 /* #undef not_substed */
535 AT_CHECK([cat config.h], 0, expout)
537 # Check the value of DEFS.
539 [[-DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -Dfoo=toto -Dbar=tata -Dbaz=titi -Dfubar=tutu -Da=A -Daaa=AAA -Daa=AA -Dmultiline=line1line2line3\ line4 -Dmultiline_args\(ARG1,\ ARG2\)=ARG2\ ARG1
542 # Because we strip trailing spaces in `testsuite' we can't leave one in
543 # expout, hence nuke the one left by AC_OUTPUT_MAKE_DEFS.
544 AT_CHECK([sed -e 's/ $//' defs], 0, expout)
550 ## ------------------------- ##
551 ## Torturing config.status. ##
552 ## ------------------------- ##
554 ## Require 100 AC_DEFINE and AC_SUBST and AC_SUBST_FILE with a significantly
555 ## big value. This is mostly to check that Autoconf produces portable sed
556 ## scripts in config.status. sed is used to skip the first two lines
557 ## `Generated by...'.
559 # We use m4_for many times.
560 m4_pattern_allow([^m4_for$])
562 AT_SETUP([Torturing config.status])
564 dnl The value used as a big value for AC_DEFINE.
565 dnl Don't use sh active chars here, below it is also used in a sh
567 m4_define([AT_BIG_VALUE],
568 [This value should be long enough to torture the various limits of sed and other tools used by Autoconf.])
570 m4_define([AT_DESCRIPTION],
571 [Define to a long string if your `Autoconf' works properly.])
574 # AT_DUMMY_VAR(NUMBER)
575 # --------------------
576 # Build a name used for AC_SUBST and AC_DEFINE. Put ac_ in it
577 # so that the check for user name space invasion does not complain
578 # of the new variables defined.
580 # Note that you should not use the name ac_dummy, because it will be
581 # turned into ac_uummy during the construction of config.status. Yes,
582 # this is admittedly a bug, but it would be too hard to fix this.
583 # There is really no point in AC_DEFINE a var named ac_d.*.
584 m4_pattern_allow([^m4_bpatsubst$])
585 m4_define([AT_DUMMY_VAR],
586 [ac_Dummy_[]m4_bpatsubst([000$1], [.*\(...\)$], [\1])])
591 [m4_for([AT_Count], 1, 100, 1,
592 [@AT_DUMMY_VAR(AT_Count)@
598 while test $i != 101; do
599 echo "content of file $i" > file_$i
608 m4_pattern_allow([^m4_(define|defun)$])
609 AT_DATA([configure.ac],
610 dnl The following lines transfer AT_DUMMY_VAR, AT_DESCRIPTION, and
611 dnl AT_BIG_VALUE into the configure.ac as AC_DUMMY_VAR etc.
612 [[m4_define([AC_DUMMY_VAR],]
613 m4_dquote(m4_defn([AT_DUMMY_VAR]))[)]]
615 [[m4_define([AC_DESCRIPTION],]
616 m4_dquote(m4_defn([AT_DESCRIPTION]))[)]]
618 [[m4_define([AC_BIG_VALUE],]
619 m4_dquote(m4_defn([AT_BIG_VALUE]))[)]]
623 # Related VALUE to NAME both with AC_SUBST and AC_DEFINE. This is
624 # used in the torture tests.
625 m4_defun([AC_DEFUBST],
626 [AC_DUMMY_VAR($1)="AC_BIG_VALUE"
627 AC_DEFINE_UNQUOTED(AC_DUMMY_VAR($1), "$AC_DUMMY_VAR($1) $AC_DUMMY_VAR($1)",
629 AC_SUBST(AC_DUMMY_VAR($1))
635 AC_CONFIG_HEADERS(config.h:config.hin)
636 AC_CONFIG_FILES(dummy)
637 m4_for(AC_Count, 1, 100, 1,
638 [AC_DEFUBST(AC_Count)])
645 # Check both awk and the result of AC_PROG_AWK
646 for awk_arg in FOO= AWK=awk; do
647 AT_CHECK_CONFIGURE([$awk_arg])
649 # Checking that AC_DEFINE worked properly.
651 [/* Define to the address where bug reports for this package should be sent. */
652 #define PACKAGE_BUGREPORT ""
654 /* Define to the full name of this package. */
655 #define PACKAGE_NAME ""
657 /* Define to the full name and version of this package. */
658 #define PACKAGE_STRING ""
660 /* Define to the one symbol short name of this package. */
661 #define PACKAGE_TARNAME ""
663 /* Define to the version of this package. */
664 #define PACKAGE_VERSION ""
665 m4_for(AT_Count, 1, 100, 1,
668 [#define] AT_DUMMY_VAR(AT_Count) "AT_BIG_VALUE AT_BIG_VALUE"
671 AT_CHECK([sed -n '4,$ p' config.h], 0, expout)
673 # Checking that AC_SUBST worked properly.
675 [m4_for(AT_Count, 1, 100, 1,
677 content of file AT_Count
680 AT_CHECK([cat dummy], 0, expout)
686 ## ------------------------------- ##
687 ## Substitute a 2000-byte string. ##
688 ## ------------------------------- ##
690 # Solaris 9 /usr/ucb/sed that rejects commands longer than 4000 bytes. HP/UX
691 # sed dumps core around 8 KiB. However, POSIX says that sed need not
692 # handle lines longer than 2048 bytes (including the trailing newline).
693 # So we'll just test a 2000-byte value, and for awk, we test a line with
694 # almost 1000 words, and one variable with 5 lines of 2000 bytes each:
695 # multi-line values should allow to get around the limitations.
697 AT_SETUP([Substitute a 2000-byte string])
699 AT_DATA([Foo.in], [@foo@
701 AT_DATA([Bar.in], [@bar@
703 AT_DATA([Baz.in], [@baz@
706 AT_DATA([configure.ac],
708 AC_SUBST([foo], ]m4_for([n], 1, 100,, ....................)[)
709 AC_SUBST([bar], "]m4_for([n], 1, 100,, @ @ @ @ @ @ @ @ @ @@)[")
710 baz="]m4_for([m], 1, 100,, ... ... ... ... ....)[
712 baz=$baz$baz$baz$baz$baz
715 AC_CONFIG_FILES([Foo Bar Baz])
719 cp "$abs_top_srcdir/build-aux/install-sh" .
722 # Check both awk and the result of AC_PROG_AWK
723 for awk_arg in Foo= AWK=awk; do
724 AT_CHECK_CONFIGURE([$awk_arg])
725 AT_CHECK([cat Foo], 0, m4_for([n], 1, 100,, ....................)
727 AT_CHECK([cat Bar], 0, m4_for([n], 1, 100,, @ @ @ @ @ @ @ @ @ @@)
730 [m4_for([n], 1, 5,, m4_for([m], 1, 100,, ... ... ... ... ....)
732 AT_CHECK([cat Baz], 0, [stdout])
737 ## ------------------------------ ##
738 ## Define to a 2000-byte string. ##
739 ## ------------------------------ ##
741 AT_SETUP([Define to a 2000-byte string])
745 AC_DEFINE([foo], ]m4_for([n], 1, 100,, ....................)[, [desc])
751 AT_CHECK_DEFINES([@%:@define foo m4_for([n], 1, 100,, ....................)
756 ## ------------------------------------------ ##
757 ## Substitute and define special characters. ##
758 ## ------------------------------------------ ##
760 # Use characters special to the shell, sed, awk, and M4.
762 AT_SETUP([Substitute and define special characters])
764 AT_DATA([Foo.in], [@foo@
765 @bar@@notsubsted@@baz@ stray @ and more@@@baz@
782 AT_DATA([Zardoz.in], [@zardoz@
786 [[foo="AS@&t@_ESCAPE([[X*'[]+ ",& &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !]])"
789 ( for i in 0 1 2 3; do
790 for j in 0 1 2 3 4 5 6 7; do
791 for k in 0 1 2 3 4 5 6 7; do
793 000 | 015 | 377) ;; # MinGW awk dislikes 0xFF, and the test does
794 # the wrong thing for CR on MinGW.
796 *) printf \\$i$j$k's' ;; # The 's' works around a Solaris 8 /bin/bash bug.
803 zardoz=`cat allowed-chars`
809 AC_SUBST_FILE([file])
810 AC_DEFINE([foo], [[X*'[]+ ",& &`\($foo !]], [Awful value.])
811 AC_DEFINE([bar], [[%!_!# X]], [Value that is used as special delimiter.])
813 AC_CONFIG_FILES([Foo Zardoz])]])
817 # Check both awk and the result of AC_PROG_AWK
818 for awk_arg in FOO= AWK=awk; do
819 AT_CHECK_CONFIGURE([$awk_arg])
820 AT_CHECK([cat Foo], 0, [[X*'[]+ ",& &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !
821 @foo@ @baz@@notsubsted@bla stray @ and more@@bla
822 abc@foo@ @baz@baz@baz
824 abc@foo@ @baz@blabaz@
833 AT_CHECK([cmp allowed-chars Zardoz])
834 AT_CHECK_DEFINES([[#define bar %!_!# X
835 #define foo X*'[]+ ",& &`\($foo !
841 ## ---------------------- ##
842 ## Substitute a newline. ##
843 ## ---------------------- ##
845 AT_SETUP([Substitute a newline])
852 AT_DATA([configure.ac],
860 AC_CONFIG_FILES([Foo])
865 cp "$abs_top_srcdir/build-aux/install-sh" .
873 # Check both awk and the result of AC_PROG_AWK
874 for awk_arg in FOO= AWK=awk; do
875 AT_CHECK_CONFIGURE([$awk_arg])
876 AT_CHECK([cat Foo], 0, [expout])
881 ## ------------------ ##
882 ## Define a newline. ##
883 ## ------------------ ##
885 AT_SETUP([Define a newline])
886 AT_CONFIGURE_AC([[AC_DEFINE([foo], [one
887 two], [This spans two lines.])
889 AT_CHECK_AUTOCONF([], [], [], [stderr])
890 dnl Older versions of m4 report error at line 5 (end of macro);
891 dnl newer versions report it at line 4 (start of macro).
892 AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
893 [[warning: AC_DEFINE: `one
894 two' is not a valid preprocessor define value
896 AT_CHECK_AUTOHEADER([], [], [], [stderr])
897 AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
898 [[warning: AC_DEFINE: `one
899 two' is not a valid preprocessor define value
902 AT_CHECK_DEFINES([[#define foo one
905 AT_CONFIGURE_AC([[AC_DEFINE_UNQUOTED([foo], [one
906 two], [This spans two lines.])
908 AT_CHECK_AUTOCONF([], [], [], [stderr])
909 AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
910 [[warning: AC_DEFINE_UNQUOTED: `one
911 two' is not a valid preprocessor define value
913 AT_CHECK_AUTOHEADER([], [], [], [stderr])
914 AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
915 [[warning: AC_DEFINE_UNQUOTED: `one
916 two' is not a valid preprocessor define value
919 AT_CHECK_DEFINES([[#define foo one
925 ## ------------------------------------ ##
926 ## AC_SUBST: variable name validation. ##
927 ## ------------------------------------ ##
929 AT_SETUP([AC_SUBST: variable name validation])
931 AT_CONFIGURE_AC([[AC_SUBST(, [])
932 AC_CONFIG_FILES([Makefile])
934 AT_DATA([Makefile.in], [[
936 mv -f configure.ac configure.tmpl
939 for var in ['' ab\~ ab\( ab[] ab\' ab\" ab\\\\]; do
940 sed ["s/AC_SUBST(/&[$var]/"] <configure.tmpl >configure.ac
941 AT_CHECK_AUTOCONF([], [1], [], [ignore])
945 for var in ab a4 'a@@&t@\&t@b'; do
946 sed ["s/AC_SUBST(/&[$var]/"] <configure.tmpl >configure.ac
955 ## ------------------------ ##
956 ## datarootdir workaround. ##
957 ## ------------------------ ##
959 AT_SETUP([datarootdir workaround])
973 AT_DATA([configure.ac],
975 d@&t@nl The following line silences the warnings, if uncommented:
976 d@&t@nl AC_DEFUN([AC_DATAROOTDIR_CHECKED])
978 # This substitution is wrong and bogus! Don't use it in your own code!
979 # Read `info Autoconf "Defining Directories"'!
980 AC_SUBST([mydatadir], [${datadir}/my])
982 AC_CONFIG_FILES([Foo Bar])
986 cp "$abs_top_srcdir/build-aux/install-sh" .
989 AT_CHECK_CONFIGURE([], [], [],
990 [config.status: WARNING: 'Foo.in' seems to ignore the --datarootdir setting
991 config.status: WARNING: Bar contains a reference to the variable `datarootdir'
992 which seems to be undefined. Please make sure it is defined.
994 AT_CHECK([grep datarootdir Foo], 1, [])
997 sed '/AC_DEFUN/s/^d@&t@nl //' configure.ac >t
1017 AT_DATA([configure.ac],
1020 AC_CONFIG_FILES([foo at-dir/bar])
1022 # Use quotes in the INIT-COMMANDS to accommodate a value of $srcdir
1023 # containing e.g., spaces or shell meta-characters.
1024 # Use *single* quotes because the context is an unquoted here-doc.
1025 AC_CONFIG_COMMANDS([report],
1026 [test -f "$srcdir/configure.ac" ||
1027 AC_MSG_ERROR([cannot find $srcdir/configure.ac])],
1031 rm -f -r foo at-dir/bar
1037 AT_CHECK([./configure], [], [ignore])
1040 AT_CHECK([cd at-dir && ../configure], [], [ignore])
1044 AT_CHECK([cd at-dir && "$at_here/configure"], [], [ignore])
1049 ## ----------------- ##
1050 ## Signal handling. ##
1051 ## ----------------- ##
1053 AT_SETUP([Signal handling])
1055 AT_DATA([configure.ac],
1062 AT_CHECK_CONFIGURE([], 1, ignore, ignore)
1067 ## ------------------------------------- ##
1068 ## AC_CONFIG_LINKS and identical files. ##
1069 ## ------------------------------------- ##
1070 AT_SETUP([AC_CONFIG_LINKS and identical files])
1072 AT_DATA([configure.ac],
1074 AC_CONFIG_LINKS([src/s:src/s])
1075 test "$srcdir" != '.' && AC_CONFIG_LINKS([src/t:src/t])
1084 AT_CHECK([../configure && ../configure], 0, [ignore])
1085 AT_CHECK([cat src/s src/t], 0, [file1
1089 AT_CHECK([./configure && ./configure], 0, [ignore], [stderr])
1090 AT_CHECK([grep src/t stderr], 1)
1091 AT_CHECK([cat src/s src/t], 0, [file1
1094 AT_CHECK(["`pwd`"/configure && "`pwd`"/configure], 0, [ignore], [ignore])
1095 AT_CHECK([cat src/s src/t], 0, [file1
1102 AT_BANNER([autoreconf.])
1104 ## ---------------------------- ##
1105 ## Configuring subdirectories. ##
1106 ## ---------------------------- ##
1111 # | |-- config.status
1114 # | |-- config.status
1121 # | |-- configure.ac
1126 AT_SETUP([Configuring subdirectories])
1127 AT_KEYWORDS(autoreconf)
1129 # We use aclocal (via autoreconf).
1130 AT_CHECK([aclocal --version || exit 77], [], [stdout], [ignore])
1131 # It should understand configure.ac.
1132 AT_CHECK([[grep '[^0-9]1.[01234][^0-9]' stdout && exit 77]], [1], [ignore])
1134 # Set CONFIG_SITE to a nonexistent file, so that there are
1135 # no worries about nonstandard values for 'prefix'.
1136 CONFIG_SITE=no-such-file
1139 # The contents of `inner/', and `inner/innermost/'.
1140 AS_MKDIR_P([inner/innermost])
1142 # We have to use configure.in, not configure.ac, if we still want to
1143 # be compatible with Automake 1.4: aclocal (run by autoreconf) would
1144 # die because it can't find configure.in.
1145 AT_DATA([inner/configure.in],
1146 [[AC_INIT(GNU Inner, 1.0)
1147 AC_CONFIG_SRCDIR([innermost/config.in])
1148 AC_ARG_VAR([INNER], [an inner variable])
1150 if test "x$INNER" = x; then
1153 AC_CONFIG_FILES([innermost/config])
1157 AT_DATA([inner/innermost/config.in],
1160 top_srcdir=@top_srcdir@
1164 # The contents of `.'
1165 AT_DATA([install-sh], [])
1167 # nonexistent is allowed not to exist.
1168 AT_DATA([configure.in],
1169 [[AC_INIT(GNU Outer, 1.0)
1170 AC_ARG_VAR([OUTER], [an outer variable])
1172 AC_CONFIG_SUBDIRS([nonexistent])
1174 AC_CONFIG_SUBDIRS([inner])
1178 # If there are improperly quoted AC_DEFUN installed in share/aclocal,
1179 # they trigger warnings from aclocal 1.8, so ignore stderr.
1180 AT_CHECK([autoreconf], [], [], [ignore])
1181 AT_CHECK([test -f inner/configure])
1183 # Running the outer configure recursively should provide the innermost
1185 chmod a-w inner/innermost inner .
1186 AT_CHECK([{ ./configure --help=recursive; chmod u+w .; } | grep INNER], 0,
1188 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1189 chmod u+w . inner inner/innermost
1191 # Running the outer configure should trigger the inner.
1193 AT_CHECK([cat inner/innermost/config], 0,
1200 # The same, but from a builddir.
1201 AS_MKDIR_P([builddir])
1202 AT_CHECK([cd builddir && ../configure], 0, [ignore])
1203 AT_CHECK([cat builddir/inner/innermost/config], 0,
1205 srcdir=../../../inner/innermost
1206 top_srcdir=../../../inner
1210 # Make sure precious variables and command line options are properly
1211 # passed, even when there are duplicates.
1212 AT_CHECK([cd builddir && ../configure --prefix /bad --prefix /good INNER=bad INNER=good], 0, [ignore])
1213 AT_CHECK([cat builddir/inner/innermost/config], 0,
1215 srcdir=../../../inner/innermost
1216 top_srcdir=../../../inner
1220 # Make sure --prefix is properly quoted
1221 AT_CHECK([cd builddir && ../configure --prefix "/a b c$ 'd"], 0, [ignore])
1222 AT_CHECK([cat builddir/inner/innermost/config], 0,
1224 srcdir=../../../inner/innermost
1225 top_srcdir=../../../inner
1229 # Make sure --silent is properly passed...
1230 AT_CHECK([cd builddir && ../configure --silent], 0, [])
1231 # ...but not stored in config.status.
1232 AT_CHECK([cd builddir && ./config.status --recheck], 0, [stdout])
1233 AT_CHECK([grep 'creating \./config.status' stdout], 0, [ignore])
1235 # Make sure we can run autoreconf on a subdirectory
1236 rm -f configure configure.in
1237 AT_CHECK([autoreconf inner], [], [], [ignore])
1239 # Make sure we can pass a configure.ac name
1240 AT_CHECK([cd inner && autoreconf configure.in], [], [], [ignore])
1241 AT_CHECK([autoreconf inner/configure.in], [], [], [ignore])
1247 ## -------------- ##
1249 ## -------------- ##
1251 AT_SETUP([Deep Package])
1252 AT_KEYWORDS(autoreconf)
1254 # We use aclocal (via autoreconf).
1255 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
1257 # The contents of `.'
1258 AT_DATA([install-sh], [])
1259 AT_DATA([configure.in],
1260 [[AC_INIT(GNU Outer, 1.0)
1261 AC_ARG_VAR([OUTER], [an outer variable])
1262 AC_CONFIG_SUBDIRS([inner inner2])
1266 # The contents of `inner/', and `inner/innermost/'.
1267 AS_MKDIR_P([inner/innermost])
1268 AS_MKDIR_P([inner2])
1270 AT_DATA([inner/configure.in],
1271 [[AC_INIT(GNU Inner, 1.0)
1272 AC_ARG_VAR([INNER], [an inner variable])
1273 AC_CONFIG_SUBDIRS(innermost)
1277 AT_DATA([inner/innermost/configure.in],
1278 [[AC_INIT(GNU Innermost, 1.0)
1279 AC_ARG_VAR([INNERMOST], [an innermost variable])
1280 AC_CONFIG_HEADERS(config.h:config.hin)
1281 AC_DEFINE_UNQUOTED([INNERMOST], [$INNERMOST], [an innermost variable])
1282 if test -n "$innermost_error"; then
1283 AC_MSG_FAILURE([Error in $PACKAGE_NAME])
1288 AT_DATA([inner2/configure.in],
1289 [[AC_INIT(GNU Inner 2, 1.0)
1290 AC_ARG_VAR([INNER2], [an inner2 variable])
1294 AT_CHECK([autoreconf -Wall -v], [0], [ignore], [ignore])
1295 AT_CHECK([test -f inner/configure])
1296 AT_CHECK([test -f inner/innermost/configure])
1297 AT_CHECK([test -f inner/innermost/config.hin])
1298 AT_CHECK([test -f inner2/configure])
1300 # Running the outer configure recursively should provide the innermost
1302 chmod a-w inner/innermost inner
1303 AT_CHECK([{ ./configure --help=recursive; chmod u+w .; } | grep " INNER "],
1304 0, [ignore], [stderr],
1305 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1307 AT_CHECK([{ ./configure --help=recursive; chmod u+w .; } | grep " INNER2 "],
1308 0, [ignore], [stderr],
1309 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1311 AT_CHECK([{ ./configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1312 0, [ignore], [stderr],
1313 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1315 AT_CHECK([{ /bin/sh ./configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1316 0, [ignore], [stderr],
1317 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1319 AT_CHECK([PATH=.$PATH_SEPARATOR$PATH; export PATH; { /bin/sh configure --help=recursive; chmod +w .; } | grep " INNERMOST "],
1320 0, [ignore], [stderr],
1321 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1323 AT_CHECK([PATH=.$PATH_SEPARATOR$PATH; export PATH; { configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1324 0, [ignore], [stderr],
1325 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1326 chmod u+w inner inner/innermost
1328 # Running the outer configure should trigger the inner.
1329 AT_CHECK_CONFIGURE([INNERMOST=tsomrenni])
1330 AT_CHECK([grep INNERMOST inner/innermost/config.h], 0,
1331 [[#define INNERMOST tsomrenni
1334 # Ensure we point to the right config.log file for errors.
1335 AT_CHECK_CONFIGURE([innermost_error=:], [1], [], [stderr])
1336 AT_CHECK([grep 'inner/innermost' stderr], [], [ignore])
1338 AT_CHECK_CONFIGURE([innermost_error=:], [1], [], [stderr])
1339 AT_CHECK([grep 'innermost' stderr], [], [ignore])
1342 # The same, but from a builddir.
1343 AS_MKDIR_P([builddir])
1344 chmod a-w builddir inner/innermost inner
1345 AT_CHECK([cd builddir && { ../configure --help=recursive; chmod u+w .; } | grep " INNER "],
1346 0, [ignore], [stderr],
1347 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1349 AT_CHECK([cd builddir && { ../configure --help=recursive; chmod u+w .; } | grep " INNER2 "],
1350 0, [ignore], [stderr],
1351 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1353 AT_CHECK([cd builddir && { ../configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1354 0, [ignore], [stderr],
1355 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1357 AT_CHECK([cd builddir && { /bin/sh ../configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1358 0, [ignore], [stderr],
1359 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1361 # Not all shells search $PATH for scripts.
1362 if (cd builddir && PATH=`pwd`/..$PATH_SEPARATOR$PATH /bin/sh configure --help) >/dev/null 2>&1; then
1363 AT_CHECK([cd builddir && PATH=`pwd`/..$PATH_SEPARATOR$PATH /bin/sh configure --help=recursive | grep " INNERMOST "], 0, [ignore])
1365 AT_CHECK([PATH=`pwd`$PATH_SEPARATOR$PATH; export PATH; cd builddir && { configure --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1366 0, [ignore], [stderr],
1367 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1368 chmod u+w builddir inner inner/innermost
1369 AT_CHECK([cd builddir && ../configure INNERMOST=build/tsomrenni], 0, [ignore])
1370 AT_CHECK([grep INNERMOST builddir/inner/innermost/config.h], 0,
1371 [[#define INNERMOST build/tsomrenni
1378 ## -------------------------------- ##
1379 ## Non-Autoconf AC_CONFIG_SUBDIRS. ##
1380 ## -------------------------------- ##
1382 AT_SETUP([Non-Autoconf AC_CONFIG_SUBDIRS])
1383 AT_KEYWORDS([autoreconf])
1385 # We use aclocal (via autoreconf).
1386 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
1388 AT_DATA([install-sh], [])
1389 AT_DATA([configure.in],
1390 [[AC_INIT(GNU Outer, 1.0)
1391 AC_CONFIG_SUBDIRS([inner])
1397 AT_DATA([inner/configure],
1400 *--help*) echo 'No Autoconf here, folks!' ;;
1401 *) echo got_it >myfile ;;
1405 chmod +x inner/configure
1407 AT_CHECK([autoreconf -Wall -v], 0, [ignore], [ignore])
1409 # Running the outer configure recursively should provide the innermost
1411 AT_CHECK([./configure --help=recursive | grep "folks"], 0, [ignore])
1413 # Running the outer configure should trigger the inner.
1414 AT_CHECK([./configure], 0, [ignore])
1415 AT_CHECK([test -f inner/myfile], 0)
1421 ## ----------------- ##
1422 ## Empty directory. ##
1423 ## ----------------- ##
1425 AT_SETUP([Empty directory])
1426 AT_KEYWORDS([autoreconf])
1428 # We use aclocal (via autoreconf).
1429 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
1431 # The test group directory is not necessarily _empty_, but it does not contain
1432 # files meaningful to `autoreconf'.
1434 AT_CHECK([autoreconf -Wall -v], 1, [ignore], [ignore])
1440 ## ------------------------------ ##
1441 ## Unusual Automake input files. ##
1442 ## ------------------------------ ##
1444 # This parallels gnumake.test in Automake.
1446 AT_SETUP([Unusual Automake input files])
1447 AT_KEYWORDS([autoreconf])
1449 # We use aclocal and automake via autoreconf.
1450 AT_CHECK([automake --version || exit 77], [], [ignore], [ignore])
1452 AT_DATA([configure.in],
1453 [[AC_INIT(GNU foo, 1.0)
1455 AC_CONFIG_FILES([HeeHee])
1459 AT_DATA([HeeHee.am],
1460 [[# Humans do no worse than `GNUmakefile.am'.
1461 AUTOMAKE_OPTIONS = foreign 1.8
1464 AT_CHECK([autoreconf -Wall -v -i], 0, [ignore], [stderr],
1465 [AT_CHECK([grep 'require.*1\.8' stderr && exit 77], [1])])
1466 AT_CHECK([test -f HeeHee.in])