1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
#!/bin/sh
#
# 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/>.
#
set -e
BASEDIR=$(pwd)
GOLD_LD=/usr/bin/ld.gold
BFD_LD=/usr/bin/ld.bfd
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
# 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 \
--disable-werror \
make -j $(nproc)
make install
# 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-&'
make -j $(nproc)
make install
# 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' \
--enable-plugins \
--disable-ld \
--disable-werror \
make -j $(nproc)
make install
# 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 \
--host=x86_64-linux-gnu \
--build=x86_64-linux-gnu \
--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 \
--enable-languages=c,c++ \
--with-ld=$GOLD_LD
make -j $(nproc)
make install
# we need to link against the correct stdatomic.h
cd ../../install/lib/gcc/x86_64-linux/4.9.x/include
rm stdatomic.h
ln -s ../../../../../../../../../bionic/libc/include/stdatomic.h stdatomic.h
# link ld from /usr
cd ../../../../../x86_64-linux/bin/
rm -f ld ld.gold ld.bfd
ln -s "$GOLD_LD" ld
ln -s "$GOLD_LD" ld.gold
ln -s "$BFD_LD" ld.bfd
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
#############################
# build jack/jill toolchain
# first the simple lib
cd ../../src/jack/simple
# Try to use mvn-debian and if it's not available, try to use mvn
$(basename $(which mvn-debian || which mvn)) \
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
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 .
# finally the jill.jar
cd ../src/jill
ant clean dist
cp ../../jack_jill/build/jill/dist/jill.jar ../../jack_jill/
cd $BASEDIR
|