|
| 1 | +RV32_EXT ?= rv32gc |
| 2 | +OPT_LEVEL ?= 0 1 2 |
| 3 | + |
| 4 | +CURDIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) |
| 5 | +SRC_DIR := $(CURDIR)/src |
| 6 | + |
| 7 | +CFLAGS := -std=c99 -I$(CURDIR)/include |
| 8 | +CFLAGS += \ |
| 9 | + -DCOMPILER_FLAGS="\"-std=c99\"" \ |
| 10 | + -DMEM_LOCATION="\"Main memory (heap)\"" \ |
| 11 | + -DPERFORMANCE_RUN=1 \ |
| 12 | + -DITERATIONS=80000 \ |
| 13 | + -DUINTPTR_TYPE \ |
| 14 | + -DPRINT_CRC |
| 15 | + |
| 16 | +# prevent lazy set |
| 17 | +ifeq ($(BUILD_DIR),) |
| 18 | + BUILD_DIR := $(CURDIR)/build |
| 19 | +endif |
| 20 | + |
| 21 | +SRCS := \ |
| 22 | + core_main.c \ |
| 23 | + core_matrix.c \ |
| 24 | + core_list_join.c \ |
| 25 | + core_state.c \ |
| 26 | + core_util.c \ |
| 27 | + core_portme.c |
| 28 | + |
| 29 | +EXECUTABLES := coremark.elf |
| 30 | + |
| 31 | +SHELL_HACK := $(shell mkdir -p $(foreach LEVEL,$(OPT_LEVEL),$(BUILD_DIR)/$(RV32_EXT)/O$(LEVEL)/coremark)) |
| 32 | + |
| 33 | +.PHONY: all clean build-O0 build-O1 build-O2 |
| 34 | + |
| 35 | +ifneq ($(filter $(OPT_LEVEL), 0),) |
| 36 | +all: build-O0 |
| 37 | +endif |
| 38 | + |
| 39 | +ifneq ($(filter $(OPT_LEVEL), 1),) |
| 40 | +all: build-O1 |
| 41 | +endif |
| 42 | + |
| 43 | +ifneq ($(filter $(OPT_LEVEL), 2),) |
| 44 | +all: build-O2 |
| 45 | +endif |
| 46 | + |
| 47 | +include ../../../mk/common.mk |
| 48 | +include ../../../mk/toolchain.mk |
| 49 | + |
| 50 | +build-O0: $(addprefix $(BUILD_DIR)/$(RV32_EXT)/O0/coremark/,$(EXECUTABLES)) |
| 51 | + |
| 52 | +$(BUILD_DIR)/$(RV32_EXT)/O0/coremark/$(EXECUTABLES): $(addprefix $(SRC_DIR)/,$(SRCS)) | build-toolchain |
| 53 | + $(VECHO) " RISCVCC\t$(patsubst $(abspath $(BUILD_DIR)/..)/%,%,$@)\n" |
| 54 | + $(Q)$(CROSS_COMPILE) -o $@ -O0 $(CFLAGS) $(addprefix $(SRC_DIR)/,$(SRCS)) |
| 55 | + |
| 56 | +build-O1: $(addprefix $(BUILD_DIR)/$(RV32_EXT)/O1/coremark/,$(EXECUTABLES)) |
| 57 | + |
| 58 | +$(BUILD_DIR)/$(RV32_EXT)/O1/coremark/$(EXECUTABLES): $(addprefix $(SRC_DIR)/,$(SRCS)) | build-toolchain |
| 59 | + $(VECHO) " RISCVCC\t$(patsubst $(abspath $(BUILD_DIR)/..)/%,%,$@)\n" |
| 60 | + $(Q)$(CROSS_COMPILE) -o $@ -O1 $(CFLAGS) $(addprefix $(SRC_DIR)/,$(SRCS)) |
| 61 | + |
| 62 | +build-O2: $(addprefix $(BUILD_DIR)/$(RV32_EXT)/O2/coremark/,$(EXECUTABLES)) |
| 63 | + |
| 64 | +$(BUILD_DIR)/$(RV32_EXT)/O2/coremark/$(EXECUTABLES): $(addprefix $(SRC_DIR)/,$(SRCS)) | build-toolchain |
| 65 | + $(VECHO) " RISCVCC\t$(patsubst $(abspath $(BUILD_DIR)/..)/%,%,$@)\n" |
| 66 | + $(Q)$(CROSS_COMPILE) -o $@ -O2 $(CFLAGS) $(addprefix $(SRC_DIR)/,$(SRCS)) |
| 67 | + |
| 68 | +clean: |
| 69 | + $(RM) $(foreach LEVEL,$(OPT_LEVEL),$(BUILD_DIR)/$(RV32_EXT)/O$(LEVEL)/coremark/*) |
0 commit comments