I attach two patches. The first is a trivial documentation fix. The second
fixes a bug I ran into recently with Vala compilation.

I just needed to add some Vala source files to my program that are added to
the relevant _SOURCES variable conditionally:

if OS_WIN32
libenchant_la_SOURCES += api-windows.vala
else
libenchant_la_SOURCES += api-posix.vala
endif

(Motivation: the reason I have to add the files conditionally is two-fold:
first, api-windows.vala and api-posix.vala call APIs that are only
available on Windows and POSIX systems respectively. In itself, this does
not require conditional inclusion; I can use Vala preprocessor directives,
just as I would in C. But the Vala compiler generates C files, and I want
the user of my package not to need a Vala compiler. Therefore, the
generated C code must be independent of build-time configuration. Since the
Vala compiler does not generate C preprocessor directives, I have to do
conditional inclusion at build time some other way. So, I am doing it by
using automake conditionals.)

With current automake, something like the following Makefile line is
generated:

$(builddir)/libenchant_la_vala.stamp: api-windows.vala api-posix.vala…

With my patch, the following line is generated instead:

$(builddir)/libenchant_la_vala.stamp: $(libenchant_la_SOURCES)

Of course, $(libenchant_la_SOURCES) expands to the actual sources.

The patch is trivial, so hopefully it's obvious if there's a problem for
some reason! I hope I explained well enough what problem I'm trying to
solve.

-- 
https://rrt.sc3d.org
From 490777db71c2086cfbd3ec359fceca5fc853047d Mon Sep 17 00:00:00 2001
From: Reuben Thomas <r...@sc3d.org>
Date: Wed, 24 Apr 2024 22:41:48 +0200
Subject: [PATCH 2/2] vala: do not build Vala sources excluded by automake
 conditionals
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* bin/automake.in: make the _vala.stamp file depend on the relevant _SOURCES
variable’s value, not the fully-expanded list of all possible sources. This
means that source files added conditionally to a _SOURCES variable will only
be added when the condition is true.
---
 bin/automake.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/automake.in b/bin/automake.in
index 112730269..95129c294 100644
--- a/bin/automake.in
+++ b/bin/automake.in
@@ -5887,7 +5887,7 @@ sub lang_vala_finish_target
   my $stampfile = "\$(builddir)/${derived}_vala.stamp";
 
   $output_rules .=
-    "\$(builddir)/${derived}_vala.stamp: @vala_sources\n".
+    "\$(builddir)/${derived}_vala.stamp: \$(${derived}_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
-- 
2.34.1

From 32ad6da2af34725cbb771e8f3824370cd15a0540 Mon Sep 17 00:00:00 2001
From: Reuben Thomas <r...@sc3d.org>
Date: Wed, 24 Apr 2024 22:41:12 +0200
Subject: [PATCH 1/2] doc: add missing close parenthesis in comment.

* bin/automake.in: add missing close parenthesis.
---
 bin/automake.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bin/automake.in b/bin/automake.in
index 1dc40a00b..112730269 100644
--- a/bin/automake.in
+++ b/bin/automake.in
@@ -5809,7 +5809,7 @@ sub lang_vala_finish_target
           #
           # The -newer test here is checking "C file not older than Vala
           # file" (not "C file newer than Vala file"; see
-          # https://bugs.gnu.org/44772. The log message on the commit
+          # https://bugs.gnu.org/44772 ). The log message on the commit
           # misleadingly says "reversed".
           #
           $output_rules .= "$built_c_file: \$(builddir)/${derived}_vala.stamp\n"
-- 
2.34.1

Reply via email to