-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
107 lines (78 loc) · 3.08 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
107
#Modify this to suit your machine
ifeq ($(ROCKSDB_BASE),)
ROCKSDB_BASE = ./rocksdb
endif
ifeq ($(PROTOBUF_BASE),)
PROTOBUF_BASE = /usr/include
endif
NATIVE_JAVA_CLASSES = org.rocksdbprotobuf.ProtobufMergeOperator
JAR = java/rocksdbprotobuf.jar
CLASSPATH = java/protobuf-java-2.5.0.jar:${ROCKSDB_BASE}/java
SOURCES = src/main/cpp/protobuf_merge.cc \
src/main/cpp/protobuf_logger.cc \
proto/message_base.pb.cc \
proto/prototest.pb.cc \
proto/merge.pb.cc
JNI_SOURCES = src/main/cpp/jni/org_rocksdbprotobuf_protobuf_merge_operator.cc
TEST_OPERATOR_SOURCES = src/test/cpp/test_operator.cc
TEST_DATABASE_SOURCES = src/test/cpp/test_database.cc
INCLUDE = -I$(ROCKSDB_BASE) -I$(ROCKSDB_BASE)/include -I$(PROTOBUF_BASE)/include \
-I${JAVA_HOME}/include -I${JAVA_HOME}/include/linux -I./include \
-I$(ROCKSDB_BASE)/java -I./proto
OPT = -std=c++11 -pthread
#Compiler flags
#if mode variable is empty, setting debug build mode
ifeq ($(mode),debug)
mode = debug
OPT += -g -DDEBUG
else
mode = release
endif
PLATFORM_CCFLAGS =
PLATFORM_CXXFLAGS =
WARNING_FLAGS = -Wall -Werror -Wsign-compare
CFLAGS += $(WARNING_FLAGS) -I. $(INCLUDE) $(PLATFORM_CCFLAGS) $(OPT) -fPIC
CXXFLAGS += $(WARNING_FLAGS) -I. $(INCLUDE) $(PLATFORM_CXXFLAGS) $(OPT) -Woverloaded-virtual -fPIC -static-libstdc++ -static-libgcc -DROCKSDB_PLATFORM_POSIX
LIBOBJECTS = $(SOURCES:.cc=.o)
JNILIBOBJECTS = $(LIBOBJECTS)
JNILIBOBJECTS += $(JNI_SOURCES:.cc=.o)
TEST_OPERATOR_OBJECTS = $(TEST_OPERATOR_SOURCES:.cc=.o)
TEST_DATABASE_OBJECTS = $(TEST_DATABASE_SOURCES:.cc=.o)
# The library name is configurable.
ifeq ($(LIBNAME),)
LIBNAME=librocksdbprotobuf
endif
LIBRARY = ${LIBNAME}.so
JNILIBRARY = ${LIBNAME}jni.so
LDFLAGS = -Lrocksdb -lpthread -lrocksdb -lprotobuf -Wl,-Bdynamic #-lrt -lsnappy -lz -lbz2 -lgflags
all: library
protogen:
protoc -I $(PROTOBUF_BASE) -I proto proto/*.proto --cpp_out=proto
protoc -I $(PROTOBUF_BASE) -I proto proto/merge.proto --java_out=src/main/java
protoc -I $(PROTOBUF_BASE) -I proto proto/prototest.proto --java_out=src/main/java
library: ${LIBRARY}
$(LIBRARY): $(LIBOBJECTS)
rm -f $@
$(CXX) -shared -fPIC -static-libstdc++ -static-libgcc -o $@ $(LIBOBJECTS) $(LDFLAGS)
clean:
-rm test_database test_operator proto/*.pb.*
find . -name "*~" -delete
find . -name "*.o" -delete
find . -name "*.so" -delete
find . -name "*.class" -delete
-rm *.a *.jar
test_operator: $(TEST_OPERATOR_OBJECTS) library
$(CXX) $(CXXFLAGS) -o test_operator $(TEST_OPERATOR_OBJECTS) $(LIBRARY) $(LDFLAGS)
LD_LIBRARY_PATH=.:rocksdb ./test_operator
test_database: $(TEST_DATABASE_OBJECTS) library
$(CXX) $(CXXFLAGS) -o test_database $(TEST_DATABASE_OBJECTS) $(LIBRARY) $(LDFLAGS)
LD_LIBRARY_PATH=.:rocksdb ./test_database
test: test_operator test_database
$(JNILIBRARY): $(JNILIBOBJECTS)
mvn compile
javah -classpath target/classes -d ./include/rocksdb_protobuf -jni $(NATIVE_JAVA_CLASSES)
rm -f $@
$(CXX) -shared -fPIC -static-libstdc++ -static-libgcc -o $@ -L$(ROCKSDB_BASE)/java/target -lrocksdbjni-linux64 $(JNILIBOBJECTS) $(LDFLAGS)
library-java: $(JNILIBRARY)
java: library-java
mvn package