2008-10-09 Mathias Hasselmann <mathias.hasselmann@gmx.de>
+ * automake.in: Support Vala in non-recursive builds. Make sure
+ foo_VALAFLAGS really use used. Inject --library switch when building
+ Vala libraries.
+ * doc/automake.texi, NEWS: Document Vala support.
+ * m4/vala.m4: Rename AC_PROG_VALAC to AM_PROG_VALAC.
+ * tests/Makefile.am: Additional Vala tests.
+ * tests/vala.test: Also test VALAFLAGS support.
+ * tests/vala1.test: Test non-recursive Vala support.
+ * tests/vala2.test: Test _PKGNAME variables.
+ * tests/vala3.test: Test compiling of C code generated by Vala.
+
+2008-10-09 Mathias Hasselmann <mathias.hasselmann@gmx.de>
+
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
- Files with extension .sx are also treated as preprocessed assembler.
+ - Vala source files are recognized now.
+
* Miscellaneous changes:
- Automake development is done in a git repository on Savannah now, see
my ($self) = @_;
if (defined $self->_finish)
{
- &{$self->_finish} ();
+ &{$self->_finish} (@_);
}
}
{
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);
. "did you mean `$suggestion'?")
}
+ ($known_libraries{$onelib} = $bn) =~ s/\.a$//;
+
$where->push_context ("while processing library `$onelib'");
$where->set (INTERNAL->get);
{
my ($where, $onelib) = @$pair;
- $known_libraries{$onelib} = $where;
-
my $seen_libobjs = 0;
my $obj = get_object_extension '.lo';
. "did you mean `$suggestion'?")
}
+ ($known_libraries{$onelib} = $bn) =~ s/\.la$//;
+
$where->push_context ("while processing Libtool library `$onelib'");
$where->set (INTERNAL->get);
{
my ($directory, $base, $ext) = @_;
- my $r = &lang_sub_obj;
(my $newext = $ext) =~ s/vala$/c/;
- return ($r, $newext);
+ return (LANG_SUBDIR, $newext);
}
# Rewrite a single yacc file.
}
}
+sub lang_vala_finish_target ($$$)
+{
+ my ($self, $name, $pkgname) = @_;
+
+ my $derived = canonicalize ($name);
+ my $varname = $derived . '_SOURCES';
+ my $var = var ($varname);
+
+ if ($var)
+ {
+ foreach my $file ($var->value_as_list_recursive)
+ {
+ $output_rules .= "$file: ${derived}_vala.stamp\n"
+ if ($file =~ s/(.*)\.vala$/$1.c $1.h/);
+ }
+ }
+
+ 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})
+ {
+ my $val = "${derived}_$flag";
+ $compile =~ s/\(AM_$flag\)/\($val\)/
+ if set_seen ($val);
+ }
+
+ my $dirname = dirname ($name);
+
+ $compile .= " -d $dirname" if $dirname ne '.';
+
+ $output_rules .=
+ "${derived}_vala.stamp: \$(${derived}_SOURCES)\n".
+ "\t${compile} \$^ && touch \$@\n";
+}
+
# 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);
+ my ($self) = @_;
- 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/);
- }
- }
+ foreach my $prog (keys %known_programs)
+ {
+ lang_vala_finish_target ($self, $prog, 0);
+ }
- $output_rules .=
- "${xname}_vala.stamp: \$(${xname}_SOURCES)\n".
- "\t\$(VALACOMPILE) \$^ && touch \$@\n";
+ while (my ($name, $pkgname) = each %known_libraries)
+ {
+ lang_vala_finish_target ($self, $name, $pkgname);
}
}
* Fortran 77 Support:: Compiling Fortran 77 sources
* Fortran 9x Support:: Compiling Fortran 9x sources
* Java Support:: Compiling Java sources
+* Vala Support:: Compiling Vala sources
* Support for Other Languages:: Compiling other languages
* ANSI:: Automatic de-ANSI-fication (obsolete)
* Dependencies:: Automatic dependency tracking
* Fortran 77 Support:: Compiling Fortran 77 sources
* Fortran 9x Support:: Compiling Fortran 9x sources
* Java Support:: Compiling Java sources
+* Vala Support:: Compiling Vala sources
* Support for Other Languages:: Compiling other languages
* ANSI:: Automatic de-ANSI-fication (obsolete)
* Dependencies:: Automatic dependency tracking
the @code{_LDFLAGS} variable for the program.
+@node Vala Support
+@comment node-name, next, previous, up
+@section Vala Support
+
+@cindex Vala Support
+@cindex Support for Vala
+
+Automake provides support for Vala compilation.
+
+@example
+foo_SOURCES = foo.vala bar.vala zardoc.c
+@end example
+
+Any .vala file listed in a @code{_SOURCE} variable will be compiled
+into C code by the Vala compiler.
+
+Automake ships with an Autoconf macro called @code{AM_PROG_VALAC}
+that will locate the Vala compiler and optionally check its version
+number.
+
+@defmac AM_PROG_VALAC ([@var{MINIMUM-VERSION}])
+
+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.
+
+@example
+AM_PROG_VALAC([0.1.3])
+@end example
+
+@end defmac
+
+There are a few variables that are used when compiling Vala sources:
+
+@vtable @code
+
+@item VALAC
+Path to the the Vala compiler.
+
+@item VALAFLAGS
+Additional arguments for the Vala compiler.
+
+@item PKGNAME
+The pkg-config and VAPI 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
+
+
@node Support for Other Languages
@comment node-name, next, previous, up
@section Support for Other Languages
#
# Author: Mathias Hasselmann <mathias.hasselmann@gmx.de>
#
-# AC_PROG_VALAC([MINIMUM-VERSION])
+# AM_PROG_VALAC([MINIMUM-VERSION])
# --------------------------------------------------------------------------
-AC_DEFUN([AC_PROG_VALAC],[
+AC_DEFUN([AM_PROG_VALAC],[
AC_PATH_PROG([VALAC], [valac], [])
AC_SUBST(VALAC)
upc2.test \
upc3.test \
vala.test \
+vala1.test \
+vala2.test \
+vala3.test \
vars.test \
vars3.test \
vartar.test \
upc2.test \
upc3.test \
vala.test \
+vala1.test \
+vala2.test \
+vala3.test \
vars.test \
vars3.test \
vartar.test \
cat >> 'configure.in' << 'END'
AC_PROG_CC
AC_PROG_LIBTOOL
-AC_PROG_VALAC
+AM_PROG_VALAC
AC_OUTPUT
END
cat > 'Makefile.am' <<'END'
bin_PROGRAMS = zardoz
zardoz_SOURCES = zardoz.vala
+zardoz_VALAFLAGS = --debug
lib_LTLIBRARIES = libzardoz.la
libzardoz_la_SOURCES = zardoz-foo.vala zardoz-bar.vala
$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'
+grep -w -- 'VALAC' 'Makefile.in'
+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 -- '--library=libzardoz' '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'
+
--- /dev/null
+#! /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 sources
+# in non-recursive automake mode.
+
+required="libtool"
+. ./defs || exit 1
+
+set -e
+
+cat >> 'configure.in' << 'END'
+AC_PROG_CC
+AC_PROG_LIBTOOL
+AM_PROG_VALAC
+AC_OUTPUT
+END
+
+cat > 'Makefile.am' <<'END'
+bin_PROGRAMS = src/zardoz
+src_zardoz_SOURCES = src/zardoz.vala
+
+lib_LTLIBRARIES = src/libzardoz.la
+src_libzardoz_la_SOURCES = src/zardoz-foo.vala src/zardoz-bar.vala
+END
+
+: > ltmain.sh
+: > config.sub
+: > config.guess
+
+$ACLOCAL
+$AUTOMAKE -a
+
+grep -w -- 'VALAC' 'Makefile.in'
+grep -w -- 'src_zardoz_OBJECTS' 'Makefile.in'
+grep -w -- 'src_libzardoz_la_OBJECTS' 'Makefile.in'
+grep -w -- 'src_zardoz_vala.stamp' 'Makefile.in'
+grep -w -- 'src_libzardoz_la_vala.stamp' 'Makefile.in'
+grep -w -- '--library=libzardoz' 'Makefile.in'
+grep -w -- 'zardoz\.c' 'Makefile.in'
+grep -w -- 'zardoz\.h' 'Makefile.in'
+grep -w -- 'src/zardoz-foo\.c' 'Makefile.in'
+grep -w -- 'src/zardoz-foo\.h' 'Makefile.in'
+
--- /dev/null
+#! /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 foo_PKGNAME variables are considered.
+
+required="libtool"
+. ./defs || exit 1
+
+set -e
+
+cat >> 'configure.in' << 'END'
+AC_PROG_CC
+AC_PROG_LIBTOOL
+AM_PROG_VALAC
+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
+END
+
+: > ltmain.sh
+: > config.sub
+: > config.guess
+
+$ACLOCAL
+$AUTOMAKE -a
+
+grep -w -- 'VALAC' 'Makefile.in'
+grep -w -- 'src_libzardoz_la_OBJECTS' 'Makefile.in'
+grep -w -- 'src_libzardoz_la_vala.stamp' 'Makefile.in'
+grep -w -- '--library=zardoz+-3.0' 'Makefile.in'
+grep -w -- 'src/zardoz-foo\.c' 'Makefile.in'
+grep -w -- 'src/zardoz-foo\.h' 'Makefile.in'
+
--- /dev/null
+#! /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 compiling Vala code really works.
+
+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_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;
+
+public class Zardoz {
+ public static void main () {
+ stdout.printf ("Zardoz!\n");
+ }
+}
+END
+
+libtoolize
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+make
+