-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathMakefile
96 lines (78 loc) · 2.4 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
84
85
86
87
88
89
90
91
92
93
94
95
96
BIN = interpreter \
compiler-x86 compiler-x64 compiler-arm \
jit-x86 jit-x64 jit-arm
CROSS_COMPILE = arm-linux-gnueabihf-
QEMU_ARM = qemu-arm -L /usr/arm-linux-gnueabihf
LUA = luajit
all: $(BIN)
CFLAGS = -Wall -Werror -std=gnu99 -I.
interpreter: interpreter.c
$(CC) $(CFLAGS) -o $@ $^
compiler-x86: compiler-x86.c
$(CC) $(CFLAGS) -o $@ $^
compiler-x64: compiler-x64.c
$(CC) $(CFLAGS) -o $@ $^
compiler-arm: compiler-arm.c
$(CC) $(CFLAGS) -o $@ $^
run-compiler: compiler-x86 compiler-x64 compiler-arm
./compiler-x86 progs/hello.b > hello.s
$(CC) -m32 -o hello-x86 hello.s
@echo 'x86: ' `./hello-x86`
@echo
./compiler-x64 progs/hello.b > hello.s
$(CC) -o hello-x64 hello.s
@echo 'x64: ' `./hello-x64`
@echo
./compiler-arm progs/hello.b > hello.s
$(CROSS_COMPILE)gcc -o hello-arm hello.s
@echo 'arm: ' `$(QEMU_ARM) hello-arm`
@echo
jit0-x64: tests/jit0-x64.c
$(CC) $(CFLAGS) -o $@ $^
jit-x86: dynasm-driver.c jit-x86.h
$(CC) $(CFLAGS) -o $@ -DJIT=\"jit-x86.h\" \
dynasm-driver.c -m32
jit-x86.h: jit-x86.dasc
$(LUA) dynasm/dynasm.lua -o $@ jit-x86.dasc
run-jit-x86: jit-x86
./jit-x86 progs/hello.b && objdump -D -b binary \
-mi386 -Mx86 /tmp/jitcode
jit-x64: dynasm-driver.c jit-x64.h
$(CC) $(CFLAGS) -o $@ -DJIT=\"jit-x64.h\" \
dynasm-driver.c
jit-x64.h: jit-x64.dasc
$(LUA) dynasm/dynasm.lua -o $@ jit-x64.dasc
run-jit-x64: jit-x64
./jit-x64 progs/hello.b && objdump -D -b binary \
-mi386 -Mx86-64 /tmp/jitcode
jit0-arm: tests/jit0-arm.c
$(CROSS_COMPILE)gcc $(CFLAGS) -o $@ $^
jit-arm: dynasm-driver.c jit-arm.h
$(CROSS_COMPILE)gcc $(CFLAGS) -o $@ -DJIT=\"jit-arm.h\" \
dynasm-driver.c
jit-arm.h: jit-arm.dasc
$(LUA) dynasm/dynasm.lua -o $@ jit-arm.dasc
run-jit-arm: jit-arm
$(QEMU_ARM) jit-arm progs/hello.b && \
$(CROSS_COMPILE)objdump -D -b binary -marm /tmp/jitcode
bench-jit-x86: jit-x86
@echo
@echo Executing Brainf*ck benchmark suite. Be patient.
@echo
@env PATH='.:${PATH}' BF_RUN='$<' tests/bench.py
bench-jit-x64: jit-x64
@echo
@echo Executing Brainf*ck benchmark suite. Be patient.
@echo
@env PATH='.:${PATH}' BF_RUN='$<' tests/bench.py
test: test_stack jit0-x64 jit0-arm
./test_stack
(./jit0-x64 42 ; echo $$?)
($(QEMU_ARM) jit0-arm 42 ; echo $$?)
test_stack: tests/test_stack.c
$(CC) $(CFLAGS) -o $@ $^
clean:
$(RM) $(BIN) \
hello-x86 hello-x64 hello-arm hello.s \
test_stack jit0-x64 jit0-arm \
jit-x86.h jit-x64.h jit-arm.h