diff options
author | Masahiro Yamada <yamada.masahiro@socionext.com> | 2019-02-22 02:40:07 -0500 |
---|---|---|
committer | Masahiro Yamada <yamada.masahiro@socionext.com> | 2019-02-27 07:43:31 -0500 |
commit | 3812b8c5c5d527239ac015f1f2c7654da7fcfbba (patch) | |
tree | 0fb2ecf0ba2bc57be1ac3f7a4ebf3b17198c93ff /Makefile | |
parent | f47a23ce2b2753ea72b4195e45c20031c46f24b5 (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-- | Makefile | 48 |
1 files changed, 26 insertions, 22 deletions
@@ -15,19 +15,6 @@ NAME = Shy Crocodile | |||
15 | PHONY := _all | 15 | PHONY := _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) | ||
20 | MAKEFLAGS += -rR | ||
21 | |||
22 | # Avoid funny character set dependencies | ||
23 | unexport LC_ALL | ||
24 | LC_COLLATE=C | ||
25 | LC_NUMERIC=C | ||
26 | export LC_COLLATE LC_NUMERIC | ||
27 | |||
28 | # Avoid interference with shell env settings | ||
29 | unexport 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 | ||
34 | ifneq ($(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) | ||
38 | MAKEFLAGS += -rR | ||
39 | |||
40 | # Avoid funny character set dependencies | ||
41 | unexport LC_ALL | ||
42 | LC_COLLATE=C | ||
43 | LC_NUMERIC=C | ||
44 | export LC_COLLATE LC_NUMERIC | ||
45 | |||
46 | # Avoid interference with shell env settings | ||
47 | unexport 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. |
114 | ifeq ($(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. |
142 | MAKEFLAGS += --include-dir=$(CURDIR) | 143 | MAKEFLAGS += --include-dir=$(CURDIR) |
143 | 144 | ||
145 | else | ||
146 | |||
147 | # Do not print "Entering directory ..." at all for in-tree build. | ||
148 | MAKEFLAGS += --no-print-directory | ||
149 | |||
150 | endif # ifneq ($(KBUILD_OUTPUT),) | ||
151 | |||
144 | PHONY += $(MAKECMDGOALS) sub-make | 152 | PHONY += $(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 |
150 | sub-make: | 158 | sub-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 | 163 | else # sub-make-done |
155 | skip-makefile := 1 | ||
156 | endif # ifneq ($(KBUILD_OUTPUT),) | ||
157 | endif # 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 |
160 | ifeq ($(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 | ||
1763 | endif # ifeq ($(config-targets),1) | 1767 | endif # ifeq ($(config-targets),1) |
1764 | endif # ifeq ($(mixed-targets),1) | 1768 | endif # ifeq ($(mixed-targets),1) |
1765 | endif # skip-makefile | 1769 | endif # sub-make-done |
1766 | 1770 | ||
1767 | PHONY += FORCE | 1771 | PHONY += FORCE |
1768 | FORCE: | 1772 | FORCE: |