maint: Document how to handle assignment exemption
[automake.git] / t / remake-after-aclocal-m4.sh
blobd955a40e7308e320bfd6cb5c34ef607d4d98575e
1 #! /bin/sh
2 # Copyright (C) 2010-2017 Free Software Foundation, Inc.
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.
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.
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/>.
17 # Test remake rules when aclocal.m4 or its prerequisites change.
18 # Keep in sync with the other sister tests 'remake-after-*.sh'.
20 . test-init.sh
22 magic1=::MagicStringOne::
23 magic2=__MagicStringTwo__
25 if using_gmake; then
26 remake_() { $MAKE nil; }
27 else
28 remake_() { $MAKE Makefile && $MAKE foo.sh; }
31 cat >> configure.ac <<END
32 FINGERPRINT='my_fingerprint'
33 AC_SUBST([FINGERPRINT])
34 AC_CONFIG_FILES([foo.sh:foo.in], [chmod a+x foo.sh])
35 AC_OUTPUT
36 END
38 cat > Makefile.am <<'END'
39 nil:
40 .PHONY: nil
42 # A non-autogenerated aclocal.m4 can be extended by hand.
43 $(srcdir)/aclocal.m4: $(srcdir)/tweak-aclocal-m4
44 $(SHELL) $(srcdir)/tweak-aclocal-m4 <$@ >$@-t
45 mv -f $@-t $@
46 touch $@
47 EXTRA_DIST = $(srcdir)/tweak-aclocal-m4
49 # Used by "make distcheck" later.
50 check-local:
51 test x'$(FINGERPRINT)' = x'DummyValue'
52 test x"`./foo.sh`" = x"DummyValue"
53 END
55 cat > foo.in <<END
56 #!/bin/sh
57 echo '@FINGERPRINT@'
58 END
60 echo cat > tweak-aclocal-m4 # It is a no-op by default.
62 $ACLOCAL
63 # Cheatingly mark aclocal.m4 as non auto-generated.
64 sed '/^ *#.*generated automatically/d' aclocal.m4 > t
65 mv -f t aclocal.m4
66 $AUTOCONF
67 $AUTOMAKE
69 for vpath in : false; do
71 if $vpath; then
72 mkdir build
73 cd build
74 srcdir=..
75 else
76 srcdir=.
79 $srcdir/configure
80 $MAKE # Should be a no-op.
82 $sleep
83 echo "AC_DEFUN([my_fingerprint], [$magic1])dnl %%%" >> $srcdir/aclocal.m4
84 remake_
85 $FGREP FINGERPRINT Makefile # For debugging.
86 $FGREP $magic1 Makefile
87 test x"$(./foo.sh)" = x"$magic1"
89 $sleep
90 echo "sed 's/.*dnl *%%%.*/AC_DEFUN([my_fingerprint], [$magic2])/'" \
91 > $srcdir/tweak-aclocal-m4
92 remake_
93 $FGREP FINGERPRINT Makefile # For debugging.
94 $FGREP $magic1 Makefile && exit 1
95 $FGREP $magic2 Makefile
96 test x"$(./foo.sh)" = x"$magic2"
98 $sleep
99 echo cat > $srcdir/tweak-aclocal-m4 # Make it a no-op again.
100 echo 'AC_DEFUN([my_fingerprint], [DummyValue])' >> $srcdir/aclocal.m4
101 using_gmake || remake_
102 $MAKE distcheck
103 $FGREP $magic1 Makefile && exit 1 # Sanity check.
104 $FGREP $magic2 Makefile && exit 1 # Likewise.
106 $MAKE distclean
108 cd $srcdir
110 done