-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
106 lines (76 loc) · 2.13 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
103
104
105
106
### PARAMETERS #####################################################
PACKAGES=core
INCLUDES=
LIBRARIES=
SYNTAX=sexplib comparelib pa_ounit
MODULES= \
linear_comb \
linear \
linear_regression \
test_linear \
test_linear_regression \
std \
B=solvers
T=$B.cmxa
TESTS=std.exe
FOR_PACK_OPT=-for-pack Solvers
### RULES ##########################################################
SYNTAX_PACKAGES=$(addsuffix .syntax, $(SYNTAX))
PACKAGE_FLAGS=$(addprefix -package , $(SYNTAX_PACKAGES) $(PACKAGES))
FIND_OPTS=$(PACKAGE_FLAGS)
ifdef SYNTAX
ifneq "$(SYNTAX)" ""
FIND_OPTS=-syntax camlp4o $(PACKAGE_FLAGS)
endif
endif
OCAMLOPT_FLAGS=\
$(FIND_OPTS) \
-thread \
-linkpkg \
-w +Y+S+P+U+Z+F-40-41-42 \
-warn-error +Y+S+P+U+Z-40-41-42
OCAMLC=ocamlfind ocamlc $(INCLUDES)
OCAMLOPT=ocamlfind ocamlopt $(INCLUDES)
OCAMLDEP=ocamlfind ocamldep
OCAMLYACC=ocamlfind ocamlyacc
OCAMLLEX=ocamlfind ocamllex -q
LIB_FILES=$(addsuffix .cmxa, $(LIBRARIES))
all: init $T
@echo done
init:
eval `opam config -env`
runtests: $(TESTS)
./$(TESTS) inline-test-runner dummy
OBJECTS=$(addsuffix .cmx, $(MODULES))
SYNTAX_EXT_PACKAGES=$(addsuffix .syntax, $(SYNTAX_EXTS))
$B.cmx: $(OBJECTS)
$(OCAMLOPT) -pack $(OBJECTS) -o $B.cmx
$B.cmo: $(OBJECTS)
$(OCAMLC) -pack $(OBJECTS) -o $B.cmo
std.cmx: std.ml
$(OCAMLOPT) $(OCAMLOPT_FLAGS) $(FOR_PACK_OPT) -c std.ml
std_internal.cmo: std_internal.ml
$(OCAMLC) $(OCAMLOPT_FLAGS) -c std_internal.ml
std_internal.cmx: std_internal.ml
$(OCAMLOPT) $(OCAMLOPT_FLAGS) $(FOR_PACK_OPT) -c std_internal.ml
%.exe: $(OBJECTS)
$(OCAMLOPT) -thread $(addprefix -package , $(PACKAGES)) -linkpkg $(LIB_FILES) $(OBJECTS) -o $*.exe
%.cma: %.cmo
$(OCAMLC) -thread -a $*.cmo -o $*.cma
%.cmxa: %.cmx
$(OCAMLOPT) -a $*.cmx -o $*.cmxa
%_intf.mli: %_intf.ml
ln -sf $*_intf.ml $*_intf.mli
%.cmi: %.mli
$(OCAMLOPT) $(OCAMLOPT_FLAGS) -c $*.mli
%.cmx: %.cmi %.ml
$(OCAMLOPT) $(OCAMLOPT_FLAGS) $(FOR_PACK_OPT) -c $*.ml
%.ml %.mli: %.mly
$(OCAMLYACC) $*.mly
%.ml: %.mli %.mll
$(OCAMLLEX) $*.mll
.depend:
$(OCAMLDEP) $(FIND_OPTS) *.mli *.ml > .depend
clean:
rm -rf .depend *.o *.a *.cmi *.cmo *.cma *.cmx *.cmxa *.exe
include .depend