3 AT_BANNER([Autoconf base layer.])
5 # Copyright (C) 2000, 2001, 2003, 2005, 2006 Free Software Foundation, Inc.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2, or (at your option)
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 ## ------------------------------- ##
24 ## AC_REQUIRE: topological sort.. ##
25 ## ------------------------------- ##
27 # Check that dependencies are always properly honored.
29 AT_SETUP([AC_REQUIRE: topological sort])
31 AT_DATA([configure.ac],
32 [[define([REQUIRE_AND_CHECK],
34 test -z "$m4@&t@_translit([$1], [A-Z], [a-z])" && AS_EXIT(1)])
37 [REQUIRE_AND_CHECK([TEST2a])
38 REQUIRE_AND_CHECK([TEST2b])
45 [REQUIRE_AND_CHECK([TEST3])
49 [REQUIRE_AND_CHECK([TEST2a])
56 AC_MSG_ERROR([\$test1 is empty])
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_DATA([configure.ac],
74 [[AC_REQUIRE([AC_PROG_CC])
77 AT_CHECK_AUTOCONF([], [1], [],
78 [[configure.ac:1: error: AC_REQUIRE(AC_PROG_CC): cannot be used outside of an AC_DEFUN'd macro
79 configure.ac:1: the top level
80 autom4te: m4 failed with exit status: 1
85 ## ----------------------------------------------- ##
86 ## AC_REQUIRE and AC_DEFUN_ONCE: Require, expand. ##
87 ## ----------------------------------------------- ##
89 AT_SETUP([AC_REQUIRE & AC_DEFUN_ONCE: Require, expand])
91 AT_DATA([configure.ac],
93 [AC_REQUIRE([MULTI_TEST])
94 AC_REQUIRE([SINGLE_TEST])])
96 AC_DEFUN([MULTI_TEST],
97 [multi_test=".$multi_test"])
99 AC_DEFUN_ONCE([SINGLE_TEST],
100 [single_test=".$single_test"])
111 case $multi_test:$single_test in
113 ...:* ) AC_MSG_ERROR([DEFUN_ONCE is broken]);;
114 *:. ) AC_MSG_ERROR([DEFUN is broken (Wow, congrats!)]);;
118 AT_CHECK_AUTOCONF([], 0, [],
119 [configure.ac:17: warning: SINGLE_TEST invoked multiple times
120 configure.ac:18: warning: SINGLE_TEST invoked multiple times
129 ## ----------------------------------------------- ##
130 ## AC_REQUIRE and AC_DEFUN_ONCE: Expand, require. ##
131 ## ----------------------------------------------- ##
133 AT_SETUP([AC_REQUIRE & AC_DEFUN_ONCE: Expand, require])
135 AT_DATA([configure.ac],
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"])
155 case $multi_test:$single_test in
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']);;
163 AT_CHECK_AUTOCONF([], 0, [],
164 [configure.ac:16: warning: SINGLE_TEST invoked multiple times
172 ## ------------------------- ##
173 ## AC_REQUIRE & AC_PROVIDE. ##
174 ## ------------------------- ##
176 AT_SETUP([AC_REQUIRE & AC_PROVIDE])
178 AT_DATA([configure.ac],
180 [AC_REQUIRE([INNER_TEST])])
182 AC_DEFUN([INNER_TEST],
183 [inner_test=".$inner_test"])
187 AC_PROVIDE([INNER_TEST])
192 * ) AC_MSG_ERROR([received `$inner_test']);;
202 ## ---------------- ##
203 ## AC_CACHE_CHECK. ##
204 ## ---------------- ##
206 # Make sure AC_CACHE_CHECK is silent with -q.
208 AT_SETUP([AC_CACHE_CHECK])
210 AT_DATA([configure.ac],
212 AC_CACHE_CHECK([for nothing],
218 AT_CHECK_CONFIGURE([-q])
223 ## ---------------- ##
224 ## AC_TRY_COMMAND. ##
225 ## ---------------- ##
227 AT_SETUP([AC_TRY_COMMAND])
229 AT_DATA([configure.ac],
232 if AC_TRY_COMMAND([(echo "The Cat in the Hat";
233 echo "The Hat in the Cat" >&2) |
234 grep \^The\ Cat\ in\ the\ Hat\$ >/dev/null]); then
237 AC_MSG_ERROR([Didn't see the Cat in the Hat!])
240 if AC_TRY_COMMAND([(echo "The Cat in the Hat";
241 echo "The Hat in the Cat" >&2) |
242 grep \^The\ Hat\ in\ the\ Cat\$ >/dev/null]); then
243 AC_MSG_ERROR([Saw the Hat in the Cat!])
248 AT_CHECK_CONFIGURE([-q])
257 AT_SETUP([Input/Output])
259 m4_pattern_allow([^AS_(MESSAGE|ORIGINAL_STDIN)_FD$])
260 AT_DATA([configure.ac],
262 cat <&AS_ORIGINAL_STDIN_FD >&AS_MESSAGE_FD
265 AT_CHECK([echo Hello | top_srcdir=$abs_top_srcdir ./configure | grep -v 'configure: loading site script '],, [Hello
267 AT_CHECK([echo Hello | top_srcdir=$abs_top_srcdir ./configure --silent])