tinyriscv/tests/isa/Makefile

70 lines
1.7 KiB
Makefile
Raw Normal View History

#=======================================================================
# Makefile for riscv-tests/isa
#-----------------------------------------------------------------------
XLEN := 32
src_dir := .
include $(src_dir)/rv32ui/Makefrag
include $(src_dir)/rv32um/Makefrag
default: all
#--------------------------------------------------------------------
# Build rules
#--------------------------------------------------------------------
RISCV_PREFIX ?= /opt/riscv32/bin/riscv32-unknown-elf-
RISCV_GCC ?= $(RISCV_PREFIX)gcc
RISCV_GCC_OPTS ?= -static -mcmodel=medany -fvisibility=hidden -nostdlib -nostartfiles
RISCV_OBJDUMP ?= $(RISCV_PREFIX)objdump --disassemble-all
RISCV_OBJCOPY ?= $(RISCV_PREFIX)objcopy
BIN_TO_MEM := $(src_dir)/../../tools/BinToMem.py
vpath %.S $(src_dir)
#------------------------------------------------------------
# Build assembly tests
%.dump: %
$(RISCV_OBJDUMP) generated/$< > generated/$@
$(RISCV_OBJCOPY) -O verilog generated/$< generated/$<.verilog
$(RISCV_OBJCOPY) -O binary generated/$< generated/$<.bin
$(BIN_TO_MEM) generated/$<.bin generated/$<.mem
define compile_template
$$($(1)_p_tests): $(1)-p-%: $(1)/%.S
$$(RISCV_GCC) $(2) $$(RISCV_GCC_OPTS) -I$(src_dir) -T$(src_dir)/link.ld $$< -o generated/$$@
$(1)_tests += $$($(1)_p_tests)
$(1)_tests_dump = $$(addsuffix .dump, $$($(1)_tests))
$(1): $$($(1)_tests_dump)
.PHONY: $(1)
tests += $$($(1)_tests)
endef
$(eval $(call compile_template,rv32ui,-march=rv32i -mabi=ilp32))
$(eval $(call compile_template,rv32um,-march=rv32im -mabi=ilp32))
tests_verilog = $(addsuffix .verilog, $(tests))
tests_dump = $(addsuffix .dump, $(tests))
#------------------------------------------------------------
# Default
all: $(tests_dump)
clean:
rm -rf generated/*