diff --git a/.gitignore b/.gitignore index 4ac71f64..8544a6b8 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ tools/*-android-toolchain tools/curl* tools/openssl* tools/protobuf* +output/ diff --git a/tools/build-curl4android.sh b/tools/build-curl4android.sh index 747ed7e5..2cf27239 100755 --- a/tools/build-curl4android.sh +++ b/tools/build-curl4android.sh @@ -16,17 +16,25 @@ set -u +SOURCE="$0" +while [ -h "$SOURCE" ]; do + DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" +done +pwd_path="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + source ./_shared.sh # Setup architectures, library name and other vars + cleanup from previous runs -ARCHS=("android" "android-armv7" "android64-arm64" "android-x86" "android-x86_64" "mips" "mips64") +ARCHS=("android" "android-armeabi" "android64-aarch64" "android-x86" "android64" "android-mips" "android-mips64") OUTNAME=("armeabi" "armeabi-v7a" "arm64-v8a" "x86" "x86_64" "mips" "mips64") -TOOLS_ROOT=`pwd` +TOOLS_ROOT="${pwd_path}" LIB_NAME="curl-7.51.0" -LIB_DEST_DIR=${TOOLS_ROOT}/libs +LIB_DEST_DIR=${TOOLS_ROOT}/../output/android NDK=$ANDROID_NDK_ROOT ANDROID_PLATFORM="android-23" -ANDROID_API="21" +ANDROID_API="23" [ -f ${LIB_NAME}.tar.gz ] || wget https://curl.haxx.se/download/${LIB_NAME}.tar.gz # Unarchive library, then configure and make for specified architectures configure_make() @@ -38,12 +46,15 @@ configure_make() configure $* # fix me - cp ${TOOLS_ROOT}/../lib/${OUT}/libssl.a ${SYSROOT}/usr/lib - cp ${TOOLS_ROOT}/../lib/${OUT}/libcrypto.a ${SYSROOT}/usr/lib - cp -r ${TOOLS_ROOT}/../include/${OUT}/openssl ${SYSROOT}/usr/include + cp ${TOOLS_ROOT}/../output/android/openssl-android-${OUT}/lib/libssl.a ${SYSROOT}/usr/lib + cp ${TOOLS_ROOT}/../output/android/openssl-android-${OUT}/lib/libcrypto.a ${SYSROOT}/usr/lib + cp -r ${TOOLS_ROOT}/../output/android/openssl-android-${OUT}/include/openssl ${SYSROOT}/usr/include - mkdir -p ${LIB_DEST_DIR}/${OUT} - ./configure --prefix=${LIB_DEST_DIR}/${OUT} \ + PREFIX_DIR=${LIB_DEST_DIR}/curl-android-${OUT} + if [ -d "${PREFIX_DIR}" ]; then + rm -fr ${PREFIX_DIR} + fi + ./configure --prefix=${PREFIX_DIR} \ --with-sysroot=${SYSROOT} \ --host=${TOOL} \ --with-ssl=/usr \ @@ -56,9 +67,6 @@ configure_make() if make -j4 then make install - - cp ${LIB_DEST_DIR}/${OUT}/lib/libcurl.a ${TOOLS_ROOT}/../lib/${OUT} - cp -r ${LIB_DEST_DIR}/${OUT}/include/curl ${TOOLS_ROOT}/../include/${OUT} fi; popd; } diff --git a/tools/build-openssl4android.sh b/tools/build-openssl4android.sh index 4dbb7095..e02d0cb7 100755 --- a/tools/build-openssl4android.sh +++ b/tools/build-openssl4android.sh @@ -16,17 +16,24 @@ set -u +SOURCE="$0" +while [ -h "$SOURCE" ]; do + DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" +done +pwd_path="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + source ./_shared.sh # Setup architectures, library name and other vars + cleanup from previous runs -ARCHS=("android" "android-armv7" "android64-arm64" "android-x86" "android-x86_64" "mips" "mips64") +ARCHS=("android" "android-armeabi" "android64-aarch64" "android-x86" "android64" "android-mips" "android-mips64") OUTNAME=("armeabi" "armeabi-v7a" "arm64-v8a" "x86" "x86_64" "mips" "mips64") -TOOLS_ROOT=`pwd` +TOOLS_ROOT="${pwd_path}" LIB_NAME="openssl-1.1.0c" -LIB_DEST_DIR=${TOOLS_ROOT}/libs +LIB_DEST_DIR=${TOOLS_ROOT}/../output/android NDK=$ANDROID_NDK_ROOT -ANDROID_API="21" -[ -d ${LIB_DEST_DIR} ] && rm -rf ${LIB_DEST_DIR} +ANDROID_API="23" [ -f "${LIB_NAME}.tar.gz" ] || wget https://www.openssl.org/source/${LIB_NAME}.tar.gz; # Unarchive library, then configure and make for specified architectures configure_make() { @@ -35,9 +42,14 @@ configure_make() { tar xfz "${LIB_NAME}.tar.gz" pushd "${LIB_NAME}"; + PREFIX_DIR=${LIB_DEST_DIR}/openssl-android-${OUT} + if [ -d "${PREFIX_DIR}" ]; then + rm -fr ${PREFIX_DIR} + fi + configure $* ./Configure $ARCH \ - --prefix=${LIB_DEST_DIR}/${OUT} \ + --prefix=${PREFIX_DIR} \ --with-zlib-include=$SYSROOT/usr/include \ --with-zlib-lib=$SYSROOT/usr/lib \ zlib \ @@ -49,11 +61,11 @@ configure_make() { if make -j4 then make install - [ -d ${TOOLS_ROOT}/../include/$OUT ] || mkdir -p ${TOOLS_ROOT}/../include/$OUT - cp -r include/openssl ${TOOLS_ROOT}/../include/$OUT + # [ -d ${TOOLS_ROOT}/../include/$OUT ] || mkdir -p ${TOOLS_ROOT}/../include/$OUT + # cp -r include/openssl ${TOOLS_ROOT}/../include/$OUT - [ -d ${TOOLS_ROOT}/../lib/$OUT ] || mkdir -p ${TOOLS_ROOT}/../lib/$OUT - find . -type f -iname \( 'libssl.a' -or -iname 'libcrypto.a' \) -exec cp {} ${TOOLS_ROOT}/../lib/$OUT \; + # [ -d ${TOOLS_ROOT}/../lib/$OUT ] || mkdir -p ${TOOLS_ROOT}/../lib/$OUT + # find . -type f -iname \( 'libssl.a' -or -iname 'libcrypto.a' \) -exec cp {} ${TOOLS_ROOT}/../lib/$OUT \; fi; } diff --git a/tools/build-openssl4ios.sh b/tools/build-openssl4ios.sh index 42d36aff..4504ae8b 100755 --- a/tools/build-openssl4ios.sh +++ b/tools/build-openssl4ios.sh @@ -31,7 +31,7 @@ PLATFORMS=("iPhoneOS" "iPhoneOS" "iPhoneOS" "iPhoneSimulator" "iPhoneSimulator") DEVELOPER=`xcode-select -print-path` SDK_VERSION=""10.2"" LIB_NAME="openssl-1.1.0c" -LIB_DEST_DIR="lib" +LIB_DEST_DIR="${pwd_path}/../output/ios/openssl-ios-universal" HEADER_DEST_DIR="include" rm -rf "${HEADER_DEST_DIR}" "${LIB_DEST_DIR}" "${LIB_NAME}" @@ -56,7 +56,7 @@ configure_make() export TOOLS="${DEVELOPER}" export CC="${TOOLS}/usr/bin/gcc -arch ${ARCH}" - PREFIX_DIR="${pwd_path}/openssl-ios-${ARCH}" + PREFIX_DIR="${pwd_path}/../output/ios/openssl-ios-${ARCH}" if [ -d "${PREFIX_DIR}" ]; then rm -fr "${PREFIX_DIR}" fi @@ -89,7 +89,7 @@ done create_lib() { LIB_SRC=$1; LIB_DST=$2; - LIB_PATHS=( "${ARCHS[@]/#/${pwd_path}/openssl-ios-}" ) + LIB_PATHS=( "${ARCHS[@]/#/${pwd_path}/../output/ios/openssl-ios-}" ) LIB_PATHS=( "${LIB_PATHS[@]/%//lib/${LIB_SRC}}" ) lipo ${LIB_PATHS[@]} -create -output "${LIB_DST}" } diff --git a/tools/build-protobuf4android.sh b/tools/build-protobuf4android.sh index b16b5c5f..d1d8f086 100755 --- a/tools/build-protobuf4android.sh +++ b/tools/build-protobuf4android.sh @@ -16,18 +16,26 @@ set -u +SOURCE="$0" +while [ -h "$SOURCE" ]; do + DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" +done +pwd_path="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + source ./_shared.sh # Setup architectures, library name and other vars + cleanup from previous runs -ARCHS=("android" "android-armv7" "android64-arm64" "android-x86" "android-x86_64" "mips" "mips64") +ARCHS=("android" "android-armeabi" "android64-aarch64" "android-x86" "android64" "android-mips" "android-mips64") OUTNAME=("armeabi" "armeabi-v7a" "arm64-v8a" "x86" "x86_64" "mips" "mips64") -TOOLS_ROOT=`pwd` +TOOLS_ROOT=${pwd_path} LIB_NAME="protobuf" LIB_VERSION="3.1.0" LIB_FILENAME=${LIB_NAME}-${LIB_VERSION} -LIB_DEST_DIR=${TOOLS_ROOT}/libs +LIB_DEST_DIR=${TOOLS_ROOT}/../output/android NDK=$ANDROID_NDK_ROOT -ANDROID_API="21" +ANDROID_API="23" # rm -rf ${LIB_DEST_DIR} [ -f ${LIB_FILENAME}.tar.gz ] || wget https://github.com/google/${LIB_NAME}/archive/v${LIB_VERSION}.tar.gz -O ${LIB_FILENAME}.tar.gz # Unarchive library, then configure and make for specified architectures @@ -38,13 +46,18 @@ configure_make() { tar xfz "${LIB_FILENAME}.tar.gz" pushd "${LIB_FILENAME}"; + PREFIX_DIR=${LIB_DEST_DIR}/protobuf-android-${OUT} + if [ -d "${PREFIX_DIR}" ]; then + rm -fr ${PREFIX_DIR} + fi + export LDFLAGS="-static-libstdc++" export LIBS="-lc++_static -latomic" configure $* "clang" # fix CXXFLAGS export CXXFLAGS=${CXXFLAGS/"-finline-limit=64"/""} ./autogen.sh - ./configure --prefix=${LIB_DEST_DIR}/${OUT} \ + ./configure --prefix=${PREFIX_DIR} \ --with-sysroot=${SYSROOT} \ --with-protoc=`which protoc` \ --with-zlib \ @@ -57,11 +70,6 @@ configure_make() { then mkdir -p ${LIB_DEST_DIR}/${OUT} make install - - [ -d ${TOOLS_ROOT}/../lib/${OUT} ] || mkdir -p ${TOOLS_ROOT}/../lib/${OUT} - find ${LIB_DEST_DIR}/${OUT}/lib -type f -iname '*.a' -exec cp {} ${TOOLS_ROOT}/../lib/${OUT} \; - [ -d ${TOOLS_ROOT}/../include/${OUT} ] || mkdir -p ${TOOLS_ROOT}/../include/${OUT} - cp -r ${LIB_DEST_DIR}/$OUT/include/ ${TOOLS_ROOT}/../include/${OUT} fi; popd; }