1# -*- Autotest -*- 2 3AT_BANNER([Autoconf base layer.]) 4 5# Copyright (C) 2000-2001, 2003, 2005-2012 Free Software Foundation, 6# 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## AC_REQUIRE: topological sort.. ## 24## ------------------------------- ## 25 26# Check that dependencies are always properly honored. 27 28AT_SETUP([AC_REQUIRE: topological sort]) 29AT_KEYWORDS([m4@&t@_require]) 30 31AT_DATA([configure.ac], 32[[define([REQUIRE_AND_CHECK], 33[AC_REQUIRE([$1]) 34test -z "$m4@&t@_translit([$1], [A-Z], [a-z])" && AS_EXIT(1)]) 35 36AC_DEFUN([TEST1], 37[REQUIRE_AND_CHECK([TEST2a]) 38REQUIRE_AND_CHECK([TEST2b]) 39test1=set]) 40 41AC_DEFUN([TEST2a], 42[test2a=set]) 43 44AC_DEFUN([TEST2b], 45[REQUIRE_AND_CHECK([TEST3]) 46test2b=set]) 47 48AC_DEFUN([TEST3], 49[REQUIRE_AND_CHECK([TEST2a]) 50test3=set]) 51 52AS@&t@_INIT 53 54TEST1 55test -z "$test1" && 56 AC_MSG_ERROR([\$test1 is empty]) 57AS_EXIT(0) 58]]) 59 60AT_CHECK_AUTOCONF 61AT_CHECK_CONFIGURE 62 63AT_CLEANUP 64 65 66## --------------------------- ## 67## AC_REQUIRE: error message. ## 68## --------------------------- ## 69 70# Check that the message mentions AC_DEFUN, not m4_defun. 71 72AT_SETUP([AC_REQUIRE: error message]) 73AT_KEYWORDS([m4@&t@_require]) 74AT_DATA([configure.ac], 75[[AC_REQUIRE([AC_PROG_CC]) 76]]) 77 78AT_CHECK_AUTOCONF([], [1], [], 79[[configure.ac:1: error: AC_REQUIRE(AC_PROG_CC): cannot be used outside of an AC_DEFUN'd macro 80configure.ac:1: the top level 81autom4te: m4 failed with exit status: 1 82]]) 83AT_CLEANUP 84 85 86## ----------------------------------------------- ## 87## AC_REQUIRE and AC_DEFUN_ONCE: Require, expand. ## 88## ----------------------------------------------- ## 89 90AT_SETUP([AC_REQUIRE & AC_DEFUN_ONCE: [Require, expand]]) 91AT_KEYWORDS([m4@&t@_require m4@&t@_require_once]) 92 93AT_DATA([configure.ac], 94[[AC_DEFUN([TEST], 95[AC_REQUIRE([MULTI_TEST]) 96AC_REQUIRE([SINGLE_TEST])]) 97 98AC_DEFUN([MULTI_TEST], 99[multi_test=".$multi_test"]) 100 101AC_DEFUN_ONCE([SINGLE_TEST], 102[single_test=".$single_test"]) 103 104AS@&t@_INIT 105 106TEST 107TEST 108MULTI_TEST 109MULTI_TEST 110SINGLE_TEST 111SINGLE_TEST 112 113case $multi_test:$single_test in 114 ...:. ) AS_EXIT(0);; 115 ...:* ) AC_MSG_ERROR([DEFUN_ONCE is broken]);; 116 *:. ) AC_MSG_ERROR([DEFUN is broken (Wow, congrats!)]);; 117esac 118]]) 119 120AT_CHECK_AUTOCONF([], 0, []) 121 122AT_CHECK_CONFIGURE 123 124AT_CLEANUP 125 126 127 128## ----------------------------------------------- ## 129## AC_REQUIRE and AC_DEFUN_ONCE: Expand, require. ## 130## ----------------------------------------------- ## 131 132AT_SETUP([AC_REQUIRE & AC_DEFUN_ONCE: [Expand, require]]) 133AT_KEYWORDS([m4@&t@_require m4@&t@_require_once]) 134 135AT_DATA([configure.ac], 136[[AC_DEFUN([TEST], 137[AC_REQUIRE([MULTI_TEST]) 138AC_REQUIRE([SINGLE_TEST])]) 139 140AC_DEFUN([MULTI_TEST], 141[multi_test=".$multi_test"]) 142 143AC_DEFUN_ONCE([SINGLE_TEST], 144[single_test=".$single_test"]) 145 146AS@&t@_INIT 147 148MULTI_TEST 149MULTI_TEST 150SINGLE_TEST 151SINGLE_TEST 152TEST 153TEST 154 155case $multi_test:$single_test in 156 ..:. ) AS_EXIT(0);; 157 ..:* ) AC_MSG_ERROR([DEFUN_ONCE is broken]);; 158 *:. ) AC_MSG_ERROR([DEFUN is broken (Wow, congrats!)]);; 159 * ) AC_MSG_ERROR([received `$multi_test:$single_test']);; 160esac 161]]) 162 163AT_CHECK_AUTOCONF([], 0, []) 164AT_CHECK_CONFIGURE 165 166AT_CLEANUP 167 168 169 170## ------------------------- ## 171## AC_REQUIRE & AC_PROVIDE. ## 172## ------------------------- ## 173 174AT_SETUP([AC_REQUIRE & AC_PROVIDE]) 175AT_KEYWORDS([m4@&t@_require]) 176 177AT_DATA([configure.ac], 178[[AC_DEFUN([TEST], 179[AC_REQUIRE([INNER_TEST])]) 180 181AC_DEFUN([INNER_TEST], 182[inner_test=".$inner_test"]) 183 184AS@&t@_INIT 185 186AC_PROVIDE([INNER_TEST]) 187TEST 188 189case $inner_test in 190 "" ) AS_EXIT(0);; 191 * ) AC_MSG_ERROR([received `$inner_test']);; 192esac 193]]) 194 195AT_CHECK_AUTOCONF 196AT_CHECK_CONFIGURE 197 198AT_CLEANUP 199 200 201## -------- ## 202## AC_INIT. ## 203## -------- ## 204 205# Make sure AC_INIT sets PACKAGE_TARNAME properly. 206 207AT_SETUP([AC_INIT]) 208 209AT_DATA([configure.ac], 210[[AC_INIT([GNU fu], [1.0], [bug-fu@gnu.org]) 211]]) 212 213AT_CHECK_AUTOCONF 214AT_CHECK_CONFIGURE([-q]) 215 216# Ensure we get the expected definition: 217AT_CHECK([grep "^PACKAGE_TARNAME='fu'\$" configure], [], [ignore]) 218 219AT_CLEANUP 220 221 222## ------------------------------------- ## 223## AC_INIT with unusual version strings. ## 224## ------------------------------------- ## 225 226AT_SETUP([AC_INIT with unusual version strings]) 227 228AT_DATA([configure.ac], 229[[AC_INIT([GNU String++ with spaces (foo)], 230 [2.48++ (2010-07-03)], [[http://example.com/?a=b&c=d#e]], [clisp]) 231AC_OUTPUT 232]]) 233 234if echo 'ab*c' | grep -F 'ab*c' >/dev/null 2>&1; then 235 FGREP="grep -F" 236else 237 FGREP=fgrep 238fi 239 240AT_CHECK_AUTOCONF([-Werror]) 241AT_CHECK_CONFIGURE([-q]) 242AT_CHECK_CONFIGURE([--help], [], [stdout]) 243AT_CHECK([[$FGREP 'com/?a=b&c=d#e' stdout]], [], [ignore]) 244AT_CHECK_CONFIGURE([--version], [], [stdout]) 245AT_CHECK([$FGREP 'GNU String++ with spaces (foo)' stdout], [], [ignore]) 246AT_CHECK([$FGREP '2.48++ (2010-07-03)' stdout], [], [ignore]) 247 248AT_CHECK([./config.status --help], [], [stdout]) 249AT_CHECK([[$FGREP 'com/?a=b&c=d#e' stdout]], [], [ignore]) 250AT_CHECK([./config.status --version], [], [stdout]) 251AT_CHECK([$FGREP 'GNU String++ with spaces (foo)' stdout], [], [ignore]) 252AT_CHECK([$FGREP '2.48++ (2010-07-03)' stdout], [], [ignore]) 253 254AT_DATA([configure.ac], 255[[AC_INIT([GNU "String++"], 256 [2.48], [http://example.com/], [clisp]) 257AC_OUTPUT 258]]) 259 260AT_CHECK_AUTOCONF([-Werror], [1], [ignore], [stderr]) 261AT_CHECK([grep 'AC_INIT: not a literal: ' stderr], [], [ignore]) 262 263AT_DATA([configure.ac], 264[[AC_INIT([GNU String++], 265 ['codename' 2.48], [http://example.com/], [clisp]) 266AC_OUTPUT 267]]) 268 269AT_CHECK_AUTOCONF([-Werror], [1], [ignore], [stderr]) 270AT_CHECK([grep 'AC_INIT: not a literal: ' stderr], [], [ignore]) 271 272AT_DATA([configure.ac], 273[[AC_INIT([GNU 274String++], [2.48], [http://example.com/], [clisp]) 275AC_OUTPUT 276]]) 277 278AT_CHECK_AUTOCONF([-Werror], [1], [ignore], [stderr]) 279AT_CHECK([grep 'AC_INIT: not a literal: ' stderr], [], [ignore]) 280 281AT_CLEANUP 282 283 284## -------------- ## 285## AC_COPYRIGHT. ## 286## -------------- ## 287 288# Ensure the FSF notice as well as the user-provided one are present 289# in the head of the testsuite as well as the --version output. 290 291AT_SETUP([AC@&t@_COPYRIGHT]) 292 293AT_DATA([configure.ac], 294[[AC_INIT([GNU fu], [1.0]) 295AC_COPYRIGHT([[This is just a test notice, not a real one, so let's avoid 296words that may be matched by scanners for legal things, 297causing extra work for distributors. 298Multi-line values should be supported. 299]]) 300]]) 301 302AT_CHECK_AUTOCONF 303AT_CHECK_CONFIGURE([--version], [], [stdout]) 304AT_CHECK([grep 'Copyright.*Free Software Foundation' stdout], [], [ignore]) 305AT_CHECK([grep 'This is just a test notice' stdout], [], [ignore]) 306AT_CHECK([sed -ne 50q -e '/Copyright/{' -e N -e N -e N -e N -e 's/#//g' ]dnl 307 [ -e 's/\n//g' -e p -e '}' configure ]dnl 308 [ | grep 'Copyright.*Free Software Foundation'], 309 [], [ignore]) 310AT_CHECK([sed 50q configure | grep 'This is just a test notice'], [], [ignore]) 311 312AT_CLEANUP 313 314 315## ---------------- ## 316## AC_CACHE_CHECK. ## 317## ---------------- ## 318 319# Make sure AC_CACHE_CHECK is silent with -q. 320# Also make sure we warn about cache id's not named with `_cv_'. 321 322AT_SETUP([AC_CACHE_CHECK]) 323AT_KEYWORDS([CONFIG_SITE]) 324 325# Don't let a config.site file affect this test. 326AS_UNSET([CONFIG_SITE]) 327 328AT_DATA([configure.ac], 329[[AC_INIT 330# m4_define([ac_nothing], [ac_cv_absolutely_nothing]) 331AC_CACHE_CHECK([for nothing], 332 [ac_nothing], 333 [ac_nothing=found]) 334 335AC_MSG_CHECKING([for some other variable]) 336commands_to_set_it_was_run=false 337AC_CACHE_VAL([my_cv_variable], [ 338# FOO 339commands_to_set_it_was_run=true 340my_cv_variable=true 341]) 342AC_MSG_RESULT([$my_cv_variable]) 343 344# Ensure that the result is available at this point. 345if test ${my_cv_variable+set} != set; then 346 AC_MSG_ERROR([AC@&@&t@t@_CACHE_VAL did not ensure that the cache variable was set]) 347fi 348 349# AC_CACHE_SAVE should be enough here, no need for AC_OUTPUT. 350AC_CACHE_SAVE 351]]) 352 353AT_CHECK_AUTOCONF([], [], [], [stderr]) 354AT_CHECK([grep 'must contain _cv_ to be cached' stderr], [], [ignore]) 355 356# Do not warn about defines: 357sed 's/^# m4_define/m4_define/' configure.ac > t 358mv -f t configure.ac 359AT_CHECK_AUTOCONF 360AT_CHECK_CONFIGURE([-q]) 361 362sed '/m4_define/d; s/ac_nothing/ac_cv_nothing/' configure.ac > t 363mv -f t configure.ac 364AT_CHECK_AUTOCONF 365AT_CHECK_CONFIGURE([-q]) 366 367# Print a message saying that the result was cached, iff it was cached. 368AT_CHECK_CONFIGURE([], [], [stdout]) 369AT_CHECK([grep 'cached' stdout], [1]) 370AT_CHECK_CONFIGURE([my_cv_variable='yes it is set'], [], [stdout]) 371AT_CHECK([grep 'cached.*yes it is set' stdout], [], [ignore]) 372 373# --cache-file is honored and has caching semantics. 374AT_CHECK_CONFIGURE([--cache-file=foobar.cache], [], [stdout]) 375AT_CHECK([grep 'cached' stdout], [1]) 376AT_CHECK([test ! -f config.cache]) 377AT_CHECK([grep 'my_cv_variable.*true' foobar.cache], [], [ignore]) 378AT_CHECK_CONFIGURE([--cache-file=foobar.cache], [], [stdout]) 379AT_CHECK([grep 'some other variable.*cached.*true' stdout], [], [ignore]) 380 381# A setting on the command line overrides the cache. 382AT_CHECK_CONFIGURE([--cache-file=foobar.cache my_cv_variable='override'], [], [stdout]) 383AT_CHECK([grep 'cached.*override' stdout], [], [ignore]) 384AT_CHECK([grep 'my_cv_variable.*override' foobar.cache], [], [ignore]) 385 386# Values containing braces need special internal treatment. 387AT_CHECK_CONFIGURE([-C ac_cv_nothing='{' my_cv_variable='contains } brace'], 388 [], [stdout]) 389AT_CHECK([grep 'ac_cv_nothing.*{' config.cache], [], [ignore]) 390AT_CHECK([grep 'my_cv_variable.*contains } brace' config.cache], [], [ignore]) 391AT_CHECK_CONFIGURE([-C], [], [stdout]) 392AT_CHECK([grep 'nothing.*{' stdout], [], [ignore]) 393AT_CHECK([grep 'some other variable.*contains } brace' stdout], [], [ignore]) 394rm -f config.cache 395 396# Diagnose common side-effects that are errors in COMMANDS-TO-SET-IT: 397sed 's/^# FOO/AC_DEFINE([some-define], [1], [oooh.])/' configure.ac > t 398mv -f t configure.ac 399AT_CHECK_AUTOCONF([], [], [], [stderr]) 400AT_CHECK([grep 'suspicious.*AC_DEFINE' stderr], [], [ignore]) 401 402sed 's/^AC_DEFINE.*/AC_SUBST([some_substitution], [oooh.])/' configure.ac > t 403mv -f t configure.ac 404AT_CHECK_AUTOCONF([], [], [], [stderr]) 405AT_CHECK([grep 'suspicious.*AC_SUBST' stderr], [], [ignore]) 406 407# Ensure the examples from the manual work as intended. 408# Taken from autoconf.texi:Caching Results 409AT_DATA([configure.ac], 410[[AC_INIT 411AC_DEFUN([AC_SHELL_TRUE], 412[AC_CACHE_CHECK([whether true(1) works], [my_cv_shell_true_works], 413 [my_cv_shell_true_works=no 414 (true) 2>/dev/null && my_cv_shell_true_works=yes 415 if test "x$my_cv_shell_true_works" = xyes; then 416 AC_DEFINE([TRUE_WORKS], [1], 417 [Define if `true(1)' works properly.]) 418 fi]) 419]) 420AC_SHELL_TRUE 421]]) 422AT_CHECK_AUTOCONF([-Werror], [1], [], [stderr]) 423AT_CHECK([grep 'suspicious.*AC_DEFINE' stderr], [], [ignore]) 424 425# Taken from autoconf.texi:Caching Results 426AT_DATA([configure.ac], 427[[AC_INIT 428AC_DEFUN([AC_SHELL_TRUE], 429[AC_CACHE_CHECK([whether true(1) works], [my_cv_shell_true_works], 430 [my_cv_shell_true_works=no 431 (true) 2>/dev/null && my_cv_shell_true_works=yes]) 432 if test "x$my_cv_shell_true_works" = xyes; then 433 AC_DEFINE([TRUE_WORKS], [1], 434 [Define if `true(1)' works properly.]) 435 fi 436]) 437AC_SHELL_TRUE 438AC_OUTPUT 439]]) 440AT_CHECK_AUTOCONF([-Werror]) 441AT_CHECK_CONFIGURE([-C], [], [stdout]) 442AT_CHECK([grep my_cv_shell_true_works config.cache], [], [ignore]) 443AT_CHECK([grep 'true.*works.*yes' stdout], [], [ignore]) 444 445AT_CHECK_CONFIGURE([--config-cache], [], [stdout]) 446AT_CHECK([grep 'true.*works.*cached.*yes' stdout], [], [ignore]) 447 448# config.status only pays attention to the cache file with --recheck. 449AT_CHECK([./config.status], [], [stdout]) 450AT_CHECK([grep cache stdout], [1]) 451AT_CHECK([./config.status --recheck], [], [stdout]) 452AT_CHECK([grep cache stdout], [0], [ignore]) 453 454# By default, configure uses no cache file, neither loading nor updating it. 455: > a-stamp-file 456AT_CHECK_CONFIGURE([], [], [stdout]) 457AT_CHECK([grep cache stdout], [1]) 458AT_CHECK([LC_ALL=C ls -t config.cache a-stamp-file | sed 1q | grep config.cache], [1]) 459 460# Using a symlinked cache file works. 461: > cache 462rm -f config.cache 463AS_LN_S([cache], [config.cache]) 464AT_CHECK_CONFIGURE([-C]) 465# Either the system does not support symlinks, or the symlinked-to file 466# should be updated. 467AT_CHECK([test -s cache || test ! -h config.cache]) 468 469# config.site can specify a site-wide cache, accumulating information. 470# Also test that we don't run afoul of sourcing a file with leading -. 471AT_DATA([-config.site], 472[[cache_file=sitecache 473]]) 474AT_DATA([sitecache], 475[[my_cv_some_preset_cache_var=yes 476]]) 477CONFIG_SITE=-config.site 478export CONFIG_SITE 479AT_CHECK_CONFIGURE 480AT_CHECK([grep my_cv_some_preset_cache_var sitecache], [], [ignore]) 481AT_CHECK([grep my_cv_shell_true_works sitecache], [], [ignore]) 482AT_CHECK_CONFIGURE([], [], [stdout]) 483AT_CHECK([grep 'whether true.*works.*cached' stdout], [], [ignore]) 484 485dnl Until we can find a way to avoid catastrophic failure, 486dnl skip the rest of this test on such shells. 487echo 'if' > syntax 488AT_CHECK([${CONFIG_SHELL-$SHELL} -c 'case `. ./syntax; echo $?` in 489 0|"") exit 77;; esac'], [0], [ignore], [ignore]) 490 491# Check that config cache scripts must be well-formed. 492AT_DATA([bad.site], 493[[fi 494]]) 495CONFIG_SITE=$PWD/bad.site 496AT_CHECK_CONFIGURE([ || exit 1], [1], [stdout], [stderr]) 497AT_CHECK([grep 'failed to load site script' stderr], [], [ignore], [ignore], 498 [AT_CHECK([grep 'whether true' stdout], [1])]) 499 500# However, a missing file is ignored. 501CONFIG_SITE=./no-such-file 502AT_CHECK_CONFIGURE 503 504AT_CLEANUP 505 506 507## --------------- ## 508## AC_CACHE_LOAD. ## 509## --------------- ## 510 511# Test AC_CACHE_LOAD. 512 513AT_SETUP([AC_CACHE_LOAD]) 514 515AT_DATA([configure.ac], 516[[AC_INIT 517$some_test_code 518AC_CACHE_LOAD 519AC_MSG_NOTICE([some_cv_variable is $some_cv_variable]) 520AC_OUTPUT 521]]) 522AT_CHECK_AUTOCONF 523AS_UNSET([some_test_code]) 524AT_DATA([new-cache], 525[[some_cv_variable=value-from-new-cache 526]]) 527AT_CHECK_CONFIGURE([some_test_code='eval cache_file=new-cache'], [], [stdout]) 528AT_CHECK([grep 'some_cv_variable.*value-from-new-cache' stdout], [], [ignore]) 529 530AT_CLEANUP 531 532 533## ---------------- ## 534## AC_COMPUTE_INT. ## 535## ---------------- ## 536 537# Make sure AC_COMPUTE_INT fails properly. 538 539AT_SETUP([AC_COMPUTE_INT]) 540 541AT_DATA([configure.ac], 542[[AC_INIT 543AC_COMPUTE_INT([invalid_expression], 544 [**0**], 545 [], 546 [invalid_expression=failed]) 547test "$invalid_expression" = failed || 548 AC_MSG_ERROR([**0** evaluated to $invalid_expression instead of failing]) 549]]) 550 551AT_CHECK_AUTOCONF 552AT_CHECK_CONFIGURE 553 554AT_CLEANUP 555 556 557## ---------------- ## 558## AC_TRY_COMMAND. ## 559## ---------------- ## 560 561AT_SETUP([AC_TRY_COMMAND]) 562 563AT_DATA([configure.ac], 564[[AC_INIT 565 566if AC_TRY_COMMAND([(echo "The Cat in the Hat"; 567 echo "The Hat in the Cat" >&2) | 568 grep \^The\ Cat\ in\ the\ Hat\$ >/dev/null]); then 569 : 570else 571 AC_MSG_ERROR([didn't see the Cat in the Hat]) 572fi 573 574if AC_TRY_COMMAND([(echo "The Cat in the Hat"; 575 echo "The Hat in the Cat" >&2) | 576 grep \^The\ Hat\ in\ the\ Cat\$ >/dev/null]); then 577 AC_MSG_ERROR([saw the Hat in the Cat]) 578fi 579]]) 580 581AT_CHECK_AUTOCONF 582AT_CHECK_CONFIGURE([-q]) 583 584AT_CLEANUP 585 586 587## ------------ ## 588## Input/Output ## 589## ------------ ## 590 591AT_SETUP([Input/Output]) 592 593AT_DATA([configure.ac], 594[[AC_INIT 595cat <&AS@&t@_ORIGINAL_STDIN_FD >&AS@&t@_MESSAGE_FD 596]]) 597AT_CHECK_AUTOCONF 598AT_CHECK([echo Hello | CONFIG_SITE=/dev/null ./configure $configure_options | grep -v 'configure: loading site script '],, [Hello 599]) 600AT_CHECK([echo Hello | CONFIG_SITE=/dev/null ./configure $configure_options --silent]) 601 602AT_CLEANUP 603 604 605## ------------------- ## 606## configure arguments ## 607## ------------------- ## 608 609AT_SETUP([configure arguments]) 610 611AT_DATA([configure.ac], 612[[AC_INIT 613echo "$@" 614]]) 615 616AT_CHECK_AUTOCONF 617AT_CHECK_CONFIGURE([FOO=bar --enable-baz --without-zork --silent], [0], [stdout], [ignore]) 618AT_CHECK([grep 'FOO=bar --enable-baz --without-zork --silent' stdout], [0], [ignore], [ignore]) 619 620dnl check that syntax error is detected 621AT_CHECK_CONFIGURE([=], [1], [], [ignore], [ignore]) 622AT_CHECK_CONFIGURE([1=2], [1], [], [ignore], [ignore]) 623 624AT_CLEANUP 625 626 627## ------------------------------ ## 628## AC_ARG_ENABLE and AC_ARG_WITH. ## 629## ------------------------------ ## 630 631AT_SETUP([AC_ARG_ENABLE and AC_ARG_WITH]) 632 633AT_DATA_M4SH([configure.ac], 634[[AC_INIT 635# Taken from autoconf.texi:Pretty Help Strings. 636AC_ARG_WITH([foo], 637 [AS_HELP_STRING([--with-foo], 638 [use foo (default is no)])], 639 [use_foo=$withval], 640 [use_foo=no]) 641AC_ARG_WITH([c++], 642 [AS_HELP_STRING([--with-c++], 643 [with c++])], 644 [choice_with=$withval]) 645AC_ARG_ENABLE([c++], 646 [AS_HELP_STRING([--enable-c++], 647 [enable c++])], 648 [choice_enable=$enableval]) 649echo "use_foo: $use_foo" 650echo "with_c++: $with_c__, $choice_with" 651echo "enable_c++: $enable_c__, $choice_enable" 652]]) 653 654AT_CHECK_AUTOCONF 655AT_CHECK_CONFIGURE([--help | grep foo], [0], 656[[ --with-foo use foo (default is no) 657]], [ignore]) 658AT_CHECK_CONFIGURE([--with-foo=yes --with-c++ --disable-c++], 659 [], [stdout], [ignore]) 660AT_CHECK([grep 'use_foo: yes' stdout], [], [ignore]) 661AT_CHECK([grep 'with_c++: yes, yes' stdout], [], [ignore]) 662AT_CHECK([grep 'enable_c++: no, no' stdout], [], [ignore]) 663AT_CHECK([grep 'unrecognized option' stdout], [1]) 664AT_CHECK_CONFIGURE([--without-foo --with-c++=no --enable-c++=maybe], 665 [], [stdout], [ignore]) 666AT_CHECK([grep 'use_foo: no' stdout], [], [ignore]) 667AT_CHECK([grep 'with_c++: no, no' stdout], [], [ignore]) 668AT_CHECK([grep 'enable_c++: maybe, maybe' stdout], [], [ignore]) 669AT_CHECK([grep 'unrecognized option' stdout], [1]) 670AT_CHECK_CONFIGURE([], [], [stdout], [ignore]) 671AT_CHECK([grep 'use_foo: no' stdout], [], [ignore]) 672AT_CHECK([grep 'with_c++: , $' stdout], [], [ignore]) 673AT_CHECK([grep 'enable_c++: , $' stdout], [], [ignore]) 674AT_CHECK([grep 'unrecognized option' stdout], [1]) 675 676AT_CLEANUP 677 678 679## --------------------- ## 680## configure directories ## 681## --------------------- ## 682 683AT_SETUP([configure directories]) 684 685AT_DATA([foo.in], 686[[prefix=@prefix@ 687exec_prefix=@exec_prefix@ 688libdir=@libdir@ 689]]) 690 691AT_DATA([configure.ac], 692[[AC_INIT 693AC_CONFIG_FILES([foo]) 694AC_OUTPUT 695]]) 696 697AT_CHECK_AUTOCONF 698dnl check that relative paths are rejected 699AT_CHECK_CONFIGURE([--libdir=.], [1], [ignore], [stderr]) 700AT_CHECK([grep 'expected an absolute directory name for --libdir: \.' stderr], 701 [0], [ignore]) 702 703dnl check that extra slashes are stripped, and that defaults are not expanded 704AT_CHECK_CONFIGURE([--prefix=/usr//]) 705AT_CHECK([cat foo], [0], [[prefix=/usr 706exec_prefix=${prefix} 707libdir=${exec_prefix}/lib 708]]) 709 710AT_CLEANUP 711