Merge tag 'u-boot-amlogic-20201105' of https://gitlab.denx.de/u-boot/custodians/u...
[platform/kernel/u-boot.git] / scripts / Makefile.spl
1 # SPDX-License-Identifier: GPL-2.0+
2 #
3 # (C) Copyright 2000-2011
4 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 #
6 # (C) Copyright 2011
7 # Daniel Schwierzeck, daniel.schwierzeck@googlemail.com.
8 #
9 # (C) Copyright 2011
10 # Texas Instruments Incorporated - http://www.ti.com/
11 # Aneesh V <aneesh@ti.com>
12 # Based on top-level Makefile.
13 #
14
15 src := $(obj)
16
17 # Create output directory if not already present
18 _dummy := $(shell [ -d $(obj) ] || mkdir -p $(obj))
19
20 include $(srctree)/scripts/Kbuild.include
21
22 -include include/config/auto.conf
23 -include $(obj)/include/autoconf.mk
24
25 UBOOTINCLUDE := -I$(obj)/include $(UBOOTINCLUDE)
26
27 KBUILD_CPPFLAGS += -DCONFIG_SPL_BUILD
28 ifeq ($(CONFIG_TPL_BUILD),y)
29 KBUILD_CPPFLAGS += -DCONFIG_TPL_BUILD
30 endif
31
32 ifeq ($(CONFIG_TPL_BUILD),y)
33 SPL_BIN := u-boot-tpl
34 else
35 SPL_BIN := u-boot-spl
36 endif
37
38 ifdef CONFIG_SPL_BUILD
39 SPL_ := SPL_
40 ifeq ($(CONFIG_TPL_BUILD),y)
41 SPL_TPL_ := TPL_
42 else
43 SPL_TPL_ := SPL_
44 endif
45 else
46 SPL_ :=
47 SPL_TPL_ :=
48 endif
49
50 ifeq ($(obj)$(CONFIG_SUPPORT_SPL),spl)
51 $(error You cannot build SPL without enabling CONFIG_SUPPORT_SPL)
52 endif
53 ifeq ($(obj)$(CONFIG_SUPPORT_TPL),tpl)
54 $(error You cannot build TPL without enabling CONFIG_SUPPORT_TPL)
55 endif
56
57 include $(srctree)/config.mk
58 include $(srctree)/arch/$(ARCH)/Makefile
59
60 include $(srctree)/scripts/Makefile.lib
61
62 # Enable garbage collection of un-used sections for SPL
63 KBUILD_CFLAGS += -ffunction-sections -fdata-sections
64 LDFLAGS_FINAL += --gc-sections
65
66 # FIX ME
67 cpp_flags := $(KBUILD_CPPFLAGS) $(PLATFORM_CPPFLAGS) $(UBOOTINCLUDE) \
68                                                         $(NOSTDINC_FLAGS)
69 c_flags := $(KBUILD_CFLAGS) $(cpp_flags)
70
71 HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(srctree)/board/$(VENDOR)/common/Makefile),y,n)
72
73 libs-y += $(if $(BOARDDIR),board/$(BOARDDIR)/)
74 libs-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/
75
76 ifeq ($(CONFIG_TPL_BUILD),y)
77 libs-$(CONFIG_TPL_FRAMEWORK) += common/spl/
78 else
79 libs-$(CONFIG_SPL_FRAMEWORK) += common/spl/
80 endif
81 libs-y += common/init/
82
83 # Special handling for a few options which support SPL/TPL
84 ifeq ($(CONFIG_TPL_BUILD),y)
85 libs-$(CONFIG_TPL_LIBCOMMON_SUPPORT) += common/ cmd/ env/
86 libs-$(CONFIG_TPL_LIBGENERIC_SUPPORT) += lib/
87 else
88 libs-$(CONFIG_SPL_LIBCOMMON_SUPPORT) += common/ cmd/ env/
89 libs-$(CONFIG_SPL_LIBGENERIC_SUPPORT) += lib/
90 ifdef CONFIG_SPL_FRAMEWORK
91 libs-$(CONFIG_PARTITIONS) += disk/
92 endif
93 endif
94
95 libs-y += drivers/
96 libs-$(CONFIG_SPL_USB_GADGET) += drivers/usb/dwc3/
97 libs-$(CONFIG_SPL_USB_GADGET) += drivers/usb/cdns3/
98 libs-y += dts/
99 libs-y += fs/
100 libs-$(CONFIG_SPL_POST_MEM_SUPPORT) += post/drivers/
101 libs-$(CONFIG_SPL_NET_SUPPORT) += net/
102 libs-$(CONFIG_SPL_UNIT_TEST) += test/
103
104 head-y          := $(addprefix $(obj)/,$(head-y))
105 libs-y          := $(addprefix $(obj)/,$(libs-y))
106 u-boot-spl-dirs := $(patsubst %/,%,$(filter %/, $(libs-y)))
107
108 libs-y := $(patsubst %/, %/built-in.o, $(libs-y))
109
110 # Add GCC lib
111 ifeq ($(CONFIG_USE_PRIVATE_LIBGCC),y)
112 PLATFORM_LIBGCC = arch/$(ARCH)/lib/lib.a
113 PLATFORM_LIBS := $(filter-out %/lib.a, $(filter-out -lgcc, $(PLATFORM_LIBS))) $(PLATFORM_LIBGCC)
114 endif
115
116 u-boot-spl-init := $(head-y)
117 u-boot-spl-main := $(libs-y)
118 ifdef CONFIG_$(SPL_TPL_)OF_PLATDATA
119 u-boot-spl-platdata := $(obj)/dts/dt-platdata.o
120 endif
121
122 # Linker Script
123 # First test whether there's a linker-script for the specific stage defined...
124 ifneq ($(CONFIG_$(SPL_TPL_)LDSCRIPT),)
125 # need to strip off double quotes
126 LDSCRIPT := $(addprefix $(srctree)/,$(CONFIG_$(SPL_TPL_)LDSCRIPT:"%"=%))
127 else
128 # ...then fall back to the generic SPL linker-script
129 ifneq ($(CONFIG_SPL_LDSCRIPT),)
130 # need to strip off double quotes
131 LDSCRIPT := $(addprefix $(srctree)/,$(CONFIG_SPL_LDSCRIPT:"%"=%))
132 endif
133 endif
134
135 ifeq ($(wildcard $(LDSCRIPT)),)
136         LDSCRIPT := $(srctree)/board/$(BOARDDIR)/u-boot-spl.lds
137 endif
138 ifeq ($(wildcard $(LDSCRIPT)),)
139         LDSCRIPT := $(srctree)/$(CPUDIR)/u-boot-spl.lds
140 endif
141 ifeq ($(wildcard $(LDSCRIPT)),)
142         LDSCRIPT := $(srctree)/arch/$(ARCH)/cpu/u-boot-spl.lds
143 endif
144 ifeq ($(wildcard $(LDSCRIPT)),)
145 $(error could not find linker script)
146 endif
147
148 # Special flags for CPP when processing the linker script.
149 # Pass the version down so we can handle backwards compatibility
150 # on the fly.
151 LDPPFLAGS += \
152         -include $(srctree)/include/u-boot/u-boot.lds.h \
153         -include $(objtree)/include/config.h \
154         -DCPUDIR=$(CPUDIR) \
155         $(shell $(LD) --version | \
156           sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
157
158 # Turn various CONFIG symbols into IMAGE symbols for easy reuse of
159 # the scripts between SPL and TPL.
160 ifneq ($(CONFIG_$(SPL_TPL_)MAX_SIZE),)
161 LDPPFLAGS += -DIMAGE_MAX_SIZE=$(CONFIG_$(SPL_TPL_)MAX_SIZE)
162 endif
163 ifneq ($(CONFIG_$(SPL_TPL_)TEXT_BASE),)
164 LDPPFLAGS += -DIMAGE_TEXT_BASE=$(CONFIG_$(SPL_TPL_)TEXT_BASE)
165 endif
166
167 MKIMAGEOUTPUT ?= /dev/null
168
169 quiet_cmd_mkimage = MKIMAGE $@
170 cmd_mkimage = $(objtree)/tools/mkimage $(MKIMAGEFLAGS_$(@F)) -d $< $@ \
171         >$(MKIMAGEOUTPUT) $(if $(KBUILD_VERBOSE:0=), && cat $(MKIMAGEOUTPUT))
172
173 quiet_cmd_mkfitimage = MKIMAGE $@
174 cmd_mkfitimage = $(objtree)/tools/mkimage $(MKIMAGEFLAGS_$(@F)) -f $(SPL_ITS) -E $@ \
175         $(if $(KBUILD_VERBOSE:1=), MKIMAGEOUTPUT)
176
177 MKIMAGEFLAGS_MLO = -T omapimage -a $(CONFIG_SPL_TEXT_BASE)
178
179 MKIMAGEFLAGS_MLO.byteswap = -T omapimage -n byteswap -a $(CONFIG_SPL_TEXT_BASE)
180
181 MLO MLO.byteswap: $(obj)/u-boot-spl.bin FORCE
182         $(call if_changed,mkimage)
183
184 ifeq ($(CONFIG_SYS_SOC),"at91")
185 MKIMAGEFLAGS_boot.bin = -T atmelimage
186
187 ifeq ($(CONFIG_SPL_GENERATE_ATMEL_PMECC_HEADER),y)
188 MKIMAGEFLAGS_boot.bin += -n $(shell $(obj)/../tools/atmel_pmecc_params)
189
190 $(obj)/boot.bin: $(obj)/../tools/atmel_pmecc_params
191 endif
192
193 $(obj)/boot.bin: $(obj)/u-boot-spl.bin FORCE
194         $(call if_changed,mkimage)
195 else
196 ifdef CONFIG_ARCH_ZYNQ
197 MKIMAGEFLAGS_boot.bin = -T zynqimage -R $(srctree)/$(CONFIG_BOOT_INIT_FILE)
198 endif
199 ifdef CONFIG_ARCH_ZYNQMP
200 ifneq ($(CONFIG_PMUFW_INIT_FILE),"")
201 spl/boot.bin: zynqmp-check-pmufw
202 zynqmp-check-pmufw: FORCE
203         ( cd $(srctree) && test -r $(CONFIG_PMUFW_INIT_FILE) ) \
204                 || ( echo "Cannot read $(CONFIG_PMUFW_INIT_FILE)" && false )
205 endif
206 MKIMAGEFLAGS_boot.bin = -T zynqmpimage -R $(srctree)/$(CONFIG_BOOT_INIT_FILE) \
207         -n "$(shell cd $(srctree); readlink -f $(CONFIG_PMUFW_INIT_FILE))"
208 endif
209
210 $(obj)/$(SPL_BIN)-align.bin: $(obj)/$(SPL_BIN).bin
211         @dd if=$< of=$@ conv=block,sync bs=4 2>/dev/null;
212
213 spl/boot.bin: $(obj)/$(SPL_BIN)-align.bin FORCE
214         $(call if_changed,mkimage)
215 endif
216
217 INPUTS-y        += $(obj)/$(SPL_BIN).bin $(obj)/$(SPL_BIN).sym
218
219 ifdef CONFIG_SAMSUNG
220 INPUTS-y        += $(obj)/$(BOARD)-spl.bin
221 endif
222
223 ifneq ($(CONFIG_TARGET_SOCFPGA_GEN5)$(CONFIG_TARGET_SOCFPGA_ARRIA10),)
224 INPUTS-y        += $(obj)/$(SPL_BIN).sfp
225 endif
226
227 ifdef CONFIG_ARCH_SUNXI
228 INPUTS-y        += $(obj)/sunxi-spl.bin
229
230 ifdef CONFIG_NAND_SUNXI
231 INPUTS-y        += $(obj)/sunxi-spl-with-ecc.bin
232 endif
233 endif
234
235 ifeq ($(CONFIG_SYS_SOC),"at91")
236 INPUTS-y        += $(obj)/boot.bin
237 endif
238
239 ifdef CONFIG_TPL_BUILD
240 INPUTS-$(CONFIG_TPL_X86_16BIT_INIT) += $(obj)/u-boot-x86-start16-tpl.bin \
241         $(obj)/u-boot-x86-reset16-tpl.bin
242 else
243 INPUTS-$(CONFIG_SPL_X86_16BIT_INIT) += $(obj)/u-boot-x86-start16-spl.bin \
244         $(obj)/u-boot-x86-reset16-spl.bin
245 endif
246
247 INPUTS-$(CONFIG_ARCH_ZYNQ)              += $(obj)/boot.bin
248 INPUTS-$(CONFIG_ARCH_ZYNQMP)    += $(obj)/boot.bin
249
250 INPUTS-$(CONFIG_ARCH_MEDIATEK)  += $(obj)/u-boot-spl-mtk.bin
251
252 all:    $(INPUTS-y)
253
254 quiet_cmd_cat = CAT     $@
255 cmd_cat = cat $(filter-out $(PHONY), $^) > $@
256
257 quiet_cmd_copy = COPY    $@
258       cmd_copy = cp $< $@
259
260 ifneq ($(CONFIG_SPL_MULTI_DTB_FIT),y)
261 FINAL_DTB_CONTAINER = $(obj)/$(SPL_BIN).dtb
262 else ifeq ($(CONFIG_SPL_MULTI_DTB_FIT_LZO),y)
263 FINAL_DTB_CONTAINER = $(obj)/$(SPL_BIN).multidtb.fit.lzo
264 else ifeq ($(CONFIG_SPL_MULTI_DTB_FIT_GZIP),y)
265 FINAL_DTB_CONTAINER = $(obj)/$(SPL_BIN).multidtb.fit.gz
266 else
267 FINAL_DTB_CONTAINER = $(obj)/$(SPL_BIN).multidtb.fit
268 endif
269
270 # Build the .dtb file if:
271 #   - we are not using OF_PLATDATA
272 #   - we are using OF_CONTROL
273 #   - we have either OF_SEPARATE or OF_HOSTFILE
274 build_dtb :=
275 ifeq ($(CONFIG_$(SPL_TPL_)OF_PLATDATA),)
276 ifneq ($(CONFIG_$(SPL_TPL_)OF_CONTROL),)
277 ifeq ($(CONFIG_OF_SEPARATE)$(CONFIG_OF_HOSTFILE),y)
278 build_dtb := y
279 endif
280 endif
281 endif
282
283 ifneq ($(build_dtb),)
284 $(obj)/$(SPL_BIN)-dtb.bin: $(obj)/$(SPL_BIN)-nodtb.bin \
285                 $(if $(CONFIG_SPL_SEPARATE_BSS),,$(obj)/$(SPL_BIN)-pad.bin) \
286                 $(FINAL_DTB_CONTAINER)  FORCE
287         $(call if_changed,cat)
288
289 $(obj)/$(SPL_BIN).bin: $(obj)/$(SPL_BIN)-dtb.bin FORCE
290         $(call if_changed,copy)
291 else
292 $(obj)/$(SPL_BIN).bin: $(obj)/$(SPL_BIN)-nodtb.bin FORCE
293         $(call if_changed,copy)
294 endif
295
296 # Create a file that pads from the end of u-boot-spl-nodtb.bin to bss_end
297 $(obj)/$(SPL_BIN)-pad.bin: $(obj)/$(SPL_BIN)
298         @bss_size_str=$(shell $(NM) $< | awk 'BEGIN {size = 0} /__bss_size/ {size = $$1} END {print "ibase=16; " toupper(size)}' | bc); \
299         dd if=/dev/zero of=$@ bs=1 count=$${bss_size_str} 2>/dev/null;
300
301 $(obj)/$(SPL_BIN).dtb: dts/dt-spl.dtb FORCE
302         $(call if_changed,copy)
303
304 pythonpath = PYTHONPATH=scripts/dtc/pylibfdt
305
306 quiet_cmd_dtocc = DTOC C  $@
307 cmd_dtocc = $(pythonpath) $(srctree)/tools/dtoc/dtoc -d $(obj)/$(SPL_BIN).dtb -o $@ platdata
308
309 quiet_cmd_dtoch = DTOC H  $@
310 cmd_dtoch = $(pythonpath) $(srctree)/tools/dtoc/dtoc -d $(obj)/$(SPL_BIN).dtb -o $@ struct
311
312 quiet_cmd_plat = PLAT    $@
313 cmd_plat = $(CC) $(c_flags) -c $< -o $(filter-out $(PHONY),$@)
314
315 targets += $(obj)/dts/dt-platdata.o
316 $(obj)/dts/dt-platdata.o: $(obj)/dts/dt-platdata.c \
317                 include/generated/dt-structs-gen.h prepare FORCE
318         $(call if_changed,plat)
319
320 PHONY += dts_dir
321 dts_dir:
322         $(shell [ -d $(obj)/dts ] || mkdir -p $(obj)/dts)
323
324 include/generated/dt-structs-gen.h: $(obj)/$(SPL_BIN).dtb dts_dir FORCE
325         $(call if_changed,dtoch)
326
327 $(obj)/dts/dt-platdata.c: $(obj)/$(SPL_BIN).dtb dts_dir FORCE
328         $(call if_changed,dtocc)
329
330 ifdef CONFIG_SAMSUNG
331 ifdef CONFIG_VAR_SIZE_SPL
332 VAR_SIZE_PARAM = --vs
333 else
334 VAR_SIZE_PARAM =
335 endif
336 $(obj)/$(BOARD)-spl.bin: $(obj)/u-boot-spl.bin
337         $(if $(wildcard $(objtree)/spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl),\
338         $(objtree)/spl/board/samsung/$(BOARD)/tools/mk$(BOARD)spl,\
339         $(objtree)/tools/mkexynosspl) $(VAR_SIZE_PARAM) $< $@
340 endif
341
342 quiet_cmd_objcopy = OBJCOPY $@
343 cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS_$(@F)) $< $@
344
345 OBJCOPYFLAGS_$(SPL_BIN)-nodtb.bin = $(SPL_OBJCFLAGS) -O binary \
346                 $(if $(CONFIG_$(SPL_TPL_)X86_16BIT_INIT),-R .start16 -R .resetvec)
347
348 $(obj)/$(SPL_BIN)-nodtb.bin: $(obj)/$(SPL_BIN) FORCE
349         $(call if_changed,objcopy)
350
351 OBJCOPYFLAGS_u-boot-x86-start16-spl.bin := -O binary -j .start16
352 $(obj)/u-boot-x86-start16-spl.bin: $(obj)/u-boot-spl FORCE
353         $(call if_changed,objcopy)
354
355 OBJCOPYFLAGS_u-boot-x86-start16-tpl.bin := -O binary -j .start16
356 $(obj)/u-boot-x86-start16-tpl.bin: $(obj)/u-boot-tpl FORCE
357         $(call if_changed,objcopy)
358
359 OBJCOPYFLAGS_u-boot-x86-reset16-spl.bin := -O binary -j .resetvec
360 $(obj)/u-boot-x86-reset16-spl.bin: $(obj)/u-boot-spl FORCE
361         $(call if_changed,objcopy)
362
363 OBJCOPYFLAGS_u-boot-x86-reset16-tpl.bin := -O binary -j .resetvec
364 $(obj)/u-boot-x86-reset16-tpl.bin: $(obj)/u-boot-tpl FORCE
365         $(call if_changed,objcopy)
366
367 LDFLAGS_$(SPL_BIN) += -T u-boot-spl.lds $(LDFLAGS_FINAL)
368
369 # Avoid 'Not enough room for program headers' error on binutils 2.28 onwards.
370 LDFLAGS_$(SPL_BIN) += $(call ld-option, --no-dynamic-linker)
371
372 # Pick the best-match (i.e. SPL_TEXT_BASE for SPL, TPL_TEXT_BASE for TPL)
373 ifneq ($(CONFIG_$(SPL_TPL_)TEXT_BASE),)
374 LDFLAGS_$(SPL_BIN) += -Ttext $(CONFIG_$(SPL_TPL_)TEXT_BASE)
375 endif
376
377 ifdef CONFIG_TARGET_SOCFPGA_ARRIA10
378 MKIMAGEFLAGS_$(SPL_BIN).sfp = -T socfpgaimage_v1
379 else
380 MKIMAGEFLAGS_$(SPL_BIN).sfp = -T socfpgaimage
381 endif
382 $(obj)/$(SPL_BIN).sfp: $(obj)/$(SPL_BIN).bin FORCE
383         $(call if_changed,mkimage)
384
385 quiet_cmd_mksunxiboot = MKSUNXI $@
386 cmd_mksunxiboot = $(objtree)/tools/mksunxiboot \
387                         --default-dt $(CONFIG_DEFAULT_DEVICE_TREE) $< $@
388 $(obj)/sunxi-spl.bin: $(obj)/$(SPL_BIN).bin FORCE
389         $(call if_changed,mksunxiboot)
390
391 quiet_cmd_sunxi_spl_image_builder = SUNXI_SPL_IMAGE_BUILDER $@
392 cmd_sunxi_spl_image_builder = $(objtree)/tools/sunxi-spl-image-builder \
393                                 -c $(CONFIG_NAND_SUNXI_SPL_ECC_STRENGTH)/$(CONFIG_NAND_SUNXI_SPL_ECC_SIZE) \
394                                 -p $(CONFIG_SYS_NAND_PAGE_SIZE) \
395                                 -o $(CONFIG_SYS_NAND_OOBSIZE) \
396                                 -u $(CONFIG_NAND_SUNXI_SPL_USABLE_PAGE_SIZE) \
397                                 -e $(CONFIG_SYS_NAND_BLOCK_SIZE) \
398                                 -s -b $< $@
399 $(obj)/sunxi-spl-with-ecc.bin: $(obj)/sunxi-spl.bin
400         $(call if_changed,sunxi_spl_image_builder)
401
402
403 # MediaTek's specific SPL build
404 MKIMAGEFLAGS_u-boot-spl-mtk.bin = -T mtk_image \
405         -a $(CONFIG_SPL_TEXT_BASE) -e $(CONFIG_SPL_TEXT_BASE) \
406         -n "$(patsubst "%",%,$(CONFIG_MTK_BROM_HEADER_INFO))"
407
408 $(obj)/u-boot-spl-mtk.bin: $(obj)/u-boot-spl.bin FORCE
409         $(call if_changed,mkimage)
410
411 quiet_cmd_sym ?= SYM     $@
412       cmd_sym ?= $(OBJDUMP) -t $< > $@
413 $(obj)/$(SPL_BIN).sym: $(obj)/$(SPL_BIN) FORCE
414         $(call if_changed,sym)
415
416 # Rule to link u-boot-spl
417 # May be overridden by arch/$(ARCH)/config.mk
418 quiet_cmd_u-boot-spl ?= LD      $@
419       cmd_u-boot-spl ?= (cd $(obj) && $(LD) $(KBUILD_LDFLAGS) $(LDFLAGS_$(@F)) \
420                        $(patsubst $(obj)/%,%,$(u-boot-spl-init)) --start-group \
421                        $(patsubst $(obj)/%,%,$(u-boot-spl-main))  \
422                        $(patsubst $(obj)/%,%,$(u-boot-spl-platdata)) \
423                        --end-group \
424                        $(PLATFORM_LIBS) -Map $(SPL_BIN).map -o $(SPL_BIN))
425
426 $(obj)/$(SPL_BIN): $(u-boot-spl-platdata) $(u-boot-spl-init) \
427                 $(u-boot-spl-main) $(obj)/u-boot-spl.lds FORCE
428         $(call if_changed,u-boot-spl)
429
430 $(sort $(u-boot-spl-init) $(u-boot-spl-main)): $(u-boot-spl-dirs) ;
431
432 PHONY += $(u-boot-spl-dirs)
433 $(u-boot-spl-dirs): $(u-boot-spl-platdata) prepare
434         $(Q)$(MAKE) $(build)=$@
435
436 PHONY += prepare
437 prepare:
438         $(Q)$(MAKE) $(build)=$(obj)/.
439
440 quiet_cmd_cpp_lds = LDS     $@
441 cmd_cpp_lds = $(CPP) -Wp,-MD,$(depfile) $(cpp_flags) $(LDPPFLAGS) -ansi \
442                 -D__ASSEMBLY__ -x assembler-with-cpp -std=c99 -P -o $@ $<
443
444 $(obj)/u-boot-spl.lds: $(LDSCRIPT) FORCE
445         $(call if_changed_dep,cpp_lds)
446
447 # read all saved command lines
448
449 targets := $(wildcard $(sort $(targets)))
450 cmd_files := $(wildcard $(obj)/.*.cmd $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
451
452 ifneq ($(cmd_files),)
453   $(cmd_files): ;       # Do not try to update included dependency files
454   include $(cmd_files)
455 endif
456
457 PHONY += FORCE
458 FORCE:
459
460 PHONY += dtbs
461 dtbs:
462         $(Q)$(MAKE) $(build)=dts dtbs
463
464 # Declare the contents of the .PHONY variable as phony.  We keep that
465 # information in a variable so we can use it in if_changed and friends.
466 .PHONY: $(PHONY)
467
468 SPL_OF_LIST_TARGETS = $(patsubst %,dts/%.dtb,$(subst ",,$(CONFIG_SPL_OF_LIST)))
469 SHRUNK_ARCH_DTB = $(addprefix $(obj)/,$(SPL_OF_LIST_TARGETS))
470 .SECONDEXPANSION:
471 $(SHRUNK_ARCH_DTB): $$(patsubst $(obj)/dts/%, arch/$(ARCH)/dts/%, $$@) dts_dir
472         $(call if_changed,fdtgrep)
473
474 targets += $(SPL_OF_LIST_TARGETS)
475
476 MKIMAGEFLAGS_$(SPL_BIN).multidtb.fit = -f auto -A $(ARCH) -T firmware -C none -O u-boot \
477         -n "Multi DTB fit image for $(SPL_BIN)" -E \
478         $(patsubst %,-b %,$(SHRUNK_ARCH_DTB))
479
480 $(obj)/$(SPL_BIN).multidtb.fit: /dev/null $(SHRUNK_ARCH_DTB) FORCE
481         $(call if_changed,mkimage)
482 ifneq ($(SOURCE_DATE_EPOCH),)
483         touch -d @$(SOURCE_DATE_EPOCH) $(obj)/$(SPL_BIN).multidtb.fit
484         chmod 0600 $(obj)/$(SPL_BIN).multidtb.fit
485 endif
486
487 $(obj)/$(SPL_BIN).multidtb.fit.gz: $(obj)/$(SPL_BIN).multidtb.fit
488         @gzip -kf9 $< > $@
489
490 $(obj)/$(SPL_BIN).multidtb.fit.lzo: $(obj)/$(SPL_BIN).multidtb.fit
491         @lzop -f9 $< > $@
492
493 ifdef CONFIG_ARCH_K3
494 tispl.bin: $(obj)/u-boot-spl-nodtb.bin $(SHRUNK_ARCH_DTB) $(SPL_ITS) FORCE
495         $(call if_changed,mkfitimage)
496 endif