-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
42 lines (33 loc) · 886 Bytes
/
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
UNAME := $(shell uname)
ifeq ($(UNAME), Linux)
FORMAT=aout
PIE=
else
ifeq ($(UNAME), Darwin)
FORMAT=macho
PIE=
endif
endif
PKGS=oUnit,extlib,unix,batteries
BUILD=ocamlbuild -r -use-ocamlfind
_build/util.o: util.c util.h
clang -m32 -c -g -o _build/util.o util.c
_build/gc.o: gc.c gc.h util.h
clang -m32 -c -g -o _build/gc.o gc.c
main: *.ml parser.mly lexer.mll
$(BUILD) -no-hygiene -package $(PKGS) main.native
mv main.native main
test: *.ml parser.mly lexer.mll
$(BUILD) -no-hygiene -package $(PKGS),str test.native
mv test.native test
output/%.run: output/%.o _build/gc.o _build/util.o main.c
clang $(PIE) -mstackrealign -g -m32 -o $@ $^
output/%.o: output/%.s
nasm -f $(FORMAT) -o $@ $<
.PRECIOUS: output/%.s
output/%.s: input/%.snake main
./main $< > $@
clean:
rm -rf output/*.o output/*.s output/*.dSYM output/*.run *.log
rm -rf _build/
rm -f main test