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 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_testauxdir"/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], [:])' > m
4/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 $MAKE distcheck
>output
2>&1 && { cat output
; exit 1; }
85 $EGREP "required m4 file.* outdated.* baz.m4( |$)" output
86 check_no_spurious_error
87 # Check that we don't complain for files that aren't outdated.
88 $EGREP " (foo|bar).m4" output
&& exit 1
90 # Now we again use '--install' explicitly, and "make distcheck"
92 $ACLOCAL -I m4 --install
93 using_gmake ||
$MAKE Makefile
96 # Similar to what have been done above, but this time we:
97 # - use ACLOCAL_PATH, and
98 # - do not add the use of a new macro.
100 echo MY_FNORD
>> configure.ac
103 cat > pth
/fnord.
m4 << 'END'
105 AC_DEFUN
([MY_FNORD
], [:])
108 ACLOCAL_PATH
="$cwd/pth"; export ACLOCAL_PATH
110 # The explicit use of '--install' here won't help when the installed file
111 # '.m4' will become out-of-date w.r.t. the one in the system acdir.
112 $ACLOCAL -I m4 --install
113 using_gmake ||
$MAKE Makefile
116 # Only increase serial number, without changing the other contents; this
118 cat > pth
/fnord.
m4 << 'END'
120 AC_DEFUN
([MY_FNORD
], [:])
123 $MAKE # Rebuild configure and makefiles.
124 $MAKE distcheck
>output
2>&1 && { cat output
; exit 1; }
126 $EGREP "required m4 file.* outdated.* fnord.m4( |$)" output
127 check_no_spurious_error
128 # Check that we don't complain for files that aren't outdated.
129 $EGREP " (foo|bar|baz).m4" output
&& exit 1
131 # Now we again use '--install' explicitly, and "make distcheck"
133 $ACLOCAL -I m4 --install
134 using_gmake ||
$MAKE Makefile