The git-version-gen thread reminded me that having include'able snippets
of these statements is increasingly useful...  I get tired of manually
syncing the Makefile.am snippets from gnulib manual on every update in
gnulib.

What do you think of a etc/make/git-version-gen.mk include snippet?

There should be some mechanism for gnulib-tool to add the files to
projects, so they are possible to 'include' from project makefiles.

Maybe simple to add a 'Files: etc/make/git-version-gen.mk' to
modules/git-version-gen?

Although I suspect gnulib-tool will have to be teached about a
--etc-base then.  Of the existing parameter, it feels like --aux-dir is
the most relevant:

      --aux-dir=DIRECTORY   Directory relative to --dir where auxiliary build
                            tools are placed (default comes from configure.ac).

So how about something like this?  It re-use the existing --aux-dir for
these files instead.

Untested, so please review and think about the concept.  I'll work on
testing this if there is no major discussion about it.

/Simon
From 00e4055222863fdbd0ac1592ba0bc34d8faa402e Mon Sep 17 00:00:00 2001
From: Simon Josefsson <si...@josefsson.org>
Date: Tue, 14 Jan 2025 07:37:31 +0100
Subject: [PATCH] git-version-gen: Add include makefile snippet.

* build-aux/git-version-gen.mk: New file.
* build-aux/git-version-gen: Mention file in documentation.
* modules/git-version-gen (Files): Add git-version-gen.mk.
---
 ChangeLog                    |  7 +++++++
 build-aux/git-version-gen    |  4 +++-
 build-aux/git-version-gen.mk | 35 +++++++++++++++++++++++++++++++++++
 modules/git-version-gen      |  1 +
 4 files changed, 46 insertions(+), 1 deletion(-)
 create mode 100644 build-aux/git-version-gen.mk

diff --git a/ChangeLog b/ChangeLog
index 86f886e236..f32627b467 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2025-01-14  Simon Josefsson  <si...@josefsson.org>
+
+	git-version-gen: Add include makefile snippet.
+	* build-aux/git-version-gen.mk: New file.
+	* build-aux/git-version-gen: Mention file in documentation.
+	* modules/git-version-gen (Files): Add git-version-gen.mk.
+
 2025-01-14  Simon Josefsson  <si...@josefsson.org>
 
 	git-version-gen: Use an indirect 'dist-hook' make rule instead.
diff --git a/build-aux/git-version-gen b/build-aux/git-version-gen
index 4ede151c8d..d14e0f91b3 100755
--- a/build-aux/git-version-gen
+++ b/build-aux/git-version-gen
@@ -82,9 +82,11 @@ scriptversion=2025-01-14.06; # UTC
 #	mv $@-t $@
 # dist-hook: tarball-version
 # .PHONY: tarball-version
-# tarball-version
+# tarball-version:
 #	echo '$(VERSION)' > $(distdir)/.tarball-version
 #
+# Considering using "include build-aux/git-version-gen.mk" instead.
+#
 # To setup support for "git archive" tarballs, use the following:
 #
 # echo '$Format:%(describe)$' > .tarball-version-git
diff --git a/build-aux/git-version-gen.mk b/build-aux/git-version-gen.mk
new file mode 100644
index 0000000000..1abeb85e8e
--- /dev/null
+++ b/build-aux/git-version-gen.mk
@@ -0,0 +1,35 @@
+# Copyright (C) 2007-2025 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 of the License, 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 <https://www.gnu.org/licenses/>.
+
+# This file is intended to be included from your top-level Makefile.am
+# like this:
+#
+# include build-aux/git-version-gen.mk
+#
+# It is assumed that EXTRA_DIST and BUILT_SOURCES are variables where
+# it is possible to use += on.
+
+EXTRA_DIST += $(top_srcdir)/.version
+BUILT_SOURCES += $(top_srcdir)/.version
+$(top_srcdir)/.version:
+        echo '$(VERSION)' > $@-t
+        mv $@-t $@
+
+dist-hook: tarball-version
+
+.PHONY: tarball-version
+
+tarball-version:
+        echo '$(VERSION)' > $(distdir)/.tarball-version
diff --git a/modules/git-version-gen b/modules/git-version-gen
index a783ac570d..31b9545357 100644
--- a/modules/git-version-gen
+++ b/modules/git-version-gen
@@ -3,6 +3,7 @@ Compute a version string from a git repository.
 
 Files:
 build-aux/git-version-gen
+build-aux/git-version-gen.mk
 
 Depends-on:
 
-- 
2.47.1

Attachment: signature.asc
Description: PGP signature

Reply via email to