-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
129 lines (114 loc) · 3.67 KB
/
build.sh
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
#!/usr/bin/env bash
set -x -e
##############################
# download & build dependency
##############################
WORK_DIR=`pwd`
DEPS_SOURCE=`pwd`/thirdsrc
DEPS_PREFIX=`pwd`/thirdparty
DEPS_CONFIG="--prefix=${DEPS_PREFIX} --disable-shared --with-pic"
FLAG_DIR=`pwd`/.build
export PATH=${DEPS_PREFIX}/bin:$PATH
mkdir -p ${DEPS_PREFIX} ${DEPS_SOURCE} ${FLAG_DIR}
cd ${DEPS_SOURCE}
#boost 1.57.0
if [ ! -d "${DEPS_PREFIX}/boost_1_57_0" ]; then
wget https://raw.githubusercontent.com/lylei9/boost_1_57_0/master/boost_1_57_0.tar.gz
tar zxf boost_1_57_0.tar.gz
rm -rf ${DEPS_PREFIX}/boost_1_57_0
mv boost_1_57_0 ${DEPS_PREFIX}/boost_1_57_0
fi
# protobuf 2.6.1
# you should run sudo apt-get install autoconf automake libtool curl make g++ unzip
if [ ! -f "${DEPS_PREFIX}/lib/libprotobuf.a" ] \
|| [ ! -d "${DEPS_PREFIX}/include/google/protobuf" ]; then
wget https://github.com/google/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.gz
tar zxf protobuf-2.6.1.tar.gz
cd protobuf-2.6.1
autoreconf -ivf
./configure ${DEPS_CONFIG}
make -j4
make install
cd -
fi
# snappy
if [ ! -f "${DEPS_PREFIX}/lib/libsnappy.a" ] \
|| [ ! -f "${DEPS_PREFIX}/include/snappy.h" ]; then
wget https://github.com/google/snappy/releases/download/1.1.3/snappy-1.1.3.tar.gz
tar zxf snappy-1.1.3.tar.gz
cd snappy-1.1.3
./configure ${DEPS_CONFIG}
make -j4
make install
cd -
fi
# sofa-pbrpc
if [ ! -f "${DEPS_PREFIX}/lib/libsofa-pbrpc.a" ] \
|| [ ! -d "${DEPS_PREFIX}/include/sofa/pbrpc" ]; then
rm -rf sofa-pbrpc
git clone --depth=1 https://github.com/baidu/sofa-pbrpc.git sofa-pbrpc
cd sofa-pbrpc
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_1_57_0" >> depends.mk
echo "PROTOBUF_DIR=${DEPS_PREFIX}" >> depends.mk
echo "SNAPPY_DIR=${DEPS_PREFIX}" >> depends.mk
echo "PREFIX=${DEPS_PREFIX}" >> depends.mk
make -j4
make install
cd -
fi
# common
if [ ! -f "${DEPS_PREFIX}/lib/libcommon.a" ]; then
rm -rf common
git clone -b cpp11 https://github.com/baidu/common
cd common
sed -i 's/^PREFIX=.*/PREFIX=..\/..\/thirdparty/' config.mk
sed -i '/^INCLUDE_PATH=*/s/$/ -I..\/..\/thirdparty\/boost_1_57_0/g' Makefile
make -j4
make install
cd -
fi
#leveldb
if [ ! -f "${DEPS_PREFIX}/lib/libleveldb.a" ] \
|| [ ! -d "${DEPS_PREFIX}/include/leveldb" ]; then
rm -rf leveldb
git clone https://github.com/lylei/leveldb.git leveldb
cd leveldb
echo "PREFIX=${DEPS_PREFIX}" > config.mk
make -j4
make install
cd -
fi
# cmake for gflags
if ! which cmake ; then
wget https://cmake.org/files/v3.2/cmake-3.2.1.tar.gz
tar zxf cmake-3.2.1.tar.gz
cd cmake-3.2.1
./configure --prefix=${DEPS_PREFIX}
make -j4
make install
cd -
fi
# gflags
if [ ! -f "${DEPS_PREFIX}/lib/libgflags.a" ] \
|| [ ! -d "${DEPS_PREFIX}/include/gflags" ]; then
git clone https://github.com/gflags/gflags.git gflags-2.2
cd gflags-2.2
cmake -DCMAKE_INSTALL_PREFIX=${DEPS_PREFIX} -DGFLAGS_NAMESPACE=google -DCMAKE_CXX_FLAGS=-fPIC
make -j4
make install
cd -
fi
cd ${WORK_DIR}
echo "PBRPC_PATH=./thirdparty" > depends.mk
echo "PROTOBUF_PATH=./thirdparty" >> depends.mk
echo "PROTOC_PATH=./thirdparty/bin/" >> depends.mk
echo 'PROTOC=$(PROTOC_PATH)protoc' >> depends.mk
echo "PBRPC_PATH=./thirdparty" >> depends.mk
echo "BOOST_PATH=./thirdparty/boost_1_57_0" >> depends.mk
echo "GFLAG_PATH=./thirdparty" >> depends.mk
#echo "GTEST_PATH=./thirdparty" >> depends.mk
echo "COMMON_PATH=./thirdparty" >> depends.mk
#echo "TCMALLOC_PATH=./thirdparty" >> depends.mk