cleanup Makefiles in isa
[riscv-tests.git] / isa / Makefile
1 #=======================================================================
2 # Makefile for riscv-tests/isa
3 #-----------------------------------------------------------------------
4
5 include rv64ui/Makefrag
6 include rv64uf/Makefrag
7 include rv64uv/Makefrag
8 include rv64si/Makefrag
9 include rv64sv/Makefrag
10
11 default: all
12
13 #--------------------------------------------------------------------
14 # Build rules
15 #--------------------------------------------------------------------
16
17 RISCV_GCC = riscv-gcc
18 RISCV_GCC_OPTS = -nostdlib -nostartfiles
19 RISCV_OBJDUMP = riscv-objdump --disassemble-all --disassemble-zeroes --section=.text --section=.data --section=.bss
20 RISCV_SIM = riscv-isa-run
21
22 #------------------------------------------------------------
23 # Build assembly tests
24
25 %.hex: %
26 elf2hex 16 16384 $< > $@
27
28 %.dump: %
29 $(RISCV_OBJDUMP) $< > $@
30
31 %.out: %
32 $(RISCV_SIM) $< 2> $@
33
34 define compile_template
35
36 $$($(1)_p_tests): $(1)-p-%: $(1)/%.S
37 $$(RISCV_GCC) $$(RISCV_GCC_OPTS) -I../env/p -I./macros/scalar -T../env/p/link.ld $$< -o $$@
38 tests += $$($(1)_p_tests)
39
40 $$($(1)_pt_tests): $(1)-pt-%: $(1)/%.S
41 $$(RISCV_GCC) $$(RISCV_GCC_OPTS) -I../env/pt -I./macros/scalar -T../env/p/link.ld $$< -o $$@
42 tests += $$($(1)_pt_tests)
43
44 $$($(1)_pm_tests): $(1)-pm-%: $(1)/%.S
45 $$(RISCV_GCC) $$(RISCV_GCC_OPTS) -I../env/pm -I./macros/scalar -T../env/pm/link.ld $$< -o $$@
46 tests += $$($(1)_pm_tests)
47
48 $$($(1)_v_tests): $(1)-v-%: $(1)/%.S
49 $$(RISCV_GCC) $$(RISCV_GCC_OPTS) -std=gnu99 -O2 -I../env/v -I./macros/scalar -T../env/v/link.ld ../env/v/entry.S ../env/v/vm.c $$< -lc -o $$@
50 tests += $$($(1)_v_tests)
51
52 $$($(1)_p_vec_tests): $(1)-p-vec-%: $(1)/%.S
53 $$(RISCV_GCC) $$(RISCV_GCC_OPTS) -I../env/p -I./macros/vector -T../env/p/link.ld $$< -o $$@
54 tests += $$($(1)_p_vec_tests)
55
56 $$($(1)_pt_vec_tests): $(1)-pt-vec-%: $(1)/%.S
57 $$(RISCV_GCC) $$(RISCV_GCC_OPTS) -I../env/pt -I./macros/vector -T../env/pt/link.ld $$< -o $$@
58 tests += $$($(1)_pt_vec_tests)
59
60 $$($(1)_v_vec_tests): $(1)-v-vec-%: $(1)/%.S
61 $$(RISCV_GCC) $$(RISCV_GCC_OPTS) -std=gnu99 -O2 -I../env/v -I./macros/vector -T../env/v/link.ld ../env/v/entry.S ../env/v/vm.c $$< -lc -o $$@
62 tests += $$($(1)_v_vec_tests)
63
64 endef
65
66 $(eval $(call compile_template,rv64ui))
67 $(eval $(call compile_template,rv64uf))
68 $(eval $(call compile_template,rv64uv))
69 $(eval $(call compile_template,rv64si))
70 $(eval $(call compile_template,rv64sv))
71
72 tests_dump = $(addsuffix .dump, $(tests))
73 tests_hex = $(addsuffix .hex, $(tests))
74 tests_out = $(addsuffix .out, $(spike_tests))
75
76 run: $(tests_out)
77 echo; perl -ne 'print " [$$1] $$ARGV \t$$2\n" if /\*{3}(.{8})\*{3}(.*)/' \
78 $(tests_out); echo;
79
80 junk += $(tests) $(tests_dump) $(tests_hex) $(tests_out)
81
82 #------------------------------------------------------------
83 # Default
84
85 all: $(tests_dump) $(tests_hex)
86
87 #------------------------------------------------------------
88 # Clean up
89
90 clean:
91 rm -rf $(junk)