am-ft: make the environment available earlier
[platform/upstream/automake.git] / t / remake-include-aclocal.sh
1 #! /bin/sh
2 # Copyright (C) 2010-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 for m4 files included (also recursively) by
18 # aclocal.m4.  Keep in sync with sister tests:
19 #   - remake-include-configure.sh
20 #   - remake-include-makefile.sh
21
22 . test-init.sh
23
24 magic1=::MagicStringOne::
25 magic2=__MagicStringTwo__
26 magic3=%%MagicStringThree%%
27
28 if using_gmake; then
29   remake="$MAKE nil"
30 else
31   remake="$MAKE Makefile"
32 fi
33
34 cat >> configure.ac <<END
35 AC_CONFIG_MACRO_DIR([m4])
36 FINGERPRINT='my_fingerprint'
37 AC_SUBST([FINGERPRINT])
38 AC_OUTPUT
39 END
40
41 cat > Makefile.am <<'END'
42 .PHONY: nil
43 nil:
44 ## Used by "make distcheck" later.
45 check-local:
46         test -f $(top_srcdir)/m4/foo.m4
47         test ! -r $(top_srcdir)/m4/bar.m4
48         test x'$(FINGERPRINT)' = x'DummyValue'
49 END
50
51 mkdir m4
52 echo 'AC_DEFUN([my_fingerprint], [BadBadBad])' > m4/foo.m4
53
54 $ACLOCAL
55 $AUTOCONF
56 $AUTOMAKE
57
58 for vpath in : false; do
59
60   if $vpath; then
61     mkdir build
62     cd build
63     top_srcdir=..
64   else
65     top_srcdir=.
66   fi
67
68   $top_srcdir/configure
69   $MAKE # Should be a no-op.
70
71   $sleep
72   echo "AC_DEFUN([my_fingerprint], [$magic1])" > $top_srcdir/m4/foo.m4
73   $remake
74   $FGREP FINGERPRINT Makefile # For debugging.
75   $FGREP $magic1 Makefile
76
77   $sleep
78   echo "AC_DEFUN([my_fingerprint], [$magic2])" > $top_srcdir/m4/foo.m4
79   $remake
80   $FGREP FINGERPRINT Makefile # For debugging.
81   $FGREP $magic1 Makefile && exit 1
82   $FGREP $magic2 Makefile
83
84   $sleep
85   echo "m4_include([m4/bar.m4])" > $top_srcdir/m4/foo.m4
86   echo "AC_DEFUN([my_fingerprint], [$magic3])" > $top_srcdir/m4/bar.m4
87   $remake
88   $FGREP FINGERPRINT Makefile # For debugging.
89   $FGREP $magic1 Makefile && exit 1
90   $FGREP $magic2 Makefile && exit 1
91   $FGREP $magic3 Makefile
92
93   $sleep
94   echo "AC_DEFUN([my_fingerprint], [$magic1])" > $top_srcdir/m4/bar.m4
95   $remake
96   $FGREP $magic2 Makefile && exit 1
97   $FGREP $magic3 Makefile && exit 1
98   $FGREP $magic1 Makefile
99
100   $sleep
101   echo "AC_DEFUN([my_fingerprint], [DummyValue])" > $top_srcdir/m4/foo.m4
102   echo "AC_DEFUN([AM_UNUSED], [NoSuchMacro])" > $top_srcdir/m4/bar.m4
103   using_gmake || $remake
104   $MAKE distcheck
105   $FGREP $magic1 Makefile && exit 1 # Sanity check.
106   $FGREP $magic2 Makefile && exit 1 # Likewise.
107   $FGREP $magic3 Makefile && exit 1 # Likewise.
108
109   $MAKE distclean
110
111   cd $top_srcdir
112
113 done
114
115 :