aboutsummaryrefslogtreecommitdiff
path: root/depends/Makefile
diff options
context:
space:
mode:
authorCarl Dong <contact@carldong.me>2020-05-27 17:03:46 -0400
committerCarl Dong <contact@carldong.me>2020-05-27 17:39:52 -0400
commitf0d7ed10b48a6303d8b0cb6f2fc6b8652945bffb (patch)
tree7df9d2c74bd325f52374198028f5a70cc825d305 /depends/Makefile
parent0a33803f1c42c938cc7c6c5291ef1f9a1dfb491b (diff)
downloadbitcoin-f0d7ed10b48a6303d8b0cb6f2fc6b8652945bffb.tar.xz
depends: Propagate only specific CLI variables to sub-makes
We want to supply well-known vars to ./configure scripts to do with as they please. However, we do _not_ want to override these well-known vars at make-time as certain build systems expect a self-mangled version of these well-known vars. For example, freetype and bdb will prepend `libtool --mode=compile' to CC and CXX, which, if we override CC on the command line at make-time, will break the build.
Diffstat (limited to 'depends/Makefile')
-rw-r--r--depends/Makefile24
1 files changed, 24 insertions, 0 deletions
diff --git a/depends/Makefile b/depends/Makefile
index 5ad82bb56a..3d0784cb6b 100644
--- a/depends/Makefile
+++ b/depends/Makefile
@@ -4,6 +4,30 @@
print-%:
@echo $* = $($*)
+# When invoking a sub-make, keep only the command line variable definitions
+# matching the pattern in the filter function.
+#
+# e.g. invoking:
+# $ make A=1 C=1 print-MAKEOVERRIDES print-MAKEFLAGS
+#
+# with the following in the Makefile:
+# MAKEOVERRIDES := $(filter A=% B=%,$(MAKEOVERRIDES))
+#
+# will print:
+# MAKEOVERRIDES = A=1
+# MAKEFLAGS = -- A=1
+#
+# this is because as the GNU make manual says:
+# The command line variable definitions really appear in the variable
+# MAKEOVERRIDES, and MAKEFLAGS contains a reference to this variable.
+#
+# and since the GNU make manual also says:
+# variables defined on the command line are passed to the sub-make through
+# MAKEFLAGS
+#
+# this means that sub-makes will be invoked as if:
+# $(MAKE) A=1 blah blah
+MAKEOVERRIDES := $(filter V=%,$(MAKEOVERRIDES))
SOURCES_PATH ?= $(BASEDIR)/sources
WORK_PATH = $(BASEDIR)/work
BASE_CACHE ?= $(BASEDIR)/built