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