forked from awslabs/amazon-kinesis-producer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.sh
executable file
·222 lines (180 loc) · 5.61 KB
/
bootstrap.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
#!/bin/bash
set -e
set -x
LIB_MIRROR="http://d3mddf4lzrx5uw.cloudfront.net"
INSTALL_DIR=$(pwd)/third_party
mkdir -p $INSTALL_DIR
if [ $1 == "clang" ] || [ $(uname) == 'Darwin' ]; then
export MACOSX_DEPLOYMENT_TARGET='10.9'
export MACOSX_MIN_COMPILER_OPT="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}"
export CC=$(which clang)
export CXX=$(which clang++)
export CXXFLAGS="-I$INSTALL_DIR/include -O3 -stdlib=libc++ ${MACOSX_MIN_COMPILER_OPT} "
export CFLAGS="${MACOSX_MIN_COMPILER_OPT} "
export C_INCLUDE_PATH="$INSTALL_DIR/include"
if [ $(uname) == 'Linux' ]; then
export LDFLAGS="-L$INSTALL_DIR/lib -nodefaultlibs -lpthread -ldl -lc++ -lc++abi -lm -lc -lgcc_s"
export LD_LIBRARY_PATH="$INSTALL_DIR/lib:$LD_LIBRARY_PATH"
else
export LDFLAGS="-L$INSTALL_DIR/lib"
export DYLD_LIBRARY_PATH="$INSTALL_DIR/lib:$DYLD_LIBRARY_PATH"
fi
else
export CC="gcc"
export CXX="g++"
export CXXFLAGS="-I$INSTALL_DIR/include -O3"
export LDFLAGS="-L$INSTALL_DIR/lib "
export LD_LIBRARY_PATH="$INSTALL_DIR/lib:$LD_LIBRARY_PATH"
fi
SED="sed -i"
if [[ "$OSTYPE" == "darwin"* ]]; then
SED="sed -i ''"
fi
# Need to unset LD_LIBRARY_PATH for curl because the OpenSSL we build doesn't
# have MD4, which curl tries to use.
function _curl {
#(unset LD_LIBRARY_PATH; curl -L $@)
curl -L $@
}
cd $INSTALL_DIR
function conf {
if [[ "$OSTYPE" == "darwin"* ]]; then
./configure \
--prefix="$INSTALL_DIR" \
DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH" \
LDFLAGS="$LDFLAGS" \
CXXFLAGS="$CXXFLAGS" \
$@
else
./configure \
--prefix="$INSTALL_DIR" \
LD_LIBRARY_PATH="$LD_LIBRARY_PATH" \
LDFLAGS="$LDFLAGS" \
CXXFLAGS="$CXXFLAGS" \
C_INCLUDE_PATH="$C_INCLUDE_PATH" \
$@
fi
}
# OpenSSL
if [ ! -d "openssl-1.0.1m" ]; then
_curl "$LIB_MIRROR/openssl-1.0.1m.tar.gz" > openssl.tgz
tar xf openssl.tgz
rm openssl.tgz
cd openssl-1.0.1m
# Have to leave MD4 enabled because curl expects it
OPTS="threads no-shared no-idea no-camellia no-seed no-bf no-cast no-rc2 no-rc4 no-rc5 no-md2 no-ripemd no-mdc2 no-ssl2 no-ssl3 no-krb5 no-jpake no-capieng no-dso"
if [[ $(uname) == 'Darwin' ]]; then
./Configure darwin64-x86_64-cc $OPTS --prefix=$INSTALL_DIR
elif [[ $(uname) == MINGW* ]]; then
./Configure mingw64 $OPTS --prefix=$INSTALL_DIR
find ./ -name Makefile | while read f; do echo >> $f; echo "%.o: %.c" >> $f; echo -e '\t$(COMPILE.c) $(OUTPUT_OPTION) $<;' >> $f; done
else
./config $OPTS --prefix=$INSTALL_DIR
fi
make # don't use -j, doesn't work half the time
make install
cd ..
fi
# Boost C++ Libraries
if [ ! -d "boost_1_58_0" ]; then
_curl "$LIB_MIRROR/boost_1_58_0.tar.gz" > boost.tgz
tar xf boost.tgz
rm boost.tgz
cd boost_1_58_0
LIBS="atomic,chrono,log,system,test,random,regex,thread,filesystem"
OPTS="-j 8 --build-type=minimal --layout=system --prefix=$INSTALL_DIR link=static threading=multi release install"
if [[ $(uname) == 'Darwin' ]]; then
./bootstrap.sh --with-libraries=$LIBS
./b2 toolset=clang-darwin $OPTS cxxflags="$MACOSX_MIN_COMPILER_OPT"
elif [[ $(uname) == MINGW* ]]; then
./bootstrap.sh --with-libraries=$LIBS --with-toolset=mingw
sed -i 's/\bmingw\b/gcc/' project-config.jam
./b2 $OPTS
else
if [ "$1" == "clang" ]; then
./bootstrap.sh --with-libraries="$LIBS" --with-toolset=clang
./b2 toolset=clang $OPTS cxxflags="$CXXFLAGS" linkflags="$LDFLAGS"
else
./bootstrap.sh --with-libraries="$LIBS" --with-toolset=gcc
./b2 toolset=gcc $OPTS
fi
fi
cd ..
fi
# zlib
if [ ! -d "zlib-1.2.8" ]; then
_curl "$LIB_MIRROR/zlib-1.2.8.tar.gz" > zlib.tgz
tar xf zlib.tgz
rm zlib.tgz
cd zlib-1.2.8
./configure --static --prefix="$INSTALL_DIR"
make -j
make install
cd ..
fi
# Google Protocol Buffers
if [ ! -d "protobuf-2.6.1" ]; then
_curl "$LIB_MIRROR/protobuf-2.6.1.tar.gz" > protobuf.tgz
tar xf protobuf.tgz
rm protobuf.tgz
cd protobuf-2.6.1
conf --enable-shared=no
make -j
make install
cd ..
fi
# libcurl
if [ ! -d "curl-7.47.0" ]; then
_curl "$LIB_MIRROR/curl-7.47.0.tar.gz" > curl.tgz
tar xf curl.tgz
rm curl.tgz
cd curl-7.47.0
conf --disable-shared --disable-ldap --disable-ldaps \
--enable-threaded-resolver --disable-debug --without-libssh2 --without-ca-bundle --with-ssl="${INSTALL_DIR}" --without-libidn
if [[ $(uname) == 'Darwin' ]]; then
#
# Apply a patch for macOS that should prevent curl from trying to use clock_gettime
# This is a temporary work around for https://github.com/awslabs/amazon-kinesis-producer/issues/117
# until dependencies are updated
#
sed -Ei .bak 's/#define HAVE_CLOCK_GETTIME_MONOTONIC 1//' lib/curl_config.h
fi
make -j
make install
cd ..
fi
# AWS C++ SDK
if [ ! -d "aws-sdk-cpp" ]; then
git clone https://github.com/awslabs/aws-sdk-cpp.git aws-sdk-cpp
pushd aws-sdk-cpp
git checkout 1.0.5
popd
rm -rf aws-sdk-cpp-build
mkdir aws-sdk-cpp-build
cd aws-sdk-cpp-build
cmake \
-DBUILD_ONLY="kinesis;monitoring" \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DSTATIC_LINKING=1 \
-DCMAKE_PREFIX_PATH="$INSTALL_DIR" \
-DCMAKE_C_COMPILER="$CC" \
-DCMAKE_CXX_COMPILER="$CXX" \
-DCMAKE_CXX_FLAGS="$CXXFLAGS" \
-DCMAKE_INSTALL_PREFIX="$INSTALL_DIR" \
-DCMAKE_FIND_FRAMEWORK=LAST \
-DENABLE_TESTING="OFF" \
../aws-sdk-cpp
make -j 4
make install
cd ..
for f in $(find $INSTALL_DIR -name "libaws-cpp-sdk*.a"); do
mv $f "$INSTALL_DIR/lib/"
done
fi
cd ..
ln -sf ./third_party/boost_?_*_*/b2* b2
set +e
set +x
echo "***************************************"
echo "Bootstrap complete. Run ./b2 to build."
echo "***************************************"