-
Notifications
You must be signed in to change notification settings - Fork 3
/
OMakefile
169 lines (130 loc) · 3.7 KB
/
OMakefile
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
prefix = /usr/local
INSTALL = install
RM = rm -f
HAS_NATDYNLINK = false
if $(file-exists $(shell $(OCAMLC) -where)/dynlink.cmxa)
HAS_NATDYNLINK = true
export HAS_NATDYNLINK
include Atdgen
# allow to override the above variables from command line
DefineCommandVars()
USE_OCAMLFIND = true
NATIVE_ENABLED = true
BYTE_ENABLED = true
VERSION = 1.0.2
match $(string $(shell ocaml -version))
case $"\([0-9]\)\.\([0-9]+\)\."
OCAML_MAJOR = $1
OCAML_MINOR = $2
export
.PHONY: clean
OCAMLOPTFLAGS += -g -inline 100
.PHONY: install
.PHONY: uninstall
OCAMLFLAGS = -g -thread -w +a-4-6-9-27..29-32..99 -warn-error -a
OCAMLFINDFLAGS = -syntax camlp4o -ppopt -lwt-debug
CFLAGS = -g -Wall -O2 -fPIC
if $(ge $(OCAML_MAJOR), 4)
OCAMLFLAGS += -bin-annot
export
OCAMLPACKS[] =
batteries
bytes
camlp4.macro
csv
cryptokit
lwt
lwt.unix
lwt.syntax
lwt.syntax.log
lwt.preemptive
ocamlgraph
atdgen
yojson
if $(not $(defined LEVELDB_DIR))
OCAMLPACKS[] += leveldb
export OCAMLPACKS
else
OCAMLINCLUDES += $(file $(LEVELDB_DIR)/src)
export OCAMLINCLUDES
OCAML_LIBS[] += $(LEVELDB_DIR)/src/leveldb
export OCAML_LIBS
if $(not $(defined EXTPROT_DIR))
OCAMLPACKS[] += extprot
export OCAMLPACKS
else
OCAMLINCLUDES += $(file $(EXTPROT_DIR)/runtime)
export OCAMLINCLUDES
OCAML_LIBS[] += $(EXTPROT_DIR)/runtime/extprot
export OCAML_LIBS
OCAMLPACKS[] += extlib
export OCAMLPACKS
LD_PATHS[] =
$(file src)
$(file src/core)
if $(defined LEVELDB_DIR)
LD_PATHS[] +=
$(file $(LEVELDB_DIR)/leveldb)
$(file $(LEVELDB_DIR)/src)
export LD_PATHS
OCAMLFLAGS += $(mapprefix -cclib, $(addprefix -L, $(LD_PATHS)))
setenv(CAML_LD_LIBRARY_PATH, $(concat :, $(absname $(LD_PATHS))))
# Link flags used by CamlStubLibrary
LINK_FLAGS =
public.CamlStubLibrary(dst, objects, stubs) =
private.stub_objects = $(addsuffix .o, $(stubs))
$(dst).cma $(dst).a dllcaml$(dst).so $(dst).cmxa: \
$(stub_objects) $(addsuffixes .cmo .cmx, $(objects))
ocamlmklib -verbose -oc caml$(dst) -o $(dst) \
$(stub_objects) \
$(OCamlLinkSort $(addsuffixes .cmo, $(objects))) \
$(OCamlLinkSort $(addsuffixes .cmx, $(objects))) \
$(LINK_FLAGS)
CamlSources(mods) =
foreach(mod, $(mods))
$(addsuffixes .cmo .cmi .cmx .sig $(EXT_OBJ), $(mod)):
%.cmxs: %.cmxa
$(OCAMLOPT) -shared -I . -o $@ $< -linkall
.SUBDIRS: doc src test
SRC_EXECS[] =
obigstore
ob_dump
ob_load
ob_repl
TEST_EXECS[] =
ob_benchmark
ob_bm_write
ob_bm_read
ob_bm_makedata
EXECS[] = $(SRC_EXECS) $(TEST_EXECS)
foreach(exec, $(SRC_EXECS))
$(exec): src/$(exec)$(EXE)
ln-or-cp $< $@
foreach(exec, $(TEST_EXECS))
$(exec): test/$(exec)$(EXE)
ln-or-cp $< $@
LIBNAMES[] =
src/core/obigstore_core
src/client/obigstore_client
src/server/obigstore_server
src/util/obigstore_util
LIBS = $(addsuffixes .cma .cmxa, $(LIBNAMES))
if HAS_NATDYNLINK
LIBS += $(addsuffix .cmxs, $(LIBNAMES))
export LIBS
.DEFAULT: $(EXECS) $(LIBS)
META: META.in
sed s/VERSION/$(VERSION)/g $< > $@
install: $(EXECS) $(LIBS) META
$(INSTALL) $(EXECS) $(prefix)/bin
ocamlfind install obigstore META \
$(cd src/core, $(ls *.cmi *.so *.cmxa *.cmxs *.cma *.cmx *.a *.mli)) \
$(cd src/client, $(ls *.cmi *.cmxa *.cmxs *.cma *.cmx *.a *.mli)) \
$(cd src/server, $(ls *.cmi *.cmxa *.cmxs *.cma *.cmx *.a *.mli)) \
$(cd src/util, $(ls *.cmi *.cmxa *.cmxs *.cma *.cmx *.a *.mli))
uninstall:
$(RM) $(addprefix $(prefix)/, $(EXECS))
ocamlfind remove obigstore
clean:
rm -f $(filter-proper-targets $(ls R, .))
# vim: set expandtab: