Commit 9eb4d4dd authored by danh-arm's avatar danh-arm Committed by GitHub
Browse files

Merge pull request #796 from masahir0y/build

Improve dependency file generation
parents 236c27d2 1d274ab0
...@@ -143,16 +143,14 @@ TF_CFLAGS_aarch64 = -mgeneral-regs-only -mstrict-align ...@@ -143,16 +143,14 @@ TF_CFLAGS_aarch64 = -mgeneral-regs-only -mstrict-align
ASFLAGS_aarch32 = -march=armv8-a ASFLAGS_aarch32 = -march=armv8-a
TF_CFLAGS_aarch32 = -march=armv8-a TF_CFLAGS_aarch32 = -march=armv8-a
ASFLAGS += -nostdinc -ffreestanding -Wa,--fatal-warnings \ CPPFLAGS = ${DEFINES} ${INCLUDES} -nostdinc \
-Werror -Wmissing-include-dirs \ -Wmissing-include-dirs -Werror
-D__ASSEMBLY__ $(ASFLAGS_$(ARCH)) \ ASFLAGS += $(CPPFLAGS) $(ASFLAGS_$(ARCH)) \
${DEFINES} ${INCLUDES} -D__ASSEMBLY__ -ffreestanding \
TF_CFLAGS += -nostdinc -ffreestanding -Wall \ -Wa,--fatal-warnings
-Werror -Wmissing-include-dirs \ TF_CFLAGS += $(CPPFLAGS) $(TF_CFLAGS_$(ARCH)) \
-std=c99 -c -Os \ -ffreestanding -Wall -std=c99 -Os \
$(TF_CFLAGS_$(ARCH)) \ -ffunction-sections -fdata-sections
${DEFINES} ${INCLUDES}
TF_CFLAGS += -ffunction-sections -fdata-sections
LDFLAGS += --fatal-warnings -O1 LDFLAGS += --fatal-warnings -O1
LDFLAGS += --gc-sections LDFLAGS += --gc-sections
......
...@@ -184,24 +184,7 @@ endef ...@@ -184,24 +184,7 @@ endef
# Auxiliary macros to build TF images from sources # Auxiliary macros to build TF images from sources
################################################################################ ################################################################################
# If no goal is specified in the command line, .DEFAULT_GOAL is used. MAKE_DEP = -Wp,-MD,$(DEP) -MT $$@ -MP
# .DEFAULT_GOAL is defined in the main Makefile before including this file.
ifeq ($(MAKECMDGOALS),)
MAKECMDGOALS := $(.DEFAULT_GOAL)
endif
define match_goals
$(strip $(foreach goal,$(1),$(filter $(goal),$(MAKECMDGOALS))))
endef
# List of rules that involve building things
BUILD_TARGETS := all bl1 bl2 bl2u bl31 bl32 certificates fip
# Does the list of goals specified on the command line include a build target?
ifneq ($(call match_goals,${BUILD_TARGETS}),)
IS_ANYTHING_TO_BUILD := 1
endif
# MAKE_C builds a C source file and generates the dependency file # MAKE_C builds a C source file and generates the dependency file
# $(1) = output directory # $(1) = output directory
...@@ -210,20 +193,14 @@ endif ...@@ -210,20 +193,14 @@ endif
define MAKE_C define MAKE_C
$(eval OBJ := $(1)/$(patsubst %.c,%.o,$(notdir $(2)))) $(eval OBJ := $(1)/$(patsubst %.c,%.o,$(notdir $(2))))
$(eval PREREQUISITES := $(patsubst %.o,%.d,$(OBJ))) $(eval DEP := $(patsubst %.o,%.d,$(OBJ)))
$(eval IMAGE := IMAGE_BL$(call uppercase,$(3))) $(eval IMAGE := IMAGE_BL$(call uppercase,$(3)))
$(OBJ): $(2) $(OBJ): $(2) | bl$(3)_dirs
@echo " CC $$<" @echo " CC $$<"
$$(Q)$$(CC) $$(TF_CFLAGS) $$(CFLAGS) -D$(IMAGE) -c $$< -o $$@ $$(Q)$$(CC) $$(TF_CFLAGS) $$(CFLAGS) -D$(IMAGE) $(MAKE_DEP) -c $$< -o $$@
$(PREREQUISITES): $(2) | bl$(3)_dirs -include $(DEP)
@echo " DEPS $$@"
$$(Q)$$(CC) $$(TF_CFLAGS) $$(CFLAGS) -M -MT $(OBJ) -MF $$@ $$<
ifdef IS_ANYTHING_TO_BUILD
-include $(PREREQUISITES)
endif
endef endef
...@@ -235,20 +212,14 @@ endef ...@@ -235,20 +212,14 @@ endef
define MAKE_S define MAKE_S
$(eval OBJ := $(1)/$(patsubst %.S,%.o,$(notdir $(2)))) $(eval OBJ := $(1)/$(patsubst %.S,%.o,$(notdir $(2))))
$(eval PREREQUISITES := $(patsubst %.o,%.d,$(OBJ))) $(eval DEP := $(patsubst %.o,%.d,$(OBJ)))
$(eval IMAGE := IMAGE_BL$(call uppercase,$(3))) $(eval IMAGE := IMAGE_BL$(call uppercase,$(3)))
$(OBJ): $(2) $(OBJ): $(2) | bl$(3)_dirs
@echo " AS $$<" @echo " AS $$<"
$$(Q)$$(AS) $$(ASFLAGS) -D$(IMAGE) -c $$< -o $$@ $$(Q)$$(AS) $$(ASFLAGS) -D$(IMAGE) $(MAKE_DEP) -c $$< -o $$@
$(PREREQUISITES): $(2) | bl$(3)_dirs
@echo " DEPS $$@"
$$(Q)$$(AS) $$(ASFLAGS) -M -MT $(OBJ) -MF $$@ $$<
ifdef IS_ANYTHING_TO_BUILD -include $(DEP)
-include $(PREREQUISITES)
endif
endef endef
...@@ -258,19 +229,13 @@ endef ...@@ -258,19 +229,13 @@ endef
# $(2) = input template # $(2) = input template
define MAKE_LD define MAKE_LD
$(eval PREREQUISITES := $(1).d) $(eval DEP := $(1).d)
$(1): $(2) $(1): $(2) | $(dir ${1})
@echo " PP $$<" @echo " PP $$<"
$$(Q)$$(AS) $$(ASFLAGS) -P -E -D__LINKER__ -o $$@ $$< $$(Q)$$(CPP) $$(CPPFLAGS) -P -D__ASSEMBLY__ -D__LINKER__ $(MAKE_DEP) -o $$@ $$<
$(PREREQUISITES): $(2) | $(dir ${1})
@echo " DEPS $$@"
$$(Q)$$(AS) $$(ASFLAGS) -M -MT $(1) -MF $$@ $$<
ifdef IS_ANYTHING_TO_BUILD -include $(DEP)
-include $(PREREQUISITES)
endif
endef endef
...@@ -358,7 +323,7 @@ ifdef MAKE_BUILD_STRINGS ...@@ -358,7 +323,7 @@ ifdef MAKE_BUILD_STRINGS
else else
@echo 'const char build_message[] = "Built : "$(BUILD_MESSAGE_TIMESTAMP); \ @echo 'const char build_message[] = "Built : "$(BUILD_MESSAGE_TIMESTAMP); \
const char version_string[] = "${VERSION_STRING}";' | \ const char version_string[] = "${VERSION_STRING}";' | \
$$(CC) $$(TF_CFLAGS) $$(CFLAGS) -xc - -o $(BUILD_DIR)/build_message.o $$(CC) $$(TF_CFLAGS) $$(CFLAGS) -xc -c - -o $(BUILD_DIR)/build_message.o
endif endif
$$(Q)$$(LD) -o $$@ $$(LDFLAGS) -Map=$(MAPFILE) --script $(LINKERFILE) \ $$(Q)$$(LD) -o $$@ $$(LDFLAGS) -Map=$(MAPFILE) --script $(LINKERFILE) \
$(BUILD_DIR)/build_message.o $(OBJS) $(BUILD_DIR)/build_message.o $(OBJS)
......
...@@ -104,6 +104,6 @@ BUILT_TIME_DATE_STRING = const char build_message[] = "Built : "${BUILD_MESSAGE_ ...@@ -104,6 +104,6 @@ BUILT_TIME_DATE_STRING = const char build_message[] = "Built : "${BUILD_MESSAGE_
VERSION_STRING_MESSAGE = const char version_string[] = "${VERSION_STRING}"; VERSION_STRING_MESSAGE = const char version_string[] = "${VERSION_STRING}";
define MAKE_BUILD_STRINGS define MAKE_BUILD_STRINGS
@echo $$(BUILT_TIME_DATE_STRING) $$(VERSION_STRING_MESSAGE) | \ @echo $$(BUILT_TIME_DATE_STRING) $$(VERSION_STRING_MESSAGE) | \
$$(CC) $$(TF_CFLAGS) $$(CFLAGS) -x c - -o $1 $$(CC) $$(TF_CFLAGS) $$(CFLAGS) -x c -c - -o $1
endef endef
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment