export DEBIAN_FRONTEND=noninteractive
export ANDROID_HOME=/tmp/android_sdk
export ANDROID_SDK_ROOT=${ANDROID_HOME}
export ANDROID_NDK_ROOT=/tmp/android_ndk
export ANDROID_NDK_TOOLCHAIN_PREFIX=arm-linux-androideabi
export ANDROID_NDK_TOOLCHAIN_VERSION=4.9
export ANDROID_NDK_HOST=linux-x86_64
export ANDROID_NDK_PLATFORM=android-21
export ANDROID_NDK_TOOLS_PREFIX=${ANDROID_NDK_TOOLCHAIN_PREFIX}
export QT_PATH=/tmp/Qt
export QT_ANDROID_ARM=${QT_PATH}/5.6/android_armv7
export QMAKESPEC=android-g++
export PATH=a${PATH}:${QT_ANDROID_ARM}/bin:${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools


cd /tmp
wget http://dl.google.com/android/android-sdk_r24.4.1-linux.tgz \
    && tar zxvf android-sdk_r24.4.1-linux.tgz \
    && mv android-sdk-linux $ANDROID_SDK_ROOT \
    && rm -rf /opt/android-sdk_r24.4.1-linux.tgz

wget http://dl.google.com/android/repository/android-ndk-r11b-linux-x86_64.zip \
    && unzip android-ndk-r11b-linux-x86_64.zip \
    && mv android-ndk-r11b $ANDROID_NDK_ROOT \
    && rm -rf android-ndk-r11b-linux-x86_64.zip

echo "y" | android update sdk -u -a -t tools,platform-tools,build-tools-21.1.2,${ANDROID_NDK_PLATFORM}

wget http://download.qt.io/official_releases/qt/5.6/5.6.0/single/qt-everywhere-opensource-src-5.6.0.tar.gz  \
    && tar zxvf qt-everywhere-opensource-src-5.6.0.tar.gz \
    && mv qt-everywhere-opensource-src-5.6.0 qt_src \
    && rm -rf qt-everywhere-opensource-src-5.6.0.tar.gz
    
cd /tmp/qt_src

./configure \
     -opensource -confirm-license \
     -release \
     -xplatform ${QMAKESPEC} \
     -nomake tests -nomake examples \
     -android-ndk ${ANDROID_NDK_ROOT} \
     -android-sdk ${ANDROID_SDK_ROOT} \
     -android-ndk-host ${ANDROID_NDK_HOST} \
     -android-toolchain-version ${ANDROID_NDK_TOOLCHAIN_VERSION} \
     -skip qttranslations -skip qtserialport \
     -no-warnings-are-errors \
     -prefix ${QT_ANDROID_ARM} \
     && make -j6 && make install \
     && echo "y" | rm -rf  /tmp/qt_src