Makefile revision 12771
1#======================================================================= 2# Makefile for riscv-tests/isa 3#----------------------------------------------------------------------- 4 5XLEN ?= 64 6 7src_dir := ./isa 8bin_dir := ../../bin/riscv 9dump_dir := ../../dump/riscv 10 11include $(src_dir)/rv64ui/Makefrag 12include $(src_dir)/rv64uc/Makefrag 13include $(src_dir)/rv64um/Makefrag 14include $(src_dir)/rv64ua/Makefrag 15include $(src_dir)/rv64uf/Makefrag 16include $(src_dir)/rv64ud/Makefrag 17include $(src_dir)/rv64si/Makefrag 18include $(src_dir)/rv64mi/Makefrag 19include $(src_dir)/rv64uamt/Makefrag 20include $(src_dir)/rv64samt/Makefrag 21 22default: all 23 24#-------------------------------------------------------------------- 25# Build rules 26#-------------------------------------------------------------------- 27 28RISCV_PREFIX ?= riscv$(XLEN)-unknown-elf- 29RISCV_GCC ?= $(RISCV_PREFIX)gcc 30RISCV_GCC_OPTS ?= -static -mcmodel=medany -fvisibility=hidden -nostdlib -nostartfiles 31RISCV_OBJDUMP ?= $(RISCV_PREFIX)objdump --disassemble-all --disassemble-zeroes --section=.text --section=.text.startup --section=.text.init --section=.data 32RISCV_SIM ?= spike 33 34vpath %.S $(src_dir) 35 36#------------------------------------------------------------ 37# Build assembly tests 38 39%.dump: % 40 mkdir -p $(dump_dir) 41 $(RISCV_OBJDUMP) $(bin_dir)/$< > $(dump_dir)/$@ 42 43%.out: % 44 $(RISCV_SIM) --isa=rv64gc $< 2> $@ 45 46define compile_template 47 48$$($(1)_ps_tests): $(1)-ps-%: $(1)/%.S 49 mkdir -p $(bin_dir) 50 $$(RISCV_GCC) $(2) $$(RISCV_GCC_OPTS) -I$(src_dir)/../env/ps -I$(src_dir)/macros/scalar -I$(src_dir)/macros/mt -T$(src_dir)/../env/ps/link.ld $$< -o $(bin_dir)/$$@ 51$(1)_ps_env_tests += $$($(1)_ps_tests) 52 53$(1)_tests_dump = $$(addsuffix .dump, $$($(1)_tests)) 54 55$(1): $$($(1)_tests_dump) 56 57.PHONY: $(1) 58 59p_env_tests += $$($(1)_p_env_tests) 60v_env_tests += $$($(1)_v_env_tests) 61ps_env_tests += $$($(1)_ps_env_tests) 62 63endef 64 65$(eval $(call compile_template,rv64ui,-march=rv64g -mabi=lp64)) 66$(eval $(call compile_template,rv64uc,-march=rv64g -mabi=lp64)) 67$(eval $(call compile_template,rv64um,-march=rv64g -mabi=lp64)) 68$(eval $(call compile_template,rv64ua,-march=rv64g -mabi=lp64)) 69$(eval $(call compile_template,rv64uf,-march=rv64g -mabi=lp64)) 70$(eval $(call compile_template,rv64ud,-march=rv64g -mabi=lp64)) 71$(eval $(call compile_template,rv64si,-march=rv64g -mabi=lp64)) 72$(eval $(call compile_template,rv64mi,-march=rv64g -mabi=lp64)) 73$(eval $(call compile_template,rv64uamt,-march=rv64g -mabi=lp64)) 74$(eval $(call compile_template,rv64samt,-march=rv64g -mabi=lp64)) 75 76ps_env_tests_dump = $(addsuffix .dump, $(ps_env_tests)) 77 78#------------------------------------------------------------ 79# Targets 80 81all: ps 82# build tests with ps environment 83ps: $(ps_env_tests_dump) 84 85#------------------------------------------------------------ 86# Clean up 87 88clean: 89 rm -rf $(bin_dir) $(dump_dir) 90