blob: 1f83e615e8aa9a07c97e6589a6ae87e25a874569 [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
Masahiro Yamada3284c8b2014-02-05 11:28:27 +090022$(obj)/dt.dtb: $(DTB) FORCE
Masahiro Yamadab9d1dbd2014-06-04 10:11:18 +090023 $(call if_changed,shipped)
Simon Glassbbb0b122011-10-15 05:48:21 +000024
Goldschmidt Simon9bd76b82017-11-21 12:29:56 +000025targets += dt.dtb dt-spl.dtb
Simon Glassbbb0b122011-10-15 05:48:21 +000026
Masahiro Yamadaa3444bd2019-03-14 14:58:36 +090027$(DTB): arch-dtbs
Masahiro Yamada3284c8b2014-02-05 11:28:27 +090028 $(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
Stephen Warren2737dfe2019-02-26 12:20:25 -070036PHONY += arch-dtbs
Masahiro Yamada3284c8b2014-02-05 11:28:27 +090037arch-dtbs:
Masahiro Yamadaa3444bd2019-03-14 14:58:36 +090038 $(Q)$(MAKE) $(build)=arch/$(ARCH)/dts dtbs
Masahiro Yamada6ab6b2a2014-02-05 11:28:25 +090039
Goldschmidt Simon9bd76b82017-11-21 12:29:56 +000040ifeq ($(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
Masahiro Yamada6ab6b2a2014-02-05 11:28:25 +090046obj-$(CONFIG_OF_EMBED) := dt.dtb.o
Goldschmidt Simon9bd76b82017-11-21 12:29:56 +000047endif
Masahiro Yamada6ab6b2a2014-02-05 11:28:25 +090048
Goldschmidt Simon9bd76b82017-11-21 12:29:56 +000049dtbs: $(obj)/dt.dtb $(obj)/dt-spl.dtb
Masahiro Yamada6ab6b2a2014-02-05 11:28:25 +090050 @:
51
Goldschmidt Simon9bd76b82017-11-21 12:29:56 +000052clean-files := dt.dtb.S dt-spl.dtb.S
Masahiro Yamada3284c8b2014-02-05 11:28:27 +090053
54# Let clean descend into dts directories
Lukas Auer17f2ffe2018-11-22 11:26:11 +010055subdir- += ../arch/arm/dts ../arch/microblaze/dts ../arch/mips/dts ../arch/sandbox/dts ../arch/x86/dts ../arch/powerpc/dts ../arch/riscv/dts