tests: expose automake bug#14560
[platform/upstream/automake.git] / t / remake-after-configure-ac.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 when configure.ac or its prerequisites change.
18 # Keep in sync with the other sister tests 'remake-after-*.sh'.
19
20 . test-init.sh
21
22 magic1=::MagicStringOne::
23 magic2=__MagicStringTwo__
24
25 if using_gmake; then
26   remake_() { $MAKE nil; }
27 else
28   remake_() { $MAKE Makefile && $MAKE foo.sh; }
29 fi
30
31 cat >> configure.ac <<END
32 FINGERPRINT=BadBadBad
33 AC_SUBST([FINGERPRINT])
34 AC_CONFIG_FILES([foo.sh:foo.in], [chmod a+x foo.sh])
35 AC_OUTPUT
36 END
37
38 cat > Makefile.am <<'END'
39 nil:
40 .PHONY: nil
41
42 $(srcdir)/configure.ac: $(srcdir)/tweak-configure-in
43         $(SHELL) $(srcdir)/tweak-configure-in <$@ >$@-t
44         mv -f $@-t $@
45 EXTRA_DIST = $(srcdir)/tweak-configure-in
46
47 # Used by "make distcheck" later.
48 check-local:
49         test x'$(FINGERPRINT)' = x'DummyValue'
50         test x"`./foo.sh`" = x"DummyValue"
51 END
52
53 cat > foo.in <<END
54 #!/bin/sh
55 echo '@FINGERPRINT@'
56 END
57
58 echo cat > tweak-configure-in # It is a no-op by default.
59
60 $ACLOCAL
61 $AUTOCONF
62 $AUTOMAKE
63
64 for vpath in : false; do
65
66   if $vpath; then
67     mkdir build
68     cd build
69     srcdir=..
70   else
71     srcdir=.
72   fi
73
74   $srcdir/configure
75   $MAKE # Should be a no-op.
76
77   $sleep
78   sed "s/^\\(FINGERPRINT\\)=.*/\\1=$magic1/" $srcdir/configure.ac >t
79   mv -f t $srcdir/configure.ac
80   remake_
81   $FGREP FINGERPRINT Makefile # For debugging.
82   $FGREP $magic1 Makefile
83   test x"$(./foo.sh)" = x"$magic1"
84
85   $sleep
86   echo 'sed "s/^\\(FINGERPRINT\\)=.*/\\1='$magic2'/"' \
87     > $srcdir/tweak-configure-in
88   remake_
89   $FGREP FINGERPRINT Makefile # For debugging.
90   $FGREP $magic1 Makefile && exit 1
91   $FGREP $magic2 Makefile
92   test x"$(./foo.sh)" = x"$magic2"
93
94   $sleep
95   echo cat > $srcdir/tweak-configure-in # Make it a no-op again.
96   sed "s/^\\(FINGERPRINT\\)=.*/\\1=DummyValue/" $srcdir/configure.ac >t
97   mv -f t $srcdir/configure.ac
98   using_gmake || remake_
99   $MAKE distcheck
100   $FGREP $magic1 Makefile && exit 1 # Sanity check.
101   $FGREP $magic2 Makefile && exit 1 # Likewise.
102
103   $MAKE distclean
104
105   cd $srcdir
106
107 done
108
109 :