am-ft: make the environment available earlier
[platform/upstream/automake.git] / t / remake-configure-dependencies.sh
1 #! /bin/sh
2 # Copyright (C) 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 CONFIGURE_DEPENDENCIES.
18
19 . test-init.sh
20
21 cat > configure.ac <<'END'
22 AC_INIT([confdeps], m4_esyscmd([./print-version]))
23 AM_INIT_AUTOMAKE([foreign])
24 AC_CONFIG_FILES([Makefile])
25 AC_OUTPUT
26 END
27
28 # Needless to say, the autom4te cache happily break this test.
29 cat > .autom4te.cfg <<'END'
30 begin-language: "Autoconf-without-aclocal-m4"
31 args: --no-cache
32 end-language: "Autoconf-without-aclocal-m4"
33 END
34
35 cat > Makefile.am <<'END'
36 EXTRA_DIST = .autom4te.cfg
37 CONFIGURE_DEPENDENCIES = $(top_srcdir)/print-version
38
39 test-1:
40         test $(VERSION) = 1.0
41 test-2:
42         test $(VERSION) = 2.1
43 test-3:
44         test $(VERSION) = 3.14
45
46 .PHONY: test-1 test-2 test-3
47
48 # Contents of $(CONFIGURE_DEPENDENCIES) are to be automatically
49 # distributed.
50 local-check: test-3 distdir
51         test -f $(distdir)/print-version
52 END
53
54 (echo '#!/bin/sh' && echo 'printf %s 1.0') > print-version
55 chmod a+x print-version
56
57 $ACLOCAL
58 $AUTOCONF
59 $AUTOMAKE
60
61 ./configure
62 $MAKE test-1
63
64 $sleep
65 (echo '#!/bin/sh' && echo 'printf %s 2.1') > print-version
66 using_gmake || $MAKE Makefile
67 $MAKE test-2
68
69 $MAKE distclean
70 mkdir build
71 cd build
72 ../configure
73 $MAKE test-2
74
75 $sleep
76 (echo '#!/bin/sh' && echo 'printf %s 3.14') > ../print-version
77 using_gmake || $MAKE Makefile
78 $MAKE test-3
79
80 # Check that $(CONFIGURE_DEPENDENCIES) are automatically distributed.
81 $MAKE distcheck
82
83 :