3 # Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 Free Software
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)
52 # ----------------------------------------------
53 # Check that AC_ARG_VAR caches the latest values, diagnoses
54 # inconsistencies, and arms config.status.
55 m4_define([AT_CHECK_AC_ARG_VAR],
60 [precious='$1'; export precious],
62 AT_CHECK_CONFIGURE([--config-cache -q])
63 AT_CHECK([cat file], [], [`$1'
66 # Testing --recheck: 1. have the environment `forget' about PRECIOUS.
68 # 2. Rerun config.status to recreate `file'.
69 AT_CHECK([./config.status --recheck], [], [ignore])
70 AT_CHECK([./config.status], [], [ignore])
71 # 3. Check that file contains the old value of PRECIOUS.
72 AT_CHECK([cat file], [], [`$1'
75 # Second value: we should issue an error here: the value
78 [precious='$2'; export precious],
80 AT_CHECK_CONFIGURE([--config-cache], [1], [], [ignore])
82 ])# AT_CHECK_AC_ARG_VAR
85 AT_SETUP([AC_ARG_VAR])
87 # We don't want to run this test if this shell doesn't support
90 if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
97 AT_DATA([configure.ac],
99 AC_ARG_VAR([precious], [this variable costs a lot])
100 echo "precious:$precious"
110 # Set a precious variable
111 AT_CHECK_AC_ARG_VAR([], [apple of my eye])
113 # Unset a precious variable
114 AT_CHECK_AC_ARG_VAR([apple of my eye], [])
116 # Change a precious variable
117 AT_CHECK_AC_ARG_VAR([apple of my eye], [orange of my eye])
124 ## ---------------------------------------------- ##
125 ## AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS. ##
126 ## ---------------------------------------------- ##
128 AT_SETUP([AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS])
130 AT_DATA([configure.ac],
132 rm -f -r header var-header file var-file link var-link command var-command
135 # Be sure to also stress the associated INIT-CMDS.
136 case $what_to_test in
138 AC_CONFIG_HEADERS(header:input);;
140 AC_CONFIG_HEADERS(var-header:$header_in, [], [header_in=input]);;
143 AC_CONFIG_FILES(file:input);;
145 AC_CONFIG_FILES(var-file:$file_in, [], [file_in=input]);;
148 AC_CONFIG_COMMANDS(command,
149 [cp input command]);;
151 AC_CONFIG_COMMANDS(var-command,
152 [cp $command_in var-command], [command_in=input]);;
155 AC_CONFIG_LINKS(link:input);;
157 AC_CONFIG_LINKS(var-link:$link_in, [], [link_in=input]);;
165 # AT_CHECK_CONFIG_CREATION(THING = (header | link | file | command))
166 # ------------------------------------------------------------------
167 # Check that THING and var-THING (which uses variables in AC_CONFIG_THING)
168 # are properly created, with the right content.
169 # Use `grep OK' instead of a simple `cat' to avoid banners such as in
171 m4_define([AT_CHECK_CONFIG_CREATION],
172 [AT_CHECK_CONFIGURE([what_to_test=$1])
173 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
176 AT_CHECK([grep OK $1], [], [OK
179 AT_CHECK_CONFIGURE([what_to_test=var-$1 --no-create])
180 # config.status might be stupidly expecting data on stdin, if it's
182 AT_CHECK([./config.status var-$1 </dev/null], [], [ignore])
183 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
186 AT_CHECK([grep OK var-$1], [], [OK
188 ])# AT_CHECK_CONFIG_CREATION
192 AT_CHECK_CONFIG_CREATION(file)
195 AT_CHECK_CONFIG_CREATION(header)
198 AT_CHECK_CONFIG_CREATION(command)
201 AT_CHECK_CONFIG_CREATION(link)
207 ## ------------------- ##
208 ## Missing templates. ##
209 ## ------------------- ##
211 # Check that config.status detects missing input files
212 AT_SETUP([Missing templates])
214 AT_DATA([configure.ac],
216 AC_CONFIG_FILES([nonexistent])
221 AT_CHECK_CONFIGURE([], [1], [],
222 [[config.status: error: cannot find input file: nonexistent.in
224 # Make sure that the output file doesn't exist
225 AT_CHECK([test -f nonexistent], 1)
232 ## ---------------------- ##
233 ## configure invocation. ##
234 ## ---------------------- ##
236 # Check that `configure' and `config.status' honor their interface.
238 # We run `./configure one=val1 --enable-two=val2 --with-three=val3'
239 # and verify that (i) `configure' correctly receives the arguments and
240 # (ii) correctly passes them to `config.status', which we check by
241 # running `config.status --recheck'.
243 AT_SETUP([configure invocation])
245 AT_DATA([configure.ac],
247 echo "result=$one$enable_two$with_three"
253 AT_CHECK_CONFIGURE([one=one --enable-two=two --with-three=three |
254 sed -n -e 's/^result=//p'], 0,
257 AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
261 AT_CHECK_CONFIGURE([one="\"'$ " --enable-two="\" ' $" --with-three=" \"'$"|
262 sed -n -e 's/^result=//p'], 0,
265 AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
273 ## -------------------------------------------- ##
274 ## Check that `#define' templates are honored. ##
275 ## -------------------------------------------- ##
277 # Use various forms of `#define' templates, and make sure there are no
278 # problems when a symbol is prefix of another.
280 AT_SETUP([#define header templates])
282 AT_DATA([configure.ac],
284 AC_CONFIG_HEADERS(config.h:config.hin)
286 # I18n of dummy variables: their French translations.
290 AC_DEFINE(fubar, tutu)
292 # Symbols which are prefixes of another.
296 AC_CONFIG_FILES(defs)
298 # Things included in confdefs.h, but which make no sense in
299 # config.h, nor in $DEFS.
300 cat <<\EOF >>confdefs.h
301 /* Hi Mum! Look, I am doing C++! */
303 void exit (int status);
307 # In addition of config.h output a full DEFS
318 AT_DATA([config.hin],
321 # define baz "Archimedes was sinking in his baz"
335 [[/* config.h. Generated from config.hin by configure. */
347 AT_CHECK([cat config.h], 0, expout)
349 # Check the value of DEFS.
351 [[-DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -Dfoo=toto -Dbar=tata -Dbaz=titi -Dfubar=tutu -Da=A -Daaa=AAA -Daa=AA
354 # Because we strip trailing spaces in `testsuite' we can't leave one in
355 # expout, hence nuke the one left by AC_OUTPUT_MAKE_DEFS.
356 AT_CHECK([sed -e 's/ $//' defs], 0, expout)
362 ## ------------------------- ##
363 ## Torturing config.status. ##
364 ## ------------------------- ##
366 ## Require 100 AC_DEFINE and AC_SUBST with a significantly big value.
367 ## This is mostly to check that Autoconf produces portable sed scripts
368 ## in config.status. sed is used to skip the first two lines
369 ## `Generated by...'.
371 # We use m4_for many times.
372 m4_pattern_allow([^m4_for$])
374 AT_SETUP([Torturing config.status])
376 dnl The value used as a big value for AC_DEFINE.
377 dnl Don't use sh active chars here, below it is also used in a sh
379 m4_define([AT_BIG_VALUE],
380 [This value should be long enough to torture the various limits of sed and other tools used by Autoconf.])
382 m4_define([AT_DESCRIPTION],
383 [Define to a long string if your `Autoconf' works properly.])
386 # AT_DUMMY_VAR(NUMBER)
387 # --------------------
388 # Build a name used for AC_SUBST and AC_DEFINE. Put ac_ in it
389 # so that the check for user name space invasion does not complain
390 # of the new variables defined.
392 # Note that you should not use the name ac_dummy, because it will be
393 # turned into ac_uummy during the construction of config.status. Yes,
394 # this is admittedly a bug, but it would be too hard to fix this.
395 # There is really no point in AC_DEFINE a var named ac_d.*.
396 m4_pattern_allow([^m4_bpatsubst$])
397 m4_define([AT_DUMMY_VAR],
398 [ac_Dummy_[]m4_bpatsubst([000$1], [.*\(...\)$], [\1])])
403 [m4_for([AT_Count], 1, 100, 1,
404 [@AT_DUMMY_VAR(AT_Count)@
412 m4_pattern_allow([^m4_(define|defun)$])
413 AT_DATA([configure.ac],
414 dnl The following lines transfer AT_DUMMY_VAR, AT_DESCRIPTION, and
415 dnl AT_BIG_VALUE into the configure.ac as AC_DUMMY_VAR etc.
416 [[m4_define([AC_DUMMY_VAR],]
417 m4_dquote(m4_defn([AT_DUMMY_VAR]))[)]]
419 [[m4_define([AC_DESCRIPTION],]
420 m4_dquote(m4_defn([AT_DESCRIPTION]))[)]]
422 [[m4_define([AC_BIG_VALUE],]
423 m4_dquote(m4_defn([AT_BIG_VALUE]))[)]]
427 # Related VALUE to NAME both with AC_SUBST and AC_DEFINE. This is
428 # used in the torture tests.
429 m4_defun([AC_DEFUBST],
430 [AC_DUMMY_VAR($1)="AC_BIG_VALUE"
431 AC_DEFINE_UNQUOTED(AC_DUMMY_VAR($1), "$AC_DUMMY_VAR($1)",
433 AC_SUBST(AC_DUMMY_VAR($1))])
436 AC_CONFIG_HEADERS(config.h:config.hin)
437 AC_CONFIG_FILES(dummy)
438 m4_for(AC_Count, 1, 100, 1,
439 [AC_DEFUBST(AC_Count)])
447 # Checking that AC_DEFINE worked properly.
449 [/* Define to the address where bug reports for this package should be sent. */
450 #define PACKAGE_BUGREPORT ""
452 /* Define to the full name of this package. */
453 #define PACKAGE_NAME ""
455 /* Define to the full name and version of this package. */
456 #define PACKAGE_STRING ""
458 /* Define to the one symbol short name of this package. */
459 #define PACKAGE_TARNAME ""
461 /* Define to the version of this package. */
462 #define PACKAGE_VERSION ""
463 m4_for(AT_Count, 1, 100, 1,
466 [#define] AT_DUMMY_VAR(AT_Count) "AT_BIG_VALUE"
468 AT_CHECK([sed -n '4,$ p' config.h], 0, expout)
470 # Checking that AC_SUBST worked properly.
472 [m4_for(AT_Count, 1, 100, 1,
479 ## ------------------------------- ##
480 ## Substitute a 2000-byte string. ##
481 ## ------------------------------- ##
483 # Solaris 9 /usr/ucb/sed that rejects commands longer than 4000 bytes. HP/UX
484 # sed dumps core around 8 KiB. However, POSIX says that sed need not
485 # handle lines longer than 2048 bytes (including the trailing newline).
486 # So we'll just test a 2000-byte value.
488 AT_SETUP([Substitute a 2000-byte string])
490 AT_DATA([Foo.in], [@foo@
493 AT_DATA([configure.ac],
495 AC_CONFIG_AUX_DIR($top_srcdir/config)
496 AC_SUBST([foo], ]m4_for([n], 1, 100,, ....................)[)
497 AC_CONFIG_FILES([Foo])
503 AT_CHECK([cat Foo], 0, m4_for([n], 1, 100,, ....................)
508 ## ------------------------------ ##
509 ## Define to a 2000-byte string. ##
510 ## ------------------------------ ##
512 AT_SETUP([Define to a 2000-byte string])
516 AC_DEFINE([foo], ]m4_for([n], 1, 100,, ....................)[, [desc])
522 AT_CHECK_DEFINES([@%:@define foo m4_for([n], 1, 100,, ....................)
527 ## ------------------------------------------ ##
528 ## Substitute and define special characters. ##
529 ## ------------------------------------------ ##
531 # Use characters special to the shell, sed, and M4.
533 AT_SETUP([Substitute and define special characters])
535 AT_DATA([Foo.in], [@foo@
539 [[foo="AS@&t@_ESCAPE([[X*'[]+ ", `\($foo]])"
541 AC_DEFINE([foo], [[X*'[]+ ", `\($foo]], [Awful value.])
542 AC_CONFIG_FILES([Foo])]])
547 AT_CHECK([cat Foo], 0, [[X*'[]+ ", `\($foo
549 AT_CHECK_DEFINES([[#define foo X*'[]+ ", `\($foo
554 ## ---------------------- ##
555 ## Substitute a newline. ##
556 ## ---------------------- ##
558 AT_SETUP([Substitute a newline])
564 AT_DATA([configure.ac],
566 AC_CONFIG_AUX_DIR($top_srcdir/config)
570 AC_CONFIG_FILES([Foo])
576 AT_CHECK([cat Foo], 0, [one
582 ## ------------------ ##
583 ## Define a newline. ##
584 ## ------------------ ##
586 AT_SETUP([Define a newline])
588 AT_CONFIGURE_AC([[AC_DEFINE([foo], [one
589 two], [This spans two lines.])
594 AT_CHECK_DEFINES([[#define foo one
611 AT_DATA([configure.ac],
614 AC_CONFIG_FILES([foo at-dir/bar])
616 AC_CONFIG_COMMANDS([report],
617 [test -f $srcdir/configure.ac ||
618 AC_MSG_ERROR([cannot find $srcdir/configure.ac])],
622 rm -f -r foo at-dir/bar
628 AT_CHECK([./configure], [], [ignore])
631 AT_CHECK([cd at-dir && ../configure], [], [ignore])
635 AT_CHECK([cd at-dir && "$at_here/configure"], [], [ignore])
640 ## ----------------- ##
641 ## Signal handling. ##
642 ## ----------------- ##
644 AT_SETUP([Signal handling])
646 AT_DATA([configure.ac],
653 AT_CHECK_CONFIGURE([], 1, ignore, ignore)
659 AT_BANNER([autoreconf.])
661 ## ---------------------------- ##
662 ## Configuring subdirectories. ##
663 ## ---------------------------- ##
668 # | |-- config.status
671 # | |-- config.status
683 AT_SETUP([Configuring subdirectories])
684 AT_KEYWORDS(autoreconf)
686 # We use aclocal (via autoreconf).
687 AT_CHECK([aclocal --version || exit 77], [], [stdout], [ignore])
688 # It should understand configure.ac.
689 AT_CHECK([[grep '1.[01234]' stdout && exit 77]], [1], [ignore])
691 # The contents of `inner/', and `inner/innermost/'.
692 AS_MKDIR_P([inner/innermost])
694 # We have to use configure.in, not configure.ac, if we still want to
695 # be compatible with Automake 1.4: aclocal (run by autoreconf) would
696 # die because it can't find configure.in.
697 AT_DATA([inner/configure.in],
698 [[AC_INIT(GNU Inner, 1.0)
699 AC_CONFIG_SRCDIR([innermost/config.in])
700 AC_ARG_VAR([INNER], [an inner variable])
702 if test "x$INNER" = x; then
705 AC_CONFIG_FILES([innermost/config])
709 AT_DATA([inner/innermost/config.in],
712 top_srcdir=@top_srcdir@
716 # The contents of `.'
717 AT_DATA([install-sh], [])
719 # nonexistent is allowed not to exist.
720 AT_DATA([configure.in],
721 [[AC_INIT(GNU Outer, 1.0)
722 AC_ARG_VAR([OUTER], [an outer variable])
724 AC_CONFIG_SUBDIRS([nonexistent])
726 AC_CONFIG_SUBDIRS([inner])
730 # If there are improperly quoted AC_DEFUN installed in share/aclocal,
731 # they trigger warnings from aclocal 1.8, so ignore stderr.
732 AT_CHECK([autoreconf], [], [], [ignore])
733 AT_CHECK([test -f inner/configure])
735 # Running the outer configure recursively should provide the innermost
737 AT_CHECK([./configure --help=recursive | grep INNER], 0, [ignore])
739 # Running the outer configure should trigger the inner.
741 AT_CHECK([cat inner/innermost/config], 0,
748 # The same, but from a builddir.
749 AS_MKDIR_P([builddir])
750 AT_CHECK([cd builddir && ../configure], 0, [ignore])
751 AT_CHECK([cat builddir/inner/innermost/config], 0,
753 srcdir=../../../inner/innermost
754 top_srcdir=../../../inner
758 # Make sure precious variables and command line options are properly
759 # passed, even when there are duplicates. Run another directory so
760 # that if the user has set config.site to have a config.cache, then
761 # the two runs don't have colliding caches.
762 AS_MKDIR_P([builddir2])
763 AT_CHECK([cd builddir2 && ../configure --prefix /bad --prefix /good INNER=bad INNER=good], 0, [ignore])
764 AT_CHECK([cat builddir2/inner/innermost/config], 0,
766 srcdir=../../../inner/innermost
767 top_srcdir=../../../inner
779 AT_SETUP([Deep Package])
780 AT_KEYWORDS(autoreconf)
782 # We use aclocal (via autoreconf).
783 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
785 # The contents of `.'
786 AT_DATA([install-sh], [])
787 AT_DATA([configure.in],
788 [[AC_INIT(GNU Outer, 1.0)
789 AC_ARG_VAR([OUTER], [an outer variable])
790 AC_CONFIG_SUBDIRS([inner])
794 # The contents of `inner/', and `inner/innermost/'.
795 AS_MKDIR_P([inner/innermost])
797 AT_DATA([inner/configure.in],
798 [[AC_INIT(GNU Inner, 1.0)
799 AC_ARG_VAR([INNER], [an inner variable])
800 AC_CONFIG_SUBDIRS(innermost)
804 AT_DATA([inner/innermost/configure.in],
805 [[AC_INIT(GNU Innermost, 1.0)
806 AC_ARG_VAR([INNERMOST], [an innermost variable])
807 AC_CONFIG_HEADERS(config.h:config.hin)
808 AC_DEFINE_UNQUOTED([INNERMOST], [$INNERMOST], [an innermost variable])
812 AT_CHECK([autoreconf -Wall -v], [0], [ignore], [ignore])
813 AT_CHECK([test -f inner/configure])
814 AT_CHECK([test -f inner/innermost/configure])
815 AT_CHECK([test -f inner/innermost/config.hin])
817 # Running the outer configure recursively should provide the innermost
819 AT_CHECK([./configure --help=recursive | grep " INNER "], 0, [ignore])
820 AT_CHECK([./configure --help=recursive | grep " INNERMOST "], 0, [ignore])
822 # Running the outer configure should trigger the inner.
823 AT_CHECK_CONFIGURE([INNERMOST=tsomrenni])
824 AT_CHECK([grep INNERMOST inner/innermost/config.h], 0,
825 [[#define INNERMOST tsomrenni
828 # The same, but from a builddir.
829 AS_MKDIR_P([builddir])
830 AT_CHECK([cd builddir && ../configure INNERMOST=build/tsomrenni], 0, [ignore])
831 AT_CHECK([grep INNERMOST builddir/inner/innermost/config.h], 0,
832 [[#define INNERMOST build/tsomrenni
839 ## -------------------------------- ##
840 ## Non-Autoconf AC_CONFIG_SUBDIRS. ##
841 ## -------------------------------- ##
843 AT_SETUP([Non-Autoconf AC_CONFIG_SUBDIRS])
844 AT_KEYWORDS([autoreconf])
846 # We use aclocal (via autoreconf).
847 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
849 AT_DATA([install-sh], [])
850 AT_DATA([configure.in],
851 [[AC_INIT(GNU Outer, 1.0)
852 AC_CONFIG_SUBDIRS([inner])
858 AT_DATA([inner/configure],
861 *--help*) echo 'No Autoconf here, folks!' ;;
862 *) echo got_it >myfile ;;
866 chmod +x inner/configure
868 AT_CHECK([autoreconf -Wall -v], 0, [ignore], [ignore])
870 # Running the outer configure recursively should provide the innermost
872 AT_CHECK([./configure --help=recursive | grep "folks"], 0, [ignore])
874 # Running the outer configure should trigger the inner.
875 AT_CHECK([./configure], 0, [ignore])
876 AT_CHECK([test -f inner/myfile], 0)
882 ## ----------------- ##
883 ## Empty directory. ##
884 ## ----------------- ##
886 AT_SETUP([Empty directory])
887 AT_KEYWORDS([autoreconf])
889 # We use aclocal (via autoreconf).
890 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
892 # The test group directory is not necessarily _empty_, but it does not contain
893 # files meaningful to `autoreconf'.
895 AT_CHECK([autoreconf -Wall -v], 1, [ignore], [ignore])
901 ## ------------------------------ ##
902 ## Unusual Automake input files. ##
903 ## ------------------------------ ##
905 # This parallels gnumake.test in Automake.
907 AT_SETUP([Unusual Automake input files])
908 AT_KEYWORDS([autoreconf])
910 # We use aclocal and automake via autoreconf.
911 AT_CHECK([automake --version || exit 77], [], [ignore], [ignore])
913 AT_DATA([configure.in],
914 [[AC_INIT(GNU foo, 1.0)
916 AC_CONFIG_FILES([HeeHee])
921 [[# Humans do no worse than `GNUmakefile.am'.
922 AUTOMAKE_OPTIONS = foreign
925 AT_CHECK([autoreconf -Wall -v -i], 0, [ignore], [ignore])
926 AT_CHECK([test -f HeeHee.in])