2 # Copyright (C) 2011-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 # Test that we can define a distcheck-hook to diagnose outdated m4
18 # files in a 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'
42 echo 'AC_DEFUN([MY_FOO], [:])' > m4/foo.m4
43 echo 'AC_DEFUN([MY_BAR], [:])' > acdir/bar.m4
44 cat > acdir/baz.m4 << 'END'
46 AC_DEFUN([MY_BAZ], [:])
49 ACLOCAL="$ACLOCAL --system-acdir=$cwd/acdir"; export ACLOCAL
51 # The use of '--install' here won't help when the installed file '.m4'
52 # will become out-of-date w.r.t. the one in the system acdir.
53 $ACLOCAL -I m4 --install
58 $MAKE distcheck # Sanity check.
60 check_no_spurious_error ()
62 $EGREP -i 'mkdir:|:.*(permission|denied)' output && exit 1
63 # On failure, some make implementations (such as Solaris make) print the
64 # whole failed recipe on stdout. The first grep works around this.
65 grep -v 'rm -rf ' output | grep -i 'autom4te.*\.cache' && exit 1
66 : To placate 'set -e'.
69 # We start to use a new "third-party" macro in a new version
70 # of a pre-existing third-party m4 file, but forget to re-run
71 # "aclocal --install" by hand, relying on automatic remake
72 # rules. Our distcheck-hook should catch this too.
73 echo MY_ZARDOZ >> configure.ac
75 cat > acdir/baz.m4 << 'END'
77 AC_DEFUN([MY_BAZ], [:])
78 AC_DEFUN([MY_ZARDOZ], [:])
81 $MAKE # Rebuild configure and makefiles.
82 run_make -M -e FAIL distcheck
83 $EGREP "required m4 file.* outdated.* baz.m4( |$)" output
84 check_no_spurious_error
85 # Check that we don't complain for files that aren't outdated.
86 $EGREP " (foo|bar).m4" output && exit 1
88 # Now we again use '--install' explicitly, and "make distcheck"
90 $ACLOCAL -I m4 --install
91 using_gmake || $MAKE Makefile
94 # Similar to what have been done above, but this time we:
95 # - use ACLOCAL_PATH, and
96 # - do not add the use of a new macro.
98 echo MY_FNORD >> configure.ac
101 cat > pth/fnord.m4 << 'END'
103 AC_DEFUN([MY_FNORD], [:])
106 ACLOCAL_PATH="$cwd/pth"; export ACLOCAL_PATH
108 # The explicit use of '--install' here won't help when the installed file
109 # '.m4' will become out-of-date w.r.t. the one in the system acdir.
110 $ACLOCAL -I m4 --install
111 using_gmake || $MAKE Makefile
114 # Only increase serial number, without changing the other contents; this
116 cat > pth/fnord.m4 << 'END'
118 AC_DEFUN([MY_FNORD], [:])
121 $MAKE # Rebuild configure and makefiles.
122 run_make -M -e FAIL distcheck
123 $EGREP "required m4 file.* outdated.* fnord.m4( |$)" output
124 check_no_spurious_error
125 # Check that we don't complain for files that aren't outdated.
126 $EGREP " (foo|bar|baz).m4" output && exit 1
128 # Now we again use '--install' explicitly, and "make distcheck"
130 $ACLOCAL -I m4 --install
131 using_gmake || $MAKE Makefile