-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
93 lines (61 loc) · 2.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
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
DESTDIR=
PREFIX=/usr
BINDIR=/bin
CFLAGS=-Wall -O2 -fomit-frame-pointer
CC=gcc
## compile the repl/compiler by default
owl: bin/ol
## building just the virtual machine to run fasl images
bin/vm: c/vm.c
$(CC) $(CFLAGS) -o bin/vm c/vm.c
c/vm.c: c/ovm.c
echo "unsigned char *heap = 0;" > c/vm.c
cat c/ovm.c >> c/vm.c;
## building the standalone read-eval-print loop and compiler
c/ol.c: .fixedpoint
bin/vm fasl/ol.fasl --run owl/ol.l -- -s some -o c/ol.c
bin/ol: c/ol.c
$(CC) $(CFLAGS) -o bin/new-ol c/ol.c
tests/run bin/new-ol
test -f bin/ol && mv bin/ol bin/old-ol || true
mv bin/new-ol bin/ol
## rebuilding the repl fasl image with itself
fasl/ol.fasl: bin/vm owl/*.l
bin/vm fasl/ol.fasl --run owl/ol.l -- -s none -o fasl/ol-new.fasl
tests/run bin/vm fasl/ol-new.fasl
cp fasl/ol.fasl fasl/ol-old.fasl
mv fasl/ol-new.fasl fasl/ol.fasl
## rebuilding the repl fasl image until a fixed point is reached
.fixedpoint: fasl/ol.fasl
test -d tmp || mkdir tmp
cp fasl/ol.fasl tmp
touch owl/ol.l
make fasl/ol.fasl
diff -q tmp/ol.fasl fasl/ol.fasl && touch .fixedpoint || make .fixedpoint
stable: .fixedpoint
## running unit tests manually against vm+fasl/ol
fasltest: bin/vm
tests/run bin/vm fasl/ol.fasl
test: bin/vm
tests/run bin/ol
## MinGW builds for win32
# these should work on Debian-likes after $ sudo apt-get install mingw32 wine1.2
bin/vm.exe: vm.c
test -x `which i586-mingw32msvc-gcc`
i586-mingw32msvc-gcc $(CFLAGS) -o bin/vm.exe vm.c -lwsock32
bin/ol.exe: ol.c
test -x `which i586-mingw32msvc-gcc`
i586-mingw32msvc-gcc $(CFLAGS) -o bin/ol.exe ol.c -lwsock32
# tests/run.sh wine bin/ol.exe <- stdio does not work in wine :(
## meta
install: bin/ol
test -d $(DESTDIR)$(PREFIX)/bin || mkdir -p $(DESTDIR)$(PREFIX)/bin
cp bin/ol $(DESTDIR)$(PREFIX)/bin
test -d $(DESTDIR)$(PREFIX)/share/man/man1 || mkdir -p $(DESTDIR)$(PREFIX)/share/man/man1
cat doc/ol.1 | gzip -9 > $(DESTDIR)$(PREFIX)/share/man/man1/ol.1.gz
uninstall:
rm $(DESTDIR)$(PREFIX)/bin/ol || echo "no ol"
rm $(DESTDIR)$(PREFIX)/share/man/man1/ol.1.gz || echo "no manpage"
todo: bin/vm
bin/vm fasl/ol.fasl -n owl/*.l | less
.PHONY: install uninstall todo test fasltest stable owl