From dea60a3418812ed649acd5aaf75a10a03bea055d Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@meta.com>
Date: Wed, 3 Jul 2024 12:32:34 -0700
Subject: [PATCH] derive VERSION from RELEASE only if specified on command line

* top/maint.mk (VERSION, RELEASE_TYPE): Do not let an environment-
specified RELEASE influence the VERSION and RELEASE_TYPE variables.
Reported by Simon Josefsson in
https://lists.gnu.org/archive/html/bug-gnulib/2024-07/msg00021.html
---
 ChangeLog    | 8 ++++++++
 top/maint.mk | 6 ++++--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index effda3a4a9..7d594c4eae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2024-07-03  Jim Meyering  <meyering@meta.com>
+
+	derive VERSION from RELEASE only if specified on command line
+	* top/maint.mk (VERSION, RELEASE_TYPE): Do not let an environment-
+	specified RELEASE influence the VERSION and RELEASE_TYPE variables.
+	Reported by Simon Josefsson in
+	https://lists.gnu.org/archive/html/bug-gnulib/2024-07/msg00021.html
+
 2024-06-28  Bruno Haible  <bruno@clisp.org>

 	doc: Mention pthread_cond_timedwait bug caused by hypervisor.
diff --git a/top/maint.mk b/top/maint.mk
index 2f35253fb7..de2aff8b9b 100644
--- a/top/maint.mk
+++ b/top/maint.mk
@@ -124,8 +124,10 @@ release_archive_dir ?= ../release
 # If RELEASE_TYPE is undefined, but RELEASE is, use its second word.
 # But overwrite VERSION.
 ifdef RELEASE
-  VERSION := $(word 1, $(RELEASE))
-  RELEASE_TYPE ?= $(word 2, $(RELEASE))
+  ifeq ($(origin RELEASE),command line)
+    VERSION := $(word 1,$(RELEASE))
+    RELEASE_TYPE ?= $(word 2,$(RELEASE))
+  endif
 endif

 # Validate and return $(RELEASE_TYPE), or die.
-- 
2.45.2

