AC_HEADER_MAJOR: port to glibc 2.25
[autoconf/ericb.git] / tests / torture.at
blobde99b79aa67e04321a82d537d3f88fee2b1e2642
1 #                                                       -*- Autotest -*-
3 # Copyright (C) 2000-2016 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 3 of the License, or
8 # (at your option) any later version.
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, see <http://www.gnu.org/licenses/>.
19 AT_BANNER([[Testing config.status.]])
22 ## ---------------------------------------- ##
23 ## AC_CONFIG_COMMANDS with empty commands.  ##
24 ## ---------------------------------------- ##
26 AT_CHECK_MACRO([AC_CONFIG_COMMANDS with empty commands],
27 [[AC_CONFIG_COMMANDS([foo], [], [:])
28 ]])
31 ## --------------------------------------------- ##
32 ## AC_CONFIG_COMMANDS with temporary directory.  ##
33 ## --------------------------------------------- ##
35 AT_CHECK_MACRO([AC_CONFIG_COMMANDS with temporary directory],
36 [[AC_CONFIG_COMMANDS([foo], [
37 case $ACTION in
38   use)
39     echo "$tmp" > tmpdir
40     test -d "$tmp" || AC_MSG_ERROR([No $tmp directory])
41     echo garbage-in > "$tmp/garbage-out"
42     ;;
43   corrupt)
44     echo "$tmp" > tmpdir
45     tmp=./nosuch
46     ;;
47   *) ;;
48 esac
50 ]], [
51 AT_CHECK([test ! -f tmpdir])
52 AT_CHECK([ACTION=use ./config.status], [], [ignore])
53 AT_CHECK([test -s tmpdir && test ! -d "`cat tmpdir`"])
54 AT_CHECK([ACTION=corrupt ./config.status], [], [ignore])
55 AT_CHECK([test -s tmpdir && test ! -d "`cat tmpdir`"])
59 ## -------------------------- ##
60 ## Multiple AC_CONFIG_FILES.  ##
61 ## -------------------------- ##
63 AT_SETUP([Multiple AC_CONFIG_FILES])
65 AT_CONFIGURE_AC([[AC_CONFIG_FILES([foo foo])]])
66 AT_CHECK_AUTOCONF([], 1, [], [ignore])
68 AT_CLEANUP
71 ## ------------------------------- ##
72 ## parameterized AC_CONFIG_FILES.  ##
73 ## ------------------------------- ##
75 AT_SETUP([Parameterized AC_CONFIG_FILES])
77 AT_CONFIGURE_AC([[
78 files="foo
79 bar"
80 AC_CONFIG_FILES([$files])]])
81 AT_CHECK_AUTOCONF([], [], [], [ignore])
82 touch foo.in bar.in config.hin
83 AT_CHECK_CONFIGURE
85 AT_CLEANUP
89 ## ------------ ##
90 ## AC_ARG_VAR.  ##
91 ## ------------ ##
93 # AT_CHECK_AC_ARG_VAR(FIRST-VALUE, SECOND-VALUE, [STATUS = 1])
94 # ------------------------------------------------------------
95 # Check that AC_ARG_VAR caches the latest values, diagnoses
96 # inconsistencies, and arms config.status.  Check that recheck
97 # returns STATUS, save configure output in files 'stdout' and 'stderr'
98 # for further inspection.
99 m4_define([AT_CHECK_AC_ARG_VAR],
100 [rm -f config.cache
102 # Initial value.
103 m4_ifval([$1],
104          [precious='m4_bpatsubst([$1], [[']], ['\\''])'; export precious],
105          [unset precious])
106 AT_CHECK_CONFIGURE([--config-cache -q])
107 AT_CHECK([cat file], [], [`$1'
110 # Testing --recheck: 1. have the environment `forget' about PRECIOUS.
111 unset precious
112 # 2. Rerun config.status to recreate `file'.
113 AT_CHECK([./config.status --recheck], [], [ignore])
114 AT_CHECK([./config.status], [], [ignore])
115 # 3. Check that file contains the old value of PRECIOUS.
116 AT_CHECK([cat file], [], [`$1'
119 # Second value: we should issue an error here: the value
120 # has changed!
121 m4_ifval([$2],
122          [precious='$2'; export precious],
123          [unset precious])
124 AT_CHECK_CONFIGURE([--config-cache], [m4_default([$3], [1])], [stdout], [stderr])
126 ])# AT_CHECK_AC_ARG_VAR
129 AT_SETUP([AC_ARG_VAR])
131 # We don't want to run this test if this shell doesn't support
132 # `unset'.
133 AT_CHECK([
134 if (FOO=FOO; unset FOO) >/dev/null 2>&1; then
135   exit 0
136 else
137   exit 77
141 AT_DATA([configure.ac],
142 [[AC_INIT
143 AC_ARG_VAR([precious], [this variable costs a lot])
144 echo "precious:$precious"
145 AC_OUTPUT(file)
148 AT_DATA([file.in],
149 [[`@precious@'
152 AT_CHECK_AUTOCONF
154 # Set a precious variable
155 AT_CHECK_AC_ARG_VAR([], [apple of my eye])
157 # Unset a precious variable
158 AT_CHECK_AC_ARG_VAR([apple of my eye], [])
160 # Change a precious variable
161 AT_CHECK_AC_ARG_VAR([apple of my eye], [orange of my eye])
163 # Change a precious variable that contains braces
164 AT_CHECK_AC_ARG_VAR([apple of my {eye}], [orange of my eye])
166 # Change a precious variable that contains all kinds of fun
167 AT_CHECK_AC_ARG_VAR(['p  r      ec"iou$], [orange of my eye])
168 dnl restore font-lock: "
170 # Warn (but do not fail) about a whitespace-only change
171 AT_CHECK_AC_ARG_VAR([    apple  of       my eye  ], [apple of my eye],
172                     [0], ["has whitespace changes"])
173 mv stdout configure-output
174 AT_CHECK([grep "ignoring whitespace changes" stderr], [], [ignore])
175 AT_CHECK([grep "precious:        apple" configure-output], [], [ignore])
177 AT_CLEANUP
182 ## ---------------------------------------------- ##
183 ## AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS.  ##
184 ## ---------------------------------------------- ##
186 AT_SETUP([[AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS]])
188 AT_DATA([configure.ac],
189 [[AC_INIT
190 AC_PROG_FGREP
191 rm -f -r header var-header file var-file link var-link command var-command
192 echo 'OK' >input
194 # Be sure to also stress the associated INIT-CMDS.
195 case $what_to_test in
196  header)
197    AC_CONFIG_HEADERS(header:input);;
198  var-header)
199    AC_CONFIG_HEADERS(var-header:$header_in, [], [header_in=input]);;
201  file)
202    AC_CONFIG_FILES(file:input);;
203  var-file)
204    AC_CONFIG_FILES(var-file:$file_in, [], [file_in=input]);;
206  command)
207    AC_CONFIG_COMMANDS(command,
208                       [cp input command]);;
209  var-command)
210    AC_CONFIG_COMMANDS(var-command,
211                       [cp $command_in var-command], [command_in=input]);;
213  link)
214    AC_CONFIG_LINKS(link:input);;
215  var-link)
216    AC_CONFIG_LINKS(var-link:$link_in, [], [link_in=input]);;
217 esac
218 AC_OUTPUT
221 AT_CHECK_AUTOCONF
224 # AT_CHECK_CONFIG_CREATION(THING = (header | link | file | command))
225 # ------------------------------------------------------------------
226 # Check that THING and var-THING (which uses variables in AC_CONFIG_THING)
227 # are properly created, with the right content.
228 # Use `grep OK' instead of a simple `cat' to avoid banners such as in
229 # AC_CONFIG_HEADERS.
230 m4_define([AT_CHECK_CONFIG_CREATION],
231 [AT_CHECK_CONFIGURE([what_to_test=$1])
232 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
233          [ignore], [$1
235 AT_CHECK([grep OK $1], [], [OK
238 AT_CHECK_CONFIGURE([what_to_test=var-$1 --no-create])
239 # config.status might be stupidly expecting data on stdin, if it's
240 # really broken...
241 AT_CHECK([./config.status var-$1 </dev/null], [], [ignore])
242 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
243          [ignore], [var-$1
245 AT_CHECK([grep OK var-$1], [], [OK
247 ])# AT_CHECK_CONFIG_CREATION
250 # AT_CHECK_CONFIG_CREATION_NOWRITE(THING = (header | link | file | command))
251 # --------------------------------------------------------------------------
252 # Check that THING and var-THING (which uses variables in AC_CONFIG_THING)
253 # are properly created, with the right content.
254 # Use `grep OK' instead of a simple `cat' to avoid banners such as in
255 # AC_CONFIG_HEADERS.
256 m4_define([AT_CHECK_CONFIG_CREATION_NOWRITE],
257 [AT_CHECK_CONFIGURE([what_to_test=$1])
258 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
259          [ignore], [$1
261 AT_CHECK([grep OK $1], [], [OK
264 AT_CHECK_CONFIGURE([what_to_test=var-$1 --no-create])
265 # config.status might be stupidly expecting data on stdin, if it's
266 # really broken...
267 # Skip check if user can rename files into a read-only directory (when
268 # run by root or on w32).
269 touch t
270 chmod a-w .
271 mv t t1 >/dev/null 2>&1 \
272   || AT_CHECK([./config.status var-$1 </dev/null || exit 1],
273    [1], [ignore], [ignore])
274 chmod u+w .
275 rm -rf t t1
276 ])# AT_CHECK_CONFIG_CREATION_NOWRITE
279 # Create a file
280 AT_CHECK_CONFIG_CREATION(file)
282 # Create a header
283 AT_CHECK_CONFIG_CREATION(header)
285 # Execute a command
286 AT_CHECK_CONFIG_CREATION(command)
288 # Create a link
289 AT_CHECK_CONFIG_CREATION(link)
291 # Now check for write errors
293 # Create a file
294 AT_CHECK_CONFIG_CREATION_NOWRITE(file)
295 # Create a file with bits from stdin
296 AT_CHECK([echo from-stdin | ./config.status --file=file:-],
297          [0], [ignore])
298 AT_CHECK([grep from-stdin file], [], [from-stdin
300 # Force write error creating a file on stdout
301 if test -w /dev/full && test -c /dev/full; then
302   AT_CHECK([./config.status --file=-:input </dev/null >/dev/full || exit 1],
303            [1], [ignore], [ignore])
306 # Validate that --file requires an argument
307 AT_CHECK([./config.status --file], [1], [ignore], [stderr])
308 AT_CHECK([grep 'missing file argument' stderr], [0], [ignore])
309 AT_CHECK([./config.status --file=], [1], [ignore], [stderr])
310 AT_CHECK([grep 'missing file argument' stderr], [0], [ignore])
312 # Create a header
313 AT_CHECK_CONFIG_CREATION_NOWRITE(header)
314 # Create a header on stdout
315 AT_CHECK([./config.status --header=-:input </dev/null],
316          [0], [stdout], [ignore])
317 AT_CHECK([grep OK stdout], [], [OK
319 # Force write error creating a header on stdout
320 if test -w /dev/full && test -c /dev/full; then
321   AT_CHECK([./config.status --header=-:input </dev/null >/dev/full || exit 1],
322            [1], [ignore], [ignore])
325 # Execute a command
326 AT_CHECK_CONFIG_CREATION_NOWRITE(command)
328 # Create a link
329 AT_CHECK_CONFIG_CREATION_NOWRITE(link)
331 # Check that no use of `ac_write_fail' escaped into config.status
332 AT_CHECK([grep ac_write_fail config.status], [1])
334 # Check that --file and --header accept funny file names
335 AT_DATA([fgrep.in],
336 [[FGREP="@FGREP@"
338 ./config.status --file=fgrep:fgrep.in
339 . ./fgrep
342 export x
343 for file in \
344   'with  funny '\'' $x & #! name' \
345   'file with  funny \ '\'' \'\'' $ & #!*? name' \
346   'with  funny \ '\'' \'\'' " | <a >b & * ? name ' # "restore font-lock
348   # The function func_sanitize_file_name comes from tools.at
349   file=`func_sanitize_file_name "$file"`
350   cat >"$file.in" <<'END'
351 @configure_input@
353   AT_CHECK([./config.status "--file=$file:$file.in"],
354            [0], [ignore])
355   AT_CHECK([$FGREP "$file" "$file"], [0], [ignore])
356   AT_CHECK([./config.status "--header=$file:$file.in"],
357            [0], [ignore])
358   # Run the same test a 2nd time to see that config.status does not recreate
359   # the header (regression test)
360   AT_CHECK_UNQUOTED([./config.status "--header=$file:$file.in"],
361                     [0], [config.status: creating $file
362 config.status: $file is unchanged
364   AT_CHECK_UNQUOTED([grep ' & ' "$file"], [],
365 [/* $file.  Generated from $file.in by configure.  */
367   AT_CHECK([$FGREP "$file" "$file"], [0], [ignore])
368 done
369 AT_CLEANUP
373 ## ---------------------------------------- ##
374 ## Macro calls in AC_CONFIG_COMMANDS tags.  ##
375 ## ---------------------------------------- ##
377 AT_SETUP([Macro calls in AC_CONFIG_COMMANDS tags])
379 AT_DATA_M4SUGAR([configure.ac],
380 [[AC_INIT
381 AC_CONFIG_COMMANDS([m4_if(1,1,mytag)])
382 AC_OUTPUT
385 AT_CHECK_AUTOCONF
386 AT_CHECK_CONFIGURE
388 AT_CLEANUP
392 ## ------------------- ##
393 ## Missing templates.  ##
394 ## ------------------- ##
396 # Check that config.status detects missing input files
397 AT_SETUP([Missing templates])
399 AT_DATA([configure.ac],
400 [[AC_INIT
401 AC_CONFIG_FILES([nonexistent])
402 AC_OUTPUT
405 AT_CHECK_AUTOCONF
406 mkdir build
407 AT_CAPTURE_FILE([build/config.log])[]dnl
408 cd build
409 AT_CHECK([../configure], [1], [ignore],
410 [[config.status: error: cannot find input file: `nonexistent.in'
412 # Make sure that the output file doesn't exist
413 AT_CHECK([test -f nonexistent], 1)
414 cd ..
415 AT_CHECK_CONFIGURE([], [1], [],
416 [[config.status: error: cannot find input file: `nonexistent.in'
418 # Make sure that the output file doesn't exist
419 AT_CHECK([test -f nonexistent], 1)
421 AT_CLEANUP
426 ## ---------------------- ##
427 ## configure invocation.  ##
428 ## ---------------------- ##
430 # Check that `configure' and `config.status' honor their interface.
432 # We run `./configure one=val1 --enable-two=val2 --with-three=val3'
433 # and verify that (i) `configure' correctly receives the arguments,
434 # (ii) correctly passes them to `config.status', which we check by
435 # running `config.status --recheck', (iii) correctly passes them
436 # to sub-configure scripts, and (iv) correctly reproduces them with
437 # `config.status --config'.
439 AT_SETUP([configure invocation])
441 mkdir sub
443 AT_DATA([configure.ac],
444 [[AC_INIT
445 AC_CONFIG_SUBDIRS([sub])
446 echo "result=$one$enable_two$with_three"
447 AC_OUTPUT
450 AT_DATA([sub/configure.ac],
451 [[AC_INIT
452 echo "result=$one$enable_two$with_three"
453 AC_OUTPUT
456 echo fake install-sh script >install-sh
458 AT_CHECK_AUTOCONF
459 cd sub
460 AT_CHECK_AUTOCONF
461 cd ..
463 AT_CHECK_CONFIGURE([one=one --enable-two=two --with-three=three |
464                      sed -n -e 's/^result=//p'], 0,
465                    [m4_do([onetwothree
466 ],                        [onetwothree
467 ])])
468 AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
469          [onetwothree
471 AT_CHECK([args=`./config.status --config` && eval ./configure \$configure_options "$args" |
472             sed -n -e 's/^result=//p'], 0,
473          [m4_do([onetwothree
474 ],              [onetwothree
475 ])])
477 AT_CHECK_CONFIGURE([one="\"'$ " --enable-two="\" '  $" --with-three="   \"'$"|
478                       sed -n -e 's/^result=//p'], 0,
479                    [m4_do(["'$ " '  $   "'$
480 ],                        ["'$ " '  $   "'$
481 ])])
482 AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
483          ["'$ " '  $    "'$
485 dnl restore font-lock: "
486 AT_CHECK([args=`./config.status --config` && eval ./configure \$configure_options "$args" |
487             sed -n -e 's/^result=//p'], 0,
488          [m4_do(["'$ " '  $     "'$
489 ],              ["'$ " '  $     "'$
490 ])])
492 AT_CLEANUP
496 ## -------------------------------------------- ##
497 ## Check that `#define' templates are honored.  ##
498 ## -------------------------------------------- ##
500 # Use various forms of `#define' templates, and make sure there are no
501 # problems when a symbol is prefix of another.
503 AT_SETUP([@%:@define header templates])
504 AT_KEYWORDS([AC@&t@_DEFINE])
506 AT_DATA([configure.ac],
507 [[AC_INIT
508 AC_CONFIG_HEADERS(config.h:config.hin)
510 # I18n of dummy variables: their French translations.
511 AC_DEFINE(foo, toto)
512 AC_DEFINE(bar, tata)
513 AC_DEFINE(baz, titi)
514 AC_DEFINE(fubar, tutu)
516 # Symbols which are prefixes of another.
517 AC_DEFINE(a, A)
518 AC_DEFINE(aaa, AAA)
519 AC_DEFINE(aa, AA)
521 # backslash-newline combinations
522 AC_DEFINE([multiline], [line1\
523 line2\
524 line3 \
525 line4])
526 AC_DEFINE([multiline_args(ARG1, ARG2)], [ARG2 \
527 ARG1])
528 AC_CONFIG_FILES(defs)
530 # underquoted #
531 AC_DEFINE([paste(a,b)], [a##b])
533 # Things included in confdefs.h, but which make no sense in
534 # config.h, nor in $DEFS.
535 cat <<\EOF >>confdefs.h
536 /* Hi Mum! Look, I am doing C++! */
537 #ifdef __cplusplus
538 void exit (int status);
539 #endif
542 # In addition of config.h output a full DEFS
543 AC_OUTPUT_MAKE_DEFS
544 DEFS_SAVED=$DEFS
545 AC_SUBST(DEFS_SAVED)
546 AC_OUTPUT
549 AT_DATA([defs.in],
550 [[@DEFS_SAVED@
553 AT_DATA([config.hin],
554 [[#define foo   0
555 #  define bar bar
556 #  define baz   "Archimedes was sinking in his baz"
557   #  define fubar                               tutu
558 #define a B
559  #define aa BB
560  #  define aaa BBB
561 #undef a
562  #  undef aa
563 #undef aaa
564 #define aaa(a, aa) aa a
565 #define aaab
566 #define aaac(a, aa) aa a
567 #undef multiline
568 #  undef multiline_args
569 #define paste(a,b) a##b
570 /* an ugly one: */
571 #define str(define) \
572 #define
573 #define stringify(arg) str(arg)
574 #undef aaa /* with comments */
575 #undef not_substed /* with comments */
578 AT_CHECK_AUTOCONF
579 AT_CHECK_CONFIGURE
581 AT_DATA([expout],
582 [[/* config.h.  Generated from config.hin by configure.  */
583 #define foo toto
584 #  define bar tata
585 #  define baz titi
586   #  define fubar tutu
587 #define a A
588  #define aa AA
589  #  define aaa AAA
590 #define a A
591  #  define aa AA
592 #define aaa AAA
593 #define aaa AAA
594 #define aaab
595 #define aaac(a, aa) aa a
596 #define multiline line1\
597 line2\
598 line3 \
599 line4
600 #  define multiline_args(ARG1, ARG2) ARG2 \
601 ARG1
602 #define paste(a,b) a##b
603 /* an ugly one: */
604 #define str(define) \
605 #define
606 #define stringify(arg) str(arg)
607 #define aaa AAA
608 /* #undef not_substed */
610 AT_CHECK([cat config.h], 0, expout)
612 # Check the value of DEFS.
613 AT_DATA([expout],
614 [[-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
617 # Because we strip trailing spaces in `testsuite' we can't leave one in
618 # expout, hence nuke the one left by AC_OUTPUT_MAKE_DEFS.
619 AT_CHECK([sed -e 's/ $//' defs], 0, expout)
621 AT_CLEANUP
625 ## ------------------------- ##
626 ## Torturing config.status.  ##
627 ## ------------------------- ##
629 ## Require 100 AC_DEFINE and AC_SUBST and AC_SUBST_FILE with a significantly
630 ## big value.  This is mostly to check that Autoconf produces portable sed
631 ## scripts in config.status.  sed is used to skip the first two lines
632 ## `Generated by ...'.
634 # We use m4_for many times.
635 m4_pattern_allow([^m4_for$])
637 AT_SETUP([Torturing config.status])
639 dnl The value used as a big value for AC_DEFINE.
640 dnl Don't use sh active chars here, below it is also used in a sh
641 dnl assignment.
642 m4_define([AT_BIG_VALUE],
643 [This value should be long enough to torture the various limits of sed and other tools used by Autoconf.])
645 m4_define([AT_DESCRIPTION],
646 [Define to a long string if your `Autoconf' works properly.])
649 # AT_DUMMY_VAR(NUMBER)
650 # --------------------
651 # Build a name used for AC_SUBST and AC_DEFINE.  Put ac_ in it
652 # so that the check for user name space invasion does not complain
653 # of the new variables defined.
655 # Note that you should not use the name ac_dummy, because it will be
656 # turned into ac_uummy during the construction of config.status.  Yes,
657 # this is admittedly a bug, but it would be too hard to fix this.
658 # There is really no point in AC_DEFINE a var named ac_d.*.
659 m4_pattern_allow([^m4_bpatsubst$])
660 m4_define([AT_DUMMY_VAR],
661 [ac_Dummy_[]m4_bpatsubst([000$1], [.*\(...\)$], [\1])])
665 AT_DATA([dummy.in],
666 [m4_for([AT_Count], 1, 100, 1,
667 [@AT_DUMMY_VAR(AT_Count)@
668 @[f]AT_Count@
669 ])])
673 while test $i != 101; do
674   echo "content of file $i" > file_$i
675   AS_VAR_ARITH([i], [$i + 1])
676 done
679 # ------------ #
680 # configure.ac #
681 # ------------ #
683 m4_pattern_allow([^m4_(define|defun)$])
684 AT_DATA([configure.ac],
685 dnl The following lines transfer AT_DUMMY_VAR, AT_DESCRIPTION, and
686 dnl AT_BIG_VALUE into the configure.ac as AC_DUMMY_VAR etc.
687 [[m4_define([AC_DUMMY_VAR],]
688 m4_dquote(m4_defn([AT_DUMMY_VAR]))[)]]
690 [[m4_define([AC_DESCRIPTION],]
691 m4_dquote(m4_defn([AT_DESCRIPTION]))[)]]
693 [[m4_define([AC_BIG_VALUE],]
694 m4_dquote(m4_defn([AT_BIG_VALUE]))[)]]
696 [[# AC_DEFUBST(NAME)
697 # ----------------
698 # Related VALUE to NAME both with AC_SUBST and AC_DEFINE.  This is
699 # used in the torture tests.
700 m4_defun([AC_DEFUBST],
701 [AC_DUMMY_VAR($1)="AC_BIG_VALUE"
702 AC_DEFINE_UNQUOTED(AC_DUMMY_VAR($1), "$AC_DUMMY_VAR($1) $AC_DUMMY_VAR($1)",
703                    AC_DESCRIPTION)
704 AC_SUBST(AC_DUMMY_VAR($1))
705 AC_SUBST_FILE([f]$1)
706 f$1=file_$1
709 AC_INIT
710 AC_CONFIG_HEADERS(config.h:config.hin)
711 AC_CONFIG_FILES(dummy)
712 m4_for(AC_Count, 1, 100, 1,
713        [AC_DEFUBST(AC_Count)])
714 AC_PROG_AWK
715 AC_OUTPUT
716 ]])# configure.ac
718 AT_CHECK_AUTOCONF
719 AT_CHECK_AUTOHEADER
720 # Check both awk and the result of AC_PROG_AWK.
721 # Quote the first word in the for list for Solaris sh.
722 for awk_arg in "FOO=" AWK=awk; do
723   AT_CHECK_CONFIGURE([$awk_arg])
725   # Checking that AC_DEFINE worked properly.
726   AT_DATA([expout],
727 [/* Define to the address where bug reports for this package should be sent. */
728 #define PACKAGE_BUGREPORT ""
730 /* Define to the full name of this package. */
731 #define PACKAGE_NAME ""
733 /* Define to the full name and version of this package. */
734 #define PACKAGE_STRING ""
736 /* Define to the one symbol short name of this package. */
737 #define PACKAGE_TARNAME ""
739 /* Define to the home page for this package. */
740 #define PACKAGE_URL ""
742 /* Define to the version of this package. */
743 #define PACKAGE_VERSION ""
744 m4_for(AT_Count, 1, 100, 1,
746 /* AT_DESCRIPTION */
747 [#define] AT_DUMMY_VAR(AT_Count) "AT_BIG_VALUE AT_BIG_VALUE"
748 ])])
750   AT_CHECK([sed -n '4,$ p' config.h], 0, expout)
752   # Checking that AC_SUBST worked properly.
753   AT_DATA([expout],
754 [m4_for(AT_Count, 1, 100, 1,
755 [AT_BIG_VALUE
756 content of file AT_Count
757 ])])
759   AT_CHECK([cat dummy], 0, expout)
760 done
762 AT_CLEANUP
765 ## ------------------------------- ##
766 ## Substitute a 2000-byte string.  ##
767 ## ------------------------------- ##
769 # Solaris 9 /usr/ucb/sed that rejects commands longer than 4000 bytes.  HP/UX
770 # sed dumps core around 8 KiB.  However, POSIX says that sed need not
771 # handle lines longer than 2048 bytes (including the trailing newline).
772 # So we'll just test a 2000-byte value, and for awk, we test a line with
773 # almost 1000 words, and one variable with 5 lines of 2000 bytes each:
774 # multi-line values should allow to get around the limitations.
775 # We also test runs of around 148 backslashes: they need to be escaped,
776 # and 148 is the portable limit for awk string literals.  config.status
777 # uses concatenation to generate longer strings.
779 AT_SETUP([Substitute a 2000-byte string])
781 AT_DATA([Foo.in], [@foo@
783 AT_DATA([Bar.in], [@bar@
785 AT_DATA([Baz.in], [@baz@
787 AT_DATA([Boo.in], [@b147@
788 @b148@
789 @b149@
790 @b295@
791 @b296@
792 @b297@
795 AT_DATA([configure.ac],
796 [[AC_INIT
797 AC_SUBST([foo], ]m4_for([n], 1, 100,, ....................)[)
798 AC_SUBST([bar], "]m4_for([n], 1, 100,, @ @ @ @ @ @ @ @ @ @@)[")
799 baz="]m4_for([m], 1, 100,, ... ... ... ... ....)[
801 baz=$baz$baz$baz$baz$baz
802 AC_SUBST([baz])
803 b29='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
804 b147=$b29$b29$b29$b29$b29'\\'
805 b148=$b147'\'
806 b149=$b148'\'
807 b295=$b147$b147'\'
808 b296=$b295'\'
809 b297=$b296'\'
810 AC_SUBST([b147])
811 AC_SUBST([b148])
812 AC_SUBST([b149])
813 AC_SUBST([b295])
814 AC_SUBST([b296])
815 AC_SUBST([b297])
816 AC_PROG_AWK
817 AC_CONFIG_FILES([Foo Bar Baz Boo])
818 AC_OUTPUT
821 cp "$abs_top_srcdir/build-aux/install-sh" .
823 b29='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
824 b147=$b29$b29$b29$b29$b29'\\'
825 b295=$b147$b147'\'
826 cat >Boo-exp <<EOF
827 $b147
828 $b147\\
829 $b147\\\\
830 $b295
831 $b295\\
832 $b295\\\\
835 AT_CHECK_AUTOCONF
836 # Check both awk and the result of AC_PROG_AWK
837 # Quote the first word in the for list for Solaris sh.
838 for awk_arg in "Foo=" AWK=awk; do
839   AT_CHECK_CONFIGURE([$awk_arg])
840   AT_CHECK([cat Foo], 0, m4_for([n], 1, 100,, ....................)
842   AT_CHECK([cat Bar], 0, m4_for([n], 1, 100,, @ @ @ @ @ @ @ @ @ @@)
844   AT_DATA([stdout],
845   [m4_for([n], 1, 5,, m4_for([m], 1, 100,, ... ... ... ... ....)
847   AT_CHECK([cat Baz], 0, [stdout])
848   AT_CHECK([diff Boo-exp Boo])
849 done
850 AT_CLEANUP
853 ## ------------------------------ ##
854 ## Define to a 2000-byte string.  ##
855 ## ------------------------------ ##
857 AT_SETUP([Define to a 2000-byte string])
858 AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
860 AT_CONFIGURE_AC(
862 AC_DEFINE_UNQUOTED([foo], ]m4_for([n], 1, 100,, ....................)[, [desc])
863 AC_DEFINE([fooq], ]m4_for([n], 1, 100,, ....................)[, [desc])
866 AT_CHECK_AUTOCONF
867 AT_CHECK_AUTOHEADER
868 AT_CHECK_CONFIGURE
869 AT_CHECK_DEFINES([@%:@define foo m4_for([n], 1, 100,, ....................)
870 @%:@define fooq m4_for([n], 1, 100,, ....................)
872 AT_CLEANUP
875 ## ------------------------------------------ ##
876 ## Substitute and define special characters.  ##
877 ## ------------------------------------------ ##
879 # Use characters special to the shell, sed, awk, and M4.
881 AT_SETUP([Substitute and define special characters])
882 AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
884 AT_XFAIL_IF([byte=\\200s; dnl
885 test `{ printf $byte; echo; } | sed -n '/^./p' | wc -l` = 0])
887 AT_DATA([Foo.in], [@foo@
888 @bar@@notsubsted@@baz@ stray @ and more@@@baz@
889 abc@bar@baz@baz
890 abc@bar@@baz@baz
891 abc@bar@@baz@baz@
892 abc@bar @baz@baz
893 abc@bar @baz@baz@
894 abc@bar @baz@@baz@
895 @file@
896          @file@
897 X@file@
898 @file@X
901 AT_DATA([File],
902 [@foo@@bar@
905 AT_DATA([Zardoz.in], [@zardoz@
908 AT_CONFIGURE_AC(
909 [[foo="AS@&t@_ESCAPE([[X*'[]+ ", & &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !]])"
911 bar="@foo@ @baz@"
912 baz=bla
913 ( for i in 0 1 2 3; do
914     for j in 0 1 2 3 4 5 6 7; do
915       for k in 0 1 2 3 4 5 6 7; do
916         case $i$j$k in #(
917         000 | 015 | 377) ;; # MinGW awk dislikes 0xFF, and the test does
918                             # the wrong thing for CR on MinGW.
919                             #(
920         *) printf \\$i$j$k's' ;; # The 's' works around a Solaris 8 /bin/bash bug.
921         esac
922       done
923     done
924   done
925   printf \\n
926 ) >allowed-chars
927 zardoz=`cat allowed-chars`
928 AC_SUBST([foo])
929 AC_SUBST([bar])
930 AC_SUBST([baz])
931 AC_SUBST([zardoz])
932 file=File
933 AC_SUBST_FILE([file])
934 AC_DEFINE([fooq], [[X*'[]+ ", & &`\($foo !]], [Awful value.])
935 AC_DEFINE([barq], [[%!_!# X]], [Value that is used as special delimiter.])
936 AC_DEFINE_UNQUOTED([foo], [[X*'[]+ ", & &\`\\(\$foo !]], [Awful value.])
937 AC_DEFINE_UNQUOTED([bar], [[%!_!# X]], [Value that is used as special delimiter.])
938 AC_DEFINE_UNQUOTED([unq1], [$baz], [unquoted, test 1])
939 AC_DEFINE_UNQUOTED([unq2], [\$baz], [unquoted, test 2])
940 AC_DEFINE_UNQUOTED([unq3], ["$baz"], [unquoted, test 3])
941 AC_DEFINE_UNQUOTED([unq4], [${baz+set}], [unquoted, test 4])
942 AC_DEFINE_UNQUOTED([unq5], ["${baz+`echo "a "' b'`}"], [unquoted, test 5])
943 AC_DEFINE_UNQUOTED([unq6], [`echo hi`], [unquoted, test 6])
944 AC_DEFINE_UNQUOTED([unq7], ['\\"'], [unquoted, test 7])
945 AC_PROG_AWK
946 AC_CONFIG_FILES([Foo Zardoz])]])
948 AT_CHECK_AUTOCONF
949 AT_CHECK_AUTOHEADER
950 # Check both awk and the result of AC_PROG_AWK
951 # Quote the first word in the for list for Solaris sh.
952 for awk_arg in "FOO=" AWK=awk; do
953   AT_CHECK_CONFIGURE([$awk_arg])
954   AT_CHECK([cat Foo], 0, [[X*'[]+ ", & &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !
955 @foo@ @baz@@notsubsted@bla stray @ and more@@bla
956 abc@foo@ @baz@baz@baz
957 abc@foo@ @baz@blabaz
958 abc@foo@ @baz@blabaz@
959 abc@bar blabaz
960 abc@bar blabaz@
961 abc@bar blabla
962 @foo@@bar@
963 @foo@@bar@
964 X@file@
965 @file@X
967   AT_CHECK([cmp allowed-chars Zardoz])
968   AT_CHECK_DEFINES([[#define bar %!_!# X
969 #define barq %!_!# X
970 #define foo X*'[]+ ", & &`\($foo !
971 #define fooq X*'[]+ ", & &`\($foo !
972 #define unq1 bla
973 #define unq2 $baz
974 #define unq3 "bla"
975 #define unq4 set
976 #define unq5 "a  b"
977 #define unq6 hi
978 #define unq7 '\"'
980 done
981 AT_CLEANUP
984 ## ---------------------- ##
985 ## Substitute a newline.  ##
986 ## ---------------------- ##
988 AT_SETUP([Substitute a newline])
990 AT_DATA([Foo.in],
991 [@foo@
992 @bar@
995 AT_DATA([configure.ac],
996 [[AC_INIT
997 foo='one
998 two'
999 bar='%!_!# ''
1001 AC_SUBST([foo])
1002 AC_SUBST([bar])
1003 AC_CONFIG_FILES([Foo])
1004 AC_PROG_AWK
1005 AC_OUTPUT
1008 cp "$abs_top_srcdir/build-aux/install-sh" .
1010 echo 'one
1012 %!_!# ''
1013 x' >expout
1015 AT_CHECK_AUTOCONF
1016 # Check both awk and the result of AC_PROG_AWK
1017 # Quote the first word in the for list for Solaris sh.
1018 for awk_arg in "FOO=" AWK=awk; do
1019   AT_CHECK_CONFIGURE([$awk_arg])
1020   AT_CHECK([cat Foo], 0, [expout])
1021 done
1022 AT_CLEANUP
1025 ## ------------------ ##
1026 ## Define a newline.  ##
1027 ## ------------------ ##
1029 AT_SETUP([Define a newline])
1030 AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
1031 AT_CONFIGURE_AC([[AC_DEFINE([foo], [one
1032 two], [This spans two lines.])
1034 AT_CHECK_AUTOCONF([], [], [], [stderr])
1035 dnl Older versions of m4 report error at line 5 (end of macro);
1036 dnl newer versions report it at line 4 (start of macro).
1037 AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
1038 [[warning: AC_DEFINE: `one
1039 two' is not a valid preprocessor define value
1041 AT_CHECK_AUTOHEADER([], [], [], [stderr])
1042 AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
1043 [[warning: AC_DEFINE: `one
1044 two' is not a valid preprocessor define value
1046 AT_CHECK_CONFIGURE
1047 AT_CHECK_DEFINES([[#define foo one
1050 AT_CONFIGURE_AC([[AC_DEFINE_UNQUOTED([foo], [one
1051 two], [This spans two lines.])
1053 AT_CHECK_AUTOCONF([], [], [], [stderr])
1054 AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
1055 [[warning: AC_DEFINE_UNQUOTED: `one
1056 two' is not a valid preprocessor define value
1058 AT_CHECK_AUTOHEADER([], [], [], [stderr])
1059 AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
1060 [[warning: AC_DEFINE_UNQUOTED: `one
1061 two' is not a valid preprocessor define value
1063 AT_CHECK_CONFIGURE
1064 AT_CHECK_DEFINES([[#define foo one
1067 AT_CLEANUP
1070 ## ------------------------------------ ##
1071 ## AC_SUBST: variable name validation.  ##
1072 ## ------------------------------------ ##
1074 AT_SETUP([AC_SUBST: variable name validation])
1076 AT_CONFIGURE_AC([[AC_SUBST(, [])
1077 AC_CONFIG_FILES([Makefile])
1079 AT_DATA([Makefile.in], [[
1081 mv -f configure.ac configure.tmpl
1083 # Invalid names.
1084 for var in ['' ab\~ ab\( ab[] ab\' ab\" ab\\\\]; do
1085   sed ["s/AC_SUBST(/&[$var]/"] <configure.tmpl >configure.ac
1086   AT_CHECK_AUTOCONF([], [1], [], [ignore])
1087 done
1089 # Valid names.
1090 for var in ab a4 'a@@&t@\&t@b'; do
1091   sed ["s/AC_SUBST(/&[$var]/"] <configure.tmpl >configure.ac
1092   AT_CHECK_AUTOCONF
1093   AT_CHECK_AUTOHEADER
1094   AT_CHECK_CONFIGURE
1095 done
1097 AT_CLEANUP
1100 ## ------------------------ ##
1101 ## datarootdir workaround.  ##
1102 ## ------------------------ ##
1104 AT_SETUP([datarootdir workaround])
1106 AT_DATA([Foo.in],
1107 [@datadir@
1108 @docdir@
1109 @infodir@
1110 @localedir@
1111 @mandir@
1114 AT_DATA([Bar.in],
1115 [@mydatadir@
1118 AT_DATA([configure.ac],
1119 [[AC_INIT
1120 d@&t@nl The following line silences the warnings, if uncommented:
1121 d@&t@nl AC_DEFUN([AC_DATAROOTDIR_CHECKED])
1123 # This substitution is wrong and bogus!  Don't use it in your own code!
1124 # Read `info Autoconf "Defining Directories"'!
1125 AC_SUBST([mydatadir], [${datadir}/my])
1127 AC_CONFIG_FILES([Foo Bar])
1128 AC_OUTPUT
1131 cp "$abs_top_srcdir/build-aux/install-sh" .
1133 AT_CHECK_AUTOCONF
1134 AT_CHECK_CONFIGURE([], [], [],
1135   [config.status: WARNING:  'Foo.in' seems to ignore the --datarootdir setting
1136 config.status: WARNING: Bar contains a reference to the variable `datarootdir'
1137 which seems to be undefined.  Please make sure it is defined
1139 AT_CHECK([grep datarootdir Foo], 1, [])
1141 rm configure
1142 sed '/AC_DEFUN/s/^d@&t@nl //' configure.ac >t
1143 mv t configure.ac
1145 AT_CHECK_AUTOCONF
1146 AT_CHECK_CONFIGURE
1148 AT_CLEANUP
1151 ## -------- ##
1152 ## srcdir.  ##
1153 ## -------- ##
1155 AT_SETUP([srcdir])
1157 rm -f -r at-dir
1158 mkdir at-dir
1159 : >at-dir/bar.in
1160 : >foo.in
1162 AT_DATA([configure.ac],
1163 [[AC_INIT
1165 AC_CONFIG_FILES([foo at-dir/bar])
1167 # Use quotes in the INIT-COMMANDS to accommodate a value of $srcdir
1168 # containing e.g., spaces or shell meta-characters.
1169 # Use *single* quotes because the context is an unquoted here-doc.
1170 AC_CONFIG_COMMANDS([report],
1171 [test -f "$srcdir/configure.ac" ||
1172    AC_MSG_ERROR([cannot find $srcdir/configure.ac])],
1173                    [srcdir='$srcdir'])
1175 AC_OUTPUT
1176 rm -f -r foo at-dir/bar
1179 AT_CHECK_AUTOCONF
1181 # In place.
1182 AT_CHECK([./configure $configure_options], [], [ignore])
1184 # Relative name.
1185 AT_CHECK([cd at-dir && ../configure $configure_options], [], [ignore])
1187 # Absolute name.
1188 at_here=`pwd`
1189 AT_CHECK([cd at-dir && "$at_here/configure" $configure_options], [], [ignore])
1191 AT_CLEANUP
1194 ## ------- ##
1195 ## VPATH.  ##
1196 ## ------- ##
1198 AT_SETUP([VPATH])
1200 dirs='at paren brace space'
1201 for dir in $dirs; do
1202   mkdir $dir $dir/s1 $dir/s2
1203   touch $dir/f $dir/s1/f1 $dir/s2/f2
1204 done
1206 AT_DATA([configure.ac],
1207 [[AC_INIT
1208 AC_CONFIG_FILES([at/Makefile paren/Makefile brace/Makefile space/Makefile])
1209 AC_OUTPUT
1212 AT_DATA([at/Makefile.in],
1213 [[# This is what you should use in order to be portable to old makes.
1214 srcdir = @srcdir@
1215 VPATH = @srcdir@/s1:@srcdir@:@srcdir@/s2
1216 all: f f1 f2
1217         @echo ok
1220 AT_DATA([paren/Makefile.in],
1221 [[# This works with some makes but not with old ones.
1222 srcdir = @srcdir@
1223 VPATH = $(srcdir)/s1:$(srcdir):$(srcdir)/s2
1224 all: f f1 f2
1225         @echo ok
1228 AT_DATA([brace/Makefile.in],
1229 [[# This works with some makes but not with old ones.
1230 srcdir = @srcdir@
1231 VPATH = ${srcdir}/s1:${srcdir}:${srcdir}/s2
1232 all: f f1 f2
1233         @echo ok
1236 AT_DATA([space/Makefile.in],
1237 [[# This fails with FreeBSD make, for example.
1238 srcdir = @srcdir@
1239 VPATH = @srcdir@/s1 @srcdir@ @srcdir@/s2
1240 all: f f1 f2
1241         @echo ok
1244 AT_CHECK_AUTOCONF
1246 : "${MAKE=make}"
1248 # In place.
1249 AT_CHECK([./configure $configure_options], [], [ignore])
1250 # Treat BSD make separately, afterwards, for maximal coverage.
1251 dirs='at paren brace'
1252 for dir in $dirs; do
1253   AT_CHECK([cd $dir && $MAKE], [], [ignore], [ignore])
1254 done
1256 rm -f config.status
1257 mkdir build absbuild
1259 # Relative name.
1260 AT_CHECK([cd build && ../configure $configure_options], [], [ignore])
1261 for dir in $dirs; do
1262   AT_CHECK([cd build/$dir && $MAKE], [], [ignore], [ignore])
1263 done
1265 # Absolute name.
1266 at_here=`pwd`
1267 AT_CHECK([cd absbuild && "$at_here/configure" $configure_options], [], [ignore])
1268 for dir in $dirs; do
1269   AT_CHECK([cd absbuild/$dir && $MAKE], [], [ignore], [ignore])
1270 done
1272 # These will not pass with BSD make.
1273 AT_CHECK([cd space && { $MAKE || exit 77; }], [], [ignore], [ignore])
1274 AT_CHECK([cd build/space && $MAKE], [], [ignore], [ignore])
1275 AT_CHECK([cd absbuild/space && $MAKE], [], [ignore], [ignore])
1277 AT_CLEANUP
1280 ## ----------------- ##
1281 ## Signal handling.  ##
1282 ## ----------------- ##
1284 AT_SETUP([Signal handling])
1286 AT_DATA([configure.ac],
1287 [[AC_INIT
1288 kill -2 $$
1289 exit 77
1292 AT_CHECK_AUTOCONF
1293 AT_CHECK_CONFIGURE([], 1, ignore, ignore)
1295 AT_CLEANUP
1298 ## ----------------- ##
1299 ## AC_CONFIG_LINKS.  ##
1300 ## ----------------- ##
1302 AT_SETUP([AC_CONFIG_LINKS])
1304 AT_DATA([configure.ac],
1305 [[AC_INIT([config links to config files test], [1.0])
1306 AC_CONFIG_SRCDIR([sub1/file1.in])
1307 AC_CONFIG_FILES([sub1/file1 file2])
1308 AC_CONFIG_LINKS([file1:sub1/file1 sub2/file2:file2])
1309 AC_OUTPUT
1312 mkdir sub1
1314 AT_DATA([sub1/file1.in],
1315 [[/* @configure_input@ */
1316 #define PACKAGE_STRING "@PACKAGE_STRING@"
1319 AT_DATA([file2.in],
1320 [[/* @configure_input@ */
1321 #define PACKAGE_STRING "@PACKAGE_STRING@"
1324 mkdir build
1325 AT_CHECK_AUTOCONF
1326 cd build
1327 AT_CHECK([../configure && ../configure], 0, [ignore])
1328 AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
1330 AT_CHECK([../configure && ../configure], 0, [ignore])
1331 AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
1333 cd ..
1334 rm -rf build
1335 mkdir build
1336 cd build
1337 cwd=`pwd`
1338 AT_CHECK(["$cwd"/../configure && "$cwd"/../configure], 0, [ignore])
1339 AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
1341 cd ..
1342 AT_CHECK([./configure && ./configure], 0, [ignore], [stderr])
1343 AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
1345 cwd=`pwd`
1346 AT_CHECK(["$cwd"/configure && "$cwd"/configure], 0, [ignore], [ignore])
1347 AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
1350 AT_CLEANUP
1353 ## ------------------------------------- ##
1354 ## AC_CONFIG_LINKS and identical files.  ##
1355 ## ------------------------------------- ##
1356 AT_SETUP([AC_CONFIG_LINKS and identical files])
1358 AT_DATA([configure.ac],
1359 [[AC_INIT
1360 AC_CONFIG_LINKS([src/s:src/s])
1361 test "$srcdir" != '.' && AC_CONFIG_LINKS([src/t:src/t])
1362 AC_OUTPUT
1365 mkdir src build
1366 echo file1 > src/s
1367 echo file2 > src/t
1368 AT_CHECK_AUTOCONF
1369 cd build
1370 AT_CHECK([../configure $configure_options && ../configure $configure_options],
1371          0, [ignore])
1372 AT_CHECK([cat src/s src/t], 0, [file1
1373 file2
1376 cd ..
1377 rm -rf build
1378 mkdir build
1379 cd build
1380 cwd=`pwd`
1381 AT_CHECK(["$cwd"/../configure], 0, [ignore])
1382 AT_CHECK([cat src/s src/t], 0, [file1
1383 file2
1385 AT_CHECK(["$cwd"/../configure], 0, [ignore])
1386 AT_CHECK([cat src/s src/t], 0, [file1
1387 file2
1389 cd ..
1390 AT_CHECK([./configure $configure_options && ./configure $configure_options],
1391          0, [ignore], [stderr])
1392 AT_CHECK([grep src/t stderr], 1)
1393 AT_CHECK([cat src/s src/t], 0, [file1
1394 file2
1396 cwd=`pwd`
1397 AT_CHECK(["$cwd"/configure && "$cwd"/configure], 0, [ignore], [ignore])
1398 AT_CHECK([cat src/s src/t], 0, [file1
1399 file2
1402 AT_CLEANUP
1405 AT_BANNER([autoreconf.])
1407 ## ---------------------------- ##
1408 ## Configuring subdirectories.  ##
1409 ## ---------------------------- ##
1411 # .
1412 # |-- builddir
1413 # |   |-- config.log
1414 # |   |-- config.status
1415 # |   `-- inner
1416 # |       |-- config.log
1417 # |       |-- config.status
1418 # |       `-- innermost
1419 # |           `-- config
1420 # |-- configure
1421 # |-- configure.ac
1422 # |-- inner
1423 # |   |-- configure
1424 # |   |-- configure.ac
1425 # |   `-- innermost
1426 # |       `-- config.in
1427 # `-- install-sh
1429 AT_SETUP([Configuring subdirectories])
1430 AT_KEYWORDS(autoreconf)
1432 # We use aclocal (via autoreconf).
1433 AT_CHECK([aclocal --version || exit 77], [], [stdout], [ignore])
1434 AT_CHECK([[grep '[1-9]\.[0-9]' stdout || exit 77]], [], [ignore])
1436 # It should understand configure.ac.
1437 AT_CHECK([[grep '[^0-9]1\.[01234][^0-9]' stdout && exit 77]], [1], [ignore])
1439 # Set CONFIG_SITE to a nonexistent file, so that there are
1440 # no worries about nonstandard values for 'prefix'.
1441 CONFIG_SITE=no-such-file
1442 export CONFIG_SITE
1444 # The contents of `inner/', and `inner/innermost/'.
1445 AS_MKDIR_P([inner/innermost])
1447 AT_DATA([inner/configure.ac],
1448 [[AC_INIT(GNU Inner, 1.0)
1449 AC_CONFIG_SRCDIR([innermost/config.in])
1450 AC_ARG_VAR([INNER], [an inner variable])
1451 AC_SUBST([INNER])
1452 if test "x$INNER" = x; then
1453   INNER=inner
1455 AC_CONFIG_FILES([innermost/config])
1456 AC_OUTPUT
1459 AT_DATA([inner/innermost/config.in],
1460 [INNER=@INNER@
1461 srcdir=@srcdir@
1462 top_srcdir=@top_srcdir@
1463 prefix=@prefix@
1466 # The contents of `.'
1467 AT_DATA([install-sh], [])
1469 # nonexistent is allowed not to exist.
1470 AT_DATA([configure.ac],
1471 [[AC_INIT(GNU Outer, 1.0)
1472 AC_ARG_VAR([OUTER], [an outer variable])
1473 if false; then
1474   AC_CONFIG_SUBDIRS([nonexistent])
1476 AC_CONFIG_SUBDIRS([inner])
1477 AC_OUTPUT
1480 # If there are improperly quoted AC_DEFUN installed in share/aclocal,
1481 # they trigger warnings from aclocal 1.8, so ignore stderr.
1482 AT_CHECK([autoreconf], [], [], [ignore])
1483 AT_CHECK([test -f inner/configure])
1485 # Running the outer configure recursively should provide the innermost
1486 # help strings.
1487 chmod a-w inner/innermost inner .
1488 AT_CHECK([{ ./configure $configure_options --help=recursive; chmod u+w .; } | grep INNER], 0,
1489          [ignore], [stderr],
1490          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1491 chmod u+w . inner inner/innermost
1493 # Running the outer configure should trigger the inner.
1494 AT_CHECK_CONFIGURE
1495 AT_CHECK([cat inner/innermost/config], 0,
1496 [INNER=inner
1497 srcdir=.
1498 top_srcdir=..
1499 prefix=/usr/local
1502 # The same, but from a builddir.
1503 AS_MKDIR_P([builddir])
1504 AT_CHECK([cd builddir && ../configure $configure_options], 0, [ignore])
1505 AT_CHECK([cat builddir/inner/innermost/config], 0,
1506 [INNER=inner
1507 srcdir=../../../inner/innermost
1508 top_srcdir=../../../inner
1509 prefix=/usr/local
1512 # Make sure precious variables and command line options are properly
1513 # passed, even when there are duplicates.
1514 AT_CHECK([cd builddir && ../configure $configure_options --prefix /bad --prefix /good INNER=bad INNER=good],
1515          0, [ignore])
1516 AT_CHECK([cat builddir/inner/innermost/config], 0,
1517 [INNER=good
1518 srcdir=../../../inner/innermost
1519 top_srcdir=../../../inner
1520 prefix=/good
1523 # Make sure --prefix is properly quoted
1524 AT_CHECK([cd builddir && ../configure --prefix "/a  b c$ 'd"], 0, [ignore])
1525 AT_CHECK([cat builddir/inner/innermost/config], 0,
1526 [INNER=inner
1527 srcdir=../../../inner/innermost
1528 top_srcdir=../../../inner
1529 prefix=/a  b c$ 'd
1532 # Make sure --silent is properly passed...
1533 AT_CHECK([cd builddir && ../configure $configure_options --silent], 0, [])
1534 # ...but not stored in config.status.
1535 AT_CHECK([cd builddir && ./config.status --recheck], 0, [stdout])
1536 AT_CHECK([grep 'creating \./config.status' stdout], 0, [ignore])
1538 # --cache-file is adjusted for subdirectories, so the cache is shared.
1539 AT_CHECK([cd builddir && ../configure $configure_options --config-cache],
1540          [], [stdout])
1541 AT_CHECK([grep 'loading .*\.\./config.cache' stdout], [], [ignore])
1543 # Make sure we can run autoreconf on a subdirectory
1544 rm -f configure configure.ac
1545 AT_CHECK([autoreconf inner], [], [], [ignore])
1547 # Make sure we can pass a configure.ac name
1548 AT_CHECK([cd inner && autoreconf configure.ac], [], [], [ignore])
1549 AT_CHECK([autoreconf inner/configure.ac], [], [], [ignore])
1551 AT_CLEANUP
1555 ## -------------- ##
1556 ## Deep Package.  ##
1557 ## -------------- ##
1559 AT_SETUP([Deep Package])
1560 AT_KEYWORDS(autoreconf)
1562 # We use aclocal (via autoreconf).
1563 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
1565 # The contents of `.'
1566 AT_DATA([install-sh], [])
1567 AT_DATA([configure.ac],
1568 [[AC_INIT(GNU Outer, 1.0)
1569 AC_ARG_VAR([OUTER], [an outer variable])
1570 AC_CONFIG_SUBDIRS([
1571   inner
1572   inner2
1574 AC_OUTPUT
1577 # The contents of `inner/', and `inner/innermost/'.
1578 AS_MKDIR_P([inner/innermost])
1579 AS_MKDIR_P([inner2])
1581 AT_DATA([inner/configure.ac],
1582 [[AC_INIT(GNU Inner, 1.0)
1583 AC_ARG_VAR([INNER], [an inner variable])
1584 AC_CONFIG_SUBDIRS(innermost)
1585 AC_OUTPUT
1588 AT_DATA([inner/innermost/configure.ac],
1589 [[AC_INIT(GNU Innermost, 1.0)
1590 AC_ARG_VAR([INNERMOST], [an innermost variable])
1591 AC_CONFIG_HEADERS(config.h:config.hin)
1592 AC_DEFINE_UNQUOTED([INNERMOST], [$INNERMOST], [an innermost variable])
1593 if test -n "$innermost_error"; then
1594   AC_MSG_FAILURE([error in $PACKAGE_NAME])
1596 AC_OUTPUT
1599 AT_DATA([inner2/configure.ac],
1600 [[AC_INIT(GNU Inner 2, 1.0)
1601 AC_ARG_VAR([INNER2], [an inner2 variable])
1602 AC_OUTPUT
1605 AT_CHECK([autoreconf -Wall -v], [0], [ignore], [stderr])
1606 # We should not warn about nonliteral argument to AC_CONFIG_SUBDIRS here.
1607 AT_CHECK([grep 'AC_CONFIG_SUBDIRS:.*literals' stderr], [1])
1608 AT_CHECK([test -f inner/configure])
1609 AT_CHECK([test -f inner/innermost/configure])
1610 AT_CHECK([test -f inner/innermost/config.hin])
1611 AT_CHECK([test -f inner2/configure])
1613 # Running the outer configure recursively should provide the innermost
1614 # help strings.
1615 chmod a-w inner/innermost inner
1616 AT_CHECK([{ ./configure $configure_options --help=recursive; chmod u+w .; } | grep " INNER "],
1617          0, [ignore], [stderr],
1618          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1619 chmod a-w .
1620 AT_CHECK([{ ./configure $configure_options --help=recursive; chmod u+w .; } | grep " INNER2 "],
1621          0, [ignore], [stderr],
1622          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1623 chmod a-w .
1624 AT_CHECK([{ ./configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1625          0, [ignore], [stderr],
1626          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1627 chmod a-w .
1628 AT_CHECK([{ /bin/sh ./configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1629          0, [ignore], [stderr],
1630          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1631 chmod a-w .
1632 AT_CHECK([PATH=.$PATH_SEPARATOR$PATH; export PATH; { /bin/sh configure $configure_options --help=recursive; chmod +w .; } | grep " INNERMOST "],
1633          0, [ignore], [stderr],
1634          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1635 chmod a-w .
1636 AT_CHECK([PATH=.$PATH_SEPARATOR$PATH; export PATH; { configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1637          0, [ignore], [stderr],
1638          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1639 chmod u+w inner inner/innermost
1641 # Running the outer configure should trigger the inner.
1642 AT_CHECK_CONFIGURE([INNERMOST=tsomrenni])
1643 AT_CHECK([grep INNERMOST inner/innermost/config.h], 0,
1644 [[#define INNERMOST tsomrenni
1647 # Ensure we point to the right config.log file for errors.
1648 AT_CHECK_CONFIGURE([innermost_error=:], [1], [], [stderr])
1649 AT_CHECK([grep 'inner/innermost' stderr], [], [ignore])
1650 cd inner
1651 AT_CHECK_CONFIGURE([innermost_error=:], [1], [], [stderr])
1652 AT_CHECK([grep 'innermost' stderr], [], [ignore])
1653 cd ..
1655 # The same, but from a builddir.
1656 AS_MKDIR_P([builddir])
1657 chmod a-w builddir inner/innermost inner
1658 AT_CHECK([cd builddir && { ../configure $configure_options --help=recursive; chmod u+w .; } | grep " INNER "],
1659          0, [ignore], [stderr],
1660          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1661 chmod a-w builddir
1662 AT_CHECK([cd builddir && { ../configure $configure_options --help=recursive; chmod u+w .; } | grep " INNER2 "],
1663          0, [ignore], [stderr],
1664          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1665 chmod a-w builddir
1666 AT_CHECK([cd builddir && { ../configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1667          0, [ignore], [stderr],
1668          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1669 chmod a-w builddir
1670 AT_CHECK([cd builddir && { /bin/sh ../configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1671          0, [ignore], [stderr],
1672          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1673 chmod a-w builddir
1674 # Not all shells search $PATH for scripts.
1675 if (cd builddir && PATH=`pwd`/..$PATH_SEPARATOR$PATH /bin/sh configure $configure_options --help) >/dev/null 2>&1; then
1676   AT_CHECK([cd builddir && PATH=`pwd`/..$PATH_SEPARATOR$PATH /bin/sh configure $configure_options --help=recursive | grep " INNERMOST "], 0, [ignore])
1678 AT_CHECK([PATH=`pwd`$PATH_SEPARATOR$PATH; export PATH; cd builddir && { configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1679          0, [ignore], [stderr],
1680          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1681 chmod u+w builddir inner inner/innermost
1682 AT_CHECK([cd builddir && ../configure $configure_options INNERMOST=build/tsomrenni], 0, [ignore])
1683 AT_CHECK([grep INNERMOST builddir/inner/innermost/config.h], 0,
1684 [[#define INNERMOST build/tsomrenni
1687 AT_CLEANUP
1691 ## -------------------------------- ##
1692 ## Non-Autoconf AC_CONFIG_SUBDIRS.  ##
1693 ## -------------------------------- ##
1695 AT_SETUP([Non-Autoconf AC_CONFIG_SUBDIRS])
1696 AT_KEYWORDS([autoreconf])
1698 # We use aclocal (via autoreconf).
1699 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
1701 AT_DATA([install-sh], [])
1702 AT_DATA([configure.ac],
1703 [[AC_INIT(GNU Outer, 1.0)
1704 AC_CONFIG_SUBDIRS([inner])
1705 AC_OUTPUT
1708 AS_MKDIR_P([inner])
1710 AT_DATA([inner/configure],
1711 [[#! /bin/sh
1712 case "$*" in
1713     *--help*) echo 'No Autoconf here, folks!' ;;
1714     *)        echo got_it >myfile ;;
1715 esac
1716 exit 0
1718 chmod +x inner/configure
1720 AT_CHECK([autoreconf -Wall -v], 0, [ignore], [ignore])
1722 # Running the outer configure recursively should provide the innermost
1723 # help strings.
1724 AT_CHECK([./configure $configure_options --help=recursive | grep "folks"], 0, [ignore])
1726 # Running the outer configure should trigger the inner.
1727 AT_CHECK([./configure $configure_options], 0, [ignore])
1728 AT_CHECK([test -f inner/myfile], 0)
1730 AT_CLEANUP
1733 ## ------------------------------- ##
1734 ## Non-literal AC_CONFIG_SUBDIRS.  ##
1735 ## ------------------------------- ##
1737 AT_SETUP([Non-literal AC_CONFIG_SUBDIRS])
1738 AT_KEYWORDS([autoreconf])
1740 AT_DATA([install-sh], [])
1741 AT_DATA([configure.ac],
1742 [[AC_INIT(GNU Outer, 1.0)
1744 my_subdirs=
1745 # Taken from autoconf.texi:Subdirectories.
1746 if test "x$package_foo_enabled" = xyes; then
1747   my_subdirs="$my_subdirs foo"
1749 AC_CONFIG_SUBDIRS([$my_subdirs])
1750 AC_OUTPUT
1753 # Hand-written aclocal.m4, so we don't invoke `aclocal -Werror' which
1754 # could barf over warnings in third-party macro files, or fail over
1755 # warnings with older aclocal which didn't yet understand -W*.
1756 AT_DATA([aclocal.m4])
1758 AS_MKDIR_P([foo])
1760 AT_DATA([foo/configure],
1761 [[#! /bin/sh
1762 touch innerfile
1763 exit 0
1765 chmod +x foo/configure
1767 # autoreconf should warn without -Wno-syntax, but should not fail without -Werror.
1768 AT_CHECK([autoreconf -Werror -v], [1], [ignore], [stderr])
1769 AT_CHECK([grep 'AC_CONFIG_SUBDIRS:.*literals' stderr], [0], [ignore])
1770 AT_CHECK([autoreconf -v], [0], [ignore], [stderr])
1771 AT_CHECK([grep 'AC_CONFIG_SUBDIRS:.*literals' stderr], [0], [ignore])
1772 AT_CHECK([autoreconf -v --force -Wno-syntax], 0, [ignore], [stderr])
1773 AT_CHECK([grep 'AC_CONFIG_SUBDIRS:.*literals' stderr], [1])
1775 AT_CHECK([./configure $configure_options], [0], [ignore])
1776 AT_CHECK([test ! -f foo/innerfile])
1777 # Running the outer configure should trigger the inner.
1778 AT_CHECK([./configure $configure_options package_foo_enabled=yes], [0], [ignore])
1779 AT_CHECK([test -f foo/innerfile])
1781 AT_CLEANUP
1784 ## ----------------- ##
1785 ## Empty directory.  ##
1786 ## ----------------- ##
1788 AT_SETUP([Empty directory])
1789 AT_KEYWORDS([autoreconf])
1791 # We use aclocal (via autoreconf).
1792 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
1794 # The test group directory is not necessarily _empty_, but it does not contain
1795 # files meaningful to `autoreconf'.
1797 AT_CHECK([autoreconf -Wall -v], 1, [ignore], [ignore])
1799 AT_CLEANUP
1803 ## ------------------------------ ##
1804 ## Unusual Automake input files.  ##
1805 ## ------------------------------ ##
1807 # This parallels gnumake.test in Automake.
1809 AT_SETUP([Unusual Automake input files])
1810 AT_KEYWORDS([autoreconf])
1812 # We use aclocal and automake via autoreconf.
1813 AT_CHECK([automake --version || exit 77], [], [stdout], [ignore])
1814 AT_CHECK([[grep '[1-9]\.[0-9]' stdout || exit 77]], [], [ignore])
1816 AT_DATA([configure.ac],
1817 [[AC_INIT(GNU foo, 1.0)
1818 AM_INIT_AUTOMAKE
1819 AC_CONFIG_FILES([HeeHee])
1820 AC_OUTPUT
1823 AT_DATA([HeeHee.am],
1824 [[# Humans do no worse than `GNUmakefile.am'.
1825 AUTOMAKE_OPTIONS = foreign 1.8
1828 AT_CHECK([autoreconf -Wall -v -i], 0, [ignore], [stderr],
1829          [AT_CHECK([grep 'require.*1\.8' stderr && exit 77], [1])])
1830 AT_CHECK([test -f HeeHee.in])
1832 AT_CLEANUP