-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap_boost.sh
executable file
·135 lines (120 loc) · 3.39 KB
/
bootstrap_boost.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
#!/usr/bin/env bash
bootstrapArgs=()
buildArgs=()
useClang='false'
useLibCXX='false'
keepArchive='false'
debugLevel=0
buildCArgs=()
buildCXXArgs=()
buildLDArgs=()
boostVersion='1.67'
while getopts 'hmcCkpvB:' OPT; do
case "${OPT}" in
h)
echo "Usage: bootstrap_boost.sh [-hmcCkpv] [-B <boostVersion>]"
echo " -h This help"
echo " -m Build a minimal set of libraries needed for Nano"
echo " -c Use Clang"
echo " -C Use libc++ when using Clang"
echo " -k Keep the downloaded archive file"
echo " -p Build a PIC version of the objects"
echo " -v Increase debug level, may be repeated to increase it"
echo " further"
echo " -B <boostVersion> Specify version of Boost to build"
exit 0
;;
m)
bootstrapArgs+=('--with-libraries=system,thread,log,filesystem,program_options,context,fiber')
;;
c)
useClang='true'
;;
C)
useLibCXX='true'
;;
k)
keepArchive='true'
;;
p)
buildCXXArgs+=(-fPIC)
buildCArgs+=(-fPIC)
;;
v)
debugLevel=$[$debugLevel + 1]
;;
B)
boostVersion="${OPTARG}"
;;
esac
done
set -o errexit
set -o xtrace
if ! c++ --version >/dev/null 2>/dev/null; then
useClang='true'
if ! clang++ --version >/dev/null 2>/dev/null; then
echo "Unable to find a usable toolset" >&2
exit 1
fi
fi
if [ "${useClang}" = 'true' ]; then
bootstrapArgs+=(--with-toolset=clang)
buildArgs+=(toolset=clang)
if [ "${useLibCXX}" = 'true' ]; then
buildCXXArgs+=(-stdlib=libc++)
buildLDArgs+=(-stdlib=libc++)
fi
fi
case "${boostVersion}" in
1.67)
BOOST_BASENAME=boost_1_67_0
BOOST_URL=https://dl.bintray.com/boostorg/release/1.67.0/source/${BOOST_BASENAME}.tar.bz2
BOOST_ARCHIVE_SHA256='2684c972994ee57fc5632e03bf044746f6eb45d4920c343937a465fd67a5adba'
;;
1.69)
BOOST_BASENAME=boost_1_69_0
BOOST_URL=https://dl.bintray.com/boostorg/release/1.69.0/source/${BOOST_BASENAME}.tar.bz2
BOOST_ARCHIVE_SHA256='8f32d4617390d1c2d16f26a27ab60d97807b35440d45891fa340fc2648b04406'
;;
1.70)
BOOST_BASENAME=boost_1_70_0
BOOST_URL=https://dl.bintray.com/boostorg/release/1.70.0/source/${BOOST_BASENAME}.tar.bz2
BOOST_ARCHIVE_SHA256='430ae8354789de4fd19ee52f3b1f739e1fba576f0aded0897c3c2bc00fb38778'
;;
*)
echo "Unsupported Boost version: ${boostVersion}" >&2
exit 1
;;
esac
BOOST_ARCHIVE="${BOOST_BASENAME}.tar.bz2"
BOOST_ROOT=${BOOST_ROOT-/tmp/boost}
if [ ! -f "${BOOST_ARCHIVE}" ]; then
wget --quiet -O "${BOOST_ARCHIVE}.new" "${BOOST_URL}"
checkHash="$(openssl dgst -sha256 "${BOOST_ARCHIVE}.new" | sed 's@^.*= *@@')"
if [ "${checkHash}" != "${BOOST_ARCHIVE_SHA256}" ]; then
echo "Checksum mismatch. Expected ${BOOST_ARCHIVE_SHA256}, got ${checkHash}" >&2
exit 1
fi
mv "${BOOST_ARCHIVE}.new" "${BOOST_ARCHIVE}" || exit 1
else
keepArchive='true'
fi
if [ -n "${buildCArgs[*]}" ]; then
buildArgs+=(cflags="${buildCArgs[*]}")
fi
if [ -n "${buildCXXArgs[*]}" ]; then
buildArgs+=(cxxflags="${buildCXXArgs[*]}")
fi
if [ -n "${buildLDArgs[*]}" ]; then
buildArgs+=(linkflags="${buildLDArgs[*]}")
fi
rm -rf "${BOOST_BASENAME}"
tar xf "${BOOST_ARCHIVE}"
pushd "${BOOST_BASENAME}"
./bootstrap.sh "${bootstrapArgs[@]}"
./b2 -d${debugLevel} --prefix="${BOOST_ROOT}" link=static "${buildArgs[@]}" install
popd
rm -rf "${BOOST_BASENAME}"
if [ "${keepArchive}" != 'true' ]; then
rm -f "${BOOST_ARCHIVE}"
fi