include: avoid "deleted .am file" problem
authorStefano Lattarini <stefano.lattarini@gmail.com>
Sun, 16 Oct 2011 12:57:37 +0000 (14:57 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Thu, 22 Dec 2011 18:00:43 +0000 (19:00 +0100)
* automake.in (handle_configure): When processing `configure.am',
also expand `HAVE-MAKEFILE-IN-DEPS' to a boolean telling whether
`MAKEFILE-IN-DEPS' is empty or not.
* lib/am/configure.am [?HAVE-MAKEFILE-IN-DEPS?]
(%MAKEFILE-IN-DEPS%): New target without dependencies, to
avoid the "deleted .am file" problem.  Emit this only when
`?HAVE-MAKEFILE-IN-DEPS?' is true, to avoid generating an
"empty" dependency declaration.
* tests/deleted-am.test: Make grepping of error message stricter.
* tests/dist-missing-am.test: Likewise.
* tests/remake-deleted-am.test: New test.
* tests/remake-deleted-am-2.test: Likewise.
* tests/remake-deleted-am-subdir.test: Likewise.
* tests/remake-renamed-am.test: Likewise.
* tests/makefile-deps.test: Likewise.
* tests/Makefile.am (TESTS): Add the new tests.
* NEWS: Update.

Fixes automake bug#9768.

Report by Peter Johansson.

See also commit `Release-1-10-40-gd0ebf71', which fixed a similar
problem for .m4 files included by configure.ac.

12 files changed:
ChangeLog
NEWS
automake.in
lib/am/configure.am
tests/Makefile.am
tests/deleted-am.test
tests/dist-missing-am.test
tests/makefile-deps.test [new file with mode: 0755]
tests/remake-deleted-am-2.test [new file with mode: 0755]
tests/remake-deleted-am-subdir.test [new file with mode: 0755]
tests/remake-deleted-am.test [new file with mode: 0755]
tests/remake-renamed-am.test [new file with mode: 0755]

index d97d461..d630aef 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2011-12-22  Stefano Lattarini  <stefano.lattarini@gmail.com>
+
+       include: avoid "deleted .am file" problem
+       * automake.in (handle_configure): When processing `configure.am',
+       also expand `HAVE-MAKEFILE-IN-DEPS' to a boolean telling whether
+       `MAKEFILE-IN-DEPS' is empty or not.
+       * lib/am/configure.am [?HAVE-MAKEFILE-IN-DEPS?]
+       (%MAKEFILE-IN-DEPS%): New target without dependencies, to
+       avoid the "deleted .am file" problem.  Emit this only when
+       `?HAVE-MAKEFILE-IN-DEPS?' is true, to avoid generating an
+       "empty" dependency declaration.
+       * tests/deleted-am.test: Make grepping of error message stricter.
+       * tests/dist-missing-am.test: Likewise.
+       * tests/remake-deleted-am.test: New test.
+       * tests/remake-deleted-am-2.test: Likewise.
+       * tests/remake-deleted-am-subdir.test: Likewise.
+       * tests/remake-renamed-am.test: Likewise.
+       * tests/makefile-deps.test: Likewise.
+       * tests/Makefile.am (TESTS): Add the new tests.
+       * NEWS: Update.
+       Fixes automake bug#9768.
+       Report by Peter Johansson.
+       See also commit `Release-1-10-40-gd0ebf71', which fixed a similar
+       problem for .m4 files included by configure.ac.
+
 2011-12-14  Stefano Lattarini  <stefano.lattarini@gmail.com>
 
        tests: better handling of gettext and libtool requirements
diff --git a/NEWS b/NEWS
index 785d6b0..ec4ab40 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -82,6 +82,10 @@ Bugs fixed in 1.11.0a:
 
 * Long-standing bugs:
 
+  - The "deleted header file problem" for *.am files is avoided by stub
+    rules.  This allows `make' to trigger a rerun of `automake' also if
+    some previously needed `.am' file has been removed.
+
   - "make distcheck" now correctly complains also when "make uninstall"
     leaves one and only one file installed in $(prefix).
 
index db7f3c6..309eade 100644 (file)
@@ -4249,6 +4249,7 @@ sub handle_configure ($$$@)
      'MAKEFILE-DEPS'       => "@rewritten",
      'CONFIG-MAKEFILE'     => ($relative_dir eq '.') ? '$@' : '$(subdir)/$@',
      'MAKEFILE-IN'         => $rel_makefile_in,
+     'HAVE-MAKEFILE-IN-DEPS' => (@include_stack > 0),
      'MAKEFILE-IN-DEPS'    => "@include_stack",
      'MAKEFILE-AM'         => $rel_makefile_am,
      'AUTOMAKE-OPTIONS'    => $automake_options,
index 594ec67..cadb27c 100644 (file)
@@ -83,6 +83,9 @@ endif %?TOPDIR_P%
            cd $(top_builddir) && $(SHELL) ./config.status %CONFIG-MAKEFILE% $(am__depfiles_maybe);; \
        esac;
 
+## Avoid the "deleted header file" problem for the dependencies.
+?HAVE-MAKEFILE-IN-DEPS?%MAKEFILE-IN-DEPS%:
+
 DIST_COMMON += %MAKEFILE-AM%
 
 
index b2a61ec..7097ff7 100644 (file)
@@ -555,6 +555,7 @@ maintclean.test \
 maintclean-vpath.test \
 maintmode-configure-msg.test \
 make.test \
+makefile-deps.test \
 makej.test \
 makej2.test \
 maken.test \
@@ -730,6 +731,10 @@ remake-subdir2.test \
 remake-subdir-long-time.test \
 remake-am-pr10111.test \
 remake-m4-pr10111.test \
+remake-deleted-am.test \
+remake-deleted-am-2.test \
+remake-deleted-am-subdir.test \
+remake-renamed-am.test \
 pr8365-remake-timing.test \
 regex.test \
 req.test \
index cc82e79..fa41e9e 100755 (executable)
@@ -39,12 +39,9 @@ $MAKE
 rm -f zardoz.am
 $MAKE >output 2>&1 && { cat output; Exit 1; }
 cat output
-# FIXME: enable this stricter grepping, once bug#9768 has been taken
-# FIXME: care of.
-## This error will come from automake, not make, so we can be stricter
-## in our grepping of it.
-# grep 'cannot open.*zardoz\.am' output
-grep 'zardoz\.am' output
+# This error will come from automake, not make, so we can be stricter
+# in our grepping of it.
+grep 'cannot open.*zardoz\.am' output
 grep 'foobar\.am' output && Exit 1 # No spurious error, please.
 
 # Try  with one less indirection.
@@ -55,11 +52,8 @@ $MAKE # Sanity check.
 rm -f foobar.am
 $MAKE >output 2>&1 && { cat output; Exit 1; }
 cat output
-# FIXME: enable this stricter grepping, once bug#9768 has been taken
-# FIXME: care of.
-## This error will come from automake, not make, so we can be stricter
-## in our grepping of it.
-# grep 'cannot open.*foobar\.am' output
-grep 'foobar\.am' output
+# This error will come from automake, not make, so we can be stricter
+# in our grepping of it.
+grep 'cannot open.*foobar\.am' output
 
 :
index 49e82aa..bb404bc 100755 (executable)
@@ -58,11 +58,9 @@ for vpath in false :; do
   fi
   $MAKE >output 2>&1 && { cat output; Exit 1; }
   cat output
-# FIXME: enable this stricter grepping, once bug#9768 has been taken
-# FIXME: care of.
-#  # This error comes from automake, not make, so we can be stricter
-#  # in our grepping of it.
-#  grep 'cannot open.*zardoz\.am' output
+  # This error comes from automake, not make, so we can be stricter
+  # in our grepping of it.
+  grep 'cannot open.*zardoz\.am' output
   grep 'foobar\.am' output && Exit 1 # No spurious error, please.
   cd "$ocwd" || fatal_ "cannot chdir back to top-level test directory"
 done
diff --git a/tests/makefile-deps.test b/tests/makefile-deps.test
new file mode 100755 (executable)
index 0000000..819c7d3
--- /dev/null
@@ -0,0 +1,31 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Make sure we don't emit a rule with empty target if list of
+# automatically-computed dependencies for Makefile.in is empty.
+
+. ./defs || Exit 1
+
+set -e
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOMAKE
+
+grep "^ *:" Makefile.in && Exit 1
+
+:
diff --git a/tests/remake-deleted-am-2.test b/tests/remake-deleted-am-2.test
new file mode 100755 (executable)
index 0000000..07142f6
--- /dev/null
@@ -0,0 +1,77 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that inclusion of `.am' fragments by automake does not suffer
+# of the "deleted header problem".  This test checks deeper inclusion
+# stacks, and use VPATH builds.
+
+. ./defs || Exit 1
+
+set -e
+
+echo AC_OUTPUT >> configure.in
+
+$ACLOCAL
+$AUTOCONF
+
+cat > Makefile.am <<'END'
+include $(srcdir)/foo.am
+END
+
+cat > foo.am <<'END'
+# this is foo
+include sub/bar.am
+include baz.am
+END
+
+mkdir sub
+echo 'include $(top_srcdir)/sub/zardoz.am' > sub/bar.am
+echo '# this is zardoz' > sub/zardoz.am
+
+echo 'include fnord.am' > baz.am
+echo '# you are not seeing this' > fnord.am
+
+$AUTOMAKE
+# Sanity checks.
+$FGREP 'this is zardoz' Makefile.in
+$FGREP 'you are not seeing this' Makefile.in
+
+mkdir build
+cd build
+
+srcdir=..
+
+$srcdir/configure
+$MAKE
+
+$sleep
+echo '# this is baz' > $srcdir/baz.am
+rm -f $srcdir/fnord.am
+$MAKE
+# Sanity checks.
+$FGREP 'you are not seeing this' $srcdir/Makefile.in Makefile && Exit 1
+$FGREP 'this is baz' $srcdir/Makefile.in
+$FGREP 'this is baz' Makefile
+
+$sleep
+rm -rf $srcdir/sub $srcdir/foo.am $srcdir/baz.am
+echo '# no more inclusions' > $srcdir/Makefile.am
+$MAKE
+# Sanity checks.
+$EGREP 'this is (foo|bar|baz)' Makefile $srcdir/Makefile.in && Exit 1
+$FGREP 'no more inclusions' Makefile
+
+:
diff --git a/tests/remake-deleted-am-subdir.test b/tests/remake-deleted-am-subdir.test
new file mode 100755 (executable)
index 0000000..9ed1078
--- /dev/null
@@ -0,0 +1,79 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that inclusion of `.am' fragments by automake does not suffer
+# of the "deleted header problem".  This test does the check when the
+# SUBDIRS variable is involved.
+
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in <<'END'
+AC_CONFIG_FILES([sub1/Makefile sub2/Makefile])
+AC_OUTPUT
+END
+
+$ACLOCAL
+$AUTOCONF
+
+cat > Makefile.am <<'END'
+include foo.am
+SUBDIRS = sub1 sub2
+END
+
+echo '# this is foo.am' > foo.am
+
+mkdir sub1 sub2
+
+echo 'include $(srcdir)/bar.am' > sub1/Makefile.am
+echo '# this is bar.am' > sub1/bar.am
+
+echo 'include $(top_srcdir)/foo.am' > sub2/Makefile.am
+
+$AUTOMAKE
+# Sanity checks.
+$FGREP 'this is foo.am' Makefile.in
+$FGREP 'this is bar.am' sub1/Makefile.in
+$FGREP 'this is foo.am' sub2/Makefile.in
+
+./configure
+$MAKE # Should be no-op.
+
+$sleep
+echo '# this is sub1/Makefile.am' > sub1/Makefile.am
+rm -f sub1/bar.am
+$MAKE all
+# Sanity checks.
+$FGREP 'this is bar' sub1/Makefile.in sub1/Makefile && Exit 1
+$FGREP 'this is sub1/Makefile.am' sub1/Makefile.in
+$FGREP 'this is sub1/Makefile.am' sub1/Makefile
+
+$sleep
+for d in . sub2; do
+  sed "s|.*include.*foo\.am.*|# this is $d/Makefile.am|" $d/Makefile.am > t
+  mv -f t $d/Makefile.am
+done
+rm -f foo.am
+$MAKE all
+# Sanity checks.
+$FGREP 'this is foo' sub*/Makefile* Makefile* && Exit 1
+for d in . sub1 sub2; do
+  $FGREP "this is $d/Makefile.am" $d/Makefile.in
+  $FGREP "this is $d/Makefile.am" $d/Makefile
+done
+
+:
diff --git a/tests/remake-deleted-am.test b/tests/remake-deleted-am.test
new file mode 100755 (executable)
index 0000000..fa5a672
--- /dev/null
@@ -0,0 +1,69 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that inclusion of `.am' fragments by automake does not suffer
+# of the "deleted header problem".  Basic checks are done here.
+
+. ./defs || Exit 1
+
+set -e
+
+echo AC_OUTPUT >> configure.in
+
+$ACLOCAL
+$AUTOCONF
+
+cat > Makefile.am <<'END'
+include foo.am
+include $(srcdir)/bar.am
+include $(top_srcdir)/baz.am
+END
+
+echo '# this is foo' > foo.am
+echo '# this is bar' > bar.am
+echo '# this is baz' > baz.am
+
+$AUTOMAKE
+# Sanity checks.
+$FGREP 'this is foo' Makefile.in
+$FGREP 'this is bar' Makefile.in
+$FGREP 'this is baz' Makefile.in
+
+./configure
+$MAKE # Should be no-op.
+
+$sleep
+sed '/^include foo\.am$/d' Makefile.am > t
+mv -f t Makefile.am
+rm -f foo.am
+$MAKE Makefile
+# Sanity checks.
+$FGREP 'this is foo' Makefile.in Makefile && Exit 1
+$FGREP 'this is bar' Makefile.in
+$FGREP 'this is bar' Makefile
+$FGREP 'this is baz' Makefile.in
+$FGREP 'this is baz' Makefile
+
+$sleep
+echo '# empty empty' > Makefile.am
+rm -f bar.am baz.am
+$MAKE Makefile
+# Sanity checks.
+$FGREP 'empty empty' Makefile.in
+$FGREP 'empty empty' Makefile
+grep 'this is ba[rz]' Makefile Makefile.in && Exit 1
+
+:
diff --git a/tests/remake-renamed-am.test b/tests/remake-renamed-am.test
new file mode 100755 (executable)
index 0000000..b3a7a41
--- /dev/null
@@ -0,0 +1,60 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that inclusion of `.am' fragments by automake does not suffer
+# of the "deleted header problem".  This test checks that we can rename
+# an included .am file without confusing the remake rules.
+
+. ./defs || Exit 1
+
+set -e
+
+echo AC_OUTPUT >> configure.in
+
+cat > Makefile.am <<'END'
+include foo.am
+END
+
+cat > foo.am <<'END'
+all-local:
+       echo ok > has-run-1
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+./configure
+$MAKE
+test -f has-run-1
+
+$sleep
+rm -f has-run-1
+mv -f foo.am bar.am
+echo include bar.am > Makefile.am
+$MAKE Makefile
+$FGREP 'foo.am' Makefile Makefile.in && Exit 1
+
+$sleep
+rm -f has-run-1 bar.am
+echo 'all-local:; echo ok > has-run-2' > zardoz.am
+echo 'include $(srcdir)/zardoz.am' > Makefile.am
+using_gmake || $MAKE Makefile
+$MAKE
+test ! -f has-run-1
+test -f has-run-2
+
+: