Merge branch 'minor'
[automake.git] / t / remake-subdir.sh
blob7a5d0825a6ea98b1254edb631c751938f65d27c9
1 #! /bin/sh
2 # Copyright (C) 2011-2017 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)
7 # any later version.
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 <https://www.gnu.org/licenses/>.
17 # Check that remake rules works from subdirectories, even with non-GNU
18 # make implementations.
19 # See also the other similar tests 'remake-subdir*.sh', and the
20 # related test 'aclocal5.sh'.
22 . test-init.sh
24 if using_gmake; then
25 remake=$MAKE
26 else
27 remake="$MAKE Makefile"
30 magic1='::MagicString::One::'
31 magic2='__MagicString__Two__'
33 debug_info ()
35 grep -i magic configure Makefile.in Makefile sub/Makefile.in sub/Makefile
38 cat >> configure.ac <<'END'
39 AC_CONFIG_FILES([sub/Makefile])
40 AC_SUBST([MAGIC], [magic])
41 AC_OUTPUT
42 END
44 cat > Makefile.am <<'END'
45 SUBDIRS = sub
46 END
48 mkdir sub
49 : > sub/Makefile.am
51 $ACLOCAL
52 $AUTOCONF
53 $AUTOMAKE
55 ./configure
56 $MAKE
57 debug_info
59 $sleep
60 sed "s|magic|$magic1|" configure.ac > t
61 mv -f t configure.ac
62 cd sub
63 $remake
64 cd ..
65 debug_info
66 $FGREP $magic1 configure
67 $FGREP $magic1 Makefile
68 $FGREP $magic1 sub/Makefile
70 $sleep
71 cd sub
72 echo MAGIC = $magic2 >> Makefile.am
73 $remake
74 cd ..
75 debug_info
76 $FGREP $magic2 sub/Makefile
77 $FGREP $magic2 sub/Makefile.in
78 $FGREP $magic1 sub/Makefile sub/Makefile.in && exit 1
79 $FGREP $magic2 Makefile Makefile.in && exit 1