From f86d9605a58c942133c395c1f978286ae1b7f11c Mon Sep 17 00:00:00 2001 From: Elliot Berman Date: Thu, 15 Oct 2020 10:50:19 -0700 Subject: [PATCH] Makefile: devicetree: Introduce support for out-of-tree dtbs Introduce support to compile devicetree sources out-of-tree. This is useful so that dt-bindings and tools are provided Kbuild. Conflicts: Makefile scripts/Makefile.lib Change-Id: I3c15e43dd132b01d5ea7a4518aa91e809e83eb48 Signed-off-by: Elliot Berman Signed-off-by: Guru Das Srinagesh --- Makefile | 55 ++++++++++++++++++++++++++++++++++++++++++++ scripts/Makefile.lib | 2 +- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 755cf8fc4549..a435d24db30c 100644 --- a/Makefile +++ b/Makefile @@ -1146,6 +1146,61 @@ endif $(Q)$(MAKE) $(hdr-inst)=$(hdr-prefix)include/uapi $(Q)$(MAKE) $(hdr-inst)=$(hdr-prefix)arch/$(SRCARCH)/include/uapi +# --------------------------------------------------------------------------- +# Devicetree files +ifeq ($(KBUILD_EXTMOD),) +ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/boot/dts/),) +dtstree := arch/$(SRCARCH)/boot/dts +endif + +else # KBUILD_EXTMOD +# Devicetree source should live in $(KBUILD_EXTMOD)/arch/$(SRCARCH)/boot/dts/ +# But it may live inside some other folder relative to KBUILD_EXTMOD, as specified +# by KBUILD_EXTMOD_DTS +KBUILD_EXTMOD_DTS = arch/$(SRCARCH)/boot/dts +ifneq ($(wildcard $(KBUILD_EXTMOD)/$(KBUILD_EXTMOD_DTS)/ $(srctree)/$(KBUILD_EXTMOD)/$(KBUILD_EXTMOD_DTS)/),) +dtstree := $(KBUILD_EXTMOD)/$(KBUILD_EXTMOD_DTS) +endif +endif + +ifneq ($(dtstree),) + +%.dtb: include/config/kernel.release scripts_dtc + $(Q)$(MAKE) $(build)=$(dtstree) $(dtstree)/$@ + +PHONY += dtbs dtbs_install dtbs_check +dtbs: include/config/kernel.release scripts_dtc + $(Q)$(MAKE) $(build)=$(dtstree) + +ifneq ($(filter dtbs_check, $(MAKECMDGOALS)),) +export CHECK_DTBS=y +dtbs: dt_binding_check +endif + +dtbs_check: dtbs + +dtbs_install: + $(Q)$(MAKE) $(dtbinst)=$(dtstree) dst=$(INSTALL_DTBS_PATH) + +ifdef CONFIG_OF_EARLY_FLATTREE +all: dtbs +endif + +endif + +PHONY += scripts_dtc +scripts_dtc: scripts_basic + $(Q)$(MAKE) $(build)=scripts/dtc + +ifneq ($(filter dt_binding_check, $(MAKECMDGOALS)),) +export CHECK_DT_BINDING=y +endif + +PHONY += dt_binding_check +dt_binding_check: scripts_dtc + $(Q)$(MAKE) $(build)=Documentation/devicetree/bindings + + ifeq ($(KBUILD_EXTMOD),) core-y += kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ core-$(CONFIG_BLOCK) += block/ diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 243ae7b9acb7..67c8be4c1f58 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -226,7 +226,7 @@ ld_flags = $(KBUILD_LDFLAGS) $(ldflags-y) $(LDFLAGS_$(@F)) # ANDROID: Allow DTC_INCLUDE to be set by the BUILD_CONFIG. This allows one to # compile an out-of-tree device tree. -DTC_INCLUDE += $(srctree)/scripts/dtc/include-prefixes +DTC_INCLUDE += $(srctree)/scripts/dtc/include-prefixes $(KBUILD_DTC_INCLUDE) dtc_cpp_flags = -Wp,-MMD,$(depfile).pre.tmp -nostdinc \ $(addprefix -I,$(DTC_INCLUDE)) \