diff options
author | Christopher Ferris <cferris@google.com> | 2019-10-22 17:40:04 -0700 |
---|---|---|
committer | Christopher Ferris <cferris@google.com> | 2019-10-23 14:28:55 -0700 |
commit | 9918bd263a3bb4186790c42d0707c2b28fd38d0a (patch) | |
tree | 9373f0e8b43528e6d039d8bce9f45cd41c0c70a8 /android | |
parent | 6840b22e8e11cb68b493297a5cd757d6eaa0b406 (diff) |
Add configure script for jemalloc.
Test: Ran this when building jemalloc 5.2.1.
Change-Id: I6c7de59cdede844f3469bcd045e8e1b638112c54
Diffstat (limited to 'android')
-rwxr-xr-x | android/conf.sh | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/android/conf.sh b/android/conf.sh new file mode 100755 index 00000000..90195a42 --- /dev/null +++ b/android/conf.sh @@ -0,0 +1,94 @@ +#!/bin/bash +# This script is used to run configure and generate all of the necessary +# files when updating to a new version of jemalloc. +# The NDK argument must be a NDK at r20 or newer so that it does not +# require installing the standalone tools. + +ndk=${1} +if [[ "$ndk" == "" ]]; then + echo "Requires two arguments." + echo "usage: conf.sh NDK ARCH" + exit 1 +fi + +arch=${2} +if [[ "$arch" == "" ]]; then + echo "Requires two arguments." + echo "usage: conf.sh NDK ARCH" + exit 1 +fi + +if [[ ! -d ${ndk} ]]; then + echo "NDK directory ${ndk} does not exist." + exit 1 +fi +toolchain=${ndk}/toolchains/llvm/prebuilt/linux-x86_64 +if [[ ! -d ${toolchain} ]]; then + echo "NDK ${ndk} cannot find toolchain directory." + echo " ${toolchain}" + exit 1 +fi + +# The latest version of clang to use for compilation. +latest_api=29 + +case "$arch" in + "arm") + prefix="arm-linux-androideabi" + clang_prefix="armv7a-linux-androideabi" + target="arm-android-linux" + ;; + "arm64") + prefix="aarch64-linux-android" + target="aarch64-android-linux" + ;; + "x86") + target="x86-android-linux" + export CPPFLAGS="-m32" + ;& + "x86_64") + prefix="x86_64-linux-android" + if [[ "$target" == "" ]]; then + target="x86_64-android-linux" + fi + ;; + *) + echo "Unknown arch $arch" + exit 1 + ;; +esac + +if [[ "${clang_prefix}" == "" ]]; then + clang_prefix="${prefix}" +fi + +tools=("AR" "ar" + "AS" "as" + "LD" "ld" + "RANLIB" "ranlib" + "STRIP" "strip") + +for ((i = 0; i < ${#tools[@]}; i = i + 2)); do + binary=${toolchain}/bin/${prefix}-${tools[$((i + 1))]} + if [[ ! -e ${binary} ]]; then + echo "${binary} does not exist." + exit 1 + fi + export ${tools[$i]}=${binary} +done + +clang=("CC" "clang" + "CXX" "clang++") + +for ((i = 0; i < ${#clang[@]}; i = i + 2)); do + binary=${toolchain}/bin/${clang_prefix}${latest_api}-${clang[$((i + 1))]} + if [[ ! -e ${binary} ]]; then + echo "${binary} does not exist." + exit 1 + fi + export ${clang[$i]}=${binary} +done + +export CPP="${CC} -E" + +./autogen.sh --with-jemalloc_prefix=je_ --host=${target} |