1# -*- Autotest -*- 2 3AT_BANNER([Executables (autoheader, autoupdate...).]) 4 5# Copyright (C) 2000-2001, 2003-2004, 2006-2012 Free Software 6# Foundation, Inc. 7# 8# This program is free software: you can redistribute it and/or modify 9# it under the terms of the GNU General Public License as published by 10# the Free Software Foundation, either version 3 of the License, or 11# (at your option) any later version. 12# 13# This program is distributed in the hope that it will be useful, 14# but WITHOUT ANY WARRANTY; without even the implied warranty of 15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16# GNU General Public License for more details. 17# 18# You should have received a copy of the GNU General Public License 19# along with this program. If not, see <http://www.gnu.org/licenses/>. 20 21 22## ----------------------------- ## 23## Syntax of the shell scripts. ## 24## ----------------------------- ## 25 26# We use `/bin/sh -n script' to check that there are no syntax errors 27# in the scripts. Although incredible, there are /bin/sh that go into 28# endless loops with `-n', e.g., SunOS's: 29# 30# $ uname -a 31# SunOS ondine 4.1.3 2 sun4m unknown 32# $ cat endless.sh 33# while false 34# do 35# : 36# done 37# exit 0 38# $ time sh endless.sh 39# sh endless.sh 0,02s user 0,03s system 78% cpu 0,064 total 40# $ time sh -nx endless.sh 41# ^Csh -nx endless.sh 3,67s user 0,03s system 63% cpu 5,868 total 42# 43# So before using `/bin/sh -n' to check our scripts, we first check 44# that `/bin/sh -n' is not broken to death. 45 46AT_SETUP([Syntax of the shell scripts]) 47 48AT_CHECK([test "$ac_cv_sh_n_works" = yes || exit 77]) 49 50# Specify the absolute name of the tool, as some shells don't honor PATH when 51# running `sh PROG'. 52 53AT_CHECK_SHELL_SYNTAX(["$abs_top_builddir/bin/autoconf"]) 54AT_CHECK_SHELL_SYNTAX(["$abs_top_builddir/tests/autoconf"]) 55AT_CHECK_SHELL_SYNTAX(["$abs_top_builddir/tests/testsuite"]) 56 57# These are not built, they are in the src tree. 58AT_CHECK_SHELL_SYNTAX(["$abs_top_srcdir/build-aux/install-sh"]) 59AT_CHECK_SHELL_SYNTAX(["$abs_top_srcdir/build-aux/missing"]) 60 61AT_CLEANUP 62 63 64 65 66## ---------------------------- ## 67## Syntax of the Perl scripts. ## 68## ---------------------------- ## 69 70AT_SETUP([Syntax of the Perl scripts]) 71 72AT_CHECK_PERL_SYNTAX([autoheader]) 73AT_CHECK_PERL_SYNTAX([autom4te]) 74AT_CHECK_PERL_SYNTAX([autoreconf]) 75AT_CHECK_PERL_SYNTAX([autoscan]) 76AT_CHECK_PERL_SYNTAX([autoupdate]) 77AT_CHECK_PERL_SYNTAX([ifnames]) 78 79AT_CLEANUP 80 81 82 83 84## ------------------ ## 85## autom4te's cache. ## 86## ------------------ ## 87 88AT_SETUP([autom4te cache]) 89 90AT_DATA_M4SUGAR([[script.4s]], 91[[m4_include([foo]) 92]]) 93 94# Everything is OK. 95touch foo 96AT_CHECK_M4SUGAR 97 98# We moved a file: it should fail 99mkdir sub 100mv foo sub 101AT_CHECK_M4SUGAR([], [1], [], 102[m4:script.4s:1: cannot open `foo': No such file or directory 103autom4te: m4 failed with exit status: 1 104]) 105 106# But if we change the main file, then we should no longer complain of 107# missing files. 108AT_DATA_M4SUGAR([[script.4s]], 109[[m4_include([sub/foo]) 110]]) 111AT_CHECK_M4SUGAR 112 113AT_CLEANUP 114 115 116# autom4te --force 117# ---------------- 118 119AT_SETUP([autom4te --force]) 120 121AT_DATA([file.m4], 122[[right 123]]) 124AT_CHECK_AUTOM4TE([-o file file.m4]) 125 126# Create a file whose time stamp is in the future. 127# (next year)-01-01 00:01 UTC should always be in the future, 128# even on slow machines. 129echo BAD >file 130this_year=`TZ=UTC0 date +%Y` 131AS_VAR_ARITH([next_year], [$this_year + 1]) 132TZ=UTC0 touch -t ${next_year}01010001 file 133 134AT_CHECK_AUTOM4TE([--force -o file file.m4]) 135AT_CHECK([cat file], 0, 136[[right 137]]) 138 139AT_CLEANUP 140 141 142# autom4te and file names containing whitespace 143# --------------------------------------------- 144 145AT_SETUP([autom4te and whitespace in file names]) 146 147x= 148export x 149rm -f a b 150for funny in \ 151 'with funny '\'' $x & #! name' \ 152 'with funny \ '\'' \'\'' " <a >b * ? name ' # "restore font-lock 153do 154 funny=`func_sanitize_file_name "$funny"` 155 file=" file $funny" 156 outfile="$file out " 157 dir=`func_sanitize_dir_name " dir $funny"` 158 cachedir=" cache$dir" 159 TMPDIR=" tmp$dir" 160 export TMPDIR 161 162 # skip if we cannot create such a file or directory 163 AT_CHECK([mkdir "$dir" "$cachedir" "$TMPDIR" && touch "$file" || exit 77]) 164 165 cat >"$file" <<'END' 166[m4@&t@_init[]m4@&t@_include(foo.m4) 167m4@&t@_divert([])d@&t@nl 168FOO] 169END 170 cat >"$dir"/foo.m4 <<'END' 171[m4@&t@_define([FOO], [bar])] 172END 173 174 AT_CHECK_AUTOM4TE([-C "$cachedir" -B "$dir" --language=m4sugar -o "$outfile" "$file"]) 175 AT_CHECK([cat "$outfile"], [], 176 [[bar 177]]) 178 rm -rf "$outfile" "$cachedir" 179 AT_CHECK_AUTOM4TE([-C "$cachedir" -I "$dir" --language=m4sugar -o "$outfile" "$file"]) 180 AT_CHECK([cat "$outfile"], [], 181 [[bar 182]]) 183 184 # This exercises a slightly different code path and will catch an open with 185 # trailing whitespace: 186 cat >"$file" <<'END' 187[m4@&t@_init[]m4@&t@_include(foo.m4) 188m4@&t@_pattern_forbid([^bar$]) 189m4@&t@_divert([])d@&t@nl 190FOO] 191END 192 rm -rf "$outfile" "$cachedir" 193 AT_CHECK_AUTOM4TE([-C "$cachedir" -I "$dir" --language=m4sugar -o "$outfile" "$file"], 194 [1], [], [stderr]) 195 AT_CHECK([grep 'possibly undefined macro' stderr], [], [ignore]) 196 197 cat >"$file" <<'END' 198[m4@&t@_init[]m4@&t@_include(foo.m4) 199m4@&t@_divert([])d@&t@nl] 200END 201 rm -rf "$file.m4f" 202 AT_CHECK_AUTOM4TE([-C "$cachedir" -I "$dir" --language=m4sugar --freeze -o "$file.m4f" "$file"]) 203 AT_CHECK([test -s "$file.m4f"]) 204 205 # Check --reload-state 206 AT_CHECK_AUTOM4TE([-C "$cachedir" --language=m4sugar -o "$outfile" "$file.m4f" /dev/null]) 207 208 test ! -f b 209done 210 211AT_CLEANUP 212 213 214# autom4te --trace and unusual macro names 215# ---------------------------------------- 216 217AT_SETUP([autom4te --trace and unusual macro names]) 218 219AT_DATA([file.m4], 220[[ 221]]) 222AT_CHECK_AUTOM4TE([-t 'TR A CE' -t 'TR(A)CE' file.m4]) 223 224AT_CLEANUP 225 226 227AT_SETUP([autom4te --trace and whitespace]) 228 229dnl line numbering differs between m4 1.4.6 and 1.4.13 if we don't 230dnl go through a single line wrapper 231AT_DATA_M4SUGAR([file.m4], 232[[m4_define([foo], [m4_echo([ a 233b c ], [\ 234d\ 235])]) 236foo 237]]) 238AT_CHECK_AUTOM4TE([--language=m4sugar -t 'm4@&t@_echo' file.m4], [0], 239[[file.m4:5:m4@&t@_echo: a b c :d 240]]) 241 242AT_CLEANUP 243 244 245## ------------------ ## 246## autoconf --trace. ## 247## ------------------ ## 248 249 250# autoconf --trace: user macros 251# ----------------------------- 252AT_SETUP([autoconf --trace: user macros]) 253 254AT_DATA([configure.ac], 255[[m4_define([active], [ACTIVE]) 256m4_define([TRACE1], [TRACE2(m4_shift($@))]) 257m4_define([TRACE2], [[$2], $1]) 258 259# No arguments. 260TRACE1 261TRACE2 262 263# With arguments, single line. 264TRACE1(foo, @bar, @baz) 265TRACE1(foo, TRACE1(bar, baz)) 266TRACE1(foo, active, baz) 267TRACE1(foo, [active], TRACE1(active, [active])) 268]]) 269 270# Several --traces. 271AT_CHECK_AUTOCONF([-t TRACE1 -t TRACE2], 0, 272[[configure.ac:6:TRACE1: 273configure.ac:6:TRACE2: 274configure.ac:7:TRACE2: 275configure.ac:10:TRACE1:foo:@bar:@baz 276configure.ac:10:TRACE2:@bar:@baz 277configure.ac:11:TRACE1:bar:baz 278configure.ac:11:TRACE2:baz 279configure.ac:11:TRACE1:foo::baz 280configure.ac:11:TRACE2::baz 281configure.ac:12:TRACE1:foo:ACTIVE:baz 282configure.ac:12:TRACE2:ACTIVE:baz 283configure.ac:13:TRACE1:ACTIVE:active 284configure.ac:13:TRACE2:active 285configure.ac:13:TRACE1:foo:active::ACTIVE 286configure.ac:13:TRACE2:active::ACTIVE 287]]) 288 289# Several line requests. 290AT_CHECK_AUTOCONF([[-t TRACE1:' 291[$1], [$2], [$3].']], 0, 292[[ 293[], [], []. 294 295[foo], [@bar], [@baz]. 296 297[bar], [baz], []. 298 299[foo], [], [baz]. 300 301[foo], [ACTIVE], [baz]. 302 303[ACTIVE], [active], []. 304 305[foo], [active], []. 306]]) 307 308# ${sep}@. 309AT_CHECK_AUTOCONF([-t TRACE2:'${)===(}@'], 0, 310[[[] 311[] 312[@bar])===([@baz] 313[baz] 314[])===([baz] 315[ACTIVE])===([baz] 316[active] 317[active])===([])===([ACTIVE] 318]]) 319 320# Arguments spanning multiple lines. 321AT_DATA([configure.ac], 322[[m4_define([TRACE], []) 323TRACE(foo 324bar, 325bar 326foo) 327]]) 328 329AT_CHECK_AUTOCONF([-t TRACE:'$%'], 0, 330[[foo bar:bar foo 331]]) 332 333AT_CLEANUP 334 335 336# autoconf --trace: builtins 337# -------------------------- 338AT_SETUP([autoconf --trace: builtins]) 339 340AT_DATA([configure.ac], 341[[define([active], [ACTIVE]) 342]]) 343 344AT_CHECK_AUTOCONF([[-t define | sed -n '$p']], 345 0, 346[[configure.ac:1:define:active:ACTIVE 347]]) 348 349# FIXME: Without `$1' the following test dies. Groumphf, once again to 350# dive into obscure feature interaction... 351# Note that using `-i' means we need the *.m4 files, not the *.m4f files, 352# hence we need srcdir, not builddir. 353AT_CHECK_AUTOCONF([[-t define:'$1' -i| sed -n '$p']], 354 0, 355[[active 356]]) 357 358AT_CLEANUP 359 360 361 362## ---------------------------- ## 363## autoconf: forbidden tokens. ## 364## ---------------------------- ## 365 366 367# autoconf: forbidden tokens, basic 368# --------------------------------- 369AT_SETUP([autoconf: forbidden tokens,[] basic]) 370 371AT_DATA_M4SH([configure.ac], 372[[AS_INIT 373m4_foo 374_m4_bar 375AS_FOO 376_AS_BAR 377[dnl] 378]]) 379 380dnl This test needs autom4te's cache, in spite of any ~/.autom4te.cfg. 381AT_DATA([.autom4te.cfg], [[ 382begin-language: "Autoconf" 383args: --cache=autom4te.cache 384end-language: "Autoconf" 385begin-language: "Autoconf-without-aclocal-m4" 386args: --cache=autom4te.cache 387end-language: "Autoconf-without-aclocal-m4" 388]]) 389 390AT_CHECK_AUTOCONF([], 1, [], 391[[configure.ac:2: error: possibly undefined macro: m4@&t@_foo 392 If this token and others are legitimate, please use m4@&t@_pattern_allow. 393 See the Autoconf documentation. 394configure.ac:3: error: possibly undefined macro: _m4@&t@_bar 395configure.ac:4: error: possibly undefined macro: AS@&t@_FOO 396configure.ac:5: error: possibly undefined macro: _AS@&t@_BAR 397configure.ac:6: error: possibly undefined macro: d@&t@nl 398]]) 399# Second run should succeed and yield no output. 400AT_CHECK([autoconf]) 401 402AT_CLEANUP 403 404 405# autoconf: forbidden tokens, exceptions 406# -------------------------------------- 407AT_SETUP([autoconf: forbidden tokens,[] exceptions]) 408 409AT_DATA_M4SH([configure.ac], 410[[AS_INIT 411 412# This is allowed in spite of the name. 413# It is on purpose that we check the case where there are several 414# tokens on the same line. 415m4_pattern_allow([^AS_ALLOWED$]) 416NOT_AS_ALLOWED AS_ALLOWED AS_ALLOWED_NOT 417 418# Test forbidding. 419m4_pattern_forbid([^FORBIDDEN$]) 420NOT_FORBIDDEN FORBIDDEN FORBIDDEN_NOT 421 422# Test Autoconf's patterns. 423AS_THIS_IS_INVALID and _AS_THIS_IS_INVALID_TOO 424BUT_AZ_THIS_IS_NOT ALTHOUGH_AS_THIS_IS 425# This is legal, although there is `AS_DEFINE' in there. 426BAS_DEFINE 427# AS_THIS_IS_A_COMMENT so just shut up. 428It would be very bad if Autoconf forgot to expand [AS_]INIT! 429]]) 430 431AT_CHECK_AUTOCONF([], 1, [], 432[[configure.ac:1: error: possibly undefined macro: AS@&t@_INIT 433 If this token and others are legitimate, please use m4@&t@_pattern_allow. 434 See the Autoconf documentation. 435configure.ac:7: error: possibly undefined macro: AS@&t@_ALLOWED_NOT 436configure.ac:10: error: possibly undefined macro: FORBIDDEN 437configure.ac:14: error: possibly undefined macro: AS@&t@_THIS_IS_INVALID 438configure.ac:14: error: possibly undefined macro: _AS@&t@_THIS_IS_INVALID_TOO 439]]) 440 441AT_CLEANUP 442 443 444# autoconf: automatically allowed tokens 445# -------------------------------------- 446AT_SETUP([autoconf: automatically allowed tokens]) 447 448AT_DATA_M4SH([configure.ac], 449[[AC_INIT 450m4_pattern_forbid([^FB_]) 451AC_DEFINE([FB_ONE]) 452AC_SUBST([FB_TWO]) 453AC_OUTPUT 454]]) 455 456AT_CHECK_AUTOCONF 457 458AT_CLEANUP 459 460 461# autoconf: do not forbid the empty token 462# --------------------------------------- 463AT_SETUP([autoconf: the empty token]) 464 465AT_DATA_M4SH([configure.ac], 466[[m4_init[]m4_pattern_allow([^foo$]) 467m4_divert([])dnl 468 line that begins with a space 469]]) 470 471AT_CHECK_AUTOCONF 472 473AT_CLEANUP 474 475 476# autoconf: subdirectories 477# ------------------------ 478AT_SETUP([autoconf: subdirectories]) 479 480AT_DATA([configure.ac], 481[[AC_INIT 482AC_PROG_MKDIR_P 483AC_CONFIG_FILES(sub/foo) 484AC_OUTPUT 485]]) 486 487mkdir sub 488 489AT_DATA([sub/foo.in], 490[[@MKDIR_P@ 491]]) 492 493AT_DATA([install-sh]) 494 495AT_CHECK_AUTOCONF 496AT_CHECK_CONFIGURE 497AT_CHECK([[grep '^[^/].*/mkdir -p' sub/foo]], 1) 498 499AT_CLEANUP 500 501 502# autoconf: input from stdin 503# -------------------------- 504AT_SETUP([autoconf: input from stdin]) 505 506# Past Autoconf versions failed to read from stdin when other, non-frozen input 507# files were present. 508AT_DATA([aclocal.m4]) 509 510AT_CHECK([echo 'AC_INIT(X, 1.0, bug-autoconf@gnu.org)' | autoconf -t AC_INIT -], 511 0, [stdin:1:AC_INIT:X:1.0:bug-autoconf@gnu.org 512]) 513AT_CHECK([echo 'AC_INIT(X, 2.0, bug-autoconf@gnu.org)' | autoconf -t AC_INIT -], 514 0, [stdin:1:AC_INIT:X:2.0:bug-autoconf@gnu.org 515]) 516 517AT_CLEANUP 518 519 520# autoconf: AC_AUTOCONF_VERSION 521# ----------------------------- 522AT_SETUP([autoconf: AC_AUTOCONF_VERSION]) 523 524AT_DATA([configure.ac], 525[[AC_INIT 526version m4@&t@_defn([AC_AUTOCONF_VERSION]) version 527AC_OUTPUT 528]]) 529 530AT_CHECK_AUTOCONF 531AT_CHECK([[grep 'version ]]AT_PACKAGE_VERSION[[ version' configure]], 5320, [ignore]) 533 534AT_CLEANUP 535 536 537 538# autoconf: AC_PRESERVE_HELP_ORDER 539# -------------------------------- 540AT_SETUP([autoconf: AC_PRESERVE_HELP_ORDER]) 541AT_KEYWORDS([m4@&t@_divert_text]) 542 543AT_DATA_AUTOCONF([configure.ac], 544[[AC_INIT 545AC_PRESERVE_HELP_ORDER 546AC_ARG_WITH([one], [ --with-one]) 547AC_ARG_ENABLE([two], [ --enable-two]) 548m4_divert_text([HELP_ENABLE], [arbitrary $text]) 549AC_ARG_WITH([three], [ --with-three]) 550AC_OUTPUT 551]]) 552 553AT_CHECK_AUTOCONF 554AT_CHECK_CONFIGURE([--help], [], [stdout]) 555AT_CHECK([sed -n '/^Optional/,/^$/p' stdout], [], 556[[Optional Features and Packages: 557 --disable-option-checking ignore unrecognized --enable/--with options 558 --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) 559 --enable-FEATURE[=ARG] include FEATURE [ARG=yes] 560 --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] 561 --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) 562 --with-one 563 --enable-two 564arbitrary $text 565 --with-three 566 567]]) 568 569AT_CLEANUP 570 571 572 573## --------- ## 574## ifnames. ## 575## --------- ## 576 577AT_SETUP([ifnames]) 578 579AT_DATA([iftest1.c], 580[[#ifdef DEF1 581#ifndef DEF2 582#if ! defined DEF3 && defined DEF4 /* but not defined DEF5 */ 583 # if SPACES 584 # if TABS 585/* #if C_COMMENTS */ 586// #if CXX_COMMENTS 587#if LINE1 = \ 588LINE2 589#if (VAL1*VAL2)==VAL3+VAL4 /* Not VAL5 !!! */ 590]]) 591 592AT_DATA([iftest2.c], 593[[#ifdef IFTEST2 594#if VAL1 595]]) 596 597AT_CHECK([ifnames iftest1.c iftest2.c], 0, 598[DEF1 iftest1.c 599DEF2 iftest1.c 600DEF3 iftest1.c 601DEF4 iftest1.c 602IFTEST2 iftest2.c 603LINE1 iftest1.c 604LINE2 iftest1.c 605SPACES iftest1.c 606TABS iftest1.c 607VAL1 iftest1.c iftest2.c 608VAL2 iftest1.c 609VAL3 iftest1.c 610VAL4 iftest1.c 611], []) 612 613AT_CLEANUP 614 615 616 617## ------------ ## 618## autoheader. ## 619## ------------ ## 620 621# autoheader is intensively used in its modern form throughout this 622# test suite. But we also have to check that acconfig.h still works. 623# autoheader uses autoconf --trace, so traces first. 624 625AT_SETUP([autoheader]) 626 627AT_DATA([acconfig.h], 628[[/* Define this to whatever you want. */ 629#undef this 630]]) 631 632 633# 1. Check that `acconfig.h' is still honored. 634AT_DATA([configure.ac], 635[[AC_INIT 636AC_CONFIG_HEADERS(config.h:config.hin) 637AC_DEFINE(this, "whatever you want.") 638]]) 639 640AT_CHECK_AUTOHEADER([], [], [], [ignore]) 641AT_CHECK([cat config.hin], 0, 642[[/* config.hin. Generated from configure.ac by autoheader. */ 643/* Define this to whatever you want. */ 644#undef this 645 646/* Define to the address where bug reports for this package should be sent. */ 647#undef PACKAGE_BUGREPORT 648 649/* Define to the full name of this package. */ 650#undef PACKAGE_NAME 651 652/* Define to the full name and version of this package. */ 653#undef PACKAGE_STRING 654 655/* Define to the one symbol short name of this package. */ 656#undef PACKAGE_TARNAME 657 658/* Define to the home page for this package. */ 659#undef PACKAGE_URL 660 661/* Define to the version of this package. */ 662#undef PACKAGE_VERSION 663]]) 664 665 666# 2. Check that missing templates are a fatal error. 667AT_DATA([configure.ac], 668[[AC_INIT 669AC_CONFIG_HEADERS(config.h:config.hin) 670AC_DEFINE(that, "whatever you want.") 671]]) 672 673# The test suite goes too fast for the cache time stamps... 674# Pass --force. 675AT_CHECK_AUTOHEADER([--force], [1], [], [ignore]) 676 677 678# 3. Check TOP and BOTTOM. 679AT_DATA([acconfig.h], 680[[/* Top from acconfig.h. */ 681@TOP@ 682/* Middle from acconfig.h. */ 683@BOTTOM@ 684/* Bottom from acconfig.h. */ 685]]) 686 687AT_DATA([configure.ac], 688[[AC_INIT 689AC_CONFIG_HEADERS(config.h:config.hin) 690AH_TOP([Top1 from configure.ac.]) 691AH_TOP([Top2 from configure.ac.]) 692AH_TOP([The Cat in a h@t.]) 693AH_VERBATIM([Middle], [Middle from configure.ac.]) 694AH_VERBATIM([Mouse], [The Mouse in a h@t.]) 695AH_BOTTOM([Bottom1 from configure.ac.]) 696AH_BOTTOM([Bottom2 from configure.ac.]) 697AH_BOTTOM([The Dog in a h@t.]) 698 699AC_DEFINE([ANT], [@], [The Ant in a h@t.]) 700]]) 701 702 703# Yes, that's right: the `middle' part of `acconfig.h' is still before 704# the AH_TOP part. But so what, you're not supposed to use the two 705# together. 706# Ignore STDERR which is the longish complaint against autoheader junk 707# files. 708AT_CHECK_AUTOHEADER([--force], [], [], [ignore]) 709AT_CHECK([cat config.hin], 0, 710[[/* config.hin. Generated from configure.ac by autoheader. */ 711/* Top from acconfig.h. */ 712/* Middle from acconfig.h. */ 713 714Top1 from configure.ac. 715 716Top2 from configure.ac. 717 718The Cat in a h@t. 719 720/* The Ant in a h@t. */ 721#undef ANT 722 723Middle from configure.ac. 724 725The Mouse in a h@t. 726 727/* Define to the address where bug reports for this package should be sent. */ 728#undef PACKAGE_BUGREPORT 729 730/* Define to the full name of this package. */ 731#undef PACKAGE_NAME 732 733/* Define to the full name and version of this package. */ 734#undef PACKAGE_STRING 735 736/* Define to the one symbol short name of this package. */ 737#undef PACKAGE_TARNAME 738 739/* Define to the home page for this package. */ 740#undef PACKAGE_URL 741 742/* Define to the version of this package. */ 743#undef PACKAGE_VERSION 744 745Bottom1 from configure.ac. 746 747Bottom2 from configure.ac. 748 749The Dog in a h@t. 750/* Bottom from acconfig.h. */ 751]]) 752 753AT_CLEANUP 754 755 756# autoheader should see through m4 macros, just like autoconf 757# http://lists.gnu.org/archive/html/bug-autoconf/2009-06/msg00000.html 758AT_SETUP([autoheader and macros]) 759 760AT_DATA([configure.ac], 761[[AC_INIT 762AC_CONFIG_HEADER([config.h]) 763m4_define([PETER], [SIMSALABIM]) 764m4_define([PAUL], [OPENSESAME]) 765AC_DEFINE([PETER], [10], [Peter's public info]) 766AC_DEFINE_UNQUOTED([PAUL], [`expr 4 + 6`], [Paul's public info]) 767AC_OUTPUT 768]]) 769 770AT_CHECK_AUTOCONF 771AT_CHECK_AUTOHEADER 772AT_CHECK([grep -c SIMSALABIM configure config.h.in], [0], 773[[configure:1 774config.h.in:1 775]]) 776AT_CHECK([grep -c OPENSESAME configure config.h.in], [0], 777[[configure:1 778config.h.in:1 779]]) 780AT_CHECK([grep -c PETER configure config.h.in], [1], 781[[configure:0 782config.h.in:0 783]]) 784AT_CHECK([grep -c PAUL configure config.h.in], [1], 785[[configure:0 786config.h.in:0 787]]) 788 789AT_CLEANUP 790 791 792 793 794## ------------ ## 795## autoupdate. ## 796## ------------ ## 797 798# Check that AC_CANONICAL_SYSTEM and AC_OUTPUT are properly updated. 799AT_SETUP([autoupdate]) 800 801AT_DATA([configure.ac], 802[[AC_INIT(Test, 1.0) 803AC_CANONICAL_SYSTEM 804# The doc says 27 is a valid fubar. 805fubar=27 806AC_OUTPUT(Makefile, echo $fubar, fubar=$fubar) 807]]) 808 809AT_DATA([expout], 810[[AC_INIT([Test],[1.0]) 811AC_CANONICAL_TARGET 812# The doc says 27 is a valid fubar. 813fubar=27 814AC_CONFIG_FILES([Makefile]) 815AC_CONFIG_COMMANDS([default],[echo $fubar],[fubar=$fubar]) 816AC_OUTPUT 817]]) 818 819# Checking `autoupdate'. 820AT_CHECK_AUTOUPDATE 821AT_CHECK([cat configure.ac], 0, [expout]) 822# Checking that `autoupdate' is idempotent 823AT_CHECK_AUTOUPDATE 824AT_CHECK([cat configure.ac], 0, [expout]) 825 826AT_CLEANUP 827 828 829# autoupdating AC_LINK_FILES 830# -------------------------- 831AT_SETUP([autoupdating AC_LINK_FILES]) 832 833AT_DATA([configure.ac], 834[[AC_INIT 835AC_LINK_FILES(dst1 dst2, src1 src2) 836AC_OUTPUT 837]]) 838 839AT_DATA([dst1], dst1 840) 841AT_DATA([dst2], dst2 842) 843 844# Checking `autoupdate'. 845AT_CHECK_AUTOUPDATE([], 0, [], ignore) 846AT_CHECK_AUTOCONF 847AT_CHECK_CONFIGURE 848AT_CHECK([cat src1], 0, [dst1 849]) 850AT_CHECK([cat src2], 0, [dst2 851]) 852 853AT_CLEANUP 854 855 856# autoupdating AC_PREREQ 857# ---------------------- 858AT_SETUP([autoupdating AC_PREREQ]) 859 860# Produce `AC_PREREQ(<AUTOUPDATE VERSION>)'. 861AT_CHECK([autoupdate --version | sed 's/.*) //;q'], 0, [stdout]) 862autoupdate_version=`cat stdout` 863[echo "AC_PREREQ([$autoupdate_version])" >expout] 864 865AT_CHECK([echo "AC_PREREQ(1.0)" | autoupdate -], 866 0, [expout], []) 867 868AT_CHECK([echo "AC_PREREQ($autoupdate_version)" | autoupdate -], 869 0, [expout], []) 870 871AT_CHECK([echo "AC_PREREQ(999.99)" | autoupdate -], 872 63, [], [ignore]) 873 874AT_CLEANUP 875 876 877# autoupdating AU_ALIAS 878# --------------------- 879AT_SETUP([autoupdating AU_ALIAS]) 880 881AT_DATA([configure.ac], 882[[AC_INIT 883AC_DEFUN([FOO], [$#]) 884AU_ALIAS([BAZ],[FOO]) 885test "FOO:FOO():FOO(x) BAZ:BAZ():BAZ(x)" = "0:1:1 0:1:1" || exit 1 886AC_PROG_CC 887AC_STDC_HEADERS 888AC_OUTPUT 889]]) 890 891# Checking `autoupdate'. 892AT_CHECK_AUTOUPDATE 893AT_CHECK_AUTOCONF 894AT_CHECK_CONFIGURE 895AT_CHECK([grep 'AC_HEADER_STDC[(]' configure.ac], 1, [ignore], [ignore]) 896AT_CHECK([grep 'AC_HEADER_STDC' configure.ac], 0, [ignore], [ignore]) 897 898AT_CLEANUP 899 900 901# autoupdating OLD to NEW 902# ----------------------- 903 904# The example taken from the code comments. 905AT_SETUP([autoupdating OLD to NEW]) 906 907AT_DATA([aclocal.m4], 908[[AU_DEFUN([OLD], [NEW([$1, $2], m4@&t@_eval([$1 + $2]))]) 909AC_DEFUN([NEW], [echo "sum($1) = $2"]) 910]]) 911 912AT_DATA([configure.ac], 913[[AC_INIT 914OLD(1, 2) 915NEW([0, 0], [0]) 916]]) 917 918# Checking `autoupdate'. 919AT_CHECK_AUTOUPDATE 920AT_CHECK_AUTOCONF 921AT_CHECK_CONFIGURE 922AT_CHECK([[grep 'NEW(\[1, 2], *\[3])' configure.ac]], 0, [ignore], [ignore]) 923AT_CHECK([[grep 'NEW(\[0, 0], *\[0])' configure.ac]], 0, [ignore], [ignore]) 924 925AT_CLEANUP 926 927 928# autoupdating macros recursively 929# ------------------------------- 930 931AT_SETUP([autoupdating macros recursively]) 932 933AT_XFAIL_IF([:]) 934 935AT_DATA([configure.ac], 936[[AC_INIT 937AC_PROG_CC 938AC_TRY_COMPILE([], [choke me], [echo bogus1], 939 [AC_TRY_COMPILE([], [return 0;], [echo good], [echo bogus2])]) 940AC_OUTPUT 941]]) 942 943# Checking `autoupdate'. 944AT_CHECK_AUTOUPDATE 945AT_CHECK([grep changequote configure.ac], [1]) 946AT_CHECK([grep TRY_COMPILE configure.ac], [1]) 947AT_CHECK_AUTOCONF 948AT_CHECK_CONFIGURE 949 950AT_CLEANUP 951 952 953# autoupdating AC_HELP_STRING 954# --------------------------- 955AT_SETUP([autoupdating AC_HELP_STRING]) 956 957AT_DATA([configure.ac], 958[[AC_INIT 959AC_ARG_ENABLE([foo], [AC_HELP_STRING([--enable-foo], [foo bar])], [:], [:]) 960]]) 961 962# Checking `autoupdate'. 963AT_CHECK_AUTOUPDATE([], [], [], [ignore]) 964AT_CHECK_AUTOCONF 965AT_CHECK_CONFIGURE([], [], [], [ignore]) 966AT_CHECK([[grep '\[--enable-foo], *\[foo bar]' configure.ac]], 0, [ignore], [ignore]) 967 968AT_CLEANUP 969 970 971# autoupdating with m4sugar 972# ------------------------- 973AT_SETUP([autoupdating with m4sugar]) 974 975AT_DATA([aclocal.m4], 976[[AU_DEFUN([OLD], 977[m4@&t@_pushdef([foo], [bar])dn@&t@l 978echo "foo $1 foo" 979m4@&t@_popdef([foo])dn@&t@l 980]) 981]]) 982 983touch foo.in 984 985AT_DATA([configure.ac], 986[[AC_PREREQ(2.54) 987m4_define([gnumeric_version_epoch], [1]) 988AC_INIT 989OLD([ bla bla ]) 990AC_FOREACH([name], [n1 n2], 991 [echo name 992]) 993AC_CHECKING([for feature]) 994AC_MSG_RESULT_UNQUOTED([`echo done`]) 995 996AC_OUTPUT([foo]) 997]]) 998 999# Checking `autoupdate'. 1000AT_CHECK_AUTOUPDATE([], [], [], [ignore]) 1001AT_CHECK_AUTOCONF 1002AT_CHECK_CONFIGURE([], [], [], [ignore]) 1003 1004AT_CLEANUP 1005 1006 1007# autoupdating with m4_pushdef 1008# ---------------------------- 1009AT_SETUP([autoupdating with m4@&t@_pushdef]) 1010 1011AT_XFAIL_IF([:]) 1012 1013touch foo.in 1014AT_DATA([configure.ac], 1015[[AC_INIT 1016AC_PROG_CC 1017# temporarily override this macro 1018m4@&t@_pushdef([AC_MSG_RESULT_UNQUOTED], [:]) 1019AC_C_BIGENDIAN 1020m4@&t@_popdef([AC_MSG_RESULT_UNQUOTED]) 1021AC_OUTPUT 1022]]) 1023 1024# Checking `autoupdate'. 1025AT_CHECK_AUTOUPDATE([], [], [], [ignore]) 1026AT_CHECK([grep changequote configure.ac], [1]) 1027AT_CHECK([grep [pushdef.*AC_MSG_RESULT_UNQUOTED] configure.ac], [0], [ignore]) 1028AT_CHECK_AUTOCONF 1029AT_CHECK_CONFIGURE([], [], [], [ignore]) 1030 1031AT_CLEANUP 1032 1033 1034# autoupdating with AC_REQUIRE 1035# ---------------------------- 1036AT_SETUP([autoupdating with AC_REQUIRE]) 1037 1038AT_XFAIL_IF([:]) 1039 1040AT_DATA([configure.ac], 1041[[AC_DEFUN([MACRO], 1042[AC_REQUIRE([AC_DECL_SYS_SIGLIST]) 1043AC_CHECK_DECLS([_sys_siglist], [], [], [#include <signal.h>]) 1044]) 1045 1046AC_INIT 1047MACRO 1048AC_OUTPUT 1049]]) 1050 1051# Checking `autoupdate'. 1052AT_CHECK_AUTOUPDATE([], [], [], [ignore]) 1053AT_CHECK_AUTOCONF 1054AT_CHECK_CONFIGURE([], [], [], [ignore]) 1055 1056AT_CLEANUP 1057 1058 1059# autoupdating with complex quoting 1060# --------------------------------- 1061AT_SETUP([autoupdating with complex quoting]) 1062 1063AT_XFAIL_IF([:]) 1064 1065AT_DATA([configure.ac], 1066[[m4_define([MACRO], 1067[[#define STRING "hello, world\n" 1068]]) 1069 1070AC_INIT 1071AC_TRY_COMPILE([#include <stdio.h> 1072 ]MACRO[], [printf (STRING);], 1073 [], [AS_EXIT([1])]) 1074AC_OUTPUT 1075]]) 1076 1077# Checking `autoupdate'. 1078AT_CHECK_AUTOUPDATE([], [], [], [ignore]) 1079AT_CHECK_AUTOCONF 1080AT_CHECK([grep MACRO configure], [1]) 1081AT_CHECK_CONFIGURE([], [], [], [ignore]) 1082 1083AT_CLEANUP 1084 1085 1086# autoupdating AC_LANG_SAVE 1087# ------------------------- 1088AT_SETUP([autoupdating AC_LANG_SAVE]) 1089 1090AT_DATA([configure.ac], 1091[[AC_INIT 1092AC_LANG_SAVE 1093AC_LANG_RESTORE 1094AC_LANG_SAVE 1095AC_LANG_RESTORE 1096]]) 1097 1098# Checking `autoupdate'. 1099AT_CHECK_AUTOUPDATE([], [], [], [ignore]) 1100AT_CHECK_AUTOCONF 1101AT_CHECK_CONFIGURE([], [], [], [ignore]) 1102 1103AT_CLEANUP 1104 1105 1106# autoupdating AC_FOREACH 1107# ----------------------- 1108AT_SETUP([autoupdating AC_FOREACH]) 1109 1110AT_DATA([aclocal.m4], 1111[[AU_DEFUN([OLD], [AC_FOREACH([myvar], [4 5 6], [' myvar'])]) 1112]]) 1113 1114AT_DATA([configure.ac], 1115[[AC_INIT 1116echo AC_FOREACH([myvar], [1 2 3], [' myvar'])OLD 1117]]) 1118 1119# Checking `autoupdate'. 1120AT_CHECK_AUTOUPDATE 1121AT_CHECK([[grep 'echo 1 2 3 4 5 6' configure.ac]], 1, [ignore], [ignore]) 1122AT_CHECK([[grep 'm4@&t@_foreach_w' configure.ac]], 0, [ignore], [ignore]) 1123AT_CHECK_AUTOCONF 1124AT_CHECK_CONFIGURE([], [0], [stdout]) 1125AT_CHECK([[grep ' 1 2 3 4 5 6' stdout]], 0, [ignore], [ignore]) 1126 1127AT_CLEANUP 1128 1129 1130# autoupdating with aclocal and m4_include 1131# ---------------------------------------- 1132AT_SETUP([autoupdating with aclocal and m4@&t@_include]) 1133 1134# We use aclocal. 1135AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore]) 1136 1137mkdir m4 aclocal 1138AT_DATA([configure.in], 1139[[AC_INIT(x,0) 1140AC_UNCHANGED_MACRO 1141AC_OLD_MACRO 1142AC_OUTPUT 1143]]) 1144AT_DATA([m4/stuff.m4], 1145[[AU_ALIAS([AC_OLD_MACRO], [AC_NEW_MACRO]) 1146AC_DEFUN([AC_NEW_MACRO], [echo hi]) 1147AC_DEFUN([AC_UNCHANGED_MACRO], [echo one]) 1148]]) 1149cp m4/stuff.m4 aclocal/stuff.m4 1150AT_CHECK([aclocal -I aclocal], [0], [ignore], [ignore]) 1151# Checking `autoupdate'. 1152AT_CHECK_AUTOUPDATE 1153AT_CHECK([aclocal -I m4], [0], [ignore], [ignore]) 1154AT_CHECK_AUTOUPDATE 1155 1156AT_CLEANUP 1157 1158 1159# Keeping autom4te.cfg complete 1160# ----------------------------- 1161 1162AT_SETUP([autom4te preselections]) 1163: ${sleep='sleep 1'} # Command to force different time stamps. 1164# If this test should run on FAT file systems and older w32, 1165# then setting $sleep correctly needs to be revisited. 1166 1167# We use aclocal and automake. Skip broken automake wrappers. 1168AT_CHECK([automake --version || exit 77], [], [stdout], [ignore]) 1169AT_CHECK([[grep '[1-9]\.[0-9]' stdout || exit 77]], [], [ignore]) 1170AT_CHECK([test ! -f $HOME/.autom4te.cfg || exit 77], [], [ignore], [ignore]) 1171 1172AT_DATA([configure.in], 1173[[AC_INIT(GNU foo, 1.0) 1174AM_INIT_AUTOMAKE 1175AC_CONFIG_FILES([Makefile]) 1176AC_OUTPUT 1177]]) 1178 1179AT_DATA([Makefile.am], 1180[[AUTOMAKE_OPTIONS = foreign 1181]]) 1182 1183$sleep # `aclocal.m4' should be strictly younger than its inputs 1184 1185# If Autoconf is too old, or the user has turned caching off, skip: 1186AT_CHECK([aclocal || { ret=$?; test $ret -eq 63 && ret=77; exit $ret; }], 1187 [], [], [ignore]) 1188AT_CHECK([test -d autom4te.cache || exit 77]) 1189AT_CHECK([autoconf]) 1190 1191# If this test fails due to missing entries in lib/autom4te.in, then 1192# comparing the old and new requests is a good place to start debugging: 1193cp autom4te.cache/requests old-requests 1194echo newer >newer 1195$sleep # if `configure' is regenerated, we want it to be strictly newer, 1196 # to catch the error consistently. 1197AT_CHECK([aclocal], [], [], [ignore]) 1198AT_CHECK([automake --no-force --add-missing], [], [], [ignore]) 1199AT_CHECK([autoconf]) 1200AT_CHECK([test "`find configure -newer newer`" = "" || 1201 { diff old-requests autom4te.cache/requests; exit 1; }], 1202 [], [], [], 1203 [extract_version=['s/^[^0-9]*\([0-9][^ ]*\).*/\1/;q'] 1204 automake_version=`automake --version | sed "$extract_version"` 1205 used_automake_version=`sed "$extract_version" "$abs_top_srcdir/Makefile.in"` 1206 AT_CHECK([if test "$automake_version" = "$used_automake_version"; ]dnl 1207 [then exit 1; else exit 77; fi])]) 1208AT_CLEANUP 1209 1210 1211# autom4te cache creation 1212# ----------------------- 1213# Ensure autom4te fails when it cannot create the cache directory 1214# or create files there. 1215AT_SETUP([autom4te cache creation]) 1216 1217AT_CHECK([test ! -f $HOME/.autom4te.cfg || exit 77], [], [ignore], [ignore]) 1218 1219# Work in a subdirectory so autotest can scribble in the toplevel. 1220mkdir sub 1221chmod a-w sub 1222 1223AT_DATA([configure.ac], 1224[[AC_INIT 1225]]) 1226 1227AT_DATA([.autom4te.cfg], 1228[[begin-language: "Autoconf-without-aclocal-m4" 1229args: --cache=sub/autom4te.cache 1230end-language: "Autoconf-without-aclocal-m4" 1231]]) 1232 1233# Do not try this when we are root or on systems without permissions. 1234# A failed redirection may cause a status of 2 with FreeBSD sh. 1235AT_CHECK([(: > sub/some-file) || exit 1 && exit 77], 1, [ignore], [ignore]) 1236 1237# Failure to create cache directory. 1238AT_CHECK_AUTOCONF([], [1], [ignore], [stderr]) 1239AT_CHECK([grep 'cannot create .*autom4te.cache' stderr], [0], [ignore]) 1240AT_CHECK([test -f configure], [1]) 1241 1242chmod u+w sub 1243AT_CHECK_AUTOCONF 1244 1245rm -f configure sub/autom4te.cache/* 1246chmod a-w sub/autom4te.cache 1247 1248# Failure to create a file in the cache directory. 1249AT_CHECK_AUTOCONF([], [1], [ignore], [stderr]) 1250AT_CHECK([grep 'cannot open.*autom4te.cache' stderr], [0], [ignore]) 1251 1252AT_CLEANUP 1253 1254 1255# autom4te cache locking 1256# ---------------------- 1257 1258AT_SETUP([autom4te cache locking]) 1259 1260# Cannot use AT_CHECK here, autotest internals could be messed up. 1261 1262(echo AC_INIT; sleep 2; echo) \ 1263 | (autom4te --language=autoconf -o configure -; echo $? >&2 ) 2>errlog & 1264AT_CHECK([echo AC_INIT | autom4te --language=autoconf -o configure -]) 1265wait 1266 1267# Ignore additional output from shell verbose or xtrace mode. 1268AT_CHECK([grep 'cannot rename' errlog], [1]) 1269AT_CHECK([grep '^0$' errlog], [], [ignore]) 1270AT_CHECK_CONFIGURE 1271 1272AT_CLEANUP 1273 1274 1275# autotools and file names containing whitespace 1276# ---------------------------------------------- 1277 1278AT_SETUP([autotools and whitespace in file names]) 1279 1280# We use aclocal. 1281AT_CHECK([aclocal --version || exit 77], [], [ignore], [ignore]) 1282 1283x= 1284export x 1285rm -f a b 1286for funny in \ 1287 'with funny '\'' $x & #! name ' \ 1288 'with funny \ '\'' \'\'' " <a >b * ? name ' #" 1289do 1290 funny=`func_sanitize_file_name "$funny"` 1291 file=" file $funny" 1292 dir=`func_sanitize_dir_name " dir $funny"` 1293 TMPDIR=" tmp$dir" 1294 export TMPDIR 1295 1296 # skip if we cannot create such a file or directory 1297 AT_CHECK([mkdir "$dir" "$TMPDIR" && touch "$file.in" || exit 77]) 1298 1299 cat >"$file.in" <<'END' 1300[AC_INIT(x,0) 1301m4@&t@_include([foo.m4]) 1302AC_CONFIG_HEADERS([config.h:config.hin]) 1303AC_MACRO 1304AC_OUTPUT] 1305END 1306 cat >"$dir"/foo.m4 <<'END' 1307[AC_DEFUN([AC_MACRO], [echo hi])] 1308END 1309 1310 AT_CHECK_AUTOHEADER([-B "$dir" "$file.in"]) 1311 AT_CHECK_AUTOHEADER([--force -I "$dir" "$file.in"]) 1312 AT_CHECK_AUTOUPDATE([-B "$dir" "$file.in"]) 1313 AT_CHECK_AUTOUPDATE([--force -I "$dir" "$file.in"]) 1314 AT_CHECK_AUTOUPDATE([-B "$dir" - < "$file.in"], [], [ignore]) 1315 AT_CHECK_AUTOCONF([-B "$dir" -o "$file" "$file.in"]) 1316 AT_CHECK_AUTOCONF([-I "$dir" -o "$file" "$file.in"]) 1317 # In autoconf, these exercise a slightly different code path: 1318 AT_CHECK_AUTOCONF([--prepend-include="$dir" -o "$file" "$file.in"]) 1319 AT_CHECK_AUTOCONF([--include="$dir" -o "$file" "$file.in"]) 1320 AT_CHECK([autoscan -B "$dir"], [], [], [ignore]) 1321 AT_CHECK([autoscan --force -I "$dir"], [], [], [ignore]) 1322 # autoreconf requires a sane input file name. Also, disable aclocal. 1323 mv -f "$file.in" configure.in 1324 AT_DATA([aclocal.m4]) 1325 AT_CHECK([autoreconf -B "$dir"]) 1326 AT_CHECK([autoreconf --force -I "$dir"]) 1327 1328 cat >"$file.c" <<'END' 1329#if FOO 1330#endif 1331END 1332 AT_CHECK([ifnames "$file.c"], [], [ignore]) 1333 1334 test ! -f b 1335done 1336 1337AT_CLEANUP 1338