This change fixes https://bugs.gnu.org/13002.
* NEWS: mention these changes.
* bin/automake.in: generated C files go in builddir, not srcdir.
Distribute the header files generated from VAPI files.
* t/vala-libs-distcheck.sh: new test for `make distcheck' of a
Vala library.
* t/vala-libs-vpath.sh: new test for a VPATH build of a Vala library.
* t/vala-libs.sh: add local VAPIs used as external --package to test.
* t/vala-recursive-setup.sh: we need to make
maintainer-clean at one point to remove stamp files to avoid
confusing a VPATH build performed after a non-VPATH build.
* t/vala-non-recursive-setup.sh: likewise.
* t/vala-parallel.sh: some test paths need changing to take into
account that generated C files now go in builddir.
* t/vala-per-target-flags.sh: likewise.
* t/vala-recursive-setup.sh: likewise.
* t/vala-vpath.sh: likewise.
- valac argument matching more precise, to avoid garbage in DIST_COMMON.
+ - Support for Vala in VPATH builds fixed so that both freshly-generated and
+ distributed C files work, and operation is more reliable with or without
+ an installed valac.
+
* Distribution
- new variable AM_DISTCHECK_DVI_TARGET, to allow overriding the
- Removed function up_to_date_p in lib/Automake/FileUtils.pm.
We believe this function is completely unused.
+ - Support for in-tree Vala libraries improved.
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
New in 1.16.2:
my $c_file = $vala_file;
if ($c_file =~ s/(.*)\.vala$/$1.c/)
{
- $c_file = "\$(srcdir)/$c_file";
- $output_rules .= "$c_file: \$(srcdir)/${derived}_vala.stamp\n"
- . "\t\@if test -f \$@; then :; else rm -f \$(srcdir)/${derived}_vala.stamp; fi\n"
+ my $built_c_file = "\$(builddir)/$c_file";
+ my $built_dir = dirname $built_c_file;
+ my $base_c_file = basename $c_file;
+ $output_rules .= "$built_c_file: \$(builddir)/${derived}_vala.stamp\n"
+ . "\t\@if test ! -f \$@ && test \$(srcdir) != \$(builddir) && test -n \"\$\$(find -L \$(srcdir)/$c_file -prune -newer \$(srcdir)/$vala_file)\"; then cp -p \$(srcdir)/$c_file $built_c_file; fi\n"
+ . "\t\@if test -f \$@; then :; else rm -f \$(builddir)/${derived}_vala.stamp; fi\n"
. "\t\@if test -f \$@; then :; else \\\n"
- . "\t \$(MAKE) \$(AM_MAKEFLAGS) \$(srcdir)/${derived}_vala.stamp; \\\n"
+ . "\t \$(MAKE) \$(AM_MAKEFLAGS) \$(builddir)/${derived}_vala.stamp; \\\n"
+ . "\t if test $built_dir != .; then mv $base_c_file $built_dir/; fi \\\n"
. "\tfi\n";
- $clean_files{$c_file} = MAINTAINER_CLEAN;
+ $clean_files{$built_c_file} = DIST_CLEAN;
+ $clean_files{"\$(srcdir)/$c_file"} = MAINTAINER_CLEAN;
}
}
if (grep (/^$lastflag$/, ('-H', '-h', '--header', '--internal-header',
'--vapi', '--internal-vapi', '--gir')))
{
- my $headerfile = "\$(srcdir)/$flag";
- $output_rules .= "$headerfile: \$(srcdir)/${derived}_vala.stamp\n"
- . "\t\@if test -f \$@; then :; else rm -f \$(srcdir)/${derived}_vala.stamp; fi\n"
+ my $headerfile = "\$(builddir)/$flag";
+ $output_rules .= "$headerfile: \$(builddir)/${derived}_vala.stamp\n"
+ . "\t\@if test -f \$@; then :; else rm -f \$(builddir)/${derived}_vala.stamp; fi\n"
. "\t\@if test -f \$@; then :; else \\\n"
- . "\t \$(MAKE) \$(AM_MAKEFLAGS) \$(srcdir)/${derived}_vala.stamp; \\\n"
+ . "\t \$(MAKE) \$(AM_MAKEFLAGS) \$(builddir)/${derived}_vala.stamp; \\\n"
. "\tfi\n";
# valac is not used when building from dist tarballs
push_dist_common ($headerfile);
$clean_files{$headerfile} = MAINTAINER_CLEAN;
}
+ if (grep (/$lastflag/, ('--library')))
+ {
+ my $headerfile = "\$(builddir)/$flag";
+ $output_rules .= "$headerfile.vapi: \$(builddir)/${derived}_vala.stamp\n"
+ . "\t\@if test -f \$@; then :; else rm -f \$(builddir)/${derived}_vala.stamp; fi\n"
+ . "\t\@if test -f \$@; then :; else \\\n"
+ . "\t \$(MAKE) \$(AM_MAKEFLAGS) \$(builddir)/${derived}_vala.stamp; \\\n"
+ . "\tfi\n";
+
+ # valac is not used when building from dist tarballs
+ # distribute the generated files
+ my $vapi = "$headerfile.vapi";
+ push_dist_common ($vapi);
+ $clean_files{$headerfile.'.vapi'} = MAINTAINER_CLEAN;
+ }
$lastflag = $flag;
}
}
my $verbose = verbose_flag ('VALAC');
my $silent = silent_flag ();
- my $stampfile = "\$(srcdir)/${derived}_vala.stamp";
+ my $stampfile = "\$(builddir)/${derived}_vala.stamp";
$output_rules .=
- "\$(srcdir)/${derived}_vala.stamp: @vala_sources\n".
+ "\$(builddir)/${derived}_vala.stamp: @vala_sources\n".
# Since the C files generated from the vala sources depend on the
# ${derived}_vala.stamp file, we must ensure its timestamp is older than
# those of the C files generated by the valac invocation below (this is
# Thus we need to create the stamp file *before* invoking valac, and to
# move it to its final location only after valac has been invoked.
"\t${silent}rm -f \$\@ && echo stamp > \$\@-t\n".
- "\t${verbose}\$(am__cd) \$(srcdir) && $compile @vala_sources\n".
+ "\t${verbose}$compile \$^\n".
"\t${silent}mv -f \$\@-t \$\@\n";
push_dist_common ($stampfile);
--- /dev/null
+#! /bin/sh
+# Copyright (C) 2012-2020 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 2, 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 <http://www.gnu.org/licenses/>.
+
+# Building libraries (libtool and static) from Vala sources.
+# And use of vapi files to call C code from Vala.
+
+required="valac cc pkg-config libtoolize GNUmake"
+am_create_testdir=empty
+. test-init.sh
+
+cat >> configure.ac << 'END'
+AC_INIT([atest],[0.1])
+AC_CONFIG_SRCDIR([data/atest.pc.in])
+AC_SUBST([API_VERSION],[0])
+
+AM_INIT_AUTOMAKE
+AM_MAINTAINER_MODE([enable])
+AM_PROG_AR
+LT_INIT
+
+AC_PROG_CC
+AC_PROG_INSTALL
+PKG_PROG_PKG_CONFIG([0.22])
+AM_PROG_VALAC([0.32])
+
+PKG_CHECK_MODULES(ATEST, [gio-2.0])
+
+AC_CONFIG_FILES([
+ Makefile
+
+ src/Makefile
+
+ src/atest-$API_VERSION.deps:src/atest.deps.in
+
+ data/Makefile
+ data/atest-$API_VERSION.pc:data/atest.pc.in
+
+],[],
+[API_VERSION='$API_VERSION'])
+AC_OUTPUT
+END
+
+
+cat > Makefile.am << 'END'
+SUBDIRS=data src
+END
+
+mkdir data
+
+cat > data/atest.pc.in << 'END'
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+datarootdir=@datarootdir@
+datadir=@datadir@
+includedir=@includedir@
+
+Name: atest-@API_VERSION@
+Description: atest library
+Version: @VERSION@
+Requires: glib-2.0 gobject-2.0
+Libs: -L${libdir} -latest-@API_VERSION@
+Cflags: -I${includedir}/atest-@API_VERSION@
+END
+
+
+cat > data/Makefile.am << 'END'
+# pkg-config data
+# Note that the template file is called atest.pc.in, but generates a
+# versioned .pc file using some magic in AC_CONFIG_FILES.
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = atest-$(API_VERSION).pc
+
+DISTCLEANFILES = $(pkgconfig_DATA)
+EXTRA_DIST = atest.pc.in
+END
+
+mkdir src
+
+cat > src/atest.deps.in << 'END'
+glib-2.0
+END
+
+
+cat > src/atest.vala << 'END'
+using GLib;
+
+namespace Atest {
+ public class A {
+ public bool foo() { return false; }
+ }
+}
+END
+
+cat > src/Makefile.am << 'END'
+lib_LTLIBRARIES = libatest-@API_VERSION@.la
+
+libatest_@API_VERSION@_la_SOURCES = \
+ atest.vala \
+ cservice.c \
+ cservice.h \
+ $(NULL)
+
+
+libatest_@API_VERSION@_la_CPPFLAGS = \
+ -DOKOKIMDEFINED=1 \
+ $(NULL)
+
+libatest_@API_VERSION@_la_CFLAGS = \
+ $(ATEST_CFLAGS) \
+ $(WARN_CFLAGS) \
+ $(NULL)
+
+libatest_@API_VERSION@_la_LIBADD = \
+ $(ATEST_LIBS) \
+ $(NULL)
+
+libatest_@API_VERSION@_la_LDFLAGS = \
+ $(WARN_LDFLAGS) \
+ $(NULL)
+
+libatest_@API_VERSION@_la_VALAFLAGS = \
+ --vapidir=$(VAPIDIR) \
+ --vapidir=$(srcdir) \
+ --pkg cservice \
+ --thread \
+ --target-glib=2.44 \
+ --pkg glib-2.0 \
+ -H atest.h \
+ --library atest-@API_VERSION@ \
+ $(NULL)
+
+header_DATA=atest.h
+headerdir=$(includedir)/atest-@API_VERSION@/atest
+
+atest-@API_VERSION@.deps:
+ cp atest.deps atest-@API_VERSION@.deps
+
+vapi_DATA=atest-@API_VERSION@.vapi atest-@API_VERSION@.deps
+vapidir=$(VAPIDIR)
+
+CLEANFILES = atest-@API_VERSION@.deps
+END
+
+
+cat > src/cservice.c << 'END'
+#include "cservice.h"
+int c_service_mu_call (void)
+{
+ return OKOKIMDEFINED;
+}
+END
+
+cat > src/cservice.h << 'END'
+int c_service_mu (void);
+END
+
+cat > src/cservice.vapi <<'END'
+namespace CService {
+ public class Mu {
+ [CCode (cheader_filename = "cservice.h", cname = "c_service_mu_call")]
+ public int call ();
+ }
+}
+END
+
+libtoolize
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+./configure
+
+$MAKE
+test -f src/libatest_0_la_vala.stamp
+test -f src/libatest-0.la
+
+$MAKE distcheck
+
+:
--- /dev/null
+#! /bin/sh
+# Copyright (C) 2012-2020 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 2, 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 <http://www.gnu.org/licenses/>.
+
+# Building libraries (libtool and static) from Vala sources.
+# And use of vapi files to call C code from Vala.
+
+required="valac cc pkg-config libtoolize GNUmake"
+am_create_testdir=empty
+. test-init.sh
+
+cat >> configure.ac << 'END'
+AC_INIT([valalibs],[0.1])
+
+AC_CONFIG_MACRO_DIR([m4])
+
+AM_INIT_AUTOMAKE
+AM_PROG_AR
+LT_INIT
+
+AC_PROG_CC
+
+AM_PROG_VALAC([0.7.3])
+PKG_CHECK_MODULES([GOBJECT], [gobject-2.0 >= 2.4])
+
+AC_CONFIG_FILES([Makefile src/Makefile])
+AC_OUTPUT
+END
+
+
+cat > Makefile.am << 'END'
+SUBDIRS=src
+END
+
+mkdir src
+
+cat > src/Makefile.am << 'END'
+AUTOMAKE_OPTIONS = subdir-objects
+lib_LTLIBRARIES = libservice.la
+libservice_la_SOURCES = service.vala cservice.c cservice.h
+libservice_la_CPPFLAGS = -DOKOKIMDEFINED=1
+libservice_la_VALAFLAGS = --vapidir=$(srcdir) --pkg cservice --library service
+AM_CFLAGS = $(GOBJECT_CFLAGS)
+END
+
+libtoolize
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE -a
+
+cat > src/cservice.c << 'END'
+#include "cservice.h"
+int c_service_mu_call (void)
+{
+ return OKOKIMDEFINED;
+}
+END
+
+cat > src/cservice.h << 'END'
+int c_service_mu (void);
+END
+
+cat > src/cservice.vapi <<'END'
+namespace CService {
+ public class Mu {
+ [CCode (cheader_filename = "cservice.h", cname = "c_service_mu_call")]
+ public int call ();
+ }
+}
+END
+
+cat > src/service.vala << 'END'
+namespace CService {
+public class Generator : Object {
+ public Generator () {
+ stdout.printf ("construct generator");
+ }
+ public void init () {
+ stdout.printf ("init generator");
+ }
+}
+}
+END
+
+mkdir build
+cd build
+../configure
+
+$MAKE
+pwd
+test -f src/libservice_la_vala.stamp
+test -f src/libservice.la
+
+:
cat > Makefile.am << 'END'
AUTOMAKE_OPTIONS = subdir-objects
-lib_LIBRARIES = libmu.a
+lib_LIBRARIES = libservice.a
lib_LTLIBRARIES = src/libzardoz.la
-libmu_a_SOURCES = mu.vala mu2.c mu.vapi mu2.h
-libmu_a_CPPFLAGS = -DOKOKIMDEFINED=1
-libmu_a_VALAFLAGS = --vapidir=$(srcdir)
+libservice_a_SOURCES = service.vala cservice.c cservice.h
+libservice_a_CPPFLAGS = -DOKOKIMDEFINED=1
+libservice_a_VALAFLAGS = --vapidir=$(srcdir) --pkg cservice --library service
AM_CFLAGS = $(GOBJECT_CFLAGS)
src_libzardoz_la_LIBADD = $(GOBJECT_LIBS)
src_libzardoz_la_SOURCES = src/zardoz-foo.vala src/zardoz-bar.vala
./configure
-cat > mu2.c << 'END'
-#include "mu2.h"
-int mu2 (void)
+cat > cservice.c << 'END'
+#include "cservice.h"
+int c_service_mu_call (void)
{
return OKOKIMDEFINED;
}
END
-cat > mu2.h << 'END'
-int mu2 (void);
+cat > cservice.h << 'END'
+int c_service_mu (void);
END
-cat > mu.vapi <<'END'
-[CCode (cheader_filename = "mu2.h", cname = "mu2")]
-public int c_mu2 ();
+cat > cservice.vapi <<'END'
+namespace CService {
+ public class Mu {
+ [CCode (cheader_filename = "cservice.h", cname = "c_service_mu_call")]
+ public int call ();
+ }
+}
END
-cat > mu.vala << 'END'
-int main ()
-{
- stdout.printf ("mumumu\n");
- return c_mu2 ();
+cat > service.vala << 'END'
+namespace CService {
+public class Generator : Object {
+ public Generator () {
+ stdout.printf ("construct generator");
+ }
+ public void init () {
+ stdout.printf ("init generator");
+ }
+}
}
END
END
$MAKE
-test -f libmu.a
+test -f libservice.a
test -f src/libzardoz.la
-$FGREP "mumumu" mu.c
+$FGREP "construct generator" service.c
$FGREP "FooFooFoo" src/zardoz-foo.c
$FGREP "BarBarBar" src/zardoz-bar.c
-test -f libmu_a_vala.stamp
+test -f libservice_a_vala.stamp
test -f src_libzardoz_la_vala.stamp
$MAKE distcheck
./configure || skip_ "configure failure"
$MAKE
$MAKE distcheck
-$MAKE distclean
+$MAKE maintainer-clean
+
mkdir build
cd build
../configure
../configure
$MAKE -j6
ls -l . .. # For debugging.
-for x in main 1 2 3 4 5 6; do test -f ../$x.c; done
-test -f ../zardoz_vala.stamp
+for x in main 1 2 3 4 5 6; do test -f $x.c; done
+test -f ./zardoz_vala.stamp
$MAKE distcheck -j4
test -f src/xbar.c
$MAKE distclean
-test -f src/xfoo.c
-test -f src/xbar.c
+test ! -e src/xfoo.c
+test ! -e src/xbar.c
# Re-create Makefile.
mv config.sav config.status
# Check the distribution.
$MAKE distcheck
-$MAKE distclean
+$MAKE maintainer-clean
-# Tru a VPATH setup.
+# Try a VPATH setup.
mkdir build
cd build
# Test rebuild rules from builddir.
-rm -f ../src/zardoz.h
-$MAKE -C src ../../src/zardoz.h
-test -f ../src/zardoz.h
+rm src/zardoz.h
+$MAKE -C src zardoz.h
+test -f src/zardoz.h
-rm -f ../src/zardoz.c
+rm -f src/zardoz.c
$MAKE
-grep 'Zardoz!' ../src/zardoz.c
+grep 'Zardoz!' src/zardoz.c
$sleep
sed 's/Zardoz!/FooBar!/' ../src/zardoz.vala > t
mv -f t ../src/zardoz.vala
$MAKE
-grep 'FooBar!' ../src/zardoz.c
-grep 'Zardoz!' ../src/zardoz.c && exit 1
+grep 'FooBar!' src/zardoz.c
+grep 'Zardoz!' src/zardoz.c && exit 1
:
$ACLOCAL
$AUTOCONF
-$AUTOMAKE
+$AUTOMAKE -a
mkdir build
cd build
../configure
$MAKE
-test -f ../foo_vala.stamp
-test -f ../bar_vala.stamp
-grep foofoofoo ../hello.c
-test -f ../zardoz.h
+test -f ./foo_vala.stamp
+test -f ./bar_vala.stamp
+grep foofoofoo ./hello.c
+test -f ./zardoz.h
$MAKE distcheck
# Rebuild rules work also in VPATH builds.
END
$MAKE
-test -f ../foo_vala.stamp
-test -f ../bar_vala.stamp
-grep barbarbar ../hello.c
+test -f ./foo_vala.stamp
+test -f ./bar_vala.stamp
+grep barbarbar ./hello.c
+$MAKE distcheck
# Rebuild rules are not uselessly triggered.
$MAKE -q
# Cleanup rules work also in VPATH builds.
$MAKE clean
-test -f ../foo_vala.stamp
-test -f ../bar_vala.stamp
-test -f ../zardoz.h
-test -f ../hello.c
+test -f ./foo_vala.stamp
+test -f ./bar_vala.stamp
+test -f ./zardoz.h
+test -f ./hello.c
$MAKE maintainer-clean
-test ! -e ../zardoz.h
-test ! -e ../hello.c
-test ! -e ../foo_vala.stamp
-test ! -e ../bar_vala.stamp
+test ! -e ./zardoz.h
+test ! -e ./hello.c
+test ! -e ./foo_vala.stamp
+test ! -e ./bar_vala.stamp
: