Move -Wl flags to linker flags
[platform/upstream/iotivity.git] / extlibs / buildDependencies.sh
index 9c65248..acd236e 100755 (executable)
@@ -5,72 +5,86 @@ set -e
 # Change to extlibs directory
 cd "$(dirname "$0")"
 
-# Check for cereal existence
-if [ ! -d "cereal" ]; then
-    git clone https://github.com/USCiLab/cereal.git cereal
-    pushd cereal
-    git reset --hard 7121e91e6ab8c3e6a6516d9d9c3e6804e6f65245
-    git apply ../../resource/patches/cereal_gcc46.patch
-    popd
-fi
+EXTDIR=$(pwd)
 
+# Pick the preferred version of boost to use
 BOOST_MAJOR=1
-BOOST_MINOR=55
+BOOST_MINOR=57
 BOOST_REVISION=0
 
 BOOST_VERSION="${BOOST_MAJOR}.${BOOST_MINOR}.${BOOST_REVISION}"
-BOOST_NAME="boost_${BOOST_MAJOR}_${BOOST_MINOR}_${BOOST_REVISION}"
-BOOST_FILE="${BOOST_NAME}.zip"
 
-function downloadBoost {
-    echo "Downloading boost v${BOOST_VERSION}"
-    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
-}
+# Determine the architecture
+HOST_ARCH=$(arch)
 
-function unpackBoost {
-    if [ ! -f "${BOOST_FILE}" ]; then
-        downloadBoost
-    fi
+if [ "${HOST_ARCH}" != "x86_64" ];
+then
+    HOST_ARCH="x86"
+fi
 
-    echo "Unpacking boost v${BOOST_VERSION}"
-    unzip ${BOOST_FILE} >> build.log
-    pushd ${BOOST_NAME}
-    ./bootstrap.sh
-    popd
+HOST_ARCH="linux-${HOST_ARCH}"
+
+function cloneBoost {
+    echo "Removing old boost repo..."
+    rm -rf boost
+    echo "Cloning boost from GIT HUB..."
+    git clone --recursive https://github.com/boostorg/boost.git boost
 }
 
 function buildBoost {
-    if [ ! -d "${BOOST_NAME}" ]; then
-        unpackBoost
+    if [ ! -d "boost" ]; then
+        cloneBoost
     fi
 
-    TOOLCHAIN=${ANDROID_NDK}/toolchains/${TOOLSET}-${VERSION}/prebuilt/linux-x86/bin
-    echo "Copying user configs to boost"
-    cp ../resource/patches/user-config-${TOOLSET}.jam ${BOOST_NAME}/tools/build/v2/user-config.jam
+    # Determine the
+    TOOLCHAIN=${ANDROID_NDK}/toolchains/${TOOLSET}-${VERSION}/prebuilt/${HOST_ARCH}/bin
 
     OLDPATH=$PATH
     PATH=$TOOLCHAIN:$PATH
 
-    pushd ${BOOST_NAME}
-    ./b2 clean
+    rm -f boost.log
+
+    pushd boost
+    echo "Checking out boost v${BOOST_VERSION}..."
+    git checkout --force -B boost-${BOOST_VERSION} tags/boost-${BOOST_VERSION}                                   &>> ../boost.log
+    git submodule foreach --recursive git checkout --force -B boost-${BOOST_VERSION} tags/boost-${BOOST_VERSION} &>> ../boost.log
+    echo "Reset and clean all modular repositories..."
+    git reset --hard HEAD                                     >> ../boost.log
+    git clean -d --force                                      >> ../boost.log
+    git clean -d --force -x                                   >> ../boost.log
+    git submodule foreach --recursive git reset --hard HEAD   >> ../boost.log
+    git submodule foreach --recursive git clean --force -d    >> ../boost.log
+    git submodule foreach --recursive git clean --force -d -x >> ../boost.log
+    echo "Copying user configs to boost..."
+    cp ${EXTDIR}/../resource/patches/boost/${TOOLSET}/user-config.jam tools/build/src/user-config.jam
+    echo "Boostrapping boost..."
+    ./bootstrap.sh
+    echo "Building..."
     ./b2 -q \
         target-os=linux \
         link=static \
         threading=multi \
         --layout=system \
-        --prefix="./../../out/boost" \
-        -s PLATFORM=android-${PLATFORM} \
+        --build-type=minimal \
+        -s PLATFORM=${PLATFORM} \
         -s VERSION=${VERSION} \
+        --prefix="${EXTDIR}/../out/boost" \
+        --includedir="${INCPATH}" \
+        --libdir="${LIBPATH}" \
+        --build-dir="$(pwd)/build" \
         --with-thread \
-        install
+        --with-program_options \
+        headers install
     popd
 
-    PATH=$OLDPATH
+    if [ ! -d "${INCPATH}" ];
+    then
+        echo "Copying headers to android include directory..."
+        mkdir -p ${INCPATH}
+        cp --recursive --dereference boost/boost ${INCPATH}
+    fi
 
-    mkdir -p ${INCPATH}
-    cp -R ../out/boost/include/* ${INCPATH}
-    mkdir -p ${LIBPATH}
-    cp -R ../out/boost/lib/*     ${LIBPATH}
+    PATH=$OLDPATH
 }
 
 function checkBoost {
@@ -78,18 +92,14 @@ function checkBoost {
     TOOLSET=$2
     VERSION=$3
 
-    INCPATH="$(dirname "$0")/../out/android/include"
-    LIBPATH="$(dirname "$0")/../out/android/lib/${TOOLSET}"
+    INCPATH="${EXTDIR}/../out/android/include"
+    LIBPATH="${EXTDIR}/../out/android/lib/${TOOLSET}"
 
-    if [ ! -d "${INCPATH}" ];
-    then
-        buildBoost
-    fi
     if [ ! -d "${LIBPATH}" ];
     then
         buildBoost
     fi
 }
 
-checkBoost 19 arm-linux-androideabi 4.9
-checkBoost 19 x86 4.9
+checkBoost android-19 arm-linux-androideabi 4.9
+checkBoost android-19 x86 4.9