-
-
Notifications
You must be signed in to change notification settings - Fork 93
/
Copy pathinstall_boost.sh
executable file
·112 lines (94 loc) · 2.93 KB
/
install_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
#!/usr/bin/env bash
: ${BOOST_VERSION:=1.65.1}
: ${BOOST_BUILD_OPTIONS:="-j4 --with-filesystem --with-iostreams --with-program_options --with-serialization --with-system --with-thread"}
: ${BOOST_BUILD_CXXFLAGS:="-O2"}
: ${BOOST_INSTALL_PREFIX:=$(pwd)/boost-$BOOST_VERSION}
if [ ! -z $BOOST_TOOLSET ]; then
BOOST_BUILD_OPTIONS="$BUILD_OPTIONS toolset=$BOOST_TOOLSET"
fi
echo "Building boost version : $BOOST_VERSION"
echo "Installing in directory: $BOOST_INSTALL_PREFIX"
echo "Build options : $BOOST_BUILD_OPTIONS"
echo "CXXFLAGS : $BOOST_BUILD_CXXFLAGS"
if [ -f config.status ]; then
CXXSTD1=`grep -o "\-std=c++[0-9a-zA-Z]*" config.status 2>/dev/null | sort -u`
CXXSTD2=`echo $BOOST_BUILD_CXXFLAGS | grep -o "\-std=c++[0-9a-zA-Z]*"`
if [ "$CXXSTD1" != "$CXXSTD2" ]; then
echo "*** WARNING: detected use of $CXXSTD1 in config.status, add this flag to CXXFLAGS:"
echo "*** BOOST_BUILD_CXXFLAGS=\"$BOOST_BUILD_CXXFLAGS $CXXSTD1\" $0"
fi
fi
echo "Starting in 3 seconds..."
sleep 3
BOOST_DIRVERSION=`echo $BOOST_VERSION | tr . _`
BOOST_DIR=boost_$BOOST_DIRVERSION
BOOST_FILE=$BOOST_DIR.tar.gz
function test_tar_gz_file
{
if [ ! -f $TGZ_FILE ]; then
return 1
fi
TGZ_FILE=$1
gzip -t $TGZ_FILE \
|| ( echo "$TGZ_FILE corrupted" ; rm $TGZ_FILE ; return 2 )
return 0
}
function retrieve_tar_gz_file
{
TGZ_FILE=$1
TGZ_URL=$2
if test_tar_gz_file $TGZ_FILE ; then
return 0
fi
wget $TGZ_URL -O $TGZ_FILE.tmp \
|| ( echo "wget $TGZ_FILE failed" ; rm $TGZ_FILE.tmp ; return 3 )
mv $TGZ_FILE.tmp $TGZ_FILE
if test_tar_gz_file $TGZ_FILE ; then
return 0
fi
return 1
}
# retrieve file if necessary
retrieve_tar_gz_file $BOOST_FILE https://downloads.sourceforge.net/project/boost/boost/$BOOST_VERSION/$BOOST_FILE
retrieve_tar_gz_file $BOOST_FILE https://downloads.sourceforge.net/project/boost/boost/$BOOST_VERSION/$BOOST_FILE
# test if we have file
test_tar_gz_file $BOOST_FILE \
|| ( echo "Cannot find or download $BOOST_FILE" ; exit 1 )
# remove existing boost directory if present
if [ -d $BOOST_DIR ]; then
echo -n "Removing old directory $BOOST_DIR..."
rm -rf "$BOOST_DIR"
echo "done."
fi
# extract boost tar file
tar -xzf $BOOST_FILE \
|| ( echo "Cannot extract $BOOST_FILE" ; exit 1 )
# go into boost directory
if [ ! -d $BOOST_DIR ]; then
echo "Expected directory $BOOST_DIR after extracting $BOOST_FILE"
exit 1
fi
cd $BOOST_DIR
# bootstrap bjam build system for boost
./bootstrap.sh \
cxxflags="$BOOST_BUILD_CXXFLAGS" \
linkflags="$BOOST_BUILD_CXXFLAGS" \
--prefix=$BOOST_INSTALL_PREFIX
if [ ! -e ./b2 ]; then
cat bootstrap.log
fi
# compile boost
./b2 -q \
cxxflags="$BOOST_BUILD_CXXFLAGS" \
linkflags="$BOOST_BUILD_CXXFLAGS" \
--prefix=$BOOST_INSTALL_PREFIX \
$BOOST_BUILD_OPTIONS \
--build-type=minimal link=static \
install \
|| ( echo "Building boost failed!" ; exit 1 )
# exit boost directory
cd ..
# cleanup boost directory
echo -n "Removing old directory $BOOST_DIR..."
rm -rf $BOOST_DIR
echo "done."