-
-
Save louisje/39e686ff4d59bcfc1247bba39cf17eba to your computer and use it in GitHub Desktop.
Cross-compile autotools library for Android / arm-linux-androideabiI stick that in ~/bin/, chmod +x, and then run it in place of "./configure" in my project. Then a make and make install later, the prefix contains libraries built for android. Neato eh?
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 | |
# | |
# NDK Standalone Toolchain: | |
# $HOM#/Android/Sdk/ndk-bundle/build/tools/make_standalone_toolchain.py --arch x86 --api 22 --stl gnustl -v --install-dir $HOME/workspace/ndk-toolchain --force | |
# cp $HOME/Android/Sdk/ndk-bundle/sources/cxx-stl/gnu-libstdc++/4.9/libs/x86/libgnustl_static.a $HOME/Android/Sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/libs/x86/libandroid_support.a $HOME/workspace/ndk-toolchain/i686-linux-android/lib | |
# | |
# NDK | |
export TARGET='i686-linux-android' | |
export TOOLCHAIN=${HOME}/workspace/ndk-toolchain | |
export SYSROOT=${TOOLCHAIN}/sysroot | |
export PREFIX=${HOME}/workspace/cross-build | |
export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig | |
export CPP=${TOOLCHAIN}/bin/${TARGET}-cpp | |
export AR=${TOOLCHAIN}/bin/${TARGET}-ar | |
export AS=${TOOLCHAIN}/bin/${TARGET}-as | |
export NM=${TOOLCHAIN}/bin/${TARGET}-nm | |
export CC=${TOOLCHAIN}/bin/${TARGET}-gcc | |
export CXX=${TOOLCHAIN}/bin/${TARGET}-g++ | |
export LD=${TOOLCHAIN}/bin/${TARGET}-ld | |
export RANLIB=${TOOLCHAIN}/bin/${TARGET}-ranlib | |
export CPPFLAGS="${CPPFLAGS} -I${PREFIX}/include -I${SYSROOT}/usr/include -I${TOOLCHAIN}/include" | |
export CFLAGS="${CFLAGS} -static -O2 --sysroot=${SYSROOT} -DANDROID -D__ANDROID__ -DSK_RELEASE -nostdlib -march=i686 -fpic" | |
export CXXFLAGS="${CXXFLAGS} ${CFLAGS}" | |
export LDFLAGS="${LDFLAGS} -Bstatic -L${PREFIX}/lib -L${SYSROOT}/usr/lib -L${TOOLCHAIN}/lib" | |
export LIBS="${LIBS} ${SYSROOT}/usr/lib/crtbegin_static.o ${SYSROOT}/usr/lib/crtend_android.o -lc -lgcc -lgnustl_static -lstdc++ -lsupc++ -landroid_support" | |
unset C_INCLUDE_PATH | |
unset LD_LIBRARY_PATH | |
PATH=$PATH:${TOOLCHAIN}/bin | |
if test -z "$CWD"; then | |
CWD="." | |
fi | |
$CWD/configure --disable-option-checking --host=${TARGET} --with-sysroot=${SYSROOT} --prefix=${PREFIX} "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment