Subject: bug#7884: Yacc and FreeBSD make in VPATH builds

From: Stefano Lattarini <[email-masked]>
Date: Thu, 27 Jan 2011 11:54:50 +0100

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