1#! /bin/sh
2# Copyright (C) 2013-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# Test CONFIGURE_DEPENDENCIES.
18
19. test-init.sh
20
21cat > configure.ac <<'END'
22AC_INIT([confdeps], m4_esyscmd([./print-version]))
23AM_INIT_AUTOMAKE([foreign])
24AC_CONFIG_FILES([Makefile])
25AC_OUTPUT
26END
27
28# Needless to say, the autom4te cache happily break this test.
29cat > .autom4te.cfg <<'END'
30begin-language: "Autoconf-without-aclocal-m4"
31args: --no-cache
32end-language: "Autoconf-without-aclocal-m4"
33END
34
35cat > Makefile.am <<'END'
36EXTRA_DIST = .autom4te.cfg
37CONFIGURE_DEPENDENCIES = $(top_srcdir)/print-version
38
39test-1:
40	test $(VERSION) = 1.0
41test-2:
42	test $(VERSION) = 2.1
43test-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.
50local-check: test-3 distdir
51	test -f $(distdir)/print-version
52END
53
54(echo '#!/bin/sh' && echo 'printf %s 1.0') > print-version
55chmod 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
66using_gmake || $MAKE Makefile
67$MAKE test-2
68
69$MAKE distclean
70mkdir build
71cd build
72../configure
73$MAKE test-2
74
75$sleep
76(echo '#!/bin/sh' && echo 'printf %s 3.14') > ../print-version
77using_gmake || $MAKE Makefile
78$MAKE test-3
79
80# Check that $(CONFIGURE_DEPENDENCIES) are automatically distributed.
81$MAKE distcheck
82
83:
84