Imported Upstream version 0.9.2
[platform/upstream/iotivity.git] / extlibs / buildDependencies.sh
1 #!/bin/bash
2
3 set -e
4
5 # Change to extlibs directory
6 cd "$(dirname "$0")"
7
8 EXTDIR=$(pwd)
9
10 # Pick the preferred version of boost to use
11 BOOST_MAJOR=1
12 BOOST_MINOR=57
13 BOOST_REVISION=0
14
15 BOOST_VERSION="${BOOST_MAJOR}.${BOOST_MINOR}.${BOOST_REVISION}"
16
17 # Determine the architecture
18 HOST_ARCH=$(arch)
19
20 if [ "${HOST_ARCH}" != "x86_64" ];
21 then
22     HOST_ARCH="x86"
23 fi
24
25 HOST_ARCH="linux-${HOST_ARCH}"
26
27 function cloneBoost {
28     echo "Removing old boost repo..."
29     rm -rf boost
30     echo "Cloning boost from GIT HUB..."
31     git clone --recursive https://github.com/boostorg/boost.git boost
32 }
33
34 function buildBoost {
35     if [ ! -d "boost" ]; then
36         cloneBoost
37     fi
38
39     # Determine the
40     TOOLCHAIN=${ANDROID_NDK}/toolchains/${TOOLSET}-${VERSION}/prebuilt/${HOST_ARCH}/bin
41
42     OLDPATH=$PATH
43     PATH=$TOOLCHAIN:$PATH
44
45     rm -f boost.log
46
47     pushd boost
48     echo "Checking out boost v${BOOST_VERSION}..."
49     git checkout --force -B boost-${BOOST_VERSION} tags/boost-${BOOST_VERSION}                                   &>> ../boost.log
50     git submodule foreach --recursive git checkout --force -B boost-${BOOST_VERSION} tags/boost-${BOOST_VERSION} &>> ../boost.log
51     echo "Reset and clean all modular repositories..."
52     git reset --hard HEAD                                     >> ../boost.log
53     git clean -d --force                                      >> ../boost.log
54     git clean -d --force -x                                   >> ../boost.log
55     git submodule foreach --recursive git reset --hard HEAD   >> ../boost.log
56     git submodule foreach --recursive git clean --force -d    >> ../boost.log
57     git submodule foreach --recursive git clean --force -d -x >> ../boost.log
58     echo "Copying user configs to boost..."
59     cp ${EXTDIR}/../resource/patches/boost/${TOOLSET}/user-config.jam tools/build/src/user-config.jam
60     echo "Boostrapping boost..."
61     ./bootstrap.sh
62     echo "Building..."
63     ./b2 -q \
64         target-os=linux \
65         link=static \
66         threading=multi \
67         --layout=system \
68         --build-type=minimal \
69         -s PLATFORM=${PLATFORM} \
70         -s VERSION=${VERSION} \
71         --prefix="${EXTDIR}/../out/boost" \
72         --includedir="${INCPATH}" \
73         --libdir="${LIBPATH}" \
74         --build-dir="$(pwd)/build" \
75         --with-thread \
76         --with-program_options \
77         headers install
78     popd
79
80     if [ ! -d "${INCPATH}" ];
81     then
82         echo "Copying headers to android include directory..."
83         mkdir -p ${INCPATH}
84         cp --recursive --dereference boost/boost ${INCPATH}
85     fi
86
87     PATH=$OLDPATH
88 }
89
90 function checkBoost {
91     PLATFORM=$1
92     TOOLSET=$2
93     VERSION=$3
94
95     INCPATH="${EXTDIR}/../out/android/include"
96     LIBPATH="${EXTDIR}/../out/android/lib/${TOOLSET}"
97
98     if [ ! -d "${LIBPATH}" ];
99     then
100         buildBoost
101     fi
102 }
103
104 checkBoost android-19 arm-linux-androideabi 4.9
105 checkBoost android-19 x86 4.9