Added build dependencies script
[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         --with-program_options \
66         install
67     popd
68
69     PATH=$OLDPATH
70
71     mkdir -p ${INCPATH}
72     cp -R ../out/boost/include/* ${INCPATH}
73     mkdir -p ${LIBPATH}
74     cp -R ../out/boost/lib/*     ${LIBPATH}
75 }
76
77 function checkBoost {
78     PLATFORM=$1
79     TOOLSET=$2
80     VERSION=$3
81
82     INCPATH="$(dirname "$0")/../out/android/include"
83     LIBPATH="$(dirname "$0")/../out/android/lib/${TOOLSET}"
84
85     if [ ! -d "${INCPATH}" ];
86     then
87         buildBoost
88     fi
89     if [ ! -d "${LIBPATH}" ];
90     then
91         buildBoost
92     fi
93 }
94
95 checkBoost 19 arm-linux-androideabi 4.9
96 checkBoost 19 x86 4.9