Merge branch 'msvc' into maint
[platform/upstream/automake.git] / tests / distcheck-missing-m4.test
1 #! /bin/sh
2 # Copyright (C) 2011 Free Software Foundation, Inc.
3 #
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.
8 #
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.
13 #
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/>.
16
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.
20
21 . ./defs || Exit 1
22
23 set -e
24
25 cwd=`pwd` || fatal_ "cannot get current working directory"
26
27 cp "$testsrcdir"/distcheck-hook-m4.am . \
28   || fatal_ "cannot fetch makefile fragment \`distcheck-hook-m4.am'"
29
30 cat > Makefile.am << 'END'
31 ## The lack of `--install' here is meant.
32 ACLOCAL_AMFLAGS = -I m4
33 include $(srcdir)/distcheck-hook-m4.am
34 END
35
36 cat >> configure.in << 'END'
37 dnl We *deliberately* don't use m4_pattern_forbid here.
38 AC_OUTPUT
39 MY_FOO
40 MY_BAR
41 MY_BAZ
42 MY_ZAR
43 END
44
45 mkdir m4 acdir acdir1 acdir2 pth
46
47 cat > acdir/dirlist << END
48 $cwd/acdir1
49 $cwd/acdir2
50 END
51
52 echo 'AC_DEFUN([MY_FOO], [:])' > m4/foo.m4
53 echo 'AC_DEFUN([MY_BAR], [:])' > acdir1/bar.m4
54 echo 'AC_DEFUN([MY_BAZ], [:])' > acdir1/baz.m4
55 echo 'AC_DEFUN([MY_QUX], [:])' > acdir2/qux.m4
56 echo 'AC_DEFUN([MY_ZAR], [:])' > pth/zar.m4
57 echo 'AC_DEFUN([MY_BLA], [:])' > pth/bla.m4
58
59 ACLOCAL="$ACLOCAL --system-acdir=$cwd/acdir"; export ACLOCAL
60 ACLOCAL_PATH=$cwd/pth; export ACLOCAL_PATH
61
62 # We don't use `--install' here.  Our distcheck-hook should catch this.
63 $ACLOCAL -I m4
64 $AUTOCONF
65 $EGREP 'MY_(FOO|BAR|BAZ|ZAR)' configure && Exit 1 # Sanity check.
66 $AUTOMAKE
67
68 check_no_spurious_error ()
69 {
70   $EGREP -i 'mkdir:|:.*(permission|denied)' output && Exit 1
71   # On failure, some make implementations (such as Solaris make) print the
72   # whole failed recipe on stdout.  The first grep works around this.
73   grep -v 'rm -rf ' output | grep -i 'autom4te.*\.cache' && Exit 1
74   : # To placate `set -e'.
75 }
76
77 ./configure
78
79 $MAKE distcheck >output 2>&1 && { cat output; Exit 1; }
80 cat output
81 for x in bar baz zar; do
82   $EGREP "required m4 file.*not distributed.* $x.m4( |$)" output
83 done
84 check_no_spurious_error
85
86 # Now we use `--install', and "make distcheck" should pass.
87 $ACLOCAL -I m4 --install
88 test -f m4/bar.m4 # Sanity check.
89 test -f m4/baz.m4 # Likewise.
90 test -f m4/zar.m4 # Likewise.
91 using_gmake || $MAKE Makefile
92 $MAKE distcheck
93
94 # We start to use new "third-party" macros from new .m4 files, but forget
95 # to re-run "aclocal --install" by hand, relying on automatic remake rules.
96 # Our distcheck-hook should catch this too.
97 cat >> configure.in << 'END'
98 MY_QUX
99 MY_BLA
100 END
101
102 $MAKE
103 $EGREP 'MY_(FOO|BAR|BAZ|QUX|ZAR|BLA)' configure && Exit 1 # Sanity check.
104
105 $MAKE distcheck >output 2>&1 && { cat output; Exit 1; }
106 cat output
107 $EGREP "required m4 file.*not distributed.* qux.m4( |$)" output
108 $EGREP "required m4 file.*not distributed.* bla.m4( |$)" output
109 check_no_spurious_error
110 # Check that we don't complain for files that should have been found.
111 $FGREP " (bar|baz|zar).m4" output && Exit 1
112
113 # Now we again use `--install', and "make distcheck" should pass.
114 $ACLOCAL -I m4 --install
115 test -f m4/qux.m4 # Sanity check.
116 test -f m4/bla.m4 # Likewise.
117 using_gmake || $MAKE Makefile
118 $MAKE distcheck
119
120 :