Home | History | Annotate | Line # | Download | only in tests
      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 
     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
    153 
    154 # Set a precious variable
    155 AT_CHECK_AC_ARG_VAR([], [apple of my eye])
    156 
    157 # Unset a precious variable
    158 AT_CHECK_AC_ARG_VAR([apple of my eye], [])
    159 
    160 # Change a precious variable
    161 AT_CHECK_AC_ARG_VAR([apple of my eye], [orange of my eye])
    162 
    163 # Change a precious variable that contains braces
    164 AT_CHECK_AC_ARG_VAR([apple of my {eye}], [orange of my eye])
    165 
    166 # Change a precious variable that contains all kinds of fun
    167 AT_CHECK_AC_ARG_VAR(['p  r	ec"iou$], [orange of my eye])
    168 dnl restore font-lock: "
    169 
    170 # Warn (but do not fail) about a whitespace-only change
    171 AT_CHECK_AC_ARG_VAR([	 apple  of	 my eye	 ], [apple of my eye],
    172 		    [0], ["has whitespace changes"])
    173 mv stdout configure-output
    174 AT_CHECK([grep "ignoring whitespace changes" stderr], [], [ignore])
    175 AT_CHECK([grep "precious:	 apple" configure-output], [], [ignore])
    176 
    177 AT_CLEANUP
    178 
    179 
    180 
    181 
    182 ## ---------------------------------------------- ##
    183 ## AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS.  ##
    184 ## ---------------------------------------------- ##
    185 
    186 AT_SETUP([[AC_CONFIG_FILES, HEADERS, LINKS and COMMANDS]])
    187 
    188 AT_DATA([configure.ac],
    189 [[AC_INIT
    190 AC_PROG_FGREP
    191 rm -f -r header var-header file var-file link var-link command var-command
    192 echo 'OK' >input
    193 
    194 # Be sure to also stress the associated INIT-CMDS.
    195 case $what_to_test in
    196  header)
    197    AC_CONFIG_HEADERS(header:input);;
    198  var-header)
    199    AC_CONFIG_HEADERS(var-header:$header_in, [], [header_in=input]);;
    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]);;
    217 esac
    218 AC_OUTPUT
    219 ]])
    220 
    221 AT_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.
    230 m4_define([AT_CHECK_CONFIG_CREATION],
    231 [AT_CHECK_CONFIGURE([what_to_test=$1])
    232 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
    233 	 [ignore], [$1
    234 ])
    235 AT_CHECK([grep OK $1], [], [OK
    236 ])
    237 
    238 AT_CHECK_CONFIGURE([what_to_test=var-$1 --no-create])
    239 # config.status might be stupidly expecting data on stdin, if it's
    240 # really broken...
    241 AT_CHECK([./config.status var-$1 </dev/null], [], [ignore])
    242 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
    243 	 [ignore], [var-$1
    244 ])
    245 AT_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.
    256 m4_define([AT_CHECK_CONFIG_CREATION_NOWRITE],
    257 [AT_CHECK_CONFIGURE([what_to_test=$1])
    258 AT_CHECK([ls header var-header file var-file command var-command link var-link 2>/dev/null],
    259 	 [ignore], [$1
    260 ])
    261 AT_CHECK([grep OK $1], [], [OK
    262 ])
    263 
    264 AT_CHECK_CONFIGURE([what_to_test=var-$1 --no-create])
    265 # config.status might be stupidly expecting data on stdin, if it's
    266 # really broken...
    267 # Skip check if user can rename files into a read-only directory (when
    268 # run by root or on w32).
    269 touch t
    270 chmod a-w .
    271 mv t t1 >/dev/null 2>&1 \
    272   || AT_CHECK([./config.status var-$1 </dev/null || exit 1],
    273    [1], [ignore], [ignore])
    274 chmod u+w .
    275 rm -rf t t1
    276 ])# AT_CHECK_CONFIG_CREATION_NOWRITE
    277 
    278 
    279 # Create a file
    280 AT_CHECK_CONFIG_CREATION(file)
    281 
    282 # Create a header
    283 AT_CHECK_CONFIG_CREATION(header)
    284 
    285 # Execute a command
    286 AT_CHECK_CONFIG_CREATION(command)
    287 
    288 # Create a link
    289 AT_CHECK_CONFIG_CREATION(link)
    290 
    291 # Now check for write errors
    292 
    293 # Create a file
    294 AT_CHECK_CONFIG_CREATION_NOWRITE(file)
    295 # Create a file with bits from stdin
    296 AT_CHECK([echo from-stdin | ./config.status --file=file:-],
    297 	 [0], [ignore])
    298 AT_CHECK([grep from-stdin file], [], [from-stdin
    299 ])
    300 # Force write error creating a file on stdout
    301 if test -w /dev/full && test -c /dev/full; then
    302   AT_CHECK([./config.status --file=-:input </dev/null >/dev/full || exit 1],
    303 	   [1], [ignore], [ignore])
    304 fi
    305 
    306 # Validate that --file requires an argument
    307 AT_CHECK([./config.status --file], [1], [ignore], [stderr])
    308 AT_CHECK([grep 'missing file argument' stderr], [0], [ignore])
    309 AT_CHECK([./config.status --file=], [1], [ignore], [stderr])
    310 AT_CHECK([grep 'missing file argument' stderr], [0], [ignore])
    311 
    312 # Create a header
    313 AT_CHECK_CONFIG_CREATION_NOWRITE(header)
    314 # Create a header on stdout
    315 AT_CHECK([./config.status --header=-:input </dev/null],
    316 	 [0], [stdout], [ignore])
    317 AT_CHECK([grep OK stdout], [], [OK
    318 ])
    319 # Force write error creating a header on stdout
    320 if test -w /dev/full && test -c /dev/full; then
    321   AT_CHECK([./config.status --header=-:input </dev/null >/dev/full || exit 1],
    322 	   [1], [ignore], [ignore])
    323 fi
    324 
    325 # Execute a command
    326 AT_CHECK_CONFIG_CREATION_NOWRITE(command)
    327 
    328 # Create a link
    329 AT_CHECK_CONFIG_CREATION_NOWRITE(link)
    330 
    331 # Check that no use of `ac_write_fail' escaped into config.status
    332 AT_CHECK([grep ac_write_fail config.status], [1])
    333 
    334 # Check that --file and --header accept funny file names
    335 AT_DATA([fgrep.in],
    336 [[FGREP="@FGREP@"
    337 ]])
    338 ./config.status --file=fgrep:fgrep.in
    339 . ./fgrep
    340 
    341 x=
    342 export x
    343 for file in \
    344   'with  funny '\'' $x & #! name' \
    345   'file with  funny \ '\'' \'\'' $ & #!*? name' \
    346   'with  funny \ '\'' \'\'' " | <a >b & * ? name ' # "restore font-lock
    347 do
    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@
    352 END
    353   AT_CHECK([./config.status "--file=$file:$file.in"],
    354 	   [0], [ignore])
    355   AT_CHECK([$FGREP "$file" "$file"], [0], [ignore])
    356   AT_CHECK([./config.status "--header=$file:$file.in"],
    357 	   [0], [ignore])
    358   # Run the same test a 2nd time to see that config.status does not recreate
    359   # the header (regression test)
    360   AT_CHECK_UNQUOTED([./config.status "--header=$file:$file.in"],
    361 		    [0], [config.status: creating $file
    362 config.status: $file is unchanged
    363 ])
    364   AT_CHECK_UNQUOTED([grep ' & ' "$file"], [],
    365 [/* $file.  Generated from $file.in by configure.  */
    366 ])
    367   AT_CHECK([$FGREP "$file" "$file"], [0], [ignore])
    368 done
    369 AT_CLEANUP
    370 
    371 
    372 
    373 ## ---------------------------------------- ##
    374 ## Macro calls in AC_CONFIG_COMMANDS tags.  ##
    375 ## ---------------------------------------- ##
    376 
    377 AT_SETUP([Macro calls in AC_CONFIG_COMMANDS tags])
    378 
    379 AT_DATA_M4SUGAR([configure.ac],
    380 [[AC_INIT
    381 AC_CONFIG_COMMANDS([m4_if(1,1,mytag)])
    382 AC_OUTPUT
    383 ]])
    384 
    385 AT_CHECK_AUTOCONF
    386 AT_CHECK_CONFIGURE
    387 
    388 AT_CLEANUP
    389 
    390 
    391 
    392 ## ------------------- ##
    393 ## Missing templates.  ##
    394 ## ------------------- ##
    395 
    396 # Check that config.status detects missing input files
    397 AT_SETUP([Missing templates])
    398 
    399 AT_DATA([configure.ac],
    400 [[AC_INIT
    401 AC_CONFIG_FILES([nonexistent])
    402 AC_OUTPUT
    403 ]])
    404 
    405 AT_CHECK_AUTOCONF
    406 mkdir build
    407 AT_CAPTURE_FILE([build/config.log])[]dnl
    408 cd build
    409 AT_CHECK([../configure], [1], [ignore],
    410 [[config.status: error: cannot find input file: `nonexistent.in'
    411 ]])
    412 # Make sure that the output file doesn't exist
    413 AT_CHECK([test -f nonexistent], 1)
    414 cd ..
    415 AT_CHECK_CONFIGURE([], [1], [],
    416 [[config.status: error: cannot find input file: `nonexistent.in'
    417 ]])
    418 # Make sure that the output file doesn't exist
    419 AT_CHECK([test -f nonexistent], 1)
    420 
    421 AT_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 
    439 AT_SETUP([configure invocation])
    440 
    441 mkdir sub
    442 
    443 AT_DATA([configure.ac],
    444 [[AC_INIT
    445 AC_CONFIG_SUBDIRS([sub])
    446 echo "result=$one$enable_two$with_three"
    447 AC_OUTPUT
    448 ]])
    449 
    450 AT_DATA([sub/configure.ac],
    451 [[AC_INIT
    452 echo "result=$one$enable_two$with_three"
    453 AC_OUTPUT
    454 ]])
    455 
    456 echo fake install-sh script >install-sh
    457 
    458 AT_CHECK_AUTOCONF
    459 cd sub
    460 AT_CHECK_AUTOCONF
    461 cd ..
    462 
    463 AT_CHECK_CONFIGURE([one=one --enable-two=two --with-three=three |
    464 		     sed -n -e 's/^result=//p'], 0,
    465 		   [m4_do([onetwothree
    466 ],			  [onetwothree
    467 ])])
    468 AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
    469 	 [onetwothree
    470 ])
    471 AT_CHECK([args=`./config.status --config` && eval ./configure \$configure_options "$args" |
    472 	    sed -n -e 's/^result=//p'], 0,
    473 	 [m4_do([onetwothree
    474 ],		[onetwothree
    475 ])])
    476 
    477 AT_CHECK_CONFIGURE([one="\"'$ " --enable-two="\" '  $" --with-three="	\"'$"|
    478 		      sed -n -e 's/^result=//p'], 0,
    479 		   [m4_do(["'$ " '  $	"'$
    480 ],			  ["'$ " '  $	"'$
    481 ])])
    482 AT_CHECK([./config.status --recheck | sed -n 's/^result=//p'], 0,
    483 	 ["'$ " '  $	"'$
    484 ])
    485 dnl restore font-lock: "
    486 AT_CHECK([args=`./config.status --config` && eval ./configure \$configure_options "$args" |
    487 	    sed -n -e 's/^result=//p'], 0,
    488 	 [m4_do(["'$ " '  $	"'$
    489 ],		["'$ " '  $	"'$
    490 ])])
    491 
    492 AT_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 
    503 AT_SETUP([@%:@define header templates])
    504 AT_KEYWORDS([AC@&t@_DEFINE])
    505 
    506 AT_DATA([configure.ac],
    507 [[AC_INIT
    508 AC_CONFIG_HEADERS(config.h:config.hin)
    509 
    510 # I18n of dummy variables: their French translations.
    511 AC_DEFINE(foo, toto)
    512 AC_DEFINE(bar, tata)
    513 AC_DEFINE(baz, titi)
    514 AC_DEFINE(fubar, tutu)
    515 
    516 # Symbols which are prefixes of another.
    517 AC_DEFINE(a, A)
    518 AC_DEFINE(aaa, AAA)
    519 AC_DEFINE(aa, AA)
    520 
    521 # backslash-newline combinations
    522 AC_DEFINE([multiline], [line1\
    523 line2\
    524 line3 \
    525 line4])
    526 AC_DEFINE([multiline_args(ARG1, ARG2)], [ARG2 \
    527 ARG1])
    528 AC_CONFIG_FILES(defs)
    529 
    530 # underquoted #
    531 AC_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.
    535 cat <<\EOF >>confdefs.h
    536 /* Hi Mum! Look, I am doing C++! */
    537 #ifdef __cplusplus
    538 void exit (int status);
    539 #endif
    540 EOF
    541 
    542 # In addition of config.h output a full DEFS
    543 AC_OUTPUT_MAKE_DEFS
    544 DEFS_SAVED=$DEFS
    545 AC_SUBST(DEFS_SAVED)
    546 AC_OUTPUT
    547 ]])
    548 
    549 AT_DATA([defs.in],
    550 [[@DEFS_SAVED@
    551 ]])
    552 
    553 AT_DATA([config.hin],
    554 [[#define foo   0
    555 #  define bar bar
    556 #  define baz   "Archimedes was sinking in his baz"
    557   #  define fubar				tutu
    558 #define a B
    559  #define aa BB
    560  #  define aaa BBB
    561 #undef a
    562  #  undef aa
    563 #undef aaa
    564 #define aaa(a, aa) aa a
    565 #define aaab
    566 #define aaac(a, aa) aa a
    567 #undef multiline
    568 #  undef multiline_args
    569 #define paste(a,b) a##b
    570 /* an ugly one: */
    571 #define str(define) \
    572 #define
    573 #define stringify(arg) str(arg)
    574 #undef aaa /* with comments */
    575 #undef not_substed /* with comments */
    576 ]])
    577 
    578 AT_CHECK_AUTOCONF
    579 AT_CHECK_CONFIGURE
    580 
    581 AT_DATA([expout],
    582 [[/* config.h.  Generated from config.hin by configure.  */
    583 #define foo toto
    584 #  define bar tata
    585 #  define baz titi
    586   #  define fubar tutu
    587 #define a A
    588  #define aa AA
    589  #  define aaa AAA
    590 #define a A
    591  #  define aa AA
    592 #define aaa AAA
    593 #define aaa AAA
    594 #define aaab
    595 #define aaac(a, aa) aa a
    596 #define multiline line1\
    597 line2\
    598 line3 \
    599 line4
    600 #  define multiline_args(ARG1, ARG2) ARG2 \
    601 ARG1
    602 #define paste(a,b) a##b
    603 /* an ugly one: */
    604 #define str(define) \
    605 #define
    606 #define stringify(arg) str(arg)
    607 #define aaa AAA
    608 /* #undef not_substed */
    609 ]])
    610 AT_CHECK([cat config.h], 0, expout)
    611 
    612 # Check the value of DEFS.
    613 AT_DATA([expout],
    614 [[-DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -Dfoo=toto -Dbar=tata -Dbaz=titi -Dfubar=tutu -Da=A -Daaa=AAA -Daa=AA -Dmultiline=line1line2line3\ line4 -Dmultiline_args\(ARG1,\ ARG2\)=ARG2\ ARG1 -Dpaste\(a,b\)=a\#\#b
    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.
    619 AT_CHECK([sed -e 's/ $//' defs], 0, expout)
    620 
    621 AT_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.
    635 m4_pattern_allow([^m4_for$])
    636 
    637 AT_SETUP([Torturing config.status])
    638 
    639 dnl The value used as a big value for AC_DEFINE.
    640 dnl Don't use sh active chars here, below it is also used in a sh
    641 dnl assignment.
    642 m4_define([AT_BIG_VALUE],
    643 [This value should be long enough to torture the various limits of sed and other tools used by Autoconf.])
    644 
    645 m4_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.*.
    659 m4_pattern_allow([^m4_bpatsubst$])
    660 m4_define([AT_DUMMY_VAR],
    661 [ac_Dummy_[]m4_bpatsubst([000$1], [.*\(...\)$], [\1])])
    662 
    663 
    664 
    665 AT_DATA([dummy.in],
    666 [m4_for([AT_Count], 1, 100, 1,
    667 [@AT_DUMMY_VAR(AT_Count)@
    668 @[f]AT_Count@
    669 ])])
    670 
    671 
    672 i=1
    673 while test $i != 101; do
    674   echo "content of file $i" > file_$i
    675   AS_VAR_ARITH([i], [$i + 1])
    676 done
    677 
    678 
    679 # ------------ #
    680 # configure.ac #
    681 # ------------ #
    682 
    683 m4_pattern_allow([^m4_(define|defun)$])
    684 AT_DATA([configure.ac],
    685 dnl The following lines transfer AT_DUMMY_VAR, AT_DESCRIPTION, and
    686 dnl AT_BIG_VALUE into the configure.ac as AC_DUMMY_VAR etc.
    687 [[m4_define([AC_DUMMY_VAR],]
    688 m4_dquote(m4_defn([AT_DUMMY_VAR]))[)]]
    689 
    690 [[m4_define([AC_DESCRIPTION],]
    691 m4_dquote(m4_defn([AT_DESCRIPTION]))[)]]
    692 
    693 [[m4_define([AC_BIG_VALUE],]
    694 m4_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.
    700 m4_defun([AC_DEFUBST],
    701 [AC_DUMMY_VAR($1)="AC_BIG_VALUE"
    702 AC_DEFINE_UNQUOTED(AC_DUMMY_VAR($1), "$AC_DUMMY_VAR($1) $AC_DUMMY_VAR($1)",
    703 		   AC_DESCRIPTION)
    704 AC_SUBST(AC_DUMMY_VAR($1))
    705 AC_SUBST_FILE([f]$1)
    706 f$1=file_$1
    707 ])
    708 
    709 AC_INIT
    710 AC_CONFIG_HEADERS(config.h:config.hin)
    711 AC_CONFIG_FILES(dummy)
    712 m4_for(AC_Count, 1, 100, 1,
    713        [AC_DEFUBST(AC_Count)])
    714 AC_PROG_AWK
    715 AC_OUTPUT
    716 ]])# configure.ac
    717 
    718 AT_CHECK_AUTOCONF
    719 AT_CHECK_AUTOHEADER
    720 # Check both awk and the result of AC_PROG_AWK.
    721 # Quote the first word in the for list for Solaris sh.
    722 for awk_arg in "FOO=" AWK=awk; do
    723   AT_CHECK_CONFIGURE([$awk_arg])
    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 ""
    744 m4_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
    756 content of file AT_Count
    757 ])])
    758 
    759   AT_CHECK([cat dummy], 0, expout)
    760 done
    761 
    762 AT_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 
    779 AT_SETUP([Substitute a 2000-byte string])
    780 
    781 AT_DATA([Foo.in], [@foo@
    782 ])
    783 AT_DATA([Bar.in], [@bar@
    784 ])
    785 AT_DATA([Baz.in], [@baz@
    786 ])
    787 AT_DATA([Boo.in], [@b147@
    788 @b148@
    789 @b149@
    790 @b295@
    791 @b296@
    792 @b297@
    793 ])
    794 
    795 AT_DATA([configure.ac],
    796 [[AC_INIT
    797 AC_SUBST([foo], ]m4_for([n], 1, 100,, ....................)[)
    798 AC_SUBST([bar], "]m4_for([n], 1, 100,, @ @ @ @ @ @ @ @ @ @@)[")
    799 baz="]m4_for([m], 1, 100,, ... ... ... ... ....)[
    800 "
    801 baz=$baz$baz$baz$baz$baz
    802 AC_SUBST([baz])
    803 b29='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
    804 b147=$b29$b29$b29$b29$b29'\\'
    805 b148=$b147'\'
    806 b149=$b148'\'
    807 b295=$b147$b147'\'
    808 b296=$b295'\'
    809 b297=$b296'\'
    810 AC_SUBST([b147])
    811 AC_SUBST([b148])
    812 AC_SUBST([b149])
    813 AC_SUBST([b295])
    814 AC_SUBST([b296])
    815 AC_SUBST([b297])
    816 AC_PROG_AWK
    817 AC_CONFIG_FILES([Foo Bar Baz Boo])
    818 AC_OUTPUT
    819 ]])
    820 
    821 cp "$abs_top_srcdir/build-aux/install-sh" .
    822 
    823 b29='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
    824 b147=$b29$b29$b29$b29$b29'\\'
    825 b295=$b147$b147'\'
    826 cat >Boo-exp <<EOF
    827 $b147
    828 $b147\\
    829 $b147\\\\
    830 $b295
    831 $b295\\
    832 $b295\\\\
    833 EOF
    834 
    835 AT_CHECK_AUTOCONF
    836 # Check both awk and the result of AC_PROG_AWK
    837 # Quote the first word in the for list for Solaris sh.
    838 for awk_arg in "Foo=" AWK=awk; do
    839   AT_CHECK_CONFIGURE([$awk_arg])
    840   AT_CHECK([cat Foo], 0, m4_for([n], 1, 100,, ....................)
    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])
    849 done
    850 AT_CLEANUP
    851 
    852 
    853 ## ------------------------------ ##
    854 ## Define to a 2000-byte string.  ##
    855 ## ------------------------------ ##
    856 
    857 AT_SETUP([Define to a 2000-byte string])
    858 AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
    859 
    860 AT_CONFIGURE_AC(
    861 [[
    862 AC_DEFINE_UNQUOTED([foo], ]m4_for([n], 1, 100,, ....................)[, [desc])
    863 AC_DEFINE([fooq], ]m4_for([n], 1, 100,, ....................)[, [desc])
    864 ]])
    865 
    866 AT_CHECK_AUTOCONF
    867 AT_CHECK_AUTOHEADER
    868 AT_CHECK_CONFIGURE
    869 AT_CHECK_DEFINES([@%:@define foo m4_for([n], 1, 100,, ....................)
    870 @%:@define fooq m4_for([n], 1, 100,, ....................)
    871 ])
    872 AT_CLEANUP
    873 
    874 
    875 ## ------------------------------------------ ##
    876 ## Substitute and define special characters.  ##
    877 ## ------------------------------------------ ##
    878 
    879 # Use characters special to the shell, sed, awk, and M4.
    880 
    881 AT_SETUP([Substitute and define special characters])
    882 AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
    883 
    884 AT_XFAIL_IF([byte=\\200s; dnl
    885 test `{ printf $byte; echo; } | sed -n '/^./p' | wc -l` = 0])
    886 
    887 AT_DATA([Foo.in], [@foo@
    888 @bar@@notsubsted@@baz@ stray @ and more@@@baz@
    889 abc@bar@baz@baz
    890 abc@bar@@baz@baz
    891 abc@bar@@baz@baz@
    892 abc@bar @baz@baz
    893 abc@bar @baz@baz@
    894 abc@bar @baz@@baz@
    895 @file@
    896 	 @file@
    897 X@file@
    898 @file@X
    899 ])
    900 
    901 AT_DATA([File],
    902 [@foo@@bar@
    903 ])
    904 
    905 AT_DATA([Zardoz.in], [@zardoz@
    906 ])
    907 
    908 AT_CONFIGURE_AC(
    909 [[foo="AS@&t@_ESCAPE([[X*'[]+ ", & &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !]])"
    910 #"
    911 bar="@foo@ @baz@"
    912 baz=bla
    913 ( for i in 0 1 2 3; do
    914     for j in 0 1 2 3 4 5 6 7; do
    915       for k in 0 1 2 3 4 5 6 7; do
    916 	case $i$j$k in #(
    917 	000 | 015 | 377) ;; # MinGW awk dislikes 0xFF, and the test does
    918 			    # the wrong thing for CR on MinGW.
    919 			    #(
    920 	*) printf \\$i$j$k's' ;; # The 's' works around a Solaris 8 /bin/bash bug.
    921 	esac
    922       done
    923     done
    924   done
    925   printf \\n
    926 ) >allowed-chars
    927 zardoz=`cat allowed-chars`
    928 AC_SUBST([foo])
    929 AC_SUBST([bar])
    930 AC_SUBST([baz])
    931 AC_SUBST([zardoz])
    932 file=File
    933 AC_SUBST_FILE([file])
    934 AC_DEFINE([fooq], [[X*'[]+ ", & &`\($foo !]], [Awful value.])
    935 AC_DEFINE([barq], [[%!_!# X]], [Value that is used as special delimiter.])
    936 AC_DEFINE_UNQUOTED([foo], [[X*'[]+ ", & &\`\\(\$foo !]], [Awful value.])
    937 AC_DEFINE_UNQUOTED([bar], [[%!_!# X]], [Value that is used as special delimiter.])
    938 AC_DEFINE_UNQUOTED([unq1], [$baz], [unquoted, test 1])
    939 AC_DEFINE_UNQUOTED([unq2], [\$baz], [unquoted, test 2])
    940 AC_DEFINE_UNQUOTED([unq3], ["$baz"], [unquoted, test 3])
    941 AC_DEFINE_UNQUOTED([unq4], [${baz+set}], [unquoted, test 4])
    942 AC_DEFINE_UNQUOTED([unq5], ["${baz+`echo "a "' b'`}"], [unquoted, test 5])
    943 AC_DEFINE_UNQUOTED([unq6], [`echo hi`], [unquoted, test 6])
    944 AC_DEFINE_UNQUOTED([unq7], ['\\"'], [unquoted, test 7])
    945 AC_PROG_AWK
    946 AC_CONFIG_FILES([Foo Zardoz])]])
    947 
    948 AT_CHECK_AUTOCONF
    949 AT_CHECK_AUTOHEADER
    950 # Check both awk and the result of AC_PROG_AWK
    951 # Quote the first word in the for list for Solaris sh.
    952 for awk_arg in "FOO=" AWK=awk; do
    953   AT_CHECK_CONFIGURE([$awk_arg])
    954   AT_CHECK([cat Foo], 0, [[X*'[]+ ", & &`\($foo \& \\& \\\& \\\\& \ \\ \\\ !
    955 @foo@ @baz@@notsubsted@bla stray @ and more@@bla
    956 abc@foo@ @baz@baz@baz
    957 abc@foo@ @baz@blabaz
    958 abc@foo@ @baz@blabaz@
    959 abc@bar blabaz
    960 abc@bar blabaz@
    961 abc@bar blabla
    962 @foo@@bar@
    963 @foo@@bar@
    964 X@file@
    965 @file@X
    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 ]])
    980 done
    981 AT_CLEANUP
    982 
    983 
    984 ## ---------------------- ##
    985 ## Substitute a newline.  ##
    986 ## ---------------------- ##
    987 
    988 AT_SETUP([Substitute a newline])
    989 
    990 AT_DATA([Foo.in],
    991 [@foo@
    992 @bar@
    993 ])
    994 
    995 AT_DATA([configure.ac],
    996 [[AC_INIT
    997 foo='one
    998 two'
    999 bar='%!_!# ''
   1000 x'
   1001 AC_SUBST([foo])
   1002 AC_SUBST([bar])
   1003 AC_CONFIG_FILES([Foo])
   1004 AC_PROG_AWK
   1005 AC_OUTPUT
   1006 ]])
   1007 
   1008 cp "$abs_top_srcdir/build-aux/install-sh" .
   1009 
   1010 echo 'one
   1011 two
   1012 %!_!# ''
   1013 x' >expout
   1014 
   1015 AT_CHECK_AUTOCONF
   1016 # Check both awk and the result of AC_PROG_AWK
   1017 # Quote the first word in the for list for Solaris sh.
   1018 for awk_arg in "FOO=" AWK=awk; do
   1019   AT_CHECK_CONFIGURE([$awk_arg])
   1020   AT_CHECK([cat Foo], 0, [expout])
   1021 done
   1022 AT_CLEANUP
   1023 
   1024 
   1025 ## ------------------ ##
   1026 ## Define a newline.  ##
   1027 ## ------------------ ##
   1028 
   1029 AT_SETUP([Define a newline])
   1030 AT_KEYWORDS([AC@&t@_DEFINE AC@&t@_DEFINE_UNQUOTED])
   1031 AT_CONFIGURE_AC([[AC_DEFINE([foo], [one
   1032 two], [This spans two lines.])
   1033 ]])
   1034 AT_CHECK_AUTOCONF([], [], [], [stderr])
   1035 dnl Older versions of m4 report error at line 5 (end of macro);
   1036 dnl newer versions report it at line 4 (start of macro).
   1037 AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
   1038 [[warning: AC_DEFINE: `one
   1039 two' is not a valid preprocessor define value
   1040 ]])
   1041 AT_CHECK_AUTOHEADER([], [], [], [stderr])
   1042 AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
   1043 [[warning: AC_DEFINE: `one
   1044 two' is not a valid preprocessor define value
   1045 ]])
   1046 AT_CHECK_CONFIGURE
   1047 AT_CHECK_DEFINES([[#define foo one
   1048 ]])
   1049 
   1050 AT_CONFIGURE_AC([[AC_DEFINE_UNQUOTED([foo], [one
   1051 two], [This spans two lines.])
   1052 ]])
   1053 AT_CHECK_AUTOCONF([], [], [], [stderr])
   1054 AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
   1055 [[warning: AC_DEFINE_UNQUOTED: `one
   1056 two' is not a valid preprocessor define value
   1057 ]])
   1058 AT_CHECK_AUTOHEADER([], [], [], [stderr])
   1059 AT_CHECK([[sed 's/^configure.ac:[45]: //' stderr]], [],
   1060 [[warning: AC_DEFINE_UNQUOTED: `one
   1061 two' is not a valid preprocessor define value
   1062 ]])
   1063 AT_CHECK_CONFIGURE
   1064 AT_CHECK_DEFINES([[#define foo one
   1065 ]])
   1066 
   1067 AT_CLEANUP
   1068 
   1069 
   1070 ## ------------------------------------ ##
   1071 ## AC_SUBST: variable name validation.  ##
   1072 ## ------------------------------------ ##
   1073 
   1074 AT_SETUP([AC_SUBST: variable name validation])
   1075 
   1076 AT_CONFIGURE_AC([[AC_SUBST(, [])
   1077 AC_CONFIG_FILES([Makefile])
   1078 ]])
   1079 AT_DATA([Makefile.in], [[
   1080 ]])
   1081 mv -f configure.ac configure.tmpl
   1082 
   1083 # Invalid names.
   1084 for var in ['' ab\~ ab\( ab[] ab\' ab\" ab\\\\]; do
   1085   sed ["s/AC_SUBST(/&[$var]/"] <configure.tmpl >configure.ac
   1086   AT_CHECK_AUTOCONF([], [1], [], [ignore])
   1087 done
   1088 
   1089 # Valid names.
   1090 for var in ab a4 'a@@&t@\&t@b'; do
   1091   sed ["s/AC_SUBST(/&[$var]/"] <configure.tmpl >configure.ac
   1092   AT_CHECK_AUTOCONF
   1093   AT_CHECK_AUTOHEADER
   1094   AT_CHECK_CONFIGURE
   1095 done
   1096 
   1097 AT_CLEANUP
   1098 
   1099 
   1100 ## ------------------------ ##
   1101 ## datarootdir workaround.  ##
   1102 ## ------------------------ ##
   1103 
   1104 AT_SETUP([datarootdir workaround])
   1105 
   1106 AT_DATA([Foo.in],
   1107 [@datadir@
   1108 @docdir@
   1109 @infodir@
   1110 @localedir@
   1111 @mandir@
   1112 ])
   1113 
   1114 AT_DATA([Bar.in],
   1115 [@mydatadir@
   1116 ])
   1117 
   1118 AT_DATA([configure.ac],
   1119 [[AC_INIT
   1120 d@&t@nl The following line silences the warnings, if uncommented:
   1121 d@&t@nl AC_DEFUN([AC_DATAROOTDIR_CHECKED])
   1122 
   1123 # This substitution is wrong and bogus!  Don't use it in your own code!
   1124 # Read `info Autoconf "Defining Directories"'!
   1125 AC_SUBST([mydatadir], [${datadir}/my])
   1126 
   1127 AC_CONFIG_FILES([Foo Bar])
   1128 AC_OUTPUT
   1129 ]])
   1130 
   1131 cp "$abs_top_srcdir/build-aux/install-sh" .
   1132 
   1133 AT_CHECK_AUTOCONF
   1134 AT_CHECK_CONFIGURE([], [], [],
   1135   [config.status: WARNING:  'Foo.in' seems to ignore the --datarootdir setting
   1136 config.status: WARNING: Bar contains a reference to the variable `datarootdir'
   1137 which seems to be undefined.  Please make sure it is defined
   1138 ])
   1139 AT_CHECK([grep datarootdir Foo], 1, [])
   1140 
   1141 rm configure
   1142 sed '/AC_DEFUN/s/^d@&t@nl //' configure.ac >t
   1143 mv t configure.ac
   1144 
   1145 AT_CHECK_AUTOCONF
   1146 AT_CHECK_CONFIGURE
   1147 
   1148 AT_CLEANUP
   1149 
   1150 
   1151 ## -------- ##
   1152 ## srcdir.  ##
   1153 ## -------- ##
   1154 
   1155 AT_SETUP([srcdir])
   1156 
   1157 rm -f -r at-dir
   1158 mkdir at-dir
   1159 : >at-dir/bar.in
   1160 : >foo.in
   1161 
   1162 AT_DATA([configure.ac],
   1163 [[AC_INIT
   1164 
   1165 AC_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.
   1170 AC_CONFIG_COMMANDS([report],
   1171 [test -f "$srcdir/configure.ac" ||
   1172    AC_MSG_ERROR([cannot find $srcdir/configure.ac])],
   1173 		   [srcdir='$srcdir'])
   1174 
   1175 AC_OUTPUT
   1176 rm -f -r foo at-dir/bar
   1177 ]])
   1178 
   1179 AT_CHECK_AUTOCONF
   1180 
   1181 # In place.
   1182 AT_CHECK([./configure $configure_options], [], [ignore])
   1183 
   1184 # Relative name.
   1185 AT_CHECK([cd at-dir && ../configure $configure_options], [], [ignore])
   1186 
   1187 # Absolute name.
   1188 at_here=`pwd`
   1189 AT_CHECK([cd at-dir && "$at_here/configure" $configure_options], [], [ignore])
   1190 
   1191 AT_CLEANUP
   1192 
   1193 
   1194 ## ------- ##
   1195 ## VPATH.  ##
   1196 ## ------- ##
   1197 
   1198 AT_SETUP([VPATH])
   1199 
   1200 dirs='at paren brace space'
   1201 for dir in $dirs; do
   1202   mkdir $dir $dir/s1 $dir/s2
   1203   touch $dir/f $dir/s1/f1 $dir/s2/f2
   1204 done
   1205 
   1206 AT_DATA([configure.ac],
   1207 [[AC_INIT
   1208 AC_CONFIG_FILES([at/Makefile paren/Makefile brace/Makefile space/Makefile])
   1209 AC_OUTPUT
   1210 ]])
   1211 
   1212 AT_DATA([at/Makefile.in],
   1213 [[# This is what you should use in order to be portable to old makes.
   1214 srcdir = @srcdir@
   1215 VPATH = @srcdir@/s1:@srcdir@:@srcdir@/s2
   1216 all: f f1 f2
   1217 	@echo ok
   1218 ]])
   1219 
   1220 AT_DATA([paren/Makefile.in],
   1221 [[# This works with some makes but not with old ones.
   1222 srcdir = @srcdir@
   1223 VPATH = $(srcdir)/s1:$(srcdir):$(srcdir)/s2
   1224 all: f f1 f2
   1225 	@echo ok
   1226 ]])
   1227 
   1228 AT_DATA([brace/Makefile.in],
   1229 [[# This works with some makes but not with old ones.
   1230 srcdir = @srcdir@
   1231 VPATH = ${srcdir}/s1:${srcdir}:${srcdir}/s2
   1232 all: f f1 f2
   1233 	@echo ok
   1234 ]])
   1235 
   1236 AT_DATA([space/Makefile.in],
   1237 [[# This fails with FreeBSD make, for example.
   1238 srcdir = @srcdir@
   1239 VPATH = @srcdir@/s1 @srcdir@ @srcdir@/s2
   1240 all: f f1 f2
   1241 	@echo ok
   1242 ]])
   1243 
   1244 AT_CHECK_AUTOCONF
   1245 
   1246 : "${MAKE=make}"
   1247 
   1248 # In place.
   1249 AT_CHECK([./configure $configure_options], [], [ignore])
   1250 # Treat BSD make separately, afterwards, for maximal coverage.
   1251 dirs='at paren brace'
   1252 for dir in $dirs; do
   1253   AT_CHECK([cd $dir && $MAKE], [], [ignore], [ignore])
   1254 done
   1255 
   1256 rm -f config.status
   1257 mkdir build absbuild
   1258 
   1259 # Relative name.
   1260 AT_CHECK([cd build && ../configure $configure_options], [], [ignore])
   1261 for dir in $dirs; do
   1262   AT_CHECK([cd build/$dir && $MAKE], [], [ignore], [ignore])
   1263 done
   1264 
   1265 # Absolute name.
   1266 at_here=`pwd`
   1267 AT_CHECK([cd absbuild && "$at_here/configure" $configure_options], [], [ignore])
   1268 for dir in $dirs; do
   1269   AT_CHECK([cd absbuild/$dir && $MAKE], [], [ignore], [ignore])
   1270 done
   1271 
   1272 # These will not pass with BSD make.
   1273 AT_CHECK([cd space && { $MAKE || exit 77; }], [], [ignore], [ignore])
   1274 AT_CHECK([cd build/space && $MAKE], [], [ignore], [ignore])
   1275 AT_CHECK([cd absbuild/space && $MAKE], [], [ignore], [ignore])
   1276 
   1277 AT_CLEANUP
   1278 
   1279 
   1280 ## ----------------- ##
   1281 ## Signal handling.  ##
   1282 ## ----------------- ##
   1283 
   1284 AT_SETUP([Signal handling])
   1285 
   1286 AT_DATA([configure.ac],
   1287 [[AC_INIT
   1288 kill -2 $$
   1289 exit 77
   1290 ]])
   1291 
   1292 AT_CHECK_AUTOCONF
   1293 AT_CHECK_CONFIGURE([], 1, ignore, ignore)
   1294 
   1295 AT_CLEANUP
   1296 
   1297 
   1298 ## ----------------- ##
   1299 ## AC_CONFIG_LINKS.  ##
   1300 ## ----------------- ##
   1301 
   1302 AT_SETUP([AC_CONFIG_LINKS])
   1303 
   1304 AT_DATA([configure.ac],
   1305 [[AC_INIT([config links to config files test], [1.0])
   1306 AC_CONFIG_SRCDIR([sub1/file1.in])
   1307 AC_CONFIG_FILES([sub1/file1 file2])
   1308 AC_CONFIG_LINKS([file1:sub1/file1 sub2/file2:file2])
   1309 AC_OUTPUT
   1310 ]])
   1311 
   1312 mkdir sub1
   1313 
   1314 AT_DATA([sub1/file1.in],
   1315 [[/* @configure_input@ */
   1316 #define PACKAGE_STRING "@PACKAGE_STRING@"
   1317 ]])
   1318 
   1319 AT_DATA([file2.in],
   1320 [[/* @configure_input@ */
   1321 #define PACKAGE_STRING "@PACKAGE_STRING@"
   1322 ]])
   1323 
   1324 mkdir build
   1325 AT_CHECK_AUTOCONF
   1326 cd build
   1327 AT_CHECK([../configure && ../configure], 0, [ignore])
   1328 AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
   1329 ])
   1330 AT_CHECK([../configure && ../configure], 0, [ignore])
   1331 AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
   1332 ])
   1333 cd ..
   1334 rm -rf build
   1335 mkdir build
   1336 cd build
   1337 cwd=`pwd`
   1338 AT_CHECK(["$cwd"/../configure && "$cwd"/../configure], 0, [ignore])
   1339 AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
   1340 ])
   1341 cd ..
   1342 AT_CHECK([./configure && ./configure], 0, [ignore], [stderr])
   1343 AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
   1344 ])
   1345 cwd=`pwd`
   1346 AT_CHECK(["$cwd"/configure && "$cwd"/configure], 0, [ignore], [ignore])
   1347 AT_CHECK([cat sub1/file1 sub2/file2 | grep -c "config links"], 0, [2
   1348 ])
   1349 
   1350 AT_CLEANUP
   1351 
   1352 
   1353 ## ------------------------------------- ##
   1354 ## AC_CONFIG_LINKS and identical files.  ##
   1355 ## ------------------------------------- ##
   1356 AT_SETUP([AC_CONFIG_LINKS and identical files])
   1357 
   1358 AT_DATA([configure.ac],
   1359 [[AC_INIT
   1360 AC_CONFIG_LINKS([src/s:src/s])
   1361 test "$srcdir" != '.' && AC_CONFIG_LINKS([src/t:src/t])
   1362 AC_OUTPUT
   1363 ]])
   1364 
   1365 mkdir src build
   1366 echo file1 > src/s
   1367 echo file2 > src/t
   1368 AT_CHECK_AUTOCONF
   1369 cd build
   1370 AT_CHECK([../configure $configure_options && ../configure $configure_options],
   1371 	 0, [ignore])
   1372 AT_CHECK([cat src/s src/t], 0, [file1
   1373 file2
   1374 ])
   1375 
   1376 cd ..
   1377 rm -rf build
   1378 mkdir build
   1379 cd build
   1380 cwd=`pwd`
   1381 AT_CHECK(["$cwd"/../configure], 0, [ignore])
   1382 AT_CHECK([cat src/s src/t], 0, [file1
   1383 file2
   1384 ])
   1385 AT_CHECK(["$cwd"/../configure], 0, [ignore])
   1386 AT_CHECK([cat src/s src/t], 0, [file1
   1387 file2
   1388 ])
   1389 cd ..
   1390 AT_CHECK([./configure $configure_options && ./configure $configure_options],
   1391 	 0, [ignore], [stderr])
   1392 AT_CHECK([grep src/t stderr], 1)
   1393 AT_CHECK([cat src/s src/t], 0, [file1
   1394 file2
   1395 ])
   1396 cwd=`pwd`
   1397 AT_CHECK(["$cwd"/configure && "$cwd"/configure], 0, [ignore], [ignore])
   1398 AT_CHECK([cat src/s src/t], 0, [file1
   1399 file2
   1400 ])
   1401 
   1402 AT_CLEANUP
   1403 
   1404 
   1405 AT_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 #
   1429 AT_SETUP([Configuring subdirectories])
   1430 AT_KEYWORDS(autoreconf)
   1431 
   1432 # We use aclocal (via autoreconf).
   1433 AT_CHECK([aclocal --version || exit 77], [], [stdout], [ignore])
   1434 AT_CHECK([[grep '[1-9]\.[0-9]' stdout || exit 77]], [], [ignore])
   1435 
   1436 # It should understand configure.ac.
   1437 AT_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'.
   1441 CONFIG_SITE=no-such-file
   1442 export CONFIG_SITE
   1443 
   1444 # The contents of `inner/', and `inner/innermost/'.
   1445 AS_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.
   1450 AT_DATA([inner/configure.in],
   1451 [[AC_INIT(GNU Inner, 1.0)
   1452 AC_CONFIG_SRCDIR([innermost/config.in])
   1453 AC_ARG_VAR([INNER], [an inner variable])
   1454 AC_SUBST([INNER])
   1455 if test "x$INNER" = x; then
   1456   INNER=inner
   1457 fi
   1458 AC_CONFIG_FILES([innermost/config])
   1459 AC_OUTPUT
   1460 ]])
   1461 
   1462 AT_DATA([inner/innermost/config.in],
   1463 [INNER=@INNER@
   1464 srcdir=@srcdir@
   1465 top_srcdir=@top_srcdir@
   1466 prefix=@prefix@
   1467 ])
   1468 
   1469 # The contents of `.'
   1470 AT_DATA([install-sh], [])
   1471 
   1472 # nonexistent is allowed not to exist.
   1473 AT_DATA([configure.in],
   1474 [[AC_INIT(GNU Outer, 1.0)
   1475 AC_ARG_VAR([OUTER], [an outer variable])
   1476 if false; then
   1477   AC_CONFIG_SUBDIRS([nonexistent])
   1478 fi
   1479 AC_CONFIG_SUBDIRS([inner])
   1480 AC_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.
   1485 AT_CHECK([autoreconf], [], [], [ignore])
   1486 AT_CHECK([test -f inner/configure])
   1487 
   1488 # Running the outer configure recursively should provide the innermost
   1489 # help strings.
   1490 chmod a-w inner/innermost inner .
   1491 AT_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])])
   1494 chmod u+w . inner inner/innermost
   1495 
   1496 # Running the outer configure should trigger the inner.
   1497 AT_CHECK_CONFIGURE
   1498 AT_CHECK([cat inner/innermost/config], 0,
   1499 [INNER=inner
   1500 srcdir=.
   1501 top_srcdir=..
   1502 prefix=/usr/local
   1503 ])
   1504 
   1505 # The same, but from a builddir.
   1506 AS_MKDIR_P([builddir])
   1507 AT_CHECK([cd builddir && ../configure $configure_options], 0, [ignore])
   1508 AT_CHECK([cat builddir/inner/innermost/config], 0,
   1509 [INNER=inner
   1510 srcdir=../../../inner/innermost
   1511 top_srcdir=../../../inner
   1512 prefix=/usr/local
   1513 ])
   1514 
   1515 # Make sure precious variables and command line options are properly
   1516 # passed, even when there are duplicates.
   1517 AT_CHECK([cd builddir && ../configure $configure_options --prefix /bad --prefix /good INNER=bad INNER=good],
   1518 	 0, [ignore])
   1519 AT_CHECK([cat builddir/inner/innermost/config], 0,
   1520 [INNER=good
   1521 srcdir=../../../inner/innermost
   1522 top_srcdir=../../../inner
   1523 prefix=/good
   1524 ])
   1525 
   1526 # Make sure --prefix is properly quoted
   1527 AT_CHECK([cd builddir && ../configure --prefix "/a  b c$ 'd"], 0, [ignore])
   1528 AT_CHECK([cat builddir/inner/innermost/config], 0,
   1529 [INNER=inner
   1530 srcdir=../../../inner/innermost
   1531 top_srcdir=../../../inner
   1532 prefix=/a  b c$ 'd
   1533 ])
   1534 
   1535 # Make sure --silent is properly passed...
   1536 AT_CHECK([cd builddir && ../configure $configure_options --silent], 0, [])
   1537 # ...but not stored in config.status.
   1538 AT_CHECK([cd builddir && ./config.status --recheck], 0, [stdout])
   1539 AT_CHECK([grep 'creating \./config.status' stdout], 0, [ignore])
   1540 
   1541 # --cache-file is adjusted for subdirectories, so the cache is shared.
   1542 AT_CHECK([cd builddir && ../configure $configure_options --config-cache],
   1543 	 [], [stdout])
   1544 AT_CHECK([grep 'loading .*\.\./config.cache' stdout], [], [ignore])
   1545 
   1546 # Make sure we can run autoreconf on a subdirectory
   1547 rm -f configure configure.in
   1548 AT_CHECK([autoreconf inner], [], [], [ignore])
   1549 
   1550 # Make sure we can pass a configure.ac name
   1551 AT_CHECK([cd inner && autoreconf configure.in], [], [], [ignore])
   1552 AT_CHECK([autoreconf inner/configure.in], [], [], [ignore])
   1553 
   1554 AT_CLEANUP
   1555 
   1556 
   1557 
   1558 ## -------------- ##
   1559 ## Deep Package.  ##
   1560 ## -------------- ##
   1561 
   1562 AT_SETUP([Deep Package])
   1563 AT_KEYWORDS(autoreconf)
   1564 
   1565 # We use aclocal (via autoreconf).
   1566 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
   1567 
   1568 # The contents of `.'
   1569 AT_DATA([install-sh], [])
   1570 AT_DATA([configure.in],
   1571 [[AC_INIT(GNU Outer, 1.0)
   1572 AC_ARG_VAR([OUTER], [an outer variable])
   1573 AC_CONFIG_SUBDIRS([
   1574   inner
   1575   inner2
   1576 ])
   1577 AC_OUTPUT
   1578 ]])
   1579 
   1580 # The contents of `inner/', and `inner/innermost/'.
   1581 AS_MKDIR_P([inner/innermost])
   1582 AS_MKDIR_P([inner2])
   1583 
   1584 AT_DATA([inner/configure.in],
   1585 [[AC_INIT(GNU Inner, 1.0)
   1586 AC_ARG_VAR([INNER], [an inner variable])
   1587 AC_CONFIG_SUBDIRS(innermost)
   1588 AC_OUTPUT
   1589 ]])
   1590 
   1591 AT_DATA([inner/innermost/configure.in],
   1592 [[AC_INIT(GNU Innermost, 1.0)
   1593 AC_ARG_VAR([INNERMOST], [an innermost variable])
   1594 AC_CONFIG_HEADERS(config.h:config.hin)
   1595 AC_DEFINE_UNQUOTED([INNERMOST], [$INNERMOST], [an innermost variable])
   1596 if test -n "$innermost_error"; then
   1597   AC_MSG_FAILURE([error in $PACKAGE_NAME])
   1598 fi
   1599 AC_OUTPUT
   1600 ]])
   1601 
   1602 AT_DATA([inner2/configure.in],
   1603 [[AC_INIT(GNU Inner 2, 1.0)
   1604 AC_ARG_VAR([INNER2], [an inner2 variable])
   1605 AC_OUTPUT
   1606 ]])
   1607 
   1608 AT_CHECK([autoreconf -Wall -v], [0], [ignore], [stderr])
   1609 # We should not warn about nonliteral argument to AC_CONFIG_SUBDIRS here.
   1610 AT_CHECK([grep 'AC_CONFIG_SUBDIRS:.*literals' stderr], [1])
   1611 AT_CHECK([test -f inner/configure])
   1612 AT_CHECK([test -f inner/innermost/configure])
   1613 AT_CHECK([test -f inner/innermost/config.hin])
   1614 AT_CHECK([test -f inner2/configure])
   1615 
   1616 # Running the outer configure recursively should provide the innermost
   1617 # help strings.
   1618 chmod a-w inner/innermost inner
   1619 AT_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])])
   1622 chmod a-w .
   1623 AT_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])])
   1626 chmod a-w .
   1627 AT_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])])
   1630 chmod a-w .
   1631 AT_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])])
   1634 chmod a-w .
   1635 AT_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])])
   1638 chmod a-w .
   1639 AT_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])])
   1642 chmod u+w inner inner/innermost
   1643 
   1644 # Running the outer configure should trigger the inner.
   1645 AT_CHECK_CONFIGURE([INNERMOST=tsomrenni])
   1646 AT_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.
   1651 AT_CHECK_CONFIGURE([innermost_error=:], [1], [], [stderr])
   1652 AT_CHECK([grep 'inner/innermost' stderr], [], [ignore])
   1653 cd inner
   1654 AT_CHECK_CONFIGURE([innermost_error=:], [1], [], [stderr])
   1655 AT_CHECK([grep 'innermost' stderr], [], [ignore])
   1656 cd ..
   1657 
   1658 # The same, but from a builddir.
   1659 AS_MKDIR_P([builddir])
   1660 chmod a-w builddir inner/innermost inner
   1661 AT_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])])
   1664 chmod a-w builddir
   1665 AT_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])])
   1668 chmod a-w builddir
   1669 AT_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])])
   1672 chmod a-w builddir
   1673 AT_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])])
   1676 chmod a-w builddir
   1677 # Not all shells search $PATH for scripts.
   1678 if (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])
   1680 fi
   1681 AT_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])])
   1684 chmod u+w builddir inner inner/innermost
   1685 AT_CHECK([cd builddir && ../configure $configure_options INNERMOST=build/tsomrenni], 0, [ignore])
   1686 AT_CHECK([grep INNERMOST builddir/inner/innermost/config.h], 0,
   1687 [[#define INNERMOST build/tsomrenni
   1688 ]])
   1689 
   1690 AT_CLEANUP
   1691 
   1692 
   1693 
   1694 ## -------------------------------- ##
   1695 ## Non-Autoconf AC_CONFIG_SUBDIRS.  ##
   1696 ## -------------------------------- ##
   1697 
   1698 AT_SETUP([Non-Autoconf AC_CONFIG_SUBDIRS])
   1699 AT_KEYWORDS([autoreconf])
   1700 
   1701 # We use aclocal (via autoreconf).
   1702 AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore])
   1703 
   1704 AT_DATA([install-sh], [])
   1705 AT_DATA([configure.in],
   1706 [[AC_INIT(GNU Outer, 1.0)
   1707 AC_CONFIG_SUBDIRS([inner])
   1708 AC_OUTPUT
   1709 ]])
   1710 
   1711 AS_MKDIR_P([inner])
   1712 
   1713 AT_DATA([inner/configure],
   1714 [[#! /bin/sh
   1715 case "$*" in
   1716     *--help*) echo 'No Autoconf here, folks!' ;;
   1717     *)        echo got_it >myfile ;;
   1718 esac
   1719 exit 0
   1720 ]])
   1721 chmod +x inner/configure
   1722 
   1723 AT_CHECK([autoreconf -Wall -v], 0, [ignore], [ignore])
   1724 
   1725 # Running the outer configure recursively should provide the innermost
   1726 # help strings.
   1727 AT_CHECK([./configure $configure_options --help=recursive | grep "folks"], 0, [ignore])
   1728 
   1729 # Running the outer configure should trigger the inner.
   1730 AT_CHECK([./configure $configure_options], 0, [ignore])
   1731 AT_CHECK([test -f inner/myfile], 0)
   1732 
   1733 AT_CLEANUP
   1734 
   1735 
   1736 ## ------------------------------- ##
   1737 ## Non-literal AC_CONFIG_SUBDIRS.  ##
   1738 ## ------------------------------- ##
   1739 
   1740 AT_SETUP([Non-literal AC_CONFIG_SUBDIRS])
   1741 AT_KEYWORDS([autoreconf])
   1742 
   1743 AT_DATA([install-sh], [])
   1744 AT_DATA([configure.in],
   1745 [[AC_INIT(GNU Outer, 1.0)
   1746 
   1747 my_subdirs=
   1748 # Taken from autoconf.texi:Subdirectories.
   1749 if test "x$package_foo_enabled" = xyes; then
   1750   my_subdirs="$my_subdirs foo"
   1751 fi
   1752 AC_CONFIG_SUBDIRS([$my_subdirs])
   1753 AC_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*.
   1759 AT_DATA([aclocal.m4])
   1760 
   1761 AS_MKDIR_P([foo])
   1762 
   1763 AT_DATA([foo/configure],
   1764 [[#! /bin/sh
   1765 touch innerfile
   1766 exit 0
   1767 ]])
   1768 chmod +x foo/configure
   1769 
   1770 # autoreconf should warn without -Wno-syntax, but should not fail without -Werror.
   1771 AT_CHECK([autoreconf -Werror -v], [1], [ignore], [stderr])
   1772 AT_CHECK([grep 'AC_CONFIG_SUBDIRS:.*literals' stderr], [0], [ignore])
   1773 AT_CHECK([autoreconf -v], [0], [ignore], [stderr])
   1774 AT_CHECK([grep 'AC_CONFIG_SUBDIRS:.*literals' stderr], [0], [ignore])
   1775 AT_CHECK([autoreconf -v --force -Wno-syntax], 0, [ignore], [stderr])
   1776 AT_CHECK([grep 'AC_CONFIG_SUBDIRS:.*literals' stderr], [1])
   1777 
   1778 AT_CHECK([./configure $configure_options], [0], [ignore])
   1779 AT_CHECK([test ! -f foo/innerfile])
   1780 # Running the outer configure should trigger the inner.
   1781 AT_CHECK([./configure $configure_options package_foo_enabled=yes], [0], [ignore])
   1782 AT_CHECK([test -f foo/innerfile])
   1783 
   1784 AT_CLEANUP
   1785 
   1786 
   1787 ## ----------------- ##
   1788 ## Empty directory.  ##
   1789 ## ----------------- ##
   1790 
   1791 AT_SETUP([Empty directory])
   1792 AT_KEYWORDS([autoreconf])
   1793 
   1794 # We use aclocal (via autoreconf).
   1795 AT_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 
   1800 AT_CHECK([autoreconf -Wall -v], 1, [ignore], [ignore])
   1801 
   1802 AT_CLEANUP
   1803 
   1804 
   1805 
   1806 ## ------------------------------ ##
   1807 ## Unusual Automake input files.  ##
   1808 ## ------------------------------ ##
   1809 
   1810 # This parallels gnumake.test in Automake.
   1811 
   1812 AT_SETUP([Unusual Automake input files])
   1813 AT_KEYWORDS([autoreconf])
   1814 
   1815 # We use aclocal and automake via autoreconf.
   1816 AT_CHECK([automake --version || exit 77], [], [stdout], [ignore])
   1817 AT_CHECK([[grep '[1-9]\.[0-9]' stdout || exit 77]], [], [ignore])
   1818 
   1819 AT_DATA([configure.in],
   1820 [[AC_INIT(GNU foo, 1.0)
   1821 AM_INIT_AUTOMAKE
   1822 AC_CONFIG_FILES([HeeHee])
   1823 AC_OUTPUT
   1824 ]])
   1825 
   1826 AT_DATA([HeeHee.am],
   1827 [[# Humans do no worse than `GNUmakefile.am'.
   1828 AUTOMAKE_OPTIONS = foreign 1.8
   1829 ]])
   1830 
   1831 AT_CHECK([autoreconf -Wall -v -i], 0, [ignore], [stderr],
   1832 	 [AT_CHECK([grep 'require.*1\.8' stderr && exit 77], [1])])
   1833 AT_CHECK([test -f HeeHee.in])
   1834 
   1835 AT_CLEANUP
   1836