xref: /openbmc/u-boot/dts/Makefile (revision 2737dfe0)
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
8DEVICE_TREE ?= $(CONFIG_DEFAULT_DEVICE_TREE:"%"=%)
9ifeq ($(DEVICE_TREE),)
10DEVICE_TREE := unset
11endif
12
13ARCH_PATH := arch/$(ARCH)/dts
14dtb_depends := arch-dtbs
15
16ifneq ($(EXT_DTB),)
17DTB := $(EXT_DTB)
18else
19DTB := $(ARCH_PATH)/$(DEVICE_TREE).dtb
20dtb_depends += $(DTB:.dtb=.dts)
21endif
22
23$(obj)/dt-spl.dtb: $(DTB) $(objtree)/tools/fdtgrep FORCE
24	$(call if_changed,fdtgrep)
25
26$(obj)/dt.dtb: $(DTB) FORCE
27	$(call if_changed,shipped)
28
29targets += dt.dtb dt-spl.dtb
30
31$(DTB): $(dtb_depends)
32ifeq ($(EXT_DTB),)
33	$(Q)$(MAKE) $(build)=$(ARCH_PATH) $@
34endif
35	$(Q)test -e $@ || (						\
36	echo >&2;							\
37	echo >&2 "Device Tree Source is not correctly specified.";	\
38	echo >&2 "Please define 'CONFIG_DEFAULT_DEVICE_TREE'";		\
39	echo >&2 "or build with 'DEVICE_TREE=<device_tree>' argument";	\
40	echo >&2;							\
41	/bin/false)
42
43PHONY += arch-dtbs
44arch-dtbs:
45	$(Q)$(MAKE) $(build)=$(ARCH_PATH) dtbs
46
47ifeq ($(CONFIG_SPL_BUILD),y)
48obj-$(CONFIG_OF_EMBED) := dt-spl.dtb.o
49# support "out-of-tree" build for dtb-spl
50$(obj)/dt-spl.dtb.o: $(obj)/dt-spl.dtb.S FORCE
51	$(call if_changed_dep,as_o_S)
52else
53obj-$(CONFIG_OF_EMBED) := dt.dtb.o
54endif
55
56dtbs: $(obj)/dt.dtb $(obj)/dt-spl.dtb
57	@:
58
59clean-files := dt.dtb.S dt-spl.dtb.S
60
61# Let clean descend into dts directories
62subdir- += ../arch/arm/dts ../arch/microblaze/dts ../arch/mips/dts ../arch/sandbox/dts ../arch/x86/dts ../arch/powerpc/dts ../arch/riscv/dts
63