Merge tag 'doc-2023-10-rc5-3' of https://source.denx.de/u-boot/custodians/u-boot-efi
[platform/kernel/u-boot.git] / dts / Makefile
1 # SPDX-License-Identifier: GPL-2.0+
2 #
3 # Copyright (c) 2011 The Chromium OS Authors.
4
5 # This Makefile builds the internal U-Boot fdt if CONFIG_OF_CONTROL is
6 # enabled. See doc/README.fdt-control for more details.
7
8 DEVICE_TREE ?= $(CONFIG_DEFAULT_DEVICE_TREE:"%"=%)
9 ifeq ($(DEVICE_TREE),)
10 DEVICE_TREE := unset
11 endif
12
13 ifneq ($(EXT_DTB),)
14 DTB := $(EXT_DTB)
15 else
16 DTB := arch/$(ARCH)/dts/$(DEVICE_TREE).dtb
17 endif
18
19 $(obj)/dt-$(SPL_NAME).dtb: dts/dt.dtb $(objtree)/tools/fdtgrep FORCE
20         mkdir -p $(dir $@)
21         $(call if_changed,fdtgrep)
22
23 ifeq ($(CONFIG_OF_DTB_PROPS_REMOVE),y)
24 $(obj)/dt.dtb: $(DTB) $(objtree)/tools/fdtgrep FORCE
25         $(call if_changed,fdt_rm_props)
26 else
27 $(obj)/dt.dtb: $(DTB) FORCE
28         $(call if_changed,shipped)
29 endif
30
31 targets += dt.dtb
32
33 $(DTB): arch-dtbs
34         $(Q)test -e $@ || (                                             \
35         echo >&2;                                                       \
36         echo >&2 "Device Tree Source ($@) is not correctly specified."; \
37         echo >&2 "Please define 'CONFIG_DEFAULT_DEVICE_TREE'";          \
38         echo >&2 "or build with 'DEVICE_TREE=<device_tree>' argument";  \
39         echo >&2;                                                       \
40         /bin/false)
41
42 PHONY += arch-dtbs
43 arch-dtbs:
44         $(Q)$(MAKE) $(build)=arch/$(ARCH)/dts dtbs
45
46 ifeq ($(CONFIG_SPL_BUILD),y)
47 obj-$(CONFIG_OF_EMBED) := dt-spl.dtb.o
48 # support "out-of-tree" build for dtb-spl
49 $(obj)/dt-spl.dtb.o: $(obj)/dt-spl.dtb.S FORCE
50         $(call if_changed_dep,as_o_S)
51 else
52 obj-$(CONFIG_OF_EMBED) := dt.dtb.o
53 endif
54
55 # Target for U-Boot proper
56 dtbs: $(obj)/dt.dtb
57         @:
58
59 # Target for SPL/TPL
60 spl_dtbs: $(obj)/dt-$(SPL_NAME).dtb
61         @:
62
63 clean-files := dt.dtb.S
64
65 # Let clean descend into dts directories
66 subdir- += ../arch/arc/dts ../arch/arm/dts ../arch/m68k/dts ../arch/microblaze/dts      \
67            ../arch/mips/dts ../arch/nios2/dts ../arch/powerpc/dts ../arch/riscv/dts     \
68            ../arch/sandbox/dts ../arch/sh/dts ../arch/x86/dts ../arch/xtensa/dts