3 AT_BANNER([Autoconf base layer.])
5 # Copyright (C) 2000, 2001, 2003, 2005, 2006, 2007, 2008, 2009, 2010
6 # Free Software Foundation, 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],
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_KEYWORDS([m4@&t@_require])
74 AT_DATA([configure.ac],
75 [[AC_REQUIRE([AC_PROG_CC])
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
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],
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"])
113 case $multi_test:$single_test in
115 ...:* ) AC_MSG_ERROR([DEFUN_ONCE is broken]);;
116 *:. ) AC_MSG_ERROR([DEFUN is broken (Wow, congrats!)]);;
120 AT_CHECK_AUTOCONF([], 0, [])
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],
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, [])
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],
179 [AC_REQUIRE([INNER_TEST])])
181 AC_DEFUN([INNER_TEST],
182 [inner_test=".$inner_test"])
186 AC_PROVIDE([INNER_TEST])
191 * ) AC_MSG_ERROR([received `$inner_test']);;
205 # Make sure AC_INIT sets PACKAGE_TARNAME properly.
209 AT_DATA([configure.ac],
210 [[AC_INIT([GNU fu], [1.0], [bug-fu@gnu.org])
214 AT_CHECK_CONFIGURE([-q])
216 # Ensure we get the expected definition:
217 AT_CHECK([grep "^PACKAGE_TARNAME='fu'\$" configure], [], [ignore])
222 ## ---------------- ##
223 ## AC_CACHE_CHECK. ##
224 ## ---------------- ##
226 # Make sure AC_CACHE_CHECK is silent with -q.
227 # Also make sure we warn about cache id's not named with `_cv_'.
229 AT_SETUP([AC_CACHE_CHECK])
231 AT_DATA([configure.ac],
233 # m4_define([ac_nothing], [ac_cv_absolutely_nothing])
234 AC_CACHE_CHECK([for nothing],
239 AT_CHECK_AUTOCONF([], [], [], [stderr])
240 AT_CHECK([grep 'must contain _cv_ to be cached' stderr], [], [ignore])
242 # Do not warn about defines:
243 sed 's/^# //' configure.ac > t
246 AT_CHECK_CONFIGURE([-q])
248 sed '/m4_define/d; s/ac_nothing/ac_cv_nothing/' configure.ac > t
251 AT_CHECK_CONFIGURE([-q])
256 ## ---------------- ##
257 ## AC_COMPUTE_INT. ##
258 ## ---------------- ##
260 # Make sure AC_COMPUTE_INT fails properly.
262 AT_SETUP([AC_COMPUTE_INT])
264 AT_DATA([configure.ac],
266 AC_COMPUTE_INT([invalid_expression],
269 [invalid_expression=failed])
270 test "$invalid_expression" = failed ||
271 AC_MSG_ERROR([**0** evaluated to $invalid_expression instead of failing])
280 ## ---------------- ##
281 ## AC_TRY_COMMAND. ##
282 ## ---------------- ##
284 AT_SETUP([AC_TRY_COMMAND])
286 AT_DATA([configure.ac],
289 if AC_TRY_COMMAND([(echo "The Cat in the Hat";
290 echo "The Hat in the Cat" >&2) |
291 grep \^The\ Cat\ in\ the\ Hat\$ >/dev/null]); then
294 AC_MSG_ERROR([didn't see the Cat in the Hat])
297 if AC_TRY_COMMAND([(echo "The Cat in the Hat";
298 echo "The Hat in the Cat" >&2) |
299 grep \^The\ Hat\ in\ the\ Cat\$ >/dev/null]); then
300 AC_MSG_ERROR([saw the Hat in the Cat])
305 AT_CHECK_CONFIGURE([-q])
314 AT_SETUP([Input/Output])
316 AT_DATA([configure.ac],
318 cat <&AS@&t@_ORIGINAL_STDIN_FD >&AS@&t@_MESSAGE_FD
321 AT_CHECK([echo Hello | CONFIG_SITE=/dev/null ./configure $configure_options | grep -v 'configure: loading site script '],, [Hello
323 AT_CHECK([echo Hello | CONFIG_SITE=/dev/null ./configure $configure_options --silent])
328 ## ------------------- ##
329 ## configure arguments ##
330 ## ------------------- ##
332 AT_SETUP([configure arguments])
334 AT_DATA([configure.ac],
340 AT_CHECK_CONFIGURE([FOO=bar --enable-baz --without-zork --silent], [0], [stdout], [ignore])
341 AT_CHECK([grep 'FOO=bar --enable-baz --without-zork --silent' stdout], [0], [ignore], [ignore])
343 dnl check that syntax error is detected
344 AT_CHECK_CONFIGURE([=], [1], [], [ignore], [ignore])
345 AT_CHECK_CONFIGURE([1=2], [1], [], [ignore], [ignore])
350 ## --------------------- ##
351 ## configure directories ##
352 ## --------------------- ##
354 AT_SETUP([configure directories])
358 exec_prefix=@exec_prefix@
362 AT_DATA([configure.ac],
364 AC_CONFIG_FILES([foo])
369 dnl check that relative paths are rejected
370 AT_CHECK_CONFIGURE([--libdir=.], [1], [ignore], [stderr])
371 AT_CHECK([grep 'expected an absolute directory name for --libdir: \.' stderr],
374 dnl check that extra slashes are stripped, and that defaults are not expanded
375 AT_CHECK_CONFIGURE([--prefix=/usr//])
376 AT_CHECK([cat foo], [0], [[prefix=/usr
377 exec_prefix=${prefix}
378 libdir=${exec_prefix}/lib