forked from apache/kudu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild-definitions.sh
320 lines (285 loc) · 9.31 KB
/
build-definitions.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
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
#!/bin/sh
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# build-definitions.sh provides functions to build thirdparty dependencies.
# These functions do not take positional arguments, but individual builds may
# be influenced by setting environment variables:
#
# * PREFIX - the install destination directory.
# * EXTRA_CFLAGS - additional flags to pass to the C compiler.
# * EXTRA_CXXFLAGS - additional flags to pass to the C++ compiler.
# * EXTRA_LDFLAGS - additional flags to pass to the linker.
# * EXTRA_LIBS - additional libraries to link.
#
# build-definitions.sh is meant to be sourced from build-thirdparty.sh, and
# relies on environment variables defined there and in vars.sh.
# Save the current build environment.
save_env() {
_PREFIX=${PREFIX}
_EXTRA_CFLAGS=${EXTRA_CFLAGS}
_EXTRA_CXXFLAGS=${EXTRA_CXXFLAGS}
_EXTRA_LDFLAGS=${EXTRA_LDFLAGS}
_EXTRA_LIBS=${EXTRA_LIBS}
}
# Restore the most recently saved build environment.
restore_env() {
PREFIX=${_PREFIX}
EXTRA_CFLAGS=${_EXTRA_CFLAGS}
EXTRA_CXXFLAGS=${_EXTRA_CXXFLAGS}
EXTRA_LDFLAGS=${_EXTRA_LDFLAGS}
EXTRA_LIBS=${_EXTRA_LIBS}
}
build_cmake() {
cd $CMAKE_DIR
./bootstrap --prefix=$PREFIX --parallel=$PARALLEL
make -j$PARALLEL
make install
}
build_llvm() {
# Build Python if necessary.
if [[ $(python2.7 -V 2>&1) =~ "Python 2.7." ]]; then
PYTHON_EXECUTABLE=$(which python2.7)
elif [[ $(python -V 2>&1) =~ "Python 2.7." ]]; then
PYTHON_EXECUTABLE=$(which python)
else
cd $PYTHON_DIR
./configure --prefix=$PREFIX
make -j$PARALLEL
PYTHON_EXECUTABLE=$PYTHON_DIR/python
fi
mkdir -p $LLVM_BUILD_DIR
cd $LLVM_BUILD_DIR
# Rebuild the CMake cache every time.
rm -Rf CMakeCache.txt CMakeFiles/
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$PREFIX \
-DLLVM_TARGETS_TO_BUILD=X86 \
-DLLVM_ENABLE_RTTI=ON \
-DCMAKE_CXX_FLAGS="$EXTRA_CXXFLAGS" \
-DPYTHON_EXECUTABLE=$PYTHON_EXECUTABLE \
$LLVM_DIR
make -j$PARALLEL install
# Create a link from Clang to thirdparty/clang-toolchain. This path is used
# for compiling Kudu with sanitizers. The link can't point to the Clang
# installed in the prefix directory, since this confuses CMake into believing
# the thirdparty prefix directory is the system-wide prefix, and it omits the
# thirdparty prefix directory from the rpath of built binaries.
ln -sfn $LLVM_BUILD_DIR $TP_DIR/clang-toolchain
}
build_libstdcxx() {
# Configure libstdcxx to use posix threads by default. Normally this symlink
# would be created automatically while building libgcc as part of the overall
# GCC build, but since we are only building libstdcxx we must configure it
# manually.
ln -sf $GCC_DIR/libgcc/gthr-posix.h $GCC_DIR/libgcc/gthr-default.h
# Remove the GCC build directory to remove cached build configuration.
rm -rf $GCC_BUILD_DIR
mkdir -p $GCC_BUILD_DIR
cd $GCC_BUILD_DIR
CFLAGS=$EXTRA_CFLAGS \
CXXFLAGS=$EXTRA_CXXFLAGS \
$GCC_DIR/libstdc++-v3/configure \
--enable-multilib=no \
--prefix="$PREFIX"
make -j$PARALLEL install
}
build_gflags() {
cd $GFLAGS_DIR
rm -rf CMakeCache.txt CMakeFiles/
CXXFLAGS="$EXTRA_CFLAGS $EXTRA_CXXFLAGS $EXTRA_LDFLAGS $EXTRA_LIBS" \
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_POSITION_INDEPENDENT_CODE=On \
-DCMAKE_INSTALL_PREFIX=$PREFIX \
-DBUILD_SHARED_LIBS=On \
-DBUILD_STATIC_LIBS=On
make -j$PARALLEL install
}
build_libunwind() {
cd $LIBUNWIND_DIR
# Disable minidebuginfo, which depends on liblzma, until/unless we decide to
# add liblzma to thirdparty.
./configure --disable-minidebuginfo --with-pic --prefix=$PREFIX
make -j$PARALLEL install
}
build_glog() {
cd $GLOG_DIR
CXXFLAGS="$EXTRA_CXXFLAGS" \
LDFLAGS="$EXTRA_LDFLAGS" \
LIBS="$EXTRA_LIBS" \
./configure --with-pic --prefix=$PREFIX --with-gflags=$PREFIX
make -j$PARALLEL install
}
build_gperftools() {
cd $GPERFTOOLS_DIR
CFLAGS="$EXTRA_CFLAGS" \
CXXFLAGS="$EXTRA_CXXFLAGS" \
LDFLAGS="$EXTRA_LDFLAGS" \
LIBS="$EXTRA_LIBS" \
./configure --enable-frame-pointers --enable-heap-checker --with-pic --prefix=$PREFIX
make -j$PARALLEL install
}
build_gmock() {
cd $GMOCK_DIR
for SHARED in OFF ON; do
rm -rf CMakeCache.txt CMakeFiles/
CXXFLAGS="$EXTRA_CXXFLAGS $EXTRA_LDFLAGS $EXTRA_LIBS" \
cmake \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_POSITION_INDEPENDENT_CODE=On \
-DBUILD_SHARED_LIBS=$SHARED .
make -j$PARALLEL
done
echo Installing gmock...
cp -a libgmock.$DYLIB_SUFFIX libgmock.a $PREFIX/lib/
rsync -av include/ $PREFIX/include/
rsync -av gtest/include/ $PREFIX/include/
}
build_protobuf() {
cd $PROTOBUF_DIR
# We build protobuf in both instrumented and non-instrumented modes.
# If we don't clean in between, we may end up mixing modes.
test -f Makefile && make distclean
CFLAGS="$EXTRA_CFLAGS" \
CXXFLAGS="$EXTRA_CXXFLAGS" \
LDFLAGS="$EXTRA_LDFLAGS" \
LIBS="$EXTRA_LIBS" \
./configure \
--with-pic \
--enable-shared \
--enable-static \
--prefix=$PREFIX
make -j$PARALLEL install
}
build_snappy() {
cd $SNAPPY_DIR
CFLAGS="$EXTRA_CFLAGS" \
CXXFLAGS="$EXTRA_CXXFLAGS" \
LDFLAGS="$EXTRA_LDFLAGS" \
LIBS="$EXTRA_LIBS" \
./configure --with-pic --prefix=$PREFIX
make -j$PARALLEL install
}
build_zlib() {
cd $ZLIB_DIR
CFLAGS="$EXTRA_CFLAGS -fPIC" ./configure --prefix=$PREFIX
make -j$PARALLEL install
}
build_lz4() {
cd $LZ4_DIR
CFLAGS="$EXTRA_CFLAGS" cmake -DCMAKE_BUILD_TYPE=release \
-DBUILD_TOOLS=0 -DCMAKE_INSTALL_PREFIX:PATH=$PREFIX cmake_unofficial/
make -j$PARALLEL install
}
build_bitshuffle() {
cd $BITSHUFFLE_DIR
# bitshuffle depends on lz4, therefore set the flag I$PREFIX/include
${CC:-gcc} $EXTRA_CFLAGS -std=c99 -I$PREFIX/include -O3 -DNDEBUG -fPIC -c bitshuffle.c
ar rs bitshuffle.a bitshuffle.o
cp bitshuffle.a $PREFIX/lib/
cp bitshuffle.h $PREFIX/include/
}
build_libev() {
cd $LIBEV_DIR
CFLAGS="$EXTRA_CFLAGS" \
CXXFLAGS="$EXTRA_CXXFLAGS" \
./configure --with-pic --prefix=$PREFIX
make -j$PARALLEL install
}
build_rapidjson() {
# just installing it into our prefix
cd $RAPIDJSON_DIR
rsync -av --delete $RAPIDJSON_DIR/include/rapidjson/ $PREFIX/include/rapidjson/
}
build_squeasel() {
# Mongoose's Makefile builds a standalone web server, whereas we just want
# a static lib
cd $SQUEASEL_DIR
${CC:-gcc} $EXTRA_CFLAGS -std=c99 -O3 -DNDEBUG -fPIC -c squeasel.c
ar rs libsqueasel.a squeasel.o
cp libsqueasel.a $PREFIX/lib/
cp squeasel.h $PREFIX/include/
}
build_curl() {
# Configure for a very minimal install - basically only HTTP, since we only
# use this for testing our own HTTP endpoints at this point in time.
cd $CURL_DIR
./configure --prefix=$PREFIX \
--disable-ftp \
--disable-file \
--disable-ldap \
--disable-ldaps \
--disable-rtsp \
--disable-dict \
--disable-telnet \
--disable-tftp \
--disable-pop3 \
--disable-imap \
--disable-smtp \
--disable-gopher \
--disable-manual \
--without-rtmp \
--disable-ipv6
make -j$PARALLEL
make install
}
build_crcutil() {
cd $CRCUTIL_DIR
./autogen.sh
CFLAGS="$EXTRA_CFLAGS" \
CXXFLAGS="$EXTRA_CXXFLAGS" \
LDFLAGS="$EXTRA_LDFLAGS" \
LIBS="$EXTRA_LIBS" \
./configure --prefix=$PREFIX
make -j$PARALLEL install
}
build_boost_uuid() {
# Copy boost_uuid into the include directory.
# This is a header-only library which isn't present in some older versions of
# boost (eg the one on el6). So, we check it in and put it in our own include
# directory.
rsync -a $TP_DIR/boost_uuid/boost/ $PREFIX/include/boost/
}
build_cpplint() {
# Copy cpplint tool into bin directory
cp $GSG_DIR/cpplint/cpplint.py $PREFIX/bin/cpplint.py
}
build_gcovr() {
# Copy gcovr tool into bin directory
cp -a $GCOVR_DIR/scripts/gcovr $PREFIX/bin/gcovr
}
build_trace_viewer() {
echo Installing trace-viewer into the www directory
cp -a $TRACE_VIEWER_DIR/* $TP_DIR/../www/
}
build_nvml() {
cd $NVML_DIR/src/
# The embedded jemalloc build doesn't pick up the EXTRA_CFLAGS environment
# variable, so we have to stick our flags into this config file.
if ! grep -q -e "$EXTRA_CFLAGS" jemalloc/jemalloc.cfg ; then
perl -p -i -e "s,(EXTRA_CFLAGS=\"),\$1$EXTRA_CFLAGS ," jemalloc/jemalloc.cfg
fi
EXTRA_CFLAGS="$EXTRA_CFLAGS" make -j$PARALLEL libvmem DEBUG=0
# NVML doesn't allow configuring PREFIX -- it always installs into
# DESTDIR/usr/lib. Additionally, the 'install' target builds all of
# the NVML libraries, even though we only need libvmem.
# So, we manually install the built artifacts.
cp -a $NVML_DIR/src/include/libvmem.h $PREFIX/include
cp -a $NVML_DIR/src/nondebug/libvmem.{so*,a} $PREFIX/lib
}