build.sh 1.75 KB
Newer Older
1 2
#!/usr/bin/env bash

3 4 5
# Use directory of current script as the build directory and working directory
cd "$( dirname "${BASH_SOURCE[0]}" )"
ANDROID_BUILD_DIR="$(pwd)"
6 7 8 9 10 11 12 13 14 15 16

# Get access to android_build functions and variables
source ${ANDROID_BUILD_DIR}/android_build_helper.sh

# Choose a C++ standard library implementation from the ndk
ANDROID_BUILD_CXXSTL="gnustl_shared_48"

# Set up android build environment and set ANDROID_BUILD_OPTS array
android_build_env
android_build_opts

17
# Use a temporary build directory
18
cache="/tmp/android_build/${TOOLCHAIN_NAME}"
19
rm -rf "${cache}"
20 21
mkdir -p "${cache}"

22 23 24 25 26 27
# Check for environment variable to clear the prefix and do a clean build
if [[ $ANDROID_BUILD_CLEAN ]]; then
    echo "Doing a clean build (removing previous build and depedencies)..."
    rm -rf "${ANDROID_BUILD_PREFIX}"/*
fi

28
##
29
# Build libsodium from latest master branch
30 31 32

(android_build_verify_so "libsodium.so" &> /dev/null) || {
    rm -rf "${cache}/libsodium"
33
    (cd "${cache}" && git clone git://github.com/jedisct1/libsodium.git) || exit 1
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
    (cd "${cache}/libsodium" && ./autogen.sh \
        && ./configure "${ANDROID_BUILD_OPTS[@]}" --disable-soname-versions \
        && make \
        && make install) || exit 1
}

##
# Build libzmq from local source

LIBTOOL_EXTRA_LDFLAGS='-avoid-version'

(android_build_verify_so "libzmq.so" "libsodium.so" &> /dev/null) || {
    rm -rf "${cache}/libzmq"
    (cp -r ../.. "${cache}/libzmq" && cd "${cache}/libzmq" && make clean)
    
    (cd "${cache}/libzmq" && ./autogen.sh \
        && ./configure "${ANDROID_BUILD_OPTS[@]}" --with-libsodium=yes \
        && make \
        && make install) || exit 1
}

##
# Verify shared libraries in prefix
57 58 59

android_build_verify_so "libsodium.so"
android_build_verify_so "libzmq.so" "libsodium.so"