2016-01-06 11:55:23 +00:00
|
|
|
#!/bin/sh
|
2016-02-05 18:58:38 +00:00
|
|
|
#
|
|
|
|
# Copyright (C) 2016 Wolfgang Wiedmeyer <wolfgit@wiedmeyer.de>
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
|
2016-01-06 11:55:23 +00:00
|
|
|
set -e
|
|
|
|
|
|
|
|
BASEDIR=$(pwd)
|
|
|
|
|
|
|
|
mkdir -p $BASEDIR/toolchain/clang
|
|
|
|
cd $BASEDIR/toolchain/clang
|
|
|
|
|
|
|
|
# build llvm and clang binaries
|
|
|
|
cmake -DCMAKE_BUILD_TYPE=Release -DLLVM_TARGETS_TO_BUILD="X86;ARM" \
|
|
|
|
-DLLVM_EXTERNAL_CLANG_SOURCE_DIR=../../external/clang \
|
|
|
|
-DCMAKE_C_FLAGS="-O2" ../../external/llvm/
|
|
|
|
make -j $(nproc)
|
|
|
|
|
|
|
|
cd $BASEDIR
|
2016-01-07 17:47:35 +00:00
|
|
|
|
2016-01-14 23:25:31 +00:00
|
|
|
|
|
|
|
# build binutils for arm
|
|
|
|
mkdir -p $BASEDIR/toolchain/gcc/arm/arm-linux-androideabi/build/binutils
|
|
|
|
cd $BASEDIR/toolchain/gcc/arm/arm-linux-androideabi/build/binutils
|
|
|
|
./../../../../../src/binutils/binutils-2.25/configure \
|
|
|
|
--prefix=$BASEDIR/toolchain/gcc/arm/arm-linux-androideabi/install \
|
|
|
|
--target=arm-linux-androideabi \
|
|
|
|
--enable-gold=default \
|
|
|
|
--enable-plugins
|
|
|
|
|
2016-12-07 22:42:06 +00:00
|
|
|
make -j $(nproc)
|
|
|
|
make install
|
2016-01-14 23:25:31 +00:00
|
|
|
|
|
|
|
# build gcc for arm
|
|
|
|
cd .. && mkdir -p gcc && cd gcc
|
|
|
|
./../../../../../src/gcc/gcc-4.9/configure \
|
|
|
|
--prefix=$BASEDIR/toolchain/gcc/arm/arm-linux-androideabi/install \
|
|
|
|
--target=arm-linux-androideabi \
|
|
|
|
--host=x86_64-linux-gnu \
|
|
|
|
--build=x86_64-linux-gnu \
|
|
|
|
--with-gnu-as \
|
|
|
|
--with-gnu-ld \
|
|
|
|
--enable-languages=c,c++ \
|
|
|
|
--enable-cloog-backend=isl \
|
|
|
|
--disable-libssp \
|
|
|
|
--enable-threads \
|
|
|
|
--disable-nls \
|
|
|
|
--disable-libmudflap \
|
|
|
|
--enable-libgomp \
|
|
|
|
--disable-libstdc__-v3 \
|
|
|
|
--disable-sjlj-exceptions \
|
|
|
|
--disable-shared \
|
|
|
|
--disable-tls \
|
|
|
|
--disable-libitm \
|
|
|
|
--with-float=soft \
|
|
|
|
--with-fpu=vfp \
|
|
|
|
--with-arch=armv5te \
|
|
|
|
--enable-target-optspace \
|
|
|
|
--enable-initfini-array \
|
|
|
|
--disable-bootstrap \
|
|
|
|
--disable-libquadmath \
|
|
|
|
--enable-plugins \
|
|
|
|
--with-sysroot=$BASEDIR/prebuilts/ndk/current/platforms/android-21/arch-arm \
|
|
|
|
--with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' \
|
|
|
|
--enable-gnu-indirect-function \
|
|
|
|
--disable-libsanitizer \
|
|
|
|
--enable-graphite=yes \
|
|
|
|
--enable-eh-frame-hdr-for-static \
|
|
|
|
--enable-gold=default \
|
|
|
|
--program-transform-name='s&^&arm-linux-androideabi-&'
|
|
|
|
|
2016-12-07 22:42:06 +00:00
|
|
|
make -j $(nproc)
|
|
|
|
make install
|
2016-01-14 23:25:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
# build binutils for host
|
|
|
|
cd ../../../../ && mkdir -p host/build/binutils
|
|
|
|
cd host/build/binutils
|
|
|
|
./../../../../src/binutils/binutils-2.25/configure \
|
|
|
|
--prefix=$BASEDIR/toolchain/gcc/host/install \
|
|
|
|
--target=x86_64-linux \
|
|
|
|
--host=x86_64-linux-gnu \
|
|
|
|
--build=x86_64-linux-gnu \
|
|
|
|
--with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' \
|
2016-12-07 22:42:06 +00:00
|
|
|
--enable-plugins \
|
|
|
|
--disable-ld
|
2016-01-14 23:25:31 +00:00
|
|
|
|
2016-12-07 22:42:06 +00:00
|
|
|
make -j $(nproc)
|
|
|
|
make install
|
2016-01-14 23:25:31 +00:00
|
|
|
|
|
|
|
# build gcc for host
|
|
|
|
cd .. && mkdir -p gcc && cd gcc
|
|
|
|
./../../../../src/gcc/gcc-4.9/configure \
|
|
|
|
--prefix=$BASEDIR/toolchain/gcc/host/install \
|
|
|
|
--target=x86_64-linux \
|
2016-12-07 22:42:06 +00:00
|
|
|
--host=x86_64-linux-gnu \
|
|
|
|
--build=x86_64-linux-gnu \
|
2016-01-14 23:25:31 +00:00
|
|
|
--enable-multiarch \
|
|
|
|
--with-arch-32=i686 \
|
|
|
|
--with-abi=m64 \
|
|
|
|
--with-arch=x86-64 \
|
|
|
|
--with-multilib-list=m32,m64 \
|
|
|
|
--disable-nls \
|
|
|
|
--enable-target-optspace \
|
|
|
|
--disable-plugin \
|
|
|
|
--disable-docs \
|
|
|
|
--disable-bootstrap \
|
|
|
|
--disable-libgomp \
|
|
|
|
--disable-libmudflap \
|
|
|
|
--disable-libquadmath \
|
|
|
|
--disable-libsanitizer \
|
2016-12-09 21:38:16 +00:00
|
|
|
--enable-languages=c,c++ \
|
|
|
|
--with-ld=/usr/bin/x86_64-linux-gnu-ld.gold
|
2016-01-14 23:25:31 +00:00
|
|
|
|
2016-12-07 22:42:06 +00:00
|
|
|
make -j $(nproc)
|
|
|
|
make install
|
2016-01-14 23:25:31 +00:00
|
|
|
|
|
|
|
# we need to link against the correct stdatomic.h
|
2016-03-18 14:47:27 +00:00
|
|
|
cd ../../install/lib/gcc/x86_64-linux/4.9.x/include
|
2016-01-14 23:25:31 +00:00
|
|
|
rm stdatomic.h
|
|
|
|
ln -s ../../../../../../../../../bionic/libc/include/stdatomic.h stdatomic.h
|
2016-12-09 21:38:16 +00:00
|
|
|
# link ld from /usr
|
2016-12-07 22:42:06 +00:00
|
|
|
cd ../../../../../x86_64-linux/bin/
|
2016-12-09 21:38:16 +00:00
|
|
|
rm -f ld ld.gold ld.bfd
|
2016-12-07 22:42:06 +00:00
|
|
|
ln -s /usr/bin/x86_64-linux-gnu-ld.gold ld
|
2016-12-09 21:38:16 +00:00
|
|
|
ln -s /usr/bin/x86_64-linux-gnu-ld.gold ld.gold
|
|
|
|
ln -s /usr/bin/x86_64-linux-gnu-ld.bfd ld.bfd
|
2016-01-14 23:25:31 +00:00
|
|
|
|
|
|
|
cd $BASEDIR
|
|
|
|
|
|
|
|
# an empty Android.mk is needed (Android.mk in jack and jill repo should be ignored)
|
|
|
|
touch toolchain/src/Android.mk
|
|
|
|
|
|
|
|
# clang needs this header as a system header
|
|
|
|
mkdir -p toolchain/headers/clang
|
|
|
|
cd toolchain/headers/clang
|
|
|
|
if [ ! -f stdatomic.h ]
|
|
|
|
then
|
|
|
|
ln -s ../../../bionic/libc/include/stdatomic.h stdatomic.h
|
|
|
|
fi
|
|
|
|
|
2016-01-29 00:21:43 +00:00
|
|
|
|
|
|
|
#############################
|
|
|
|
# build jack/jill toolchain
|
|
|
|
|
|
|
|
# first the simple lib
|
|
|
|
cd ../../src/jack/simple
|
|
|
|
mvn-debian clean package -Dmaven.test.skip=true
|
|
|
|
cd ..
|
|
|
|
|
|
|
|
# then jack
|
|
|
|
ant clean dist
|
|
|
|
|
|
|
|
# setup the jack/jill binary folder
|
|
|
|
cp jack/etc/Android.mk.build ../../jack_jill/Android.mk
|
2016-02-08 17:04:54 +00:00
|
|
|
cd ../../jack_jill
|
|
|
|
cp build/jack/dist/jack .
|
|
|
|
chmod +x jack
|
|
|
|
cp build/jack/dist/jack-admin .
|
|
|
|
chmod +x jack-admin
|
|
|
|
cp build/jack/dist/jack.jar .
|
|
|
|
cp build/jack/dist/jack-launcher.jar .
|
2016-01-29 00:21:43 +00:00
|
|
|
|
|
|
|
# finally the jill.jar
|
2016-02-08 17:04:54 +00:00
|
|
|
cd ../src/jill
|
2016-01-29 00:21:43 +00:00
|
|
|
ant clean dist
|
2016-02-08 17:04:54 +00:00
|
|
|
cp ../../jack_jill/build/jill/dist/jill.jar ../../jack_jill/
|
2016-01-29 00:21:43 +00:00
|
|
|
|
2016-01-14 23:25:31 +00:00
|
|
|
cd $BASEDIR
|
|
|
|
|
|
|
|
|
|
|
|
#TODO:
|
2016-01-29 00:21:43 +00:00
|
|
|
# search for binaries in external and remove them
|
|
|
|
# build manifest merger from source
|
|
|
|
# jack source has prebuilts
|