am-ft: make the environment available earlier
[platform/upstream/automake.git] / t / remake-subdir-gnu.sh
1 #! /bin/sh
2 # Copyright (C) 2011-2013 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 <http://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
23 required=GNUmake
24 . test-init.sh
25
26 magic1='::MagicString::One::'
27 magic2='__MagicString__Two__'
28
29 debug_info ()
30 {
31   grep -i magic configure GNUmakefile.in GNUmakefile \
32                 sub/GNUmakefile.in sub/GNUmakefile
33 }
34
35 cat > configure.ac <<END
36 AC_INIT([$me], [1.0])
37 AM_INIT_AUTOMAKE
38 AC_CONFIG_FILES([GNUmakefile sub/GNUmakefile])
39 AC_SUBST([MAGIC], [magic])
40 AC_OUTPUT
41 END
42
43 cat > GNUmakefile.am <<'END'
44 SUBDIRS = sub
45 END
46
47 mkdir sub
48 : > sub/GNUmakefile.am
49
50 $ACLOCAL
51 $AUTOCONF
52 $AUTOMAKE
53
54 ./configure
55 $MAKE
56 debug_info
57
58 $sleep
59 sed "s|magic|$magic1|" configure.ac > t
60 mv -f t configure.ac
61 cd sub
62 $MAKE
63 cd ..
64 debug_info
65 $FGREP $magic1 configure
66 $FGREP $magic1 GNUmakefile
67 $FGREP $magic1 sub/GNUmakefile
68
69 $sleep
70 cd sub
71 echo MAGIC = $magic2 >> GNUmakefile.am
72 $MAKE
73 cd ..
74 debug_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 :