The following commit has been merged in the sid branch:
commit 44aa764eb17a7665c291b424ddc3a4b6ef5a0754
Author: Raphaël Hertzog <[email protected]>
Date:   Mon Oct 10 10:50:02 2011 +0200

    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 <[email protected]>

diff --git a/debian/changelog b/debian/changelog
index cb6e194..3376439 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -16,6 +16,8 @@ dpkg (1.16.1.1) UNRELEASED; urgency=low
     triggers-pending or installed. Closes: #644492
   * Fix dpkg-source to ignore changes on debian/patches/.dpkg-source-applied
     when building a "2.0" source package. Closes: #642656
+  * Fix buildflags.mk to re-export the environment variables that
+    the maintainer can use to change the build flags. Closes: #644412
 
   [ Guillem Jover ]
   * Change dpkg-buildflags to set preprocessor option -D_FORTIFY_SOURCE=2
diff --git a/scripts/mk/buildflags.mk b/scripts/mk/buildflags.mk
index 1b4a22c..8f0f215 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

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to