Merge "Android SDK - Initial commit and build system updates"
[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
26 # Determine the architecture
27 HOST_ARCH=$(arch)
28
29 if [ "${HOST_ARCH}" != "x86_64" ];
30 then
31     HOST_ARCH="x86"
32 fi
33
34 HOST_ARCH="linux-${HOST_ARCH}"
35
36 function cloneBoost {
37     echo "Removing old boost repo..."
38     rm -rf boost
39     echo "Cloning boost from GIT HUB..."
40     git clone --recursive https://github.com/boostorg/boost.git boost
41 }
42
43 function buildBoost {
44     if [ ! -d "boost" ]; then
45         cloneBoost
46     fi
47     
48     # Determine the 
49     TOOLCHAIN=${ANDROID_NDK}/toolchains/${TOOLSET}-${VERSION}/prebuilt/${HOST_ARCH}/bin
50
51     OLDPATH=$PATH
52     PATH=$TOOLCHAIN:$PATH
53
54     rm -f boost.log
55
56     pushd boost
57     echo "Checking out boost v${BOOST_VERSION}..."
58     git checkout --force -B boost-${BOOST_VERSION} tags/boost-${BOOST_VERSION}                                   &>> ../boost.log
59     git submodule foreach --recursive git checkout --force -B boost-${BOOST_VERSION} tags/boost-${BOOST_VERSION} &>> ../boost.log
60     echo "Reset and clean all modular repositories..."
61     git reset --hard HEAD                                     >> ../boost.log
62     git clean -d --force                                      >> ../boost.log
63     git clean -d --force -x                                   >> ../boost.log
64     git submodule foreach --recursive git reset --hard HEAD   >> ../boost.log
65     git submodule foreach --recursive git clean --force -d    >> ../boost.log
66     git submodule foreach --recursive git clean --force -d -x >> ../boost.log
67     echo "Copying user configs to boost..."
68     cp ${EXTDIR}/../resource/patches/boost/${TOOLSET}/user-config.jam tools/build/src/user-config.jam
69     echo "Boostrapping boost..."
70     ./bootstrap.sh
71     echo "Building..."
72     ./b2 -q \
73         target-os=linux \
74         link=static \
75         threading=multi \
76         --layout=system \
77         --build-type=minimal \
78         -s PLATFORM=${PLATFORM} \
79         -s VERSION=${VERSION} \
80         --prefix="${EXTDIR}/../out/boost" \
81         --includedir="${INCPATH}" \
82         --libdir="${LIBPATH}" \
83         --build-dir="$(pwd)/build" \
84         --with-thread \
85         --with-program_options \
86         headers install
87     popd
88
89     if [ ! -d "${INCPATH}" ];
90     then
91         echo "Copying headers to android include directory..."
92         mkdir -p ${INCPATH}
93         cp --recursive --dereference boost/boost ${INCPATH}
94     fi
95
96     PATH=$OLDPATH
97 }
98
99 function checkBoost {
100     PLATFORM=$1
101     TOOLSET=$2
102     VERSION=$3
103
104     INCPATH="${EXTDIR}/../out/android/include"
105     LIBPATH="${EXTDIR}/../out/android/lib/${TOOLSET}"
106
107     if [ ! -d "${LIBPATH}" ];
108     then
109         buildBoost
110     fi
111 }
112
113 checkBoost android-19 arm-linux-androideabi 4.9
114 checkBoost android-19 x86 4.9