-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
87 lines (84 loc) · 3.32 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
# Use any of these:
#scheme = guile -s
scheme = mzscheme -r
# SCM gives nice stack traces:
#scheme = scm -f
# Bigloo produces lots of warnings but used to work, but it demands
# that you pass only a single argument to (error ...)
#scheme = bigloo -i
#scheme = elk -l
# The Chicken Scheme interpreter:
#scheme = csi -s
# Stalin doesn't work because it doesn't recognize #\tab, but I seem
# to recall that it had some deeper problem as well.
listing=tmp.s.lst
# Unfortunately RScheme's interpreter "rs" outputs warnings to stdout,
# and it emits a warning when we define the variable "text", so I'm
# not going to bother to make this work with RScheme.
# The code used to mostly work in tinyscheme, but apparently in
# tinyscheme, (read) reads from the program you're running, not from
# stdin. This means the compiler can't read its input, and actually
# it seems to prematurely exit with no error message when it tries.
# It used to work before it started trying to read input... but now it
# has another problem as well when it starts trying to compile the
# standard library: "Error: xxx->string: not a xxx #f". Dunno what
# that's about.
# This -nostdlib flag is optional; it just makes a smaller output
# file. (It's unusual to have an assembly file that can compile both
# with and without -nostdlib, but this is one.)
#asflags = -nostdlib
# If you're using gas, to generate an assembly listing:
asflags = -nostdlib -Wa,-adhlns=$(listing)
all: test tests urscheme-compiler
urscheme-compiler: compiler.s
time $(CC) $(asflags) $< -o $@
compiler.s: compiler.scm
time $(scheme) $< < $< > $@
test: a.out
./a.out
a.out: tmp.s
$(CC) $(asflags) $<
tmp.s: compiler.scm test.crufty.scm
$(scheme) compiler.scm < test.crufty.scm > $@
cp $@ [email protected]
diff -u [email protected] [email protected] ||:
clean:
rm -f a.out tmp.s $(listing) tmp.s.ref tmp.s.ref.old \
urscheme-compiler compiler.s runscheme.s compiler.s.stage2 \
compiler.c compiler_c compiler.gambit.s compiler.so \
compiler.gambit.s compiler.mzc.s
slowtests: chmodding
./runtests
./test-read-char
tests: chmodding urscheme-compiler
urscheme=./urscheme-compiler ./runtests
./test-read-char
summary:
egrep '^;;;|^\(' compiler.scm
chmodding:
chmod 755 runtests runscheme test-read-char
stage2-test: urscheme-compiler compiler.s compiler.scm
time ./urscheme-compiler < compiler.scm > compiler.s.stage2
diff -u compiler.s compiler.s.stage2
# Rule to compile with Gambit.
# The Gambit documentation warns that -O -D___SINGLE_HOST may use too
# much memory or take too long, but on my laptop it only takes two
# minutes to compile, and produces a faster executable.
gambit-test: compiler.s
time gsc -link compiler.scm
time $(CC) -O -D___SINGLE_HOST compiler.c compiler_.c -lgambc -o gambit-compiler
time ./gambit-compiler < compiler.scm > compiler.gambit.s
diff -u compiler.s compiler.gambit.s
# mzc does work, but it's even slower than the MzScheme interpreter
# --- twice as slow! And it takes even longer than Gambit-C to compile.
compiler.so: compiler.scm
time mzc compiler.scm
mzc-test: compiler.s compiler.so
time mzscheme -mve '(load-extension "compiler.so")' < compiler.scm > compiler.mzc.s
diff -u compiler.mzc.s compiler.s
chicken-test: compiler.s
time csc compiler.scm
mv compiler chicken-compiler
time ./chicken-compiler < compiler.scm > compiler.chicken.s
diff -u compiler.s compiler.chicken.s