diff --git a/.gitignore b/.gitignore index f3e8ec47da..8fc8285e16 100644 --- a/.gitignore +++ b/.gitignore @@ -69,6 +69,7 @@ build.*/ docs/ # Ignore NuGet artifacts .nuget/ +Build_android/build/ Generated Files/ # Ignore iOS temp build directories -Build_iOS/Apple-Boost-BuildScript \ No newline at end of file +Build_iOS/Apple-Boost-BuildScript diff --git a/Build_android/boost-for-android-x86.patch b/Build_android/boost-for-android-x86.patch deleted file mode 100644 index 4e24b988e3..0000000000 --- a/Build_android/boost-for-android-x86.patch +++ /dev/null @@ -1,173 +0,0 @@ -diff --git a/build-android.sh b/build-android.sh -index 40453f7..5902fe2 100755 ---- a/build-android.sh -+++ b/build-android.sh -@@ -195,8 +195,12 @@ case "$HOST_OS" in - PlatformOS=linux - esac - -+NDK_SOURCE_PROPERTIES=$AndroidNDKRoot"/source.properties" - NDK_RELEASE_FILE=$AndroidNDKRoot"/RELEASE.TXT" --if [ -f "${NDK_RELEASE_FILE}" ]; then -+if [ -f "${NDK_SOURCE_PROPERTIES}" ]; then -+ version=$(grep -i '^Pkg.Revision =' $NDK_SOURCE_PROPERTIES | cut -f2- -d=) -+ NDK_RN=$(echo $version | awk -F. '{print $1}') -+elif [ -f "${NDK_RELEASE_FILE}" ]; then - NDK_RN=`cat $NDK_RELEASE_FILE | sed 's/^r\(.*\)$/\1/g'` - elif [ -n "${AndroidSourcesDetected}" ]; then - if [ -f "${ANDROID_BUILD_TOP}/ndk/docs/CHANGES.html" ]; then -@@ -258,10 +262,20 @@ case "$NDK_RN" in - TOOLSET=gcc-androidR8e - ;; - "10 (64-bit)") -- TOOLCHAIN=${TOOLCHAIN:-arm-linux-androideabi-4.6} -- CXXPATH=$AndroidNDKRoot/toolchains/${TOOLCHAIN}/prebuilt/${PlatformOS}-x86_64/bin/arm-linux-androideabi-g++ -- TOOLSET=gcc-androidR8e -+ TOOLCHAIN=llvm-3.4 -+ CXXPATH=$AndroidNDKRoot/toolchains/${TOOLCHAIN}/prebuilt/${PlatformOS}-x86_64/bin/clang++ -+ TOOLSET=clang-androidR8e -+ ;; -+ "10e-rc4 (64-bit)"|"10e (64-bit)") -+ TOOLCHAIN=llvm-3.6 -+ CXXPATH=$AndroidNDKRoot/toolchains/${TOOLCHAIN}/prebuilt/${PlatformOS}-x86_64/bin/clang++ -+ TOOLSET=clang-androidR8e - ;; -+ 11) -+ TOOLCHAIN=llvm -+ CXXPATH=$AndroidNDKRoot/toolchains/${TOOLCHAIN}/prebuilt/${PlatformOS}-x86_64/bin/clang++ -+ TOOLSET=clang-androidR8e -+ ;; - *) - echo "Undefined or not supported Android NDK version!" - exit 1 -@@ -391,6 +405,7 @@ echo "Building boost for android" - export AndroidBinariesPath=`dirname $CXXPATH` - export PATH=$AndroidBinariesPath:$PATH - export AndroidNDKRoot -+ export PlatformOS - export NO_BZIP2=1 - - cxxflags="" -@@ -405,7 +420,7 @@ echo "Building boost for android" - --layout=versioned \ - --prefix="./../$BUILD_DIR/" \ - $LIBRARIES \ -- install 2>&1 \ -+ release debug install 2>&1 \ - || { dump "ERROR: Failed to build boost for android!" ; exit 1 ; } - } | tee -a $PROGDIR/build.log - -diff --git a/configs/user-config-boost-1_55_0.jam b/configs/user-config-boost-1_55_0.jam -index 666d4c8..93aba68 100644 ---- a/configs/user-config-boost-1_55_0.jam -+++ b/configs/user-config-boost-1_55_0.jam -@@ -39,93 +39,47 @@ - - import os ; - local AndroidNDKRoot = [ os.environ AndroidNDKRoot ] ; -+local PlatformOS = [ os.environ PlatformOS ] ; - - # -------------------------------------------------------------------- --# Is same for 8b, 8c and 8d --using gcc : androidR8b -+using clang : androidR8e - : --arm-linux-androideabi-g++ -+$(AndroidNDKRoot)/toolchains/llvm/prebuilt/$(PlatformOS)-x86_64/bin/clang++ - : --arm-linux-androideabi-ar -+--gcc-toolchain="$(AndroidNDKRoot)/toolchains/x86-4.9/prebuilt/$(PlatformOS)-x86_64" - -fexceptions - -frtti - -fpic - -ffunction-sections - -funwind-tables ---D__ARM_ARCH_5__ ---D__ARM_ARCH_5T__ ---D__ARM_ARCH_5E__ ---D__ARM_ARCH_5TE__ ---Wno-psabi ---march=armv5te ---mtune=xscale ---msoft-float ---mthumb -+-fstack-protector -+-no-canonical-prefixes -+--target=i686-none-linux-android -+--sysroot="$(AndroidNDKRoot)/platforms/android-9/arch-x86" - -Os - -fomit-frame-pointer ---fno-strict-aliasing ---finline-limit=64 ---I$(AndroidNDKRoot)/platforms/android-9/arch-arm/usr/include -+-fstrict-aliasing - -Wa,--noexecstack - -DANDROID - -D__ANDROID__ - -DNDEBUG - -O2 - -g ---I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.6/include ---I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/include -+-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.9/include -+-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86/include -+--target=i686-none-linux-android -+--gcc-toolchain="$(AndroidNDKRoot)/toolchains/x86-4.9/prebuilt/$(PlatformOS)-x86_64" -+--sysroot=$(AndroidNDKRoot)/platforms/android-9/arch-x86 - # @Moss - Above are the 'oficial' android flags --arm -+i686 - -fvisibility=hidden - -fvisibility-inlines-hidden - -fdata-sections ---D__arm__ - -D_REENTRANT - -D_GLIBCXX__PTHREADS -+-std=c++11 - ; - --# -------------------------------------------------------------------- --using gcc : androidR8e --: --arm-linux-androideabi-g++ --: --arm-linux-androideabi-ar ---fexceptions ---frtti ---fpic ---ffunction-sections ---funwind-tables ---D__ARM_ARCH_5__ ---D__ARM_ARCH_5T__ ---D__ARM_ARCH_5E__ ---D__ARM_ARCH_5TE__ ---Wno-psabi ---march=armv5te ---mtune=xscale ---msoft-float ---mthumb ---Os ---fomit-frame-pointer ---fno-strict-aliasing ---finline-limit=64 ---I$(AndroidNDKRoot)/platforms/android-9/arch-arm/usr/include ---Wa,--noexecstack ---DANDROID ---D__ANDROID__ ---DNDEBUG ---O2 ---g ---I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.6/include ---I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/include --# @Moss - Above are the 'oficial' android flags --arm ---fvisibility=hidden ---fvisibility-inlines-hidden ---fdata-sections ---D__arm__ ---D_REENTRANT ---D_GLIBCXX__PTHREADS --; - - - # ------------------ diff --git a/Build_android/boost-for-android.patch b/Build_android/boost-for-android.patch deleted file mode 100644 index 2b86e8f833..0000000000 --- a/Build_android/boost-for-android.patch +++ /dev/null @@ -1,175 +0,0 @@ -diff --git a/build-android.sh b/build-android.sh -index 40453f7..5902fe2 100755 ---- a/build-android.sh -+++ b/build-android.sh -@@ -195,8 +195,12 @@ case "$HOST_OS" in - PlatformOS=linux - esac - -+NDK_SOURCE_PROPERTIES=$AndroidNDKRoot"/source.properties" - NDK_RELEASE_FILE=$AndroidNDKRoot"/RELEASE.TXT" --if [ -f "${NDK_RELEASE_FILE}" ]; then -+if [ -f "${NDK_SOURCE_PROPERTIES}" ]; then -+ version=$(grep -i '^Pkg.Revision =' $NDK_SOURCE_PROPERTIES | cut -f2- -d=) -+ NDK_RN=$(echo $version | awk -F. '{print $1}') -+elif [ -f "${NDK_RELEASE_FILE}" ]; then - NDK_RN=`cat $NDK_RELEASE_FILE | sed 's/^r\(.*\)$/\1/g'` - elif [ -n "${AndroidSourcesDetected}" ]; then - if [ -f "${ANDROID_BUILD_TOP}/ndk/docs/CHANGES.html" ]; then -@@ -258,10 +262,20 @@ case "$NDK_RN" in - TOOLSET=gcc-androidR8e - ;; - "10 (64-bit)") -- TOOLCHAIN=${TOOLCHAIN:-arm-linux-androideabi-4.6} -- CXXPATH=$AndroidNDKRoot/toolchains/${TOOLCHAIN}/prebuilt/${PlatformOS}-x86_64/bin/arm-linux-androideabi-g++ -- TOOLSET=gcc-androidR8e -+ TOOLCHAIN=llvm-3.4 -+ CXXPATH=$AndroidNDKRoot/toolchains/${TOOLCHAIN}/prebuilt/${PlatformOS}-x86_64/bin/clang++ -+ TOOLSET=clang-androidR8e -+ ;; -+ "10e-rc4 (64-bit)"|"10e (64-bit)") -+ TOOLCHAIN=llvm-3.6 -+ CXXPATH=$AndroidNDKRoot/toolchains/${TOOLCHAIN}/prebuilt/${PlatformOS}-x86_64/bin/clang++ -+ TOOLSET=clang-androidR8e - ;; -+ 11) -+ TOOLCHAIN=llvm -+ CXXPATH=$AndroidNDKRoot/toolchains/${TOOLCHAIN}/prebuilt/${PlatformOS}-x86_64/bin/clang++ -+ TOOLSET=clang-androidR8e -+ ;; - *) - echo "Undefined or not supported Android NDK version!" - exit 1 -@@ -391,6 +405,7 @@ echo "Building boost for android" - export AndroidBinariesPath=`dirname $CXXPATH` - export PATH=$AndroidBinariesPath:$PATH - export AndroidNDKRoot -+ export PlatformOS - export NO_BZIP2=1 - - cxxflags="" -@@ -405,7 +420,7 @@ echo "Building boost for android" - --layout=versioned \ - --prefix="./../$BUILD_DIR/" \ - $LIBRARIES \ -- install 2>&1 \ -+ release debug install 2>&1 \ - || { dump "ERROR: Failed to build boost for android!" ; exit 1 ; } - } | tee -a $PROGDIR/build.log - -diff --git a/configs/user-config-boost-1_55_0.jam b/configs/user-config-boost-1_55_0.jam -index 666d4c8..cdab118 100644 ---- a/configs/user-config-boost-1_55_0.jam -+++ b/configs/user-config-boost-1_55_0.jam -@@ -39,84 +39,44 @@ - - import os ; - local AndroidNDKRoot = [ os.environ AndroidNDKRoot ] ; -+local PlatformOS = [ os.environ PlatformOS ] ; - - # -------------------------------------------------------------------- --# Is same for 8b, 8c and 8d --using gcc : androidR8b -+using clang : androidR8e - : --arm-linux-androideabi-g++ -+$(AndroidNDKRoot)/toolchains/llvm/prebuilt/$(PlatformOS)-x86_64/bin/clang++ - : --arm-linux-androideabi-ar -+--gcc-toolchain="$(AndroidNDKRoot)/toolchains/arm-linux-androideabi-4.9/prebuilt/$(PlatformOS)-x86_64" - -fexceptions - -frtti - -fpic - -ffunction-sections - -funwind-tables ---D__ARM_ARCH_5__ ---D__ARM_ARCH_5T__ ---D__ARM_ARCH_5E__ ---D__ARM_ARCH_5TE__ ---Wno-psabi ---march=armv5te ---mtune=xscale ---msoft-float -+-no-canonical-prefixes -+--target=armv7-none-linux-androideabi -+-march=armv7-a -+-mfloat-abi=softfp -+-mfpu=vfpv3-d16 - -mthumb ---Os ---fomit-frame-pointer ---fno-strict-aliasing ---finline-limit=64 ---I$(AndroidNDKRoot)/platforms/android-9/arch-arm/usr/include ---Wa,--noexecstack ---DANDROID ---D__ANDROID__ ---DNDEBUG ---O2 ---g ---I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.6/include ---I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/include --# @Moss - Above are the 'oficial' android flags --arm ---fvisibility=hidden ---fvisibility-inlines-hidden ---fdata-sections ---D__arm__ ---D_REENTRANT ---D_GLIBCXX__PTHREADS --; -- --# -------------------------------------------------------------------- --using gcc : androidR8e --: --arm-linux-androideabi-g++ --: --arm-linux-androideabi-ar ---fexceptions ---frtti ---fpic ---ffunction-sections ---funwind-tables -+--sysroot="$(AndroidNDKRoot)/platforms/android-9/arch-arm" - -D__ARM_ARCH_5__ - -D__ARM_ARCH_5T__ - -D__ARM_ARCH_5E__ - -D__ARM_ARCH_5TE__ ---Wno-psabi ---march=armv5te ---mtune=xscale ---msoft-float ---mthumb - -Os - -fomit-frame-pointer - -fno-strict-aliasing ---finline-limit=64 ---I$(AndroidNDKRoot)/platforms/android-9/arch-arm/usr/include - -Wa,--noexecstack - -DANDROID - -D__ANDROID__ - -DNDEBUG - -O2 - -g ---I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.6/include ---I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi/include -+-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.9/include -+-I$(AndroidNDKRoot)/sources/cxx-stl/gnu-libstdc++/4.9/libs/armeabi/include -+--target=armv7-none-linux-androideabi -+--gcc-toolchain="$(AndroidNDKRoot)/toolchains/arm-linux-androideabi-4.9/prebuilt/$(PlatformOS)-x86_64" -+--sysroot=$(AndroidNDKRoot)/platforms/android-9/arch-arm - # @Moss - Above are the 'oficial' android flags - arm - -fvisibility=hidden -@@ -125,9 +85,11 @@ arm-linux-androideabi-g++ - -D__arm__ - -D_REENTRANT - -D_GLIBCXX__PTHREADS -+-std=c++11 - ; - - -+ - # ------------------ - # GCC configuration. - # ------------------ diff --git a/Build_android/configure.sh b/Build_android/configure.sh index fd17fb7007..7dd6d8cf82 100755 --- a/Build_android/configure.sh +++ b/Build_android/configure.sh @@ -13,9 +13,8 @@ set -e -# Note: we require android ndk r10e available from -# http://dl.google.com/android/ndk/android-ndk-r10e-linux-x86_64.tar.bz2 -# http://dl.google.com/android/ndk/android-ndk-r10e-windows-x86_64.zip +# The Android NDK r10e or later may work, but we test with r17c. To download, see the following link: +# https://developer.android.com/ndk/downloads/index.html # ----------------- # Parse args @@ -25,40 +24,58 @@ DO_BOOST=1 DO_OPENSSL=1 DO_CPPRESTSDK=1 +BOOSTVER=1.65.1 +OPENSSLVER=1.0.2k + +API=15 +STL=c++_static + function usage { echo "Usage: $0 [--skip-boost] [--skip-openssl] [--skip-cpprestsdk] [-h] [--ndk ]" echo "" echo " --skip-boost Skip fetching and compiling boost" echo " --skip-openssl Skip fetching and compiling openssl" echo " --skip-cpprestsdk Skip compiling cpprestsdk" - echo " -h,--help,-? Display this information" + echo " --boost Override the Boost version to build (default is ${BOOSTVER})" + echo " --openssl Override the OpenSSL version to build (default is ${OPENSSLVER})" echo " --ndk If specified, overrides the ANDROID_NDK environment variable" + echo " -h,--help,-? Display this information" } while [[ $# > 0 ]] do case $1 in - "--skip-boost") - DO_BOOST=0 - ;; - "--skip-openssl") - DO_OPENSSL=0 - ;; - "--skip-cpprestsdk") - DO_CPPRESTSDK=0 - ;; - "-?"|"-h"|"--help") - usage - exit - ;; - "--ndk") - shift - export ANDROID_NDK=$1 - ;; - *) - usage - exit 1 - ;; + "--skip-boost") + DO_BOOST=0 + ;; + "--skip-openssl") + DO_OPENSSL=0 + ;; + "--skip-cpprestsdk") + DO_CPPRESTSDK=0 + ;; + "--boost") + shift + DO_BOOST=1 + BOOSTVER=$1 + ;; + "--openssl") + shift + DO_OPENSSL=1 + OPENSSLVER=$1 + ;; + "--ndk") + shift + export ANDROID_NDK=$1 + ;; + "-?"|"-h"|"--help") + usage + exit + ;; + *) + usage + exit 1 + ;; esac shift done @@ -74,6 +91,13 @@ fi NDK_DIR=`cd "${ANDROID_NDK}" && pwd` SRC_DIR=`pwd` +if [ -z "$NCPU" ]; then + NCPU=4 + if uname -s | grep -i "linux" > /dev/null ; then + NCPU=`cat /proc/cpuinfo | grep -c -i processor` + fi +fi + # ----------------------- # Identify the script dir # ----------------------- @@ -102,140 +126,55 @@ fi # This steps are based on the official openssl build instructions # http://wiki.openssl.org/index.php/Android -if [ "${DO_OPENSSL}" == "1" ] -then -( +if [ "${DO_OPENSSL}" == "1" ]; then ( if [ ! -d "openssl" ]; then mkdir openssl; fi cd openssl - cp "${DIR}/openssl/Makefile" . - export ANDROID_NDK_ROOT="${NDK_DIR}" - make all -) -fi - + cp -af "${DIR}/openssl/." . + make all ANDROID_NDK="${NDK_DIR}" ANDROID_TOOLCHAIN=clang ANDROID_GCC_VERSION=4.9 ANDROID_ABI=armeabi-v7a OPENSSL_PREFIX=armeabi-v7a OPENSSL_VERSION=$OPENSSLVER + make all ANDROID_NDK="${NDK_DIR}" ANDROID_TOOLCHAIN=clang ANDROID_GCC_VERSION=4.9 ANDROID_ABI=x86 OPENSSL_PREFIX=x86 OPENSSL_VERSION=$OPENSSLVER +) fi # ----- # Boost # ----- -# Uses the script from MysticTreeGames - -if [ "${DO_BOOST}" == "1" ] -then -( - ( - if [ ! -d "Boost-for-Android" ] - then - git clone https://github.com/MysticTreeGames/Boost-for-Android.git - fi - cd Boost-for-Android - if [ ! -e "cpprestsdk.patched.stamp" ] - then - git checkout 1c95d349d5f92c5ac1c24e0ec6985272a3e3883c - git reset --hard HEAD - git apply "$DIR/boost-for-android.patch" - touch cpprestsdk.patched.stamp - fi - - PATH="$PATH:$NDK_DIR" ./build-android.sh --boost=1.55.0 --with-libraries=random,date_time,filesystem,system,thread,chrono "${NDK_DIR}" || exit 1 - ) - - ( - if [ ! -d "Boost-for-Android-x86" ] - then - git clone Boost-for-Android Boost-for-Android-x86 - fi - cd Boost-for-Android-x86 - if [ ! -e "cpprestsdk.patched.stamp" ] - then - git checkout 1c95d349d5f92c5ac1c24e0ec6985272a3e3883c - git reset --hard HEAD - git apply "$DIR/boost-for-android-x86.patch" - ln -s ../Boost-for-Android/boost_1_55_0.tar.bz2 . - touch cpprestsdk.patched.stamp - fi - - PATH="$PATH:$NDK_DIR" ./build-android.sh --boost=1.55.0 --with-libraries=atomic,random,date_time,filesystem,system,thread,chrono "${NDK_DIR}" || exit 1 - ) -) -fi - -if [ "${DO_CPPRESTSDK}" == "1" ] -then -( -# ------------- -# android-cmake -# ------------- - if [ ! -e android-cmake ] - then - git clone https://github.com/taka-no-me/android-cmake.git - fi +# Uses the build script from Moritz Wundke (formerly MysticTreeGames) +# https://github.com/moritz-wundke/Boost-for-Android + +if [ "${DO_BOOST}" == "1" ]; then ( + if [ ! -d 'Boost-for-Android' ]; then git clone https://github.com/moritz-wundke/Boost-for-Android; fi + cd Boost-for-Android + git checkout 1bd9aa13463be4553b1146d6a5916566c2fba69c + PATH="$PATH:$NDK_DIR" \ + CXXFLAGS="-std=gnu++11" \ + ./build-android.sh \ + --boost=$BOOSTVER \ + --arch=armeabi-v7a,x86 \ + --with-libraries=atomic,random,date_time,filesystem,system,thread,chrono \ + "${NDK_DIR}" || exit 1 +) fi # ---------- # casablanca # ---------- - ( - mkdir -p build.armv7.debug - cd build.armv7.debug - cmake "$DIR/../Release/" \ - -DCMAKE_TOOLCHAIN_FILE=../android-cmake/android.toolchain.cmake \ - -DANDROID_ABI=armeabi-v7a \ - -DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-clang3.8 \ - -DANDROID_STL=none \ - -DANDROID_STL_FORCE_FEATURES=ON \ - -DANDROID_NATIVE_API_LEVEL=android-9 \ - -DANDROID_GOLD_LINKER=OFF \ - -DCMAKE_BUILD_TYPE=Debug \ - -DANDROID_NDK="${ANDROID_NDK}" - make -j 1 - ) - - ( - mkdir -p build.armv7.release - cd build.armv7.release - cmake "$DIR/../Release/" \ - -DCMAKE_TOOLCHAIN_FILE=../android-cmake/android.toolchain.cmake \ - -DANDROID_ABI=armeabi-v7a \ - -DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-clang3.8 \ - -DANDROID_STL=none \ - -DANDROID_STL_FORCE_FEATURES=ON \ - -DANDROID_NDK="${ANDROID_NDK}" \ - -DANDROID_NATIVE_API_LEVEL=android-9 \ - -DANDROID_GOLD_LINKER=OFF \ - -DCMAKE_BUILD_TYPE=Release - make -j 1 - ) - - ( - mkdir -p build.x86.debug - cd build.x86.debug - cmake "$DIR/../Release/" \ - -DCMAKE_TOOLCHAIN_FILE=../android-cmake/android.toolchain.cmake \ - -DANDROID_ABI=x86 \ - -DANDROID_TOOLCHAIN_NAME=x86-clang3.8 \ - -DANDROID_STL=none \ - -DANDROID_STL_FORCE_FEATURES=ON \ - -DANDROID_NATIVE_API_LEVEL=android-9 \ - -DANDROID_GOLD_LINKER=OFF \ - -DCMAKE_BUILD_TYPE=Debug \ - -DANDROID_NDK="${ANDROID_NDK}" - make -j 1 - ) - - ( - mkdir -p build.x86.release - cd build.x86.release - cmake "$DIR/../Release/" \ - -DCMAKE_TOOLCHAIN_FILE=../android-cmake/android.toolchain.cmake \ - -DANDROID_ABI=x86 \ - -DANDROID_TOOLCHAIN_NAME=x86-clang3.8 \ - -DANDROID_STL=none \ - -DANDROID_STL_FORCE_FEATURES=ON \ - -DANDROID_NDK="${ANDROID_NDK}" \ - -DANDROID_NATIVE_API_LEVEL=android-9 \ - -DANDROID_GOLD_LINKER=OFF \ - -DCMAKE_BUILD_TYPE=Release - make -j 1 - ) -) +if [ "${DO_CPPRESTSDK}" == "1" ]; then + # Use the builtin CMake toolchain configuration that comes with the NDK + function build_cpprestsdk { ( + mkdir -p $1 + cd $1 + cmake "${DIR}/.." \ + -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK}/build/cmake/android.toolchain.cmake" \ + -DANDROID_NDK="${ANDROID_NDK}" \ + -DANDROID_TOOLCHAIN=clang \ + -DANDROID_ABI=$2 \ + -DBOOST_VERSION="${BOOSTVER}" \ + -DCMAKE_BUILD_TYPE=$3 + make -j $NCPU + ) } + + # Build the cpprestsdk for each target configuration + build_cpprestsdk build.armv7.debug armeabi-v7a Debug + build_cpprestsdk build.armv7.release armeabi-v7a Release + build_cpprestsdk build.x86.debug x86 Debug + build_cpprestsdk build.x86.release x86 Release fi diff --git a/Build_android/openssl/Makefile b/Build_android/openssl/Makefile index 71a992164d..2da8fa48c9 100644 --- a/Build_android/openssl/Makefile +++ b/Build_android/openssl/Makefile @@ -1,60 +1,176 @@ -SHELL := /bin/bash -OPENSSL_VER = openssl-1.0.2k +# Configuration parameters +ANDROID_API = 18 +ANDROID_ABI = armeabi-v7a +ANDROID_HOST = linux-x86_64 +ANDROID_TOOLCHAIN = gcc +ANDROID_GCC_VERSION = 4.8 +OPENSSL_VERSION = 1.0.2k +OPENSSL_PACKAGE = openssl-$(OPENSSL_VERSION) +OPENSSL_PATCH = $(OPENSSL_PACKAGE).patch +OPENSSL_TARBALL = $(OPENSSL_PACKAGE).tar.gz +OPENSSL_URL = https://www.openssl.org/source/$(OPENSSL_TARBALL) +OPENSSL_OPTIONS = -no-ssl2 -no-ssl3 -no-comp -no-hw -no-engine +OPENSSL_PREFIX = android-$(ANDROID_API)-$(ANDROID_ABI)-$(ANDROID_TOOLCHAIN) +OPENSSL_SOURCE = $(OPENSSL_PACKAGE)-$(ANDROID_ABI) -all: armeabi-v7a/lib/libssl.a x86/lib/libssl.a +# Setup target parameters from ABI +ifneq ($(findstring armeabi,$(ANDROID_ABI)),) +ANDROID_ARCH := arm +ANDROID_TRIPLE := arm-linux-androideabi +ANDROID_TOOLARCH := $(ANDROID_TRIPLE) +OPENSSL_MACHINE := armv7 +OPENSSL_SYSTEM := android +OPENSSL_TARGET := android-armeabi +endif -clean: - rm -rf $(OPENSSL_VER) - rm -rf $(OPENSSL_VER)-armeabi-v7a - rm -rf armeabi-v7a - rm -rf setenv-android-x86.sh - -setenv-android.sh: - wget https://wiki.openssl.org/images/7/70/Setenv-android.sh - mv Setenv-android.sh setenv-android.sh - chmod a+x setenv-android.sh - -setenv-android-x86.sh: setenv-android.sh - cp setenv-android.sh setenv-android-x86.sh.tmp - sed -i -e 's/_ANDROID_EABI="arm-linux-androideabi-4.8"/_ANDROID_EABI="x86-4.8"/g' setenv-android-x86.sh.tmp - sed -i -e 's/_ANDROID_ARCH=arch-arm/_ANDROID_ARCH=arch-x86/g' setenv-android-x86.sh.tmp - mv setenv-android-x86.sh.tmp setenv-android-x86.sh - -$(OPENSSL_VER).tar.gz: - wget https://www.openssl.org/source/$(OPENSSL_VER).tar.gz - -armeabi-v7a/lib/libssl.a: setenv-android.sh $(OPENSSL_VER).tar.gz - [ -d "$(ANDROID_NDK_ROOT)" ] - export ANDROID_NDK_ROOT="$(ANDROID_NDK_ROOT)"; \ - . ./setenv-android.sh; \ +ifneq ($(findstring aarch64,$(ANDROID_ABI)),) +ANDROID_ARCH := arm64 +ANDROID_TRIPLE := aarch64-linux-android +ANDROID_TOOLARCH := $(ANDROID_TRIPLE) +OPENSSL_MACHINE := aarch64 +OPENSSL_SYSTEM := android64 +OPENSSL_TARGET := android64-aarch64 +endif + +ifneq ($(findstring x86,$(ANDROID_ABI)),) +ANDROID_ARCH := x86 +ANDROID_TRIPLE := i686-linux-android +ANDROID_TOOLARCH := $(ANDROID_ARCH) +OPENSSL_MACHINE := i686 +OPENSSL_SYSTEM := android +OPENSSL_TARGET := android-x86 +endif + +# Validate Android NDK directory paths and use fallback directories where applicable +define direxists = +$(if $(wildcard $(1)),$(strip $(1)),"") +endef + +define findfirstdir = +$(call direxists,$(firstword $(filter-out "",$(foreach val,$(3),$(call direxists,$(subst $(2),$(strip $(val)),$(1))))))) +endef + +ifeq ($(call direxists,$(ANDROID_NDK)),"") +$(error invalid Android NDK root directory) +endif + +ANDROID_LINK_SYSROOT := $(ANDROID_NDK)/platforms/android-$(ANDROID_API)/arch-$(ANDROID_ARCH) +ifeq ($(call direxists,$(ANDROID_LINK_SYSROOT)),"") +$(error invalid Android ABI or API level, could not locate Android NDK sysroot directory) +endif + +ANDROID_SYSROOT := $(ANDROID_NDK)/sysroot +ifeq ($(call direxists,$(ANDROID_SYSROOT)),"") +ANDROID_SYSROOT := $(ANDROID_LINK_SYSROOT) +endif + +ANDROID_GCC_VERSIONS := $(ANDROID_GCC_VERSION) 4.9 4.8 +ANDROID_GCC_PREBUILT_template := $(ANDROID_NDK)/toolchains/$(ANDROID_TOOLARCH)-<>/prebuilt +ANDROID_GCC_PREBUILT := $(call findfirstdir,$(ANDROID_GCC_PREBUILT_template),<>,$(ANDROID_GCC_VERSIONS)) +ifeq ($(ANDROID_GCC_PREBUILT),"") +$(error could not determine Android NDK GCC toolchain prebuilt directory) +endif + +ANDROID_HOSTS := $(ANDROID_HOST) linux-x86_64 linux-x86 darwin-x86_64 darwin-x86 +ANDROID_GCC_TOOLCHAIN_template := $(ANDROID_GCC_PREBUILT)/<> +ANDROID_GCC_TOOLCHAIN := $(call findfirstdir,$(ANDROID_GCC_TOOLCHAIN_template),<>,$(ANDROID_HOSTS)) +ifeq ($(ANDROID_GCC_TOOLCHAIN),"") +$(error could not determine Android NDK GCC toolchain host directory) +endif + +ANDROID_LLVM_VERSIONS := llvm llvm-3.6 llvm-3.5 llvm-3.4 +ANDROID_LLVM_TOOLCHAIN_template := $(ANDROID_NDK)/toolchains/<>/prebuilt/$(notdir $(ANDROID_GCC_TOOLCHAIN)) +ANDROID_LLVM_TOOLCHAIN := $(call findfirstdir,$(ANDROID_LLVM_TOOLCHAIN_template),<>,$(ANDROID_LLVM_VERSIONS)) +ifeq ($(ANDROID_LLVM_TOOLCHAIN),"") +$(error could not determine Android NDK LLVM toolchain directory) +endif + +# Configure toolchain +OPENSSL_CROSS_COMPILE := +OPENSSL_CC := +OPENSSL_RANLIB := $(ANDROID_GCC_TOOLCHAIN)/bin/$(ANDROID_TRIPLE)-ranlib + +ifneq ($(findstring clang,$(ANDROID_TOOLCHAIN)),) +OPENSSL_TARGET := $(OPENSSL_TARGET)-clang +OPENSSL_CC := $(ANDROID_LLVM_TOOLCHAIN)/bin/clang +endif + +ifneq ($(findstring gcc,$(ANDROID_TOOLCHAIN)),) +OPENSSL_CROSS_COMPILE := $(ANDROID_TRIPLE)- +OPENSSL_CC := $(ANDROID_GCC_TOOLCHAIN)/bin/$(ANDROID_TRIPLE)-gcc +endif + +ifeq ($(OPENSSL_CC),) +$(error invalid toolchain specified for ANDROID_TOOLCHAIN) +endif + +all: info $(OPENSSL_PREFIX)/lib/libssl.a + +$(OPENSSL_TARBALL): + @echo "Downloading OpenSSL tarball" + wget $(OPENSSL_URL) + +$(OPENSSL_PREFIX)/lib/libssl.a: $(OPENSSL_TARBALL) + @echo "Decompressing OpenSSL package" && \ ( \ set -e; \ - rm -rf $(OPENSSL_VER)/; \ - tar xzf $(OPENSSL_VER).tar.gz; \ - rm -rf $(OPENSSL_VER)-armeabi-v7a/ \ + rm -rf $(OPENSSL_SOURCE); \ + rm -rf $(OPENSSL_PACKAGE); \ + tar xzf $(OPENSSL_TARBALL); \ ) && \ - mv $(OPENSSL_VER) $(OPENSSL_VER)-armeabi-v7a && \ - cd $(OPENSSL_VER)-armeabi-v7a && \ - perl -pi -e 's/install: all install_docs install_sw/install: install_docs install_sw/g' Makefile.org && \ - ./config shared -no-ssl2 -no-ssl3 -no-comp -no-hw -no-engine --openssldir="`pwd`/../armeabi-v7a" && \ - make depend && \ - make all && \ - make install CC=$${ANDROID_TOOLCHAIN}/arm-linux-androideabi-gcc RANLIB=$${ANDROID_TOOLCHAIN}/arm-linux-androideabi-ranlib - -x86/lib/libssl.a: setenv-android-x86.sh $(OPENSSL_VER).tar.gz - [ -d "$(ANDROID_NDK_ROOT)" ] - export ANDROID_NDK_ROOT="$(ANDROID_NDK_ROOT)"; \ - . ./setenv-android-x86.sh; \ + mv $(OPENSSL_PACKAGE) $(OPENSSL_SOURCE) + @if test -f $(OPENSSL_PATCH); then \ + echo "Patching OpenSSL source tree"; \ + ( cd $(OPENSSL_SOURCE) && patch -p1 < ../$(OPENSSL_PATCH) ); \ + fi + @echo "Building OpenSSL" && \ + export ANDROID_NDK="$(ANDROID_NDK)" && \ + export ANDROID_API="$(ANDROID_API)" && \ + export ANDROID_ARCH="$(ANDROID_ARCH)" && \ + export ANDROID_TRIPLE="$(ANDROID_TRIPLE)" && \ + export ANDROID_SYSROOT="$(ANDROID_SYSROOT)" && \ + export ANDROID_LINK_SYSROOT="$(ANDROID_LINK_SYSROOT)" && \ + export ANDROID_GCC_TOOLCHAIN="$(ANDROID_GCC_TOOLCHAIN)" && \ + export CROSS_SYSROOT="$(ANDROID_SYSROOT)" && \ + export SYSROOT="$(ANDROID_SYSROOT)" && \ + export ARCH="$(ANDROID_ARCH)" && \ + export MACHINE="$(OPENSSL_MACHINE)" && \ + export SYSTEM="$(OPENSSL_SYSTEM)" && \ + export CROSS_COMPILE="$(OPENSSL_CROSS_COMPILE)" && \ + export HOSTCC="$(ANDROID_TOOLCHAIN)" && \ + export PATH="$(ANDROID_GCC_TOOLCHAIN)/bin:$(ANDROID_LLVM_TOOLCHAIN)/bin:$(PATH)" && \ ( \ - set -e; \ - rm -rf $(OPENSSL_VER)/; \ - tar xzf $(OPENSSL_VER).tar.gz; \ - rm -rf $(OPENSSL_VER)-x86/ \ - ) && \ - mv $(OPENSSL_VER) $(OPENSSL_VER)-x86 && \ - cd $(OPENSSL_VER)-x86 && \ - perl -pi -e 's/install: all install_docs install_sw/install: install_docs install_sw/g' Makefile.org && \ - ./config shared -no-ssl2 -no-ssl3 -no-comp -no-hw -no-engine --openssldir="`pwd`/../x86" && \ - make depend && \ - make all && \ - make install CC=$${ANDROID_TOOLCHAIN}/i686-linux-android-gcc RANLIB=$${ANDROID_TOOLCHAIN}/i686-linux-android-ranlib + cd $(OPENSSL_SOURCE); \ + perl Configure $(OPENSSL_TARGET) shared $(OPENSSL_OPTIONS) --prefix="`pwd`/../$(OPENSSL_PREFIX)" $(OPENSSL_CFLAGS) && \ + make depend && \ + make all && \ + make install CC=$(OPENSSL_CC) RANLIB=$(OPENSSL_RANLIB); \ + ) + +clean: + @echo "Cleaning" + rm -rf $(OPENSSL_SOURCE) + rm -rf $(OPENSSL_PACKAGE) + rm -rf $(OPENSSL_PREFIX) + +info: + @echo "OpenSSL build options" + @echo "ANDROID_NDK = $(ANDROID_NDK)" + @echo "ANDROID_API = $(ANDROID_API)" + @echo "ANDROID_ABI = $(ANDROID_ABI)" + @echo "ANDROID_HOST = $(ANDROID_HOST)" + @echo "ANDROID_TOOLCHAIN = $(ANDROID_TOOLCHAIN)" + @echo "ANDROID_TRIPLE = $(ANDROID_TRIPLE)" + @echo "ANDROID_SYSROOT = $(ANDROID_SYSROOT)" + @echo "ANDROID_LINK_SYSROOT = $(ANDROID_LINK_SYSROOT)" + @echo "ANDROID_GCC_TOOLCHAIN = $(ANDROID_GCC_TOOLCHAIN)" + @echo "ANDROID_LLVM_TOOLCHAIN = $(ANDROID_LLVM_TOOLCHAIN)" + @echo "OPENSSL_VERSION = $(OPENSSL_VERSION)" + @echo "OPENSSL_URL = $(OPENSSL_URL)" + @echo "OPENSSL_OPTIONS = $(OPENSSL_OPTIONS)" + @echo "OPENSSL_PREFIX = $(OPENSSL_PREFIX)" + @echo "OPENSSL_CFLAGS = $(OPENSSL_CFLAGS)" + @echo "OPENSSL_CC = $(OPENSSL_CC)" + @echo "OPENSSL_RANLIB = $(OPENSSL_RANLIB)" + +.PHONY: all clean info diff --git a/Build_android/openssl/openssl-1.0.2k.patch b/Build_android/openssl/openssl-1.0.2k.patch new file mode 100644 index 0000000000..992a27e9f9 --- /dev/null +++ b/Build_android/openssl/openssl-1.0.2k.patch @@ -0,0 +1,108 @@ +This patch applies several changes that enable OpenSSL 1.0.2k to be built +for Android using either Clang or GCC toolchains. + +An alias for the android-armv7 target, named android-armeabi, is added for +compatability with the OpenSSL 1.1.0 configuration target names. Support for +the AArch64 archicture is also added, as well as targets using the Clang +compiler. + +Clang does not recognize some of the ARM assembly nmenonics that are used in +OpenSSL. In particular, the 'adrl' pseudo instruction is not supported. To +further complicate matters, Clang doesn't support immediate fixup values so +the alternative adr/sub sequence used for the Thumb2 code path cannot be +used either. Instead it is replaced with a sequence of instructions that +computes the offset at runtime. It utilizes register r4 for computing the +intermediate result, which is first saved to and later restored from the +stack. The upstream bug in LLVM can be found here: +https://llvm.org/bugs/show_bug.cgi?id=24350 + +diff -Naur org/Configure mod/Configure +--- org/Configure 2017-01-26 05:22:03.000000000 -0800 ++++ mod/Configure 2018-01-17 14:25:44.712943600 -0800 +@@ -471,10 +471,17 @@ + "linux-alpha+bwx-ccc","ccc:-fast -readonly_strings -DL_ENDIAN::-D_REENTRANT:::SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL:${alpha_asm}", + + # Android: linux-* but without pointers to headers and libs. +-"android","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", +-"android-x86","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:".eval{my $asm=${x86_elf_asm};$asm=~s/:elf/:android/;$asm}.":dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", +-"android-armv7","gcc:-march=armv7-a -mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", +-"android-mips","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${mips32_asm}:o32:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android","gcc:-mandroid --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android-x86","gcc:-mandroid --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:".eval{my $asm=${x86_elf_asm};$asm=~s/:elf/:android/;$asm}.":dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android-armv7","gcc:-march=armv7-a -mandroid --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android-armeabi","gcc:-march=armv7-a -mandroid --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android64-aarch64","gcc:-march=armv8-a -mandroid --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${aarch64_asm}:linux64:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android-mips","gcc:-mandroid --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${mips32_asm}:o32:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android-x86-clang","clang:-target i686-none-linux-android --gcc-toolchain=\$(ANDROID_GCC_TOOLCHAIN) --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:".eval{my $asm=${x86_elf_asm};$asm=~s/:elf/:android/;$asm}.":dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android-armv7-clang","clang:-target armv7-none-linux-androideabi --gcc-toolchain=\$(ANDROID_GCC_TOOLCHAIN) --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android-armeabi-clang","clang:-target armv7-none-linux-androideabi --gcc-toolchain=\$(ANDROID_GCC_TOOLCHAIN) --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android64-aarch64-clang","clang:-target aarch64-none-linux-android --gcc-toolchain=\$(ANDROID_GCC_TOOLCHAIN) --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${aarch64_asm}:linux64:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android-mips-clang","clang:-target mipsel-none-linux-android --gcc-toolchain=\$(ANDROID_GCC_TOOLCHAIN) --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${mips32_asm}:o32:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", + + #### *BSD [do see comment about ${BSDthreads} above!] + "BSD-generic32","gcc:-O3 -fomit-frame-pointer -Wall::${BSDthreads}:::BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL:${no_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", +diff -Naur org/crypto/bn/asm/armv4-gf2m.pl mod/crypto/bn/asm/armv4-gf2m.pl +--- org/crypto/bn/asm/armv4-gf2m.pl 2017-01-26 05:22:03.000000000 -0800 ++++ mod/crypto/bn/asm/armv4-gf2m.pl 2018-01-17 11:38:57.297482700 -0800 +@@ -213,8 +213,8 @@ + .align 5 + .LNEON: + ldr r12, [sp] @ 5th argument +- vmov.32 $a, r2, r1 +- vmov.32 $b, r12, r3 ++ vmov $a, r2, r1 ++ vmov $b, r12, r3 + vmov.i64 $k48, #0x0000ffffffffffff + vmov.i64 $k32, #0x00000000ffffffff + vmov.i64 $k16, #0x000000000000ffff +diff -Naur org/crypto/sha/asm/sha256-armv4.pl mod/crypto/sha/asm/sha256-armv4.pl +--- org/crypto/sha/asm/sha256-armv4.pl 2017-01-26 05:22:03.000000000 -0800 ++++ mod/crypto/sha/asm/sha256-armv4.pl 2018-01-17 11:38:57.306342000 -0800 +@@ -576,6 +576,7 @@ + my @MSG=map("q$_",(8..11)); + my ($W0,$W1,$ABCD_SAVE,$EFGH_SAVE)=map("q$_",(12..15)); + my $Ktbl="r3"; ++my $Temp="r4"; + + $code.=<<___; + #if __ARM_MAX_ARCH__>=7 && !defined(__KERNEL__) +@@ -591,7 +592,13 @@ + sha256_block_data_order_armv8: + .LARMv8: + vld1.32 {$ABCD,$EFGH},[$ctx] +-# ifdef __thumb2__ ++# if defined(__clang__) ++ stmdb sp!,{r4,lr} ++ adr $Ktbl,.LARMv8 ++ ldr $Temp,=K256 ++ sub $Temp,$Ktbl,$Temp ++ sub $Ktbl,$Ktbl,$Temp ++# elif defined(__thumb2__) + adr $Ktbl,.LARMv8 + sub $Ktbl,$Ktbl,#.LARMv8-K256 + # else +@@ -655,7 +662,12 @@ + + vst1.32 {$ABCD,$EFGH},[$ctx] + ++# ifdef __clang__ ++ ldmia sp!,{r4,pc} ++# else + ret @ bx lr ++# endif ++ + .size sha256_block_data_order_armv8,.-sha256_block_data_order_armv8 + #endif + ___ +diff -Naur org/Makefile.org mod/Makefile.org +--- org/Makefile.org 2017-01-26 05:22:03.000000000 -0800 ++++ mod/Makefile.org 2018-01-17 14:26:20.623418300 -0800 +@@ -532,7 +532,7 @@ + @$(MAKE) SDIRS='$(SDIRS)' clean + @$(MAKE) TAR='$(TAR)' TARFLAGS='$(TARFLAGS)' $(DISTTARVARS) tar + +-install: all install_docs install_sw ++install: install_docs install_sw + + install_sw: + @$(PERL) $(TOP)/util/mkdir-p.pl $(INSTALL_PREFIX)$(INSTALLTOP)/bin \ diff --git a/Build_android/openssl/openssl-1.0.2l.patch b/Build_android/openssl/openssl-1.0.2l.patch new file mode 100644 index 0000000000..03acbee7c0 --- /dev/null +++ b/Build_android/openssl/openssl-1.0.2l.patch @@ -0,0 +1,108 @@ +This patch applies several changes that enable OpenSSL 1.0.2l to be built +for Android using either Clang or GCC toolchains. + +An alias for the android-armv7 target, named android-armeabi, is added for +compatability with the OpenSSL 1.1.0 configuration target names. Support for +the AArch64 archicture is also added, as well as targets using the Clang +compiler. + +Clang does not recognize some of the ARM assembly nmenonics that are used in +OpenSSL. In particular, the 'adrl' pseudo instruction is not supported. To +further complicate matters, Clang doesn't support immediate fixup values so +the alternative adr/sub sequence used for the Thumb2 code path cannot be +used either. Instead it is replaced with a sequence of instructions that +computes the offset at runtime. It utilizes register r4 for computing the +intermediate result, which is first saved to and later restored from the +stack. The upstream bug in LLVM can be found here: +https://llvm.org/bugs/show_bug.cgi?id=24350 + +diff -Naur org/Configure mod/Configure +--- org/Configure 2017-05-25 05:54:38.000000000 -0700 ++++ mod/Configure 2018-01-17 20:36:12.497485400 -0800 +@@ -471,10 +471,17 @@ + "linux-alpha+bwx-ccc","ccc:-fast -readonly_strings -DL_ENDIAN::-D_REENTRANT:::SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL:${alpha_asm}", + + # Android: linux-* but without pointers to headers and libs. +-"android","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", +-"android-x86","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:".eval{my $asm=${x86_elf_asm};$asm=~s/:elf/:android/;$asm}.":dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", +-"android-armv7","gcc:-march=armv7-a -mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", +-"android-mips","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${mips32_asm}:o32:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android","gcc:-mandroid --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android-x86","gcc:-mandroid --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:".eval{my $asm=${x86_elf_asm};$asm=~s/:elf/:android/;$asm}.":dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android-armv7","gcc:-march=armv7-a -mandroid --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android-armeabi","gcc:-march=armv7-a -mandroid --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android64-aarch64","gcc:-march=armv8-a -mandroid --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${aarch64_asm}:linux64:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android-mips","gcc:-mandroid --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${mips32_asm}:o32:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android-x86-clang","clang:-target i686-none-linux-android --gcc-toolchain=\$(ANDROID_GCC_TOOLCHAIN) --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:".eval{my $asm=${x86_elf_asm};$asm=~s/:elf/:android/;$asm}.":dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android-armv7-clang","clang:-target armv7-none-linux-androideabi --gcc-toolchain=\$(ANDROID_GCC_TOOLCHAIN) --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android-armeabi-clang","clang:-target armv7-none-linux-androideabi --gcc-toolchain=\$(ANDROID_GCC_TOOLCHAIN) --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android64-aarch64-clang","clang:-target aarch64-none-linux-android --gcc-toolchain=\$(ANDROID_GCC_TOOLCHAIN) --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${aarch64_asm}:linux64:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android-mips-clang","clang:-target mipsel-none-linux-android --gcc-toolchain=\$(ANDROID_GCC_TOOLCHAIN) --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${mips32_asm}:o32:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", + + #### *BSD [do see comment about ${BSDthreads} above!] + "BSD-generic32","gcc:-O3 -fomit-frame-pointer -Wall::${BSDthreads}:::BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL:${no_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", +diff -Naur org/crypto/bn/asm/armv4-gf2m.pl mod/crypto/bn/asm/armv4-gf2m.pl +--- org/crypto/bn/asm/armv4-gf2m.pl 2017-05-25 05:54:34.000000000 -0700 ++++ mod/crypto/bn/asm/armv4-gf2m.pl 2018-01-17 20:36:12.508421200 -0800 +@@ -213,8 +213,8 @@ + .align 5 + .LNEON: + ldr r12, [sp] @ 5th argument +- vmov.32 $a, r2, r1 +- vmov.32 $b, r12, r3 ++ vmov $a, r2, r1 ++ vmov $b, r12, r3 + vmov.i64 $k48, #0x0000ffffffffffff + vmov.i64 $k32, #0x00000000ffffffff + vmov.i64 $k16, #0x000000000000ffff +diff -Naur org/crypto/sha/asm/sha256-armv4.pl mod/crypto/sha/asm/sha256-armv4.pl +--- org/crypto/sha/asm/sha256-armv4.pl 2017-05-25 05:54:34.000000000 -0700 ++++ mod/crypto/sha/asm/sha256-armv4.pl 2018-01-17 20:36:12.518242800 -0800 +@@ -576,6 +576,7 @@ + my @MSG=map("q$_",(8..11)); + my ($W0,$W1,$ABCD_SAVE,$EFGH_SAVE)=map("q$_",(12..15)); + my $Ktbl="r3"; ++my $Temp="r4"; + + $code.=<<___; + #if __ARM_MAX_ARCH__>=7 && !defined(__KERNEL__) +@@ -591,7 +592,13 @@ + sha256_block_data_order_armv8: + .LARMv8: + vld1.32 {$ABCD,$EFGH},[$ctx] +-# ifdef __thumb2__ ++# if defined(__clang__) ++ stmdb sp!,{r4,lr} ++ adr $Ktbl,.LARMv8 ++ ldr $Temp,=K256 ++ sub $Temp,$Ktbl,$Temp ++ sub $Ktbl,$Ktbl,$Temp ++# elif defined(__thumb2__) + adr $Ktbl,.LARMv8 + sub $Ktbl,$Ktbl,#.LARMv8-K256 + # else +@@ -655,7 +662,12 @@ + + vst1.32 {$ABCD,$EFGH},[$ctx] + ++# ifdef __clang__ ++ ldmia sp!,{r4,pc} ++# else + ret @ bx lr ++# endif ++ + .size sha256_block_data_order_armv8,.-sha256_block_data_order_armv8 + #endif + ___ +diff -Naur org/Makefile.org mod/Makefile.org +--- org/Makefile.org 2017-05-25 05:54:38.000000000 -0700 ++++ mod/Makefile.org 2018-01-17 20:36:12.532553700 -0800 +@@ -540,7 +540,7 @@ + @$(MAKE) SDIRS='$(SDIRS)' clean + @$(MAKE) TAR='$(TAR)' TARFLAGS='$(TARFLAGS)' $(DISTTARVARS) tar + +-install: all install_docs install_sw ++install: install_docs install_sw + + install_sw: + @$(PERL) $(TOP)/util/mkdir-p.pl $(INSTALL_PREFIX)$(INSTALLTOP)/bin \ diff --git a/Build_android/openssl/openssl-1.0.2m.patch b/Build_android/openssl/openssl-1.0.2m.patch new file mode 100644 index 0000000000..8314b1e7fd --- /dev/null +++ b/Build_android/openssl/openssl-1.0.2m.patch @@ -0,0 +1,108 @@ +This patch applies several changes that enable OpenSSL 1.0.2m to be built +for Android using either Clang or GCC toolchains. + +An alias for the android-armv7 target, named android-armeabi, is added for +compatability with the OpenSSL 1.1.0 configuration target names. Support for +the AArch64 archicture is also added, as well as targets using the Clang +compiler. + +Clang does not recognize some of the ARM assembly nmenonics that are used in +OpenSSL. In particular, the 'adrl' pseudo instruction is not supported. To +further complicate matters, Clang doesn't support immediate fixup values so +the alternative adr/sub sequence used for the Thumb2 code path cannot be +used either. Instead it is replaced with a sequence of instructions that +computes the offset at runtime. It utilizes register r4 for computing the +intermediate result, which is first saved to and later restored from the +stack. The upstream bug in LLVM can be found here: +https://llvm.org/bugs/show_bug.cgi?id=24350 + +diff -Naur org/Configure mod/Configure +--- org/Configure 2017-11-02 07:32:57.000000000 -0700 ++++ mod/Configure 2018-01-17 20:39:03.152448900 -0800 +@@ -471,10 +471,17 @@ + "linux-alpha+bwx-ccc","ccc:-fast -readonly_strings -DL_ENDIAN::-D_REENTRANT:::SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL:${alpha_asm}", + + # Android: linux-* but without pointers to headers and libs. +-"android","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", +-"android-x86","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:".eval{my $asm=${x86_elf_asm};$asm=~s/:elf/:android/;$asm}.":dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", +-"android-armv7","gcc:-march=armv7-a -mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", +-"android-mips","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${mips32_asm}:o32:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android","gcc:-mandroid --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android-x86","gcc:-mandroid --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:".eval{my $asm=${x86_elf_asm};$asm=~s/:elf/:android/;$asm}.":dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android-armv7","gcc:-march=armv7-a -mandroid --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android-armeabi","gcc:-march=armv7-a -mandroid --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android64-aarch64","gcc:-march=armv8-a -mandroid --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${aarch64_asm}:linux64:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android-mips","gcc:-mandroid --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${mips32_asm}:o32:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android-x86-clang","clang:-target i686-none-linux-android --gcc-toolchain=\$(ANDROID_GCC_TOOLCHAIN) --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:".eval{my $asm=${x86_elf_asm};$asm=~s/:elf/:android/;$asm}.":dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android-armv7-clang","clang:-target armv7-none-linux-androideabi --gcc-toolchain=\$(ANDROID_GCC_TOOLCHAIN) --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android-armeabi-clang","clang:-target armv7-none-linux-androideabi --gcc-toolchain=\$(ANDROID_GCC_TOOLCHAIN) --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android64-aarch64-clang","clang:-target aarch64-none-linux-android --gcc-toolchain=\$(ANDROID_GCC_TOOLCHAIN) --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${aarch64_asm}:linux64:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android-mips-clang","clang:-target mipsel-none-linux-android --gcc-toolchain=\$(ANDROID_GCC_TOOLCHAIN) --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${mips32_asm}:o32:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", + + #### *BSD [do see comment about ${BSDthreads} above!] + "BSD-generic32","gcc:-O3 -fomit-frame-pointer -Wall::${BSDthreads}:::BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL:${no_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", +diff -Naur org/crypto/bn/asm/armv4-gf2m.pl mod/crypto/bn/asm/armv4-gf2m.pl +--- org/crypto/bn/asm/armv4-gf2m.pl 2017-11-02 07:32:57.000000000 -0700 ++++ mod/crypto/bn/asm/armv4-gf2m.pl 2018-01-17 20:39:03.163187500 -0800 +@@ -213,8 +213,8 @@ + .align 5 + .LNEON: + ldr r12, [sp] @ 5th argument +- vmov.32 $a, r2, r1 +- vmov.32 $b, r12, r3 ++ vmov $a, r2, r1 ++ vmov $b, r12, r3 + vmov.i64 $k48, #0x0000ffffffffffff + vmov.i64 $k32, #0x00000000ffffffff + vmov.i64 $k16, #0x000000000000ffff +diff -Naur org/crypto/sha/asm/sha256-armv4.pl mod/crypto/sha/asm/sha256-armv4.pl +--- org/crypto/sha/asm/sha256-armv4.pl 2017-11-02 07:32:58.000000000 -0700 ++++ mod/crypto/sha/asm/sha256-armv4.pl 2018-01-17 20:39:03.173547800 -0800 +@@ -576,6 +576,7 @@ + my @MSG=map("q$_",(8..11)); + my ($W0,$W1,$ABCD_SAVE,$EFGH_SAVE)=map("q$_",(12..15)); + my $Ktbl="r3"; ++my $Temp="r4"; + + $code.=<<___; + #if __ARM_MAX_ARCH__>=7 && !defined(__KERNEL__) +@@ -591,7 +592,13 @@ + sha256_block_data_order_armv8: + .LARMv8: + vld1.32 {$ABCD,$EFGH},[$ctx] +-# ifdef __thumb2__ ++# if defined(__clang__) ++ stmdb sp!,{r4,lr} ++ adr $Ktbl,.LARMv8 ++ ldr $Temp,=K256 ++ sub $Temp,$Ktbl,$Temp ++ sub $Ktbl,$Ktbl,$Temp ++# elif defined(__thumb2__) + adr $Ktbl,.LARMv8 + sub $Ktbl,$Ktbl,#.LARMv8-K256 + # else +@@ -655,7 +662,12 @@ + + vst1.32 {$ABCD,$EFGH},[$ctx] + ++# ifdef __clang__ ++ ldmia sp!,{r4,pc} ++# else + ret @ bx lr ++# endif ++ + .size sha256_block_data_order_armv8,.-sha256_block_data_order_armv8 + #endif + ___ +diff -Naur org/Makefile.org mod/Makefile.org +--- org/Makefile.org 2017-11-02 07:32:57.000000000 -0700 ++++ mod/Makefile.org 2018-01-17 20:39:03.187911200 -0800 +@@ -540,7 +540,7 @@ + @$(MAKE) SDIRS='$(SDIRS)' clean + @$(MAKE) TAR='$(TAR)' TARFLAGS='$(TARFLAGS)' $(DISTTARVARS) tar + +-install: all install_docs install_sw ++install: install_docs install_sw + + install_sw: + @$(PERL) $(TOP)/util/mkdir-p.pl $(INSTALL_PREFIX)$(INSTALLTOP)/bin \ diff --git a/Build_android/openssl/openssl-1.0.2n.patch b/Build_android/openssl/openssl-1.0.2n.patch new file mode 100644 index 0000000000..7e96205923 --- /dev/null +++ b/Build_android/openssl/openssl-1.0.2n.patch @@ -0,0 +1,108 @@ +This patch applies several changes that enable OpenSSL 1.0.2n to be built +for Android using either Clang or GCC toolchains. + +An alias for the android-armv7 target, named android-armeabi, is added for +compatability with the OpenSSL 1.1.0 configuration target names. Support for +the AArch64 archicture is also added, as well as targets using the Clang +compiler. + +Clang does not recognize some of the ARM assembly nmenonics that are used in +OpenSSL. In particular, the 'adrl' pseudo instruction is not supported. To +further complicate matters, Clang doesn't support immediate fixup values so +the alternative adr/sub sequence used for the Thumb2 code path cannot be +used either. Instead it is replaced with a sequence of instructions that +computes the offset at runtime. It utilizes register r4 for computing the +intermediate result, which is first saved to and later restored from the +stack. The upstream bug in LLVM can be found here: +https://llvm.org/bugs/show_bug.cgi?id=24350 + +diff -Naur org/Configure mod/Configure +--- org/Configure 2017-12-07 05:16:38.000000000 -0800 ++++ mod/Configure 2018-01-17 20:41:03.880613500 -0800 +@@ -471,10 +471,17 @@ + "linux-alpha+bwx-ccc","ccc:-fast -readonly_strings -DL_ENDIAN::-D_REENTRANT:::SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL:${alpha_asm}", + + # Android: linux-* but without pointers to headers and libs. +-"android","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", +-"android-x86","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:".eval{my $asm=${x86_elf_asm};$asm=~s/:elf/:android/;$asm}.":dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", +-"android-armv7","gcc:-march=armv7-a -mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", +-"android-mips","gcc:-mandroid -I\$(ANDROID_DEV)/include -B\$(ANDROID_DEV)/lib -O3 -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${mips32_asm}:o32:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android","gcc:-mandroid --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android-x86","gcc:-mandroid --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:".eval{my $asm=${x86_elf_asm};$asm=~s/:elf/:android/;$asm}.":dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android-armv7","gcc:-march=armv7-a -mandroid --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android-armeabi","gcc:-march=armv7-a -mandroid --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android64-aarch64","gcc:-march=armv8-a -mandroid --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${aarch64_asm}:linux64:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android-mips","gcc:-mandroid --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${mips32_asm}:o32:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android-x86-clang","clang:-target i686-none-linux-android --gcc-toolchain=\$(ANDROID_GCC_TOOLCHAIN) --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:".eval{my $asm=${x86_elf_asm};$asm=~s/:elf/:android/;$asm}.":dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android-armv7-clang","clang:-target armv7-none-linux-androideabi --gcc-toolchain=\$(ANDROID_GCC_TOOLCHAIN) --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android-armeabi-clang","clang:-target armv7-none-linux-androideabi --gcc-toolchain=\$(ANDROID_GCC_TOOLCHAIN) --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${armv4_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android64-aarch64-clang","clang:-target aarch64-none-linux-android --gcc-toolchain=\$(ANDROID_GCC_TOOLCHAIN) --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -fomit-frame-pointer -Wall::-D_REENTRANT::-ldl:SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${aarch64_asm}:linux64:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", ++"android-mips-clang","clang:-target mipsel-none-linux-android --gcc-toolchain=\$(ANDROID_GCC_TOOLCHAIN) --sysroot \$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -B\$(ANDROID_LINK_SYSROOT)/lib -D__ANDROID_API__=\$(ANDROID_API) -O3 -Wall::-D_REENTRANT::-ldl:BN_LLONG RC4_CHAR RC4_CHUNK DES_INT DES_UNROLL BF_PTR:${mips32_asm}:o32:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", + + #### *BSD [do see comment about ${BSDthreads} above!] + "BSD-generic32","gcc:-O3 -fomit-frame-pointer -Wall::${BSDthreads}:::BN_LLONG RC2_CHAR RC4_INDEX DES_INT DES_UNROLL:${no_asm}:dlfcn:bsd-gcc-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)", +diff -Naur org/crypto/bn/asm/armv4-gf2m.pl mod/crypto/bn/asm/armv4-gf2m.pl +--- org/crypto/bn/asm/armv4-gf2m.pl 2017-12-07 05:16:38.000000000 -0800 ++++ mod/crypto/bn/asm/armv4-gf2m.pl 2018-01-17 20:41:03.891956700 -0800 +@@ -213,8 +213,8 @@ + .align 5 + .LNEON: + ldr r12, [sp] @ 5th argument +- vmov.32 $a, r2, r1 +- vmov.32 $b, r12, r3 ++ vmov $a, r2, r1 ++ vmov $b, r12, r3 + vmov.i64 $k48, #0x0000ffffffffffff + vmov.i64 $k32, #0x00000000ffffffff + vmov.i64 $k16, #0x000000000000ffff +diff -Naur org/crypto/sha/asm/sha256-armv4.pl mod/crypto/sha/asm/sha256-armv4.pl +--- org/crypto/sha/asm/sha256-armv4.pl 2017-12-07 05:16:38.000000000 -0800 ++++ mod/crypto/sha/asm/sha256-armv4.pl 2018-01-17 20:41:03.901983600 -0800 +@@ -576,6 +576,7 @@ + my @MSG=map("q$_",(8..11)); + my ($W0,$W1,$ABCD_SAVE,$EFGH_SAVE)=map("q$_",(12..15)); + my $Ktbl="r3"; ++my $Temp="r4"; + + $code.=<<___; + #if __ARM_MAX_ARCH__>=7 && !defined(__KERNEL__) +@@ -591,7 +592,13 @@ + sha256_block_data_order_armv8: + .LARMv8: + vld1.32 {$ABCD,$EFGH},[$ctx] +-# ifdef __thumb2__ ++# if defined(__clang__) ++ stmdb sp!,{r4,lr} ++ adr $Ktbl,.LARMv8 ++ ldr $Temp,=K256 ++ sub $Temp,$Ktbl,$Temp ++ sub $Ktbl,$Ktbl,$Temp ++# elif defined(__thumb2__) + adr $Ktbl,.LARMv8 + sub $Ktbl,$Ktbl,#.LARMv8-K256 + # else +@@ -655,7 +662,12 @@ + + vst1.32 {$ABCD,$EFGH},[$ctx] + ++# ifdef __clang__ ++ ldmia sp!,{r4,pc} ++# else + ret @ bx lr ++# endif ++ + .size sha256_block_data_order_armv8,.-sha256_block_data_order_armv8 + #endif + ___ +diff -Naur org/Makefile.org mod/Makefile.org +--- org/Makefile.org 2017-12-07 05:16:38.000000000 -0800 ++++ mod/Makefile.org 2018-01-17 20:41:03.916748800 -0800 +@@ -540,7 +540,7 @@ + @$(MAKE) SDIRS='$(SDIRS)' clean + @$(MAKE) TAR='$(TAR)' TARFLAGS='$(TARFLAGS)' $(DISTTARVARS) tar + +-install: all install_docs install_sw ++install: install_docs install_sw + + install_sw: + @$(PERL) $(TOP)/util/mkdir-p.pl $(INSTALL_PREFIX)$(INSTALLTOP)/bin \ diff --git a/Build_android/openssl/openssl-1.1.0g.patch b/Build_android/openssl/openssl-1.1.0g.patch new file mode 100644 index 0000000000..77a92779d7 --- /dev/null +++ b/Build_android/openssl/openssl-1.1.0g.patch @@ -0,0 +1,76 @@ +This patch applies several changes that enable OpenSSL 1.1.0g to be built +for Android using either Clang or GCC toolchains. + +diff -Naur org/Configurations/10-main.conf mod/Configurations/10-main.conf +--- org/Configurations/10-main.conf 2017-11-02 07:29:01.000000000 -0700 ++++ mod/Configurations/10-main.conf 2018-01-18 10:59:41.675138500 -0800 +@@ -910,15 +910,27 @@ + # systems are perfectly capable of executing binaries targeting + # Froyo. Keep in mind that in the nutshell Android builds are + # about JNI, i.e. shared libraries, not applications. +- cflags => add(picker(default => "-mandroid -fPIC --sysroot=\$(CROSS_SYSROOT) -Wa,--noexecstack")), ++ cflags => add(picker(default => "-mandroid -fPIC --sysroot=\$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -D__ANDROID_API__=\$(ANDROID_API) -Wa,--noexecstack")), + bin_cflags => "-pie", + }, ++ "android-clang" => { ++ inherit_from => [ "linux-generic32" ], ++ cc => "clang", ++ cflags => add(picker(default => "-fPIC --gcc-toolchain=\$(ANDROID_GCC_TOOLCHAIN) --sysroot=\$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -D__ANDROID_API__=\$(ANDROID_API) -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Qunused-arguments -Wa,--noexecstack")), ++}, + "android-x86" => { + inherit_from => [ "android", asm("x86_asm") ], + cflags => add(picker(release => "-fomit-frame-pointer")), + bn_ops => "BN_LLONG", + perlasm_scheme => "android", + }, ++ "android-x86-clang" => { ++ inherit_from => [ "android-clang", asm("x86_asm") ], ++ cflags => add(picker(default => "-target i686-none-linux-android", ++ release => "-fomit-frame-pointer")), ++ bn_ops => "BN_LLONG", ++ perlasm_scheme => "android", ++ }, + ################################################################ + # Contemporary Android applications can provide multiple JNI + # providers in .apk, targeting multiple architectures. Among +@@ -943,20 +955,38 @@ + "android-armeabi" => { + inherit_from => [ "android", asm("armv4_asm") ], + }, ++ "android-armeabi-clang" => { ++ inherit_from => [ "android-clang", asm("armv4_asm") ], ++ cflags => add("-target armv7-none-linux-androideabi"), ++ }, + "android-mips" => { + inherit_from => [ "android", asm("mips32_asm") ], + perlasm_scheme => "o32", + }, +- ++ "android-mips-clang" => { ++ inherit_from => [ "android-clang", asm("mips32_asm") ], ++ cflags => add("-target mipsel-none-linux-android"), ++ perlasm_scheme => "o32", ++ }, + "android64" => { + inherit_from => [ "linux-generic64" ], +- cflags => add(picker(default => "-mandroid -fPIC --sysroot=\$(CROSS_SYSROOT) -Wa,--noexecstack")), ++ cflags => add(picker(default => "-mandroid -fPIC --sysroot=\$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -D__ANDROID_API__=\$(ANDROID_API) -Wa,--noexecstack")), + bin_cflags => "-pie", + }, ++ "android64-clang" => { ++ inherit_from => [ "linux-generic64" ], ++ cc => "clang", ++ cflags => add(picker(default => "-fPIC --gcc-toolchain=\$(ANDROID_GCC_TOOLCHAIN) --sysroot=\$(ANDROID_LINK_SYSROOT) -isystem \$(ANDROID_SYSROOT)/usr/include -isystem \$(ANDROID_SYSROOT)/usr/include/\$(ANDROID_TRIPLE) -D__ANDROID_API__=\$(ANDROID_API) -Wextra -Wno-missing-field-initializers -Wno-unused-parameter -Qunused-arguments -Wa,--noexecstack")), ++ }, + "android64-aarch64" => { + inherit_from => [ "android64", asm("aarch64_asm") ], + perlasm_scheme => "linux64", + }, ++ "android64-aarch64-clang" => { ++ inherit_from => [ "android64-clang", asm("aarch64_asm") ], ++ cflags => add("-target aarch64-none-linux-android"), ++ perlasm_scheme => "linux64", ++ }, + + #### *BSD + "BSD-generic32" => { diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index ca43881905..7e11cc2478 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -22,6 +22,7 @@ adish LeonidCSIT kreuzerkrieg evanc +Jesse Towner (jwtowner) Abinsula s.r.l. Gianfranco Costamagna (LocutusOfBorg) diff --git a/Release/CMakeLists.txt b/Release/CMakeLists.txt index 6f6eba37ea..54cfa18585 100644 --- a/Release/CMakeLists.txt +++ b/Release/CMakeLists.txt @@ -113,34 +113,15 @@ else() endif() set(WARNINGS) -set(ANDROID_STL_FLAGS) +set(ANDROID_LIBS) # Platform (not compiler) specific settings if(IOS) # The cxx_flags must be reset here, because the ios-cmake toolchain file unfortunately sets "-headerpad_max_install_names" which is not a valid clang flag. set(CMAKE_CXX_FLAGS "-fvisibility=hidden") elseif(ANDROID) - if(ARM) - set(LIBCXX_STL "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/thumb/libgnustl_static.a") - else() - set(LIBCXX_STL "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/4.8/libs/x86/libgnustl_static.a") - endif() # These are used in the shared library case - set(ANDROID_STL_FLAGS - ${LIBCXX_STL} - atomic - dl - gcc - c - m - -nodefaultlibs - ) - - include_directories(SYSTEM - "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/4.8/include" - "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/4.8/libs/armeabi-v7a/include" - "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/4.8/include/backward" - ) + set(ANDROID_LIBS atomic dl) elseif(UNIX) # This includes OSX elseif(WIN32) add_definitions(-DUNICODE -D_UNICODE -DWIN32 -D_SCL_SECURE_NO_WARNINGS) @@ -165,8 +146,7 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR IOS) message("-- Setting clang options") if(ANDROID) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-pedantic") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes -Wno-pointer-arith") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-pedantic -Wno-attributes -Wno-pointer-arith") elseif(CMAKE_SYSTEM_NAME MATCHES "Linux") set(WARNINGS -Wall -Wextra -Wcast-qual -Wconversion -Wformat=2 -Winit-self -Winvalid-pch -Wmissing-format-attribute -Wmissing-include-dirs -Wpacked -Wredundant-decls) set(LINUX_SUPPRESSIONS -Wno-overloaded-virtual -Wno-sign-conversion -Wno-deprecated -Wno-unknown-pragmas -Wno-reorder -Wno-char-subscripts -Wno-switch -Wno-unused-parameter -Wno-unused-variable -Wno-deprecated -Wno-unused-value -Wno-unknown-warning-option -Wno-return-type-c-linkage -Wno-unused-function -Wno-sign-compare -Wno-shorten-64-to-32 -Wno-unused-local-typedefs) @@ -241,7 +221,7 @@ function(add_casablanca_test NAME SOURCES_VAR) cpprest common_utilities unittestpp - ${ANDROID_STL_FLAGS} + ${ANDROID_LIBS} ) if (BUILD_SHARED_LIBS) add_test(NAME ${NAME} diff --git a/Release/cmake/cpprest_find_boost.cmake b/Release/cmake/cpprest_find_boost.cmake index 67f5dad9b8..0138893bd6 100644 --- a/Release/cmake/cpprest_find_boost.cmake +++ b/Release/cmake/cpprest_find_boost.cmake @@ -1,3 +1,23 @@ +macro(cpprestsdk_find_boost_android_package) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) + if(CMAKE_HOST_WIN32) + set(WIN32 1) + set(UNIX) + elseif(CMAKE_HOST_APPLE) + set(APPLE 1) + set(UNIX) + endif() + find_package(${ARGN}) + set(APPLE) + set(WIN32) + set(UNIX 1) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY) +endmacro() + function(cpprest_find_boost) if(TARGET cpprestsdk_boost_internal) return() @@ -16,13 +36,13 @@ function(cpprest_find_boost) elseif(ANDROID) set(Boost_COMPILER "-clang") if(ARM) - set(BOOST_ROOT "${CMAKE_BINARY_DIR}/../Boost-for-Android/build" CACHE INTERNAL "") - set(BOOST_LIBRARYDIR "${CMAKE_BINARY_DIR}/../Boost-for-Android/build/lib" CACHE INTERNAL "") + set(BOOST_ROOT "${CMAKE_BINARY_DIR}/../Boost-for-Android/build/out/armeabi-v7a" CACHE INTERNAL "") + set(BOOST_LIBRARYDIR "${CMAKE_BINARY_DIR}/../Boost-for-Android/build/out/armeabi-v7a/lib" CACHE INTERNAL "") else() - set(BOOST_ROOT "${CMAKE_BINARY_DIR}/../Boost-for-Android-x86/build" CACHE INTERNAL "") - set(BOOST_LIBRARYDIR "${CMAKE_BINARY_DIR}/../Boost-for-Android-x86/build/lib" CACHE INTERNAL "") + set(BOOST_ROOT "${CMAKE_BINARY_DIR}/../Boost-for-Android/build/out/x86" CACHE INTERNAL "") + set(BOOST_LIBRARYDIR "${CMAKE_BINARY_DIR}/../Boost-for-Android/build/out/x86/lib" CACHE INTERNAL "") endif() - find_host_package(Boost 1.55 EXACT REQUIRED COMPONENTS random system thread filesystem chrono atomic) + cpprestsdk_find_boost_android_package(Boost ${BOOST_VERSION} EXACT REQUIRED COMPONENTS random system thread filesystem chrono atomic) elseif(UNIX) find_package(Boost REQUIRED COMPONENTS random system thread filesystem chrono atomic date_time regex) else() diff --git a/Release/include/cpprest/details/basic_types.h b/Release/include/cpprest/details/basic_types.h index eadba01684..e9477c736a 100644 --- a/Release/include/cpprest/details/basic_types.h +++ b/Release/include/cpprest/details/basic_types.h @@ -20,8 +20,10 @@ #include "cpprest/details/cpprest_compat.h" #ifndef _WIN32 -# define __STDC_LIMIT_MACROS -# include +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS +#endif +#include #else #include #endif diff --git a/Release/src/android/asm/page.h b/Release/src/android/asm/page.h deleted file mode 100644 index bd2f6e60c5..0000000000 --- a/Release/src/android/asm/page.h +++ /dev/null @@ -1,5 +0,0 @@ -#pragma once - -// This file is to fix a break introduced by Android 5 in Boost 1.55. - -// As noted in http://code.google.com/p/android/issues/detail?id=39983, asm/page.h was removed. diff --git a/Release/src/http/client/http_client_asio.cpp b/Release/src/http/client/http_client_asio.cpp index ada8e9494d..0ef90695a5 100644 --- a/Release/src/http/client/http_client_asio.cpp +++ b/Release/src/http/client/http_client_asio.cpp @@ -1842,7 +1842,7 @@ class asio_context final : public request_context, public std::enable_shared_fro timedout }; -#if defined(ANDROID) || defined(__ANDROID__) +#if (defined(ANDROID) || defined(__ANDROID__)) && !defined(_LIBCPP_VERSION) boost::chrono::microseconds m_duration; #else std::chrono::microseconds m_duration; diff --git a/Release/src/http/listener/http_server_asio.cpp b/Release/src/http/listener/http_server_asio.cpp index 02aa616177..14d75316a7 100644 --- a/Release/src/http/listener/http_server_asio.cpp +++ b/Release/src/http/listener/http_server_asio.cpp @@ -250,7 +250,7 @@ struct crlfcrlf_nonascii_searcher_t State state = State::none; while (cur != end) { - char c = *cur; + const auto c = static_cast(*cur); if (c == '\r') { if (state == State::crlf) @@ -282,12 +282,7 @@ struct crlfcrlf_nonascii_searcher_t state = State::none; } } - else if (c <= '\x1F' && c >= '\x00') - { - ++cur; - return std::make_pair(cur, true); - } - else if (c <= '\xFF' && c >= '\x80') + else if (c <= 0x1Fu || c >= 0x80) { ++cur; return std::make_pair(cur, true); diff --git a/Release/src/pch/stdafx.h b/Release/src/pch/stdafx.h index dc909d5afd..811786cacf 100644 --- a/Release/src/pch/stdafx.h +++ b/Release/src/pch/stdafx.h @@ -52,7 +52,7 @@ #include #include #include "pthread.h" -#if (defined(ANDROID) || defined(__ANDROID__)) +#if (defined(ANDROID) || defined(__ANDROID__)) && !defined(_LIBCPP_VERSION) // Boost doesn't recognize libstdcpp on top of clang correctly #include "boost/config.hpp" #include "boost/config/stdlib/libstdcpp3.hpp" diff --git a/Release/src/pplx/threadpool.cpp b/Release/src/pplx/threadpool.cpp index 9bfeb398ba..a569eb861c 100644 --- a/Release/src/pplx/threadpool.cpp +++ b/Release/src/pplx/threadpool.cpp @@ -25,6 +25,17 @@ namespace // This pointer will be 0-initialized by default (at load time). std::atomic JVM; +static void abort_if_no_jvm() +{ + if (JVM == nullptr) + { + __android_log_print(ANDROID_LOG_ERROR, "CPPRESTSDK", "%s", + "The CppREST SDK must be initialized before first use on android: " + "https://github.com/Microsoft/cpprestsdk/wiki/How-to-build-for-Android"); + std::abort(); + } +} + JNIEnv* get_jvm_env() { abort_if_no_jvm(); @@ -37,17 +48,6 @@ JNIEnv* get_jvm_env() return env; } - -static void abort_if_no_jvm() -{ - if (JVM == nullptr) - { - __android_log_print(ANDROID_LOG_ERROR, "CPPRESTSDK", "%s", - "The CppREST SDK must be initialized before first use on android: " - "https://github.com/Microsoft/cpprestsdk/wiki/How-to-build-for-Android"); - std::abort(); - } -} #endif // __ANDROID__ struct threadpool_impl final : crossplat::threadpool diff --git a/Release/src/websockets/client/ws_client_wspp.cpp b/Release/src/websockets/client/ws_client_wspp.cpp index 5ba93d25eb..0715249f16 100644 --- a/Release/src/websockets/client/ws_client_wspp.cpp +++ b/Release/src/websockets/client/ws_client_wspp.cpp @@ -24,23 +24,26 @@ // Force websocketpp to use C++ std::error_code instead of Boost. #define _WEBSOCKETPP_CPP11_SYSTEM_ERROR_ #if defined(_MSC_VER) -#pragma warning( push ) -#pragma warning( disable : 4100 4127 4512 4996 4701 4267 ) -#define _WEBSOCKETPP_CPP11_STL_ -#define _WEBSOCKETPP_CONSTEXPR_TOKEN_ -#if _MSC_VER < 1900 -#define _WEBSOCKETPP_NOEXCEPT_TOKEN_ -#endif -#elif defined(__GNUC__) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wconversion" -#pragma GCC diagnostic ignored "-Wunused-parameter" -#pragma GCC diagnostic ignored "-Wignored-qualifiers" -#pragma GCC diagnostic ignored "-Wcast-qual" + #pragma warning( push ) + #pragma warning( disable : 4100 4127 4512 4996 4701 4267 ) + #define _WEBSOCKETPP_CPP11_STL_ + #define _WEBSOCKETPP_CONSTEXPR_TOKEN_ + #if _MSC_VER < 1900 + #define _WEBSOCKETPP_NOEXCEPT_TOKEN_ + #endif #elif defined(__clang__) -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wconversion" -#pragma clang diagnostic ignored "-Winfinite-recursion" + #pragma clang diagnostic push + #pragma clang diagnostic ignored "-Wconversion" + #pragma clang diagnostic ignored "-Winfinite-recursion" + #pragma clang diagnostic ignored "-Wtautological-constant-compare" + #pragma clang diagnostic ignored "-Wtautological-unsigned-enum-zero-compare" + #pragma clang diagnostic ignored "-Wcast-qual" +#elif defined(__GNUC__) + #pragma GCC diagnostic push + #pragma GCC diagnostic ignored "-Wconversion" + #pragma GCC diagnostic ignored "-Wunused-parameter" + #pragma GCC diagnostic ignored "-Wignored-qualifiers" + #pragma GCC diagnostic ignored "-Wcast-qual" #endif #include @@ -49,10 +52,10 @@ #if defined(_WIN32) #pragma warning( pop ) -#elif defined(__GNUC__) -#pragma GCC diagnostic pop #elif defined(__clang__) #pragma clang diagnostic pop +#elif defined(__GNUC__) +#pragma GCC diagnostic pop #endif diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 198df70a30..993b92accf 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -205,6 +205,16 @@ jobs: cd build.release/Release/Binaries ./test_runner *test.so displayName: 'Run tests, release' + - job: Android + pool: + vmImage: 'Ubuntu 16.04' + steps: + - script: | + mkdir Build_android/build + cd Build_android/build + export NCPU=2 + ../configure.sh --ndk /usr/local/lib/android/sdk/ndk-bundle + displayName: 'Build for Android' - job: MacOS_Homebrew pool: vmImage: 'macOS-10.13'