-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
102 lines (75 loc) · 2.79 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
97
98
99
100
101
102
# Author: Chih-Hung Lu
# Make sure ocamlbuild can find opam-managed packages: first run
#
#
# eval `opam config env`
# Easiest way to build: using ocamlbuild, which in turn uses ocamlfind
CPATH = source/c
MLPATH = source/ml
.PHONY : all
all : fpl.native $(CPATH)/printbig.o $(CPATH)/fplFunctions.o
.PHONY : fpl.native
fpl.native : cleanObjectC
ocamlbuild -use-ocamlfind -pkgs llvm,llvm.analysis -cflags -w,+a-4 \
$(MLPATH)/fpl.native
# "make clean" removes all generated files
.PHONY : clean
cleanObjectC:
@rm -rf $(CPATH)/printbig.o
@rm -rf $(CPATH)/fplFunctions.o
clean :
ocamlbuild -clean
rm -rf testall.log *.diff fpl scanner.ml parser.ml parser.mli
rm -rf $(CPATH)/printbig.o
rm -rf $(CPATH)/fplFunctions.o
rm -rf *.cmx *.cmi *.cmo *.cmx *.o *.s *.ll *.out *.exe *.S
# More detailed: build using ocamlc/ocamlopt + ocamlfind to locate LLVM
OBJS = ast.cmx codegen.cmx parser.cmx scanner.cmx semant.cmx fpl.cmx
fpl : $(OBJS)
ocamlfind ocamlopt -linkpkg -package llvm -package llvm.analysis $(OBJS) -o fpl
scanner.ml : scanner.mll
ocamllex $(MLPATH)/scanner.mll
parser.ml parser.mli : parser.mly
ocamlyacc $(MLPATH)/parser.mly
%.cmo : %.ml
ocamlc -c $<
%.cmi : %.mli
ocamlc -c $<
%.cmx : %.ml
ocamlfind ocamlopt -c -package llvm $<
# Testing the "printbig" example
printbig : $(CPATH)/printbig.c
cc -o printbig -DBUILD_TEST $(CPATH)/printbig.c
fplFunctions : $(CPATH)/fplFunctions.c
cc -o fplFunctions -DBUILD_TEST $(CPATH)/fplFunctions.c
### Generated by "ocamldep *.ml *.mli" after building scanner.ml and parser.ml
ast.cmo :
ast.cmx :
codegen.cmo : ast.cmo
codegen.cmx : ast.cmx
fpl.cmo : semant.cmo scanner.cmo parser.cmi codegen.cmo ast.cmo
fpl.cmx : semant.cmx scanner.cmx parser.cmx codegen.cmx ast.cmx
parser.cmo : ast.cmo parser.cmi
parser.cmx : ast.cmx parser.cmi
scanner.cmo : parser.cmi
scanner.cmx : parser.cmx
semant.cmo : ast.cmo
semant.cmx : ast.cmx
parser.cmi : ast.cmo
# Building the tarball
TESTS = add1 arith1 arith2 arith3 fib for1 for2 func1 func2 func3 \
func4 func5 func6 func7 func8 gcd2 gcd global1 global2 global3 \
hello if1 if2 if3 if4 if5 local1 local2 ops1 ops2 var1 var2 \
while1 while2 printbig
FAILS = assign1 assign2 assign3 dead1 dead2 expr1 expr2 for1 for2 \
for3 for4 for5 func1 func2 func3 func4 func5 func6 func7 func8 \
func9 global1 global2 if1 if2 if3 nomain return1 return2 while1 \
while2
TESTFILES = $(TESTS:%=test-%.mc) $(TESTS:%=test-%.out) \
$(FAILS:%=fail-%.mc) $(FAILS:%=fail-%.err)
TARFILES = $(MLPATH)/ast.ml $(MLPATH)/codegen.ml Makefile _tags $(MLPATH)/fpl.ml $(MLPATH)/parser.mly README \
scanner.mll semant.ml testall.sh $(CPATH)/printbig.c $(CPATH)/fplFunctions.c arcade-font.pbm font2c \
$(TESTFILES:%=tests/%)
fpl-llvm.tar.gz : $(TARFILES)
cd .. && tar czf fpl-llvm/fpl-llvm.tar.gz \
$(TARFILES:%=fpl-llvm/%)