blob: 94967cf656ca7f8492a6ebd8ec6ab7fc2b0d51e5 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001# SPDX-License-Identifier: GPL-2.0+
Simon Glass38d6b8d2011-10-15 05:48:21 +00002#
3# Copyright (c) 2011 The Chromium OS Authors.
Simon Glass38d6b8d2011-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 Yamada43c08932014-02-05 11:28:25 +09008DEVICE_TREE ?= $(CONFIG_DEFAULT_DEVICE_TREE:"%"=%)
9ifeq ($(DEVICE_TREE),)
Masahiro Yamadae7a579f2014-02-05 11:28:27 +090010DEVICE_TREE := unset
Masahiro Yamada43c08932014-02-05 11:28:25 +090011endif
Stephen Warrenc198ef72013-07-24 10:09:19 -070012
Simon Glassc3b0de42014-06-12 07:24:43 -060013ifneq ($(EXT_DTB),)
14DTB := $(EXT_DTB)
Simon Glass67bce6b2014-06-02 22:04:50 -060015else
Masahiro Yamada43fa91f2019-03-14 14:58:36 +090016DTB := arch/$(ARCH)/dts/$(DEVICE_TREE).dtb
Simon Glass67bce6b2014-06-02 22:04:50 -060017endif
Stephen Warrenc198ef72013-07-24 10:09:19 -070018
Simon Glass6886c722020-12-22 19:30:15 -070019$(obj)/dt-$(SPL_NAME).dtb: dts/dt.dtb $(objtree)/tools/fdtgrep FORCE
Simon Glassc490de82020-12-22 19:30:14 -070020 mkdir -p $(dir $@)
Goldschmidt Simon5e7a1c22017-11-21 12:29:56 +000021 $(call if_changed,fdtgrep)
22
Anatolij Gustschin08568342020-01-12 15:57:42 +010023ifeq ($(CONFIG_OF_DTB_PROPS_REMOVE),y)
24$(obj)/dt.dtb: $(DTB) $(objtree)/tools/fdtgrep FORCE
25 $(call if_changed,fdt_rm_props)
26else
Masahiro Yamadae7a579f2014-02-05 11:28:27 +090027$(obj)/dt.dtb: $(DTB) FORCE
Masahiro Yamada97e101c2014-06-04 10:11:18 +090028 $(call if_changed,shipped)
Anatolij Gustschin08568342020-01-12 15:57:42 +010029endif
Simon Glass38d6b8d2011-10-15 05:48:21 +000030
Simon Glass6886c722020-12-22 19:30:15 -070031targets += dt.dtb
Simon Glass38d6b8d2011-10-15 05:48:21 +000032
Masahiro Yamada43fa91f2019-03-14 14:58:36 +090033$(DTB): arch-dtbs
Masahiro Yamadae7a579f2014-02-05 11:28:27 +090034 $(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
Stephen Warrend2d742c2019-02-26 12:20:25 -070042PHONY += arch-dtbs
Masahiro Yamadae7a579f2014-02-05 11:28:27 +090043arch-dtbs:
Masahiro Yamada43fa91f2019-03-14 14:58:36 +090044 $(Q)$(MAKE) $(build)=arch/$(ARCH)/dts dtbs
Simon Glass38d6b8d2011-10-15 05:48:21 +000045
Goldschmidt Simon5e7a1c22017-11-21 12:29:56 +000046ifeq ($(CONFIG_SPL_BUILD),y)
47obj-$(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)
51else
Masahiro Yamada43c08932014-02-05 11:28:25 +090052obj-$(CONFIG_OF_EMBED) := dt.dtb.o
Goldschmidt Simon5e7a1c22017-11-21 12:29:56 +000053endif
Simon Glass38d6b8d2011-10-15 05:48:21 +000054
Simon Glass6886c722020-12-22 19:30:15 -070055# Target for U-Boot proper
56dtbs: $(obj)/dt.dtb
Masahiro Yamada43c08932014-02-05 11:28:25 +090057 @:
Simon Glass38d6b8d2011-10-15 05:48:21 +000058
Simon Glass6886c722020-12-22 19:30:15 -070059# Target for SPL/TPL
60spl_dtbs: $(obj)/dt-$(SPL_NAME).dtb
61 @:
62
63clean-files := dt.dtb.S
Masahiro Yamadae7a579f2014-02-05 11:28:27 +090064
65# Let clean descend into dts directories
Lukas Auerbad1b5e2018-11-22 11:26:11 +010066subdir- += ../arch/arm/dts ../arch/microblaze/dts ../arch/mips/dts ../arch/sandbox/dts ../arch/x86/dts ../arch/powerpc/dts ../arch/riscv/dts