• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3if [[ "$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
7fi
8
9x86_cc="${ANDROID_TOOLCHAIN}/x86_64-linux-android-gcc -m32"
10x86_cpp="${ANDROID_TOOLCHAIN}/x86_64-linux-android-g++ -m32"
11
12includes=(
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"
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/i387"
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/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
53eval ./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
62