| Christopher Ferris | 5daf4e4 | 2014-04-22 18:52:58 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | if [[ "$OUT" == "" ]]; then |
| 4 | echo "In order for this script to function, please choose an x86 target" |
| 5 | echo "using source build/envsetup.sh and lunch XXX\n" |
| 6 | exit 1 |
| 7 | fi |
| 8 | |
| 9 | x86_cc="${ANDROID_TOOLCHAIN}/x86_64-linux-android-gcc -m32" |
| 10 | x86_cpp="${ANDROID_TOOLCHAIN}/x86_64-linux-android-g++ -m32" |
| 11 | |
| 12 | includes=( |
| 13 | "-isystem ${ANDROID_BUILD_TOP}/bionic/libc/arch-x86/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-x86" |
| Christopher Ferris | fb1f094 | 2016-11-08 14:47:48 -0800 | [diff] [blame] | 18 | "-isystem ${ANDROID_BUILD_TOP}/bionic/libc/kernel/android/uapi" |
| Christopher Ferris | 5daf4e4 | 2014-04-22 18:52:58 -0700 | [diff] [blame] | 19 | "-isystem ${ANDROID_BUILD_TOP}/bionic/libm/include" |
| 20 | "-isystem ${ANDROID_BUILD_TOP}/bionic/libm/include/i387" |
| Christopher Ferris | 5daf4e4 | 2014-04-22 18:52:58 -0700 | [diff] [blame] | 21 | ) |
| 22 | |
| 23 | # Copy libm.so to libpthread.so to allow -lpthread to work. |
| 24 | cp ${OUT}/obj/lib/libm.so ${OUT}/obj/lib/libpthread.so |
| 25 | |
| 26 | ldflags=( |
| 27 | "-nostdlib" |
| 28 | "-Bdynamic" |
| 29 | "-fPIE" |
| 30 | "-pie" |
| 31 | "-Wl,-dynamic-linker,/system/bin/linker" |
| 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,--icf=safe" |
| 49 | "-Wl,--no-undefined" |
| 50 | "-ldl" |
| 51 | ) |
| 52 | |
| 53 | eval ./configure CC=\"${x86_cc} ${includes[@]}\" \ |
| 54 | CPP=\"${x86_cc} ${includes[@]} -E\" \ |
| 55 | CXX=\"${x86_cpp} ${includes[@]}\" \ |
| 56 | CXXCPP=\"${x86_cpp} ${includes[@]} -E\" \ |
| 57 | LDFLAGS=\"${ldflags[@]}\" \ |
| 58 | --host=x86-android-linux \ |
| 59 | --disable-valgrind \ |
| 60 | --with-jemalloc_prefix=je_ \ |
| 61 | |