2 # Copyright (C) 2012 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
17 # Several tests on the use of the m4 macro AC_CONFIG_MACRO_DIRS with
18 # aclocal. See also related test 'aclocal-macrodir.tap'.
20 am_create_testdir=empty
23 { $AUTOCONF -o /dev/null - <<END
25 AC_CONFIG_MACRO_DIRS([.])
27 } || skip_all_ "autoconf doesn't define the AC_CONFIG_MACRO_DIRS macro"
31 ocwd=$(pwd) || fatal_ "getting current working directory"
32 ACLOCAL_PATH=; unset ACLOCAL_PATH
35 # General utility functions and variables.
37 # TODO: These should maybe be refactored, generalized and
38 # moved into 't/ax/tap-functions.sh' ...
48 if test -n "$description"; then
49 fatal_ "'test_begin' called, but another test seems active already"
54 echo "$description" > README.txt
57 tcount=$(($tcount + 1)) && test $tcount -gt 0 \
58 || fatal_ "failed to bump the test count"
65 if test -z "$description"; then
66 fatal_ "'test_end' called, but no test seems active"
68 cd "$ocwd" || fatal_ "cannot chdir back to top-level directory"
69 result_ "$r" -D "$directive" -- "$description"
70 # Don't leave directories for successful subtests hanging around.
71 if test -z "$directive" && test "$r" = ok; then
72 rm -rf "$tcount.d" || fatal_ "removing subdir $tcount.d"
74 r=invalid directive= description=
78 #---------------------------------------------------------------------------
80 test_begin "AC_CONFIG_MACRO_DIRS is honored"
82 cat > configure.ac <<'END'
84 AC_CONFIG_MACRO_DIRS([macro-dir])
89 echo 'AC_DEFUN([MY_FOO], [::my::foo::])' > macro-dir/foo.m4
92 && $FGREP 'm4_include([macro-dir/foo.m4])' aclocal.m4 \
94 && not $FGREP 'MY_FOO' configure \
95 && $FGREP '::my::foo::' configure \
100 #---------------------------------------------------------------------------
105 echo 'AC_DEFUN([MY_FOO], [::my::foo::])' > dir1/foo.m4
106 echo 'AC_DEFUN([MY_BAR], [!!my!!bar!!])' > dir2/zap.m4
108 && $FGREP 'm4_include([dir1/foo.m4])' aclocal.m4 \
109 && $FGREP 'm4_include([dir2/zap.m4])' aclocal.m4 \
111 && not $EGREP 'MY_(FOO|BAR)' configure \
112 && $FGREP '::my::foo::' configure \
113 && $FGREP '!!my!!bar!!' configure \
117 #---------------------------------------------------------------------------
119 test_begin "AC_CONFIG_MACRO_DIRS: several arguments"
121 cat > configure.ac <<'END'
122 AC_INIT([more-args], [0.2])
123 AC_CONFIG_MACRO_DIRS([dir1 dir2])
132 #---------------------------------------------------------------------------
134 test_begin "AC_CONFIG_MACRO_DIRS: several calls"
136 cat > configure.ac <<'END'
137 AC_INIT([more-calls], [2.0])
138 AC_CONFIG_MACRO_DIRS([dir1])
139 AC_CONFIG_MACRO_DIRS([dir2])
148 #---------------------------------------------------------------------------
150 test_begin "AC_CONFIG_MACRO_DIRS interaction with --install"
152 cat > configure.ac << 'END'
153 AC_INIT([inst], [1.0])
154 AC_CONFIG_MACRO_DIRS([the-dir])
158 mkdir sys-dir the-dir
159 echo 'AC_DEFUN([THE_MACRO], [:])' > sys-dir/my.m4
161 test ! -r the-dir/my.m4 \
162 && $ACLOCAL --install --system-acdir ./sys-dir \
163 && diff sys-dir/my.m4 the-dir/my.m4 \
168 #---------------------------------------------------------------------------
170 two_dirs_install_check ()
172 mkdir sys-dir dir1 dir2
173 echo 'AC_DEFUN([THE_MACRO], [:])' > sys-dir/my.m4
174 echo 'AC_DEFUN([AX_FOO], [:])' > dir2/zap.m4
175 test ! -r dir1/my.m4 \
176 && $ACLOCAL --install --system-acdir ./sys-dir \
177 && diff sys-dir/my.m4 dir1/my.m4 \
178 && test ! -e dir2/my.m4 \
179 && $FGREP 'm4_include([dir1/my.m4])' aclocal.m4 \
180 && $FGREP 'm4_include([dir2/zap.m4])' aclocal.m4 \
184 #---------------------------------------------------------------------------
186 test_begin "several AC_CONFIG_MACRO_DIRS arguments and --install"
188 cat > configure.ac << 'END'
189 AC_INIT([inst2a], [1.0])
190 AC_CONFIG_MACRO_DIRS([dir1 dir2])
195 two_dirs_install_check
199 #---------------------------------------------------------------------------
202 test_begin "several AC_CONFIG_MACRO_DIRS calls and --install"
204 cat > configure.ac << 'END'
205 AC_INIT([inst2b], [1.0])
206 AC_CONFIG_MACRO_DIRS([dir1])
207 AC_CONFIG_MACRO_DIRS([dir2])
212 two_dirs_install_check
216 #---------------------------------------------------------------------------
218 test_begin "'-I' option wins over AC_CONFIG_MACRO_DIRS"
220 cat > configure.ac <<'END'
222 AC_CONFIG_MACRO_DIRS([dir1])
227 echo 'AC_DEFUN([MY_FOO], [::ko::ko::])' > dir1/1.m4
228 echo 'AC_DEFUN([MY_FOO], [::ok::ok::])' > dir2/2.m4
231 && $FGREP 'm4_include([dir2/2.m4])' aclocal.m4 \
232 && not $FGREP 'm4_include([dir1/1.m4])' aclocal.m4 \
234 && not $FGREP '::ko::ko::' configure \
235 && $FGREP '::ok::ok::' configure \
240 #---------------------------------------------------------------------------
242 test_begin "AC_CONFIG_MACRO_DIRS([foo]) can create directory 'foo'"
244 cat > configure.ac << 'END'
246 AC_CONFIG_MACRO_DIRS([foo])
251 echo 'AC_DEFUN([MY_MACRO], [:])' > acdir/bar.m4
254 && $ACLOCAL --install --system-acdir ./acdir \
255 && diff acdir/bar.m4 foo/bar.m4 \
260 #---------------------------------------------------------------------------
262 test_begin "AC_CONFIG_MACRO_DIRS([non-existent]) errors out (1)"
264 cat > configure.ac << 'END'
265 AC_INIT([oops], [1.0])
266 AC_CONFIG_MACRO_DIRS([non-existent])
269 not $ACLOCAL 2>stderr \
271 && grep "couldn't open directory 'non-existent'" stderr \
276 #---------------------------------------------------------------------------
278 test_begin "AC_CONFIG_MACRO_DIRS([non-existent]) errors out (2)"
280 cat > configure.ac << 'END'
281 AC_INIT([oops], [1.0])
282 AC_CONFIG_MACRO_DIRS([dir-ok])
283 AC_CONFIG_MACRO_DIRS([dir-ko])
287 not $ACLOCAL 2>stderr \
289 && grep "couldn't open directory 'dir-ko'" stderr \
290 && not grep "dir-ok" stderr \
295 #---------------------------------------------------------------------------
297 test_begin "AC_CONFIG_MACRO_DIRS([non-existent]) errors out (tricky setup)"
299 cat > configure.ac << 'END'
300 AC_INIT([oops], [1.0])
301 AC_CONFIG_MACRO_DIRS([dir-ok])
302 AC_CONFIG_MACRO_DIRS([dir-ko])
307 not $ACLOCAL -Wnone --install 2>stderr \
309 && grep "couldn't open directory 'dir-ko'" stderr \
310 && test ! -e dir-ko \
315 #---------------------------------------------------------------------------