GNU bug report logs - #7884
Yacc and FreeBSD make in VPATH builds

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: automake; Severity: important; Reported by: Stefano Lattarini <stefano.lattarini@HIDDEN>; dated Fri, 21 Jan 2011 21:21:01 UTC; Maintainer for automake is bug-automake@HIDDEN.
Severity set to 'important' from 'normal' Request was from Stefano Lattarini <stefano.lattarini@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 7884 <at> debbugs.gnu.org:


Received: (at 7884) by debbugs.gnu.org; 29 Jan 2011 10:23:15 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 29 05:23:14 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Pj7xa-0006kC-8R
	for submit <at> debbugs.gnu.org; Sat, 29 Jan 2011 05:23:14 -0500
Received: from mail-ww0-f46.google.com ([74.125.82.46])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <stefano.lattarini@HIDDEN>) id 1Pj7xY-0006k0-97
	for 7884 <at> debbugs.gnu.org; Sat, 29 Jan 2011 05:23:13 -0500
Received: by wwj40 with SMTP id 40so4328472wwj.15
	for <7884 <at> debbugs.gnu.org>; Sat, 29 Jan 2011 02:31:26 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:from:to:subject:date:user-agent:cc:references
	:in-reply-to:mime-version:content-type:content-transfer-encoding
	:message-id; bh=ATKggcRDsj5BhA2LP8lu1cwbv0o/xjIpfXEwWjheGSY=;
	b=TvLDXCpJuVE5vO+Nds6sqmEHXngu6iGIr0zhAhew5US0YMTR7heoHILqeOJWydzLpn
	m7rmjfFIMPPIexd4fa3tDR5x55A68aVwDmSPE7TFF7NmDKA0DsfHce6NtLbIzTEINiGL
	JwVOwsDeMbWF5fix+McuQQROO68xtm7sgyzj0=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=from:to:subject:date:user-agent:cc:references:in-reply-to
	:mime-version:content-type:content-transfer-encoding:message-id;
	b=fb90SDX5WxivGP2UVeeE9RQcUEjcWjBmDzkGlQ0m/NasR3BV35I8uFcx4OExFC36F+
	E6ZZqDn0b0VpeqSeyw3lEkay2UDRUULH8CdVH0/ggiMAfmI3wO2ygp3bmEdnAToIjJht
	3mJwGbCEUjCUWoVux1wi8gV9LhMmjTeMS0aFI=
Received: by 10.216.144.205 with SMTP id n55mr8901496wej.5.1296297086531;
	Sat, 29 Jan 2011 02:31:26 -0800 (PST)
Received: from bigio.localnet
	(host8-53-dynamic.48-82-r.retail.telecomitalia.it [82.48.53.8])
	by mx.google.com with ESMTPS id n78sm9545976weq.3.2011.01.29.02.31.24
	(version=TLSv1/SSLv3 cipher=RC4-MD5);
	Sat, 29 Jan 2011 02:31:25 -0800 (PST)
From: Stefano Lattarini <stefano.lattarini@HIDDEN>
To: Ralf Wildenhues <Ralf.Wildenhues@HIDDEN>
Subject: Re: [PATCH] yacc: fix VPATH builds with FreeBSD make
Date: Sat, 29 Jan 2011 11:31:15 +0100
User-Agent: KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; )
References: <201101212228.25510.stefano.lattarini@HIDDEN>
	<201101281351.40873.stefano.lattarini@HIDDEN>
	<20110129001711.GQ7234@HIDDEN>
In-Reply-To: <20110129001711.GQ7234@HIDDEN>
MIME-Version: 1.0
Content-Type: Text/Plain;
  charset="us-ascii"
Content-Transfer-Encoding: 7bit
Message-Id: <201101291131.15789.stefano.lattarini@HIDDEN>
X-Spam-Score: -3.6 (---)
X-Debbugs-Envelope-To: 7884
Cc: automake-patches@HIDDEN, 7884 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -3.6 (---)

On Saturday 29 January 2011, Ralf Wildenhues wrote:
> * Stefano Lattarini wrote on Fri, Jan 28, 2011 at 01:51:40PM CET:
> > On Thursday 27 January 2011, Ralf Wildenhues wrote:
> > > Does 'make -n' create files (for any target)?
> > >
> > No, and I've updated the `yaccdry.test' testcase to also check for this
> > (see attached amended patch).
> 
> Thanks.
> 
> > > How do you ensure in your patch that 'make distdir' does not create files?
> > >
> > Well, it does, but I don't see any problem with this.
> 
> Ah, you're right.  I was confused here.
> 
> > > How do you ensure in your patch that 'make clean' does not create files?
> > >
> > In fact, it does (good catch, BTW); see new testcase in the attached patch.
> > Yes, this is clearly a wart, but a minor one, and having it is IMHO a price
> > worth paying in order to have VPATH builds work on FreeBSD.
> 
> Wait.  When you do '../configure && make clean', then your code creates
> the files just before removing them again, no?
>
Actually no, it's worse, because the files are copied by "make clean", but
removed only by "make maintainer-clean".

> That is what I meant.
> It is not a disqualifying problem that it does so, but it is not nice.
>
See above.

> It becomes more of a problem when things like
>   make tags
>   make some-arbitrary-user-target
> 
> start creating files that they shouldn't have anything to do with.
> OTOH,
>   make some-prog-that-depends-on-yacc-output
> 
> should be built with updated yacc outputs.
> 
> > BTW, if you decide to get rid of said wart in a follow-up patch, that can
> > probably be done using the FreeBSD make special variable `.TARGETS' (akin
> > to GNU make's `MAKECMDGOALS').
> 
> I suppose, yes.
> 
> Another problem, which might be more serious:
> 
> Say I checkout a git tree of my project, do a VPATH build from it on
> FreeBSD.  The next day someone has updated foo.y in git, I pull the new
> version, type 'make' again inside the old build tree.  This fails to use
> the code from the new foo.y code version (because at the time the .BEGIN
> rule was invoked, the old $(srcdir)/foo.c was still in place).
>
No, it should work anyway.  I see three scenarious:

 1. You have a pre-existing `foo.c' in the builddir.  After you update
    the `foo.y' in the srcdir, you run "make".  The .BEGIN target will
    do nothing, because there's already a `foo.c' in the builddir; then,
    since this `foo.c' is older than the `foo.y' in the srcdir, make
    will rebuild it.  From there, everything should go as expected.

 2. You have a pre-existing `foo.c' in the srcdir, but not in the
    builddir.  You update the `foo.y' in the srcdir, which will make
    it newer than `foo.c'.  Then you run "make".  The .BEGIN target
    will copy the `foo.c' from the srcdir in the builddir, using the
    cp -p command; this means that the timestamp of `foo.c' will be
    preserved, so that the `foo.c' in the builddir will result older
    than the `foo.y' in the srcdir -- and will thus be rebuilt by
    make.  At this point, `foo.c' is really up-to-date with the new
    `foo.y', and from there, everything should go as expected.

 3. There's no pre-existing `foo.c' in the srcdir nor in the builddir.
    The .BEGIN target will do nothing, because there's not `foo.c' in
    the srcdir to copy.  Make will then create (in the builddir) the
    `foo.c' derived from `foo.y'.  From there, everything should go as
    expected.

> I use such setups regularly.  I know they break when the source tree
> changes are large, but still, with no source tree graph changes it is a
> subtle failure that developers will rightly blame Automake for.  It can
> be fixed by comparing time stamps, at the cost of now getting into the
> time stamp business that I mentioned earlier.
>
There should no need to; and the fact that the behaviour you want really
works should be already verified by the test `yaccvpath.test' (which you
are free to improve if you like, I obviously won't object ;-)

> Then, there is the issue of which make implementations support the
> .TARGETS feature.
>
You mean the ".BEGIN" feature here, right?

> What if GNU make 3.84 starts supporting it?
>
Then we start checking in the `.BEGIN' recipe that the currently-running
make is really a BSD make (e.g. by checking that ${.MAKE.PID} is
non-empty, or something like that).  If it's not a BSD make, we exit
early from the recipe.

But then, that wouldn't be really necessary, since the setup done by
the `.BEGIN' recipe shouldn't break builds for non-BSD makes: it's just
redundant for them.  So, even if GNU make 3.84 starts supporting the
`.BEGIN' target, Makefiles generated with automake 1.12 should still
be able to build packages using Yacc correctly.

> Our makefiles then would suddenly cause regressions for GNU make users.
>
How so exactly?

> I guess my point is, I fear that your approach is fundamentally not
> robust.  I acknowledge that BUILT_SOURCES is not robust either
> ($(BUILT_SOURCES) being updated routinely as part of 'all', 'check',
> 'install', but no other special targets).  But at least with dependency
> tracking enabled, BUILT_SOURCES is typically needed only the first time
> 'make' is used in some build tree.
>
Which BTW is also the way the `.BEGIN' recipe we're using should
behave, ideally ...

Hmm... Maybe having a similar (internal) variable `am__LINKED_SOURCES'
holding a list of files to be copied from srcdir to builddir *only for
targets 'all', 'check' and 'install'* might be a better stategy?
Should I try to pursue that?

> Cheers,
> Ralf
> 

Regards,
  Stefano




Information forwarded to owner <at> debbugs.gnu.org, bug-automake@HIDDEN:
bug#7884; Package automake. Full text available.

Message received at 7884 <at> debbugs.gnu.org:


Received: (at 7884) by debbugs.gnu.org; 29 Jan 2011 00:09:04 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jan 28 19:09:04 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1PiyNC-00015l-Cd
	for submit <at> debbugs.gnu.org; Fri, 28 Jan 2011 19:09:03 -0500
Received: from mailout-de.gmx.net ([213.165.64.22])
	by debbugs.gnu.org with smtp (Exim 4.69)
	(envelope-from <Ralf.Wildenhues@HIDDEN>) id 1PiyN9-00015F-S3
	for 7884 <at> debbugs.gnu.org; Fri, 28 Jan 2011 19:09:01 -0500
Received: (qmail invoked by alias); 29 Jan 2011 00:17:12 -0000
Received: from xdsl-89-0-182-62.netcologne.de (EHLO localhost.localdomain)
	[89.0.182.62]
	by mail.gmx.net (mp006) with SMTP; 29 Jan 2011 01:17:12 +0100
X-Authenticated: #13673931
X-Provags-ID: V01U2FsdGVkX18A2gBRB3QA7naDyD7TprCaI97c8y6ehZlzQFIhdk
	a8JlkoVpKwleNx
Received: from ralf by localhost.localdomain with local (Exim 4.69)
	(envelope-from <Ralf.Wildenhues@HIDDEN>)
	id 1PiyV6-0000Rl-4h; Sat, 29 Jan 2011 01:17:12 +0100
Date: Sat, 29 Jan 2011 01:17:12 +0100
From: Ralf Wildenhues <Ralf.Wildenhues@HIDDEN>
To: Stefano Lattarini <stefano.lattarini@HIDDEN>
Subject: Re: [PATCH] yacc: fix VPATH builds with FreeBSD make
Message-ID: <20110129001711.GQ7234@HIDDEN>
Mail-Followup-To: Stefano Lattarini <stefano.lattarini@HIDDEN>,
	automake-patches@HIDDEN, 7884 <at> debbugs.gnu.org
References: <201101212228.25510.stefano.lattarini@HIDDEN>
	<201101272026.43640.stefano.lattarini@HIDDEN>
	<201101272115.37504.stefano.lattarini@HIDDEN>
	<201101281351.40873.stefano.lattarini@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <201101281351.40873.stefano.lattarini@HIDDEN>
Organization: Institute for Numerical Simulation, University of Bonn
User-Agent: Mutt/1.5.20 (2010-08-04)
X-Y-GMX-Trusted: 0
X-Spam-Score: -2.8 (--)
X-Debbugs-Envelope-To: 7884
Cc: automake-patches@HIDDEN, 7884 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -2.8 (--)

* Stefano Lattarini wrote on Fri, Jan 28, 2011 at 01:51:40PM CET:
> On Thursday 27 January 2011, Ralf Wildenhues wrote:
> > Does 'make -n' create files (for any target)?
> >
> No, and I've updated the `yaccdry.test' testcase to also check for this
> (see attached amended patch).

Thanks.

> > How do you ensure in your patch that 'make distdir' does not create files?
> >
> Well, it does, but I don't see any problem with this.

Ah, you're right.  I was confused here.

> > How do you ensure in your patch that 'make clean' does not create files?
> >
> In fact, it does (good catch, BTW); see new testcase in the attached patch.
> Yes, this is clearly a wart, but a minor one, and having it is IMHO a price
> worth paying in order to have VPATH builds work on FreeBSD.

Wait.  When you do '../configure && make clean', then your code creates
the files just before removing them again, no?  That is what I meant.
It is not a disqualifying problem that it does so, but it is not nice.

It becomes more of a problem when things like
  make tags
  make some-arbitrary-user-target

start creating files that they shouldn't have anything to do with.
OTOH,
  make some-prog-that-depends-on-yacc-output

should be built with updated yacc outputs.

> BTW, if you decide to get rid of said wart in a follow-up patch, that can
> probably be done using the FreeBSD make special variable `.TARGETS' (akin
> to GNU make's `MAKECMDGOALS').

I suppose, yes.

Another problem, which might be more serious:

Say I checkout a git tree of my project, do a VPATH build from it on
FreeBSD.  The next day someone has updated foo.y in git, I pull the new
version, type 'make' again inside the old build tree.  This fails to use
the code from the new foo.y code version (because at the time the .BEGIN
rule was invoked, the old $(srcdir)/foo.c was still in place).

I use such setups regularly.  I know they break when the source tree
changes are large, but still, with no source tree graph changes it is a
subtle failure that developers will rightly blame Automake for.  It can
be fixed by comparing time stamps, at the cost of now getting into the
time stamp business that I mentioned earlier.

Then, there is the issue of which make implementations support the
.TARGETS feature.  What if GNU make 3.84 starts supporting it?
Our makefiles then would suddenly cause regressions for GNU make users.

I guess my point is, I fear that your approach is fundamentally not
robust.  I acknowledge that BUILT_SOURCES is not robust either
($(BUILT_SOURCES) being updated routinely as part of 'all', 'check',
'install', but no other special targets).  But at least with dependency
tracking enabled, BUILT_SOURCES is typically needed only the first time
'make' is used in some build tree.

Cheers,
Ralf




Information forwarded to owner <at> debbugs.gnu.org, bug-automake@HIDDEN:
bug#7884; Package automake. Full text available.

Message received at 7884 <at> debbugs.gnu.org:


Received: (at 7884) by debbugs.gnu.org; 28 Jan 2011 20:47:41 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jan 28 15:47:41 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1PivEK-0002WD-NH
	for submit <at> debbugs.gnu.org; Fri, 28 Jan 2011 15:47:40 -0500
Received: from mail-ww0-f46.google.com ([74.125.82.46])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <stefano.lattarini@HIDDEN>) id 1PivEI-0002W1-SO
	for 7884 <at> debbugs.gnu.org; Fri, 28 Jan 2011 15:47:39 -0500
Received: by wwj40 with SMTP id 40so3887369wwj.15
	for <7884 <at> debbugs.gnu.org>; Fri, 28 Jan 2011 12:55:51 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:from:to:subject:date:user-agent:references
	:in-reply-to:mime-version:content-type:content-transfer-encoding
	:message-id; bh=E0tGAdKmkDu9oHHGqssOv5glOsz0Ki+o3i0xNniG+mw=;
	b=onuTNSheXfy5Z1HHvmeoiFUplyEGPHxamd3m2vKd4UBC5OILptP3IihzD7TyRhpwC8
	bkfYFbAQ2ZK0tpahFQMsr5vNfcNEjnH5tfuH57Yd5fD56CsjrmIC9KuiB0Sc8gk8N0+K
	vmmsoX0d++q0ZtYfBQ1w+lWrpcmsHzEtL9oAM=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=from:to:subject:date:user-agent:references:in-reply-to:mime-version
	:content-type:content-transfer-encoding:message-id;
	b=nmr4wKsL1ZMlvmHWmgQ13mkt1LztLqBOBoX4LeVsoSlTBh1AHHWG5P/FCqWNB0+m3s
	SSqjbVQkwtsM/13fnajsKuPA0RdxTbb61Fz7+0dZHRb7pz/cZV3bdqNgIrLnbAFUoQUq
	ijKtiBC0he+wNatfbbjmltz+hV4kM8Ie92IPM=
Received: by 10.216.145.154 with SMTP id p26mr8427375wej.11.1296248151813;
	Fri, 28 Jan 2011 12:55:51 -0800 (PST)
Received: from bigio.localnet
	(host11-92-dynamic.54-82-r.retail.telecomitalia.it [82.54.92.11])
	by mx.google.com with ESMTPS id o19sm9264853wee.26.2011.01.28.12.55.50
	(version=TLSv1/SSLv3 cipher=RC4-MD5);
	Fri, 28 Jan 2011 12:55:50 -0800 (PST)
From: Stefano Lattarini <stefano.lattarini@HIDDEN>
To: 7884 <at> debbugs.gnu.org
Subject: Re: bug#7884: Yacc and FreeBSD make in VPATH builds
Date: Fri, 28 Jan 2011 21:55:39 +0100
User-Agent: KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; )
References: <201101212228.25510.stefano.lattarini@HIDDEN>
In-Reply-To: <201101212228.25510.stefano.lattarini@HIDDEN>
MIME-Version: 1.0
Content-Type: Text/Plain;
  charset="us-ascii"
Content-Transfer-Encoding: 7bit
Message-Id: <201101282155.40138.stefano.lattarini@HIDDEN>
X-Spam-Score: -4.8 (----)
X-Debbugs-Envelope-To: 7884
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -4.4 (----)

Hello automakers.

JFTR: I've found a prior report of this same issue in the automake
mailing list archives, and I think it could be useful to link it
here, for completeness:
 <http://lists.gnu.org/archive/html/automake/2007-11/msg00058.html>

Regards,
  Stefano




Information forwarded to owner <at> debbugs.gnu.org, bug-automake@HIDDEN:
bug#7884; Package automake. Full text available.

Message received at 7884 <at> debbugs.gnu.org:


Received: (at 7884) by debbugs.gnu.org; 28 Jan 2011 12:43:47 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jan 28 07:43:47 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Ping1-0003I0-Qj
	for submit <at> debbugs.gnu.org; Fri, 28 Jan 2011 07:43:47 -0500
Received: from mail-wy0-f172.google.com ([74.125.82.172])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <stefano.lattarini@HIDDEN>) id 1Pinfy-0003Hl-Ho
	for 7884 <at> debbugs.gnu.org; Fri, 28 Jan 2011 07:43:44 -0500
Received: by wyf23 with SMTP id 23so3288901wyf.3
	for <7884 <at> debbugs.gnu.org>; Fri, 28 Jan 2011 04:51:54 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:from:to:subject:date:user-agent:cc:references
	:in-reply-to:mime-version:content-type:message-id;
	bh=3YdL8VSPynI/vi5I7gpNMYeHyLX4ohPHzYeIZQ4QBZE=;
	b=bhmkcJ+A1CTAHHiCG7RfgDo6DWTjjPRQg3Gpc/fRdTKfypldJWG8+eBkh829W3vZo2
	jIOb7Ehn7/LPso2niE3xhEMARF8LYqGvAKMDVgU6jSh+UYi9S8OJqz2PXW66n/ecDmz5
	jWcf/vYFHo8SE77MoIhsR0DXe4zqUpOx4ac0c=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=from:to:subject:date:user-agent:cc:references:in-reply-to
	:mime-version:content-type:message-id;
	b=ZWrhb8jSw0TNts9J4ZpxHNrb38oLz9RVI1SLbD45ZfQLGDoNujGkwS4ZDJWbnF5+lc
	clmaBsMtXxYbZG7xzRhPi99uHiH/h25ITpy3RqdqwjiMUMUHmhG6Dx7DzJTBlM/67aer
	7Izk846FgwwV5THaPkTii8NNu/9dQr6Y/8kXQ=
Received: by 10.227.155.83 with SMTP id r19mr2585428wbw.137.1296219114422;
	Fri, 28 Jan 2011 04:51:54 -0800 (PST)
Received: from bigio.localnet
	(host124-38-dynamic.52-82-r.retail.telecomitalia.it [82.52.38.124])
	by mx.google.com with ESMTPS id u2sm6405509weh.12.2011.01.28.04.51.51
	(version=TLSv1/SSLv3 cipher=RC4-MD5);
	Fri, 28 Jan 2011 04:51:53 -0800 (PST)
From: Stefano Lattarini <stefano.lattarini@HIDDEN>
To: automake-patches@HIDDEN
Subject: Re: [PATCH] yacc: fix VPATH builds with FreeBSD make (was: Re:
	bug#7884: Yacc and FreeBSD make in VPATH builds)
Date: Fri, 28 Jan 2011 13:51:40 +0100
User-Agent: KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; )
References: <201101212228.25510.stefano.lattarini@HIDDEN>
	<201101272026.43640.stefano.lattarini@HIDDEN>
	<201101272115.37504.stefano.lattarini@HIDDEN>
In-Reply-To: <201101272115.37504.stefano.lattarini@HIDDEN>
MIME-Version: 1.0
Content-Type: Multipart/Mixed;
  boundary="Boundary-00=_cvrQNUzJ1crgrMs"
Message-Id: <201101281351.40873.stefano.lattarini@HIDDEN>
X-Spam-Score: -3.8 (---)
X-Debbugs-Envelope-To: 7884
Cc: Ralf Wildenhues <Ralf.Wildenhues@HIDDEN>, 7884 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -3.8 (---)

--Boundary-00=_cvrQNUzJ1crgrMs
Content-Type: Text/Plain;
  charset="us-ascii"
Content-Transfer-Encoding: 7bit

On Thursday 27 January 2011, Ralf Wildenhues wrote:
> Does 'make -n' create files (for any target)?
>
No, and I've updated the `yaccdry.test' testcase to also check for this
(see attached amended patch).

> How do you ensure in your patch that 'make distdir' does not create files?
>
Well, it does, but I don't see any problem with this.  It's perfectly normal
for 'make distdir' to create files in the build directory, no?  And anyway,
this behaviour was pre-existint with FreeBSD make, just in a much worser
form ('yacc' was used to recreate the files, instead of a simple "cp -p").

> How do you ensure in your patch that 'make clean' does not create files?
>
In fact, it does (good catch, BTW); see new testcase in the attached patch.
Yes, this is clearly a wart, but a minor one, and having it is IMHO a price
worth paying in order to have VPATH builds work on FreeBSD.

BTW, if you decide to get rid of said wart in a follow-up patch, that can
probably be done using the FreeBSD make special variable `.TARGETS' (akin
to GNU make's `MAKECMDGOALS').

Thanks,
  Stefano

--Boundary-00=_cvrQNUzJ1crgrMs
Content-Type: text/x-patch;
  charset="us-ascii";
  name="0001-yacc-fix-VPATH-builds-with-FreeBSD-make.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline;
	filename="0001-yacc-fix-VPATH-builds-with-FreeBSD-make.patch"

=46rom e5b393aaf4fe417e8cc8cae8056829f9083cc51c Mon Sep 17 00:00:00 2001
=46rom: Stefano Lattarini <stefano.lattarini@HIDDEN>
Date: Thu, 27 Jan 2011 20:30:56 +0100
Subject: [PATCH] yacc: fix VPATH builds with FreeBSD make

=46ixes automake bug#7884.

* lib/am/yacc.am (.BEGIN): New target, hack to support VPATH
builds with FreeBSD make.
* automake.in (lang_yacc_target_hook): Now update the private
make variable `am__yacc_c_outputs', used by the target above.
* tests/yacc-dist-nobuild.test: Update.
* tests/yaccdry.test: Extend.
* tests/yaccvpath.test: Likewise.
* tests/yacc-d-vpath.test: Likewise.
* tests/yacc-subdir-objects-vpath.test: New test.
* tests/yacc-cond.test: Likewise.
* tests/yacc-cond-minimal.test: New test, still failing with
BSD make.
* tests/yaccdry2.test: Likewise.
* tests/Makefile.am (TESTS): Update.
=2D--
 ChangeLog                            |   19 +++++
 automake.in                          |    7 ++
 lib/am/yacc.am                       |   20 +++++
 tests/Makefile.am                    |    4 +
 tests/Makefile.in                    |    4 +
 tests/yacc-cond-minimal.test         |   81 ++++++++++++++++++++
 tests/yacc-cond.test                 |  122 ++++++++++++++++++++++++++++++
 tests/yacc-d-vpath.test              |   14 ++++
 tests/yacc-dist-nobuild.test         |    7 +-
 tests/yacc-subdir-objects-vpath.test |  137 ++++++++++++++++++++++++++++++=
++++
 tests/yaccdry.test                   |   39 ++++++++++
 tests/yaccdry2.test                  |   77 +++++++++++++++++++
 tests/yaccvpath.test                 |   12 +++
 13 files changed, 540 insertions(+), 3 deletions(-)
 create mode 100755 tests/yacc-cond-minimal.test
 create mode 100755 tests/yacc-cond.test
 create mode 100755 tests/yacc-subdir-objects-vpath.test
 create mode 100755 tests/yaccdry2.test

diff --git a/ChangeLog b/ChangeLog
index 4470c28..da291f3 100644
=2D-- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2011-01-28   Stefano Lattarini  <stefano.lattarini@HIDDEN>
+
+	yacc: fix VPATH builds with FreeBSD make
+	Fixes automake bug#7884.
+	* lib/am/yacc.am (.BEGIN): New target, hack to support VPATH
+	builds with FreeBSD make.
+	* automake.in (lang_yacc_target_hook): Now update the private
+	make variable `am__yacc_c_outputs', used by the target above.
+	* tests/yacc-dist-nobuild.test: Update.
+	* tests/yaccdry.test: Extend.
+	* tests/yaccvpath.test: Likewise.
+	* tests/yacc-d-vpath.test: Likewise.
+	* tests/yacc-subdir-objects-vpath.test: New test.
+	* tests/yacc-cond.test: Likewise.
+	* tests/yacc-cond-minimal.test: New test, still failing with
+	BSD make.
+	* tests/yaccdry2.test: Likewise.
+	* tests/Makefile.am (TESTS): Update.
+
 2011-01-22   Stefano Lattarini  <stefano.lattarini@HIDDEN>
=20
 	configure: look for a yacc program to be used by the testsuite
diff --git a/automake.in b/automake.in
index fa458d6..c72e0bc 100755
=2D-- a/automake.in
+++ b/automake.in
@@ -6082,6 +6082,13 @@ sub lang_yacc_target_hook
 	  }
       }
=20
+    # Required to have FreeBSD make working correctly in VPATH builds.
+    # FIXME: It would be nice to add a yacc-generated C file to
+    # $(am__yacc_c_outputs) only if it's required by the build, e.g.
+    # only if it's not declared in a false conditional ...
+    Automake::Variable::define ('am__yacc_c_outputs', VAR_AUTOMAKE, '+',
+                                TRUE, $output, '', INTERNAL, VAR_PRETTY);
+
     if ($yflags_contains_minus_d)
       {
 	(my $output_base =3D $output) =3D~ s/$KNOWN_EXTENSIONS_PATTERN$//;
diff --git a/lib/am/yacc.am b/lib/am/yacc.am
index 6d35cd4..8de0edc 100644
=2D-- a/lib/am/yacc.am
+++ b/lib/am/yacc.am
@@ -46,3 +46,23 @@ endif %?MAINTAINER-MODE%
 ?!GENERIC??DIST_SOURCE?	$(am__skipyacc) \
 ## For non-suffix rules, we must emulate a VPATH search on %SOURCE%.
 ?!GENERIC?	$(SHELL) $(YLWRAP) `test -f '%SOURCE%' || echo '$(srcdir)/'`%SO=
URCE% y.tab.c %OBJ% y.tab.h %BASE%.h y.output %BASE%.output -- %COMPILE%
+
+## This is releated to automake bug#7884.
+## The automake-generated Makefiles usually distribute the yacc-derived C
+## files, so that the final user won't need a working yacc to build the
+## package.  But for some reason, in a VPATH build, FreeBSD make does not
+## see (or decides not to use) the yacc-derived and distributed C files
+## which are in the source directory, and tries to rebuild them (in the
+## build directory).  This might fail if the user hasn't a yacc program
+## installed, or even if he has one which is uncompatible with that used
+## by the developer.  So we use the following hack to ensure that, with
+## BSD make, the distributed, yacc-generated C sources are copied from
+## the source directory into the build directory, before starting the
+## "real" make operations.
+.BEGIN:
+	@for f in $(am__yacc_c_outputs); do \
+	   if test ! -r $$f && test -f $(srcdir)/$$f; then \
+	     echo " cp -p $(srcdir)/$$f $$f"; \
+	     cp -p $(srcdir)/$$f $$f || exit 1; \
+	   else :; fi; \
+	done;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e639b6c..d0e3e31 100644
=2D-- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -807,8 +807,12 @@ yacc6.test \
 yacc7.test \
 yacc8.test \
 yaccdry.test \
+yaccdry2.test \
+yacc-cond.test \
+yacc-cond-minimal.test \
 yacc-dist-nobuild.test \
 yacc-nodist.test \
+yacc-subdir-objects-vpath.test \
 yaccpp.test \
 yaccvpath.test \
 yacc-d-vpath.test \
diff --git a/tests/Makefile.in b/tests/Makefile.in
index 25fc4a8..7eca925 100644
=2D-- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -1075,8 +1075,12 @@ yacc6.test \
 yacc7.test \
 yacc8.test \
 yaccdry.test \
+yaccdry2.test \
+yacc-cond.test \
+yacc-cond-minimal.test \
 yacc-dist-nobuild.test \
 yacc-nodist.test \
+yacc-subdir-objects-vpath.test \
 yaccpp.test \
 yaccvpath.test \
 yacc-d-vpath.test \
diff --git a/tests/yacc-cond-minimal.test b/tests/yacc-cond-minimal.test
new file mode 100755
index 0000000..2956f01
=2D-- /dev/null
+++ b/tests/yacc-cond-minimal.test
@@ -0,0 +1,81 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that if a yacc-generated C source or header is not needed in the
+# build tree, make won't generate not copy it there.
+
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AM_CONDITIONAL([COND], [:])
+AC_PROG_CC
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS =3D foo bar
+if COND
+foo_SOURCES =3D main.c
+else
+foo_SOURCES =3D parse.y main.c
+endif
+
+bar_SOURCES =3D $(foo_SOURCES)
+bar_YFLAGS =3D -d
+END
+
+cat > main.c << 'END'
+int main () { return 0; }
+END
+
+mkdir bin
+cat > bin/yacc <<'END'
+#!/bin/sh
+echo "$0 invoked, shouldn't happen!" >&2
+exit 1
+END
+cp bin/yacc bin/bison
+chmod a+x bin/yacc bin/bison
+PATH=3D`pwd`/bin$PATH_SEPARATOR$PATH
+
+YACC=3Dyacc BISON=3Dbison
+export YACC BISON
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+mkdir build
+cd build
+../configure
+$MAKE
+test ! -r parse.c
+test ! -r bar-parse.c
+test ! -r bar-parse.h
+$MAKE clean
+$sleep
+: > ../parse.c
+: > ../bar-parse.c
+: > ../bar-parse.h
+$MAKE
+test ! -r parse.c
+test ! -r bar-parse.c
+test ! -r bar-parse.h
+
+:
diff --git a/tests/yacc-cond.test b/tests/yacc-cond.test
new file mode 100755
index 0000000..1ebce92
=2D-- /dev/null
+++ b/tests/yacc-cond.test
@@ -0,0 +1,122 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check interaction of Yacc and conditionals.
+
+required=3Dyacc
+. ./defs || Exit 1
+
+set -e
+
+distdir=3D$me-1.0
+
+cat >> configure.in << 'END'
+AM_CONDITIONAL([COND], [:])
+AC_PROG_CC
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS =3D foobar zardoz
+
+AM_YFLAGS =3D -d
+
+if COND
+foobar_SOURCES =3D parse.y parse.h
+else
+foobar_SOURCES =3D parse.y main.c
+endif
+
+if COND
+zardoz_SOURCES =3D main2.c
+else
+zardoz_SOURCES =3D parse2.y parse2.h main2.c
+endif
+
+.PHONY: test-objs
+test-objs:
+	test -f parse.$(OBJEXT)
+	test ! -r parse2.$(OBJEXT)
+	test -f main2.$(OBJEXT)
+	test ! -r main.$(OBJEXT)
+END
+
+cat > parse2.y << 'END'
+%{
+int yylex () { return 0; }
+void yyerror (char *s) {}
+%}
+%%
+foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
+%%
+END
+
+cat > main.c << 'END'
+int main (void) { return 0; }
+END
+
+cp main.c main2.c
+
+cat parse2.y main.c > parse.y
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE
+ls -l
+test -f parse.c
+test -f parse.h
+test ! -r parse2.c
+test ! -r parse2.h
+$MAKE test-objs
+
+$MAKE distdir
+ls -l $distdir
+test -f $distdir/parse.c
+test -f $distdir/parse.h
+# For all we know, the `parse2.[ch]' generated files might be required by
+# the end user (if he enable the COND conditional), so we must distribute
+# them.
+test -f $distdir/parse2.c
+test -f $distdir/parse2.h
+
+# Now check that yacc is not needed to build from a distribution tarball.
+
+chmod -R a-w $distdir
+
+mkdir bin
+cat > bin/yacc <<'END'
+#!/bin/sh
+echo "$0 invoked, shouldn't happen!" >&2
+exit 1
+END
+cp bin/yacc bin/bison
+chmod a+x bin/yacc bin/bison
+PATH=3D`pwd`/bin$PATH_SEPARATOR$PATH
+
+YACC=3Dyacc BISON=3Dbison
+export YACC BISON
+
+mkdir build
+cd build
+../$distdir/configure
+$MAKE
+$MAKE test-objs
+
+:
diff --git a/tests/yacc-d-vpath.test b/tests/yacc-d-vpath.test
index bb09990..4d2fed8 100755
=2D-- a/tests/yacc-d-vpath.test
+++ b/tests/yacc-d-vpath.test
@@ -109,4 +109,18 @@ $MAKE distdir
 $FGREP maude $distdir/parse.c
 $FGREP MAUDE $distdir/parse.h
=20
+# Now check that `make maintainer-clean' removes all yacc-derived
+# files (if any) created in the builddir.  Try it two times, to
+# be stricter in face of possible `.BEGIN' targets executed by BSD
+# make.
+cp config.status config.sav
+$MAKE maintainer-clean
+test ! -r parse.c
+test ! -r parse.h
+# Recreate Makefile, depfiles, etc.
+mv -f config.sav config.status; ./config.status
+$MAKE maintainer-clean
+test ! -r parse.c
+test ! -r parse.h
+
 :
diff --git a/tests/yacc-dist-nobuild.test b/tests/yacc-dist-nobuild.test
index 9061f57..26f5924 100755
=2D-- a/tests/yacc-dist-nobuild.test
+++ b/tests/yacc-dist-nobuild.test
@@ -79,9 +79,10 @@ cd build
 $MAKE
=20
 # Sanity check.
=2Dchmod u+w ../$distdir
=2Drm -f ../$distdir/parse.c
=2Dchmod a-w ../$distdir
+$sleep
+chmod u+w ../$distdir/parse.y
+echo >>  ../$distdir/parse.y
+chmod a-w ../$distdir/parse.y
 $MAKE >out 2>&1 && { cat out; Exit 1; }
 cat out
 $FGREP parse.c out
diff --git a/tests/yacc-subdir-objects-vpath.test b/tests/yacc-subdir-objec=
ts-vpath.test
new file mode 100755
index 0000000..c427e47
=2D-- /dev/null
+++ b/tests/yacc-subdir-objects-vpath.test
@@ -0,0 +1,137 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Some tests for subdir parsers in VPATH builds.
+# See also test `yacc8.test'.
+
+required=3Dyacc
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS =3D subdir-objects
+bin_PROGRAMS =3D foo/bar baz/qux
+foo_bar_SOURCES =3D foo/parse.y
+baz_qux_SOURCES =3D baz/parse.y baz/main.c baz/parse.h
+AM_YFLAGS =3D -d
+
+.PHONY: test-com test1 test2
+test-com:
+	ls -l . foo $(srcdir) $(srcdir)/foo
+	test ! -r parse.h
+	test ! -r parse.c
+	test ! -r parse.$(OBJEXT)
+	test -f foo/parse.$(OBJEXT)
+	test -f baz/parse.$(OBJEXT)
+test1: test-com
+	test -f foo/parse.c
+	test -f foo/parse.h
+	test -f baz/parse.c
+	test -f baz/parse.h
+test2: test-com
+	test -f $(srcdir)/foo/parse.c
+	test -f $(srcdir)/foo/parse.h
+	test -f $(srcdir)/baz/parse.c
+	test -f $(srcdir)/baz/parse.h
+END
+
+mkdir foo
+cat > foo/parse.y << 'END'
+%{
+int yylex () { return 0; }
+void yyerror (char *s) { return; }
+%}
+%%
+x : 'x' {};
+%%
+int main  (void) { return 0; }
+END
+
+mkdir baz
+cat > baz/parse.y << 'END'
+%{
+int yylex () { return 0; }
+void yyerror (char *s) { return; }
+%}
+%token BAZBAZ
+%%
+x : 'x' {};
+%%
+END
+cat > baz/main.c << 'END'
+#include "baz/parse.h"
+int main (void)
+{
+  return (BAZBAZ);
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+# Try a from-scratch VPATH build.
+mkdir sub1
+cd sub1
+../configure
+$MAKE
+$MAKE test1
+
+# Also, let's see if we can recover from removal of generated header
+# files.
+rm -f foo/parse.h baz/parse.h
+$MAKE foo/parse.h baz/parse.h
+test -f foo/parse.h
+test -f baz/parse.h
+$MAKE clean
+rm -f foo/parse.h baz/parse.h
+$MAKE
+test -f baz/parse.h
+# foo/parse.h is not declares in any *_SOURCES, nor #included by any
+# C file, so that it shouldn't be rebuilt by "make all".
+test ! -r foo/parse.h
+
+cd ..
+
+# Generate yacc-derived files with an in-tree build.
+./configure
+$MAKE foo/parse.c foo/parse.h baz/parse.c baz/parse.h
+$MAKE distclean
+ls -l . foo
+test -f foo/parse.c
+test -f foo/parse.h
+test -f baz/parse.c
+test -f baz/parse.h
+
+# Now try a VPATH build with yacc-generated files already present in
+# the srcdir.
+YACC=3Dfalse BISON=3Dfalse
+export YACC BISON
+mkdir sub2
+cd sub2
+../configure
+$MAKE
+$MAKE test2
+
+:
diff --git a/tests/yaccdry.test b/tests/yaccdry.test
index d30fb80..8eebc67 100755
=2D-- a/tests/yaccdry.test
+++ b/tests/yaccdry.test
@@ -21,6 +21,8 @@ required=3Dyacc
=20
 set -e
=20
+distdir=3D$me-1.0
+
 cat >> configure.in << 'END'
 AC_PROG_CC
 AC_PROG_YACC
@@ -49,12 +51,49 @@ END
 $ACLOCAL
 $AUTOMAKE --add-missing
 $AUTOCONF
+
+# Try an in-tree build first.
+
 ./configure
 $MAKE
=20
 rm -f parse.h
+
+$MAKE -n
+test -f parse.c
+test ! -f parse.h
+
 $MAKE -n parse.h
 test -f parse.c
 test ! -f parse.h
=20
+# Now try VPATH build.
+
+$MAKE distdir
+mkdir build
+cd build
+../$distdir/configure
+
+$MAKE -n
+test ! -f parse.c
+test ! -f parse.h
+
+$MAKE -n parse.h
+test ! -f parse.c
+test ! -f parse.h
+
+rm -f ../$distdir/parse.h
+
+$MAKE -n
+test ! -f parse.c
+test ! -f parse.h
+test ! -f ../$distdir/parse.h
+test -f ../$distdir/parse.c
+
+$MAKE -n parse.h
+test ! -f parse.c
+test ! -f parse.h
+test ! -f ../$distdir/parse.h
+test -f ../$distdir/parse.c
+
 :
diff --git a/tests/yaccdry2.test b/tests/yaccdry2.test
new file mode 100755
index 0000000..22902af
=2D-- /dev/null
+++ b/tests/yaccdry2.test
@@ -0,0 +1,77 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that, in a VPATH build, no yacc-derived C file is created in
+# the build directory by targets like "make clean".
+
+. ./defs || Exit 1
+
+set -e
+
+unset YACC || :
+
+distdir=3D$me-1.0
+
+cat > my-yacc <<'END'
+#!/bin/sh
+echo 'int main () { return 0; }' > y.tab.c
+: > y.tab.h
+END
+chmod a+x my-yacc
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AC_SUBST([YACC], ['$(abs_builddir)/my-yacc'])
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AM_YFLAGS =3D -d
+bin_PROGRAMS =3D foo
+foo_SOURCES =3D parse.y
+END
+
+: > parse.y
+
+$ACLOCAL
+$AUTOMAKE --add-missing
+$AUTOCONF
+
+# From-scratch VPATH build.
+mkdir build-scratch
+cd build-scratch
+../configure
+for target in mostlyclean clean distclean; do
+  $MAKE $target
+  test ! -f parse.c
+  test ! -f parse.h
+done
+
+cd ..
+./configure
+$MAKE distdir
+
+# VPATH build from distributed tarball.
+mkdir build-dist
+cd build-dist
+../$distdir/configure
+for target in mostlyclean clean distclean; do
+  $MAKE $target
+  test ! -f parse.c
+  test ! -f parse.h
+done
+
+:
diff --git a/tests/yaccvpath.test b/tests/yaccvpath.test
index 52092fa..853c5df 100755
=2D-- a/tests/yaccvpath.test
+++ b/tests/yaccvpath.test
@@ -99,4 +99,16 @@ END
 $MAKE distdir
 $FGREP maude $distdir/parse.c
=20
+# Now check that `make maintainer-clean' removes all yacc-derived
+# files (if any) created in the builddir.  Try it two times, to
+# be stricter in face of possible `.BEGIN' targets executed by BSD
+# make.
+cp config.status config.sav
+$MAKE maintainer-clean
+test ! -r parse.c
+# Recreate Makefile, depfiles, etc.
+mv -f config.sav config.status; ./config.status
+$MAKE maintainer-clean
+test ! -r parse.c
+
 :
=2D-=20
1.7.2.3


--Boundary-00=_cvrQNUzJ1crgrMs--




Information forwarded to owner <at> debbugs.gnu.org, bug-automake@HIDDEN:
bug#7884; Package automake. Full text available.

Message received at 7884 <at> debbugs.gnu.org:


Received: (at 7884) by debbugs.gnu.org; 27 Jan 2011 22:30:04 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 27 17:30:04 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1PiaLr-0000Pd-Tk
	for submit <at> debbugs.gnu.org; Thu, 27 Jan 2011 17:30:04 -0500
Received: from mailout-de.gmx.net ([213.165.64.22])
	by debbugs.gnu.org with smtp (Exim 4.69)
	(envelope-from <Ralf.Wildenhues@HIDDEN>) id 1PiaLo-0000Ot-DX
	for 7884 <at> debbugs.gnu.org; Thu, 27 Jan 2011 17:30:01 -0500
Received: (qmail invoked by alias); 27 Jan 2011 22:38:10 -0000
Received: from xdsl-78-34-214-231.netcologne.de (EHLO localhost.localdomain)
	[78.34.214.231]
	by mail.gmx.net (mp006) with SMTP; 27 Jan 2011 23:38:10 +0100
X-Authenticated: #13673931
X-Provags-ID: V01U2FsdGVkX1895608WcM9w6a5HL6JmS3wK7a+v2bDBpwDdX6BTd
	dFXTm/lHpVCqK/
Received: from ralf by localhost.localdomain with local (Exim 4.69)
	(envelope-from <Ralf.Wildenhues@HIDDEN>)
	id 1PiaTh-0001XT-7Q; Thu, 27 Jan 2011 23:38:09 +0100
Date: Thu, 27 Jan 2011 23:38:09 +0100
From: Ralf Wildenhues <Ralf.Wildenhues@HIDDEN>
To: Stefano Lattarini <stefano.lattarini@HIDDEN>
Subject: Re: bug#7884: Yacc and FreeBSD make in VPATH builds
Message-ID: <20110127223808.GA5900@HIDDEN>
References: <201101212228.25510.stefano.lattarini@HIDDEN>
	<201101271154.51301.stefano.lattarini@HIDDEN>
	<20110127183414.GN4929@HIDDEN>
	<201101272026.43640.stefano.lattarini@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <201101272026.43640.stefano.lattarini@HIDDEN>
Organization: Institute for Numerical Simulation, University of Bonn
User-Agent: Mutt/1.5.20 (2010-08-04)
X-Y-GMX-Trusted: 0
X-Spam-Score: -2.8 (--)
X-Debbugs-Envelope-To: 7884
Cc: 7884 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -2.8 (--)

* Stefano Lattarini wrote on Thu, Jan 27, 2011 at 08:26:42PM CET:
> On Thursday 27 January 2011, Ralf Wildenhues wrote:
> > I must admit that I still don't like this a lot.  BSD is free software,
> > we shouldn't have to put ugly workarounds in place for it, and this
> > workaround does have some ugliness to it.
> >
> But IMHO its ugliness pales when confronted with that of other
> VPATH-related workarounds that are currently in automake:
>    `test -f '$<' || echo $(srcdir)`/$<

Sure.  But first off, one ugliness should not hold as excuse for
another, second, we cannot do much about IRIX/Sun make (well, at
least we could not, at the time).

> And moreover, while this last ugliness is imposed to every make
> implementation, even the well-behaved ones, the ugliness introduced
> by my patch only affects the "offending" make implementations
> (here, BSD make).

(FWIW, it's on my table to eliminate the above for GNU make, and
in turn to maybe fix depend2 to use it everywhere for non-GNU, as it
still lacks uses cases.)

> > Here's a radically different idea: get them to fix/improve their make.
> > 
> > What do you think about this?
> >
> That's surely good in the long run and for the future, but it won't help
> with older versions of FreeBSD.
> 
> Also, I'm halfway through an automake patch on the lines I've sketched,
> and I can say that it seems remarkably easy at this point ...

How do you ensure in your patch that 'make clean' does not create files?
Likewise distdir?  Does 'make -n' create files (for any target)?

Thanks,
Ralf




Information forwarded to owner <at> debbugs.gnu.org, bug-automake@HIDDEN:
bug#7884; Package automake. Full text available.

Message received at 7884 <at> debbugs.gnu.org:


Received: (at 7884) by debbugs.gnu.org; 27 Jan 2011 20:07:51 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 27 15:07:51 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1PiY8F-0005iH-25
	for submit <at> debbugs.gnu.org; Thu, 27 Jan 2011 15:07:51 -0500
Received: from mail-ww0-f46.google.com ([74.125.82.46])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <stefano.lattarini@HIDDEN>) id 1PiY8C-0005i0-CA
	for 7884 <at> debbugs.gnu.org; Thu, 27 Jan 2011 15:07:49 -0500
Received: by wwj40 with SMTP id 40so2627846wwj.15
	for <7884 <at> debbugs.gnu.org>; Thu, 27 Jan 2011 12:15:58 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:from:to:subject:date:user-agent:cc:references
	:in-reply-to:mime-version:message-id:content-type;
	bh=h9/BpABRhgKt/EOl3T05GmTJDsdsn2SjeeHc9KlJ9Og=;
	b=ZLe+LCsQrXEc0QsxK8svdt1bt+SW+yIr1P8scm9TgoMLjp/nSvDreF/ut4uCQSsIWa
	fC0ldelydw35VDt5aTOs7PZb+nKXix2flK391m39u7sqIsEBmDjWXEVXzX6Vqzbg3v1k
	IVDBtrjQE35hh/jN0yALMDC0We9GIQ4fig21w=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=from:to:subject:date:user-agent:cc:references:in-reply-to
	:mime-version:message-id:content-type;
	b=oUPL0IAZ73uO1057uf9uoTwvORNUsobUR5N2Cq1zuoSwJkQEQKzgheM4k5dYfACPXe
	Qk9kH6bc/mm67ml9rg+U+4T+IV/NN4noXaOMF87+3sJdn6C6V2+aGWRupLyHgJcR4mj9
	29v3T1hZCK6LQVn3+dNCehhD5VlCZ7Mbk7ALQ=
Received: by 10.227.152.73 with SMTP id f9mr1609539wbw.190.1296159358571;
	Thu, 27 Jan 2011 12:15:58 -0800 (PST)
Received: from bigio.localnet
	(host54-100-dynamic.1-79-r.retail.telecomitalia.it [79.1.100.54])
	by mx.google.com with ESMTPS id y29sm6939050wbd.4.2011.01.27.12.15.56
	(version=TLSv1/SSLv3 cipher=RC4-MD5);
	Thu, 27 Jan 2011 12:15:57 -0800 (PST)
From: Stefano Lattarini <stefano.lattarini@HIDDEN>
To: automake-patches@HIDDEN
Subject: [PATCH] yacc: fix VPATH builds with FreeBSD make (was: Re: bug#7884:
	Yacc and FreeBSD make in VPATH builds)
Date: Thu, 27 Jan 2011 21:15:36 +0100
User-Agent: KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; )
References: <201101212228.25510.stefano.lattarini@HIDDEN>
	<20110127183414.GN4929@HIDDEN>
	<201101272026.43640.stefano.lattarini@HIDDEN>
In-Reply-To: <201101272026.43640.stefano.lattarini@HIDDEN>
MIME-Version: 1.0
Message-Id: <201101272115.37504.stefano.lattarini@HIDDEN>
Content-Type: Multipart/Mixed;
  boundary="Boundary-00=_pJdQNQCiTibfijs"
X-Spam-Score: -4.1 (----)
X-Debbugs-Envelope-To: 7884
Cc: Ralf Wildenhues <Ralf.Wildenhues@HIDDEN>, 7884 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -4.0 (----)

--Boundary-00=_pJdQNQCiTibfijs
Content-Type: text/plain;
  charset="us-ascii"
Content-Transfer-Encoding: 7bit

On Thursday 27 January 2011, Stefano Lattarini wrote:
> Also, I'm halfway through an automake patch on the lines I've sketched,
> and I can say that it seems remarkably easy at this point ...
>
In fact it has been even easier than I thought, after the discovery that
the same 'Automake::Variable::define' call can be used to initialize the
value of a variable as well as to append to it.

The attached patch should fix automake bug#7884 (and now the test
`yacc-dist-nobuild.test' passes also with FreeBSD make).

OK for the 'yacc-work' branch?

Regards,
  Stefano

--Boundary-00=_pJdQNQCiTibfijs
Content-Type: text/x-patch;
  charset="us-ascii";
  name="0001-yacc-fix-VPATH-builds-with-FreeBSD-make.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline;
	filename="0001-yacc-fix-VPATH-builds-with-FreeBSD-make.patch"

=46rom 95e09f4b2b52d0e4ede51e238c2f8fce684fd085 Mon Sep 17 00:00:00 2001
=46rom: Stefano Lattarini <stefano.lattarini@HIDDEN>
Date: Thu, 27 Jan 2011 20:30:56 +0100
Subject: [PATCH] yacc: fix VPATH builds with FreeBSD make

=46ixes automake bug#7884.

* lib/am/yacc.am (.BEGIN): New target, hack to support VPATH
builds with FreeBSD make.
* automake.in (lang_yacc_target_hook): Now update the private
make variable `am__yacc_c_outputs', used by the target above.
* tests/yacc-dist-nobuild.test: Update.
* tests/yacc-subdir-objects-vpath.test: New test.
* tests/yacc-cond.test: Likewise.
* tests/yacc-cond-minimal.test: New test, still failing with
BSD make (but it's not a big deal).
* tests/Makefile.am (TESTS): Update.
=2D--
 ChangeLog                            |   15 ++++
 automake.in                          |    7 ++
 lib/am/yacc.am                       |   20 +++++
 tests/Makefile.am                    |    3 +
 tests/Makefile.in                    |    3 +
 tests/yacc-cond-minimal.test         |   81 ++++++++++++++++++++
 tests/yacc-cond.test                 |  122 ++++++++++++++++++++++++++++++
 tests/yacc-dist-nobuild.test         |    7 +-
 tests/yacc-subdir-objects-vpath.test |  137 ++++++++++++++++++++++++++++++=
++++
 9 files changed, 392 insertions(+), 3 deletions(-)
 create mode 100755 tests/yacc-cond-minimal.test
 create mode 100755 tests/yacc-cond.test
 create mode 100755 tests/yacc-subdir-objects-vpath.test

diff --git a/ChangeLog b/ChangeLog
index 4470c28..93194b3 100644
=2D-- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2011-01-27   Stefano Lattarini  <stefano.lattarini@HIDDEN>
+
+	yacc: fix VPATH builds with FreeBSD make
+	Fixes automake bug#7884.
+	* lib/am/yacc.am (.BEGIN): New target, hack to support VPATH
+	builds with FreeBSD make.
+	* automake.in (lang_yacc_target_hook): Now update the private
+	make variable `am__yacc_c_outputs', used by the target above.
+	* tests/yacc-dist-nobuild.test: Update.
+	* tests/yacc-subdir-objects-vpath.test: New test.
+	* tests/yacc-cond.test: Likewise.
+	* tests/yacc-cond-minimal.test: New test, still failing with
+	BSD make (but it's not a big deal).
+	* tests/Makefile.am (TESTS): Update.
+
 2011-01-22   Stefano Lattarini  <stefano.lattarini@HIDDEN>
=20
 	configure: look for a yacc program to be used by the testsuite
diff --git a/automake.in b/automake.in
index fa458d6..c72e0bc 100755
=2D-- a/automake.in
+++ b/automake.in
@@ -6082,6 +6082,13 @@ sub lang_yacc_target_hook
 	  }
       }
=20
+    # Required to have FreeBSD make working correctly in VPATH builds.
+    # FIXME: It would be nice to add a yacc-generated C file to
+    # $(am__yacc_c_outputs) only if it's required by the build, e.g.
+    # only if it's not declared in a false conditional ...
+    Automake::Variable::define ('am__yacc_c_outputs', VAR_AUTOMAKE, '+',
+                                TRUE, $output, '', INTERNAL, VAR_PRETTY);
+
     if ($yflags_contains_minus_d)
       {
 	(my $output_base =3D $output) =3D~ s/$KNOWN_EXTENSIONS_PATTERN$//;
diff --git a/lib/am/yacc.am b/lib/am/yacc.am
index 6d35cd4..8de0edc 100644
=2D-- a/lib/am/yacc.am
+++ b/lib/am/yacc.am
@@ -46,3 +46,23 @@ endif %?MAINTAINER-MODE%
 ?!GENERIC??DIST_SOURCE?	$(am__skipyacc) \
 ## For non-suffix rules, we must emulate a VPATH search on %SOURCE%.
 ?!GENERIC?	$(SHELL) $(YLWRAP) `test -f '%SOURCE%' || echo '$(srcdir)/'`%SO=
URCE% y.tab.c %OBJ% y.tab.h %BASE%.h y.output %BASE%.output -- %COMPILE%
+
+## This is releated to automake bug#7884.
+## The automake-generated Makefiles usually distribute the yacc-derived C
+## files, so that the final user won't need a working yacc to build the
+## package.  But for some reason, in a VPATH build, FreeBSD make does not
+## see (or decides not to use) the yacc-derived and distributed C files
+## which are in the source directory, and tries to rebuild them (in the
+## build directory).  This might fail if the user hasn't a yacc program
+## installed, or even if he has one which is uncompatible with that used
+## by the developer.  So we use the following hack to ensure that, with
+## BSD make, the distributed, yacc-generated C sources are copied from
+## the source directory into the build directory, before starting the
+## "real" make operations.
+.BEGIN:
+	@for f in $(am__yacc_c_outputs); do \
+	   if test ! -r $$f && test -f $(srcdir)/$$f; then \
+	     echo " cp -p $(srcdir)/$$f $$f"; \
+	     cp -p $(srcdir)/$$f $$f || exit 1; \
+	   else :; fi; \
+	done;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e639b6c..d595c46 100644
=2D-- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -807,8 +807,11 @@ yacc6.test \
 yacc7.test \
 yacc8.test \
 yaccdry.test \
+yacc-cond.test \
+yacc-cond-minimal.test \
 yacc-dist-nobuild.test \
 yacc-nodist.test \
+yacc-subdir-objects-vpath.test \
 yaccpp.test \
 yaccvpath.test \
 yacc-d-vpath.test \
diff --git a/tests/Makefile.in b/tests/Makefile.in
index 25fc4a8..74df65d 100644
=2D-- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -1075,8 +1075,11 @@ yacc6.test \
 yacc7.test \
 yacc8.test \
 yaccdry.test \
+yacc-cond.test \
+yacc-cond-minimal.test \
 yacc-dist-nobuild.test \
 yacc-nodist.test \
+yacc-subdir-objects-vpath.test \
 yaccpp.test \
 yaccvpath.test \
 yacc-d-vpath.test \
diff --git a/tests/yacc-cond-minimal.test b/tests/yacc-cond-minimal.test
new file mode 100755
index 0000000..2956f01
=2D-- /dev/null
+++ b/tests/yacc-cond-minimal.test
@@ -0,0 +1,81 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check that if a yacc-generated C source or header is not needed in the
+# build tree, make won't generate not copy it there.
+
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AM_CONDITIONAL([COND], [:])
+AC_PROG_CC
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS =3D foo bar
+if COND
+foo_SOURCES =3D main.c
+else
+foo_SOURCES =3D parse.y main.c
+endif
+
+bar_SOURCES =3D $(foo_SOURCES)
+bar_YFLAGS =3D -d
+END
+
+cat > main.c << 'END'
+int main () { return 0; }
+END
+
+mkdir bin
+cat > bin/yacc <<'END'
+#!/bin/sh
+echo "$0 invoked, shouldn't happen!" >&2
+exit 1
+END
+cp bin/yacc bin/bison
+chmod a+x bin/yacc bin/bison
+PATH=3D`pwd`/bin$PATH_SEPARATOR$PATH
+
+YACC=3Dyacc BISON=3Dbison
+export YACC BISON
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+mkdir build
+cd build
+../configure
+$MAKE
+test ! -r parse.c
+test ! -r bar-parse.c
+test ! -r bar-parse.h
+$MAKE clean
+$sleep
+: > ../parse.c
+: > ../bar-parse.c
+: > ../bar-parse.h
+$MAKE
+test ! -r parse.c
+test ! -r bar-parse.c
+test ! -r bar-parse.h
+
+:
diff --git a/tests/yacc-cond.test b/tests/yacc-cond.test
new file mode 100755
index 0000000..8c7729b
=2D-- /dev/null
+++ b/tests/yacc-cond.test
@@ -0,0 +1,122 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Check interaction of Yacc (without the `-d' option) and conditionals.
+
+required=3Dyacc
+. ./defs || Exit 1
+
+set -e
+
+distdir=3D$me-1.0
+
+cat >> configure.in << 'END'
+AM_CONDITIONAL([COND], [:])
+AC_PROG_CC
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+bin_PROGRAMS =3D foobar zardoz
+
+AM_YFLAGS =3D -d
+
+if COND
+foobar_SOURCES =3D parse.y parse.h
+else
+foobar_SOURCES =3D parse.y main.c
+endif
+
+if COND
+zardoz_SOURCES =3D main2.c
+else
+zardoz_SOURCES =3D parse2.y parse2.h main2.c
+endif
+
+.PHONY: test-objs
+test-objs:
+	test -f parse.$(OBJEXT)
+	test ! -r parse2.$(OBJEXT)
+	test -f main2.$(OBJEXT)
+	test ! -r main.$(OBJEXT)
+END
+
+cat > parse2.y << 'END'
+%{
+int yylex () { return 0; }
+void yyerror (char *s) {}
+%}
+%%
+foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
+%%
+END
+
+cat > main.c << 'END'
+int main (void) { return 0; }
+END
+
+cp main.c main2.c
+
+cat parse2.y main.c > parse.y
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE
+ls -l
+test -f parse.c
+test -f parse.h
+test ! -r parse2.c
+test ! -r parse2.h
+$MAKE test-objs
+
+$MAKE distdir
+ls -l $distdir
+test -f $distdir/parse.c
+test -f $distdir/parse.h
+# For all we know, the `parse2.[ch]' generated files might be required by
+# the end user (if he enable the COND conditional), so we must distribute
+# them.
+test -f $distdir/parse2.c
+test -f $distdir/parse2.h
+
+# Now check that yacc is not needed to build from a distribution tarball.
+
+chmod -R a-w $distdir
+
+mkdir bin
+cat > bin/yacc <<'END'
+#!/bin/sh
+echo "$0 invoked, shouldn't happen!" >&2
+exit 1
+END
+cp bin/yacc bin/bison
+chmod a+x bin/yacc bin/bison
+PATH=3D`pwd`/bin$PATH_SEPARATOR$PATH
+
+YACC=3Dyacc BISON=3Dbison
+export YACC BISON
+
+mkdir build
+cd build
+../$distdir/configure
+$MAKE
+$MAKE test-objs
+
+:
diff --git a/tests/yacc-dist-nobuild.test b/tests/yacc-dist-nobuild.test
index 9061f57..26f5924 100755
=2D-- a/tests/yacc-dist-nobuild.test
+++ b/tests/yacc-dist-nobuild.test
@@ -79,9 +79,10 @@ cd build
 $MAKE
=20
 # Sanity check.
=2Dchmod u+w ../$distdir
=2Drm -f ../$distdir/parse.c
=2Dchmod a-w ../$distdir
+$sleep
+chmod u+w ../$distdir/parse.y
+echo >>  ../$distdir/parse.y
+chmod a-w ../$distdir/parse.y
 $MAKE >out 2>&1 && { cat out; Exit 1; }
 cat out
 $FGREP parse.c out
diff --git a/tests/yacc-subdir-objects-vpath.test b/tests/yacc-subdir-objec=
ts-vpath.test
new file mode 100755
index 0000000..c427e47
=2D-- /dev/null
+++ b/tests/yacc-subdir-objects-vpath.test
@@ -0,0 +1,137 @@
+#! /bin/sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Some tests for subdir parsers in VPATH builds.
+# See also test `yacc8.test'.
+
+required=3Dyacc
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_YACC
+AC_OUTPUT
+END
+
+cat > Makefile.am << 'END'
+AUTOMAKE_OPTIONS =3D subdir-objects
+bin_PROGRAMS =3D foo/bar baz/qux
+foo_bar_SOURCES =3D foo/parse.y
+baz_qux_SOURCES =3D baz/parse.y baz/main.c baz/parse.h
+AM_YFLAGS =3D -d
+
+.PHONY: test-com test1 test2
+test-com:
+	ls -l . foo $(srcdir) $(srcdir)/foo
+	test ! -r parse.h
+	test ! -r parse.c
+	test ! -r parse.$(OBJEXT)
+	test -f foo/parse.$(OBJEXT)
+	test -f baz/parse.$(OBJEXT)
+test1: test-com
+	test -f foo/parse.c
+	test -f foo/parse.h
+	test -f baz/parse.c
+	test -f baz/parse.h
+test2: test-com
+	test -f $(srcdir)/foo/parse.c
+	test -f $(srcdir)/foo/parse.h
+	test -f $(srcdir)/baz/parse.c
+	test -f $(srcdir)/baz/parse.h
+END
+
+mkdir foo
+cat > foo/parse.y << 'END'
+%{
+int yylex () { return 0; }
+void yyerror (char *s) { return; }
+%}
+%%
+x : 'x' {};
+%%
+int main  (void) { return 0; }
+END
+
+mkdir baz
+cat > baz/parse.y << 'END'
+%{
+int yylex () { return 0; }
+void yyerror (char *s) { return; }
+%}
+%token BAZBAZ
+%%
+x : 'x' {};
+%%
+END
+cat > baz/main.c << 'END'
+#include "baz/parse.h"
+int main (void)
+{
+  return (BAZBAZ);
+}
+END
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+# Try a from-scratch VPATH build.
+mkdir sub1
+cd sub1
+../configure
+$MAKE
+$MAKE test1
+
+# Also, let's see if we can recover from removal of generated header
+# files.
+rm -f foo/parse.h baz/parse.h
+$MAKE foo/parse.h baz/parse.h
+test -f foo/parse.h
+test -f baz/parse.h
+$MAKE clean
+rm -f foo/parse.h baz/parse.h
+$MAKE
+test -f baz/parse.h
+# foo/parse.h is not declares in any *_SOURCES, nor #included by any
+# C file, so that it shouldn't be rebuilt by "make all".
+test ! -r foo/parse.h
+
+cd ..
+
+# Generate yacc-derived files with an in-tree build.
+./configure
+$MAKE foo/parse.c foo/parse.h baz/parse.c baz/parse.h
+$MAKE distclean
+ls -l . foo
+test -f foo/parse.c
+test -f foo/parse.h
+test -f baz/parse.c
+test -f baz/parse.h
+
+# Now try a VPATH build with yacc-generated files already present in
+# the srcdir.
+YACC=3Dfalse BISON=3Dfalse
+export YACC BISON
+mkdir sub2
+cd sub2
+../configure
+$MAKE
+$MAKE test2
+
+:
=2D-=20
1.7.2.3


--Boundary-00=_pJdQNQCiTibfijs--




Information forwarded to owner <at> debbugs.gnu.org, bug-automake@HIDDEN:
bug#7884; Package automake. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 27 Jan 2011 19:19:28 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 27 14:19:28 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1PiXNP-0004cV-O2
	for submit <at> debbugs.gnu.org; Thu, 27 Jan 2011 14:19:27 -0500
Received: from eggs.gnu.org ([140.186.70.92])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <stefano.lattarini@HIDDEN>) id 1PiXNO-0004cJ-26
	for submit <at> debbugs.gnu.org; Thu, 27 Jan 2011 14:19:26 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <stefano.lattarini@HIDDEN>) id 1PiXVH-0008Eo-Gh
	for submit <at> debbugs.gnu.org; Thu, 27 Jan 2011 14:27:36 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM,
	RCVD_IN_DNSWL_LOW, T_DKIM_INVALID,
	T_TO_NO_BRKTS_FREEMAIL autolearn=unavailable version=3.3.1
Received: from lists.gnu.org ([199.232.76.165]:47035)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <stefano.lattarini@HIDDEN>) id 1PiXVF-0008E5-Ko
	for submit <at> debbugs.gnu.org; Thu, 27 Jan 2011 14:27:35 -0500
Received: from [140.186.70.92] (port=38912 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1PiXVC-0002dC-3I
	for bug-automake@HIDDEN; Thu, 27 Jan 2011 14:27:32 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <stefano.lattarini@HIDDEN>) id 1PiXUe-00084n-4R
	for bug-automake@HIDDEN; Thu, 27 Jan 2011 14:26:57 -0500
Received: from mail-ww0-f41.google.com ([74.125.82.41]:58552)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <stefano.lattarini@HIDDEN>) id 1PiXUd-00084J-TB
	for bug-automake@HIDDEN; Thu, 27 Jan 2011 14:26:56 -0500
Received: by wwi18 with SMTP id 18so135657wwi.0
	for <bug-automake@HIDDEN>; Thu, 27 Jan 2011 11:26:55 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:from:to:subject:date:user-agent:cc:references
	:in-reply-to:mime-version:content-type:content-transfer-encoding
	:message-id; bh=+tUe08iudcOJ7Ic67I6mHbu3rOd+JE1Uf3m45AFofYs=;
	b=jLkiY51c8wQ/jlWwdW5IIi9EztlMLxOKoRI0uUC4LwhoftI5i+qZwjkLZF4BAwp3sf
	6nkbDdX5nW7gd6xDdqrfs0LmGylPx8SKVRYxVMkarelw3glTIvP1FG0x8uuv75llUjR5
	zvezAIvtNf1HAFAXun2aG/mdIxbkbcMZIPtms=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=from:to:subject:date:user-agent:cc:references:in-reply-to
	:mime-version:content-type:content-transfer-encoding:message-id;
	b=GWuxzeJRreH/DJ7FIS/+nLPq/tAyBG3mt+Skvb8FhdS9SW9W7KO9Wc/8oSiR4qVcKe
	5GLz2m0jkmDeDJOlJsCyB/zUjrbxqmHm+awTMsADhNgdDcYFK2tPgULoTlO1tEGMfjP0
	C0fWSb6pV7ME9GOo3vkOZ/3sLjsQc0aI14tQ4=
Received: by 10.216.78.146 with SMTP id g18mr2252666wee.1.1296156415090;
	Thu, 27 Jan 2011 11:26:55 -0800 (PST)
Received: from bigio.localnet
	(host54-100-dynamic.1-79-r.retail.telecomitalia.it [79.1.100.54])
	by mx.google.com with ESMTPS id t11sm8583451wes.17.2011.01.27.11.26.52
	(version=TLSv1/SSLv3 cipher=RC4-MD5);
	Thu, 27 Jan 2011 11:26:53 -0800 (PST)
From: Stefano Lattarini <stefano.lattarini@HIDDEN>
To: bug-automake@HIDDEN
Subject: Re: bug#7884: Yacc and FreeBSD make in VPATH builds
Date: Thu, 27 Jan 2011 20:26:42 +0100
User-Agent: KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; )
References: <201101212228.25510.stefano.lattarini@HIDDEN>
	<201101271154.51301.stefano.lattarini@HIDDEN>
	<20110127183414.GN4929@HIDDEN>
In-Reply-To: <20110127183414.GN4929@HIDDEN>
MIME-Version: 1.0
Content-Type: Text/Plain;
  charset="us-ascii"
Content-Transfer-Encoding: 7bit
Message-Id: <201101272026.43640.stefano.lattarini@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 74.125.82.41
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Received-From: 199.232.76.165
X-Spam-Score: -5.0 (-----)
X-Debbugs-Envelope-To: submit
Cc: Ralf Wildenhues <Ralf.Wildenhues@HIDDEN>, 7884 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -5.1 (-----)

On Thursday 27 January 2011, Ralf Wildenhues wrote:
> * Stefano Lattarini wrote on Thu, Jan 27, 2011 at 11:54:50AM CET:
> > On Tuesday 25 January 2011, Ralf Wildenhues wrote:
> > > * Stefano Lattarini wrote on Tue, Jan 25, 2011 at 08:52:56PM CET:
> > > > Hmm... maybe a variation of this might be a good solution after all, at
> > > > least for FreeBSD make: the special `.BEGIN' target[1][2] might be used
> > > > to copy Yacc-derived *.c and *.h files from $(srcdir) to $(builddir),
> > > > unless they are already there.
> > > 
> > > How do you ensure that you don't overwrite newer such files in the build
> > > tree?
> > >
> > Because we won't copy a file `foo.c' from srcdir to builddir if a `foo.c'
> > already exists in builddir -- even if this `foo.c' in builddir is older
> > than the one in the srcdir.  This should be good enough for the intended
> > usages (VPATH builds with FreeBSD make), no?
> 
> Hmm.
> 
> I must admit that I still don't like this a lot.  BSD is free software,
> we shouldn't have to put ugly workarounds in place for it, and this
> workaround does have some ugliness to it.
>
But IMHO its ugliness pales when confronted with that of other
VPATH-related workarounds that are currently in automake:
   `test -f '$<' || echo $(srcdir)`/$<
And moreover, while this last ugliness is imposed to every make
implementation, even the well-behaved ones, the ugliness introduced
by my patch only affects the "offending" make implementations
(here, BSD make).

> Here's a radically different idea: get them to fix/improve their make.
> 
> What do you think about this?
>
That's surely good in the long run and for the future, but it won't help
with older versions of FreeBSD.

Also, I'm halfway through an automake patch on the lines I've sketched,
and I can say that it seems remarkably easy at this point ...

> If you like it, would you be willing to write a PR and/or patch?
>
I might try to write a PR if you don't have time, but I don't feel
qualified to write a patch (nor very motivated either, TBH).  Sorry.

> (I could otherwise try, but I'm not sure I have time for a patch.)
> 
> Thanks,
> Ralf
> 
> 

Regards,
   Stefano




Information forwarded to owner <at> debbugs.gnu.org, bug-automake@HIDDEN:
bug#7884; Package automake. Full text available.

Message received at 7884 <at> debbugs.gnu.org:


Received: (at 7884) by debbugs.gnu.org; 27 Jan 2011 19:18:47 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 27 14:18:47 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1PiXMl-0004bK-E5
	for submit <at> debbugs.gnu.org; Thu, 27 Jan 2011 14:18:47 -0500
Received: from mail-ww0-f42.google.com ([74.125.82.42])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <stefano.lattarini@HIDDEN>) id 1PiXMj-0004b7-4y
	for 7884 <at> debbugs.gnu.org; Thu, 27 Jan 2011 14:18:45 -0500
Received: by wwi17 with SMTP id 17so129300wwi.3
	for <7884 <at> debbugs.gnu.org>; Thu, 27 Jan 2011 11:26:55 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:from:to:subject:date:user-agent:cc:references
	:in-reply-to:mime-version:content-type:content-transfer-encoding
	:message-id; bh=+tUe08iudcOJ7Ic67I6mHbu3rOd+JE1Uf3m45AFofYs=;
	b=jLkiY51c8wQ/jlWwdW5IIi9EztlMLxOKoRI0uUC4LwhoftI5i+qZwjkLZF4BAwp3sf
	6nkbDdX5nW7gd6xDdqrfs0LmGylPx8SKVRYxVMkarelw3glTIvP1FG0x8uuv75llUjR5
	zvezAIvtNf1HAFAXun2aG/mdIxbkbcMZIPtms=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=from:to:subject:date:user-agent:cc:references:in-reply-to
	:mime-version:content-type:content-transfer-encoding:message-id;
	b=GWuxzeJRreH/DJ7FIS/+nLPq/tAyBG3mt+Skvb8FhdS9SW9W7KO9Wc/8oSiR4qVcKe
	5GLz2m0jkmDeDJOlJsCyB/zUjrbxqmHm+awTMsADhNgdDcYFK2tPgULoTlO1tEGMfjP0
	C0fWSb6pV7ME9GOo3vkOZ/3sLjsQc0aI14tQ4=
Received: by 10.216.78.146 with SMTP id g18mr2252666wee.1.1296156415090;
	Thu, 27 Jan 2011 11:26:55 -0800 (PST)
Received: from bigio.localnet
	(host54-100-dynamic.1-79-r.retail.telecomitalia.it [79.1.100.54])
	by mx.google.com with ESMTPS id t11sm8583451wes.17.2011.01.27.11.26.52
	(version=TLSv1/SSLv3 cipher=RC4-MD5);
	Thu, 27 Jan 2011 11:26:53 -0800 (PST)
From: Stefano Lattarini <stefano.lattarini@HIDDEN>
To: bug-automake@HIDDEN
Subject: Re: bug#7884: Yacc and FreeBSD make in VPATH builds
Date: Thu, 27 Jan 2011 20:26:42 +0100
User-Agent: KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; )
References: <201101212228.25510.stefano.lattarini@HIDDEN>
	<201101271154.51301.stefano.lattarini@HIDDEN>
	<20110127183414.GN4929@HIDDEN>
In-Reply-To: <20110127183414.GN4929@HIDDEN>
MIME-Version: 1.0
Content-Type: Text/Plain;
  charset="us-ascii"
Content-Transfer-Encoding: 7bit
Message-Id: <201101272026.43640.stefano.lattarini@HIDDEN>
X-Spam-Score: -3.9 (---)
X-Debbugs-Envelope-To: 7884
Cc: Ralf Wildenhues <Ralf.Wildenhues@HIDDEN>, 7884 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -3.9 (---)

On Thursday 27 January 2011, Ralf Wildenhues wrote:
> * Stefano Lattarini wrote on Thu, Jan 27, 2011 at 11:54:50AM CET:
> > On Tuesday 25 January 2011, Ralf Wildenhues wrote:
> > > * Stefano Lattarini wrote on Tue, Jan 25, 2011 at 08:52:56PM CET:
> > > > Hmm... maybe a variation of this might be a good solution after all, at
> > > > least for FreeBSD make: the special `.BEGIN' target[1][2] might be used
> > > > to copy Yacc-derived *.c and *.h files from $(srcdir) to $(builddir),
> > > > unless they are already there.
> > > 
> > > How do you ensure that you don't overwrite newer such files in the build
> > > tree?
> > >
> > Because we won't copy a file `foo.c' from srcdir to builddir if a `foo.c'
> > already exists in builddir -- even if this `foo.c' in builddir is older
> > than the one in the srcdir.  This should be good enough for the intended
> > usages (VPATH builds with FreeBSD make), no?
> 
> Hmm.
> 
> I must admit that I still don't like this a lot.  BSD is free software,
> we shouldn't have to put ugly workarounds in place for it, and this
> workaround does have some ugliness to it.
>
But IMHO its ugliness pales when confronted with that of other
VPATH-related workarounds that are currently in automake:
   `test -f '$<' || echo $(srcdir)`/$<
And moreover, while this last ugliness is imposed to every make
implementation, even the well-behaved ones, the ugliness introduced
by my patch only affects the "offending" make implementations
(here, BSD make).

> Here's a radically different idea: get them to fix/improve their make.
> 
> What do you think about this?
>
That's surely good in the long run and for the future, but it won't help
with older versions of FreeBSD.

Also, I'm halfway through an automake patch on the lines I've sketched,
and I can say that it seems remarkably easy at this point ...

> If you like it, would you be willing to write a PR and/or patch?
>
I might try to write a PR if you don't have time, but I don't feel
qualified to write a patch (nor very motivated either, TBH).  Sorry.

> (I could otherwise try, but I'm not sure I have time for a patch.)
> 
> Thanks,
> Ralf
> 
> 

Regards,
   Stefano




Information forwarded to owner <at> debbugs.gnu.org, bug-automake@HIDDEN:
bug#7884; Package automake. Full text available.

Message received at 7884 <at> debbugs.gnu.org:


Received: (at 7884) by debbugs.gnu.org; 27 Jan 2011 18:26:09 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 27 13:26:09 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1PiWXp-0003TY-G1
	for submit <at> debbugs.gnu.org; Thu, 27 Jan 2011 13:26:09 -0500
Received: from mailout-de.gmx.net ([213.165.64.22])
	by debbugs.gnu.org with smtp (Exim 4.69)
	(envelope-from <Ralf.Wildenhues@HIDDEN>) id 1PiWXm-0003T4-8d
	for 7884 <at> debbugs.gnu.org; Thu, 27 Jan 2011 13:26:07 -0500
Received: (qmail invoked by alias); 27 Jan 2011 18:34:15 -0000
Received: from xdsl-89-0-159-122.netcologne.de (EHLO localhost.localdomain)
	[89.0.159.122]
	by mail.gmx.net (mp058) with SMTP; 27 Jan 2011 19:34:15 +0100
X-Authenticated: #13673931
X-Provags-ID: V01U2FsdGVkX18aI1cA8sMaLzxy2E6F/4+hkFYNZnKyRY3gRG4vzW
	KHouI0x/fAEmgO
Received: from ralf by localhost.localdomain with local (Exim 4.69)
	(envelope-from <Ralf.Wildenhues@HIDDEN>)
	id 1PiWfe-0001MV-Aj; Thu, 27 Jan 2011 19:34:14 +0100
Date: Thu, 27 Jan 2011 19:34:14 +0100
From: Ralf Wildenhues <Ralf.Wildenhues@HIDDEN>
To: Stefano Lattarini <stefano.lattarini@HIDDEN>
Subject: Re: bug#7884: Yacc and FreeBSD make in VPATH builds
Message-ID: <20110127183414.GN4929@HIDDEN>
References: <201101212228.25510.stefano.lattarini@HIDDEN>
	<201101252052.57678.stefano.lattarini@HIDDEN>
	<20110125200517.GE29244@HIDDEN>
	<201101271154.51301.stefano.lattarini@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <201101271154.51301.stefano.lattarini@HIDDEN>
Organization: Institute for Numerical Simulation, University of Bonn
User-Agent: Mutt/1.5.20 (2010-08-04)
X-Y-GMX-Trusted: 0
X-Spam-Score: -2.8 (--)
X-Debbugs-Envelope-To: 7884
Cc: 7884 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -2.8 (--)

* Stefano Lattarini wrote on Thu, Jan 27, 2011 at 11:54:50AM CET:
> On Tuesday 25 January 2011, Ralf Wildenhues wrote:
> > * Stefano Lattarini wrote on Tue, Jan 25, 2011 at 08:52:56PM CET:
> > > Hmm... maybe a variation of this might be a good solution after all, at
> > > least for FreeBSD make: the special `.BEGIN' target[1][2] might be used
> > > to copy Yacc-derived *.c and *.h files from $(srcdir) to $(builddir),
> > > unless they are already there.
> > 
> > How do you ensure that you don't overwrite newer such files in the build
> > tree?
> >
> Because we won't copy a file `foo.c' from srcdir to builddir if a `foo.c'
> already exists in builddir -- even if this `foo.c' in builddir is older
> than the one in the srcdir.  This should be good enough for the intended
> usages (VPATH builds with FreeBSD make), no?

Hmm.

I must admit that I still don't like this a lot.  BSD is free software,
we shouldn't have to put ugly workarounds in place for it, and this
workaround does have some ugliness to it.  Here's a radically different
idea: get them to fix/improve their make.

What do you think about this?
If you like it, would you be willing to write a PR and/or patch?
(I could otherwise try, but I'm not sure I have time for a patch.)

Thanks,
Ralf




Information forwarded to owner <at> debbugs.gnu.org, bug-automake@HIDDEN:
bug#7884; Package automake. Full text available.

Message received at 7884 <at> debbugs.gnu.org:


Received: (at 7884) by debbugs.gnu.org; 27 Jan 2011 10:46:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Jan 27 05:46:56 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1PiPNQ-00013a-GD
	for submit <at> debbugs.gnu.org; Thu, 27 Jan 2011 05:46:56 -0500
Received: from mail-wy0-f172.google.com ([74.125.82.172])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <stefano.lattarini@HIDDEN>) id 1PiPNP-00013N-0k
	for 7884 <at> debbugs.gnu.org; Thu, 27 Jan 2011 05:46:55 -0500
Received: by wyf23 with SMTP id 23so1993026wyf.3
	for <7884 <at> debbugs.gnu.org>; Thu, 27 Jan 2011 02:55:04 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:from:to:subject:date:user-agent:cc:references
	:in-reply-to:mime-version:content-type:message-id;
	bh=r1HHYR9zdarjFFN7nAb3AAwweVbiAQgboRcXpmmqvrE=;
	b=sC620lJ2gIaeD5ejM0Be0xH6EgLDgf/Hvqw82wkk7dHkeLWjXiarO5mpI2wLiueGzP
	nOPN1oGknIpbJ/g6t0PBq4Xg72P3bbSARDaCUyc3ovS/fBg4LTxZHfz92sfuAdjyqPib
	YsrCHLawdOMvFW4CjxMaSVQZiZkSQ72J2DBLE=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=from:to:subject:date:user-agent:cc:references:in-reply-to
	:mime-version:content-type:message-id;
	b=k85CMUKVT1RSy8iO476c+8ewRtGjaYFBnU3c04Ke1VV5wRxzy5bbMWjrS//VJWkLEb
	RysCVreUY3SwYhnfJQIT41igAIgFfgai0YNWOBQWukLLTW0oiEJvzDp9eA8cElAy9ck1
	h2FkYWgCHmo4oOeiRaPHfNr+LDFASvlIyNFko=
Received: by 10.227.134.206 with SMTP id k14mr886020wbt.5.1296125703968;
	Thu, 27 Jan 2011 02:55:03 -0800 (PST)
Received: from bigio.localnet
	(host215-13-dynamic.52-82-r.retail.telecomitalia.it [82.52.13.215])
	by mx.google.com with ESMTPS id f35sm11710884wbf.2.2011.01.27.02.55.02
	(version=TLSv1/SSLv3 cipher=RC4-MD5);
	Thu, 27 Jan 2011 02:55:02 -0800 (PST)
From: Stefano Lattarini <stefano.lattarini@HIDDEN>
To: Ralf Wildenhues <Ralf.Wildenhues@HIDDEN>
Subject: Re: bug#7884: Yacc and FreeBSD make in VPATH builds
Date: Thu, 27 Jan 2011 11:54:50 +0100
User-Agent: KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; )
References: <201101212228.25510.stefano.lattarini@HIDDEN>
	<201101252052.57678.stefano.lattarini@HIDDEN>
	<20110125200517.GE29244@HIDDEN>
In-Reply-To: <20110125200517.GE29244@HIDDEN>
MIME-Version: 1.0
Content-Type: Multipart/Mixed;
  boundary="Boundary-00=_77UQNvR8rkg/bOh"
Message-Id: <201101271154.51301.stefano.lattarini@HIDDEN>
X-Spam-Score: -3.8 (---)
X-Debbugs-Envelope-To: 7884
Cc: 7884 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -3.8 (---)

--Boundary-00=_77UQNvR8rkg/bOh
Content-Type: Text/Plain;
  charset="us-ascii"
Content-Transfer-Encoding: 7bit

On Tuesday 25 January 2011, Ralf Wildenhues wrote:
> * Stefano Lattarini wrote on Tue, Jan 25, 2011 at 08:52:56PM CET:
> > On Saturday 22 January 2011, Ralf Wildenhues wrote:
> > > 
> > > >  - Tell the developer to add proper AC_CONFIG_LINKS to configure in
> > > >    order to support VPATH builds with FreeBSD make (yuck^2, since
> > > >    that means keeping track of renamed files when object-specific
> > > >    flags are involved).
> > > >
> > Hmm... maybe a variation of this might be a good solution after all, at
> > least for FreeBSD make: the special `.BEGIN' target[1][2] might be used
> > to copy Yacc-derived *.c and *.h files from $(srcdir) to $(builddir),
> > unless they are already there.
> 
> How do you ensure that you don't overwrite newer such files in the build
> tree?
>
Because we won't copy a file `foo.c' from srcdir to builddir if a `foo.c'
already exists in builddir -- even if this `foo.c' in builddir is older
than the one in the srcdir.  This should be good enough for the intended
usages (VPATH builds with FreeBSD make), no?

> Please note that 'test' and 'ls' might not have the same time
> stamp reading granularity that 'make' might have.  Well, at least in
> general, this might be less of a problem on FreeBSD specifically.
>
I don't plan to do any by-hand timestamp checking.

> Anyway, the above sounds a lot like a hack with possible traps, I'm not
> sure I like going that way.
>
But the good thing about this hack is that it's (at least, should be)
triggered only with BSD make, for which VPATH builds involving Yacc
files are already broken.

> > Note that the 'distcleancheck' target would still fail with this change,
> > but that's more of an annoyance rather than a serious bug (like the one
> > under discussion is IMHO).  And we could try to fix that later.
> 
> Well, regressions are generally worse than bugs.
>
Yes, but this wouldn't be a regression, since currently the 'distcleancheck'
target is already broken in VPATH builds with FreeBSD make.

> Generally, whatever solution you would like to propose, I would suggest
> that you could first try to create in a simple Makefile the rules as you
> think automake should produce them;
>
Good advice; and in fact, I've played this way with the testcase
`yacc-dist-nobuild.test' before advancing my proposal, to avoid losing
my time and yours.  See attachement.  It works with GNU make, Heirloom
make, FreeBSD make and NetBSD make.

> then we have something to digest
> (and possibly throw away) without having to invest a lot of work in a
> proper automake implementation.  It is often possible to rule out
> strategies quickly at such an early stage.
>
I heartily agree.

> Thanks,
> Ralf
> 

Thanks,
  Stefano

--Boundary-00=_77UQNvR8rkg/bOh
Content-Type: application/x-shellscript;
  name="yacc-freebsd-make-vpath-experiment.test"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
	filename="yacc-freebsd-make-vpath-experiment.test"

#! /bin/sh
# Copyright (C) 2011 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Check that distributed Yacc-generated parsers are not uselessly
# remade from an unpacked distributed tarball.

required=yacc
. ./defs || Exit 1

set -e

distdir=$me-1.0

cat >> configure.in << 'END'
AC_PROG_CC
AC_PROG_YACC
AC_OUTPUT
END

cat > Makefile.am << 'END'
bin_PROGRAMS = foobar zardoz
foobar_SOURCES = parse.y main.c
zardoz_SOURCES = $(foobar_SOURCES)
zardoz_YFLAGS = -d
BUILT_SOURCES = zardoz-parse.h

## This definition should be generated by the automake script, which
## knows the name of the yacc-generated C files.
am__yacc_c_outputs = zardoz-parse.c parse.c

## This should go in am/yacc.am.
.BEGIN:
	for f in $(am__yacc_c_outputs); do \
	   if test ! -r $$f && test -f $(srcdir)/$$f; then \
	     cp -p $(srcdir)/$$f ./$$f || exit 1; \
	   else :; fi; \
	done;
END

cat > parse.y << 'END'
%{
int yylex () { return 0; }
void yyerror (char *s) {}
%}
%%
foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
END

cat > main.c << 'END'
int main () { return 0; }
END

$ACLOCAL
$AUTOCONF
$AUTOMAKE -a

./configure
$MAKE

$MAKE distdir
chmod -R a-w $distdir

mkdir bin
cat > bin/yacc <<'END'
#!/bin/sh
echo "$0 invoked, shouldn't happen!" >&2
exit 1
END
cp bin/yacc bin/bison
chmod a+x bin/yacc bin/bison
PATH=`pwd`/bin$PATH_SEPARATOR$PATH

YACC=yacc BISON=bison
export YACC BISON

mkdir build
cd build
../$distdir/configure
$MAKE

# Sanity check.
$sleep
chmod u+w ../$distdir/parse.y
echo >>  ../$distdir/parse.y
chmod a-w ../$distdir/parse.y
$MAKE >out 2>&1 && { cat out; Exit 1; }
cat out
$FGREP parse.c out

:

--Boundary-00=_77UQNvR8rkg/bOh--




Information forwarded to owner <at> debbugs.gnu.org, bug-automake@HIDDEN:
bug#7884; Package automake. Full text available.

Message received at 7884 <at> debbugs.gnu.org:


Received: (at 7884) by debbugs.gnu.org; 25 Jan 2011 19:57:24 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jan 25 14:57:23 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Php10-0003xT-V0
	for submit <at> debbugs.gnu.org; Tue, 25 Jan 2011 14:57:23 -0500
Received: from mailout-de.gmx.net ([213.165.64.23])
	by debbugs.gnu.org with smtp (Exim 4.69)
	(envelope-from <Ralf.Wildenhues@HIDDEN>) id 1Php0t-0003xB-73
	for 7884 <at> debbugs.gnu.org; Tue, 25 Jan 2011 14:57:21 -0500
Received: (qmail invoked by alias); 25 Jan 2011 20:05:19 -0000
Received: from xdsl-78-34-215-228.netcologne.de (EHLO localhost.localdomain)
	[78.34.215.228]
	by mail.gmx.net (mp063) with SMTP; 25 Jan 2011 21:05:19 +0100
X-Authenticated: #13673931
X-Provags-ID: V01U2FsdGVkX1890mx9Kjw9IoLMY+G8ZwKA0d9EM+bPTawMUcgVko
	knKEo5171kbBJP
Received: from ralf by localhost.localdomain with local (Exim 4.69)
	(envelope-from <Ralf.Wildenhues@HIDDEN>)
	id 1Php8f-0008Ex-WC; Tue, 25 Jan 2011 21:05:18 +0100
Date: Tue, 25 Jan 2011 21:05:17 +0100
From: Ralf Wildenhues <Ralf.Wildenhues@HIDDEN>
To: Stefano Lattarini <stefano.lattarini@HIDDEN>
Subject: Re: bug#7884: Yacc and FreeBSD make in VPATH builds
Message-ID: <20110125200517.GE29244@HIDDEN>
References: <201101212228.25510.stefano.lattarini@HIDDEN>
	<20110122091115.GD31878@HIDDEN>
	<201101252052.57678.stefano.lattarini@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <201101252052.57678.stefano.lattarini@HIDDEN>
Organization: Institute for Numerical Simulation, University of Bonn
User-Agent: Mutt/1.5.20 (2010-08-04)
X-Y-GMX-Trusted: 0
X-Spam-Score: -2.8 (--)
X-Debbugs-Envelope-To: 7884
Cc: 7884 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -2.8 (--)

* Stefano Lattarini wrote on Tue, Jan 25, 2011 at 08:52:56PM CET:
> On Saturday 22 January 2011, Ralf Wildenhues wrote:
> > 
> > >  - Tell the developer to add proper AC_CONFIG_LINKS to configure in
> > >    order to support VPATH builds with FreeBSD make (yuck^2, since
> > >    that means keeping track of renamed files when object-specific
> > >    flags are involved).
> > >
> Hmm... maybe a variation of this might be a good solution after all, at
> least for FreeBSD make: the special `.BEGIN' target[1][2] might be used
> to copy Yacc-derived *.c and *.h files from $(srcdir) to $(builddir),
> unless they are already there.

How do you ensure that you don't overwrite newer such files in the build
tree?  Please note that 'test' and 'ls' might not have the same time
stamp reading granularity that 'make' might have.  Well, at least in
general, this might be less of a problem on FreeBSD specifically.

Anyway, the above sounds a lot like a hack with possible traps, I'm not
sure I like going that way.

> Note that the 'distcleancheck' target would still fail with this change,
> but that's more of an annoyance rather than a serious bug (like the one
> under discussion is IMHO).  And we could try to fix that later.

Well, regressions are generally worse than bugs.

Generally, whatever solution you would like to propose, I would suggest
that you could first try to create in a simple Makefile the rules as you
think automake should produce them; then we have something to digest
(and possibly throw away) without having to invest a lot of work in a
proper automake implementation.  It is often possible to rule out
strategies quickly at such an early stage.

Thanks,
Ralf




Information forwarded to owner <at> debbugs.gnu.org, bug-automake@HIDDEN:
bug#7884; Package automake. Full text available.

Message received at 7884 <at> debbugs.gnu.org:


Received: (at 7884) by debbugs.gnu.org; 25 Jan 2011 19:45:27 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jan 25 14:45:26 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1PhopS-0003gl-Kr
	for submit <at> debbugs.gnu.org; Tue, 25 Jan 2011 14:45:26 -0500
Received: from mail-wy0-f172.google.com ([74.125.82.172])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <stefano.lattarini@HIDDEN>) id 1PhopQ-0003gY-KD
	for 7884 <at> debbugs.gnu.org; Tue, 25 Jan 2011 14:45:25 -0500
Received: by wyf23 with SMTP id 23so179300wyf.3
	for <7884 <at> debbugs.gnu.org>; Tue, 25 Jan 2011 11:53:29 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:from:to:subject:date:user-agent:cc:references
	:in-reply-to:mime-version:content-type:content-transfer-encoding
	:message-id; bh=Q0PSYWyq3FTC+bk4vbar9Q7Dl9bmD8UK6mf/lFRVqRo=;
	b=ToSy4QbXsuEisWQdwSyroYYsX9zPKrhDIBl+wyH32boxeIZ9Y+lDf2BRMlcuRRykiq
	4cHVATsleuPt8k8ruT2qt8NMgJHnS8zTC9TRQqOwiWwK7uw3Nt9EmSDFP5arTbIZWREI
	lwujQyEKrWHuox95R9NpBdFDVk28FXu80uHXA=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=from:to:subject:date:user-agent:cc:references:in-reply-to
	:mime-version:content-type:content-transfer-encoding:message-id;
	b=R1Q0j4E1jZgEwejRcvI5z0iybLeKPDik4ki8bnk2rRIjYQQo0yRgWm1RFZSNqMyvAp
	lkJslCkIzLt2xQ2zP3XK6iCTnRizdGBGJsZBfoPmBVsrEMbdWWRYzlS//qRxhNtVk81g
	T+2mAv5AiEs4LhTqgRm4g4CJjcWVWnKmV9TTI=
Received: by 10.216.63.132 with SMTP id a4mr310389wed.3.1295985208502;
	Tue, 25 Jan 2011 11:53:28 -0800 (PST)
Received: from bigio.localnet
	(host156-97-dynamic.30-79-r.retail.telecomitalia.it [79.30.97.156])
	by mx.google.com with ESMTPS id n18sm7354370wee.16.2011.01.25.11.53.26
	(version=TLSv1/SSLv3 cipher=RC4-MD5);
	Tue, 25 Jan 2011 11:53:27 -0800 (PST)
From: Stefano Lattarini <stefano.lattarini@HIDDEN>
To: Ralf Wildenhues <Ralf.Wildenhues@HIDDEN>
Subject: Re: bug#7884: Yacc and FreeBSD make in VPATH builds
Date: Tue, 25 Jan 2011 20:52:56 +0100
User-Agent: KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; )
References: <201101212228.25510.stefano.lattarini@HIDDEN>
	<20110122091115.GD31878@HIDDEN>
In-Reply-To: <20110122091115.GD31878@HIDDEN>
MIME-Version: 1.0
Content-Type: Text/Plain;
  charset="us-ascii"
Content-Transfer-Encoding: 7bit
Message-Id: <201101252052.57678.stefano.lattarini@HIDDEN>
X-Spam-Score: -3.6 (---)
X-Debbugs-Envelope-To: 7884
Cc: 7884 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -3.6 (---)

Hello automakers.

A small update on this ...

On Saturday 22 January 2011, Ralf Wildenhues wrote:
> * Stefano Lattarini wrote on Fri, Jan 21, 2011 at 10:28:24PM CET:
> >  - Always create yacc-derived and distributed .c and .h files in
> >    $(srcdir), and explicitly instruct make to alwsys look fr them
> >    there at first -- similarly to what is done for info files
> >    (yuck)
> 
> Yes, this is ugly, but it is a way that can be made to work.
> One complication is that, for portable semantics, if a file is
> ever mentioned as $(srcdir)/file as a prerequisite, then it also
> needs to be listed that way as a target.  (I think; it might've
> been the other way round.)
> 
> Downside of this is that now builds fail to work as expected when
> there are newer versions of the files in the build tree.  GNU make
> users would likely complain.
>
Yes... and they would be right IMO.  To be honest, if I were just an
automake user, I'd complain myself about such a behaviour.  So IMVHO
this is not a viable solution, after all.

> Still, this could be viable as optional behavior.
> 
> >  - Tell the developer to add proper AC_CONFIG_LINKS to configure in
> >    order to support VPATH builds with FreeBSD make (yuck^2, since
> >    that means keeping track of renamed files when object-specific
> >    flags are involved).
> >
Hmm... maybe a variation of this might be a good solution after all, at
least for FreeBSD make: the special `.BEGIN' target[1][2] might be used
to copy Yacc-derived *.c and *.h files from $(srcdir) to $(builddir),
unless they are already there.

 [1] See <http://www.freebsd.org/cgi/man.cgi?query=make> for more info.
 [2] This variable doesn't seem to cause problems with GNU make, Solaris
     XPG4/CCS make, Solaris dmake, not Heirloom make.

Note that the 'distcleancheck' target would still fail with this change,
but that's more of an annoyance rather than a serious bug (like the one
under discussion is IMHO).  And we could try to fix that later.

> >  - Make the `parse.c' and `parse.h' rules look for same named files
> >    in $(srcdir) during a VPATH build, and copy them in $(builddir)
> >    if they're neweer than `parse.y'.  But then how can distclean be
> >    made to work in evey situation?
> 
> I doubt that these two options can be made to work sanely.  A
>   file: $(srcdir)/file
> 
> doesn't work with GNU make, for example: it will rightfully complain
> about a circular dependency.
> 
> >  - Tell that FreeBSD make is not supported in VPATH builds (not
> >    really a solution, I admit).
> 
> Why not?  VPATH is not specified by Posix, and there is a reason for
> that: behavior is just too variable and different between makes.  This
> means that only some setups work well, others don't.
> 
> I'm concerned mostly with users downloading stuff: they should be able
> to build source packages.  If VPATH doesn't work, that is not a big
> problem because they can still use an in-tree build.  It doesn't make
> the package unusable for them.
> 
Anyway, I think this bug woul be worth fixing, if that can be done
without too much fuss.

> The actual complication, as far as I can see, comes from the fact that
> I want VPATH builds to work for the packages I'm interested in.  ;-)
> 
:-)

Regards,
  Stefano




Information forwarded to owner <at> debbugs.gnu.org, bug-automake@HIDDEN:
bug#7884; Package automake. Full text available.

Message received at 7884 <at> debbugs.gnu.org:


Received: (at 7884) by debbugs.gnu.org; 22 Jan 2011 09:03:25 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jan 22 04:03:25 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1PgZNU-0001bO-Sm
	for submit <at> debbugs.gnu.org; Sat, 22 Jan 2011 04:03:25 -0500
Received: from mailout-de.gmx.net ([213.165.64.22])
	by debbugs.gnu.org with smtp (Exim 4.69)
	(envelope-from <Ralf.Wildenhues@HIDDEN>) id 1PgZNR-0001b8-NL
	for 7884 <at> debbugs.gnu.org; Sat, 22 Jan 2011 04:03:22 -0500
Received: (qmail invoked by alias); 22 Jan 2011 09:11:15 -0000
Received: from xdsl-89-0-146-100.netcologne.de (EHLO localhost.localdomain)
	[89.0.146.100]
	by mail.gmx.net (mp060) with SMTP; 22 Jan 2011 10:11:15 +0100
X-Authenticated: #13673931
X-Provags-ID: V01U2FsdGVkX19HypMu7ipHimmXqmdUNNADq9IZAeC6Jr6AyE0v8u
	eBNSl6zWymuUAS
Received: from ralf by localhost.localdomain with local (Exim 4.69)
	(envelope-from <Ralf.Wildenhues@HIDDEN>)
	id 1PgZV5-0000B7-AG; Sat, 22 Jan 2011 10:11:15 +0100
Date: Sat, 22 Jan 2011 10:11:15 +0100
From: Ralf Wildenhues <Ralf.Wildenhues@HIDDEN>
To: Stefano Lattarini <stefano.lattarini@HIDDEN>
Subject: Re: bug#7884: Yacc and FreeBSD make in VPATH builds
Message-ID: <20110122091115.GD31878@HIDDEN>
References: <201101212228.25510.stefano.lattarini@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <201101212228.25510.stefano.lattarini@HIDDEN>
Organization: Institute for Numerical Simulation, University of Bonn
User-Agent: Mutt/1.5.20 (2010-08-04)
X-Y-GMX-Trusted: 0
X-Spam-Score: -2.8 (--)
X-Debbugs-Envelope-To: 7884
Cc: 7884 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -2.8 (--)

* Stefano Lattarini wrote on Fri, Jan 21, 2011 at 10:28:24PM CET:
>  - Always create yacc-derived and distributed .c and .h files in
>    $(srcdir), and explicitly instruct make to alwsys look fr them
>    there at first -- similarly to what is done for info files
>    (yuck)

Yes, this is ugly, but it is a way that can be made to work.
One complication is that, for portable semantics, if a file is
ever mentioned as $(srcdir)/file as a prerequisite, then it also
needs to be listed that way as a target.  (I think; it might've
been the other way round.)

Downside of this is that now builds fail to work as expected when
there are newer versions of the files in the build tree.  GNU make
users would likely complain.

Still, this could be viable as optional behavior.

>  - Tell the developer to add proper AC_CONFIG_LINKS to configure in
>    order to support VPATH builds with FreeBSD make (yuck^2, since
>    that means keeping track of renamed files when object-specific
>    flags are involved).
> 
>  - Make the `parse.c' and `parse.h' rules look for same named files
>    in $(srcdir) during a VPATH build, and copy them in $(builddir)
>    if they're neweer than `parse.y'.  But then how can distclean be
>    made to work in evey situation?

I doubt that these two options can be made to work sanely.  A
  file: $(srcdir)/file

doesn't work with GNU make, for example: it will rightfully complain
about a circular dependency.

>  - Tell that FreeBSD make is not supported in VPATH builds (not
>    really a solution, I admit).

Why not?  VPATH is not specified by Posix, and there is a reason for
that: behavior is just too variable and different between makes.  This
means that only some setups work well, others don't.

I'm concerned mostly with users downloading stuff: they should be able
to build source packages.  If VPATH doesn't work, that is not a big
problem because they can still use an in-tree build.  It doesn't make
the package unusable for them.

The actual complication, as far as I can see, comes from the fact that
I want VPATH builds to work for the packages I'm interested in.  ;-)

Cheers,
Ralf




Information forwarded to owner <at> debbugs.gnu.org, bug-automake@HIDDEN:
bug#7884; Package automake. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 21 Jan 2011 21:20:54 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Jan 21 16:20:54 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1PgOPd-0003Zz-Sk
	for submit <at> debbugs.gnu.org; Fri, 21 Jan 2011 16:20:54 -0500
Received: from eggs.gnu.org ([140.186.70.92])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <stefano.lattarini@HIDDEN>) id 1PgOPb-0003Zo-0Q
	for submit <at> debbugs.gnu.org; Fri, 21 Jan 2011 16:20:51 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <stefano.lattarini@HIDDEN>) id 1PgOXE-0003Fc-Ui
	for submit <at> debbugs.gnu.org; Fri, 21 Jan 2011 16:28:46 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM,
	RCVD_IN_DNSWL_LOW, T_DKIM_INVALID,
	T_TO_NO_BRKTS_FREEMAIL autolearn=unavailable version=3.3.1
Received: from lists.gnu.org ([199.232.76.165]:36430)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <stefano.lattarini@HIDDEN>) id 1PgOXE-0003FT-Rf
	for submit <at> debbugs.gnu.org; Fri, 21 Jan 2011 16:28:44 -0500
Received: from [140.186.70.92] (port=59104 helo=eggs.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1PgOXD-0005zR-Pj
	for bug-automake@HIDDEN; Fri, 21 Jan 2011 16:28:44 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <stefano.lattarini@HIDDEN>) id 1PgOXB-0003ES-H2
	for bug-automake@HIDDEN; Fri, 21 Jan 2011 16:28:43 -0500
Received: from mail-wy0-f169.google.com ([74.125.82.169]:35363)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <stefano.lattarini@HIDDEN>) id 1PgOXB-0003E1-A1
	for bug-automake@HIDDEN; Fri, 21 Jan 2011 16:28:41 -0500
Received: by wyj26 with SMTP id 26so2470809wyj.0
	for <bug-automake@HIDDEN>; Fri, 21 Jan 2011 13:28:40 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:from:subject:date:user-agent:mime-version:to
	:content-type:message-id;
	bh=d3wq/nMPTbqSCQ1DZoxbHTdhG1dU6DRV5I7cAlF/VLE=;
	b=GcerjXjTey2uzA4/PQ+O13TI19+0N6rEsu82alE2O7RSFg4Z2K+j0xdtutC1iF4o9o
	yUMzdhr7nAxWV95+o/7Ogd1Lab8IfArLgf00QH9vOpyMKvvsmeLNhGvKb5Fr6Gsl1Rt5
	A5WhSAxMhjm/nosndc4DlJnH1Hv6S6u2T3YDM=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=from:subject:date:user-agent:mime-version:to:content-type
	:message-id;
	b=U26hlh6hHD2TbzZJwdKSST1QMOtD6keTgrl7UpAr9xK3gYdIH63uxHHdESNCWbC0IC
	EZO5dLAA8GyofcTKoaaHwTUn+G4FvTUnhCSNIVSQXXFbftY2G1JYSqkGVDLEuwzqGve1
	Oj1vCkD/CkoXw7eh4Li4KSzal5MyYsNdCGFH8=
Received: by 10.227.152.71 with SMTP id f7mr1405188wbw.144.1295645319559;
	Fri, 21 Jan 2011 13:28:39 -0800 (PST)
Received: from bigio.localnet
	(host162-166-dynamic.50-82-r.retail.telecomitalia.it [82.50.166.162])
	by mx.google.com with ESMTPS id q18sm7211389wbe.11.2011.01.21.13.28.37
	(version=TLSv1/SSLv3 cipher=RC4-MD5);
	Fri, 21 Jan 2011 13:28:38 -0800 (PST)
From: Stefano Lattarini <stefano.lattarini@HIDDEN>
Subject: Yacc and FreeBSD make in VPATH builds
Date: Fri, 21 Jan 2011 22:28:24 +0100
User-Agent: KMail/1.13.3 (Linux/2.6.30-2-686; KDE/4.4.4; i686; ; )
MIME-Version: 1.0
To: bug-automake@HIDDEN
Content-Type: Multipart/Mixed;
  boundary="Boundary-00=_5pfONGliVqxJzY6"
Message-Id: <201101212228.25510.stefano.lattarini@HIDDEN>
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-Spam-Score: -5.3 (-----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -5.4 (-----)

--Boundary-00=_5pfONGliVqxJzY6
Content-Type: Text/Plain;
  charset="us-ascii"
Content-Transfer-Encoding: 7bit

Hello automakers.

What I'm going to illustrate here is a long-standing bug in automake;
but since I don't see it described in the manual, nor reported in the
GNATS database, making it explicitly registered here in Debbugs won't
hurt IMHO.

-*-*-

Here is a description of the bug.

 1) The package developer declares a Yacc-generated program in the
    Makefile.am:
      bin_PROGRAMS = calc
      cacl_SOURCES = calc.y

 2) From that input, automake can generate rules to create *and distribute*
    the Yacc-derived C file `calc.c'.  This C file is distributed so that
    the user won't need to have a yacc program installed in order to build
    the package.

 3) The user has GNU bison installed on his developement machine, and also
    wants to take advantage of bison-specific features.  So he decides to
    just require GNU bison, knowing that such a decision shouldn't affect
    the end users --  the `calc.c' file will be shipped in the distribution
    tarball, so that those users won't need bison in order to rebuild it.

 4) The developer completes the program, and uses "make dist" to build
    the distribution tarball; a proper, up-to-date copy of the generated
    `calc.c' file will be bundled there.

 4) A FreeBSD user, which doesn't have bison installed, but which has the
    standard BSD yacc available in his PATH, fetch the tarball, and
    attempts a VPATH build of the package:
      $ tar xzvf calc-1.0.tar.gz
      $ cd calc-1.0
      $ mkdir build && cd build
      $ ../configure
      ...
      $ make  # this is FreeBSD make
   
 5) For some reason, FreeBSD make does not see, or decides not to use,
    the `calc.c' file in VPATH (here, `..'), and tries to rebuild it
    in thecurrent directory, obviously using FreeBSD yacc.  Oops.
   
I used to think that this bug was due to the fact that FreeBSD make
never performs a VPATH search for a dependency that has an explicit
rule, as reported also in the autoconf manual, see:
 <http://www.gnu.org/software/autoconf/manual/html_node/Make-Target-Lookup.html>

But digging some more, I realized that the bug is present even when
only suffix rues are involved :-(  (see the minmal testcase attached).

-*-*-

The already-committed (to master) testcase `yacc-dist-nobuild.test'
should provide coverage for the bug.

-*-*-

Proposals for a fix (Note: none of these solutions has been really
attempted by me in practice, and none of them seems particularly
appealing, either):

 - Always create yacc-derived and distributed .c and .h files in
   $(srcdir), and explicitly instruct make to alwsys look fr them
   there at first -- similarly to what is done for info files
   (yuck)

 - Tell the developer to add proper AC_CONFIG_LINKS to configure in
   order to support VPATH builds with FreeBSD make (yuck^2, since
   that means keeping track of renamed files when object-specific
   flags are involved).

 - Make the `parse.c' and `parse.h' rules look for same named files
   in $(srcdir) during a VPATH build, and copy them in $(builddir)
   if they're neweer than `parse.y'.  But then how can distclean be
   made to work in evey situation?

 - Tell that FreeBSD make is not supported in VPATH builds (not
   really a solution, I admit).

-*-*-

Regards,
   Stefano

--Boundary-00=_5pfONGliVqxJzY6
Content-Type: application/x-shellscript;
  name="foo.test"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
	filename="foo.test"

#! /bin/sh

required=yacc
. ./defs || Exit 1

set -e

distdir=$me-1.0

cat >> configure.in << 'END'
AC_PROG_CC
AC_PROG_YACC
AC_OUTPUT
END

cat > Makefile.am << 'END'
bin_PROGRAMS = foobar
foobar_SOURCES = parse.y main.c
END

cat > parse.y << 'END'
%{
int yylex () { return 0; }
void yyerror (char *s) {}
%}
%%
foobar : 'f' 'o' 'o' 'b' 'a' 'r' {};
END

cat > main.c << 'END'
int main () { return 0; }
END

$ACLOCAL
$AUTOCONF
$AUTOMAKE -a

./configure
$MAKE

$MAKE distdir
chmod -R a-w $distdir

mkdir bin
cat > bin/yacc <<'END'
#!/bin/sh
echo "$0 invoked, shouldn't happen!" >&2
exit 1
END
cp bin/yacc bin/bison
chmod a+x bin/yacc bin/bison
PATH=`pwd`/bin$PATH_SEPARATOR$PATH

YACC=yacc BISON=bison
export YACC BISON

mkdir build
cd build
../$distdir/configure
$MAKE

:

--Boundary-00=_5pfONGliVqxJzY6--




Acknowledgement sent to Stefano Lattarini <stefano.lattarini@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-automake@HIDDEN. Full text available.
Report forwarded to owner <at> debbugs.gnu.org, bug-automake@HIDDEN:
bug#7884; Package automake. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 31 Oct 2014 17:00:04 UTC

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