generated from cc3-ug/proj01-c-riscv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
37 lines (25 loc) · 1023 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
SOURCES := utils.c part1.c part2.c riscv.c
HEADERS := types.h utils.h riscv.h
ASM_TESTS := simple multiply random
all: riscv part1 part2
@echo "============All tests finished============"
.PHONY: part1 part2 %_disasm %_execute
riscv: $(SOURCES) $(HEADERS) out
gcc -g -Wall -O2 -o $@ $(SOURCES)
out:
@mkdir -p ./riscvcode/out
# Part 1 Tests
part1: riscv $(addsuffix _disasm, $(ASM_TESTS))
@echo "---------Disassembly Tests Complete---------"
%_disasm: riscvcode/code/%.input riscvcode/ref/%.solution riscv
@./riscv -d $< > riscvcode/out/test.dump
@diff $(word 2, $^) riscvcode/out/test.dump && echo "$@ TEST PASSED!" || echo "$@ TEST FAILED!"
# Part 2 Tests
part2: riscv $(addsuffix _execute, $(ASM_TESTS))
@echo "-----------Execute Tests Complete-----------"
%_execute: riscvcode/code/%.input riscvcode/ref/%.trace riscv
@./riscv -r $< > riscvcode/out/test.trace
@diff $(word 2, $^) riscvcode/out/test.trace && echo "$@ TEST PASSED!" || echo "$@ TEST FAILED!"
clean:
rm -f riscv
rm -rf riscvcode/out