Debian Codegraph @

tests/torture.at

raw
1 # -*- Autotest -*-
2
3 # Copyright (C) 2000-2017, 2020-2026 Free Software Foundation, Inc.
4
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.
9 #
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.
14 #
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/>.
17
18
19 AT_BANNER([[Testing config.status.]])
20
21
22 ## ---------------------------------------- ##
23 ## AC_CONFIG_COMMANDS with empty commands. ##
24 ## ---------------------------------------- ##
25
26 AT_CHECK_MACRO([AC_CONFIG_COMMANDS with empty commands],
27 [[AC_CONFIG_COMMANDS([foo], [], [:])
28 ]])
29
30
31 ## --------------------------------------------- ##
32 ## AC_CONFIG_COMMANDS with temporary directory. ##
33 ## --------------------------------------------- ##
34
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
49 ])
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`"])
56 ])
57
58
59 ## -------------------------- ##
60 ## Multiple AC_CONFIG_FILES. ##
61 ## -------------------------- ##
62
63 AT_SETUP([Multiple AC_CONFIG_FILES])
64
65 AT_CONFIGURE_AC([[AC_CONFIG_FILES([foo foo])]])
66 AT_CHECK_AUTOCONF([], 1, [], [ignore])
67
68 AT_CLEANUP
69
70
71 ## ------------------------------- ##
72 ## parameterized AC_CONFIG_FILES. ##
73 ## ------------------------------- ##
74
75 AT_SETUP([Parameterized AC_CONFIG_FILES])
76
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
84
85 AT_CLEANUP
86
87
88
89 ## ------------ ##
90 ## AC_ARG_VAR. ##
91 ## ------------ ##
92
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
101
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'
108 ])
109
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'
117 ])
118
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])
125
126 ])# AT_CHECK_AC_ARG_VAR
127
128
129 AT_SETUP([AC_ARG_VAR])
130
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
138 fi
139 ])
140
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)
146 ]])
147
148 AT_DATA([file.in],
149 [[`@precious@'
150 ]])
151
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.
155 ]])
156
157 # Set a precious variable
158 AT_CHECK_AC_ARG_VAR([], [apple of my eye])
159
160 # Unset a precious variable
161 AT_CHECK_AC_ARG_VAR([apple of my eye], [])
162
163 # Change a precious variable
164 AT_CHECK_AC_ARG_VAR([apple of my eye], [orange of my eye])
165
166 # Change a precious variable that contains braces
167 AT_CHECK_AC_ARG_VAR([apple of my {eye}], [orange of my eye])
168
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: "
172
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])
179
180 AT_CLEANUP
181
182
183
184
185 ## ---------------------------------------------- ##
186 ## AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS. ##
187 ## ---------------------------------------------- ##
188
189 AT_SETUP([[AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS]])
190
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
196
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]);;
203
204 file)
205 AC_CONFIG_FILES(file:input);;
206 var-file)
207 AC_CONFIG_FILES(var-file:$file_in, [], [file_in=input]);;
208
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]);;
215
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
222 ]])
223
224 AT_CHECK_AUTOCONF
225
226
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
237 ])
238 AT_CHECK([grep OK $1], [], [OK
239 ])
240
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
247 ])
248 AT_CHECK([grep OK var-$1], [], [OK
249 ])
250 ])# AT_CHECK_CONFIG_CREATION
251
252
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
263 ])
264 AT_CHECK([grep OK $1], [], [OK
265 ])
266
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
280
281
282 # Create a file
283 AT_CHECK_CONFIG_CREATION(file)
284
285 # Create a header
286 AT_CHECK_CONFIG_CREATION(header)
287
288 # Execute a command
289 AT_CHECK_CONFIG_CREATION(command)
290
291 # Create a link
292 AT_CHECK_CONFIG_CREATION(link)
293
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
308 fi
309
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
316 ])
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])
321 fi
322
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])
328
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
335 ])
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])
340 fi
341
342 # Execute a command
343 AT_CHECK_CONFIG_CREATION_NOWRITE(command)
344
345 # Create a link
346 AT_CHECK_CONFIG_CREATION_NOWRITE(link)
347
348 # Check that no use of 'ac_write_fail' escaped into config.status
349 AT_CHECK([grep ac_write_fail config.status], [1])
350
351 # Check that --file and --header accept funny file names
352 AT_DATA([fgrep.in],
353 [[FGREP="@FGREP@"
354 ]])
355 ./config.status --file=fgrep:fgrep.in
356 . ./fgrep
357
358 x=
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
364 do
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@
369 END
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
380 ])
381 AT_CHECK_UNQUOTED([grep ' & ' "$file"], [],
382 [/* $file. Generated from $file.in by configure. */
383 ])
384 AT_CHECK([$FGREP "$file" "$file"], [0], [ignore])
385 done
386 AT_CLEANUP
387
388
389
390 ## ---------------------------------------- ##
391 ## Macro calls in AC_CONFIG_COMMANDS tags. ##
392 ## ---------------------------------------- ##
393
394 AT_SETUP([Macro calls in AC_CONFIG_COMMANDS tags])
395
396 AT_DATA_M4SUGAR([configure.ac],
397 [[AC_INIT
398 AC_CONFIG_COMMANDS([m4_if(1,1,mytag)])
399 AC_OUTPUT
400 ]])
401
402 AT_CHECK_AUTOCONF
403 AT_CHECK_CONFIGURE
404
405 AT_CLEANUP
406
407 ## ----------------------------- ##
408 ## AC_OUTPUT with one argument. ##
409 ## ----------------------------- ##
410
411 AT_SETUP([AC_OUTPUT with one argument])
412
413 AT_DATA([Makefile.in],
414 [[VARIABLE = @VARIABLE@
415 ]])
416
417 AT_DATA_AUTOCONF([configure.ac],
418 [[AC_INIT
419 AC_SUBST([VARIABLE], [value])
420 AC_OUTPUT([Makefile])
421 ]])
422
423 AT_CHECK_AUTOCONF([], [0], [],
424 [configure.ac:3: warning: AC_OUTPUT should be used without arguments.
425 configure.ac:3: You should run autoupdate.
426 ])
427
428 AT_CHECK_CONFIGURE
429
430 AT_CHECK([test x"`cat Makefile || echo Makefile not found`" \
431 = x"VARIABLE = value"])
432
433 AT_CHECK_AUTOUPDATE
434
435 AT_CHECK([[$EGREP '^AC_OUTPUT$' configure.ac]],
436 [0], [ignore])
437 AT_CHECK([[$EGREP '^AC_CONFIG_FILES\(\[Makefile\]\)$' configure.ac]],
438 [0], [ignore])
439
440 AT_CLEANUP
441
442
443 ## -------------------------------- ##
444 ## AC_OUTPUT with three arguments. ##
445 ## -------------------------------- ##
446
447 AT_SETUP([AC_OUTPUT with three arguments])
448
449 AT_DATA([Makefile.in],
450 [[VARIABLE = @VARIABLE@
451 ]])
452
453 AT_DATA([strange.in],
454 [[VARIABLE = %VARIABLE%
455 ]])
456
457 AT_DATA_AUTOCONF([configure.ac],
458 [[AC_INIT
459 AC_SUBST([VARIABLE], [value])
460 AC_OUTPUT([Makefile],
461 [sed -e "s/%VARIABLE%/${VARIABLE}/g" < strange.in > strange],
462 [VARIABLE=$VARIABLE])
463 ]])
464
465 AT_CHECK_AUTOCONF([], [0], [],
466 [configure.ac:3: warning: AC_OUTPUT should be used without arguments.
467 configure.ac:3: You should run autoupdate.
468 ])
469
470 AT_CHECK_CONFIGURE
471
472 AT_CHECK([test x"`cat Makefile || echo Makefile not found`" \
473 = x"VARIABLE = value"])
474 AT_CHECK([test x"`cat strange || echo strange not found`" \
475 = x"VARIABLE = value"])
476
477 AT_CHECK_AUTOUPDATE
478
479 AT_CHECK([[$EGREP '^AC_''OUTPUT$' configure.ac]],
480 [0], [ignore])
481 AT_CHECK([[$EGREP '^AC_''CONFIG_FILES\(\[Makefile\]\)$' configure.ac]],
482 [0], [ignore])
483 AT_CHECK([[$EGREP '^AC_''CONFIG_COMMANDS\(\[default\]' configure.ac]],
484 [0], [ignore])
485
486 AT_CLEANUP
487
488 ## ----------------------------------- ##
489 ## AC_OUTPUT with too many arguments. ##
490 ## ----------------------------------- ##
491
492 AT_SETUP([AC_OUTPUT with too many arguments])
493
494 AT_DATA_AUTOCONF([configure.ac],
495 [[AC_INIT
496 AC_SUBST([VARIABLE], [value])
497 AC_OUTPUT([Makefile],
498 [sed -e "s/%VARIABLE%/${VARIABLE}/g" < strange.in > strange],
499 [VARIABLE=$VARIABLE],
500 [needs-something-extra])
501 ]])
502
503 AT_CHECK_AUTOCONF([], [1], [],
504 [configure.ac:3: error: AC_OUTPUT takes at most three arguments.
505 This configure script cannot be compiled by this version of Autoconf.
506 configure.ac:3: the top level
507 autom4te: error: m4 failed with exit status: 1
508 ])
509
510 AT_CLEANUP
511
512
513 ## ------------------- ##
514 ## Missing templates. ##
515 ## ------------------- ##
516
517 # Check that config.status detects missing input files
518 AT_SETUP([Missing templates])
519
520 AT_DATA([configure.ac],
521 [[AC_INIT
522 AC_CONFIG_FILES([nonexistent])
523 AC_OUTPUT
524 ]])
525
526 AT_CHECK_AUTOCONF
527 mkdir build
528 AT_CAPTURE_FILE([build/config.log])[]dnl
529 cd build
530 AT_CHECK([../configure], [1], [ignore],
531 [[config.status: error: cannot find input file: 'nonexistent.in'
532 ]])
533 # Make sure that the output file doesn't exist
534 AT_CHECK([test -f nonexistent], 1)
535 cd ..
536 AT_CHECK_CONFIGURE([], [1], [],
537 [[config.status: error: cannot find input file: 'nonexistent.in'
538 ]])
539 # Make sure that the output file doesn't exist
540 AT_CHECK([test -f nonexistent], 1)
541
542 AT_CLEANUP
543
544
545
546
547 ## ---------------------- ##
548 ## configure invocation. ##
549 ## ---------------------- ##
550
551 # Check that 'configure' and 'config.status' honor their interface.
552 #
553 # We run './configure one=val1 --enable-two=val2 --with-three=val3'
554 # and verify that (i) 'configure' correctly receives the arguments,
555 # (ii) correctly passes them to 'config.status', which we check by
556 # running 'config.status --recheck', (iii) correctly passes them
557 # to sub-configure scripts, and (iv) correctly reproduces them with
558 # 'config.status --config'.
559
560 AT_SETUP([configure invocation])
561
562 mkdir sub
563
564 AT_DATA([configure.ac],
565 [[AC_INIT
566 AC_CONFIG_SUBDIRS([sub])
567 echo "result=$one$enable_two$with_three"
568 AC_OUTPUT
569 ]])
570
571 AT_DATA([sub/configure.ac],
572 [[AC_INIT
573 echo "result=$one$enable_two$with_three"
574 AC_OUTPUT
575 ]])
576
577 echo fake install-sh script >install-sh
578
579 AT_CHECK_AUTOCONF
580 cd sub
581 AT_CHECK_AUTOCONF
582 cd ..
583
584 AT_CHECK_CONFIGURE([one=one --enable-two=two --with-three=three |
585 sed -n -e 's/^result=//p'], 0,
586 [m4_do([onetwothree
587 ], [onetwothree
588 ])])
589 AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
590 [onetwothree
591 ])
592 AT_CHECK([args=`./config.status --config` && eval ./configure \$configure_options "$args" |
593 sed -n -e 's/^result=//p'], 0,
594 [m4_do([onetwothree
595 ], [onetwothree
596 ])])
597
598 AT_CHECK_CONFIGURE([one="\"'$ " --enable-two="\" ' $" --with-three=" \"'$"|
599 sed -n -e 's/^result=//p'], 0,
600 [m4_do(["'$ " ' $ "'$
601 ], ["'$ " ' $ "'$
602 ])])
603 AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
604 ["'$ " ' $ "'$
605 ])
606 dnl restore font-lock: "
607 AT_CHECK([args=`./config.status --config` && eval ./configure \$configure_options "$args" |
608 sed -n -e 's/^result=//p'], 0,
609 [m4_do(["'$ " ' $ "'$
610 ], ["'$ " ' $ "'$
611 ])])
612
613 AT_CLEANUP
614
615
616
617 ## ---------------------- ##
618 ## --help and --version. ##
619 ## ---------------------- ##
620
621 AT_SETUP([--help and --version in unwritable directory])
622
623 AS_MKDIR_P([inner])
624 AT_DATA([inner/configure.ac],
625 [[AC_INIT
626 AC_OUTPUT
627 ]])
628
629 AT_CHECK_M4([(cd inner && autoconf --force)])
630 AT_CHECK([test -s inner/configure])
631 if test "$SHELL_N" != none; then
632 AT_CHECK_SHELL_SYNTAX([inner/configure])
633 fi
634
635 chmod a-w inner
636 AT_CHECK([(cd inner && ./configure --help)], 0, [ignore], [ignore])
637 AT_CHECK([(cd inner && ./configure --version)], 0, [ignore], [ignore])
638 chmod u+w inner
639
640 AT_CLEANUP
641
642
643
644 ## -------------------------------------------- ##
645 ## Check that '#define' templates are honored. ##
646 ## -------------------------------------------- ##
647
648 # Use various forms of '#define' templates, and make sure there are no
649 # problems when a symbol is prefix of another.
650
651 AT_SETUP([@%:@define header templates])
652 AT_KEYWORDS([AC@&t@_DEFINE])
653
654 AT_DATA([configure.ac],
655 [[AC_INIT
656 AC_CONFIG_HEADERS(config.h:config.hin)
657
658 # I18n of dummy variables: their French translations.
659 AC_DEFINE(foo, toto)
660 AC_DEFINE(bar, tata)
661 AC_DEFINE(baz, titi)
662 AC_DEFINE(fubar, tutu)
663
664 # Symbols which are prefixes of another.
665 AC_DEFINE(a, A)
666 AC_DEFINE(aaa, AAA)
667 AC_DEFINE(aa, AA)
668
669 # backslash-newline combinations
670 AC_DEFINE([multiline], [line1\
671 line2\
672 line3 \
673 line4])
674 AC_DEFINE([multiline_args(ARG1, ARG2)], [ARG2 \
675 ARG1])
676 AC_CONFIG_FILES(defs)
677
678 # underquoted #
679 AC_DEFINE([paste(a,b)], [a##b])
680
681 # Things included in confdefs.h, but which make no sense in
682 # config.h, nor in $DEFS.
683 cat <<\EOF >>confdefs.h
684 /* Hi Mum! Look, I am doing C++! */
685 #ifdef __cplusplus
686 void exit (int status);
687 #endif
688 EOF
689
690 # In addition of config.h output a full DEFS
691 AC_OUTPUT_MAKE_DEFS
692 DEFS_SAVED=$DEFS
693 AC_SUBST(DEFS_SAVED)
694 AC_OUTPUT
695 ]])
696
697 AT_DATA([defs.in],
698 [[@DEFS_SAVED@
699 ]])
700
701 AT_DATA([config.hin],
702 [[#define foo 0
703 # define bar bar
704 # define baz "Archimedes was sinking in his baz"
705 # define fubar tutu
706 #define a B
707 #define aa BB
708 # define aaa BBB
709 #undef a
710 # undef aa
711 #undef aaa
712 #define aaa(a, aa) aa a
713 #define aaab
714 #define aaac(a, aa) aa a
715 #undef multiline
716 # undef multiline_args
717 #define paste(a,b) a##b
718 /* an ugly one: */
719 #define str(define) \
720 #define
721 #define stringify(arg) str(arg)
722 #undef aaa /* with comments */
723 #undef not_substed /* with comments */
724 ]])
725
726 AT_CHECK_AUTOCONF
727 AT_CHECK_CONFIGURE
728
729 AT_DATA([expout],
730 [[/* config.h. Generated from config.hin by configure. */
731 #define foo toto
732 # define bar tata
733 # define baz titi
734 # define fubar tutu
735 #define a A
736 #define aa AA
737 # define aaa AAA
738 #define a A
739 # define aa AA
740 #define aaa AAA
741 #define aaa AAA
742 #define aaab
743 #define aaac(a, aa) aa a
744 #define multiline line1\
745 line2\
746 line3 \
747 line4
748 # define multiline_args(ARG1, ARG2) ARG2 \
749 ARG1
750 #define paste(a,b) a##b
751 /* an ugly one: */
752 #define str(define) \
753 #define
754 #define stringify(arg) str(arg)
755 #define aaa AAA
756 /* #undef not_substed */
757 ]])
758 AT_CHECK([cat config.h], 0, expout)
759
760 # Check the value of DEFS.
761 AT_DATA([expout],
762 [[-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
763 ]])
764
765 # Because we strip trailing spaces in 'testsuite' we can't leave one in
766 # expout, hence nuke the one left by AC_OUTPUT_MAKE_DEFS.
767 AT_CHECK([sed -e 's/ $//' defs], 0, expout)
768
769 AT_CLEANUP
770
771
772
773 ## ------------------------- ##
774 ## Torturing config.status. ##
775 ## ------------------------- ##
776
777 ## Require 100 AC_DEFINE and AC_SUBST and AC_SUBST_FILE with a significantly
778 ## big value. This is mostly to check that Autoconf produces portable sed
779 ## scripts in config.status. sed is used to skip the first two lines
780 ## 'Generated by ...'.
781
782 # We use m4_for many times.
783 m4_pattern_allow([^m4_for$])
784
785 AT_SETUP([Torturing config.status])
786
787 dnl The value used as a big value for AC_DEFINE.
788 dnl Don't use sh active chars here, below it is also used in a sh
789 dnl assignment.
790 m4_define([AT_BIG_VALUE],
791 [This value should be long enough to torture the various limits of sed and other tools used by Autoconf.])
792
793 m4_define([AT_DESCRIPTION],
794 [Define to a long string if your 'Autoconf' works properly.])
795
796
797 # AT_DUMMY_VAR(NUMBER)
798 # --------------------
799 # Build a name used for AC_SUBST and AC_DEFINE. Put ac_ in it
800 # so that the check for user name space invasion does not complain
801 # of the new variables defined.
802 #
803 # Note that you should not use the name ac_dummy, because it will be
804 # turned into ac_uummy during the construction of config.status. Yes,
805 # this is admittedly a bug, but it would be too hard to fix this.
806 # There is really no point in AC_DEFINE a var named ac_d.*.
807 m4_pattern_allow([^m4_bpatsubst$])
808 m4_define([AT_DUMMY_VAR],
809 [ac_Dummy_[]m4_bpatsubst([000$1], [.*\(...\)$], [\1])])
810
811
812
813 AT_DATA([dummy.in],
814 [m4_for([AT_Count], 1, 100, 1,
815 [@AT_DUMMY_VAR(AT_Count)@
816 @[f]AT_Count@
817 ])])
818
819
820 i=1
821 while test $i != 101; do
822 echo "content of file $i" > file_$i
823 AS_VAR_ARITH([i], [$i + 1])
824 done
825
826
827 # ------------ #
828 # configure.ac #
829 # ------------ #
830
831 m4_pattern_allow([^m4_(define|defun)$])
832 AT_DATA([configure.ac],
833 dnl The following lines transfer AT_DUMMY_VAR, AT_DESCRIPTION, and
834 dnl AT_BIG_VALUE into the configure.ac as AC_DUMMY_VAR etc.
835 [[m4_define([AC_DUMMY_VAR],]
836 m4_dquote(m4_defn([AT_DUMMY_VAR]))[)]]
837
838 [[m4_define([AC_DESCRIPTION],]
839 m4_dquote(m4_defn([AT_DESCRIPTION]))[)]]
840
841 [[m4_define([AC_BIG_VALUE],]
842 m4_dquote(m4_defn([AT_BIG_VALUE]))[)]]
843
844 [[# AC_DEFUBST(NAME)
845 # ----------------
846 # Related VALUE to NAME both with AC_SUBST and AC_DEFINE. This is
847 # used in the torture tests.
848 m4_defun([AC_DEFUBST],
849 [AC_DUMMY_VAR($1)="AC_BIG_VALUE"
850 AC_DEFINE_UNQUOTED(AC_DUMMY_VAR($1), "$AC_DUMMY_VAR($1) $AC_DUMMY_VAR($1)",
851 AC_DESCRIPTION)
852 AC_SUBST(AC_DUMMY_VAR($1))
853 AC_SUBST_FILE([f]$1)
854 f$1=file_$1
855 ])
856
857 AC_INIT
858 AC_CONFIG_HEADERS(config.h:config.hin)
859 AC_CONFIG_FILES(dummy)
860 m4_for(AC_Count, 1, 100, 1,
861 [AC_DEFUBST(AC_Count)])
862 AC_PROG_AWK
863 AC_OUTPUT
864 ]])# configure.ac
865
866 AT_CHECK_AUTOCONF
867 AT_CHECK_AUTOHEADER([],
868 m4_for(AT_Count, 1, 100, 1, [ AT_DUMMY_VAR(AT_Count)]))
869
870 # Check both awk and the result of AC_PROG_AWK.
871 # Quote the first word in the for list for Solaris sh.
872 for awk_arg in "FOO=" AWK=awk; do
873 AT_CHECK_CONFIGURE([$awk_arg])
874
875 # Checking that AC_DEFINE worked properly.
876 AT_DATA([expout],
877 [/* Define to the address where bug reports for this package should be sent. */
878 #define PACKAGE_BUGREPORT ""
879
880 /* Define to the full name of this package. */
881 #define PACKAGE_NAME ""
882
883 /* Define to the full name and version of this package. */
884 #define PACKAGE_STRING ""
885
886 /* Define to the one symbol short name of this package. */
887 #define PACKAGE_TARNAME ""
888
889 /* Define to the home page for this package. */
890 #define PACKAGE_URL ""
891
892 /* Define to the version of this package. */
893 #define PACKAGE_VERSION ""
894 m4_for(AT_Count, 1, 100, 1,
895 [
896 /* AT_DESCRIPTION */
897 [#define] AT_DUMMY_VAR(AT_Count) "AT_BIG_VALUE AT_BIG_VALUE"
898 ])])
899
900 AT_CHECK([sed -n '4,$ p' config.h], 0, expout)
901
902 # Checking that AC_SUBST worked properly.
903 AT_DATA([expout],
904 [m4_for(AT_Count, 1, 100, 1,
905 [AT_BIG_VALUE
906 content of file AT_Count
907 ])])
908
909 AT_CHECK([cat dummy], 0, expout)
910 done
911
912 AT_CLEANUP
913
914
915 ## ------------------------------- ##
916 ## Substitute a 2000-byte string. ##
917 ## ------------------------------- ##
918
919 # Solaris 9 /usr/ucb/sed that rejects commands longer than 4000 bytes. HP-UX
920 # sed dumps core around 8 KiB. However, POSIX says that sed need not
921 # handle lines longer than 2048 bytes (including the trailing newline).
922 # So we'll just test a 2000-byte value, and for awk, we test a line with
923 # almost 1000 words, and one variable with 5 lines of 2000 bytes each:
924 # multi-line values should allow to get around the limitations.
925 # We also test runs of around 148 backslashes: they need to be escaped,
926 # and 148 is the portable limit for awk string literals. config.status
927 # uses concatenation to generate longer strings.
928
929 AT_SETUP([Substitute a 2000-byte string])
930
931 AT_DATA([Foo.in], [@foo@
932 ])
933 AT_DATA([Bar.in], [@bar@
934 ])
935 AT_DATA([Baz.in], [@baz@
936 ])
937 AT_DATA([Boo.in], [@b147@
938 @b148@
939 @b149@
940 @b295@
941 @b296@
942 @b297@
943 ])
944
945 AT_DATA([configure.ac],
946 [[AC_INIT
947 AC_SUBST([foo], ]m4_for([n], 1, 100,, ....................)[)
948 AC_SUBST([bar], "]m4_for([n], 1, 100,, @ @ @ @ @ @ @ @ @ @@)[")
949 baz="]m4_for([m], 1, 100,, ... ... ... ... ....)[
950 "
951 baz=$baz$baz$baz$baz$baz
952 AC_SUBST([baz])
953 b29='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
954 b147=$b29$b29$b29$b29$b29'\\'
955 b148=$b147'\'
956 b149=$b148'\'
957 b295=$b147$b147'\'
958 b296=$b295'\'
959 b297=$b296'\'
960 AC_SUBST([b147])
961 AC_SUBST([b148])
962 AC_SUBST([b149])
963 AC_SUBST([b295])
964 AC_SUBST([b296])
965 AC_SUBST([b297])
966 AC_PROG_AWK
967 AC_CONFIG_FILES([Foo Bar Baz Boo])
968 AC_OUTPUT
969 ]])
970
971 cp "$abs_top_srcdir/build-aux/install-sh" .
972
973 b29='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
974 b147=$b29$b29$b29$b29$b29'\\'
975 b295=$b147$b147'\'
976 cat >Boo-exp <<EOF
977 $b147
978 $b147\\
979 $b147\\\\
980 $b295
981 $b295\\
982 $b295\\\\
983 EOF
984
985 AT_CHECK_AUTOCONF
986 # Check both awk and the result of AC_PROG_AWK
987 # Quote the first word in the for list for Solaris sh.
988 for awk_arg in "Foo=" AWK=awk; do
989 AT_CHECK_CONFIGURE([$awk_arg])
990 AT_CHECK([cat Foo], 0, m4_for([n], 1, 100,, ....................)
991 )
992 AT_CHECK([cat Bar], 0, m4_for([n], 1, 100,, @ @ @ @ @ @ @ @ @ @@)
993 )
994 AT_DATA([stdout],
995 [m4_for([n], 1, 5,, m4_for([m], 1, 100,, ... ... ... ... ....)
996 )])
997 AT_CHECK([cat Baz], 0, [stdout])
998 AT_CHECK([diff Boo-exp Boo])
999 done
1000 AT_CLEANUP
1001
1002
1003 ## ------------------------------ ##
1004 ## Define to a 2000-byte string. ##
1005 ## ------------------------------ ##
1006
1007 AT_SETUP([Define to a 2000-byte string])
1008 AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
1009
1010 AT_CONFIGURE_AC(
1011 [[
1012 AC_DEFINE_UNQUOTED([foo], ]m4_for([n], 1, 100,, ....................)[, [desc])
1013 AC_DEFINE([fooq], ]m4_for([n], 1, 100,, ....................)[, [desc])
1014 ]])
1015
1016 AT_CHECK_AUTOCONF
1017 AT_CHECK_AUTOHEADER([], [foo fooq])
1018 AT_CHECK_CONFIGURE
1019 AT_CHECK_DEFINES([@%:@define foo m4_for([n], 1, 100,, ....................)
1020 @%:@define fooq m4_for([n], 1, 100,, ....................)
1021 ])
1022 AT_CLEANUP
1023
1024
1025 ## ------------------------------------------ ##
1026 ## Substitute and define special characters. ##
1027 ## ------------------------------------------ ##
1028
1029 # Use characters special to the shell, sed, awk, and M4.
1030
1031 AT_SETUP([Substitute and define special characters])
1032 AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
1033
1034 AT_XFAIL_IF([byte=\\200s; dnl
1035 test `{ printf $byte; echo; } | sed -n '/^./p' | wc -l` = 0])
1036
1037 AT_DATA([Foo.in], [@foo@
1038 @bar@@notsubsted@@baz@ stray @ and more@@@baz@
1039 abc@bar@baz@baz
1040 abc@bar@@baz@baz
1041 abc@bar@@baz@baz@
1042 abc@bar @baz@baz
1043 abc@bar @baz@baz@
1044 abc@bar @baz@@baz@
1045 @file@
1046 @file@
1047 X@file@
1048 @file@X
1049 ])
1050
1051 AT_DATA([File],
1052 [@foo@@bar@
1053 ])
1054
1055 AT_DATA([Zardoz.in], [@zardoz@
1056 ])
1057
1058 AT_CONFIGURE_AC(
1059 [[foo="AS@&t@_ESCAPE([[X*'[]+ ", & &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !]])"
1060 #"
1061 bar="@foo@ @baz@"
1062 baz=bla
1063 ( for i in 0 1 2 3; do
1064 for j in 0 1 2 3 4 5 6 7; do
1065 for k in 0 1 2 3 4 5 6 7; do
1066 case $i$j$k in #(
1067 000 | 015 | 377) ;; # MinGW awk dislikes 0xFF, and the test does
1068 # the wrong thing for CR on MinGW.
1069 #(
1070 *) printf \\$i$j$k's' ;; # The 's' works around a Solaris 8 /bin/bash bug.
1071 esac
1072 done
1073 done
1074 done
1075 printf \\n
1076 ) >allowed-chars
1077 zardoz=`cat allowed-chars`
1078 AC_SUBST([foo])
1079 AC_SUBST([bar])
1080 AC_SUBST([baz])
1081 AC_SUBST([zardoz])
1082 file=File
1083 AC_SUBST_FILE([file])
1084 AC_DEFINE([fooq], [[X*'[]+ ", & &`\($foo !]], [Awful value.])
1085 AC_DEFINE([barq], [[%!_!# X]], [Value that is used as special delimiter.])
1086 AC_DEFINE_UNQUOTED([foo], [[X*'[]+ ", & &\`\\(\$foo !]], [Awful value.])
1087 AC_DEFINE_UNQUOTED([bar], [[%!_!# X]], [Value that is used as special delimiter.])
1088 AC_DEFINE_UNQUOTED([unq1], [$baz], [unquoted, test 1])
1089 AC_DEFINE_UNQUOTED([unq2], [\$baz], [unquoted, test 2])
1090 AC_DEFINE_UNQUOTED([unq3], ["$baz"], [unquoted, test 3])
1091 AC_DEFINE_UNQUOTED([unq4], [${baz+set}], [unquoted, test 4])
1092 AC_DEFINE_UNQUOTED([unq5], ["${baz+`echo "a "' b'`}"], [unquoted, test 5])
1093 AC_DEFINE_UNQUOTED([unq6], [`echo hi`], [unquoted, test 6])
1094 AC_DEFINE_UNQUOTED([unq7], ['\\"'], [unquoted, test 7])
1095 AC_DEFINE_UNQUOTED([unq8], ["${baz+$(echo "a "' b')}"], [unquoted, test 8])
1096 AC_PROG_AWK
1097 AC_CONFIG_FILES([Foo Zardoz])]])
1098
1099 AT_CHECK_AUTOCONF
1100 AT_CHECK_AUTOHEADER([],
1101 [foo fooq bar barq unq1 unq2 unq2 unq3 unq4 unq5 unq6 unq7 unq8])
1102 # Check both awk and the result of AC_PROG_AWK
1103 # Quote the first word in the for list for Solaris sh.
1104 for awk_arg in "FOO=" AWK=awk; do
1105 AT_CHECK_CONFIGURE([$awk_arg])
1106 AT_CHECK([cat Foo], 0, [[X*'[]+ ", & &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !
1107 @foo@ @baz@@notsubsted@bla stray @ and more@@bla
1108 abc@foo@ @baz@baz@baz
1109 abc@foo@ @baz@blabaz
1110 abc@foo@ @baz@blabaz@
1111 abc@bar blabaz
1112 abc@bar blabaz@
1113 abc@bar blabla
1114 @foo@@bar@
1115 @foo@@bar@
1116 X@file@
1117 @file@X
1118 ]])
1119 AT_CHECK([cmp allowed-chars Zardoz])
1120 AT_CHECK_DEFINES([[#define bar %!_!# X
1121 #define barq %!_!# X
1122 #define foo X*'[]+ ", & &`\($foo !
1123 #define fooq X*'[]+ ", & &`\($foo !
1124 #define unq1 bla
1125 #define unq2 $baz
1126 #define unq3 "bla"
1127 #define unq4 set
1128 #define unq5 "a b"
1129 #define unq6 hi
1130 #define unq7 '\"'
1131 #define unq8 "a b"
1132 ]])
1133 done
1134 AT_CLEANUP
1135
1136 ## ---------------------------------------------- ##
1137 ## No trailing white space in macro definitions. ##
1138 ## ---------------------------------------------- ##
1139 AT_SETUP([No trailing white space in macro definitions])
1140 AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
1141
1142 AT_DATA([config.hin], [
1143 #undef EMPTY
1144 #undef SPACE
1145 #undef TAB
1146 #undef LEADING_SPACES
1147 #undef LEADING_TABS
1148 ])
1149
1150 AT_DATA([configure.ac],
1151 [[AC_INIT
1152 AC_CONFIG_HEADERS([config.h:config.hin])
1153 empty=
1154 space=' '
1155 tab=' '
1156 leading_spaces=' a'
1157 leading_tabs=' a'
1158 AC_DEFINE_UNQUOTED([EMPTY], [$empty], [empty])
1159 AC_DEFINE_UNQUOTED([SPACE], [$space], [space])
1160 AC_DEFINE_UNQUOTED([TAB], [$tab], [tab])
1161 AC_DEFINE_UNQUOTED([LEADING_SPACES], [$leading_spaces], [leading spaces])
1162 AC_DEFINE_UNQUOTED([LEADING_TABS], [$leading_tabs], [leading tabs])
1163 AC_OUTPUT
1164 ]])
1165
1166 AT_CHECK_AUTOCONF
1167 AT_CHECK_CONFIGURE
1168
1169 AT_DATA([expout],
1170 [[/* config.h. Generated from config.hin by configure. */
1171
1172 #define EMPTY
1173 #define SPACE
1174 #define TAB
1175 #define LEADING_SPACES a
1176 #define LEADING_TABS a
1177 ]])
1178 AT_CHECK([cat config.h], 0, expout)
1179
1180 AT_CLEANUP
1181
1182 ## ---------------------- ##
1183 ## Substitute a newline. ##
1184 ## ---------------------- ##
1185
1186 AT_SETUP([Substitute a newline])
1187
1188 AT_DATA([Foo.in],
1189 [@foo@
1190 @bar@
1191 ])
1192
1193 AT_DATA([configure.ac],
1194 [[AC_INIT
1195 foo='one
1196 two'
1197 bar='%!_!# ''
1198 x'
1199 AC_SUBST([foo])
1200 AC_SUBST([bar])
1201 AC_CONFIG_FILES([Foo])
1202 AC_PROG_AWK
1203 AC_OUTPUT
1204 ]])
1205
1206 cp "$abs_top_srcdir/build-aux/install-sh" .
1207
1208 echo 'one
1209 two
1210 %!_!# ''
1211 x' >expout
1212
1213 AT_CHECK_AUTOCONF
1214 # Check both awk and the result of AC_PROG_AWK
1215 # Quote the first word in the for list for Solaris sh.
1216 for awk_arg in "FOO=" AWK=awk; do
1217 AT_CHECK_CONFIGURE([$awk_arg])
1218 AT_CHECK([cat Foo], 0, [expout])
1219 done
1220 AT_CLEANUP
1221
1222
1223 ## ------------------ ##
1224 ## Define a newline. ##
1225 ## ------------------ ##
1226
1227 AT_SETUP([Define a newline])
1228 AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
1229 AT_CONFIGURE_AC([[AC_DEFINE([foo], [one
1230 two], [This spans two lines.])
1231 ]])
1232 AT_CHECK_AUTOCONF([], [], [], [stderr])
1233 dnl Older versions of m4 report error at line 5 (end of macro);
1234 dnl newer versions report it at line 4 (start of macro).
1235 AT_CHECK([[sed '/trailer\.m4:/d; s/^configure\.ac:[45]: //' stderr]], [],
1236 [[warning: AC_DEFINE: 'one
1237 two' is not a valid preprocessor define value
1238 ]])
1239 AT_CHECK_AUTOHEADER([], [foo])
1240 AT_CHECK_CONFIGURE
1241 AT_CHECK_DEFINES([[#define foo one
1242 ]])
1243
1244 rm -rf autom4te.cache
1245
1246 AT_CONFIGURE_AC([[AC_DEFINE_UNQUOTED([foo], [one
1247 two], [This spans two lines.])
1248 ]])
1249 AT_CHECK_AUTOCONF([], [], [], [stderr])
1250 AT_CHECK([[sed '/trailer.m4:/d; s/^configure\.ac:[45]: //' stderr]], [],
1251 [[warning: AC_DEFINE_UNQUOTED: 'one
1252 two' is not a valid preprocessor define value
1253 ]])
1254 AT_CHECK_AUTOHEADER([], [foo])
1255 AT_CHECK_CONFIGURE
1256 AT_CHECK_DEFINES([[#define foo one
1257 ]])
1258
1259 AT_CLEANUP
1260
1261
1262 ## ------------------------------------ ##
1263 ## AC_SUBST: variable name validation. ##
1264 ## ------------------------------------ ##
1265
1266 AT_SETUP([AC_SUBST: variable name validation])
1267
1268 AT_CONFIGURE_AC([[AC_SUBST(, [])
1269 AC_CONFIG_FILES([Makefile])
1270 ]])
1271 AT_DATA([Makefile.in], [[
1272 ]])
1273 mv -f configure.ac configure.tmpl
1274
1275 # Invalid names.
1276 for var in ['' ab\~ ab\( ab[] ab\' ab\" ab\\\\]; do
1277 sed ["s/AC_SUBST(/&[$var]/"] <configure.tmpl >configure.ac
1278 AT_CHECK_AUTOCONF([], [1], [], [ignore])
1279 done
1280
1281 # Valid names.
1282 for var in ab a4 'a@@&t@\&t@b'; do
1283 sed ["s/AC_SUBST(/&[$var]/"] <configure.tmpl >configure.ac
1284 AT_CHECK_AUTOCONF
1285 AT_CHECK_AUTOHEADER
1286 AT_CHECK_CONFIGURE
1287 done
1288
1289 AT_CLEANUP
1290
1291
1292 ## ------------------------ ##
1293 ## datarootdir workaround. ##
1294 ## ------------------------ ##
1295
1296 AT_SETUP([datarootdir workaround])
1297
1298 AT_DATA([Foo.in],
1299 [@datadir@
1300 @docdir@
1301 @infodir@
1302 @localedir@
1303 @mandir@
1304 ])
1305
1306 AT_DATA([Bar.in],
1307 [@mydatadir@
1308 ])
1309
1310 AT_DATA([configure.ac],
1311 [[AC_INIT
1312 d@&t@nl The following line silences the warnings, if uncommented:
1313 d@&t@nl AC_DEFUN([AC_DATAROOTDIR_CHECKED])
1314
1315 # This substitution is wrong and bogus! Don't use it in your own code!
1316 # Read 'info Autoconf "Defining Directories"'!
1317 AC_SUBST([mydatadir], [${datadir}/my])
1318
1319 AC_CONFIG_FILES([Foo Bar])
1320 AC_OUTPUT
1321 ]])
1322
1323 cp "$abs_top_srcdir/build-aux/install-sh" .
1324
1325 AT_CHECK_AUTOCONF
1326 AT_CHECK_CONFIGURE([], [], [],
1327 [config.status: WARNING: 'Foo.in' seems to ignore the --datarootdir setting
1328 config.status: WARNING: Bar contains a reference to the variable 'datarootdir'
1329 which seems to be undefined. Please make sure it is defined
1330 ])
1331 AT_CHECK([grep datarootdir Foo], 1, [])
1332
1333 rm configure
1334 sed '/AC_DEFUN/s/^d@&t@nl //' configure.ac >t
1335 mv t configure.ac
1336
1337 AT_CHECK_AUTOCONF
1338 AT_CHECK_CONFIGURE
1339
1340 AT_CLEANUP
1341
1342
1343 ## -------- ##
1344 ## srcdir. ##
1345 ## -------- ##
1346
1347 AT_SETUP([srcdir])
1348
1349 rm -f -r at-dir
1350 mkdir at-dir
1351 : >at-dir/bar.in
1352 : >foo.in
1353
1354 AT_DATA([configure.ac],
1355 [[AC_INIT
1356
1357 AC_CONFIG_FILES([foo at-dir/bar])
1358
1359 # Use quotes in the INIT-COMMANDS to accommodate a value of $srcdir
1360 # containing e.g., spaces or shell meta-characters.
1361 # Use *single* quotes because the context is an unquoted here-doc.
1362 AC_CONFIG_COMMANDS([report],
1363 [test -f "$srcdir/configure.ac" ||
1364 AC_MSG_ERROR([cannot find $srcdir/configure.ac])],
1365 [srcdir='$srcdir'])
1366
1367 AC_OUTPUT
1368 rm -f -r foo at-dir/bar
1369 ]])
1370
1371 AT_CHECK_AUTOCONF
1372
1373 # In place.
1374 AT_CHECK([./configure $configure_options], [], [ignore])
1375
1376 # Relative name.
1377 AT_CHECK([cd at-dir && ../configure $configure_options], [], [ignore])
1378
1379 # Absolute name.
1380 at_here=`pwd`
1381 AT_CHECK([cd at-dir && "$at_here/configure" $configure_options], [], [ignore])
1382
1383 AT_CLEANUP
1384
1385
1386 ## ------- ##
1387 ## VPATH. ##
1388 ## ------- ##
1389
1390 AT_SETUP([VPATH])
1391
1392 dirs='at paren brace space'
1393 for dir in $dirs; do
1394 mkdir $dir $dir/s1 $dir/s2
1395 touch $dir/f $dir/s1/f1 $dir/s2/f2
1396 done
1397
1398 AT_DATA([configure.ac],
1399 [[AC_INIT
1400 AC_CONFIG_FILES([at/Makefile paren/Makefile brace/Makefile space/Makefile])
1401 AC_OUTPUT
1402 ]])
1403
1404 AT_DATA([at/Makefile.in],
1405 [[# This is what you should use in order to be portable to old makes.
1406 srcdir = @srcdir@
1407 VPATH = @srcdir@/s1:@srcdir@:@srcdir@/s2
1408 all: f f1 f2
1409 @echo ok
1410 ]])
1411
1412 AT_DATA([paren/Makefile.in],
1413 [[# This works with some makes but not with old ones.
1414 srcdir = @srcdir@
1415 VPATH = $(srcdir)/s1:$(srcdir):$(srcdir)/s2
1416 all: f f1 f2
1417 @echo ok
1418 ]])
1419
1420 AT_DATA([brace/Makefile.in],
1421 [[# This works with some makes but not with old ones.
1422 srcdir = @srcdir@
1423 VPATH = ${srcdir}/s1:${srcdir}:${srcdir}/s2
1424 all: f f1 f2
1425 @echo ok
1426 ]])
1427
1428 AT_DATA([space/Makefile.in],
1429 [[# This fails with FreeBSD make, for example.
1430 srcdir = @srcdir@
1431 VPATH = @srcdir@/s1 @srcdir@ @srcdir@/s2
1432 all: f f1 f2
1433 @echo ok
1434 ]])
1435
1436 AT_CHECK_AUTOCONF
1437
1438 # In place.
1439 AT_CHECK([./configure $configure_options], [], [ignore])
1440 # Treat BSD make separately, afterwards, for maximal coverage.
1441 dirs='at paren brace'
1442 for dir in $dirs; do
1443 AT_CHECK_MAKE([], [$dir])
1444 done
1445
1446 rm -f config.status
1447 mkdir build absbuild
1448
1449 # Relative name.
1450 AT_CHECK([cd build && ../configure $configure_options], [], [ignore])
1451 for dir in $dirs; do
1452 AT_CHECK_MAKE([], [build/$dir])
1453 done
1454
1455 # Absolute name.
1456 at_here=`pwd`
1457 AT_CHECK([cd absbuild && "$at_here/configure" $configure_options], [], [ignore])
1458 for dir in $dirs; do
1459 AT_CHECK_MAKE([], [absbuild/$dir])
1460 done
1461
1462 # These will not pass with BSD make.
1463 AT_CHECK_MAKE([|| exit 77], [space])
1464 AT_CHECK_MAKE([], [build/space])
1465 AT_CHECK_MAKE([], [absbuild/space])
1466
1467
1468 AT_CLEANUP
1469
1470
1471 ## ----------------- ##
1472 ## Signal handling. ##
1473 ## ----------------- ##
1474
1475 AT_SETUP([Signal handling])
1476
1477 AT_DATA([configure.ac],
1478 [[AC_INIT
1479 kill -2 $$
1480 exit 77
1481 AC_OUTPUT
1482 ]])
1483
1484 AT_CHECK_AUTOCONF
1485 AT_CHECK_CONFIGURE([], [1], [ignore], [ignore])
1486
1487 AT_CLEANUP
1488
1489
1490 ## ----------------- ##
1491 ## AC_CONFIG_LINKS. ##
1492 ## ----------------- ##
1493
1494 AT_SETUP([AC_CONFIG_LINKS])
1495
1496 AT_DATA([configure.ac],
1497 [[AC_INIT([config links to config files test], [1.0])
1498 AC_CONFIG_SRCDIR([sub1/file1.in])
1499 AC_CONFIG_FILES([sub1/file1 file2])
1500 AC_CONFIG_LINKS([file1:sub1/file1 sub2/file2:file2])
1501 AC_OUTPUT
1502 ]])
1503
1504 mkdir sub1
1505
1506 AT_DATA([sub1/file1.in],
1507 [[/* @configure_input@ */
1508 #define PACKAGE_STRING "@PACKAGE_STRING@"
1509 ]])
1510
1511 AT_DATA([file2.in],
1512 [[/* @configure_input@ */
1513 #define PACKAGE_STRING "@PACKAGE_STRING@"
1514 ]])
1515
1516 mkdir build
1517 AT_CHECK_AUTOCONF
1518 cd build
1519 AT_CHECK([../configure && ../configure], 0, [ignore])
1520 AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
1521 ])
1522 AT_CHECK([../configure && ../configure], 0, [ignore])
1523 AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
1524 ])
1525 cd ..
1526 rm -rf build
1527 mkdir build
1528 cd build
1529 cwd=`pwd`
1530 AT_CHECK(["$cwd"/../configure && "$cwd"/../configure], 0, [ignore])
1531 AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
1532 ])
1533 cd ..
1534 AT_CHECK([./configure && ./configure], 0, [ignore], [stderr])
1535 AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
1536 ])
1537 cwd=`pwd`
1538 AT_CHECK(["$cwd"/configure && "$cwd"/configure], 0, [ignore], [ignore])
1539 AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
1540 ])
1541
1542 AT_CLEANUP
1543
1544
1545 ## ------------------------------------- ##
1546 ## AC_CONFIG_LINKS and identical files. ##
1547 ## ------------------------------------- ##
1548 AT_SETUP([AC_CONFIG_LINKS and identical files])
1549
1550 AT_DATA([configure.ac],
1551 [[AC_INIT
1552 AC_CONFIG_LINKS([src/s:src/s])
1553 test "$srcdir" != '.' && AC_CONFIG_LINKS([src/t:src/t])
1554 AC_OUTPUT
1555 ]])
1556
1557 mkdir src build
1558 echo file1 > src/s
1559 echo file2 > src/t
1560 AT_CHECK_AUTOCONF
1561 cd build
1562 AT_CHECK([../configure $configure_options && ../configure $configure_options],
1563 0, [ignore])
1564 AT_CHECK([cat src/s src/t], 0, [file1
1565 file2
1566 ])
1567
1568 cd ..
1569 rm -rf build
1570 mkdir build
1571 cd build
1572 cwd=`pwd`
1573 AT_CHECK(["$cwd"/../configure], 0, [ignore])
1574 AT_CHECK([cat src/s src/t], 0, [file1
1575 file2
1576 ])
1577 AT_CHECK(["$cwd"/../configure], 0, [ignore])
1578 AT_CHECK([cat src/s src/t], 0, [file1
1579 file2
1580 ])
1581 cd ..
1582 AT_CHECK([./configure $configure_options && ./configure $configure_options],
1583 0, [ignore], [stderr])
1584 AT_CHECK([grep src/t stderr], 1)
1585 AT_CHECK([cat src/s src/t], 0, [file1
1586 file2
1587 ])
1588 cwd=`pwd`
1589 AT_CHECK(["$cwd"/configure && "$cwd"/configure], 0, [ignore], [ignore])
1590 AT_CHECK([cat src/s src/t], 0, [file1
1591 file2
1592 ])
1593
1594 AT_CLEANUP
1595
1596
1597 AT_BANNER([autoreconf.])
1598
1599 ## ---------------------------- ##
1600 ## Configuring subdirectories. ##
1601 ## ---------------------------- ##
1602
1603 # .
1604 # |-- builddir
1605 # | |-- config.log
1606 # | |-- config.status
1607 # | `-- inner
1608 # | |-- config.log
1609 # | |-- config.status
1610 # | `-- innermost
1611 # | `-- config
1612 # |-- configure
1613 # |-- configure.ac
1614 # |-- inner
1615 # | |-- configure
1616 # | |-- configure.ac
1617 # | `-- innermost
1618 # | `-- config.in
1619 # `-- install-sh
1620 #
1621 AT_SETUP([Configuring subdirectories])
1622 AT_KEYWORDS(autoreconf)
1623
1624 AT_REQUIRE_ACLOCAL
1625
1626 # The contents of 'inner/', and 'inner/innermost/'.
1627 AS_MKDIR_P([inner/innermost])
1628
1629 AT_DATA([inner/configure.ac],
1630 [[AC_INIT(GNU Inner, 1.0)
1631 AC_CONFIG_SRCDIR([innermost/config.in])
1632 AC_ARG_VAR([INNER], [an inner variable])
1633 AC_SUBST([INNER])
1634 if test "x$INNER" = x; then
1635 INNER=inner
1636 fi
1637 AC_CONFIG_FILES([innermost/config])
1638 AC_OUTPUT
1639 ]])
1640
1641 AT_DATA([inner/innermost/config.in],
1642 [INNER=@INNER@
1643 srcdir=@srcdir@
1644 top_srcdir=@top_srcdir@
1645 prefix=@prefix@
1646 ])
1647
1648 # The contents of '.'
1649 AT_DATA([install-sh], [])
1650
1651 # nonexistent is allowed not to exist.
1652 AT_DATA([configure.ac],
1653 [[AC_INIT(GNU Outer, 1.0)
1654 AC_ARG_VAR([OUTER], [an outer variable])
1655 if false; then
1656 AC_CONFIG_SUBDIRS([nonexistent])
1657 fi
1658 AC_CONFIG_SUBDIRS([inner])
1659 AC_OUTPUT
1660 ]])
1661
1662 AT_CHECK([autoreconf])
1663 AT_CHECK([test -f inner/configure])
1664
1665 # Running the outer configure recursively should provide the innermost
1666 # help strings.
1667 chmod a-w inner/innermost inner .
1668 AT_CHECK([{ ./configure $configure_options --help=recursive; chmod u+w .; } | grep INNER], 0,
1669 [ignore], [stderr],
1670 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1671 chmod u+w . inner inner/innermost
1672
1673 # Running the outer configure should trigger the inner.
1674 AT_CHECK_CONFIGURE
1675 AT_CHECK([cat inner/innermost/config], 0,
1676 [INNER=inner
1677 srcdir=.
1678 top_srcdir=..
1679 prefix=/usr/local
1680 ])
1681
1682 # The same, but from a builddir.
1683 AS_MKDIR_P([builddir])
1684 AT_CHECK([cd builddir && ../configure $configure_options], 0, [ignore])
1685 AT_CHECK([cat builddir/inner/innermost/config], 0,
1686 [INNER=inner
1687 srcdir=../../../inner/innermost
1688 top_srcdir=../../../inner
1689 prefix=/usr/local
1690 ])
1691
1692 # Make sure precious variables and command line options are properly
1693 # passed, even when there are duplicates.
1694 AT_CHECK([cd builddir && ../configure $configure_options --prefix /bad --prefix /good INNER=bad INNER=good],
1695 0, [ignore])
1696 AT_CHECK([cat builddir/inner/innermost/config], 0,
1697 [INNER=good
1698 srcdir=../../../inner/innermost
1699 top_srcdir=../../../inner
1700 prefix=/good
1701 ])
1702
1703 # Make sure --prefix is properly quoted
1704 AT_CHECK([cd builddir && ../configure --prefix "/a b c$ 'd"], 0, [ignore])
1705 AT_CHECK([cat builddir/inner/innermost/config], 0,
1706 [INNER=inner
1707 srcdir=../../../inner/innermost
1708 top_srcdir=../../../inner
1709 prefix=/a b c$ 'd
1710 ])
1711
1712 # Make sure --silent is properly passed...
1713 AT_CHECK([cd builddir && ../configure $configure_options --silent], 0, [])
1714 # ...but not stored in config.status.
1715 AT_CHECK([cd builddir && ./config.status --recheck], 0, [stdout])
1716 AT_CHECK([grep 'creating \./config.status' stdout], 0, [ignore])
1717
1718 # --cache-file is adjusted for subdirectories, so the cache is shared.
1719 AT_CHECK([cd builddir && ../configure $configure_options --config-cache],
1720 [], [stdout])
1721 AT_CHECK([grep 'loading .*\.\./config.cache' stdout], [], [ignore])
1722
1723 # Make sure we can run autoreconf on a subdirectory
1724 rm -f configure configure.ac
1725 AT_CHECK([autoreconf inner], [], [], [ignore])
1726
1727 # Make sure we can pass a configure.ac name
1728 AT_CHECK([cd inner && autoreconf configure.ac], [], [], [ignore])
1729 AT_CHECK([autoreconf inner/configure.ac], [], [], [ignore])
1730
1731 AT_CLEANUP
1732
1733
1734
1735 ## -------------- ##
1736 ## Deep Package. ##
1737 ## -------------- ##
1738
1739 AT_SETUP([Deep Package])
1740 AT_KEYWORDS(autoreconf)
1741
1742 AT_REQUIRE_ACLOCAL
1743
1744 # The contents of '.'
1745 AT_DATA([install-sh], [])
1746 AT_DATA([configure.ac],
1747 [[AC_INIT(GNU Outer, 1.0)
1748 AC_ARG_VAR([OUTER], [an outer variable])
1749 AC_CONFIG_SUBDIRS([
1750 inner
1751 inner2
1752 ])
1753 AC_OUTPUT
1754 ]])
1755
1756 # The contents of 'inner/', and 'inner/innermost/'.
1757 AS_MKDIR_P([inner/innermost])
1758 AS_MKDIR_P([inner2])
1759
1760 AT_DATA([inner/configure.ac],
1761 [[AC_INIT(GNU Inner, 1.0)
1762 AC_ARG_VAR([INNER], [an inner variable])
1763 AC_CONFIG_SUBDIRS(innermost)
1764 AC_OUTPUT
1765 ]])
1766
1767 AT_DATA([inner/innermost/configure.ac],
1768 [[AC_INIT(GNU Innermost, 1.0)
1769 AC_ARG_VAR([INNERMOST], [an innermost variable])
1770 AC_CONFIG_HEADERS(config.h:config.hin)
1771 AC_DEFINE_UNQUOTED([INNERMOST], [$INNERMOST], [an innermost variable])
1772 if test -n "$innermost_error"; then
1773 AC_MSG_FAILURE([error in $PACKAGE_NAME])
1774 fi
1775 AC_OUTPUT
1776 ]])
1777
1778 AT_DATA([inner2/configure.ac],
1779 [[AC_INIT(GNU Inner 2, 1.0)
1780 AC_ARG_VAR([INNER2], [an inner2 variable])
1781 AC_OUTPUT
1782 ]])
1783
1784 AT_CHECK([autoreconf -Wall], [0], [ignore])
1785 AT_CHECK([test -f inner/configure])
1786 AT_CHECK([test -f inner/innermost/configure])
1787 AT_CHECK([test -f inner/innermost/config.hin])
1788 AT_CHECK([test -f inner2/configure])
1789
1790 # Running the outer configure recursively should provide the innermost
1791 # help strings.
1792 chmod a-w inner/innermost inner
1793 AT_CHECK([{ ./configure $configure_options --help=recursive; chmod u+w .; } | grep " INNER "],
1794 0, [ignore], [stderr],
1795 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1796 chmod a-w .
1797 AT_CHECK([{ ./configure $configure_options --help=recursive; chmod u+w .; } | grep " INNER2 "],
1798 0, [ignore], [stderr],
1799 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1800 chmod a-w .
1801 AT_CHECK([{ ./configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1802 0, [ignore], [stderr],
1803 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1804 chmod a-w .
1805 AT_CHECK([{ /bin/sh ./configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1806 0, [ignore], [stderr],
1807 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1808 chmod a-w .
1809 AT_CHECK([PATH=.$PATH_SEPARATOR$PATH; export PATH; { /bin/sh configure $configure_options --help=recursive; chmod +w .; } | grep " INNERMOST "],
1810 0, [ignore], [stderr],
1811 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1812 chmod a-w .
1813 AT_CHECK([PATH=.$PATH_SEPARATOR$PATH; export PATH; { configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1814 0, [ignore], [stderr],
1815 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1816 chmod u+w inner inner/innermost
1817
1818 # Running the outer configure should trigger the inner.
1819 AT_CHECK_CONFIGURE([INNERMOST=tsomrenni])
1820 AT_CHECK([grep INNERMOST inner/innermost/config.h], 0,
1821 [[#define INNERMOST tsomrenni
1822 ]])
1823
1824 # Ensure we point to the right config.log file for errors.
1825 AT_CHECK_CONFIGURE([innermost_error=:], [1], [], [stderr])
1826 AT_CHECK([grep 'inner/innermost' stderr], [], [ignore])
1827 cd inner
1828 AT_CHECK_CONFIGURE([innermost_error=:], [1], [], [stderr])
1829 AT_CHECK([grep 'innermost' stderr], [], [ignore])
1830 cd ..
1831
1832 # The same, but from a builddir.
1833 AS_MKDIR_P([builddir])
1834 chmod a-w builddir inner/innermost inner
1835 AT_CHECK([cd builddir && { ../configure $configure_options --help=recursive; chmod u+w .; } | grep " INNER "],
1836 0, [ignore], [stderr],
1837 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1838 chmod a-w builddir
1839 AT_CHECK([cd builddir && { ../configure $configure_options --help=recursive; chmod u+w .; } | grep " INNER2 "],
1840 0, [ignore], [stderr],
1841 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1842 chmod a-w builddir
1843 AT_CHECK([cd builddir && { ../configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1844 0, [ignore], [stderr],
1845 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1846 chmod a-w builddir
1847 AT_CHECK([cd builddir && { /bin/sh ../configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1848 0, [ignore], [stderr],
1849 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1850 chmod a-w builddir
1851 # Not all shells search $PATH for scripts.
1852 if (cd builddir && PATH=`pwd`/..$PATH_SEPARATOR$PATH /bin/sh configure $configure_options --help) >/dev/null 2>&1; then
1853 AT_CHECK([cd builddir && PATH=`pwd`/..$PATH_SEPARATOR$PATH /bin/sh configure $configure_options --help=recursive | grep " INNERMOST "], 0, [ignore])
1854 fi
1855 AT_CHECK([PATH=`pwd`$PATH_SEPARATOR$PATH; export PATH; cd builddir && { configure $configure_options --help=recursive; chmod u+w .; } | grep " INNERMOST "],
1856 0, [ignore], [stderr],
1857 [AT_CHECK([grep 'rerun with a POSIX shell' stderr], [], [ignore])])
1858 chmod u+w builddir inner inner/innermost
1859 AT_CHECK([cd builddir && ../configure $configure_options INNERMOST=build/tsomrenni], 0, [ignore])
1860 AT_CHECK([grep INNERMOST builddir/inner/innermost/config.h], 0,
1861 [[#define INNERMOST build/tsomrenni
1862 ]])
1863
1864 AT_CLEANUP
1865
1866
1867
1868 ## -------------------------------- ##
1869 ## Non-Autoconf AC_CONFIG_SUBDIRS. ##
1870 ## -------------------------------- ##
1871
1872 AT_SETUP([Non-Autoconf AC_CONFIG_SUBDIRS])
1873 AT_KEYWORDS([autoreconf])
1874
1875 # We use aclocal (via autoreconf).
1876 AT_REQUIRE_ACLOCAL
1877
1878 AT_DATA([install-sh], [])
1879 AT_DATA([configure.ac],
1880 [[AC_INIT(GNU Outer, 1.0)
1881 AC_CONFIG_SUBDIRS([inner])
1882 AC_OUTPUT
1883 ]])
1884
1885 AS_MKDIR_P([inner])
1886
1887 AT_DATA([inner/configure],
1888 [[#! /bin/sh
1889 case "$*" in
1890 *--help*) echo 'No Autoconf here, folks!' ;;
1891 *) echo got_it >myfile ;;
1892 esac
1893 exit 0
1894 ]])
1895 chmod +x inner/configure
1896
1897 AT_CHECK([autoreconf -Wall], 0, [ignore])
1898
1899 # Running the outer configure recursively should provide the innermost
1900 # help strings.
1901 AT_CHECK([./configure $configure_options --help=recursive | grep "folks"],
1902 [0], [ignore])
1903
1904 # Running the outer configure should trigger the inner.
1905 AT_CHECK([./configure $configure_options], 0, [ignore])
1906 AT_CHECK([test -f inner/myfile], 0)
1907
1908 AT_CLEANUP
1909
1910
1911 ## ------------------------------- ##
1912 ## Non-literal AC_CONFIG_SUBDIRS. ##
1913 ## ------------------------------- ##
1914
1915 AT_SETUP([Non-literal AC_CONFIG_SUBDIRS])
1916 AT_KEYWORDS([autoreconf])
1917
1918 AT_DATA([install-sh], [])
1919 AT_DATA([configure.ac],
1920 [[AC_INIT(GNU Outer, 1.0)
1921
1922 my_subdirs=
1923 # Taken from autoconf.texi:Subdirectories.
1924 if test "x$package_foo_enabled" = xyes; then
1925 my_subdirs="$my_subdirs foo"
1926 fi
1927 AC_CONFIG_SUBDIRS([$my_subdirs])
1928 AC_OUTPUT
1929 ]])
1930
1931 AT_SUPPRESS_ACLOCAL
1932 AS_MKDIR_P([foo])
1933
1934 AT_DATA([foo/configure],
1935 [[#! /bin/sh
1936 touch innerfile
1937 exit 0
1938 ]])
1939 chmod +x foo/configure
1940
1941 # autoreconf should warn without -Wno-syntax, but should not fail without -Werror.
1942 AT_CHECK([autoreconf -Werror -v], [1], [ignore], [stderr])
1943 AT_CHECK([grep 'AC_CONFIG_SUBDIRS:.*literals' stderr], [0], [ignore])
1944 AT_CHECK([autoreconf -v], [0], [ignore], [stderr])
1945 AT_CHECK([grep 'AC_CONFIG_SUBDIRS:.*literals' stderr], [0], [ignore])
1946 AT_CHECK([autoreconf -v --force -Wno-syntax], 0, [ignore], [stderr])
1947 AT_CHECK([grep 'AC_CONFIG_SUBDIRS:.*literals' stderr], [1])
1948
1949 AT_CHECK([./configure $configure_options], [0], [ignore])
1950 AT_CHECK([test ! -f foo/innerfile])
1951 # Running the outer configure should trigger the inner.
1952 AT_CHECK([./configure $configure_options package_foo_enabled=yes], [0], [ignore])
1953 AT_CHECK([test -f foo/innerfile])
1954
1955 AT_CLEANUP
1956
1957 ## ------------------------- ##
1958 ## Empty AC_CONFIG_SUBDIRS. ##
1959 ## ------------------------- ##
1960
1961 AT_SETUP([Empty AC_CONFIG_SUBDIRS])
1962 AT_KEYWORDS([autoreconf])
1963
1964 AT_DATA([install-sh], [])
1965 AT_DATA([configure.ac],
1966 [[AC_INIT(GNU Outer, 1.0)
1967
1968 AC_CONFIG_SUBDIRS()
1969 AC_OUTPUT
1970 ]])
1971
1972 AT_SUPPRESS_ACLOCAL
1973 # autoreconf should have no complaints, and the generated configure
1974 # script should run fine with or without --no-recursion.
1975 AT_CHECK([autoreconf -Werror], [0], [ignore])
1976 AT_CHECK_CONFIGURE()
1977 AT_CHECK_CONFIGURE([--no-recursion])
1978
1979 AT_CLEANUP
1980
1981 ## ----------------- ##
1982 ## Empty directory. ##
1983 ## ----------------- ##
1984
1985 AT_SETUP([Empty directory])
1986 AT_KEYWORDS([autoreconf])
1987
1988 # Prevent autoreconf from running aclocal, which might not be available.
1989 dnl We can't use AT_SUPPRESS_ACLOCAL here because it creates an aclocal.m4.
1990 ACLOCAL=true
1991
1992 # The test group directory is not necessarily _empty_, but it does not contain
1993 # files meaningful to 'autoreconf'.
1994
1995 AT_STATE_SAVE_DIR([before])
1996
1997 AT_CHECK([autoreconf -Wall -v], 1, [ignore], [ignore])
1998
1999 AT_CHECK_ENV
2000
2001 AT_CLEANUP
2002
2003 ## ------------------------------ ##
2004 ## Unusual Automake input files. ##
2005 ## ------------------------------ ##
2006
2007 # This parallels gnumake.test in Automake.
2008
2009 AT_SETUP([Unusual Automake input files])
2010 AT_KEYWORDS([autoreconf])
2011
2012 AT_REQUIRE_AUTOMAKE
2013 AT_REQUIRE_ACLOCAL
2014
2015 AT_DATA([configure.ac],
2016 [[AC_INIT(GNU foo, 1.0)
2017 AM_INIT_AUTOMAKE
2018 AC_CONFIG_FILES([HeeHee])
2019 AC_OUTPUT
2020 ]])
2021
2022 AT_DATA([HeeHee.am],
2023 [[# Humans do no worse than 'GNUmakefile.am'.
2024 AUTOMAKE_OPTIONS = foreign 1.8
2025 ]])
2026
2027 AT_CHECK([autoreconf -Wall -v -i], 0, [ignore], [stderr],
2028 [AT_CHECK([grep 'require.*1\.8' stderr && exit 77], [1])])
2029 AT_CHECK([test -f HeeHee.in])
2030
2031 AT_CLEANUP
2032
2033 ## -------------------- ##
2034 ## Running libtoolize. ##
2035 ## -------------------- ##
2036
2037 AT_SETUP([Package requiring libtool])
2038 AT_KEYWORDS([autoreconf libtool])
2039
2040 AT_REQUIRE_AUTOMAKE
2041 AT_REQUIRE_ACLOCAL
2042 AT_REQUIRE_LIBTOOL
2043
2044 AT_DATA([configure.ac],
2045 [[AC_INIT(GNU foo, 1.0)
2046 AC_CONFIG_MACRO_DIRS([m4])
2047 AM_INIT_AUTOMAKE
2048 LT_INIT
2049 AC_CONFIG_FILES([Makefile])
2050 AC_OUTPUT
2051 ]])
2052
2053 AT_DATA([Makefile.am],
2054 [[AUTOMAKE_OPTIONS = foreign
2055 ACLOCAL_AMFLAGS = -I m4
2056 ]])
2057
2058 # autoreconf will only notice that it needs to run libtoolize if
2059 # libtool's .m4 files are visible to aclocal. The test harness has
2060 # deliberately suppressed use of third-party .m4 files by aclocal,
2061 # because there may be bugs in those files that would cause spurious
2062 # test failures. Get libtoolize to tell us the names of the relevant
2063 # .m4 files, and link them into the per-package m4 directory specified
2064 # in configure.ac and Makefile.am.
2065 #
2066 # (If autoreconf ran libtoolize *before* aclocal, it would handle this
2067 # for us, but it doesn't, for good reason; we *have* to do that for
2068 # autopoint and it's a mess.)
2069
2070 mkdir m4
2071 $LIBTOOLIZE -n -v -i 2> /dev/null |
2072 sed -e '/ \(ln -s\|cp\) /!d; / m4$/!d; s/ m4$//; s/^.* \(ln -s\|cp\) //' |
2073 while read f; do cp "$f" m4; done
2074
2075 AT_CHECK([autoreconf -Wall -v -i], 0, [ignore], [stderr])
2076 AT_CHECK([$EGREP 'running: .*libtoolize' stderr], 0, [ignore], [ignore])
2077
2078 AT_CHECK_CONFIGURE
2079
2080 AT_CLEANUP
2081
2082 ## -------------------- ##
2083 ## Running autopoint. ##
2084 ## -------------------- ##
2085
2086 AT_SETUP([Package requiring autopoint (AM_GNU_GETTEXT + _VERSION)])
2087 AT_KEYWORDS([autoreconf autopoint])
2088
2089 AT_REQUIRE_AUTOMAKE
2090 AT_REQUIRE_ACLOCAL
2091 AT_REQUIRE_AUTOPOINT
2092
2093 AT_DATA([configure.ac],
2094 [[AC_INIT(GNU foo, 1.0)
2095 AC_CONFIG_MACRO_DIRS([m4])
2096 AM_INIT_AUTOMAKE
2097 AM_GNU_GETTEXT([external])
2098 # This is the oldest version of gettext.m4 that defines the
2099 # AM_GNU_GETTEXT_VERSION macro.
2100 AM_GNU_GETTEXT_VERSION([0.11.4])
2101
2102 AC_CONFIG_FILES([Makefile po/Makefile.in])
2103 AC_OUTPUT
2104 ]])
2105
2106 AT_DATA([Makefile.am],
2107 [[AUTOMAKE_OPTIONS = foreign
2108 ACLOCAL_AMFLAGS = -I m4
2109 SUBDIRS = po
2110 ]])
2111
2112 # autoreconf runs autopoint before aclocal, so we don't need to
2113 # worry about the m4 files being unavailable as we do for libtool.
2114 AT_CHECK([autoreconf -Wall -v -i], 0, [ignore], [stderr])
2115 AT_CHECK([$EGREP 'running: .*autopoint' stderr], 0, [ignore], [ignore])
2116
2117 AT_CHECK_CONFIGURE([--no-create])
2118
2119 # Because we're intentionally calling for very old gettext infrastructure,
2120 # config.status will cough up a warning about po/Makefile.in.in but
2121 # should otherwise run fine.
2122 AT_CHECK([./config.status], [0],
2123 [[config.status: creating Makefile
2124 config.status: creating po/Makefile.in
2125 config.status: executing default-1 commands
2126 config.status: executing depfiles commands
2127 ]],
2128 [[config.status: WARNING: 'po/Makefile.in.in' seems to ignore the --datarootdir setting
2129 ]])
2130
2131 AT_CLEANUP
2132
2133
2134 AT_SETUP([Package requiring autopoint (AM_GNU_GETTEXT + _REQUIRE_VERSION)])
2135 AT_KEYWORDS([autoreconf autopoint])
2136
2137 AT_REQUIRE_AUTOMAKE
2138 AT_REQUIRE_ACLOCAL
2139 AT_REQUIRE_AUTOPOINT
2140
2141 AT_DATA([configure.ac],
2142 [[AC_INIT(GNU foo, 1.0)
2143 AC_CONFIG_MACRO_DIRS([m4])
2144 AM_INIT_AUTOMAKE
2145 AM_GNU_GETTEXT([external])
2146 # This is the oldest version of gettext.m4 that defines the
2147 # AM_GNU_GETTEXT_REQUIRE_VERSION macro.
2148 AM_GNU_GETTEXT_REQUIRE_VERSION([0.19.6])
2149
2150 AC_CONFIG_FILES([Makefile po/Makefile.in])
2151 AC_OUTPUT
2152 ]])
2153
2154 AT_DATA([Makefile.am],
2155 [[AUTOMAKE_OPTIONS = foreign
2156 ACLOCAL_AMFLAGS = -I m4
2157 SUBDIRS = po
2158 ]])
2159
2160 # autoreconf runs autopoint before aclocal, so we don't need to
2161 # worry about the m4 files being unavailable as we do for libtool.
2162 AT_CHECK([autoreconf -Wall -v -i], 0, [ignore], [stderr])
2163 AT_CHECK([$EGREP 'running: .*autopoint' stderr], 0, [ignore], [ignore])
2164
2165 # The requested version of gettext.m4 is new enough that its
2166 # po/Makefile.in.in does not provoke warnings from config.status.
2167 AT_CHECK_CONFIGURE
2168
2169 AT_CLEANUP
2170
2171
2172 AT_SETUP([Package requiring autopoint (AM_GNU_GETTEXT alone)])
2173 AT_KEYWORDS([autoreconf autopoint])
2174
2175 AT_REQUIRE_AUTOMAKE
2176 AT_REQUIRE_ACLOCAL
2177 AT_REQUIRE_AUTOPOINT
2178
2179 AT_DATA([configure.ac],
2180 [[AC_INIT(GNU foo, 1.0)
2181 AC_CONFIG_MACRO_DIRS([m4])
2182 AM_INIT_AUTOMAKE
2183 AM_GNU_GETTEXT([external])
2184
2185 AC_CONFIG_FILES([Makefile po/Makefile.in])
2186 AC_OUTPUT
2187 ]])
2188
2189 AT_DATA([Makefile.am],
2190 [[AUTOMAKE_OPTIONS = foreign
2191 ACLOCAL_AMFLAGS = -I m4
2192 SUBDIRS = po
2193 ]])
2194
2195 # autoreconf runs autopoint before aclocal, so we don't need to
2196 # worry about the m4 files being unavailable as we do for libtool.
2197 AT_CHECK([autoreconf -Wall -v -i], 0, [ignore], [stderr])
2198
2199 # autoreconf should have completed successfully regardless of what
2200 # version of autopoint is available; however, if we have an old
2201 # autopoint, it will not have run autopoint, and the generated
2202 # configure script will not work.
2203
2204 AS_IF([$at_autopoint_modern], [
2205 AT_CHECK([$EGREP 'running: .*autopoint' stderr], 0, [ignore], [ignore])
2206 AT_CHECK_CONFIGURE
2207 ], [
2208 AT_CHECK([$EGREP 'not running autopoint because it is too old' stderr],
2209 0, [ignore], [ignore])
2210 ])
2211
2212 AT_CLEANUP
2213
2214
2215 AT_SETUP([Package requiring autopoint (AM_ICONV alone)])
2216 AT_KEYWORDS([autoreconf autopoint])
2217
2218 AT_REQUIRE_AUTOMAKE
2219 AT_REQUIRE_ACLOCAL
2220 AT_REQUIRE_AUTOPOINT
2221
2222 AT_DATA([configure.ac],
2223 [[AC_INIT(GNU foo, 1.0)
2224 AC_CONFIG_MACRO_DIRS([m4])
2225 AM_INIT_AUTOMAKE
2226 AM_ICONV
2227
2228 AC_CONFIG_FILES([Makefile])
2229 AC_OUTPUT
2230 ]])
2231
2232 AT_DATA([Makefile.am],
2233 [[AUTOMAKE_OPTIONS = foreign
2234 ACLOCAL_AMFLAGS = -I m4
2235 ]])
2236
2237 # autoreconf runs autopoint before aclocal, so we don't need to
2238 # worry about the m4 files being unavailable as we do for libtool.
2239 AT_CHECK([autoreconf -Wall -v -i], 0, [ignore], [stderr])
2240
2241 # autoreconf should have completed successfully regardless of what
2242 # version of autopoint is available; however, if we have an old
2243 # autopoint, it will not have run autopoint, and the generated
2244 # configure script will not work.
2245
2246 AS_IF([$at_autopoint_modern], [
2247 AT_CHECK([$EGREP 'running: .*autopoint' stderr], 0, [ignore], [ignore])
2248 AT_CHECK_CONFIGURE
2249 ], [
2250 AT_CHECK([$EGREP 'not running autopoint because it is too old' stderr],
2251 0, [ignore], [ignore])
2252 ])
2253
2254 AT_CLEANUP
2255
2256
2257 AT_SETUP([Package requiring autopoint (AC_LIB_LINKFLAGS alone)])
2258 AT_KEYWORDS([autoreconf autopoint])
2259
2260 AT_REQUIRE_AUTOMAKE
2261 AT_REQUIRE_ACLOCAL
2262 AT_REQUIRE_AUTOPOINT
2263
2264 AT_DATA([configure.ac],
2265 [[AC_INIT(GNU foo, 1.0)
2266 AC_CONFIG_MACRO_DIRS([m4])
2267 AM_INIT_AUTOMAKE
2268 AC_LIB_LINKFLAGS
2269
2270 AC_CONFIG_FILES([Makefile])
2271 AC_OUTPUT
2272 ]])
2273
2274 AT_DATA([Makefile.am],
2275 [[AUTOMAKE_OPTIONS = foreign
2276 ACLOCAL_AMFLAGS = -I m4
2277 ]])
2278
2279 # autoreconf runs autopoint before aclocal, so we don't need to
2280 # worry about the m4 files being unavailable as we do for libtool.
2281 AT_CHECK([autoreconf -Wall -v -i], 0, [ignore], [stderr])
2282
2283 # autoreconf should have completed successfully regardless of what
2284 # version of autopoint is available; however, if we have an old
2285 # autopoint, it will not have run autopoint, and the generated
2286 # configure script will not work.
2287
2288 AS_IF([$at_autopoint_modern], [
2289 AT_CHECK([$EGREP 'running: .*autopoint' stderr], 0, [ignore], [ignore])
2290 AT_CHECK_CONFIGURE
2291 ], [
2292 AT_CHECK([$EGREP 'not running autopoint because it is too old' stderr],
2293 0, [ignore], [ignore])
2294 ])
2295
2296 AT_CLEANUP
2297
2298
2299 ## ---------------------------------------------------- ##
2300 ## autoreconf --exclude (aclocal, automake, autoconf). ##
2301 ## ---------------------------------------------------- ##
2302
2303 AT_SETUP([autoreconf --exclude (aclocal, automake, autoconf)])
2304 AT_KEYWORDS([autoreconf])
2305
2306 # This test should work even if we *don't* have aclocal or automake,
2307 # because we're telling autoreconf not to run them.
2308
2309 AT_DATA([configure.ac],
2310 [[AC_INIT(GNU foo, 1.0)
2311 AM_INIT_AUTOMAKE
2312 AC_CONFIG_FILES([Makefile])
2313 AC_OUTPUT
2314 ]])
2315
2316 AT_DATA([Makefile.am],
2317 [[AUTOMAKE_OPTIONS = foreign
2318 ]])
2319
2320 AT_STATE_SAVE_DIR([before])
2321
2322 # This should do nothing, as each of the tools it would normally run have
2323 # been excluded.
2324 AT_CHECK([autoreconf -Wall -v -i -x aclocal,automake,autoconf], 0, [], [ignore])
2325 AT_CHECK_ENV
2326 rm -f state-ls.after
2327
2328 # This should run autoconf, which will complain about not having any available
2329 # definition for AM_INIT_AUTOMAKE and bomb out.
2330 AT_CHECK([autoreconf -Wall -v -i -x aclocal,automake], 1, [], [stderr])
2331 AT_CHECK([$EGREP 'not running aclocal' stderr], 0, [ignore], [ignore])
2332 AT_CHECK([$EGREP 'running: .*autoconf' stderr], 0, [ignore], [ignore])
2333 AT_CHECK(
2334 [$EGREP 'error: undefined or overquoted macro: AM_INIT_AUTOMAKE' stderr],
2335 0, [ignore], [ignore])
2336
2337 # If we supply a fake definition of AM_INIT_AUTOMAKE, autoconf should now
2338 # succeed.
2339 AT_DATA([aclocal.m4],
2340 [[m4_define([AM_INIT_AUTOMAKE])
2341 ]])
2342
2343 # The 'not running aclocal' message changes to 'not using aclocal' because
2344 # autoreconf detects that our stub aclocal.m4 was not generated by aclocal.
2345 AT_CHECK([autoreconf -Wall -v -i -x aclocal,automake], 0, [], [stderr])
2346 AT_CHECK([$EGREP 'not using aclocal' stderr], 0, [ignore], [ignore])
2347 AT_CHECK([$EGREP 'running: .*autoconf' stderr], 0, [ignore], [ignore])
2348 AT_CHECK(
2349 [$EGREP 'error: undefined or overquoted macro: AM_INIT_AUTOMAKE' stderr],
2350 1, [ignore], [ignore])
2351
2352 # The generated configure script should run fine with --no-create.
2353 AT_CHECK_CONFIGURE([--no-create])
2354
2355 # However, config.status should fail as Makefile.in does not exist.
2356 AT_CHECK([./config.status], 1, [], [stderr])
2357 AT_CHECK(
2358 [$EGREP "error: cannot find input file: 'Makefile\\.in'" stderr],
2359 0, [ignore], [ignore])
2360
2361 AT_CHECK_ENV
2362
2363 AT_CLEANUP
2364
2365
2366 ## ----------------------------------- ##
2367 ## autoreconf --exclude (libtoolize). ##
2368 ## ----------------------------------- ##
2369
2370 AT_SETUP([autoreconf --exclude (libtoolize)])
2371 AT_KEYWORDS([autoreconf])
2372
2373 AT_REQUIRE_AUTOMAKE
2374 AT_REQUIRE_ACLOCAL
2375 AT_REQUIRE_LIBTOOL
2376
2377 # This test needs autoreconf to *think* it needs to run libtoolize,
2378 # otherwise the --exclude option won't have any effect.
2379
2380 AT_DATA([configure.ac],
2381 [[AC_INIT(GNU foo, 1.0)
2382 AC_CONFIG_MACRO_DIRS([m4])
2383 AM_INIT_AUTOMAKE
2384 LT_INIT
2385 AC_CONFIG_FILES([Makefile])
2386 AC_OUTPUT
2387 ]])
2388
2389 AT_DATA([Makefile.am],
2390 [[AUTOMAKE_OPTIONS = foreign
2391 ACLOCAL_AMFLAGS = -I m4
2392 ]])
2393
2394 # See commentary in the 'Package requiring libtool' test for further
2395 # explanation of what this does.
2396
2397 mkdir m4
2398 $LIBTOOLIZE -n -v -i 2> /dev/null |
2399 sed -e '/ \(ln -s\|cp\) /!d; / m4$/!d; s/ m4$//; s/^.* \(ln -s\|cp\) //' |
2400 while read f; do cp "$f" m4; done
2401
2402 # This run will fail at the automake stage because automake will notice
2403 # that ltmain.sh is missing.
2404 AT_CHECK([autoreconf -Wall -v -i --exclude libtoolize], 1, [ignore], [stderr])
2405 AT_CHECK([$EGREP 'not running libtoolize' stderr], 0, [ignore], [ignore])
2406 AT_CHECK(
2407 [$EGREP 'required file .\./ltmain\.sh. not found' stderr],
2408 0, [ignore], [ignore])
2409
2410 # Create a fake ltmain.sh to get past the above failure.
2411 AT_DATA([ltmain.sh],
2412 [[#! /bin/sh
2413 exit 1
2414 ]])
2415 chmod +x ltmain.sh
2416
2417 # This run of autoreconf should succeed.
2418 AT_CHECK([autoreconf -Wall -v -i --exclude libtoolize], 0, [ignore], [stderr])
2419 AT_CHECK([$EGREP 'not running libtoolize' stderr], 0, [ignore], [ignore])
2420
2421 # ./configure does not need to run ./ltmain.sh, so this should also succeed.
2422 AT_CHECK_CONFIGURE
2423
2424 AT_CLEANUP
2425
2426
2427 ## ----------------------------------- ##
2428 ## autoreconf --exclude (libtoolize). ##
2429 ## ----------------------------------- ##
2430
2431 AT_SETUP([autoreconf --exclude (autopoint)])
2432 AT_KEYWORDS([autoreconf])
2433
2434 AT_REQUIRE_AUTOMAKE
2435 AT_REQUIRE_ACLOCAL
2436 AT_REQUIRE_AUTOPOINT
2437
2438 # This test needs autoreconf to *think* it needs to run autopoint,
2439 # otherwise the --exclude option won't have any effect.
2440
2441 AT_DATA([configure.ac],
2442 [[AC_INIT(GNU foo, 1.0)
2443 AC_CONFIG_MACRO_DIRS([m4])
2444 AM_INIT_AUTOMAKE
2445 AM_GNU_GETTEXT([external])
2446 # This is the oldest version of gettext.m4 that defines the
2447 # AM_GNU_GETTEXT_VERSION macro.
2448 AM_GNU_GETTEXT_VERSION([0.11.4])
2449
2450 AC_CONFIG_FILES([Makefile po/Makefile.in])
2451 AC_OUTPUT
2452 ]])
2453
2454
2455 AT_DATA([Makefile.am],
2456 [[AUTOMAKE_OPTIONS = foreign
2457 ACLOCAL_AMFLAGS = -I m4
2458 SUBDIRS = po
2459 ]])
2460
2461 mkdir m4
2462
2463 # This run will fail at the autoconf stage because there won't be any
2464 # definition of AM_GNU_GETTEXT nor AM_GNU_GETTEXT_VERSION available.
2465 AT_CHECK([autoreconf -Wall -v -i --exclude autopoint], 1, [ignore], [stderr])
2466 AT_CHECK([$EGREP 'not running autopoint' stderr], 0, [ignore], [ignore])
2467 AT_CHECK(
2468 [$EGREP 'undefined or overquoted macro: AM_GNU_GETTEXT' stderr],
2469 0, [ignore], [ignore])
2470 AT_CHECK(
2471 [$EGREP 'undefined or overquoted macro: AM_GNU_GETTEXT_VERSION' stderr],
2472 0, [ignore], [ignore])
2473
2474 # Create a fake gettext.m4 to get past the above failures.
2475 AT_DATA([m4/gettext_stub.m4],
2476 [[AC@&t@_DEFUN([AM_GNU_GETTEXT])
2477 AC@&t@_DEFUN([AM_GNU_GETTEXT_VERSION])
2478 ]])
2479
2480 # Also create a fake po/Makefile.in.in.
2481 mkdir po
2482 AT_DATA([po/Makefile.in.in],
2483 [[# stub
2484 ]])
2485
2486 # This run of autoreconf should succeed.
2487 AT_CHECK([autoreconf -Wall -v -i --exclude autopoint], 0, [ignore], [stderr])
2488 AT_CHECK([$EGREP 'not running autopoint' stderr], 0, [ignore], [ignore])
2489
2490 # The stubbed-out macros should permit configure to run to completion.
2491 AT_CHECK_CONFIGURE
2492
2493 AT_CLEANUP
2494
2495
2496 ## ------------------------------ ##
2497 ## Specific warnings options. ##
2498 ## ------------------------------ ##
2499
2500 AT_SETUP([Specific warnings options for autoreconf])
2501 AT_KEYWORDS([autoreconf])
2502
2503 # If autoreconf is given a -W option that's mentioned in its own
2504 # --help output, that option should not cause errors, even if some
2505 # of the subsidiary programs don't support it.
2506
2507 AT_REQUIRE_AUTOMAKE
2508 AT_REQUIRE_ACLOCAL
2509
2510 AT_DATA([configure.ac],
2511 [[AC_INIT(GNU foo, 1.0)
2512 AM_INIT_AUTOMAKE
2513 AC_CONFIG_HEADERS([config.h])
2514 AC_CONFIG_FILES([Makefile])
2515 AC_OUTPUT
2516 ]])
2517
2518 AT_DATA([Makefile.am],
2519 [[AUTOMAKE_OPTIONS = foreign
2520 ]])
2521
2522 # To silence complaints about required helper scripts from automake.
2523 # We aren't going to run the generated Makefile so we don't need the
2524 # real helper scripts.
2525 AT_DATA([install-sh], [])
2526 AT_DATA([missing], [])
2527
2528 # In order to cut down the time this test takes, we do not test all
2529 # of the supported warning categories, just the most common case
2530 # (-Wall) and some specific categories that are known to have been a
2531 # problem in the past.
2532 AT_CHECK([autoreconf -Werror -Wall], 0, [], [])
2533 rm -rf configure config.h.in Makefile.in aclocal.m4 autom4te.cache
2534
2535 AT_CHECK([autoreconf -Werror -Wcross], 0, [], [])
2536 rm -rf configure config.h.in Makefile.in aclocal.m4 autom4te.cache
2537
2538 AT_CHECK([autoreconf -Werror -Wportability-recursive], 0, [], [])
2539 rm -rf configure config.h.in Makefile.in aclocal.m4 autom4te.cache
2540
2541 AT_CLEANUP
2542
2543 ## ------------------------- ##
2544 ## Missing auxiliary files. ##
2545 ## ------------------------- ##
2546
2547 AT_SETUP([Missing auxiliary files (config.*)])
2548 AT_KEYWORDS([autoreconf])
2549
2550 AT_SUPPRESS_ACLOCAL
2551 AT_DATA([configure.ac],
2552 [[AC_INIT([GNU foo], [1.0])
2553 AC_CONFIG_AUX_DIR([build-aux])
2554 AC_CANONICAL_HOST
2555 AC_OUTPUT
2556 ]])
2557
2558 AT_CHECK_AUTOCONF
2559
2560 # Both configure and autoreconf should detect the missing files.
2561 AT_CHECK_CONFIGURE([], [1], [ignore],
2562 [configure: error: cannot find required auxiliary files: config.guess config.sub
2563 ])
2564
2565 AT_CHECK([autoreconf], 1, [],
2566 [configure.ac: error: required file 'config.sub' not found
2567 configure.ac: error: required file 'config.guess' not found
2568 configure.ac: try running autoreconf --install
2569 ])
2570
2571 # If only one file is missing, the error messages should only report
2572 # that one. Also, the above invocation of autoreconf should _not_
2573 # have created build-aux, because it wasn't called with --install.
2574 AT_CHECK([test ! -e build-aux])
2575 mkdir build-aux
2576 : > build-aux/config.guess
2577
2578 AT_CHECK_CONFIGURE([], [1], [ignore],
2579 [configure: error: cannot find required auxiliary files: config.sub
2580 ])
2581
2582 AT_CHECK([autoreconf], 1, [],
2583 [configure.ac: error: required file 'config.sub' not found
2584 configure.ac: try running autoreconf --install
2585 ])
2586
2587 # Missing aux files should not interfere with --help and --version.
2588 AT_CHECK_CONFIGURE([--help], [0], [ignore], [ignore])
2589 AT_CHECK_CONFIGURE([--version], [0], [ignore], [ignore])
2590
2591 # autoreconf --install should be able to install config.sub and config.guess.
2592 rm build-aux/config.guess
2593 AT_CHECK([autoreconf --install])
2594
2595 AT_CHECK([test -x build-aux/config.guess])
2596 AT_CHECK([test -x build-aux/config.sub])
2597 AT_CHECK([test ! -e build-aux/install-sh])
2598
2599 AT_CHECK_CONFIGURE
2600
2601 AT_CLEANUP
2602
2603
2604 AT_SETUP([Missing auxiliary files (install-sh)])
2605 AT_KEYWORDS([autoreconf])
2606
2607 # Same as "Missing auxiliary files (config.*)" except that the
2608 # configure script _doesn't_ need config.{sub,guess} but does need
2609 # install-sh.
2610
2611 AT_SUPPRESS_ACLOCAL
2612 AT_DATA([configure.ac],
2613 [[AC_INIT([GNU foo], [1.0])
2614 AC_CONFIG_AUX_DIR([build-aux])
2615 AC_PROG_INSTALL
2616 AC_OUTPUT
2617 ]])
2618
2619 AT_CHECK_AUTOCONF
2620
2621 # Both configure and autoreconf should detect the missing files.
2622 AT_CHECK_CONFIGURE([], [1], [ignore],
2623 [configure: error: cannot find required auxiliary files: install-sh
2624 ])
2625
2626 AT_CHECK([autoreconf], 1, [],
2627 [configure.ac: error: required file 'install-sh' not found
2628 configure.ac: try running autoreconf --install
2629 ])
2630 AT_CHECK([test ! -e build-aux])
2631
2632 AT_CHECK_CONFIGURE([--help], [0], [ignore], [ignore])
2633 AT_CHECK_CONFIGURE([--version], [0], [ignore], [ignore])
2634
2635 AT_CHECK([autoreconf --install])
2636
2637 AT_CHECK([test ! -e build-aux/config.guess])
2638 AT_CHECK([test ! -e build-aux/config.sub])
2639 AT_CHECK([test -x build-aux/install-sh])
2640
2641 AT_CHECK_CONFIGURE
2642
2643 AT_CLEANUP
2644
2645
2646 AT_SETUP([Missing auxiliary files (foreign)])
2647 AT_KEYWORDS([autoreconf])
2648
2649 # If an aux file is required that autoreconf doesn't know how to install,
2650 # it shouldn't suggest autoreconf --install.
2651 # This also verifies that AC_REQUIRE_AUX_FILE can be used outside of a
2652 # macro definition, which was always the intent, and was recommended
2653 # usage in some automake recipes, but which was broken in autoconf
2654 # beta 2.69d (see https://savannah.gnu.org/support/?110363).
2655
2656 AT_SUPPRESS_ACLOCAL
2657 AT_DATA([configure.ac],
2658 [[AC_INIT([GNU foo], [1.0])
2659 AC_CONFIG_AUX_DIR([build-aux])
2660 AC_REQUIRE_AUX_FILE([tap-driver.sh])
2661 AC_OUTPUT
2662 ]])
2663
2664 AT_CHECK_AUTOCONF
2665 AT_CHECK_CONFIGURE([], [1], [ignore],
2666 [configure: error: cannot find required auxiliary files: tap-driver.sh
2667 ])
2668
2669 AT_CHECK([autoreconf], 1, [],
2670 [configure.ac: error: required file 'tap-driver.sh' not found
2671 ])
2672 AT_CHECK([test ! -e build-aux])
2673
2674 AT_CHECK([autoreconf --install], 1, [],
2675 [configure.ac: error: required file 'tap-driver.sh' not found
2676 ])
2677 # autoreconf --install always creates the aux directory.
2678 AT_CHECK([test -e build-aux])
2679
2680 touch build-aux/tap-driver.sh
2681
2682 AT_CHECK([autoreconf])
2683 AT_CHECK_CONFIGURE
2684
2685 AT_CLEANUP
2686
2687
2688 AT_SETUP([Missing auxiliary files (--force)])
2689 AT_KEYWORDS([autoreconf])
2690
2691 # Aux files that already exist should not be overwritten, unless
2692 # --force is used, in which case they *should* be overwritten.
2693 # Additional wrinkle: in case automake got to the files we install
2694 # first, we need to *not* overwrite a newer copy supplied by them.
2695
2696 AT_SUPPRESS_ACLOCAL
2697 AT_DATA([configure.ac],
2698 [[AC_INIT([GNU foo], [1.0])
2699 AC_CONFIG_AUX_DIR([build-aux])
2700 AC_PROG_INSTALL
2701 AC_CANONICAL_HOST
2702 AC_OUTPUT
2703 ]])
2704
2705 mkdir build-aux
2706
2707 AT_DATA([build-aux/config-guess.old],
2708 [[#! /bin/sh
2709 timestamp='1970-01-01'
2710 printf '%s\n' 'frobozz-bogon-bogos1'
2711 ]])
2712
2713 AT_DATA([build-aux/config-sub.new],
2714 [[#! /bin/sh
2715 scriptversion='9999-12-31'
2716 printf '%s\n' "$*"
2717 ]])
2718
2719 AT_DATA([build-aux/install-sh.old],
2720 [[#! /bin/sh
2721 # Old versions of install-sh did not have a timestamp line.
2722 ]])
2723
2724 cp build-aux/config-guess.old build-aux/config.guess
2725 cp build-aux/config-sub.new build-aux/config.sub
2726 cp build-aux/install-sh.old build-aux/install-sh
2727 chmod +x build-aux/config.sub build-aux/config.guess build-aux/install-sh
2728
2729 # This pass should not change any of the files.
2730 AT_CHECK([autoreconf --install])
2731 AT_CMP([build-aux/config-guess.old], [build-aux/config.guess])
2732 AT_CMP([build-aux/config-sub.new], [build-aux/config.sub])
2733 AT_CMP([build-aux/install-sh.old], [build-aux/install-sh])
2734
2735 # This pass should change only config.guess and install-sh, not config.sub.
2736 AT_CHECK([autoreconf --install --force])
2737 AT_CHECK(
2738 [if cmp build-aux/config-guess.old build-aux/config.guess > /dev/null 2>&1
2739 then exit 1
2740 fi])
2741 AT_CMP([build-aux/config-sub.new], [build-aux/config.sub])
2742 AT_CHECK(
2743 [if cmp build-aux/install-sh.old build-aux/install-sh > /dev/null 2>&1
2744 then exit 1
2745 fi])
2746
2747
2748 AT_CLEANUP
2749
2750 ## ------------------------------ ##
2751 ## Files clobbered by AC_OPENMP. ##
2752 ## ------------------------------ ##
2753
2754 AT_SETUP([Files clobbered by AC_OPENMP])
2755
2756 AT_CONFIGURE_AC(
2757 [[AC_PROG_CC
2758 AC_OPENMP
2759 ]])
2760
2761 AT_CHECK_AUTOHEADER
2762
2763 # autoconf should bomb out if either 'mp' or 'openmp' exists in the
2764 # srcdir.
2765 AT_DATA([mp])
2766 AT_CHECK_AUTOCONF([], [1], [], [stderr])
2767 AT_CHECK([grep "clobbers files named 'mp' and 'penmp'" stderr],
2768 [0], [ignore], [ignore])
2769 rm -f mp
2770
2771 AT_DATA([penmp])
2772 AT_CHECK_AUTOCONF([], [1], [], [stderr])
2773 AT_CHECK([grep "clobbers files named 'mp' and 'penmp'" stderr],
2774 [0], [ignore], [ignore])
2775 rm -f penmp
2776
2777 # If neither of these files exist, autoconf should go through...
2778 AT_CHECK_AUTOCONF
2779
2780 # ... but configure should bomb out, and *not* delete the files,
2781 # if they are added after autoconf is run.
2782 AT_DATA([mp])
2783 AT_CHECK_CONFIGURE([], [1], [], [stderr])
2784 AT_CHECK([test -e mp])
2785 AT_CHECK([grep "clobbers files named 'mp' and 'penmp'" stderr],
2786 [0], [ignore], [ignore])
2787 rm -f mp
2788
2789 AT_DATA([penmp])
2790 AT_CHECK_CONFIGURE([], [1], [], [stderr])
2791 AT_CHECK([test -e penmp])
2792 AT_CHECK([grep "clobbers files named 'mp' and 'penmp'" stderr],
2793 [0], [ignore], [ignore])
2794 rm -f penmp
2795
2796 AT_CHECK_CONFIGURE
2797 AT_CHECK_ENV
2798
2799 AT_CLEANUP