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

From: Vivien Malerba <[email-masked]>
Date: Sat, 29 Sep 2012 19:32:11 +0200

Hi!

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)
    {
      my $c_file = $vala_file;
      if ($c_file =~ s/(.*)\.vala$/$1.c/)
        {
          $c_file = "\$(srcdir)/$c_file";
          $output_rules .= "$c_file: \$(srcdir)/${derived}_vala.stamp\n"
            . "\t\@if test -f \$@; then :; else rm -f
\$(srcdir)/${derived}_vala.stamp; fi\n"
            . "\t\@if test -f \$@; then :; else \\\n"
            . "\t  \$(MAKE) \$(AM_MAKEFLAGS)
\$(srcdir)/${derived}_vala.stamp; \\\n"
            . "\tfi\n";
          $clean_files{$c_file} = MAINTAINER_CLEAN;
        }
    }

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).

Best regards,

Vivien