forked from cksystemsteaching/selfie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
83 lines (67 loc) · 2.34 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Compiler flags
CFLAGS := -Wall -Wextra -O3 -m32 -D'main(a,b)=main(int argc, char** argv)' -Duint32_t='unsigned int'
# Compile selfie.c into selfie executable
selfie: selfie.c
$(CC) $(CFLAGS) $< -o $@
# Consider these targets as targets, not files
.PHONY : compile quine escape debug replay os vm min mob sat spike riscv-tools all clean
# Self-compile
compile: selfie
./selfie -c selfie.c -o selfie1.m -s selfie1.s -m 3 -c selfie.c -o selfie2.m -s selfie2.s
diff -q selfie1.m selfie2.m
diff -q selfie1.s selfie2.s
# Compile and run quine and compare its output to itself
quine: selfie
./selfie -c manuscript/code/quine.c selfie.c -m 1 | sed '/^.\/selfie/d' | diff -q manuscript/code/quine.c -
# Demonstrate available escape sequences
escape: selfie
./selfie -c manuscript/code/escape.c -m 1
# Run debugger
debug: selfie
./selfie -c manuscript/code/pointer.c -d 1
# Run replay engine
replay: selfie
./selfie -c manuscript/code/division-by-zero.c -r 1
# Run emulator on emulator
os: selfie
./selfie -c selfie.c -o selfie.m -m 2 -l selfie.m -m 1
# Self-compile on two virtual machines
vm: selfie
./selfie -c selfie.c -o selfie3.m -s selfie3.s -m 3 -l selfie3.m -y 3 -l selfie3.m -y 3 -c selfie.c -o selfie4.m -s selfie4.s
diff -q selfie3.m selfie4.m
diff -q selfie3.s selfie4.s
diff -q selfie1.m selfie3.m
diff -q selfie1.s selfie3.s
# Self-compile on two virtual machines on fully mapped virtual memory
min: selfie
./selfie -c selfie.c -o selfie5.m -s selfie5.s -min 15 -l selfie5.m -y 3 -l selfie5.m -y 3 -c selfie.c -o selfie6.m -s selfie6.s
diff -q selfie5.m selfie6.m
diff -q selfie5.s selfie6.s
diff -q selfie3.m selfie5.m
diff -q selfie3.s selfie5.s
# Run mobster
mob: selfie
./selfie -c -mob 1
# Run SAT solver
sat: selfie
./selfie -sat manuscript/cnfs/rivest.cnf
./selfie -c selfie.c -m 1 -sat manuscript/cnfs/rivest.cnf
# Run selfie on spike
spike: selfie
./selfie -c selfie.c -o selfie.m -s selfie.s
spike pk selfie.m -c selfie.c -o selfie7.m -s selfie7.s -m 1
diff -q selfie.m selfie7.m
diff -q selfie.s selfie7.s
# Build and update riscv32-tools Docker image
riscv-tools:
docker build -f Dockerfile-riscv-tools -t joanbm/riscv32-tools .
docker login -u joanbm
docker push joanbm/riscv32-tools
# Run everything
all: compile quine debug replay os vm min mob sat
# Clean up
clean:
rm -rf *.m
rm -rf *.s
rm -rf selfie
rm -rf selfie.exe