diff options
| author | Masahiro Yamada <yamada.masahiro@socionext.com> | 2019-03-19 00:02:36 -0400 |
|---|---|---|
| committer | Masahiro Yamada <yamada.masahiro@socionext.com> | 2019-03-20 21:03:11 -0400 |
| commit | 688931a5ad4e55ba0c215248ba510cd67bc3afb4 (patch) | |
| tree | eb9f74942f5107a0a19ca328139ca10be2718751 /Makefile | |
| parent | a75bb4eb9e565b9f5115e2e8c07377ce32cbe69a (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-- | Makefile | 32 |
1 files changed, 16 insertions, 16 deletions
| @@ -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. | ||
| 38 | ifneq ($(word 2, $(MAKEFILE_LIST)),) | ||
| 39 | $(warning Do not include top Makefile of Linux Kernel) | ||
| 40 | sub-make-done := 1 | ||
| 41 | MAKEFLAGS += -rR | ||
| 42 | endif | ||
| 43 | |||
| 44 | ifneq ($(sub-make-done),1) | 34 | ifneq ($(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) |
| 48 | MAKEFLAGS += -rR | 38 | MAKEFLAGS += -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 |
| 55 | unexport LC_ALL | 41 | unexport LC_ALL |
| 56 | LC_COLLATE=C | 42 | LC_COLLATE=C |
| @@ -153,6 +139,7 @@ $(if $(KBUILD_OUTPUT),, \ | |||
| 153 | # 'sub-make' below. | 139 | # 'sub-make' below. |
| 154 | MAKEFLAGS += --include-dir=$(CURDIR) | 140 | MAKEFLAGS += --include-dir=$(CURDIR) |
| 155 | 141 | ||
| 142 | need-sub-make := 1 | ||
| 156 | else | 143 | else |
| 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 | ||
| 161 | endif # ifneq ($(KBUILD_OUTPUT),) | 148 | endif # ifneq ($(KBUILD_OUTPUT),) |
| 162 | 149 | ||
| 150 | ifneq ($(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. | ||
| 153 | need-sub-make := 1 | ||
| 154 | # Cancel implicit rules for this Makefile. | ||
| 155 | $(lastword $(MAKEFILE_LIST)): ; | ||
| 156 | endif | ||
| 157 | |||
| 158 | ifeq ($(need-sub-make),1) | ||
| 159 | |||
| 163 | PHONY += $(MAKECMDGOALS) sub-make | 160 | PHONY += $(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 | ||
| 174 | else # sub-make-done | 171 | endif # need-sub-make |
| 172 | endif # 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 |
| 175 | ifeq ($(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 | ||
| 1758 | endif # ifeq ($(config-targets),1) | 1758 | endif # ifeq ($(config-targets),1) |
| 1759 | endif # ifeq ($(mixed-targets),1) | 1759 | endif # ifeq ($(mixed-targets),1) |
| 1760 | endif # sub-make-done | 1760 | endif # need-sub-make |
| 1761 | 1761 | ||
| 1762 | PHONY += FORCE | 1762 | PHONY += FORCE |
| 1763 | FORCE: | 1763 | FORCE: |
