]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/bash | |
2 | ## | |
3 | ## This file is part of the sigrok-util project. | |
4 | ## | |
5 | ## Copyright (C) 2013 Uwe Hermann <uwe@hermann-uwe.de> | |
6 | ## | |
7 | ## This program is free software; you can redistribute it and/or modify | |
8 | ## it under the terms of the GNU General Public License as published by | |
9 | ## the Free Software Foundation; either version 2 of the License, or | |
10 | ## (at your option) any later version. | |
11 | ## | |
12 | ## This program is distributed in the hope that it will be useful, | |
13 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | ## GNU General Public License for more details. | |
16 | ## | |
17 | ## You should have received a copy of the GNU General Public License | |
18 | ## along with this program; if not, write to the Free Software | |
19 | ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
20 | ## | |
21 | ||
22 | set -e | |
23 | ||
24 | # The path where Android NDK is located. | |
25 | ANDROID_NDK=/usr/local/android-ndk-r9d | |
26 | ||
27 | # The path where Android SDK is located. | |
28 | ANDROID_SDK=/usr/local/android | |
29 | ||
30 | # The path where your Android toolchain directory is located. | |
31 | TOOLCHAIN=$HOME/android/android-arm-toolchain | |
32 | # TOOLCHAIN=$HOME/android/android-mipsel-toolchain | |
33 | # TOOLCHAIN=$HOME/android/android-i686-toolchain | |
34 | ||
35 | # Select which Android toolchain to use. | |
36 | # Don't forget to also adapt TOOLCHAIN above if you change TOOLCHAIN_TRIPLET! | |
37 | TOOLCHAIN_TRIPLET=arm-linux-androideabi | |
38 | # TOOLCHAIN_TRIPLET=mipsel-linux-android | |
39 | # TOOLCHAIN_TRIPLET=i686-linux-android | |
40 | ||
41 | # The path where the cross-compiled packages will be installed. | |
42 | PREFIX=$HOME/sr_android | |
43 | ||
44 | # The path where to download files to and where to build packages. | |
45 | BUILDDIR=./build | |
46 | ||
47 | # Edit this to enable/disable/modify parallel compiles. | |
48 | PARALLEL="-j 2" | |
49 | ||
50 | # You usually don't need to change anything below this line. | |
51 | ||
52 | # ----------------------------------------------------------------------------- | |
53 | ||
54 | VER_LIBICONV=1.14 | |
55 | VER_GETTEXT=0.18.3 | |
56 | VER_ZLIB=1.2.8 | |
57 | VER_PCRE=8.33 | |
58 | VER_LIBFFI=3.0.13 | |
59 | VER_GLIB=2.38.2 | |
60 | VER_GLIB_SHORT=2.38 | |
61 | VER_LIBZIP=0.11.1 | |
62 | VER_LIBFTDI1=1.1 | |
63 | VER_LIBUSBX=1.0.17 | |
64 | VER_PYTHON=3.3.3 | |
65 | VER_BOOST=1.55.0 | |
66 | VER_QT=n0.31 | |
67 | ||
68 | SF_MIRROR=switch.dl.sourceforge.net | |
69 | ||
70 | WGET="wget --quiet" | |
71 | GIT_CLONE="git clone --depth=1" | |
72 | ||
73 | case "$TOOLCHAIN_TRIPLET" in | |
74 | arm*) TARGET_ARCH=armeabi;; | |
75 | mips*) TARGET_ARCH=mips;; | |
76 | i686*) TARGET_ARCH=x86;; | |
77 | *) echo >&2 "Unknown prefix for TOOLCHAIN_TRIPLET"; exit 1;; | |
78 | esac | |
79 | ||
80 | # ----------------------------------------------------------------------------- | |
81 | ||
82 | # Remove build directory contents (if any) and create a new build dir. | |
83 | rm -rf $BUILDDIR | |
84 | mkdir $BUILDDIR | |
85 | cd $BUILDDIR | |
86 | ||
87 | # Build host Python before we start messing with the environment. | |
88 | $WGET http://python.org/ftp/python/$VER_PYTHON/Python-$VER_PYTHON.tar.xz | |
89 | tar xJf Python-$VER_PYTHON.tar.xz | |
90 | cd Python-$VER_PYTHON | |
91 | ./configure | |
92 | make python $PARALLEL | |
93 | make Parser/pgen $PARALLEL | |
94 | mv python hostpython | |
95 | mv Parser/pgen Parser/hostpgen | |
96 | cd .. | |
97 | ||
98 | # ----------------------------------------------------------------------------- | |
99 | ||
100 | # We need to find tools in the toolchain. | |
101 | export PATH=$TOOLCHAIN/bin:$PATH | |
102 | ||
103 | # Tell pkg-config to only look for our cross-built stuff. | |
104 | export PKG_CONFIG_LIBDIR="$PREFIX/lib/pkgconfig" | |
105 | export -n PKG_CONFIG_PATH | |
106 | ||
107 | # Define some helper variables. | |
108 | C="--host=$TOOLCHAIN_TRIPLET --prefix=$PREFIX" | |
109 | CM="-Wno-dev -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake -DANDROID_ABI=${TARGET_ARCH} -DCMAKE_INSTALL_PREFIX=${PREFIX} -DANDROID_STANDALONE_TOOLCHAIN=${TOOLCHAIN}" | |
110 | ||
111 | # Get the latest versions of config.guess/config.sub that know about Android. | |
112 | $GIT_CLONE git://git.savannah.gnu.org/config.git | |
113 | ||
114 | # Get a toolchain for cmake that knows about Android | |
115 | wget https://android-cmake.googlecode.com/hg/toolchain/android.toolchain.cmake | |
116 | patch < ../android.toolchain.cmake.patch android.toolchain.cmake | |
117 | ||
118 | # ----------------------------------------------------------------------------- | |
119 | ||
120 | # Python (needed for libsigrokdecode) | |
121 | cd Python-$VER_PYTHON | |
122 | make distclean | |
123 | autoreconf | |
124 | patch -p1 < ../../Python-$VER_PYTHON.patch | |
125 | ac_cv_file__dev_ptmx=no ac_cv_file__dev_ptc=no ac_cv_func_pipe2=no ac_cv_func_fdatasync=no ac_cv_func_killpg=no ac_cv_func_waitid=no ac_cv_func_sigaltstack=no ./configure $C --build=x86_64-linux-gnu --disable-ipv6 | |
126 | make HOSTPYTHON=./hostpython HOSTPGEN=./Parser/hostpgen install $PARALLEL | |
127 | cd .. | |
128 | ||
129 | # libiconv (needed for glib) | |
130 | $WGET http://ftp.gnu.org/pub/gnu/libiconv/libiconv-$VER_LIBICONV.tar.gz | |
131 | tar xfz libiconv-$VER_LIBICONV.tar.gz | |
132 | cd libiconv-$VER_LIBICONV | |
133 | cp -f ../config/config.guess build-aux | |
134 | cp -f ../config/config.sub build-aux | |
135 | cp -f ../config/config.guess libcharset/build-aux | |
136 | cp -f ../config/config.sub libcharset/build-aux | |
137 | ./configure $C --enable-shared | |
138 | make lib/localcharset.h | |
139 | cd libcharset | |
140 | make $PARALLEL | |
141 | make install | |
142 | cd ../lib | |
143 | make $PARALLEL | |
144 | make install | |
145 | cd .. | |
146 | test -d $PREFIX/include || mkdir $PREFIX/include | |
147 | cp include/iconv.h.inst $PREFIX/include/iconv.h | |
148 | cd .. | |
149 | ||
150 | # gettext (needed for glib) | |
151 | $WGET http://ftp.gnu.org/pub/gnu/gettext/gettext-$VER_GETTEXT.tar.gz | |
152 | tar xfz gettext-$VER_GETTEXT.tar.gz | |
153 | cd gettext-$VER_GETTEXT | |
154 | ./configure $C --enable-shared --disable-libasprintf | |
155 | cd gettext-runtime | |
156 | make $PARALLEL | |
157 | make install | |
158 | cd ../.. | |
159 | ||
160 | # zlib (needed for glib and libzip) | |
161 | $WGET http://zlib.net/zlib-$VER_ZLIB.tar.gz | |
162 | tar xfvz zlib-$VER_ZLIB.tar.gz | |
163 | cd zlib-$VER_ZLIB | |
164 | # Note: zlib's configure doesn't understand --host, we need to pass $CC. | |
165 | CC=$TOOLCHAIN_TRIPLET-gcc ./configure --prefix=$PREFIX | |
166 | make $PARALLEL | |
167 | make install | |
168 | cd .. | |
169 | ||
170 | # pcre (needed for glib) | |
171 | $WGET ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-$VER_PCRE.tar.gz | |
172 | tar xfvz pcre-$VER_PCRE.tar.gz | |
173 | cd pcre-$VER_PCRE | |
174 | ./configure $C --disable-cpp | |
175 | make $PARALLEL | |
176 | make install | |
177 | cd .. | |
178 | ||
179 | # libffi (needed for glib) | |
180 | $WGET ftp://sourceware.org/pub/libffi/libffi-$VER_LIBFFI.tar.gz | |
181 | tar xfz libffi-$VER_LIBFFI.tar.gz | |
182 | cd libffi-$VER_LIBFFI | |
183 | ./configure $C | |
184 | make $PARALLEL | |
185 | make install | |
186 | cd .. | |
187 | ||
188 | # glib | |
189 | $WGET http://ftp.gnome.org/pub/gnome/sources/glib/$VER_GLIB_SHORT/glib-$VER_GLIB.tar.xz | |
190 | tar xJf glib-$VER_GLIB.tar.xz | |
191 | cd glib-$VER_GLIB | |
192 | ./autogen.sh | |
193 | # Note: Manual LDFLAGS/CPPFLAGS needed for libiconv, rest uses pkg-config. | |
194 | LDFLAGS=-L$PREFIX/lib CPPFLAGS=-I$PREFIX/include glib_cv_stack_grows=no glib_cv_uscore=no ac_cv_func_posix_getpwuid_r=no ac_cv_func_posix_getgrgid_r=no ./configure --disable-compile-warnings $C | |
195 | make $PARALLEL | |
196 | make install | |
197 | cd .. | |
198 | ||
199 | # libzip | |
200 | $WGET http://www.nih.at/libzip/libzip-$VER_LIBZIP.tar.gz | |
201 | tar xfz libzip-$VER_LIBZIP.tar.gz | |
202 | cd libzip-$VER_LIBZIP | |
203 | cp -f ../config/config.guess . | |
204 | cp -f ../config/config.sub . | |
205 | ./configure $C | |
206 | make $PARALLEL | |
207 | make install | |
208 | cd .. | |
209 | ||
210 | # libusb-1.0 | |
211 | $WGET http://$SF_MIRROR/project/libusbx/releases/$VER_LIBUSBX/source/libusbx-$VER_LIBUSBX.tar.bz2 | |
212 | tar xfj libusbx-$VER_LIBUSBX.tar.bz2 | |
213 | cd libusbx-$VER_LIBUSBX | |
214 | patch -p1 < ../../libusb-1.0.patch | |
215 | ./configure $C --disable-udev | |
216 | make $PARALLEL | |
217 | make install | |
218 | cd .. | |
219 | ||
220 | # libftdi1 | |
221 | $WGET http://www.intra2net.com/en/developer/libftdi/download/libftdi1-$VER_LIBFTDI1.tar.bz2 | |
222 | tar xfj libftdi1-$VER_LIBFTDI1.tar.bz2 | |
223 | cd libftdi1-$VER_LIBFTDI1 | |
224 | cmake $CM . | |
225 | make $PARALLEL | |
226 | make install | |
227 | cd .. | |
228 | ||
229 | # libserialport | |
230 | $GIT_CLONE git://sigrok.org/libserialport | |
231 | cd libserialport | |
232 | ./autogen.sh | |
233 | ./configure $C | |
234 | make $PARALLEL V=1 | |
235 | make install | |
236 | cd .. | |
237 | ||
238 | # libsigrok | |
239 | $GIT_CLONE git://sigrok.org/libsigrok | |
240 | cd libsigrok | |
241 | ./autogen.sh | |
242 | ./configure $C | |
243 | make $PARALLEL V=1 | |
244 | make install | |
245 | cd .. | |
246 | ||
247 | # libsigrokdecode | |
248 | $GIT_CLONE git://sigrok.org/libsigrokdecode | |
249 | cd libsigrokdecode | |
250 | ./autogen.sh | |
251 | ./configure $C | |
252 | make $PARALLEL V=1 | |
253 | make install | |
254 | cd .. | |
255 | ||
256 | # sigrok-cli | |
257 | $GIT_CLONE git://sigrok.org/sigrok-cli | |
258 | cd sigrok-cli | |
259 | ./autogen.sh | |
260 | ./configure $C | |
261 | make $PARALLEL V=1 | |
262 | make install | |
263 | cd .. | |
264 | ||
265 | ||
266 | # Check if we have kit to build PulseView | |
267 | ||
268 | if [ -z "$ANDROID_NDK" -o ! -d "$ANDROID_NDK" ]; then | |
269 | echo "Android NDK not available, not building PulseView" | |
270 | exit 0 | |
271 | fi | |
272 | ||
273 | if [ -z "$ANDROID_SDK" -o ! -d "$ANDROID_SDK"/platforms/android-4 -o \ | |
274 | ! -d "$ANDROID_SDK"/platforms/android-7 -o \ | |
275 | ! -d "$ANDROID_SDK"/platforms/android-8 -o \ | |
276 | ! -d "$ANDROID_SDK"/platforms/android-14 ]; then | |
277 | echo "Android SDK with platforms 4 7 8 14 not available, not building PulseView" | |
278 | exit 0 | |
279 | fi | |
280 | ||
281 | ANDROID_TOOLS=${ANDROID_SDK}/tools | |
282 | ANDROID_BUILD_TOOLS=${ANDROID_SDK}/build-tools/19.0.1 | |
283 | ||
284 | if [ ! -e "$ANDROID_TOOLS/android" -o ! -e "$ANDROID_BUILD_TOOLS/dx" ]; then | |
285 | echo "Essential Android build tools not available, not building PulseView" | |
286 | exit 0 | |
287 | fi | |
288 | ||
289 | NDK_TOOLCHAIN_VERSION=`${TOOLCHAIN_TRIPLET}-gcc --version | head -1 | sed -e 's/.* \([0-9]\+\.[0-9.]\+\)\( \|.*\)$/\1/'` | |
290 | NDK_HOST=`"$ANDROID_NDK/ndk-build" -p 2>/dev/null | awk '$1 == "HOST_TAG" { print $3 }'` | |
291 | ||
292 | ||
293 | # boost (needed for PulseView) | |
294 | $WGET http://$SF_MIRROR/project/boost/boost/$VER_BOOST/boost_${VER_BOOST//./_}.tar.bz2 | |
295 | tar xfj boost_${VER_BOOST//./_}.tar.bz2 | |
296 | cd boost_${VER_BOOST//./_} | |
297 | patch -p1 < ../../boost.patch | |
298 | ./bootstrap.sh --with-toolset=gcc --with-libraries=filesystem,system,thread --without-icu | |
299 | echo "using gcc : $NDK_TOOLCHAIN_VERSION : \"${TOOLCHAIN_TRIPLET}-g++\" : <cxxflags>\"-I$PREFIX/include -I${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${NDK_TOOLCHAIN_VERSION}/include -I${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${NDK_TOOLCHAIN_VERSION}/libs/${TARGET_ARCH}/include\" <linkflags>\"-L$PREFIX/lib -L${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${NDK_TOOLCHAIN_VERSION}/libs/${TARGET_ARCH} -lgnustl_shared\" ;" > user-config.jam | |
300 | ./b2 -q -d+2 --user-config=user-config.jam toolset=gcc variant=release link=shared threading=multi runtime-link=shared target-os=android --prefix=$PREFIX --layout=system install | |
301 | cd .. | |
302 | ||
303 | # qt (needed for PulseView) | |
304 | $GIT_CLONE -b $VER_QT git://anongit.kde.org/android-qt.git | |
305 | cd android-qt | |
306 | patch -p1 < ../../android-qt.patch | |
307 | ANDROID_SDK_PLATFORM_TOOLS_PATH=$ANDROID_BUILD_TOOLS ANDROID_SDK_TOOLS_PATH=$ANDROID_TOOLS ./android/androidconfigbuild.sh -n $ANDROID_NDK -a $TARGET_ARCH -l 14 -q 1 -d 1 -i $PREFIX -k 1 -o $NDK_HOST -v $NDK_TOOLCHAIN_VERSION | |
308 | cd .. | |
309 | ||
310 | # PulseView | |
311 | $GIT_CLONE git://sigrok.org/pulseview | |
312 | cd pulseview | |
313 | patch -p1 < ../../pulseview-cpp.patch | |
314 | cmake $CM -DQT_QMAKE_EXECUTABLE=${PREFIX}/bin/qmake -DANDROID_STL_PATH=${ANDROID_NDK}/sources/cxx-stl -DENABLE_DECODE=FALSE . | |
315 | make $PARALLEL | |
316 | cp -r "$PREFIX"/src/android/java . | |
317 | cp -r libs java/ | |
318 | cd java | |
319 | patch -p2 < ../../../pulseview-java.patch | |
320 | mkdir -p assets | |
321 | READELF=$TOOLCHAIN_TRIPLET-readelf ../../../fix-libraries.sh "$PREFIX/lib" libs/"$TARGET_ARCH" libpulseview.so > assets/liblist.txt | |
322 | cp ${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${NDK_TOOLCHAIN_VERSION}/libs/${TARGET_ARCH}/libgnustl_shared.so libs/${TARGET_ARCH}/ | |
323 | "$ANDROID_TOOLS/android" update project -p . -t android-14 -n PulseView | |
324 | ant debug | |
325 | cd ../.. |