am-ft: make the environment available earlier
[platform/upstream/automake.git] / t / remake-deleted-m4-file.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 # Test remake rules when an m4 file gets removed and the macros it
18 # defined get inlined into the caller.  Try with both an indirect
19 # call and a direct one.  This can be seen as testing the "deleted
20 # header file" issue w.r.t. aclocal.m4 dependencies.  See also
21 # related test 'aclocal-deleted-header.sh'.
22
23 . test-init.sh
24
25 cat >> configure.ac <<'END'
26 FOO_MACRO
27 AC_OUTPUT
28 END
29
30 cat > Makefile.am <<'END'
31 ACLOCAL_AMFLAGS = -I m4
32 .PHONY: test
33 test:
34         test '$(the_answer)' -eq 42
35 END
36
37 macro_value='the_answer=42; AC_SUBST([the_answer])'
38
39 mkdir m4
40
41 cat > m4/foo.m4 <<'END'
42 AC_DEFUN([FOO_MACRO], [BAR_MACRO])
43 END
44
45 cat > m4/bar.m4 <<END
46 AC_DEFUN([BAR_MACRO], [$macro_value])
47 END
48
49 $ACLOCAL -I m4
50 $AUTOCONF
51 $AUTOMAKE
52
53 ./configure
54 $MAKE test
55
56 $sleep
57
58 sed -e "s|BAR_MACRO|$macro_value|" m4/foo.m4 > t
59 mv -f t m4/foo.m4
60 rm -f m4/bar.m4
61
62 using_gmake || $MAKE Makefile
63 $MAKE test
64
65 $sleep
66
67 sed -e "s|FOO_MACRO|$macro_value|" configure.ac > t
68 mv -f t configure.ac
69 rm -f m4/foo.m4
70
71 using_gmake || $MAKE Makefile
72 $MAKE test
73
74 :