From e77ade2887337ba5dfc55e69c3f1ed115c273a9a Mon Sep 17 00:00:00 2001 From: Julius Werner Date: Mon, 31 Oct 2016 19:18:47 -0700 Subject: [PATCH 1/2] rockchip: Clean up parent directory creation for M0 The dependencies in the M0 Makefile are not correctly laid out, which may lead to errors with make -j if the binary target gets evaluated before the target that creates the directory. In addition, the M0 Makefile just calls mkdir without using the platform-independent macros from the main ARM TF build system. This patch fixes those issues, removes some unused (and broken) M0 build targets and merges the two M0 output directories into one (since there's no real point splitting it up and it creates more hassle). Change-Id: Ia5002479cf9c57fea7aefa8ca88e373df3a51f61 Signed-off-by: Julius Werner --- plat/rockchip/rk3399/drivers/m0/Makefile | 38 +++++------------------- plat/rockchip/rk3399/platform.mk | 9 +++--- 2 files changed, 12 insertions(+), 35 deletions(-) diff --git a/plat/rockchip/rk3399/drivers/m0/Makefile b/plat/rockchip/rk3399/drivers/m0/Makefile index 8adc47e1f..a04192982 100644 --- a/plat/rockchip/rk3399/drivers/m0/Makefile +++ b/plat/rockchip/rk3399/drivers/m0/Makefile @@ -39,16 +39,11 @@ PLAT_M0 ?= rk3399m0 ifeq (${V},0) Q=@ - CHECKCODE_ARGS += --no-summary --terse else Q= endif export Q -# All PHONY definition -.PHONY: all clean distclean ${ARCH} -all: ${ARCH} - .SUFFIXES: INCLUDES += -Iinclude/ @@ -86,14 +81,12 @@ define SOURCES_TO_OBJS $(notdir $(patsubst %.S,%.o,$(filter %.S,$(1)))) endef -BUILD_DIR := ${BUILD_PLAT}/obj -BIN_DIR := ${BUILD_PLAT}/bin SOURCES := $(C_SOURCES) -OBJS := $(addprefix $(BUILD_DIR)/,$(call SOURCES_TO_OBJS,$(SOURCES))) +OBJS := $(addprefix $(BUILD)/,$(call SOURCES_TO_OBJS,$(SOURCES))) LINKERFILE := src/rk3399m0.ld -MAPFILE := $(BIN_DIR)/$(PLAT_M0).map -ELF := $(BIN_DIR)/$(PLAT_M0).elf -BIN := $(BIN_DIR)/$(PLAT_M0).bin +MAPFILE := $(BUILD)/$(PLAT_M0).map +ELF := $(BUILD)/$(PLAT_M0).elf +BIN := $(BUILD)/$(PLAT_M0).bin # Function definition related compilation define MAKE_C @@ -124,11 +117,8 @@ define MAKE_OBJS $(and $(REMAIN),$(error Unexpected source files present: $(REMAIN))) endef -$(BIN_DIR) : - $(Q)mkdir -p "$@" - -$(BUILD_DIR) : $(BIN_DIR) - $(Q)mkdir -p "$@" +.PHONY: all +all: $(BIN) $(ELF) : $(OBJS) $(LINKERFILE) @echo " LD $@" @@ -139,18 +129,4 @@ $(BIN) : $(ELF) @echo " BIN $@" $(Q)$(OC) -O binary $< $@ -.PHONY : ${ARCH} -${ARCH} : $(BUILD_DIR) $(BIN) - -$(eval $(call MAKE_OBJS,$(BUILD_DIR),$(SOURCES),$(1))) - -# Other common compilation entries -clean: - @echo " CLEAN" - ${Q}rm -rf ${BUILD_BASE}/${PLAT_M0} - ${Q}rm -rf ${VER_BIN_DIR}/$(PLAT_M0)* - -distclean: - @echo " DISTCLEAN" - ${Q}rm -rf ${BUILD_BASE}/${PLAT_M0} - ${Q}rm -rf ${VER_BIN_DIR}/$(PLAT_M0)* +$(eval $(call MAKE_OBJS,$(BUILD),$(SOURCES),$(1))) diff --git a/plat/rockchip/rk3399/platform.mk b/plat/rockchip/rk3399/platform.mk index 604de9c8c..059ee7b49 100644 --- a/plat/rockchip/rk3399/platform.mk +++ b/plat/rockchip/rk3399/platform.mk @@ -88,8 +88,9 @@ $(eval $(call add_define,PLAT_EXTRA_LD_SCRIPT)) # M0 source build PLAT_M0 := ${PLAT}m0 +BUILD_M0 := ${BUILD_PLAT}/m0 -RK3399M0FW=${BUILD_PLAT}/m0/bin/${PLAT_M0}.bin +RK3399M0FW=${BUILD_M0}/${PLAT_M0}.bin $(eval $(call add_define,RK3399M0FW)) # CCACHE_EXTRAFILES is needed because ccache doesn't handle .incbin @@ -97,7 +98,7 @@ export CCACHE_EXTRAFILES ${BUILD_PLAT}/bl31/pmu_fw.o: CCACHE_EXTRAFILES=$(RK3399M0FW) ${RK_PLAT_SOC}/drivers/pmu/pmu_fw.c: $(RK3399M0FW) +$(eval $(call MAKE_PREREQ_DIR,${BUILD_M0},)) .PHONY: $(RK3399M0FW) -$(RK3399M0FW): - $(MAKE) -C ${RK_PLAT_SOC}/drivers/m0 \ - BUILD_PLAT=$(abspath ${BUILD_PLAT}/m0) +$(RK3399M0FW): | ${BUILD_M0} + $(MAKE) -C ${RK_PLAT_SOC}/drivers/m0 BUILD=$(abspath ${BUILD_PLAT}/m0) From 71581c9c17764c0834ff7052a0c990dcfc4f500f Mon Sep 17 00:00:00 2001 From: Julius Werner Date: Thu, 3 Nov 2016 12:25:48 -0700 Subject: [PATCH 2/2] rockchip: Add proper dependency tracking to M0 Makefile This patch adds dependency rule generation and inclusion to the M0 Makefile, so that M0 objects will get correctly remade with an incremental build if a header file they included changed. Change-Id: I2067bd9fd4d9dad3e77a09cbf09c7b4db3c1eda5 Signed-off-by: Julius Werner --- plat/rockchip/rk3399/drivers/m0/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plat/rockchip/rk3399/drivers/m0/Makefile b/plat/rockchip/rk3399/drivers/m0/Makefile index a04192982..b8e3cd410 100644 --- a/plat/rockchip/rk3399/drivers/m0/Makefile +++ b/plat/rockchip/rk3399/drivers/m0/Makefile @@ -91,10 +91,11 @@ BIN := $(BUILD)/$(PLAT_M0).bin # Function definition related compilation define MAKE_C $(eval OBJ := $(1)/$(patsubst %.c,%.o,$(notdir $(2)))) +-include $(patsubst %.o,%.d,$(OBJ)) $(OBJ) : $(2) @echo " CC $$<" - $$(Q)$$(CC) $$(CFLAGS) $$(INCLUDES) -c $$< -o $$@ + $$(Q)$$(CC) $$(CFLAGS) $$(INCLUDES) -MMD -MT $$@ -c $$< -o $$@ endef define MAKE_S