Commit ffe29ebc070104b529abcdc589eb87f3e5d85fa4
Committed by
Tom Rini
1 parent
cb6e7b0db9
Exists in
v2017.01-smarct4x
and in
37 other branches
kbuild: sync top Makefile with Linux 3.18-rc1
Since Linux 3.15, relative path feature and related fixes, cleanups have been merged to the top Makefile. The relative path feature looks stable enough, so let's import it to U-Boot along with various cleanups. Commits imported from Linux (some need adjustment) are: [1] commit 7e1c04779efd by Michal Marek kbuild: Use relative path for $(objtree) [2] commit 890676c65d69 by Michal Marek kbuild: Use relative path when building in the source tree [3] commit 9da0763bdd82 by Michal Marek kbuild: Use relative path when building in a subdir of the source tree [4] commit c2e28dc975ea by Michal Marek kbuild: Print the name of the build directory [5] commit 066b7ed95580 by Michal Marek kbuild: Do not print the build directory with make -s [6] commit 3f1d9a6cec01 by Michal Marek kbuild: make -s should be used with kernelrelease/kernelversion/image_name [7] commit 7ff525712acf by Masahiro Yamada kbuild: fake the "Entering directory ..." message more simply [8] commit 745a254322c8 by Masahiro Yamada kbuild: use $(Q) for sub-make target [9] commit aa55c8e2f7a3 by Masahiro Yamada kbuild: handle C=... and M=... after entering into build directory [10] commit ab7474ea5361 by Borislav Petkov Kbuild: Ignore GREP_OPTIONS env variable To use relative path feature, tools/Makefile and scripts/Makefile.autoconf must be tweaked. Signed-off-by: Michal Marek <mmarek@suse.cz> Signed-off-by: Borislav Petkov <bp@suse.de> Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com>
Showing 3 changed files with 102 additions and 93 deletions Side-by-side Diff
Makefile
1 | -# | |
2 | -# (C) Copyright 2000-2013 | |
3 | -# Wolfgang Denk, DENX Software Engineering, wd@denx.de. | |
4 | -# | |
5 | -# SPDX-License-Identifier: GPL-2.0+ | |
6 | -# | |
7 | - | |
8 | 1 | VERSION = 2014 |
9 | 2 | PATCHLEVEL = 10 |
10 | 3 | SUBLEVEL = |
... | ... | @@ -17,11 +10,9 @@ |
17 | 10 | # Comments in this file are targeted only to the developer, do not |
18 | 11 | # expect to learn how to build the kernel reading this file. |
19 | 12 | |
20 | -# Do not: | |
21 | -# o use make's built-in rules and variables | |
22 | -# (this increases performance and avoids hard-to-debug behaviour); | |
23 | -# o print "Entering directory ..."; | |
24 | -MAKEFLAGS += -rR --no-print-directory | |
13 | +# Do not use make's built-in rules and variables | |
14 | +# (this increases performance and avoids hard-to-debug behaviour); | |
15 | +MAKEFLAGS += -rR | |
25 | 16 | |
26 | 17 | # Avoid funny character set dependencies |
27 | 18 | unexport LC_ALL |
... | ... | @@ -29,6 +20,9 @@ |
29 | 20 | LC_NUMERIC=C |
30 | 21 | export LC_COLLATE LC_NUMERIC |
31 | 22 | |
23 | +# Avoid interference with shell env settings | |
24 | +unexport GREP_OPTIONS | |
25 | + | |
32 | 26 | # We are using a recursive build, so we need to do a little thinking |
33 | 27 | # to get the ordering right. |
34 | 28 | # |
... | ... | @@ -45,6 +39,29 @@ |
45 | 39 | # descending is started. They are now explicitly listed as the |
46 | 40 | # prepare rule. |
47 | 41 | |
42 | +# Beautify output | |
43 | +# --------------------------------------------------------------------------- | |
44 | +# | |
45 | +# Normally, we echo the whole command before executing it. By making | |
46 | +# that echo $($(quiet)$(cmd)), we now have the possibility to set | |
47 | +# $(quiet) to choose other forms of output instead, e.g. | |
48 | +# | |
49 | +# quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@ | |
50 | +# cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< | |
51 | +# | |
52 | +# If $(quiet) is empty, the whole command will be printed. | |
53 | +# If it is set to "quiet_", only the short version will be printed. | |
54 | +# If it is set to "silent_", nothing will be printed at all, since | |
55 | +# the variable $(silent_cmd_cc_o_c) doesn't exist. | |
56 | +# | |
57 | +# A simple variant is to prefix commands with $(Q) - that's useful | |
58 | +# for commands that shall be hidden in non-verbose mode. | |
59 | +# | |
60 | +# $(Q)ln $@ :< | |
61 | +# | |
62 | +# If KBUILD_VERBOSE equals 0 then the above command will be hidden. | |
63 | +# If KBUILD_VERBOSE equals 1 then the above command is displayed. | |
64 | +# | |
48 | 65 | # To put more focus on warnings, be less verbose as default |
49 | 66 | # Use 'make V=1' to see the full commands |
50 | 67 | |
51 | 68 | |
52 | 69 | |
53 | 70 | |
54 | 71 | |
... | ... | @@ -55,33 +72,28 @@ |
55 | 72 | KBUILD_VERBOSE = 0 |
56 | 73 | endif |
57 | 74 | |
58 | -# Call a source code checker (by default, "sparse") as part of the | |
59 | -# C compilation. | |
60 | -# | |
61 | -# Use 'make C=1' to enable checking of only re-compiled files. | |
62 | -# Use 'make C=2' to enable checking of *all* source files, regardless | |
63 | -# of whether they are re-compiled or not. | |
64 | -# | |
65 | -# See the file "Documentation/sparse.txt" for more details, including | |
66 | -# where to get the "sparse" utility. | |
75 | +ifeq ($(KBUILD_VERBOSE),1) | |
76 | + quiet = | |
77 | + Q = | |
78 | +else | |
79 | + quiet=quiet_ | |
80 | + Q = @ | |
81 | +endif | |
67 | 82 | |
68 | -ifeq ("$(origin C)", "command line") | |
69 | - KBUILD_CHECKSRC = $(C) | |
83 | +# If the user is running make -s (silent mode), suppress echoing of | |
84 | +# commands | |
85 | + | |
86 | +ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4 | |
87 | +ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),) | |
88 | + quiet=silent_ | |
70 | 89 | endif |
71 | -ifndef KBUILD_CHECKSRC | |
72 | - KBUILD_CHECKSRC = 0 | |
90 | +else # make-3.8x | |
91 | +ifneq ($(filter s% -s%,$(MAKEFLAGS)),) | |
92 | + quiet=silent_ | |
73 | 93 | endif |
74 | - | |
75 | -# Use make M=dir to specify directory of external module to build | |
76 | -# Old syntax make ... SUBDIRS=$PWD is still supported | |
77 | -# Setting the environment variable KBUILD_EXTMOD take precedence | |
78 | -ifdef SUBDIRS | |
79 | - KBUILD_EXTMOD ?= $(SUBDIRS) | |
80 | 94 | endif |
81 | 95 | |
82 | -ifeq ("$(origin M)", "command line") | |
83 | - KBUILD_EXTMOD := $(M) | |
84 | -endif | |
96 | +export quiet Q KBUILD_VERBOSE | |
85 | 97 | |
86 | 98 | # kbuild supports saving output files in a separate directory. |
87 | 99 | # To locate output files in a separate directory two syntaxes are supported. |
... | ... | @@ -98,7 +110,6 @@ |
98 | 110 | # The O= assignment takes precedence over the KBUILD_OUTPUT environment |
99 | 111 | # variable. |
100 | 112 | |
101 | - | |
102 | 113 | # KBUILD_SRC is set on invocation of make in OBJ directory |
103 | 114 | # KBUILD_SRC is not intended to be used by the regular user (for now) |
104 | 115 | ifeq ($(KBUILD_SRC),) |
... | ... | @@ -131,10 +142,8 @@ |
131 | 142 | @: |
132 | 143 | |
133 | 144 | sub-make: FORCE |
134 | - $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \ | |
135 | - KBUILD_SRC=$(CURDIR) \ | |
136 | - KBUILD_EXTMOD="$(KBUILD_EXTMOD)" -f $(CURDIR)/Makefile \ | |
137 | - $(filter-out _all sub-make,$(MAKECMDGOALS)) | |
145 | + $(Q)$(MAKE) -C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR) \ | |
146 | + -f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS)) | |
138 | 147 | |
139 | 148 | # Leave processing to above invocation of make |
140 | 149 | skip-makefile := 1 |
... | ... | @@ -144,6 +153,39 @@ |
144 | 153 | # We process the rest of the Makefile if this is the final invocation of make |
145 | 154 | ifeq ($(skip-makefile),) |
146 | 155 | |
156 | +# Do not print "Entering directory ...", | |
157 | +# but we want to display it when entering to the output directory | |
158 | +# so that IDEs/editors are able to understand relative filenames. | |
159 | +MAKEFLAGS += --no-print-directory | |
160 | + | |
161 | +# Call a source code checker (by default, "sparse") as part of the | |
162 | +# C compilation. | |
163 | +# | |
164 | +# Use 'make C=1' to enable checking of only re-compiled files. | |
165 | +# Use 'make C=2' to enable checking of *all* source files, regardless | |
166 | +# of whether they are re-compiled or not. | |
167 | +# | |
168 | +# See the file "Documentation/sparse.txt" for more details, including | |
169 | +# where to get the "sparse" utility. | |
170 | + | |
171 | +ifeq ("$(origin C)", "command line") | |
172 | + KBUILD_CHECKSRC = $(C) | |
173 | +endif | |
174 | +ifndef KBUILD_CHECKSRC | |
175 | + KBUILD_CHECKSRC = 0 | |
176 | +endif | |
177 | + | |
178 | +# Use make M=dir to specify directory of external module to build | |
179 | +# Old syntax make ... SUBDIRS=$PWD is still supported | |
180 | +# Setting the environment variable KBUILD_EXTMOD take precedence | |
181 | +ifdef SUBDIRS | |
182 | + KBUILD_EXTMOD ?= $(SUBDIRS) | |
183 | +endif | |
184 | + | |
185 | +ifeq ("$(origin M)", "command line") | |
186 | + KBUILD_EXTMOD := $(M) | |
187 | +endif | |
188 | + | |
147 | 189 | # If building an external module we do not care about the all: rule |
148 | 190 | # but instead _all depend on modules |
149 | 191 | PHONY += all |
... | ... | @@ -153,8 +195,18 @@ |
153 | 195 | _all: modules |
154 | 196 | endif |
155 | 197 | |
156 | -srctree := $(if $(KBUILD_SRC),$(KBUILD_SRC),$(CURDIR)) | |
157 | -objtree := $(CURDIR) | |
198 | +ifeq ($(KBUILD_SRC),) | |
199 | + # building in the source tree | |
200 | + srctree := . | |
201 | +else | |
202 | + ifeq ($(KBUILD_SRC)/,$(dir $(CURDIR))) | |
203 | + # building in a subdirectory of the source tree | |
204 | + srctree := .. | |
205 | + else | |
206 | + srctree := $(KBUILD_SRC) | |
207 | + endif | |
208 | +endif | |
209 | +objtree := . | |
158 | 210 | src := $(srctree) |
159 | 211 | obj := $(objtree) |
160 | 212 | |
... | ... | @@ -262,52 +314,6 @@ |
262 | 314 | export KBUILD_MODULES KBUILD_BUILTIN |
263 | 315 | export KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD |
264 | 316 | |
265 | -# Beautify output | |
266 | -# --------------------------------------------------------------------------- | |
267 | -# | |
268 | -# Normally, we echo the whole command before executing it. By making | |
269 | -# that echo $($(quiet)$(cmd)), we now have the possibility to set | |
270 | -# $(quiet) to choose other forms of output instead, e.g. | |
271 | -# | |
272 | -# quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@ | |
273 | -# cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< | |
274 | -# | |
275 | -# If $(quiet) is empty, the whole command will be printed. | |
276 | -# If it is set to "quiet_", only the short version will be printed. | |
277 | -# If it is set to "silent_", nothing will be printed at all, since | |
278 | -# the variable $(silent_cmd_cc_o_c) doesn't exist. | |
279 | -# | |
280 | -# A simple variant is to prefix commands with $(Q) - that's useful | |
281 | -# for commands that shall be hidden in non-verbose mode. | |
282 | -# | |
283 | -# $(Q)ln $@ :< | |
284 | -# | |
285 | -# If KBUILD_VERBOSE equals 0 then the above command will be hidden. | |
286 | -# If KBUILD_VERBOSE equals 1 then the above command is displayed. | |
287 | - | |
288 | -ifeq ($(KBUILD_VERBOSE),1) | |
289 | - quiet = | |
290 | - Q = | |
291 | -else | |
292 | - quiet=quiet_ | |
293 | - Q = @ | |
294 | -endif | |
295 | - | |
296 | -# If the user is running make -s (silent mode), suppress echoing of | |
297 | -# commands | |
298 | - | |
299 | -ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4 | |
300 | -ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),) | |
301 | - quiet=silent_ | |
302 | -endif | |
303 | -else # make-3.8x | |
304 | -ifneq ($(filter s% -s%,$(MAKEFLAGS)),) | |
305 | - quiet=silent_ | |
306 | -endif | |
307 | -endif | |
308 | - | |
309 | -export quiet Q KBUILD_VERBOSE | |
310 | - | |
311 | 317 | # Look for make include files relative to root of kernel src |
312 | 318 | MAKEFLAGS += --include-dir=$(srctree) |
313 | 319 | |
... | ... | @@ -1308,7 +1314,7 @@ |
1308 | 1314 | @echo '' |
1309 | 1315 | @echo 'Other generic targets:' |
1310 | 1316 | @echo ' all - Build all necessary images depending on configuration' |
1311 | - @echo ' u-boot - Build the bare u-boot' | |
1317 | + @echo '* u-boot - Build the bare u-boot' | |
1312 | 1318 | @echo ' dir/ - Build all files in dir and below' |
1313 | 1319 | @echo ' dir/file.[oisS] - Build specified target only' |
1314 | 1320 | @echo ' dir/file.lst - Build specified mixed source/assembly target only' |
... | ... | @@ -1316,8 +1322,8 @@ |
1316 | 1322 | @echo ' tags/ctags - Generate ctags file for editors' |
1317 | 1323 | @echo ' etags - Generate etags file for editors' |
1318 | 1324 | @echo ' cscope - Generate cscope index' |
1319 | - @echo ' ubootrelease - Output the release version string' | |
1320 | - @echo ' ubootversion - Output the version stored in Makefile' | |
1325 | + @echo ' ubootrelease - Output the release version string (use with make -s)' | |
1326 | + @echo ' ubootversion - Output the version stored in Makefile (use with make -s)' | |
1321 | 1327 | @echo '' |
1322 | 1328 | @echo 'Static analysers' |
1323 | 1329 | @echo ' checkstack - Generate a list of stack hogs' |
scripts/Makefile.autoconf
... | ... | @@ -89,9 +89,12 @@ |
89 | 89 | create_symlink: |
90 | 90 | ifneq ($(KBUILD_SRC),) |
91 | 91 | $(Q)mkdir -p include/asm |
92 | + $(Q)ln -fsn $(KBUILD_SRC)/arch/$(ARCH)/include/asm/arch-$(if $(SOC),$(SOC),$(CPU)) \ | |
93 | + include/asm/arch | |
94 | +else | |
95 | + $(Q)ln -fsn arch-$(if $(SOC),$(SOC),$(CPU)) \ | |
96 | + arch/$(ARCH)/include/asm/arch | |
92 | 97 | endif |
93 | - $(Q)ln -fsn $(srctree)/arch/$(ARCH)/include/asm/arch-$(if $(SOC),$(SOC),$(CPU)) \ | |
94 | - $(if $(KBUILD_SRC),,arch/$(ARCH)/)include/asm/arch | |
95 | 98 | |
96 | 99 | PHONY += FORCE |
97 | 100 | FORCE: |
tools/Makefile
... | ... | @@ -157,7 +157,7 @@ |
157 | 157 | #HOSTCFLAGS_mpc86x_clk.o := -pedantic |
158 | 158 | |
159 | 159 | quiet_cmd_wrap = WRAP $@ |
160 | -cmd_wrap = echo "\#include <$(srctree)/$(patsubst $(obj)/%,%,$@)>" >$@ | |
160 | +cmd_wrap = echo "\#include <../$(patsubst $(obj)/%,%,$@)>" >$@ | |
161 | 161 | |
162 | 162 | $(obj)/lib/%.c $(obj)/common/%.c: |
163 | 163 | $(call cmd,wrap) |