-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·399 lines (368 loc) · 12 KB
/
build.sh
File metadata and controls
executable file
·399 lines (368 loc) · 12 KB
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
#!/usr/bin/env bash
set -x -e
# Every script you write should include set -e at the top.
# This tells bash that it should exit the script
# if any statement returns a non-true return value.
# The benefit of using -e is that it prevents errors snowballing into serious issues
# when they could have been caught earlier. Again, for readability you may want to use set -o errexit.
########################################
# download & build depend software
########################################
WORK_DIR=`pwd`
DEPS_PACKAGE=`pwd`/third_pkg
DEPS_SOURCE=`pwd`/third_src
DEPS_PREFIX=`pwd`/third_party
FLAG_DIR=`pwd`/flag_build
DEPS_CONFIG="--prefix=${DEPS_PREFIX} --disable-shared --with-pic"
# export PATH=${DEPS_PREFIX}/bin:$PATH
mkdir -p ${DEPS_SOURCE} ${DEPS_PREFIX} ${FLAG_DIR}
mkdir -p ${DEPS_PREFIX}/bin ${DEPS_PREFIX}/lib ${DEPS_PREFIX}/include
if [ ! -f "${FLAG_DIR}/dl_third" ]; then
touch "${FLAG_DIR}/dl_third"
fi
cd ${DEPS_SOURCE}
# ldconfig for searching in /usr/lib
# echo "/usr/local/lib" >> /etc/ld.so.conf for searching in /usr/local/lib
# in .bashrc or /etc/profile or shell, export LD_LIBRARY_PATH=/PATH/TO/LIB:$LD_LIBRARY_PATH for searching lib*.so* in other dirs
# or use -rpath/-R for runtime shared-lib searching, prio > LD_LIBRARY_PATH
#Pre-installed
#sudo apt-get install autoconf automake libtool zlib1g zlib1g-dev
# boost
if [ ! -f "${FLAG_DIR}/boost_1_65_0" ] \
|| [ ! -d "${DEPS_PREFIX}/boost" ]; then
cd ${DEPS_PREFIX}
if [ -d "${DEPS_PREFIX}/boost" ]; then
rm -rf ${DEPS_PREFIX}/boost
fi
tar zxvf ${DEPS_PACKAGE}/boost_1_65_0.tar.gz -C .
mv boost_1_65_0 boost
#cd boost
#./bootstrap.sh
#./b2
#sudo ./b2 install
touch "${FLAG_DIR}/boost_1_65_0"
fi
# rapidjson
if [ ! -f "${FLAG_DIR}/rapidjson_1_1_0" ] \
|| [ ! -d "${DEPS_PREFIX}/include/rapidjson" ]; then
cd ${DEPS_SOURCE}
if [ -d "${DEPS_SOURCE}/rapidjson" ]; then
rm -rf ${DEPS_SOURCE}/rapidjson
fi
unzip ${DEPS_PACKAGE}/rapidjson-1.1.0.zip -d .
mv rapidjson-1.1.0 rapidjson && cd rapidjson
cp -a include/rapidjson ${DEPS_PREFIX}/include
touch "${FLAG_DIR}/rapidjson_1_1_0"
fi
# jemalloc
if [ ! -f "${FLAG_DIR}/jemalloc_5_0_1" ] \
|| [ ! -f "${DEPS_PREFIX}/lib/libjemalloc.a" ] \
|| [ ! -d "${DEPS_PREFIX}/include/jemalloc" ]; then
cd ${DEPS_SOURCE}
if [ -d "${DEPS_SOURCE}/jemalloc" ]; then
rm -rf ${DEPS_SOURCE}/jemalloc
fi
unzip ${DEPS_PACKAGE}/jemalloc-5.0.1.zip -d .
mv jemalloc-5.0.1 jemalloc && cd jemalloc
mkdir build
./autogen.sh
./configure --prefix=${DEPS_SOURCE}/jemalloc/build
make -j4
make install_bin install_include install_lib
cd build
cp -a lib/libjemalloc.a ${DEPS_PREFIX}/lib
cp -a include/jemalloc ${DEPS_PREFIX}/include
touch "${FLAG_DIR}/jemalloc_5_0_1"
fi
# gflags
if [ ! -f "${FLAG_DIR}/gflags_2_0" ]; then
cd ${DEPS_SOURCE}
if [ -d "${DEPS_SOURCE}/gflags" ] ; then
rm -rf ${DEPS_SOURCE}/gflags
fi
unzip ${DEPS_PACKAGE}/gflags-2.0.zip -d .
mv gflags-2.0 gflags && cd gflags
./configure
make -j4
make check
sudo make install
sudo ldconfig
touch "${FLAG_DIR}/gflags_2_0"
fi
# googletest
if [ ! -f "${FLAG_DIR}/googletest_1_8_0" ] \
|| [ ! -f "${DEPS_PREFIX}/lib/libgtest.a" ] \
|| [ ! -d "${DEPS_PREFIX}/include/gtest" ]; then
cd ${DEPS_SOURCE}
if [ -d "${DEPS_SOURCE}/googletest" ]; then
rm -rf ${DEPS_SOURCE}/googletest
fi
unzip ${DEPS_PACKAGE}/googletest-release-1.8.0.zip -d .
mv googletest-release-1.8.0 googletest
cd googletest/googletest
g++ -isystem include -I. -pthread -c src/gtest-all.cc
ar -rv libgtest.a gtest-all.o
cp -a libgtest.a ${DEPS_PREFIX}/lib
cp -a include/gtest ${DEPS_PREFIX}/include
touch "${FLAG_DIR}/googletest_1_8_0"
fi
# snappy
# use cmake 3.x or above
if [ ! -f "${FLAG_DIR}/snappy_1_1_7" ] \
|| [ ! -f "${DEPS_PREFIX}/lib/libsnappy.a" ] \
|| [ ! -f "${DEPS_PREFIX}/include/snappy.h" ]; then
cd ${DEPS_SOURCE}
if [ -d "${DEPS_SOURCE}/snappy" ]; then
rm -rf ${DEPS_SOURCE}/snappy
fi
unzip ${DEPS_PACKAGE}/snappy-1.1.7.zip -d .
mv snappy-1.1.7 snappy && cd snappy
mkdir build && cd build
cmake ..
make -j4
cp -a libsnappy.a ${DEPS_PREFIX}/lib
cp -a ${DEPS_SOURCE}/snappy/snappy.h ${DEPS_PREFIX}/include
cp -a snappy-stubs-public.h ${DEPS_PREFIX}/include
touch "${FLAG_DIR}/snappy_1_1_7"
fi
# leveldb
if [ ! -f "${FLAG_DIR}/leveldb_1_2_0" ] \
|| [ ! -f "${DEPS_PREFIX}/lib/libleveldb.a" ] \
|| [ ! -d "${DEPS_PREFIX}/include/leveldb" ]; then
cd ${DEPS_SOURCE}
if [ -d "${DEPS_SOURCE}/leveldb" ]; then
rm -rf ${DEPS_SOURCE}/leveldb
fi
unzip ${DEPS_PACKAGE}/leveldb-1.20.zip -d .
mv leveldb-1.20 leveldb && cd leveldb
make -j4
cp -a out-static/libleveldb.a ${DEPS_PREFIX}/lib
cp -a include/leveldb ${DEPS_PREFIX}/include
touch "${FLAG_DIR}/leveldb_1_2_0"
fi
# protobuf
if [ ! -f "${FLAG_DIR}/protobuf_3_3_2" ] \
|| [ ! -f "${DEPS_PREFIX}/bin/protoc" ] \
|| [ ! -f "${DEPS_PREFIX}/lib/libprotobuf.a" ] \
|| [ ! -d "${DEPS_PREFIX}/include/google/protobuf" ]; then
cd ${DEPS_SOURCE}
if [ -d "${DEPS_SOURCE}/protobuf" ]; then
rm -rf ${DEPS_SOURCE}/protobuf
fi
unzip ${DEPS_PACKAGE}/protobuf-3.3.2.zip -d .
mv protobuf-3.3.2 protobuf && cd protobuf
mkdir build
./autogen.sh
./configure --prefix=${DEPS_SOURCE}/protobuf/build
make -j4
make check
make install
cd build
cp -a bin/protoc ${DEPS_PREFIX}/bin
cp -a lib/libprotobuf.a ${DEPS_PREFIX}/lib
cp -a include/google ${DEPS_PREFIX}/include
touch "${FLAG_DIR}/protobuf_3_3_2"
fi
# sofa-pbrpc
if [ ! -f "${FLAG_DIR}/sofa-pbrpc_1_1_3" ] \
|| [ ! -f "${DEPS_PREFIX}/bin/sofa-pbrpc-client" ] \
|| [ ! -f "${DEPS_PREFIX}/lib/libsofa-pbrpc.a" ] \
|| [ ! -d "${DEPS_PREFIX}/include/sofa/pbrpc" ]; then
cd ${DEPS_SOURCE}
if [ -d "${DEPS_SOURCE}/sofa-pbrpc" ]; then
rm -rf ${DEPS_SOURCE}/sofa-pbrpc
fi
unzip ${DEPS_PACKAGE}/sofa-pbrpc-1.1.3.zip -d .
mv sofa-pbrpc-1.1.3 sofa-pbrpc && cd sofa-pbrpc
mkdir build
sed -i '/BOOST_HEADER_DIR=/ d' depends.mk
sed -i '/PROTOBUF_DIR=/ d' depends.mk
sed -i '/SNAPPY_DIR=/ d' depends.mk
echo "BOOST_HEADER_DIR=${DEPS_PREFIX}/boost" >> depends.mk
echo "PROTOBUF_DIR=${DEPS_PREFIX}" >> depends.mk
echo "SNAPPY_DIR=${DEPS_PREFIX}" >> depends.mk
echo "PREFIX=${DEPS_SOURCE}/sofa-pbrpc/build" >> depends.mk
make -j4
make install
cd build
cp -a bin/sofa-pbrpc-client ${DEPS_PREFIX}/bin
cp -a lib/libsofa-pbrpc.a ${DEPS_PREFIX}/lib
cp -a include/sofa ${DEPS_PREFIX}/include
touch "${FLAG_DIR}/sofa-pbrpc_1_1_3"
fi
# libunwind for gperftools
if [ ! -f "${FLAG_DIR}/libunwind_1_0_0" ] \
|| [ ! -f "${DEPS_PREFIX}/lib/libunwind.a" ] \
|| [ ! -f "${DEPS_PREFIX}/include/libunwind.h" ]; then
cd ${DEPS_SOURCE}
if [ -d "${DEPS_SOURCE}/libunwind" ]; then
rm -rf ${DEPS_SOURCE}/libunwind
fi
unzip ${DEPS_PACKAGE}/libunwind-vanilla_pathscale.zip -d .
mv libunwind-vanilla_pathscale libunwind && cd libunwind
mkdir build
./autogen.sh
./configure --prefix=${DEPS_SOURCE}/libunwind/build --disable-shared --with-pic
make CFLAGS=-fPIC -j4
make CFLAGS=-fPIC install
cd build
cp -a lib/libunwind.a ${DEPS_PREFIX}/lib
cp -a include/libunwind.h ${DEPS_PREFIX}/include
touch "${FLAG_DIR}/libunwind_1_0_0"
fi
# gperftools (tcmalloc)
if [ ! -f "${FLAG_DIR}/gperftools_2_5_0" ] \
|| [ ! -f "${DEPS_PREFIX}/lib/libtcmalloc.a" ] \
|| [ ! -f "${DEPS_PREFIX}/lib/libtcmalloc_minimal.a" ] \
|| [ ! -d "${DEPS_PREFIX}/include/gperftools" ]; then
cd ${DEPS_SOURCE}
if [ -d "${DEPS_SOURCE}/gperftools" ]; then
rm -rf ${DEPS_SOURCE}/gperftools
fi
unzip ${DEPS_PACKAGE}/gperftools-gperftools-2.5.zip -d .
mv gperftools-gperftools-2.5 gperftools && cd gperftools
mkdir build
./autogen.sh
./configure --prefix=${DEPS_SOURCE}/gperftools/build --disable-shared --with-pic CPPFLAGS=-I${DEPS_PREFIX}/include LDFLAGS=-L${DEPS_PREFIX}/lib
make -j4
make install
cd build
cp -a lib/libtcmalloc.a lib/libtcmalloc_minimal.a ${DEPS_PREFIX}/lib
cp -a include/gperftools ${DEPS_PREFIX}/include
touch "${FLAG_DIR}/gperftools_2_5_0"
fi
:<<\EOF
# tbb
if [ ! -f "${FLAG_DIR}/tbb_2017_U7" ] \
|| [ ! -f "${DEPS_PREFIX}/lib/libtbb.so" ] \
|| [ ! -f "${DEPS_PREFIX}/lib/libtbb.so.2" ] \
|| [ ! -d "${DEPS_PREFIX}/include/tbb" ]; then
cd ${DEPS_SOURCE}
if [ -d "${DEPS_SOURCE}/tbb" ]; then
rm -rf ${DEPS_SOURCE}/tbb
fi
unzip ${DEPS_PACKAGE}/tbb-2017_U7.zip -d .
mv tbb-2017_U7 tbb && cd tbb
make
# Note: replace linux_intel64_gcc_cc4.8_libc2.19_kernel3.13.0_release with your system
cd build/linux_intel64_gcc_cc4.8_libc2.19_kernel3.13.0_release
cp -a libtbb.so libtbb.so.2 ${DEPS_PREFIX}/lib
cd ../..
cp -a include/tbb ${DEPS_PREFIX}/include
touch "${FLAG_DIR}/tbb_2017_U7"
fi
# glog
if [ ! -f "${FLAG_DIR}/glog_0_3_4" ]; then
cd ${DEPS_SOURCE}
if [ -d "${DEPS_SOURCE}/glog" ] ; then
rm -rf ${DEPS_SOURCE}/glog
fi
unzip ${DEPS_PACKAGE}/glog-0.3.4.zip -d .
mv glog-0.3.4 glog
cd glog
./configure
make -j4
sudo make install
sudo ldconfig
touch "${FLAG_DIR}/glog_0_3_4"
fi
# cpp-btree
if [ ! -f "${FLAG_DIR}/cpp-btree_1_0_1" ] \
|| [ ! -d "${DEPS_PREFIX}/include/cpp-btree" ]; then
cd ${DEPS_PREFIX}/include
if [ -d "${DEPS_PREFIX}/include/cpp-btree" ]; then
rm -rf ${DEPS_PREFIX}/include/cpp-btree
fi
tar zxvf ${DEPS_PACKAGE}/cpp-btree-1.0.1.tar.gz -C .
mv cpp-btree-1.0.1 cpp-btree
touch "${FLAG_DIR}/cpp-btree_1_0_1"
fi
# libco
if [ ! -f "${FLAG_DIR}/libco-master" ] \
|| [ ! -f "${DEPS_PREFIX}/lib/libcolib.a" ]; then
cd ${DEPS_SOURCE}
if [ -d "${DEPS_SOURCE}/libco" ]; then
rm -rf ${DEPS_SOURCE}/libco
fi
unzip ${DEPS_PACKAGE}/libco-master.zip -d .
mv libco-master libco
cp -a libco ${DEPS_PREFIX}/include
cd libco
make
cp -a lib/libcolib.a ${DEPS_PREFIX}/lib
touch "${FLAG_DIR}/libco-master"
fi
# libuv
if [ ! -f "${FLAG_DIR}/libuv_1_12_0" ]; then
cd ${DEPS_SOURCE}
if [ -d "${DEPS_SOURCE}/libuv" ] ; then
rm -rf ${DEPS_SOURCE}/libuv
fi
unzip ${DEPS_PACKAGE}/libuv-1.12.0.zip -d .
mv libuv-1.12.0 libuv && cd libuv
sh autogen.sh
./configure
make -j4
make check
sudo make install
sudo ldconfig
touch "${FLAG_DIR}/libuv_1_12_0"
fi
# redis
if [ ! -f "${FLAG_DIR}/redis_3_2_11" ]; then
cd ${DEPS_SOURCE}
if [ -d "${DEPS_SOURCE}/redis" ] ; then
rm -rf ${DEPS_SOURCE}/redis
fi
tar zxvf ${DEPS_PACKAGE}/redis-3.2.11.tar.gz -C .
mv redis-3.2.11 redis
cd redis
make
make test
touch "${FLAG_DIR}/redis_3_2_11"
fi
# hiredis
if [ ! -f "${FLAG_DIR}/hiredis_0_13_3" ] \
|| [ ! -f "${DEPS_PREFIX}/lib/libhiredis.a" ] \
|| [ ! -d "${DEPS_PREFIX}/include/hiredis" ]; then
cd ${DEPS_SOURCE}
if [ -d "${DEPS_SOURCE}/hiredis" ] ; then
rm -rf ${DEPS_SOURCE}/hiredis
fi
unzip ${DEPS_PACKAGE}/hiredis-0.13.3.zip -d .
mv hiredis-0.13.3 hiredis
cd hiredis
make
mkdir ${DEPS_PREFIX}/include/hiredis
cp -a hiredis.h read.h sds.h ${DEPS_PREFIX}/include/hiredis
cp -a libhiredis.a ${DEPS_PREFIX}/lib
touch "${FLAG_DIR}/hiredis_0_13_3"
fi
# zeromq
if [ ! -f "${FLAG_DIR}/zeromq_4_2_2" ] \
|| [ ! -f "${DEPS_PREFIX}/lib/libzmq.a" ] \
|| [ ! -f "${DEPS_PREFIX}/include/zmq.h" ]; then
cd ${DEPS_SOURCE}
if [ -d "${DEPS_SOURCE}/zeromq" ] ; then
rm -rf ${DEPS_SOURCE}/zeromq
fi
tar zxvf ${DEPS_PACKAGE}/zeromq-4.2.2.tar.gz -C .
mv zeromq-4.2.2 zeromq && cd zeromq
mkdir build
./configure --prefix=${DEPS_SOURCE}/zeromq/build
make && make check
make install
cd build
cp -a lib/libzmq.a ${DEPS_PREFIX}/lib
cp -a include/zmq.h include/zmq_utils.h ${DEPS_PREFIX}/include
touch "${FLAG_DIR}/zeromq_4_2_2"
fi
EOF
cd ${WORK_DIR}
echo "build complete"
echo "Done"
########################################
# build
########################################
#make clean
#make -j4