]> git.ipfire.org Git - u-boot.git/blame - dts/Makefile
kernel-doc: fix some errors
[u-boot.git] / dts / Makefile
CommitLineData
bbb0b128
SG
1#
2# Copyright (c) 2011 The Chromium OS Authors.
3#
1a459660 4# SPDX-License-Identifier: GPL-2.0+
bbb0b128
SG
5#
6
7# This Makefile builds the internal U-Boot fdt if CONFIG_OF_CONTROL is
8# enabled. See doc/README.fdt-control for more details.
9
c8391a0e
SW
10DTS_INCDIRS = $(SRCTREE)/board/$(VENDOR)/$(BOARD)/dts
11DTS_INCDIRS += $(SRCTREE)/board/$(VENDOR)/dts
12DTS_INCDIRS += $(SRCTREE)/arch/$(ARCH)/dts
13
f53932ad 14DTS_CPPFLAGS := -x assembler-with-cpp -undef -D__DTS__ \
c8391a0e
SW
15 -nostdinc $(addprefix -I,$(DTS_INCDIRS))
16
17DTC_FLAGS := -R 4 -p 0x1000 \
18 $(addprefix -i ,$(DTS_INCDIRS))
bbb0b128 19
bbb0b128
SG
20# Use a constant name for this so we can access it from C code.
21# objcopy doesn't seem to allow us to set the symbol name independently of
22# the filename.
9e414032 23DT_BIN := $(obj)/dt.dtb
bbb0b128 24
efcf8619
MY
25DEVICE_TREE ?= $(CONFIG_DEFAULT_DEVICE_TREE:"%"=%)
26ifeq ($(DEVICE_TREE),)
27$(DT_BIN): FORCE
28 echo >&2 "Please define CONFIG_DEFAULT_DEVICE_TREE in your board header file"
29else
bbb0b128 30$(DT_BIN): $(TOPDIR)/board/$(VENDOR)/dts/$(DEVICE_TREE).dts
32ac4bd9 31 $(CPP) $(DTS_CPPFLAGS) $< -o $(DT_BIN).dts.tmp
c8391a0e 32 $(DTC) $(DTC_FLAGS) -O dtb -o ${DT_BIN} $(DT_BIN).dts.tmp
efcf8619 33endif
bbb0b128
SG
34
35process_lds = \
36 $(1) | sed -r -n 's/^OUTPUT_$(2)[ ("]*([^")]*).*/\1/p'
37
38# Run the compiler and get the link script from the linker
6825a95b 39GET_LDS = $(CC) $(c_flags) $(ld_flags) -Wl,--verbose 2>&1
bbb0b128 40
9e414032 41$(obj)/dt.o: $(DT_BIN)
bbb0b128
SG
42 # We want the output format and arch.
43 # We also hope to win a prize for ugliest Makefile / shell interaction
44 # We look in the LDSCRIPT first.
45 # Then try the linker which should give us the answer.
46 # Then check it worked.
a4ff4719
HK
47 [ -n "$(LDSCRIPT)" ] && \
48 oformat=`$(call process_lds,cat $(LDSCRIPT),FORMAT)` && \
49 oarch=`$(call process_lds,cat $(LDSCRIPT),ARCH)` ;\
bbb0b128
SG
50 \
51 [ -z $${oformat} ] && \
52 oformat=`$(call process_lds,$(GET_LDS),FORMAT)` ;\
53 [ -z $${oarch} ] && \
54 oarch=`$(call process_lds,$(GET_LDS),ARCH)` ;\
55 \
56 [ -z $${oformat} ] && \
57 echo "Cannot read OUTPUT_FORMAT from lds file $(LDSCRIPT)" && \
58 exit 1 || true ;\
59 [ -z $${oarch} ] && \
60 echo "Cannot read OUTPUT_ARCH from lds file $(LDSCRIPT)" && \
61 exit 1 || true ;\
62 \
63 cd $(dir ${DT_BIN}) && \
64 $(OBJCOPY) -I binary -O $${oformat} -B $${oarch} \
9e414032 65 $(notdir ${DT_BIN}) $(notdir $@)
bbb0b128
SG
66 rm $(DT_BIN)
67
bcfe8fdf 68obj-$(CONFIG_OF_EMBED) := dt.o
bbb0b128
SG
69
70binary: $(DT_BIN)