Improve Vala support.
authorJürg Billeter <j@bitron.ch>
Sun, 5 Apr 2009 13:16:48 +0000 (15:16 +0200)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sun, 19 Apr 2009 06:05:38 +0000 (08:05 +0200)
* automake.in: Update to Vala 0.7.0 semantics, recover from removal
of built sources, support silent-rules, drop _PKGNAME variables
* doc/automake.texi, NEWS: Update.
* lib/am/vala.am: Bump copyright years.
* m4/vala.m4: Likewise.
* tests/vala.test: Remove obsolete grep tests.
* tests/vala1.test: Likewise.
* tests/vala2.test: Test full build, distcheck, and distclean.
* tests/vala3.test: Likewise, also test with subdir-objects.
* tests/vala4.test: Bump copyright years.
* tests/vala5.test: New test for per-target flags, expected to fail.
* tests/Makefile.am: Update.
* THANKS: Update.

Signed-off-by: Jürg Billeter <j@bitron.ch>
Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
15 files changed:
ChangeLog
NEWS
THANKS
automake.in
doc/automake.texi
lib/am/vala.am
m4/vala.m4
tests/Makefile.am
tests/Makefile.in
tests/vala.test
tests/vala1.test
tests/vala2.test
tests/vala3.test
tests/vala4.test
tests/vala5.test [new file with mode: 0755]

index 00c6f5e..e0f25c9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2009-04-05  Jürg Billeter  <j@bitron.ch>
+
+       Improve Vala support.
+       * automake.in: Update to Vala 0.7.0 semantics, recover from removal
+       of built sources, support silent-rules, drop _PKGNAME variables
+       * doc/automake.texi, NEWS: Update.
+       * lib/am/vala.am: Bump copyright years.
+       * m4/vala.m4: Likewise.
+       * tests/vala.test: Remove obsolete grep tests.
+       * tests/vala1.test: Likewise.
+       * tests/vala2.test: Test full build, distcheck, and distclean.
+       * tests/vala3.test: Likewise, also test with subdir-objects.
+       * tests/vala4.test: Bump copyright years.
+       * tests/vala5.test: New test for per-target flags, expected to fail.
+       * tests/Makefile.am: Update.
+       * THANKS: Update.
+
 2008-10-10  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
        Minor fixups for Vala support.
diff --git a/NEWS b/NEWS
index 4a0e13c..fd45cc0 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,7 +2,7 @@ New in 1.10c:
 
 * Languages changes:
 
-  - Vala source files are recognized now.
+  - Vala 0.7.0 and later is supported now.
 
 * Miscellaneous Changes:
 
diff --git a/THANKS b/THANKS
index 9f91c9c..6235436 100644 (file)
--- a/THANKS
+++ b/THANKS
@@ -164,6 +164,7 @@ Juergen A. Erhard   jae@laden.ilk.de
 Juergen Keil           jk@tools.de
 Juergen Leising                juergen.leising@gmx.de
 Julien Sopena          julien.sopena@lip6.fr
+Jürg Billeter         j@bitron.ch
 Karl Berry             kb@cs.umb.edu
 Karl Heuer             kwzh@gnu.org
 Kelley Cook            kcook@gcc.gnu.org
@@ -202,6 +203,7 @@ Martin Frydl                martin@idoox.com
 Martin Waitz           tali@admingilde.org
 Mathias Doreille       doreille@smr.ch
 Mathias Froehlich      M.Froehlich@science-computing.de
+Mathias Hasselmann     mathias.hasselmann@gmx.de
 Matt Leach             mleach@cygnus.com
 Matthew D. Langston    langston@SLAC.Stanford.EDU
 Matthias Andree                matthias.andree@gmx.de
index e2e5643..a756089 100755 (executable)
@@ -817,11 +817,11 @@ register_language ('name' => 'vala',
                   'config_vars' => ['VALAC'],
                   'flags' => ['VALAFLAGS'],
                   'compile' => '$(VALAC) $(AM_VALAFLAGS) $(VALAFLAGS)',
+                  'ccer' => 'VALAC',
                   'compiler' => 'VALACOMPILE',
                   'extensions' => ['.vala'],
-                  'output_extensions' => sub { (my $ext1 = $_[0]) =~ s/vala$/c/;
-                                               (my $ext2 = $_[0]) =~ s/vala$/h/;
-                                               return ($ext1, $ext2) },
+                  'output_extensions' => sub { (my $ext = $_[0]) =~ s/vala$/c/;
+                                               return ($ext,) },
                   'rule_file' => 'vala',
                   '_finish' => \&lang_vala_finish,
                   '_target_hook' => \&lang_vala_target_hook,
@@ -5907,9 +5907,9 @@ sub lang_c_finish
     }
 }
 
-sub lang_vala_finish_target ($$$)
+sub lang_vala_finish_target ($$)
 {
-  my ($self, $name, $pkgname) = @_;
+  my ($self, $name) = @_;
 
   my $derived = canonicalize ($name);
   my $varname = $derived . '_SOURCES';
@@ -5919,22 +5919,17 @@ sub lang_vala_finish_target ($$$)
     {
       foreach my $file ($var->value_as_list_recursive)
         {
-          $output_rules .= "$file: ${derived}_vala.stamp\n"
-            if ($file =~ s/(.*)\.vala$/$1.c $1.h/);
+          $output_rules .= "$file: ${derived}_vala.stamp\n".
+            "\t\@if test -f \$@; then :; else \\\n".
+            "\t  rm -f ${derived}_vala.stamp; \\\n".
+            "\t  \$(MAKE) \$(AM_MAKEFLAGS) ${derived}_vala.stamp; \\\n".
+            "\tfi\n"
+            if $file =~ s/(.*)\.vala$/$1.c/;
         }
     }
 
   my $compile = $self->compile;
 
-  if (defined ($pkgname))
-    {
-      $varname = $derived . '_PKGNAME';
-      $var = var ($varname);
-
-      $pkgname = $var->variable_value if $var;
-      $compile =~s/\$\(AM_VALAFLAGS\)/--library=$pkgname $&/;
-    }
-
   # Rewrite each occurrence of `AM_$flag' in the compile
   # rule into `${derived}_$flag' if it exists.
   for my $flag (@{$self->flags})
@@ -5946,42 +5941,47 @@ sub lang_vala_finish_target ($$$)
 
   my $dirname = dirname ($name);
 
-  $compile .= " -d $dirname" if $dirname ne '.';
+  # Only generate C code, do not run C compiler
+  $compile .= " -C";
+
+  my $verbose = verbose_flag ('VALAC');
+  my $silent = silent_flag ();
 
   $output_rules .=
     "${derived}_vala.stamp: \$(${derived}_SOURCES)\n".
-    "\t${compile} \$^ && touch \$@\n";
+    "\t${verbose}${compile} \$(${derived}_SOURCES)\n".
+    "\t${silent}touch \$@\n";
+
+  push_dist_common ("${derived}_vala.stamp");
+
+  $clean_files{"${derived}_vala.stamp"} = MAINTAINER_CLEAN;
 }
 
-# This is a vala helper which is called after all source file
-# processing is done.
+# Add output ruless to invoke valac and create stamp file as a witness
+# to handle multiple outputs. This function is called after all source
+# file processing is done.
 sub lang_vala_finish
 {
   my ($self) = @_;
 
   foreach my $prog (keys %known_programs)
     {
-      lang_vala_finish_target ($self, $prog, 0);
+      lang_vala_finish_target ($self, $prog);
     }
 
-  while (my ($name, $pkgname) = each %known_libraries)
+  while (my ($name) = each %known_libraries)
     {
-      lang_vala_finish_target ($self, $name, $pkgname);
+      lang_vala_finish_target ($self, $name);
     }
 }
 
-# This is a vala helper which is called whenever we have decided to
-# compile a vala file.
+# The built .c files should be cleaned only on maintainer-clean
+# as the .c files are distributed. This function is called for each
+# .vala source file.
 sub lang_vala_target_hook
 {
   my ($self, $aggregate, $output, $input, %transform) = @_;
 
-  (my $output_base = $output) =~ s/$KNOWN_EXTENSIONS_PATTERN$//;
-  my $header = $output_base . '.h';
-
-  &push_dist_common ($header);
-
-  $clean_files{$header} = MAINTAINER_CLEAN;
   $clean_files{$output} = MAINTAINER_CLEAN;
 }
 
index 05f2bfd..fc3c434 100644 (file)
@@ -6603,15 +6603,16 @@ the @code{_LDFLAGS} variable for the program.
 @cindex Vala Support
 @cindex Support for Vala
 
-Automake provides support for Vala compilation
-(@uref{http://live.gnome.org/@/Vala}).
+Automake provides support for Vala (@uref{http://www.vala-project.org/}).
+This requires valac version 0.7.0 or later.
 
 @example
 foo_SOURCES = foo.vala bar.vala zardoc.c
 @end example
 
 Any @file{.vala} file listed in a @code{_SOURCE} variable will be
-compiled into C code by the Vala compiler.
+compiled into C code by the Vala compiler. The generated @file{.c} files are
+distributed. The end user does not need to have a Vala compiler installed.
 
 Automake ships with an Autoconf macro called @code{AM_PROG_VALAC}
 that will locate the Vala compiler and optionally check its version
@@ -6623,7 +6624,7 @@ Try to find a Vala compiler in @env{PATH}. If it is found, the variable
 can be requested:
 
 @example
-AM_PROG_VALAC([0.1.3])
+AM_PROG_VALAC([0.7.0])
 @end example
 @end defmac
 
@@ -6639,14 +6640,8 @@ Additional arguments for the Vala compiler.
 @item AM_VALAFLAGS
 The maintainer's variant of @code{VALAFLAGS}.
 
-@item PKGNAME
-The pkg-config
-(@uref{http://www.freedesktop.org/@/software/@/pkgconfig/}) and VAPI
-(Vala API definition file) name to use when building Vala based library.
-
 @example
 lib_LTLIBRARIES = libfoo.la
-libfoo_la_PKGNAME = foo-2.0
 libfoo_la_SOURCES = foo.vala
 @end example
 @end vtable
index fa2a23c..ed12dc5 100644 (file)
@@ -1,5 +1,5 @@
 ## automake - create Makefile.in from Makefile.am
-## Copyright (C) 2008  Free Software Foundation, Inc.
+## Copyright (C) 2008, 2009  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
index 5606296..d3f73a5 100644 (file)
@@ -1,6 +1,6 @@
 # Autoconf support for the Vala compiler
 
-# Copyright (C) 2008 Free Software Foundation, Inc.
+# Copyright (C) 2008, 2009 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
index 88619b4..7b17271 100644 (file)
@@ -4,7 +4,8 @@ XFAIL_TESTS =                                   \
 all.test                                       \
 auxdir2.test                                   \
 cond17.test                                    \
-txinfo5.test
+txinfo5.test                                   \
+vala5.test
 
 include $(srcdir)/parallel-tests.am
 
@@ -695,6 +696,7 @@ vala1.test \
 vala2.test \
 vala3.test \
 vala4.test \
+vala5.test \
 vars.test \
 vars3.test \
 vartar.test \
index 11a9f8e..d1c1ccb 100644 (file)
@@ -228,7 +228,8 @@ XFAIL_TESTS = \
 all.test                                       \
 auxdir2.test                                   \
 cond17.test                                    \
-txinfo5.test
+txinfo5.test                                   \
+vala5.test
 
 parallel_tests = \
 check-p.test \
@@ -927,6 +928,7 @@ vala1.test \
 vala2.test \
 vala3.test \
 vala4.test \
+vala5.test \
 vars.test \
 vars3.test \
 vartar.test \
index c9b12af..a0e97ad 100755 (executable)
@@ -1,6 +1,6 @@
 #! /bin/sh
-# Copyright (C) 1996, 2001, 2002, 2006, 2008  Free Software Foundation,
-# Inc.
+# Copyright (C) 1996, 2001, 2002, 2006, 2008, 2009
+# Free Software Foundation, Inc.
 #
 # This file is part of GNU Automake.
 #
@@ -54,9 +54,6 @@ grep 'am_zardoz_OBJECTS' Makefile.in
 grep 'am_libzardoz_la_OBJECTS' Makefile.in
 grep 'zardoz_vala.stamp' Makefile.in
 grep 'libzardoz_la_vala.stamp' Makefile.in
-grep ' --library=libzardoz' Makefile.in
 grep 'zardoz\.c' Makefile.in
-grep 'zardoz\.h' Makefile.in
 grep 'zardoz-foo\.c' Makefile.in
-grep 'zardoz-foo\.h' Makefile.in
 
index 69edb15..158adcf 100755 (executable)
@@ -1,6 +1,6 @@
 #! /bin/sh
-# Copyright (C) 1996, 2001, 2002, 2006, 2008  Free Software Foundation,
-# Inc.
+# Copyright (C) 1996, 2001, 2002, 2006, 2008, 2009
+# Free Software Foundation, Inc.
 #
 # This file is part of GNU Automake.
 #
@@ -54,8 +54,5 @@ grep 'src_zardoz_OBJECTS' Makefile.in
 grep 'src_libzardoz_la_OBJECTS' Makefile.in
 grep 'src_zardoz_vala.stamp' Makefile.in
 grep 'src_libzardoz_la_vala.stamp' Makefile.in
-grep ' --library=libzardoz' Makefile.in
 grep 'zardoz\.c' Makefile.in
-grep 'zardoz\.h' Makefile.in
 grep 'src/zardoz-foo\.c' Makefile.in
-grep 'src/zardoz-foo\.h' Makefile.in
index ce568d5..6209aa6 100755 (executable)
@@ -1,6 +1,6 @@
 #! /bin/sh
-# Copyright (C) 1996, 2001, 2002, 2006, 2008  Free Software Foundation,
-# Inc.
+# Copyright (C) 1996, 2001, 2002, 2006, 2008, 2009
+# Free Software Foundation, Inc.
 #
 # This file is part of GNU Automake.
 #
 # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 # Boston, MA 02110-1301, USA.
 
-# Test to make foo_PKGNAME variables are considered.
+# Test to make sure compiling Vala code really works with recursive make.
 
-required="libtool"
+required="libtool libtoolize pkg-config valac gcc"
 . ./defs || Exit 1
 
 set -e
 
+mkdir src
+
 cat >> 'configure.in' << 'END'
 AC_PROG_CC
+AM_PROG_CC_C_O
 AC_PROG_LIBTOOL
 AM_PROG_VALAC
+PKG_CHECK_MODULES([GOBJECT],[gobject-2.0 >= 2.10])
+AC_CONFIG_FILES([src/Makefile])
 AC_OUTPUT
 END
 
 cat > 'Makefile.am' <<'END'
-lib_LTLIBRARIES = src/libzardoz.la
-src_libzardoz_la_SOURCES = src/zardoz-foo.vala src/zardoz-bar.vala
-src_libzardoz_la_PKGNAME = zardoz+-3.0
+SUBDIRS = src
+END
+
+cat > 'src/Makefile.am' <<'END'
+bin_PROGRAMS = zardoz
+zardoz_CFLAGS = $(GOBJECT_CFLAGS)
+zardoz_LDADD = $(GOBJECT_LIBS)
+zardoz_SOURCES = zardoz.vala
 END
 
-: > ltmain.sh
-: > config.sub
-: > config.guess
+cat > 'src/zardoz.vala' <<'END'
+using GLib;
+
+public class Zardoz {
+  public static void main () {
+    stdout.printf ("Zardoz!\n");
+  }
+}
+END
+
+libtoolize
 
 $ACLOCAL
+$AUTOCONF
 $AUTOMAKE -a
 
-grep 'VALAC' Makefile.in
-grep 'src_libzardoz_la_OBJECTS' Makefile.in
-grep 'src_libzardoz_la_vala.stamp' Makefile.in
-grep ' --library=zardoz+-3.0' Makefile.in
-grep 'src/zardoz-foo\.c' Makefile.in
-grep 'src/zardoz-foo\.h' Makefile.in
+./configure
+$MAKE
+$MAKE distcheck
+$MAKE distclean
+mkdir build
+cd build
+../configure
+$MAKE
+$MAKE distcheck
+
index 41b083d..7815393 100755 (executable)
@@ -1,5 +1,6 @@
 #! /bin/sh
-# Copyright (C) 1996, 2001, 2002, 2006  Free Software Foundation, Inc.
+# Copyright (C) 1996, 2001, 2002, 2006, 2008, 2009
+# Free Software Foundation, Inc.
 #
 # This file is part of GNU Automake.
 #
@@ -18,7 +19,7 @@
 # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 # Boston, MA 02110-1301, USA.
 
-# Test to make sure compiling Vala code really works.
+# Test to make sure compiling Vala code really works with non-recursive make.
 
 required="libtool libtoolize pkg-config valac gcc"
 . ./defs || Exit 1
@@ -31,18 +32,11 @@ cat >> 'configure.in' << 'END'
 AC_PROG_CC
 AM_PROG_CC_C_O
 AC_PROG_LIBTOOL
-AM_PROG_VALAC
-PKG_CHECK_MODULES(GOBJECT,gobject-2.0 >= 2.10)
+AM_PROG_VALAC([0.7.0])
+PKG_CHECK_MODULES([GOBJECT],[gobject-2.0 >= 2.10])
 AC_OUTPUT
 END
 
-cat > 'Makefile.am' <<'END'
-bin_PROGRAMS = src/zardoz
-src_zardoz_CFLAGS = $(GOBJECT_CFLAGS)
-src_zardoz_LDADD = $(GOBJECT_LIBS)
-src_zardoz_SOURCES = src/zardoz.vala
-END
-
 cat > 'src/zardoz.vala' <<'END'
 using GLib;
 
@@ -53,12 +47,57 @@ public class Zardoz {
 }
 END
 
+cat > 'Makefile.am' <<'END'
+bin_PROGRAMS = src/zardoz
+src_zardoz_CFLAGS = $(GOBJECT_CFLAGS)
+src_zardoz_LDADD = $(GOBJECT_LIBS)
+src_zardoz_SOURCES = src/zardoz.vala
+END
+
 libtoolize
 
 $ACLOCAL
 $AUTOCONF
 $AUTOMAKE -a
 
-./configure
+./configure || Exit 77
 $MAKE
+$MAKE distcheck
+$MAKE distclean
+mkdir build
+cd build
+../configure
+$MAKE
+$MAKE distcheck
+
+cd ..
+rm -rf build
+
+# Try again with subdir-objects.
+
+cat > 'Makefile.am' <<'END'
+AUTOMAKE_OPTIONS = subdir-objects
+
+bin_PROGRAMS = src/zardoz
+src_zardoz_CFLAGS = $(GOBJECT_CFLAGS)
+src_zardoz_LDADD = $(GOBJECT_LIBS)
+src_zardoz_SOURCES = src/zardoz.vala
+END
+
+libtoolize
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure || Exit 77
+$MAKE
+$MAKE distcheck
+$MAKE distclean
+mkdir build
+cd build
+../configure
+$MAKE
+$MAKE distcheck
+
 
index a2e8c96..1f9d2ca 100755 (executable)
@@ -1,5 +1,5 @@
 #! /bin/sh
-# Copyright (C) 2008  Free Software Foundation, Inc.
+# Copyright (C) 2008, 2009  Free Software Foundation, Inc.
 #
 # This file is part of GNU Automake.
 #
diff --git a/tests/vala5.test b/tests/vala5.test
new file mode 100755 (executable)
index 0000000..7369186
--- /dev/null
@@ -0,0 +1,74 @@
+#! /bin/sh
+# Copyright (C) 1996, 2001, 2002, 2006, 2008, 2009
+# Free Software Foundation, Inc.
+#
+# This file is part of GNU Automake.
+#
+# GNU Automake 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 3, or (at your option)
+# any later version.
+#
+# GNU Automake 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 Automake; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+# Test per-target flags, expected to fail.
+
+required="libtool libtoolize pkg-config valac gcc"
+. ./defs || Exit 1
+
+set -e
+
+mkdir src
+
+cat >> 'configure.in' << 'END'
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_LIBTOOL
+AM_PROG_VALAC
+PKG_CHECK_MODULES([GOBJECT],[gobject-2.0 >= 2.10])
+AC_CONFIG_FILES([src/Makefile])
+AC_OUTPUT
+END
+
+cat > 'Makefile.am' <<'END'
+SUBDIRS = src
+END
+
+cat > 'src/Makefile.am' <<'END'
+bin_PROGRAMS = foo bar
+foo_CFLAGS = $(GOBJECT_CFLAGS)
+foo_LDADD = $(GOBJECT_LIBS)
+foo_SOURCES = baz.vala
+bar_SOURCES = baz.vala
+bar_VALAFLAGS = -D BAR
+bar_CFLAGS = $(GOBJECT_CFLAGS)
+bar_LDADD = $(GOBJECT_LIBS)
+END
+
+cat > 'src/baz.vala' <<'END'
+void main () {
+#if BAR
+  stdout.printf ("bar\n");
+#else
+  stdout.printf ("foo\n");
+#endif
+}
+END
+
+libtoolize
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+$MAKE
+