Merge branch 'connectivity-abstraction' to master
[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 # Check for cereal existence
11 if [ ! -d "cereal" ]; then
12     git clone https://github.com/USCiLab/cereal.git cereal
13     pushd cereal
14     git reset --hard 7121e91e6ab8c3e6a6516d9d9c3e6804e6f65245
15     git apply ../../resource/patches/cereal_gcc46.patch
16     popd
17 fi
18
19 # Pick the preferred version of boost to use
20 BOOST_MAJOR=1
21 BOOST_MINOR=57
22 BOOST_REVISION=0
23
24 BOOST_VERSION="${BOOST_MAJOR}.${BOOST_MINOR}.${BOOST_REVISION}"
25 BOOST_NAME="boost_${BOOST_MAJOR}_${BOOST_MINOR}_${BOOST_REVISION}"
26 BOOST_FILE="${BOOST_NAME}.zip"
27
28 function downloadBoost {
29     echo "Downloading boost v${BOOST_VERSION}"
30     wget --progress=bar --continue --output-document=${BOOST_FILE} http://downloads.sourceforge.net/project/boost/boost/${BOOST_VERSION}/${BOOST_FILE}?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fboost%2Ffiles%2Fboost%2F${BOOST_VERSION}%2F\&ts=1419450713\&use_mirror=iweb
31 }
32
33 function unpackBoost {
34     if [ ! -f "${BOOST_FILE}" ]; then
35         downloadBoost
36     fi
37
38     echo "Unpacking boost v${BOOST_VERSION}"
39     unzip ${BOOST_FILE} >> build.log
40     pushd ${BOOST_NAME}
41     ./bootstrap.sh
42     popd
43 }
44
45 function buildBoost {
46     if [ ! -d "${BOOST_NAME}" ]; then
47         unpackBoost
48     fi
49
50     TOOLCHAIN=${ANDROID_NDK}/toolchains/${TOOLSET}-${VERSION}/prebuilt/linux-x86/bin
51     echo "Copying user configs to boost"
52     cp ../resource/patches/user-config-${TOOLSET}.jam ${BOOST_NAME}/tools/build/v2/user-config.jam
53
54     OLDPATH=$PATH
55     PATH=$TOOLCHAIN:$PATH
56
57     pushd ${BOOST_NAME}
58     ./b2 clean
59     ./b2 -q \
60         target-os=linux \
61         link=static \
62         threading=multi \
63         --layout=system \
64         --prefix="./../../out/boost" \
65         -s PLATFORM=android-${PLATFORM} \
66         -s VERSION=${VERSION} \
67         --with-thread \
68         install
69     popd
70
71     PATH=$OLDPATH
72
73     mkdir -p ${INCPATH}
74     cp -R ../out/boost/include/* ${INCPATH}
75     mkdir -p ${LIBPATH}
76     cp -R ../out/boost/lib/*     ${LIBPATH}
77 }
78
79 function checkBoost {
80     PLATFORM=$1
81     TOOLSET=$2
82     VERSION=$3
83
84     INCPATH="$(dirname "$0")/../out/android/include"
85     LIBPATH="$(dirname "$0")/../out/android/lib/${TOOLSET}"
86
87     if [ ! -d "${INCPATH}" ];
88     then
89         buildBoost
90     fi
91     if [ ! -d "${LIBPATH}" ];
92     then
93         buildBoost
94     fi
95 }
96
97 checkBoost 19 arm-linux-androideabi 4.9
98 checkBoost 19 x86 4.9
99