#/*Copyright 2020-2021 T-Head Semiconductor Co., Ltd. # #Licensed under the Apache License, Version 2.0 (the "License"); #you may not use this file except in compliance with the License. #You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # #Unless required by applicable law or agreed to in writing, software #distributed under the License is distributed on an "AS IS" BASIS, #WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #See the License for the specific language governing permissions and #limitations under the License. #*/ #*/ #*/ # the compiler toolset setting TOOL_EXTENSION = /opt/riscv/bin CC = ${TOOL_EXTENSION}/riscv64-unknown-elf-gcc AS = ${TOOL_EXTENSION}/riscv64-unknown-elf-as LINK = ${TOOL_EXTENSION}/riscv64-unknown-elf-ld OBJDUMP = ${TOOL_EXTENSION}/riscv64-unknown-elf-objdump OBJCOPY = ${TOOL_EXTENSION}/riscv64-unknown-elf-objcopy CONVERT =./Srec2vmem SSRC = $(wildcard *.S) sSRC = $(wildcard *.s) CSRC = $(wildcard *.c) OBJECTS = $(SSRC:%.S=%.o) $(sSRC:%.s=%.o) $(CSRC:%.c=%.o) CPU_ARCH_FLAG_0=e906f CASENAME=debug FILE=debug FLAG_MARCH = -mtune=e906 FLAG_MARCH += -march=rv32imafc FLAG_ABI = -mabi=ilp32f CFLAGS = ${FLAG_MARCH} ${FLAG_ABI} ifeq (${CASENAME}, coremark) CFLAGS +=-c -v -O3 -g -funroll-all-loops -fgcse-sm -finline-limit=500 -fno-schedule-insns --param max-rtl-if-conversion-unpredictable-cost=100 -msignedness-cmpiv -fno-code-hoisting -mno-thread-jumps1 -mno-iv-adjust-addr-cost -mno-expand-split-imm -fno-tree-loop-distribution else CFLAGS += -c -v -O2 -g endif LINKFLAGS = -Tlinker.lcf -nostartfiles ${FLAG_MARCH} ${FLAG_ABI} # LINKLIBS = -L${TOOL_PATH}/lib/gcc/riscv64-unknown-elf/8.1.0/rv32imac # LINKLIBS += -L${TOOL_PATH}/riscv64-unknown-elf/lib/rv32imac # LINKLIBS += -L${TOOL_PATH}/riscv64-unknown-elf/lib LINKLIBS = -lc -lgcc OBJDUMPFLAGS = -S -Mnumeric HEXFLAGS = -O srec %.o : %.c ${CC} -c ${CFLAGS} -o $@ $< %.o : %.s ${CC} -c ${CFLAGS} -o $@ $< %.o : %.S ${CC} -c ${CFLAGS} -o $@ $< ${FILE}.elf : ${OBJECTS} linker.lcf ${CC} ${LINKFLAGS} ${LINKLIBS} ${OBJECTS} -o $@ -lm ${FILE}.obj : ${FILE}.elf ${OBJDUMP} ${OBJDUMPFLAGS} $< > $@ INST_HEX = ${FILE}_inst.hex DATA_HEX = ${FILE}_data.hex FILE_HEX = ${FILE}.hex ${FILE}.hex : ${FILE}.elf ${OBJCOPY} ${HEXFLAGS} $< ${INST_HEX} -j .text* -j .rodata* -j .eh_frame* ${OBJCOPY} ${HEXFLAGS} $< ${DATA_HEX} -j .data* -j .bss -j .COMMON ${OBJCOPY} ${HEXFLAGS} $< $@ ${FILE}.dis : ${FILE}.elf ${OBJDUMP} -S $< > ${FILE}.dis INST_PAT = inst.pat DATA_PAT = data.pat FILE_PAT = case.pat %.pat : %.hex rm -f *.pat ${CONVERT} ${INST_HEX} ${INST_PAT} ${CONVERT} ${DATA_HEX} ${DATA_PAT} ${CONVERT} ${FILE_HEX} ${FILE_PAT} #-------------------------------------------------------------------- # target setting .PHONY :all all : clean ${FILE}.pat ${FILE}.hex ${FILE}.elf ${FILE}.obj ${FILE}.dis #--------------------------------------------------------------------- # clean some medium code and .pat .PHONY :clean clean: rm -rf *.o *.pat *.obj *.hex *.dis *.elf