debian/rules: Set DEB_BUILD_MAINT_OPTIONS in shell
authorIan Jackson <ian.jackson@citrix.com>
Tue, 4 Feb 2020 14:11:10 +0000 (14:11 +0000)
committerHans van Kranenburg <hans@knorrie.org>
Thu, 23 Jul 2020 12:35:10 +0000 (14:35 +0200)
This makes these hardening options actually effective.

Closes: #939560 (1/3)
Reported-by: Guillem Jover <guillem@debian.org>
Signed-off-by: Ian Jackson <ian.jackson@citrix.com>
debian/rules

index b96017a7bae9be22b1b4521a7433d5ac1d959389..fdf68805b477bceb291b320d0db59fe7f683ce7a 100755 (executable)
@@ -16,7 +16,10 @@ SHELL    := bash -e
 # of them are sane to use in the hypervisor context, rather than
 # simply in userland binaries.
 #
-export DEB_BUILD_MAINT_OPTIONS = hardening=+all
+# Inexplicably, if you tell make `export V=value' and `$(shell ...)'
+# it does not pass V to the shell.  WTF.  So we set a variable
+# dbmo which we include in the relevant $(shell ...) invocations.
+dbmo= DEB_BUILD_MAINT_OPTIONS=hardening=+all
 
 # Architecture handling.
 #
@@ -127,9 +130,9 @@ export WGET=/bin/false GIT=/bin/false
 
 t=$(PWD)/debian/tmp
 
-dpkg_CFLAGS   := $(shell dpkg-buildflags --get CFLAGS)
-dpkg_CPPFLAGS := $(shell dpkg-buildflags --get CPPFLAGS)
-dpkg_LDFLAGS  := $(shell dpkg-buildflags --get LDFLAGS)
+dpkg_CFLAGS   := $(shell $(dbmo) dpkg-buildflags --get CFLAGS)
+dpkg_CPPFLAGS := $(shell $(dbmo) dpkg-buildflags --get CPPFLAGS)
+dpkg_LDFLAGS  := $(shell $(dbmo) dpkg-buildflags --get LDFLAGS)
 
 make_args_xen= $(make_args_common) \
        XEN_COMPILE_ARCH=$(xen_arch_$(DEB_BUILD_ARCH)) \