-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·32 lines (22 loc) · 1.15 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
SOURCES := sim.c processor.c load_program.c disassemble.c memory.c
HEADERS := elf.h load_program.h processor.h disassemble.h memory.h
ASM_TESTS := simple insts rt3 rt13 rt25 oritests sll test1 swaptest nchoosektest test2
all: mips-sim $(addprefix mipscode/, $(ASM_TESTS))
.PHONY: disasmtest runtest %_test
mipscode/%.o: mipscode/%.s
mips-gcc -c -o $@ $<
$(addprefix mipscode/, $(ASM_TESTS)): %: %.s mipscode/mips.ld
mips-gcc -o $(patsubst %.s, %.o, $<) -c $<
mips-ld -o $@ $(patsubst %.s, %.o, $<) -T mipscode/mips.ld
mips-sim: $(SOURCES) $(HEADERS)
gcc -g -Wall -Werror -Wfatal-errors -O2 -o $@ $(SOURCES)
disasmtest: mips-sim mipscode/insts
./mips-sim -d mipscode/insts > insts.dump
@diff insts.dump mipscode/insts.dump && echo "DISASSEMBLY TEST PASSED!" || echo "DISASSEMBLY TEST FAILED!"
%_test: mipscode/% mipscode/%.trace
./mips-sim -r $< > test.trace
@diff test.trace $(addsuffix .trace, $(basename $<)) && echo "$@ PASSED" || echo "$@ FAILED"
runtest: mips-sim insts_test rt3_test rt13_test rt25_test
@echo "Tests Complete"
clean:
rm -f mips-sim $(addprefix mipscode/, $(ASM_TESTS)) $(addsuffix .o, $(addprefix mipscode/, $(ASM_TESTS))) *.dump *.trace