Package: dpkg-dev
Followup-For: Bug #872381

Of course,
-dpkg_datadir := $(shell $(dir $(lastword $(MAKEFILE_LIST))))
+dpkg_datadir := $(dir $(lastword $(MAKEFILE_LIST)))

Hello.
I have rebased the changes and taken your explanations into
account. This new patch queue is not tested again, but should be
easyer to review.
>From 5852b310ea8cdd519a0f7d6e1099c3c54db026ed Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <nico...@debian.org>
Date: Mon, 29 Jul 2019 14:38:32 +0200
Subject: [PATCH 01/10] scripts/mk: stop hard-coding dpkg_datadir

The Makefile snippets include each other from their common directory,
but the path differ during tests and after installation.  Instead of
rewriting the file with a hardcoded path, compute it within Make.
---
 build-aux/subst.am       |  6 ------
 scripts/mk/Makefile.am   | 17 -----------------
 scripts/mk/buildtools.mk |  3 +--
 scripts/mk/default.mk    | 12 ++++++------
 4 files changed, 7 insertions(+), 31 deletions(-)

diff --git a/build-aux/subst.am b/build-aux/subst.am
index 74a40bf0b..4cd4bdca8 100644
--- a/build-aux/subst.am
+++ b/build-aux/subst.am
@@ -38,9 +38,3 @@ SUFFIXES += .pl
 	@test -d `dirname $@` || $(MKDIR_P) `dirname $@`
 	$(do_perl_subst) <$< >$@
 	$(AM_V_at) chmod +x $@
-
-# Makefile support.
-
-do_make_subst = $(AM_V_GEN) $(SED) \
-	-e "s:dpkg_datadir[[:space:]]*=[[:space:]]*[^[:space:]]*:dpkg_datadir = $(pkgdatadir):" \
-	# EOL
diff --git a/scripts/mk/Makefile.am b/scripts/mk/Makefile.am
index 62d8592d2..0c635bf00 100644
--- a/scripts/mk/Makefile.am
+++ b/scripts/mk/Makefile.am
@@ -9,20 +9,3 @@ dist_pkgdata_DATA = \
 	pkg-info.mk \
 	vendor.mk \
 	# EOL
-
-SUFFIXES =
-
-include $(top_srcdir)/build-aux/subst.am
-
-install-data-hook:
-	mv $(DESTDIR)$(pkgdatadir)/default.mk \
-	   $(DESTDIR)$(pkgdatadir)/default.mk.tmp
-	$(do_make_subst) <$(DESTDIR)$(pkgdatadir)/default.mk.tmp \
-	                 >$(DESTDIR)$(pkgdatadir)/default.mk
-	rm -f $(DESTDIR)$(pkgdatadir)/default.mk.tmp
-
-	mv $(DESTDIR)$(pkgdatadir)/buildtools.mk \
-	   $(DESTDIR)$(pkgdatadir)/buildtools.mk.tmp
-	$(do_make_subst) <$(DESTDIR)$(pkgdatadir)/buildtools.mk.tmp \
-	                 >$(DESTDIR)$(pkgdatadir)/buildtools.mk
-	rm -f $(DESTDIR)$(pkgdatadir)/buildtools.mk.tmp
diff --git a/scripts/mk/buildtools.mk b/scripts/mk/buildtools.mk
index b2ab2a2ac..5cd9151f1 100644
--- a/scripts/mk/buildtools.mk
+++ b/scripts/mk/buildtools.mk
@@ -26,8 +26,7 @@
 # The variables are not exported by default. This can be changed by
 # defining DPKG_EXPORT_BUILDTOOLS.
 
-dpkg_datadir = $(srcdir)/mk
-include $(dpkg_datadir)/architecture.mk
+include $(dir $(lastword $(MAKEFILE_LIST)))architecture.mk
 
 # We set the TOOL_FOR_BUILD variables to the specified value, and the TOOL
 # variables (for the host) to the their triplet-prefixed form iff they are
diff --git a/scripts/mk/default.mk b/scripts/mk/default.mk
index 3916a0c24..afe5d6876 100644
--- a/scripts/mk/default.mk
+++ b/scripts/mk/default.mk
@@ -1,9 +1,9 @@
 # This Makefile fragment (since dpkg 1.16.1) includes all the Makefile
 # fragments that define variables that can be useful within debian/rules.
 
-dpkg_datadir = $(srcdir)/mk
-include $(dpkg_datadir)/architecture.mk
-include $(dpkg_datadir)/buildflags.mk
-include $(dpkg_datadir)/buildopts.mk
-include $(dpkg_datadir)/pkg-info.mk
-include $(dpkg_datadir)/vendor.mk
+dpkg_datadir := $(dir $(lastword $(MAKEFILE_LIST)))
+include $(dpkg_datadir)architecture.mk
+include $(dpkg_datadir)buildflags.mk
+include $(dpkg_datadir)buildopts.mk
+include $(dpkg_datadir)pkg-info.mk
+include $(dpkg_datadir)vendor.mk
-- 
2.30.2

>From 94c84d34ff28d81f2fceef797fa8314d7b03fb23 Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <nico...@debian.org>
Date: Thu, 11 Feb 2021 15:36:15 +0100
Subject: [PATCH 02/10] scripts/t: test SOURCE_DATE_EPOCH

Set SOURCE_DATE_EPOCH either from the environment or the Debian changelog.
Check that the value is (re)exported.
---
 scripts/t/mk.t           | 9 ++++++++-
 scripts/t/mk/pkg-info.mk | 2 ++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/scripts/t/mk.t b/scripts/t/mk.t
index 10e030a16..25e25d56c 100644
--- a/scripts/t/mk.t
+++ b/scripts/t/mk.t
@@ -16,7 +16,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 10;
+use Test::More tests => 11;
 use Test::Dpkg qw(:paths);
 
 use File::Spec::Functions qw(rel2abs);
@@ -131,6 +131,13 @@ foreach my $tool (keys %buildtools) {
     delete $ENV{"${tool}_FOR_BUILD"};
 }
 
+delete $ENV{SOURCE_DATE_EPOCH};
+$ENV{TEST_SOURCE_DATE_EPOCH} = `date +%s -d "Tue, 04 Aug 2015 16:13:50 +0200"`;
+chomp $ENV{TEST_SOURCE_DATE_EPOCH};
+test_makefile('pkg-info.mk');
+
+$ENV{SOURCE_DATE_EPOCH} = 100;
+$ENV{TEST_SOURCE_DATE_EPOCH} = 100;
 test_makefile('pkg-info.mk');
 
 test_makefile('vendor.mk');
diff --git a/scripts/t/mk/pkg-info.mk b/scripts/t/mk/pkg-info.mk
index 22a2bf44f..c0e3287b5 100644
--- a/scripts/t/mk/pkg-info.mk
+++ b/scripts/t/mk/pkg-info.mk
@@ -7,3 +7,5 @@ test:
 	test "$(DEB_VERSION_UPSTREAM_REVISION)" = "2:3.4-5-6"
 	test "$(DEB_VERSION_UPSTREAM)" = "2:3.4-5"
 	test "$(DEB_DISTRIBUTION)" = "suite"
+	test '$(SOURCE_DATE_EPOCH)' = '$(TEST_SOURCE_DATE_EPOCH)'
+	test "$${SOURCE_DATE_EPOCH}" = '$(TEST_SOURCE_DATE_EPOCH)'
-- 
2.30.2

>From 32c2fad6ef96479afcffc38b40f8b2e82d3c46c4 Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <nico...@debian.org>
Date: Thu, 11 Feb 2021 15:45:03 +0100
Subject: [PATCH 03/10] scripts/t: slightly optimize hash traversals

Iterate on key/value pairs instead of iterating on keys then search
for each value.
---
 scripts/t/mk.t | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/scripts/t/mk.t b/scripts/t/mk.t
index 25e25d56c..139b19455 100644
--- a/scripts/t/mk.t
+++ b/scripts/t/mk.t
@@ -74,10 +74,15 @@ sub cmd_get_vars {
 
 my %arch = cmd_get_vars($ENV{PERL}, "$srcdir/dpkg-architecture.pl", '-f');
 
-delete $ENV{$_} foreach keys %arch;
-$ENV{"TEST_$_"} = $arch{$_} foreach keys %arch;
+while (my ($k, $v) = each %arch) {
+    delete $ENV{$k};
+    $ENV{"TEST_$k"} = $v;
+}
 test_makefile('architecture.mk', 'without envvars');
-$ENV{$_} = $arch{$_} foreach keys %arch;
+
+while (my ($k, $v) = each %arch) {
+    $ENV{$k} = $v;
+}
 test_makefile('architecture.mk', 'with envvars');
 
 $ENV{DEB_BUILD_OPTIONS} = 'parallel=16';
@@ -88,8 +93,10 @@ delete $ENV{TEST_DEB_BUILD_OPTION_PARALLEL};
 
 my %buildflag = cmd_get_vars($ENV{PERL}, "$srcdir/dpkg-buildflags.pl");
 
-delete $ENV{$_} foreach keys %buildflag;
-$ENV{"TEST_$_"} = $buildflag{$_} foreach keys %buildflag;
+while (my ($k, $v) = each %buildflag) {
+    delete $ENV{$k};
+    $ENV{"TEST_$k"} = $v;
+}
 test_makefile('buildflags.mk');
 
 my %buildtools = (
@@ -112,11 +119,11 @@ my %buildtools = (
     PKG_CONFIG => 'pkg-config',
 );
 
-foreach my $tool (keys %buildtools) {
+while (my ($tool, $default) = each %buildtools) {
     delete $ENV{$tool};
-    $ENV{"TEST_$tool"} = "$ENV{DEB_HOST_GNU_TYPE}-$buildtools{$tool}";
+    $ENV{"TEST_$tool"} = "$ENV{DEB_HOST_GNU_TYPE}-$default";
     delete $ENV{"${tool}_FOR_BUILD"};
-    $ENV{"TEST_${tool}_FOR_BUILD"} = "$ENV{DEB_BUILD_GNU_TYPE}-$buildtools{$tool}";
+    $ENV{"TEST_${tool}_FOR_BUILD"} = "$ENV{DEB_BUILD_GNU_TYPE}-$default";
 }
 test_makefile('buildtools.mk', 'without envvars');
 
-- 
2.30.2

>From cb0d31dc92f61144150ad2b042a01987540e0ddf Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <nico...@debian.org>
Date: Thu, 11 Feb 2021 16:09:48 +0100
Subject: [PATCH 04/10] scripts/t: use loops instead of repetitions, check
 exports and overrides

Replace copied lines with Make loops.

Add tests: architecture variable override, buildflags set and export,
buildtool override and export.
---
 scripts/t/mk/architecture.mk | 57 +++++++++++++-------------------
 scripts/t/mk/buildflags.mk   | 38 +++++++++++++++-------
 scripts/t/mk/buildtools.mk   | 63 +++++++++++++++++-------------------
 3 files changed, 79 insertions(+), 79 deletions(-)

diff --git a/scripts/t/mk/architecture.mk b/scripts/t/mk/architecture.mk
index 2ac0222ca..a938a6d6c 100644
--- a/scripts/t/mk/architecture.mk
+++ b/scripts/t/mk/architecture.mk
@@ -1,36 +1,25 @@
+DEB_BUILD_ARCH := overridden
+
 include $(srcdir)/mk/architecture.mk
 
-test:
-	test "$(DEB_BUILD_ARCH)" = "$(TEST_DEB_BUILD_ARCH)"
-	test "$(DEB_BUILD_ARCH_ABI)" = "$(TEST_DEB_BUILD_ARCH_ABI)"
-	test "$(DEB_BUILD_ARCH_BITS)" = "$(TEST_DEB_BUILD_ARCH_BITS)"
-	test "$(DEB_BUILD_ARCH_CPU)" = "$(TEST_DEB_BUILD_ARCH_CPU)"
-	test "$(DEB_BUILD_ARCH_ENDIAN)" = "$(TEST_DEB_BUILD_ARCH_ENDIAN)"
-	test "$(DEB_BUILD_ARCH_LIBC)" = "$(TEST_DEB_BUILD_ARCH_LIBC)"
-	test "$(DEB_BUILD_ARCH_OS)" = "$(TEST_DEB_BUILD_ARCH_OS)"
-	test "$(DEB_BUILD_GNU_CPU)" = "$(TEST_DEB_BUILD_GNU_CPU)"
-	test "$(DEB_BUILD_GNU_SYSTEM)" = "$(TEST_DEB_BUILD_GNU_SYSTEM)"
-	test "$(DEB_BUILD_GNU_TYPE)" = "$(TEST_DEB_BUILD_GNU_TYPE)"
-	test "$(DEB_BUILD_MULTIARCH)" = "$(TEST_DEB_BUILD_MULTIARCH)"
-	test "$(DEB_HOST_ARCH)" = "$(TEST_DEB_HOST_ARCH)"
-	test "$(DEB_HOST_ARCH_ABI)" = "$(TEST_DEB_HOST_ARCH_ABI)"
-	test "$(DEB_HOST_ARCH_BITS)" = "$(TEST_DEB_HOST_ARCH_BITS)"
-	test "$(DEB_HOST_ARCH_CPU)" = "$(TEST_DEB_HOST_ARCH_CPU)"
-	test "$(DEB_HOST_ARCH_ENDIAN)" = "$(TEST_DEB_HOST_ARCH_ENDIAN)"
-	test "$(DEB_HOST_ARCH_LIBC)" = "$(TEST_DEB_HOST_ARCH_LIBC)"
-	test "$(DEB_HOST_ARCH_OS)" = "$(TEST_DEB_HOST_ARCH_OS)"
-	test "$(DEB_HOST_GNU_CPU)" = "$(TEST_DEB_HOST_GNU_CPU)"
-	test "$(DEB_HOST_GNU_SYSTEM)" = "$(TEST_DEB_HOST_GNU_SYSTEM)"
-	test "$(DEB_HOST_GNU_TYPE)" = "$(TEST_DEB_HOST_GNU_TYPE)"
-	test "$(DEB_HOST_MULTIARCH)" = "$(TEST_DEB_HOST_MULTIARCH)"
-	test "$(DEB_TARGET_ARCH)" = "$(TEST_DEB_TARGET_ARCH)"
-	test "$(DEB_TARGET_ARCH_ABI)" = "$(TEST_DEB_TARGET_ARCH_ABI)"
-	test "$(DEB_TARGET_ARCH_BITS)" = "$(TEST_DEB_TARGET_ARCH_BITS)"
-	test "$(DEB_TARGET_ARCH_CPU)" = "$(TEST_DEB_TARGET_ARCH_CPU)"
-	test "$(DEB_TARGET_ARCH_ENDIAN)" = "$(TEST_DEB_TARGET_ARCH_ENDIAN)"
-	test "$(DEB_TARGET_ARCH_LIBC)" = "$(TEST_DEB_TARGET_ARCH_LIBC)"
-	test "$(DEB_TARGET_ARCH_OS)" = "$(TEST_DEB_TARGET_ARCH_OS)"
-	test "$(DEB_TARGET_GNU_CPU)" = "$(TEST_DEB_TARGET_GNU_CPU)"
-	test "$(DEB_TARGET_GNU_SYSTEM)" = "$(TEST_DEB_TARGET_GNU_SYSTEM)"
-	test "$(DEB_TARGET_GNU_TYPE)" = "$(TEST_DEB_TARGET_GNU_TYPE)"
-	test "$(DEB_TARGET_MULTIARCH)" = "$(TEST_DEB_TARGET_MULTIARCH)"
+vars := $(foreach machine,BUILD HOST TARGET,$(foreach var,\
+  ARCH \
+  ARCH_ABI \
+  ARCH_BITS \
+  ARCH_CPU \
+  ARCH_ENDIAN \
+  ARCH_LIBC \
+  ARCH_OS \
+  GNU_CPU \
+  GNU_SYSTEM \
+  GNU_TYPE \
+  MULTIARCH \
+  ,DEB_$(machine)_$(var)))
+
+test: $(vars)
+DEB_BUILD_ARCH:
+	test '$($@)' = overridden
+	test "$${$@}" = overridden
+$(filter-out DEB_BUILD_ARCH,$(vars)):
+	test '$($@)' = '$(TEST_$@)'
+	test "$${$@}" = '$(TEST_$@)'
diff --git a/scripts/t/mk/buildflags.mk b/scripts/t/mk/buildflags.mk
index 542bced43..83b583597 100644
--- a/scripts/t/mk/buildflags.mk
+++ b/scripts/t/mk/buildflags.mk
@@ -1,16 +1,30 @@
 DEB_CPPFLAGS_MAINT_APPEND = -DTEST_MK=test
+DEB_CXXFLAGS_MAINT_SET := set
+DPKG_EXPORT_BUILDFLAGS := 1
 
 include $(srcdir)/mk/buildflags.mk
 
-test:
-	test "$(ASFLAGS)" = "$(TEST_ASFLAGS)"
-	test "$(CFLAGS)" = "$(TEST_CFLAGS)"
-	test "$(CPPFLAGS)" = "$(TEST_CPPFLAGS) -DTEST_MK=test"
-	test "$(CXXFLAGS)" = "$(TEST_CXXFLAGS)"
-	test "$(DFLAGS)" = "$(TEST_DFLAGS)"
-	test "$(FCFLAGS)" = "$(TEST_FCFLAGS)"
-	test "$(FFLAGS)" = "$(TEST_FFLAGS)"
-	test "$(GCJFLAGS)" = "$(TEST_GCJFLAGS)"
-	test "$(LDFLAGS)" = "$(TEST_LDFLAGS)"
-	test "$(OBJCFLAGS)" = "$(TEST_OBJCFLAGS)"
-	test "$(OBJCXXFLAGS)" = "$(TEST_OBJCXXFLAGS)"
+vars := \
+  ASFLAGS \
+  CFLAGS \
+  CPPFLAGS \
+  CXXFLAGS \
+  DFLAGS \
+  FCFLAGS \
+  FFLAGS \
+  GCJFLAGS \
+  LDFLAGS \
+  OBJCFLAGS \
+  OBJCXXFLAGS \
+  # EOL
+
+test: $(vars)
+CPPFLAGS:
+	test '$($@)' = '$(TEST_$@) -DTEST_MK=test'
+	test "$${$@}" = '$(TEST_$@) -DTEST_MK=test'
+CXXFLAGS:
+	test '$($@)' = set
+	test "$${$@}" = set
+$(filter-out CPPFLAGS CXXFLAGS,$(vars)):
+	test '$($@)' = '$(TEST_$@)'
+	test "$${$@}" = '$(TEST_$@)'
diff --git a/scripts/t/mk/buildtools.mk b/scripts/t/mk/buildtools.mk
index 0077791b5..2fe049818 100644
--- a/scripts/t/mk/buildtools.mk
+++ b/scripts/t/mk/buildtools.mk
@@ -1,35 +1,32 @@
+AR := overridden
+DPKG_EXPORT_BUILDTOOLS := 1
+
 include $(srcdir)/mk/buildtools.mk
 
-test:
-	test "$(AS)" = "$(TEST_AS)"
-	test "$(AS_FOR_BUILD)" = "$(TEST_AS_FOR_BUILD)"
-	test "$(CC)" = "$(TEST_CC)"
-	test "$(CC_FOR_BUILD)" = "$(TEST_CC_FOR_BUILD)"
-	test "$(CXX)" = "$(TEST_CXX)"
-	test "$(CXX_FOR_BUILD)" = "$(TEST_CXX_FOR_BUILD)"
-	test "$(OBJC)" = "$(TEST_OBJC)"
-	test "$(OBJC_FOR_BUILD)" = "$(TEST_OBJC_FOR_BUILD)"
-	test "$(OBJCXX)" = "$(TEST_OBJCXX)"
-	test "$(OBJCXX_FOR_BUILD)" = "$(TEST_OBJCXX_FOR_BUILD)"
-	test "$(GCJ)" = "$(TEST_GCJ)"
-	test "$(GCJ_FOR_BUILD)" = "$(TEST_GCJ_FOR_BUILD)"
-	test "$(F77)" = "$(TEST_F77)"
-	test "$(F77_FOR_BUILD)" = "$(TEST_F77_FOR_BUILD)"
-	test "$(FC)" = "$(TEST_FC)"
-	test "$(FC_FOR_BUILD)" = "$(TEST_FC_FOR_BUILD)"
-	test "$(LD)" = "$(TEST_LD)"
-	test "$(LD_FOR_BUILD)" = "$(TEST_LD_FOR_BUILD)"
-	test "$(STRIP)" = "$(TEST_STRIP)"
-	test "$(STRIP_FOR_BUILD)" = "$(TEST_STRIP_FOR_BUILD)"
-	test "$(OBJCOPY)" = "$(TEST_OBJCOPY)"
-	test "$(OBJCOPY_FOR_BUILD)" = "$(TEST_OBJCOPY_FOR_BUILD)"
-	test "$(OBJDUMP)" = "$(TEST_OBJDUMP)"
-	test "$(OBJDUMP_FOR_BUILD)" = "$(TEST_OBJDUMP_FOR_BUILD)"
-	test "$(NM)" = "$(TEST_NM)"
-	test "$(NM_FOR_BUILD)" = "$(TEST_NM_FOR_BUILD)"
-	test "$(AR)" = "$(TEST_AR)"
-	test "$(AR_FOR_BUILD)" = "$(TEST_AR_FOR_BUILD)"
-	test "$(RANLIB)" = "$(TEST_RANLIB)"
-	test "$(RANLIB_FOR_BUILD)" = "$(TEST_RANLIB_FOR_BUILD)"
-	test "$(PKG_CONFIG)" = "$(TEST_PKG_CONFIG)"
-	test "$(PKG_CONFIG_FOR_BUILD)" = "$(TEST_PKG_CONFIG_FOR_BUILD)"
+vars := $(foreach tool,\
+  AR \
+  AS \
+  CC \
+  CPP \
+  CXX \
+  F77 \
+  FC \
+  GCJ \
+  LD \
+  NM \
+  OBJC \
+  OBJCOPY \
+  OBJCXX \
+  OBJDUMP \
+  PKG_CONFIG \
+  RANLIB \
+  STRIP \
+  ,$(tool) $(tool)_FOR_BUILD)
+
+test: $(vars)
+AR AR_FOR_BUILD:
+	test '$($@)' = overridden
+	test "$${$@}" = overridden
+$(filter-out AR AR_FOR_BUILD,$(vars)):
+	test '$($@)' = '$(TEST_$@)'
+	test "$${$@}" = '$(TEST_$@)'
-- 
2.30.2

>From d27c9abc9d88a76c98597ee872adefd7c2dedd6a Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <nico...@debian.org>
Date: Thu, 11 Feb 2021 16:34:23 +0100
Subject: [PATCH 05/10] scripts/buildtools.mk: remove unneeded conditionals

The ?= had no effect when the previous test was succeeding.  Make that
explicit with an 'else'.

The 'ifdef' was always succeeding because previous stanza sets $1.
---
 scripts/mk/buildtools.mk | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/scripts/mk/buildtools.mk b/scripts/mk/buildtools.mk
index 5cd9151f1..d2b195515 100644
--- a/scripts/mk/buildtools.mk
+++ b/scripts/mk/buildtools.mk
@@ -36,16 +36,16 @@ define dpkg_buildtool_setvar
 ifeq (,$(findstring $(3),$(DEB_BUILD_OPTIONS)))
 ifeq ($(origin $(1)),default)
 $(1) = $(DEB_HOST_GNU_TYPE)-$(2)
-endif
+else
 $(1) ?= $(DEB_HOST_GNU_TYPE)-$(2)
+endif
 
 # On native build fallback to use TOOL if that's defined.
 ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
-ifdef $(1)
 $(1)_FOR_BUILD ?= $$($(1))
-endif
-endif
+else
 $(1)_FOR_BUILD ?= $(DEB_BUILD_GNU_TYPE)-$(2)
+endif
 else
 $(1) = :
 $(1)_FOR_BUILD = :
-- 
2.30.2

>From 26df5b04bb981bf9f1a23bf2341f5de1854e5daa Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <nicolas.bouleng...@free.fr>
Date: Sat, 13 Feb 2021 09:58:27 +0100
Subject: [PATCH 06/10] scripts/buildtools.mk: indent for readability

---
 scripts/mk/buildtools.mk | 43 +++++++++++++++++++++-------------------
 1 file changed, 23 insertions(+), 20 deletions(-)

diff --git a/scripts/mk/buildtools.mk b/scripts/mk/buildtools.mk
index d2b195515..a42011c3b 100644
--- a/scripts/mk/buildtools.mk
+++ b/scripts/mk/buildtools.mk
@@ -33,28 +33,31 @@ include $(dir $(lastword $(MAKEFILE_LIST)))architecture.mk
 # not defined or contain the make built-in defaults. On native builds if
 # TOOL is defined and TOOL_FOR_BUILD is not, we fallback to use TOOL.
 define dpkg_buildtool_setvar
-ifeq (,$(findstring $(3),$(DEB_BUILD_OPTIONS)))
-ifeq ($(origin $(1)),default)
-$(1) = $(DEB_HOST_GNU_TYPE)-$(2)
-else
-$(1) ?= $(DEB_HOST_GNU_TYPE)-$(2)
-endif
 
-# On native build fallback to use TOOL if that's defined.
-ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
-$(1)_FOR_BUILD ?= $$($(1))
-else
-$(1)_FOR_BUILD ?= $(DEB_BUILD_GNU_TYPE)-$(2)
-endif
-else
-$(1) = :
-$(1)_FOR_BUILD = :
-endif
+  ifeq (,$(findstring $(3),$(DEB_BUILD_OPTIONS)))
+
+    ifeq ($(origin $(1)),default)
+      $(1) = $(DEB_HOST_GNU_TYPE)-$(2)
+    else
+      $(1) ?= $(DEB_HOST_GNU_TYPE)-$(2)
+    endif
+
+    # On native build fallback to use TOOL if that's defined.
+    ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
+      $(1)_FOR_BUILD ?= $$($(1))
+    else
+      $(1)_FOR_BUILD ?= $(DEB_BUILD_GNU_TYPE)-$(2)
+    endif
+
+  else
+    $(1) = :
+    $(1)_FOR_BUILD = :
+  endif
+
+  ifdef DPKG_EXPORT_BUILDTOOLS
+    export $(1) $(1)_FOR_BUILD
+  endif
 
-ifdef DPKG_EXPORT_BUILDTOOLS
-export $(1)
-export $(1)_FOR_BUILD
-endif
 endef
 
 $(eval $(call dpkg_buildtool_setvar,AS,as))
-- 
2.30.2

>From cb1a48beaa613b7f55dee0842afbd5ba51495b74 Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <nico...@debian.org>
Date: Mon, 1 Nov 2021 10:08:08 +0100
Subject: [PATCH 07/10] scripts/mk/buildopts.mk: small optimisations

Assign DEB_BUILD_OPTION_PARALLEL with := so that the value is computed
only once instead of every time the variable is used.
The maintainer is not supposed to modify DEB_BUILD_OPTIONS.

Always define DEB_BUILD_OPTION_PARALLEL, even if empty when
DEB_BUILD_OPTIONS does not contain parallel=%.
The distinction between DEB_BUILD_OPTIONS= and
DEB_BUILD_OPTIONS=parallel= does probably not deserve a test.
---
 scripts/mk/buildopts.mk | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/scripts/mk/buildopts.mk b/scripts/mk/buildopts.mk
index c95777719..420b6359c 100644
--- a/scripts/mk/buildopts.mk
+++ b/scripts/mk/buildopts.mk
@@ -5,6 +5,5 @@
 #
 #   DEB_BUILD_OPTION_PARALLEL: the argument for the parallel=N option.
 
-ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
-  DEB_BUILD_OPTION_PARALLEL = $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS)))
-endif
+DEB_BUILD_OPTION_PARALLEL := $(patsubst parallel=%,%,\
+                               $(filter parallel=%,$(DEB_BUILD_OPTIONS)))
-- 
2.30.2

>From 4d63491c8dc9c6df85f0472d00f34c82e91ec05e Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <nico...@debian.org>
Date: Thu, 11 Feb 2021 16:26:50 +0100
Subject: [PATCH 08/10] scripts/mk: reduce the number of subprocesses

architecture.mk and buildflags.mk spawn less subshells, improving the
overall speed (the tests run twice faster according to bash time
builtin).

pkg-info.mk uses the same trick than buildflags.mk in order to spawn
at most one subshell. The performance gain is visible, but minor
because there are way less variables.
---
 scripts/mk/architecture.mk | 18 +++++++++++-----
 scripts/mk/buildflags.mk   | 23 ++++++++++++++------
 scripts/mk/pkg-info.mk     | 44 +++++++++++++++++++++++++++++++-------
 3 files changed, 66 insertions(+), 19 deletions(-)

diff --git a/scripts/mk/architecture.mk b/scripts/mk/architecture.mk
index 2aa115822..198e5e145 100644
--- a/scripts/mk/architecture.mk
+++ b/scripts/mk/architecture.mk
@@ -2,10 +2,18 @@
 # DEB_BUILD_* variables that dpkg-architecture can return. Existing values
 # of those variables are preserved as per policy.
 
-dpkg_lazy_eval ?= $$(or $$(value DPKG_CACHE_$(1)),$$(eval DPKG_CACHE_$(1) := $$(shell $(2)))$$(value DPKG_CACHE_$(1)))
-
-dpkg_architecture_setvar = export $(1) ?= $(call dpkg_lazy_eval,$(1),dpkg-architecture -q$(1))
-
+dpkg-architecture_vars := \
 $(foreach machine,BUILD HOST TARGET,\
   $(foreach var,ARCH ARCH_ABI ARCH_LIBC ARCH_OS ARCH_CPU ARCH_BITS ARCH_ENDIAN GNU_CPU GNU_SYSTEM GNU_TYPE MULTIARCH,\
-    $(eval $(call dpkg_architecture_setvar,DEB_$(machine)_$(var)))))
+    DEB_$(machine)_$(var)))
+
+# Spare a subprocess in the frequent case where dpkg-buildpackage
+# has already exported all variables.
+ifneq (,$(filter undefined,$(foreach v,$(dpkg-architecture_vars),$(origin $(v)))))
+
+  # ?= preserves overriddes from debian/rules or its command line.
+  $(foreach v,$(subst =,?=,$(shell dpkg-architecture)),$(eval $(v)))
+
+endif
+
+export $(dpkg-architecture_vars)
diff --git a/scripts/mk/buildflags.mk b/scripts/mk/buildflags.mk
index 9c2a27169..856dbfc32 100644
--- a/scripts/mk/buildflags.mk
+++ b/scripts/mk/buildflags.mk
@@ -18,11 +18,13 @@
 # This list is kept in sync with the default set of flags returned
 # by dpkg-buildflags.
 
-dpkg_lazy_eval ?= $$(or $$(value DPKG_CACHE_$(1)),$$(eval DPKG_CACHE_$(1) := $$(shell $(2)))$$(value DPKG_CACHE_$(1)))
-
 DPKG_BUILDFLAGS_LIST = ASFLAGS CFLAGS CPPFLAGS CXXFLAGS OBJCFLAGS OBJCXXFLAGS \
                        GCJFLAGS DFLAGS FFLAGS FCFLAGS LDFLAGS
 
+# Accumulate the parameters for dpkg-buildflags, in case it is ever
+# called.
+
+DPKG_BUILDFLAGS_EXPORT_ENVVAR :=
 define dpkg_buildflags_export_envvar
 ifdef $(1)
 DPKG_BUILDFLAGS_EXPORT_ENVVAR += $(1)="$$(value $(1))"
@@ -36,11 +38,20 @@ $(foreach flag,$(DPKG_BUILDFLAGS_LIST),\
   $(foreach operation,SET STRIP APPEND PREPEND,\
     $(eval $(call dpkg_buildflags_export_envvar,DEB_$(flag)_MAINT_$(operation)))))
 
-dpkg_buildflags_setvar = $(1) = $(call dpkg_lazy_eval,$(1),$(DPKG_BUILDFLAGS_EXPORT_ENVVAR) dpkg-buildflags --get $(1))
-
-$(foreach flag,$(DPKG_BUILDFLAGS_LIST),\
-  $(eval $(call dpkg_buildflags_setvar,$(flag))))
+# This variable is only expanded on demand, and we ensure that it
+# happens at most once..
+dpkg-buildflags_run = $(eval $(shell \
+  $(DPKG_BUILDFLAGS_EXPORT_ENVVAR) dpkg-buildflags \
+  | sed 's/^\([^=]*\)\(.*\)/$$(eval \1:\2)/'))
 
 ifdef DPKG_EXPORT_BUILDFLAGS
+  # We must compute all values right now.
+  $(dpkg-buildflags_run)
   export $(DPKG_BUILDFLAGS_LIST)
+else
+  # Only run a subprocess when a variable is actually used,
+  # but then replace each recursive definition with a non-recursive one
+  # (and of course return the asked value).
+  $(foreach var,$(DPKG_BUILDFLAGS_LIST),\
+    $(eval $(var)=$$(dpkg-buildflags_run)$$($(var))))
 endif
diff --git a/scripts/mk/pkg-info.mk b/scripts/mk/pkg-info.mk
index bccde2317..27e16c50c 100644
--- a/scripts/mk/pkg-info.mk
+++ b/scripts/mk/pkg-info.mk
@@ -12,16 +12,44 @@
 #   SOURCE_DATE_EPOCH: source release date as seconds since the epoch, as
 #     specified by <https://reproducible-builds.org/specs/source-date-epoch/>
 #     (since dpkg 1.18.8).
+#     If it is undefined, the date of the latest changelog entry is used.
+#     In both cases, the value is exported.
 
-dpkg_late_eval ?= $(or $(value DPKG_CACHE_$(1)),$(eval DPKG_CACHE_$(1) := $(shell $(2)))$(value DPKG_CACHE_$(1)))
 
-DEB_SOURCE = $(call dpkg_late_eval,DEB_SOURCE,dpkg-parsechangelog -SSource)
-DEB_VERSION = $(call dpkg_late_eval,DEB_VERSION,dpkg-parsechangelog -SVersion)
-DEB_VERSION_EPOCH_UPSTREAM = $(call dpkg_late_eval,DEB_VERSION_EPOCH_UPSTREAM,echo '$(DEB_VERSION)' | sed -e 's/-[^-]*$$//')
-DEB_VERSION_UPSTREAM_REVISION = $(call dpkg_late_eval,DEB_VERSION_UPSTREAM_REVISION,echo '$(DEB_VERSION)' | sed -e 's/^[0-9]*://')
-DEB_VERSION_UPSTREAM = $(call dpkg_late_eval,DEB_VERSION_UPSTREAM,echo '$(DEB_VERSION_EPOCH_UPSTREAM)' | sed -e 's/^[0-9]*://')
-DEB_DISTRIBUTION = $(call dpkg_late_eval,DEB_DISTRIBUTION,dpkg-parsechangelog -SDistribution)
+# This variable is only expanded on demand, and we ensure that it
+# happens at most once..
+dpkg-parsechangelog_run = $(eval $(shell dpkg-parsechangelog \
+                                   | sed -n '$(dpkg-parsechangelog_sed)'))
 
-SOURCE_DATE_EPOCH ?= $(call dpkg_late_eval,SOURCE_DATE_EPOCH,dpkg-parsechangelog -STimestamp)
+dpkg-parsechangelog_sed := \
+  s/^Source: \(.*\)/\
+    $$(eval DEB_SOURCE                    := \1)/p;\
+  s/^Version: \([0-9]*:\)\?\(.*\)\(-[^-]*\)$$/\
+    $$(eval DEB_VERSION                   := \1\2\3)\
+    $$(eval DEB_VERSION_EPOCH_UPSTREAM    := \1\2)\
+    $$(eval DEB_VERSION_UPSTREAM_REVISION := \2\3)\
+    $$(eval DEB_VERSION_UPSTREAM          := \2)/p;\
+  s/^Distribution: \(.*\)/\
+    $$(eval DEB_DISTRIBUTION              := \1)/p
+
+ifdef SOURCE_DATE_EPOCH
+  # Only parse the changelog if a variable is actually used,
+  # but then replace each recursive definition with a non-recursive one
+  # (and of course return the asked value).
+  $(foreach var,\
+    DEB_SOURCE \
+    DEB_VERSION \
+    DEB_VERSION_EPOCH_UPSTREAM \
+    DEB_VERSION_UPSTREAM_REVISION \
+    DEB_VERSION_UPSTREAM \
+    DEB_DISTRIBUTION \
+    ,$(eval $(var) = $$(dpkg-parsechangelog_run)$$($(var))))
+else
+  # We must run a subshell in order to compute SOURCE_DATE_EPOCH,
+  # so we may as well set all variables.
+  dpkg-parsechangelog_sed += \
+    ;s/^Timestamp: \(.*\)/$$(eval SOURCE_DATE_EPOCH:=\1)/p
+  $(dpkg-parsechangelog_run)
+endif
 
 export SOURCE_DATE_EPOCH
-- 
2.30.2

>From c92fd3aac8703475913db041c0bea53221757b5f Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <nico...@debian.org>
Date: Sun, 13 Feb 2022 14:17:20 +0100
Subject: [PATCH 09/10] scripts/mk: protect against repeated inclusion

For example, buildtools.mk implicitly includes architecture.mk.
---
 scripts/mk/architecture.mk | 5 +++++
 scripts/mk/buildflags.mk   | 6 ++++++
 scripts/mk/buildopts.mk    | 5 +++++
 scripts/mk/buildtools.mk   | 5 +++++
 scripts/mk/pkg-info.mk     | 6 ++++++
 scripts/mk/vendor.mk       | 5 +++++
 6 files changed, 32 insertions(+)

diff --git a/scripts/mk/architecture.mk b/scripts/mk/architecture.mk
index 198e5e145..5f03e764d 100644
--- a/scripts/mk/architecture.mk
+++ b/scripts/mk/architecture.mk
@@ -2,6 +2,9 @@
 # DEB_BUILD_* variables that dpkg-architecture can return. Existing values
 # of those variables are preserved as per policy.
 
+# Protect against repeated inclusion (via buildtools.mk for example).
+ifndef dpkg-architecture_vars
+
 dpkg-architecture_vars := \
 $(foreach machine,BUILD HOST TARGET,\
   $(foreach var,ARCH ARCH_ABI ARCH_LIBC ARCH_OS ARCH_CPU ARCH_BITS ARCH_ENDIAN GNU_CPU GNU_SYSTEM GNU_TYPE MULTIARCH,\
@@ -17,3 +20,5 @@ ifneq (,$(filter undefined,$(foreach v,$(dpkg-architecture_vars),$(origin $(v)))
 endif
 
 export $(dpkg-architecture_vars)
+
+endif
diff --git a/scripts/mk/buildflags.mk b/scripts/mk/buildflags.mk
index 856dbfc32..ac74fe656 100644
--- a/scripts/mk/buildflags.mk
+++ b/scripts/mk/buildflags.mk
@@ -15,6 +15,10 @@
 # You can also export them in the environment by setting
 # DPKG_EXPORT_BUILDFLAGS to a non-empty value.
 #
+
+# Protect against repeated inclusion
+ifndef DPKG_BUILDFLAGS_LIST
+
 # This list is kept in sync with the default set of flags returned
 # by dpkg-buildflags.
 
@@ -55,3 +59,5 @@ else
   $(foreach var,$(DPKG_BUILDFLAGS_LIST),\
     $(eval $(var)=$$(dpkg-buildflags_run)$$($(var))))
 endif
+
+endif
diff --git a/scripts/mk/buildopts.mk b/scripts/mk/buildopts.mk
index 420b6359c..a8d6f1987 100644
--- a/scripts/mk/buildopts.mk
+++ b/scripts/mk/buildopts.mk
@@ -5,5 +5,10 @@
 #
 #   DEB_BUILD_OPTION_PARALLEL: the argument for the parallel=N option.
 
+# Protect against repeated inclusion
+ifndef DEB_BUILD_OPTION_PARALLEL
+
 DEB_BUILD_OPTION_PARALLEL := $(patsubst parallel=%,%,\
                                $(filter parallel=%,$(DEB_BUILD_OPTIONS)))
+
+endif
diff --git a/scripts/mk/buildtools.mk b/scripts/mk/buildtools.mk
index a42011c3b..b4cdbcb40 100644
--- a/scripts/mk/buildtools.mk
+++ b/scripts/mk/buildtools.mk
@@ -26,6 +26,9 @@
 # The variables are not exported by default. This can be changed by
 # defining DPKG_EXPORT_BUILDTOOLS.
 
+# Protect against repeated inclusion
+ifndef dpkg_buildtool_setvar
+
 include $(dir $(lastword $(MAKEFILE_LIST)))architecture.mk
 
 # We set the TOOL_FOR_BUILD variables to the specified value, and the TOOL
@@ -78,3 +81,5 @@ $(eval $(call dpkg_buildtool_setvar,AR,ar))
 $(eval $(call dpkg_buildtool_setvar,RANLIB,ranlib))
 $(eval $(call dpkg_buildtool_setvar,PKG_CONFIG,pkg-config))
 $(eval $(call dpkg_buildtool_setvar,QMAKE,qmake))
+
+endif
diff --git a/scripts/mk/pkg-info.mk b/scripts/mk/pkg-info.mk
index 27e16c50c..7ee3cbd6b 100644
--- a/scripts/mk/pkg-info.mk
+++ b/scripts/mk/pkg-info.mk
@@ -15,6 +15,8 @@
 #     If it is undefined, the date of the latest changelog entry is used.
 #     In both cases, the value is exported.
 
+# Protect against repeated inclusion
+ifndef dpkg-parsechangelog_sed
 
 # This variable is only expanded on demand, and we ensure that it
 # happens at most once..
@@ -33,6 +35,8 @@ dpkg-parsechangelog_sed := \
     $$(eval DEB_DISTRIBUTION              := \1)/p
 
 ifdef SOURCE_DATE_EPOCH
+  # dpkg-buildpackage exports SOURCE_DATE_EPOCH.
+
   # Only parse the changelog if a variable is actually used,
   # but then replace each recursive definition with a non-recursive one
   # (and of course return the asked value).
@@ -53,3 +57,5 @@ else
 endif
 
 export SOURCE_DATE_EPOCH
+
+endif
diff --git a/scripts/mk/vendor.mk b/scripts/mk/vendor.mk
index f7c61bf6f..8f8618880 100644
--- a/scripts/mk/vendor.mk
+++ b/scripts/mk/vendor.mk
@@ -32,6 +32,9 @@
 #     ...
 #   endif
 
+# Protect against repeated inclusion
+ifndef DEB_VENDOR
+
 dpkg_late_eval ?= $(or $(value DPKG_CACHE_$(1)),$(eval DPKG_CACHE_$(1) := $(shell $(2)))$(value DPKG_CACHE_$(1)))
 
 DEB_VENDOR = $(call dpkg_late_eval,DEB_VENDOR,dpkg-vendor --query Vendor)
@@ -41,3 +44,5 @@ dpkg_vendor_derives_from_v0 = dpkg-vendor --derives-from $(1) && echo yes || ech
 dpkg_vendor_derives_from_v1 = $(shell $(dpkg_vendor_derives_from_v0))
 
 dpkg_vendor_derives_from ?= $(dpkg_vendor_derives_from_v0)
+
+endif
-- 
2.30.2

>From 7a873a2e15dbb003aa9974c9019a7ca1821062e7 Mon Sep 17 00:00:00 2001
From: Nicolas Boulenguez <nico...@debian.org>
Date: Sun, 13 Feb 2022 13:41:26 +0100
Subject: [PATCH 10/10] scripts/mk: improve details in documentation

architecture.mk: give more details
Mention default.mk as an alternative in included scripts.
Improve consistency accross Makefile snippets.
Stop documenting version restrictions older than oldoldstable.
---
 scripts/mk/architecture.mk | 14 +++++++++++---
 scripts/mk/buildflags.mk   | 10 ++++++++--
 scripts/mk/buildopts.mk    |  6 ++----
 scripts/mk/buildtools.mk   |  5 +++--
 scripts/mk/default.mk      |  3 +--
 scripts/mk/pkg-info.mk     |  5 ++---
 scripts/mk/vendor.mk       |  4 ++--
 7 files changed, 29 insertions(+), 18 deletions(-)

diff --git a/scripts/mk/architecture.mk b/scripts/mk/architecture.mk
index 5f03e764d..c654991bd 100644
--- a/scripts/mk/architecture.mk
+++ b/scripts/mk/architecture.mk
@@ -1,6 +1,14 @@
-# This Makefile frament (since dpkg 1.16.1) defines all the DEB_HOST_* and
-# DEB_BUILD_* variables that dpkg-architecture can return. Existing values
-# of those variables are preserved as per policy.
+# debian/rules helper defining dpkg-architecture(1) variables.
+# Include this (or default.mk) if using DEB_{HOST,BUILD,TARGET}_*.
+#
+# These variables are usually computed by dpkg-buildpackage and simply
+# inherited by debian/rules, but need a definition when debian/rules
+# is invoked directly.
+#
+# Each variable may be overridden by the end user (on the debian/rules
+# command line) or by the maintainer (within debian/rules).
+#
+# All values are unconditionally exported.
 
 # Protect against repeated inclusion (via buildtools.mk for example).
 ifndef dpkg-architecture_vars
diff --git a/scripts/mk/buildflags.mk b/scripts/mk/buildflags.mk
index ac74fe656..87a0fba0f 100644
--- a/scripts/mk/buildflags.mk
+++ b/scripts/mk/buildflags.mk
@@ -1,4 +1,5 @@
-# This Makefile fragment (since dpkg 1.16.1) defines the following variables:
+# debian/rules helper defining the dpkg-buildflags(1) variables.
+# Include this (or default.mk) if using:
 #
 #   ASFLAGS: flags for the assembler (since 1.21.0).
 #   CFLAGS: flags for the C compiler.
@@ -13,8 +14,13 @@
 #   LDFLAGS: flags for the linker.
 #
 # You can also export them in the environment by setting
-# DPKG_EXPORT_BUILDFLAGS to a non-empty value.
+# DPKG_EXPORT_BUILDFLAGS.
 #
+# These variables are computed by dpkg-buildflags(1) and should not be
+# directly overridden.  The following setting are exported to
+# dpkg-buildflags.
+#   DEB_BUILD_{OPTIONS,MAINT_OPTIONS,PATH}
+#   DEB_*_MAINT_{APPEND,PREPEND,SET,STRIP}
 
 # Protect against repeated inclusion
 ifndef DPKG_BUILDFLAGS_LIST
diff --git a/scripts/mk/buildopts.mk b/scripts/mk/buildopts.mk
index a8d6f1987..9ebc8e9ac 100644
--- a/scripts/mk/buildopts.mk
+++ b/scripts/mk/buildopts.mk
@@ -1,7 +1,5 @@
-# This Makefile fragment (since dpkg 1.20.1) parses option arguments from
-# DEB_BUILD_OPTIONS, and exposes these as variables.
-#
-# Defines the following variables:
+# debian/rules helper extracting some arguments from DEB_BUILD_OPTIONS.
+# Include this (or default.mk) if using:
 #
 #   DEB_BUILD_OPTION_PARALLEL: the argument for the parallel=N option.
 
diff --git a/scripts/mk/buildtools.mk b/scripts/mk/buildtools.mk
index b4cdbcb40..be08c3915 100644
--- a/scripts/mk/buildtools.mk
+++ b/scripts/mk/buildtools.mk
@@ -1,5 +1,6 @@
-# This Makefile fragment (since dpkg 1.19.0) defines the following variables
-# for host tools:
+# debian/rules helper defining some host and build tools
+# (since dpkg 1.19.0)
+# Include this if using:
 #
 #   AS: assembler (since dpkg 1.19.1).
 #   CPP: C preprocessor.
diff --git a/scripts/mk/default.mk b/scripts/mk/default.mk
index afe5d6876..278a9481c 100644
--- a/scripts/mk/default.mk
+++ b/scripts/mk/default.mk
@@ -1,5 +1,4 @@
-# This Makefile fragment (since dpkg 1.16.1) includes all the Makefile
-# fragments that define variables that can be useful within debian/rules.
+# debian/rules helper including a selection of more specific helpers.
 
 dpkg_datadir := $(dir $(lastword $(MAKEFILE_LIST)))
 include $(dpkg_datadir)architecture.mk
diff --git a/scripts/mk/pkg-info.mk b/scripts/mk/pkg-info.mk
index 7ee3cbd6b..a40116ace 100644
--- a/scripts/mk/pkg-info.mk
+++ b/scripts/mk/pkg-info.mk
@@ -1,5 +1,5 @@
-# This Makefile fragment (since dpkg 1.16.1) defines the following package
-# information variables:
+# debian/rules helper defining some dpkg-parsechangelog(1) variables.
+# Include this (or default.mk) if using:
 #
 #   DEB_SOURCE: source package name.
 #   DEB_VERSION: package's full version (epoch + upstream vers. + revision).
@@ -11,7 +11,6 @@
 #
 #   SOURCE_DATE_EPOCH: source release date as seconds since the epoch, as
 #     specified by <https://reproducible-builds.org/specs/source-date-epoch/>
-#     (since dpkg 1.18.8).
 #     If it is undefined, the date of the latest changelog entry is used.
 #     In both cases, the value is exported.
 
diff --git a/scripts/mk/vendor.mk b/scripts/mk/vendor.mk
index 8f8618880..521d9e0ec 100644
--- a/scripts/mk/vendor.mk
+++ b/scripts/mk/vendor.mk
@@ -1,5 +1,5 @@
-# This Makefile fragment (since dpkg 1.16.1) defines the following
-# vendor-related variables:
+# debian/rules helper defining some dpkg-vendor(1) variables.
+# Include this (or default.mk) if using:
 #
 #   DEB_VENDOR: output of «dpkg-vendor --query Vendor».
 #   DEB_PARENT_VENDOR: output of «dpkg-vendor --query Parent» (can be empty).
-- 
2.30.2

Reply via email to