Re: [PATCH 1/3] Vala: Fix build when using per-target VALAFLAGS

2009-05-17 Thread Jürg Billeter
Hi Ralf,

On Sun, 2009-05-17 at 09:41 +0200, Ralf Wildenhues wrote:
 * Jürg Billeter wrote on Fri, May 15, 2009 at 03:50:55PM CEST:
  This does not yet implement full per-target support for VALAFLAGS,
  however, this change at least fixes building when there is only one
  target per source file, which is the most common situation.
 
 When testing vala5.test with this, you get several rules including
 commands for baz.c in src/Makefile.  This will cause failures for
 non-GNU make, and thus needs to be fixed.
 
 Also, this change now would make
   bin_PROGRAMS = foo bar
   foo_SOURCES = foo.vala
   bar_SOURCES = foo.vala
   bar_VALAFLAGS = -D bar
 
 a possibly silently broken build, IIUC.  That deserves at least a
 comment in the manual; see the suggestion below.  I haven't thought
 about a consistency check in automake.in; fixing the issue would be
 effort spent better.

Yes, at least a comment in the manual certainly makes sense.

 Please note that I'm really close to finishing 1.11, and considering
 to postpone this change unless there is an easy way out.

I expect per-target VALAFLAGS to be relatively common as VALAFLAGS will
be used for all libraries. While using the same Vala source file in
multiple targets might be useful in some occasions, I'd expect it to be
less used than per-target VALAFLAGS. In my opinion, the Vala support in
automake 1.11 would be a lot more useful with the patchset applied.

Unfortunately, I don't have an idea right now how to easily guard
against the issue in automake.in except maybe using something like a
global array of processed .vala source files.

Thanks,
Jürg





[PATCH 2/3] Vala: Add and test rebuild rules for generated header and vapi files

2009-05-15 Thread Jürg Billeter
valac will generate additional files when using, for example, -H in
VALAFLAGS. We need to recognize these options and add appropriate
rebuild rules to fix parallel build.

Signed-off-by: Jürg Billeter j...@bitron.ch
---
 automake.in  |   26 ++
 tests/vala2.test |6 ++
 2 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/automake.in b/automake.in
index be52505..a2b735f 100755
--- a/automake.in
+++ b/automake.in
@@ -5951,6 +5951,32 @@ sub lang_vala_finish_target ($$)
 }
 }
 
+  # Add rebuild rules for generated header and vapi files
+  my $flags = var ($derived . '_VALAFLAGS');
+  if ($flags)
+{
+  my $lastflag = '';
+  foreach my $flag ($flags-value_as_list_recursive)
+   {
+ if (grep (/$lastflag/, ('-H', '-h', '--header', '--internal-header',
+ '--vapi', '--internal-vapi', '--gir')))
+   {
+ my $headerfile = $flag;
+ $output_rules .= $headerfile: ${derived}_vala.stamp\n.
+   \...@if test -f \$@; then :; else \\\n.
+   \t  rm -f ${derived}_vala.stamp; \\\n.
+   \t  \$(MAKE) \$(AM_MAKEFLAGS) ${derived}_vala.stamp; \\\n.
+   \tfi\n;
+
+ # valac is not used when building from dist tarballs
+ # distribute the generated files
+ push_dist_common ($headerfile);
+ $clean_files{$headerfile} = MAINTAINER_CLEAN;
+   }
+ $lastflag = $flag;
+   }
+}
+
   my $compile = $self-compile;
 
   # Rewrite each occurrence of `AM_VALAFLAGS' in the compile
diff --git a/tests/vala2.test b/tests/vala2.test
index a6efba9..bfa38cd 100755
--- a/tests/vala2.test
+++ b/tests/vala2.test
@@ -44,6 +44,7 @@ END
 
 cat  'src/Makefile.am' 'END'
 bin_PROGRAMS = zardoz
+zardoz_VALAFLAGS = -H zardoz.h
 zardoz_CFLAGS = $(GOBJECT_CFLAGS)
 zardoz_LDADD = $(GOBJECT_LIBS)
 zardoz_SOURCES = zardoz.vala
@@ -67,6 +68,11 @@ $AUTOMAKE -a
 
 ./configure || Exit 77
 $MAKE
+
+# test rebuild rules
+rm src/zardoz.h
+$MAKE -C src zardoz.h
+
 $MAKE distcheck
 $MAKE distclean
 mkdir build
-- 
1.6.3






[PATCH 1/3] Vala: Fix build when using per-target VALAFLAGS

2009-05-15 Thread Jürg Billeter
This does not yet implement full per-target support for VALAFLAGS,
however, this change at least fixes building when there is only one
target per source file, which is the most common situation.

Signed-off-by: Jürg Billeter j...@bitron.ch
---
 automake.in   |   19 ++-
 tests/Makefile.am |3 +--
 tests/Makefile.in |3 +--
 3 files changed, 12 insertions(+), 13 deletions(-)

diff --git a/automake.in b/automake.in
index 20ef3bd..be52505 100755
--- a/automake.in
+++ b/automake.in
@@ -815,7 +815,7 @@ register_language ('name' = 'header',
 register_language ('name' = 'vala',
   'Name' = 'Vala',
   'config_vars' = ['VALAC'],
-  'flags' = ['VALAFLAGS'],
+  'flags' = [],
   'compile' = '$(VALAC) $(AM_VALAFLAGS) $(VALAFLAGS)',
   'ccer' = 'VALAC',
   'compiler' = 'VALACOMPILE',
@@ -5953,14 +5953,15 @@ sub lang_vala_finish_target ($$)
 
   my $compile = $self-compile;
 
-  # Rewrite each occurrence of `AM_$flag' in the compile
-  # rule into `${derived}_$flag' if it exists.
-  for my $flag (@{$self-flags})
-{
-  my $val = ${derived}_$flag;
-  $compile =~ s/\(AM_$flag\)/\($val\)/
-if set_seen ($val);
-}
+  # Rewrite each occurrence of `AM_VALAFLAGS' in the compile
+  # rule into `${derived}_VALAFLAGS' if it exists.
+  my $val = ${derived}_VALAFLAGS;
+  $compile =~ s/\(AM_VALAFLAGS\)/\($val\)/
+if set_seen ($val);
+
+  # VALAFLAGS is a user variable (per GNU Standards),
+  # it should not be overridden in the Makefile...
+  check_user_variables ['VALAFLAGS'];
 
   my $dirname = dirname ($name);
 
diff --git a/tests/Makefile.am b/tests/Makefile.am
index afcfda8..d700608 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -4,8 +4,7 @@ XFAIL_TESTS =   \
 all.test   \
 auxdir2.test   \
 cond17.test\
-txinfo5.test   \
-vala5.test
+txinfo5.test
 
 include $(srcdir)/parallel-tests.am
 
diff --git a/tests/Makefile.in b/tests/Makefile.in
index ce8e779..bc77d23 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -229,8 +229,7 @@ XFAIL_TESTS = \
 all.test   \
 auxdir2.test   \
 cond17.test\
-txinfo5.test   \
-vala5.test
+txinfo5.test
 
 parallel_tests = \
 check-p.test \
-- 
1.6.3






[PATCH 3/3] Vala: Use $(srcdir) in rebuild rules

2009-05-15 Thread Jürg Billeter
valac is always run in srcdir as the generated files are distributed.
So srcdir needs to be taken into account in the rebuild rules to not
wrongly trigger a rebuild in the wrong directory.

Signed-off-by: Jürg Billeter j...@bitron.ch
---
 automake.in  |   12 ++--
 tests/vala2.test |4 
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/automake.in b/automake.in
index a2b735f..13dd79b 100755
--- a/automake.in
+++ b/automake.in
@@ -5942,10 +5942,10 @@ sub lang_vala_finish_target ($$)
 {
   foreach my $file ($var-value_as_list_recursive)
 {
-  $output_rules .= $file: ${derived}_vala.stamp\n.
+  $output_rules .= \$(srcdir)/$file: 
\$(srcdir)/${derived}_vala.stamp\n.
 \...@if test -f \$@; then :; else \\\n.
-\t  rm -f ${derived}_vala.stamp; \\\n.
-\t  \$(MAKE) \$(AM_MAKEFLAGS) ${derived}_vala.stamp; \\\n.
+\t  rm -f \$(srcdir)/${derived}_vala.stamp; \\\n.
+\t  cd \$(srcdir)  \$(MAKE) \$(AM_MAKEFLAGS) 
${derived}_vala.stamp; \\\n.
 \tfi\n
 if $file =~ s/(.*)\.vala$/$1.c/;
 }
@@ -5962,10 +5962,10 @@ sub lang_vala_finish_target ($$)
  '--vapi', '--internal-vapi', '--gir')))
{
  my $headerfile = $flag;
- $output_rules .= $headerfile: ${derived}_vala.stamp\n.
+ $output_rules .= \$(srcdir)/$headerfile: 
\$(srcdir)/${derived}_vala.stamp\n.
\...@if test -f \$@; then :; else \\\n.
-   \t  rm -f ${derived}_vala.stamp; \\\n.
-   \t  \$(MAKE) \$(AM_MAKEFLAGS) ${derived}_vala.stamp; \\\n.
+   \t  rm -f \$(srcdir)/${derived}_vala.stamp; \\\n.
+   \t  cd \$(srcdir)  \$(MAKE) \$(AM_MAKEFLAGS) 
${derived}_vala.stamp; \\\n.
\tfi\n;
 
  # valac is not used when building from dist tarballs
diff --git a/tests/vala2.test b/tests/vala2.test
index bfa38cd..d9dcfc5 100755
--- a/tests/vala2.test
+++ b/tests/vala2.test
@@ -81,3 +81,7 @@ cd build
 $MAKE
 $MAKE distcheck
 
+# test rebuild rules from builddir
+touch ../src/zardoz.vala
+$MAKE
+
-- 
1.6.3






Re: [PATCH 3/3] Vala: Use $(srcdir) in rebuild rules

2009-05-15 Thread Jürg Billeter
Hi Ralf,

On Sat, 2009-05-09 at 19:51 +0200, Ralf Wildenhues wrote:
 Hi Jürg,
 
 * Jürg Billeter wrote on Sat, May 09, 2009 at 03:09:03PM CEST:
  valac is always run in srcdir as the generated files are distributed.
  So srcdir needs to be taken into account in the rebuild rules to not
  wrongly trigger a rebuild in the wrong directory.
 
 Can you add (or amend current) test cases for patch 2 and 3, or indicate
 how I could write them otherwise?  Generally, we should try to test each
 bug that we fix, to ensure we consistently get better.  Also, it would
 give me more confidence when improving things later.

I've just resent the patch set to the mailing list. I've amended
vala2.test for patch 2 and 3 and made sure that the new test fails
without the patches and succeeds with the patches.

Regards,
Jürg





[PATCH 2/3] Vala: Add rebuild rules for generated header and vapi files

2009-05-09 Thread Jürg Billeter
valac will generate additional files when using, for example, -H in
VALAFLAGS. We need to recognize these options and add appropriate
rebuild rules to fix parallel build.

Signed-off-by: Jürg Billeter j...@bitron.ch
---
 automake.in |   26 ++
 1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/automake.in b/automake.in
index be52505..08a0ed1 100755
--- a/automake.in
+++ b/automake.in
@@ -5951,6 +5951,32 @@ sub lang_vala_finish_target ($$)
 }
 }
 
+  # Add rebuild rules for generated header and vapi files
+  my $flags = var ($derived . '_VALAFLAGS');
+  if ($flags)
+{
+  my $lastflag = '';
+  foreach my $flag ($flags-value_as_list_recursive)
+   {
+ if (grep (/$lastflag/, ('-H', '-h', '--header', '--internal-header',
+ '--vapi')))
+   {
+ my $headerfile = $flag;
+ $output_rules .= $headerfile: ${derived}_vala.stamp\n.
+   \...@if test -f \$@; then :; else \\\n.
+   \t  rm -f ${derived}_vala.stamp; \\\n.
+   \t  \$(MAKE) \$(AM_MAKEFLAGS) ${derived}_vala.stamp; \\\n.
+   \tfi\n;
+
+ # valac is not used when building from dist tarballs
+ # distribute the generated files
+ push_dist_common ($headerfile);
+ $clean_files{$headerfile} = MAINTAINER_CLEAN;
+   }
+ $lastflag = $flag;
+   }
+}
+
   my $compile = $self-compile;
 
   # Rewrite each occurrence of `AM_VALAFLAGS' in the compile
-- 
1.6.3






Re: Vala support for automake

2009-04-16 Thread Jürg Billeter
Hi Ralf,

On Thu, 2009-04-16 at 20:49 +0200, Ralf Wildenhues wrote:
 * Jürg Billeter wrote on Wed, Apr 15, 2009 at 08:56:44PM CEST:
  On Wed, 2009-04-15 at 20:42 +0200, Ralf Wildenhues wrote:
   or even
 valac -C b.vala
 valac -C e.vala
  
  This would not work, valac requires all Vala source files of the same
  program / library on the same commandline. The reason is that the source
  files can depend on each other, but there is no header/include
  mechanism.
 
 Hmm.  What if I do something like this:
 
 bin_PROGRAMS = foo
 foo_SOURCES = foo1.vala foo2.vala
 foo_LDADD = libbar.a
 noinst_LIBRARIES = libbar.a
 libbar_a_SOURCES = bar1.vala bar2.vala
 
 How would valac cope with the necessarily separate invocations for
 foo*.vala and bar*.vala?  And what happens if you try to put vala
 code into shared libraries, and use them from other vala code?

In this case you instruct valac to generate a bar.vapi and a bar.h file
and use those files in the program by specifying

libbar_a_VALAFLAGS = --library bar -H bar.h
foo_VALAFLAGS = bar.vapi

A .vapi file contains declarations for Vala libraries, similar to a .h
file for C libraries.

Thanks,
Jürg








Vala support for automake

2009-03-31 Thread Jürg Billeter
I've updated the Vala support patches initially written by Mathias
Hasselmann to fix a few issues and to conform to the reworked header
file generation in Vala 0.7. It appears to work well with a simple test
project including correct distcheck and maintainer-clean functionality.
I didn't get around yet to test it with larger projects, but I'm not
aware of outstanding issues in the patch.

The Vala support is intended to be used with the upcoming Vala 0.7
release series (git master) and all later versions. Earlier versions may
work with some limitations (e.g., only recursive make). Vala 0.7.0 is
expected to be released this week.

Regards,
Jürg
From e98d9faf34fbb9ab2e719c22beb968e386d06425 Mon Sep 17 00:00:00 2001
From: =?utf-8?q?J=C3=BCrg=20Billeter?= j...@bitron.ch
Date: Tue, 31 Mar 2009 10:08:24 +0200
Subject: [PATCH] Initial support for the Vala programming language.

* automake.in: Add %known_libraries, lang_vala_rewrite,
lang_vala_finish and lang_vala_target_hook to support the Vala
programming language. Register Vala language hooks.
* doc/automake.texi, NEWS: Document Vala support.
* lib/am/vala.am: Empty rules file to prevent creation of depend2
based rules for Vala code.
* lib/am/Makefile.am (dist_am_DATA): Add vala.am.
* m4/vala.m4: Provide AM_PROG_VALAC for detecting the Vala compiler.
* m4/Makefile.am (dist_m4data_DATA): Add vala.m4.
* tests/vala.test: Test Vala support.
* tests/vala1.test: Test .c file generation.
* tests/vala2.test: Test recursive make.
* tests/vala3.test: Test non-recursive make.
* tests/vala4.test: Test AM_PROG_VALAC.
* tests/Makefile.am: Update.
Based on patch by Mathias Hasselmann.
---
 ChangeLog  |   20 ++
 NEWS   |2 +
 automake.in|   99 +++-
 doc/automake.texi  |   52 +++
 lib/am/Makefile.am |1 +
 lib/am/Makefile.in |1 +
 lib/am/vala.am |   17 +
 m4/Makefile.am |3 +-
 m4/Makefile.in |3 +-
 m4/vala.m4 |   29 +++
 tests/Makefile.am  |5 +++
 tests/Makefile.in  |5 +++
 tests/vala.test|   59 +++
 tests/vala1.test   |   58 ++
 tests/vala2.test   |   70 
 tests/vala3.test   |   64 +
 tests/vala4.test   |   61 
 17 files changed, 546 insertions(+), 3 deletions(-)
 create mode 100644 lib/am/vala.am
 create mode 100644 m4/vala.m4
 create mode 100755 tests/vala.test
 create mode 100755 tests/vala1.test
 create mode 100755 tests/vala2.test
 create mode 100755 tests/vala3.test
 create mode 100755 tests/vala4.test

diff --git a/ChangeLog b/ChangeLog
index 3e08fe6..cadf637 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2009-03-31  Jürg Billeter  j...@bitron.ch
+
+	Initial support for the Vala programming language.
+	* automake.in: Add %known_libraries, lang_vala_rewrite,
+	lang_vala_finish and lang_vala_target_hook to support the Vala
+	programming language. Register Vala language hooks.
+	* doc/automake.texi, NEWS: Document Vala support.
+	* lib/am/vala.am: Empty rules file to prevent creation of depend2
+	based rules for Vala code.
+	* lib/am/Makefile.am (dist_am_DATA): Add vala.am.
+	* m4/vala.m4: Provide AM_PROG_VALAC for detecting the Vala compiler.
+	* m4/Makefile.am (dist_m4data_DATA): Add vala.m4.
+	* tests/vala.test: Test Vala support.
+	* tests/vala1.test: Test .c file generation.
+	* tests/vala2.test: Test recursive make.
+	* tests/vala3.test: Test non-recursive make.
+	* tests/vala4.test: Test AM_PROG_VALAC.
+	* tests/Makefile.am: Update.
+	Based on patch by Mathias Hasselmann.
+
 2009-03-29  Ralf Wildenhues  ralf.wildenh...@gmx.de
 
 	Rewrite maintainer-check in separate tests, parallelizable.
diff --git a/NEWS b/NEWS
index 6b94a7c..0126a14 100644
--- a/NEWS
+++ b/NEWS
@@ -42,6 +42,8 @@ New in 1.10a:
   - The default source file extension (.c) can be overridden with
 AM_DEFAULT_SOURCE_EXT now.
 
+  - Vala source files are recognized now.
+
 * Miscellaneous changes:
 
   - Automake development is done in a git repository on Savannah now, see
diff --git a/automake.in b/automake.in
index c1321f0..f5d0dac 100755
--- a/automake.in
+++ b/automake.in
@@ -112,7 +112,7 @@ sub finish ($)
   my ($self) = @_;
   if (defined $self-_finish)
 {
-  {$self-_finish} ();
+  {$self-_finish} (@_);
 }
 }
 
@@ -569,6 +569,7 @@ my @dist_targets;
 # Keep track of all programs declared in this Makefile, without
 # $(EXEEXT).  @substitutions@ are not listed.
 my %known_programs;
+my %known_libraries;
 
 # Keys in this hash are the basenames of files which must depend on
 # ansi2knr.  Values are either the empty string, or the directory in
@@ -699,6 +700,7 @@ sub initialize_per_input ()
 @dist_targets = ();
 
 %known_programs = ();
+%known_libraries= ();
 
 %de_ansi_files = ();
 
@@ -802,6 +804,21 @@ register_language ('name