-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
69 lines (51 loc) · 2.14 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
ROCKS_VERSION ?= 5.8
ROCKS_INSTALL ?= $(THRIFTROOT)
ROCKS_LIBDIR ?= $(ROCKS_INSTALL)/lib
ROCKS_LIB ?= rocksdb
export ROCKS_LIB ROCKS_LIBDIR ROCKS_INSTALL
ifeq ($(ROCKS_VERSION),myrocks)
UNIFDEF_ARGS = -D ROCKS_VERSION_MYROCKS
else
UNIFDEF_ARGS = -U ROCKS_VERSION_MYROCKS
endif
OCAMLLIB := $(shell ocamlc -where)
OCAMLMKLIB_FLAGS= \
-Wl,-rpath=$(ROCKS_LIBDIR) -L$(ROCKS_LIBDIR) -l$(ROCKS_LIB) \
-lstdc++
RESULT=ocaml_rocksdb
RESULT_PACKAGE=ocaml-rocksdb
CXXFLAGS += -g2 -I. -I`ocamlfind query cppffigen` -I$(OCAMLLIB) -I$(ROCKS_INSTALL)/include -std=gnu++11 -fno-rtti
PACKS = result,threads,core_kernel
MLI=rocks_types.mli $(RESULT).mli rocks.mli
ML= misc.ml rocks_types.ml $(RESULT).ml rocks.ml
CMO= $(patsubst %.ml,%.cmo, $(ML))
CMX= $(patsubst %.ml,%.cmx, $(ML))
CMI= $(patsubst %.ml,%.cmi, $(ML))
OBJECTS = $(CMO) $(CMX) $(CMI)
all: $(RESULT).cma $(RESULT).cmxa dll$(RESULT).so
$(RESULT).cma $(RESULT).cmxa dll$(RESULT).so: $(OBJECTS) $(RESULT)_stubs.o
ocamlmklib -verbose -o $(RESULT) $(CMO) $(CMX) $(RESULT)_stubs.o $(OCAMLMKLIB_FLAGS)
$(CMO) $(CMI): $(ML)
ocamlfind ocamlc -thread -package $(PACKS) -c -g $(MLI)
ocamlfind ocamlc -thread -package $(PACKS) -c -g $(ML)
$(CMX): $(ML) $(CMI)
ocamlfind ocamlopt -thread -package $(PACKS) -c $(ML)
$(RESULT).ml $(RESULT).mli $(RESULT)_stubs.cc: rocksdb-ffi.idl
cppffigen --output ml < rocksdb-ffi.idl > $(RESULT).ml
cppffigen --output mli < rocksdb-ffi.idl > $(RESULT).mli
cppffigen --output cpp < rocksdb-ffi.idl > $(RESULT)_stubs.cc
$(RESULT)_stubs.o: $(RESULT)_stubs.cc
g++ -c -fPIC ${CXXFLAGS} -DPIC -o $(RESULT)_stubs.o $(RESULT)_stubs.cc
top:
ocamlfind ocamlmktop -thread -package $(PACKS),$(RESULT_PACKAGE) -linkpkg -o $(RESULT_PACKAGE).top
uninstall::
ocamlfind remove $(RESULT_PACKAGE)
install:: META
ocamlfind install $(RESULT_PACKAGE) META $(CMI) $(RESULT).cma $(RESULT).cmxa $(RESULT).a lib$(RESULT).a dll$(RESULT).so
META: META.pl
./META.pl > META
clean::
rm -f META *.a *.cma *.cmi *.cmo *.cmx *.cmxa *.o *.so \
$(RESULT).ml $(RESULT).mli $(RESULT).top \
$(RESULT)_stubs.c $(RESULT)_stubs.c.ORIG $(RESULT)_stubs.cc $(RESULT_PACKAGE).top \
rocksffi.ml rocksffi.cc rocksffi.o