Build: add cpp build processing for dtb
authorYann Gautier <[email protected]>
Mon, 18 Jun 2018 14:00:23 +0000 (16:00 +0200)
committerYann Gautier <[email protected]>
Mon, 18 Jun 2018 14:05:16 +0000 (16:05 +0200)
This is an add-on feature that allows processing
device tree with external includes.

"-Iinclude" is also added to INCLUDES.
It allows inclusion of dt-bindings files either in dts files or drivers,
as those files will be in include/dt-bindings/.

"-i fdts" is added to the DTC command line.
As the pre-processed files are in build directory, the DT source directory
has to be explicitely included, to manages /include/ directives.

fixes arm-software/tf-issues#595

Signed-off-by: Lionel Debieve <[email protected]>
Signed-off-by: Yann Gautier <[email protected]>
Makefile
make_helpers/build_macros.mk

index 17630fbf38dd7e6132d25a064d9a1d64333972e0..f230f4af3aab90e845de76051be4733090dc182e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -198,7 +198,8 @@ BL_COMMON_SOURCES   +=      common/bl_common.c                      \
                                ${COMPILER_RT_SRCS}                     \
                                ${STDLIB_SRCS}
 
-INCLUDES               +=      -Iinclude/bl1                           \
+INCLUDES               +=      -Iinclude                               \
+                               -Iinclude/bl1                           \
                                -Iinclude/bl2                           \
                                -Iinclude/bl2u                          \
                                -Iinclude/bl31                          \
index cac9dfc44b434128ff9081c7cf7f6f5b7858f3bb..2a6ded497064a09e24266ad5f94effd1803f9fa1 100644 (file)
@@ -372,11 +372,14 @@ endef
 define MAKE_DTB
 
 $(eval DOBJ := $(addprefix $(1)/,$(call SOURCES_TO_DTBS,$(2))))
+$(eval DPRE := $(addprefix $(1)/,$(patsubst %.dts,%.pre.dts,$(notdir $(2)))))
 $(eval DEP := $(patsubst %.dtb,%.d,$(DOBJ)))
 
 $(DOBJ): $(2) $(filter-out %.d,$(MAKEFILE_LIST)) | fdt_dirs
+       @echo "  CPP     $$<"
+       $$(Q)$$(CPP) $$(CPPFLAGS) -x assembler-with-cpp -o $(DPRE) $$<
        @echo "  DTC     $$<"
-       $$(Q)$$(DTC) $$(DTC_FLAGS) -d $(DEP) -o $$@ $$<
+       $$(Q)$$(DTC) $$(DTC_FLAGS) -i fdts -d $(DEP) -o $$@ $(DPRE)
 
 -include $(DEP)