Home | History | Annotate | Download | only in scripts
      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"
     18   "-isystem ${ANDROID_BUILD_TOP}/bionic/libm/include"
     19   "-isystem ${ANDROID_BUILD_TOP}/bionic/libm/include/i387"
     20 )
     21 
     22 # Copy libm.so to libpthread.so to allow -lpthread to work.
     23 cp ${OUT}/obj/lib/libm.so ${OUT}/obj/lib/libpthread.so
     24 
     25 ldflags=(
     26   "-nostdlib"
     27   "-Bdynamic"
     28   "-fPIE"
     29   "-pie"
     30   "-Wl,-dynamic-linker,/system/bin/linker"
     31   "-Wl,--gc-sections"
     32   "-Wl,-z,nocopyreloc"
     33   "-L${OUT}/obj/lib"
     34   "-Wl,-rpath-link=${OUT}/obj/lib"
     35   "${OUT}/obj/lib/crtbegin_dynamic.o"
     36   "-Wl,--whole-archive"
     37   "-Wl,--no-whole-archive"
     38   "-lc"
     39   "-lstdc++"
     40   "-lgcc"
     41   "-lm"
     42   "-Wl,-z,noexecstack"
     43   "-Wl,-z,relro"
     44   "-Wl,-z,now"
     45   "-Wl,--warn-shared-textrel"
     46   "-Wl,--fatal-warnings"
     47   "-Wl,--icf=safe"
     48   "-Wl,--no-undefined"
     49   "-ldl"
     50 )
     51 
     52 eval ./configure CC=\"${x86_cc} ${includes[@]}\" \
     53                  CPP=\"${x86_cc} ${includes[@]} -E\" \
     54                  CXX=\"${x86_cpp} ${includes[@]}\" \
     55                  CXXCPP=\"${x86_cpp} ${includes[@]} -E\" \
     56                  LDFLAGS=\"${ldflags[@]}\" \
     57                  --host=x86-android-linux \
     58                  --disable-valgrind \
     59                  --with-jemalloc_prefix=je_ \
     60 
     61