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