1#!/bin/bash 2 3if [[ "$OUT" == "" ]]; then 4 echo "In order for this script to function, please choose an arm64 target" 5 echo "using source build/envsetup.sh and lunch XXX\n" 6 exit 1 7fi 8 9aarch64_cc="${ANDROID_TOOLCHAIN}/aarch64-linux-android-gcc" 10aarch64_cpp="${ANDROID_TOOLCHAIN}/aarch64-linux-android-g++" 11 12includes=( 13 "-isystem ${ANDROID_BUILD_TOP}/bionic/libc/arch-arm64/include" 14 "-isystem ${ANDROID_BUILD_TOP}/bionic/libc/include" 15 "-isystem ${ANDROID_BUILD_TOP}/bionic/libstdc++/include" 16 "-isystem ${ANDROID_BUILD_TOP}/bionic/libc/kernel/uapi" 17 "-isystem ${ANDROID_BUILD_TOP}/bionic/libc/kernel/uapi/asm-arm64" 18 "-isystem ${ANDROID_BUILD_TOP}/bionic/libc/kernel/android/uapi" 19 "-isystem ${ANDROID_BUILD_TOP}/bionic/libm/include" 20 "-isystem ${ANDROID_BUILD_TOP}/bionic/libm/include/arm64" 21) 22 23# Copy libm.so to libpthread.so to allow -lpthread to work. 24cp ${OUT}/obj/lib/libm.so ${OUT}/obj/lib/libpthread.so 25 26ldflags=( 27 "-nostdlib" 28 "-Bdynamic" 29 "-fPIE" 30 "-pie" 31 "-Wl,-dynamic-linker,/system/bin/linker64" 32 "-Wl,--gc-sections" 33 "-Wl,-z,nocopyreloc" 34 "-L${OUT}/obj/lib" 35 "-Wl,-rpath-link=${OUT}/obj/lib" 36 "${OUT}/obj/lib/crtbegin_dynamic.o" 37 "-Wl,--whole-archive" 38 "-Wl,--no-whole-archive" 39 "-lc" 40 "-lstdc++" 41 "-lgcc" 42 "-lm" 43 "-Wl,-z,noexecstack" 44 "-Wl,-z,relro" 45 "-Wl,-z,now" 46 "-Wl,--warn-shared-textrel" 47 "-Wl,--fatal-warnings" 48 "-Wl,--no-undefined" 49 "-ldl" 50) 51 52eval ./configure CC=\"${aarch64_cc} ${includes[@]}\" \ 53 CPP=\"${aarch64_cc} ${includes[@]} -E\" \ 54 CXX=\"${aarch64_cpp} ${includes[@]}\" \ 55 CXXCPP=\"${aarch64_cpp} ${includes[@]} -E\" \ 56 LDFLAGS=\"${ldflags[@]}\" \ 57 --host=aarch64-android-linux \ 58 --disable-valgrind \ 59 --with-jemalloc_prefix=je_ \ 60 61