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