-
-
Save electrolobzik/abadf7011e14f02c73f9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# This script runs a configure script with the Android NDK toolchain | |
# You may need to adjust the COMPILE_TARGET and ANDROID_API variables | |
# depending on your requirements. | |
# | |
# Call this script in a directory with a valid configure script. | |
# Example: PREFIX=${PWD}/bin android-configure.sh | |
# Set the ANDROID_NDK variable to the root | |
# Example: export ANDROID_NDK=${HOME}/.local/android-ndk-r9b | |
if [ -z ${ANDROID_NDK} ]; then | |
echo "Please set ANDROID_NDK environment variable to the root directory of the Android NDK" | |
exit 1 | |
fi | |
# This is just an empty directory where I want the built objects to be installed | |
if [ -z ${PREFIX} ]; then | |
echo "Please set PREFIX environment variable to the output directory" | |
exit 1 | |
fi | |
export COMPILE_TARGET=x86 | |
export TOOLCHAIN_PREFIX=i686-linux-android | |
export ANDROID_API=14 | |
export ANDROID_PREFIX=${ANDROID_NDK}/toolchains/${COMPILE_TARGET}-4.9/prebuilt/darwin-x86_64 | |
export SYSROOT=${ANDROID_NDK}/platforms/android-${ANDROID_API}/arch-x86 | |
export TOOLCHAIN_PATH=${ANDROID_PREFIX}/bin | |
# These are the toolchain utilities | |
export CPP=${TOOLCHAIN_PATH}/${TOOLCHAIN_PREFIX}-cpp | |
export AR=${TOOLCHAIN_PATH}/${TOOLCHAIN_PREFIX}-ar | |
export AS=${TOOLCHAIN_PATH}/${TOOLCHAIN_PREFIX}-as | |
export NM=${TOOLCHAIN_PATH}/${TOOLCHAIN_PREFIX}-nm | |
export CC=${TOOLCHAIN_PATH}/${TOOLCHAIN_PREFIX}-gcc | |
export CXX=${TOOLCHAIN_PATH}/${TOOLCHAIN_PREFIX}-g++ | |
export LD=${TOOLCHAIN_PATH}/${TOOLCHAIN_PREFIX}-ld | |
export RANLIB=${TOOLCHAIN_PATH}/${TOOLCHAIN_PREFIX}-ranlib | |
export STRIP=${TOOLCHAIN_PATH}/${TOOLCHAIN_PREFIX}-strip | |
export OBJDUMP=${TOOLCHAIN_PATH}/${TOOLCHAIN_PREFIX}-objdump | |
export OBJCOPY=${TOOLCHAIN_PATH}/${TOOLCHAIN_PREFIX}-objcopy | |
export ADDR2LINE=${TOOLCHAIN_PATH}/${TOOLCHAIN_PREFIX}-addr2line | |
export READELF=${TOOLCHAIN_PATH}/${TOOLCHAIN_PREFIX}-readelf | |
export SIZE=${TOOLCHAIN_PATH}/${TOOLCHAIN_PREFIX}-size | |
export STRINGS=${TOOLCHAIN_PATH}/${TOOLCHAIN_PREFIX}-strings | |
export ELFEDIT=${TOOLCHAIN_PATH}/${TOOLCHAIN_PREFIX}-elfedit | |
export GCOV=${TOOLCHAIN_PATH}/${TOOLCHAIN_PREFIX}-gcov | |
export GDB=${TOOLCHAIN_PATH}/${TOOLCHAIN_PREFIX}-gdb | |
export GPROF=${TOOLCHAIN_PATH}/${TOOLCHAIN_PREFIX}-gprof | |
# Don't mix up .pc files from your host and build target | |
export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig | |
export CFLAGS="${CFLAGS} --sysroot=${SYSROOT} -I${SYSROOT}/usr/include -I${ANDROID_PREFIX}/include" | |
export CPPFLAGS="${CFLAGS}" | |
export LDFLAGS="${LDFLAGS} -L${SYSROOT}/usr/lib -L${ANDROID_PREFIX}/lib" | |
./configure --host=${COMPILE_TARGET} --prefix=${PREFIX} "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment