GNU bug report logs - #10111
remake rules can fail in a weird corner case (VPATH into $distdir).

Previous Next

Package: automake;

Reported by: Stefano Lattarini <stefano.lattarini <at> gmail.com>

Date: Tue, 22 Nov 2011 19:06:02 UTC

Severity: minor

To reply to this bug, email your comments to 10111 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-automake <at> gnu.org:
bug#10111; Package automake. (Tue, 22 Nov 2011 19:06:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Stefano Lattarini <stefano.lattarini <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-automake <at> gnu.org. (Tue, 22 Nov 2011 19:06:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: bug-automake <at> gnu.org
Subject: remake rules can fail in a weird corner case (VPATH into $distdir).
Date: Tue, 22 Nov 2011 20:03:51 +0100
[Message part 1 (text/plain, inline)]
Severity: minor
thanks

This report describes a failure of the automake-generated remake
rules in a particular, low-probability scenario.  I admit upfront
that the scenario I'm speaking about is pretty corner-case, and
very unlikely to be problemtic in practice.  Still, I think it's
still worth having a description and a testsuite exposure for the
problem.

Here is how to reporduce the bug, step by step.

  $ mkdir bug
  $ cd bug
  $ cat > configure.ac <<'END'
  AC_INIT([foo], [1.0])
  AM_INIT_AUTOMAKE([foreign])
  m4_include([foobar.m4])
  AC_CONFIG_FILES([Makefile])
  AC_OUTPUT
  END
  $ : > foobar.m4
  $ cat > Makefile.am <<'END'
  $(srcdir)/foobar.m4:
	echo ': foobar was here :' > $@
  END
  $ autoreconf -vi
  autoreconf: Entering directory `.'
  autoreconf: configure.ac: not using Gettext
  autoreconf: running: aclocal 
  autoreconf: configure.ac: tracing
  autoreconf: configure.ac: not using Libtool
  autoreconf: running: /usr/bin/autoconf
  autoreconf: configure.ac: not using Autoheader
  autoreconf: running: automake --add-missing --copy --no-force
  configure.ac:2: installing `./install-sh'
  configure.ac:2: installing `./missing'
  autoreconf: Leaving directory `.'
  $ ./configure
  checking for a BSD-compatible install... /usr/bin/install -c
  checking whether build environment is sane... yes
  ...
  config.status: creating Makefile
  # OK, so the developer wants to interactively try out how the
  # "distributed form" of his package behaves
  $ make distdir
  ...
  $ ls foo-1.0 
  Makefile.am  aclocal.m4  configure.ac  install-sh
  Makefile.in  configure   foobar.m4     missing
  $ cd f00-1.0
  # He's interested in trying out a VPATH build.
  $ mkdir build && cd build
  $ ../configure
  checking for a BSD-compatible install... /usr/bin/install -c
  ...
  config.status: creating Makefile
  # He wants to verify that the rules he's written to rebuild a file
  # included by configure.in works also in VPATH builds.
  $ rm -f ../foobar.m4
  # But things won't work as expected!
  $ make
  make: Nothing to be done for `all'.
  $ ls -l ../foobar.m4
  ls: cannot access ../foobar.m4: No such file or directory
  $ grep foobar ../configure || echo no match
  no match
  # And a spurious error will fail when trying to rebuild the
  # distribution tarball.
  $ make dist
  ...
  test -d "foo-1.0" || mkdir "foo-1.0"
  cp: cannot stat `../foobar.m4': No such file or directory
  make: *** [distdir] Error 1

Let's see the explanation of the bug.  The following dependency is
in the generated Makefile:

  $(top_srcdir)/configure:  $(am__configure_deps)

Once the macros are expanded, this becomes:

  ../configure: ../foobar.m4 ../configure.ac ../aclocal.m4

GNN make sees that `../foobar.m4' does not exists in the current
directory; but since a VPATH build is being performed, make does not
error out, but rather looks for that file in the $(srcdir) directory
too.  Now, in our case `$(srcdir)' is `..', so make looks for the
file `../../foobar.m4' -- which do exists!  In fact, the first `..'
brings us in the `foo-1.0' directory, the second one in the original
test directory -- where our original, empty `foobar.m4' resides.

If this is true, nesting the build directory one level more should
solve the problem -- and it does:

  $ cd ..
  $ mkdir -p build2/sub
  $ cd build2/sub
  $ ../../configure
  checking for a BSD-compatible install... /usr/bin/install -c
  checking whether build environment is sane... yes
  ...
  config.status: creating Makefile
  $ make
  echo ': foobar was here :' > ../../foobar.m4
  CDPATH="${ZSH_VERSION+.}:" && cd ../.. && /bin/sh /tmp/bug/foo-1.0/missing --run aclocal-1.11 
   cd ../.. && /bin/sh /tmp/bug/foo-1.0/missing --run automake-1.11 --foreign
  CDPATH="${ZSH_VERSION+.}:" && cd ../.. && /bin/sh /tmp/bug/foo-1.0/missing --run autoconf
  /bin/sh ./config.status --recheck
  running CONFIG_SHELL=/bin/sh /bin/sh ../../configure --no-create --no-recursion
  checking for a BSD-compatible install... /usr/bin/install -c
  ...
  configure: creating ./config.status
   /bin/sh ./config.status
  config.status: creating Makefile
  make: Nothing to be done for `all'.

Attached are two test scripts that expose the bug for the related but
slightly different cases of an `.m4' file included by `configure.ac'
and an `.am' file included by `Makefile.am'.  I will soonish add them
to the maint branch if there is no objection.

Regards,
  Stefano
[foo1.test (application/x-shellscript, inline)]
[foo2.test (application/x-shellscript, inline)]

Information forwarded to bug-automake <at> gnu.org:
bug#10111; Package automake. (Tue, 22 Nov 2011 20:27:02 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: bug-automake <at> gnu.org
Cc: 10111 <at> debbugs.gnu.org, automake-patches <at> gnu.org
Subject: Re: bug#10111: remake rules can fail in a weird corner case (VPATH
	into $distdir).
Date: Tue, 22 Nov 2011 21:24:58 +0100
[Message part 1 (text/plain, inline)]
[adding automake-patches]

Reference:
 <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=10111>

On Tuesday 22 November 2011, Stefano Lattarini wrote:
> Attached are two test scripts that expose the bug for the related but
> slightly different cases of an `.m4' file included by `configure.ac'
> and an `.am' file included by `Makefile.am'.  I will soonish add them
> to the maint branch if there is no objection.
>
Done with the attached patch.

Regards,
  Stefano

[0001-remake-expose-automake-bug-10111-in-the-testsuite.patch (text/x-patch, inline)]
From 96b93273f629c4844e19d429a1cec61ff6d406c4 Mon Sep 17 00:00:00 2001
Message-Id: <96b93273f629c4844e19d429a1cec61ff6d406c4.1321991878.git.stefano.lattarini <at> gmail.com>
From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
Date: Tue, 22 Nov 2011 20:50:53 +0100
Subject: [PATCH] remake: expose automake bug#10111 in the testsuite

* tests/remake-am-pr10111.test: New test, xfailing.
* tests/remake-m4-pr10111.test: Likewise.
* tests/Makefile.am (TESTS, XFAIL_TESTS): Add them.
---
 ChangeLog                    |    7 ++++
 tests/Makefile.am            |    4 ++
 tests/Makefile.in            |    4 ++
 tests/remake-am-pr10111.test |   64 ++++++++++++++++++++++++++++++++++++++++++
 tests/remake-m4-pr10111.test |   62 ++++++++++++++++++++++++++++++++++++++++
 5 files changed, 141 insertions(+), 0 deletions(-)
 create mode 100644 tests/remake-am-pr10111.test
 create mode 100644 tests/remake-m4-pr10111.test

diff --git a/ChangeLog b/ChangeLog
index a828c21..0151d96 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-11-22  Stefano Lattarini  <stefano.lattarini <at> gmail.com>
+
+	remake: expose automake bug#10111 in the testsuite
+	* tests/remake-am-pr10111.test: New test, xfailing.
+	* tests/remake-m4-pr10111.test: Likewise.
+	* tests/Makefile.am (TESTS, XFAIL_TESTS): Add them.
+
 2011-11-19  Stefano Lattarini  <stefano.lattarini <at> gmail.com>
 
 	texinfo: work around Solaris 10 xpg4 shell bug in install rules
diff --git a/tests/Makefile.am b/tests/Makefile.am
index dd3fb46..936b781 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -26,6 +26,8 @@ gcj6.test \
 java-nobase.test \
 pr8365-remake-timing.test \
 lex-subobj-nodep.test \
+remake-am-pr10111.test \
+remake-m4-pr10111.test \
 vala-vpath.test \
 txinfo5.test
 
@@ -722,6 +724,8 @@ remake-subdir-gnu.test \
 remake-subdir.test \
 remake-subdir2.test \
 remake-subdir-long-time.test \
+remake-am-pr10111.test \
+remake-m4-pr10111.test \
 pr8365-remake-timing.test \
 regex.test \
 req.test \
diff --git a/tests/Makefile.in b/tests/Makefile.in
index d2085c8..18983ae 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -297,6 +297,8 @@ gcj6.test \
 java-nobase.test \
 pr8365-remake-timing.test \
 lex-subobj-nodep.test \
+remake-am-pr10111.test \
+remake-m4-pr10111.test \
 vala-vpath.test \
 txinfo5.test
 
@@ -1006,6 +1008,8 @@ remake-subdir-gnu.test \
 remake-subdir.test \
 remake-subdir2.test \
 remake-subdir-long-time.test \
+remake-am-pr10111.test \
+remake-m4-pr10111.test \
 pr8365-remake-timing.test \
 regex.test \
 req.test \
diff --git a/tests/remake-am-pr10111.test b/tests/remake-am-pr10111.test
new file mode 100644
index 0000000..a8c2dc6
--- /dev/null
+++ b/tests/remake-am-pr10111.test
@@ -0,0 +1,64 @@
+#! /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 our remake rules doesn't give spurious successes in
+# some corner case situations where they should actually fail.
+# See automake bug#10111.
+# To be clear, we are speaking about *very* corner-case situations here,
+# and the fact that the remake rules might get confused in them is not a
+# big deal in practice (in fact, this test *currently fails*).  Still,
+# keeping the limitation exposed is a good idea anyway.
+
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in <<'END'
+AC_OUTPUT
+END
+
+: > foobar.am
+
+cat > Makefile.am <<'END'
+include $(srcdir)/foobar.am
+$(srcdir)/foobar.am:
+## Creative quoring to avoid spurious matches in the grepping
+## of Makefile.in, later.
+	echo '#' 'foobar' 'was 'here' '#' > $@
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+# OK, so the developer wants to interactively try out how the
+# "distributed form" of his package behaves.
+$MAKE distdir
+cd $distdir
+# He's interested in trying out a VPATH build.
+mkdir build
+cd build
+../configure
+# He wants to verify that the rules he's written to rebuild a file
+# included by configure.in works also in VPATH builds.
+rm -f ../foobar.am
+$MAKE
+grep '# foobar was here #' ../Makefile.in
+$MAKE distcheck
+
+:
diff --git a/tests/remake-m4-pr10111.test b/tests/remake-m4-pr10111.test
new file mode 100644
index 0000000..2d89c25
--- /dev/null
+++ b/tests/remake-m4-pr10111.test
@@ -0,0 +1,62 @@
+#! /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 our remake rules doesn't give spurious successes in
+# some corner case situations where they should actually fail.
+# See automake bug#10111.
+# To be clear, we are speaking about *very* corner-case situations here,
+# and the fact that the remake rules might get confused in them is not a
+# big deal in practice (in fact, this test *currently fails*).  Still,
+# keeping the limitation exposed is a good idea anyway.
+
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in <<'END'
+m4_include([foobar.m4])
+AC_OUTPUT
+END
+
+: > foobar.m4
+
+cat > Makefile.am <<'END'
+$(srcdir)/foobar.m4:
+	echo ': foobar was here :' > $@
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+
+./configure
+
+# OK, so the developer wants to interactively try out how the
+# "distributed form" of his package behaves.
+$MAKE distdir
+cd $distdir
+# He's interested in trying out a VPATH build.
+mkdir build
+cd build
+../configure
+# He wants to verify that the rules he's written to rebuild a file
+# included by configure.in works also in VPATH builds.
+rm -f ../foobar.m4
+$MAKE
+grep ': foobar was here :' ../configure
+$MAKE distcheck
+
+:
-- 
1.7.2.3


Information forwarded to bug-automake <at> gnu.org:
bug#10111; Package automake. (Tue, 22 Nov 2011 20:27:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-automake <at> gnu.org:
bug#10111; Package automake. (Wed, 23 Nov 2011 10:13:02 GMT) Full text and rfc822 format available.

Message #14 received at 10111 <at> debbugs.gnu.org (full text, mbox):

From: Krzysztof Żelechowski
 <giecrilj <at> stegny.2a.pl>
To: 10111 <at> debbugs.gnu.org
Subject: typo fix
Date: Wed, 23 Nov 2011 11:10:58 +0100
> +## Creative quoring to avoid spurious matches in the grepping
quoting




Information forwarded to bug-automake <at> gnu.org:
bug#10111; Package automake. (Thu, 24 Nov 2011 14:54:02 GMT) Full text and rfc822 format available.

Message #17 received at 10111 <at> debbugs.gnu.org (full text, mbox):

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: Krzysztof Żelechowski <giecrilj <at> stegny.2a.pl>
Cc: 10111 <at> debbugs.gnu.org, automake-patches <at> gnu.org
Subject: Re: bug#10111: typo fix
Date: Thu, 24 Nov 2011 15:52:08 +0100
[Message part 1 (text/plain, inline)]
On Wednesday 23 November 2011, Krzysztof Żelechowski wrote:
> > +## Creative quoring to avoid spurious matches in the grepping
> quoting
> 
Thanks for spotting it.  Fixed by the attached patch.

Regards,
  Stefano
[0001-cosmetics-typofix-in-comments.patch (text/x-patch, inline)]
From 39a0fd0267ca5aab3d7c4677586181c355233eef Mon Sep 17 00:00:00 2001
Message-Id: <39a0fd0267ca5aab3d7c4677586181c355233eef.1322133328.git.stefano.lattarini <at> gmail.com>
From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
Date: Thu, 24 Nov 2011 12:14:49 +0100
Subject: [PATCH] cosmetics: typofix in comments
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* tests/remake-am-pr10111.test (Makefile.am): Fix typo in comments.
* THANKS: Update.

Reported by Krzysztof Żelechowski.
---
 ChangeLog                    |    7 +++++++
 THANKS                       |    1 +
 tests/remake-am-pr10111.test |    2 +-
 3 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 51d2dd8..a8e6587 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-11-24  Stefano Lattarini  <stefano.lattarini <at> gmail.com>
+
+	cosmetics: typofix in comments
+	* tests/remake-am-pr10111.test (Makefile.am): Fix typo in comments.
+	* THANKS: Update.
+	Reported by Krzysztof Żelechowski.
+
 2011-11-22  Stefano Lattarini  <stefano.lattarini <at> gmail.com>
 
 	coverage: undistributed '.am' and '.m4' files are diagnosed
diff --git a/THANKS b/THANKS
index 7e6de25..e9da06c 100644
--- a/THANKS
+++ b/THANKS
@@ -189,6 +189,7 @@ Kevin P. Fleming.	kpfleming <at> cox.net
 Kevin Ryde		user42 <at> zip.com.au
 Kevin Street		street <at> iname.com
 Klaus Reichl		Klaus.Reichl <at> alcatel.at
+Krzysztof Żelechowski	giecrilj <at> stegny.2a.pl
 L. Peter Deutsch	ghost <at> aladdin.com
 Ladislav Strojil	Ladislav.Strojil <at> seznam.cz
 Larry Jones		larry.jones <at> sdrc.com
diff --git a/tests/remake-am-pr10111.test b/tests/remake-am-pr10111.test
index a8c2dc6..6f622f8 100644
--- a/tests/remake-am-pr10111.test
+++ b/tests/remake-am-pr10111.test
@@ -35,7 +35,7 @@ END
 cat > Makefile.am <<'END'
 include $(srcdir)/foobar.am
 $(srcdir)/foobar.am:
-## Creative quoring to avoid spurious matches in the grepping
+## Creative quoting to avoid spurious matches in the grepping
 ## of Makefile.in, later.
 	echo '#' 'foobar' 'was 'here' '#' > $@
 END
-- 
1.7.2.3


This bug report was last modified 13 years and 205 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.