GNU bug report logs - #13928
foo_SOURCES containing unexpanded $(var) breaks with 'subdir-object' option active

Previous Next

Package: automake;

Reported by: Bert Wesarg <bert.wesarg <at> googlemail.com>

Date: Mon, 11 Mar 2013 21:04:02 UTC

Severity: important

Tags: patch

Done: Stefano Lattarini <stefano.lattarini <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 13928 in the body.
You can then email your comments to 13928 AT debbugs.gnu.org in the normal way.

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#13928; Package automake. (Mon, 11 Mar 2013 21:04: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. (Mon, 11 Mar 2013 21:04: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: Bert Wesarg <bert.wesarg <at> googlemail.com>
Cc: bug-automake <at> gnu.org, Peter Rosin <peda <at> lysator.liu.se>,
	Bob Friesenhahn <bfriesen <at> simple.dallas.tx.us>,
	Eric Blake <eblake <at> redhat.com>, Miles Bader <miles <at> gnu.org>
Subject: VPATH issues with subdir-objects (was: [PATCH 1/2] preproc: add
	support for relative names in included fragments)
Date: Mon, 11 Mar 2013 21:55:08 +0100
On 03/11/2013 08:45 PM, Bert Wesarg wrote:
> [ Removing patches@ and 13524@ from Cc. ]
>
I think it's better if this discussion remains public.  I'm re-adding
automake-patches, and since you have apparently uncovered a new bug
in automake, I'm also re-adding bug-automake, so that this discussion
will be registered in the bug tracker.

> On Mon, Mar 11, 2013 at 7:58 PM, Stefano Lattarini
> <stefano.lattarini <at> gmail.com> wrote:
>> On 03/11/2013 01:05 PM, Bert Wesarg wrote:
>>> On Mon, Mar 11, 2013 at 10:46 AM, Stefano Lattarini
>>> <stefano.lattarini <at> gmail.com> wrote:
>>>> On 03/11/2013 10:31 AM, Bert Wesarg wrote:
>>>>> I have the impression that variable references in filenames aren't
>>>>> supported anyway, right?
>>>>>
>>>> Wrong, actually.
>>>
>>> But when I prefixing a source file with '$(src)/' and use
>>> subdir-objects then I get something like this in the Makefile.in
>>>
>>> $(src)/test-test.o: $(src)/test.c
>>>
>>> And after a configure I get an '$(src)' directory in my build dir.
>>>
>> Yes -- and this is intended behavior of subdir-objects.  Why do you
>> think Automake is acting wrong?  (Honest question, I might be missing
>> something here ...)
> 
> Why would I want a directory named '$(src)' in my build directory?
>
Oh, but $(src) would of course be expanded at make runtime, not used
literally.

> If anything than this variable should be resolved.
>
And it isn't?  That would be a bug.  (Apparently, from what I read
below, this indeed the case, sadly).

> Anyway, when running make I get:
> 
> Makefile:299: .deps/test-test.Po: No such file or directory
> make: *** No rule to make target `.deps/test-test.Po'.  Stop.
> 
> Because the file '.deps/test-test.Po' is here
> '$(src)/.deps/test-test.Po', literally. So maybe automake is not to
> blame here but the autoconf machinery which creates the dummy .Po
> files at configure time.
>
Ah, I think I'm beginning to understand the issue.  This appears to be
an actual bug.  And since that configure machinery comes from Automake
provided macros, it is an Automake bug :-(

Since I'm short of time right now, I won't be able to pursue this
issue shortly, nor write a proper test case.  If you can and want
offer one, that would be great; otherwise, I hope I'll be able to
write one myself in reasonable time.

And here is a quick and brutal proposal to resolve the issue:

  - since it's not a regression, simply keep the buggy behaviour
    in the 1.x Automake series;

  - from Automake 2.0 onward, only enable the automatic dependency
    tracking if GNU make is used; we can thus assume the presence
    of the "-include" directive (which ignore non-existing files,
    rather than punting), and its use will allow us to get rid of
    the configure time machinery for the initial creation of .deps
    directories (this has already been done in Automake-NG, and has
    worked beautifully so far).

I think the approach described above is acceptable because automatic
dependency tracking is important only for developers or power users,
and those should be using GNU make anyway.

> Actually, I first prefixed it with '$(srcdir)/',
> 
> test_SOURCES = $(srcdir)/test.c
> 
> just to see the generated make rule:
> 
> $(srcdir)/test-test.o: $(srcdir)/test.c
> 
> which would completely circumvent VPATH builds, would it?
>
Yes.  The answer is: don't use $(srcdir) in your source files -- they
will be picked up anyway thanks to VPATH.  A better and more friendly
solution would be to enhance Automake so that it can understand that
the object file generated from a '$(srcdir)/foo.c' is to be placed in
the build directory even when the 'subdir-object' option is active --
which is clearly the right thing to do.  As usual, patches welcome
(just having a test case exposing the issue would be a good start).

> But than I
> saw the '$(srcdir)' directory which just looks very odd. Than I used
> another variable to see the same behavior.
> 
> I tried playing with this after you mentioned to make subdir-objects
> the default sometime in the future and our automake files use
> extensively variable references in the source file names.
>
And it's very appreciated that you have taken the time to bring these
issues up.  Thank you.

Best regards,
  Stefano




Changed bug submitter to 'Bert Wesarg <bert.wesarg <at> googlemail.com>' from 'Stefano Lattarini <stefano.lattarini <at> gmail.com>' Request was from Stefano Lattarini <stefano.lattarini <at> gmail.com> to control <at> debbugs.gnu.org. (Mon, 11 Mar 2013 21:26:02 GMT) Full text and rfc822 format available.

Changed bug title to 'VPATH issues with subdir-objects' from 'VPATH issues with subdir-objects (was: [PATCH 1/2] preproc: add support for relative names in included fragments)' Request was from Stefano Lattarini <stefano.lattarini <at> gmail.com> to control <at> debbugs.gnu.org. (Mon, 11 Mar 2013 21:26:02 GMT) Full text and rfc822 format available.

Removed tag(s) patch. Request was from Stefano Lattarini <stefano.lattarini <at> gmail.com> to control <at> debbugs.gnu.org. (Mon, 11 Mar 2013 21:29:01 GMT) Full text and rfc822 format available.

Information forwarded to bug-automake <at> gnu.org:
bug#13928; Package automake. (Mon, 11 Mar 2013 21:35:01 GMT) Full text and rfc822 format available.

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

From: Nick Bowler <nbowler <at> elliptictech.com>
To: Stefano Lattarini <stefano.lattarini <at> gmail.com>
Cc: 13928 <at> debbugs.gnu.org, peda <at> lysator.liu.se, bfriesen <at> simple.dallas.tx.us,
	Bert Wesarg <bert.wesarg <at> googlemail.com>, eblake <at> redhat.com, miles <at> gnu.org
Subject: Re: bug#13928: VPATH issues with subdir-objects (was: [PATCH 1/2]
	preproc: add support for relative names in included fragments)
Date: Mon, 11 Mar 2013 17:33:34 -0400
On 2013-03-11 21:55 +0100, Stefano Lattarini wrote:
[...]
>   - from Automake 2.0 onward, only enable the automatic dependency
>     tracking if GNU make is used; we can thus assume the presence
>     of the "-include" directive (which ignore non-existing files,
>     rather than punting), and its use will allow us to get rid of
>     the configure time machinery for the initial creation of .deps
>     directories (this has already been done in Automake-NG, and has
>     worked beautifully so far).
> 
> I think the approach described above is acceptable because automatic
> dependency tracking is important only for developers or power users,
> and those should be using GNU make anyway.

I can't say I'm a big fan of breaking the current wide-support of
automatic dependency tracking in Automake.  While not universal, the
automatic dependency tracking currently works with many different make
implementations (particularly those provided by the BSD flavours).

I also don't agree with the rationale that only developers and "power
users" need this feature.  The most obvious class of users who may need
this feature are those applying patches sent by a maintainer to test a
bug fix.  Particularly if those users are running on an exotic platform
without GNU make that the maintainer would not otherwise have access to.

Or users who want to run "git bisect" -- I've done this on packages with
buggy incremental builds before, and it's not a lot of fun.

Ideally, we should try to fix the bug before ripping out an
otherwise-working feature.

Cheers,
-- 
Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/)




Information forwarded to bug-automake <at> gnu.org:
bug#13928; Package automake. (Mon, 11 Mar 2013 22:29:01 GMT) Full text and rfc822 format available.

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

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: Nick Bowler <nbowler <at> elliptictech.com>
Cc: 13928 <at> debbugs.gnu.org, peda <at> lysator.liu.se, bfriesen <at> simple.dallas.tx.us,
	Bert Wesarg <bert.wesarg <at> googlemail.com>, eblake <at> redhat.com, miles <at> gnu.org
Subject: Re: bug#13928: VPATH issues with subdir-objects
Date: Mon, 11 Mar 2013 23:27:11 +0100
On 03/11/2013 10:33 PM, Nick Bowler wrote:
> On 2013-03-11 21:55 +0100, Stefano Lattarini wrote:
> [...]
>>   - from Automake 2.0 onward, only enable the automatic dependency
>>     tracking if GNU make is used; we can thus assume the presence
>>     of the "-include" directive
>>
Actually, to be more precise, we could simply test at runtime if that
directive is supported by the target make implementation (there is
already code that does so for the "include" directive, so we shouldn't
need any real new code or logic); or at least, if some equivalent
directive is available.  If yes, we can enable automatic dependency
tracking (without having to worry about the GNU vs. non-GNU make issue
at all).  But sadly, it appears that in practice GNU make is the only
make flavor to actually implement this kind feature so far :-/ so all
of this is moot.

>> (which ignore non-existing files,
>>     rather than punting), and its use will allow us to get rid of
>>     the configure time machinery for the initial creation of .deps
>>     directories (this has already been done in Automake-NG, and has
>>     worked beautifully so far).
>>
>> I think the approach described above is acceptable because automatic
>> dependency tracking is important only for developers or power users,
>> and those should be using GNU make anyway.
> 
> I can't say I'm a big fan of breaking the current wide-support of
> automatic dependency tracking in Automake.  While not universal, the
> automatic dependency tracking currently works with many different make
> implementations (particularly those provided by the BSD flavours).
>
[In fact, it works with every version of make that supports the 'include'
directive -- including, e.g., Solaris make].

> I also don't agree with the rationale that only developers and "power
> users" need this feature.  The most obvious class of users who may need
> this feature are those applying patches sent by a maintainer to test a
> bug fix.
>
OK, fair point here.

> Particularly if those users are running on an exotic platform
> without GNU make
>
<complain-mode>
  Which makes me ask again, as I've done many times already: does such
  platforms truly exist, and if yes, are they really relevant and
  worth bending over backwards for?
</complain-mode>

> that the maintainer would not otherwise have access to.
> 
> Or users who want to run "git bisect" -- I've done this on packages with
> buggy incremental builds before, and it's not a lot of fun.
>
They could use GNU make for that.  Developers should be using it anyway ;-)

> Ideally, we should try to fix the bug before ripping out an
> otherwise-working feature.
>
If someone volunteers to write a patch for such a fix, I certainly won't
object to it.  But I'm not going to do it myself anytime soon (and likely,
not even anytime later).

Regards,
  Stefano




Information forwarded to bug-automake <at> gnu.org:
bug#13928; Package automake. (Tue, 12 Mar 2013 14:11:01 GMT) Full text and rfc822 format available.

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

From: Nick Bowler <nbowler <at> elliptictech.com>
To: Stefano Lattarini <stefano.lattarini <at> gmail.com>
Cc: 13928 <at> debbugs.gnu.org, peda <at> lysator.liu.se, bfriesen <at> simple.dallas.tx.us,
	Bert Wesarg <bert.wesarg <at> googlemail.com>, eblake <at> redhat.com, miles <at> gnu.org
Subject: Re: bug#13928: VPATH issues with subdir-objects
Date: Tue, 12 Mar 2013 10:09:29 -0400
On 2013-03-11 23:27 +0100, Stefano Lattarini wrote:
> On 03/11/2013 10:33 PM, Nick Bowler wrote:
> > On 2013-03-11 21:55 +0100, Stefano Lattarini wrote:
> > [...]
> >>   - from Automake 2.0 onward, only enable the automatic dependency
> >>     tracking if GNU make is used; we can thus assume the presence
> >>     of the "-include" directive
> >>
> Actually, to be more precise, we could simply test at runtime if that
> directive is supported by the target make implementation (there is
> already code that does so for the "include" directive, so we shouldn't
> need any real new code or logic); or at least, if some equivalent
> directive is available.  If yes, we can enable automatic dependency
> tracking (without having to worry about the GNU vs. non-GNU make issue
> at all).  But sadly, it appears that in practice GNU make is the only
> make flavor to actually implement this kind feature so far :-/ so all
> of this is moot.

FWIW, I believe that NetBSD make supports -include as well.

[...]
> > Particularly if those users are running on an exotic platform
> > without GNU make
> >
> <complain-mode>
>   Which makes me ask again, as I've done many times already: does such
>   platforms truly exist, and if yes, are they really relevant and
>   worth bending over backwards for?
> </complain-mode>

A platform on which GNU make does not run at all?  Probably not, as
GNU make itself is very portable.  But platforms which do not have it
installed by default are easy to find: FreeBSD, for example.

More importantly, the problems caused by incomplete make dependencies
may not be obvious as an error when building the package: it's entirely
possible that the package will build successfully, but incompletely,
after modifying the sources, only causing incorrect behaviour later
when the program is run.

[...]
> > Ideally, we should try to fix the bug before ripping out an
> > otherwise-working feature.
>
> If someone volunteers to write a patch for such a fix, I certainly won't
> object to it.  But I'm not going to do it myself anytime soon (and likely,
> not even anytime later).

Regarding the actual bug: without knowing much (yet!) about the relevant
Automake internals, I'm a bit surprised that

  src = src
  foo_SOURCES = $(src)/foo.c

fails with subdir-objects, but on the other hand

  src = src/foo.c
  foo_SOURCES = $(src)

seems to work just fine...

Cheers,
-- 
Nick Bowler, Elliptic Technologies (http://www.elliptictech.com/)




Information forwarded to bug-automake <at> gnu.org:
bug#13928; Package automake. (Tue, 12 Mar 2013 14:41:03 GMT) Full text and rfc822 format available.

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

From: Bert Wesarg <bert.wesarg <at> googlemail.com>
To: Nick Bowler <nbowler <at> elliptictech.com>
Cc: 13928 <at> debbugs.gnu.org, peda <at> lysator.liu.se,
	Stefano Lattarini <stefano.lattarini <at> gmail.com>,
	bfriesen <at> simple.dallas.tx.us, eblake <at> redhat.com, miles <at> gnu.org
Subject: Re: bug#13928: VPATH issues with subdir-objects
Date: Tue, 12 Mar 2013 15:39:18 +0100
> Regarding the actual bug: without knowing much (yet!) about the relevant
> Automake internals, I'm a bit surprised that
>
>   src = src
>   foo_SOURCES = $(src)/foo.c
>
> fails with subdir-objects, but on the other hand
>
>   src = src/foo.c
>   foo_SOURCES = $(src)
>
> seems to work just fine...

That's because automake expands entries in _SURCES which are only
variable references. It needs to because of AM_CONDITIONAL. In case
the value of _SOURCES is subject to an condition, the conditional
source file name is stored in an intermediate variable but the actual
assignment happens only if the condition is TRUE. But the intermediate
variable is unconditionally added to the _SOURCES variable.

Bert

>
> Cheers,




Information forwarded to bug-automake <at> gnu.org:
bug#13928; Package automake. (Sat, 08 Jun 2013 21:10:02 GMT) Full text and rfc822 format available.

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

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: Bert Wesarg <bert.wesarg <at> googlemail.com>
Cc: Nick Bowler <nbowler <at> elliptictech.com>, 13928 <at> debbugs.gnu.org,
	peda <at> lysator.liu.se, "automake-patches <at> gnu.org" <automake-patches <at> gnu.org>,
	bfriesen <at> simple.dallas.tx.us, eblake <at> redhat.com, miles <at> gnu.org
Subject: Re: bug#13928: VPATH issues with subdir-objects
Date: Sat, 08 Jun 2013 23:08:14 +0200
[+cc automake-patches]

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

Hello everybody, sorry for the delay.

On 11/03/2013 01:05 PM, Bert Wesarg wrote (more or less):
>
> But when I prefix a source file with '$(src)/' and use
> subdir-objects then I get something like this in the Makefile.in
>
>   $(src)/test-test.o: $(src)/test.c
>
> And after a configure I get in my build dir a directory named
> literally "$(src)".
>
> Why would I want a directory named "$(src)" in my build
> directory? If anything than the $(src) make variable should
> be resolved. Anyway, when running make I get:
>
>   Makefile:299: .deps/test-test.Po: No such file or directory
>   make: *** No rule to make target `.deps/test-test.Po'.  Stop.
>

On 12/03/2013 03:39 PM, Bert Wesarg wrote:
>
> Regarding the actual bug: without knowing much (yet!) about the relevant
> Automake internals, I'm a bit surprised that
>
>   src = src
>   foo_SOURCES = $(src)/foo.c
>
> fails with subdir-objects, but on the other hand
>
>   src = src/foo.c
>   foo_SOURCES = $(src)
>
> seems to work just fine...
> 

Still not sure when I'll manage to look into these issues properly.
But in the meantime, I've at least added a couple of test cases to
expose them.  See the patch below.  Will soon push it to 'micro'.

Regards,
  Stefano

---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ----

From 004eba9b3c19747652fa9feab9846d646c83f5d8 Mon Sep 17 00:00:00 2001
Message-Id: <004eba9b3c19747652fa9feab9846d646c83f5d8.1370725645.git.stefano.lattarini <at> gmail.com>
From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
Date: Sat, 8 Jun 2013 22:00:32 +0200
Subject: [PATCH] tests: expose automake bug#13928

* t/subobj-indir-pr13928.sh: New test, still xfailing.
* t/subobj-vpath-pr13928.sh: Likewise.
* t/list-of-tests.mk (XFAIL_TESTS, handwritten_TESTS): Update.

Signed-off-by: Stefano Lattarini <stefano.lattarini <at> gmail.com>
---
 t/list-of-tests.mk        |  4 ++++
 t/subobj-indir-pr13928.sh | 49 ++++++++++++++++++++++++++++++++++++++
 t/subobj-vpath-pr13928.sh | 60 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 113 insertions(+)
 create mode 100644 t/subobj-indir-pr13928.sh
 create mode 100644 t/subobj-vpath-pr13928.sh

diff --git a/t/list-of-tests.mk b/t/list-of-tests.mk
index 68ca58c..1d7cf87 100644
--- a/t/list-of-tests.mk
+++ b/t/list-of-tests.mk
@@ -40,6 +40,8 @@ t/java-nobase.sh \
 t/objext-pr10128.sh \
 t/remake-timing-bug-pr8365.sh \
 t/lex-subobj-nodep.sh \
+t/subobj-indir-pr13928.sh \
+t/subobj-vpath-pr13928.sh \
 t/remake-am-pr10111.sh \
 t/remake-m4-pr10111.sh \
 $(perl_fake_XFAIL_TESTS)
@@ -1034,6 +1036,8 @@ t/subobj11c.sh \
 t/subobjname.sh \
 t/subobj-clean-pr10697.sh \
 t/subobj-clean-lt-pr10697.sh \
+t/subobj-indir-pr13928.sh \
+t/subobj-vpath-pr13928.sh \
 t/subpkg.sh \
 t/subpkg2.sh \
 t/subpkg3.sh \
diff --git a/t/subobj-indir-pr13928.sh b/t/subobj-indir-pr13928.sh
new file mode 100644
index 0000000..11b865c
--- /dev/null
+++ b/t/subobj-indir-pr13928.sh
@@ -0,0 +1,49 @@
+#! /bin/sh
+# Copyright (C) 2013 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/>.
+
+# Expose part of Automake bug#13928: config.status generates broken
+# makefiles if the subdir-objects option is used and a _SOURCES
+# variable lists sources whose directory part is specified as a
+# make variable ("foo_SOURCES = $(src)/foo.c").
+
+required=cc
+. test-init.sh
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+AUTOMAKE_OPTIONS = subdir-objects
+src = s
+bin_PROGRAMS = foo
+foo_SOURCES = $(src)/foo.c
+END
+
+mkdir s
+echo 'int main(void) { return 0; }' > s/foo.c
+
+$ACLOCAL && $AUTOCONF && $AUTOMAKE -a || fatal_ "autotools failed"
+
+./configure
+$MAKE
+test -f s/.deps/foo.Po
+find . | $FGREP '$(src)' && exit 1
+$MAKE distcheck
+
+:
diff --git a/t/subobj-vpath-pr13928.sh b/t/subobj-vpath-pr13928.sh
new file mode 100644
index 0000000..96cb219
--- /dev/null
+++ b/t/subobj-vpath-pr13928.sh
@@ -0,0 +1,60 @@
+#! /bin/sh
+# Copyright (C) 2013 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/>.
+
+# Expose part of automake bug#13928: if the subdir-objects option is
+# in use and a source file is listed in a _SOURCES variable with a
+# leading $(srcdir) component, Automake will generate a Makefile that
+# tries to create the corresponding object file in $(srcdir) as well.
+
+required=cc
+. test-init.sh
+
+cat >> configure.ac << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+AUTOMAKE_OPTIONS = subdir-objects
+noinst_PROGRAMS = test
+test_SOURCES = $(srcdir)/test.c
+test-objs:
+	test ! -f $(srcdir)/test.$(OBJEXT)
+	test -f test.$(OBJEXT)
+END
+
+$ACLOCAL && $AUTOCONF && $AUTOMAKE -a || fatal_ "autotools failed"
+
+$EGREP 'test\.|DEPDIR|dirstamp|srcdir' Makefile.in || : # For debugging.
+$EGREP '\$.srcdir./test\.[o$]' Makefile.in && exit 1
+$FGREP '$(srcdir)/$(am__dirstamp)' Makefile.in && exit 1
+$FGREP '$(srcdir)/$(DEPDIR)' && exit 1
+
+cat > test.c << 'END'
+int main (void)
+{
+  return 0;
+}
+END
+
+mkdir build && cd build || fatal "preparation of build directory failed"
+../configure || fatal_ "./configure failed"
+
+$MAKE
+$MAKE test-objs
+
+:
-- 
1.8.3.rc3.8.g5e49f30







Information forwarded to bug-automake <at> gnu.org:
bug#13928; Package automake. (Mon, 05 Aug 2013 21:52:01 GMT) Full text and rfc822 format available.

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

From: Shawn Webb <swebb <at> sourcefire.com>
To: 13928 <at> debbugs.gnu.org
Subject: bug#13928
Date: Mon, 5 Aug 2013 17:35:25 -0400
[Message part 1 (text/plain, inline)]
I'm hitting this bug as well. Are there any known workarounds?

Thanks,

Shawn Webb
[Message part 2 (text/html, inline)]

Information forwarded to bug-automake <at> gnu.org:
bug#13928; Package automake. (Mon, 21 Apr 2014 10:34:01 GMT) Full text and rfc822 format available.

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

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: Diab Jerius <djerius <at> cfa.harvard.edu>
Cc: 13928 <at> debbugs.gnu.org
Subject: Re: bug#16375: subdir-objects breaks build which specifies sources
 relative to $(top_srcdir)
Date: Mon, 21 Apr 2014 11:33:27 +0100
[+cc 13928 <at> debbugs.gnu.org]

References:
  http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16375
  http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15919
  http://debbugs.gnu.org/cgi/bugreport.cgi?bug=15293

Known bugs sadly -- all duplicates of http://debbugs.gnu.org/13928

See also recent thread on the automake list (with sad updates
regarding the current Automake development status):
http://lists.gnu.org/archive/html/automake/2014-04/msg00002.html

Closing these bug as a duplicate.  Feel free to continue the
discussion in the http://debbugs.gnu.org/13928 thread.  And
if anyone manages to come up with a patch, I will certainly
make time to review it.

Thanks, and sorry for the lack of progress,
  Stefano




Information forwarded to bug-automake <at> gnu.org:
bug#13928; Package automake. (Mon, 21 Apr 2014 14:33:01 GMT) Full text and rfc822 format available.

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

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: automake-patches <at> gnu.org
Cc: 13928 <at> debbugs.gnu.org
Subject: [PATCH] plans: enabling subdir-object by default is blocked on
 bug#13928
Date: Mon, 21 Apr 2014 15:32:21 +0100
Signed-off-by: Stefano Lattarini <stefano.lattarini <at> gmail.com>
---
 PLANS/subdir-objects.txt | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/PLANS/subdir-objects.txt b/PLANS/subdir-objects.txt
index 94c6305..3cf6101 100644
--- a/PLANS/subdir-objects.txt
+++ b/PLANS/subdir-objects.txt
@@ -5,6 +5,9 @@ We want to make the behaviour currently enabled by the 'subdir-objects'
 the default one, and in fact the *only* one, in Automake 2.0.
 See automake bug#13378: <http://debbugs.gnu.org/13378>.
 
+Sadly, **THIS IS IMPOSSIBLE** until automake bug#13928 is resolved:
+http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13928
+
 Details
 -------
 
@@ -50,6 +53,12 @@ We also make sure to avoid the warning when it would be irrelevant, i.e.,
 if all source files sit in "current" directory (thanks to Peter Johansson
 for suggesting this).
 
+For some automake 1.x (*before* 2.0 can be released)
+----------------------------------------------------
+
+Find a proper way to fix the blocking automake bug#13928:
+http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13928
+
 For automake 2.0
 ----------------
 
-- 
1.9.1





Information forwarded to bug-automake <at> gnu.org:
bug#13928; Package automake. (Tue, 22 Apr 2014 08:12:03 GMT) Full text and rfc822 format available.

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

From: Bert Wesarg <bert.wesarg <at> googlemail.com>
To: Stefano Lattarini <stefano.lattarini <at> gmail.com>
Cc: 13928 <at> debbugs.gnu.org, automake-patches <at> gnu.org
Subject: Re: bug#13928: [PATCH] plans: enabling subdir-object by default is
 blocked on bug#13928
Date: Tue, 22 Apr 2014 10:11:47 +0200
Stefano,

may it be possible to disable the 'subdir-object is the
default'-warning in the 1.14 release series than? We should have this
warning only active when we are sure that this bug is resolved.

Thanks.

Bert

On Mon, Apr 21, 2014 at 4:32 PM, Stefano Lattarini
<stefano.lattarini <at> gmail.com> wrote:
> Signed-off-by: Stefano Lattarini <stefano.lattarini <at> gmail.com>
> ---
>  PLANS/subdir-objects.txt | 9 +++++++++
>  1 file changed, 9 insertions(+)
>
> diff --git a/PLANS/subdir-objects.txt b/PLANS/subdir-objects.txt
> index 94c6305..3cf6101 100644
> --- a/PLANS/subdir-objects.txt
> +++ b/PLANS/subdir-objects.txt
> @@ -5,6 +5,9 @@ We want to make the behaviour currently enabled by the 'subdir-objects'
>  the default one, and in fact the *only* one, in Automake 2.0.
>  See automake bug#13378: <http://debbugs.gnu.org/13378>.
>
> +Sadly, **THIS IS IMPOSSIBLE** until automake bug#13928 is resolved:
> +http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13928
> +
>  Details
>  -------
>
> @@ -50,6 +53,12 @@ We also make sure to avoid the warning when it would be irrelevant, i.e.,
>  if all source files sit in "current" directory (thanks to Peter Johansson
>  for suggesting this).
>
> +For some automake 1.x (*before* 2.0 can be released)
> +----------------------------------------------------
> +
> +Find a proper way to fix the blocking automake bug#13928:
> +http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13928
> +
>  For automake 2.0
>  ----------------
>
> --
> 1.9.1
>
>
>
>




Information forwarded to bug-automake <at> gnu.org:
bug#13928; Package automake. (Tue, 22 Apr 2014 10:06:02 GMT) Full text and rfc822 format available.

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

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: Bert Wesarg <bert.wesarg <at> googlemail.com>
Cc: 13928 <at> debbugs.gnu.org, automake-patches <at> gnu.org
Subject: Re: bug#13928: [PATCH] plans: enabling subdir-object by default is
 blocked on bug#13928
Date: Tue, 22 Apr 2014 11:05:41 +0100
On 04/22/2014 09:11 AM, Bert Wesarg wrote:
> Stefano,
> 
> may it be possible to disable the 'subdir-object is the
> default'-warning in the 1.14 release series than? We should have this
> warning only active when we are sure that this bug is resolved.
>
I'd rather not take this step back, since the 'subdir-objects'
option works correctly in most situations.

The right thing to do would be to fix the bug once and for all.
If somebody wants to give it a try, I will be happy to review any
patch in that direction.  Otherwise, I will try to make time to
attempt a fix myself in the coming weeks, but be warned that it
would likely entail dropping automatic dependency tracking support
for all those make implementations that doesn't support an
equivalent of GNU make "-include" directive.  (FWIW, I actually
believe that is the right way forward, but several people on this
list have expressed their dislike toward such a change, so I will
give them time to try a different approach themselves before
plunging ahead).

Regards,
  Stefano




Information forwarded to bug-automake <at> gnu.org:
bug#13928; Package automake. (Sat, 05 Jul 2014 18:01:01 GMT) Full text and rfc822 format available.

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

From: Johan Kristensen <johankristensen <at> gmail.com>
To: automake-patches <at> gnu.org, 13928 <at> debbugs.gnu.org
Subject: Re: bug#13928: [PATCH] plans: enabling subdir-object by default is
 blocked on bug#13928
Date: Sat, 5 Jul 2014 19:59:34 +0200
[Message part 1 (text/plain, inline)]
Hi,

What is the current status of this bug? I spent some time tracking down the
reason for this bug, but I am totally new to the automake sources and what
would be required for a patch to be acceptable. The problem is that when
the dummy dependency-files is created by "./config.status" (by code from
"m4/depout.m4"), only the DEPDIR variable is substituted. Any other
variable expansions are ignored.

I have a couple of suggestions for a fix. The first is to somehow delegate
the creation of the dummy dependency-files to make, and executing something
like "make dummy-depfiles" from config.status. This seems like the most
straightforward solution but raises the question of how to handle the
includes that are missing. One solution to this problem would be to have
some conditional include of the dependency-files based on if target
"dummy-depfiles" is built. An other solution would be to generate a
temporary Makefile without these includes.

The other alternative is to resolve all variables in depout.m4. To be
correct this would require a recursive lookup of all variable substitutions
in the Makefile. Perhaps the structure imposed by automake makes this kind
of trivial but I have no idea. Will automake under some circumstances
output something like "+=", "?=" or conditional assigns? This would make a
solution along these lines intractable.

kind regards,
Johan Kristensen
[Message part 2 (text/html, inline)]

Severity set to 'important' from 'normal' Request was from Stefano Lattarini <stefano.lattarini <at> gmail.com> to control <at> debbugs.gnu.org. (Wed, 24 Dec 2014 13:23:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-automake <at> gnu.org:
bug#13928; Package automake. (Thu, 01 Jan 2015 16:29:02 GMT) Full text and rfc822 format available.

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

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: Johan Kristensen <johankristensen <at> gmail.com>, automake <at> gnu.org, 
 13928 <at> debbugs.gnu.org
Cc: Nick Bowler <nbowler <at> elliptictech.com>,
 Bert Wesarg <bert.wesarg <at> googlemail.com>
Subject: The 'subdir-object' option breaks makefiles where foo_SOURCES contains
 $(var)
Date: Thu, 01 Jan 2015 17:28:10 +0100
retitle 13928 foo_SOURCES containing unexpanded $(var) breaks with 'subdir-object' option active
stop

Reference: http://debbugs.gnu.org/13928

Hi Johan and everybody, sorry for the awful delay.

On 07/05/2014 07:59 PM, Johan Kristensen wrote:
> Hi,
>
> What is the current status of this bug?
>
> [MEGA-SNIP]
>
I'm trying a simple approach (which seems quite promising so far)
in the experimental Git branch experimental/deps-pr13928-take-2.

The new code seems to work with the following make versions:

  - GNU
  - NetBSD 5.1
  - FreeBSD 8.0
  - Solaris 10
  - AIX 7.1


Notice that the new code will not land in Automake 1.15 (that I
hope to be able to release in less than a week, as soon as my
new GPG key is accepted by ftp-upload <at> gnu.org).  But unless any
unanticipated issue arises, I definitely want the fix to land
in Automake 1.16 (and the fix for this bug alone would IMHO be
enough to justify a new minor release).

Thanks,
  Stefano





Changed bug title to 'foo_SOURCES containing unexpanded $(var) breaks with 'subdir-object' option active' from 'VPATH issues with subdir-objects' Request was from Stefano Lattarini <stefano.lattarini <at> gmail.com> to control <at> debbugs.gnu.org. (Thu, 01 Jan 2015 16:29:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-automake <at> gnu.org:
bug#13928; Package automake. (Thu, 01 Jan 2015 20:58:01 GMT) Full text and rfc822 format available.

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

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: automake-patches <at> gnu.org
Cc: nbowler <at> elliptictech.com, 13928 <at> debbugs.gnu.org, peda <at> lysator.liu.se,
 jujulicca <at> gmail.com, johankristensen <at> gmail.com, bfriesen <at> simple.dallas.tx.us,
 bert.wesarg <at> googlemail.com, eblake <at> redhat.com, miles <at> gnu.org
Subject: [PATCH] deps: 'subdir-object' option now works when foo_SOURCES
 contains $(var)
Date: Thu,  1 Jan 2015 21:57:38 +0100
Following a suggestions of Johan Kristensen, we have config.status use
'make' invocations rather than Makefile-parsing 'sed' hacks to bootstrap
the dependency-tracking '.Po' and '.Plo' makefile fragments. To handle
the inclusion of such files that are still missing when make is first
we basically generate a temporary Makefile without these includes, and
call 'make' on that Makefile.

This fixes the serious bug bug#13928, which was an hard blocker to make the
behavior mandated by the 'subdir-object' active by default (which we want
to do in Automake 2.0).

The issue has also been reported in bug#15919.

* NEWS, THANKS, PLANS/subdir-objects.txt: Update
* bin/automake.in (handle_languages): Add a trailing "marking" comment
("# am--include-marker") to the generated Makefile lines issuing 'include'
directives for the dependency-tracking '.Po' and '.Plo' makefile fragments.
Also rename the generated Makefile variable 'am__depfiles_maybe' to the
clearer 'am__maybe_remake_depfiles'.
Minor unrelated refactoring.
* lib/am/configure.am: Adjust to account for the 'am__depfiles_maybe' ->
'am__maybe_remake_depfiles' renaming.
* lib/am/depend.am: Add rules to generate a dummy version of all the
dependency-tracking '.Po' and '.Plo' makefile fragments.
* m4/depout.m4: Use make invocations rather than Makefile-parsing sed hacks
to bootstrap the dependency-tracking '.Po' and '.Plo' makefile fragments.
We still use some sed trickery in order to remove the inclusion of the
still non existing .Po and .Plo files from the Makefile we invoke make
upon; this is done stripping lines that contain the magic string
"# am--include-marker".
* m4/make.m4 (AM_MAKE_INCLUDE): Given that now automake generates Makefiles
containing include statements with trailing comment, adjust the checks done
here to make sure $MAKE support that; e.g., "include foo.mk # comment"
rather than just "include foo.mk".
Also refactor and adjust to leave better debugging info in config.log.
* t/postproc.sh: Rename ...
* t/depend-postproc.sh: ... to this, and adjust and enhance.
* t/list-of-tests.mk (handwritten_TESTS): Adjust.
(XFAIL_TESTS): Remove 't/subobj-indir-pr13928.sh', which is now succeeding.
* t/subobj-indir-pr13928.sh: Simplify slightly, now that we expect it to
pass.
* t/depcomp8a.sh: Adjust grepping check to account for the changes in
the generated Makefile, and tp be somewhat more robust in light of possible
future modifications.
* t/depcomp8b.sh: Likewise.
* t/subobj11b.sh: Likewise.
* t/subobj11c.sh: Likewise.
* t/extra-sources.sh: Likewise.
* t/lex-depend-grep.sh: Likewise.
* t/lex-depend-cxx.sh: Add a command to help debugging in case of test
failure.

Helped-by: Johan Kristensen <johankristensen <at> gmail.com>
Signed-off-by: Stefano Lattarini <stefano.lattarini <at> gmail.com>
---
 NEWS                                  | 28 ++++++++++++
 PLANS/subdir-objects.txt              | 10 ++---
 THANKS                                |  1 +
 bin/automake.in                       | 84 ++++++++++++++++++-----------------
 lib/am/configure.am                   |  6 +--
 lib/am/depend.am                      |  7 +++
 m4/depout.m4                          | 78 ++++++++++++++------------------
 m4/make.m4                            | 59 +++++++++++-------------
 t/depcomp8a.sh                        | 16 +++----
 t/depcomp8b.sh                        | 16 +++----
 t/{postproc.sh => depend-postproc.sh} | 29 ++++++++++--
 t/extra-sources.sh                    |  5 ++-
 t/lex-depend-cxx.sh                   |  5 +++
 t/lex-depend-grep.sh                  |  2 +-
 t/list-of-tests.mk                    |  3 +-
 t/subobj-indir-pr13928.sh             |  4 +-
 t/subobj11b.sh                        | 10 ++---
 t/subobj11c.sh                        |  2 +-
 18 files changed, 206 insertions(+), 159 deletions(-)
 rename t/{postproc.sh => depend-postproc.sh} (68%)

diff --git a/NEWS b/NEWS
index 84a5e0a..a930049 100644
--- a/NEWS
+++ b/NEWS
@@ -62,6 +62,34 @@
 
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+New in 1.16:
+
+* Bugs fixed:
+
+  - Automatic dependency tracking has been fixed to work also when the
+    subdir-object option is used and some 'foo_SOURCES' definition contains
+    unexpanded references to make variables, as in, e.g.:
+
+        a_src = sources/libs/aaa
+        b_src = sources/bbb
+        foo_SOURCES = $(a_src)/bar.c $(b_src)/baz.c
+
+    With such a setup, the created makefile fragment containing dependency
+    tracking information will be correctly placed under the directories
+    named 'sources/libs/aaa/.deps' and 'sources/bbb/.deps', rather than
+    mistakenly under directories named (literally!) '$(src_a)/.deps' and
+    '$(src_b)/.deps' (this was automake bug#13928).
+
+    Notice that in order to fix this bug we had to slightly change the
+    semantics of how config.status bootstraps the makefile fragments
+    required for the dependency tracking to work: rather than attempting
+    to parse the Makefiles via grep and sed trickeries only, we actually
+    invoke 'make' on a slightly preprocessed version of those Makefiles,
+    using a private target that is only meant to bootstrap the required
+    makefile fragments.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
 New in 1.15:
 
 * Improvements and refactorings in the install-sh script:
diff --git a/PLANS/subdir-objects.txt b/PLANS/subdir-objects.txt
index 3cf6101..39b42da 100644
--- a/PLANS/subdir-objects.txt
+++ b/PLANS/subdir-objects.txt
@@ -5,9 +5,6 @@ We want to make the behaviour currently enabled by the 'subdir-objects'
 the default one, and in fact the *only* one, in Automake 2.0.
 See automake bug#13378: <http://debbugs.gnu.org/13378>.
 
-Sadly, **THIS IS IMPOSSIBLE** until automake bug#13928 is resolved:
-http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13928
-
 Details
 -------
 
@@ -53,11 +50,10 @@ We also make sure to avoid the warning when it would be irrelevant, i.e.,
 if all source files sit in "current" directory (thanks to Peter Johansson
 for suggesting this).
 
-For some automake 1.x (*before* 2.0 can be released)
-----------------------------------------------------
+For automake 1.16 (*before* 2.0 can be released)
+------------------------------------------------
 
-Find a proper way to fix the blocking automake bug#13928:
-http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13928
+Submit the patch fixing http://debbugs.gnu.org/13928
 
 For automake 2.0
 ----------------
diff --git a/THANKS b/THANKS
index b66f744..8b87d58 100644
--- a/THANKS
+++ b/THANKS
@@ -192,6 +192,7 @@ Joel N. Weber II                nemo <at> koa.iolani.honolulu.hi.us
 Joerg-Martin Schwarz            jms <at> jms.prima.ruhr.de
 Johan Dahlin                    jdahlin <at> async.com.br
 Johan Danielsson                joda <at> pdc.kth.se
+Johan Kristensen                johankristensen <at> gmail.com
 Johannes Nicolai                johannes.nicolai <at> student.hpi.uni-potsdam.de
 John Calcote                    john.calcote <at> gmail.com
 John F Trudeau                  JohnTrudeau <at> firsthealth.com
diff --git a/bin/automake.in b/bin/automake.in
index eedc8bc..f19be92 100644
--- a/bin/automake.in
+++ b/bin/automake.in
@@ -1230,48 +1230,50 @@ sub check_user_variables
 sub handle_languages ()
 {
     if (! option 'no-dependencies')
-    {
-	# Include auto-dep code.  Don't include it if DEP_FILES would
-	# be empty.
-	if (keys %extension_seen && keys %dep_files)
-	{
-	    # Set location of depcomp.
-	    define_variable ('depcomp',
-			     "\$(SHELL) $am_config_aux_dir/depcomp",
-			     INTERNAL);
-	    define_variable ('am__depfiles_maybe', 'depfiles', INTERNAL);
-
-	    require_conf_file ("$am_file.am", FOREIGN, 'depcomp');
-
-	    my @deplist = sort keys %dep_files;
-	    # Generate each 'include' individually.  Irix 6 make will
-	    # not properly include several files resulting from a
-	    # variable expansion; generating many separate includes
-	    # seems safest.
-	    $output_rules .= "\n";
-	    foreach my $iter (@deplist)
-	    {
-		$output_rules .= (subst ('AMDEP_TRUE')
-				  . subst ('am__include')
-				  . ' '
-				  . subst ('am__quote')
-				  . $iter
-				  . subst ('am__quote')
-				  . "\n");
-	    }
-
-	    # Compute the set of directories to remove in distclean-depend.
-	    my @depdirs = uniq (map { dirname ($_) } @deplist);
-	    $output_rules .= file_contents ('depend',
-					    new Automake::Location,
-					    DEPDIRS => "@depdirs");
-	}
-    }
+      {
+        # Include auto-dep code.  Don't include it if DEP_FILES would
+        # be empty.
+        if (keys %extension_seen && keys %dep_files)
+          {
+            my @dep_files = sort keys %dep_files;
+            # Set location of depcomp.
+            define_variable ('depcomp',
+                             "\$(SHELL) $am_config_aux_dir/depcomp",
+                             INTERNAL);
+            define_variable ('am__maybe_remake_depfiles', 'depfiles', INTERNAL);
+            define_variable ('am__depfiles_remade', "@dep_files", INTERNAL);
+            # Generate each 'include' directive individually.  Several make
+            # implementations (IRIX 6, Solaris 10, FreeBSD 8) will fail to
+            # properly include several files resulting from a variable
+            # expansion. Just Generating many separate includes seems thus
+            # safest.
+            $output_rules .= "\n";
+            foreach my $depfile (@dep_files)
+              {
+                $output_rules .= subst ('AMDEP_TRUE') .
+                                 subst ('am__include') .
+                                 " " .
+                                 subst('am__quote') .
+                                 $depfile .
+                                 subst('am__quote') .
+                                 " " .
+                                 "# am--include-marker\n";
+              }
+
+            require_conf_file ("$am_file.am", FOREIGN, 'depcomp');
+
+            # Compute the set of directories to remove in distclean-depend.
+            my @dep_dirs = uniq (map { dirname ($_) } @dep_files);
+            $output_rules .= file_contents ('depend',
+                                            new Automake::Location,
+                                            DEPDIRS => "@dep_dirs");
+          }
+      }
     else
-    {
-	define_variable ('depcomp', '', INTERNAL);
-	define_variable ('am__depfiles_maybe', '', INTERNAL);
-    }
+      {
+        define_variable ('depcomp', '', INTERNAL);
+        define_variable ('am__maybe_remake_depfiles', '', INTERNAL);
+      }
 
     my %done;
 
diff --git a/lib/am/configure.am b/lib/am/configure.am
index 34ebd17..a6086dd 100644
--- a/lib/am/configure.am
+++ b/lib/am/configure.am
@@ -76,10 +76,10 @@ endif %?TOPDIR_P%
 ?TOPDIR_P?	    $(SHELL) ./config.status;; \
 ?!TOPDIR_P?	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
 	  *) \
-## FIXME: $(am__depfiles_maybe) lets us re-run the rule to create the
+## FIXME: $(am__maybe_remake_depfiles) lets us re-run the rule to create the
 ## .P files.  Ideally we wouldn't have to do this by hand.
-	    echo ' cd $(top_builddir) && $(SHELL) ./config.status %CONFIG-MAKEFILE% $(am__depfiles_maybe)'; \
-	    cd $(top_builddir) && $(SHELL) ./config.status %CONFIG-MAKEFILE% $(am__depfiles_maybe);; \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status %CONFIG-MAKEFILE% $(am__maybe_remake_depfiles)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status %CONFIG-MAKEFILE% $(am__maybe_remake_depfiles);; \
 	esac;
 
 ## Avoid the "deleted header file" problem for the dependencies.
diff --git a/lib/am/depend.am b/lib/am/depend.am
index 00ba5b3..0b226b6 100644
--- a/lib/am/depend.am
+++ b/lib/am/depend.am
@@ -16,6 +16,13 @@
 
 am__mv = mv -f
 
+$(am__depfiles_remade):
+	@$(MKDIR_P) $(@D)
+	@echo '# dummy' >$@-t && $(am__mv) $@-t $@
+
+am--depfiles: $(am__depfiles_remade)
+.PHONY: am--depfiles
+
 ## This Makefile depends on Depdirs' files, so we should never
 ## erase them in -am or -recursive rules; that would prevent any other
 ## rules from being recursive (for instance multilib clean rules are
diff --git a/m4/depout.m4 b/m4/depout.m4
index a59dcf5..2109bb3 100644
--- a/m4/depout.m4
+++ b/m4/depout.m4
@@ -6,7 +6,6 @@
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-
 # _AM_OUTPUT_DEPENDENCY_COMMANDS
 # ------------------------------
 AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
@@ -14,49 +13,41 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
   # Older Autoconf quotes --file arguments for eval, but not when files
   # are listed without --file.  Let's play safe and only enable the eval
   # if we detect the quoting.
-  case $CONFIG_FILES in
-  *\'*) eval set x "$CONFIG_FILES" ;;
-  *)   set x $CONFIG_FILES ;;
-  esac
+  # TODO: see whether this extra hack can be removed once we start
+  # requiring Autoconf 2.70 or later.
+  AS_CASE([$CONFIG_FILES],
+          [*\'*], [eval set x "$CONFIG_FILES"],
+          [*], [set x $CONFIG_FILES])
   shift
-  for mf
+  # Used to flag and report bootstrapping failures.
+  am_rc=0
+  for am_mf
   do
     # Strip MF so we end up with the name of the file.
-    mf=`echo "$mf" | sed -e 's/:.*$//'`
-    # Check whether this is an Automake generated Makefile or not.
-    # We used to match only the files named 'Makefile.in', but
-    # some people rename them; so instead we look at the file content.
-    # Grep'ing the first line is not enough: some people post-process
-    # each Makefile.in and add a new line on top of each file to say so.
-    # Grep'ing the whole file is not good either: AIX grep has a line
+    am_mf=`AS_ECHO(["$am_mf"]) | sed -e 's/:.*$//'`
+    # Check whether this is an Automake generated Makefile which includes
+    # dependency-tracking related rules and includes.
+    # Grep'ing the whole file directly is not great: AIX grep has a line
     # limit of 2048, but all sed's we know have understand at least 4000.
-    if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
-      dirpart=`AS_DIRNAME("$mf")`
-    else
-      continue
-    fi
-    # Extract the definition of DEPDIR, am__include, and am__quote
-    # from the Makefile without running 'make'.
-    DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
-    test -z "$DEPDIR" && continue
-    am__include=`sed -n 's/^am__include = //p' < "$mf"`
-    test -z "$am__include" && continue
-    am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
-    # Find all dependency output files, they are included files with
-    # $(DEPDIR) in their names.  We invoke sed twice because it is the
-    # simplest approach to changing $(DEPDIR) to its actual value in the
-    # expansion.
-    for file in `sed -n "
-      s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
-	 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do
-      # Make sure the directory exists.
-      test -f "$dirpart/$file" && continue
-      fdir=`AS_DIRNAME(["$file"])`
-      AS_MKDIR_P([$dirpart/$fdir])
-      # echo "creating $dirpart/$file"
-      echo '# dummy' > "$dirpart/$file"
-    done
+    sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \
+      || continue
+    am_dirpart=`AS_DIRNAME(["$am_mf"])`
+    am_filepart=`AS_BASENAME(["$am_mf"])`
+    AM_RUN_LOG([cd "$am_dirpart" \
+      && sed -e '/# am--include-marker/d' "$am_filepart" \
+        | $MAKE -f - am--depfiles]) || am_rc=$?
   done
+  if test $am_rc -ne 0; then
+    AC_MSG_FAILURE([Something went wrong bootstrapping makefile fragments
+    for automatic dependency tracking.  Try re-running configure with the
+    '--disable-dependency-tracking' option to at least be able to build
+    the package (albeit without support for automatic dependency tracking).])
+  fi
+  AS_UNSET([am_dirpart])
+  AS_UNSET([am_filepart])
+  AS_UNSET([am_mf])
+  AS_UNSET([am_rc])
+  rm -f conftest-deps.mk
 }
 ])# _AM_OUTPUT_DEPENDENCY_COMMANDS
 
@@ -65,11 +56,10 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
 # -----------------------------
 # This macro should only be invoked once -- use via AC_REQUIRE.
 #
-# This code is only required when automatic dependency tracking
-# is enabled.  FIXME.  This creates each '.P' file that we will
-# need in order to bootstrap the dependency handling code.
+# This code is only required when automatic dependency tracking is enabled.
+# This creates each '.Po' and '.Plo' makefile fragment that we'll need in
+# order to bootstrap the dependency handling code.
 AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
 [AC_CONFIG_COMMANDS([depfiles],
      [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
-     [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
-])
+     [AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}"])])
diff --git a/m4/make.m4 b/m4/make.m4
index a82d2d2..f5520b1 100644
--- a/m4/make.m4
+++ b/m4/make.m4
@@ -8,42 +8,35 @@
 
 # AM_MAKE_INCLUDE()
 # -----------------
-# Check to see how make treats includes.
+# Check whether make has an 'include' directive that can support all
+# the idioms we need for our automatic dependency tracking code.
 AC_DEFUN([AM_MAKE_INCLUDE],
-[am_make=${MAKE-make}
-cat > confinc << 'END'
+[AC_MSG_CHECKING([whether ${MAKE-make} supports the include directive])
+cat > confinc.mk << 'END'
 am__doit:
-	@echo this is the am__doit target
+	@echo this is the am__doit target >confinc.out
 .PHONY: am__doit
 END
-# If we don't find an include directive, just comment out the code.
-AC_MSG_CHECKING([for style of include used by $am_make])
 am__include="#"
 am__quote=
-_am_result=none
-# First try GNU make style include.
-echo "include confinc" > confmf
-# Ignore all kinds of additional output from 'make'.
-case `$am_make -s -f confmf 2> /dev/null` in #(
-*the\ am__doit\ target*)
-  am__include=include
-  am__quote=
-  _am_result=GNU
-  ;;
-esac
-# Now try BSD make style include.
-if test "$am__include" = "#"; then
-   echo '.include "confinc"' > confmf
-   case `$am_make -s -f confmf 2> /dev/null` in #(
-   *the\ am__doit\ target*)
-     am__include=.include
-     am__quote="\""
-     _am_result=BSD
-     ;;
-   esac
-fi
-AC_SUBST([am__include])
-AC_SUBST([am__quote])
-AC_MSG_RESULT([$_am_result])
-rm -f confinc confmf
-])
+# BSD make does it like this.
+echo '.include "confinc.mk" # ignored' > confmf.BSD
+# Other make implementations (GNU, Solaris 10, AIX) do it like this.
+echo 'include confinc.mk # ignored' > confmf.GNU
+_am_result=no
+for s in GNU BSD; do
+  AM_RUN_LOG([${MAKE-make} -f confmf.$s && cat confinc.out])
+  AS_CASE([$?:`cat confinc.out 2>/dev/null`],
+      ['0:this is the am__doit target'],
+      [AS_CASE([$s],
+          [BSD], [am__include='.include' am__quote='"'],
+          [am__include='include' am__quote=''])])
+  if test "$am__include" != "#"; then
+    _am_result="yes ($s style)"
+    break
+  fi
+done
+rm -f confinc.* confmf.*
+AC_MSG_RESULT([${_am_result}])
+AC_SUBST([am__include])])
+AC_SUBST([am__quote])])
diff --git a/t/depcomp8a.sh b/t/depcomp8a.sh
index 94b7afa..ee440ed 100644
--- a/t/depcomp8a.sh
+++ b/t/depcomp8a.sh
@@ -51,10 +51,10 @@ $ACLOCAL
 # FIXME: stop disabling the warnings in the 'unsupported' category
 # FIXME: once the 'subdir-objects' option has been mandatory.
 $AUTOMAKE -a -Wno-unsupported
-grep include Makefile.in # For debugging.
-grep 'include.*\./\$(DEPDIR)/foo\.P' Makefile.in
-grep 'include.*\./\$(DEPDIR)/bar\.P' Makefile.in
-grep 'include.*/\./\$(DEPDIR)' Makefile.in && exit 1
+grep '\.P' Makefile.in # For debugging.
+grep '\./\$(DEPDIR)/foo\.Po' Makefile.in
+grep '\./\$(DEPDIR)/bar\.Po' Makefile.in
+grep '/\./\$(DEPDIR)' Makefile.in && exit 1
 
 $AUTOCONF
 # Don't reject slower dependency extractors, for better coverage.
@@ -68,10 +68,10 @@ DISTCHECK_CONFIGURE_FLAGS='--enable-dependency-tracking' $MAKE distcheck
 echo AUTOMAKE_OPTIONS = subdir-objects >> Makefile.am
 
 $AUTOMAKE
-grep include Makefile.in # For debugging.
-grep 'include.*\./\$(DEPDIR)/foo\.P' Makefile.in
-grep 'include.*[^a-zA-Z0-9_/]sub/\$(DEPDIR)/bar\.P' Makefile.in
-$EGREP 'include.*/(\.|sub)/\$\(DEPDIR\)' Makefile.in && exit 1
+grep '\.P' Makefile.in # For debugging.
+grep '\./\$(DEPDIR)/foo\.Po' Makefile.in
+grep '[^a-zA-Z0-9_/]sub/\$(DEPDIR)/bar\.Po' Makefile.in
+$EGREP '/(\.|sub)/\$\(DEPDIR\)' Makefile.in && exit 1
 
 $AUTOCONF
 # Don't reject slower dependency extractors, for better coverage.
diff --git a/t/depcomp8b.sh b/t/depcomp8b.sh
index 47bf5c5..f1f65f3 100644
--- a/t/depcomp8b.sh
+++ b/t/depcomp8b.sh
@@ -48,10 +48,10 @@ $ACLOCAL
 # FIXME: stop disabling the warnings in the 'unsupported' category
 # FIXME: once the 'subdir-objects' option has been mandatory.
 $AUTOMAKE -a -Wno-unsupported
-grep include Makefile.in # For debugging.
-grep 'include.*\./\$(DEPDIR)/foo\.P' Makefile.in
-grep 'include.*\./\$(DEPDIR)/bar\.P' Makefile.in
-grep 'include.*/\./\$(DEPDIR)' Makefile.in && exit 1
+grep '\.P' Makefile.in # For debugging.
+grep '\./\$(DEPDIR)/foo\.Plo' Makefile.in
+grep '\./\$(DEPDIR)/bar\.Plo' Makefile.in
+grep '/\./\$(DEPDIR)' Makefile.in && exit 1
 
 $AUTOCONF
 # Don't reject slower dependency extractors, for better coverage.
@@ -64,10 +64,10 @@ DISTCHECK_CONFIGURE_FLAGS='--enable-dependency-tracking' $MAKE distcheck
 echo AUTOMAKE_OPTIONS += subdir-objects >> Makefile.am
 
 $AUTOMAKE
-grep include Makefile.in # For debugging.
-grep 'include.*\./\$(DEPDIR)/foo\.P' Makefile.in
-grep 'include.*[^a-zA-Z0-9_/]sub/\$(DEPDIR)/bar\.P' Makefile.in
-$EGREP 'include.*/(\.|sub)/\$\(DEPDIR\)' Makefile.in && exit 1
+grep '\.P' Makefile.in # For debugging.
+grep '\./\$(DEPDIR)/foo\.Plo' Makefile.in
+grep '[^a-zA-Z0-9_/]sub/\$(DEPDIR)/bar\.Plo' Makefile.in
+$EGREP '/(\.|sub)/\$\(DEPDIR\)' Makefile.in && exit 1
 
 $AUTOCONF
 # Don't reject slower dependency extractors, for better coverage.
diff --git a/t/postproc.sh b/t/depend-postproc.sh
similarity index 68%
rename from t/postproc.sh
rename to t/depend-postproc.sh
index 3ac64a4..74088db0 100644
--- a/t/postproc.sh
+++ b/t/depend-postproc.sh
@@ -15,20 +15,22 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Check to make sure we recognize a Makefile.in, even if post-processed
-# and renamed.
+# and renamed.  The particularly tricky code for automatic dependency
+# tracking support used to have issues with that.
 
 required=cc
 . test-init.sh
 
-cat >configure.ac <<END
+cat > configure.ac <<END
 AC_INIT([$me], [1.0])
 AM_INIT_AUTOMAKE
 AC_PROG_CC
 AC_CONFIG_FILES([myMakefile])
+dnl: AC_CONFIG_LINKS([Makefile:Makefile])
 AC_OUTPUT
 END
 
-cat > myMakefile.am << 'END'
+cat > myMakefile.am <<'END'
 bin_PROGRAMS = fred
 fred_SOURCES = fred.c
 END
@@ -45,4 +47,25 @@ cat myMakefile.old >> myMakefile.in
 
 test -f .deps/fred.Po || test -f _deps/fred.Po || exit 1
 
+$sleep
+
+cat > Makefile <<'END'
+include myMakefile
+END
+
+sed 's/^dnl: *//' configure.ac >t
+mv -f t configure.ac
+
+$MAKE myMakefile Makefile
+
+rm -rf .deps _deps
+./config.status
+
+test ! -e fred.c
+echo 'int main (void) { return 0; }' > fred.c
+
+$MAKE
+test -f .deps/fred.Po || test -f _deps/fred.Po || exit 1
+$MAKE distcheck
+
 :
diff --git a/t/extra-sources.sh b/t/extra-sources.sh
index e3f15c8..8e204a5 100644
--- a/t/extra-sources.sh
+++ b/t/extra-sources.sh
@@ -21,7 +21,7 @@
 
 echo AC_PROG_CC >> configure.ac
 
-cat > Makefile.am << 'END'
+cat > Makefile.am <<'END'
 bin_PROGRAMS = www
 www_SOURCES = www.c
 EXTRA_www_SOURCES = xtra.c
@@ -31,6 +31,7 @@ END
 $ACLOCAL
 $AUTOMAKE
 
-grep '@am__include@ .*/xtra\.P' Makefile.in
+grep '@am__include@ .*/xtra\.Po' Makefile.in
+grep '^am__depfiles_remade =.*/xtra.Po' Makefile.in
 
 :
diff --git a/t/lex-depend-cxx.sh b/t/lex-depend-cxx.sh
index 2abb101..eee2f5c 100644
--- a/t/lex-depend-cxx.sh
+++ b/t/lex-depend-cxx.sh
@@ -82,6 +82,11 @@ $AUTOCONF
 # using slow dependency extractors.
 ./configure --enable-dependency-tracking
 
+# For debugging.
+for f in $(find . -name '*.Po'); do
+  cat $f
+done
+
 $MAKE test-deps-exist
 $MAKE
 
diff --git a/t/lex-depend-grep.sh b/t/lex-depend-grep.sh
index 4a6473b..be9be29 100644
--- a/t/lex-depend-grep.sh
+++ b/t/lex-depend-grep.sh
@@ -40,7 +40,7 @@ $AUTOMAKE -a
 $EGREP '([mj]oe|_[01234]|include|\.P)' Makefile.in # For debugging.
 
 for x in joe moe _0 _1 _2 _3 _4; do
-  grep "include.*$x\.Po" Makefile.in
+  $EGREP '\$\(DEPDIR\)/'"$x"'\.Po( |$)' Makefile.in
 done
 
 :
diff --git a/t/list-of-tests.mk b/t/list-of-tests.mk
index 9363ee3..5085780 100644
--- a/t/list-of-tests.mk
+++ b/t/list-of-tests.mk
@@ -41,7 +41,6 @@ t/java-nobase.sh \
 t/objext-pr10128.sh \
 t/remake-timing-bug-pr8365.sh \
 t/lex-subobj-nodep.sh \
-t/subobj-indir-pr13928.sh \
 t/subobj-vpath-pr13928.sh \
 t/remake-am-pr10111.sh \
 t/remake-m4-pr10111.sh \
@@ -391,6 +390,7 @@ t/depend3.sh \
 t/depend4.sh \
 t/depend5.sh \
 t/depend6.sh \
+t/depend-postproc.sh \
 t/deprecated-acinit.sh \
 t/destdir.sh \
 t/dir-named-obj-is-bad.sh \
@@ -866,7 +866,6 @@ t/posixsubst-programs.sh \
 t/posixsubst-scripts.sh \
 t/posixsubst-sources.sh \
 t/posixsubst-tests.sh \
-t/postproc.sh \
 t/ppf77.sh \
 t/pr2.sh \
 t/pr9.sh \
diff --git a/t/subobj-indir-pr13928.sh b/t/subobj-indir-pr13928.sh
index 22cb7f5..3ccd037 100644
--- a/t/subobj-indir-pr13928.sh
+++ b/t/subobj-indir-pr13928.sh
@@ -38,7 +38,9 @@ END
 mkdir s
 echo 'int main(void) { return 0; }' > s/foo.c
 
-$ACLOCAL && $AUTOCONF && $AUTOMAKE -a || fatal_ "autotools failed"
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
 
 ./configure
 $MAKE
diff --git a/t/subobj11b.sh b/t/subobj11b.sh
index 5ebb42a..613fa26 100644
--- a/t/subobj11b.sh
+++ b/t/subobj11b.sh
@@ -56,9 +56,9 @@ END
 $ACLOCAL
 $AUTOMAKE -a
 
-# Be lax in the regexp, to account for automake conditionals, the
-# use of @am__include@, and similar stuff.
-grep 'include.*//.*foobar' Makefile.in && exit 1
+grep '\.P' Makefile.in # For debugging.
+
+grep '//.*foobar\.P' Makefile.in && exit 1
 
 # These checks depend on automake internals, but presently this is
 # the only way to test the code path we are interested in.
@@ -71,12 +71,12 @@ for x in zardoz0 zardoz1 path/to/zardoz2 another/path/to/zardoz3; do
   esac
   # Be a little lax in the regexp, to account for automake conditionals,
   # quoting, and similar stuff.
-  grep "^[^/]*am__include[^/]*//server/$d\\\$(DEPDIR)/$b\\.[^/]*$" Makefile.in
+  grep "[ 	]//server/$d\\\$(DEPDIR)/$b\\.Po" Makefile.in
 done
 
 # Sanity checks.
 for i in 0 1 2 3 4 5 6 7 8 9; do
-  grep "am__include.*/foobar$i\\." Makefile.in
+  grep "\$(DEPDIR)/foobar$i\\.Po" Makefile.in
 done
 
 :
diff --git a/t/subobj11c.sh b/t/subobj11c.sh
index a80d760..f5e8340 100644
--- a/t/subobj11c.sh
+++ b/t/subobj11c.sh
@@ -43,6 +43,6 @@ $AUTOMAKE -a
 #
 # FIXME: Are we sure this is the most sensible output in our situation?
 #
-grep '^[^/]*am__include[^/]*//\$(DEPDIR)/zardoz\.[^/]*$' Makefile.in
+grep 'am__depfiles_remade =.* //\$(DEPDIR)/zardoz\.Po' Makefile.in
 
 :
-- 
2.1.3





Information forwarded to bug-automake <at> gnu.org:
bug#13928; Package automake. (Fri, 02 Jan 2015 02:03:02 GMT) Full text and rfc822 format available.

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

From: Harlan Stenn <stenn <at> ntp.org>
To: Stefano Lattarini <stefano.lattarini <at> gmail.com>
Cc: Nick Bowler <nbowler <at> elliptictech.com>, 13928 <at> debbugs.gnu.org,
 Johan Kristensen <johankristensen <at> gmail.com>, automake <at> gnu.org
Subject: Re: The 'subdir-object' option breaks makefiles where foo_SOURCES
 contains $(var)
Date: Fri, 02 Jan 2015 01:16:03 +0000
Excellent timing, thanks!

Now that ntp-4.2.8 is settling down, I'm looking to update our
Makefile.am's to use subdir-objects, and it's not being fun.

I may wait until 1.15 is released to continue this effort.

H




Information forwarded to bug-automake <at> gnu.org:
bug#13928; Package automake. (Fri, 02 Jan 2015 10:53:01 GMT) Full text and rfc822 format available.

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

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: Harlan Stenn <stenn <at> ntp.org>
Cc: Nick Bowler <nbowler <at> elliptictech.com>, 13928 <at> debbugs.gnu.org,
 Johan Kristensen <johankristensen <at> gmail.com>, automake <at> gnu.org
Subject: Re: The 'subdir-object' option breaks makefiles where foo_SOURCES
 contains $(var)
Date: Fri, 02 Jan 2015 11:52:33 +0100
On 01/02/2015 02:16 AM, Harlan Stenn wrote:
> Excellent timing, thanks!
>
> Now that ntp-4.2.8 is settling down, I'm looking to update our
> Makefile.am's to use subdir-objects, and it's not being fun.
>
(An aside: I see that ntp still uses a recursive Makefile setup.
Given that you are about to mess with the ntp build system anyway,
have you thought about trying to convert it to a non-recursive
make setup?  That is the suggested way to go nowadays...)

> I may wait until 1.15 is released to continue this effort.
>
Well, actually, Automake 1.15 is already tagged in the Git repository
and ready to be released (as soon as my new GPG key, replacing the one
that expired 2 months ago, will be accepted by fpt-upload <at> gnu.org).
So this patch will not be available before Automake 1.16.  But then
again, I believe the fix for this bug alone would be enough to
justify a new minor Automake release, so don't worry, this fix will
go in some release soon enough :-)

Also, more importantly, notice that this patch do not yet solve the
issue of '.deps' directories and object files being created in the
source directory (rather than in the build directory) for source
files that contains an explicit reference to $(srcdir), when the
'subdir-object' option is enabled; see the still XFAIL'ing test
't/subobj-vpath-pr13928.sh'.

This issue should *hopefully* be easy to fix, especially with the
new dependency-bootstrapping logic; and I will try hard to make
that happen before the 1.16 release.

Thanks,
  Stefano




Information forwarded to bug-automake <at> gnu.org:
bug#13928; Package automake. (Fri, 02 Jan 2015 12:06:02 GMT) Full text and rfc822 format available.

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

From: Harlan Stenn <stenn <at> ntp.org>
To: Stefano Lattarini <stefano.lattarini <at> gmail.com>
Cc: Harlan Stenn <stenn <at> ntp.org>, Nick Bowler <nbowler <at> elliptictech.com>,
 13928 <at> debbugs.gnu.org, Johan Kristensen <johankristensen <at> gmail.com>,
 automake <at> gnu.org
Subject: Re: The 'subdir-object' option breaks makefiles where foo_SOURCES
 contains $(var)
Date: Fri, 02 Jan 2015 12:04:16 +0000
Stefano Lattarini writes:
> On 01/02/2015 02:16 AM, Harlan Stenn wrote:
> > Excellent timing, thanks!
> >
> > Now that ntp-4.2.8 is settling down, I'm looking to update our
> > Makefile.am's to use subdir-objects, and it's not being fun.
>
> (An aside: I see that ntp still uses a recursive Makefile setup.
> Given that you are about to mess with the ntp build system anyway,
> have you thought about trying to convert it to a non-recursive
> make setup?  That is the suggested way to go nowadays...)

I'd *love* to go non-recursive.  I've tried before, and haven't been
able to make it work.  The documentation wasn't there before, and my
brain didn't "see" what the new paradigm was trying to do.

> > I may wait until 1.15 is released to continue this effort.
>
> Well, actually, Automake 1.15 is already tagged in the Git repository
> and ready to be released (as soon as my new GPG key, replacing the one
> that expired 2 months ago, will be accepted by fpt-upload <at> gnu.org).
> So this patch will not be available before Automake 1.16.  But then
> again, I believe the fix for this bug alone would be enough to
> justify a new minor Automake release, so don't worry, this fix will
> go in some release soon enough :-)

Fair enough, thanks!

> Also, more importantly, notice that this patch do not yet solve the
> issue of '.deps' directories and object files being created in the
> source directory (rather than in the build directory) for source
> files that contains an explicit reference to $(srcdir), when the
> 'subdir-object' option is enabled; see the still XFAIL'ing test
> 't/subobj-vpath-pr13928.sh'.

I'm likely seeing that problem too.

> This issue should *hopefully* be easy to fix, especially with the
> new dependency-bootstrapping logic; and I will try hard to make
> that happen before the 1.16 release.

Cool, thanks!

H




Information forwarded to bug-automake <at> gnu.org:
bug#13928; Package automake. (Fri, 02 Jan 2015 18:50:01 GMT) Full text and rfc822 format available.

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

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: automake-patches <at> gnu.org
Cc: Eric Blake <eblake <at> redhat.com>, Diab Jerius <djerius <at> cfa.harvard.edu>,
 13928 <at> debbugs.gnu.org, Oleg Latin <jujulicca <at> gmail.com>,
 Bert Wesarg <bert.wesarg <at> googlemail.com>
Subject: [PATCH] compile: don't place built object files in $(srcdir), ever ...
Date: Fri,  2 Jan 2015 19:49:43 +0100
... even when a source file is specified as '$(srdir)/foo.c' or
'$(top_srcdir)/bar.c'. And ditto for dependency-tracking makefile
fragments (those under '.deps' directories).

Such issues used to occur when the 'subdir-objects' option was given.

This change should fix the second and last part of automake bug#13928.
See also bug#16375 and bug#15293.

* NEWS: Update.
* bin/automake.in (handle_single_transform): Make sure object files
and dependency-tracking makefile fragments coming from source like
'$(srcdir)/foo.c' and '$(top_srcdir)/bar.c' are placed respectively
under $(builddir) and $(top_builddir).
* t/subobj-vpath-pr13928.sh: Enhance to expose even more aspects
of the bug we've just fixed.
* t/subobj-pr13928-more-langs.sh: New test, similar to the one above,
but with non-C languages as well.
* t/list-of-tests.mk (XFAIL_TESTS): Remove 'subobj-vpath-pr13928.sh',
it's now supposed to pass.
(handwritten_TESTS): Add 'subobj-pr13928-more-langs.sh'.

Signed-off-by: Stefano Lattarini <stefano.lattarini <at> gmail.com>
---
 NEWS                           |  21 ++++++-
 bin/automake.in                |  49 ++++++++++-----
 t/list-of-tests.mk             |   2 +-
 t/subobj-pr13928-more-langs.sh | 138 +++++++++++++++++++++++++++++++++++++++++
 t/subobj-vpath-pr13928.sh      |  89 ++++++++++++++++++++++----
 5 files changed, 268 insertions(+), 31 deletions(-)
 create mode 100644 t/subobj-pr13928-more-langs.sh

diff --git a/NEWS b/NEWS
index a930049..6355f74 100644
--- a/NEWS
+++ b/NEWS
@@ -67,8 +67,8 @@ New in 1.16:
 * Bugs fixed:
 
   - Automatic dependency tracking has been fixed to work also when the
-    subdir-object option is used and some 'foo_SOURCES' definition contains
-    unexpanded references to make variables, as in, e.g.:
+    'subdir-object' option is used and some 'foo_SOURCES' definition
+    contains unexpanded references to make variables, as in, e.g.:
 
         a_src = sources/libs/aaa
         b_src = sources/bbb
@@ -78,7 +78,7 @@ New in 1.16:
     tracking information will be correctly placed under the directories
     named 'sources/libs/aaa/.deps' and 'sources/bbb/.deps', rather than
     mistakenly under directories named (literally!) '$(src_a)/.deps' and
-    '$(src_b)/.deps' (this was automake bug#13928).
+    '$(src_b)/.deps' (this was the first part of automake bug#13928).
 
     Notice that in order to fix this bug we had to slightly change the
     semantics of how config.status bootstraps the makefile fragments
@@ -88,6 +88,21 @@ New in 1.16:
     using a private target that is only meant to bootstrap the required
     makefile fragments.
 
+  - The 'subdir-object' option no longer causes object files corresponding
+    to source files specified with an explicit '$(srcdir)' component to be
+    placed in the source tree rather than in the build tree.
+
+    For example, if Makefile.am contains:
+
+        AUTOMAKE_OPTIONS = subdir-objects
+        foo_SOURCES = $(srcdir)/foo.c $(srcdir)/s/bar.c $(top_srcdir)/baz.c
+
+    then "make all" will create 'foo.o' and 's/bar.o' $(builddir) rather
+    than in $(srcdir), and 'baz.o' in $(top_builddir) rather than in
+    $(top_srcdir).
+
+    This was the second part of automake bug#13928.
+
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 New in 1.15:
diff --git a/bin/automake.in b/bin/automake.in
index f19be92..f4327fc 100644
--- a/bin/automake.in
+++ b/bin/automake.in
@@ -1617,9 +1617,9 @@ sub handle_single_transform
 	my $renamed = 0;
 	my ($linker, $object);
 
-	# This records whether we've seen a derived source file (e.g.
-	# yacc output).
-	my $derived_source = 0;
+        # This records whether we've seen a derived source file (e.g., yacc
+        # or lex output).
+        my $derived_source;
 
 	# This holds the 'aggregate context' of the file we are
 	# currently examining.  If the file is compiled with
@@ -1667,17 +1667,35 @@ sub handle_single_transform
 	    # Now extract linker and other info.
 	    $linker = $lang->linker;
 
-	    my $this_obj_ext;
-	    if (defined $source_extension)
-	    {
-		$this_obj_ext = $source_extension;
-		$derived_source = 1;
-	    }
-	    else
-	    {
-		$this_obj_ext = $obj;
-	    }
-	    $object = $base . $this_obj_ext;
+            my $this_obj_ext;
+            if (defined $source_extension)
+              {
+                $this_obj_ext = $source_extension;
+                $derived_source = 1;
+              }
+            else
+              {
+                $this_obj_ext = $obj;
+                $derived_source = 0;
+                # Don't ever place built object files in $(srcdir), even when
+                # sources are specified explicitly as (say) '$(srcdir)/foo.c'
+                # or '$(top_srcdir)/foo.c'.  See automake bug#13928.
+                my @d = split '/', $directory;
+                if (@d)
+                  {
+                    my $d = $d[0];
+                    if ($d eq '$(srcdir)' or $d eq '${srcdir}')
+                      {
+                        shift @d;
+                      }
+                    elsif ($d eq '$(top_srcdir)' or $d eq '${top_srcdir}')
+                      {
+                       $d[0] = '$(top_builddir)';
+                      }
+                    $directory = join '/', @d;
+                  }
+              }
+            $object = $base . $this_obj_ext;
 
 	    if ($have_per_exec_flags)
 	    {
@@ -1710,8 +1728,7 @@ sub handle_single_transform
 		$renamed = 1;
 	    }
 
-	    # If rewrite said it was ok, put the object into a
-	    # subdir.
+	    # If rewrite said it was ok, put the object into a subdir.
 	    if ($directory ne '')
 	    {
               if ($r == LANG_SUBDIR)
diff --git a/t/list-of-tests.mk b/t/list-of-tests.mk
index 5085780..ddf5fdf 100644
--- a/t/list-of-tests.mk
+++ b/t/list-of-tests.mk
@@ -41,7 +41,6 @@ t/java-nobase.sh \
 t/objext-pr10128.sh \
 t/remake-timing-bug-pr8365.sh \
 t/lex-subobj-nodep.sh \
-t/subobj-vpath-pr13928.sh \
 t/remake-am-pr10111.sh \
 t/remake-m4-pr10111.sh \
 $(perl_fake_XFAIL_TESTS)
@@ -1063,6 +1062,7 @@ t/subobj-clean-pr10697.sh \
 t/subobj-clean-lt-pr10697.sh \
 t/subobj-indir-pr13928.sh \
 t/subobj-vpath-pr13928.sh \
+t/subobj-pr13928-more-langs.sh \
 t/subpkg.sh \
 t/subpkg2.sh \
 t/subpkg3.sh \
diff --git a/t/subobj-pr13928-more-langs.sh b/t/subobj-pr13928-more-langs.sh
new file mode 100644
index 0000000..323e248
--- /dev/null
+++ b/t/subobj-pr13928-more-langs.sh
@@ -0,0 +1,138 @@
+#! /bin/sh
+# Copyright (C) 2015 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/>.
+
+# Expose part of automake bug#13928, also for non-C languages: if the
+# subdir-objects option is in use and a source file is listed in a
+# _SOURCES variable with a leading $(srcdir) component, Automake will
+# generate a Makefile that tries to create the corresponding object
+# file in $(srcdir) as well.
+
+required='cc c++ fortran77 fortran'
+. test-init.sh
+
+cat >> configure.ac <<'END'
+AC_PROG_CC
+AC_PROG_CXX
+AC_PROG_F77
+AC_PROG_FC
+AM_CONDITIONAL([OBVIOUS], [:])
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+AUTOMAKE_OPTIONS = subdir-objects
+SUBDIRS = sub
+
+LESS = m/o/r/e
+
+noinst_PROGRAMS = test test2
+test_SOURCES = $(srcdir)/test.f90
+
+test2_SOURCES = $(indir)
+
+indir = ${indir2} $(empty)
+indir2 =
+if OBVIOUS
+indir2 += ${srcdir}/$(LESS)///test.f
+else
+endif
+
+test-objs:
+	ls -la @srcdir@ .
+        :
+	test ! -f @srcdir@/test.$(OBJEXT)
+	test -f test.$(OBJEXT)
+	test ! -f @srcdir@/m/o/r/e/test.$(OBJEXT)
+	test -f m/o/r/e/test.$(OBJEXT)
+        :
+	test ! -f @srcdir@/bar.$(OBJEXT)
+	test -f bar.$(OBJEXT)
+	test ! -f @srcdir@/baz.$(OBJEXT)
+	test -f baz.$(OBJEXT)
+        :
+	test ! -d @srcdir@/$(DEPDIR)
+	test ! -d @srcdir@/m/o/r/e/$(DEPDIR)
+	test -d $(DEPDIR)
+	test -d m/o/r/e/$(DEPDIR)
+
+check-local: test-objs
+END
+
+mkdir sub
+cat > sub/Makefile.am <<'END'
+AUTOMAKE_OPTIONS = subdir-objects
+bin_PROGRAMS = foo
+foo = baz
+foo_SOURCES = foo.h \
+	      $(top_srcdir)/bar.cc \
+              ${top_srcdir}/$(foo).c
+END
+
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+mkfiles='Makefile.in sub/Makefile.in'
+$EGREP '(test|ba[rz])\.|DEPDIR|dirstamp|srcdir' $mkfiles # For debugging.
+$EGREP '\$.(top_)?srcdir./(test|ba[rz]|\$.foo.)\.[o$]' $mkfiles && exit 1
+$FGREP '\$.(top_)?srcdir./.*$(am__dirstamp)' $mkfiles && exit 1
+$FGREP '\$.(top_)?srcdir./.*$(DEPDIR)' $mkfiles && exit 1
+
+cat > test.f90 <<'EOF'
+      program foo
+      stop
+      end
+EOF
+
+mkdir -p m/o/r/e
+cp test.f90 m/o/r/e/test.f
+
+cat > sub/foo.h <<'END'
+#ifdef __cplusplus
+extern "C"
+#endif
+int foo (void);
+END
+
+cat > bar.cc <<'END'
+#include "foo.h"
+#include <iostream>
+int main (void)
+{
+  std::cout << "OK!" << "\n";
+  return foo ();
+}
+END
+
+cat > baz.c <<'END'
+#include "foo.h"
+int foo (void)
+{
+  return 0;
+}
+END
+
+mkdir build
+cd build
+../configure
+
+$MAKE
+$MAKE test-objs
+$MAKE distcheck
+
+:
diff --git a/t/subobj-vpath-pr13928.sh b/t/subobj-vpath-pr13928.sh
index 8c3a6c5..24eff1d 100644
--- a/t/subobj-vpath-pr13928.sh
+++ b/t/subobj-vpath-pr13928.sh
@@ -22,39 +22,106 @@
 required=cc
 . test-init.sh
 
-cat >> configure.ac << 'END'
+cat >> configure.ac <<'END'
 AC_PROG_CC
 AM_PROG_CC_C_O
+AM_CONDITIONAL([OBVIOUS], [:])
+AC_CONFIG_FILES([sub/Makefile])
 AC_OUTPUT
 END
 
 cat > Makefile.am <<'END'
 AUTOMAKE_OPTIONS = subdir-objects
-noinst_PROGRAMS = test
+SUBDIRS = sub
+
+LESS = more
+
+noinst_PROGRAMS = test test2
 test_SOURCES = $(srcdir)/test.c
+
+test2_SOURCES = $(indir)
+
+indir =
+if OBVIOUS
+indir += ${srcdir}/$(LESS)/test.c
+else
+endif
+
 test-objs:
-	test ! -f '@srcdir@/test.$(OBJEXT)'
+	ls -la @srcdir@ .
+        :
+	test ! -f @srcdir@/test.$(OBJEXT)
 	test -f test.$(OBJEXT)
+	test ! -f @srcdir@/more/test.$(OBJEXT)
+	test -f more/test.$(OBJEXT)
+        :
+	test ! -f @srcdir@/bar.$(OBJEXT)
+	test -f bar.$(OBJEXT)
+	test ! -f @srcdir@/baz.$(OBJEXT)
+	test -f baz.$(OBJEXT)
+        :
+	test ! -d @srcdir@/$(DEPDIR)
+	test ! -d @srcdir@/more/$(DEPDIR)
+	test -d $(DEPDIR)
+	test -d more/$(DEPDIR)
+
+check-local: test-objs
+END
+
+mkdir sub
+cat > sub/Makefile.am <<'END'
+AUTOMAKE_OPTIONS = subdir-objects
+bin_PROGRAMS = foo
+foo_SOURCES = foo.h \
+	      $(top_srcdir)/bar.c \
+              ${top_srcdir}/baz.c
+END
+
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+mkfiles='Makefile.in sub/Makefile.in'
+$EGREP '(test|ba[rz])\.|DEPDIR|dirstamp|srcdir' $mkfiles # For debugging.
+$EGREP '\$.(top_)?srcdir./(test|ba[rz])\.[o$]' $mkfiles && exit 1
+$FGREP '\$.(top_)?srcdir./.*$(am__dirstamp)' $mkfiles && exit 1
+$FGREP '\$.(top_)?srcdir./.*$(DEPDIR)' $mkfiles && exit 1
+
+cat > test.c <<'END'
+int main (void)
+{
+  return 0;
+}
 END
 
-$ACLOCAL && $AUTOCONF && $AUTOMAKE -a || fatal_ "autotools failed"
+mkdir more
+cp test.c more/test.c
 
-$EGREP 'test\.|DEPDIR|dirstamp|srcdir' Makefile.in || : # For debugging.
-$EGREP '\$.srcdir./test\.[o$]' Makefile.in && exit 1
-$FGREP '$(srcdir)/$(am__dirstamp)' Makefile.in && exit 1
-$FGREP '$(srcdir)/$(DEPDIR)' Makefile.in && exit 1
+echo 'int foo (void);' > sub/foo.h
 
-cat > test.c << 'END'
+cat > bar.c <<'END'
+#include "foo.h"
 int main (void)
 {
+  return foo ();
+}
+END
+
+cat > baz.c <<'END'
+#include "foo.h"
+int foo (void)
+{
   return 0;
 }
 END
 
-mkdir build && cd build || fatal "preparation of build directory failed"
-../configure || fatal_ "./configure failed"
+mkdir build
+cd build
+../configure
 
 $MAKE
 $MAKE test-objs
+$MAKE distcheck
 
 :
-- 
2.1.3





Information forwarded to bug-automake <at> gnu.org:
bug#13928; Package automake. (Fri, 02 Jan 2015 23:15:02 GMT) Full text and rfc822 format available.

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

From: Eric Blake <eblake <at> redhat.com>
To: Stefano Lattarini <stefano.lattarini <at> gmail.com>, automake-patches <at> gnu.org
Cc: Oleg Latin <jujulicca <at> gmail.com>, Diab Jerius <djerius <at> cfa.harvard.edu>,
 13928 <at> debbugs.gnu.org, Bert Wesarg <bert.wesarg <at> googlemail.com>
Subject: Re: [PATCH] compile: don't place built object files in $(srcdir),
 ever ...
Date: Fri, 02 Jan 2015 16:14:44 -0700
[Message part 1 (text/plain, inline)]
On 01/02/2015 11:49 AM, Stefano Lattarini wrote:
> ... even when a source file is specified as '$(srdir)/foo.c' or
> '$(top_srcdir)/bar.c'. And ditto for dependency-tracking makefile
> fragments (those under '.deps' directories).

> +++ b/NEWS

> @@ -88,6 +88,21 @@ New in 1.16:
>      using a private target that is only meant to bootstrap the required
>      makefile fragments.
>  
> +  - The 'subdir-object' option no longer causes object files corresponding
> +    to source files specified with an explicit '$(srcdir)' component to be
> +    placed in the source tree rather than in the build tree.
> +
> +    For example, if Makefile.am contains:
> +
> +        AUTOMAKE_OPTIONS = subdir-objects
> +        foo_SOURCES = $(srcdir)/foo.c $(srcdir)/s/bar.c $(top_srcdir)/baz.c
> +
> +    then "make all" will create 'foo.o' and 's/bar.o' $(builddir) rather

s|'s/bar.o'|'s/bar.o' in|

> +    than in $(srcdir), and 'baz.o' in $(top_builddir) rather than in
> +    $(top_srcdir).
> +
> +    This was the second part of automake bug#13928.
> +
>  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

And thanks for tackling this!

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

[signature.asc (application/pgp-signature, attachment)]

Information forwarded to bug-automake <at> gnu.org:
bug#13928; Package automake. (Fri, 02 Jan 2015 23:24:01 GMT) Full text and rfc822 format available.

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

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: Eric Blake <eblake <at> redhat.com>, automake-patches <at> gnu.org
Cc: Oleg Latin <jujulicca <at> gmail.com>, Diab Jerius <djerius <at> cfa.harvard.edu>,
 13928 <at> debbugs.gnu.org, Bert Wesarg <bert.wesarg <at> googlemail.com>
Subject: Re: bug#13928: [PATCH] compile: don't place built object files in
 $(srcdir), ever ...
Date: Sat, 03 Jan 2015 00:23:30 +0100
Hi Eric.

On 01/03/2015 12:14 AM, Eric Blake wrote:
> On 01/02/2015 11:49 AM, Stefano Lattarini wrote:
>> ... even when a source file is specified as '$(srdir)/foo.c' or
>> '$(top_srcdir)/bar.c'. And ditto for dependency-tracking makefile
>> fragments (those under '.deps' directories).
>
>> +++ b/NEWS
>
>> @@ -88,6 +88,21 @@ New in 1.16:
>>       using a private target that is only meant to bootstrap the required
>>       makefile fragments.
>>
>> +  - The 'subdir-object' option no longer causes object files corresponding
>> +    to source files specified with an explicit '$(srcdir)' component to be
>> +    placed in the source tree rather than in the build tree.
>> +
>> +    For example, if Makefile.am contains:
>> +
>> +        AUTOMAKE_OPTIONS = subdir-objects
>> +        foo_SOURCES = $(srcdir)/foo.c $(srcdir)/s/bar.c $(top_srcdir)/baz.c
>> +
>> +    then "make all" will create 'foo.o' and 's/bar.o' $(builddir) rather
>
> s|'s/bar.o'|'s/bar.o' in|
>
Thanks, will fix before merging this in a non-rewindable branch (that
can't happen before Automake 1.16 is released anyway).

>> +    than in $(srcdir), and 'baz.o' in $(top_builddir) rather than in
>> +    $(top_srcdir).
>> +
>> +    This was the second part of automake bug#13928.
>> +
>>   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> And thanks for tackling this!
>
Wait to thank me, I've found another pre-existing bug in this area, affecting
non-GNU makes :-/  And by that I mean non-borked ones, like BSD make and
Solaris 10 CCS make.

On the plus side, the bug only affects "make distclean" (causing spurious
failures), and only for packages using a recursive setup and referencing
source files in a parent directory from a subdir Make; so it's a minor one.
On the negative side, I probably introduced it myself in some 1.12.x
release...

Hopefully I'll have a fix in a week or so (I'll be AFK for most time in the
coming days).




Information forwarded to bug-automake <at> gnu.org:
bug#13928; Package automake. (Sat, 03 Jan 2015 01:15:02 GMT) Full text and rfc822 format available.

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

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: Eric Blake <eblake <at> redhat.com>, automake-patches <at> gnu.org
Cc: Oleg Latin <jujulicca <at> gmail.com>, Diab Jerius <djerius <at> cfa.harvard.edu>,
 13928 <at> debbugs.gnu.org, Bert Wesarg <bert.wesarg <at> googlemail.com>
Subject: Re: bug#13928: [PATCH] compile: don't place built object files in
 $(srcdir), ever ...
Date: Sat, 03 Jan 2015 02:14:38 +0100
On 01/03/2015 12:23 AM, Stefano Lattarini wrote:
> Hi Eric.
>
> On 01/03/2015 12:14 AM, Eric Blake wrote:
>> On 01/02/2015 11:49 AM, Stefano Lattarini wrote:
>>> ... even when a source file is specified as '$(srdir)/foo.c' or
>>> '$(top_srcdir)/bar.c'. And ditto for dependency-tracking makefile
>>> fragments (those under '.deps' directories).
>>
>>> +++ b/NEWS
>>
>>> @@ -88,6 +88,21 @@ New in 1.16:
>>>       using a private target that is only meant to bootstrap the required
>>>       makefile fragments.
>>>
>>> +  - The 'subdir-object' option no longer causes object files corresponding
>>> +    to source files specified with an explicit '$(srcdir)' component to be
>>> +    placed in the source tree rather than in the build tree.
>>> +
>>> +    For example, if Makefile.am contains:
>>> +
>>> +        AUTOMAKE_OPTIONS = subdir-objects
>>> +        foo_SOURCES = $(srcdir)/foo.c $(srcdir)/s/bar.c $(top_srcdir)/baz.c
>>> +
>>> +    then "make all" will create 'foo.o' and 's/bar.o' $(builddir) rather
>>
>> s|'s/bar.o'|'s/bar.o' in|
>>
> Thanks, will fix before merging this in a non-rewindable branch (that
> can't happen before Automake 1.16 is released anyway).
>
>>> +    than in $(srcdir), and 'baz.o' in $(top_builddir) rather than in
>>> +    $(top_srcdir).
>>> +
>>> +    This was the second part of automake bug#13928.
>>> +
>>>   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>
>> And thanks for tackling this!
>>
> Wait to thank me, I've found another pre-existing bug in this area, affecting
> non-GNU makes :-/  And by that I mean non-borked ones, like BSD make and
> Solaris 10 CCS make.
>
> On the plus side, the bug only affects "make distclean" (causing spurious
> failures), and only for packages using a recursive setup and referencing
> source files in a parent directory from a subdir Make; so it's a minor one.
> On the negative side, I probably introduced it myself in some 1.12.x
> release...
>
> Hopefully I'll have a fix in a week or so (I'll be AFK for most time in the
> coming days).
>
Also, it appears this is causing another new testsuite failure with BSD make.
The following squash-in diff seems to take care of that:

-*-*-*-

diff --git a/bin/automake.in b/bin/automake.in
index f4327fc..0c44703 100644
--- a/bin/automake.in
+++ b/bin/automake.in
@@ -1677,12 +1677,15 @@ sub handle_single_transform
               {
                 $this_obj_ext = $obj;
                 $derived_source = 0;
-                # Don't ever place built object files in $(srcdir), even when
-                # sources are specified explicitly as (say) '$(srcdir)/foo.c'
-                # or '$(top_srcdir)/foo.c'.  See automake bug#13928.
-                my @d = split '/', $directory;
-                if (@d)
+                do
                   {
+                    last unless option 'subdir-objects';
+                    # Don't ever place built object files in $(srcdir),
+                    # even when sources are specified explicitly as (say)
+                    # '$(srcdir)/foo.c' or '$(top_srcdir)/foo.c'.
+                    # See automake bug#13928.
+                    my @d = split '/', $directory;
+                    last unless @d;
                     my $d = $d[0];
                     if ($d eq '$(srcdir)' or $d eq '${srcdir}')
                       {
@@ -1690,7 +1693,7 @@ sub handle_single_transform
                       }
                     elsif ($d eq '$(top_srcdir)' or $d eq '${top_srcdir}')
                       {
-                       $d[0] = '$(top_builddir)';
+                        $d[0] = '$(top_builddir)';
                       }
                     $directory = join '/', @d;
                   }

-*-*-*-

I will re-run the whole testsuite with all the affected make implementations
in the coming days, to make sure this change doesn't introduce new failures.

Sorry for the noise,
  Stefano




Information forwarded to bug-automake <at> gnu.org:
bug#13928; Package automake. (Sun, 04 Jan 2015 17:19:01 GMT) Full text and rfc822 format available.

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

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: Eric Blake <eblake <at> redhat.com>, automake-patches <at> gnu.org
Cc: Oleg Latin <jujulicca <at> gmail.com>, Diab Jerius <djerius <at> cfa.harvard.edu>,
 13928 <at> debbugs.gnu.org, Bert Wesarg <bert.wesarg <at> googlemail.com>
Subject: Re: bug#13928: [PATCH] compile: don't place built object files in
 $(srcdir), ever ...
Date: Sun, 04 Jan 2015 18:18:33 +0100
[I once again have to correct myself, sigh]

On 01/03/2015 02:14 AM, Stefano Lattarini wrote:
> On 01/03/2015 12:23 AM, Stefano Lattarini wrote:
>> Hi Eric.
>>
>> On 01/03/2015 12:14 AM, Eric Blake wrote:
>>> On 01/02/2015 11:49 AM, Stefano Lattarini wrote:
>>>> ... even when a source file is specified as '$(srdir)/foo.c' or
>>>> '$(top_srcdir)/bar.c'. And ditto for dependency-tracking makefile
>>>> fragments (those under '.deps' directories).
>>>
>>>> +++ b/NEWS
>>>
>>>> @@ -88,6 +88,21 @@ New in 1.16:
>>>>       using a private target that is only meant to bootstrap the required
>>>>       makefile fragments.
>>>>
>>>> +  - The 'subdir-object' option no longer causes object files corresponding
>>>> +    to source files specified with an explicit '$(srcdir)' component to be
>>>> +    placed in the source tree rather than in the build tree.
>>>> +
>>>> +    For example, if Makefile.am contains:
>>>> +
>>>> +        AUTOMAKE_OPTIONS = subdir-objects
>>>> +        foo_SOURCES = $(srcdir)/foo.c $(srcdir)/s/bar.c $(top_srcdir)/baz.c
>>>> +
>>>> +    then "make all" will create 'foo.o' and 's/bar.o' $(builddir) rather
>>>
>>> s|'s/bar.o'|'s/bar.o' in|
>>>
>> Thanks, will fix before merging this in a non-rewindable branch (that
>> can't happen before Automake 1.16 is released anyway).
>>
>>>> +    than in $(srcdir), and 'baz.o' in $(top_builddir) rather than in
>>>> +    $(top_srcdir).
>>>> +
>>>> +    This was the second part of automake bug#13928.
>>>> +
>>>>   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>>>
>>> And thanks for tackling this!
>>>
>> Wait to thank me, I've found another pre-existing bug in this area, affecting
>> non-GNU makes :-/  And by that I mean non-borked ones, like BSD make and
>> Solaris 10 CCS make.
>>
>> On the plus side, the bug only affects "make distclean" (causing spurious
>> failures), and only for packages using a recursive setup and referencing
>> source files in a parent directory from a subdir Make; so it's a minor one.
>> On the negative side, I probably introduced it myself in some 1.12.x
>> release...
>>
Nope, it was pre-existing.  And I appear to have found an easy enough
fix for it; I will soon post a patch if the testsuite is happy on BSD
and Solaris.

>> Hopefully I'll have a fix in a week or so (I'll be AFK for most time in the
>> coming days).
>  >
> Also, it appears this is causing another new testsuite failure with BSD make.
> The following squash-in diff seems to take care of that:
>
> -*-*-*-
>
> diff --git a/bin/automake.in b/bin/automake.in
> index f4327fc..0c44703 100644
> --- a/bin/automake.in
> +++ b/bin/automake.in
> @@ -1677,12 +1677,15 @@ sub handle_single_transform
>                 {
>                   $this_obj_ext = $obj;
>                   $derived_source = 0;
> -                # Don't ever place built object files in $(srcdir), even when
> -                # sources are specified explicitly as (say) '$(srcdir)/foo.c'
> -                # or '$(top_srcdir)/foo.c'.  See automake bug#13928.
> -                my @d = split '/', $directory;
> -                if (@d)
> +                do
>                     {
> +                    last unless option 'subdir-objects';
> +                    # Don't ever place built object files in $(srcdir),
> +                    # even when sources are specified explicitly as (say)
> +                    # '$(srcdir)/foo.c' or '$(top_srcdir)/foo.c'.
> +                    # See automake bug#13928.
> +                    my @d = split '/', $directory;
> +                    last unless @d;
>                       my $d = $d[0];
>                       if ($d eq '$(srcdir)' or $d eq '${srcdir}')
>                         {
> @@ -1690,7 +1693,7 @@ sub handle_single_transform
>                         }
>                       elsif ($d eq '$(top_srcdir)' or $d eq '${top_srcdir}')
>                         {
> -                       $d[0] = '$(top_builddir)';
> +                        $d[0] = '$(top_builddir)';
>                         }
>                       $directory = join '/', @d;
>                     }
>
> -*-*-*-
>
This change was serious bugged BTW.  I've now fixed it, but rather than
posting another squash-in, I will re-post the whole adjust patch series
once I've made sure there are no regressions on an of the UNIX flavors
I can test with (GNU/Linux, Solaris 10, AIX 7.1, NetBSD 5.1, FreeBSD 8.0)

Regards,
  Stefano




Information forwarded to bug-automake <at> gnu.org:
bug#13928; Package automake. (Mon, 05 Jan 2015 11:17:01 GMT) Full text and rfc822 format available.

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

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: automake-patches <at> gnu.org
Cc: 13928 <at> debbugs.gnu.org
Subject: [PATCH 0/4] Fix automake bug#13928
Date: Mon,  5 Jan 2015 12:15:49 +0100
Stefano Lattarini (4):
  deps: 'subdir-object' option now works when foo_SOURCES contains $(var)
  tests: fix some bugs in an XFAILing test
  compile: don't place built object files in $(srcdir), ever ...
  deps: fix corner-case "make distclean" bug

 NEWS                                  |  43 +++++++++++
 PLANS/subdir-objects.txt              |  10 +--
 THANKS                                |   1 +
 bin/automake.in                       | 134 +++++++++++++++++++--------------
 lib/am/configure.am                   |   6 +-
 lib/am/depend.am                      |  14 +++-
 m4/depout.m4                          |  78 +++++++++----------
 m4/make.m4                            |  59 +++++++--------
 t/depcomp8a.sh                        |  16 ++--
 t/depcomp8b.sh                        |  16 ++--
 t/{postproc.sh => depend-postproc.sh} |  29 ++++++-
 t/extra-sources.sh                    |   5 +-
 t/lex-depend-cxx.sh                   |   5 ++
 t/lex-depend-grep.sh                  |   2 +-
 t/list-of-tests.mk                    |   5 +-
 t/pr224.sh                            |   4 +-
 t/subobj-indir-pr13928.sh             |   4 +-
 t/subobj-pr13928-more-langs.sh        | 138 ++++++++++++++++++++++++++++++++++
 t/subobj-vpath-pr13928.sh             |  89 +++++++++++++++++++---
 t/subobj11b.sh                        |  10 +--
 t/subobj11c.sh                        |   2 +-
 21 files changed, 478 insertions(+), 192 deletions(-)
 rename t/{postproc.sh => depend-postproc.sh} (68%)
 create mode 100644 t/subobj-pr13928-more-langs.sh

-- 
2.1.3





Information forwarded to bug-automake <at> gnu.org:
bug#13928; Package automake. (Mon, 05 Jan 2015 11:17:02 GMT) Full text and rfc822 format available.

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

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: automake-patches <at> gnu.org
Cc: 13928 <at> debbugs.gnu.org
Subject: [PATCH 1/4] deps: 'subdir-object' option now works when foo_SOURCES
 contains $(var)
Date: Mon,  5 Jan 2015 12:15:50 +0100
Following a suggestions of Johan Kristensen, we have config.status use
'make' invocations rather than Makefile-parsing 'sed' hacks to bootstrap
the dependency-tracking '.Po' and '.Plo' makefile fragments. To handle
the inclusion of such files that are still missing when make is first
we basically generate a temporary Makefile without these includes, and
call 'make' on that Makefile.

This fixes the serious bug bug#13928, which was an hard blocker to make the
behavior mandated by the 'subdir-object' active by default (which we want
to do in Automake 2.0).

The issue has also been reported in bug#15919.

* NEWS, THANKS: Update.
* bin/automake.in (handle_languages): Add a trailing "marking" comment
("# am--include-marker") to the generated Makefile lines issuing 'include'
directives for the dependency-tracking '.Po' and '.Plo' makefile fragments.
Also rename the generated Makefile variable 'am__depfiles_maybe' to the
clearer 'am__maybe_remake_depfiles'.
Minor unrelated refactoring.
* lib/am/configure.am: Adjust to account for the 'am__depfiles_maybe' ->
'am__maybe_remake_depfiles' renaming.
* lib/am/depend.am: Add rules to generate a dummy version of all the
dependency-tracking '.Po' and '.Plo' makefile fragments.
* m4/depout.m4: Use make invocations rather than Makefile-parsing sed hacks
to bootstrap the dependency-tracking '.Po' and '.Plo' makefile fragments.
We still use some sed trickery in order to remove the inclusion of the
still non existing .Po and .Plo files from the Makefile we invoke make
upon; this is done stripping lines that contain the magic string
"# am--include-marker".
* m4/make.m4 (AM_MAKE_INCLUDE): Given that now automake generates Makefiles
containing include statements with trailing comment, adjust the checks done
here to make sure $MAKE support that; e.g., "include foo.mk # comment"
rather than just "include foo.mk".
Also refactor and adjust to leave better debugging info in config.log.
* t/postproc.sh: Rename ...
* t/depend-postproc.sh: ... to this, and adjust and enhance.
* t/list-of-tests.mk (handwritten_TESTS): Adjust.
(XFAIL_TESTS): Remove 't/subobj-indir-pr13928.sh', which is now succeeding.
* t/subobj-indir-pr13928.sh: Simplify slightly, now that we expect it to
pass.
* t/depcomp8a.sh: Adjust grepping check to account for the changes in
the generated Makefile, and tp be somewhat more robust in light of possible
future modifications.
* t/depcomp8b.sh: Likewise.
* t/subobj11b.sh: Likewise.
* t/subobj11c.sh: Likewise.
* t/extra-sources.sh: Likewise.
* t/lex-depend-grep.sh: Likewise.
* t/lex-depend-cxx.sh: Add a command to help debugging in case of test
failure.

Helped-by: Johan Kristensen <johankristensen <at> gmail.com>
Signed-off-by: Stefano Lattarini <stefano.lattarini <at> gmail.com>
---
 NEWS                                  | 28 ++++++++++++
 THANKS                                |  1 +
 bin/automake.in                       | 84 ++++++++++++++++++-----------------
 lib/am/configure.am                   |  6 +--
 lib/am/depend.am                      |  7 +++
 m4/depout.m4                          | 78 ++++++++++++++------------------
 m4/make.m4                            | 59 +++++++++++-------------
 t/depcomp8a.sh                        | 16 +++----
 t/depcomp8b.sh                        | 16 +++----
 t/{postproc.sh => depend-postproc.sh} | 29 ++++++++++--
 t/extra-sources.sh                    |  5 ++-
 t/lex-depend-cxx.sh                   |  5 +++
 t/lex-depend-grep.sh                  |  2 +-
 t/list-of-tests.mk                    |  3 +-
 t/subobj-indir-pr13928.sh             |  4 +-
 t/subobj11b.sh                        | 10 ++---
 t/subobj11c.sh                        |  2 +-
 17 files changed, 203 insertions(+), 152 deletions(-)
 rename t/{postproc.sh => depend-postproc.sh} (68%)

diff --git a/NEWS b/NEWS
index 84a5e0a..a930049 100644
--- a/NEWS
+++ b/NEWS
@@ -62,6 +62,34 @@
 
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+New in 1.16:
+
+* Bugs fixed:
+
+  - Automatic dependency tracking has been fixed to work also when the
+    subdir-object option is used and some 'foo_SOURCES' definition contains
+    unexpanded references to make variables, as in, e.g.:
+
+        a_src = sources/libs/aaa
+        b_src = sources/bbb
+        foo_SOURCES = $(a_src)/bar.c $(b_src)/baz.c
+
+    With such a setup, the created makefile fragment containing dependency
+    tracking information will be correctly placed under the directories
+    named 'sources/libs/aaa/.deps' and 'sources/bbb/.deps', rather than
+    mistakenly under directories named (literally!) '$(src_a)/.deps' and
+    '$(src_b)/.deps' (this was automake bug#13928).
+
+    Notice that in order to fix this bug we had to slightly change the
+    semantics of how config.status bootstraps the makefile fragments
+    required for the dependency tracking to work: rather than attempting
+    to parse the Makefiles via grep and sed trickeries only, we actually
+    invoke 'make' on a slightly preprocessed version of those Makefiles,
+    using a private target that is only meant to bootstrap the required
+    makefile fragments.
+
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
 New in 1.15:
 
 * Improvements and refactorings in the install-sh script:
diff --git a/THANKS b/THANKS
index b66f744..8b87d58 100644
--- a/THANKS
+++ b/THANKS
@@ -192,6 +192,7 @@ Joel N. Weber II                nemo <at> koa.iolani.honolulu.hi.us
 Joerg-Martin Schwarz            jms <at> jms.prima.ruhr.de
 Johan Dahlin                    jdahlin <at> async.com.br
 Johan Danielsson                joda <at> pdc.kth.se
+Johan Kristensen                johankristensen <at> gmail.com
 Johannes Nicolai                johannes.nicolai <at> student.hpi.uni-potsdam.de
 John Calcote                    john.calcote <at> gmail.com
 John F Trudeau                  JohnTrudeau <at> firsthealth.com
diff --git a/bin/automake.in b/bin/automake.in
index eedc8bc..f19be92 100644
--- a/bin/automake.in
+++ b/bin/automake.in
@@ -1230,48 +1230,50 @@ sub check_user_variables
 sub handle_languages ()
 {
     if (! option 'no-dependencies')
-    {
-	# Include auto-dep code.  Don't include it if DEP_FILES would
-	# be empty.
-	if (keys %extension_seen && keys %dep_files)
-	{
-	    # Set location of depcomp.
-	    define_variable ('depcomp',
-			     "\$(SHELL) $am_config_aux_dir/depcomp",
-			     INTERNAL);
-	    define_variable ('am__depfiles_maybe', 'depfiles', INTERNAL);
-
-	    require_conf_file ("$am_file.am", FOREIGN, 'depcomp');
-
-	    my @deplist = sort keys %dep_files;
-	    # Generate each 'include' individually.  Irix 6 make will
-	    # not properly include several files resulting from a
-	    # variable expansion; generating many separate includes
-	    # seems safest.
-	    $output_rules .= "\n";
-	    foreach my $iter (@deplist)
-	    {
-		$output_rules .= (subst ('AMDEP_TRUE')
-				  . subst ('am__include')
-				  . ' '
-				  . subst ('am__quote')
-				  . $iter
-				  . subst ('am__quote')
-				  . "\n");
-	    }
-
-	    # Compute the set of directories to remove in distclean-depend.
-	    my @depdirs = uniq (map { dirname ($_) } @deplist);
-	    $output_rules .= file_contents ('depend',
-					    new Automake::Location,
-					    DEPDIRS => "@depdirs");
-	}
-    }
+      {
+        # Include auto-dep code.  Don't include it if DEP_FILES would
+        # be empty.
+        if (keys %extension_seen && keys %dep_files)
+          {
+            my @dep_files = sort keys %dep_files;
+            # Set location of depcomp.
+            define_variable ('depcomp',
+                             "\$(SHELL) $am_config_aux_dir/depcomp",
+                             INTERNAL);
+            define_variable ('am__maybe_remake_depfiles', 'depfiles', INTERNAL);
+            define_variable ('am__depfiles_remade', "@dep_files", INTERNAL);
+            # Generate each 'include' directive individually.  Several make
+            # implementations (IRIX 6, Solaris 10, FreeBSD 8) will fail to
+            # properly include several files resulting from a variable
+            # expansion. Just Generating many separate includes seems thus
+            # safest.
+            $output_rules .= "\n";
+            foreach my $depfile (@dep_files)
+              {
+                $output_rules .= subst ('AMDEP_TRUE') .
+                                 subst ('am__include') .
+                                 " " .
+                                 subst('am__quote') .
+                                 $depfile .
+                                 subst('am__quote') .
+                                 " " .
+                                 "# am--include-marker\n";
+              }
+
+            require_conf_file ("$am_file.am", FOREIGN, 'depcomp');
+
+            # Compute the set of directories to remove in distclean-depend.
+            my @dep_dirs = uniq (map { dirname ($_) } @dep_files);
+            $output_rules .= file_contents ('depend',
+                                            new Automake::Location,
+                                            DEPDIRS => "@dep_dirs");
+          }
+      }
     else
-    {
-	define_variable ('depcomp', '', INTERNAL);
-	define_variable ('am__depfiles_maybe', '', INTERNAL);
-    }
+      {
+        define_variable ('depcomp', '', INTERNAL);
+        define_variable ('am__maybe_remake_depfiles', '', INTERNAL);
+      }
 
     my %done;
 
diff --git a/lib/am/configure.am b/lib/am/configure.am
index 34ebd17..a6086dd 100644
--- a/lib/am/configure.am
+++ b/lib/am/configure.am
@@ -76,10 +76,10 @@ endif %?TOPDIR_P%
 ?TOPDIR_P?	    $(SHELL) ./config.status;; \
 ?!TOPDIR_P?	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
 	  *) \
-## FIXME: $(am__depfiles_maybe) lets us re-run the rule to create the
+## FIXME: $(am__maybe_remake_depfiles) lets us re-run the rule to create the
 ## .P files.  Ideally we wouldn't have to do this by hand.
-	    echo ' cd $(top_builddir) && $(SHELL) ./config.status %CONFIG-MAKEFILE% $(am__depfiles_maybe)'; \
-	    cd $(top_builddir) && $(SHELL) ./config.status %CONFIG-MAKEFILE% $(am__depfiles_maybe);; \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status %CONFIG-MAKEFILE% $(am__maybe_remake_depfiles)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status %CONFIG-MAKEFILE% $(am__maybe_remake_depfiles);; \
 	esac;
 
 ## Avoid the "deleted header file" problem for the dependencies.
diff --git a/lib/am/depend.am b/lib/am/depend.am
index 00ba5b3..0b226b6 100644
--- a/lib/am/depend.am
+++ b/lib/am/depend.am
@@ -16,6 +16,13 @@
 
 am__mv = mv -f
 
+$(am__depfiles_remade):
+	@$(MKDIR_P) $(@D)
+	@echo '# dummy' >$@-t && $(am__mv) $@-t $@
+
+am--depfiles: $(am__depfiles_remade)
+.PHONY: am--depfiles
+
 ## This Makefile depends on Depdirs' files, so we should never
 ## erase them in -am or -recursive rules; that would prevent any other
 ## rules from being recursive (for instance multilib clean rules are
diff --git a/m4/depout.m4 b/m4/depout.m4
index a59dcf5..2109bb3 100644
--- a/m4/depout.m4
+++ b/m4/depout.m4
@@ -6,7 +6,6 @@
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-
 # _AM_OUTPUT_DEPENDENCY_COMMANDS
 # ------------------------------
 AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
@@ -14,49 +13,41 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
   # Older Autoconf quotes --file arguments for eval, but not when files
   # are listed without --file.  Let's play safe and only enable the eval
   # if we detect the quoting.
-  case $CONFIG_FILES in
-  *\'*) eval set x "$CONFIG_FILES" ;;
-  *)   set x $CONFIG_FILES ;;
-  esac
+  # TODO: see whether this extra hack can be removed once we start
+  # requiring Autoconf 2.70 or later.
+  AS_CASE([$CONFIG_FILES],
+          [*\'*], [eval set x "$CONFIG_FILES"],
+          [*], [set x $CONFIG_FILES])
   shift
-  for mf
+  # Used to flag and report bootstrapping failures.
+  am_rc=0
+  for am_mf
   do
     # Strip MF so we end up with the name of the file.
-    mf=`echo "$mf" | sed -e 's/:.*$//'`
-    # Check whether this is an Automake generated Makefile or not.
-    # We used to match only the files named 'Makefile.in', but
-    # some people rename them; so instead we look at the file content.
-    # Grep'ing the first line is not enough: some people post-process
-    # each Makefile.in and add a new line on top of each file to say so.
-    # Grep'ing the whole file is not good either: AIX grep has a line
+    am_mf=`AS_ECHO(["$am_mf"]) | sed -e 's/:.*$//'`
+    # Check whether this is an Automake generated Makefile which includes
+    # dependency-tracking related rules and includes.
+    # Grep'ing the whole file directly is not great: AIX grep has a line
     # limit of 2048, but all sed's we know have understand at least 4000.
-    if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
-      dirpart=`AS_DIRNAME("$mf")`
-    else
-      continue
-    fi
-    # Extract the definition of DEPDIR, am__include, and am__quote
-    # from the Makefile without running 'make'.
-    DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
-    test -z "$DEPDIR" && continue
-    am__include=`sed -n 's/^am__include = //p' < "$mf"`
-    test -z "$am__include" && continue
-    am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
-    # Find all dependency output files, they are included files with
-    # $(DEPDIR) in their names.  We invoke sed twice because it is the
-    # simplest approach to changing $(DEPDIR) to its actual value in the
-    # expansion.
-    for file in `sed -n "
-      s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
-	 sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do
-      # Make sure the directory exists.
-      test -f "$dirpart/$file" && continue
-      fdir=`AS_DIRNAME(["$file"])`
-      AS_MKDIR_P([$dirpart/$fdir])
-      # echo "creating $dirpart/$file"
-      echo '# dummy' > "$dirpart/$file"
-    done
+    sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \
+      || continue
+    am_dirpart=`AS_DIRNAME(["$am_mf"])`
+    am_filepart=`AS_BASENAME(["$am_mf"])`
+    AM_RUN_LOG([cd "$am_dirpart" \
+      && sed -e '/# am--include-marker/d' "$am_filepart" \
+        | $MAKE -f - am--depfiles]) || am_rc=$?
   done
+  if test $am_rc -ne 0; then
+    AC_MSG_FAILURE([Something went wrong bootstrapping makefile fragments
+    for automatic dependency tracking.  Try re-running configure with the
+    '--disable-dependency-tracking' option to at least be able to build
+    the package (albeit without support for automatic dependency tracking).])
+  fi
+  AS_UNSET([am_dirpart])
+  AS_UNSET([am_filepart])
+  AS_UNSET([am_mf])
+  AS_UNSET([am_rc])
+  rm -f conftest-deps.mk
 }
 ])# _AM_OUTPUT_DEPENDENCY_COMMANDS
 
@@ -65,11 +56,10 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
 # -----------------------------
 # This macro should only be invoked once -- use via AC_REQUIRE.
 #
-# This code is only required when automatic dependency tracking
-# is enabled.  FIXME.  This creates each '.P' file that we will
-# need in order to bootstrap the dependency handling code.
+# This code is only required when automatic dependency tracking is enabled.
+# This creates each '.Po' and '.Plo' makefile fragment that we'll need in
+# order to bootstrap the dependency handling code.
 AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
 [AC_CONFIG_COMMANDS([depfiles],
      [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
-     [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
-])
+     [AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}"])])
diff --git a/m4/make.m4 b/m4/make.m4
index a82d2d2..f5520b1 100644
--- a/m4/make.m4
+++ b/m4/make.m4
@@ -8,42 +8,35 @@
 
 # AM_MAKE_INCLUDE()
 # -----------------
-# Check to see how make treats includes.
+# Check whether make has an 'include' directive that can support all
+# the idioms we need for our automatic dependency tracking code.
 AC_DEFUN([AM_MAKE_INCLUDE],
-[am_make=${MAKE-make}
-cat > confinc << 'END'
+[AC_MSG_CHECKING([whether ${MAKE-make} supports the include directive])
+cat > confinc.mk << 'END'
 am__doit:
-	@echo this is the am__doit target
+	@echo this is the am__doit target >confinc.out
 .PHONY: am__doit
 END
-# If we don't find an include directive, just comment out the code.
-AC_MSG_CHECKING([for style of include used by $am_make])
 am__include="#"
 am__quote=
-_am_result=none
-# First try GNU make style include.
-echo "include confinc" > confmf
-# Ignore all kinds of additional output from 'make'.
-case `$am_make -s -f confmf 2> /dev/null` in #(
-*the\ am__doit\ target*)
-  am__include=include
-  am__quote=
-  _am_result=GNU
-  ;;
-esac
-# Now try BSD make style include.
-if test "$am__include" = "#"; then
-   echo '.include "confinc"' > confmf
-   case `$am_make -s -f confmf 2> /dev/null` in #(
-   *the\ am__doit\ target*)
-     am__include=.include
-     am__quote="\""
-     _am_result=BSD
-     ;;
-   esac
-fi
-AC_SUBST([am__include])
-AC_SUBST([am__quote])
-AC_MSG_RESULT([$_am_result])
-rm -f confinc confmf
-])
+# BSD make does it like this.
+echo '.include "confinc.mk" # ignored' > confmf.BSD
+# Other make implementations (GNU, Solaris 10, AIX) do it like this.
+echo 'include confinc.mk # ignored' > confmf.GNU
+_am_result=no
+for s in GNU BSD; do
+  AM_RUN_LOG([${MAKE-make} -f confmf.$s && cat confinc.out])
+  AS_CASE([$?:`cat confinc.out 2>/dev/null`],
+      ['0:this is the am__doit target'],
+      [AS_CASE([$s],
+          [BSD], [am__include='.include' am__quote='"'],
+          [am__include='include' am__quote=''])])
+  if test "$am__include" != "#"; then
+    _am_result="yes ($s style)"
+    break
+  fi
+done
+rm -f confinc.* confmf.*
+AC_MSG_RESULT([${_am_result}])
+AC_SUBST([am__include])])
+AC_SUBST([am__quote])])
diff --git a/t/depcomp8a.sh b/t/depcomp8a.sh
index 94b7afa..ee440ed 100644
--- a/t/depcomp8a.sh
+++ b/t/depcomp8a.sh
@@ -51,10 +51,10 @@ $ACLOCAL
 # FIXME: stop disabling the warnings in the 'unsupported' category
 # FIXME: once the 'subdir-objects' option has been mandatory.
 $AUTOMAKE -a -Wno-unsupported
-grep include Makefile.in # For debugging.
-grep 'include.*\./\$(DEPDIR)/foo\.P' Makefile.in
-grep 'include.*\./\$(DEPDIR)/bar\.P' Makefile.in
-grep 'include.*/\./\$(DEPDIR)' Makefile.in && exit 1
+grep '\.P' Makefile.in # For debugging.
+grep '\./\$(DEPDIR)/foo\.Po' Makefile.in
+grep '\./\$(DEPDIR)/bar\.Po' Makefile.in
+grep '/\./\$(DEPDIR)' Makefile.in && exit 1
 
 $AUTOCONF
 # Don't reject slower dependency extractors, for better coverage.
@@ -68,10 +68,10 @@ DISTCHECK_CONFIGURE_FLAGS='--enable-dependency-tracking' $MAKE distcheck
 echo AUTOMAKE_OPTIONS = subdir-objects >> Makefile.am
 
 $AUTOMAKE
-grep include Makefile.in # For debugging.
-grep 'include.*\./\$(DEPDIR)/foo\.P' Makefile.in
-grep 'include.*[^a-zA-Z0-9_/]sub/\$(DEPDIR)/bar\.P' Makefile.in
-$EGREP 'include.*/(\.|sub)/\$\(DEPDIR\)' Makefile.in && exit 1
+grep '\.P' Makefile.in # For debugging.
+grep '\./\$(DEPDIR)/foo\.Po' Makefile.in
+grep '[^a-zA-Z0-9_/]sub/\$(DEPDIR)/bar\.Po' Makefile.in
+$EGREP '/(\.|sub)/\$\(DEPDIR\)' Makefile.in && exit 1
 
 $AUTOCONF
 # Don't reject slower dependency extractors, for better coverage.
diff --git a/t/depcomp8b.sh b/t/depcomp8b.sh
index 47bf5c5..f1f65f3 100644
--- a/t/depcomp8b.sh
+++ b/t/depcomp8b.sh
@@ -48,10 +48,10 @@ $ACLOCAL
 # FIXME: stop disabling the warnings in the 'unsupported' category
 # FIXME: once the 'subdir-objects' option has been mandatory.
 $AUTOMAKE -a -Wno-unsupported
-grep include Makefile.in # For debugging.
-grep 'include.*\./\$(DEPDIR)/foo\.P' Makefile.in
-grep 'include.*\./\$(DEPDIR)/bar\.P' Makefile.in
-grep 'include.*/\./\$(DEPDIR)' Makefile.in && exit 1
+grep '\.P' Makefile.in # For debugging.
+grep '\./\$(DEPDIR)/foo\.Plo' Makefile.in
+grep '\./\$(DEPDIR)/bar\.Plo' Makefile.in
+grep '/\./\$(DEPDIR)' Makefile.in && exit 1
 
 $AUTOCONF
 # Don't reject slower dependency extractors, for better coverage.
@@ -64,10 +64,10 @@ DISTCHECK_CONFIGURE_FLAGS='--enable-dependency-tracking' $MAKE distcheck
 echo AUTOMAKE_OPTIONS += subdir-objects >> Makefile.am
 
 $AUTOMAKE
-grep include Makefile.in # For debugging.
-grep 'include.*\./\$(DEPDIR)/foo\.P' Makefile.in
-grep 'include.*[^a-zA-Z0-9_/]sub/\$(DEPDIR)/bar\.P' Makefile.in
-$EGREP 'include.*/(\.|sub)/\$\(DEPDIR\)' Makefile.in && exit 1
+grep '\.P' Makefile.in # For debugging.
+grep '\./\$(DEPDIR)/foo\.Plo' Makefile.in
+grep '[^a-zA-Z0-9_/]sub/\$(DEPDIR)/bar\.Plo' Makefile.in
+$EGREP '/(\.|sub)/\$\(DEPDIR\)' Makefile.in && exit 1
 
 $AUTOCONF
 # Don't reject slower dependency extractors, for better coverage.
diff --git a/t/postproc.sh b/t/depend-postproc.sh
similarity index 68%
rename from t/postproc.sh
rename to t/depend-postproc.sh
index 3ac64a4..74088db0 100644
--- a/t/postproc.sh
+++ b/t/depend-postproc.sh
@@ -15,20 +15,22 @@
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 # Check to make sure we recognize a Makefile.in, even if post-processed
-# and renamed.
+# and renamed.  The particularly tricky code for automatic dependency
+# tracking support used to have issues with that.
 
 required=cc
 . test-init.sh
 
-cat >configure.ac <<END
+cat > configure.ac <<END
 AC_INIT([$me], [1.0])
 AM_INIT_AUTOMAKE
 AC_PROG_CC
 AC_CONFIG_FILES([myMakefile])
+dnl: AC_CONFIG_LINKS([Makefile:Makefile])
 AC_OUTPUT
 END
 
-cat > myMakefile.am << 'END'
+cat > myMakefile.am <<'END'
 bin_PROGRAMS = fred
 fred_SOURCES = fred.c
 END
@@ -45,4 +47,25 @@ cat myMakefile.old >> myMakefile.in
 
 test -f .deps/fred.Po || test -f _deps/fred.Po || exit 1
 
+$sleep
+
+cat > Makefile <<'END'
+include myMakefile
+END
+
+sed 's/^dnl: *//' configure.ac >t
+mv -f t configure.ac
+
+$MAKE myMakefile Makefile
+
+rm -rf .deps _deps
+./config.status
+
+test ! -e fred.c
+echo 'int main (void) { return 0; }' > fred.c
+
+$MAKE
+test -f .deps/fred.Po || test -f _deps/fred.Po || exit 1
+$MAKE distcheck
+
 :
diff --git a/t/extra-sources.sh b/t/extra-sources.sh
index e3f15c8..8e204a5 100644
--- a/t/extra-sources.sh
+++ b/t/extra-sources.sh
@@ -21,7 +21,7 @@
 
 echo AC_PROG_CC >> configure.ac
 
-cat > Makefile.am << 'END'
+cat > Makefile.am <<'END'
 bin_PROGRAMS = www
 www_SOURCES = www.c
 EXTRA_www_SOURCES = xtra.c
@@ -31,6 +31,7 @@ END
 $ACLOCAL
 $AUTOMAKE
 
-grep '@am__include@ .*/xtra\.P' Makefile.in
+grep '@am__include@ .*/xtra\.Po' Makefile.in
+grep '^am__depfiles_remade =.*/xtra.Po' Makefile.in
 
 :
diff --git a/t/lex-depend-cxx.sh b/t/lex-depend-cxx.sh
index 2abb101..eee2f5c 100644
--- a/t/lex-depend-cxx.sh
+++ b/t/lex-depend-cxx.sh
@@ -82,6 +82,11 @@ $AUTOCONF
 # using slow dependency extractors.
 ./configure --enable-dependency-tracking
 
+# For debugging.
+for f in $(find . -name '*.Po'); do
+  cat $f
+done
+
 $MAKE test-deps-exist
 $MAKE
 
diff --git a/t/lex-depend-grep.sh b/t/lex-depend-grep.sh
index 4a6473b..be9be29 100644
--- a/t/lex-depend-grep.sh
+++ b/t/lex-depend-grep.sh
@@ -40,7 +40,7 @@ $AUTOMAKE -a
 $EGREP '([mj]oe|_[01234]|include|\.P)' Makefile.in # For debugging.
 
 for x in joe moe _0 _1 _2 _3 _4; do
-  grep "include.*$x\.Po" Makefile.in
+  $EGREP '\$\(DEPDIR\)/'"$x"'\.Po( |$)' Makefile.in
 done
 
 :
diff --git a/t/list-of-tests.mk b/t/list-of-tests.mk
index 9363ee3..5085780 100644
--- a/t/list-of-tests.mk
+++ b/t/list-of-tests.mk
@@ -41,7 +41,6 @@ t/java-nobase.sh \
 t/objext-pr10128.sh \
 t/remake-timing-bug-pr8365.sh \
 t/lex-subobj-nodep.sh \
-t/subobj-indir-pr13928.sh \
 t/subobj-vpath-pr13928.sh \
 t/remake-am-pr10111.sh \
 t/remake-m4-pr10111.sh \
@@ -391,6 +390,7 @@ t/depend3.sh \
 t/depend4.sh \
 t/depend5.sh \
 t/depend6.sh \
+t/depend-postproc.sh \
 t/deprecated-acinit.sh \
 t/destdir.sh \
 t/dir-named-obj-is-bad.sh \
@@ -866,7 +866,6 @@ t/posixsubst-programs.sh \
 t/posixsubst-scripts.sh \
 t/posixsubst-sources.sh \
 t/posixsubst-tests.sh \
-t/postproc.sh \
 t/ppf77.sh \
 t/pr2.sh \
 t/pr9.sh \
diff --git a/t/subobj-indir-pr13928.sh b/t/subobj-indir-pr13928.sh
index 22cb7f5..3ccd037 100644
--- a/t/subobj-indir-pr13928.sh
+++ b/t/subobj-indir-pr13928.sh
@@ -38,7 +38,9 @@ END
 mkdir s
 echo 'int main(void) { return 0; }' > s/foo.c
 
-$ACLOCAL && $AUTOCONF && $AUTOMAKE -a || fatal_ "autotools failed"
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
 
 ./configure
 $MAKE
diff --git a/t/subobj11b.sh b/t/subobj11b.sh
index 5ebb42a..613fa26 100644
--- a/t/subobj11b.sh
+++ b/t/subobj11b.sh
@@ -56,9 +56,9 @@ END
 $ACLOCAL
 $AUTOMAKE -a
 
-# Be lax in the regexp, to account for automake conditionals, the
-# use of @am__include@, and similar stuff.
-grep 'include.*//.*foobar' Makefile.in && exit 1
+grep '\.P' Makefile.in # For debugging.
+
+grep '//.*foobar\.P' Makefile.in && exit 1
 
 # These checks depend on automake internals, but presently this is
 # the only way to test the code path we are interested in.
@@ -71,12 +71,12 @@ for x in zardoz0 zardoz1 path/to/zardoz2 another/path/to/zardoz3; do
   esac
   # Be a little lax in the regexp, to account for automake conditionals,
   # quoting, and similar stuff.
-  grep "^[^/]*am__include[^/]*//server/$d\\\$(DEPDIR)/$b\\.[^/]*$" Makefile.in
+  grep "[ 	]//server/$d\\\$(DEPDIR)/$b\\.Po" Makefile.in
 done
 
 # Sanity checks.
 for i in 0 1 2 3 4 5 6 7 8 9; do
-  grep "am__include.*/foobar$i\\." Makefile.in
+  grep "\$(DEPDIR)/foobar$i\\.Po" Makefile.in
 done
 
 :
diff --git a/t/subobj11c.sh b/t/subobj11c.sh
index a80d760..f5e8340 100644
--- a/t/subobj11c.sh
+++ b/t/subobj11c.sh
@@ -43,6 +43,6 @@ $AUTOMAKE -a
 #
 # FIXME: Are we sure this is the most sensible output in our situation?
 #
-grep '^[^/]*am__include[^/]*//\$(DEPDIR)/zardoz\.[^/]*$' Makefile.in
+grep 'am__depfiles_remade =.* //\$(DEPDIR)/zardoz\.Po' Makefile.in
 
 :
-- 
2.1.3





Information forwarded to bug-automake <at> gnu.org:
bug#13928; Package automake. (Mon, 05 Jan 2015 11:17:03 GMT) Full text and rfc822 format available.

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

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: automake-patches <at> gnu.org
Cc: 13928 <at> debbugs.gnu.org
Subject: [PATCH 2/4] tests: fix some bugs in an XFAILing test
Date: Mon,  5 Jan 2015 12:15:51 +0100
* t/subobj-vpath-pr13928.sh: This one. The test would have failed (or
hung!) even if the bug it was testing against were fixed.

Signed-off-by: Stefano Lattarini <stefano.lattarini <at> gmail.com>
---
 t/subobj-vpath-pr13928.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/t/subobj-vpath-pr13928.sh b/t/subobj-vpath-pr13928.sh
index 9c78d2e..8c3a6c5 100644
--- a/t/subobj-vpath-pr13928.sh
+++ b/t/subobj-vpath-pr13928.sh
@@ -33,7 +33,7 @@ AUTOMAKE_OPTIONS = subdir-objects
 noinst_PROGRAMS = test
 test_SOURCES = $(srcdir)/test.c
 test-objs:
-	test ! -f $(srcdir)/test.$(OBJEXT)
+	test ! -f '@srcdir@/test.$(OBJEXT)'
 	test -f test.$(OBJEXT)
 END
 
@@ -42,7 +42,7 @@ $ACLOCAL && $AUTOCONF && $AUTOMAKE -a || fatal_ "autotools failed"
 $EGREP 'test\.|DEPDIR|dirstamp|srcdir' Makefile.in || : # For debugging.
 $EGREP '\$.srcdir./test\.[o$]' Makefile.in && exit 1
 $FGREP '$(srcdir)/$(am__dirstamp)' Makefile.in && exit 1
-$FGREP '$(srcdir)/$(DEPDIR)' && exit 1
+$FGREP '$(srcdir)/$(DEPDIR)' Makefile.in && exit 1
 
 cat > test.c << 'END'
 int main (void)
-- 
2.1.3





Information forwarded to bug-automake <at> gnu.org:
bug#13928; Package automake. (Mon, 05 Jan 2015 11:17:03 GMT) Full text and rfc822 format available.

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

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: automake-patches <at> gnu.org
Cc: 13928 <at> debbugs.gnu.org
Subject: [PATCH 3/4] compile: don't place built object files in $(srcdir),
 ever ...
Date: Mon,  5 Jan 2015 12:15:52 +0100
... even when a source file is specified as '$(srdir)/foo.c' or
'$(top_srcdir)/bar.c'. And ditto for dependency-tracking makefile
fragments (those under '.deps' directories).

Such issues used to occur when the 'subdir-objects' option was given.

This change should fix the second and last part of automake bug#13928.
See also bug#16375 and bug#15293.

* NEWS: Update.
* bin/automake.in (handle_single_transform): Make sure object files
and dependency-tracking makefile fragments coming from source like
'$(srcdir)/foo.c' and '$(top_srcdir)/bar.c' are placed respectively
under $(builddir) and $(top_builddir).
* t/subobj-vpath-pr13928.sh: Enhance to expose even more aspects
of the bug we've just fixed.
* t/subobj-pr13928-more-langs.sh: New test, similar to the one above,
but with non-C languages as well.
* t/list-of-tests.mk (XFAIL_TESTS): Remove 'subobj-vpath-pr13928.sh',
it's now supposed to pass.
(handwritten_TESTS): Add 'subobj-pr13928-more-langs.sh'.

Signed-off-by: Stefano Lattarini <stefano.lattarini <at> gmail.com>
---
 NEWS                           |  21 ++++++-
 bin/automake.in                |  50 ++++++++++-----
 t/list-of-tests.mk             |   2 +-
 t/subobj-pr13928-more-langs.sh | 138 +++++++++++++++++++++++++++++++++++++++++
 t/subobj-vpath-pr13928.sh      |  89 ++++++++++++++++++++++----
 5 files changed, 269 insertions(+), 31 deletions(-)
 create mode 100644 t/subobj-pr13928-more-langs.sh

diff --git a/NEWS b/NEWS
index a930049..eb3bc6f 100644
--- a/NEWS
+++ b/NEWS
@@ -67,8 +67,8 @@ New in 1.16:
 * Bugs fixed:
 
   - Automatic dependency tracking has been fixed to work also when the
-    subdir-object option is used and some 'foo_SOURCES' definition contains
-    unexpanded references to make variables, as in, e.g.:
+    'subdir-object' option is used and some 'foo_SOURCES' definition
+    contains unexpanded references to make variables, as in, e.g.:
 
         a_src = sources/libs/aaa
         b_src = sources/bbb
@@ -78,7 +78,7 @@ New in 1.16:
     tracking information will be correctly placed under the directories
     named 'sources/libs/aaa/.deps' and 'sources/bbb/.deps', rather than
     mistakenly under directories named (literally!) '$(src_a)/.deps' and
-    '$(src_b)/.deps' (this was automake bug#13928).
+    '$(src_b)/.deps' (this was the first part of automake bug#13928).
 
     Notice that in order to fix this bug we had to slightly change the
     semantics of how config.status bootstraps the makefile fragments
@@ -88,6 +88,21 @@ New in 1.16:
     using a private target that is only meant to bootstrap the required
     makefile fragments.
 
+  - The 'subdir-object' option no longer causes object files corresponding
+    to source files specified with an explicit '$(srcdir)' component to be
+    placed in the source tree rather than in the build tree.
+
+    For example, if Makefile.am contains:
+
+        AUTOMAKE_OPTIONS = subdir-objects
+        foo_SOURCES = $(srcdir)/foo.c $(srcdir)/s/bar.c $(top_srcdir)/baz.c
+
+    then "make all" will create 'foo.o' and 's/bar.o' in $(builddir) rather
+    than in $(srcdir), and will create 'baz.o' in $(top_builddir) rather
+    than in $(top_srcdir).
+
+    This was the second part of automake bug#13928.
+
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 New in 1.15:
diff --git a/bin/automake.in b/bin/automake.in
index f19be92..d8ecca5 100644
--- a/bin/automake.in
+++ b/bin/automake.in
@@ -1617,9 +1617,9 @@ sub handle_single_transform
 	my $renamed = 0;
 	my ($linker, $object);
 
-	# This records whether we've seen a derived source file (e.g.
-	# yacc output).
-	my $derived_source = 0;
+        # This records whether we've seen a derived source file (e.g., yacc
+        # or lex output).
+        my $derived_source;
 
 	# This holds the 'aggregate context' of the file we are
 	# currently examining.  If the file is compiled with
@@ -1667,17 +1667,36 @@ sub handle_single_transform
 	    # Now extract linker and other info.
 	    $linker = $lang->linker;
 
-	    my $this_obj_ext;
-	    if (defined $source_extension)
-	    {
-		$this_obj_ext = $source_extension;
-		$derived_source = 1;
-	    }
-	    else
-	    {
-		$this_obj_ext = $obj;
-	    }
-	    $object = $base . $this_obj_ext;
+            my $this_obj_ext;
+            if (defined $source_extension)
+              {
+                $this_obj_ext = $source_extension;
+                $derived_source = 1;
+              }
+            else
+              {
+                $this_obj_ext = $obj;
+                $derived_source = 0;
+                # Don't ever place built object files in $(srcdir),
+                # even when sources are specified explicitly as (say)
+                # '$(srcdir)/foo.c' or '$(top_srcdir)/foo.c'.
+                # See automake bug#13928.
+                my @d = split '/', $directory;
+                if (@d > 0 && option 'subdir-objects')
+                  {
+                    my $d = $d[0];
+                    if ($d eq '$(srcdir)' or $d eq '${srcdir}')
+                      {
+                        shift @d;
+                      }
+                    elsif ($d eq '$(top_srcdir)' or $d eq '${top_srcdir}')
+                      {
+                        $d[0] = '$(top_builddir)';
+                      }
+                    $directory = join '/', @d;
+                  }
+              }
+            $object = $base . $this_obj_ext;
 
 	    if ($have_per_exec_flags)
 	    {
@@ -1710,8 +1729,7 @@ sub handle_single_transform
 		$renamed = 1;
 	    }
 
-	    # If rewrite said it was ok, put the object into a
-	    # subdir.
+	    # If rewrite said it was ok, put the object into a subdir.
 	    if ($directory ne '')
 	    {
               if ($r == LANG_SUBDIR)
diff --git a/t/list-of-tests.mk b/t/list-of-tests.mk
index 5085780..ddf5fdf 100644
--- a/t/list-of-tests.mk
+++ b/t/list-of-tests.mk
@@ -41,7 +41,6 @@ t/java-nobase.sh \
 t/objext-pr10128.sh \
 t/remake-timing-bug-pr8365.sh \
 t/lex-subobj-nodep.sh \
-t/subobj-vpath-pr13928.sh \
 t/remake-am-pr10111.sh \
 t/remake-m4-pr10111.sh \
 $(perl_fake_XFAIL_TESTS)
@@ -1063,6 +1062,7 @@ t/subobj-clean-pr10697.sh \
 t/subobj-clean-lt-pr10697.sh \
 t/subobj-indir-pr13928.sh \
 t/subobj-vpath-pr13928.sh \
+t/subobj-pr13928-more-langs.sh \
 t/subpkg.sh \
 t/subpkg2.sh \
 t/subpkg3.sh \
diff --git a/t/subobj-pr13928-more-langs.sh b/t/subobj-pr13928-more-langs.sh
new file mode 100644
index 0000000..323e248
--- /dev/null
+++ b/t/subobj-pr13928-more-langs.sh
@@ -0,0 +1,138 @@
+#! /bin/sh
+# Copyright (C) 2015 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/>.
+
+# Expose part of automake bug#13928, also for non-C languages: if the
+# subdir-objects option is in use and a source file is listed in a
+# _SOURCES variable with a leading $(srcdir) component, Automake will
+# generate a Makefile that tries to create the corresponding object
+# file in $(srcdir) as well.
+
+required='cc c++ fortran77 fortran'
+. test-init.sh
+
+cat >> configure.ac <<'END'
+AC_PROG_CC
+AC_PROG_CXX
+AC_PROG_F77
+AC_PROG_FC
+AM_CONDITIONAL([OBVIOUS], [:])
+AC_CONFIG_FILES([sub/Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+AUTOMAKE_OPTIONS = subdir-objects
+SUBDIRS = sub
+
+LESS = m/o/r/e
+
+noinst_PROGRAMS = test test2
+test_SOURCES = $(srcdir)/test.f90
+
+test2_SOURCES = $(indir)
+
+indir = ${indir2} $(empty)
+indir2 =
+if OBVIOUS
+indir2 += ${srcdir}/$(LESS)///test.f
+else
+endif
+
+test-objs:
+	ls -la @srcdir@ .
+        :
+	test ! -f @srcdir@/test.$(OBJEXT)
+	test -f test.$(OBJEXT)
+	test ! -f @srcdir@/m/o/r/e/test.$(OBJEXT)
+	test -f m/o/r/e/test.$(OBJEXT)
+        :
+	test ! -f @srcdir@/bar.$(OBJEXT)
+	test -f bar.$(OBJEXT)
+	test ! -f @srcdir@/baz.$(OBJEXT)
+	test -f baz.$(OBJEXT)
+        :
+	test ! -d @srcdir@/$(DEPDIR)
+	test ! -d @srcdir@/m/o/r/e/$(DEPDIR)
+	test -d $(DEPDIR)
+	test -d m/o/r/e/$(DEPDIR)
+
+check-local: test-objs
+END
+
+mkdir sub
+cat > sub/Makefile.am <<'END'
+AUTOMAKE_OPTIONS = subdir-objects
+bin_PROGRAMS = foo
+foo = baz
+foo_SOURCES = foo.h \
+	      $(top_srcdir)/bar.cc \
+              ${top_srcdir}/$(foo).c
+END
+
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+mkfiles='Makefile.in sub/Makefile.in'
+$EGREP '(test|ba[rz])\.|DEPDIR|dirstamp|srcdir' $mkfiles # For debugging.
+$EGREP '\$.(top_)?srcdir./(test|ba[rz]|\$.foo.)\.[o$]' $mkfiles && exit 1
+$FGREP '\$.(top_)?srcdir./.*$(am__dirstamp)' $mkfiles && exit 1
+$FGREP '\$.(top_)?srcdir./.*$(DEPDIR)' $mkfiles && exit 1
+
+cat > test.f90 <<'EOF'
+      program foo
+      stop
+      end
+EOF
+
+mkdir -p m/o/r/e
+cp test.f90 m/o/r/e/test.f
+
+cat > sub/foo.h <<'END'
+#ifdef __cplusplus
+extern "C"
+#endif
+int foo (void);
+END
+
+cat > bar.cc <<'END'
+#include "foo.h"
+#include <iostream>
+int main (void)
+{
+  std::cout << "OK!" << "\n";
+  return foo ();
+}
+END
+
+cat > baz.c <<'END'
+#include "foo.h"
+int foo (void)
+{
+  return 0;
+}
+END
+
+mkdir build
+cd build
+../configure
+
+$MAKE
+$MAKE test-objs
+$MAKE distcheck
+
+:
diff --git a/t/subobj-vpath-pr13928.sh b/t/subobj-vpath-pr13928.sh
index 8c3a6c5..24eff1d 100644
--- a/t/subobj-vpath-pr13928.sh
+++ b/t/subobj-vpath-pr13928.sh
@@ -22,39 +22,106 @@
 required=cc
 . test-init.sh
 
-cat >> configure.ac << 'END'
+cat >> configure.ac <<'END'
 AC_PROG_CC
 AM_PROG_CC_C_O
+AM_CONDITIONAL([OBVIOUS], [:])
+AC_CONFIG_FILES([sub/Makefile])
 AC_OUTPUT
 END
 
 cat > Makefile.am <<'END'
 AUTOMAKE_OPTIONS = subdir-objects
-noinst_PROGRAMS = test
+SUBDIRS = sub
+
+LESS = more
+
+noinst_PROGRAMS = test test2
 test_SOURCES = $(srcdir)/test.c
+
+test2_SOURCES = $(indir)
+
+indir =
+if OBVIOUS
+indir += ${srcdir}/$(LESS)/test.c
+else
+endif
+
 test-objs:
-	test ! -f '@srcdir@/test.$(OBJEXT)'
+	ls -la @srcdir@ .
+        :
+	test ! -f @srcdir@/test.$(OBJEXT)
 	test -f test.$(OBJEXT)
+	test ! -f @srcdir@/more/test.$(OBJEXT)
+	test -f more/test.$(OBJEXT)
+        :
+	test ! -f @srcdir@/bar.$(OBJEXT)
+	test -f bar.$(OBJEXT)
+	test ! -f @srcdir@/baz.$(OBJEXT)
+	test -f baz.$(OBJEXT)
+        :
+	test ! -d @srcdir@/$(DEPDIR)
+	test ! -d @srcdir@/more/$(DEPDIR)
+	test -d $(DEPDIR)
+	test -d more/$(DEPDIR)
+
+check-local: test-objs
+END
+
+mkdir sub
+cat > sub/Makefile.am <<'END'
+AUTOMAKE_OPTIONS = subdir-objects
+bin_PROGRAMS = foo
+foo_SOURCES = foo.h \
+	      $(top_srcdir)/bar.c \
+              ${top_srcdir}/baz.c
+END
+
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+mkfiles='Makefile.in sub/Makefile.in'
+$EGREP '(test|ba[rz])\.|DEPDIR|dirstamp|srcdir' $mkfiles # For debugging.
+$EGREP '\$.(top_)?srcdir./(test|ba[rz])\.[o$]' $mkfiles && exit 1
+$FGREP '\$.(top_)?srcdir./.*$(am__dirstamp)' $mkfiles && exit 1
+$FGREP '\$.(top_)?srcdir./.*$(DEPDIR)' $mkfiles && exit 1
+
+cat > test.c <<'END'
+int main (void)
+{
+  return 0;
+}
 END
 
-$ACLOCAL && $AUTOCONF && $AUTOMAKE -a || fatal_ "autotools failed"
+mkdir more
+cp test.c more/test.c
 
-$EGREP 'test\.|DEPDIR|dirstamp|srcdir' Makefile.in || : # For debugging.
-$EGREP '\$.srcdir./test\.[o$]' Makefile.in && exit 1
-$FGREP '$(srcdir)/$(am__dirstamp)' Makefile.in && exit 1
-$FGREP '$(srcdir)/$(DEPDIR)' Makefile.in && exit 1
+echo 'int foo (void);' > sub/foo.h
 
-cat > test.c << 'END'
+cat > bar.c <<'END'
+#include "foo.h"
 int main (void)
 {
+  return foo ();
+}
+END
+
+cat > baz.c <<'END'
+#include "foo.h"
+int foo (void)
+{
   return 0;
 }
 END
 
-mkdir build && cd build || fatal "preparation of build directory failed"
-../configure || fatal_ "./configure failed"
+mkdir build
+cd build
+../configure
 
 $MAKE
 $MAKE test-objs
+$MAKE distcheck
 
 :
-- 
2.1.3





Information forwarded to bug-automake <at> gnu.org:
bug#13928; Package automake. (Mon, 05 Jan 2015 11:17:04 GMT) Full text and rfc822 format available.

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

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: automake-patches <at> gnu.org
Cc: 13928 <at> debbugs.gnu.org
Subject: [PATCH 4/4] deps: fix corner-case "make distclean" bug
Date: Mon,  5 Jan 2015 12:15:53 +0100
Assume we have package satisfying the following conditions:
  (1) automatic dependency tracking is enabled;
  (2) the 'subdir-objects' Automake option is enabled;
  (3) the package uses a recursive make setup.

Also assume that:
  (a) a subdir Makefile declares a foo_SOURCES variable containing
      a source file in the parent directory;
  (b) that parent Makefile declare a compiled program itself.

Then BSD and Solaris make used to fail when running "make distclean",
because the 'distclean' target of the subdir Makefile removed the
whole '.deps' directory before the parent Makefile was done with the
included '.Po' makefile fragments in that directory. This issue was
revealed by failures in the 'subobj-vpath-pr13928.sh' test when those
make implementations were used.

We fix the issue by ensuring the 'distclean' target of any Makefile
only removed the '.Po' makefile fragments included by it, rather than
the whole '.deps' directory where such files resides.

This change should be the last step in fixing automake bug#13928
for good.

* bin/automake.in (handle_languages), lib/am/depend.am: Adjust
to implement the new 'distclean' logic.
* t/pr224.sh: Adjust to avoid a spurious failure.
* PLANS/subdir-objects.txt: Update.

Signed-off-by: Stefano Lattarini <stefano.lattarini <at> gmail.com>
---
 PLANS/subdir-objects.txt | 10 +++-------
 bin/automake.in          | 20 ++++++++++----------
 lib/am/depend.am         |  7 ++++---
 t/pr224.sh               |  4 ++--
 4 files changed, 19 insertions(+), 22 deletions(-)

diff --git a/PLANS/subdir-objects.txt b/PLANS/subdir-objects.txt
index 3cf6101..c849e33 100644
--- a/PLANS/subdir-objects.txt
+++ b/PLANS/subdir-objects.txt
@@ -5,9 +5,6 @@ We want to make the behaviour currently enabled by the 'subdir-objects'
 the default one, and in fact the *only* one, in Automake 2.0.
 See automake bug#13378: <http://debbugs.gnu.org/13378>.
 
-Sadly, **THIS IS IMPOSSIBLE** until automake bug#13928 is resolved:
-http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13928
-
 Details
 -------
 
@@ -53,11 +50,10 @@ We also make sure to avoid the warning when it would be irrelevant, i.e.,
 if all source files sit in "current" directory (thanks to Peter Johansson
 for suggesting this).
 
-For some automake 1.x (*before* 2.0 can be released)
-----------------------------------------------------
+For automake 1.16 (*before* 2.0 can be released)
+------------------------------------------------
 
-Find a proper way to fix the blocking automake bug#13928:
-http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13928
+Submit the pending patch series that fixes http://debbugs.gnu.org/13928
 
 For automake 2.0
 ----------------
diff --git a/bin/automake.in b/bin/automake.in
index d8ecca5..21cccbe 100644
--- a/bin/automake.in
+++ b/bin/automake.in
@@ -1242,14 +1242,16 @@ sub handle_languages ()
                              INTERNAL);
             define_variable ('am__maybe_remake_depfiles', 'depfiles', INTERNAL);
             define_variable ('am__depfiles_remade', "@dep_files", INTERNAL);
-            # Generate each 'include' directive individually.  Several make
-            # implementations (IRIX 6, Solaris 10, FreeBSD 8) will fail to
-            # properly include several files resulting from a variable
-            # expansion. Just Generating many separate includes seems thus
-            # safest.
             $output_rules .= "\n";
+            my @dist_rms;
             foreach my $depfile (@dep_files)
               {
+                push @dist_rms, "\t-rm -f $depfile";
+                # Generate each 'include' directive individually.  Several
+                # make implementations (IRIX 6, Solaris 10, FreeBSD 8) will
+                # fail to properly include several files resulting from a
+                # variable expansion. Just Generating many separate includes
+                # seems thus safest.
                 $output_rules .= subst ('AMDEP_TRUE') .
                                  subst ('am__include') .
                                  " " .
@@ -1262,11 +1264,9 @@ sub handle_languages ()
 
             require_conf_file ("$am_file.am", FOREIGN, 'depcomp');
 
-            # Compute the set of directories to remove in distclean-depend.
-            my @dep_dirs = uniq (map { dirname ($_) } @dep_files);
-            $output_rules .= file_contents ('depend',
-                                            new Automake::Location,
-                                            DEPDIRS => "@dep_dirs");
+            $output_rules .= file_contents (
+                'depend', new Automake::Location,
+                'DISTRMS' => join ("\n", @dist_rms));
           }
       }
     else
diff --git a/lib/am/depend.am b/lib/am/depend.am
index 0b226b6..3813996 100644
--- a/lib/am/depend.am
+++ b/lib/am/depend.am
@@ -27,8 +27,9 @@ am--depfiles: $(am__depfiles_remade)
 ## erase them in -am or -recursive rules; that would prevent any other
 ## rules from being recursive (for instance multilib clean rules are
 ## recursive).
+if %?DISTRMS%
 distclean:
-	-rm -rf %DEPDIRS%
-
+	%DISTRMS%
 maintainer-clean:
-	-rm -rf %DEPDIRS%
+	%DISTRMS%
+endif
diff --git a/t/pr224.sh b/t/pr224.sh
index fcea148..1961786 100644
--- a/t/pr224.sh
+++ b/t/pr224.sh
@@ -56,8 +56,8 @@ cd build
 ../configure
 
 $MAKE
-test -d foo/.deps
+test -f foo/.deps/main.Po
 $MAKE distclean
-test -d foo/.deps && exit 1
+test ! -e foo/.deps/main.Po
 
 :
-- 
2.1.3





Added tag(s) patch. Request was from Stefano Lattarini <stefano.lattarini <at> gmail.com> to control <at> debbugs.gnu.org. (Mon, 05 Jan 2015 11:17:04 GMT) Full text and rfc822 format available.

Information forwarded to bug-automake <at> gnu.org:
bug#13928; Package automake. (Tue, 06 Jan 2015 19:31:02 GMT) Full text and rfc822 format available.

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

From: Stefano Lattarini <stefano.lattarini <at> gmail.com>
To: 13928 <at> debbugs.gnu.org
Cc: Nick Bowler <nbowler <at> elliptictech.com>, Shawn Webb <swebb <at> sourcefire.com>,
 Eric Blake <eblake <at> redhat.com>, Diab Jerius <dj <at> head.cfa.harvard.edu>,
 Bob Friesenhahn <bfriesen <at> simple.dallas.tx.us>, Miles Bader <miles <at> gnu.org>,
 Oleg Latin <jujulicca <at> gmail.com>, Bert Wesarg <bert.wesarg <at> googlemail.com>
Subject: Closing automake bug#13928 (bad interactions between 'subdir-object'
 option and automatic dependency tracking)
Date: Tue, 06 Jan 2015 20:30:12 +0100
close 13928
thanks

Reference: <http://debbugs.gnu.org/13928>

I've merged the latest patch series:
<http://lists.gnu.org/archive/html/automake-patches/2015-01/msg00006.html>
into the 'minor' and 'master' branches, and the testsuite appears to be
happy (or at least no more unhappy than before) on the following systems
(in addition to GNU/Linux):

 - Solaris 10
 - NetBSD 5.1
 - FreeBSD 8.0
 - AIX 7.1

I'm thus optimistically declaring victory on this long-standing issue.
Hopefully I'll be able to release a new Automake minor version (1.16)
containing this fix in the coming month or so.  If in the meantime
anyone feels patient enough to test the unreleased Automake from the
'minor' branch on real-world projects which were being bitten by the
bug, I would be very grateful.

Thanks,
  Stefano




bug closed, send any further explanations to 13928 <at> debbugs.gnu.org and Bert Wesarg <bert.wesarg <at> googlemail.com> Request was from Stefano Lattarini <stefano.lattarini <at> gmail.com> to control <at> debbugs.gnu.org. (Tue, 06 Jan 2015 19:31:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 04 Feb 2015 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 9 years and 76 days ago.

Previous Next


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