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