2011-10-15 05:48:21 +00:00
|
|
|
#
|
|
|
|
# Copyright (c) 2011 The Chromium OS Authors.
|
|
|
|
#
|
2013-07-08 07:37:19 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0+
|
2011-10-15 05:48:21 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
# This Makefile builds the internal U-Boot fdt if CONFIG_OF_CONTROL is
|
|
|
|
# enabled. See doc/README.fdt-control for more details.
|
|
|
|
|
|
|
|
include $(TOPDIR)/config.mk
|
|
|
|
|
|
|
|
LIB = $(obj)libdts.o
|
|
|
|
|
2013-02-28 10:20:18 +00:00
|
|
|
ifeq ($(DEVICE_TREE),)
|
2011-10-15 05:48:21 +00:00
|
|
|
$(if $(CONFIG_DEFAULT_DEVICE_TREE),,\
|
|
|
|
$(error Please define CONFIG_DEFAULT_DEVICE_TREE in your board header file))
|
|
|
|
DEVICE_TREE = $(subst ",,$(CONFIG_DEFAULT_DEVICE_TREE))
|
2013-02-28 10:20:18 +00:00
|
|
|
endif
|
2011-10-15 05:48:21 +00:00
|
|
|
|
|
|
|
$(if $(CONFIG_ARCH_DEVICE_TREE),,\
|
|
|
|
$(error Your architecture does not have device tree support enabled. \
|
|
|
|
Please define CONFIG_ARCH_DEVICE_TREE))
|
|
|
|
|
|
|
|
# We preprocess the device tree file provide a useful define
|
2013-01-08 16:07:54 +00:00
|
|
|
DTS_CPPFLAGS := -x assembler-with-cpp \
|
2012-07-13 03:03:40 +00:00
|
|
|
-DARCH_CPU_DTS=\"$(SRCTREE)/arch/$(ARCH)/dts/$(CONFIG_ARCH_DEVICE_TREE).dtsi\" \
|
2013-02-21 12:31:27 +00:00
|
|
|
-DBOARD_DTS=\"$(SRCTREE)/board/$(VENDOR)/$(BOARD)/dts/$(DEVICE_TREE).dts\" \
|
|
|
|
-I$(SRCTREE)/board/$(VENDOR)/dts -I$(SRCTREE)/arch/$(ARCH)/dts
|
2011-10-15 05:48:21 +00:00
|
|
|
|
|
|
|
all: $(obj).depend $(LIB)
|
|
|
|
|
|
|
|
# Use a constant name for this so we can access it from C code.
|
|
|
|
# objcopy doesn't seem to allow us to set the symbol name independently of
|
|
|
|
# the filename.
|
|
|
|
DT_BIN := $(obj)dt.dtb
|
|
|
|
|
|
|
|
$(DT_BIN): $(TOPDIR)/board/$(VENDOR)/dts/$(DEVICE_TREE).dts
|
dts/Makefile: simplify dtc invocation
The invocation of dtc is significantly more complex that it could be,
in order to work around an issue on old versions of dtc, which print
a message to stdout every time they run.
Remove this workaround, on the assumption that people have or will
upgrade to a newer version of dtc. This simplifies the build rule
significantly.
Related, split the invocation of cpp and dtc into separate commands
rather than a pipeline, so that if either fail, it is detected. This has
the nice benefit of saving off the result of the pre-processing step,
allowing it to be easily inspected.
Assuming a new enough dtc (which an earlier patch enforces), dtc will
parse #line directives in its input file, and generate correct file and
line numbers in error messages, even though cpp is unconditionally
applied to its input file.
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: Simon Glass <sjg@chromium.org>
2013-07-24 17:09:18 +00:00
|
|
|
$(CPP) -P $(DTS_CPPFLAGS) $< -o $(DT_BIN).dts.tmp
|
|
|
|
$(DTC) -R 4 -p 0x1000 -O dtb -o ${DT_BIN} $(DT_BIN).dts.tmp
|
2011-10-15 05:48:21 +00:00
|
|
|
|
|
|
|
process_lds = \
|
|
|
|
$(1) | sed -r -n 's/^OUTPUT_$(2)[ ("]*([^")]*).*/\1/p'
|
|
|
|
|
|
|
|
# Run the compiler and get the link script from the linker
|
|
|
|
GET_LDS = $(CC) $(CFLAGS) $(LDFLAGS) -Wl,--verbose 2>&1
|
|
|
|
|
|
|
|
$(obj)dt.o: $(DT_BIN)
|
|
|
|
# We want the output format and arch.
|
|
|
|
# We also hope to win a prize for ugliest Makefile / shell interaction
|
|
|
|
# We look in the LDSCRIPT first.
|
|
|
|
# Then try the linker which should give us the answer.
|
|
|
|
# Then check it worked.
|
2012-07-12 02:58:32 +00:00
|
|
|
[ -n "$(LDSCRIPT)" ] && \
|
|
|
|
oformat=`$(call process_lds,cat $(LDSCRIPT),FORMAT)` && \
|
|
|
|
oarch=`$(call process_lds,cat $(LDSCRIPT),ARCH)` ;\
|
2011-10-15 05:48:21 +00:00
|
|
|
\
|
|
|
|
[ -z $${oformat} ] && \
|
|
|
|
oformat=`$(call process_lds,$(GET_LDS),FORMAT)` ;\
|
|
|
|
[ -z $${oarch} ] && \
|
|
|
|
oarch=`$(call process_lds,$(GET_LDS),ARCH)` ;\
|
|
|
|
\
|
|
|
|
[ -z $${oformat} ] && \
|
|
|
|
echo "Cannot read OUTPUT_FORMAT from lds file $(LDSCRIPT)" && \
|
|
|
|
exit 1 || true ;\
|
|
|
|
[ -z $${oarch} ] && \
|
|
|
|
echo "Cannot read OUTPUT_ARCH from lds file $(LDSCRIPT)" && \
|
|
|
|
exit 1 || true ;\
|
|
|
|
\
|
|
|
|
cd $(dir ${DT_BIN}) && \
|
|
|
|
$(OBJCOPY) -I binary -O $${oformat} -B $${oarch} \
|
|
|
|
$(notdir ${DT_BIN}) $@
|
|
|
|
rm $(DT_BIN)
|
|
|
|
|
|
|
|
OBJS-$(CONFIG_OF_EMBED) := dt.o
|
|
|
|
|
|
|
|
COBJS := $(OBJS-y)
|
|
|
|
|
|
|
|
OBJS := $(addprefix $(obj),$(COBJS))
|
|
|
|
|
|
|
|
binary: $(DT_BIN)
|
|
|
|
|
|
|
|
$(LIB): $(OBJS) $(DTB)
|
|
|
|
$(call cmd_link_o_target, $(OBJS))
|
|
|
|
|
|
|
|
#########################################################################
|
|
|
|
|
|
|
|
# defines $(obj).depend target
|
|
|
|
include $(SRCTREE)/rules.mk
|
|
|
|
|
|
|
|
sinclude $(obj).depend
|
|
|
|
|
|
|
|
#########################################################################
|