-
Notifications
You must be signed in to change notification settings - Fork 439
/
build.sh
executable file
·289 lines (261 loc) · 11 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
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
#!/bin/bash
set -e -u -E # this script will exit if any sub-command fails
MIRROR=origin
if [ $# -ge 1 ]; then
MIRROR=$1
fi
WORK_DIR=$(cd $(dirname $0); pwd)
if [ ! -f "${WORK_DIR}/build.conf" ]; then
cp ${WORK_DIR}/build.conf.template ${WORK_DIR}/build.conf
fi
source ./build.conf ${MIRROR}
########################################
# download & build depend software
########################################
DEPS_SOURCE=$WORK_DIR/thirdsrc
DEPS_PREFIX=$WORK_DIR/thirdparty
DEPS_CONFIG="--prefix=${DEPS_PREFIX} --disable-shared --with-pic"
FLAG_DIR=$WORK_DIR/.build
export PATH=${DEPS_PREFIX}/bin:$PATH
mkdir -p ${DEPS_SOURCE} ${DEPS_PREFIX} ${FLAG_DIR}
if [ ! -f "$WORK_DIR/depends.mk" ]; then
cp $WORK_DIR/depends.mk.template $WORK_DIR/depends.mk
fi
cd ${DEPS_SOURCE}
# boost
if [ ${BOOST_VERSION} == "DISABLE" ]; then
echo "Disable boost."
elif [ ! -f "${FLAG_DIR}/boost_${BOOST_VERSION}" ] \
|| [ ! -d "${DEPS_PREFIX}/boost_${BOOST_VERSION}/boost" ]; then
wget --no-check-certificate -O boost_${BOOST_VERSION}.tar.bz2 ${BOOST_URL}
tar xjf boost_${BOOST_VERSION}.tar.bz2 --recursive-unlink
rm -rf ${DEPS_PREFIX}/boost_${BOOST_VERSION}
mv boost_${BOOST_VERSION} ${DEPS_PREFIX}
touch "${FLAG_DIR}/boost_${BOOST_VERSION}"
fi
# protobuf
if [ ${PROTOBUF_VERSION} == "DISABLE" ]; then
echo "Disable protobuf."
elif [ ! -f "${FLAG_DIR}/protobuf_${PROTOBUF_VERSION}" ] \
|| [ ! -f "${DEPS_PREFIX}/lib/libprotobuf.a" ] \
|| [ ! -d "${DEPS_PREFIX}/include/google/protobuf" ]; then
#wget --no-check-certificate -O protobuf-${PROTOBUF_VERSION}.tar.gz ${PROTOBUF_URL}
curl -k -L ${PROTOBUF_URL} -o protobuf-${PROTOBUF_VERSION}.tar.gz
tar zxf protobuf-${PROTOBUF_VERSION}.tar.gz --recursive-unlink
cd protobuf-${PROTOBUF_VERSION}
./configure ${DEPS_CONFIG}
make -j4
make install
cd -
touch "${FLAG_DIR}/protobuf_${PROTOBUF_VERSION}"
fi
# snappy
if [ ${SNAPPY_VERSION} == "DISABLE" ]; then
echo "Disable snappy."
elif [ ! -f "${FLAG_DIR}/snappy_${SNAPPY_VERSION}" ] \
|| [ ! -f "${DEPS_PREFIX}/lib/libsnappy.a" ] \
|| [ ! -f "${DEPS_PREFIX}/include/snappy.h" ]; then
#wget --no-check-certificate -O snappy-${SNAPPY_VERSION}.tar.gz ${SNAPPY_URL}
curl -k -L ${SNAPPY_URL} -o snappy-${SNAPPY_VERSION}.tar.gz
tar zxf snappy-${SNAPPY_VERSION}.tar.gz --recursive-unlink
cd snappy-${SNAPPY_VERSION}
./configure ${DEPS_CONFIG}
make -j4
make install
cd -
touch "${FLAG_DIR}/snappy_${SNAPPY_VERSION}"
fi
# sofa-pbrpc
if [ ${SOFA_PBRPC_VERSION} == "DISABLE" ]; then
echo "Disable sofa-pbrpc."
elif [ ! -f "${FLAG_DIR}/sofa-pbrpc_${SOFA_PBRPC_VERSION}" ] \
|| [ ! -f "${DEPS_PREFIX}/lib/libsofa-pbrpc.a" ] \
|| [ ! -d "${DEPS_PREFIX}/include/sofa/pbrpc" ]; then
#wget --no-check-certificate -O sofa-pbrpc-${SOFA_PBRPC_VERSION}.tar.gz ${SOFA_PBRPC_URL}
curl -k -L ${SOFA_PBRPC_URL} -o sofa-pbrpc-${SOFA_PBRPC_VERSION}.tar.gz
tar zxf sofa-pbrpc-${SOFA_PBRPC_VERSION}.tar.gz --recursive-unlink
cd sofa-pbrpc-${SOFA_PBRPC_VERSION}
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_${BOOST_VERSION}" >> 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 ..
touch "${FLAG_DIR}/sofa-pbrpc_${SOFA_PBRPC_VERSION}"
fi
# zookeeper
if [ ${ZOOKEEPER_VERSION} == "DISABLE" ]; then
echo "Disable zookeeper."
elif [ ! -f "${FLAG_DIR}/zookeeper_${ZOOKEEPER_VERSION}" ] \
|| [ ! -f "${DEPS_PREFIX}/lib/libzookeeper_mt.a" ] \
|| [ ! -d "${DEPS_PREFIX}/include/zookeeper" ]; then
wget --no-check-certificate -O zookeeper-${ZOOKEEPER_VERSION}.tar.gz ${ZOOKEEPER_URL}
tar zxf zookeeper-${ZOOKEEPER_VERSION}.tar.gz --recursive-unlink
cd zookeeper-${ZOOKEEPER_VERSION}/src/c
./configure ${DEPS_CONFIG}
make -j4
make install
cd -
touch "${FLAG_DIR}/zookeeper_${ZOOKEEPER_VERSION}"
fi
# gflags
if [ ${GFLAGS_VERSION} == "DISABLE" ]; then
echo "Disable gflags."
elif [ ! -f "${FLAG_DIR}/gflags_${GFLAGS_VERSION}" ] \
|| [ ! -f "${DEPS_PREFIX}/lib/libgflags.a" ] \
|| [ ! -d "${DEPS_PREFIX}/include/gflags" ]; then
#wget --no-check-certificate -O gflags-${GFLAGS_VERSION}.tar.gz ${GFLAGS_URL}
curl -k -L ${GFLAGS_URL} -o gflags-${GFLAGS_VERSION}.tar.gz
tar zxf gflags-${GFLAGS_VERSION}.tar.gz --recursive-unlink
cd gflags-${GFLAGS_VERSION}
cmake -DCMAKE_INSTALL_PREFIX=${DEPS_PREFIX} -DGFLAGS_NAMESPACE=google -DCMAKE_CXX_FLAGS=-fPIC
make -j4
make install
cd -
touch "${FLAG_DIR}/gflags_${GFLAGS_VERSION}"
fi
# glog
if [ ${GLOG_VERSION} == "DISABLE" ]; then
echo "Disable glog."
elif [ ! -f "${FLAG_DIR}/glog_${GLOG_VERSION}" ] \
|| [ ! -f "${DEPS_PREFIX}/lib/libglog.a" ] \
|| [ ! -d "${DEPS_PREFIX}/include/glog" ]; then
#wget --no-check-certificate -O glog-${GLOG_VERSION}.tar.gz ${GLOG_URL}
curl -k -L ${GLOG_URL} -o glog-${GLOG_VERSION}.tar.gz
tar zxf glog-${GLOG_VERSION}.tar.gz --recursive-unlink
cd glog-${GLOG_VERSION}
./configure ${DEPS_CONFIG} CPPFLAGS=-I${DEPS_PREFIX}/include LDFLAGS=-L${DEPS_PREFIX}/lib
make -j4
make install
cd -
touch "${FLAG_DIR}/glog_${GLOG_VERSION}"
fi
# gtest
if [ ${GTEST_VERSION} == "DISABLE" ]; then
echo "Disable gtest."
elif [ ! -f "${FLAG_DIR}/gtest_${GTEST_VERSION}" ] \
|| [ ! -f "${DEPS_PREFIX}/lib/libgtest.a" ] \
|| [ ! -d "${DEPS_PREFIX}/include/gtest" ]; then
#wget --no-check-certificate -O googletest-release-${GTEST_VERSION}.tar.gz ${GTEST_URL}
curl -k -L ${GTEST_URL} -o googletest-release-${GTEST_VERSION}.tar.gz
tar zxf googletest-release-${GTEST_VERSION}.tar.gz --recursive-unlink
cd googletest-release-${GTEST_VERSION}/googletest
# XXX make gcc3 happy; what's the cmake way?
sed -i 's/ -Wno-missing-field-initializers/ /' cmake/internal_utils.cmake
mkdir tmpbuild
cd tmpbuild
cmake -DCMAKE_C_FLAGS="-fPIC" -DCMAKE_CXX_FLAGS="-fPIC" ..
make
cd ..
cp -af tmpbuild/libgtest.a ${DEPS_PREFIX}/lib
cp -af tmpbuild/libgtest_main.a ${DEPS_PREFIX}/lib
cp -af include/gtest ${DEPS_PREFIX}/include
cd ../..
touch "${FLAG_DIR}/gtest_${GTEST_VERSION}"
fi
# libunwind for gperftools
if [ ${LIBUNWIND_VERSION} == "DISABLE" ]; then
echo "Disable libunwind."
elif [ ! -f "${FLAG_DIR}/libunwind_${LIBUNWIND_VERSION}" ] \
|| [ ! -f "${DEPS_PREFIX}/lib/libunwind.a" ] \
|| [ ! -f "${DEPS_PREFIX}/include/libunwind.h" ]; then
wget --no-check-certificate -O libunwind-${LIBUNWIND_VERSION}.tar.gz ${LIBUNWIND_URL}
tar xzf libunwind-${LIBUNWIND_VERSION}.tar.gz --recursive-unlink
cd libunwind-${LIBUNWIND_VERSION}
./configure ${DEPS_CONFIG}
make CFLAGS=-fPIC -j4
make CFLAGS=-fPIC install
cd -
touch "${FLAG_DIR}/libunwind_${LIBUNWIND_VERSION}"
fi
# gperftools (tcmalloc)
if [ ${GPERFTOOLS_VERSION} == "DISABLE" ]; then
echo "Disable gperftools."
elif [ ! -f "${FLAG_DIR}/gperftools_${GPERFTOOLS_VERSION}" ] \
|| [ ! -f "${DEPS_PREFIX}/lib/libtcmalloc_minimal.a" ]; then
#wget --no-check-certificate -O gperftools-${GPERFTOOLS_VERSION}.tar.gz ${GPERFTOOLS_URL}
curl -k -L ${GPERFTOOLS_URL} -o gperftools-${GPERFTOOLS_VERSION}.tar.gz
tar zxf gperftools-${GPERFTOOLS_VERSION}.tar.gz --recursive-unlink
cd gperftools-${GPERFTOOLS_VERSION}
./configure ${DEPS_CONFIG} CPPFLAGS=-I${DEPS_PREFIX}/include LDFLAGS=-L${DEPS_PREFIX}/lib
make -j4
make install
cd -
touch "${FLAG_DIR}/gperftools_${GPERFTOOLS_VERSION}"
fi
# ins
if [ ${INS_VERSION} == "DISABLE" ]; then
echo "Disable ins."
elif [ ! -f "${FLAG_DIR}/ins_${INS_VERSION}" ] \
|| [ ! -f "${DEPS_PREFIX}/lib/libins_sdk.a" ] \
|| [ ! -f "${DEPS_PREFIX}/include/ins_sdk.h" ]; then
#wget --no-check-certificate -O ins-${INS_VERSION}.tar.gz ${INS_URL}
curl -k -L ${INS_URL} -o ins-${INS_VERSION}.tar.gz
tar zxf ins-${INS_VERSION}.tar.gz --recursive-unlink
cd ins-${INS_VERSION}
sed -i "s|^PREFIX=.*|PREFIX=${DEPS_PREFIX}|" Makefile
sed -i "s|^PROTOC ?=.*|PROTOC ?=${DEPS_PREFIX}/bin/protoc|" Makefile
sed -i "s|^SNAPPY_PATH ?=.*|SNAPPY_PATH ?=${DEPS_PREFIX}|" Makefile
sed -i "s|^BOOST_PATH ?=.*|BOOST_PATH ?=${DEPS_PREFIX}/boost_${BOOST_VERSION}|" Makefile
sed -i "s|^GFLAGS_PATH ?=.*|GFLAGS_PATH ?=${DEPS_PREFIX}|" Makefile
sed -i "s|^PROTOBUF_PATH ?=.*|PROTOBUF_PATH ?=${DEPS_PREFIX}|" Makefile
sed -i "s|^PBRPC_PATH ?=.*|PBRPC_PATH ?=${DEPS_PREFIX}|" Makefile
sed -i "s|^GTEST_PATH ?=.*|GTEST_PATH ?=${DEPS_PREFIX}|" Makefile
#BOOST_PATH=${DEPS_PREFIX}/boost_${BOOST_VERSION} make install_sdk
make -j4 install_sdk
cd -
touch "${FLAG_DIR}/ins_${INS_VERSION}"
fi
# nose (for test)
if [ ${NOSE_VERSION} == "DISABLE" ]; then
echo "Disable nose."
elif [ ! -f "${FLAG_DIR}/nose_${NOSE_VERSION}" ] \
|| [ ! -f "${DEPS_PREFIX}/bin/nosetests" ] \
|| [ ! -d "${DEPS_PREFIX}/lib/nose" ]; then
wget --no-check-certificate -O nose-${NOSE_VERSION}.tar.gz ${NOSE_URL}
tar zxf nose-${NOSE_VERSION}.tar.gz --recursive-unlink
cd nose-${NOSE_VERSION}
export PYTHONPATH=${DEPS_PREFIX}/lib
python setup.py install --prefix=. --install-scripts=${DEPS_PREFIX}/bin --install-lib=${DEPS_PREFIX}/lib
cd -
touch "${FLAG_DIR}/nose_${NOSE_VERSION}"
fi
# mongoose (for test)
if [ ${MONGOOSE_VERSION} == "DISABLE" ]; then
echo "Disable mongoose."
elif [ ! -f "${FLAG_DIR}/mongoose_${MONGOOSE_VERSION}" ] \
|| [ ! -f "${DEPS_PREFIX}/include/mongoose.h" ] \
|| [ ! -f "${DEPS_PREFIX}/lib/libmongoose.a" ]; then
#wget --no-check-certificate -O mongoose-${MONGOOSE_VERSION}.tar.gz ${MONGOOSE_URL}
curl -k -L ${MONGOOSE_URL} -o mongoose-${MONGOOSE_VERSION}.tar.gz
tar zxf mongoose-${MONGOOSE_VERSION}.tar.gz --recursive-unlink
cd mongoose-${MONGOOSE_VERSION}
gcc -c -D_GNU_SOURCE -D__STDC_LIMIT_MACROS -g2 -pipe -Wall -Werror -fPIC mongoose.c
ar -lr libmongoose.a mongoose.o
cp mongoose.h ${DEPS_PREFIX}/include
cp libmongoose.a ${DEPS_PREFIX}/lib
touch "${FLAG_DIR}/mongoose_${MONGOOSE_VERSION}"
fi
cd ${WORK_DIR}
########################################
# config depengs.mk
########################################
sed -i "s:^SOFA_PBRPC_PREFIX=.*:SOFA_PBRPC_PREFIX=$DEPS_PREFIX:" depends.mk
sed -i "s:^PROTOBUF_PREFIX=.*:PROTOBUF_PREFIX=$DEPS_PREFIX:" depends.mk
sed -i "s:^SNAPPY_PREFIX=.*:SNAPPY_PREFIX=$DEPS_PREFIX:" depends.mk
sed -i "s:^ZOOKEEPER_PREFIX=.*:ZOOKEEPER_PREFIX=$DEPS_PREFIX:" depends.mk
sed -i "s:^GFLAGS_PREFIX=.*:GFLAGS_PREFIX=$DEPS_PREFIX:" depends.mk
sed -i "s:^GLOG_PREFIX=.*:GLOG_PREFIX=$DEPS_PREFIX:" depends.mk
sed -i "s:^GTEST_PREFIX=.*:GTEST_PREFIX=$DEPS_PREFIX:" depends.mk
sed -i "s:^GPERFTOOLS_PREFIX=.*:GPERFTOOLS_PREFIX=$DEPS_PREFIX:" depends.mk
sed -i "s:^BOOST_INCDIR=.*:BOOST_INCDIR=$DEPS_PREFIX/boost_${BOOST_VERSION}:" depends.mk
sed -i "s:^INS_PREFIX=.*:INS_PREFIX=$DEPS_PREFIX:" depends.mk
########################################
# build tera
########################################
make clean
make