diff options
Diffstat (limited to 'scripts/mk')
-rw-r--r-- | scripts/mk/architecture.mk | 14 | ||||
-rw-r--r-- | scripts/mk/buildapi.mk | 6 | ||||
-rw-r--r-- | scripts/mk/buildflags.mk | 36 | ||||
-rw-r--r-- | scripts/mk/pkg-info.mk | 19 | ||||
-rw-r--r-- | scripts/mk/vendor.mk | 8 |
5 files changed, 37 insertions, 46 deletions
diff --git a/scripts/mk/architecture.mk b/scripts/mk/architecture.mk index 4f0559c..c2f6a05 100644 --- a/scripts/mk/architecture.mk +++ b/scripts/mk/architecture.mk @@ -6,16 +6,12 @@ ifndef dpkg_architecture_mk_included dpkg_architecture_mk_included = yes -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,\ - DEB_$(machine)_$(var))) +dpkg_lazy_eval ?= $$(or $$(value DPKG_CACHE_$(1)),$$(eval DPKG_CACHE_$(1) := $$(shell $(2)))$$(value DPKG_CACHE_$(1))) -# dpkg-buildpackage sets all variables. Optimize this frequent case. -ifneq (,$(strip $(foreach v,$(dpkg_architecture_vars),$(if $(value $(v)),,1)))) - $(foreach line,$(subst =,?=,$(shell dpkg-architecture)),$(eval $(line))) -endif +dpkg_architecture_setvar = export $(1) ?= $(call dpkg_lazy_eval,$(1),dpkg-architecture -q$(1)) -export $(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))))) endif # dpkg_architecture_mk_included diff --git a/scripts/mk/buildapi.mk b/scripts/mk/buildapi.mk index 6b665f3..3a1f164 100644 --- a/scripts/mk/buildapi.mk +++ b/scripts/mk/buildapi.mk @@ -4,11 +4,7 @@ ifndef dpkg_buildapi_mk_included dpkg_buildapi_mk_included = yes # Default API level when not set. -ifndef DPKG_BUILD_API - dpkg_lazy_eval ?= $(eval $(1) = $(2)$$($(1))) - dpkg_lazy_set ?= $(call dpkg_lazy_eval,$(1),$$(eval $(1) := $(2))) - $(call dpkg_lazy_set,DPKG_BUILD_API,$$(shell dpkg-buildapi)) -endif +DPKG_BUILD_API ?= $(shell dpkg-buildapi) # We could use only built-in GNU make functions, but that seems too much # complexity given no integer operators, given that we currently have to diff --git a/scripts/mk/buildflags.mk b/scripts/mk/buildflags.mk index bc04488..1159700 100644 --- a/scripts/mk/buildflags.mk +++ b/scripts/mk/buildflags.mk @@ -35,6 +35,8 @@ dpkg_buildflags_mk_included = yes # 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 := $(foreach var,\ ASFLAGS \ CFLAGS \ @@ -48,26 +50,26 @@ DPKG_BUILDFLAGS_LIST := $(foreach var,\ LDFLAGS \ ,$(var) $(var)_FOR_BUILD) -dpkg_buildflags_run = $(eval $(shell \ - $(foreach exported,\ - DEB_BUILD_OPTIONS \ - DEB_BUILD_MAINT_OPTIONS \ - DEB_BUILD_PATH \ - $(foreach flag,$(DPKG_BUILDFLAGS_LIST),\ - $(foreach operation,SET STRIP APPEND PREPEND,\ - DEB_$(flag)_MAINT_$(operation))),\ - $(if $(value $(exported)),\ - $(exported)="$($(exported))"))\ - dpkg-buildflags | sed 's/\([^=]*\)\(.*\)/$$(eval \1:\2)/')) +define dpkg_buildflags_export_envvar + ifdef $(1) + DPKG_BUILDFLAGS_EXPORT_ENVVAR += $(1)="$$(value $(1))" + endif +endef + +$(eval $(call dpkg_buildflags_export_envvar,DEB_BUILD_OPTIONS)) +$(eval $(call dpkg_buildflags_export_envvar,DEB_BUILD_MAINT_OPTIONS)) +$(eval $(call dpkg_buildflags_export_envvar,DEB_BUILD_PATH)) +$(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)))) ifdef DPKG_EXPORT_BUILDFLAGS - # We need to compute the values right now. - $(dpkg_buildflags_run) export $(DPKG_BUILDFLAGS_LIST) -else - dpkg_lazy_eval ?= $(eval $(1) = $(2)$$($(1))) - $(foreach v,$(DPKG_BUILDFLAGS_LIST),\ - $(call dpkg_lazy_eval,$(v),$$(dpkg_buildflags_run))) endif endif # dpkg_buildflags_mk_included diff --git a/scripts/mk/pkg-info.mk b/scripts/mk/pkg-info.mk index 37bf422..658e4f6 100644 --- a/scripts/mk/pkg-info.mk +++ b/scripts/mk/pkg-info.mk @@ -21,18 +21,15 @@ ifndef dpkg_pkg_info_mk_included dpkg_pkg_info_mk_included = yes -dpkg_parsechangelog_run = $(eval $(shell dpkg-parsechangelog | sed -n '\ - s/^Distribution: \(.*\)/$$(eval DEB_DISTRIBUTION:=\1)/p;\ - s/^Source: \(.*\)/$$(eval DEB_SOURCE:=\1)/p;\ - s/^Version: \([0-9]*:\)\{0,1\}\([^-]*\)\(\(.*\)-[^-]*\)\{0,1\}$$/\ - $$(eval DEB_VERSION:=\1\2\3)\ - $$(eval DEB_VERSION_EPOCH_UPSTREAM:=\1\2\4)\ - $$(eval DEB_VERSION_UPSTREAM_REVISION:=\2\3)\ - $$(eval DEB_VERSION_UPSTREAM:=\2\4)/p;\ - s/^Timestamp: \(.*\)/$$(eval DEB_TIMESTAMP:=\1)/p')) +dpkg_late_eval ?= $(or $(value DPKG_CACHE_$(1)),$(eval DPKG_CACHE_$(1) := $(shell $(2)))$(value DPKG_CACHE_$(1))) -# Compute all the values in one go. -$(dpkg_parsechangelog_run) +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) +DEB_TIMESTAMP = $(call dpkg_late_eval,DEB_TIMESTAMP,dpkg-parsechangelog -STimestamp) SOURCE_DATE_EPOCH ?= $(DEB_TIMESTAMP) export SOURCE_DATE_EPOCH diff --git a/scripts/mk/vendor.mk b/scripts/mk/vendor.mk index d257edd..a8d29cb 100644 --- a/scripts/mk/vendor.mk +++ b/scripts/mk/vendor.mk @@ -41,10 +41,10 @@ ifndef dpkg_datadir endif include $(dpkg_datadir)/buildapi.mk -dpkg_lazy_eval ?= $(eval $(1) = $(2)$$($(1))) -dpkg_lazy_set ?= $(call dpkg_lazy_eval,$(1),$$(eval $(1) := $(2))) -$(call dpkg_lazy_set,DEB_VENDOR,$$(shell dpkg-vendor --query Vendor)) -$(call dpkg_lazy_set,DEB_PARENT_VENDOR,$$(shell dpkg-vendor --query Parent)) +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) +DEB_PARENT_VENDOR = $(call dpkg_late_eval,DEB_PARENT_VENDOR,dpkg-vendor --query Parent) dpkg_vendor_derives_from_v0 = dpkg-vendor --derives-from $(1) && echo yes || echo no dpkg_vendor_derives_from_v1 = $(shell $(dpkg_vendor_derives_from_v0)) |