diff --git a/ChangeLog b/ChangeLog index 6eddcf3..8a8ebbd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2007-09-29 Mathias Hasselmann + + * 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. + * m4/vala.m4: Provide AC_PROG_VALAC for detecting the Vala compiler. + * tests/Makefile.am, tests/Makefile.in: Add vala.test. + * tests/vala.test: Test Vala support. + 2007-08-23 Ralf Wildenhues * tests/defs.in (required): For gcj, check whether `gcj -v' diff --git a/automake.in b/automake.in index d7e48a1..60f6cb8 100755 --- a/automake.in +++ b/automake.in @@ -545,6 +545,7 @@ my @dist_targets; # Keep track of all programs declared in this Makefile, without # $(EXEEXT). @substitution@ 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 @@ -666,6 +667,7 @@ sub initialize_per_input () @dist_targets = (); %known_programs = (); + %known_libraries= (); %de_ansi_files = (); @@ -776,6 +778,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', @@ -2535,6 +2553,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); @@ -2700,6 +2720,8 @@ sub handle_ltlibraries { my ($where, $onelib) = @$pair; + $known_libraries{$onelib} = $where; + my $seen_libobjs = 0; my $obj = get_object_extension '.lo'; @@ -5309,6 +5331,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 { @@ -5467,6 +5499,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/vala.am b/lib/am/vala.am new file mode 100644 index 0000000..e69de29 diff --git a/m4/vala.m4 b/m4/vala.m4 new file mode 100644 index 0000000..61bab7f --- /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 ee35345..a9851a0 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -589,6 +589,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 52a125a..ab1547f 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -722,6 +722,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'