• Bug#872381: dpkg-dev: optimize Makefile snippets for debian/rules (4/5)

    From Nicolas Boulenguez@1:229/2 to All on Wed Jan 10 22:10:01 2024
    [continued from previous message]

    Subject: [PATCH 5/8] scripts/buildflags.mk: reduce the number of subprocesses

    Ensure that dpkg-buildflags is only called when a *FLAGS variable is
    is expanded.

    If so, call it once and cache all results for future expansions.
    ---
    scripts/mk/buildflags.mk | 45 +++++++++++++++++++++++-----------------
    1 file changed, 26 insertions(+), 19 deletions(-)

    diff --git a/scripts/mk/buildflags.mk b/scripts/mk/buildflags.mk
    index 02baa53f2..f0d32d78c 100644
    --- a/scripts/mk/buildflags.mk
    +++ b/scripts/mk/buildflags.mk
    @@ -26,8 +26,13 @@
    # LDFLAGS_FOR_BUILD: flags for the build 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}

    ifndef dpkg_buildflags.mk_included
    dpkg_buildflags.mk_included :=
    @@ -35,31 +40,24 @@ dpkg_buildflags.mk_included :=
    # This list is kept in sync with the default set of flags returned
    # by dpkg-buildflags.

    -dpkg_lazy_eval ?= $$(or $$(value DPKG_CACH
  • From Nicolas Boulenguez@1:229/2 to All on Wed Apr 10 19:50:02 2024
    [continued from previous message]

    Vendors.mk was correct but use the same mechanism for consistency.
    ---
    scripts/mk/architecture.mk | 15 ++++++++++-----
    scripts/mk/buildapi.mk | 6 +++++-
    scripts/mk/buildflags.mk | 36 +++++++++++++++++-------------------
    scripts/mk/pkg-info.mk | 33 +++++++++++++++++++++++----------
    scripts/mk/vendor.mk | 8 ++++----
    5 files changed, 59 insertions(+), 39 deletions(-)

    diff --git a/scripts/mk/architecture.mk b/scripts/mk/architecture.mk
    index ab42f8788..6963d2ea7 100644
    --- a/scripts/mk/architecture.mk
    +++ b/scripts/mk/architecture.mk
    @@ -1,16 +1,21 @@
    # This Makefile fragment (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.
    +# All variables are exported.

    ifndef dpkg_architecture_mk_included
    dpkg_architecture_mk_included = yes

    -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_