AC_HEADER_MAJOR: port to glibc 2.25
[autoconf/ericb.git] / tests / base.at
blob1c02d8d043be03688b406f5c538e111b24a136e3
1 #                                                       -*- Autotest -*-
3 AT_BANNER([Autoconf base layer.])
5 # Copyright (C) 2000-2001, 2003, 2005-2016 Free Software Foundation,
6 # Inc.
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.
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.
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/>.
22 ## ------------------------------- ##
23 ## AC_REQUIRE: topological sort..  ##
24 ## ------------------------------- ##
26 # Check that dependencies are always properly honored.
28 AT_SETUP([AC_REQUIRE: topological sort])
29 AT_KEYWORDS([m4@&t@_require])
31 AT_DATA([configure.ac],
32 [[define([REQUIRE_AND_CHECK],
33 [AC_REQUIRE([$1])
34 test -z "$m4@&t@_translit([$1], [A-Z], [a-z])" && AS_EXIT(1)])
36 AC_DEFUN([TEST1],
37 [REQUIRE_AND_CHECK([TEST2a])
38 REQUIRE_AND_CHECK([TEST2b])
39 test1=set])
41 AC_DEFUN([TEST2a],
42 [test2a=set])
44 AC_DEFUN([TEST2b],
45 [REQUIRE_AND_CHECK([TEST3])
46 test2b=set])
48 AC_DEFUN([TEST3],
49 [REQUIRE_AND_CHECK([TEST2a])
50 test3=set])
52 AS@&t@_INIT
54 TEST1
55 test -z "$test1" &&
56   AC_MSG_ERROR([\$test1 is empty])
57 AS_EXIT(0)
58 ]])
60 AT_CHECK_AUTOCONF
61 AT_CHECK_CONFIGURE
63 AT_CLEANUP
66 ## --------------------------- ##
67 ## AC_REQUIRE: error message.  ##
68 ## --------------------------- ##
70 # Check that the message mentions AC_DEFUN, not m4_defun.
72 AT_SETUP([AC_REQUIRE: error message])
73 AT_KEYWORDS([m4@&t@_require])
74 AT_DATA([configure.ac],
75 [[AC_REQUIRE([AC_PROG_CC])
76 ]])
78 AT_CHECK_AUTOCONF([], [1], [],
79 [[configure.ac:1: error: AC_REQUIRE(AC_PROG_CC): cannot be used outside of an AC_DEFUN'd macro
80 configure.ac:1: the top level
81 autom4te: m4 failed with exit status: 1
82 ]])
83 AT_CLEANUP
86 ## ----------------------------------------------- ##
87 ## AC_REQUIRE and AC_DEFUN_ONCE: Require, expand.  ##
88 ## ----------------------------------------------- ##
90 AT_SETUP([AC_REQUIRE & AC_DEFUN_ONCE: [Require, expand]])
91 AT_KEYWORDS([m4@&t@_require m4@&t@_require_once])
93 AT_DATA([configure.ac],
94 [[AC_DEFUN([TEST],
95 [AC_REQUIRE([MULTI_TEST])
96 AC_REQUIRE([SINGLE_TEST])])
98 AC_DEFUN([MULTI_TEST],
99 [multi_test=".$multi_test"])
101 AC_DEFUN_ONCE([SINGLE_TEST],
102 [single_test=".$single_test"])
104 AS@&t@_INIT
106 TEST
107 TEST
108 MULTI_TEST
109 MULTI_TEST
110 SINGLE_TEST
111 SINGLE_TEST
113 case $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!)]);;
117 esac
120 AT_CHECK_AUTOCONF([], 0, [])
122 AT_CHECK_CONFIGURE
124 AT_CLEANUP
128 ## ----------------------------------------------- ##
129 ## AC_REQUIRE and AC_DEFUN_ONCE: Expand, require.  ##
130 ## ----------------------------------------------- ##
132 AT_SETUP([AC_REQUIRE & AC_DEFUN_ONCE: [Expand, require]])
133 AT_KEYWORDS([m4@&t@_require m4@&t@_require_once])
135 AT_DATA([configure.ac],
136 [[AC_DEFUN([TEST],
137 [AC_REQUIRE([MULTI_TEST])
138 AC_REQUIRE([SINGLE_TEST])])
140 AC_DEFUN([MULTI_TEST],
141 [multi_test=".$multi_test"])
143 AC_DEFUN_ONCE([SINGLE_TEST],
144 [single_test=".$single_test"])
146 AS@&t@_INIT
148 MULTI_TEST
149 MULTI_TEST
150 SINGLE_TEST
151 SINGLE_TEST
152 TEST
153 TEST
155 case $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']);;
160 esac
163 AT_CHECK_AUTOCONF([], 0, [])
164 AT_CHECK_CONFIGURE
166 AT_CLEANUP
170 ## ------------------------- ##
171 ## AC_REQUIRE & AC_PROVIDE.  ##
172 ## ------------------------- ##
174 AT_SETUP([AC_REQUIRE & AC_PROVIDE])
175 AT_KEYWORDS([m4@&t@_require])
177 AT_DATA([configure.ac],
178 [[AC_DEFUN([TEST],
179 [AC_REQUIRE([INNER_TEST])])
181 AC_DEFUN([INNER_TEST],
182 [inner_test=".$inner_test"])
184 AS@&t@_INIT
186 AC_PROVIDE([INNER_TEST])
187 TEST
189 case $inner_test in
190   "" ) AS_EXIT(0);;
191   *  ) AC_MSG_ERROR([received `$inner_test']);;
192 esac
195 AT_CHECK_AUTOCONF
196 AT_CHECK_CONFIGURE
198 AT_CLEANUP
201 ## -------- ##
202 ## AC_INIT. ##
203 ## -------- ##
205 # Make sure AC_INIT sets PACKAGE_TARNAME properly.
207 AT_SETUP([AC_INIT])
209 AT_DATA([configure.ac],
210 [[AC_INIT([GNU fu], [1.0], [bug-fu@gnu.org])
213 AT_CHECK_AUTOCONF
214 AT_CHECK_CONFIGURE([-q])
216 # Ensure we get the expected definition:
217 AT_CHECK([grep "^PACKAGE_TARNAME='fu'\$" configure], [], [ignore])
219 AT_CLEANUP
222 ## ------------------------------------- ##
223 ## AC_INIT with unusual version strings. ##
224 ## ------------------------------------- ##
226 AT_SETUP([AC_INIT with unusual version strings])
228 AT_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])
231 AC_OUTPUT
234 if echo 'ab*c' | grep -F 'ab*c' >/dev/null 2>&1; then
235   FGREP="grep -F"
236 else
237   FGREP=fgrep
240 AT_CHECK_AUTOCONF([-Werror])
241 AT_CHECK_CONFIGURE([-q])
242 AT_CHECK_CONFIGURE([--help], [], [stdout])
243 AT_CHECK([[$FGREP 'com/?a=b&c=d#e' stdout]], [], [ignore])
244 AT_CHECK_CONFIGURE([--version], [], [stdout])
245 AT_CHECK([$FGREP 'GNU String++ with  spaces (foo)' stdout], [], [ignore])
246 AT_CHECK([$FGREP '2.48++  (2010-07-03)' stdout], [], [ignore])
248 AT_CHECK([./config.status --help], [], [stdout])
249 AT_CHECK([[$FGREP 'com/?a=b&c=d#e' stdout]], [], [ignore])
250 AT_CHECK([./config.status --version], [], [stdout])
251 AT_CHECK([$FGREP 'GNU String++ with  spaces (foo)' stdout], [], [ignore])
252 AT_CHECK([$FGREP '2.48++  (2010-07-03)' stdout], [], [ignore])
254 AT_DATA([configure.ac],
255 [[AC_INIT([GNU "String++"],
256           [2.48], [http://example.com/], [clisp])
257 AC_OUTPUT
260 AT_CHECK_AUTOCONF([-Werror], [1], [ignore], [stderr])
261 AT_CHECK([grep 'AC_INIT: not a literal: ' stderr], [], [ignore])
263 AT_DATA([configure.ac],
264 [[AC_INIT([GNU String++],
265           ['codename' 2.48], [http://example.com/], [clisp])
266 AC_OUTPUT
269 AT_CHECK_AUTOCONF([-Werror], [1], [ignore], [stderr])
270 AT_CHECK([grep 'AC_INIT: not a literal: ' stderr], [], [ignore])
272 AT_DATA([configure.ac],
273 [[AC_INIT([GNU
274 String++], [2.48], [http://example.com/], [clisp])
275 AC_OUTPUT
278 AT_CHECK_AUTOCONF([-Werror], [1], [ignore], [stderr])
279 AT_CHECK([grep 'AC_INIT: not a literal: ' stderr], [], [ignore])
281 AT_CLEANUP
284 ## -------------- ##
285 ## AC_COPYRIGHT.  ##
286 ## -------------- ##
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.
291 AT_SETUP([AC@&t@_COPYRIGHT])
293 AT_DATA([configure.ac],
294 [[AC_INIT([GNU fu], [1.0])
295 AC_COPYRIGHT([[This is just a test notice, not a real one, so let's avoid
296 words that may be matched by scanners for legal things,
297 causing extra work for distributors.
298 Multi-line values should be supported.
302 AT_CHECK_AUTOCONF
303 AT_CHECK_CONFIGURE([--version], [], [stdout])
304 AT_CHECK([grep 'Copyright.*Free Software Foundation' stdout], [], [ignore])
305 AT_CHECK([grep 'This is just a test notice' stdout], [], [ignore])
306 AT_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])
310 AT_CHECK([sed 50q configure | grep 'This is just a test notice'], [], [ignore])
312 AT_CLEANUP
315 ## ---------------- ##
316 ## AC_CACHE_CHECK.  ##
317 ## ---------------- ##
319 # Make sure AC_CACHE_CHECK is silent with -q.
320 # Also make sure we warn about cache id's not named with `_cv_'.
322 AT_SETUP([AC_CACHE_CHECK])
323 AT_KEYWORDS([CONFIG_SITE])
325 # Don't let a config.site file affect this test.
326 AS_UNSET([CONFIG_SITE])
328 AT_DATA([configure.ac],
329 [[AC_INIT
330 # m4_define([ac_nothing], [ac_cv_absolutely_nothing])
331 AC_CACHE_CHECK([for nothing],
332                [ac_nothing],
333                [ac_nothing=found])
335 AC_MSG_CHECKING([for some other variable])
336 commands_to_set_it_was_run=false
337 AC_CACHE_VAL([my_cv_variable], [
338 # FOO
339 commands_to_set_it_was_run=true
340 my_cv_variable=true
342 AC_MSG_RESULT([$my_cv_variable])
344 # Ensure that the result is available at this point.
345 if ${my_cv_variable+false} :; then
346   AC_MSG_ERROR([AC@&@&t@t@_CACHE_VAL did not ensure that the cache variable was set])
349 # AC_CACHE_SAVE should be enough here, no need for AC_OUTPUT.
350 AC_CACHE_SAVE
353 AT_CHECK_AUTOCONF([], [], [], [stderr])
354 AT_CHECK([grep 'must contain _cv_ to be cached' stderr], [], [ignore])
356 # Do not warn about defines:
357 sed 's/^# m4_define/m4_define/' configure.ac > t
358 mv -f t configure.ac
359 AT_CHECK_AUTOCONF
360 AT_CHECK_CONFIGURE([-q])
362 sed '/m4_define/d; s/ac_nothing/ac_cv_nothing/' configure.ac > t
363 mv -f t configure.ac
364 AT_CHECK_AUTOCONF
365 AT_CHECK_CONFIGURE([-q])
367 # Print a message saying that the result was cached, iff it was cached.
368 AT_CHECK_CONFIGURE([], [], [stdout])
369 AT_CHECK([grep 'cached' stdout], [1])
370 AT_CHECK_CONFIGURE([my_cv_variable='yes it is set'], [], [stdout])
371 AT_CHECK([grep 'cached.*yes it is set' stdout], [], [ignore])
373 # --cache-file is honored and has caching semantics.
374 AT_CHECK_CONFIGURE([--cache-file=foobar.cache], [], [stdout])
375 AT_CHECK([grep 'cached' stdout], [1])
376 AT_CHECK([test ! -f config.cache])
377 AT_CHECK([grep 'my_cv_variable.*true' foobar.cache], [], [ignore])
378 AT_CHECK_CONFIGURE([--cache-file=foobar.cache], [], [stdout])
379 AT_CHECK([grep 'some other variable.*cached.*true' stdout], [], [ignore])
381 # A setting on the command line overrides the cache.
382 AT_CHECK_CONFIGURE([--cache-file=foobar.cache my_cv_variable='override'], [], [stdout])
383 AT_CHECK([grep 'cached.*override' stdout], [], [ignore])
384 AT_CHECK([grep 'my_cv_variable.*override' foobar.cache], [], [ignore])
386 # Values containing braces need special internal treatment.
387 AT_CHECK_CONFIGURE([-C ac_cv_nothing='{' my_cv_variable='contains } brace'],
388                    [], [stdout])
389 AT_CHECK([grep 'ac_cv_nothing.*{' config.cache], [], [ignore])
390 AT_CHECK([grep 'my_cv_variable.*contains } brace' config.cache], [], [ignore])
391 AT_CHECK_CONFIGURE([-C], [], [stdout])
392 AT_CHECK([grep 'nothing.*{' stdout], [], [ignore])
393 AT_CHECK([grep 'some other variable.*contains } brace' stdout], [], [ignore])
394 rm -f config.cache
396 # Diagnose common side-effects that are errors in COMMANDS-TO-SET-IT:
397 sed 's/^# FOO/AC_DEFINE([some-define], [1], [oooh.])/' configure.ac > t
398 mv -f t configure.ac
399 AT_CHECK_AUTOCONF([], [], [], [stderr])
400 AT_CHECK([grep 'suspicious.*AC_DEFINE' stderr], [], [ignore])
402 sed 's/^AC_DEFINE.*/AC_SUBST([some_substitution], [oooh.])/' configure.ac > t
403 mv -f t configure.ac
404 AT_CHECK_AUTOCONF([], [], [], [stderr])
405 AT_CHECK([grep 'suspicious.*AC_SUBST' stderr], [], [ignore])
407 # Ensure the examples from the manual work as intended.
408 # Taken from autoconf.texi:Caching Results
409 AT_DATA([configure.ac],
410 [[AC_INIT
411 AC_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])
420 AC_SHELL_TRUE
422 AT_CHECK_AUTOCONF([-Werror], [1], [], [stderr])
423 AT_CHECK([grep 'suspicious.*AC_DEFINE' stderr], [], [ignore])
425 # Taken from autoconf.texi:Caching Results
426 AT_DATA([configure.ac],
427 [[AC_INIT
428 AC_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
437 AC_SHELL_TRUE
438 AC_OUTPUT
440 AT_CHECK_AUTOCONF([-Werror])
441 AT_CHECK_CONFIGURE([-C], [], [stdout])
442 AT_CHECK([grep my_cv_shell_true_works config.cache], [], [ignore])
443 AT_CHECK([grep 'true.*works.*yes' stdout], [], [ignore])
445 AT_CHECK_CONFIGURE([--config-cache], [], [stdout])
446 AT_CHECK([grep 'true.*works.*cached.*yes' stdout], [], [ignore])
448 # config.status only pays attention to the cache file with --recheck.
449 AT_CHECK([./config.status], [], [stdout])
450 AT_CHECK([grep cache stdout], [1])
451 AT_CHECK([./config.status --recheck], [], [stdout])
452 AT_CHECK([grep cache stdout], [0], [ignore])
454 # By default, configure uses no cache file, neither loading nor updating it.
455 : > a-stamp-file
456 AT_CHECK_CONFIGURE([], [], [stdout])
457 AT_CHECK([grep cache stdout], [1])
458 AT_CHECK([LC_ALL=C ls -t config.cache a-stamp-file | sed 1q | grep config.cache], [1])
460 # Using a symlinked cache file works.
461 : > cache
462 rm -f config.cache
463 AS_LN_S([cache], [config.cache])
464 AT_CHECK_CONFIGURE([-C])
465 # Either the system does not support symlinks, or the symlinked-to file
466 # should be updated.
467 AT_CHECK([test -s cache || test ! -h config.cache])
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 -.
471 AT_DATA([-config.site],
472 [[cache_file=sitecache
474 AT_DATA([sitecache],
475 [[my_cv_some_preset_cache_var=yes
477 CONFIG_SITE=-config.site
478 export CONFIG_SITE
479 AT_CHECK_CONFIGURE
480 AT_CHECK([grep my_cv_some_preset_cache_var sitecache], [], [ignore])
481 AT_CHECK([grep my_cv_shell_true_works sitecache], [], [ignore])
482 AT_CHECK_CONFIGURE([], [], [stdout])
483 AT_CHECK([grep 'whether true.*works.*cached' stdout], [], [ignore])
485 dnl Until we can find a way to avoid catastrophic failure,
486 dnl skip the rest of this test on such shells.
487 echo 'if' > syntax
488 AT_CHECK([${CONFIG_SHELL-$SHELL} -c 'case `. ./syntax; echo $?` in
489             0|"") exit 77;; esac'], [0], [ignore], [ignore])
491 # Check that config cache scripts must be well-formed.
492 AT_DATA([bad.site],
493 [[fi
495 CONFIG_SITE=$PWD/bad.site
496 AT_CHECK_CONFIGURE([ || exit 1], [1], [stdout], [stderr])
497 AT_CHECK([grep 'failed to load site script' stderr], [], [ignore], [ignore],
498          [AT_CHECK([grep 'whether true' stdout], [1])])
500 # However, a missing file is ignored.
501 CONFIG_SITE=./no-such-file
502 AT_CHECK_CONFIGURE
504 AT_CLEANUP
507 ## --------------- ##
508 ## AC_CACHE_LOAD.  ##
509 ## --------------- ##
511 # Test AC_CACHE_LOAD.
513 AT_SETUP([AC_CACHE_LOAD])
515 AT_DATA([configure.ac],
516 [[AC_INIT
517 $some_test_code
518 AC_CACHE_LOAD
519 AC_MSG_NOTICE([some_cv_variable is $some_cv_variable])
520 AC_OUTPUT
522 AT_CHECK_AUTOCONF
523 AS_UNSET([some_test_code])
524 AT_DATA([new-cache],
525 [[some_cv_variable=value-from-new-cache
527 AT_CHECK_CONFIGURE([some_test_code='eval cache_file=new-cache'], [], [stdout])
528 AT_CHECK([grep 'some_cv_variable.*value-from-new-cache' stdout], [], [ignore])
530 AT_CLEANUP
533 ## ---------------- ##
534 ## AC_COMPUTE_INT.  ##
535 ## ---------------- ##
537 # Make sure AC_COMPUTE_INT fails properly.
539 AT_SETUP([AC_COMPUTE_INT])
541 AT_DATA([configure.ac],
542 [[AC_INIT
543 AC_COMPUTE_INT([invalid_expression],
544                [**0**],
545                [],
546                [invalid_expression=failed])
547 test "$invalid_expression" = failed ||
548   AC_MSG_ERROR([**0** evaluated to $invalid_expression instead of failing])
551 AT_CHECK_AUTOCONF
552 AT_CHECK_CONFIGURE
554 AT_CLEANUP
557 ## ---------------- ##
558 ## AC_TRY_COMMAND.  ##
559 ## ---------------- ##
561 AT_SETUP([AC_TRY_COMMAND])
563 AT_DATA([configure.ac],
564 [[AC_INIT
566 if 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   :
570 else
571   AC_MSG_ERROR([didn't see the Cat in the Hat])
574 if 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])
581 AT_CHECK_AUTOCONF
582 AT_CHECK_CONFIGURE([-q])
584 AT_CLEANUP
587 ## ------------ ##
588 ## Input/Output ##
589 ## ------------ ##
591 AT_SETUP([Input/Output])
593 AT_DATA([configure.ac],
594 [[AC_INIT
595 cat <&AS@&t@_ORIGINAL_STDIN_FD >&AS@&t@_MESSAGE_FD
597 AT_CHECK_AUTOCONF
598 AT_CHECK([echo Hello | CONFIG_SITE=/dev/null ./configure $configure_options | grep -v 'configure: loading site script '],, [Hello
600 AT_CHECK([echo Hello | CONFIG_SITE=/dev/null ./configure $configure_options --silent])
602 AT_CLEANUP
605 ## ------------------- ##
606 ## configure arguments ##
607 ## ------------------- ##
609 AT_SETUP([configure arguments])
611 AT_DATA([configure.ac],
612 [[AC_INIT
613 echo "$@"
616 AT_CHECK_AUTOCONF
617 AT_CHECK_CONFIGURE([FOO=bar --enable-baz --without-zork --silent], [0], [stdout], [ignore])
618 AT_CHECK([grep 'FOO=bar --enable-baz --without-zork --silent' stdout], [0], [ignore], [ignore])
620 dnl check that syntax error is detected
621 AT_CHECK_CONFIGURE([=], [1], [], [ignore], [ignore])
622 AT_CHECK_CONFIGURE([1=2], [1], [], [ignore], [ignore])
624 AT_CLEANUP
627 ## ------------------------------ ##
628 ## AC_ARG_ENABLE and AC_ARG_WITH. ##
629 ## ------------------------------ ##
631 AT_SETUP([AC_ARG_ENABLE and AC_ARG_WITH])
633 AT_DATA_M4SH([configure.ac],
634 [[AC_INIT
635 # Taken from autoconf.texi:Pretty Help Strings.
636 AC_ARG_WITH([foo],
637   [AS_HELP_STRING([--with-foo],
638      [use foo (default is no)])],
639   [use_foo=$withval],
640   [use_foo=no])
641 AC_ARG_WITH([c++],
642   [AS_HELP_STRING([--with-c++],
643      [with c++])],
644   [choice_with=$withval])
645 AC_ARG_ENABLE([c++],
646   [AS_HELP_STRING([--enable-c++],
647      [enable c++])],
648   [choice_enable=$enableval])
649 echo "use_foo: $use_foo"
650 echo "with_c++: $with_c__, $choice_with"
651 echo "enable_c++: $enable_c__, $choice_enable"
654 AT_CHECK_AUTOCONF
655 AT_CHECK_CONFIGURE([--help | grep foo], [0],
656 [[  --with-foo              use foo (default is no)
657 ]], [ignore])
658 AT_CHECK_CONFIGURE([--with-foo=yes --with-c++ --disable-c++],
659   [], [stdout], [ignore])
660 AT_CHECK([grep 'use_foo: yes' stdout], [], [ignore])
661 AT_CHECK([grep 'with_c++: yes, yes' stdout], [], [ignore])
662 AT_CHECK([grep 'enable_c++: no, no' stdout], [], [ignore])
663 AT_CHECK([grep 'unrecognized option' stdout], [1])
664 AT_CHECK_CONFIGURE([--without-foo --with-c++=no --enable-c++=maybe],
665   [], [stdout], [ignore])
666 AT_CHECK([grep 'use_foo: no' stdout], [], [ignore])
667 AT_CHECK([grep 'with_c++: no, no' stdout], [], [ignore])
668 AT_CHECK([grep 'enable_c++: maybe, maybe' stdout], [], [ignore])
669 AT_CHECK([grep 'unrecognized option' stdout], [1])
670 AT_CHECK_CONFIGURE([], [], [stdout], [ignore])
671 AT_CHECK([grep 'use_foo: no' stdout], [], [ignore])
672 AT_CHECK([grep 'with_c++: , $' stdout], [], [ignore])
673 AT_CHECK([grep 'enable_c++: , $' stdout], [], [ignore])
674 AT_CHECK([grep 'unrecognized option' stdout], [1])
676 AT_CLEANUP
679 ## --------------------- ##
680 ## configure directories ##
681 ## --------------------- ##
683 AT_SETUP([configure directories])
685 CONFIG_SITE=/dev/null
686 export CONFIG_SITE
688 AT_DATA([foo.in],
689 [[prefix=@prefix@
690 exec_prefix=@exec_prefix@
691 libdir=@libdir@
694 AT_DATA([configure.ac],
695 [[AC_INIT
696 AC_CONFIG_FILES([foo])
697 AC_OUTPUT
700 AT_CHECK_AUTOCONF
701 dnl check that relative paths are rejected
702 AT_CHECK_CONFIGURE([--libdir=.], [1], [ignore], [stderr])
703 AT_CHECK([grep 'expected an absolute directory name for --libdir: \.' stderr],
704          [0], [ignore])
706 dnl check that extra slashes are stripped, and that defaults are not expanded
707 AT_CHECK_CONFIGURE([--prefix=/usr//])
708 AT_CHECK([cat foo], [0], [[prefix=/usr
709 exec_prefix=${prefix}
710 libdir=${exec_prefix}/lib
713 AT_CLEANUP
715 ## ---------- ##
716 ## AC_SUBST.  ##
717 ## ---------- ##
719 AT_SETUP([AC_SUBST])
720 AT_KEYWORDS([AS@&t@_IDENTIFIER_IF])
722 # Check that a valid variable name is used.
723 AT_DATA([configure.ac],
724 [[AC_INIT([test], [1])
725 AC_SUBST([1], [bar])
726 AC_OUTPUT
728 AT_CHECK_AUTOCONF([], [1], [], [stderr])
729 AT_CHECK([grep 'not a valid shell variable' stderr], [], [ignore])
731 AT_DATA([configure.ac],
732 [[AC_INIT([test], [1])
733 AC_SUBST([], [bar])
734 AC_OUTPUT
736 AT_CHECK_AUTOCONF([], [1], [], [stderr])
737 AT_CHECK([grep 'not a valid shell variable' stderr], [], [ignore])
739 AT_DATA([configure.ac],
740 [[AC_INIT([test], [1])
741 AC_SUBST([*], [bar])
742 AC_OUTPUT
744 AT_CHECK_AUTOCONF([], [1], [], [stderr])
745 AT_CHECK([grep 'not a valid shell variable' stderr], [], [ignore])
747 # Make sure AC_SUBST handles variables as expected.
748 AT_DATA([file.in],
749 [[@FOO@
750 @BAR@
753 AT_DATA([configure.ac],
754 [[AC_INIT([test], [0])
755 m4_define([FOO], [baz])
756 AC_SUBST([FOO], [bar])
757 BAR=one
758 AC_SUBST([B@&t@AR])
759 BAR=two
760 AC_CONFIG_FILES([file])
761 AC_OUTPUT
764 AT_CHECK_AUTOCONF([], [], [], [stderr])
765 AT_CHECK_CONFIGURE
766 AT_CHECK([cat file], [],
767 [[bar
772 AT_CLEANUP