blob: a20930eb9a5e656bbdedf924e4f754c7da7552e4 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001# SPDX-License-Identifier: GPL-2.0+
Simon Glassbbb0b122011-10-15 05:48:21 +00002#
3# Copyright (c) 2011 The Chromium OS Authors.
Simon Glassbbb0b122011-10-15 05:48:21 +00004
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
Masahiro Yamadaefcf8612014-02-04 17:24:40 +09008DEVICE_TREE ?= $(CONFIG_DEFAULT_DEVICE_TREE:"%"=%)
9ifeq ($(DEVICE_TREE),)
Masahiro Yamada3284c8b2014-02-05 11:28:27 +090010DEVICE_TREE := unset
Masahiro Yamadaefcf8612014-02-04 17:24:40 +090011endif
Simon Glassbbb0b122011-10-15 05:48:21 +000012
Simon Glassd18926a2014-06-12 07:24:43 -060013ifneq ($(EXT_DTB),)
14DTB := $(EXT_DTB)
Simon Glass63b4b5b2014-06-02 22:04:50 -060015else
Masahiro Yamadaa3444bd2019-03-14 14:58:36 +090016DTB := arch/$(ARCH)/dts/$(DEVICE_TREE).dtb
Simon Glass63b4b5b2014-06-02 22:04:50 -060017endif
Simon Glassbbb0b122011-10-15 05:48:21 +000018
Goldschmidt Simon9bd76b82017-11-21 12:29:56 +000019$(obj)/dt-spl.dtb: $(DTB) $(objtree)/tools/fdtgrep FORCE
20 $(call if_changed,fdtgrep)
21
Anatolij Gustschin43b6e382020-01-12 15:57:42 +010022ifeq ($(CONFIG_OF_DTB_PROPS_REMOVE),y)
23$(obj)/dt.dtb: $(DTB) $(objtree)/tools/fdtgrep FORCE
24 $(call if_changed,fdt_rm_props)
25else
Masahiro Yamada3284c8b2014-02-05 11:28:27 +090026$(obj)/dt.dtb: $(DTB) FORCE
Masahiro Yamadab9d1dbd2014-06-04 10:11:18 +090027 $(call if_changed,shipped)
Anatolij Gustschin43b6e382020-01-12 15:57:42 +010028endif
Simon Glassbbb0b122011-10-15 05:48:21 +000029
Goldschmidt Simon9bd76b82017-11-21 12:29:56 +000030targets += dt.dtb dt-spl.dtb
Simon Glassbbb0b122011-10-15 05:48:21 +000031
Masahiro Yamadaa3444bd2019-03-14 14:58:36 +090032$(DTB): arch-dtbs
Masahiro Yamada3284c8b2014-02-05 11:28:27 +090033 $(Q)test -e $@ || ( \
34 echo >&2; \
35 echo >&2 "Device Tree Source is not correctly specified."; \
36 echo >&2 "Please define 'CONFIG_DEFAULT_DEVICE_TREE'"; \
37 echo >&2 "or build with 'DEVICE_TREE=<device_tree>' argument"; \
38 echo >&2; \
39 /bin/false)
40
Stephen Warren2737dfe2019-02-26 12:20:25 -070041PHONY += arch-dtbs
Masahiro Yamada3284c8b2014-02-05 11:28:27 +090042arch-dtbs:
Masahiro Yamadaa3444bd2019-03-14 14:58:36 +090043 $(Q)$(MAKE) $(build)=arch/$(ARCH)/dts dtbs
Masahiro Yamada6ab6b2a2014-02-05 11:28:25 +090044
Goldschmidt Simon9bd76b82017-11-21 12:29:56 +000045ifeq ($(CONFIG_SPL_BUILD),y)
46obj-$(CONFIG_OF_EMBED) := dt-spl.dtb.o
47# support "out-of-tree" build for dtb-spl
48$(obj)/dt-spl.dtb.o: $(obj)/dt-spl.dtb.S FORCE
49 $(call if_changed_dep,as_o_S)
50else
Masahiro Yamada6ab6b2a2014-02-05 11:28:25 +090051obj-$(CONFIG_OF_EMBED) := dt.dtb.o
Goldschmidt Simon9bd76b82017-11-21 12:29:56 +000052endif
Masahiro Yamada6ab6b2a2014-02-05 11:28:25 +090053
Goldschmidt Simon9bd76b82017-11-21 12:29:56 +000054dtbs: $(obj)/dt.dtb $(obj)/dt-spl.dtb
Masahiro Yamada6ab6b2a2014-02-05 11:28:25 +090055 @:
56
Goldschmidt Simon9bd76b82017-11-21 12:29:56 +000057clean-files := dt.dtb.S dt-spl.dtb.S
Masahiro Yamada3284c8b2014-02-05 11:28:27 +090058
59# Let clean descend into dts directories
Lukas Auer17f2ffe2018-11-22 11:26:11 +010060subdir- += ../arch/arm/dts ../arch/microblaze/dts ../arch/mips/dts ../arch/sandbox/dts ../arch/x86/dts ../arch/powerpc/dts ../arch/riscv/dts