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_DIR with
20 am_create_testdir=empty
25 ocwd=$(pwd) || fatal_ "getting current working directory"
26 ACLOCAL_PATH=; unset ACLOCAL_PATH
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"
47 echo "$description" > README.txt
50 tcount=$(($tcount + 1)) && test $tcount -gt 0 \
51 || fatal_ "failed to bump the test count"
58 if test -z "$description"; then
59 fatal_ "'test_end' called, but no test seems active"
61 cd "$ocwd" || fatal_ "cannot chdir back to top-level directory"
62 result_ "$r" -D "$directive" -- "$description"
63 # Don't leave directories for successful subtests hanging around.
64 if test -z "$directive" && test "$r" = ok; then
65 rm -rf "$tcount.d" || fatal_ "removing subdir $tcount.d"
67 r=invalid directive= description=
71 test_todo () { directive=TODO; }
73 #---------------------------------------------------------------------------
75 test_begin "AC_CONFIG_MACRO_DIR is honored"
77 cat > configure.ac <<'END'
79 AC_CONFIG_MACRO_DIR([macro-dir])
84 echo 'AC_DEFUN([MY_FOO], [::my::foo::])' > macro-dir/foo.m4
87 && $FGREP 'm4_include([macro-dir/foo.m4])' aclocal.m4 \
89 && not $FGREP 'MY_FOO' configure \
90 && $FGREP '::my::foo::' configure \
95 #---------------------------------------------------------------------------
97 test_begin "AC_CONFIG_MACRO_DIR([foo]) interaction with --install"
99 cat > configure.ac << 'END'
100 AC_INIT([inst], [1.0])
101 AC_CONFIG_MACRO_DIR([the-dir])
105 mkdir sys-dir the-dir
106 echo 'AC_DEFUN([THE_MACRO], [:])' > sys-dir/my.m4
108 test ! -r the-dir/my.m4 \
109 && $ACLOCAL --install --system-acdir ./sys-dir \
110 && diff sys-dir/my.m4 the-dir/my.m4 \
115 #---------------------------------------------------------------------------
117 test_begin "'-I' option wins over AC_CONFIG_MACRO_DIR"
119 cat > configure.ac <<'END'
121 AC_CONFIG_MACRO_DIR([dir1])
126 echo 'AC_DEFUN([MY_FOO], [::ko::ko::])' > dir1/1.m4
127 echo 'AC_DEFUN([MY_FOO], [::ok::ok::])' > dir2/2.m4
130 && $FGREP 'm4_include([dir2/2.m4])' aclocal.m4 \
131 && not $FGREP 'm4_include([dir1/1.m4])' aclocal.m4 \
133 && not $FGREP '::ko::ko::' configure \
134 && $FGREP '::ok::ok::' configure \
139 #---------------------------------------------------------------------------
141 test_begin "AC_CONFIG_MACRO_DIR([foo]) can create directory 'foo'"
143 cat > configure.ac << 'END'
145 AC_CONFIG_MACRO_DIR([foo])
150 echo 'AC_DEFUN([MY_MACRO], [:])' > acdir/bar.m4
153 && $ACLOCAL --install --system-acdir ./acdir \
154 && diff acdir/bar.m4 foo/bar.m4 \
159 #---------------------------------------------------------------------------