>From 70d10fcba71c69a901ab909da1a4d97a32b4b903 Mon Sep 17 00:00:00 2001 From: Ralf Wildenhues Date: Fri, 10 Oct 2008 07:44:01 +0200 Subject: [PATCH 3/4] Minor fixups for Vala support. * automake.in: $(VALAFLAGS) comes after $(AM_VALAFLAGS). * doc/automake.texi (Vala Support): Add some references, document AM_VALAFLAGS, streamline a bit. * lib/am/vala.am: Copyright blurb. * m4/vala.m4 (AM_PROG_VALAC): Rewrite using AS_VERSION_COMPARE. * tests/vala.test: Fix minor nits. * tests/vala1.test: Likewise. * tests/vala2.test: Likewise. * tests/vala3.test: Likewise. * tests/vala4.test: New test, for version argument of AM_PROG_VALAC. * tests/Makefile.am: Update. Signed-off-by: Ralf Wildenhues --- ChangeLog | 16 ++++++++++++++ automake.in | 2 +- doc/automake.texi | 26 ++++++++++++---------- lib/am/vala.am | 17 ++++++++++++++ m4/vala.m4 | 43 +++++++++++++++--------------------- tests/Makefile.am | 1 + tests/Makefile.in | 1 + tests/vala.test | 25 +++++++++++---------- tests/vala1.test | 26 +++++++++++----------- tests/vala2.test | 18 +++++++------- tests/vala3.test | 7 +---- tests/vala4.test | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 12 files changed, 166 insertions(+), 77 deletions(-) create mode 100755 tests/vala4.test diff --git a/ChangeLog b/ChangeLog index 4a41898..3a7657e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,19 @@ +2008-10-10 Ralf Wildenhues + + Minor fixups for Vala support. + * automake.in: $(VALAFLAGS) comes after $(AM_VALAFLAGS). + * doc/automake.texi (Vala Support): Add some references, + document AM_VALAFLAGS, streamline a bit. + * lib/am/vala.am: Copyright blurb. + * m4/vala.m4 (AM_PROG_VALAC): Rewrite using AS_VERSION_COMPARE. + * tests/vala.test: Fix minor nits. + * tests/vala1.test: Likewise. + * tests/vala2.test: Likewise. + * tests/vala3.test: Likewise. + * tests/vala4.test: New test, for version argument of + AM_PROG_VALAC. + * tests/Makefile.am: Update. + 2008-10-09 Mathias Hasselmann * automake.in: Support Vala in non-recursive builds. Make sure diff --git a/automake.in b/automake.in index 195b1fe..e2e5643 100755 --- a/automake.in +++ b/automake.in @@ -816,7 +816,7 @@ register_language ('name' => 'vala', 'Name' => 'Vala', 'config_vars' => ['VALAC'], 'flags' => ['VALAFLAGS'], - 'compile' => '$(VALAC) $(VALAFLAGS) $(AM_VALAFLAGS)', + 'compile' => '$(VALAC) $(AM_VALAFLAGS) $(VALAFLAGS)', 'compiler' => 'VALACOMPILE', 'extensions' => ['.vala'], 'output_extensions' => sub { (my $ext1 = $_[0]) =~ s/vala$/c/; diff --git a/doc/automake.texi b/doc/automake.texi index 36814d1..05f2bfd 100644 --- a/doc/automake.texi +++ b/doc/automake.texi @@ -6603,50 +6603,52 @@ the @code{_LDFLAGS} variable for the program. @cindex Vala Support @cindex Support for Vala -Automake provides support for Vala compilation. +Automake provides support for Vala compilation +(@uref{http://live.gnome.org/@/Vala}). @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. +Any @file{.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. address@hidden AM_PROG_VALAC (address@hidden) - -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. address@hidden AM_PROG_VALAC (@ovar{MINIMUM-VERSION}) +Try to find a Vala compiler in @env{PATH}. If it is found, the variable address@hidden 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. address@hidden AM_VALAFLAGS +The maintainer's variant of @code{VALAFLAGS}. + @item PKGNAME -The pkg-config and VAPI name to use when building Vala based library. +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 diff --git a/lib/am/vala.am b/lib/am/vala.am index e69de29..fa2a23c 100644 --- a/lib/am/vala.am +++ b/lib/am/vala.am @@ -0,0 +1,17 @@ +## automake - create Makefile.in from Makefile.am +## Copyright (C) 2008 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 +## the Free Software Foundation; either version 3, or (at your option) +## any later version. + +## This program 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 this program. If not, see . + +## There is no rule here. :-) diff --git a/m4/vala.m4 b/m4/vala.m4 index 57aae60..5606296 100644 --- a/m4/vala.m4 +++ b/m4/vala.m4 @@ -1,36 +1,29 @@ # Autoconf support for the Vala compiler -# Copyright (C) 2007 Free Software Foundation, Inc. +# Copyright (C) 2008 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 +# serial 3 -# 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 +# 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. # # AM_PROG_VALAC([MINIMUM-VERSION]) -# -------------------------------------------------------------------------- -AC_DEFUN([AM_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 +# -------------------------------- +AC_DEFUN([AM_PROG_VALAC], +[AC_PATH_PROG([VALAC], [valac], []) + AS_IF([test -z "$VALAC"], + [AC_MSG_WARN([No Vala compiler found. You will not be able to compile .vala source files.])], + [AS_IF([test -n "$1"], + [AC_MSG_CHECKING([$VALAC is at least version $1]) + am__vala_version=`$VALAC --version` + AS_VERSION_COMPARE([$1], ["$am__vala_version"], + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([yes])], + [AC_MSG_RESULT([no]) + AC_MSG_ERROR([Vala $1 not found.])])])]) ]) diff --git a/tests/Makefile.am b/tests/Makefile.am index 36a8983..88619b4 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -694,6 +694,7 @@ vala.test \ vala1.test \ vala2.test \ vala3.test \ +vala4.test \ vars.test \ vars3.test \ vartar.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index ea4bc8c..11a9f8e 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -926,6 +926,7 @@ vala.test \ vala1.test \ vala2.test \ vala3.test \ +vala4.test \ vars.test \ vars3.test \ vartar.test \ diff --git a/tests/vala.test b/tests/vala.test index d709cb2..c9b12af 100755 --- a/tests/vala.test +++ b/tests/vala.test @@ -1,5 +1,6 @@ #! /bin/sh -# Copyright (C) 1996, 2001, 2002, 2006 Free Software Foundation, Inc. +# Copyright (C) 1996, 2001, 2002, 2006, 2008 Free Software Foundation, +# Inc. # # This file is part of GNU Automake. # @@ -21,7 +22,7 @@ # Test to make sure intermediate .c files are built from vala source. required="libtool" -. ./defs || exit 1 +. ./defs || Exit 1 set -e @@ -48,14 +49,14 @@ END $ACLOCAL $AUTOMAKE -a -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' +grep 'VALAC' Makefile.in +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 diff --git a/tests/vala1.test b/tests/vala1.test index 086b312..69edb15 100755 --- a/tests/vala1.test +++ b/tests/vala1.test @@ -1,5 +1,6 @@ #! /bin/sh -# Copyright (C) 1996, 2001, 2002, 2006 Free Software Foundation, Inc. +# Copyright (C) 1996, 2001, 2002, 2006, 2008 Free Software Foundation, +# Inc. # # This file is part of GNU Automake. # @@ -22,7 +23,7 @@ # in non-recursive automake mode. required="libtool" -. ./defs || exit 1 +. ./defs || Exit 1 set -e @@ -48,14 +49,13 @@ END $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' - +grep 'VALAC' Makefile.in +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 diff --git a/tests/vala2.test b/tests/vala2.test index 03ce33c..ce568d5 100755 --- a/tests/vala2.test +++ b/tests/vala2.test @@ -1,5 +1,6 @@ #! /bin/sh -# Copyright (C) 1996, 2001, 2002, 2006 Free Software Foundation, Inc. +# Copyright (C) 1996, 2001, 2002, 2006, 2008 Free Software Foundation, +# Inc. # # This file is part of GNU Automake. # @@ -21,7 +22,7 @@ # Test to make foo_PKGNAME variables are considered. required="libtool" -. ./defs || exit 1 +. ./defs || Exit 1 set -e @@ -45,10 +46,9 @@ END $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' - +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 diff --git a/tests/vala3.test b/tests/vala3.test index 70aca27..41b083d 100755 --- a/tests/vala3.test +++ b/tests/vala3.test @@ -21,7 +21,7 @@ # Test to make sure compiling Vala code really works. required="libtool libtoolize pkg-config valac gcc" -. ./defs || exit 1 +. ./defs || Exit 1 set -e @@ -31,11 +31,8 @@ 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 @@ -63,5 +60,5 @@ $AUTOCONF $AUTOMAKE -a ./configure -make +$MAKE diff --git a/tests/vala4.test b/tests/vala4.test new file mode 100755 index 0000000..a2e8c96 --- /dev/null +++ b/tests/vala4.test @@ -0,0 +1,61 @@ +#! /bin/sh +# Copyright (C) 2008 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 AM_PROG_VALAC. + +required=libtoolize +. ./defs || Exit 1 + +set -e + +cat >> configure.in << 'END' +AC_PROG_CC +AC_PROG_LIBTOOL +AM_PROG_VALAC([0.0.1]) +AC_OUTPUT +END + +: > Makefile.am + +cat > valac << 'END' +#! /bin/sh +if test "x$1" = x--version; then + echo 1.2.3 +fi +exit 0 +END +chmod +x valac + +libtoolize +$ACLOCAL +$AUTOMAKE -a +$AUTOCONF +./configure "VALAC=`pwd`/valac" + +sed 's/AM_PROG_VALAC.*/AM_PROG_VALAC([9999.9])/' < configure.in >t +mv -f t configure.in +$AUTOCONF --force +./configure "VALAC=`pwd`/valac" && Exit 1 + +sed 's/AM_PROG_VALAC.*/AM_PROG_VALAC([1.2.3])/' < configure.in >t +mv -f t configure.in +$AUTOCONF --force +./configure "VALAC=`pwd`/valac" +: -- 1.6.2