forked from baidu/tera
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
218 lines (175 loc) · 7.73 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
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
include depends.mk
# OPT ?= -O2 -DNDEBUG # (A) Production use (optimized mode)
OPT ?= -g2 -Wall -Werror # (B) Debug mode, w/ full line-level debugging symbols
# OPT ?= -O2 -g2 -DNDEBUG # (C) Profiling mode: opt, but w/debugging symbols
ifndef CXX
CXX = g++
endif
ifndef CC
CC = gcc
endif
INCPATH += -I./src -I./include -I./src/leveldb/include -I./src/leveldb \
-I./src/sdk/java/native-src $(DEPS_INCPATH)
CFLAGS += $(OPT) $(INCPATH) -fPIC -fvisibility=hidden # hide internal symbol of tera
CXXFLAGS += -std=gnu++11 $(CFLAGS)
LDFLAGS += -rdynamic $(DEPS_LDPATH) $(DEPS_LDFLAGS) -lpthread -lrt -lz -ldl \
-lreadline -lncurses
SO_LDFLAGS += -rdynamic $(DEPS_LDPATH) $(SO_DEPS_LDFLAGS) -lpthread -lrt -lz -ldl \
-shared -Wl,--version-script,so-version-script # hide symbol of thirdparty libs
PROTO_FILES := $(wildcard src/proto/*.proto)
PROTO_OUT_CC := $(PROTO_FILES:.proto=.pb.cc)
PROTO_OUT_H := $(PROTO_FILES:.proto=.pb.h)
MASTER_SRC := $(wildcard src/master/*.cc)
TABLETNODE_SRC := $(wildcard src/tabletnode/*.cc)
IO_SRC := $(wildcard src/io/*.cc)
SDK_SRC := $(wildcard src/sdk/*.cc)
HTTP_SRC := $(wildcard src/sdk/http/*.cc)
PROTO_SRC := $(filter-out %.pb.cc, $(wildcard src/proto/*.cc)) $(PROTO_OUT_CC)
JNI_TERA_SRC := $(wildcard src/sdk/java/native-src/*.cc)
VERSION_SRC := src/version.cc
OTHER_SRC := $(wildcard src/zk/*.cc) $(wildcard src/utils/*.cc) $(VERSION_SRC) \
src/tera_flags.cc
COMMON_SRC := $(wildcard src/common/base/*.cc) $(wildcard src/common/net/*.cc) \
$(wildcard src/common/file/*.cc) $(wildcard src/common/file/recordio/*.cc) \
$(wildcard src/common/console/*.cc)
SERVER_WRAPPER_SRC := src/tera_main_wrapper.cc
SERVER_SRC := src/tera_main.cc src/tera_entry.cc
CLIENT_SRC := src/teracli_main.cc
TEST_CLIENT_SRC := src/tera_test_main.cc
TERA_C_SRC := src/tera_c.cc
MONITOR_SRC := src/monitor/teramo_main.cc
MARK_SRC := src/benchmark/mark.cc src/benchmark/mark_main.cc
TEST_SRC := src/utils/test/prop_tree_test.cc src/utils/test/tprinter_test.cc \
src/io/test/tablet_io_test.cc src/io/test/tablet_scanner_test.cc \
src/master/test/master_impl_test.cc src/io/test/load_test.cc
TEST_OUTPUT := test_output
UNITTEST_OUTPUT := $(TEST_OUTPUT)/unittest
MASTER_OBJ := $(MASTER_SRC:.cc=.o)
TABLETNODE_OBJ := $(TABLETNODE_SRC:.cc=.o)
IO_OBJ := $(IO_SRC:.cc=.o)
SDK_OBJ := $(SDK_SRC:.cc=.o)
PROTO_OBJ := $(PROTO_SRC:.cc=.o)
JNI_TERA_OBJ := $(JNI_TERA_SRC:.cc=.o)
OTHER_OBJ := $(OTHER_SRC:.cc=.o)
COMMON_OBJ := $(COMMON_SRC:.cc=.o)
SERVER_WRAPPER_OBJ := $(SERVER_WRAPPER_SRC:.cc=.o)
SERVER_OBJ := $(SERVER_SRC:.cc=.o)
CLIENT_OBJ := $(CLIENT_SRC:.cc=.o)
TEST_CLIENT_OBJ := $(TEST_CLIENT_SRC:.cc=.o)
TERA_C_OBJ := $(TERA_C_SRC:.cc=.o)
MONITOR_OBJ := $(MONITOR_SRC:.cc=.o)
MARK_OBJ := $(MARK_SRC:.cc=.o)
HTTP_OBJ := $(HTTP_SRC:.cc=.o)
TEST_OBJ := $(TEST_SRC:.cc=.o)
ALL_OBJ := $(MASTER_OBJ) $(TABLETNODE_OBJ) $(IO_OBJ) $(SDK_OBJ) $(PROTO_OBJ) \
$(JNI_TERA_OBJ) $(OTHER_OBJ) $(COMMON_OBJ) $(SERVER_OBJ) $(CLIENT_OBJ) \
$(TEST_CLIENT_OBJ) $(TERA_C_OBJ) $(MONITOR_OBJ) $(MARK_OBJ) $(TEST_OBJ) \
$(SERVER_WRAPPER_OBJ)
LEVELDB_LIB := src/leveldb/libleveldb.a
LEVELDB_UTIL := src/leveldb/util/histogram.o src/leveldb/port/port_posix.o
PROGRAM = tera_main tera_master tabletserver teracli teramo tera_test
LIBRARY = libtera.a
SOLIBRARY = libtera.so
TERA_C_SO = libtera_c.so
JNILIBRARY = libjni_tera.so
BENCHMARK = tera_bench tera_mark
TESTS = prop_tree_test tprinter_test string_util_test tablet_io_test \
tablet_scanner_test fragment_test progress_bar_test master_impl_test load_test
.PHONY: all clean cleanall test
all: $(PROGRAM) $(LIBRARY) $(SOLIBRARY) $(TERA_C_SO) $(JNILIBRARY) $(BENCHMARK)
mkdir -p build/include build/lib build/bin build/log build/benchmark
cp $(PROGRAM) build/bin
cp $(LIBRARY) $(SOLIBRARY) $(TERA_C_SO) $(JNILIBRARY) build/lib
cp src/leveldb/tera_bench .
cp -r benchmark/*.sh $(BENCHMARK) build/benchmark
cp -r include build/
cp -r conf build
echo 'Done'
test: $(TESTS)
mkdir -p $(UNITTEST_OUTPUT)
cp $(TESTS) $(UNITTEST_OUTPUT)
$(MAKE) test -C src/leveldb
cp src/leveldb/*_test $(UNITTEST_OUTPUT)
check: test
( cd $(UNITTEST_OUTPUT); \
for t in $(TESTS); do echo "***** Running $$t"; ./$$t || exit 1; done )
$(MAKE) check -C src/leveldb
sh ./src/sdk/python/checker.sh
clean:
rm -rf $(ALL_OBJ) $(PROTO_OUT_CC) $(PROTO_OUT_H) $(TEST_OUTPUT)
$(MAKE) clean -C src/leveldb
rm -rf $(PROGRAM) $(LIBRARY) $(SOLIBRARY) $(TERA_C_SO) $(JNILIBRARY) $(BENCHMARK) $(TESTS) terahttp
cleanall:
$(MAKE) clean
rm -rf build
tera_main: src/tera_main_wrapper.o src/version.o src/tera_flags.o
$(CXX) -o $@ $^ $(LDFLAGS)
tera_master: $(SERVER_OBJ) $(MASTER_OBJ) $(IO_OBJ) $(SDK_OBJ) \
$(PROTO_OBJ) $(OTHER_OBJ) $(COMMON_OBJ) $(LEVELDB_LIB)
$(CXX) -o $@ $^ $(LDFLAGS)
tabletserver: $(SERVER_OBJ) $(TABLETNODE_OBJ) $(IO_OBJ) $(SDK_OBJ) \
$(PROTO_OBJ) $(OTHER_OBJ) $(COMMON_OBJ) $(LEVELDB_LIB)
$(CXX) -o $@ $^ $(LDFLAGS)
libtera.a: $(SDK_OBJ) $(PROTO_OBJ) $(OTHER_OBJ) $(COMMON_OBJ) $(LEVELDB_UTIL)
$(AR) -rs $@ $^
libtera.so: $(SDK_OBJ) $(PROTO_OBJ) $(OTHER_OBJ) $(COMMON_OBJ) $(LEVELDB_UTIL)
$(CXX) -o $@ $^ $(SO_LDFLAGS)
libtera_c.so: $(TERA_C_OBJ) $(LIBRARY)
$(CXX) -o $@ $^ $(SO_LDFLAGS)
teracli: $(CLIENT_OBJ) $(LIBRARY)
$(CXX) -o $@ $^ $(LDFLAGS)
teramo: $(MONITOR_OBJ) $(LIBRARY)
$(CXX) -o $@ $^ $(LDFLAGS)
tera_mark: $(MARK_OBJ) $(LIBRARY) $(LEVELDB_LIB)
$(CXX) -o $@ $^ $(LDFLAGS)
tera_test: $(TEST_CLIENT_OBJ) $(LIBRARY)
$(CXX) -o $@ $(TEST_CLIENT_OBJ) $(LIBRARY) $(LDFLAGS)
terahttp: $(HTTP_OBJ) $(PROTO_OBJ) $(LIBRARY)
$(CXX) -o $@ $^ $(LDFLAGS)
libjni_tera.so: $(JNI_TERA_OBJ) $(LIBRARY)
$(CXX) -o $@ $^ $(SO_LDFLAGS)
src/leveldb/libleveldb.a: FORCE
CC=$(CC) CXX=$(CXX) $(MAKE) -C src/leveldb
tera_bench:
# unit test
prop_tree_test: src/utils/test/prop_tree_test.o $(LIBRARY)
$(CXX) -o $@ $^ $(LDFLAGS)
tprinter_test: src/utils/test/tprinter_test.o $(LIBRARY)
$(CXX) -o $@ $^ $(LDFLAGS)
string_util_test: src/utils/test/string_util_test.o $(LIBRARY)
$(CXX) -o $@ $^ $(LDFLAGS)
tablet_io_test: src/io/test/tablet_io_test.o src/tabletnode/tabletnode_sysinfo.o \
$(IO_OBJ) $(PROTO_OBJ) $(OTHER_OBJ) $(COMMON_OBJ) $(LEVELDB_LIB)
$(CXX) -o $@ $^ $(LDFLAGS)
load_test: src/io/test/load_test.o src/tabletnode/tabletnode_sysinfo.o \
$(IO_OBJ) $(PROTO_OBJ) $(OTHER_OBJ) $(COMMON_OBJ) $(LEVELDB_LIB)
$(CXX) -o $@ $^ $(LDFLAGS)
fragment_test: src/utils/test/fragment_test.o src/utils/fragment.o
$(CXX) -o $@ $^ $(LDFLAGS)
progress_bar_test: src/common/console/progress_bar_test.o src/common/console/progress_bar.o
$(CXX) -o $@ $^ $(LDFLAGS)
tablet_scanner_test: src/io/test/tablet_scanner_test.o src/tabletnode/tabletnode_sysinfo.o \
$(IO_OBJ) $(PROTO_OBJ) $(OTHER_OBJ) $(COMMON_OBJ) $(LEVELDB_LIB)
$(CXX) -o $@ $^ $(LDFLAGS)
master_impl_test: src/master/test/master_impl_test.o src/tera_entry.cc $(MASTER_OBJ) $(IO_OBJ) $(SDK_OBJ) \
$(PROTO_OBJ) $(OTHER_OBJ) $(COMMON_OBJ) $(LEVELDB_LIB)
$(CXX) -o $@ $^ $(LDFLAGS)
$(ALL_OBJ): %.o: %.cc $(PROTO_OUT_H)
$(CXX) $(CXXFLAGS) -c $< -o $@
$(VERSION_SRC): FORCE
sh build_version.sh
.PHONY: FORCE
FORCE:
.PHONY: proto
proto: $(PROTO_OUT_CC) $(PROTO_OUT_H)
%.pb.cc %.pb.h: %.proto
$(PROTOC) --proto_path=./src/proto/ --proto_path=$(PROTOBUF_INCDIR) \
--proto_path=$(SOFA_PBRPC_INCDIR) \
--cpp_out=./src/proto/ $<
# install output into system directories
.PHONY: install
install: $(PROGRAM) $(LIBRARY) $(SOLIBRARY) $(TERA_C_SO) $(JNILIBRARY)
mkdir -p $(INSTALL_PREFIX)/bin $(INSTALL_PREFIX)/include $(INSTALL_PREFIX)/lib
cp -rf $(PROGRAM) $(INSTALL_PREFIX)/bin
cp -rf include/* $(INSTALL_PREFIX)/include
cp -rf $(LIBRARY) $(SOLIBRARY) $(TERA_C_SO) $(JNILIBRARY) $(INSTALL_PREFIX)/lib