3 AT_BANNER([Autoconf base layer.])
5 # Copyright (C) 2000, 2001, 2003, 2005, 2006, 2007 Free Software
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 2, or (at your option)
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, write to the Free Software
20 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 ## ------------------------------- ##
25 ## AC_REQUIRE: topological sort.. ##
26 ## ------------------------------- ##
28 # Check that dependencies are always properly honored.
30 AT_SETUP([AC_REQUIRE: topological sort])
32 AT_DATA([configure.ac],
33 [[define([REQUIRE_AND_CHECK],
35 test -z "$m4@&t@_translit([$1], [A-Z], [a-z])" && AS_EXIT(1)])
38 [REQUIRE_AND_CHECK([TEST2a])
39 REQUIRE_AND_CHECK([TEST2b])
46 [REQUIRE_AND_CHECK([TEST3])
50 [REQUIRE_AND_CHECK([TEST2a])
57 AC_MSG_ERROR([\$test1 is empty])
67 ## --------------------------- ##
68 ## AC_REQUIRE: error message. ##
69 ## --------------------------- ##
71 # Check that the message mentions AC_DEFUN, not m4_defun.
73 AT_SETUP([AC_REQUIRE: error message])
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]])
92 AT_DATA([configure.ac],
94 [AC_REQUIRE([MULTI_TEST])
95 AC_REQUIRE([SINGLE_TEST])])
97 AC_DEFUN([MULTI_TEST],
98 [multi_test=".$multi_test"])
100 AC_DEFUN_ONCE([SINGLE_TEST],
101 [single_test=".$single_test"])
112 case $multi_test:$single_test in
114 ...:* ) AC_MSG_ERROR([DEFUN_ONCE is broken]);;
115 *:. ) AC_MSG_ERROR([DEFUN is broken (Wow, congrats!)]);;
119 AT_CHECK_AUTOCONF([], 0, [],
120 [configure.ac:17: warning: SINGLE_TEST invoked multiple times
121 configure.ac:18: warning: SINGLE_TEST invoked multiple times
130 ## ----------------------------------------------- ##
131 ## AC_REQUIRE and AC_DEFUN_ONCE: Expand, require. ##
132 ## ----------------------------------------------- ##
134 AT_SETUP([AC_REQUIRE & AC_DEFUN_ONCE: [Expand, require]])
136 AT_DATA([configure.ac],
138 [AC_REQUIRE([MULTI_TEST])
139 AC_REQUIRE([SINGLE_TEST])])
141 AC_DEFUN([MULTI_TEST],
142 [multi_test=".$multi_test"])
144 AC_DEFUN_ONCE([SINGLE_TEST],
145 [single_test=".$single_test"])
156 case $multi_test:$single_test in
158 ..:* ) AC_MSG_ERROR([DEFUN_ONCE is broken]);;
159 *:. ) AC_MSG_ERROR([DEFUN is broken (Wow, congrats!)]);;
160 * ) AC_MSG_ERROR([received `$multi_test:$single_test']);;
164 AT_CHECK_AUTOCONF([], 0, [],
165 [configure.ac:16: warning: SINGLE_TEST invoked multiple times
173 ## ------------------------- ##
174 ## AC_REQUIRE & AC_PROVIDE. ##
175 ## ------------------------- ##
177 AT_SETUP([AC_REQUIRE & AC_PROVIDE])
179 AT_DATA([configure.ac],
181 [AC_REQUIRE([INNER_TEST])])
183 AC_DEFUN([INNER_TEST],
184 [inner_test=".$inner_test"])
188 AC_PROVIDE([INNER_TEST])
193 * ) AC_MSG_ERROR([received `$inner_test']);;
203 ## ---------------- ##
204 ## AC_CACHE_CHECK. ##
205 ## ---------------- ##
207 # Make sure AC_CACHE_CHECK is silent with -q.
208 # Also make sure we warn about cache id's not named with `_cv_'.
210 AT_SETUP([AC_CACHE_CHECK])
212 AT_DATA([configure.ac],
214 # m4_define([ac_nothing], [ac_cv_absolutely_nothing])
215 AC_CACHE_CHECK([for nothing],
220 AT_CHECK_AUTOCONF([], [], [], [stderr])
221 AT_CHECK([grep 'must contain _cv_ to be cached' stderr], [], [ignore])
223 # Do not warn about defines:
224 sed 's/^# //' configure.ac > t
227 AT_CHECK_CONFIGURE([-q])
229 sed '/m4_define/d; s/ac_nothing/ac_cv_nothing/' configure.ac > t
232 AT_CHECK_CONFIGURE([-q])
237 ## ---------------- ##
238 ## AC_COMPUTE_INT. ##
239 ## ---------------- ##
241 # Make sure AC_COMPUTE_INT fails properly.
243 AT_SETUP([AC_COMPUTE_INT])
245 AT_DATA([configure.ac],
247 AC_COMPUTE_INT([invalid_expression],
250 [invalid_expression=failed])
251 test "$invalid_expression" = failed ||
252 AC_MSG_ERROR([**0** evaluated to $invalid_expression instead of failing])
261 ## ---------------- ##
262 ## AC_TRY_COMMAND. ##
263 ## ---------------- ##
265 AT_SETUP([AC_TRY_COMMAND])
267 AT_DATA([configure.ac],
270 if AC_TRY_COMMAND([(echo "The Cat in the Hat";
271 echo "The Hat in the Cat" >&2) |
272 grep \^The\ Cat\ in\ the\ Hat\$ >/dev/null]); then
275 AC_MSG_ERROR([Didn't see the Cat in the Hat!])
278 if AC_TRY_COMMAND([(echo "The Cat in the Hat";
279 echo "The Hat in the Cat" >&2) |
280 grep \^The\ Hat\ in\ the\ Cat\$ >/dev/null]); then
281 AC_MSG_ERROR([Saw the Hat in the Cat!])
286 AT_CHECK_CONFIGURE([-q])
295 AT_SETUP([Input/Output])
297 m4_pattern_allow([^AS_(MESSAGE|ORIGINAL_STDIN)_FD$])
298 AT_DATA([configure.ac],
300 cat <&AS_ORIGINAL_STDIN_FD >&AS_MESSAGE_FD
303 AT_CHECK([echo Hello | ./configure | grep -v 'configure: loading site script '],, [Hello
305 AT_CHECK([echo Hello | ./configure --silent])
310 ## ------------------- ##
311 ## configure arguments ##
312 ## ------------------- ##
314 AT_SETUP([configure arguments])
316 AT_DATA([configure.ac],
322 AT_CHECK_CONFIGURE([FOO=bar --enable-baz --without-zork --silent], [0], [stdout], [ignore])
323 AT_CHECK([grep 'FOO=bar --enable-baz --without-zork --silent' stdout], [0], [ignore], [ignore])
328 ## --------------------- ##
329 ## configure directories ##
330 ## --------------------- ##
332 AT_SETUP([configure directories])
336 exec_prefix=@exec_prefix@
340 AT_DATA([configure.ac],
342 AC_CONFIG_FILES([foo])
347 dnl check that relative paths are rejected
348 AT_CHECK_CONFIGURE([--libdir=.], [1], [ignore], [stderr])
349 AT_CHECK([grep 'expected an absolute directory name for --libdir: \.' stderr],
352 dnl check that extra slashes are stripped, and that defaults are not expanded
353 AT_CHECK_CONFIGURE([--prefix=/usr//])
354 AT_CHECK([cat foo], [0], [[prefix=/usr
355 exec_prefix=${prefix}
356 libdir=${exec_prefix}/lib