>From b1a07a77831107053d55fc5326f8b4c78e107cf6 Mon Sep 17 00:00:00 2001 From: Mathias Hasselmann Date: Thu, 9 Oct 2008 20:06:20 +0200 Subject: [PATCH 1/4] 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. * 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 AC_PROG_VALAC for detecting the Vala compiler. * m4/Makefile.am (dist_m4data_DATA): Add vala.m4. * tests/vala.test: Test Vala support. * tests/Makefile.am: Update. Signed-off-by: Mathias Hasselmann Signed-off-by: Ralf Wildenhues --- ChangeLog | 13 +++++++++ automake.in | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/am/Makefile.am | 1 + lib/am/Makefile.in | 1 + m4/Makefile.am | 3 +- m4/Makefile.in | 3 +- m4/vala.m4 | 36 ++++++++++++++++++++++++++ tests/Makefile.am | 1 + tests/Makefile.in | 1 + tests/vala.test | 58 +++++++++++++++++++++++++++++++++++++++++ 10 files changed, 187 insertions(+), 2 deletions(-) create mode 100644 lib/am/vala.am create mode 100644 m4/vala.m4 create mode 100755 tests/vala.test diff --git a/ChangeLog b/ChangeLog index 7eb5db7..96b8a6e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2008-10-09 Mathias Hasselmann + + 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. + * 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 AC_PROG_VALAC for detecting the Vala compiler. + * m4/Makefile.am (dist_m4data_DATA): Add vala.m4. + * tests/vala.test: Test Vala support. + 2009-04-04 Ralf Wildenhues parallel-tests: LOG_COMPILER for tests without known extension. diff --git a/automake.in b/automake.in index 0460a44..b8fd750 100755 --- a/automake.in +++ b/automake.in @@ -572,6 +572,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 @@ -702,6 +703,7 @@ sub initialize_per_input () @dist_targets = (); %known_programs = (); + %known_libraries= (); %de_ansi_files = (); @@ -809,6 +811,22 @@ register_language ('name' => 'header', # Nothing to do. '_finish' => sub { }); +# Vala +register_language ('name' => 'vala', + 'Name' => 'Vala', + 'config_vars' => ['VALAC'], + 'flags' => ['VALAFLAGS'], + 'compile' => '$(VALAC) $(VALAFLAGS) $(AM_VALAFLAGS)', + 'compiler' => 'VALACOMPILE', + 'extensions' => ['.vala'], + 'output_extensions' => sub { (my $ext1 = $_[0]) =~ s/vala$/c/; + (my $ext2 = $_[0]) =~ s/vala$/h/; + return ($ext1, $ext2) }, + 'rule_file' => 'vala', + '_finish' => \&lang_vala_finish, + '_target_hook' => \&lang_vala_target_hook, + 'nodist_specific' => 1); + # Yacc (C & C++). register_language ('name' => 'yacc', 'Name' => 'Yacc', @@ -2689,6 +2707,8 @@ sub handle_libraries { my ($where, $onelib) = @$pair; + $known_libraries{$onelib} = $where; + my $seen_libobjs = 0; # Check that the library fits the standard naming convention. my $bn = basename ($onelib); @@ -2868,6 +2888,8 @@ sub handle_ltlibraries { my ($where, $onelib) = @$pair; + $known_libraries{$onelib} = $where; + my $seen_libobjs = 0; my $obj = get_object_extension '.lo'; @@ -5718,6 +5740,16 @@ sub lang_header_rewrite return LANG_IGNORE; } +# Rewrite a single Vala source file. +sub lang_vala_rewrite +{ + my ($directory, $base, $ext) = @_; + + my $r = &lang_sub_obj; + (my $newext = $ext) =~ s/vala$/c/; + return ($r, $newext); +} + # Rewrite a single yacc file. sub lang_yacc_rewrite { @@ -5876,6 +5908,46 @@ sub lang_c_finish } } +# This is a vala helper which is called after all source file +# processing is done. +sub lang_vala_finish +{ + foreach my $name (keys %known_programs, keys %known_libraries) + { + my $xname = canonicalize ($name); + my $varname = $xname . '_SOURCES'; + my $var = var ($varname); + + if ($var) + { + foreach my $file ($var->value_as_list_recursive) + { + $output_rules .= "$file: ${xname}_vala.stamp\n" + if ($file =~ s/(.*)\.vala$/$1.c $1.h/); + } + } + + $output_rules .= + "${xname}_vala.stamp: \$(${xname}_SOURCES)\n". + "\t\$(VALACOMPILE) \$^ && touch address@hidden"; + } +} + +# This is a vala helper which is called whenever we have decided to +# compile a vala 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; +} + # This is a yacc helper which is called whenever we have decided to # compile a yacc file. sub lang_yacc_target_hook diff --git a/lib/am/Makefile.am b/lib/am/Makefile.am index b1cae3b..1ab2f31 100644 --- a/lib/am/Makefile.am +++ b/lib/am/Makefile.am @@ -60,4 +60,5 @@ tags.am \ texi-vers.am \ texibuild.am \ texinfos.am \ +vala.am \ yacc.am diff --git a/lib/am/Makefile.in b/lib/am/Makefile.in index 66490fe..ce96885 100644 --- a/lib/am/Makefile.in +++ b/lib/am/Makefile.in @@ -205,6 +205,7 @@ tags.am \ texi-vers.am \ texibuild.am \ texinfos.am \ +vala.am \ yacc.am all: all-am diff --git a/lib/am/vala.am b/lib/am/vala.am new file mode 100644 index 0000000..e69de29 diff --git a/m4/Makefile.am b/m4/Makefile.am index 9f5e1c2..fd7c71c 100644 --- a/m4/Makefile.am +++ b/m4/Makefile.am @@ -55,7 +55,8 @@ sanity.m4 \ strip.m4 \ substnot.m4 \ tar.m4 \ -upc.m4 +upc.m4 \ +vala.m4 EXTRA_DIST = dirlist amversion.in diff --git a/m4/Makefile.in b/m4/Makefile.in index 9635c07..db2a213 100644 --- a/m4/Makefile.in +++ b/m4/Makefile.in @@ -200,7 +200,8 @@ sanity.m4 \ strip.m4 \ substnot.m4 \ tar.m4 \ -upc.m4 +upc.m4 \ +vala.m4 EXTRA_DIST = dirlist amversion.in all: all-am diff --git a/m4/vala.m4 b/m4/vala.m4 new file mode 100644 index 0000000..ce2474e --- /dev/null +++ b/m4/vala.m4 @@ -0,0 +1,36 @@ +# Autoconf support for the Vala compiler + +# Copyright (C) 2007 Free Software Foundation, Inc. +# +# This file is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# serial 2 + +# Check whether the Vala compiler exists in `PATH'. If it is found the +# variable VALAC is set. Optionally a minimum release number of the compiler +# can be requested. +# +# Author: Mathias Hasselmann +# +# AC_PROG_VALAC([MINIMUM-VERSION]) +# -------------------------------------------------------------------------- +AC_DEFUN([AC_PROG_VALAC],[ + AC_PATH_PROG([VALAC], [valac], []) + AC_SUBST(VALAC) + + if test -z "${VALAC}"; then + AC_MSG_WARN([No Vala compiler found. You will not be able to recompile .vala source files.]) + elif test -n "$1"; then + AC_REQUIRE([AC_PROG_AWK]) + AC_MSG_CHECKING([valac is at least version $1]) + + if "${VALAC}" --version | "${AWK}" -v r='$1' 'function vn(s) { if (3 == split(s,v,".")) return (v[1]*1000+v[2])*1000+v[3]; else exit 2; } /^Vala / { exit vn(r) > vn($[2]) }'; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + AC_MSG_ERROR([Vala $1 not found.]) + fi + fi +]) diff --git a/tests/Makefile.am b/tests/Makefile.am index a7ce706..3f95483 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -690,6 +690,7 @@ unused.test \ upc.test \ upc2.test \ upc3.test \ +vala.test \ vars.test \ vars3.test \ vartar.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index 58de5e3..34de9b4 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -922,6 +922,7 @@ unused.test \ upc.test \ upc2.test \ upc3.test \ +vala.test \ vars.test \ vars3.test \ vartar.test \ diff --git a/tests/vala.test b/tests/vala.test new file mode 100755 index 0000000..adbf2af --- /dev/null +++ b/tests/vala.test @@ -0,0 +1,58 @@ +#! /bin/sh +# Copyright (C) 1996, 2001, 2002, 2006 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 to make sure intermediate .c files are built from vala source. + +required="libtool" +. ./defs || exit 1 + +set -e + +cat >> 'configure.in' << 'END' +AC_PROG_CC +AC_PROG_LIBTOOL +AC_PROG_VALAC +AC_OUTPUT +END + +cat > 'Makefile.am' <<'END' +bin_PROGRAMS = zardoz +zardoz_SOURCES = zardoz.vala + +lib_LTLIBRARIES = libzardoz.la +libzardoz_la_SOURCES = zardoz-foo.vala zardoz-bar.vala +END + +: > ltmain.sh +: > config.sub +: > config.guess + +$ACLOCAL +$AUTOMAKE -a + +grep -w 'am_zardoz_OBJECTS' 'Makefile.in' +grep -w 'am_libzardoz_la_OBJECTS' 'Makefile.in' +grep -w 'zardoz_vala.stamp' 'Makefile.in' +grep -w 'libzardoz_la_vala.stamp' 'Makefile.in' +grep -w 'VALACOMPILE' 'Makefile.in' +grep -w 'zardoz\.c' 'Makefile.in' +grep -w 'zardoz\.h' 'Makefile.in' +grep -w 'zardoz-foo\.c' 'Makefile.in' +grep -w 'zardoz-foo\.h' 'Makefile.in' -- 1.6.2