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 arm target"
      5   echo "using source build/envsetup.sh and lunch XXX\n"
      6   exit 1
      7 fi
      8 
      9 arm_cc="${ANDROID_TOOLCHAIN}/arm-linux-androideabi-gcc"
     10 arm_cpp="${ANDROID_TOOLCHAIN}/arm-linux-androideabi-g++"
     11 
     12 includes=(
     13   "-isystem ${ANDROID_BUILD_TOP}/bionic/libc/arch-arm/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-arm"
     18   "-isystem ${ANDROID_BUILD_TOP}/bionic/libm/include"
     19   "-isystem ${ANDROID_BUILD_TOP}/bionic/libm/include/arm"
     20   "-include ${ANDROID_BUILD_TOP}/build/core/combo/include/arch/linux-arm/AndroidConfig.h"
     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=\"${arm_cc} ${includes[@]}\" \
     54                  CPP=\"${arm_cc} ${includes[@]} -E\" \
     55                  CXX=\"${arm_cpp} ${includes[@]}\" \
     56                  CXXCPP=\"${arm_cpp} ${includes[@]} -E\" \
     57                  LDFLAGS=\"${ldflags[@]}\" \
     58                  --host=arm-android-linux \
     59                  --disable-valgrind \
     60                  --with-jemalloc_prefix=je_ \
     61 
     62