1#! /bin/sh
2# Copyright (C) 2008-2021 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 <https://www.gnu.org/licenses/>.
16
17# Make sure the suggested 'distcleancheck_listfiles' in the manual works.
18# The example Makefile.am we use is from the FAQ entry 'distcleancheck'.
19
20required=cc
21. test-init.sh
22
23cat >>configure.ac << 'END'
24AC_PROG_CC
25AC_OUTPUT
26END
27
28cat > Makefile.am << 'END'
29# This Makefile.am is bogus.  See @node{distcleancheck} in the manual
30# for how to fix it properly.
31bin_PROGRAMS = foo
32foo_SOURCES = foo.c
33dist_man_MANS = foo.1
34
35# We write './foo.1' inside the rule on purpose, to avoid VPATH rewriting
36# done by some 'make' implementations.
37foo.1: foo$(EXEEXT)
38	echo man page for foo$(EXEEXT) > ./foo.1
39
40## Ignore warnings about overridden variables
41AUTOMAKE_OPTIONS = -Wno-override
42distcleancheck_listfiles = \
43  find . -type f -exec sh -c 'test -f $(srcdir)/$$1 || echo $$1' \
44       sh '{}' ';'
45END
46
47cat >foo.c <<'END'
48int main () { return 0; }
49END
50
51$ACLOCAL
52$AUTOCONF
53$AUTOMAKE
54
55./configure
56$MAKE
57$MAKE distcheck
58
59# Now ensure that we really needed the override.
60sed '/distcleancheck_listfiles/,$d' Makefile.am > t
61mv -f t Makefile.am
62$AUTOMAKE
63./configure
64$MAKE
65run_make -E -e FAIL distcheck
66grep 'ERROR:.*files left in build directory after distclean' stderr
67grep '^\./foo\.1$' stderr
68
69:
70