summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2019-03-19 00:02:36 -0400
committerMasahiro Yamada <yamada.masahiro@socionext.com>2019-03-20 21:03:11 -0400
commit688931a5ad4e55ba0c215248ba510cd67bc3afb4 (patch)
treeeb9f74942f5107a0a19ca328139ca10be2718751 /Makefile
parenta75bb4eb9e565b9f5115e2e8c07377ce32cbe69a (diff)
kbuild: skip sub-make for in-tree build with GNU Make 4.x
Commit 2b50f7ab6368 ("kbuild: add workaround for Debian make-kpkg") annoyed people who want to wrap the top Makefile with GNUmakefile to customize it for their use. On second thought, we do not need to run the sub-make for in-tree build with Make 4.x because the 'MAKEFLAGS += -rR' issue only happens on GNU Make 3.x. With this commit, people will get back their workflow, and the Debian make-kpkg will still work. Fixes: 2b50f7ab6368 ("kbuild: add workaround for Debian make-kpkg") Reported-by: Andreas Schwab <schwab@suse.de> Reported-by: David Howells <dhowells@redhat.com> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Tested-by: Andreas Schwab <schwab@suse.de> Tested-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile32
1 files changed, 16 insertions, 16 deletions
diff --git a/Makefile b/Makefile
index 8c6acfdfe660..6c0635f69982 100644
--- a/Makefile
+++ b/Makefile
@@ -31,26 +31,12 @@ _all:
31# descending is started. They are now explicitly listed as the 31# descending is started. They are now explicitly listed as the
32# prepare rule. 32# prepare rule.
33 33
34# Ugly workaround for Debian make-kpkg:
35# make-kpkg directly includes the top Makefile of Linux kernel. In such a case,
36# skip sub-make to support debian_* targets in ruleset/kernel_version.mk, but
37# displays warning to discourage such abusage.
38ifneq ($(word 2, $(MAKEFILE_LIST)),)
39$(warning Do not include top Makefile of Linux Kernel)
40sub-make-done := 1
41MAKEFLAGS += -rR
42endif
43
44ifneq ($(sub-make-done),1) 34ifneq ($(sub-make-done),1)
45 35
46# Do not use make's built-in rules and variables 36# Do not use make's built-in rules and variables
47# (this increases performance and avoids hard-to-debug behaviour) 37# (this increases performance and avoids hard-to-debug behaviour)
48MAKEFLAGS += -rR 38MAKEFLAGS += -rR
49 39
50# 'MAKEFLAGS += -rR' does not become immediately effective for old
51# GNU Make versions. Cancel implicit rules for this Makefile.
52$(lastword $(MAKEFILE_LIST)): ;
53
54# Avoid funny character set dependencies 40# Avoid funny character set dependencies
55unexport LC_ALL 41unexport LC_ALL
56LC_COLLATE=C 42LC_COLLATE=C
@@ -153,6 +139,7 @@ $(if $(KBUILD_OUTPUT),, \
153# 'sub-make' below. 139# 'sub-make' below.
154MAKEFLAGS += --include-dir=$(CURDIR) 140MAKEFLAGS += --include-dir=$(CURDIR)
155 141
142need-sub-make := 1
156else 143else
157 144
158# Do not print "Entering directory ..." at all for in-tree build. 145# Do not print "Entering directory ..." at all for in-tree build.
@@ -160,6 +147,16 @@ MAKEFLAGS += --no-print-directory
160 147
161endif # ifneq ($(KBUILD_OUTPUT),) 148endif # ifneq ($(KBUILD_OUTPUT),)
162 149
150ifneq ($(filter 3.%,$(MAKE_VERSION)),)
151# 'MAKEFLAGS += -rR' does not immediately become effective for GNU Make 3.x
152# We need to invoke sub-make to avoid implicit rules in the top Makefile.
153need-sub-make := 1
154# Cancel implicit rules for this Makefile.
155$(lastword $(MAKEFILE_LIST)): ;
156endif
157
158ifeq ($(need-sub-make),1)
159
163PHONY += $(MAKECMDGOALS) sub-make 160PHONY += $(MAKECMDGOALS) sub-make
164 161
165$(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make 162$(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make
@@ -171,8 +168,11 @@ sub-make:
171 $(if $(KBUILD_OUTPUT),-C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR)) \ 168 $(if $(KBUILD_OUTPUT),-C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR)) \
172 -f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS)) 169 -f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS))
173 170
174else # sub-make-done 171endif # need-sub-make
172endif # sub-make-done
173
175# We process the rest of the Makefile if this is the final invocation of make 174# We process the rest of the Makefile if this is the final invocation of make
175ifeq ($(need-sub-make),)
176 176
177# Do not print "Entering directory ...", 177# Do not print "Entering directory ...",
178# but we want to display it when entering to the output directory 178# but we want to display it when entering to the output directory
@@ -1757,7 +1757,7 @@ existing-targets := $(wildcard $(sort $(targets)))
1757 1757
1758endif # ifeq ($(config-targets),1) 1758endif # ifeq ($(config-targets),1)
1759endif # ifeq ($(mixed-targets),1) 1759endif # ifeq ($(mixed-targets),1)
1760endif # sub-make-done 1760endif # need-sub-make
1761 1761
1762PHONY += FORCE 1762PHONY += FORCE
1763FORCE: 1763FORCE: