Makefile revision 12771
112771Sqtt2@cornell.edu#=======================================================================
212771Sqtt2@cornell.edu# Makefile for riscv-tests/isa
312771Sqtt2@cornell.edu#-----------------------------------------------------------------------
412771Sqtt2@cornell.edu
512771Sqtt2@cornell.eduXLEN ?= 64
612771Sqtt2@cornell.edu
712771Sqtt2@cornell.edusrc_dir 	:= ./isa
812771Sqtt2@cornell.edubin_dir 	:= ../../bin/riscv
912771Sqtt2@cornell.edudump_dir 	:= ../../dump/riscv
1012771Sqtt2@cornell.edu
1112771Sqtt2@cornell.eduinclude $(src_dir)/rv64ui/Makefrag
1212771Sqtt2@cornell.eduinclude $(src_dir)/rv64uc/Makefrag
1312771Sqtt2@cornell.eduinclude $(src_dir)/rv64um/Makefrag
1412771Sqtt2@cornell.eduinclude $(src_dir)/rv64ua/Makefrag
1512771Sqtt2@cornell.eduinclude $(src_dir)/rv64uf/Makefrag
1612771Sqtt2@cornell.eduinclude $(src_dir)/rv64ud/Makefrag
1712771Sqtt2@cornell.eduinclude $(src_dir)/rv64si/Makefrag
1812771Sqtt2@cornell.eduinclude $(src_dir)/rv64mi/Makefrag
1912771Sqtt2@cornell.eduinclude $(src_dir)/rv64uamt/Makefrag
2012771Sqtt2@cornell.eduinclude $(src_dir)/rv64samt/Makefrag
2112771Sqtt2@cornell.edu
2212771Sqtt2@cornell.edudefault: all
2312771Sqtt2@cornell.edu
2412771Sqtt2@cornell.edu#--------------------------------------------------------------------
2512771Sqtt2@cornell.edu# Build rules
2612771Sqtt2@cornell.edu#--------------------------------------------------------------------
2712771Sqtt2@cornell.edu
2812771Sqtt2@cornell.eduRISCV_PREFIX ?= riscv$(XLEN)-unknown-elf-
2912771Sqtt2@cornell.eduRISCV_GCC ?= $(RISCV_PREFIX)gcc
3012771Sqtt2@cornell.eduRISCV_GCC_OPTS ?= -static -mcmodel=medany -fvisibility=hidden -nostdlib -nostartfiles
3112771Sqtt2@cornell.eduRISCV_OBJDUMP ?= $(RISCV_PREFIX)objdump --disassemble-all --disassemble-zeroes --section=.text --section=.text.startup --section=.text.init --section=.data
3212771Sqtt2@cornell.eduRISCV_SIM ?= spike
3312771Sqtt2@cornell.edu
3412771Sqtt2@cornell.eduvpath %.S $(src_dir)
3512771Sqtt2@cornell.edu
3612771Sqtt2@cornell.edu#------------------------------------------------------------
3712771Sqtt2@cornell.edu# Build assembly tests
3812771Sqtt2@cornell.edu
3912771Sqtt2@cornell.edu%.dump: %
4012771Sqtt2@cornell.edu	mkdir -p $(dump_dir)
4112771Sqtt2@cornell.edu	$(RISCV_OBJDUMP) $(bin_dir)/$< > $(dump_dir)/$@
4212771Sqtt2@cornell.edu
4312771Sqtt2@cornell.edu%.out: %
4412771Sqtt2@cornell.edu	$(RISCV_SIM) --isa=rv64gc $< 2> $@
4512771Sqtt2@cornell.edu
4612771Sqtt2@cornell.edudefine compile_template
4712771Sqtt2@cornell.edu
4812771Sqtt2@cornell.edu$$($(1)_ps_tests): $(1)-ps-%: $(1)/%.S
4912771Sqtt2@cornell.edu	mkdir -p $(bin_dir)
5012771Sqtt2@cornell.edu	$$(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)/$$@
5112771Sqtt2@cornell.edu$(1)_ps_env_tests += $$($(1)_ps_tests)
5212771Sqtt2@cornell.edu
5312771Sqtt2@cornell.edu$(1)_tests_dump = $$(addsuffix .dump, $$($(1)_tests))
5412771Sqtt2@cornell.edu
5512771Sqtt2@cornell.edu$(1): $$($(1)_tests_dump)
5612771Sqtt2@cornell.edu
5712771Sqtt2@cornell.edu.PHONY: $(1)
5812771Sqtt2@cornell.edu
5912771Sqtt2@cornell.edup_env_tests 	+= $$($(1)_p_env_tests)
6012771Sqtt2@cornell.eduv_env_tests 	+= $$($(1)_v_env_tests)
6112771Sqtt2@cornell.edups_env_tests 	+= $$($(1)_ps_env_tests)
6212771Sqtt2@cornell.edu
6312771Sqtt2@cornell.eduendef
6412771Sqtt2@cornell.edu
6512771Sqtt2@cornell.edu$(eval $(call compile_template,rv64ui,-march=rv64g -mabi=lp64))
6612771Sqtt2@cornell.edu$(eval $(call compile_template,rv64uc,-march=rv64g -mabi=lp64))
6712771Sqtt2@cornell.edu$(eval $(call compile_template,rv64um,-march=rv64g -mabi=lp64))
6812771Sqtt2@cornell.edu$(eval $(call compile_template,rv64ua,-march=rv64g -mabi=lp64))
6912771Sqtt2@cornell.edu$(eval $(call compile_template,rv64uf,-march=rv64g -mabi=lp64))
7012771Sqtt2@cornell.edu$(eval $(call compile_template,rv64ud,-march=rv64g -mabi=lp64))
7112771Sqtt2@cornell.edu$(eval $(call compile_template,rv64si,-march=rv64g -mabi=lp64))
7212771Sqtt2@cornell.edu$(eval $(call compile_template,rv64mi,-march=rv64g -mabi=lp64))
7312771Sqtt2@cornell.edu$(eval $(call compile_template,rv64uamt,-march=rv64g -mabi=lp64))
7412771Sqtt2@cornell.edu$(eval $(call compile_template,rv64samt,-march=rv64g -mabi=lp64))
7512771Sqtt2@cornell.edu
7612771Sqtt2@cornell.edups_env_tests_dump = $(addsuffix .dump, $(ps_env_tests))
7712771Sqtt2@cornell.edu
7812771Sqtt2@cornell.edu#------------------------------------------------------------
7912771Sqtt2@cornell.edu# Targets
8012771Sqtt2@cornell.edu
8112771Sqtt2@cornell.eduall: 	ps
8212771Sqtt2@cornell.edu# build tests with ps environment
8312771Sqtt2@cornell.edups: 	$(ps_env_tests_dump)
8412771Sqtt2@cornell.edu
8512771Sqtt2@cornell.edu#------------------------------------------------------------
8612771Sqtt2@cornell.edu# Clean up
8712771Sqtt2@cornell.edu
8812771Sqtt2@cornell.educlean:
8912771Sqtt2@cornell.edu	rm -rf $(bin_dir) $(dump_dir)
90