2 # Copyright (C) 2012-2013 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_DIR with
18 # aclocal. See also related test 'aclocal-macrodir.tap'.
20 am_create_testdir=empty
25 ocwd=$(pwd) || fatal_ "getting current working directory"
29 # General utility functions and variables.
31 # TODO: These should maybe be refactored, generalized and
32 # moved into 't/ax/tap-functions.sh' ...
42 if test -n "$description"; then
43 fatal_ "'test_begin' called, but another test seems active already"
48 echo "$description" > README.txt
51 tcount=$(($tcount + 1)) && test $tcount -gt 0 \
52 || fatal_ "failed to bump the test count"
59 if test -z "$description"; then
60 fatal_ "'test_end' called, but no test seems active"
62 cd "$ocwd" || fatal_ "cannot chdir back to top-level directory"
63 result_ "$r" -D "$directive" -- "$description"
64 # Don't leave directories for successful subtests hanging around.
65 if test -z "$directive" && test "$r" = ok; then
66 rm -rf "$tcount.d" || fatal_ "removing subdir $tcount.d"
68 r=invalid directive= description=
72 #---------------------------------------------------------------------------
74 test_begin "AC_CONFIG_MACRO_DIR is honored"
76 cat > configure.ac <<'END'
78 AC_CONFIG_MACRO_DIR([macro-dir])
83 echo 'AC_DEFUN([MY_FOO], [::my::foo::])' > macro-dir/foo.m4
86 && $FGREP 'm4_include([macro-dir/foo.m4])' aclocal.m4 \
88 && not $FGREP 'MY_FOO' configure \
89 && $FGREP '::my::foo::' configure \
94 #---------------------------------------------------------------------------
96 test_begin "AC_CONFIG_MACRO_DIR([foo]) interaction with --install"
98 cat > configure.ac << 'END'
99 AC_INIT([inst], [1.0])
100 AC_CONFIG_MACRO_DIR([the-dir])
104 mkdir sys-dir the-dir
105 echo 'AC_DEFUN([THE_MACRO], [:])' > sys-dir/my.m4
107 test ! -r the-dir/my.m4 \
108 && $ACLOCAL --install --system-acdir ./sys-dir \
109 && diff sys-dir/my.m4 the-dir/my.m4 \
114 #---------------------------------------------------------------------------
116 test_begin "'-I' option wins over AC_CONFIG_MACRO_DIR"
118 cat > configure.ac <<'END'
120 AC_CONFIG_MACRO_DIR([dir1])
125 echo 'AC_DEFUN([MY_FOO], [::ko::ko::])' > dir1/1.m4
126 echo 'AC_DEFUN([MY_FOO], [::ok::ok::])' > dir2/2.m4
129 && $FGREP 'm4_include([dir2/2.m4])' aclocal.m4 \
130 && not $FGREP 'm4_include([dir1/1.m4])' aclocal.m4 \
132 && not $FGREP '::ko::ko::' configure \
133 && $FGREP '::ok::ok::' configure \
138 #---------------------------------------------------------------------------
140 test_begin "AC_CONFIG_MACRO_DIR([foo]) can create directory 'foo'"
142 cat > configure.ac << 'END'
144 AC_CONFIG_MACRO_DIR([foo])
149 echo 'AC_DEFUN([MY_MACRO], [:])' > acdir/bar.m4
152 && $ACLOCAL --install --system-acdir ./acdir \
153 && diff acdir/bar.m4 foo/bar.m4 \
158 #---------------------------------------------------------------------------
160 test_begin "AC_CONFIG_MACRO_DIR([non-existent]) warns with -Wunsupported"
162 cat > configure.ac << 'END'
163 AC_INIT([oops], [1.0])
164 AC_CONFIG_MACRO_DIR([non-existent])
168 $ACLOCAL -Wno-error 2>stderr \
170 && grep "couldn't open directory 'non-existent'" stderr \
171 && test -f aclocal.m4 \
174 rm -rf aclocal.m4 autom4te*.cache
176 $ACLOCAL -Werror -Wno-unsupported \
177 && test -f aclocal.m4 \
182 #---------------------------------------------------------------------------
184 test_begin "AC_CONFIG_MACRO_DIR([not-exist]) and ACLOCAL_AMFLAGS = -I not-exist"
186 cat > configure.ac << 'END'
187 AC_INIT([oops], [1.0])
188 AC_CONFIG_MACRO_DIR([not-exist])
191 cat > Makefile.am << 'END'
192 ACLOCAL_AMFLAGS = -I not-exist
195 $ACLOCAL -Wno-error 2>stderr \
197 && test $(grep -c "couldn't open directory 'not-exist'" stderr) -eq 1 \
202 #---------------------------------------------------------------------------
204 # Avoid spurious failures with pre-2.70 autoconf.
205 # FIXME: remove this in automake 2.0, once we require Autoconf 2.70.
206 if echo 'AC_INIT AC_CONFIG_MACRO_DIRS' | $AUTOCONF -o/dev/null -; then
208 test_begin "AC_CONFIG_MACRO_DIR interaction with AC_REQUIRE"
210 unindent > configure.ac <<'END'
211 AC_INIT([req], [1.0])
212 AC_CONFIG_MACRO_DIR([macro-dir])
213 AC_DEFUN([MY_FOO], [AC_REQUIRE([MY_BAR])])
218 echo 'AC_DEFUN([MY_BAR], [//my//bar//])' > macro-dir/x.m4
220 st=0; $ACLOCAL 2>stderr || st=$?
224 && test ! -s stderr \
225 && $FGREP 'm4_include([macro-dir/x.m4])' aclocal.m4 \
227 && not $EGREP 'MY_(FOO|BAR)' configure \
228 && $FGREP '//my//bar//' configure \
235 skip_ -r "autoconf is too old (AC_CONFIG_MACRO_DIRS not defined)"