Skip to content

Commit f0d7ed1

Browse files
committed
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.
1 parent 0a33803 commit f0d7ed1

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

depends/Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,30 @@
44
print-%:
55
@echo $* = $($*)
66

7+
# When invoking a sub-make, keep only the command line variable definitions
8+
# matching the pattern in the filter function.
9+
#
10+
# e.g. invoking:
11+
# $ make A=1 C=1 print-MAKEOVERRIDES print-MAKEFLAGS
12+
#
13+
# with the following in the Makefile:
14+
# MAKEOVERRIDES := $(filter A=% B=%,$(MAKEOVERRIDES))
15+
#
16+
# will print:
17+
# MAKEOVERRIDES = A=1
18+
# MAKEFLAGS = -- A=1
19+
#
20+
# this is because as the GNU make manual says:
21+
# The command line variable definitions really appear in the variable
22+
# MAKEOVERRIDES, and MAKEFLAGS contains a reference to this variable.
23+
#
24+
# and since the GNU make manual also says:
25+
# variables defined on the command line are passed to the sub-make through
26+
# MAKEFLAGS
27+
#
28+
# this means that sub-makes will be invoked as if:
29+
# $(MAKE) A=1 blah blah
30+
MAKEOVERRIDES := $(filter V=%,$(MAKEOVERRIDES))
731
SOURCES_PATH ?= $(BASEDIR)/sources
832
WORK_PATH = $(BASEDIR)/work
933
BASE_CACHE ?= $(BASEDIR)/built

0 commit comments

Comments
 (0)