summaryrefslogtreecommitdiff
path: root/scripts/mk
diff options
context:
space:
mode:
authorRaphaël Hertzog <hertzog@debian.org>2011-10-10 10:50:02 +0200
committerRaphaël Hertzog <hertzog@debian.org>2011-10-10 10:50:02 +0200
commit44aa764eb17a7665c291b424ddc3a4b6ef5a0754 (patch)
tree55720e2bd445e3a63b0e35c28c1133714b872887 /scripts/mk
parentceb939d278689634037115a728fd7c083d0e4a39 (diff)
downloaddpkg-44aa764eb17a7665c291b424ddc3a4b6ef5a0754.tar.gz
scripts/mk: fix buildflags.mk to make use of the DEB_*_MAINT_* variables
Make does not export its own variables (even those which have been exported explicitly) to sub-shells executed with $(shell …). Since dpkg-buildflags is called that way, we have to modify the command line to embed variable initializations to ensure that we forward the variables that have been set by the maintainer in debian/rules. Since this code required to loop over all possible flags, I took the opportunity to also set the output variables within a loop construct using a single template (avoids copy&paste mistakes). Reported-by: Pierre Chifflier <pollux@debian.org>
Diffstat (limited to 'scripts/mk')
-rw-r--r--scripts/mk/buildflags.mk24
1 files changed, 18 insertions, 6 deletions
diff --git a/scripts/mk/buildflags.mk b/scripts/mk/buildflags.mk
index 1b4a22c7a..8f0f215f8 100644
--- a/scripts/mk/buildflags.mk
+++ b/scripts/mk/buildflags.mk
@@ -14,12 +14,24 @@
dpkg_late_eval ?= $(or $(value DPKG_CACHE_$(1)),$(eval DPKG_CACHE_$(1) := $(shell $(2)))$(value DPKG_CACHE_$(1)))
-CFLAGS = $(call dpkg_late_eval,CFLAGS,dpkg-buildflags --get CFLAGS)
-CPPFLAGS = $(call dpkg_late_eval,CPPFLAGS,dpkg-buildflags --get CPPFLAGS)
-CXXFLAGS = $(call dpkg_late_eval,CXXFLAGS,dpkg-buildflags --get CXXFLAGS)
-FFLAGS = $(call dpkg_late_eval,FFLAGS,dpkg-buildflags --get FFLAGS)
-LDFLAGS = $(call dpkg_late_eval,LDFLAGS,dpkg-buildflags --get LDFLAGS)
+DPKG_BUILDFLAGS_LIST = CFLAGS CPPFLAGS CXXFLAGS FFLAGS LDFLAGS
+
+define dpkg_buildflags_export_envvar
+ifdef $(1)
+DPKG_BUILDFLAGS_EXPORT_ENVVAR += $(1)="$(value $(1))"
+endif
+endef
+
+$(eval $(call dpkg_buildflags_export_envvar,DEB_BUILD_MAINT_OPTIONS))
+$(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_late_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
- export CFLAGS CPPFLAGS CXXFLAGS FFLAGS LDFLAGS
+ export $(DPKG_BUILDFLAGS_LIST)
endif