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