diff options
author | Douglas Raillard <douglas.raillard@arm.com> | 2016-10-27 17:01:28 +0100 |
---|---|---|
committer | Douglas Raillard <douglas.raillard@arm.com> | 2016-11-09 16:13:11 +0000 |
commit | 7b0272e94e3a5ea4e4bba5f73940f9032c17ab5f (patch) | |
tree | c2d46ea77f40df1a70f5a1a0e6599052af5c9495 | |
parent | 97416437fa05c9afb239ac5a7bc8fbe6a29d34a8 (diff) |
Makefile: Let the user specify CFLAGS
Allow the user to pass some custom CFLAGS as a make parameter or as
an environment variable.
Internally, the Makefile and *.mk now use the TFTF_CFLAGS variable.
The user CFLAGS are among the last options given to the compiler as
they are appended to TFTF_CFLAGS after all the TFTF_CFLAGS options
defined in the Makefile and *.mk.
Change-Id: I97d032883cb92a23e9ff9edcf8d3470edd6254b5
Signed-off-by: Douglas Raillard <douglas.raillard@arm.com>
-rw-r--r-- | Makefile | 26 | ||||
-rw-r--r-- | framework/framework.mk | 8 |
2 files changed, 19 insertions, 15 deletions
@@ -238,25 +238,29 @@ endif ifeq (${DEBUG},0) $(eval $(call add_define,NDEBUG)) else -CFLAGS += -g +TFTF_CFLAGS += -g ASFLAGS += -g -Wa,--gdwarf-2 endif ASFLAGS_aarch64 = -mgeneral-regs-only -CFLAGS_aarch64 = -mgeneral-regs-only +TFTF_CFLAGS_aarch64 = -mgeneral-regs-only ASFLAGS_aarch32 = -march=armv8-a -CFLAGS_aarch32 = -march=armv8-a +TFTF_CFLAGS_aarch32 = -march=armv8-a -ASFLAGS += -nostdinc -ffreestanding -Wa,--fatal-warnings \ +ASFLAGS += -nostdinc -ffreestanding -Wa,--fatal-warnings \ -Werror -Wmissing-include-dirs \ -D__ASSEMBLY__ $(ASFLAGS_$(ARCH)) \ ${DEFINES} ${INCLUDES} -CFLAGS += -nostdinc -pedantic -ffreestanding -Wall \ +TFTF_CFLAGS += -nostdinc -pedantic -ffreestanding -Wall\ -Werror -Wno-error=unused-function \ - -Wmissing-include-dirs $(CFLAGS_$(ARCH)) \ + -Wmissing-include-dirs $(TFTF_CFLAGS_$(ARCH)) \ -std=c99 -c -Os ${DEFINES} ${INCLUDES} -CFLAGS += -ffunction-sections -fdata-sections +TFTF_CFLAGS += -ffunction-sections -fdata-sections + +# Get the content of CFLAGS user defined value last so they are appended after +# the options defined in the Makefile +TFTF_CFLAGS += ${CFLAGS} LDFLAGS += --fatal-warnings -O1 LDFLAGS += --gc-sections --build-id=none @@ -275,7 +279,7 @@ LD := ${CROSS_COMPILE}ld OC := ${CROSS_COMPILE}objcopy OD := ${CROSS_COMPILE}objdump NM := ${CROSS_COMPILE}nm -PP := ${CROSS_COMPILE}gcc -E ${CFLAGS} +PP := ${CROSS_COMPILE}gcc -E ${TFTF_CFLAGS} locate-checkpatch: ifndef CHECKPATCH @@ -334,13 +338,13 @@ $(eval PREREQUISITES := $(patsubst %.o,%.d,$(OBJ))) $(OBJ) : $(2) @echo " CC $$<" - $$(Q)$$(CC) $$(CFLAGS) -DIMAGE_$(3) -c $$< -o $$@ + $$(Q)$$(CC) $$(TFTF_CFLAGS) -DIMAGE_$(3) -c $$< -o $$@ $(PREREQUISITES) : $(2) $(AUTOGEN_DIR)/tests_list.h @echo " DEPS $$@" @mkdir -p $(1) - $$(Q)$$(CC) $$(CFLAGS) -M -MT $(OBJ) -MF $$@ $$< + $$(Q)$$(CC) $$(TFTF_CFLAGS) -M -MT $(OBJ) -MF $$@ $$< ifdef IS_ANYTHING_TO_BUILD -include $(PREREQUISITES) @@ -435,7 +439,7 @@ $(ELF) : $(OBJS) $(LINKERFILE) @echo " LD $$@" @echo 'const char build_message[] = "Built : "__TIME__", "__DATE__; \ const char version_string[] = "${VERSION_STRING}";' | \ - $$(CC) $$(CFLAGS) -xc - -o $(BUILD_DIR)/build_message.o + $$(CC) $$(TFTF_CFLAGS) -xc - -o $(BUILD_DIR)/build_message.o $$(Q)$$(CC) -o $$@ $$(LDFLAGS) -Xlinker -Map=$(MAPFILE) -T $(LINKERFILE) \ $(BUILD_DIR)/build_message.o $(OBJS) diff --git a/framework/framework.mk b/framework/framework.mk index 5327707..fa18db9 100644 --- a/framework/framework.mk +++ b/framework/framework.mk @@ -88,14 +88,14 @@ TFTF_LINKERFILE := framework/tftf.ld.S TEST_REPORTS ?= uart:raw $(info Selected reports: $(TEST_REPORTS)) ifneq (,$(findstring uart:raw,$(TEST_REPORTS))) - CFLAGS += -DTEST_REPORT_UART_RAW + TFTF_CFLAGS += -DTEST_REPORT_UART_RAW endif ifneq (,$(findstring uart:junit,$(TEST_REPORTS))) - CFLAGS += -DTEST_REPORT_UART_JUNIT + TFTF_CFLAGS += -DTEST_REPORT_UART_JUNIT endif ifneq (,$(findstring semihosting:raw,$(TEST_REPORTS))) - CFLAGS += -DTEST_REPORT_SEMIHOSTING_RAW + TFTF_CFLAGS += -DTEST_REPORT_SEMIHOSTING_RAW endif ifneq (,$(findstring semihosting:junit,$(TEST_REPORTS))) - CFLAGS += -DTEST_REPORT_SEMIHOSTING_JUNIT + TFTF_CFLAGS += -DTEST_REPORT_SEMIHOSTING_JUNIT endif |