-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
executable file
·45 lines (32 loc) · 1.16 KB
/
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
38
39
40
41
42
43
44
45
SOURCES := utils.c part1.c part2.c riscv.c
HEADERS := types.h utils.h riscv.h
CUNIT := -L/home/ff/cs61c/cunit/install/lib -I/home/ff/cs61c/cunit/install/include -lcunit
CFLAGS := -g -std=gnu99 -Wall
ASM_TESTS := simple multiply random
all: riscv part1 part2
@echo "=============All tests finished============="
.PHONY: part1 %_disasm
riscv: $(SOURCES) $(HEADERS) out
gcc $(CFLAGS) -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!"
part2: riscv $(addsuffix _execute, $(ASM_TESTS))
@echo "-----------Execute Tests Complete-----------"
%_execute: riscvcode/code/%.input riscvcode/ref/%.solution riscv
@./riscv -r $< > riscvcode/out/$*.trace
@python2.7 part2_tester.py $*
test-utils:
gcc $(CFLAGS) -DTESTING -o test-utils test_utils.c utils.c $(CUNIT)
./test-utils
rm -f test-utils
clean:
rm -f riscv
rm -f *.o
rm -f test-utils
rm -rf riscvcode/out