Skip to content

Instantly share code, notes, and snippets.

@pratclot
Forked from nddrylliog/android_configure.sh
Last active January 12, 2022 16:02
Show Gist options
  • Save pratclot/7d86a2f7a0fa2ecb88c70785d5b72eda to your computer and use it in GitHub Desktop.
Save pratclot/7d86a2f7a0fa2ecb88c70785d5b72eda to your computer and use it in GitHub Desktop.
Update to work with modern toolchain
#!/bin/sh
# I put all my dev stuff in here
export DEV_PREFIX=${PWD}/buildings
# Don't forget to adjust this to your NDK path
export ANDROID_PREFIX=${HOME}/Android/Sdk
export ANDROID_NDK=${ANDROID_PREFIX}/ndk/23.1.7779620
# export CROSS_COMPILE=aarch64-linux-android31
# export CROSS_COMPILE=i686-linux-android31
# export CROSS_COMPILE=armv7a-linux-androideabi31
export CROSS_COMPILE=x86_64-linux-android31
# I chose the gcc-4.7 toolchain - works fine for me!
export ANDROID_PREFIX=${ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64
export ANDROID_PREFIX=${ANDROID_NDK}/toolchains/llvm/prebuilt/linux-x86_64
# Apparently android-8 works fine, there are other versions, look them up
export SYSROOT=${ANDROID_PREFIX}/sysroot
export BIN_PATH=${ANDROID_PREFIX}/bin
export CROSS_PATH=${BIN_PATH}/${CROSS_COMPILE}
export LLVM=${BIN_PATH}/llvm
# Non-exhaustive lists of compiler + binutils
# Depending on what you compile, you might need more binutils than that
# export CPP=${CROSS_PATH}-clang++
export AR=${LLVM}-ar
export AS=${LLVM}-as
export NM=${LLVM}-nm
export CC=${CROSS_PATH}-clang
export CXX=${CROSS_PATH}-clang++
export LD=${BIN_PATH}/ld
export RANLIB=${LLVM}-ranlib
# This is just an empty directory where I want the built objects to be installed
export PREFIX=${DEV_PREFIX}/android/prefix
# Don't mix up .pc files from your host and build target
export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig
# You can clone the full Android sources to get bionic if you want.. I didn't
# want to so I just got linker.h from here: http://gitorious.org/0xdroid/bionic
# Note that this was only required to build boehm-gc with dynamic linking support.
export CFLAGS="${CFLAGS} --sysroot=${SYSROOT} -I${SYSROOT}/usr/include -I${ANDROID_PREFIX}/include -I${DEV_PREFIX}/android/bionic"
export CPPFLAGS="${CFLAGS}"
export LDFLAGS="${LDFLAGS} -L${SYSROOT}/usr/lib -L${ANDROID_PREFIX}/lib"
./configure --host=${CROSS_COMPILE} --with-sysroot=${SYSROOT} --prefix=${PREFIX} "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment