]>
Commit | Line | Data |
---|---|---|
0832e7d6 UH |
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 | ||
c28fee03 MC |
22 | set -e |
23 | ||
11b9792e MC |
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 | ||
0832e7d6 UH |
30 | # The path where your Android toolchain directory is located. |
31 | TOOLCHAIN=$HOME/android/android-arm-toolchain | |
e2bb3ab1 UH |
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 | |
0832e7d6 UH |
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. | |
07947dda | 45 | BUILDDIR=./build |
0832e7d6 | 46 | |
819eb05b UH |
47 | # Edit this to enable/disable/modify parallel compiles. |
48 | PARALLEL="-j 2" | |
49 | ||
0832e7d6 UH |
50 | # You usually don't need to change anything below this line. |
51 | ||
52 | # ----------------------------------------------------------------------------- | |
53 | ||
54 | VER_LIBICONV=1.14 | |
5036134a | 55 | VER_GETTEXT=0.18.3 |
b118df5f | 56 | VER_ZLIB=1.2.8 |
5036134a UH |
57 | VER_PCRE=8.33 |
58 | VER_LIBFFI=3.0.13 | |
f7b8aa73 UH |
59 | VER_GLIB=2.38.2 |
60 | VER_GLIB_SHORT=2.38 | |
5036134a | 61 | VER_LIBZIP=0.11.1 |
7966c37c | 62 | VER_LIBFTDI1=1.1 |
6907ee7e | 63 | VER_LIBUSBX=1.0.17 |
5451bfe2 | 64 | VER_PYTHON=3.3.3 |
11b9792e | 65 | VER_BOOST=1.55.0 |
2256009e | 66 | VER_QT=5.3.1 |
0832e7d6 UH |
67 | |
68 | SF_MIRROR=switch.dl.sourceforge.net | |
69 | ||
ec49447e | 70 | WGET="wget --quiet" |
a51ca6bd | 71 | GIT_CLONE="git clone --depth=1" |
ec49447e | 72 | |
7966c37c MC |
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 | ||
0832e7d6 UH |
80 | # ----------------------------------------------------------------------------- |
81 | ||
2e353a08 ML |
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. | |
ec49447e | 88 | $WGET http://python.org/ftp/python/$VER_PYTHON/Python-$VER_PYTHON.tar.xz |
5451bfe2 ML |
89 | tar xJf Python-$VER_PYTHON.tar.xz |
90 | cd Python-$VER_PYTHON | |
2e353a08 | 91 | ./configure |
819eb05b UH |
92 | make python $PARALLEL |
93 | make Parser/pgen $PARALLEL | |
2e353a08 ML |
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 | |
0832e7d6 | 102 | |
02c87af2 | 103 | # Tell pkg-config to only look for our cross-built stuff. |
226830e4 MC |
104 | export PKG_CONFIG_LIBDIR="$PREFIX/lib/pkgconfig" |
105 | export -n PKG_CONFIG_PATH | |
106 | ||
0832e7d6 | 107 | # Define some helper variables. |
e2bb3ab1 | 108 | C="--host=$TOOLCHAIN_TRIPLET --prefix=$PREFIX" |
7966c37c | 109 | CM="-Wno-dev -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake -DANDROID_ABI=${TARGET_ARCH} -DCMAKE_INSTALL_PREFIX=${PREFIX} -DANDROID_STANDALONE_TOOLCHAIN=${TOOLCHAIN}" |
0832e7d6 | 110 | |
0832e7d6 | 111 | # Get the latest versions of config.guess/config.sub that know about Android. |
a51ca6bd | 112 | $GIT_CLONE git://git.savannah.gnu.org/config.git |
0832e7d6 | 113 | |
7966c37c MC |
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 | ||
0832e7d6 UH |
118 | # ----------------------------------------------------------------------------- |
119 | ||
f7b8aa73 UH |
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 | |
9a98e0d1 | 126 | sed -i "s/^#zlib/zlib/g" Modules/Setup |
819eb05b | 127 | make HOSTPYTHON=./hostpython HOSTPGEN=./Parser/hostpgen install $PARALLEL |
f7b8aa73 UH |
128 | cd .. |
129 | ||
85b46172 | 130 | # libiconv (needed for glib) |
ec49447e | 131 | $WGET http://ftp.gnu.org/pub/gnu/libiconv/libiconv-$VER_LIBICONV.tar.gz |
85b46172 MC |
132 | tar xfz libiconv-$VER_LIBICONV.tar.gz |
133 | cd libiconv-$VER_LIBICONV | |
134 | cp -f ../config/config.guess build-aux | |
135 | cp -f ../config/config.sub build-aux | |
136 | cp -f ../config/config.guess libcharset/build-aux | |
137 | cp -f ../config/config.sub libcharset/build-aux | |
138 | ./configure $C --enable-shared | |
139 | make lib/localcharset.h | |
140 | cd libcharset | |
819eb05b | 141 | make $PARALLEL |
85b46172 MC |
142 | make install |
143 | cd ../lib | |
819eb05b | 144 | make $PARALLEL |
85b46172 MC |
145 | make install |
146 | cd .. | |
147 | test -d $PREFIX/include || mkdir $PREFIX/include | |
148 | cp include/iconv.h.inst $PREFIX/include/iconv.h | |
149 | cd .. | |
0832e7d6 | 150 | |
87ea3974 | 151 | # gettext (needed for glib) |
ec49447e | 152 | $WGET http://ftp.gnu.org/pub/gnu/gettext/gettext-$VER_GETTEXT.tar.gz |
87ea3974 MC |
153 | tar xfz gettext-$VER_GETTEXT.tar.gz |
154 | cd gettext-$VER_GETTEXT | |
155 | ./configure $C --enable-shared --disable-libasprintf | |
156 | cd gettext-runtime | |
819eb05b | 157 | make $PARALLEL |
87ea3974 MC |
158 | make install |
159 | cd ../.. | |
0832e7d6 UH |
160 | |
161 | # zlib (needed for glib and libzip) | |
ec49447e | 162 | $WGET http://zlib.net/zlib-$VER_ZLIB.tar.gz |
167cb16e UH |
163 | tar xfvz zlib-$VER_ZLIB.tar.gz |
164 | cd zlib-$VER_ZLIB | |
165 | # Note: zlib's configure doesn't understand --host, we need to pass $CC. | |
e2bb3ab1 | 166 | CC=$TOOLCHAIN_TRIPLET-gcc ./configure --prefix=$PREFIX |
819eb05b | 167 | make $PARALLEL |
c28fee03 | 168 | make install |
167cb16e | 169 | cd .. |
0832e7d6 UH |
170 | |
171 | # pcre (needed for glib) | |
ec49447e | 172 | $WGET ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-$VER_PCRE.tar.gz |
85c9910a UH |
173 | tar xfvz pcre-$VER_PCRE.tar.gz |
174 | cd pcre-$VER_PCRE | |
091ed535 | 175 | ./configure $C --disable-cpp |
819eb05b | 176 | make $PARALLEL |
c28fee03 | 177 | make install |
85c9910a | 178 | cd .. |
0832e7d6 UH |
179 | |
180 | # libffi (needed for glib) | |
ec49447e | 181 | $WGET ftp://sourceware.org/pub/libffi/libffi-$VER_LIBFFI.tar.gz |
0832e7d6 UH |
182 | tar xfz libffi-$VER_LIBFFI.tar.gz |
183 | cd libffi-$VER_LIBFFI | |
c28fee03 | 184 | ./configure $C |
819eb05b | 185 | make $PARALLEL |
c28fee03 | 186 | make install |
0832e7d6 UH |
187 | cd .. |
188 | ||
559be0ff | 189 | # glib |
ec49447e | 190 | $WGET http://ftp.gnome.org/pub/gnome/sources/glib/$VER_GLIB_SHORT/glib-$VER_GLIB.tar.xz |
f7b8aa73 UH |
191 | tar xJf glib-$VER_GLIB.tar.xz |
192 | cd glib-$VER_GLIB | |
f0e760bb | 193 | ./autogen.sh |
559be0ff | 194 | # Note: Manual LDFLAGS/CPPFLAGS needed for libiconv, rest uses pkg-config. |
e2bb3ab1 | 195 | 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 |
819eb05b | 196 | make $PARALLEL |
f0e760bb MC |
197 | make install |
198 | cd .. | |
0832e7d6 UH |
199 | |
200 | # libzip | |
ec49447e | 201 | $WGET http://www.nih.at/libzip/libzip-$VER_LIBZIP.tar.gz |
0832e7d6 UH |
202 | tar xfz libzip-$VER_LIBZIP.tar.gz |
203 | cd libzip-$VER_LIBZIP | |
204 | cp -f ../config/config.guess . | |
205 | cp -f ../config/config.sub . | |
c28fee03 | 206 | ./configure $C |
819eb05b | 207 | make $PARALLEL |
c28fee03 | 208 | make install |
0832e7d6 UH |
209 | cd .. |
210 | ||
13b2dfdc | 211 | # libusb-1.0 |
ec49447e | 212 | $WGET http://$SF_MIRROR/project/libusbx/releases/$VER_LIBUSBX/source/libusbx-$VER_LIBUSBX.tar.bz2 |
6907ee7e MC |
213 | tar xfj libusbx-$VER_LIBUSBX.tar.bz2 |
214 | cd libusbx-$VER_LIBUSBX | |
c09c85b3 | 215 | patch -p1 < ../../libusb-1.0.patch |
6907ee7e | 216 | ./configure $C --disable-udev |
819eb05b | 217 | make $PARALLEL |
13b2dfdc MC |
218 | make install |
219 | cd .. | |
220 | ||
7966c37c MC |
221 | # libftdi1 |
222 | $WGET http://www.intra2net.com/en/developer/libftdi/download/libftdi1-$VER_LIBFTDI1.tar.bz2 | |
223 | tar xfj libftdi1-$VER_LIBFTDI1.tar.bz2 | |
224 | cd libftdi1-$VER_LIBFTDI1 | |
225 | cmake $CM . | |
226 | make $PARALLEL | |
227 | make install | |
228 | cd .. | |
229 | ||
900a8684 | 230 | # libserialport |
a51ca6bd | 231 | $GIT_CLONE git://sigrok.org/libserialport |
900a8684 ML |
232 | cd libserialport |
233 | ./autogen.sh | |
6cdef103 | 234 | ./configure $C |
83b801db | 235 | make $PARALLEL V=1 |
900a8684 ML |
236 | make install |
237 | cd .. | |
238 | ||
c062d1dc | 239 | # libsigrok |
a51ca6bd | 240 | $GIT_CLONE git://sigrok.org/libsigrok |
c062d1dc MC |
241 | cd libsigrok |
242 | ./autogen.sh | |
d9b3295c | 243 | ./configure $C --datadir=/sdcard |
83b801db | 244 | make $PARALLEL V=1 |
c062d1dc MC |
245 | make install |
246 | cd .. | |
02c87af2 | 247 | |
2fbea156 | 248 | # libsigrokdecode |
a51ca6bd | 249 | $GIT_CLONE git://sigrok.org/libsigrokdecode |
2fbea156 ML |
250 | cd libsigrokdecode |
251 | ./autogen.sh | |
252 | ./configure $C | |
83b801db | 253 | make $PARALLEL V=1 |
2fbea156 ML |
254 | make install |
255 | cd .. | |
256 | ||
257 | # sigrok-cli | |
a51ca6bd | 258 | $GIT_CLONE git://sigrok.org/sigrok-cli |
2fbea156 ML |
259 | cd sigrok-cli |
260 | ./autogen.sh | |
261 | ./configure $C | |
83b801db | 262 | make $PARALLEL V=1 |
2fbea156 ML |
263 | make install |
264 | cd .. | |
819eb05b | 265 | |
11b9792e MC |
266 | |
267 | # Check if we have kit to build PulseView | |
268 | ||
269 | if [ -z "$ANDROID_NDK" -o ! -d "$ANDROID_NDK" ]; then | |
270 | echo "Android NDK not available, not building PulseView" | |
271 | exit 0 | |
272 | fi | |
273 | ||
7b888971 MC |
274 | if [ -z "$ANDROID_SDK" -o ! -d "$ANDROID_SDK"/platforms/android-8 -o \ |
275 | ! -d "$ANDROID_SDK"/platforms/android-10 -o \ | |
276 | ! -d "$ANDROID_SDK"/platforms/android-11 -o \ | |
277 | ! -d "$ANDROID_SDK"/platforms/android-14 -o \ | |
278 | ! -d "$ANDROID_SDK"/platforms/android-16 ]; then | |
279 | echo "Android SDK with platforms 8 10 11 14 16 not available, not building PulseView" | |
11b9792e MC |
280 | exit 0 |
281 | fi | |
282 | ||
283 | ANDROID_TOOLS=${ANDROID_SDK}/tools | |
284 | ANDROID_BUILD_TOOLS=${ANDROID_SDK}/build-tools/19.0.1 | |
285 | ||
286 | if [ ! -e "$ANDROID_TOOLS/android" -o ! -e "$ANDROID_BUILD_TOOLS/dx" ]; then | |
287 | echo "Essential Android build tools not available, not building PulseView" | |
288 | exit 0 | |
289 | fi | |
290 | ||
291 | NDK_TOOLCHAIN_VERSION=`${TOOLCHAIN_TRIPLET}-gcc --version | head -1 | sed -e 's/.* \([0-9]\+\.[0-9.]\+\)\( \|.*\)$/\1/'` | |
292 | NDK_HOST=`"$ANDROID_NDK/ndk-build" -p 2>/dev/null | awk '$1 == "HOST_TAG" { print $3 }'` | |
293 | ||
294 | ||
295 | # boost (needed for PulseView) | |
296 | $WGET http://$SF_MIRROR/project/boost/boost/$VER_BOOST/boost_${VER_BOOST//./_}.tar.bz2 | |
297 | tar xfj boost_${VER_BOOST//./_}.tar.bz2 | |
298 | cd boost_${VER_BOOST//./_} | |
299 | patch -p1 < ../../boost.patch | |
7744cf5c | 300 | ./bootstrap.sh --with-toolset=gcc --with-libraries=filesystem,system --without-icu |
b03a5e48 | 301 | 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 |
11b9792e MC |
302 | ./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 |
303 | cd .. | |
304 | ||
305 | # qt (needed for PulseView) | |
7b888971 MC |
306 | $WGET http://download.qt-project.org/official_releases/qt/${VER_QT%.*}/${VER_QT}/single/qt-everywhere-opensource-src-${VER_QT}.tar.gz |
307 | tar xfz qt-everywhere-opensource-src-${VER_QT}.tar.gz | |
308 | cd qt-everywhere-opensource-src-${VER_QT} | |
11b9792e | 309 | patch -p1 < ../../android-qt.patch |
2256009e | 310 | ./configure --prefix="$PREFIX" -developer-build -xplatform android-g++ -nomake tests -nomake examples -android-sdk "$ANDROID_SDK" -android-ndk "$ANDROID_NDK" -android-ndk-host "$NDK_HOST" -android-arch "$TARGET_ARCH" -android-toolchain-version "$NDK_TOOLCHAIN_VERSION" -skip qttranslations -skip qtwebkit -skip qtserialport -skip qtwebkit-examples -skip qtlocation -skip qtconnectivity -opensource -confirm-license |
7b888971 MC |
311 | make $PARALLEL |
312 | make install | |
11b9792e | 313 | cd .. |
5d1a9a53 MC |
314 | |
315 | # PulseView | |
316 | $GIT_CLONE git://sigrok.org/pulseview | |
317 | cd pulseview | |
aef0361e | 318 | patch -p1 < ../../pulseview-cpp.patch |
0c5c3b89 | 319 | cmake $CM -DANDROID_STL_PATH=${ANDROID_NDK}/sources/cxx-stl . |
aef0361e | 320 | make $PARALLEL |
3c45ba19 | 321 | git clone https://github.com/zeldin/pulseview_android_java java |
aef0361e | 322 | cp -r libs java/ |
6f61b17c MC |
323 | mkdir -p java/res/drawable |
324 | cp icons/sigrok-logo-notext.png java/res/drawable/logo.png | |
aef0361e | 325 | cd java |
aef0361e MC |
326 | mkdir -p assets |
327 | READELF=$TOOLCHAIN_TRIPLET-readelf ../../../fix-libraries.sh "$PREFIX/lib" libs/"$TARGET_ARCH" libpulseview.so > assets/liblist.txt | |
bdf42f4b MC |
328 | cp -r "$PREFIX"/lib/python3.3 assets/ |
329 | cp -r "$PREFIX"/share/libsigrokdecode assets/ | |
aef0361e MC |
330 | cp ${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${NDK_TOOLCHAIN_VERSION}/libs/${TARGET_ARCH}/libgnustl_shared.so libs/${TARGET_ARCH}/ |
331 | "$ANDROID_TOOLS/android" update project -p . -t android-14 -n PulseView | |
332 | ant debug | |
333 | cd ../.. |