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