]>
Commit | Line | Data |
---|---|---|
1 | # SPDX-License-Identifier: GPL-2.0+ | |
2 | ||
3 | VERSION = 2025 | |
4 | PATCHLEVEL = 10 | |
5 | SUBLEVEL = | |
6 | EXTRAVERSION = -rc4 | |
7 | NAME = | |
8 | ||
9 | # *DOCUMENTATION* | |
10 | # To see a list of typical targets execute "make help" | |
11 | # More info can be located in ./README | |
12 | # Comments in this file are targeted only to the developer, do not | |
13 | # expect to learn how to build the kernel reading this file. | |
14 | ||
15 | # That's our default target when none is given on the command line | |
16 | PHONY := _all | |
17 | _all: | |
18 | ||
19 | # Determine target architecture for the sandbox | |
20 | include include/host_arch.h | |
21 | ifeq ("", "$(CROSS_COMPILE)") | |
22 | MK_ARCH="${shell uname -m}" | |
23 | else | |
24 | MK_ARCH="${shell echo $(CROSS_COMPILE) | sed -n 's/^\(.*ccache\)\{0,1\}[[:space:]]*\([^\/]*\/\)*\([^-]*\)-[^[:space:]]*/\3/p'}" | |
25 | endif | |
26 | unexport HOST_ARCH | |
27 | ifeq ("x86_64", $(MK_ARCH)) | |
28 | export HOST_ARCH=$(HOST_ARCH_X86_64) | |
29 | else ifneq (,$(findstring $(MK_ARCH), "i386" "i486" "i586" "i686")) | |
30 | export HOST_ARCH=$(HOST_ARCH_X86) | |
31 | else ifneq (,$(findstring $(MK_ARCH), "aarch64" "armv8l")) | |
32 | export HOST_ARCH=$(HOST_ARCH_AARCH64) | |
33 | else ifneq (,$(findstring $(MK_ARCH), "arm" "armv5tel" "armv6l" "armv7" "armv7a" "armv7l")) | |
34 | export HOST_ARCH=$(HOST_ARCH_ARM) | |
35 | else ifeq ("riscv32", $(MK_ARCH)) | |
36 | export HOST_ARCH=$(HOST_ARCH_RISCV32) | |
37 | else ifeq ("riscv64", $(MK_ARCH)) | |
38 | export HOST_ARCH=$(HOST_ARCH_RISCV64) | |
39 | endif | |
40 | undefine MK_ARCH | |
41 | ||
42 | # We are using a recursive build, so we need to do a little thinking | |
43 | # to get the ordering right. | |
44 | # | |
45 | # Most importantly: sub-Makefiles should only ever modify files in | |
46 | # their own directory. If in some directory we have a dependency on | |
47 | # a file in another dir (which doesn't happen often, but it's often | |
48 | # unavoidable when linking the built-in.a targets which finally | |
49 | # turn into vmlinux), we will call a sub make in that other dir, and | |
50 | # after that we are sure that everything which is in that other dir | |
51 | # is now up to date. | |
52 | # | |
53 | # The only cases where we need to modify files which have global | |
54 | # effects are thus separated out and done before the recursive | |
55 | # descending is started. They are now explicitly listed as the | |
56 | # prepare rule. | |
57 | ||
58 | ifneq ($(sub_make_done),1) | |
59 | ||
60 | # Do not use make's built-in rules and variables | |
61 | # (this increases performance and avoids hard-to-debug behaviour) | |
62 | MAKEFLAGS += -rR | |
63 | ||
64 | # Avoid funny character set dependencies | |
65 | unexport LC_ALL | |
66 | LC_COLLATE=C | |
67 | LC_NUMERIC=C | |
68 | export LC_COLLATE LC_NUMERIC | |
69 | ||
70 | # Avoid interference with shell env settings | |
71 | unexport GREP_OPTIONS | |
72 | ||
73 | # Beautify output | |
74 | # --------------------------------------------------------------------------- | |
75 | # | |
76 | # Normally, we echo the whole command before executing it. By making | |
77 | # that echo $($(quiet)$(cmd)), we now have the possibility to set | |
78 | # $(quiet) to choose other forms of output instead, e.g. | |
79 | # | |
80 | # quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@ | |
81 | # cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< | |
82 | # | |
83 | # If $(quiet) is empty, the whole command will be printed. | |
84 | # If it is set to "quiet_", only the short version will be printed. | |
85 | # If it is set to "silent_", nothing will be printed at all, since | |
86 | # the variable $(silent_cmd_cc_o_c) doesn't exist. | |
87 | # | |
88 | # A simple variant is to prefix commands with $(Q) - that's useful | |
89 | # for commands that shall be hidden in non-verbose mode. | |
90 | # | |
91 | # $(Q)ln $@ :< | |
92 | # | |
93 | # If KBUILD_VERBOSE equals 0 then the above command will be hidden. | |
94 | # If KBUILD_VERBOSE equals 1 then the above command is displayed. | |
95 | # | |
96 | # To put more focus on warnings, be less verbose as default | |
97 | # Use 'make V=1' to see the full commands | |
98 | ||
99 | ifeq ("$(origin V)", "command line") | |
100 | KBUILD_VERBOSE = $(V) | |
101 | endif | |
102 | ifndef KBUILD_VERBOSE | |
103 | KBUILD_VERBOSE = 0 | |
104 | endif | |
105 | ||
106 | ifeq ($(KBUILD_VERBOSE),1) | |
107 | quiet = | |
108 | Q = | |
109 | else | |
110 | quiet=quiet_ | |
111 | Q = @ | |
112 | endif | |
113 | ||
114 | # If the user is running make -s (silent mode), suppress echoing of | |
115 | # commands | |
116 | ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4 | |
117 | ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),) | |
118 | quiet=silent_ | |
119 | endif | |
120 | else # make-3.8x | |
121 | ifneq ($(filter s% -s%,$(MAKEFLAGS)),) | |
122 | quiet=silent_ | |
123 | endif | |
124 | endif | |
125 | ||
126 | export quiet Q KBUILD_VERBOSE | |
127 | ||
128 | # kbuild supports saving output files in a separate directory. | |
129 | # To locate output files in a separate directory two syntaxes are supported. | |
130 | # In both cases the working directory must be the root of the kernel src. | |
131 | # 1) O= | |
132 | # Use "make O=dir/to/store/output/files/" | |
133 | # | |
134 | # 2) Set KBUILD_OUTPUT | |
135 | # Set the environment variable KBUILD_OUTPUT to point to the directory | |
136 | # where the output files shall be placed. | |
137 | # export KBUILD_OUTPUT=dir/to/store/output/files/ | |
138 | # make | |
139 | # | |
140 | # The O= assignment takes precedence over the KBUILD_OUTPUT environment | |
141 | # variable. | |
142 | ||
143 | # KBUILD_SRC is not intended to be used by the regular user (for now), | |
144 | # it is set on invocation of make with KBUILD_OUTPUT or O= specified. | |
145 | ||
146 | # OK, Make called in directory where kernel src resides | |
147 | # Do we want to locate output files in a separate directory? | |
148 | ifeq ("$(origin O)", "command line") | |
149 | KBUILD_OUTPUT := $(O) | |
150 | endif | |
151 | ||
152 | ifneq ($(words $(subst :, ,$(CURDIR))), 1) | |
153 | $(error main directory cannot contain spaces nor colons) | |
154 | endif | |
155 | ||
156 | ifneq ($(KBUILD_OUTPUT),) | |
157 | # check that the output directory actually exists | |
158 | saved-output := $(KBUILD_OUTPUT) | |
159 | KBUILD_OUTPUT := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) \ | |
160 | && pwd) | |
161 | $(if $(KBUILD_OUTPUT),, \ | |
162 | $(error failed to create output directory "$(saved-output)")) | |
163 | ||
164 | # Look for make include files relative to root of kernel src | |
165 | # | |
166 | # This does not become effective immediately because MAKEFLAGS is re-parsed | |
167 | # once after the Makefile is read. It is OK since we are going to invoke | |
168 | # 'sub-make' below. | |
169 | MAKEFLAGS += --include-dir=$(CURDIR) | |
170 | ||
171 | need-sub-make := 1 | |
172 | else | |
173 | ||
174 | # Do not print "Entering directory ..." at all for in-tree build. | |
175 | MAKEFLAGS += --no-print-directory | |
176 | ||
177 | endif # ifneq ($(KBUILD_OUTPUT),) | |
178 | ||
179 | ifneq ($(filter 3.%,$(MAKE_VERSION)),) | |
180 | # 'MAKEFLAGS += -rR' does not immediately become effective for GNU Make 3.x | |
181 | # We need to invoke sub-make to avoid implicit rules in the top Makefile. | |
182 | need-sub-make := 1 | |
183 | # Cancel implicit rules for this Makefile. | |
184 | $(lastword $(MAKEFILE_LIST)): ; | |
185 | endif | |
186 | ||
187 | export sub_make_done := 1 | |
188 | ||
189 | ifeq ($(need-sub-make),1) | |
190 | ||
191 | PHONY += $(MAKECMDGOALS) sub-make | |
192 | ||
193 | $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make | |
194 | @: | |
195 | ||
196 | # Invoke a second make in the output directory, passing relevant variables | |
197 | sub-make: | |
198 | $(Q)$(MAKE) \ | |
199 | $(if $(KBUILD_OUTPUT),-C $(KBUILD_OUTPUT) KBUILD_SRC=$(CURDIR)) \ | |
200 | -f $(CURDIR)/Makefile $(filter-out _all sub-make,$(MAKECMDGOALS)) | |
201 | ||
202 | endif # need-sub-make | |
203 | endif # sub_make_done | |
204 | ||
205 | # We process the rest of the Makefile if this is the final invocation of make | |
206 | ifeq ($(need-sub-make),) | |
207 | ||
208 | # Do not print "Entering directory ...", | |
209 | # but we want to display it when entering to the output directory | |
210 | # so that IDEs/editors are able to understand relative filenames. | |
211 | MAKEFLAGS += --no-print-directory | |
212 | ||
213 | # Call a source code checker (by default, "sparse") as part of the | |
214 | # C compilation. | |
215 | # | |
216 | # Use 'make C=1' to enable checking of only re-compiled files. | |
217 | # Use 'make C=2' to enable checking of *all* source files, regardless | |
218 | # of whether they are re-compiled or not. | |
219 | # | |
220 | # See the file "Documentation/dev-tools/sparse.rst" for more details, | |
221 | # including where to get the "sparse" utility. | |
222 | ||
223 | ifeq ("$(origin C)", "command line") | |
224 | KBUILD_CHECKSRC = $(C) | |
225 | endif | |
226 | ifndef KBUILD_CHECKSRC | |
227 | KBUILD_CHECKSRC = 0 | |
228 | endif | |
229 | ||
230 | # Use make M=dir to specify directory of external module to build | |
231 | # Old syntax make ... SUBDIRS=$PWD is still supported | |
232 | # Setting the environment variable KBUILD_EXTMOD take precedence | |
233 | ifdef SUBDIRS | |
234 | $(warning ================= WARNING ================) | |
235 | $(warning 'SUBDIRS' will be removed after Linux 5.3) | |
236 | $(warning Please use 'M=' or 'KBUILD_EXTMOD' instead) | |
237 | $(warning ==========================================) | |
238 | KBUILD_EXTMOD ?= $(SUBDIRS) | |
239 | endif | |
240 | ||
241 | ifeq ("$(origin M)", "command line") | |
242 | KBUILD_EXTMOD := $(M) | |
243 | endif | |
244 | ||
245 | ifeq ($(KBUILD_SRC),) | |
246 | # building in the source tree | |
247 | srctree := . | |
248 | else | |
249 | ifeq ($(KBUILD_SRC)/,$(dir $(CURDIR))) | |
250 | # building in a subdirectory of the source tree | |
251 | srctree := .. | |
252 | else | |
253 | srctree := $(KBUILD_SRC) | |
254 | endif | |
255 | endif | |
256 | ||
257 | export KBUILD_CHECKSRC KBUILD_EXTMOD KBUILD_SRC | |
258 | ||
259 | objtree := . | |
260 | src := $(srctree) | |
261 | obj := $(objtree) | |
262 | ||
263 | VPATH := $(srctree) | |
264 | ||
265 | export srctree objtree VPATH | |
266 | ||
267 | # To make sure we do not include .config for any of the *config targets | |
268 | # catch them early, and hand them over to scripts/kconfig/Makefile | |
269 | # It is allowed to specify more targets when calling make, including | |
270 | # mixing *config targets and build targets. | |
271 | # For example 'make oldconfig all'. | |
272 | # Detect when mixed targets is specified, and make a second invocation | |
273 | # of make so .config is not included in this case either (for *config). | |
274 | ||
275 | version_h := include/generated/version_autogenerated.h | |
276 | timestamp_h := include/generated/timestamp_autogenerated.h | |
277 | defaultenv_h := include/generated/defaultenv_autogenerated.h | |
278 | dt_h := include/generated/dt.h | |
279 | env_h := include/generated/environment.h | |
280 | ||
281 | clean-targets := %clean mrproper cleandocs | |
282 | no-dot-config-targets := $(clean-targets) \ | |
283 | clobber distclean \ | |
284 | help %docs check% coccicheck \ | |
285 | ubootversion backup tests check pcheck qcheck tcheck \ | |
286 | pylint pylint_err _pip pip pip_test pip_release | |
287 | no-sync-config-targets := $(no-dot-config-targets) install %install \ | |
288 | kernelrelease | |
289 | ||
290 | config-targets := 0 | |
291 | mixed-targets := 0 | |
292 | dot-config := 1 | |
293 | may-sync-config := 1 | |
294 | ||
295 | ifneq ($(filter $(no-dot-config-targets), $(MAKECMDGOALS)),) | |
296 | ifeq ($(filter-out $(no-dot-config-targets), $(MAKECMDGOALS)),) | |
297 | dot-config := 0 | |
298 | endif | |
299 | endif | |
300 | ||
301 | ifneq ($(filter $(no-sync-config-targets), $(MAKECMDGOALS)),) | |
302 | ifeq ($(filter-out $(no-sync-config-targets), $(MAKECMDGOALS)),) | |
303 | may-sync-config := 0 | |
304 | endif | |
305 | endif | |
306 | ||
307 | ifneq ($(KBUILD_EXTMOD),) | |
308 | may-sync-config := 0 | |
309 | endif | |
310 | ||
311 | ifeq ($(KBUILD_EXTMOD),) | |
312 | ifneq ($(filter config %config,$(MAKECMDGOALS)),) | |
313 | config-targets := 1 | |
314 | ifneq ($(words $(MAKECMDGOALS)),1) | |
315 | mixed-targets := 1 | |
316 | endif | |
317 | endif | |
318 | endif | |
319 | ||
320 | # For "make -j clean all", "make -j mrproper defconfig all", etc. | |
321 | ifneq ($(filter $(clean-targets),$(MAKECMDGOALS)),) | |
322 | ifneq ($(filter-out $(clean-targets),$(MAKECMDGOALS)),) | |
323 | mixed-targets := 1 | |
324 | endif | |
325 | endif | |
326 | ||
327 | # install and modules_install need also be processed one by one | |
328 | ifneq ($(filter install,$(MAKECMDGOALS)),) | |
329 | ifneq ($(filter modules_install,$(MAKECMDGOALS)),) | |
330 | mixed-targets := 1 | |
331 | endif | |
332 | endif | |
333 | ||
334 | ifeq ($(mixed-targets),1) | |
335 | # =========================================================================== | |
336 | # We're called with mixed targets (*config and build targets). | |
337 | # Handle them one by one. | |
338 | ||
339 | PHONY += $(MAKECMDGOALS) __build_one_by_one | |
340 | ||
341 | $(filter-out __build_one_by_one, $(MAKECMDGOALS)): __build_one_by_one | |
342 | @: | |
343 | ||
344 | __build_one_by_one: | |
345 | $(Q)set -e; \ | |
346 | for i in $(MAKECMDGOALS); do \ | |
347 | $(MAKE) -f $(srctree)/Makefile $$i; \ | |
348 | done | |
349 | ||
350 | else | |
351 | ||
352 | include scripts/Kbuild.include | |
353 | ||
354 | # Read UBOOTRELEASE from include/config/uboot.release (if it exists) | |
355 | UBOOTRELEASE = $(shell cat include/config/uboot.release 2> /dev/null) | |
356 | UBOOTVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION) | |
357 | export VERSION PATCHLEVEL SUBLEVEL UBOOTRELEASE UBOOTVERSION | |
358 | ||
359 | # Modified for U-Boot | |
360 | -include scripts/subarch.include | |
361 | ||
362 | # Cross compiling and selecting different set of gcc/bin-utils | |
363 | # --------------------------------------------------------------------------- | |
364 | # | |
365 | # When performing cross compilation for other architectures ARCH shall be set | |
366 | # to the target architecture. (See arch/* for the possibilities). | |
367 | # ARCH can be set during invocation of make: | |
368 | # make ARCH=ia64 | |
369 | # Another way is to have ARCH set in the environment. | |
370 | # The default ARCH is the host where make is executed. | |
371 | ||
372 | # CROSS_COMPILE specify the prefix used for all executables used | |
373 | # during compilation. Only gcc and related bin-utils executables | |
374 | # are prefixed with $(CROSS_COMPILE). | |
375 | # CROSS_COMPILE can be set on the command line | |
376 | # make CROSS_COMPILE=ia64-linux- | |
377 | # Alternatively CROSS_COMPILE can be set in the environment. | |
378 | # Default value for CROSS_COMPILE is not to prefix executables | |
379 | # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile | |
380 | ARCH ?= $(SUBARCH) | |
381 | ||
382 | # Architecture as present in compile.h | |
383 | UTS_MACHINE := $(ARCH) | |
384 | SRCARCH := $(ARCH) | |
385 | ||
386 | # Additional ARCH settings for x86 | |
387 | ifeq ($(ARCH),i386) | |
388 | SRCARCH := x86 | |
389 | endif | |
390 | ifeq ($(ARCH),x86_64) | |
391 | SRCARCH := x86 | |
392 | endif | |
393 | ||
394 | # Additional ARCH settings for sparc | |
395 | ifeq ($(ARCH),sparc32) | |
396 | SRCARCH := sparc | |
397 | endif | |
398 | ifeq ($(ARCH),sparc64) | |
399 | SRCARCH := sparc | |
400 | endif | |
401 | ||
402 | # Additional ARCH settings for sh | |
403 | ifeq ($(ARCH),sh64) | |
404 | SRCARCH := sh | |
405 | endif | |
406 | ||
407 | KCONFIG_CONFIG ?= .config | |
408 | export KCONFIG_CONFIG | |
409 | ||
410 | # SHELL used by kbuild | |
411 | CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ | |
412 | else if [ -x /bin/bash ]; then echo /bin/bash; \ | |
413 | else echo sh; fi ; fi) | |
414 | ||
415 | HOST_LFS_CFLAGS := $(shell getconf LFS_CFLAGS 2>/dev/null) | |
416 | HOST_LFS_LDFLAGS := $(shell getconf LFS_LDFLAGS 2>/dev/null) | |
417 | HOST_LFS_LIBS := $(shell getconf LFS_LIBS 2>/dev/null) | |
418 | ||
419 | HOSTCC = cc | |
420 | HOSTCXX = c++ | |
421 | KBUILD_HOSTCFLAGS := -Wall -Wstrict-prototypes -O2 \ | |
422 | -fomit-frame-pointer -std=gnu11 $(HOST_LFS_CFLAGS) \ | |
423 | $(HOSTCFLAGS) #-Wmissing-prototypes Enable it and fix warnings | |
424 | KBUILD_HOSTCXXFLAGS := -O2 $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS) | |
425 | KBUILD_HOSTLDFLAGS := $(HOST_LFS_LDFLAGS) $(HOSTLDFLAGS) | |
426 | KBUILD_HOSTLDLIBS := $(HOST_LFS_LIBS) $(HOSTLDLIBS) | |
427 | ||
428 | # Check ths size of a binary: | |
429 | # Args: | |
430 | # $1: File to check | |
431 | # #2: Size limit in bytes (decimal or 0xhex) | |
432 | define size_check | |
433 | actual=$$( wc -c $1 | awk '{print $$1}'); \ | |
434 | limit=$$( printf "%d" $2 ); \ | |
435 | if test $$actual -gt $$limit; then \ | |
436 | echo "$1 exceeds file size limit:" >&2; \ | |
437 | echo " limit: $$(printf %#x $$limit) bytes" >&2; \ | |
438 | echo " actual: $$(printf %#x $$actual) bytes" >&2; \ | |
439 | echo " excess: $$(printf %#x $$((actual - limit))) bytes" >&2;\ | |
440 | exit 1; \ | |
441 | fi | |
442 | endef | |
443 | export size_check | |
444 | ||
445 | export KBUILD_MODULES KBUILD_BUILTIN | |
446 | export KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD | |
447 | ||
448 | # Make variables (CC, etc...) | |
449 | AS = $(CROSS_COMPILE)as | |
450 | LD = $(CROSS_COMPILE)ld | |
451 | CC = $(CROSS_COMPILE)gcc | |
452 | CPP = $(CC) -E | |
453 | AR = $(CROSS_COMPILE)ar | |
454 | NM = $(CROSS_COMPILE)nm | |
455 | LDR = $(CROSS_COMPILE)ldr | |
456 | STRIP = $(CROSS_COMPILE)strip | |
457 | OBJCOPY = $(CROSS_COMPILE)objcopy | |
458 | OBJDUMP = $(CROSS_COMPILE)objdump | |
459 | READELF = $(CROSS_COMPILE)readelf | |
460 | LEX = flex | |
461 | YACC = bison | |
462 | AWK = awk | |
463 | INSTALLKERNEL := installkernel | |
464 | DEPMOD = /sbin/depmod | |
465 | PERL = perl | |
466 | PYTHON = python | |
467 | PYTHON2 = python2 | |
468 | PYTHON3 = python3 | |
469 | ||
470 | # The devicetree compiler and pylibfdt are automatically built unless DTC is | |
471 | # provided. If DTC is provided, it is assumed the pylibfdt is available too. | |
472 | DTC_INTREE := $(objtree)/scripts/dtc/dtc | |
473 | DTC ?= $(DTC_INTREE) | |
474 | DTC_MIN_VERSION := 010406 | |
475 | ||
476 | CHECK = sparse | |
477 | ||
478 | CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ | |
479 | -Wbitwise -Wno-return-void -Wno-unknown-attribute -D__CHECK_ENDIAN__ $(CF) | |
480 | NOSTDINC_FLAGS := | |
481 | CFLAGS_MODULE = | |
482 | AFLAGS_MODULE = | |
483 | LDFLAGS_MODULE = | |
484 | CFLAGS_KERNEL = | |
485 | AFLAGS_KERNEL = | |
486 | LDFLAGS_vmlinux = | |
487 | ||
488 | # Use USERINCLUDE when you must reference the UAPI directories only. | |
489 | USERINCLUDE := \ | |
490 | -I$(srctree)/arch/$(SRCARCH)/include/uapi \ | |
491 | -I$(objtree)/arch/$(SRCARCH)/include/generated/uapi \ | |
492 | -I$(srctree)/include/uapi \ | |
493 | -I$(objtree)/include/generated/uapi \ | |
494 | -include $(srctree)/include/linux/kconfig.h | |
495 | ||
496 | # Use UBOOTINCLUDE when you must reference the include/ directory. | |
497 | # Needed to be compatible with the O= option | |
498 | UBOOTINCLUDE := \ | |
499 | -Iinclude \ | |
500 | $(if $(KBUILD_SRC), -I$(srctree)/include) \ | |
501 | $(if $(CONFIG_$(XPL_)MBEDTLS_LIB), \ | |
502 | "-DMBEDTLS_CONFIG_FILE=\"mbedtls_def_config.h\"" \ | |
503 | -I$(srctree)/lib/mbedtls \ | |
504 | -I$(srctree)/lib/mbedtls/port \ | |
505 | -I$(srctree)/lib/mbedtls/external/mbedtls \ | |
506 | -I$(srctree)/lib/mbedtls/external/mbedtls/include) \ | |
507 | $(if $(CONFIG_$(PHASE_)SYS_THUMB_BUILD), \ | |
508 | $(if $(CONFIG_HAS_THUMB2), \ | |
509 | $(if $(CONFIG_CPU_V7M), \ | |
510 | -I$(srctree)/arch/arm/thumb1/include), \ | |
511 | -I$(srctree)/arch/arm/thumb1/include)) \ | |
512 | -I$(srctree)/arch/$(ARCH)/include \ | |
513 | -include $(srctree)/include/linux/kconfig.h \ | |
514 | -I$(srctree)/dts/upstream/include \ | |
515 | $(if $(CONFIG_NET_LWIP), -I$(srctree)/lib/lwip/lwip/src/include \ | |
516 | -I$(srctree)/lib/lwip/u-boot) | |
517 | ||
518 | ||
519 | KBUILD_AFLAGS := -D__ASSEMBLY__ -fno-PIE | |
520 | KBUILD_CFLAGS := -Wall -Werror=strict-prototypes -Wno-trigraphs \ | |
521 | -fno-strict-aliasing -fno-common -fshort-wchar -fno-PIE \ | |
522 | -Werror=implicit-function-declaration -Werror=implicit-int \ | |
523 | -Wno-format-security -std=gnu11 #-Wundef Enable it and fix warnings | |
524 | UBOOT_CFLAGS := -ffreestanding -fno-builtin | |
525 | KBUILD_CFLAGS += $(UBOOT_CFLAGS) | |
526 | ||
527 | KBUILD_CPPFLAGS := -D__KERNEL__ -D__UBOOT__ | |
528 | KBUILD_AFLAGS_KERNEL := | |
529 | KBUILD_CFLAGS_KERNEL := | |
530 | KBUILD_AFLAGS_MODULE := -DMODULE | |
531 | KBUILD_CFLAGS_MODULE := -DMODULE | |
532 | KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds | |
533 | KBUILD_LDFLAGS := | |
534 | GCC_PLUGINS_CFLAGS := | |
535 | ||
536 | export ARCH SRCARCH CONFIG_SHELL HOSTCC KBUILD_HOSTCFLAGS CROSS_COMPILE AS LD CC | |
537 | export CPP AR NM STRIP OBJCOPY OBJDUMP KBUILD_HOSTLDFLAGS KBUILD_HOSTLDLIBS | |
538 | export MAKE LEX YACC AWK INSTALLKERNEL PERL PYTHON PYTHON2 PYTHON3 UTS_MACHINE | |
539 | export HOSTCXX KBUILD_HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS | |
540 | ||
541 | export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS KBUILD_LDFLAGS | |
542 | export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE | |
543 | export CFLAGS_KASAN CFLAGS_KASAN_NOSANITIZE CFLAGS_UBSAN | |
544 | export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE | |
545 | export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE | |
546 | export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL | |
547 | export KBUILD_ARFLAGS | |
548 | ||
549 | export LDR | |
550 | export CPU BOARD VENDOR SOC CPUDIR BOARDDIR | |
551 | export UBOOTINCLUDE | |
552 | export CC_VERSION_TEXT := $(shell $(CC) --version | head -n 1) | |
553 | ||
554 | # When compiling out-of-tree modules, put MODVERDIR in the module | |
555 | # tree rather than in the kernel tree. The kernel tree might | |
556 | # even be read-only. | |
557 | export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_versions | |
558 | ||
559 | # Files to ignore in find ... statements | |
560 | ||
561 | export RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o \ | |
562 | -name CVS -o -name .pc -o -name .hg -o -name .git \) \ | |
563 | -prune -o | |
564 | export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \ | |
565 | --exclude CVS --exclude .pc --exclude .hg --exclude .git | |
566 | ||
567 | export PYTHON_ENABLE | |
568 | ||
569 | # This is y if U-Boot should not build any Python tools or libraries. Typically | |
570 | # you would need to set this if those tools/libraries (typically binman and | |
571 | # pylibfdt) cannot be built by your environment and are provided separately. | |
572 | ifeq ($(NO_PYTHON),) | |
573 | PYTHON_ENABLE=y | |
574 | endif | |
575 | ||
576 | # =========================================================================== | |
577 | # Rules shared between *config targets and build targets | |
578 | ||
579 | # Basic helpers built in scripts/basic/ | |
580 | PHONY += scripts_basic | |
581 | scripts_basic: | |
582 | $(Q)$(MAKE) $(build)=scripts/basic | |
583 | $(Q)rm -f .tmp_quiet_recordmcount | |
584 | ||
585 | PHONY += outputmakefile | |
586 | # outputmakefile generates a Makefile in the output directory, if using a | |
587 | # separate output directory. This allows convenient use of make in the | |
588 | # output directory. | |
589 | # At the same time when output Makefile generated, generate .gitignore to | |
590 | # ignore whole output directory | |
591 | outputmakefile: | |
592 | ifneq ($(KBUILD_SRC),) | |
593 | $(Q)ln -fsn $(srctree) source | |
594 | $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree) | |
595 | $(Q)test -e .gitignore || \ | |
596 | { echo "# this is build directory, ignore it"; echo "*"; } > .gitignore | |
597 | endif | |
598 | ||
599 | ifneq ($(shell $(CC) --version 2>&1 | head -n 1 | grep clang),) | |
600 | ifneq ($(CROSS_COMPILE),) | |
601 | CLANG_FLAGS := --target=$(notdir $(CROSS_COMPILE:%-=%)) | |
602 | GCC_TOOLCHAIN_DIR := $(dir $(shell which $(CROSS_COMPILE)elfedit)) | |
603 | CLANG_FLAGS += --prefix=$(GCC_TOOLCHAIN_DIR) | |
604 | GCC_TOOLCHAIN := $(realpath $(GCC_TOOLCHAIN_DIR)/..) | |
605 | endif | |
606 | ifneq ($(GCC_TOOLCHAIN),) | |
607 | CLANG_FLAGS += --gcc-toolchain=$(GCC_TOOLCHAIN) | |
608 | endif | |
609 | CLANG_FLAGS += -no-integrated-as | |
610 | KBUILD_CFLAGS += $(CLANG_FLAGS) | |
611 | KBUILD_AFLAGS += $(CLANG_FLAGS) | |
612 | export CLANG_FLAGS | |
613 | endif | |
614 | ||
615 | RETPOLINE_CFLAGS_GCC := -mindirect-branch=thunk-extern -mindirect-branch-register | |
616 | RETPOLINE_VDSO_CFLAGS_GCC := -mindirect-branch=thunk-inline -mindirect-branch-register | |
617 | RETPOLINE_CFLAGS_CLANG := -mretpoline-external-thunk | |
618 | RETPOLINE_VDSO_CFLAGS_CLANG := -mretpoline | |
619 | RETPOLINE_CFLAGS := $(call cc-option,$(RETPOLINE_CFLAGS_GCC),$(call cc-option,$(RETPOLINE_CFLAGS_CLANG))) | |
620 | RETPOLINE_VDSO_CFLAGS := $(call cc-option,$(RETPOLINE_VDSO_CFLAGS_GCC),$(call cc-option,$(RETPOLINE_VDSO_CFLAGS_CLANG))) | |
621 | export RETPOLINE_CFLAGS | |
622 | export RETPOLINE_VDSO_CFLAGS | |
623 | ||
624 | # The expansion should be delayed until arch/$(SRCARCH)/Makefile is included. | |
625 | # Some architectures define CROSS_COMPILE in arch/$(SRCARCH)/Makefile. | |
626 | # CC_VERSION_TEXT is referenced from Kconfig (so it needs export), | |
627 | # and from include/config/auto.conf.cmd to detect the compiler upgrade. | |
628 | CC_VERSION_TEXT = $(shell $(CC) --version | head -n 1) | |
629 | ||
630 | ifeq ($(config-targets),1) | |
631 | # =========================================================================== | |
632 | # *config targets only - make sure prerequisites are updated, and descend | |
633 | # in scripts/kconfig to make the *config target | |
634 | ||
635 | # Read arch specific Makefile to set KBUILD_DEFCONFIG as needed. | |
636 | # KBUILD_DEFCONFIG may point out an alternative default configuration | |
637 | # used for 'make defconfig' | |
638 | # Modified for U-Boot: we don't include arch/$(SRCARCH)/Makefile for config | |
639 | # targets, which is useless since U-Boot has no architecture defining its own | |
640 | # KBUILD_{DEF,K}CONFIG, or CROSS_COMPILE. | |
641 | export KBUILD_DEFCONFIG KBUILD_KCONFIG CC_VERSION_TEXT | |
642 | ||
643 | config: scripts_basic outputmakefile FORCE | |
644 | $(Q)$(MAKE) $(build)=scripts/kconfig $@ | |
645 | ||
646 | %config: scripts_basic outputmakefile FORCE | |
647 | $(Q)$(MAKE) $(build)=scripts/kconfig $@ | |
648 | ||
649 | else | |
650 | # =========================================================================== | |
651 | # Build targets only - this includes vmlinux, arch specific targets, clean | |
652 | # targets and others. In general all targets except *config targets. | |
653 | ||
654 | # If building an external module we do not care about the all: rule | |
655 | # but instead _all depend on modules | |
656 | PHONY += all | |
657 | ifeq ($(KBUILD_EXTMOD),) | |
658 | _all: all | |
659 | else | |
660 | _all: modules | |
661 | endif | |
662 | ||
663 | # Decide whether to build built-in, modular, or both. | |
664 | # Normally, just do built-in. | |
665 | ||
666 | KBUILD_MODULES := | |
667 | KBUILD_BUILTIN := 1 | |
668 | ||
669 | # If we have only "make modules", don't compile built-in objects. | |
670 | # When we're building modules with modversions, we need to consider | |
671 | # the built-in objects during the descend as well, in order to | |
672 | # make sure the checksums are up to date before we record them. | |
673 | ||
674 | ifeq ($(MAKECMDGOALS),modules) | |
675 | KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1) | |
676 | endif | |
677 | ||
678 | # If we have "make <whatever> modules", compile modules | |
679 | # in addition to whatever we do anyway. | |
680 | # Just "make" or "make all" shall build modules as well | |
681 | ||
682 | ifneq ($(filter all _all modules,$(MAKECMDGOALS)),) | |
683 | KBUILD_MODULES := 1 | |
684 | endif | |
685 | ||
686 | ifeq ($(MAKECMDGOALS),) | |
687 | KBUILD_MODULES := 1 | |
688 | endif | |
689 | ||
690 | export KBUILD_MODULES KBUILD_BUILTIN | |
691 | ||
692 | ifeq ($(KBUILD_EXTMOD),) | |
693 | # Objects we will link into vmlinux / subdirs we need to visit | |
694 | init-y := init/ | |
695 | drivers-y := drivers/ sound/ | |
696 | net-y := net/ | |
697 | libs-y := lib/ | |
698 | core-y := usr/ | |
699 | virt-y := virt/ | |
700 | endif # KBUILD_EXTMOD | |
701 | ||
702 | ifeq ($(dot-config),1) | |
703 | # Modified for U-Boot | |
704 | -include include/config/auto.conf | |
705 | endif | |
706 | ||
707 | # The all: target is the default when no target is given on the | |
708 | # command line. | |
709 | # This allow a user to issue only 'make' to build a kernel including modules | |
710 | # Defaults to vmlinux, but the arch makefile usually adds further targets | |
711 | all: u-boot | |
712 | ||
713 | CFLAGS_GCOV := -fprofile-arcs -ftest-coverage \ | |
714 | $(call cc-option,-fno-tree-loop-im) \ | |
715 | $(call cc-disable-warning,maybe-uninitialized,) | |
716 | export CFLAGS_GCOV | |
717 | ||
718 | # The arch Makefiles can override CC_FLAGS_FTRACE. We may also append it later. | |
719 | ifdef CONFIG_FUNCTION_TRACER | |
720 | CC_FLAGS_FTRACE := -pg | |
721 | endif | |
722 | ||
723 | # The arch Makefile can set ARCH_{CPP,A,C}FLAGS to override the default | |
724 | # values of the respective KBUILD_* variables | |
725 | ARCH_CPPFLAGS := | |
726 | ARCH_AFLAGS := | |
727 | ARCH_CFLAGS := | |
728 | # Modified for U-Boot: we put off the include of arch/$(SRCARCH)/Makefile until | |
729 | # making sure include/config/auto.conf is up-to-date and include of config.mk, | |
730 | # because the architecture-specific Makefile may make use of variables defined | |
731 | # in config.mk. See also the comment about autoconf_is_old. | |
732 | ||
733 | ifeq ($(dot-config),1) | |
734 | ifeq ($(may-sync-config),1) | |
735 | # Read in dependencies to all Kconfig* files, make sure to run syncconfig if | |
736 | # changes are detected. This should be included after arch/$(SRCARCH)/Makefile | |
737 | # because some architectures define CROSS_COMPILE there. | |
738 | -include include/config/auto.conf.cmd | |
739 | ||
740 | $(KCONFIG_CONFIG): | |
741 | @echo >&2 '***' | |
742 | @echo >&2 '*** Configuration file "$@" not found!' | |
743 | @echo >&2 '***' | |
744 | @echo >&2 '*** Please run some configurator (e.g. "make oldconfig" or' | |
745 | @echo >&2 '*** "make menuconfig" or "make xconfig").' | |
746 | @echo >&2 '***' | |
747 | @/bin/false | |
748 | ||
749 | # If .config is newer than include/config/auto.conf, someone tinkered | |
750 | # with it and forgot to run make oldconfig. | |
751 | # if auto.conf.cmd is missing then we are probably in a cleaned tree so | |
752 | # we execute the config step to be sure to catch updated Kconfig files | |
753 | include/config/%.conf: $(KCONFIG_CONFIG) #include/config/auto.conf.cmd | |
754 | $(Q)$(MAKE) -f $(srctree)/Makefile syncconfig | |
755 | @# If the following part fails, include/config/auto.conf should be | |
756 | @# deleted so "make silentoldconfig" will be re-run on the next build. | |
757 | $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.autoconf || \ | |
758 | { rm -f include/config/auto.conf; false; } | |
759 | @# include/config.h has been updated after "make silentoldconfig". | |
760 | @# We need to touch include/config/auto.conf so it gets newer | |
761 | @# than include/config.h. | |
762 | @# Otherwise, 'make silentoldconfig' would be invoked twice. | |
763 | $(Q)touch include/config/auto.conf | |
764 | ||
765 | u-boot.cfg spl/u-boot.cfg tpl/u-boot.cfg vpl/u-boot.cfg: | |
766 | $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.autoconf $(@) | |
767 | ||
768 | -include include/autoconf.mk | |
769 | -include include/autoconf.mk.dep | |
770 | ||
771 | # We want to include arch/$(ARCH)/config.mk only when include/config/auto.conf | |
772 | # is up-to-date. When we switch to a different board configuration, old CONFIG | |
773 | # macros are still remaining in include/config/auto.conf. Without the following | |
774 | # gimmick, wrong config.mk would be included leading nasty warnings/errors. | |
775 | ifneq ($(wildcard $(KCONFIG_CONFIG)),) | |
776 | ifneq ($(wildcard include/config/auto.conf),) | |
777 | autoconf_is_old := $(shell find . -path ./$(KCONFIG_CONFIG) -newer \ | |
778 | include/config/auto.conf) | |
779 | ifeq ($(autoconf_is_old),) | |
780 | include config.mk | |
781 | include arch/$(ARCH)/Makefile | |
782 | endif | |
783 | endif | |
784 | endif | |
785 | ||
786 | # These are set by the arch-specific config.mk. Make sure they are exported | |
787 | # so they can be used when building an EFI application. | |
788 | export EFI_LDS # Filename of EFI link script in arch/$(ARCH)/lib | |
789 | export EFI_CRT0 # Filename of EFI CRT0 in arch/$(ARCH)/lib | |
790 | export EFI_RELOC # Filename of EFU relocation code in arch/$(ARCH)/lib | |
791 | export CFLAGS_EFI # Compiler flags to add when building EFI app | |
792 | export CFLAGS_NON_EFI # Compiler flags to remove when building EFI app | |
793 | export EFI_TARGET # binutils target if EFI is natively supported | |
794 | ||
795 | export LTO_ENABLE | |
796 | ||
797 | # This is y if LTO is enabled for this build. See NO_LTO=1 to disable LTO | |
798 | ifeq ($(NO_LTO),) | |
799 | LTO_ENABLE=$(if $(CONFIG_LTO),y) | |
800 | endif | |
801 | ||
802 | # If board code explicitly specified LDSCRIPT or CONFIG_SYS_LDSCRIPT, use | |
803 | # that (or fail if absent). Otherwise, search for a linker script in a | |
804 | # standard location. | |
805 | ||
806 | ifndef LDSCRIPT | |
807 | #LDSCRIPT := $(srctree)/board/$(BOARDDIR)/u-boot.lds.debug | |
808 | ifdef CONFIG_SYS_LDSCRIPT | |
809 | # need to strip off double quotes | |
810 | LDSCRIPT := $(srctree)/$(CONFIG_SYS_LDSCRIPT:"%"=%) | |
811 | endif | |
812 | endif | |
813 | ||
814 | # If there is no specified link script, we look in a number of places for it | |
815 | ifndef LDSCRIPT | |
816 | ifeq ($(wildcard $(LDSCRIPT)),) | |
817 | LDSCRIPT := $(srctree)/board/$(BOARDDIR)/u-boot.lds | |
818 | endif | |
819 | ifeq ($(wildcard $(LDSCRIPT)),) | |
820 | LDSCRIPT := $(srctree)/$(CPUDIR)/u-boot.lds | |
821 | endif | |
822 | ifeq ($(wildcard $(LDSCRIPT)),) | |
823 | LDSCRIPT := $(srctree)/arch/$(ARCH)/cpu/u-boot.lds | |
824 | endif | |
825 | endif | |
826 | ||
827 | else | |
828 | # External modules and some install targets need include/generated/autoconf.h | |
829 | # and include/config/auto.conf but do not care if they are up-to-date. | |
830 | # Use auto.conf to trigger the test | |
831 | PHONY += include/config/auto.conf | |
832 | ||
833 | include/config/auto.conf: | |
834 | $(Q)test -e include/generated/autoconf.h -a -e $@ || ( \ | |
835 | echo >&2; \ | |
836 | echo >&2 " ERROR: Kernel configuration is invalid."; \ | |
837 | echo >&2 " include/generated/autoconf.h or $@ are missing.";\ | |
838 | echo >&2 " Run 'make oldconfig && make prepare' on kernel src to fix it."; \ | |
839 | echo >&2 ; \ | |
840 | /bin/false) | |
841 | ||
842 | endif # may-sync-config | |
843 | endif # $(dot-config) | |
844 | ||
845 | KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks,) | |
846 | KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,) | |
847 | KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation) | |
848 | KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow) | |
849 | KBUILD_CFLAGS += $(call cc-disable-warning, int-in-bool-context) | |
850 | KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) | |
851 | ||
852 | ifdef CONFIG_CC_OPTIMIZE_FOR_DEBUG | |
853 | KBUILD_HOSTCFLAGS := -Wall -Wstrict-prototypes -Og -g -fomit-frame-pointer \ | |
854 | $(HOST_LFS_CFLAGS) $(HOSTCFLAGS) | |
855 | # Avoid false positives -Wmaybe-uninitialized | |
856 | # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78394 | |
857 | KBUILD_HOSTCFLAGS += -Wno-maybe-uninitialized | |
858 | KBUILD_HOSTCXXFLAGS := -Og -g $(HOST_LFS_CFLAGS) $(HOSTCXXFLAGS) | |
859 | endif | |
860 | ||
861 | # | |
862 | # Xtensa linker script cannot be preprocessed with -ansi because of | |
863 | # preprocessor operations on strings that don't make C identifiers. | |
864 | # | |
865 | ifeq ($(CONFIG_XTENSA),) | |
866 | LDPPFLAGS += -ansi | |
867 | endif | |
868 | ||
869 | ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE | |
870 | KBUILD_CFLAGS += -Os | |
871 | else | |
872 | KBUILD_CFLAGS += -O2 | |
873 | endif | |
874 | ||
875 | ifdef CONFIG_CC_DISABLE_WARN_MAYBE_UNINITIALIZED | |
876 | KBUILD_CFLAGS += -Wno-maybe-uninitialized | |
877 | endif | |
878 | ||
879 | # Tell gcc to never replace conditional load with a non-conditional one | |
880 | KBUILD_CFLAGS += $(call cc-option,--param=allow-store-data-races=0) | |
881 | ||
882 | include scripts/Makefile.kcov | |
883 | include scripts/Makefile.gcc-plugins | |
884 | LTO_CFLAGS := | |
885 | LTO_FINAL_LDFLAGS := | |
886 | export LTO_CFLAGS LTO_FINAL_LDFLAGS | |
887 | ifeq ($(LTO_ENABLE),y) | |
888 | ifeq ($(cc-name),clang) | |
889 | LTO_CFLAGS += -DLTO_ENABLE -flto | |
890 | LTO_FINAL_LDFLAGS += -flto | |
891 | ||
892 | AR = $(shell $(CC) -print-prog-name=llvm-ar) | |
893 | NM = $(shell $(CC) -print-prog-name=llvm-nm) | |
894 | else | |
895 | NPROC := $(shell nproc 2>/dev/null || echo 1) | |
896 | LTO_CFLAGS += -DLTO_ENABLE -flto=$(NPROC) | |
897 | LTO_FINAL_LDFLAGS += -fuse-linker-plugin -flto=$(NPROC) | |
898 | ||
899 | # use plugin aware tools | |
900 | AR = $(CROSS_COMPILE)gcc-ar | |
901 | NM = $(CROSS_COMPILE)gcc-nm | |
902 | endif | |
903 | ||
904 | CFLAGS_NON_EFI += $(LTO_CFLAGS) | |
905 | ||
906 | KBUILD_CFLAGS += $(LTO_CFLAGS) | |
907 | endif | |
908 | ||
909 | ifeq ($(CONFIG_STACKPROTECTOR),y) | |
910 | KBUILD_CFLAGS += $(call cc-option,-fstack-protector-strong) | |
911 | KBUILD_CFLAGS += $(call cc-option,-mstack-protector-guard=global) | |
912 | CFLAGS_EFI += $(call cc-option,-fno-stack-protector) | |
913 | else | |
914 | KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector) | |
915 | endif | |
916 | KBUILD_CFLAGS += $(call cc-option,-fno-delete-null-pointer-checks) | |
917 | ||
918 | KBUILD_CFLAGS += $(call cc-disable-warning, zero-length-bounds) | |
919 | KBUILD_CFLAGS += $(call cc-disable-warning, array-bounds) | |
920 | KBUILD_CFLAGS += $(call cc-disable-warning, stringop-overflow) | |
921 | ||
922 | # Enabled with W=2, disabled by default as noisy | |
923 | KBUILD_CFLAGS += $(call cc-disable-warning, maybe-uninitialized) | |
924 | ||
925 | # change __FILE__ to the relative path from the srctree | |
926 | KBUILD_CFLAGS += $(call cc-option,-fmacro-prefix-map=$(srctree)/=) | |
927 | ||
928 | KBUILD_CFLAGS += -gdwarf-4 | |
929 | # $(KBUILD_AFLAGS) sets -g, which causes gcc to pass a suitable -g<format> | |
930 | # option to the assembler. | |
931 | KBUILD_AFLAGS += -gdwarf-4 | |
932 | ||
933 | # Report stack usage if supported | |
934 | # ARC tools based on GCC 7.1 has an issue with stack usage | |
935 | # with naked functions, see commit message for more details | |
936 | ifndef CONFIG_ARC | |
937 | ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-stack-usage.sh $(CC)),y) | |
938 | KBUILD_CFLAGS += -fstack-usage | |
939 | endif | |
940 | endif | |
941 | ||
942 | KBUILD_CFLAGS += $(call cc-option,-Wno-format-nonliteral) | |
943 | KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) | |
944 | ||
945 | ifdef CONFIG_CC_IS_CLANG | |
946 | KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,) | |
947 | KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier) | |
948 | KBUILD_CFLAGS += $(call cc-disable-warning, gnu) | |
949 | # Quiet clang warning: comparison of unsigned expression < 0 is always false | |
950 | KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare) | |
951 | # CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the | |
952 | # source of a reference will be _MergedGlobals and not on of the whitelisted names. | |
953 | # See modpost pattern 2 | |
954 | KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,) | |
955 | KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior) | |
956 | KBUILD_CFLAGS += $(call cc-disable-warning, deprecated-non-prototype) | |
957 | else | |
958 | ||
959 | # These warnings generated too much noise in a regular build. | |
960 | # Use make W=1 to enable them (see scripts/Makefile.extrawarn) | |
961 | KBUILD_CFLAGS += -Wno-unused-but-set-variable | |
962 | endif | |
963 | ||
964 | # These warnings generated too much noise in a regular build. | |
965 | # Use make W=1 to enable them (see scripts/Makefile.extrawarn) | |
966 | KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) | |
967 | ||
968 | # Prohibit date/time macros, which would make the build non-deterministic | |
969 | KBUILD_CFLAGS += $(call cc-option,-Werror=date-time) | |
970 | ||
971 | include scripts/Makefile.extrawarn | |
972 | ||
973 | # Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments | |
974 | KBUILD_CPPFLAGS += $(KCPPFLAGS) | |
975 | KBUILD_AFLAGS += $(KAFLAGS) | |
976 | KBUILD_CFLAGS += $(KCFLAGS) | |
977 | ||
978 | KBUILD_LDFLAGS += -z noexecstack | |
979 | KBUILD_LDFLAGS += -z norelro | |
980 | KBUILD_LDFLAGS += $(call ld-option,--no-warn-rwx-segments) | |
981 | ||
982 | KBUILD_HOSTCFLAGS += $(if $(CONFIG_TOOLS_DEBUG),-g) | |
983 | ||
984 | # Use UBOOTINCLUDE when you must reference the include/ directory. | |
985 | # Needed to be compatible with the O= option | |
986 | UBOOTINCLUDE := \ | |
987 | -Iinclude \ | |
988 | $(if $(KBUILD_SRC), -I$(srctree)/include) \ | |
989 | $(if $(CONFIG_$(XPL_)MBEDTLS_LIB), \ | |
990 | "-DMBEDTLS_CONFIG_FILE=\"mbedtls_def_config.h\"" \ | |
991 | -I$(srctree)/lib/mbedtls \ | |
992 | -I$(srctree)/lib/mbedtls/port \ | |
993 | -I$(srctree)/lib/mbedtls/external/mbedtls \ | |
994 | -I$(srctree)/lib/mbedtls/external/mbedtls/include) \ | |
995 | $(if $(CONFIG_$(PHASE_)SYS_THUMB_BUILD), \ | |
996 | $(if $(CONFIG_HAS_THUMB2), \ | |
997 | $(if $(CONFIG_CPU_V7M), \ | |
998 | -I$(srctree)/arch/arm/thumb1/include), \ | |
999 | -I$(srctree)/arch/arm/thumb1/include)) \ | |
1000 | -I$(srctree)/arch/$(ARCH)/include \ | |
1001 | -include $(srctree)/include/linux/kconfig.h \ | |
1002 | -I$(srctree)/dts/upstream/include \ | |
1003 | $(if $(CONFIG_NET_LWIP), -I$(srctree)/lib/lwip/lwip/src/include \ | |
1004 | -I$(srctree)/lib/lwip/u-boot) | |
1005 | ||
1006 | NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) | |
1007 | ||
1008 | # FIX ME | |
1009 | cpp_flags := $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) $(UBOOTINCLUDE) \ | |
1010 | $(NOSTDINC_FLAGS) | |
1011 | c_flags := $(KBUILD_CFLAGS) $(cpp_flags) | |
1012 | ||
1013 | ||
1014 | ######################################################################### | |
1015 | # U-Boot objects....order is important (i.e. start must be first) | |
1016 | ||
1017 | HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(srctree)/board/$(VENDOR)/common/Makefile),y,n) | |
1018 | ||
1019 | libs-$(CONFIG_API) += api/ | |
1020 | libs-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/ | |
1021 | libs-y += boot/ | |
1022 | libs-$(CONFIG_CMDLINE) += cmd/ | |
1023 | libs-y += common/ | |
1024 | libs-$(CONFIG_OF_EMBED) += dts/ | |
1025 | libs-y += env/ | |
1026 | libs-y += lib/ | |
1027 | libs-y += fs/ | |
1028 | libs-$(filter y,$(CONFIG_NET) $(CONFIG_NET_LWIP)) += net/ | |
1029 | libs-y += disk/ | |
1030 | libs-y += drivers/ | |
1031 | libs-$(CONFIG_SYS_FSL_DDR) += drivers/ddr/fsl/ | |
1032 | libs-$(CONFIG_SYS_FSL_MMDC) += drivers/ddr/fsl/ | |
1033 | libs-$(CONFIG_$(PHASE_)ALTERA_SDRAM) += drivers/ddr/altera/ | |
1034 | libs-y += drivers/usb/cdns3/ | |
1035 | libs-y += drivers/usb/dwc3/ | |
1036 | libs-y += drivers/usb/common/ | |
1037 | libs-y += drivers/usb/emul/ | |
1038 | libs-y += drivers/usb/eth/ | |
1039 | libs-$(CONFIG_USB_GADGET) += drivers/usb/gadget/ | |
1040 | libs-$(CONFIG_USB_GADGET) += drivers/usb/gadget/udc/ | |
1041 | libs-y += drivers/usb/host/ | |
1042 | libs-y += drivers/usb/mtu3/ | |
1043 | libs-y += drivers/usb/musb/ | |
1044 | libs-y += drivers/usb/musb-new/ | |
1045 | libs-y += drivers/usb/isp1760/ | |
1046 | libs-y += drivers/usb/phy/ | |
1047 | libs-y += drivers/usb/tcpm/ | |
1048 | libs-y += drivers/usb/ulpi/ | |
1049 | ifdef CONFIG_POST | |
1050 | libs-y += post/ | |
1051 | endif | |
1052 | libs-$(CONFIG_$(PHASE_)UNIT_TEST) += test/ | |
1053 | ||
1054 | libs-y += $(if $(wildcard $(srctree)/board/$(BOARDDIR)/Makefile),board/$(BOARDDIR)/) | |
1055 | ||
1056 | libs-y := $(sort $(libs-y)) | |
1057 | ||
1058 | u-boot-dirs := $(patsubst %/,%,$(filter %/, $(libs-y))) tools examples | |
1059 | ||
1060 | u-boot-alldirs := $(sort $(u-boot-dirs) $(patsubst %/,%,$(filter %/, $(libs-)))) | |
1061 | ||
1062 | libs-y := $(patsubst %/, %/built-in.a, $(libs-y)) | |
1063 | # Not needed in U-Boot | |
1064 | #init-y := $(patsubst %/, %/built-in.a, $(init-y)) | |
1065 | #core-y := $(patsubst %/, %/built-in.a, $(core-y)) | |
1066 | drivers-y := $(patsubst %/, %/built-in.a, $(drivers-y)) | |
1067 | #net-y := $(patsubst %/, %/built-in.a, $(net-y)) | |
1068 | libs-y1 := $(patsubst %/, %/lib.a, $(libs-y)) | |
1069 | libs-y2 := $(patsubst %/, %/built-in.a, $(filter-out %.a, $(libs-y))) | |
1070 | #virt-y := $(patsubst %/, %/built-in.a, $(virt-y)) | |
1071 | ||
1072 | u-boot-init := $(head-y) | |
1073 | u-boot-main := $(libs-y) | |
1074 | ||
1075 | ||
1076 | # Add GCC lib | |
1077 | ifeq ($(CONFIG_USE_PRIVATE_LIBGCC),y) | |
1078 | PLATFORM_LIBGCC = arch/$(ARCH)/lib/lib.a | |
1079 | else | |
1080 | ifndef CONFIG_CC_IS_CLANG | |
1081 | PLATFORM_LIBGCC := -L $(shell dirname `$(CC) $(c_flags) -print-libgcc-file-name`) -lgcc | |
1082 | endif | |
1083 | endif | |
1084 | PLATFORM_LIBS += $(PLATFORM_LIBGCC) | |
1085 | ||
1086 | ifdef CONFIG_CC_COVERAGE | |
1087 | KBUILD_CFLAGS += --coverage | |
1088 | PLATFORM_LIBGCC += -lgcov | |
1089 | endif | |
1090 | ||
1091 | export PLATFORM_LIBS | |
1092 | export PLATFORM_LIBGCC | |
1093 | ||
1094 | # Special flags for CPP when processing the linker script. | |
1095 | # Pass the version down so we can handle backwards compatibility | |
1096 | # on the fly. | |
1097 | LDPPFLAGS += \ | |
1098 | -include $(srctree)/include/u-boot/u-boot.lds.h \ | |
1099 | -DCPUDIR=$(CPUDIR) \ | |
1100 | $(shell $(LD) --version | \ | |
1101 | sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p') | |
1102 | ||
1103 | ######################################################################### | |
1104 | ######################################################################### | |
1105 | ||
1106 | ifneq ($(CONFIG_BOARD_SIZE_LIMIT),) | |
1107 | BOARD_SIZE_CHECK= @ $(call size_check,$@,$(CONFIG_BOARD_SIZE_LIMIT)) | |
1108 | else | |
1109 | BOARD_SIZE_CHECK = | |
1110 | endif | |
1111 | ||
1112 | ifneq ($(CONFIG_SPL_SIZE_LIMIT),0x0) | |
1113 | SPL_SIZE_CHECK = @$(call size_check,$@,$$(tools/spl_size_limit)) | |
1114 | else | |
1115 | SPL_SIZE_CHECK = | |
1116 | endif | |
1117 | ||
1118 | ifneq ($(CONFIG_TPL_SIZE_LIMIT),0x0) | |
1119 | TPL_SIZE_CHECK = @$(call size_check,$@,$(CONFIG_TPL_SIZE_LIMIT)) | |
1120 | else | |
1121 | TPL_SIZE_CHECK = | |
1122 | endif | |
1123 | ||
1124 | ifneq ($(CONFIG_VPL_SIZE_LIMIT),0x0) | |
1125 | VPL_SIZE_CHECK = @$(call size_check,$@,$(CONFIG_VPL_SIZE_LIMIT)) | |
1126 | else | |
1127 | VPL_SIZE_CHECK = | |
1128 | endif | |
1129 | ||
1130 | # Statically apply RELA-style relocations (currently arm64 only) | |
1131 | # This is useful for arm64 where static relocation needs to be performed on | |
1132 | # the raw binary, but certain simulators only accept an ELF file (but don't | |
1133 | # do the relocation). | |
1134 | ifneq ($(CONFIG_STATIC_RELA),) | |
1135 | # $(2) is u-boot ELF, $(3) is u-boot bin, $(4) is text base | |
1136 | quiet_cmd_static_rela = RELOC $@ | |
1137 | cmd_static_rela = \ | |
1138 | tools/relocate-rela $(3) $(2) | |
1139 | else | |
1140 | quiet_cmd_static_rela = | |
1141 | cmd_static_rela = | |
1142 | endif | |
1143 | ||
1144 | # Always append INPUTS so that arch config.mk's can add custom ones | |
1145 | INPUTS-y += u-boot.srec u-boot.bin u-boot.sym System.map binary_size_check | |
1146 | ||
1147 | ifeq ($(CONFIG_SPL_FSL_PBL),y) | |
1148 | INPUTS-$(CONFIG_RAMBOOT_PBL) += u-boot-with-spl-pbl.bin | |
1149 | else | |
1150 | ifneq ($(CONFIG_NXP_ESBC), y) | |
1151 | # For Secure Boot The Image needs to be signed and Header must also | |
1152 | # be included. So The image has to be built explicitly | |
1153 | INPUTS-$(CONFIG_RAMBOOT_PBL) += u-boot.pbl | |
1154 | endif | |
1155 | endif | |
1156 | INPUTS-$(CONFIG_SPL) += spl/u-boot-spl.bin | |
1157 | ifeq ($(CONFIG_MX6)$(CONFIG_IMX_HAB), yy) | |
1158 | INPUTS-$(CONFIG_SPL_FRAMEWORK) += u-boot-ivt.img | |
1159 | else | |
1160 | ifeq ($(CONFIG_MX7)$(CONFIG_IMX_HAB), yy) | |
1161 | INPUTS-$(CONFIG_SPL_FRAMEWORK) += u-boot-ivt.img | |
1162 | else | |
1163 | INPUTS-$(CONFIG_SPL_FRAMEWORK) += u-boot.img | |
1164 | endif | |
1165 | endif | |
1166 | INPUTS-$(CONFIG_TPL) += tpl/u-boot-tpl.bin | |
1167 | INPUTS-$(CONFIG_VPL) += vpl/u-boot-vpl.bin | |
1168 | ||
1169 | # Allow omitting the .dtb output if it is not normally used | |
1170 | INPUTS-$(CONFIG_OF_SEPARATE) += $(if $(CONFIG_OF_OMIT_DTB),dts/dt.dtb,u-boot.dtb) | |
1171 | ifeq ($(CONFIG_SPL_FRAMEWORK),y) | |
1172 | INPUTS-$(CONFIG_OF_SEPARATE) += u-boot-dtb.img | |
1173 | endif | |
1174 | INPUTS-$(CONFIG_SANDBOX) += u-boot.dtb | |
1175 | ifneq ($(CONFIG_SPL_TARGET),) | |
1176 | INPUTS-$(CONFIG_SPL) += $(CONFIG_SPL_TARGET:"%"=%) | |
1177 | endif | |
1178 | INPUTS-$(CONFIG_REMAKE_ELF) += u-boot.elf | |
1179 | INPUTS-$(CONFIG_EFI_APP) += u-boot-app.efi | |
1180 | INPUTS-$(CONFIG_EFI_STUB) += u-boot-payload.efi | |
1181 | ||
1182 | # Generate this input file for binman | |
1183 | ifeq ($(CONFIG_SPL),) | |
1184 | ifneq ($(patsubst "%",%,$(CONFIG_MTK_BROM_HEADER_INFO)),) | |
1185 | INPUTS-$(CONFIG_ARCH_MEDIATEK) += u-boot-mtk.bin | |
1186 | endif | |
1187 | endif | |
1188 | ||
1189 | ifdef CONFIG_FUNCTION_TRACER | |
1190 | ifdef CONFIG_FTRACE_MCOUNT_RECORD | |
1191 | # gcc 5 supports generating the mcount tables directly | |
1192 | ifeq ($(call cc-option-yn,-mrecord-mcount),y) | |
1193 | CC_FLAGS_FTRACE += -mrecord-mcount | |
1194 | export CC_USING_RECORD_MCOUNT := 1 | |
1195 | endif | |
1196 | ifdef CONFIG_HAVE_NOP_MCOUNT | |
1197 | ifeq ($(call cc-option-yn, -mnop-mcount),y) | |
1198 | CC_FLAGS_FTRACE += -mnop-mcount | |
1199 | CC_FLAGS_USING += -DCC_USING_NOP_MCOUNT | |
1200 | endif | |
1201 | endif | |
1202 | endif | |
1203 | ifdef CONFIG_HAVE_FENTRY | |
1204 | ifeq ($(call cc-option-yn, -mfentry),y) | |
1205 | CC_FLAGS_FTRACE += -mfentry | |
1206 | CC_FLAGS_USING += -DCC_USING_FENTRY | |
1207 | endif | |
1208 | endif | |
1209 | export CC_FLAGS_FTRACE | |
1210 | KBUILD_CFLAGS += $(CC_FLAGS_FTRACE) $(CC_FLAGS_USING) | |
1211 | KBUILD_AFLAGS += $(CC_FLAGS_USING) | |
1212 | ifdef CONFIG_DYNAMIC_FTRACE | |
1213 | ifdef CONFIG_HAVE_C_RECORDMCOUNT | |
1214 | BUILD_C_RECORDMCOUNT := y | |
1215 | export BUILD_C_RECORDMCOUNT | |
1216 | endif | |
1217 | endif | |
1218 | endif | |
1219 | ||
1220 | # Add optional build target if defined in board/cpu/soc headers | |
1221 | ifneq ($(CONFIG_BUILD_TARGET),) | |
1222 | INPUTS-y += $(CONFIG_BUILD_TARGET:"%"=%) | |
1223 | endif | |
1224 | ||
1225 | ifeq ($(CONFIG_INIT_SP_RELATIVE)$(CONFIG_OF_SEPARATE),yy) | |
1226 | INPUTS-y += init_sp_bss_offset_check | |
1227 | endif | |
1228 | ||
1229 | ifeq ($(CONFIG_ARCH_ROCKCHIP)_$(CONFIG_SPL_FRAMEWORK),y_) | |
1230 | INPUTS-y += u-boot.img | |
1231 | endif | |
1232 | ||
1233 | INPUTS-$(CONFIG_X86) += u-boot-x86-start16.bin u-boot-x86-reset16.bin \ | |
1234 | $(if $(CONFIG_SPL_X86_16BIT_INIT),spl/u-boot-spl.bin) \ | |
1235 | $(if $(CONFIG_TPL_X86_16BIT_INIT),tpl/u-boot-tpl.bin) | |
1236 | ||
1237 | LDFLAGS_u-boot += $(LDFLAGS_FINAL) | |
1238 | ||
1239 | # Avoid 'Not enough room for program headers' error on binutils 2.28 onwards. | |
1240 | LDFLAGS_u-boot += $(call ld-option, --no-dynamic-linker) | |
1241 | ||
1242 | # ld.lld support | |
1243 | LDFLAGS_u-boot += -z notext $(call ld-option,--apply-dynamic-relocs) | |
1244 | ||
1245 | LDFLAGS_u-boot += --build-id=none | |
1246 | ||
1247 | ifeq ($(CONFIG_ARC)$(CONFIG_NIOS2)$(CONFIG_X86)$(CONFIG_XTENSA),) | |
1248 | LDFLAGS_u-boot += -Ttext $(CONFIG_TEXT_BASE) | |
1249 | endif | |
1250 | ||
1251 | # make the checker run with the right architecture | |
1252 | CHECKFLAGS += --arch=$(ARCH) | |
1253 | ||
1254 | # insure the checker run with the right endianness | |
1255 | CHECKFLAGS += $(if $(CONFIG_SYS_BIG_ENDIAN),-mbig-endian,-mlittle-endian) | |
1256 | ||
1257 | # the checker needs the correct machine size | |
1258 | CHECKFLAGS += $(if $(CONFIG_64BIT),-m64,-m32) | |
1259 | ||
1260 | # Normally we fill empty space with 0xff | |
1261 | quiet_cmd_objcopy = OBJCOPY $@ | |
1262 | cmd_objcopy = $(OBJCOPY) --gap-fill=0xff $(OBJCOPYFLAGS) \ | |
1263 | $(OBJCOPYFLAGS_$(@F)) $< $@ | |
1264 | ||
1265 | # disable pointer signed / unsigned warnings in gcc 4.0 | |
1266 | KBUILD_CFLAGS += -Wno-pointer-sign | |
1267 | ||
1268 | # disable stringop warnings in gcc 8+ | |
1269 | KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation) | |
1270 | ||
1271 | # disable invalid "can't wrap" optimizations for signed / pointers | |
1272 | KBUILD_CFLAGS += $(call cc-option,-fno-strict-overflow) | |
1273 | ||
1274 | # Provide a version which does not do this, for use by EFI and hex/srec | |
1275 | quiet_cmd_zobjcopy = OBJCOPY $@ | |
1276 | cmd_zobjcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@ | |
1277 | ||
1278 | quiet_cmd_efipayload = OBJCOPY $@ | |
1279 | cmd_efipayload = $(OBJCOPY) -I binary -O $(EFIPAYLOAD_BFDTARGET) -B $(EFIPAYLOAD_BFDARCH) $< $@ | |
1280 | ||
1281 | MKIMAGEOUTPUT ?= /dev/null | |
1282 | ||
1283 | quiet_cmd_mkimage = MKIMAGE $@ | |
1284 | cmd_mkimage = $(objtree)/tools/mkimage $(MKIMAGEFLAGS_$(@F)) -d $< $@ \ | |
1285 | >$(MKIMAGEOUTPUT) $(if $(KBUILD_VERBOSE:0=), && cat $(MKIMAGEOUTPUT)) | |
1286 | ||
1287 | quiet_cmd_mkfitimage = MKIMAGE $@ | |
1288 | cmd_mkfitimage = $(objtree)/tools/mkimage $(MKIMAGEFLAGS_$(@F)) \ | |
1289 | -f $(U_BOOT_ITS) -p $(CONFIG_FIT_EXTERNAL_OFFSET) $@ \ | |
1290 | >$(MKIMAGEOUTPUT) $(if $(KBUILD_VERBOSE:0=), && cat $(MKIMAGEOUTPUT)) | |
1291 | ||
1292 | quiet_cmd_cat = CAT $@ | |
1293 | cmd_cat = cat $(filter-out $(PHONY), $^) > $@ | |
1294 | ||
1295 | append = cat $(filter-out $< $(PHONY), $^) >> $@ | |
1296 | ||
1297 | quiet_cmd_pad_cat = CAT $@ | |
1298 | cmd_pad_cat = $(cmd_objcopy) && $(append) || { rm -f $@; false; } | |
1299 | ||
1300 | quiet_cmd_lzma = LZMA $@ | |
1301 | cmd_lzma = lzma -c -z -k -9 $< > $@ | |
1302 | ||
1303 | cfg: u-boot.cfg | |
1304 | ||
1305 | quiet_cmd_ofcheck = OFCHK $2 | |
1306 | cmd_ofcheck = $(srctree)/scripts/check-of.sh $2 \ | |
1307 | $(srctree)/scripts/of_allowlist.txt | |
1308 | ||
1309 | # Concat the value of all the CONFIGs (result is 'y' or 'yy', etc. ) | |
1310 | got = $(foreach cfg,$(1),$($(cfg))) | |
1311 | ||
1312 | # expected value 'y for each one | |
1313 | expect = $(foreach cfg,$(1),y) | |
1314 | ||
1315 | # Show a deprecation message | |
1316 | # Args: | |
1317 | # 1: List of options to migrate to (e.g. "CONFIG_DM_MMC CONFIG_BLK") | |
1318 | # 2: Name of component (e.g . "Ethernet drivers") | |
1319 | # 3: Release deadline (e.g. "v202.07") | |
1320 | # 4: Condition to require before checking (e.g. "$(CONFIG_NET)") | |
1321 | # Note: Script avoids bash construct, hence the strange double 'if' | |
1322 | # (patches welcome!) | |
1323 | define deprecated | |
1324 | @if [ -n "$(strip $(4))" ]; then if [ "$(got)" != "$(expect)" ]; then \ | |
1325 | echo >&2 "===================== WARNING ======================"; \ | |
1326 | echo >&2 "This board does not use $(firstword $(1)) (Driver Model"; \ | |
1327 | echo >&2 "for $(2)). Please update the board to use"; \ | |
1328 | echo >&2 "$(firstword $(1)) before the $(3) release. Failure to"; \ | |
1329 | echo >&2 "update by the deadline may result in board removal."; \ | |
1330 | echo >&2 "See doc/develop/driver-model/migration.rst for more info."; \ | |
1331 | echo >&2 "===================================================="; \ | |
1332 | fi; fi | |
1333 | ||
1334 | endef | |
1335 | ||
1336 | # Timestamp file to make sure that binman always runs | |
1337 | .binman_stamp: $(INPUTS-y) FORCE | |
1338 | ifeq ($(CONFIG_BINMAN),y) | |
1339 | $(call if_changed,binman) | |
1340 | endif | |
1341 | @touch $@ | |
1342 | ||
1343 | all: .binman_stamp | |
1344 | ||
1345 | ifeq ($(CONFIG_DEPRECATED),y) | |
1346 | $(warning "You have deprecated configuration options enabled in your .config! Please check your configuration.") | |
1347 | endif | |
1348 | ifeq ($(CONFIG_OF_EMBED)$(CONFIG_EFI_APP),y) | |
1349 | @echo >&2 "===================== WARNING ======================" | |
1350 | @echo >&2 "CONFIG_OF_EMBED is enabled. This option should only" | |
1351 | @echo >&2 "be used for debugging purposes. Please use" | |
1352 | @echo >&2 "CONFIG_OF_SEPARATE for boards in mainline." | |
1353 | @echo >&2 "See doc/develop/devicetree/control.rst for more info." | |
1354 | @echo >&2 "====================================================" | |
1355 | endif | |
1356 | $(call deprecated,CONFIG_WDT,DM watchdog,v2019.10,\ | |
1357 | $(CONFIG_WATCHDOG)$(CONFIG_HW_WATCHDOG)) | |
1358 | $(call deprecated,CONFIG_DM_I2C,I2C drivers,v2022.04,$(CONFIG_SYS_I2C_LEGACY)) | |
1359 | @# CFG_SYS_TIMER_RATE has brackets in it for some boards which | |
1360 | @# confuses this rule. Use if() to send just a single character which | |
1361 | @# is enable to tell 'deprecated' that one of these symbols exists | |
1362 | $(call deprecated,CONFIG_TIMER,Timer drivers,v2023.01,$(if $(strip $(CFG_SYS_TIMER_RATE)$(CFG_SYS_TIMER_COUNTER)),x)) | |
1363 | $(call deprecated,CONFIG_DM_SERIAL,Serial drivers,v2023.04,$(CONFIG_SERIAL)) | |
1364 | @# Check that this build does not override OF_HAS_PRIOR_STAGE by | |
1365 | @# disabling OF_BOARD. | |
1366 | $(call cmd,ofcheck,$(KCONFIG_CONFIG)) | |
1367 | ||
1368 | PHONY += dtbs dtbs_check | |
1369 | dtbs: dts/dt.dtb | |
1370 | @: | |
1371 | dts/dt.dtb: dtbs_prepare u-boot | |
1372 | $(Q)$(MAKE) $(build)=dts dtbs | |
1373 | ||
1374 | dtbs_prepare: prepare3 | |
1375 | ||
1376 | ifneq ($(filter dtbs_check, $(MAKECMDGOALS)),) | |
1377 | export CHECK_DTBS=y | |
1378 | endif | |
1379 | ||
1380 | ifneq ($(CHECK_DTBS),) | |
1381 | dtbs_prepare: dt_binding_check | |
1382 | endif | |
1383 | ||
1384 | dtbs_check: dt_binding_check dtbs | |
1385 | ||
1386 | DT_BINDING_DIR := dts/upstream/Bindings | |
1387 | dt_binding_check: scripts_dtc | |
1388 | $(Q)$(MAKE) $(build)=$(DT_BINDING_DIR) $(DT_BINDING_DIR)/processed-schema.json | |
1389 | ||
1390 | quiet_cmd_copy = COPY $@ | |
1391 | cmd_copy = cp $< $@ | |
1392 | ||
1393 | ifeq ($(CONFIG_OF_UPSTREAM),y) | |
1394 | ifeq ($(CONFIG_ARM64),y) | |
1395 | dt_dir := dts/upstream/src/arm64 | |
1396 | else | |
1397 | dt_dir := dts/upstream/src/$(ARCH) | |
1398 | endif | |
1399 | else | |
1400 | dt_dir := arch/$(ARCH)/dts | |
1401 | endif | |
1402 | ||
1403 | ifeq ($(CONFIG_MULTI_DTB_FIT),y) | |
1404 | ||
1405 | ifeq ($(CONFIG_MULTI_DTB_FIT_LZO),y) | |
1406 | FINAL_DTB_CONTAINER = fit-dtb.blob.lzo | |
1407 | else ifeq ($(CONFIG_MULTI_DTB_FIT_GZIP),y) | |
1408 | FINAL_DTB_CONTAINER = fit-dtb.blob.gz | |
1409 | else | |
1410 | FINAL_DTB_CONTAINER = fit-dtb.blob | |
1411 | endif | |
1412 | ||
1413 | fit-dtb.blob.gz: fit-dtb.blob | |
1414 | @gzip -nkf9 $< > $@ | |
1415 | ||
1416 | fit-dtb.blob.lzo: fit-dtb.blob | |
1417 | @lzop -f9 $< > $@ | |
1418 | ||
1419 | fit-dtb.blob: dts/dt.dtb FORCE | |
1420 | $(call if_changed,mkimage) | |
1421 | ifneq ($(SOURCE_DATE_EPOCH),) | |
1422 | touch -d @$(SOURCE_DATE_EPOCH) fit-dtb.blob | |
1423 | chmod 0600 fit-dtb.blob | |
1424 | endif | |
1425 | ||
1426 | MKIMAGEFLAGS_fit-dtb.blob = -f auto -A $(ARCH) -T firmware -C none -O u-boot \ | |
1427 | -a 0 -e 0 -E \ | |
1428 | $(patsubst %,-b $(dt_dir)/%.dtb,$(subst ",,$(CONFIG_OF_LIST))) -d /dev/null | |
1429 | ||
1430 | MKIMAGEFLAGS_fit-dtb.blob += -B 0x8 | |
1431 | ||
1432 | ifneq ($(EXT_DTB),) | |
1433 | u-boot-fit-dtb.bin: u-boot-nodtb.bin $(EXT_DTB) | |
1434 | $(call if_changed,cat) | |
1435 | else | |
1436 | u-boot-fit-dtb.bin: u-boot-nodtb.bin $(FINAL_DTB_CONTAINER) | |
1437 | $(call if_changed,cat) | |
1438 | endif | |
1439 | ||
1440 | u-boot.bin: u-boot-fit-dtb.bin FORCE | |
1441 | $(call if_changed,copy) | |
1442 | ||
1443 | ifneq ($(CONFIG_MPC85XX_HAVE_RESET_VECTOR)$(CONFIG_OF_SEPARATE),yy) | |
1444 | u-boot-dtb.bin: u-boot-nodtb.bin dts/dt.dtb FORCE | |
1445 | $(call if_changed,cat) | |
1446 | endif | |
1447 | ||
1448 | else ifeq ($(CONFIG_OF_SEPARATE).$(CONFIG_OF_OMIT_DTB),y.) | |
1449 | ||
1450 | ifneq ($(CONFIG_MPC85XX_HAVE_RESET_VECTOR)$(CONFIG_OF_SEPARATE),yy) | |
1451 | u-boot-dtb.bin: u-boot-nodtb.bin dts/dt.dtb FORCE | |
1452 | $(call if_changed,cat) | |
1453 | endif | |
1454 | ||
1455 | u-boot.bin: u-boot-dtb.bin FORCE | |
1456 | $(call if_changed,copy) | |
1457 | ||
1458 | else | |
1459 | u-boot.bin: u-boot-nodtb.bin FORCE | |
1460 | $(call if_changed,copy) | |
1461 | endif | |
1462 | ||
1463 | # we call Makefile in arch/arm/mach-imx which | |
1464 | # has targets which are dependent on targets defined | |
1465 | # here. make could not resolve them and we must ensure | |
1466 | # that they are finished before calling imx targets | |
1467 | ifeq ($(CONFIG_MULTI_DTB_FIT),y) | |
1468 | IMX_DEPS = u-boot-fit-dtb.bin | |
1469 | endif | |
1470 | ||
1471 | %.imx: $(IMX_DEPS) %.bin | |
1472 | $(Q)$(MAKE) $(build)=arch/arm/mach-imx $@ | |
1473 | $(BOARD_SIZE_CHECK) | |
1474 | ||
1475 | %.vyb: %.imx | |
1476 | $(Q)$(MAKE) $(build)=arch/arm/cpu/armv7/vf610 $@ | |
1477 | ||
1478 | quiet_cmd_copy = COPY $@ | |
1479 | cmd_copy = cp $< $@ | |
1480 | ||
1481 | u-boot.dtb: dts/dt.dtb | |
1482 | $(call cmd,copy) | |
1483 | ||
1484 | OBJCOPYFLAGS_u-boot.hex := -O ihex | |
1485 | ||
1486 | OBJCOPYFLAGS_u-boot.srec := -O srec | |
1487 | ||
1488 | u-boot.hex u-boot.srec: u-boot FORCE | |
1489 | $(call if_changed,zobjcopy) | |
1490 | ||
1491 | OBJCOPYFLAGS_u-boot-elf.srec := $(OBJCOPYFLAGS_u-boot.srec) | |
1492 | ||
1493 | ifeq ($(CONFIG_POSITION_INDEPENDENT)$(CONFIG_RCAR_GEN3),yy) | |
1494 | # The flash_writer tool and previous recovery tools | |
1495 | # require the SREC load address to be 0x5000_0000 . | |
1496 | # The PIE U-Boot build sets the address to 0x0, so | |
1497 | # override the address back to make u-boot-elf.srec | |
1498 | # compatible with the recovery tools. | |
1499 | OBJCOPYFLAGS_u-boot-elf.srec += --change-addresses=0x50000000 | |
1500 | endif | |
1501 | ||
1502 | u-boot-elf.srec: u-boot.elf FORCE | |
1503 | $(call if_changed,zobjcopy) | |
1504 | ||
1505 | OBJCOPYFLAGS_u-boot-spl.srec = $(OBJCOPYFLAGS_u-boot.srec) | |
1506 | ||
1507 | spl/u-boot-spl.srec: spl/u-boot-spl FORCE | |
1508 | $(call if_changed,zobjcopy) | |
1509 | ||
1510 | %.scif: %.srec | |
1511 | $(Q)$(MAKE) $(build)=arch/arm/mach-renesas $@ | |
1512 | ||
1513 | OBJCOPYFLAGS_u-boot-nodtb.bin := -O binary \ | |
1514 | $(if $(CONFIG_X86_16BIT_INIT),-R .start16 -R .resetvec) \ | |
1515 | $(if $(CONFIG_MPC85XX_HAVE_RESET_VECTOR),$(if $(CONFIG_OF_SEPARATE),-R .bootpg -R .resetvec)) | |
1516 | ||
1517 | binary_size_check: u-boot-nodtb.bin FORCE | |
1518 | @file_size=$(shell wc -c u-boot-nodtb.bin | awk '{ print $$1 }') ; \ | |
1519 | map_size=$(shell cat u-boot.map | \ | |
1520 | awk ' \ | |
1521 | /_image_copy_start/ { start = $$1 } \ | |
1522 | /_image_binary_end/ { end = $$1 } \ | |
1523 | END { \ | |
1524 | if (start != "" && end != "") \ | |
1525 | print end " " start; \ | |
1526 | }' \ | |
1527 | | sh -c 'read end start && echo $$((end - start))'); \ | |
1528 | if [ -n "$$map_size" ]; then \ | |
1529 | if test $$map_size -ne $$file_size; then \ | |
1530 | echo "u-boot.map shows a binary size of $$map_size" >&2 ; \ | |
1531 | echo " but u-boot-nodtb.bin shows $$file_size" >&2 ; \ | |
1532 | exit 1; \ | |
1533 | fi; \ | |
1534 | fi | |
1535 | ||
1536 | ifeq ($(CONFIG_INIT_SP_RELATIVE)$(CONFIG_OF_SEPARATE),yy) | |
1537 | ifneq ($(CONFIG_SYS_MALLOC_F),) | |
1538 | subtract_sys_malloc_f_len = space=$$(($${space} - $(CONFIG_SYS_MALLOC_F_LEN))) | |
1539 | else | |
1540 | subtract_sys_malloc_f_len = true | |
1541 | endif | |
1542 | # The 1/4 margin below is somewhat arbitrary. The likely initial SP usage is | |
1543 | # so low that the DTB could probably use 90%+ of the available space, for | |
1544 | # current values of CONFIG_SYS_INIT_SP_BSS_OFFSET at least. However, let's be | |
1545 | # safe for now and tweak this later if space becomes tight. | |
1546 | # A rejected alternative would be to check that some absolute minimum stack | |
1547 | # space was available. However, since CONFIG_SYS_INIT_SP_BSS_OFFSET is | |
1548 | # deliberately build-specific, to take account of build-to-build stack usage | |
1549 | # differences due to different feature sets, there is no common absolute value | |
1550 | # to check against. | |
1551 | init_sp_bss_offset_check: u-boot.dtb FORCE | |
1552 | @dtb_size=$(shell wc -c u-boot.dtb | awk '{print $$1}') ; \ | |
1553 | space=$(CONFIG_SYS_INIT_SP_BSS_OFFSET) ; \ | |
1554 | $(subtract_sys_malloc_f_len) ; \ | |
1555 | quarter_space=$$(($${space} / 4)) ; \ | |
1556 | if [ $${dtb_size} -gt $${quarter_space} ]; then \ | |
1557 | echo "u-boot.dtb is larger than 1 quarter of " >&2 ; \ | |
1558 | echo "(CONFIG_SYS_INIT_SP_BSS_OFFSET - CONFIG_SYS_MALLOC_F_LEN)" >&2 ; \ | |
1559 | exit 1 ; \ | |
1560 | fi | |
1561 | endif | |
1562 | ||
1563 | shell_cmd = { $(call echo-cmd,$(1)) $(cmd_$(1)); } | |
1564 | ||
1565 | quiet_cmd_objcopy_uboot = OBJCOPY $@ | |
1566 | ifdef cmd_static_rela | |
1567 | cmd_objcopy_uboot = $(cmd_objcopy) && $(call shell_cmd,static_rela,$<,$@,$(CONFIG_TEXT_BASE)) || { rm -f $@; false; } | |
1568 | else | |
1569 | cmd_objcopy_uboot = $(cmd_objcopy) | |
1570 | endif | |
1571 | ||
1572 | u-boot-nodtb.bin: u-boot FORCE | |
1573 | $(call if_changed,objcopy_uboot) | |
1574 | $(BOARD_SIZE_CHECK) | |
1575 | ||
1576 | u-boot.ldr: u-boot | |
1577 | $(LDR) -T $(CONFIG_LDR_CPU) -c $@ $< $(LDR_FLAGS) | |
1578 | $(BOARD_SIZE_CHECK) | |
1579 | ||
1580 | # binman | |
1581 | # --------------------------------------------------------------------------- | |
1582 | # Use 'make BINMAN_DEBUG=1' to enable debugging | |
1583 | # Use 'make BINMAN_VERBOSE=3' to set vebosity level | |
1584 | ||
1585 | ifneq ($(EXT_DTB),) | |
1586 | ext_dtb_list := $(basename $(notdir $(EXT_DTB))) | |
1587 | default_dt := $(firstword $(ext_dtb_list)) | |
1588 | of_list := "$(ext_dtb_list)" | |
1589 | of_list_dirs := $(dir $(EXT_DTB)) $(dt_dir) | |
1590 | else | |
1591 | of_list := $(CONFIG_OF_LIST) | |
1592 | of_list_dirs := $(dt_dir) | |
1593 | default_dt := $(if $(DEVICE_TREE),$(DEVICE_TREE),$(CONFIG_DEFAULT_DEVICE_TREE)) | |
1594 | endif | |
1595 | ||
1596 | ifneq ($(CONFIG_OF_UPSTREAM_INCLUDE_LOCAL_FALLBACK_DTBOS),) | |
1597 | of_list_dirs += arch/$(ARCH)/dts | |
1598 | endif | |
1599 | ||
1600 | binman_dtb := $(shell echo $(CONFIG_BINMAN_DTB)) | |
1601 | ifeq ($(strip $(binman_dtb)),) | |
1602 | ifeq ($(CONFIG_OF_EMBED),y) | |
1603 | binman_dtb = ./dts/dt.dtb | |
1604 | else | |
1605 | binman_dtb = ./u-boot.dtb | |
1606 | endif | |
1607 | endif | |
1608 | ||
1609 | quiet_cmd_binman = BINMAN $@ | |
1610 | cmd_binman = $(srctree)/tools/binman/binman $(if $(BINMAN_DEBUG),-D) \ | |
1611 | $(foreach f,$(BINMAN_TOOLPATHS),--toolpath $(f)) \ | |
1612 | --toolpath $(objtree)/tools \ | |
1613 | $(if $(BINMAN_VERBOSE),-v$(BINMAN_VERBOSE)) \ | |
1614 | build -u -d $(binman_dtb) -O . -m \ | |
1615 | --allow-missing --fake-ext-blobs \ | |
1616 | $(if $(BINMAN_ALLOW_MISSING),--ignore-missing) \ | |
1617 | -I . -I $(srctree) -I $(srctree)/board/$(BOARDDIR) \ | |
1618 | $(foreach f,$(of_list_dirs),-I $(f)) -a of-list=$(of_list) \ | |
1619 | $(foreach f,$(BINMAN_INDIRS),-I $(f)) \ | |
1620 | -a atf-bl1-path=${BL1} \ | |
1621 | -a atf-bl31-path=${BL31} \ | |
1622 | -a tee-os-path=${TEE} \ | |
1623 | -a ti-dm-path=${TI_DM} \ | |
1624 | -a opensbi-path=${OPENSBI} \ | |
1625 | -a default-dt=$(default_dt) \ | |
1626 | -a scp-path=$(SCP) \ | |
1627 | -a rockchip-tpl-path=$(ROCKCHIP_TPL) \ | |
1628 | -a spl-bss-pad=$(if $(CONFIG_SPL_SEPARATE_BSS),,1) \ | |
1629 | -a tpl-bss-pad=$(if $(CONFIG_TPL_SEPARATE_BSS),,1) \ | |
1630 | -a vpl-bss-pad=$(if $(CONFIG_VPL_SEPARATE_BSS),,1) \ | |
1631 | -a spl-dtb=$(CONFIG_SPL_OF_REAL) \ | |
1632 | -a tpl-dtb=$(CONFIG_TPL_OF_REAL) \ | |
1633 | -a vpl-dtb=$(CONFIG_VPL_OF_REAL) \ | |
1634 | -a pre-load-key-path=${PRE_LOAD_KEY_PATH} \ | |
1635 | -a of-spl-remove-props=$(CONFIG_OF_SPL_REMOVE_PROPS) \ | |
1636 | $(BINMAN_$(@F)) | |
1637 | ||
1638 | OBJCOPYFLAGS_u-boot.ldr.hex := -I binary -O ihex | |
1639 | ||
1640 | OBJCOPYFLAGS_u-boot.ldr.srec := -I binary -O srec | |
1641 | ||
1642 | u-boot.ldr.hex u-boot.ldr.srec: u-boot.ldr FORCE | |
1643 | $(call if_changed,zobjcopy) | |
1644 | ||
1645 | ifdef CONFIG_SPL_LOAD_FIT | |
1646 | MKIMAGEFLAGS_u-boot.img = -f auto -A $(ARCH) -T firmware -C none -O u-boot \ | |
1647 | -a $(CONFIG_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \ | |
1648 | -p $(CONFIG_FIT_EXTERNAL_OFFSET) \ | |
1649 | -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board" -E \ | |
1650 | $(patsubst %,-b $(dt_dir)/%.dtb,$(subst ",,$(DEVICE_TREE))) \ | |
1651 | $(patsubst %,-b $(dt_dir)/%.dtb,$(subst ",,$(CONFIG_OF_LIST))) \ | |
1652 | $(patsubst %,-b $(dt_dir)/%.dtbo,$(subst ",,$(CONFIG_OF_OVERLAY_LIST))) | |
1653 | else | |
1654 | MKIMAGEFLAGS_u-boot.img = -A $(ARCH) -T firmware -C none -O u-boot \ | |
1655 | -a $(CONFIG_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \ | |
1656 | -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board" | |
1657 | MKIMAGEFLAGS_u-boot-ivt.img = -A $(ARCH) -T firmware_ivt -C none -O u-boot \ | |
1658 | -a $(CONFIG_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \ | |
1659 | -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board" | |
1660 | u-boot-ivt.img: MKIMAGEOUTPUT = u-boot-ivt.img.log | |
1661 | endif | |
1662 | ||
1663 | MKIMAGEFLAGS_u-boot-dtb.img = $(MKIMAGEFLAGS_u-boot.img) | |
1664 | ||
1665 | # Some boards have the kwbimage.cfg file written in advance, while some | |
1666 | # other boards generate it on the fly during the build in the build tree. | |
1667 | # Let's check if the file exists in the build tree first, otherwise we | |
1668 | # fall back to use the one in the source tree. | |
1669 | KWD_CONFIG_FILE = $(shell \ | |
1670 | if [ -f $(objtree)/$(CONFIG_SYS_KWD_CONFIG:"%"=%) ]; then \ | |
1671 | echo -n $(objtree)/$(CONFIG_SYS_KWD_CONFIG:"%"=%); \ | |
1672 | else \ | |
1673 | echo -n $(srctree)/$(CONFIG_SYS_KWD_CONFIG:"%"=%); \ | |
1674 | fi) | |
1675 | ||
1676 | MKIMAGEFLAGS_u-boot.kwb = -n $(KWD_CONFIG_FILE) \ | |
1677 | -T kwbimage -a $(CONFIG_TEXT_BASE) -e $(CONFIG_TEXT_BASE) | |
1678 | ||
1679 | MKIMAGEFLAGS_u-boot-with-spl.kwb = -n $(KWD_CONFIG_FILE) \ | |
1680 | -T kwbimage -a $(CONFIG_TEXT_BASE) -e $(CONFIG_TEXT_BASE) \ | |
1681 | $(if $(KEYDIR),-k $(KEYDIR)) | |
1682 | ||
1683 | MKIMAGEFLAGS_u-boot.pbl = -n $(srctree)/$(CONFIG_SYS_FSL_PBL_RCW:"%"=%) \ | |
1684 | -R $(srctree)/$(CONFIG_SYS_FSL_PBL_PBI:"%"=%) -A $(ARCH) -T pblimage | |
1685 | ||
1686 | UBOOT_BIN := u-boot.bin | |
1687 | ||
1688 | MKIMAGEFLAGS_u-boot-lzma.img = -A $(ARCH) -T standalone -C lzma -O u-boot \ | |
1689 | -a $(CONFIG_TEXT_BASE) -e $(CONFIG_SYS_UBOOT_START) \ | |
1690 | -n "U-Boot $(UBOOTRELEASE) for $(BOARD) board" | |
1691 | ||
1692 | u-boot.bin.lzma: u-boot.bin FORCE | |
1693 | $(call if_changed,lzma) | |
1694 | ||
1695 | u-boot-lzma.img: u-boot.bin.lzma FORCE | |
1696 | $(call if_changed,mkimage) | |
1697 | ||
1698 | fit_image := $(if $(CONFIG_SANDBOX_VPL),u-boot,u-boot-nodtb.bin) | |
1699 | ||
1700 | u-boot-dtb.img u-boot.img u-boot.kwb u-boot.pbl u-boot-ivt.img: \ | |
1701 | $(if $(CONFIG_SPL_LOAD_FIT),$(fit_image) \ | |
1702 | $(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_SANDBOX),dts/dt.dtb) \ | |
1703 | ,$(UBOOT_BIN)) FORCE | |
1704 | $(call if_changed,mkimage) | |
1705 | $(BOARD_SIZE_CHECK) | |
1706 | ||
1707 | ifeq ($(CONFIG_SPL_LOAD_FIT_FULL),y) | |
1708 | MKIMAGEFLAGS_u-boot.itb = | |
1709 | else | |
1710 | MKIMAGEFLAGS_u-boot.itb = -E | |
1711 | endif | |
1712 | MKIMAGEFLAGS_u-boot.itb += -B 0x8 | |
1713 | ||
1714 | ifdef U_BOOT_ITS | |
1715 | u-boot.itb: u-boot-nodtb.bin \ | |
1716 | $(if $(CONFIG_OF_SEPARATE)$(CONFIG_OF_EMBED)$(CONFIG_SANDBOX),dts/dt.dtb) \ | |
1717 | $(if $(CONFIG_MULTI_DTB_FIT),$(FINAL_DTB_CONTAINER)) \ | |
1718 | $(U_BOOT_ITS) FORCE | |
1719 | $(call if_changed,mkfitimage) | |
1720 | $(BOARD_SIZE_CHECK) | |
1721 | endif | |
1722 | ||
1723 | u-boot-with-spl.kwb: u-boot.bin spl/u-boot-spl.bin FORCE | |
1724 | $(call if_changed,mkimage) | |
1725 | $(BOARD_SIZE_CHECK) | |
1726 | ||
1727 | u-boot.dis: u-boot | |
1728 | $(OBJDUMP) -d $< > $@ | |
1729 | ||
1730 | ifneq ($(CONFIG_SPL_PAYLOAD),) | |
1731 | SPL_PAYLOAD := $(CONFIG_SPL_PAYLOAD:"%"=%) | |
1732 | else | |
1733 | SPL_PAYLOAD := u-boot.bin | |
1734 | endif | |
1735 | ||
1736 | SPL_IMAGE := $(CONFIG_SPL_IMAGE:"%"=%) | |
1737 | ||
1738 | OBJCOPYFLAGS_u-boot-with-spl.bin = -I binary -O binary \ | |
1739 | --pad-to=$(CONFIG_SPL_PAD_TO) | |
1740 | u-boot-with-spl.bin: $(SPL_IMAGE) $(SPL_PAYLOAD) FORCE | |
1741 | $(call if_changed,pad_cat) | |
1742 | ||
1743 | ifeq ($(CONFIG_ARCH_LPC32XX)$(CONFIG_SPL),yy) | |
1744 | MKIMAGEFLAGS_lpc32xx-spl.img = -T lpc32xximage -a $(CONFIG_SPL_TEXT_BASE) | |
1745 | ||
1746 | lpc32xx-spl.img: spl/u-boot-spl.bin FORCE | |
1747 | $(call if_changed,mkimage) | |
1748 | ||
1749 | OBJCOPYFLAGS_lpc32xx-boot-0.bin = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO) | |
1750 | ||
1751 | lpc32xx-boot-0.bin: lpc32xx-spl.img FORCE | |
1752 | $(call if_changed,objcopy) | |
1753 | ||
1754 | OBJCOPYFLAGS_lpc32xx-boot-1.bin = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO) | |
1755 | ||
1756 | lpc32xx-boot-1.bin: lpc32xx-spl.img FORCE | |
1757 | $(call if_changed,objcopy) | |
1758 | ||
1759 | lpc32xx-full.bin: lpc32xx-boot-0.bin lpc32xx-boot-1.bin u-boot.img FORCE | |
1760 | $(call if_changed,cat) | |
1761 | ||
1762 | endif | |
1763 | ||
1764 | OBJCOPYFLAGS_u-boot-with-tpl.bin = -I binary -O binary \ | |
1765 | --pad-to=$(CONFIG_TPL_PAD_TO) | |
1766 | tpl/u-boot-with-tpl.bin: tpl/u-boot-tpl.bin u-boot.bin FORCE | |
1767 | $(call if_changed,pad_cat) | |
1768 | ||
1769 | SPL: spl/u-boot-spl.bin FORCE | |
1770 | $(Q)$(MAKE) $(build)=arch/arm/mach-imx $@ | |
1771 | ||
1772 | #ifeq ($(CONFIG_ARCH_IMX8M)$(CONFIG_ARCH_IMX8), y) | |
1773 | ifeq ($(CONFIG_SPL_LOAD_IMX_CONTAINER), y) | |
1774 | u-boot.cnt: u-boot.bin FORCE | |
1775 | $(Q)$(MAKE) $(build)=arch/arm/mach-imx $@ | |
1776 | ||
1777 | flash.bin: spl/u-boot-spl.bin u-boot.cnt FORCE | |
1778 | $(Q)$(MAKE) $(build)=arch/arm/mach-imx $@ | |
1779 | else | |
1780 | ifeq ($(CONFIG_BINMAN),y) | |
1781 | flash.bin: spl/u-boot-spl.bin $(INPUTS-y) FORCE | |
1782 | $(call if_changed,binman) | |
1783 | else | |
1784 | flash.bin: spl/u-boot-spl.bin u-boot.itb FORCE | |
1785 | $(Q)$(MAKE) $(build)=arch/arm/mach-imx $@ | |
1786 | endif | |
1787 | endif | |
1788 | #endif | |
1789 | ||
1790 | u-boot.uim: u-boot.bin FORCE | |
1791 | $(Q)$(MAKE) $(build)=arch/arm/mach-imx $@ | |
1792 | ||
1793 | u-boot-nand.imx: u-boot.imx FORCE | |
1794 | $(Q)$(MAKE) $(build)=arch/arm/mach-imx $@ | |
1795 | ||
1796 | u-boot-with-spl.imx u-boot-with-nand-spl.imx: SPL $(if $(CONFIG_OF_SEPARATE),u-boot.img,u-boot.uim) FORCE | |
1797 | $(Q)$(MAKE) $(build)=arch/arm/mach-imx $@ | |
1798 | ||
1799 | MKIMAGEFLAGS_u-boot.ubl = -n $(UBL_CONFIG) -T ublimage -e $(CONFIG_TEXT_BASE) | |
1800 | ||
1801 | u-boot.ubl: u-boot-with-spl.bin FORCE | |
1802 | $(call if_changed,mkimage) | |
1803 | ||
1804 | MKIMAGEFLAGS_u-boot-spl.ais = -s -n "/dev/null" \ | |
1805 | -T aisimage -e $(CONFIG_SPL_TEXT_BASE) | |
1806 | spl/u-boot-spl.ais: spl/u-boot-spl.bin FORCE | |
1807 | $(call if_changed,mkimage) | |
1808 | ||
1809 | OBJCOPYFLAGS_u-boot.ais = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO) | |
1810 | u-boot.ais: spl/u-boot-spl.ais u-boot.img FORCE | |
1811 | $(call if_changed,pad_cat) | |
1812 | ||
1813 | u-boot-signed.sb: u-boot.bin spl/u-boot-spl.bin | |
1814 | $(Q)$(MAKE) $(build)=arch/arm/cpu/arm926ejs/mxs u-boot-signed.sb | |
1815 | u-boot.sb: u-boot.bin spl/u-boot-spl.bin | |
1816 | $(Q)$(MAKE) $(build)=arch/arm/cpu/arm926ejs/mxs u-boot.sb | |
1817 | ||
1818 | MKIMAGEFLAGS_u-boot-spl.img = -A $(ARCH) -T firmware -C none \ | |
1819 | -a $(CONFIG_SPL_TEXT_BASE) -e $(CONFIG_SPL_TEXT_BASE) -n XLOADER | |
1820 | spl/u-boot-spl.img: spl/u-boot-spl.bin FORCE | |
1821 | $(call if_changed,mkimage) | |
1822 | ||
1823 | ifneq ($(CONFIG_ARCH_SOCFPGA),) | |
1824 | quiet_cmd_gensplx4 = GENSPLX4 $@ | |
1825 | cmd_gensplx4 = $(OBJCOPY) -I binary -O binary --gap-fill=0x0 \ | |
1826 | --pad-to=$(CONFIG_SPL_PAD_TO) \ | |
1827 | spl/u-boot-spl.sfp spl/u-boot-spl.sfp && \ | |
1828 | cat spl/u-boot-spl.sfp spl/u-boot-spl.sfp \ | |
1829 | spl/u-boot-spl.sfp spl/u-boot-spl.sfp > $@ || { rm -f $@; false; } | |
1830 | spl/u-boot-splx4.sfp: spl/u-boot-spl.sfp FORCE | |
1831 | $(call if_changed,gensplx4) | |
1832 | ||
1833 | quiet_cmd_socboot = SOCBOOT $@ | |
1834 | cmd_socboot = cat spl/u-boot-splx4.sfp u-boot.img > $@ || { rm -f $@; false; } | |
1835 | u-boot-with-spl.sfp: spl/u-boot-splx4.sfp u-boot.img FORCE | |
1836 | $(call if_changed,socboot) | |
1837 | ||
1838 | quiet_cmd_gensplpadx4 = GENSPLPADX4 $@ | |
1839 | cmd_gensplpadx4 = dd if=/dev/zero of=spl/u-boot-spl.pad bs=64 count=1024 ; \ | |
1840 | cat spl/u-boot-spl.sfp spl/u-boot-spl.pad \ | |
1841 | spl/u-boot-spl.sfp spl/u-boot-spl.pad \ | |
1842 | spl/u-boot-spl.sfp spl/u-boot-spl.pad \ | |
1843 | spl/u-boot-spl.sfp spl/u-boot-spl.pad > $@ || \ | |
1844 | { rm -f $@ spl/u-boot-spl.pad; false; } | |
1845 | u-boot-spl-padx4.sfp: spl/u-boot-spl.sfp FORCE | |
1846 | $(call if_changed,gensplpadx4) | |
1847 | ||
1848 | quiet_cmd_socnandboot = SOCNANDBOOT $@ | |
1849 | cmd_socnandboot = cat u-boot-spl-padx4.sfp u-boot.img > $@ || { rm -f $@; false; } | |
1850 | u-boot-with-nand-spl.sfp: u-boot-spl-padx4.sfp u-boot.img FORCE | |
1851 | $(call if_changed,socnandboot) | |
1852 | ||
1853 | endif | |
1854 | ||
1855 | ifeq ($(CONFIG_MPC85XX_HAVE_RESET_VECTOR)$(CONFIG_OF_SEPARATE),yy) | |
1856 | u-boot-dtb.bin: u-boot-nodtb.bin u-boot.dtb u-boot-br.bin FORCE | |
1857 | $(call if_changed,binman) | |
1858 | ||
1859 | OBJCOPYFLAGS_u-boot-br.bin := -O binary -j .bootpg -j .resetvec | |
1860 | u-boot-br.bin: u-boot FORCE | |
1861 | $(call if_changed,objcopy) | |
1862 | endif | |
1863 | ||
1864 | quiet_cmd_ldr = LD $@ | |
1865 | cmd_ldr = $(LD) $(LDFLAGS_$(@F)) \ | |
1866 | $(filter-out FORCE,$^) -o $@ | |
1867 | ||
1868 | ifdef CONFIG_X86 | |
1869 | OBJCOPYFLAGS_u-boot-x86-start16.bin := -O binary -j .start16 | |
1870 | u-boot-x86-start16.bin: u-boot FORCE | |
1871 | $(call if_changed,objcopy) | |
1872 | ||
1873 | OBJCOPYFLAGS_u-boot-x86-reset16.bin := -O binary -j .resetvec | |
1874 | u-boot-x86-reset16.bin: u-boot FORCE | |
1875 | $(call if_changed,objcopy) | |
1876 | ||
1877 | endif # CONFIG_X86 | |
1878 | ||
1879 | OBJCOPYFLAGS_u-boot-app.efi := $(OBJCOPYFLAGS_EFI) | |
1880 | u-boot-app.efi: u-boot FORCE | |
1881 | $(call if_changed,zobjcopy) | |
1882 | ||
1883 | u-boot.bin.o: u-boot.bin FORCE | |
1884 | $(call if_changed,efipayload) | |
1885 | ||
1886 | u-boot-payload.lds: $(LDSCRIPT_EFI) FORCE | |
1887 | $(call if_changed_dep,cpp_lds) | |
1888 | ||
1889 | # Rule to link the EFI payload which contains a stub and a U-Boot binary | |
1890 | quiet_cmd_u-boot_payload ?= LD $@ | |
1891 | cmd_u-boot_payload ?= $(LD) $(LDFLAGS_EFI_PAYLOAD) -o $@ \ | |
1892 | -T u-boot-payload.lds arch/x86/cpu/call32.o \ | |
1893 | lib/efi_client/efi.o lib/efi_client/efi_stub.o u-boot.bin.o \ | |
1894 | $(addprefix arch/$(ARCH)/lib/,$(EFISTUB)) | |
1895 | ||
1896 | u-boot-payload: u-boot.bin.o u-boot-payload.lds FORCE | |
1897 | $(call if_changed,u-boot_payload) | |
1898 | ||
1899 | OBJCOPYFLAGS_u-boot-payload.efi := $(OBJCOPYFLAGS_EFI) | |
1900 | u-boot-payload.efi: u-boot-payload FORCE | |
1901 | $(call if_changed,zobjcopy) | |
1902 | ||
1903 | u-boot-img.bin: spl/u-boot-spl.bin u-boot.img FORCE | |
1904 | $(call if_changed,cat) | |
1905 | ||
1906 | #Add a target to create boot binary having SPL binary in PBI format | |
1907 | #concatenated with u-boot binary. It is need by PowerPC SoC having | |
1908 | #internal SRAM <= 512KB. | |
1909 | MKIMAGEFLAGS_u-boot-spl.pbl = -n $(srctree)/$(CONFIG_SYS_FSL_PBL_RCW:"%"=%) \ | |
1910 | -R $(srctree)/$(CONFIG_SYS_FSL_PBL_PBI:"%"=%) -T pblimage \ | |
1911 | -A $(ARCH) -a $(CONFIG_SPL_TEXT_BASE) | |
1912 | ||
1913 | spl/u-boot-spl.pbl: spl/u-boot-spl.bin FORCE | |
1914 | $(call if_changed,mkimage) | |
1915 | ||
1916 | ifeq ($(ARCH),arm) | |
1917 | UBOOT_BINLOAD := u-boot.img | |
1918 | else | |
1919 | UBOOT_BINLOAD := u-boot.bin | |
1920 | endif | |
1921 | ||
1922 | OBJCOPYFLAGS_u-boot-with-spl-pbl.bin = -I binary -O binary --pad-to=$(CONFIG_SPL_PAD_TO) \ | |
1923 | --gap-fill=0xff | |
1924 | ||
1925 | u-boot-with-spl-pbl.bin: spl/u-boot-spl.pbl $(UBOOT_BINLOAD) FORCE | |
1926 | $(call if_changed,pad_cat) | |
1927 | ||
1928 | quiet_cmd_u-boot-elf ?= LD $@ | |
1929 | cmd_u-boot-elf ?= $(LD) u-boot-elf.o -o $@ \ | |
1930 | $(if $(CONFIG_SYS_BIG_ENDIAN),-EB,-EL) \ | |
1931 | -T u-boot-elf.lds --defsym=$(CONFIG_PLATFORM_ELFENTRY)=$(CONFIG_TEXT_BASE) \ | |
1932 | -Ttext=$(CONFIG_TEXT_BASE) | |
1933 | u-boot.elf: u-boot.bin u-boot-elf.lds | |
1934 | $(Q)$(OBJCOPY) -I binary $(PLATFORM_ELFFLAGS) $< u-boot-elf.o | |
1935 | $(call if_changed,u-boot-elf) | |
1936 | ||
1937 | u-boot-elf.lds: arch/u-boot-elf.lds prepare FORCE | |
1938 | $(call if_changed_dep,cpp_lds) | |
1939 | ||
1940 | PHONY += prepare0 | |
1941 | # MediaTek's ARM-based u-boot needs a header to contains its load address | |
1942 | # which is parsed by the BootROM. | |
1943 | # If the SPL build is enabled, the header will be added to the spl binary, | |
1944 | # and the spl binary and the u-boot.img will be combined into one file. | |
1945 | # Otherwise the header will be added to the u-boot.bin directly. | |
1946 | ||
1947 | ifeq ($(CONFIG_SPL),y) | |
1948 | spl/u-boot-spl-mtk.bin: spl/u-boot-spl | |
1949 | ||
1950 | u-boot-mtk.bin: u-boot-with-spl.bin | |
1951 | $(call if_changed,copy) | |
1952 | else | |
1953 | MKIMAGEFLAGS_u-boot-mtk.bin = -T mtk_image \ | |
1954 | -a $(CONFIG_TEXT_BASE) -e $(CONFIG_TEXT_BASE) \ | |
1955 | -n "$(patsubst "%",%,$(CONFIG_MTK_BROM_HEADER_INFO))" | |
1956 | ||
1957 | u-boot-mtk.bin: u-boot.bin FORCE | |
1958 | $(call if_changed,mkimage) | |
1959 | endif | |
1960 | ||
1961 | quiet_cmd_endian_swap = SWAP $@ | |
1962 | cmd_endian_swap = $(srctree)/tools/endian-swap.py $< $@ | |
1963 | ||
1964 | u-boot-swap.bin: u-boot.bin FORCE | |
1965 | $(call if_changed,endian_swap) | |
1966 | ||
1967 | ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(ARCH)/Makefile.postlink) | |
1968 | ||
1969 | # Generate linker list symbols references to force compiler to not optimize | |
1970 | # them away when compiling with LTO | |
1971 | ifeq ($(LTO_ENABLE),y) | |
1972 | u-boot-keep-syms-lto := keep-syms-lto.o | |
1973 | u-boot-keep-syms-lto_c := $(patsubst %.o,%.c,$(u-boot-keep-syms-lto)) | |
1974 | ||
1975 | quiet_cmd_keep_syms_lto = KSL $@ | |
1976 | cmd_keep_syms_lto = \ | |
1977 | $(srctree)/scripts/gen_ll_addressable_symbols.sh $(NM) $^ > $@ | |
1978 | ||
1979 | quiet_cmd_keep_syms_lto_cc = KSLCC $@ | |
1980 | cmd_keep_syms_lto_cc = \ | |
1981 | $(CC) $(filter-out $(LTO_CFLAGS),$(c_flags)) -c -o $@ $< | |
1982 | ||
1983 | $(u-boot-keep-syms-lto_c): $(u-boot-main) | |
1984 | $(call if_changed,keep_syms_lto) | |
1985 | $(u-boot-keep-syms-lto): $(u-boot-keep-syms-lto_c) | |
1986 | $(call if_changed,keep_syms_lto_cc) | |
1987 | else | |
1988 | u-boot-keep-syms-lto := | |
1989 | endif | |
1990 | ||
1991 | # Rule to link u-boot | |
1992 | # May be overridden by arch/$(ARCH)/config.mk | |
1993 | ifeq ($(LTO_ENABLE),y) | |
1994 | quiet_cmd_u-boot__ ?= LTO $@ | |
1995 | cmd_u-boot__ ?= \ | |
1996 | touch $(u-boot-main) ; \ | |
1997 | $(CC) -nostdlib -nostartfiles \ | |
1998 | $(LTO_FINAL_LDFLAGS) $(c_flags) \ | |
1999 | $(KBUILD_LDFLAGS:%=-Wl,%) $(LDFLAGS_u-boot:%=-Wl,%) -o $@ \ | |
2000 | -T u-boot.lds $(u-boot-init) \ | |
2001 | -Wl,--whole-archive \ | |
2002 | $(u-boot-main) \ | |
2003 | $(u-boot-keep-syms-lto) \ | |
2004 | $(PLATFORM_LIBS) \ | |
2005 | -Wl,--no-whole-archive \ | |
2006 | -Wl,-Map,u-boot.map; \ | |
2007 | $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) | |
2008 | else | |
2009 | quiet_cmd_u-boot__ ?= LD $@ | |
2010 | cmd_u-boot__ ?= \ | |
2011 | touch $(u-boot-main) ; \ | |
2012 | $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_u-boot) -o $@ \ | |
2013 | -T u-boot.lds $(u-boot-init) \ | |
2014 | --whole-archive \ | |
2015 | $(u-boot-main) \ | |
2016 | --no-whole-archive \ | |
2017 | $(PLATFORM_LIBS) -Map u-boot.map; \ | |
2018 | $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) | |
2019 | endif | |
2020 | ||
2021 | quiet_cmd_smap = GEN common/system_map.o | |
2022 | cmd_smap = \ | |
2023 | smap=`$(call SYSTEM_MAP,u-boot) | \ | |
2024 | awk '$$2 ~ /[tTwW]/ {printf $$1 $$3 "\\\\000"}'` ; \ | |
2025 | $(CC) $(c_flags) -DSYSTEM_MAP="\"$${smap}\"" \ | |
2026 | -c $(srctree)/common/system_map.c -o common/system_map.o | |
2027 | ||
2028 | u-boot: $(u-boot-init) $(u-boot-main) $(u-boot-keep-syms-lto) u-boot.lds FORCE | |
2029 | +$(call if_changed,u-boot__) | |
2030 | ifeq ($(CONFIG_KALLSYMS),y) | |
2031 | $(call cmd,smap) | |
2032 | $(call cmd,u-boot__) common/system_map.o | |
2033 | endif | |
2034 | ||
2035 | ifeq ($(CONFIG_RISCV),y) | |
2036 | @tools/prelink-riscv $@ | |
2037 | endif | |
2038 | ||
2039 | quiet_cmd_sym ?= SYM $@ | |
2040 | cmd_sym ?= $(OBJDUMP) -t $< > $@ | |
2041 | u-boot.sym: u-boot FORCE | |
2042 | $(call if_changed,sym) | |
2043 | ||
2044 | # Environment processing | |
2045 | # --------------------------------------------------------------------------- | |
2046 | ||
2047 | # Directory where we expect the .env file, if it exists | |
2048 | ENV_DIR := $(srctree)/board/$(BOARDDIR) | |
2049 | ||
2050 | # Basename of .env file, stripping quotes | |
2051 | ENV_SOURCE_FILE := $(CONFIG_ENV_SOURCE_FILE:"%"=%) | |
2052 | ||
2053 | # Filename of .env file | |
2054 | ENV_FILE_CFG := $(ENV_DIR)/$(ENV_SOURCE_FILE).env | |
2055 | ||
2056 | # Default filename, if CONFIG_ENV_SOURCE_FILE is empty | |
2057 | ENV_FILE_BOARD := $(ENV_DIR)/$(CONFIG_SYS_BOARD:"%"=%).env | |
2058 | ||
2059 | # Select between the CONFIG_ENV_SOURCE_FILE and the default one | |
2060 | ENV_FILE := $(if $(ENV_SOURCE_FILE),$(ENV_FILE_CFG),$(wildcard $(ENV_FILE_BOARD))) | |
2061 | ||
2062 | # Run the environment text file through the preprocessor, but only if it is | |
2063 | # non-empty, to save time and possible build errors if something is wonky with | |
2064 | # the board. | |
2065 | # If there is no ENV_FILE, produce an empty output file, to prevent a previous | |
2066 | # build's file being used in the case of in-tree builds. | |
2067 | quiet_cmd_gen_envp = ENVP $@ | |
2068 | cmd_gen_envp = \ | |
2069 | if [ -s "$(ENV_FILE)" ]; then \ | |
2070 | $(CPP) -P $(cpp_flags) -x assembler-with-cpp -undef \ | |
2071 | -D__ASSEMBLY__ \ | |
2072 | -D__UBOOT_CONFIG__ \ | |
2073 | -DDEFAULT_DEVICE_TREE=$(subst ",,$(CONFIG_DEFAULT_DEVICE_TREE)) \ | |
2074 | -I . -I include -I $(srctree)/include \ | |
2075 | -include linux/kconfig.h -include include/config.h \ | |
2076 | -I$(srctree)/arch/$(ARCH)/include \ | |
2077 | $< -o $@; \ | |
2078 | else \ | |
2079 | rm -f $@; \ | |
2080 | touch $@ ; \ | |
2081 | fi | |
2082 | include/generated/env.in: include/generated/env.txt | |
2083 | $(call cmd,gen_envp) | |
2084 | ||
2085 | # Regenerate the environment if it changes | |
2086 | # We use 'wildcard' since the file is not required to exist (at present), in | |
2087 | # which case we don't want this dependency, but instead should create an empty | |
2088 | # file | |
2089 | # This rule is useful since it shows the source file for the environment | |
2090 | quiet_cmd_envc = ENVC $@ | |
2091 | cmd_envc = \ | |
2092 | if [ -f "$<" ]; then \ | |
2093 | cat $< > $@; \ | |
2094 | elif [ -n "$(ENV_SOURCE_FILE)" ]; then \ | |
2095 | echo "Missing file $(ENV_FILE_CFG)"; \ | |
2096 | else \ | |
2097 | touch $@ ; \ | |
2098 | fi | |
2099 | ||
2100 | include/generated/env.txt: $(wildcard $(ENV_FILE)) include/generated/autoconf.h | |
2101 | $(call cmd,envc) | |
2102 | ||
2103 | # Write out the resulting environment, converted to a C string | |
2104 | quiet_cmd_gen_envt = ENVT $@ | |
2105 | cmd_gen_envt = \ | |
2106 | awk -f $(srctree)/scripts/env2string.awk $< >$@ | |
2107 | $(env_h): include/generated/env.in | |
2108 | $(call cmd,gen_envt) | |
2109 | ||
2110 | # --------------------------------------------------------------------------- | |
2111 | ||
2112 | # The actual objects are generated when descending, | |
2113 | # make sure no implicit rule kicks in | |
2114 | $(sort $(u-boot-init) $(u-boot-main)): $(u-boot-dirs) ; | |
2115 | ||
2116 | # Handle descending into subdirectories listed in $(u-boot-dirs) | |
2117 | # Preset locale variables to speed up the build process. Limit locale | |
2118 | # tweaks to this spot to avoid wrong language settings when running | |
2119 | # make menuconfig etc. | |
2120 | # Error messages still appears in the original language | |
2121 | ||
2122 | PHONY += $(u-boot-dirs) | |
2123 | $(u-boot-dirs): prepare | |
2124 | $(Q)$(MAKE) $(build)=$@ need-builtin=1 | |
2125 | ||
2126 | tools: prepare | |
2127 | # The "tools" are needed early | |
2128 | $(filter-out tools, $(u-boot-dirs)): tools | |
2129 | # The "examples" conditionally depend on U-Boot (say, when USE_PRIVATE_LIBGCC | |
2130 | # is "yes"), so compile examples after U-Boot is compiled. | |
2131 | examples: $(filter-out examples, $(u-boot-dirs)) | |
2132 | ||
2133 | ifeq ($(CONFIG_USE_PRIVATE_LIBGCC),y) | |
2134 | # lib/efi_loader apps depend on arch/$(ARCH)/lib for lib.a | |
2135 | lib: $(filter arch/$(ARCH)/lib, $(u-boot-dirs)) | |
2136 | endif | |
2137 | ||
2138 | # The setlocalversion script comes from linux and expects a | |
2139 | # KERNELVERSION variable in the environment for figuring out which | |
2140 | # annotated tags are relevant. Pass UBOOTVERSION. | |
2141 | define filechk_uboot.release | |
2142 | KERNELVERSION=$(UBOOTVERSION) $(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree) | |
2143 | endef | |
2144 | ||
2145 | # Store (new) UBOOTRELEASE string in include/config/uboot.release | |
2146 | include/config/uboot.release: include/config/auto.conf FORCE | |
2147 | $(call filechk,uboot.release) | |
2148 | # Additional helpers built in scripts/ | |
2149 | # Carefully list dependencies so we do not try to build scripts twice | |
2150 | # in parallel | |
2151 | PHONY += scripts | |
2152 | scripts: scripts_basic scripts_dtc | |
2153 | $(Q)$(MAKE) $(build)=$(@) | |
2154 | ||
2155 | # Things we need to do before we recursively start building the kernel | |
2156 | # or the modules are listed in "prepare". | |
2157 | # A multi level approach is used. prepareN is processed before prepareN-1. | |
2158 | # archprepare is used in arch Makefiles and when processed asm symlink, | |
2159 | # version.h and scripts_basic is processed / created. | |
2160 | ||
2161 | PHONY += prepare archprepare prepare1 prepare3 | |
2162 | ||
2163 | # prepare3 is used to check if we are building in a separate output directory, | |
2164 | # and if so do: | |
2165 | # 1) Check that make has not been executed in the kernel src $(srctree) | |
2166 | prepare3: include/config/uboot.release | |
2167 | ifneq ($(KBUILD_SRC),) | |
2168 | @$(kecho) ' Using $(srctree) as source for U-Boot' | |
2169 | $(Q)if [ -f $(srctree)/.config -o -d $(srctree)/include/config ]; then \ | |
2170 | echo >&2 " $(srctree) is not clean, please run 'make mrproper'"; \ | |
2171 | echo >&2 " in the '$(srctree)' directory.";\ | |
2172 | /bin/false; \ | |
2173 | fi; | |
2174 | endif | |
2175 | ||
2176 | prepare1: prepare3 outputmakefile cfg $(version_h) $(timestamp_h) $(dt_h) $(env_h) \ | |
2177 | include/config/auto.conf | |
2178 | ifeq ($(wildcard $(LDSCRIPT)),) | |
2179 | @echo >&2 " Could not find linker script." | |
2180 | @/bin/false | |
2181 | endif | |
2182 | ||
2183 | ifeq ($(CONFIG_ENV_USE_DEFAULT_ENV_TEXT_FILE),y) | |
2184 | prepare1: $(defaultenv_h) | |
2185 | ||
2186 | envtools: $(defaultenv_h) | |
2187 | endif | |
2188 | archprepare: prepare1 scripts | |
2189 | ||
2190 | prepare0: archprepare | |
2191 | $(Q)$(MAKE) $(build)=. | |
2192 | ||
2193 | # All the preparing.. | |
2194 | prepare: prepare0 prepare-objtool | |
2195 | ||
2196 | # Support for using generic headers in asm-generic | |
2197 | asm-generic := -f $(srctree)/scripts/Makefile.asm-generic obj | |
2198 | ||
2199 | PHONY += asm-generic uapi-asm-generic | |
2200 | asm-generic: uapi-asm-generic | |
2201 | $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/asm \ | |
2202 | generic=include/asm-generic | |
2203 | uapi-asm-generic: | |
2204 | $(Q)$(MAKE) $(asm-generic)=arch/$(SRCARCH)/include/generated/uapi/asm \ | |
2205 | generic=include/uapi/asm-generic | |
2206 | ||
2207 | PHONY += prepare-objtool | |
2208 | prepare-objtool: $(objtool_target) | |
2209 | ifeq ($(SKIP_STACK_VALIDATION),1) | |
2210 | ifdef CONFIG_UNWINDER_ORC | |
2211 | @echo "error: Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2 | |
2212 | @false | |
2213 | else | |
2214 | @echo "warning: Cannot use CONFIG_STACK_VALIDATION=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel" >&2 | |
2215 | endif | |
2216 | endif | |
2217 | ||
2218 | # Generate some files | |
2219 | # --------------------------------------------------------------------------- | |
2220 | ||
2221 | # Use sed to remove leading zeros from PATCHLEVEL to avoid using octal numbers | |
2222 | define filechk_version.h | |
2223 | (echo \#define PLAIN_VERSION \"$(UBOOTRELEASE)\"; \ | |
2224 | echo \#define U_BOOT_VERSION \"U-Boot \" PLAIN_VERSION; \ | |
2225 | echo \#define U_BOOT_VERSION_NUM $(VERSION); \ | |
2226 | echo \#define U_BOOT_VERSION_NUM_PATCH $$(echo $(PATCHLEVEL) | \ | |
2227 | sed -e "s/^0*//"); \ | |
2228 | echo \#define HOST_ARCH $(HOST_ARCH); \ | |
2229 | echo \#define CC_VERSION_STRING \"$$(LC_ALL=C $(CC) --version | head -n 1)\"; \ | |
2230 | echo \#define LD_VERSION_STRING \"$$(LC_ALL=C $(LD) --version | head -n 1)\"; ) | |
2231 | endef | |
2232 | ||
2233 | # The SOURCE_DATE_EPOCH mechanism requires a date that behaves like GNU date. | |
2234 | # The BSD date on the other hand behaves different and would produce errors | |
2235 | # with the misused '-d' switch. Respect that and search a working date with | |
2236 | # well known pre- and suffixes for the GNU variant of date. | |
2237 | define filechk_timestamp.h | |
2238 | (if test -n "$${SOURCE_DATE_EPOCH}"; then \ | |
2239 | SOURCE_DATE="@$${SOURCE_DATE_EPOCH}"; \ | |
2240 | DATE=""; \ | |
2241 | for date in gdate date.gnu date; do \ | |
2242 | $${date} -u -d "$${SOURCE_DATE}" >/dev/null 2>&1 && DATE="$${date}"; \ | |
2243 | done; \ | |
2244 | if test -n "$${DATE}"; then \ | |
2245 | LC_ALL=C $${DATE} -u -d "$${SOURCE_DATE}" +'#define U_BOOT_DATE "%b %d %C%y"'; \ | |
2246 | LC_ALL=C $${DATE} -u -d "$${SOURCE_DATE}" +'#define U_BOOT_TIME "%T"'; \ | |
2247 | LC_ALL=C $${DATE} -u -d "$${SOURCE_DATE}" +'#define U_BOOT_TZ "%z"'; \ | |
2248 | LC_ALL=C $${DATE} -u -d "$${SOURCE_DATE}" +'#define U_BOOT_EPOCH %s'; \ | |
2249 | else \ | |
2250 | return 42; \ | |
2251 | fi; \ | |
2252 | else \ | |
2253 | LC_ALL=C date +'#define U_BOOT_DATE "%b %d %C%y"'; \ | |
2254 | LC_ALL=C date +'#define U_BOOT_TIME "%T"'; \ | |
2255 | LC_ALL=C date +'#define U_BOOT_TZ "%z"'; \ | |
2256 | LC_ALL=C date +'#define U_BOOT_EPOCH %s'; \ | |
2257 | fi) | |
2258 | endef | |
2259 | ||
2260 | define filechk_defaultenv.h | |
2261 | ( { grep -v '^#' | grep -v '^$$' || true ; echo '' ; } | \ | |
2262 | tr '\n' '\0' | \ | |
2263 | sed -e 's/\\\x0\s*//g' | \ | |
2264 | xxd -i ; ) | |
2265 | endef | |
2266 | ||
2267 | define filechk_dt.h | |
2268 | (if test -n "$${DEVICE_TREE}"; then \ | |
2269 | echo \#define DEVICE_TREE \"$(DEVICE_TREE)\"; \ | |
2270 | else \ | |
2271 | echo \#define DEVICE_TREE CONFIG_DEFAULT_DEVICE_TREE; \ | |
2272 | fi) | |
2273 | endef | |
2274 | ||
2275 | $(version_h): include/config/uboot.release FORCE | |
2276 | $(call filechk,version.h) | |
2277 | ||
2278 | $(timestamp_h): $(srctree)/Makefile FORCE | |
2279 | $(call filechk,timestamp.h) | |
2280 | ||
2281 | $(dt_h): $(srctree)/Makefile FORCE | |
2282 | $(call filechk,dt.h) | |
2283 | ||
2284 | $(defaultenv_h): $(CONFIG_ENV_DEFAULT_ENV_TEXT_FILE:"%"=%) FORCE | |
2285 | $(call filechk,defaultenv.h) | |
2286 | ||
2287 | # --------------------------------------------------------------------------- | |
2288 | # Devicetree files | |
2289 | ||
2290 | ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/boot/dts/),) | |
2291 | dtstree := arch/$(SRCARCH)/boot/dts | |
2292 | endif | |
2293 | ||
2294 | ifneq ($(dtstree),) | |
2295 | ||
2296 | %.dtb: prepare3 scripts_dtc | |
2297 | $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@ | |
2298 | ||
2299 | PHONY += dtbs dtbs_install dt_binding_check | |
2300 | dtbs dtbs_check: prepare3 scripts_dtc | |
2301 | $(Q)$(MAKE) $(build)=$(dtstree) | |
2302 | ||
2303 | dtbs_check: export CHECK_DTBS=1 | |
2304 | dtbs_check: dt_binding_check | |
2305 | ||
2306 | dtbs_install: | |
2307 | $(Q)$(MAKE) $(dtbinst)=$(dtstree) | |
2308 | ||
2309 | ifdef CONFIG_OF_EARLY_FLATTREE | |
2310 | all: dtbs | |
2311 | endif | |
2312 | ||
2313 | endif | |
2314 | ||
2315 | # Check dtc and pylibfdt, if DTC is provided, else build them | |
2316 | PHONY += scripts_dtc | |
2317 | scripts_dtc: scripts_basic | |
2318 | $(Q)if test "$(DTC)" = "$(DTC_INTREE)"; then \ | |
2319 | $(MAKE) $(build)=scripts/dtc; \ | |
2320 | else \ | |
2321 | if ! $(DTC) -v >/dev/null; then \ | |
2322 | echo '*** Failed to check dtc version: $(DTC)'; \ | |
2323 | false; \ | |
2324 | else \ | |
2325 | if test "$(call dtc-version)" -lt $(DTC_MIN_VERSION); then \ | |
2326 | echo '*** Your dtc is too old, please upgrade to dtc $(DTC_MIN_VERSION) or newer'; \ | |
2327 | false; \ | |
2328 | else \ | |
2329 | if [ -n "$(CONFIG_PYLIBFDT)" ]; then \ | |
2330 | if ! echo "import libfdt" | $(PYTHON3) 2>/dev/null; then \ | |
2331 | echo '*** pylibfdt does not seem to be available with $(PYTHON3)'; \ | |
2332 | false; \ | |
2333 | fi; \ | |
2334 | fi; \ | |
2335 | fi; \ | |
2336 | fi; \ | |
2337 | fi | |
2338 | ||
2339 | # --------------------------------------------------------------------------- | |
2340 | quiet_cmd_cpp_lds = LDS $@ | |
2341 | cmd_cpp_lds = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) \ | |
2342 | -D__ASSEMBLY__ -x assembler-with-cpp -std=c99 -P -o $@ $< | |
2343 | ||
2344 | u-boot.lds: $(LDSCRIPT) prepare FORCE | |
2345 | $(call if_changed_dep,cpp_lds) | |
2346 | ||
2347 | spl/u-boot-spl.bin: spl/u-boot-spl | |
2348 | @: | |
2349 | $(SPL_SIZE_CHECK) | |
2350 | ||
2351 | spl/u-boot-spl-dtb.bin: spl/u-boot-spl | |
2352 | @: | |
2353 | ||
2354 | spl/u-boot-spl-dtb.hex: spl/u-boot-spl | |
2355 | @: | |
2356 | ||
2357 | spl/u-boot-spl: tools prepare $(if $(CONFIG_SPL_OF_CONTROL),dts/dt.dtb) | |
2358 | $(Q)$(MAKE) obj=spl -f $(srctree)/scripts/Makefile.xpl all | |
2359 | ||
2360 | spl/sunxi-spl.bin: spl/u-boot-spl | |
2361 | @: | |
2362 | ||
2363 | spl/sunxi-spl-with-ecc.bin: spl/sunxi-spl.bin | |
2364 | @: | |
2365 | ||
2366 | spl/u-boot-spl.sfp: spl/u-boot-spl | |
2367 | @: | |
2368 | ||
2369 | spl/boot.bin: spl/u-boot-spl | |
2370 | @: | |
2371 | ||
2372 | tpl/u-boot-tpl.bin: tpl/u-boot-tpl | |
2373 | @: | |
2374 | $(TPL_SIZE_CHECK) | |
2375 | ||
2376 | tpl/u-boot-tpl: tools prepare $(if $(CONFIG_TPL_OF_CONTROL),dts/dt.dtb) | |
2377 | $(Q)$(MAKE) obj=tpl -f $(srctree)/scripts/Makefile.xpl all | |
2378 | ||
2379 | vpl/u-boot-vpl.bin: vpl/u-boot-vpl | |
2380 | @: | |
2381 | $(VPL_SIZE_CHECK) | |
2382 | ||
2383 | vpl/u-boot-vpl: tools prepare $(if $(CONFIG_TPL_OF_CONTROL),dts/dt.dtb) | |
2384 | $(Q)$(MAKE) obj=vpl -f $(srctree)/scripts/Makefile.xpl all | |
2385 | ||
2386 | TAG_SUBDIRS := $(patsubst %,$(srctree)/%,$(u-boot-dirs) include) | |
2387 | ||
2388 | FIND := find | |
2389 | FINDFLAGS := -L | |
2390 | ||
2391 | tags ctags: | |
2392 | ctags -w -o ctags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \ | |
2393 | -name '*.[chS]' -print` | |
2394 | ln -s ctags tags | |
2395 | ||
2396 | etags: | |
2397 | etags -a -o etags `$(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) \ | |
2398 | -name '*.[chS]' -print` | |
2399 | cscope: | |
2400 | $(FIND) $(FINDFLAGS) $(TAG_SUBDIRS) -name '*.[chS]' -print > \ | |
2401 | cscope.files | |
2402 | @find $(TAG_SUBDIRS) -name '*.[chS]' -type l -print | \ | |
2403 | grep -xvf - cscope.files > cscope.files.no-symlinks; \ | |
2404 | mv cscope.files.no-symlinks cscope.files | |
2405 | cscope -b -q -k | |
2406 | ||
2407 | SYSTEM_MAP = \ | |
2408 | $(NM) $1 | \ | |
2409 | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \ | |
2410 | LC_ALL=C sort | |
2411 | System.map: u-boot | |
2412 | @$(call SYSTEM_MAP,$<) > $@ | |
2413 | ||
2414 | # ARM relocations should all be R_ARM_RELATIVE (32-bit) or | |
2415 | # R_AARCH64_RELATIVE (64-bit). | |
2416 | checkarmreloc: u-boot | |
2417 | @RELOC="`$(READELF) -r -W $< | cut -d ' ' -f 4 | \ | |
2418 | grep R_A | sort -u`"; \ | |
2419 | if test "$$RELOC" != "R_ARM_RELATIVE" -a \ | |
2420 | "$$RELOC" != "R_AARCH64_RELATIVE"; then \ | |
2421 | echo "$< contains unexpected relocations: $$RELOC"; \ | |
2422 | false; \ | |
2423 | fi | |
2424 | ||
2425 | tools/version.h: include/version.h | |
2426 | $(Q)mkdir -p $(dir $@) | |
2427 | $(call if_changed,copy) | |
2428 | ||
2429 | envtools: u-boot-initial-env scripts_basic $(version_h) $(timestamp_h) tools/version.h | |
2430 | $(Q)$(MAKE) $(build)=tools/env | |
2431 | ||
2432 | tools-only: export TOOLS_ONLY=y | |
2433 | tools-only: scripts_basic $(version_h) $(timestamp_h) tools/version.h | |
2434 | $(Q)$(MAKE) $(build)=tools | |
2435 | ||
2436 | tools-all: export HOST_TOOLS_ALL=y | |
2437 | tools-all: envtools tools ; | |
2438 | ||
2439 | cross_tools: export CROSS_BUILD_TOOLS=y | |
2440 | cross_tools: tools ; | |
2441 | ||
2442 | .PHONY : CHANGELOG | |
2443 | CHANGELOG: | |
2444 | git log --no-merges U-Boot-1_1_5.. | \ | |
2445 | unexpand -a | sed -e 's/\s\s*$$//' > $@ | |
2446 | ||
2447 | ######################################################################### | |
2448 | ||
2449 | ### | |
2450 | # Cleaning is done on three levels. | |
2451 | # make clean Delete most generated files | |
2452 | # Leave enough to build external modules | |
2453 | # make mrproper Delete the current configuration, and all generated files | |
2454 | # make distclean Remove editor backup files, patch leftover files and the like | |
2455 | ||
2456 | # Directories & files removed with 'make clean' | |
2457 | CLEAN_DIRS += $(MODVERDIR) \ | |
2458 | $(foreach d, spl tpl vpl, $(patsubst %,$d/%, \ | |
2459 | $(filter-out include, $(shell ls -1 $d 2>/dev/null)))) | |
2460 | ||
2461 | CLEAN_FILES += include/autoconf.mk* include/bmp_logo.h include/bmp_logo_data.h \ | |
2462 | include/config.h include/generated/env.* drivers/video/u_boot_logo.S \ | |
2463 | tools/version.h u-boot* MLO* SPL System.map fit-dtb.blob* \ | |
2464 | u-boot-ivt.img.log u-boot-dtb.imx.log SPL.log u-boot.imx.log \ | |
2465 | lpc32xx-* bl31.c bl31.elf bl31_*.bin image.map tispl.bin* \ | |
2466 | idbloader.img flash.bin flash.log defconfig keep-syms-lto.c \ | |
2467 | mkimage-out.spl.mkimage mkimage.spl.mkimage imx-boot.map \ | |
2468 | itb.fit.fit itb.fit.itb itb.map spl.map mkimage-out.rom.mkimage \ | |
2469 | mkimage.rom.mkimage mkimage-in-simple-bin* rom.map simple-bin* \ | |
2470 | idbloader-spi.img lib/efi_loader/helloworld_efi.S *.itb \ | |
2471 | Test* capsule*.*.efi-capsule capsule*.map mkimage.imx-boot.spl \ | |
2472 | mkimage.imx-boot.u-boot mkimage-out.imx-boot.spl mkimage-out.imx-boot.u-boot \ | |
2473 | imx9image* m33-oei-ddrfw* | |
2474 | ||
2475 | # Directories & files removed with 'make mrproper' | |
2476 | MRPROPER_DIRS += include/config include/generated spl tpl vpl \ | |
2477 | .tmp_objdiff doc/output include/asm | |
2478 | ||
2479 | # Remove include/asm symlink created by U-Boot before v2014.01 | |
2480 | MRPROPER_FILES += .config .config.old include/autoconf.mk* include/config.h \ | |
2481 | ctags etags tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \ | |
2482 | drivers/video/fonts/*.S include/asm *imx8mimage* *imx8mcst* | |
2483 | ||
2484 | # clean - Delete most, but leave enough to build external modules | |
2485 | # | |
2486 | clean: rm-dirs := $(CLEAN_DIRS) | |
2487 | clean: rm-files := $(CLEAN_FILES) | |
2488 | clean-dirs := $(foreach f,$(u-boot-alldirs),$(if $(wildcard $(srctree)/$f/Makefile),$f)) | |
2489 | clean-dirs := $(addprefix _clean_, $(clean-dirs)) | |
2490 | ||
2491 | PHONY += $(clean-dirs) clean archclean | |
2492 | $(clean-dirs): | |
2493 | $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) | |
2494 | ||
2495 | clean: $(clean-dirs) | |
2496 | $(call cmd,rmdirs) | |
2497 | $(call cmd,rmfiles) | |
2498 | @find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \ | |
2499 | \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ | |
2500 | -o -name '*.ko.*' -o -name '*.su' -o -name '*.pyc' \ | |
2501 | -o -name '*.dtb' -o -name '*.dtbo' \ | |
2502 | -o -name '*.dtb.S' -o -name '*.dtbo.S' \ | |
2503 | -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ | |
2504 | -o -name '*.lex.c' -o -name '*.tab.[ch]' \ | |
2505 | -o -name '*.asn1.[ch]' \ | |
2506 | -o -name '*.symtypes' -o -name 'modules.order' \ | |
2507 | -o -name modules.builtin -o -name '.tmp_*.o.*' \ | |
2508 | -o -name 'dsdt_generated.aml' -o -name 'dsdt_generated.asl.tmp' \ | |
2509 | -o -name 'dsdt_generated.c' \ | |
2510 | -o -name 'generated_defconfig' \ | |
2511 | -o -name '*.efi' -o -name '*.gcno' -o -name '*.so' \) \ | |
2512 | -type f -print | xargs rm -f | |
2513 | ||
2514 | # mrproper - Delete all generated files, including .config | |
2515 | # | |
2516 | mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS)) | |
2517 | mrproper: rm-files := $(wildcard $(MRPROPER_FILES)) | |
2518 | mrproper-dirs := $(addprefix _mrproper_,scripts) | |
2519 | ||
2520 | PHONY += $(mrproper-dirs) mrproper | |
2521 | $(mrproper-dirs): | |
2522 | $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@) | |
2523 | ||
2524 | mrproper: clean $(mrproper-dirs) | |
2525 | $(call cmd,rmdirs) | |
2526 | $(call cmd,rmfiles) | |
2527 | @rm -f arch/*/include/asm/arch | |
2528 | ||
2529 | # distclean | |
2530 | # | |
2531 | PHONY += distclean | |
2532 | ||
2533 | distclean: mrproper | |
2534 | @find $(srctree) $(RCS_FIND_IGNORE) \ | |
2535 | \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ | |
2536 | -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \ | |
2537 | -o -name '.*.rej' -o -name '*%' -o -name 'core' \ | |
2538 | -o -name '*.pyc' \) \ | |
2539 | -type f -print | xargs rm -f | |
2540 | @rm -f boards.cfg CHANGELOG .binman_stamp | |
2541 | ||
2542 | # See doc/develop/python_cq.rst | |
2543 | PHONY += pylint pylint_err | |
2544 | PYLINT_BASE := scripts/pylint.base | |
2545 | PYLINT_CUR := pylint.cur | |
2546 | PYLINT_DIFF := pylint.diff | |
2547 | pylint: | |
2548 | $(Q)echo "Running pylint on all files (summary in $(PYLINT_CUR); output in pylint.out/)" | |
2549 | $(Q)mkdir -p pylint.out | |
2550 | $(Q)rm -f pylint.out/out* | |
2551 | $(Q)find tools test -name "*.py" \ | |
2552 | | xargs -n1 -P$(shell nproc 2>/dev/null || echo 1) \ | |
2553 | sh -c 'pylint --reports=y --exit-zero -f parseable --ignore-imports=yes $$@ > pylint.out/$$(echo $$@ | tr / _ | sed s/.py//)' _ | |
2554 | $(Q)rm -f $(PYLINT_CUR) | |
2555 | $(Q)( cd pylint.out; for f in *; do \ | |
2556 | sed -ne "s/Your code has been rated at \([-0-9.]*\).*/$$f \1/p" $$f; \ | |
2557 | done ) | sort > $(PYLINT_CUR) | |
2558 | $(Q)base=$$(mktemp) cur=$$(mktemp); cut -d' ' -f1 $(PYLINT_BASE) >$$base; \ | |
2559 | cut -d' ' -f1 $(PYLINT_CUR) >$$cur; \ | |
2560 | comm -3 $$base $$cur > $(PYLINT_DIFF); \ | |
2561 | if [ -s $(PYLINT_DIFF) ]; then \ | |
2562 | echo "Files have been added/removed. Try:\n\tcp $(PYLINT_CUR) $(PYLINT_BASE)"; \ | |
2563 | echo; \ | |
2564 | echo "Added files:"; \ | |
2565 | comm -13 $$base $$cur; \ | |
2566 | echo; \ | |
2567 | echo "Removed files:"; \ | |
2568 | comm -23 $$base $$cur; \ | |
2569 | false; \ | |
2570 | else \ | |
2571 | rm $$base $$cur $(PYLINT_DIFF); \ | |
2572 | fi | |
2573 | $(Q)bad=false; while read base_file base_val <&3 && read cur_file cur_val <&4; do \ | |
2574 | if awk "BEGIN {exit !($$cur_val < $$base_val)}"; then \ | |
2575 | echo "$$base_file: Score was $$base_val, now $$cur_val"; \ | |
2576 | bad=true; fi; \ | |
2577 | done 3<$(PYLINT_BASE) 4<$(PYLINT_CUR); \ | |
2578 | if $$bad; then \ | |
2579 | echo "Some files have regressed, please fix"; \ | |
2580 | false; \ | |
2581 | else \ | |
2582 | echo "No pylint regressions"; \ | |
2583 | fi | |
2584 | ||
2585 | # Check for errors only | |
2586 | pylint_err: | |
2587 | $(Q)pylint -E -j 0 --ignore-imports=yes \ | |
2588 | $(shell find tools test -name "*.py") | |
2589 | ||
2590 | backup: | |
2591 | F=`basename $(srctree)` ; cd .. ; \ | |
2592 | gtar --force-local -zcvf `LC_ALL=C date "+$$F-%Y-%m-%d-%T.tar.gz"` $$F | |
2593 | ||
2594 | PHONY += _pip pip pip_release | |
2595 | ||
2596 | pip_release: PIP_ARGS="--real" | |
2597 | pip_test: PIP_ARGS="" | |
2598 | pip: PIP_ARGS="-n" | |
2599 | ||
2600 | pip pip_test pip_release: _pip | |
2601 | ||
2602 | _pip: | |
2603 | scripts/make_pip.sh u_boot_pylib ${PIP_ARGS} | |
2604 | scripts/make_pip.sh patman ${PIP_ARGS} | |
2605 | scripts/make_pip.sh buildman ${PIP_ARGS} | |
2606 | scripts/make_pip.sh dtoc ${PIP_ARGS} | |
2607 | scripts/make_pip.sh binman ${PIP_ARGS} | |
2608 | ||
2609 | help: | |
2610 | @echo 'Cleaning targets:' | |
2611 | @echo ' clean - Remove most generated files but keep the config' | |
2612 | @echo ' mrproper - Remove all generated files + config + various backup files' | |
2613 | @echo ' distclean - mrproper + remove editor backup and patch files' | |
2614 | @echo '' | |
2615 | @echo 'Configuration targets:' | |
2616 | @$(MAKE) -f $(srctree)/scripts/kconfig/Makefile help | |
2617 | @echo '' | |
2618 | @echo 'Test targets:' | |
2619 | @echo '' | |
2620 | @echo ' check - Run all automated tests that use sandbox' | |
2621 | @echo ' pcheck - Run quick automated tests in parallel' | |
2622 | @echo ' qcheck - Run quick automated tests that use sandbox' | |
2623 | @echo ' tcheck - Run quick automated tests on tools' | |
2624 | @echo ' pylint - Run pylint on all Python files' | |
2625 | @echo '' | |
2626 | @echo 'Other generic targets:' | |
2627 | @echo ' all - Build all necessary images depending on configuration' | |
2628 | @echo ' tests - Build U-Boot for sandbox and run tests' | |
2629 | @echo '* u-boot - Build the bare u-boot' | |
2630 | @echo ' dir/ - Build all files in dir and below' | |
2631 | @echo ' dir/file.[oisS] - Build specified target only' | |
2632 | @echo ' dir/file.lst - Build specified mixed source/assembly target only' | |
2633 | @echo ' (requires a recent binutils and recent build (System.map))' | |
2634 | @echo ' tags/ctags - Generate ctags file for editors' | |
2635 | @echo ' etags - Generate etags file for editors' | |
2636 | @echo ' cscope - Generate cscope index' | |
2637 | @echo ' ubootrelease - Output the release version string (use with make -s)' | |
2638 | @echo ' ubootversion - Output the version stored in Makefile (use with make -s)' | |
2639 | @echo " cfg - Don't build, just create the .cfg files" | |
2640 | @echo " envtools - Build only the target-side environment tools" | |
2641 | @echo '' | |
2642 | @echo 'PyPi / pip targets:' | |
2643 | @echo ' pip - Check building of PyPi packages' | |
2644 | @echo ' pip_test - Build PyPi pakages and upload to test server' | |
2645 | @echo ' pip_release - Build PyPi pakages and upload to release server' | |
2646 | @echo '' | |
2647 | @echo 'Static analysers' | |
2648 | @echo ' checkstack - Generate a list of stack hogs' | |
2649 | @echo ' coccicheck - Execute static code analysis with Coccinelle' | |
2650 | @echo '' | |
2651 | @echo 'Documentation targets:' | |
2652 | @$(MAKE) -f $(srctree)/doc/Makefile dochelp | |
2653 | @echo '' | |
2654 | @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build' | |
2655 | @echo ' make V=2 [targets] 2 => give reason for rebuild of target' | |
2656 | @echo ' make O=dir [targets] Locate all output files in "dir", including .config' | |
2657 | @echo ' make C=1 [targets] Check all c source with $$CHECK (sparse by default)' | |
2658 | @echo ' make C=2 [targets] Force check of all c source with $$CHECK' | |
2659 | @echo ' make RECORDMCOUNT_WARN=1 [targets] Warn about ignored mcount sections' | |
2660 | @echo ' make W=n [targets] Enable extra gcc checks, n=1,2,3 where' | |
2661 | @echo ' 1: warnings which may be relevant and do not occur too often' | |
2662 | @echo ' 2: warnings which occur quite often but may still be relevant' | |
2663 | @echo ' 3: more obscure warnings, can most likely be ignored' | |
2664 | @echo ' Multiple levels can be combined with W=12 or W=123' | |
2665 | @echo '' | |
2666 | @echo 'Execute "make" or "make all" to build all targets marked with [*] ' | |
2667 | @echo 'For further info see the ./README file' | |
2668 | ||
2669 | tests check: | |
2670 | $(srctree)/test/run | |
2671 | ||
2672 | pcheck: | |
2673 | $(srctree)/test/run parallel | |
2674 | ||
2675 | qcheck: | |
2676 | $(srctree)/test/run quick | |
2677 | ||
2678 | tcheck: | |
2679 | $(srctree)/test/run tools | |
2680 | ||
2681 | # Documentation targets | |
2682 | # --------------------------------------------------------------------------- | |
2683 | DOC_TARGETS := xmldocs latexdocs pdfdocs htmldocs epubdocs cleandocs \ | |
2684 | linkcheckdocs dochelp refcheckdocs texinfodocs infodocs | |
2685 | PHONY += $(DOC_TARGETS) | |
2686 | $(DOC_TARGETS): scripts_basic FORCE | |
2687 | $(Q)PYTHONPATH=$(srctree)/test/py/tests:$(srctree)/test/py \ | |
2688 | $(MAKE) $(build)=doc $@ | |
2689 | ||
2690 | PHONY += checkstack ubootrelease ubootversion | |
2691 | ||
2692 | checkstack: | |
2693 | $(OBJDUMP) -d u-boot $$(find . -name u-boot-spl) | \ | |
2694 | $(PERL) $(src)/scripts/checkstack.pl $(ARCH) | |
2695 | ||
2696 | ubootversion: | |
2697 | @echo $(UBOOTVERSION) | |
2698 | ||
2699 | ubootrelease: | |
2700 | @$(filechk_uboot.release) | |
2701 | ||
2702 | # Clear a bunch of variables before executing the submake | |
2703 | ||
2704 | ifeq ($(quiet),silent_) | |
2705 | tools_silent=s | |
2706 | endif | |
2707 | ||
2708 | tools/: FORCE | |
2709 | $(Q)mkdir -p $(objtree)/tools | |
2710 | $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(src)/tools/ | |
2711 | ||
2712 | tools/%: FORCE | |
2713 | $(Q)mkdir -p $(objtree)/tools | |
2714 | $(Q)$(MAKE) LDFLAGS= MAKEFLAGS="$(tools_silent) $(filter --j% -j,$(MAKEFLAGS))" O=$(abspath $(objtree)) subdir=tools -C $(src)/tools/ $* | |
2715 | ||
2716 | # Single targets | |
2717 | # --------------------------------------------------------------------------- | |
2718 | # Single targets are compatible with: | |
2719 | # - build with mixed source and output | |
2720 | # - build with separate output dir 'make O=...' | |
2721 | # - external modules | |
2722 | # | |
2723 | # target-dir => where to store outputfile | |
2724 | # build-dir => directory in kernel source tree to use | |
2725 | ||
2726 | build-target = $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD)/)$@ | |
2727 | build-dir = $(patsubst %/,%,$(dir $(build-target))) | |
2728 | ||
2729 | %.i: prepare FORCE | |
2730 | $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) | |
2731 | %.ll: prepare FORCE | |
2732 | $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) | |
2733 | %.lst: prepare FORCE | |
2734 | $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) | |
2735 | %.o: prepare FORCE | |
2736 | $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) | |
2737 | %.s: prepare FORCE | |
2738 | $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) | |
2739 | %.symtypes: prepare FORCE | |
2740 | $(Q)$(MAKE) $(build)=$(build-dir) $(build-target) | |
2741 | %.ko: %.o | |
2742 | $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost | |
2743 | ||
2744 | # Modules | |
2745 | PHONY += / | |
2746 | /: ./ | |
2747 | ||
2748 | # Make sure the latest headers are built for Documentation | |
2749 | Documentation/ samples/: headers_install | |
2750 | %/: prepare FORCE | |
2751 | $(Q)$(MAKE) KBUILD_MODULES=1 $(build)=$(build-dir) | |
2752 | ||
2753 | quiet_cmd_genenv = GENENV $@ | |
2754 | cmd_genenv = \ | |
2755 | $(objtree)/tools/printinitialenv | \ | |
2756 | sed -e '/^\s*$$/d' | \ | |
2757 | sort -t '=' -k 1,1 -s -o $@ | |
2758 | ||
2759 | u-boot-initial-env: scripts_basic $(version_h) $(env_h) include/config.h FORCE | |
2760 | $(Q)$(MAKE) $(build)=tools $(objtree)/tools/printinitialenv | |
2761 | $(call if_changed,genenv) | |
2762 | ||
2763 | # Consistency checks | |
2764 | # --------------------------------------------------------------------------- | |
2765 | ||
2766 | PHONY += coccicheck | |
2767 | ||
2768 | coccicheck: | |
2769 | $(Q)$(CONFIG_SHELL) $(srctree)/scripts/$@ | |
2770 | ||
2771 | # FIXME Should go into a make.lib or something | |
2772 | # =========================================================================== | |
2773 | ||
2774 | quiet_cmd_rmdirs = $(if $(wildcard $(rm-dirs)),CLEAN $(wildcard $(rm-dirs))) | |
2775 | cmd_rmdirs = rm -rf $(rm-dirs) | |
2776 | ||
2777 | quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files))) | |
2778 | cmd_rmfiles = rm -f $(rm-files) | |
2779 | ||
2780 | # Run depmod only if we have System.map and depmod is executable | |
2781 | quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) | |
2782 | cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \ | |
2783 | $(KERNELRELEASE) | |
2784 | ||
2785 | # Create temporary dir for module support files | |
2786 | # clean it up only when building all modules | |
2787 | cmd_crmodverdir = $(Q)mkdir -p $(MODVERDIR) \ | |
2788 | $(if $(KBUILD_MODULES),; rm -f $(MODVERDIR)/*) | |
2789 | ||
2790 | # read saved command lines for existing targets | |
2791 | existing-targets := $(wildcard $(sort $(targets))) | |
2792 | ||
2793 | -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) | |
2794 | ||
2795 | endif # ifeq ($(config-targets),1) | |
2796 | endif # ifeq ($(mixed-targets),1) | |
2797 | endif # need-sub-make | |
2798 | ||
2799 | PHONY += FORCE | |
2800 | FORCE: | |
2801 | ||
2802 | # Declare the contents of the PHONY variable as phony. We keep that | |
2803 | # information in a variable so we can use it in if_changed and friends. | |
2804 | .PHONY: $(PHONY) |