You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

186 lines
5.0 KiB

  1. #!/bin/sh
  2. #
  3. # Copyright (C) 2016 Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de>
  4. #
  5. # This program is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, either version 3 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. #
  18. set -e
  19. BASEDIR=$(pwd)
  20. GOLD_LD=/usr/bin/ld.gold
  21. BFD_LD=/usr/bin/ld.bfd
  22. mkdir -p $BASEDIR/toolchain/clang
  23. cd $BASEDIR/toolchain/clang
  24. # build llvm and clang binaries
  25. cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="X86;ARM" \
  26. -DLLVM_EXTERNAL_CLANG_SOURCE_DIR=../../external/clang \
  27. -DCMAKE_C_FLAGS="-O2" ../../external/llvm/
  28. make -j $(nproc)
  29. cd $BASEDIR
  30. # build binutils for arm
  31. mkdir -p $BASEDIR/toolchain/gcc/arm/arm-linux-androideabi/build/binutils
  32. cd $BASEDIR/toolchain/gcc/arm/arm-linux-androideabi/build/binutils
  33. ./../../../../../src/binutils/binutils-2.25/configure \
  34. --prefix=$BASEDIR/toolchain/gcc/arm/arm-linux-androideabi/install \
  35. --target=arm-linux-androideabi \
  36. --enable-gold=default \
  37. --enable-plugins
  38. make -j $(nproc)
  39. make install
  40. # build gcc for arm
  41. cd .. && mkdir -p gcc && cd gcc
  42. ./../../../../../src/gcc/gcc-4.9/configure \
  43. --prefix=$BASEDIR/toolchain/gcc/arm/arm-linux-androideabi/install \
  44. --target=arm-linux-androideabi \
  45. --host=x86_64-linux-gnu \
  46. --build=x86_64-linux-gnu \
  47. --with-gnu-as \
  48. --with-gnu-ld \
  49. --enable-languages=c,c++ \
  50. --enable-cloog-backend=isl \
  51. --disable-libssp \
  52. --enable-threads \
  53. --disable-nls \
  54. --disable-libmudflap \
  55. --enable-libgomp \
  56. --disable-libstdc__-v3 \
  57. --disable-sjlj-exceptions \
  58. --disable-shared \
  59. --disable-tls \
  60. --disable-libitm \
  61. --with-float=soft \
  62. --with-fpu=vfp \
  63. --with-arch=armv5te \
  64. --enable-target-optspace \
  65. --enable-initfini-array \
  66. --disable-bootstrap \
  67. --disable-libquadmath \
  68. --enable-plugins \
  69. --with-sysroot=$BASEDIR/prebuilts/ndk/current/platforms/android-21/arch-arm \
  70. --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' \
  71. --enable-gnu-indirect-function \
  72. --disable-libsanitizer \
  73. --enable-graphite=yes \
  74. --enable-eh-frame-hdr-for-static \
  75. --enable-gold=default \
  76. --program-transform-name='s&^&arm-linux-androideabi-&'
  77. make -j $(nproc)
  78. make install
  79. # build binutils for host
  80. cd ../../../../ && mkdir -p host/build/binutils
  81. cd host/build/binutils
  82. ./../../../../src/binutils/binutils-2.25/configure \
  83. --prefix=$BASEDIR/toolchain/gcc/host/install \
  84. --target=x86_64-linux \
  85. --host=x86_64-linux-gnu \
  86. --build=x86_64-linux-gnu \
  87. --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' \
  88. --enable-plugins \
  89. --disable-ld
  90. make -j $(nproc)
  91. make install
  92. # build gcc for host
  93. cd .. && mkdir -p gcc && cd gcc
  94. ./../../../../src/gcc/gcc-4.9/configure \
  95. --prefix=$BASEDIR/toolchain/gcc/host/install \
  96. --target=x86_64-linux \
  97. --host=x86_64-linux-gnu \
  98. --build=x86_64-linux-gnu \
  99. --enable-multiarch \
  100. --with-arch-32=i686 \
  101. --with-abi=m64 \
  102. --with-arch=x86-64 \
  103. --with-multilib-list=m32,m64 \
  104. --disable-nls \
  105. --enable-target-optspace \
  106. --disable-plugin \
  107. --disable-docs \
  108. --disable-bootstrap \
  109. --disable-libgomp \
  110. --disable-libmudflap \
  111. --disable-libquadmath \
  112. --disable-libsanitizer \
  113. --enable-languages=c,c++ \
  114. --with-ld=$GOLD_LD
  115. make -j $(nproc)
  116. make install
  117. # we need to link against the correct stdatomic.h
  118. cd ../../install/lib/gcc/x86_64-linux/4.9.x/include
  119. rm stdatomic.h
  120. ln -s ../../../../../../../../../bionic/libc/include/stdatomic.h stdatomic.h
  121. # link ld from /usr
  122. cd ../../../../../x86_64-linux/bin/
  123. rm -f ld ld.gold ld.bfd
  124. ln -s "$GOLD_LD" ld
  125. ln -s "$GOLD_LD" ld.gold
  126. ln -s "$BFD_LD" ld.bfd
  127. cd $BASEDIR
  128. # an empty Android.mk is needed (Android.mk in jack and jill repo should be ignored)
  129. touch toolchain/src/Android.mk
  130. # clang needs this header as a system header
  131. mkdir -p toolchain/headers/clang
  132. cd toolchain/headers/clang
  133. if [ ! -f stdatomic.h ]
  134. then
  135. ln -s ../../../bionic/libc/include/stdatomic.h stdatomic.h
  136. fi
  137. #############################
  138. # build jack/jill toolchain
  139. # first the simple lib
  140. cd ../../src/jack/simple
  141. mvn-debian clean package -Dmaven.test.skip=true
  142. cd ..
  143. # then jack
  144. ant clean dist
  145. # setup the jack/jill binary folder
  146. cp jack/etc/Android.mk.build ../../jack_jill/Android.mk
  147. cd ../../jack_jill
  148. cp build/jack/dist/jack .
  149. chmod +x jack
  150. cp build/jack/dist/jack-admin .
  151. chmod +x jack-admin
  152. cp build/jack/dist/jack.jar .
  153. cp build/jack/dist/jack-launcher.jar .
  154. # finally the jill.jar
  155. cd ../src/jill
  156. ant clean dist
  157. cp ../../jack_jill/build/jill/dist/jill.jar ../../jack_jill/
  158. cd $BASEDIR