diff options
author | Christopher Ferris <cferris@google.com> | 2019-10-24 08:22:46 -0700 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2019-10-24 08:22:46 -0700 |
commit | 8ac3fef633e74cfb1696c3b3fa1d0d2c350571d3 (patch) | |
tree | 9373f0e8b43528e6d039d8bce9f45cd41c0c70a8 | |
parent | 6840b22e8e11cb68b493297a5cd757d6eaa0b406 (diff) | |
parent | db317931e8152780c401ea5a99e275906144bd94 (diff) |
Add configure script for jemalloc. am: 9918bd263a am: f435ef65df
am: db317931e8
Change-Id: I922efff62e924eea14a0f0794744901a7cce6522
-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} |