3 # Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 AT_BANNER([[Testing config.status.]])
24 ## ---------------------------------------- ##
25 ## AC_CONFIG_COMMANDS with empty commands. ##
26 ## ---------------------------------------- ##
28 AT_CHECK_MACRO([AC_CONFIG_COMMANDS with empty commands],
29 [[AC_CONFIG_COMMANDS([foo], [], [:])
33 ## -------------------------- ##
34 ## Multiple AC_CONFIG_FILES. ##
35 ## -------------------------- ##
37 AT_SETUP([Multiple AC_CONFIG_FILES])
39 AT_CONFIGURE_AC([[AC_CONFIG_FILES([foo foo])]])
40 AT_CHECK_AUTOCONF([], 1, [], [ignore])
50 # AT_CHECK_AC_ARG_VAR(FIRST-VALUE, SECOND-VALUE)
51 # ----------------------------------------------
52 # Check that AC_ARG_VAR caches the latest values, diagnoses
53 # inconsistencies, and arms config.status.
54 m4_define([AT_CHECK_AC_ARG_VAR],
59 [precious='$1'; export precious],
61 AT_CHECK_CONFIGURE([--config-cache -q])
62 AT_CHECK([cat file], [], [`$1'
65 # Testing --recheck: 1. have the environment `forget' about PRECIOUS.
67 # 2. Rerun config.status to recreate `file'.
68 AT_CHECK([./config.status --recheck], [], [ignore])
69 AT_CHECK([./config.status], [], [ignore])
70 # 3. Check that file contains the old value of PRECIOUS.
71 AT_CHECK([cat file], [], [`$1'
74 # Second value: we should issue an error here: the value
77 [precious='$2'; export precious],
79 AT_CHECK_CONFIGURE([--config-cache], [1], [], [ignore])
81 ])# AT_CHECK_AC_ARG_VAR
84 AT_SETUP([AC_ARG_VAR])
86 # We don't want to run this test if this shell doesn't support
89 if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
96 AT_DATA([configure.ac],
98 AC_ARG_VAR([precious], [this variable costs a lot])
99 echo "precious:$precious"
109 # Set a precious variable
110 AT_CHECK_AC_ARG_VAR([], [apple of my eye])
112 # Unset a precious variable
113 AT_CHECK_AC_ARG_VAR([apple of my eye], [])
115 # Change a precious variable
116 AT_CHECK_AC_ARG_VAR([apple of my eye], [orange of my eye])
123 ## ---------------------------------------------- ##
124 ## AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS. ##
125 ## ---------------------------------------------- ##
127 AT_SETUP([AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS])
129 AT_DATA([configure.ac],
131 rm -f -r header var-header file var-file link var-link command var-command
134 # Be sure to also stress the associated INIT-CMDS.
135 case $what_to_test in
137 AC_CONFIG_HEADERS(header:input);;
139 AC_CONFIG_HEADERS(var-header:$header_in, [], [header_in=input]);;
142 AC_CONFIG_FILES(file:input);;
144 AC_CONFIG_FILES(var-file:$file_in, [], [file_in=input]);;
147 AC_CONFIG_COMMANDS(command:input,
148 [cp input command]);;
150 AC_CONFIG_COMMANDS(var-command:$command_in,
151 [cp $command_in var-command], [command_in=input]);;
154 AC_CONFIG_LINKS(link:input);;
156 AC_CONFIG_LINKS(var-link:$link_in, [], [link_in=input]);;
164 # AT_CHECK_CONFIG_CREATION(THING = (header | link | file | command))
165 # ------------------------------------------------------------------
166 # Check that THING and var-THING (which uses variables in AC_CONFIG_THING)
167 # are properly created, with the right content.
168 # Use `grep OK' instead of a simple `cat' to avoid banners such as in
170 m4_define([AT_CHECK_CONFIG_CREATION],
171 [AT_CHECK_CONFIGURE([what_to_test=$1])
172 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
175 AT_CHECK([grep OK $1], [], [OK
178 AT_CHECK_CONFIGURE([what_to_test=var-$1 --no-create])
179 # config.status might be stupidly expecting data on stdin, if it's
181 AT_CHECK([./config.status var-$1 </dev/null], [], [ignore])
182 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
185 AT_CHECK([grep OK var-$1], [], [OK
187 ])# AT_CHECK_CONFIG_CREATION
191 AT_CHECK_CONFIG_CREATION(file)
194 AT_CHECK_CONFIG_CREATION(header)
197 AT_CHECK_CONFIG_CREATION(command)
200 AT_CHECK_CONFIG_CREATION(link)
206 ## ------------------- ##
207 ## Missing templates. ##
208 ## ------------------- ##
210 # Check that config.status detects missing input files
211 AT_SETUP([Missing templates])
213 AT_DATA([configure.ac],
215 AC_CONFIG_FILES([nonexistent])
220 AT_CHECK_CONFIGURE([], [1], [],
221 [[config.status: error: cannot find input file: nonexistent.in
223 # Make sure that the output file doesn't exist
224 AT_CHECK([test -f nonexistent], 1)
231 ## ---------------------- ##
232 ## configure invocation. ##
233 ## ---------------------- ##
235 # Check that `configure' and `config.status' honor their interface.
237 # We run `./configure one=val1 --enable-two=val2 --with-three=val3'
238 # and verify that (i) `configure' correctly receives the arguments and
239 # (ii) correctly passes them to `config.status', which we check by
240 # running `config.status --recheck'.
242 AT_SETUP([configure invocation])
244 AT_DATA([configure.ac],
246 echo "result=$one$enable_two$with_three"
252 AT_CHECK_CONFIGURE([one=one --enable-two=two --with-three=three |
253 sed -n -e 's/^result=//p'], 0,
256 AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
260 AT_CHECK_CONFIGURE([one="\"'$ " --enable-two="\" ' $" --with-three=" \"'$"|
261 sed -n -e 's/^result=//p'], 0,
264 AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
272 ## -------------------------------------------- ##
273 ## Check that `#define' templates are honored. ##
274 ## -------------------------------------------- ##
276 # Use various forms of `#define' templates, and make sure there are no
277 # problems when a symbol is prefix of another.
279 AT_SETUP([#define header templates])
281 AT_DATA([configure.ac],
283 AC_CONFIG_HEADERS(config.h:config.hin)
285 # I18n of dummy variables: their French translations.
289 AC_DEFINE(fubar, tutu)
291 # Symbols which are prefixes of another.
295 AC_CONFIG_FILES(defs)
297 # Things included in confdefs.h, but which make no sense in
298 # config.h, nor in $DEFS.
299 cat <<\EOF >>confdefs.h
300 /* Hi Mum! Look, I am doing C++! */
302 void exit (int status);
306 # In addition of config.h output a full DEFS
317 AT_DATA([config.hin],
320 # define baz "Archimedes was sinking in his baz"
334 [[/* config.h. Generated by configure. */
346 AT_CHECK([cat config.h], 0, expout)
348 # Check the value of DEFS.
350 [[-DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -Dfoo=toto -Dbar=tata -Dbaz=titi -Dfubar=tutu -Da=A -Daaa=AAA -Daa=AA
353 # Because we strip trailing spaces in `testsuite' we can't leave one in
354 # expout, hence nuke the one left by AC_OUTPUT_MAKE_DEFS.
355 AT_CHECK([sed -e 's/ $//' defs], 0, expout)
361 ## ------------------------- ##
362 ## Torturing config.status. ##
363 ## ------------------------- ##
365 ## Require 100 AC_DEFINE and AC_SUBST with a significantly big value.
366 ## This is mostly to check that Autoconf produces portable sed scripts
367 ## in config.status. sed is used to skip the first two lines
368 ## `Generated by...'.
370 # We use m4_for many times.
371 m4_pattern_allow([^m4_for$])
373 AT_SETUP([Torturing config.status])
375 dnl The value used as a big value for AC_DEFINE.
376 dnl Don't use sh active chars here, below it is also used in a sh
378 m4_define([AT_BIG_VALUE],
379 [This value should be long enough to torture the various limits of sed and other tools used by Autoconf.])
381 m4_define([AT_DESCRIPTION],
382 [Define to a long string if your `Autoconf' works properly.])
385 # AT_DUMMY_VAR(NUMBER)
386 # --------------------
387 # Build a name used for AC_SUBST and AC_DEFINE. Put ac_ in it
388 # so that the check for user name space invasion does not complain
389 # of the new variables defined.
391 # Note that you should not use the name ac_dummy, because it will be
392 # turned into ac_uummy during the construction of config.status. Yes,
393 # this is admittedly a bug, but it would be too hard to fix this.
394 # There is really no point in AC_DEFINE a var named ac_d.*.
395 m4_pattern_allow([^m4_bpatsubst$])
396 m4_define([AT_DUMMY_VAR],
397 [ac_Dummy_[]m4_bpatsubst([000$1], [.*\(...\)$], [\1])])
402 [m4_for([AT_Count], 1, 100, 1,
403 [@AT_DUMMY_VAR(AT_Count)@
411 m4_pattern_allow([^m4_(define|defun)$])
412 AT_DATA([configure.ac],
413 dnl The following lines transfer AT_DUMMY_VAR, AT_DESCRIPTION, and
414 dnl AT_BIG_VALUE into the configure.ac as AC_DUMMY_VAR etc.
415 [[m4_define([AC_DUMMY_VAR],]
416 m4_dquote(m4_defn([AT_DUMMY_VAR]))[)]]
418 [[m4_define([AC_DESCRIPTION],]
419 m4_dquote(m4_defn([AT_DESCRIPTION]))[)]]
421 [[m4_define([AC_BIG_VALUE],]
422 m4_dquote(m4_defn([AT_BIG_VALUE]))[)]]
426 # Related VALUE to NAME both with AC_SUBST and AC_DEFINE. This is
427 # used in the torture tests.
428 m4_defun([AC_DEFUBST],
429 [AC_DUMMY_VAR($1)="AC_BIG_VALUE"
430 AC_DEFINE_UNQUOTED(AC_DUMMY_VAR($1), "$AC_DUMMY_VAR($1)",
432 AC_SUBST(AC_DUMMY_VAR($1))])
435 AC_CONFIG_HEADERS(config.h:config.hin)
436 AC_CONFIG_FILES(dummy)
437 m4_for(AC_Count, 1, 100, 1,
438 [AC_DEFUBST(AC_Count)])
446 # Checking that AC_DEFINE worked properly.
448 [/* Define to the address where bug reports for this package should be sent. */
449 #define PACKAGE_BUGREPORT ""
451 /* Define to the full name of this package. */
452 #define PACKAGE_NAME ""
454 /* Define to the full name and version of this package. */
455 #define PACKAGE_STRING ""
457 /* Define to the one symbol short name of this package. */
458 #define PACKAGE_TARNAME ""
460 /* Define to the version of this package. */
461 #define PACKAGE_VERSION ""
462 m4_for(AT_Count, 1, 100, 1,
465 [#define] AT_DUMMY_VAR(AT_Count) "AT_BIG_VALUE"
467 AT_CHECK([sed -n '4,$ p' config.h], 0, expout)
469 # Checking that AC_SUBST worked properly.
471 [m4_for(AT_Count, 1, 100, 1,
489 AT_DATA([configure.ac],
492 AC_CONFIG_FILES([foo at-dir/bar])
494 AC_CONFIG_COMMANDS([report],
495 [test -f $srcdir/configure.ac ||
496 AC_MSG_ERROR([cannot find $srcdir/configure.ac])],
500 rm -f -r foo at-dir/bar
506 AT_CHECK([./configure], [], [ignore])
509 AT_CHECK([cd at-dir && ../configure], [], [ignore])
513 AT_CHECK([cd at-dir && $at_here/configure], [], [ignore])
518 ## ----------------- ##
519 ## Signal handling. ##
520 ## ----------------- ##
522 AT_SETUP([Signal handling])
524 AT_DATA([configure.ac],
531 AT_CHECK_CONFIGURE([], 1, ignore, ignore)
536 ## ---------------------------- ##
537 ## Configuring subdirectories. ##
538 ## ---------------------------- ##
543 # | |-- config.status
546 # | |-- config.status
558 AT_SETUP([Configuring subdirectories])
559 AT_KEYWORDS(autoreconf)
561 # We use aclocal (via autoreconf).
562 AT_CHECK([aclocal --version || exit 77], [], [stdout], [ignore])
563 # It should understand configure.ac.
564 AT_CHECK([[grep '1.[01234]' stdout && exit 77]], [1], [ignore])
566 # The contents of `inner/', and `inner/innermost/'.
567 AS_MKDIR_P([inner/innermost])
569 # We have to use configure.in, not configure.ac, if we still want to
570 # be compatible with Automake 1.4: aclocal (run by autoreconf) would
571 # die because it can't find configure.in.
572 AT_DATA([inner/configure.in],
573 [[AC_INIT(GNU Inner, 1.0)
574 AC_CONFIG_SRCDIR([innermost/config.in])
575 AC_ARG_VAR([INNER], [an inner variable])
577 if test "x$INNER" = x; then
580 AC_CONFIG_FILES([innermost/config])
584 AT_DATA([inner/innermost/config.in],
587 top_srcdir=@top_srcdir@
591 # The contents of `.'
592 AT_DATA([install-sh], [])
594 # nonexistent is allowed not to exist.
595 AT_DATA([configure.in],
596 [[AC_INIT(GNU Outer, 1.0)
597 AC_ARG_VAR([OUTER], [an outer variable])
599 AC_CONFIG_SUBDIRS([nonexistent])
601 AC_CONFIG_SUBDIRS([inner])
605 # If there are improperly quoted AC_DEFUN installed in share/aclocal,
606 # they trigger warnings from aclocal 1.8, so ignore stderr.
607 AT_CHECK([autoreconf], [], [], [ignore])
608 AT_CHECK([test -f inner/configure])
610 # Running the outer configure recursively should provide the innermost
612 AT_CHECK([./configure --help=recursive | grep INNER], 0, [ignore])
614 # Running the outer configure should trigger the inner.
616 AT_CHECK([cat inner/innermost/config], 0,
623 # The same, but from a builddir.
624 AS_MKDIR_P([builddir])
625 AT_CHECK([cd builddir && ../configure], 0, [ignore])
626 AT_CHECK([cat builddir/inner/innermost/config], 0,
628 srcdir=../../../inner/innermost
629 top_srcdir=../../../inner
633 # Make sure precious variables and command line options are properly
634 # passed, even when there are duplicates. Run another directory so
635 # that if the user has set config.site to have a config.cache, then
636 # the two runs don't have colliding caches.
637 AS_MKDIR_P([builddir2])
638 AT_CHECK([cd builddir2 && ../configure --prefix /bad --prefix /good INNER=bad INNER=good], 0, [ignore])
639 AT_CHECK([cat builddir2/inner/innermost/config], 0,
641 srcdir=../../../inner/innermost
642 top_srcdir=../../../inner
654 AT_SETUP([Deep Package])
655 AT_KEYWORDS(autoreconf)
657 # We use aclocal (via autoreconf).
658 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
660 # The contents of `.'
661 AT_DATA([install-sh], [])
662 AT_DATA([configure.in],
663 [[AC_INIT(GNU Outer, 1.0)
664 AC_ARG_VAR([OUTER], [an outer variable])
665 AC_CONFIG_SUBDIRS([inner])
669 # The contents of `inner/', and `inner/innermost/'.
670 AS_MKDIR_P([inner/innermost])
672 AT_DATA([inner/configure.ac],
673 [[AC_INIT(GNU Inner, 1.0)
674 AC_ARG_VAR([INNER], [an inner variable])
675 AC_CONFIG_SUBDIRS(innermost)
679 AT_DATA([inner/innermost/configure.ac],
680 [[AC_INIT(GNU Innermost, 1.0)
681 AC_ARG_VAR([INNERMOST], [an innermost variable])
682 AC_CONFIG_HEADERS(config.h:config.hin)
683 AC_DEFINE_UNQUOTED([INNERMOST], [$INNERMOST], [an innermost variable])
687 AT_CHECK([autoreconf -Wall -v], [0], [ignore], [ignore])
688 AT_CHECK([test -f inner/configure])
689 AT_CHECK([test -f inner/innermost/configure])
690 AT_CHECK([test -f inner/innermost/config.hin])
692 # Running the outer configure recursively should provide the innermost
694 AT_CHECK([./configure --help=recursive | grep " INNER "], 0, [ignore])
695 AT_CHECK([./configure --help=recursive | grep " INNERMOST "], 0, [ignore])
697 # Running the outer configure should trigger the inner.
698 AT_CHECK_CONFIGURE([INNERMOST=tsomrenni])
699 AT_CHECK([grep INNERMOST inner/innermost/config.h], 0,
700 [[#define INNERMOST tsomrenni
703 # The same, but from a builddir.
704 AS_MKDIR_P([builddir])
705 AT_CHECK([cd builddir && ../configure INNERMOST=build/tsomrenni], 0, [ignore])
706 AT_CHECK([grep INNERMOST builddir/inner/innermost/config.h], 0,
707 [[#define INNERMOST build/tsomrenni