1#! /bin/sh
2# Copyright (C) 2011-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# Check that remake rules works from subdirectories, even using
18# 'GNUmakefile' as makefiles name.  This obviously requires GNU
19# make.
20# See also the other similar tests 'remake-subdir*.sh', and the
21# related test 'aclocal5.sh'
22
23required=GNUmake
24. test-init.sh
25
26magic1='::MagicString::One::'
27magic2='__MagicString__Two__'
28
29debug_info ()
30{
31  grep -i magic configure GNUmakefile.in GNUmakefile \
32                sub/GNUmakefile.in sub/GNUmakefile
33}
34
35cat > configure.ac <<END
36AC_INIT([$me], [1.0])
37AM_INIT_AUTOMAKE
38AC_CONFIG_FILES([GNUmakefile sub/GNUmakefile])
39AC_SUBST([MAGIC], [magic])
40AC_OUTPUT
41END
42
43cat > GNUmakefile.am <<'END'
44SUBDIRS = sub
45END
46
47mkdir sub
48: > sub/GNUmakefile.am
49
50$ACLOCAL
51$AUTOCONF
52$AUTOMAKE
53
54./configure
55$MAKE
56debug_info
57
58$sleep
59sed "s|magic|$magic1|" configure.ac > t
60mv -f t configure.ac
61cd sub
62$MAKE
63cd ..
64debug_info
65$FGREP $magic1 configure
66$FGREP $magic1 GNUmakefile
67$FGREP $magic1 sub/GNUmakefile
68
69$sleep
70cd sub
71echo MAGIC = $magic2 >> GNUmakefile.am
72$MAKE
73cd ..
74debug_info
75$FGREP $magic2 sub/GNUmakefile
76$FGREP $magic2 sub/GNUmakefile.in
77$FGREP $magic1 sub/GNUmakefile sub/GNUmakefile.in && exit 1
78$FGREP $magic2 GNUmakefile GNUmakefile.in && exit 1
79
80:
81