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 mips target"
      5   echo "using source build/envsetup.sh and lunch XXX\n"
      6   exit 1
      7 fi
      8 
      9 mips_cc="${ANDROID_TOOLCHAIN}/mipsel-linux-android-gcc"
     10 mips_cpp="${ANDROID_TOOLCHAIN}/mipsel-linux-android-g++"
     11 
     12 includes=(
     13   "-isystem ${ANDROID_BUILD_TOP}/bionic/libc/arch-mips/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-mips"
     18   "-isystem ${ANDROID_BUILD_TOP}/bionic/libm/include"
     19   "-isystem ${ANDROID_BUILD_TOP}/bionic/libm/include/mips"
     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,--no-undefined"
     48   "-ldl"
     49 )
     50 
     51 eval ./configure CC=\"${mips_cc} ${includes[@]}\" \
     52                  CPP=\"${mips_cc} ${includes[@]} -E\" \
     53                  CXX=\"${mips_cpp} ${includes[@]}\" \
     54                  CXXCPP=\"${mips_cpp} ${includes[@]} -E\" \
     55                  LDFLAGS=\"${ldflags[@]}\" \
     56                  --host=mips-android-linux \
     57                  --disable-valgrind \
     58                  --with-jemalloc_prefix=je_ \
     59 
     60