tests: make 'lzip.test' executable
[automake.git] / tests / dist-missing-m4.test
bloba2618e980e44228e7c1f7ccf40c25412fc851eef
1 #! /bin/sh
2 # Copyright (C) 2011 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)
7 # any later version.
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 # The stub rules emitted to work around the "deleted header problem"
18 # for `.m4' files shouldn't prevent "make" from diagnosing a missing
19 # required `.m4' file from a distribution tarball.
20 # See discussion about automake bug#9768.
21 # See also sister test `dist-missing-included-m4.test'.
23 . ./defs || Exit 1
25 set -e
27 cat >> configure.in <<'END'
28 m4_pattern_forbid([^MY_])
29 MY_FOOBAR || exit 1
30 MY_ZARDOZ || exit 1
31 AC_OUTPUT
32 END
34 mkdir m4
35 echo 'AC_DEFUN([MY_FOOBAR], [:])' > m4/foobar.m4
36 echo 'AC_DEFUN([MY_ZARDOZ], [:])' > m4/zardoz.m4
38 echo 'ACLOCAL_AMFLAGS = -I m4' > Makefile.am
40 $ACLOCAL -I m4
41 $AUTOCONF
42 $AUTOMAKE
44 ./configure
46 # A faulty distribution tarball, with a required `.m4' file missing.
47 # Building from it should fail, both for in-tree and VPATH builds.
48 ocwd=`pwd` || fatal_ "cannot get current working directory"
49 for vpath in false :; do
50 $MAKE distdir
51 test -f $distdir/m4/zardoz.m4 # Sanity check.
52 rm -f $distdir/m4/zardoz.m4
53 if $vpath; then
54 # We can't just build in a subdirectory of $distdir, otherwise
55 # we'll hit automake bug#10111.
56 mkdir vpath-distcheck
57 cd vpath-distcheck
58 ../$distdir/configure
59 else
60 cd $distdir
61 ./configure
63 $MAKE >output 2>&1 && { cat output; Exit 1; }
64 cat output
65 # This error will come from autoconf, not make, so we can be stricter
66 # in our grepping of it.
67 grep 'possibly undefined .*MY_ZARDOZ' output
68 grep 'MY_FOOBAR' output && Exit 1 # No spurious error, please.
69 cd "$ocwd" || fatal_ "cannot chdir back to top-level test directory"
70 done