summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2019-02-22 02:40:07 -0500
committerMasahiro Yamada <yamada.masahiro@socionext.com>2019-02-27 07:43:31 -0500
commit3812b8c5c5d527239ac015f1f2c7654da7fcfbba (patch)
tree0fb2ecf0ba2bc57be1ac3f7a4ebf3b17198c93ff /Makefile
parentf47a23ce2b2753ea72b4195e45c20031c46f24b5 (diff)
kbuild: make -r/-R effective in top Makefile for old Make versions
Adding -rR to MAKEFLAGS is important because we do not want to be bothered by built-in implicit rules or variables. One problem that used to exist in older GNU Make versions is MAKEFLAGS += -rR ... does not become effective in the current Makefile. When you are building with O= option, it becomes effective in the top Makefile since it recurses via 'sub-make' target. Otherwise, the top Makefile tries implicit rules. That is why we explicitly add empty rules for Makefiles, but we often miss to do that. In fact, adding -d option to older GNU Make versions shows it is trying a bunch of implicit pattern rules. Considering target file `scripts/Makefile.kcov'. Looking for an implicit rule for `scripts/Makefile.kcov'. Trying pattern rule with stem `Makefile.kcov'. Trying implicit prerequisite `scripts/Makefile.kcov.o'. Trying pattern rule with stem `Makefile.kcov'. Trying implicit prerequisite `scripts/Makefile.kcov.c'. Trying pattern rule with stem `Makefile.kcov'. Trying implicit prerequisite `scripts/Makefile.kcov.cc'. Trying pattern rule with stem `Makefile.kcov'. Trying implicit prerequisite `scripts/Makefile.kcov.C'. ... This issue was fixed by GNU Make commit 58dae243526b ("[Savannah #20501] Handle adding -r/-R to MAKEFLAGS in the makefile"). So, it is no longer a problem if you use GNU Make 4.0 or later. However, older versions are still widely used. So, I decided to patch the kernel Makefile to invoke sub-make regardless of O= option. This will allow further cleanups. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile48
1 files changed, 26 insertions, 22 deletions
diff --git a/Makefile b/Makefile
index 55de9f5d38cb..db3cb73d3088 100644
--- a/Makefile
+++ b/Makefile
@@ -15,19 +15,6 @@ NAME = Shy Crocodile
15PHONY := _all 15PHONY := _all
16_all: 16_all:
17 17
18# Do not use make's built-in rules and variables
19# (this increases performance and avoids hard-to-debug behaviour)
20MAKEFLAGS += -rR
21
22# Avoid funny character set dependencies
23unexport LC_ALL
24LC_COLLATE=C
25LC_NUMERIC=C
26export LC_COLLATE LC_NUMERIC
27
28# Avoid interference with shell env settings
29unexport GREP_OPTIONS
30
31# We are using a recursive build, so we need to do a little thinking 18# We are using a recursive build, so we need to do a little thinking
32# to get the ordering right. 19# to get the ordering right.
33# 20#
@@ -44,6 +31,21 @@ unexport GREP_OPTIONS
44# descending is started. They are now explicitly listed as the 31# descending is started. They are now explicitly listed as the
45# prepare rule. 32# prepare rule.
46 33
34ifneq ($(sub-make-done),1)
35
36# Do not use make's built-in rules and variables
37# (this increases performance and avoids hard-to-debug behaviour)
38MAKEFLAGS += -rR
39
40# Avoid funny character set dependencies
41unexport LC_ALL
42LC_COLLATE=C
43LC_NUMERIC=C
44export LC_COLLATE LC_NUMERIC
45
46# Avoid interference with shell env settings
47unexport GREP_OPTIONS
48
47# Beautify output 49# Beautify output
48# --------------------------------------------------------------------------- 50# ---------------------------------------------------------------------------
49# 51#
@@ -111,7 +113,6 @@ export quiet Q KBUILD_VERBOSE
111 113
112# KBUILD_SRC is not intended to be used by the regular user (for now), 114# KBUILD_SRC is not intended to be used by the regular user (for now),
113# it is set on invocation of make with KBUILD_OUTPUT or O= specified. 115# it is set on invocation of make with KBUILD_OUTPUT or O= specified.
114ifeq ($(KBUILD_SRC),)
115 116
116# OK, Make called in directory where kernel src resides 117# OK, Make called in directory where kernel src resides
117# Do we want to locate output files in a separate directory? 118# Do we want to locate output files in a separate directory?
@@ -141,6 +142,13 @@ $(if $(KBUILD_OUTPUT),, \
141# 'sub-make' below. 142# 'sub-make' below.
142MAKEFLAGS += --include-dir=$(CURDIR) 143MAKEFLAGS += --include-dir=$(CURDIR)
143 144
145else
146
147# Do not print "Entering directory ..." at all for in-tree build.
148MAKEFLAGS += --no-print-directory
149
150endif # ifneq ($(KBUILD_OUTPUT),)
151
144PHONY += $(MAKECMDGOALS) sub-make 152PHONY += $(MAKECMDGOALS) sub-make
145 153
146$(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make 154$(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make
@@ -148,16 +156,12 @@ $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make
148 156
149# Invoke a second make in the output directory, passing relevant variables 157# Invoke a second make in the output directory, passing relevant variables
150sub-make: 158sub-make:
151 $(Q)$(MAKE) -C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR) \ 159 $(Q)$(MAKE) sub-make-done=1 \
160 $(if $(KBUILD_OUTPUT),-C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR)) \
152 -f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS)) 161 -f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS))
153 162
154# Leave processing to above invocation of make 163else # sub-make-done
155skip-makefile := 1
156endif # ifneq ($(KBUILD_OUTPUT),)
157endif # ifeq ($(KBUILD_SRC),)
158
159# We process the rest of the Makefile if this is the final invocation of make 164# We process the rest of the Makefile if this is the final invocation of make
160ifeq ($(skip-makefile),)
161 165
162# Do not print "Entering directory ...", 166# Do not print "Entering directory ...",
163# but we want to display it when entering to the output directory 167# but we want to display it when entering to the output directory
@@ -1762,7 +1766,7 @@ $(cmd_files): ; # Do not try to update included dependency files
1762 1766
1763endif # ifeq ($(config-targets),1) 1767endif # ifeq ($(config-targets),1)
1764endif # ifeq ($(mixed-targets),1) 1768endif # ifeq ($(mixed-targets),1)
1765endif # skip-makefile 1769endif # sub-make-done
1766 1770
1767PHONY += FORCE 1771PHONY += FORCE
1768FORCE: 1772FORCE: