Christopher Ferris | 9918bd2 | 2019-10-22 17:40:04 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # This script is used to run configure and generate all of the necessary |
| 3 | # files when updating to a new version of jemalloc. |
| 4 | # The NDK argument must be a NDK at r20 or newer so that it does not |
| 5 | # require installing the standalone tools. |
| 6 | |
| 7 | ndk=${1} |
| 8 | if [[ "$ndk" == "" ]]; then |
| 9 | echo "Requires two arguments." |
| 10 | echo "usage: conf.sh NDK ARCH" |
| 11 | exit 1 |
| 12 | fi |
| 13 | |
| 14 | arch=${2} |
| 15 | if [[ "$arch" == "" ]]; then |
| 16 | echo "Requires two arguments." |
| 17 | echo "usage: conf.sh NDK ARCH" |
| 18 | exit 1 |
| 19 | fi |
| 20 | |
| 21 | if [[ ! -d ${ndk} ]]; then |
| 22 | echo "NDK directory ${ndk} does not exist." |
| 23 | exit 1 |
| 24 | fi |
| 25 | toolchain=${ndk}/toolchains/llvm/prebuilt/linux-x86_64 |
| 26 | if [[ ! -d ${toolchain} ]]; then |
| 27 | echo "NDK ${ndk} cannot find toolchain directory." |
| 28 | echo " ${toolchain}" |
| 29 | exit 1 |
| 30 | fi |
| 31 | |
| 32 | # The latest version of clang to use for compilation. |
| 33 | latest_api=29 |
| 34 | |
| 35 | case "$arch" in |
| 36 | "arm") |
| 37 | prefix="arm-linux-androideabi" |
| 38 | clang_prefix="armv7a-linux-androideabi" |
| 39 | target="arm-android-linux" |
| 40 | ;; |
| 41 | "arm64") |
| 42 | prefix="aarch64-linux-android" |
| 43 | target="aarch64-android-linux" |
| 44 | ;; |
| 45 | "x86") |
| 46 | target="x86-android-linux" |
| 47 | export CPPFLAGS="-m32" |
| 48 | ;& |
| 49 | "x86_64") |
| 50 | prefix="x86_64-linux-android" |
| 51 | if [[ "$target" == "" ]]; then |
| 52 | target="x86_64-android-linux" |
| 53 | fi |
| 54 | ;; |
| 55 | *) |
| 56 | echo "Unknown arch $arch" |
| 57 | exit 1 |
| 58 | ;; |
| 59 | esac |
| 60 | |
| 61 | if [[ "${clang_prefix}" == "" ]]; then |
| 62 | clang_prefix="${prefix}" |
| 63 | fi |
| 64 | |
| 65 | tools=("AR" "ar" |
| 66 | "AS" "as" |
| 67 | "LD" "ld" |
| 68 | "RANLIB" "ranlib" |
| 69 | "STRIP" "strip") |
| 70 | |
| 71 | for ((i = 0; i < ${#tools[@]}; i = i + 2)); do |
| 72 | binary=${toolchain}/bin/${prefix}-${tools[$((i + 1))]} |
| 73 | if [[ ! -e ${binary} ]]; then |
| 74 | echo "${binary} does not exist." |
| 75 | exit 1 |
| 76 | fi |
| 77 | export ${tools[$i]}=${binary} |
| 78 | done |
| 79 | |
| 80 | clang=("CC" "clang" |
| 81 | "CXX" "clang++") |
| 82 | |
| 83 | for ((i = 0; i < ${#clang[@]}; i = i + 2)); do |
| 84 | binary=${toolchain}/bin/${clang_prefix}${latest_api}-${clang[$((i + 1))]} |
| 85 | if [[ ! -e ${binary} ]]; then |
| 86 | echo "${binary} does not exist." |
| 87 | exit 1 |
| 88 | fi |
| 89 | export ${clang[$i]}=${binary} |
| 90 | done |
| 91 | |
| 92 | export CPP="${CC} -E" |
| 93 | |
| 94 | ./autogen.sh --with-jemalloc_prefix=je_ --host=${target} |