2 # Copyright (C) 2011-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 # Test that we can define a distcheck-hook to diagnose m4 files
18 # missing from the dist tarball (interaction with '--install').
19 # See automake bug#9037.
23 cwd
=$
(pwd) || fatal_
"cannot get current working directory"
25 cp "$am_testaux_srcdir"/distcheck-hook-m4.am . \
26 || fatal_
"cannot fetch makefile fragment 'distcheck-hook-m4.am'"
28 cat > Makefile.am
<< 'END'
29 ## The lack of '--install' here is meant.
30 ACLOCAL_AMFLAGS
= -I m4
31 include $
(srcdir
)/distcheck-hook-m4.am
34 cat >> configure.ac
<< 'END'
35 dnl We
*deliberately
* don
't use m4_pattern_forbid here.
43 mkdir m4 acdir acdir1 acdir2 pth
45 cat > acdir/dirlist << END
50 echo 'AC_DEFUN
([MY_FOO
], [:])' > m4/foo.m4
51 echo 'AC_DEFUN
([MY_BAR
], [:])' > acdir1/bar.m4
52 echo 'AC_DEFUN
([MY_BAZ
], [:])' > acdir1/baz.m4
53 echo 'AC_DEFUN
([MY_QUX
], [:])' > acdir2/qux.m4
54 echo 'AC_DEFUN
([MY_ZAR
], [:])' > pth/zar.m4
55 echo 'AC_DEFUN
([MY_BLA
], [:])' > pth/bla.m4
57 ACLOCAL="$ACLOCAL --system-acdir=$cwd/acdir"; export ACLOCAL
58 ACLOCAL_PATH=$cwd/pth; export ACLOCAL_PATH
60 # We don't use
'--install' here. Our distcheck-hook should catch this.
63 $EGREP 'MY_(FOO|BAR|BAZ|ZAR)' configure
&& exit 1 # Sanity check.
66 check_no_spurious_error
()
68 $EGREP -i 'mkdir:|:.*(permission|denied)' output
&& exit 1
69 # On failure, some make implementations (such as Solaris make) print the
70 # whole failed recipe on stdout. The first grep works around this.
71 grep -v 'rm -rf ' output |
grep -i 'autom4te.*\.cache' && exit 1
72 : To placate
'set -e'.
77 $MAKE distcheck
>output
2>&1 && { cat output
; exit 1; }
79 for x
in bar baz zar
; do
80 $EGREP "required m4 file.*not distributed.* $x.m4( |$)" output
82 check_no_spurious_error
84 # Now we use '--install', and "make distcheck" should pass.
85 $ACLOCAL -I m4 --install
86 test -f m
4/bar.
m4 # Sanity check.
87 test -f m
4/baz.
m4 # Likewise.
88 test -f m
4/zar.
m4 # Likewise.
89 using_gmake ||
$MAKE Makefile
92 # We start to use new "third-party" macros from new .m4 files, but forget
93 # to re-run "aclocal --install" by hand, relying on automatic remake rules.
94 # Our distcheck-hook should catch this too.
95 cat >> configure.ac
<< 'END'
101 $EGREP 'MY_(FOO|BAR|BAZ|QUX|ZAR|BLA)' configure
&& exit 1 # Sanity check.
103 $MAKE distcheck
>output
2>&1 && { cat output
; exit 1; }
105 $EGREP "required m4 file.*not distributed.* qux.m4( |$)" output
106 $EGREP "required m4 file.*not distributed.* bla.m4( |$)" output
107 check_no_spurious_error
108 # Check that we don't complain for files that should have been found.
109 $FGREP " (bar|baz|zar).m4" output
&& exit 1
111 # Now we again use '--install', and "make distcheck" should pass.
112 $ACLOCAL -I m4 --install
113 test -f m
4/qux.
m4 # Sanity check.
114 test -f m
4/bla.
m4 # Likewise.
115 using_gmake ||
$MAKE Makefile