Subject: bug#12540: Usage of srcdir when valac is generating a header file

From: Nick Bowler <[email-masked]>
Date: Mon, 1 Oct 2012 09:41:21 -0400

On 2012-09-29 19:32 +0200, Vivien Malerba wrote:
> I'm working on the Libgda project, which includes Vala source code. I use
> the Autotools to generate the Makefiles and I've noticed that during the
> conversion of vala code to C an H code a .stamp file is generated (from
> what I understand, that timestamped file is then a dependency for all the
> Vala files' conversion). The Automake's code to make that happen is:
> foreach my $vala_file (@vala_sources)
[...]
> You can see that the .stamp file is generated in the $(srcdir) directory
> instead of $(builddir), which breaks the rule when building out of sources.
> My suggestion is to replace $(srcdir) with $(builddir) (this timestamp file
> is also a build dependency for each vala file, so there is more code
> impacted than the snippet above).

Disclaimer: I have never used Vala.

I think these generated files are intended to be included in the
distribution.  Automake takes the approach of putting generated and
distributed files in srcdir.  The reason for this is that things can
get really hairy when generated files are built in builddir, essentially
because of the following scenario (for the following, we will say that
foo.h is distributed and generated from foo.vala):

 (1) user unpacks tarball, foo.h is unpacked to srcdir.
 (2) user does a VPATH build of the package.
 (3) user edits foo.vala, causing the foo.h in srcdir to be out of date.
 (4) user does an incremental VPATH build of the package, generating
     foo.h in the builddir.

Now, we have an environment with an up-to-date version of foo.h in the
builddir and an out-of-date foo.h in the srcdir.  This is not per se a
problem, but it is very tricky to get right and a bunch of Automake's
built-in behaviours (such as its automatic dependency tracking for C
programs) get it wrong.

This particular problem can be avoided by putting such generated files
in the srcdir, so that distributed versions get overwritten.  This is
the approach taken by Automake.

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