make fetch
[autoconf.git] / tests / torture.at
blob594299ef6d54b23523833850dda39317a138065a
1 #                                                       -*- Autotest -*-
3 # Copyright (C) 2000-2017, 2020-2024 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 <https://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([], 0, [],
153 [[configure.ac:4: warning: AC_OUTPUT should be used without arguments.
154 configure.ac:4: You should run autoupdate.
157 # Set a precious variable
158 AT_CHECK_AC_ARG_VAR([], [apple of my eye])
160 # Unset a precious variable
161 AT_CHECK_AC_ARG_VAR([apple of my eye], [])
163 # Change a precious variable
164 AT_CHECK_AC_ARG_VAR([apple of my eye], [orange of my eye])
166 # Change a precious variable that contains braces
167 AT_CHECK_AC_ARG_VAR([apple of my {eye}], [orange of my eye])
169 # Change a precious variable that contains all kinds of fun
170 AT_CHECK_AC_ARG_VAR(['p  r      ec"iou$], [orange of my eye])
171 dnl restore font-lock: "
173 # Warn (but do not fail) about a whitespace-only change
174 AT_CHECK_AC_ARG_VAR([    apple  of       my eye  ], [apple of my eye],
175                     [0], ["has whitespace changes"])
176 mv stdout configure-output
177 AT_CHECK([grep "ignoring whitespace changes" stderr], [], [ignore])
178 AT_CHECK([grep "precious:        apple" configure-output], [], [ignore])
180 AT_CLEANUP
185 ## ---------------------------------------------- ##
186 ## AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS.  ##
187 ## ---------------------------------------------- ##
189 AT_SETUP([[AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS]])
191 AT_DATA([configure.ac],
192 [[AC_INIT
193 AC_PROG_FGREP
194 rm -f -r header var-header file var-file link var-link command var-command
195 echo 'OK' >input
197 # Be sure to also stress the associated INIT-CMDS.
198 case $what_to_test in
199  header)
200    AC_CONFIG_HEADERS(header:input);;
201  var-header)
202    AC_CONFIG_HEADERS(var-header:$header_in, [], [header_in=input]);;
204  file)
205    AC_CONFIG_FILES(file:input);;
206  var-file)
207    AC_CONFIG_FILES(var-file:$file_in, [], [file_in=input]);;
209  command)
210    AC_CONFIG_COMMANDS(command,
211                       [cp input command]);;
212  var-command)
213    AC_CONFIG_COMMANDS(var-command,
214                       [cp $command_in var-command], [command_in=input]);;
216  link)
217    AC_CONFIG_LINKS(link:input);;
218  var-link)
219    AC_CONFIG_LINKS(var-link:$link_in, [], [link_in=input]);;
220 esac
221 AC_OUTPUT
224 AT_CHECK_AUTOCONF
227 # AT_CHECK_CONFIG_CREATION(THING = (header | link | file | command))
228 # ------------------------------------------------------------------
229 # Check that THING and var-THING (which uses variables in AC_CONFIG_THING)
230 # are properly created, with the right content.
231 # Use 'grep OK' instead of a simple 'cat' to avoid banners such as in
232 # AC_CONFIG_HEADERS.
233 m4_define([AT_CHECK_CONFIG_CREATION],
234 [AT_CHECK_CONFIGURE([what_to_test=$1])
235 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
236          [ignore], [$1
238 AT_CHECK([grep OK $1], [], [OK
241 AT_CHECK_CONFIGURE([what_to_test=var-$1 --no-create])
242 # config.status might be stupidly expecting data on stdin, if it's
243 # really broken...
244 AT_CHECK([./config.status var-$1 </dev/null], [], [ignore])
245 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
246          [ignore], [var-$1
248 AT_CHECK([grep OK var-$1], [], [OK
250 ])# AT_CHECK_CONFIG_CREATION
253 # AT_CHECK_CONFIG_CREATION_NOWRITE(THING = (header | link | file | command))
254 # --------------------------------------------------------------------------
255 # Check that THING and var-THING (which uses variables in AC_CONFIG_THING)
256 # are properly created, with the right content.
257 # Use 'grep OK' instead of a simple 'cat' to avoid banners such as in
258 # AC_CONFIG_HEADERS.
259 m4_define([AT_CHECK_CONFIG_CREATION_NOWRITE],
260 [AT_CHECK_CONFIGURE([what_to_test=$1])
261 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
262          [ignore], [$1
264 AT_CHECK([grep OK $1], [], [OK
267 AT_CHECK_CONFIGURE([what_to_test=var-$1 --no-create])
268 # config.status might be stupidly expecting data on stdin, if it's
269 # really broken...
270 # Skip check if user can rename files into a read-only directory (when
271 # run by root or on w32).
272 touch t
273 chmod a-w .
274 mv t t1 >/dev/null 2>&1 \
275   || AT_CHECK([./config.status var-$1 </dev/null || exit 1],
276    [1], [ignore], [ignore])
277 chmod u+w .
278 rm -rf t t1
279 ])# AT_CHECK_CONFIG_CREATION_NOWRITE
282 # Create a file
283 AT_CHECK_CONFIG_CREATION(file)
285 # Create a header
286 AT_CHECK_CONFIG_CREATION(header)
288 # Execute a command
289 AT_CHECK_CONFIG_CREATION(command)
291 # Create a link
292 AT_CHECK_CONFIG_CREATION(link)
294 # Now check for write errors.
295 # Depending on the shell, 'printf' might or might not report write
296 # errors on stdout.  Check /bin/sh regardless of $SHELL, because
297 # config.status always uses /bin/sh.
298 # Note: another way to force a write error is with ulimit -f, but
299 # depending on the OS it might not be possible to set that limit
300 # lower than one disk block, so we'd have to make the tests below
301 # produce much more output.
302 test_write_errors=false
303 if test -w /dev/full && test -c /dev/full; then
304   if /bin/sh -c 'printf "write errors detected?\\n"' > /dev/full 2> /dev/null
305   then :
306   else test_write_errors=:
307   fi
310 # Create a file
311 AT_CHECK_CONFIG_CREATION_NOWRITE(file)
312 # Create a file with bits from stdin
313 AT_CHECK([echo from-stdin | ./config.status --file=file:-],
314          [0], [ignore])
315 AT_CHECK([grep from-stdin file], [], [from-stdin
317 # Force write error creating a file on stdout
318 if $test_write_errors; then
319   AT_CHECK([./config.status --file=-:input </dev/null >/dev/full || exit 1],
320            [1], [ignore], [ignore])
323 # Validate that --file requires an argument
324 AT_CHECK([./config.status --file], [1], [ignore], [stderr])
325 AT_CHECK([grep 'missing file argument' stderr], [0], [ignore])
326 AT_CHECK([./config.status --file=], [1], [ignore], [stderr])
327 AT_CHECK([grep 'missing file argument' stderr], [0], [ignore])
329 # Create a header
330 AT_CHECK_CONFIG_CREATION_NOWRITE(header)
331 # Create a header on stdout
332 AT_CHECK([./config.status --header=-:input </dev/null],
333          [0], [stdout], [ignore])
334 AT_CHECK([grep OK stdout], [], [OK
336 # Force write error creating a header on stdout
337 if $test_write_errors; then
338   AT_CHECK([./config.status --header=-:input </dev/null >/dev/full || exit 1],
339            [1], [ignore], [ignore])
342 # Execute a command
343 AT_CHECK_CONFIG_CREATION_NOWRITE(command)
345 # Create a link
346 AT_CHECK_CONFIG_CREATION_NOWRITE(link)
348 # Check that no use of 'ac_write_fail' escaped into config.status
349 AT_CHECK([grep ac_write_fail config.status], [1])
351 # Check that --file and --header accept funny file names
352 AT_DATA([fgrep.in],
353 [[FGREP="@FGREP@"
355 ./config.status --file=fgrep:fgrep.in
356 . ./fgrep
359 export x
360 for file in \
361   'with  funny '\'' $x & #! name' \
362   'file with  funny \ '\'' \'\'' $ & #!*? name' \
363   'with  funny \ '\'' \'\'' " | <a >b & * ? name ' # "restore font-lock
365   # The function func_sanitize_file_name comes from tools.at
366   file=`func_sanitize_file_name "$file"`
367   cat >"$file.in" <<'END'
368 @configure_input@
370   AT_CHECK([./config.status "--file=$file:$file.in"],
371            [0], [ignore])
372   AT_CHECK([$FGREP "$file" "$file"], [0], [ignore])
373   AT_CHECK([./config.status "--header=$file:$file.in"],
374            [0], [ignore])
375   # Run the same test a 2nd time to see that config.status does not recreate
376   # the header (regression test)
377   AT_CHECK_UNQUOTED([./config.status "--header=$file:$file.in"],
378                     [0], [config.status: creating $file
379 config.status: $file is unchanged
381   AT_CHECK_UNQUOTED([grep ' & ' "$file"], [],
382 [/* $file.  Generated from $file.in by configure.  */
384   AT_CHECK([$FGREP "$file" "$file"], [0], [ignore])
385 done
386 AT_CLEANUP
390 ## ---------------------------------------- ##
391 ## Macro calls in AC_CONFIG_COMMANDS tags.  ##
392 ## ---------------------------------------- ##
394 AT_SETUP([Macro calls in AC_CONFIG_COMMANDS tags])
396 AT_DATA_M4SUGAR([configure.ac],
397 [[AC_INIT
398 AC_CONFIG_COMMANDS([m4_if(1,1,mytag)])
399 AC_OUTPUT
402 AT_CHECK_AUTOCONF
403 AT_CHECK_CONFIGURE
405 AT_CLEANUP
409 ## ------------------- ##
410 ## Missing templates.  ##
411 ## ------------------- ##
413 # Check that config.status detects missing input files
414 AT_SETUP([Missing templates])
416 AT_DATA([configure.ac],
417 [[AC_INIT
418 AC_CONFIG_FILES([nonexistent])
419 AC_OUTPUT
422 AT_CHECK_AUTOCONF
423 mkdir build
424 AT_CAPTURE_FILE([build/config.log])[]dnl
425 cd build
426 AT_CHECK([../configure], [1], [ignore],
427 [[config.status: error: cannot find input file: 'nonexistent.in'
429 # Make sure that the output file doesn't exist
430 AT_CHECK([test -f nonexistent], 1)
431 cd ..
432 AT_CHECK_CONFIGURE([], [1], [],
433 [[config.status: error: cannot find input file: 'nonexistent.in'
435 # Make sure that the output file doesn't exist
436 AT_CHECK([test -f nonexistent], 1)
438 AT_CLEANUP
443 ## ---------------------- ##
444 ## configure invocation.  ##
445 ## ---------------------- ##
447 # Check that 'configure' and 'config.status' honor their interface.
449 # We run './configure one=val1 --enable-two=val2 --with-three=val3'
450 # and verify that (i) 'configure' correctly receives the arguments,
451 # (ii) correctly passes them to 'config.status', which we check by
452 # running 'config.status --recheck', (iii) correctly passes them
453 # to sub-configure scripts, and (iv) correctly reproduces them with
454 # 'config.status --config'.
456 AT_SETUP([configure invocation])
458 mkdir sub
460 AT_DATA([configure.ac],
461 [[AC_INIT
462 AC_CONFIG_SUBDIRS([sub])
463 echo "result=$one$enable_two$with_three"
464 AC_OUTPUT
467 AT_DATA([sub/configure.ac],
468 [[AC_INIT
469 echo "result=$one$enable_two$with_three"
470 AC_OUTPUT
473 echo fake install-sh script >install-sh
475 AT_CHECK_AUTOCONF
476 cd sub
477 AT_CHECK_AUTOCONF
478 cd ..
480 AT_CHECK_CONFIGURE([one=one --enable-two=two --with-three=three |
481                      sed -n -e 's/^result=//p'], 0,
482                    [m4_do([onetwothree
483 ],                        [onetwothree
484 ])])
485 AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
486          [onetwothree
488 AT_CHECK([args=`./config.status --config` && eval ./configure \$configure_options "$args" |
489             sed -n -e 's/^result=//p'], 0,
490          [m4_do([onetwothree
491 ],              [onetwothree
492 ])])
494 AT_CHECK_CONFIGURE([one="\"'$ " --enable-two="\" '  $" --with-three="   \"'$"|
495                       sed -n -e 's/^result=//p'], 0,
496                    [m4_do(["'$ " '  $   "'$
497 ],                        ["'$ " '  $   "'$
498 ])])
499 AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
500          ["'$ " '  $    "'$
502 dnl restore font-lock: "
503 AT_CHECK([args=`./config.status --config` && eval ./configure \$configure_options "$args" |
504             sed -n -e 's/^result=//p'], 0,
505          [m4_do(["'$ " '  $     "'$
506 ],              ["'$ " '  $     "'$
507 ])])
509 AT_CLEANUP
513 ## ---------------------- ##
514 ## --help and --version.  ##
515 ## ---------------------- ##
517 AT_SETUP([--help and --version in unwritable directory])
519 AS_MKDIR_P([inner])
520 AT_DATA([inner/configure.ac],
521 [[AC_INIT
522 AC_OUTPUT
525 AT_CHECK_M4([(cd inner && autoconf --force)])
526 AT_CHECK([test -s inner/configure])
527 if test "$SHELL_N" != none; then
528   AT_CHECK_SHELL_SYNTAX([inner/configure])
531 chmod a-w inner
532 AT_CHECK([(cd inner && ./configure --help)], 0, [ignore], [ignore])
533 AT_CHECK([(cd inner && ./configure --version)], 0, [ignore], [ignore])
534 chmod u+w inner
536 AT_CLEANUP
540 ## -------------------------------------------- ##
541 ## Check that '#define' templates are honored.  ##
542 ## -------------------------------------------- ##
544 # Use various forms of '#define' templates, and make sure there are no
545 # problems when a symbol is prefix of another.
547 AT_SETUP([@%:@define header templates])
548 AT_KEYWORDS([AC@&t@_DEFINE])
550 AT_DATA([configure.ac],
551 [[AC_INIT
552 AC_CONFIG_HEADERS(config.h:config.hin)
554 # I18n of dummy variables: their French translations.
555 AC_DEFINE(foo, toto)
556 AC_DEFINE(bar, tata)
557 AC_DEFINE(baz, titi)
558 AC_DEFINE(fubar, tutu)
560 # Symbols which are prefixes of another.
561 AC_DEFINE(a, A)
562 AC_DEFINE(aaa, AAA)
563 AC_DEFINE(aa, AA)
565 # backslash-newline combinations
566 AC_DEFINE([multiline], [line1\
567 line2\
568 line3 \
569 line4])
570 AC_DEFINE([multiline_args(ARG1, ARG2)], [ARG2 \
571 ARG1])
572 AC_CONFIG_FILES(defs)
574 # underquoted #
575 AC_DEFINE([paste(a,b)], [a##b])
577 # Things included in confdefs.h, but which make no sense in
578 # config.h, nor in $DEFS.
579 cat <<\EOF >>confdefs.h
580 /* Hi Mum! Look, I am doing C++! */
581 #ifdef __cplusplus
582 void exit (int status);
583 #endif
586 # In addition of config.h output a full DEFS
587 AC_OUTPUT_MAKE_DEFS
588 DEFS_SAVED=$DEFS
589 AC_SUBST(DEFS_SAVED)
590 AC_OUTPUT
593 AT_DATA([defs.in],
594 [[@DEFS_SAVED@
597 AT_DATA([config.hin],
598 [[#define foo   0
599 #  define bar bar
600 #  define baz   "Archimedes was sinking in his baz"
601   #  define fubar                               tutu
602 #define a B
603  #define aa BB
604  #  define aaa BBB
605 #undef a
606  #  undef aa
607 #undef aaa
608 #define aaa(a, aa) aa a
609 #define aaab
610 #define aaac(a, aa) aa a
611 #undef multiline
612 #  undef multiline_args
613 #define paste(a,b) a##b
614 /* an ugly one: */
615 #define str(define) \
616 #define
617 #define stringify(arg) str(arg)
618 #undef aaa /* with comments */
619 #undef not_substed /* with comments */
622 AT_CHECK_AUTOCONF
623 AT_CHECK_CONFIGURE
625 AT_DATA([expout],
626 [[/* config.h.  Generated from config.hin by configure.  */
627 #define foo toto
628 #  define bar tata
629 #  define baz titi
630   #  define fubar tutu
631 #define a A
632  #define aa AA
633  #  define aaa AAA
634 #define a A
635  #  define aa AA
636 #define aaa AAA
637 #define aaa AAA
638 #define aaab
639 #define aaac(a, aa) aa a
640 #define multiline line1\
641 line2\
642 line3 \
643 line4
644 #  define multiline_args(ARG1, ARG2) ARG2 \
645 ARG1
646 #define paste(a,b) a##b
647 /* an ugly one: */
648 #define str(define) \
649 #define
650 #define stringify(arg) str(arg)
651 #define aaa AAA
652 /* #undef not_substed */
654 AT_CHECK([cat config.h], 0, expout)
656 # Check the value of DEFS.
657 AT_DATA([expout],
658 [[-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
661 # Because we strip trailing spaces in 'testsuite' we can't leave one in
662 # expout, hence nuke the one left by AC_OUTPUT_MAKE_DEFS.
663 AT_CHECK([sed -e 's/ $//' defs], 0, expout)
665 AT_CLEANUP
669 ## ------------------------- ##
670 ## Torturing config.status.  ##
671 ## ------------------------- ##
673 ## Require 100 AC_DEFINE and AC_SUBST and AC_SUBST_FILE with a significantly
674 ## big value.  This is mostly to check that Autoconf produces portable sed
675 ## scripts in config.status.  sed is used to skip the first two lines
676 ## 'Generated by ...'.
678 # We use m4_for many times.
679 m4_pattern_allow([^m4_for$])
681 AT_SETUP([Torturing config.status])
683 dnl The value used as a big value for AC_DEFINE.
684 dnl Don't use sh active chars here, below it is also used in a sh
685 dnl assignment.
686 m4_define([AT_BIG_VALUE],
687 [This value should be long enough to torture the various limits of sed and other tools used by Autoconf.])
689 m4_define([AT_DESCRIPTION],
690 [Define to a long string if your 'Autoconf' works properly.])
693 # AT_DUMMY_VAR(NUMBER)
694 # --------------------
695 # Build a name used for AC_SUBST and AC_DEFINE.  Put ac_ in it
696 # so that the check for user name space invasion does not complain
697 # of the new variables defined.
699 # Note that you should not use the name ac_dummy, because it will be
700 # turned into ac_uummy during the construction of config.status.  Yes,
701 # this is admittedly a bug, but it would be too hard to fix this.
702 # There is really no point in AC_DEFINE a var named ac_d.*.
703 m4_pattern_allow([^m4_bpatsubst$])
704 m4_define([AT_DUMMY_VAR],
705 [ac_Dummy_[]m4_bpatsubst([000$1], [.*\(...\)$], [\1])])
709 AT_DATA([dummy.in],
710 [m4_for([AT_Count], 1, 100, 1,
711 [@AT_DUMMY_VAR(AT_Count)@
712 @[f]AT_Count@
713 ])])
717 while test $i != 101; do
718   echo "content of file $i" > file_$i
719   AS_VAR_ARITH([i], [$i + 1])
720 done
723 # ------------ #
724 # configure.ac #
725 # ------------ #
727 m4_pattern_allow([^m4_(define|defun)$])
728 AT_DATA([configure.ac],
729 dnl The following lines transfer AT_DUMMY_VAR, AT_DESCRIPTION, and
730 dnl AT_BIG_VALUE into the configure.ac as AC_DUMMY_VAR etc.
731 [[m4_define([AC_DUMMY_VAR],]
732 m4_dquote(m4_defn([AT_DUMMY_VAR]))[)]]
734 [[m4_define([AC_DESCRIPTION],]
735 m4_dquote(m4_defn([AT_DESCRIPTION]))[)]]
737 [[m4_define([AC_BIG_VALUE],]
738 m4_dquote(m4_defn([AT_BIG_VALUE]))[)]]
740 [[# AC_DEFUBST(NAME)
741 # ----------------
742 # Related VALUE to NAME both with AC_SUBST and AC_DEFINE.  This is
743 # used in the torture tests.
744 m4_defun([AC_DEFUBST],
745 [AC_DUMMY_VAR($1)="AC_BIG_VALUE"
746 AC_DEFINE_UNQUOTED(AC_DUMMY_VAR($1), "$AC_DUMMY_VAR($1) $AC_DUMMY_VAR($1)",
747                    AC_DESCRIPTION)
748 AC_SUBST(AC_DUMMY_VAR($1))
749 AC_SUBST_FILE([f]$1)
750 f$1=file_$1
753 AC_INIT
754 AC_CONFIG_HEADERS(config.h:config.hin)
755 AC_CONFIG_FILES(dummy)
756 m4_for(AC_Count, 1, 100, 1,
757        [AC_DEFUBST(AC_Count)])
758 AC_PROG_AWK
759 AC_OUTPUT
760 ]])# configure.ac
762 AT_CHECK_AUTOCONF
763 AT_CHECK_AUTOHEADER([],
764   m4_for(AT_Count, 1, 100, 1, [ AT_DUMMY_VAR(AT_Count)]))
766 # Check both awk and the result of AC_PROG_AWK.
767 # Quote the first word in the for list for Solaris sh.
768 for awk_arg in "FOO=" AWK=awk; do
769   AT_CHECK_CONFIGURE([$awk_arg])
771   # Checking that AC_DEFINE worked properly.
772   AT_DATA([expout],
773 [/* Define to the address where bug reports for this package should be sent. */
774 #define PACKAGE_BUGREPORT ""
776 /* Define to the full name of this package. */
777 #define PACKAGE_NAME ""
779 /* Define to the full name and version of this package. */
780 #define PACKAGE_STRING ""
782 /* Define to the one symbol short name of this package. */
783 #define PACKAGE_TARNAME ""
785 /* Define to the home page for this package. */
786 #define PACKAGE_URL ""
788 /* Define to the version of this package. */
789 #define PACKAGE_VERSION ""
790 m4_for(AT_Count, 1, 100, 1,
792 /* AT_DESCRIPTION */
793 [#define] AT_DUMMY_VAR(AT_Count) "AT_BIG_VALUE AT_BIG_VALUE"
794 ])])
796   AT_CHECK([sed -n '4,$ p' config.h], 0, expout)
798   # Checking that AC_SUBST worked properly.
799   AT_DATA([expout],
800 [m4_for(AT_Count, 1, 100, 1,
801 [AT_BIG_VALUE
802 content of file AT_Count
803 ])])
805   AT_CHECK([cat dummy], 0, expout)
806 done
808 AT_CLEANUP
811 ## ------------------------------- ##
812 ## Substitute a 2000-byte string.  ##
813 ## ------------------------------- ##
815 # Solaris 9 /usr/ucb/sed that rejects commands longer than 4000 bytes.  HP/UX
816 # sed dumps core around 8 KiB.  However, POSIX says that sed need not
817 # handle lines longer than 2048 bytes (including the trailing newline).
818 # So we'll just test a 2000-byte value, and for awk, we test a line with
819 # almost 1000 words, and one variable with 5 lines of 2000 bytes each:
820 # multi-line values should allow to get around the limitations.
821 # We also test runs of around 148 backslashes: they need to be escaped,
822 # and 148 is the portable limit for awk string literals.  config.status
823 # uses concatenation to generate longer strings.
825 AT_SETUP([Substitute a 2000-byte string])
827 AT_DATA([Foo.in], [@foo@
829 AT_DATA([Bar.in], [@bar@
831 AT_DATA([Baz.in], [@baz@
833 AT_DATA([Boo.in], [@b147@
834 @b148@
835 @b149@
836 @b295@
837 @b296@
838 @b297@
841 AT_DATA([configure.ac],
842 [[AC_INIT
843 AC_SUBST([foo], ]m4_for([n], 1, 100,, ....................)[)
844 AC_SUBST([bar], "]m4_for([n], 1, 100,, @ @ @ @ @ @ @ @ @ @@)[")
845 baz="]m4_for([m], 1, 100,, ... ... ... ... ....)[
847 baz=$baz$baz$baz$baz$baz
848 AC_SUBST([baz])
849 b29='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
850 b147=$b29$b29$b29$b29$b29'\\'
851 b148=$b147'\'
852 b149=$b148'\'
853 b295=$b147$b147'\'
854 b296=$b295'\'
855 b297=$b296'\'
856 AC_SUBST([b147])
857 AC_SUBST([b148])
858 AC_SUBST([b149])
859 AC_SUBST([b295])
860 AC_SUBST([b296])
861 AC_SUBST([b297])
862 AC_PROG_AWK
863 AC_CONFIG_FILES([Foo Bar Baz Boo])
864 AC_OUTPUT
867 cp "$abs_top_srcdir/build-aux/install-sh" .
869 b29='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
870 b147=$b29$b29$b29$b29$b29'\\'
871 b295=$b147$b147'\'
872 cat >Boo-exp <<EOF
873 $b147
874 $b147\\
875 $b147\\\\
876 $b295
877 $b295\\
878 $b295\\\\
881 AT_CHECK_AUTOCONF
882 # Check both awk and the result of AC_PROG_AWK
883 # Quote the first word in the for list for Solaris sh.
884 for awk_arg in "Foo=" AWK=awk; do
885   AT_CHECK_CONFIGURE([$awk_arg])
886   AT_CHECK([cat Foo], 0, m4_for([n], 1, 100,, ....................)
888   AT_CHECK([cat Bar], 0, m4_for([n], 1, 100,, @ @ @ @ @ @ @ @ @ @@)
890   AT_DATA([stdout],
891   [m4_for([n], 1, 5,, m4_for([m], 1, 100,, ... ... ... ... ....)
893   AT_CHECK([cat Baz], 0, [stdout])
894   AT_CHECK([diff Boo-exp Boo])
895 done
896 AT_CLEANUP
899 ## ------------------------------ ##
900 ## Define to a 2000-byte string.  ##
901 ## ------------------------------ ##
903 AT_SETUP([Define to a 2000-byte string])
904 AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
906 AT_CONFIGURE_AC(
908 AC_DEFINE_UNQUOTED([foo], ]m4_for([n], 1, 100,, ....................)[, [desc])
909 AC_DEFINE([fooq], ]m4_for([n], 1, 100,, ....................)[, [desc])
912 AT_CHECK_AUTOCONF
913 AT_CHECK_AUTOHEADER([], [foo fooq])
914 AT_CHECK_CONFIGURE
915 AT_CHECK_DEFINES([@%:@define foo m4_for([n], 1, 100,, ....................)
916 @%:@define fooq m4_for([n], 1, 100,, ....................)
918 AT_CLEANUP
921 ## ------------------------------------------ ##
922 ## Substitute and define special characters.  ##
923 ## ------------------------------------------ ##
925 # Use characters special to the shell, sed, awk, and M4.
927 AT_SETUP([Substitute and define special characters])
928 AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
930 AT_XFAIL_IF([byte=\\200s; dnl
931 test `{ printf $byte; echo; } | sed -n '/^./p' | wc -l` = 0])
933 AT_DATA([Foo.in], [@foo@
934 @bar@@notsubsted@@baz@ stray @ and more@@@baz@
935 abc@bar@baz@baz
936 abc@bar@@baz@baz
937 abc@bar@@baz@baz@
938 abc@bar @baz@baz
939 abc@bar @baz@baz@
940 abc@bar @baz@@baz@
941 @file@
942          @file@
943 X@file@
944 @file@X
947 AT_DATA([File],
948 [@foo@@bar@
951 AT_DATA([Zardoz.in], [@zardoz@
954 AT_CONFIGURE_AC(
955 [[foo="AS@&t@_ESCAPE([[X*'[]+ ", & &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !]])"
957 bar="@foo@ @baz@"
958 baz=bla
959 ( for i in 0 1 2 3; do
960     for j in 0 1 2 3 4 5 6 7; do
961       for k in 0 1 2 3 4 5 6 7; do
962         case $i$j$k in #(
963         000 | 015 | 377) ;; # MinGW awk dislikes 0xFF, and the test does
964                             # the wrong thing for CR on MinGW.
965                             #(
966         *) printf \\$i$j$k's' ;; # The 's' works around a Solaris 8 /bin/bash bug.
967         esac
968       done
969     done
970   done
971   printf \\n
972 ) >allowed-chars
973 zardoz=`cat allowed-chars`
974 AC_SUBST([foo])
975 AC_SUBST([bar])
976 AC_SUBST([baz])
977 AC_SUBST([zardoz])
978 file=File
979 AC_SUBST_FILE([file])
980 AC_DEFINE([fooq], [[X*'[]+ ", & &`\($foo !]], [Awful value.])
981 AC_DEFINE([barq], [[%!_!# X]], [Value that is used as special delimiter.])
982 AC_DEFINE_UNQUOTED([foo], [[X*'[]+ ", & &\`\\(\$foo !]], [Awful value.])
983 AC_DEFINE_UNQUOTED([bar], [[%!_!# X]], [Value that is used as special delimiter.])
984 AC_DEFINE_UNQUOTED([unq1], [$baz], [unquoted, test 1])
985 AC_DEFINE_UNQUOTED([unq2], [\$baz], [unquoted, test 2])
986 AC_DEFINE_UNQUOTED([unq3], ["$baz"], [unquoted, test 3])
987 AC_DEFINE_UNQUOTED([unq4], [${baz+set}], [unquoted, test 4])
988 AC_DEFINE_UNQUOTED([unq5], ["${baz+`echo "a "' b'`}"], [unquoted, test 5])
989 AC_DEFINE_UNQUOTED([unq6], [`echo hi`], [unquoted, test 6])
990 AC_DEFINE_UNQUOTED([unq7], ['\\"'], [unquoted, test 7])
991 AC_PROG_AWK
992 AC_CONFIG_FILES([Foo Zardoz])]])
994 AT_CHECK_AUTOCONF
995 AT_CHECK_AUTOHEADER([],
996    [foo fooq bar barq unq1 unq2 unq2 unq3 unq4 unq5 unq6 unq7])
997 # Check both awk and the result of AC_PROG_AWK
998 # Quote the first word in the for list for Solaris sh.
999 for awk_arg in "FOO=" AWK=awk; do
1000   AT_CHECK_CONFIGURE([$awk_arg])
1001   AT_CHECK([cat Foo], 0, [[X*'[]+ ", & &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !
1002 @foo@ @baz@@notsubsted@bla stray @ and more@@bla
1003 abc@foo@ @baz@baz@baz
1004 abc@foo@ @baz@blabaz
1005 abc@foo@ @baz@blabaz@
1006 abc@bar blabaz
1007 abc@bar blabaz@
1008 abc@bar blabla
1009 @foo@@bar@
1010 @foo@@bar@
1011 X@file@
1012 @file@X
1014   AT_CHECK([cmp allowed-chars Zardoz])
1015   AT_CHECK_DEFINES([[#define bar %!_!# X
1016 #define barq %!_!# X
1017 #define foo X*'[]+ ", & &`\($foo !
1018 #define fooq X*'[]+ ", & &`\($foo !
1019 #define unq1 bla
1020 #define unq2 $baz
1021 #define unq3 "bla"
1022 #define unq4 set
1023 #define unq5 "a  b"
1024 #define unq6 hi
1025 #define unq7 '\"'
1027 done
1028 AT_CLEANUP
1031 ## ---------------------- ##
1032 ## Substitute a newline.  ##
1033 ## ---------------------- ##
1035 AT_SETUP([Substitute a newline])
1037 AT_DATA([Foo.in],
1038 [@foo@
1039 @bar@
1042 AT_DATA([configure.ac],
1043 [[AC_INIT
1044 foo='one
1045 two'
1046 bar='%!_!# ''
1048 AC_SUBST([foo])
1049 AC_SUBST([bar])
1050 AC_CONFIG_FILES([Foo])
1051 AC_PROG_AWK
1052 AC_OUTPUT
1055 cp "$abs_top_srcdir/build-aux/install-sh" .
1057 echo 'one
1059 %!_!# ''
1060 x' >expout
1062 AT_CHECK_AUTOCONF
1063 # Check both awk and the result of AC_PROG_AWK
1064 # Quote the first word in the for list for Solaris sh.
1065 for awk_arg in "FOO=" AWK=awk; do
1066   AT_CHECK_CONFIGURE([$awk_arg])
1067   AT_CHECK([cat Foo], 0, [expout])
1068 done
1069 AT_CLEANUP
1072 ## ------------------ ##
1073 ## Define a newline.  ##
1074 ## ------------------ ##
1076 AT_SETUP([Define a newline])
1077 AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
1078 AT_CONFIGURE_AC([[AC_DEFINE([foo], [one
1079 two], [This spans two lines.])
1081 AT_CHECK_AUTOCONF([], [], [], [stderr])
1082 dnl Older versions of m4 report error at line 5 (end of macro);
1083 dnl newer versions report it at line 4 (start of macro).
1084 AT_CHECK([[sed '/trailer\.m4:/d; s/^configure\.ac:[45]: //' stderr]], [],
1085 [[warning: AC_DEFINE: 'one
1086 two' is not a valid preprocessor define value
1088 AT_CHECK_AUTOHEADER([], [foo])
1089 AT_CHECK_CONFIGURE
1090 AT_CHECK_DEFINES([[#define foo one
1093 rm -rf autom4te.cache
1095 AT_CONFIGURE_AC([[AC_DEFINE_UNQUOTED([foo], [one
1096 two], [This spans two lines.])
1098 AT_CHECK_AUTOCONF([], [], [], [stderr])
1099 AT_CHECK([[sed '/trailer.m4:/d; s/^configure\.ac:[45]: //' stderr]], [],
1100 [[warning: AC_DEFINE_UNQUOTED: 'one
1101 two' is not a valid preprocessor define value
1103 AT_CHECK_AUTOHEADER([], [foo])
1104 AT_CHECK_CONFIGURE
1105 AT_CHECK_DEFINES([[#define foo one
1108 AT_CLEANUP
1111 ## ------------------------------------ ##
1112 ## AC_SUBST: variable name validation.  ##
1113 ## ------------------------------------ ##
1115 AT_SETUP([AC_SUBST: variable name validation])
1117 AT_CONFIGURE_AC([[AC_SUBST(, [])
1118 AC_CONFIG_FILES([Makefile])
1120 AT_DATA([Makefile.in], [[
1122 mv -f configure.ac configure.tmpl
1124 # Invalid names.
1125 for var in ['' ab\~ ab\( ab[] ab\' ab\" ab\\\\]; do
1126   sed ["s/AC_SUBST(/&[$var]/"] <configure.tmpl >configure.ac
1127   AT_CHECK_AUTOCONF([], [1], [], [ignore])
1128 done
1130 # Valid names.
1131 for var in ab a4 'a@@&t@\&t@b'; do
1132   sed ["s/AC_SUBST(/&[$var]/"] <configure.tmpl >configure.ac
1133   AT_CHECK_AUTOCONF
1134   AT_CHECK_AUTOHEADER
1135   AT_CHECK_CONFIGURE
1136 done
1138 AT_CLEANUP
1141 ## ------------------------ ##
1142 ## datarootdir workaround.  ##
1143 ## ------------------------ ##
1145 AT_SETUP([datarootdir workaround])
1147 AT_DATA([Foo.in],
1148 [@datadir@
1149 @docdir@
1150 @infodir@
1151 @localedir@
1152 @mandir@
1155 AT_DATA([Bar.in],
1156 [@mydatadir@
1159 AT_DATA([configure.ac],
1160 [[AC_INIT
1161 d@&t@nl The following line silences the warnings, if uncommented:
1162 d@&t@nl AC_DEFUN([AC_DATAROOTDIR_CHECKED])
1164 # This substitution is wrong and bogus!  Don't use it in your own code!
1165 # Read 'info Autoconf "Defining Directories"'!
1166 AC_SUBST([mydatadir], [${datadir}/my])
1168 AC_CONFIG_FILES([Foo Bar])
1169 AC_OUTPUT
1172 cp "$abs_top_srcdir/build-aux/install-sh" .
1174 AT_CHECK_AUTOCONF
1175 AT_CHECK_CONFIGURE([], [], [],
1176   [config.status: WARNING:  'Foo.in' seems to ignore the --datarootdir setting
1177 config.status: WARNING: Bar contains a reference to the variable 'datarootdir'
1178 which seems to be undefined.  Please make sure it is defined
1180 AT_CHECK([grep datarootdir Foo], 1, [])
1182 rm configure
1183 sed '/AC_DEFUN/s/^d@&t@nl //' configure.ac >t
1184 mv t configure.ac
1186 AT_CHECK_AUTOCONF
1187 AT_CHECK_CONFIGURE
1189 AT_CLEANUP
1192 ## -------- ##
1193 ## srcdir.  ##
1194 ## -------- ##
1196 AT_SETUP([srcdir])
1198 rm -f -r at-dir
1199 mkdir at-dir
1200 : >at-dir/bar.in
1201 : >foo.in
1203 AT_DATA([configure.ac],
1204 [[AC_INIT
1206 AC_CONFIG_FILES([foo at-dir/bar])
1208 # Use quotes in the INIT-COMMANDS to accommodate a value of $srcdir
1209 # containing e.g., spaces or shell meta-characters.
1210 # Use *single* quotes because the context is an unquoted here-doc.
1211 AC_CONFIG_COMMANDS([report],
1212 [test -f "$srcdir/configure.ac" ||
1213    AC_MSG_ERROR([cannot find $srcdir/configure.ac])],
1214                    [srcdir='$srcdir'])
1216 AC_OUTPUT
1217 rm -f -r foo at-dir/bar
1220 AT_CHECK_AUTOCONF
1222 # In place.
1223 AT_CHECK([./configure $configure_options], [], [ignore])
1225 # Relative name.
1226 AT_CHECK([cd at-dir && ../configure $configure_options], [], [ignore])
1228 # Absolute name.
1229 at_here=`pwd`
1230 AT_CHECK([cd at-dir && "$at_here/configure" $configure_options], [], [ignore])
1232 AT_CLEANUP
1235 ## ------- ##
1236 ## VPATH.  ##
1237 ## ------- ##
1239 AT_SETUP([VPATH])
1241 dirs='at paren brace space'
1242 for dir in $dirs; do
1243   mkdir $dir $dir/s1 $dir/s2
1244   touch $dir/f $dir/s1/f1 $dir/s2/f2
1245 done
1247 AT_DATA([configure.ac],
1248 [[AC_INIT
1249 AC_CONFIG_FILES([at/Makefile paren/Makefile brace/Makefile space/Makefile])
1250 AC_OUTPUT
1253 AT_DATA([at/Makefile.in],
1254 [[# This is what you should use in order to be portable to old makes.
1255 srcdir = @srcdir@
1256 VPATH = @srcdir@/s1:@srcdir@:@srcdir@/s2
1257 all: f f1 f2
1258         @echo ok
1261 AT_DATA([paren/Makefile.in],
1262 [[# This works with some makes but not with old ones.
1263 srcdir = @srcdir@
1264 VPATH = $(srcdir)/s1:$(srcdir):$(srcdir)/s2
1265 all: f f1 f2
1266         @echo ok
1269 AT_DATA([brace/Makefile.in],
1270 [[# This works with some makes but not with old ones.
1271 srcdir = @srcdir@
1272 VPATH = ${srcdir}/s1:${srcdir}:${srcdir}/s2
1273 all: f f1 f2
1274         @echo ok
1277 AT_DATA([space/Makefile.in],
1278 [[# This fails with FreeBSD make, for example.
1279 srcdir = @srcdir@
1280 VPATH = @srcdir@/s1 @srcdir@ @srcdir@/s2
1281 all: f f1 f2
1282         @echo ok
1285 AT_CHECK_AUTOCONF
1287 # In place.
1288 AT_CHECK([./configure $configure_options], [], [ignore])
1289 # Treat BSD make separately, afterwards, for maximal coverage.
1290 dirs='at paren brace'
1291 for dir in $dirs; do
1292   AT_CHECK_MAKE([], [$dir])
1293 done
1295 rm -f config.status
1296 mkdir build absbuild
1298 # Relative name.
1299 AT_CHECK([cd build && ../configure $configure_options], [], [ignore])
1300 for dir in $dirs; do
1301   AT_CHECK_MAKE([], [build/$dir])
1302 done
1304 # Absolute name.
1305 at_here=`pwd`
1306 AT_CHECK([cd absbuild && "$at_here/configure" $configure_options], [], [ignore])
1307 for dir in $dirs; do
1308   AT_CHECK_MAKE([], [absbuild/$dir])
1309 done
1311 # These will not pass with BSD make.
1312 AT_CHECK_MAKE([|| exit 77], [space])
1313 AT_CHECK_MAKE([], [build/space])
1314 AT_CHECK_MAKE([], [absbuild/space])
1317 AT_CLEANUP
1320 ## ----------------- ##
1321 ## Signal handling.  ##
1322 ## ----------------- ##
1324 AT_SETUP([Signal handling])
1326 AT_DATA([configure.ac],
1327 [[AC_INIT
1328 kill -2 $$
1329 exit 77
1330 AC_OUTPUT
1333 AT_CHECK_AUTOCONF
1334 AT_CHECK_CONFIGURE([], [1], [ignore], [ignore])
1336 AT_CLEANUP
1339 ## ----------------- ##
1340 ## AC_CONFIG_LINKS.  ##
1341 ## ----------------- ##
1343 AT_SETUP([AC_CONFIG_LINKS])
1345 AT_DATA([configure.ac],
1346 [[AC_INIT([config links to config files test], [1.0])
1347 AC_CONFIG_SRCDIR([sub1/file1.in])
1348 AC_CONFIG_FILES([sub1/file1 file2])
1349 AC_CONFIG_LINKS([file1:sub1/file1 sub2/file2:file2])
1350 AC_OUTPUT
1353 mkdir sub1
1355 AT_DATA([sub1/file1.in],
1356 [[/* @configure_input@ */
1357 #define PACKAGE_STRING "@PACKAGE_STRING@"
1360 AT_DATA([file2.in],
1361 [[/* @configure_input@ */
1362 #define PACKAGE_STRING "@PACKAGE_STRING@"
1365 mkdir build
1366 AT_CHECK_AUTOCONF
1367 cd build
1368 AT_CHECK([../configure && ../configure], 0, [ignore])
1369 AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
1371 AT_CHECK([../configure && ../configure], 0, [ignore])
1372 AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
1374 cd ..
1375 rm -rf build
1376 mkdir build
1377 cd build
1378 cwd=`pwd`
1379 AT_CHECK(["$cwd"/../configure && "$cwd"/../configure], 0, [ignore])
1380 AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
1382 cd ..
1383 AT_CHECK([./configure && ./configure], 0, [ignore], [stderr])
1384 AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
1386 cwd=`pwd`
1387 AT_CHECK(["$cwd"/configure && "$cwd"/configure], 0, [ignore], [ignore])
1388 AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
1391 AT_CLEANUP
1394 ## ------------------------------------- ##
1395 ## AC_CONFIG_LINKS and identical files.  ##
1396 ## ------------------------------------- ##
1397 AT_SETUP([AC_CONFIG_LINKS and identical files])
1399 AT_DATA([configure.ac],
1400 [[AC_INIT
1401 AC_CONFIG_LINKS([src/s:src/s])
1402 test "$srcdir" != '.' && AC_CONFIG_LINKS([src/t:src/t])
1403 AC_OUTPUT
1406 mkdir src build
1407 echo file1 > src/s
1408 echo file2 > src/t
1409 AT_CHECK_AUTOCONF
1410 cd build
1411 AT_CHECK([../configure $configure_options && ../configure $configure_options],
1412          0, [ignore])
1413 AT_CHECK([cat src/s src/t], 0, [file1
1414 file2
1417 cd ..
1418 rm -rf build
1419 mkdir build
1420 cd build
1421 cwd=`pwd`
1422 AT_CHECK(["$cwd"/../configure], 0, [ignore])
1423 AT_CHECK([cat src/s src/t], 0, [file1
1424 file2
1426 AT_CHECK(["$cwd"/../configure], 0, [ignore])
1427 AT_CHECK([cat src/s src/t], 0, [file1
1428 file2
1430 cd ..
1431 AT_CHECK([./configure $configure_options && ./configure $configure_options],
1432          0, [ignore], [stderr])
1433 AT_CHECK([grep src/t stderr], 1)
1434 AT_CHECK([cat src/s src/t], 0, [file1
1435 file2
1437 cwd=`pwd`
1438 AT_CHECK(["$cwd"/configure && "$cwd"/configure], 0, [ignore], [ignore])
1439 AT_CHECK([cat src/s src/t], 0, [file1
1440 file2
1443 AT_CLEANUP
1446 AT_BANNER([autoreconf.])
1448 ## ---------------------------- ##
1449 ## Configuring subdirectories.  ##
1450 ## ---------------------------- ##
1452 # .
1453 # |-- builddir
1454 # |   |-- config.log
1455 # |   |-- config.status
1456 # |   `-- inner
1457 # |       |-- config.log
1458 # |       |-- config.status
1459 # |       `-- innermost
1460 # |           `-- config
1461 # |-- configure
1462 # |-- configure.ac
1463 # |-- inner
1464 # |   |-- configure
1465 # |   |-- configure.ac
1466 # |   `-- innermost
1467 # |       `-- config.in
1468 # `-- install-sh
1470 AT_SETUP([Configuring subdirectories])
1471 AT_KEYWORDS(autoreconf)
1473 AT_REQUIRE_ACLOCAL
1475 # The contents of 'inner/', and 'inner/innermost/'.
1476 AS_MKDIR_P([inner/innermost])
1478 AT_DATA([inner/configure.ac],
1479 [[AC_INIT(GNU Inner, 1.0)
1480 AC_CONFIG_SRCDIR([innermost/config.in])
1481 AC_ARG_VAR([INNER], [an inner variable])
1482 AC_SUBST([INNER])
1483 if test "x$INNER" = x; then
1484   INNER=inner
1486 AC_CONFIG_FILES([innermost/config])
1487 AC_OUTPUT
1490 AT_DATA([inner/innermost/config.in],
1491 [INNER=@INNER@
1492 srcdir=@srcdir@
1493 top_srcdir=@top_srcdir@
1494 prefix=@prefix@
1497 # The contents of '.'
1498 AT_DATA([install-sh], [])
1500 # nonexistent is allowed not to exist.
1501 AT_DATA([configure.ac],
1502 [[AC_INIT(GNU Outer, 1.0)
1503 AC_ARG_VAR([OUTER], [an outer variable])
1504 if false; then
1505   AC_CONFIG_SUBDIRS([nonexistent])
1507 AC_CONFIG_SUBDIRS([inner])
1508 AC_OUTPUT
1511 AT_CHECK([autoreconf])
1512 AT_CHECK([test -f inner/configure])
1514 # Running the outer configure recursively should provide the innermost
1515 # help strings.
1516 chmod a-w inner/innermost inner .
1517 AT_CHECK([{ ./configure $configure_options --help=recursive; chmod u+w .; } | grep INNER], 0,
1518          [ignore], [stderr],
1519          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1520 chmod u+w . inner inner/innermost
1522 # Running the outer configure should trigger the inner.
1523 AT_CHECK_CONFIGURE
1524 AT_CHECK([cat inner/innermost/config], 0,
1525 [INNER=inner
1526 srcdir=.
1527 top_srcdir=..
1528 prefix=/usr/local
1531 # The same, but from a builddir.
1532 AS_MKDIR_P([builddir])
1533 AT_CHECK([cd builddir && ../configure $configure_options], 0, [ignore])
1534 AT_CHECK([cat builddir/inner/innermost/config], 0,
1535 [INNER=inner
1536 srcdir=../../../inner/innermost
1537 top_srcdir=../../../inner
1538 prefix=/usr/local
1541 # Make sure precious variables and command line options are properly
1542 # passed, even when there are duplicates.
1543 AT_CHECK([cd builddir && ../configure $configure_options --prefix /bad --prefix /good INNER=bad INNER=good],
1544          0, [ignore])
1545 AT_CHECK([cat builddir/inner/innermost/config], 0,
1546 [INNER=good
1547 srcdir=../../../inner/innermost
1548 top_srcdir=../../../inner
1549 prefix=/good
1552 # Make sure --prefix is properly quoted
1553 AT_CHECK([cd builddir && ../configure --prefix "/a  b c$ 'd"], 0, [ignore])
1554 AT_CHECK([cat builddir/inner/innermost/config], 0,
1555 [INNER=inner
1556 srcdir=../../../inner/innermost
1557 top_srcdir=../../../inner
1558 prefix=/a  b c$ 'd
1561 # Make sure --silent is properly passed...
1562 AT_CHECK([cd builddir && ../configure $configure_options --silent], 0, [])
1563 # ...but not stored in config.status.
1564 AT_CHECK([cd builddir && ./config.status --recheck], 0, [stdout])
1565 AT_CHECK([grep 'creating \./config.status' stdout], 0, [ignore])
1567 # --cache-file is adjusted for subdirectories, so the cache is shared.
1568 AT_CHECK([cd builddir && ../configure $configure_options --config-cache],
1569          [], [stdout])
1570 AT_CHECK([grep 'loading .*\.\./config.cache' stdout], [], [ignore])
1572 # Make sure we can run autoreconf on a subdirectory
1573 rm -f configure configure.ac
1574 AT_CHECK([autoreconf inner], [], [], [ignore])
1576 # Make sure we can pass a configure.ac name
1577 AT_CHECK([cd inner && autoreconf configure.ac], [], [], [ignore])
1578 AT_CHECK([autoreconf inner/configure.ac], [], [], [ignore])
1580 AT_CLEANUP
1584 ## -------------- ##
1585 ## Deep Package.  ##
1586 ## -------------- ##
1588 AT_SETUP([Deep Package])
1589 AT_KEYWORDS(autoreconf)
1591 AT_REQUIRE_ACLOCAL
1593 # The contents of '.'
1594 AT_DATA([install-sh], [])
1595 AT_DATA([configure.ac],
1596 [[AC_INIT(GNU Outer, 1.0)
1597 AC_ARG_VAR([OUTER], [an outer variable])
1598 AC_CONFIG_SUBDIRS([
1599   inner
1600   inner2
1602 AC_OUTPUT
1605 # The contents of 'inner/', and 'inner/innermost/'.
1606 AS_MKDIR_P([inner/innermost])
1607 AS_MKDIR_P([inner2])
1609 AT_DATA([inner/configure.ac],
1610 [[AC_INIT(GNU Inner, 1.0)
1611 AC_ARG_VAR([INNER], [an inner variable])
1612 AC_CONFIG_SUBDIRS(innermost)
1613 AC_OUTPUT
1616 AT_DATA([inner/innermost/configure.ac],
1617 [[AC_INIT(GNU Innermost, 1.0)
1618 AC_ARG_VAR([INNERMOST], [an innermost variable])
1619 AC_CONFIG_HEADERS(config.h:config.hin)
1620 AC_DEFINE_UNQUOTED([INNERMOST], [$INNERMOST], [an innermost variable])
1621 if test -n "$innermost_error"; then
1622   AC_MSG_FAILURE([error in $PACKAGE_NAME])
1624 AC_OUTPUT
1627 AT_DATA([inner2/configure.ac],
1628 [[AC_INIT(GNU Inner 2, 1.0)
1629 AC_ARG_VAR([INNER2], [an inner2 variable])
1630 AC_OUTPUT
1633 AT_CHECK([autoreconf -Wall], [0], [ignore])
1634 AT_CHECK([test -f inner/configure])
1635 AT_CHECK([test -f inner/innermost/configure])
1636 AT_CHECK([test -f inner/innermost/config.hin])
1637 AT_CHECK([test -f inner2/configure])
1639 # Running the outer configure recursively should provide the innermost
1640 # help strings.
1641 chmod a-w inner/innermost inner
1642 AT_CHECK([{ ./configure $configure_options --help=recursive; chmod u+w .; } | grep " INNER "],
1643          0, [ignore], [stderr],
1644          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1645 chmod a-w .
1646 AT_CHECK([{ ./configure $configure_options --help=recursive; chmod u+w .; } | grep " INNER2 "],
1647          0, [ignore], [stderr],
1648          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1649 chmod a-w .
1650 AT_CHECK([{ ./configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1651          0, [ignore], [stderr],
1652          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1653 chmod a-w .
1654 AT_CHECK([{ /bin/sh ./configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1655          0, [ignore], [stderr],
1656          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1657 chmod a-w .
1658 AT_CHECK([PATH=.$PATH_SEPARATOR$PATH; export PATH; { /bin/sh configure $configure_options --help=recursive; chmod +w .; } | grep " INNERMOST "],
1659          0, [ignore], [stderr],
1660          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1661 chmod a-w .
1662 AT_CHECK([PATH=.$PATH_SEPARATOR$PATH; export PATH; { configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1663          0, [ignore], [stderr],
1664          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1665 chmod u+w inner inner/innermost
1667 # Running the outer configure should trigger the inner.
1668 AT_CHECK_CONFIGURE([INNERMOST=tsomrenni])
1669 AT_CHECK([grep INNERMOST inner/innermost/config.h], 0,
1670 [[#define INNERMOST tsomrenni
1673 # Ensure we point to the right config.log file for errors.
1674 AT_CHECK_CONFIGURE([innermost_error=:], [1], [], [stderr])
1675 AT_CHECK([grep 'inner/innermost' stderr], [], [ignore])
1676 cd inner
1677 AT_CHECK_CONFIGURE([innermost_error=:], [1], [], [stderr])
1678 AT_CHECK([grep 'innermost' stderr], [], [ignore])
1679 cd ..
1681 # The same, but from a builddir.
1682 AS_MKDIR_P([builddir])
1683 chmod a-w builddir inner/innermost inner
1684 AT_CHECK([cd builddir && { ../configure $configure_options --help=recursive; chmod u+w .; } | grep " INNER "],
1685          0, [ignore], [stderr],
1686          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1687 chmod a-w builddir
1688 AT_CHECK([cd builddir && { ../configure $configure_options --help=recursive; chmod u+w .; } | grep " INNER2 "],
1689          0, [ignore], [stderr],
1690          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1691 chmod a-w builddir
1692 AT_CHECK([cd builddir && { ../configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1693          0, [ignore], [stderr],
1694          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1695 chmod a-w builddir
1696 AT_CHECK([cd builddir && { /bin/sh ../configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1697          0, [ignore], [stderr],
1698          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1699 chmod a-w builddir
1700 # Not all shells search $PATH for scripts.
1701 if (cd builddir && PATH=`pwd`/..$PATH_SEPARATOR$PATH /bin/sh configure $configure_options --help) >/dev/null 2>&1; then
1702   AT_CHECK([cd builddir && PATH=`pwd`/..$PATH_SEPARATOR$PATH /bin/sh configure $configure_options --help=recursive | grep " INNERMOST "], 0, [ignore])
1704 AT_CHECK([PATH=`pwd`$PATH_SEPARATOR$PATH; export PATH; cd builddir && { configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1705          0, [ignore], [stderr],
1706          [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1707 chmod u+w builddir inner inner/innermost
1708 AT_CHECK([cd builddir && ../configure $configure_options INNERMOST=build/tsomrenni], 0, [ignore])
1709 AT_CHECK([grep INNERMOST builddir/inner/innermost/config.h], 0,
1710 [[#define INNERMOST build/tsomrenni
1713 AT_CLEANUP
1717 ## -------------------------------- ##
1718 ## Non-Autoconf AC_CONFIG_SUBDIRS.  ##
1719 ## -------------------------------- ##
1721 AT_SETUP([Non-Autoconf AC_CONFIG_SUBDIRS])
1722 AT_KEYWORDS([autoreconf])
1724 # We use aclocal (via autoreconf).
1725 AT_REQUIRE_ACLOCAL
1727 AT_DATA([install-sh], [])
1728 AT_DATA([configure.ac],
1729 [[AC_INIT(GNU Outer, 1.0)
1730 AC_CONFIG_SUBDIRS([inner])
1731 AC_OUTPUT
1734 AS_MKDIR_P([inner])
1736 AT_DATA([inner/configure],
1737 [[#! /bin/sh
1738 case "$*" in
1739     *--help*) echo 'No Autoconf here, folks!' ;;
1740     *)        echo got_it >myfile ;;
1741 esac
1742 exit 0
1744 chmod +x inner/configure
1746 AT_CHECK([autoreconf -Wall], 0, [ignore])
1748 # Running the outer configure recursively should provide the innermost
1749 # help strings.
1750 AT_CHECK([./configure $configure_options --help=recursive | grep "folks"],
1751          [0], [ignore])
1753 # Running the outer configure should trigger the inner.
1754 AT_CHECK([./configure $configure_options], 0, [ignore])
1755 AT_CHECK([test -f inner/myfile], 0)
1757 AT_CLEANUP
1760 ## ------------------------------- ##
1761 ## Non-literal AC_CONFIG_SUBDIRS.  ##
1762 ## ------------------------------- ##
1764 AT_SETUP([Non-literal AC_CONFIG_SUBDIRS])
1765 AT_KEYWORDS([autoreconf])
1767 AT_DATA([install-sh], [])
1768 AT_DATA([configure.ac],
1769 [[AC_INIT(GNU Outer, 1.0)
1771 my_subdirs=
1772 # Taken from autoconf.texi:Subdirectories.
1773 if test "x$package_foo_enabled" = xyes; then
1774   my_subdirs="$my_subdirs foo"
1776 AC_CONFIG_SUBDIRS([$my_subdirs])
1777 AC_OUTPUT
1780 AT_SUPPRESS_ACLOCAL
1781 AS_MKDIR_P([foo])
1783 AT_DATA([foo/configure],
1784 [[#! /bin/sh
1785 touch innerfile
1786 exit 0
1788 chmod +x foo/configure
1790 # autoreconf should warn without -Wno-syntax, but should not fail without -Werror.
1791 AT_CHECK([autoreconf -Werror -v], [1], [ignore], [stderr])
1792 AT_CHECK([grep 'AC_CONFIG_SUBDIRS:.*literals' stderr], [0], [ignore])
1793 AT_CHECK([autoreconf -v], [0], [ignore], [stderr])
1794 AT_CHECK([grep 'AC_CONFIG_SUBDIRS:.*literals' stderr], [0], [ignore])
1795 AT_CHECK([autoreconf -v --force -Wno-syntax], 0, [ignore], [stderr])
1796 AT_CHECK([grep 'AC_CONFIG_SUBDIRS:.*literals' stderr], [1])
1798 AT_CHECK([./configure $configure_options], [0], [ignore])
1799 AT_CHECK([test ! -f foo/innerfile])
1800 # Running the outer configure should trigger the inner.
1801 AT_CHECK([./configure $configure_options package_foo_enabled=yes], [0], [ignore])
1802 AT_CHECK([test -f foo/innerfile])
1804 AT_CLEANUP
1806 ## ------------------------- ##
1807 ## Empty AC_CONFIG_SUBDIRS.  ##
1808 ## ------------------------- ##
1810 AT_SETUP([Empty AC_CONFIG_SUBDIRS])
1811 AT_KEYWORDS([autoreconf])
1813 AT_DATA([install-sh], [])
1814 AT_DATA([configure.ac],
1815 [[AC_INIT(GNU Outer, 1.0)
1817 AC_CONFIG_SUBDIRS()
1818 AC_OUTPUT
1821 AT_SUPPRESS_ACLOCAL
1822 # autoreconf should have no complaints, and the generated configure
1823 # script should run fine with or without --no-recursion.
1824 AT_CHECK([autoreconf -Werror], [0], [ignore])
1825 AT_CHECK_CONFIGURE()
1826 AT_CHECK_CONFIGURE([--no-recursion])
1828 AT_CLEANUP
1830 ## ----------------- ##
1831 ## Empty directory.  ##
1832 ## ----------------- ##
1834 AT_SETUP([Empty directory])
1835 AT_KEYWORDS([autoreconf])
1837 # Prevent autoreconf from running aclocal, which might not be available.
1838 dnl We can't use AT_SUPPRESS_ACLOCAL here because it creates an aclocal.m4.
1839 ACLOCAL=true
1841 # The test group directory is not necessarily _empty_, but it does not contain
1842 # files meaningful to 'autoreconf'.
1844 AT_CHECK([autoreconf -Wall -v], 1, [ignore], [ignore])
1846 AT_CLEANUP
1850 ## ------------------------------ ##
1851 ## Unusual Automake input files.  ##
1852 ## ------------------------------ ##
1854 # This parallels gnumake.test in Automake.
1856 AT_SETUP([Unusual Automake input files])
1857 AT_KEYWORDS([autoreconf])
1859 AT_REQUIRE_AUTOMAKE
1860 AT_REQUIRE_ACLOCAL
1862 AT_DATA([configure.ac],
1863 [[AC_INIT(GNU foo, 1.0)
1864 AM_INIT_AUTOMAKE
1865 AC_CONFIG_FILES([HeeHee])
1866 AC_OUTPUT
1869 AT_DATA([HeeHee.am],
1870 [[# Humans do no worse than 'GNUmakefile.am'.
1871 AUTOMAKE_OPTIONS = foreign 1.8
1874 AT_CHECK([autoreconf -Wall -v -i], 0, [ignore], [stderr],
1875          [AT_CHECK([grep 'require.*1\.8' stderr && exit 77], [1])])
1876 AT_CHECK([test -f HeeHee.in])
1878 AT_CLEANUP
1880 ## ------------------------------ ##
1881 ## Specific warnings options.     ##
1882 ## ------------------------------ ##
1884 AT_SETUP([Specific warnings options for autoreconf])
1885 AT_KEYWORDS([autoreconf])
1887 # If autoreconf is given a -W option that's mentioned in its own
1888 # --help output, that option should not cause errors, even if some
1889 # of the subsidiary programs don't support it.
1891 AT_REQUIRE_AUTOMAKE
1892 AT_REQUIRE_ACLOCAL
1894 AT_DATA([configure.ac],
1895 [[AC_INIT(GNU foo, 1.0)
1896 AM_INIT_AUTOMAKE
1897 AC_CONFIG_HEADERS([config.h])
1898 AC_CONFIG_FILES([Makefile])
1899 AC_OUTPUT
1902 AT_DATA([Makefile.am],
1903 [[AUTOMAKE_OPTIONS = foreign
1906 # To silence complaints about required helper scripts from automake.
1907 # We aren't going to run the generated Makefile so we don't need the
1908 # real helper scripts.
1909 AT_DATA([install-sh], [])
1910 AT_DATA([missing], [])
1912 # In order to cut down the time this test takes, we do not test all
1913 # of the supported warning categories, just the most common case
1914 # (-Wall) and some specific categories that are known to have been a
1915 # problem in the past.
1916 AT_CHECK([autoreconf -Werror -Wall], 0, [], [])
1917 rm -rf configure config.h.in Makefile.in aclocal.m4 autom4te.cache
1919 AT_CHECK([autoreconf -Werror -Wcross], 0, [], [])
1920 rm -rf configure config.h.in Makefile.in aclocal.m4 autom4te.cache
1922 AT_CHECK([autoreconf -Werror -Wportability-recursive], 0, [], [])
1923 rm -rf configure config.h.in Makefile.in aclocal.m4 autom4te.cache
1925 AT_CLEANUP
1927 ## ------------------------- ##
1928 ## Missing auxiliary files.  ##
1929 ## ------------------------- ##
1931 AT_SETUP([Missing auxiliary files (config.*)])
1932 AT_KEYWORDS([autoreconf])
1934 AT_SUPPRESS_ACLOCAL
1935 AT_DATA([configure.ac],
1936 [[AC_INIT([GNU foo], [1.0])
1937 AC_CONFIG_AUX_DIR([build-aux])
1938 AC_CANONICAL_HOST
1939 AC_OUTPUT
1942 AT_CHECK_AUTOCONF
1944 # Both configure and autoreconf should detect the missing files.
1945 AT_CHECK_CONFIGURE([], [1], [ignore],
1946 [configure: error: cannot find required auxiliary files: config.guess config.sub
1949 AT_CHECK([autoreconf], 1, [],
1950 [configure.ac: error: required file 'config.sub' not found
1951 configure.ac: error: required file 'config.guess' not found
1952 configure.ac:   try running autoreconf --install
1955 # If only one file is missing, the error messages should only report
1956 # that one.  Also, the above invocation of autoreconf should _not_
1957 # have created build-aux, because it wasn't called with --install.
1958 AT_CHECK([test ! -e build-aux])
1959 mkdir build-aux
1960 : > build-aux/config.guess
1962 AT_CHECK_CONFIGURE([], [1], [ignore],
1963 [configure: error: cannot find required auxiliary files: config.sub
1966 AT_CHECK([autoreconf], 1, [],
1967 [configure.ac: error: required file 'config.sub' not found
1968 configure.ac:   try running autoreconf --install
1971 # Missing aux files should not interfere with --help and --version.
1972 AT_CHECK_CONFIGURE([--help], [0], [ignore], [ignore])
1973 AT_CHECK_CONFIGURE([--version], [0], [ignore], [ignore])
1975 # autoreconf --install should be able to install config.sub and config.guess.
1976 rm build-aux/config.guess
1977 AT_CHECK([autoreconf --install])
1979 AT_CHECK([test -x build-aux/config.guess])
1980 AT_CHECK([test -x build-aux/config.sub])
1981 AT_CHECK([test ! -e build-aux/install-sh])
1983 AT_CHECK_CONFIGURE
1985 AT_CLEANUP
1988 AT_SETUP([Missing auxiliary files (install-sh)])
1989 AT_KEYWORDS([autoreconf])
1991 # Same as "Missing auxiliary files (config.*)" except that the
1992 # configure script _doesn't_ need config.{sub,guess} but does need
1993 # install-sh.
1995 AT_SUPPRESS_ACLOCAL
1996 AT_DATA([configure.ac],
1997 [[AC_INIT([GNU foo], [1.0])
1998 AC_CONFIG_AUX_DIR([build-aux])
1999 AC_PROG_INSTALL
2000 AC_OUTPUT
2003 AT_CHECK_AUTOCONF
2005 # Both configure and autoreconf should detect the missing files.
2006 AT_CHECK_CONFIGURE([], [1], [ignore],
2007 [configure: error: cannot find required auxiliary files: install-sh
2010 AT_CHECK([autoreconf], 1, [],
2011 [configure.ac: error: required file 'install-sh' not found
2012 configure.ac:   try running autoreconf --install
2014 AT_CHECK([test ! -e build-aux])
2016 AT_CHECK_CONFIGURE([--help], [0], [ignore], [ignore])
2017 AT_CHECK_CONFIGURE([--version], [0], [ignore], [ignore])
2019 AT_CHECK([autoreconf --install])
2021 AT_CHECK([test ! -e build-aux/config.guess])
2022 AT_CHECK([test ! -e build-aux/config.sub])
2023 AT_CHECK([test -x build-aux/install-sh])
2025 AT_CHECK_CONFIGURE
2027 AT_CLEANUP
2030 AT_SETUP([Missing auxiliary files (foreign)])
2031 AT_KEYWORDS([autoreconf])
2033 # If an aux file is required that autoreconf doesn't know how to install,
2034 # it shouldn't suggest autoreconf --install.
2035 # This also verifies that AC_REQUIRE_AUX_FILE can be used outside of a
2036 # macro definition, which was always the intent, and was recommended
2037 # usage in some automake recipes, but which was broken in autoconf
2038 # beta 2.69d (see https://savannah.gnu.org/support/?110363).
2040 AT_SUPPRESS_ACLOCAL
2041 AT_DATA([configure.ac],
2042 [[AC_INIT([GNU foo], [1.0])
2043 AC_CONFIG_AUX_DIR([build-aux])
2044 AC_REQUIRE_AUX_FILE([tap-driver.sh])
2045 AC_OUTPUT
2048 AT_CHECK_AUTOCONF
2049 AT_CHECK_CONFIGURE([], [1], [ignore],
2050 [configure: error: cannot find required auxiliary files: tap-driver.sh
2053 AT_CHECK([autoreconf], 1, [],
2054 [configure.ac: error: required file 'tap-driver.sh' not found
2056 AT_CHECK([test ! -e build-aux])
2058 AT_CHECK([autoreconf --install], 1, [],
2059 [configure.ac: error: required file 'tap-driver.sh' not found
2061 # autoreconf --install always creates the aux directory.
2062 AT_CHECK([test -e build-aux])
2064 touch build-aux/tap-driver.sh
2066 AT_CHECK([autoreconf])
2067 AT_CHECK_CONFIGURE
2069 AT_CLEANUP
2072 AT_SETUP([Missing auxiliary files (--force)])
2073 AT_KEYWORDS([autoreconf])
2075 # Aux files that already exist should not be overwritten, unless
2076 # --force is used, in which case they *should* be overwritten.
2077 # Additional wrinkle: in case automake got to the files we install
2078 # first, we need to *not* overwrite a newer copy supplied by them.
2080 AT_SUPPRESS_ACLOCAL
2081 AT_DATA([configure.ac],
2082 [[AC_INIT([GNU foo], [1.0])
2083 AC_CONFIG_AUX_DIR([build-aux])
2084 AC_PROG_INSTALL
2085 AC_CANONICAL_HOST
2086 AC_OUTPUT
2089 mkdir build-aux
2091 AT_DATA([build-aux/config-guess.old],
2092 [[#! /bin/sh
2093 timestamp='1970-01-01'
2094 printf '%s\n' 'frobozz-bogon-bogos1'
2097 AT_DATA([build-aux/config-sub.new],
2098 [[#! /bin/sh
2099 scriptversion='9999-12-31'
2100 printf '%s\n' "$*"
2103 AT_DATA([build-aux/install-sh.old],
2104 [[#! /bin/sh
2105 # Old versions of install-sh did not have a timestamp line.
2108 cp build-aux/config-guess.old build-aux/config.guess
2109 cp build-aux/config-sub.new build-aux/config.sub
2110 cp build-aux/install-sh.old build-aux/install-sh
2111 chmod +x build-aux/config.sub build-aux/config.guess build-aux/install-sh
2113 # This pass should not change any of the files.
2114 AT_CHECK([autoreconf --install])
2115 AT_CMP([build-aux/config-guess.old], [build-aux/config.guess])
2116 AT_CMP([build-aux/config-sub.new], [build-aux/config.sub])
2117 AT_CMP([build-aux/install-sh.old], [build-aux/install-sh])
2119 # This pass should change only config.guess and install-sh, not config.sub.
2120 AT_CHECK([autoreconf --install --force])
2121 AT_CHECK(
2122   [if cmp build-aux/config-guess.old build-aux/config.guess > /dev/null 2>&1
2123   then exit 1
2124   fi])
2125 AT_CMP([build-aux/config-sub.new], [build-aux/config.sub])
2126 AT_CHECK(
2127   [if cmp build-aux/install-sh.old build-aux/install-sh > /dev/null 2>&1
2128   then exit 1
2129   fi])
2132 AT_CLEANUP
2134 ## ------------------------------ ##
2135 ## Files clobbered by AC_OPENMP.  ##
2136 ## ------------------------------ ##
2138 AT_SETUP([Files clobbered by AC_OPENMP])
2140 AT_CONFIGURE_AC(
2141 [[AC_PROG_CC
2142 AC_OPENMP
2145 AT_CHECK_AUTOHEADER
2147 # autoconf should bomb out if either 'mp' or 'openmp' exists in the
2148 # srcdir.
2149 AT_DATA([mp])
2150 AT_CHECK_AUTOCONF([], [1], [], [stderr])
2151 AT_CHECK([grep "clobbers files named 'mp' and 'penmp'" stderr],
2152          [0], [ignore], [ignore])
2153 rm -f mp
2155 AT_DATA([penmp])
2156 AT_CHECK_AUTOCONF([], [1], [], [stderr])
2157 AT_CHECK([grep "clobbers files named 'mp' and 'penmp'" stderr],
2158          [0], [ignore], [ignore])
2159 rm -f penmp
2161 # If neither of these files exist, autoconf should go through...
2162 AT_CHECK_AUTOCONF
2164 # ... but configure should bomb out, and *not* delete the files,
2165 # if they are added after autoconf is run.
2166 AT_DATA([mp])
2167 AT_CHECK_CONFIGURE([], [1], [], [stderr])
2168 AT_CHECK([test -e mp])
2169 AT_CHECK([grep "clobbers files named 'mp' and 'penmp'" stderr],
2170          [0], [ignore], [ignore])
2171 rm -f mp
2173 AT_DATA([penmp])
2174 AT_CHECK_CONFIGURE([], [1], [], [stderr])
2175 AT_CHECK([test -e penmp])
2176 AT_CHECK([grep "clobbers files named 'mp' and 'penmp'" stderr],
2177          [0], [ignore], [ignore])
2178 rm -f penmp
2180 AT_CHECK_CONFIGURE
2181 AT_CHECK_ENV
2183 AT_CLEANUP