Skip to content

Commit

Permalink
Add more support for building Boost with different options (#1468)
Browse files Browse the repository at this point in the history
  • Loading branch information
rkeene authored Dec 16, 2018
1 parent d46621d commit 87bcd33
Showing 1 changed file with 72 additions and 9 deletions.
81 changes: 72 additions & 9 deletions util/build_prep/bootstrap_boost.sh
Original file line number Diff line number Diff line change
@@ -1,25 +1,58 @@
#!/usr/bin/env bash

set -o errexit
set -o xtrace

bootstrapArgs=()
buildArgs=()
useClang='false'
useLibCXX='false'
keepArchive='false'
while getopts 'mck' OPT; do
debugLevel=0
buildCArgs=()
buildCXXArgs=()
buildLDArgs=()
boostVersion='1.69'
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=thread,log,filesystem,program_options')
;;
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'

Expand All @@ -32,13 +65,31 @@ fi

if [ "${useClang}" = 'true' ]; then
bootstrapArgs+=(--with-toolset=clang)
buildArgs+=(toolset=clang)
if [ "${useLibCXX}" = 'true' ]; then
buildCXXArgs+=(-stdlib=libc++)
buildLDArgs+=(-stdlib=libc++)
fi
fi

BOOST_BASENAME=boost_1_66_0
BOOST_ROOT=${BOOST_ROOT-/usr/local/boost}
BOOST_URL=https://downloads.sourceforge.net/project/boost/boost/1.66.0/${BOOST_BASENAME}.tar.bz2
case "${boostVersion}" in
1.66)
BOOST_BASENAME=boost_1_66_0
BOOST_URL=https://downloads.sourceforge.net/project/boost/boost/1.66.0/${BOOST_BASENAME}.tar.bz2
BOOST_ARCHIVE_SHA256='5721818253e6a0989583192f96782c4a98eb6204965316df9f5ad75819225ca9'
;;
1.69)
BOOST_BASENAME=boost_1_69_0
BOOST_URL=https://downloads.sourceforge.net/project/boost/boost/1.69.0/${BOOST_BASENAME}.tar.bz2
BOOST_ARCHIVE_SHA256='8f32d4617390d1c2d16f26a27ab60d97807b35440d45891fa340fc2648b04406'
;;
*)
echo "Unsupported Boost version: ${boostVersion}" >&2
exit 1
;;
esac
BOOST_ARCHIVE="${BOOST_BASENAME}.tar.bz2"
BOOST_ARCHIVE_SHA256='5721818253e6a0989583192f96782c4a98eb6204965316df9f5ad75819225ca9'
BOOST_ROOT=${BOOST_ROOT-/usr/local/boost}

if [ ! -f "${BOOST_ARCHIVE}" ]; then
wget --quiet -O "${BOOST_ARCHIVE}.new" "${BOOST_URL}"
Expand All @@ -53,12 +104,24 @@ 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 -d0 --prefix="${BOOST_ROOT}" link=static install
./b2 -d${debugLevel} --prefix="${BOOST_ROOT}" link=static "${buildArgs[@]}" install
popd

rm -rf "${BOOST_BASENAME}"
Expand Down

0 comments on commit 87bcd33

Please sign in to comment.