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