3 ## This file is part of the sigrok-util project.
5 ## Copyright (C) 2013-2014 Uwe Hermann <uwe@hermann-uwe.de>
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.
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.
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
24 # The path where the NDK, SDK, and toolchains are located.
25 ANDROID_PATH
=$HOME/android
27 # The path where the Android NDK is located.
28 ANDROID_NDK
=$ANDROID_PATH/android-ndk-r10c
30 # The path where the Android SDK is located.
31 ANDROID_SDK
=$ANDROID_PATH/android-sdk-linux
33 # The path where your Android toolchain directory is located.
34 TOOLCHAIN
=$ANDROID_PATH/android-arm-toolchain
35 # TOOLCHAIN=$ANDROID_PATH/android-mipsel-toolchain
36 # TOOLCHAIN=$ANDROID_PATH/android-i686-toolchain
37 # TOOLCHAIN=$ANDROID_NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86
38 # TOOLCHAIN=$ANDROID_NDK/toolchains/x86-4.9/prebuilt/linux-x86
39 # TOOLCHAIN=$ANDROID_NDK/toolchains/mipsel-linux-android-4.9/prebuilt/linux-x86
41 # Select which Android toolchain to use.
42 # Don't forget to also adapt TOOLCHAIN above if you change TOOLCHAIN_TRIPLET!
43 TOOLCHAIN_TRIPLET
=arm-linux-androideabi
44 # TOOLCHAIN_TRIPLET=mipsel-linux-android
45 # TOOLCHAIN_TRIPLET=i686-linux-android
47 # The path where the cross-compiled packages will be installed.
48 PREFIX
=$HOME/sr_android
50 # The path where to download files to and where to build packages.
53 # Edit this to enable/disable/modify parallel compiles.
56 # You usually don't need to change anything below this line.
58 # -----------------------------------------------------------------------------
68 VER_LIBSIGCXX_SHORT
=2.3
78 SF_MIRROR
=switch.dl.sourceforge.net
81 GIT_CLONE
="git clone --depth=1"
83 case "$TOOLCHAIN_TRIPLET" in
84 arm
*) TARGET_ARCH
=armeabi
;;
85 mips
*) TARGET_ARCH
=mips
;;
86 i686
*) TARGET_ARCH
=x86
;;
87 *) echo >&2 "Unknown prefix for TOOLCHAIN_TRIPLET."; exit 1;;
90 # -----------------------------------------------------------------------------
92 # Get the Android NDK and SDK, install required packages and toolchains.
93 if [ "x$1" = "xprepare" ]; then
94 mkdir
-p $ANDROID_PATH
98 $WGET http
://dl.google.com
/android
/ndk
/android-ndk-r
$VER_NDK-linux-x86.bin
99 chmod 700 android-ndk-r
$VER_NDK-linux-x86.bin
100 .
/android-ndk-r
$VER_NDK-linux-x86.bin
101 cd android-ndk-r
$VER_NDK
102 .
/build
/tools
/make-standalone-toolchain.sh
--platform=android-16 \
103 --toolchain=arm-linux-androideabi-4.9 \
104 --install-dir=$ANDROID_PATH/android-arm-toolchain
108 $WGET http
://dl.google.com
/android
/android-sdk_r
$VER_SDK-linux.tgz
109 tar xfz android-sdk_r
$VER_SDK-linux.tgz
111 .
/tools
/android update sdk
--no-ui --filter platform-tools
,build-tools-21.1
.0,android-8
,android-10
,android-11
,android-14
,android-16
117 # -----------------------------------------------------------------------------
119 # Remove build directory contents (if any) and create a new build dir.
124 # -----------------------------------------------------------------------------
126 # Build host Python before we start messing with the environment.
127 # Don't do parallel builds, this doesn't seem to work well.
128 $WGET http
://python.org
/ftp
/python
/$VER_PYTHON/Python-
$VER_PYTHON.
tar.xz
129 tar xfJ Python-
$VER_PYTHON.
tar.xz
130 cd Python-
$VER_PYTHON
136 # -----------------------------------------------------------------------------
138 # We need to find tools in the toolchain.
139 export PATH
=$TOOLCHAIN/bin
:$PATH
141 # Tell pkg-config to only look for our cross-built stuff.
142 export PKG_CONFIG_LIBDIR
="$PREFIX/lib/pkgconfig"
143 export -n PKG_CONFIG_PATH
146 if test -d "$TOOLCHAIN"/sysroot
; then
147 echo "Toolchain is standalone"
148 STANDALONE_TOOLCHAIN
=$TOOLCHAIN
151 STANDALONE_TOOLCHAIN
=
153 SYSROOT_DIR
=${ANDROID_NDK}/platforms/android-${NATIVE_API_LEVEL}/arch-${TARGET_ARCH%eabi*}
154 if [ ! -d "$SYSROOT_DIR" ]; then
155 echo >&2 "Can't build with NDK toolchain; sysroot $SYSROOT_DIR is missing"
158 SYSROOT
="--sysroot $SYSROOT_DIR"
159 CC
="$TOOLCHAIN_TRIPLET-gcc $SYSROOT"
160 CXX
="$TOOLCHAIN_TRIPLET-g++ $SYSROOT"
163 NDK_TOOLCHAIN_VERSION
=`${TOOLCHAIN_TRIPLET}-gcc --version | head -1 | sed -e 's/.* \([0-9]\+\.[0-9.]\+\)\( \|.*\)$/\1/'`
165 # Define some helper variables.
166 C
="--host=$TOOLCHAIN_TRIPLET --prefix=$PREFIX"
167 CM
="-Wno-dev -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake -DANDROID_ABI=${TARGET_ARCH} -DCMAKE_INSTALL_PREFIX=${PREFIX}"
168 if [ -n "$STANDALONE_TOOLCHAIN" ]; then
169 CM
="$CM -DANDROID_STANDALONE_TOOLCHAIN=${STANDALONE_TOOLCHAIN}"
170 if [ -d "${ANDROID_NDK}/sources/cxx-stl" ]; then
171 CM
="$CM -DANDROID_STL_PATH=${ANDROID_NDK}/sources/cxx-stl"
174 CM
="$CM -DANDROID_NDK=${ANDROID_NDK}"
175 CM
="$CM -DANDROID_NATIVE_API_LEVEL=${NATIVE_API_LEVEL}"
176 CM
="$CM -DANDROID_TOOLCHAIN_NAME=${TOOLCHAIN_TRIPLET}-${NDK_TOOLCHAIN_VERSION}"
179 # Look for STL, needed to build bindings
180 STL_BASE
="${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${NDK_TOOLCHAIN_VERSION}"
181 if [ -d ${STL_BASE}/include
]; then
182 CPPFLAGS_STL
="-I${STL_BASE}/include -I${STL_BASE}/libs/${TARGET_ARCH}/include"
183 LDFLAGS_STL
="-L${STL_BASE}/libs/${TARGET_ARCH} -Wl,-rpath=${STL_BASE}/libs/${TARGET_ARCH}"
184 BINDINGS_CONFIG
="--enable-bindings"
186 echo "Warning: STL unavailable, libsigrok bindings will not be built."
189 BINDINGS_CONFIG
="--disable-bindings"
192 # -----------------------------------------------------------------------------
194 # Get the latest versions of config.guess/config.sub that know about Android.
195 $GIT_CLONE git
://git.savannah.gnu.org
/config.git
197 # Get a toolchain for cmake that knows about Android.
198 $WGET https
://android-cmake.googlecode.com
/hg
/toolchain
/android.toolchain.cmake
199 patch < ..
/android.toolchain.cmake.
patch android.toolchain.cmake
201 # -----------------------------------------------------------------------------
203 # Python (needed for libsigrokdecode)
204 # Don't do parallel Python builds, this doesn't seem to work well.
205 cd Python-
$VER_PYTHON
208 patch -p1 < ..
/..
/Python-
$VER_PYTHON.
patch
209 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
210 sed -i "s/^#zlib/zlib/g" Modules
/Setup
211 make PYTHON_FOR_BUILD
='_PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) ./hostpython' install
214 # libiconv (needed for glib)
215 $WGET http
://ftp.gnu.org
/pub
/gnu
/libiconv
/libiconv-
$VER_LIBICONV.
tar.gz
216 tar xfz libiconv-
$VER_LIBICONV.
tar.gz
217 cd libiconv-
$VER_LIBICONV
218 cp -f ..
/config
/config.guess build-aux
219 cp -f ..
/config
/config.sub build-aux
220 cp -f ..
/config
/config.guess libcharset
/build-aux
221 cp -f ..
/config
/config.sub libcharset
/build-aux
222 .
/configure
$C --enable-shared
223 make lib
/localcharset.h
231 test -d $PREFIX/include || mkdir
$PREFIX/include
232 cp include
/iconv.h.inst
$PREFIX/include
/iconv.h
235 # gettext (needed for glib)
236 $WGET http
://ftp.gnu.org
/pub
/gnu
/gettext
/gettext-
$VER_GETTEXT.
tar.gz
237 tar xfz gettext-
$VER_GETTEXT.
tar.gz
238 cd gettext-
$VER_GETTEXT
239 .
/configure
$C --enable-shared --disable-libasprintf
245 # zlib (needed for glib and libzip)
246 $WGET http
://zlib.net
/zlib-
$VER_ZLIB.
tar.gz
247 tar xfz zlib-
$VER_ZLIB.
tar.gz
249 # Note: zlib's configure doesn't understand --host, we need to pass $CC.
250 CC
="$TOOLCHAIN_TRIPLET-gcc $SYSROOT" .
/configure
--prefix=$PREFIX
255 # pcre (needed for glib)
256 $WGET ftp://ftp.csx.cam.ac.uk
/pub
/software
/programming
/pcre
/pcre-
$VER_PCRE.
tar.gz
257 tar xfz pcre-
$VER_PCRE.
tar.gz
259 .
/configure
$C --disable-cpp
264 # libffi (needed for glib)
265 $WGET ftp://sourceware.org
/pub
/libffi
/libffi-
$VER_LIBFFI.
tar.gz
266 tar xfz libffi-
$VER_LIBFFI.
tar.gz
267 cd libffi-
$VER_LIBFFI
273 # glib (needed for libsigrok)
274 $WGET http
://ftp.gnome.org
/pub
/gnome
/sources
/glib
/$VER_GLIB_SHORT/glib-
$VER_GLIB.
tar.xz
275 tar xfJ glib-
$VER_GLIB.
tar.xz
277 NOCONFIGURE
=yes .
/autogen.sh
278 # Note: Manual LDFLAGS/CPPFLAGS needed for libiconv, rest uses pkg-config.
279 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
284 # libzip (needed for libsigrok)
285 $WGET http
://www.nih.at
/libzip
/libzip-
$VER_LIBZIP.
tar.gz
286 tar xfz libzip-
$VER_LIBZIP.
tar.gz
287 cd libzip-
$VER_LIBZIP
288 cp -f ..
/config
/config.guess .
289 cp -f ..
/config
/config.sub .
295 # libusb-1.0 (needed for libsigrok)
296 $WGET http
://$SF_MIRROR/project
/libusb
/libusb-1.0
/libusb-
$VER_LIBUSB/libusb-
$VER_LIBUSB.
tar.bz2
297 tar xfj libusb-
$VER_LIBUSB.
tar.bz2
298 cd libusb-
$VER_LIBUSB
299 patch -p1 < ..
/..
/libusb-1.0.
patch
300 .
/configure
$C --disable-udev
305 # libftdi1 (needed for libsigrok)
306 $WGET http
://www.intra2net.com
/en
/developer
/libftdi
/download
/libftdi1-
$VER_LIBFTDI1.
tar.bz2
307 tar xfj libftdi1-
$VER_LIBFTDI1.
tar.bz2
308 cd libftdi1-
$VER_LIBFTDI1
309 cmake
$CM -DFTDIPP=no
-DDOCUMENTATION=no
-DEXAMPLES=no
-DFTDI_EEPROM=no
-DPYTHON_BINDINGS=no .
315 $GIT_CLONE git
://sigrok.org
/libserialport
325 # Build dependencies for libsigrok bindings if needed
327 if [ x
"$CPPFLAGS_STL" != x
]; then
329 # libsigc++ (needed for glibmm)
330 $WGET http
://ftp.gnome.org
/pub
/gnome
/sources
/libsigc
++/$VER_LIBSIGCXX_SHORT/libsigc
++-$VER_LIBSIGCXX.
tar.xz
331 tar xfJ libsigc
++-$VER_LIBSIGCXX.
tar.xz
332 cd libsigc
++-$VER_LIBSIGCXX
333 cp -f ..
/config
/config.guess build
334 cp -f ..
/config
/config.sub build
335 CPPFLAGS
="$CPPFLAGS_STL" LDFLAGS
="$LDFLAGS_STL -lgnustl_shared" .
/configure
--disable-documentation $C
340 # glibmm (needed for libsigrok bindings)
341 $WGET http
://ftp.gnome.org
/pub
/gnome
/sources
/glibmm
/$VER_GLIB_SHORT/glibmm-
$VER_GLIB.
tar.xz
342 tar xfJ glibmm-
$VER_GLIB.
tar.xz
344 CPPFLAGS
="$CPPFLAGS_STL" LDFLAGS
="$LDFLAGS_STL -lgnustl_shared" .
/configure
--disable-documentation $C
352 $GIT_CLONE git
://sigrok.org
/libsigrok
357 CPPFLAGS
="$CPPFLAGS_STL" LDFLAGS
="$LDFLAGS_STL" ..
/configure
$C $BINDINGS_CONFIG --datadir=/sdcard
359 make datadir
='$(datarootdir)' install
363 $GIT_CLONE git
://sigrok.org
/libsigrokdecode
374 $GIT_CLONE git
://sigrok.org
/sigrok-cli
384 # Check if we have all requirements to build PulseView:
386 if [ -z "$ANDROID_NDK" -o ! -d "$ANDROID_NDK" ]; then
387 echo "Android NDK not available, not building PulseView."
391 if [ -z "$ANDROID_SDK" -o \
392 ! -d "$ANDROID_SDK"/platforms
/android-8
-o \
393 ! -d "$ANDROID_SDK"/platforms
/android-10
-o \
394 ! -d "$ANDROID_SDK"/platforms
/android-11
-o \
395 ! -d "$ANDROID_SDK"/platforms
/android-14
-o \
396 ! -d "$ANDROID_SDK"/platforms
/android-16
]; then
397 echo "Android SDK with platforms 8 10 11 14 16 not available, not building PulseView."
401 if [ ! -e "${ANDROID_SDK}/tools/android" ]; then
402 echo "Essential Android build tools not available, not building PulseView."
406 NDK_HOST
=`"$ANDROID_NDK/ndk-build" -p 2>/dev/null | awk '$1 == "HOST_TAG" { print $3 }'`
408 # Boost (needed for PulseView)
409 $WGET http
://$SF_MIRROR/project
/boost
/boost
/$VER_BOOST/boost_
${VER_BOOST//./_}.
tar.bz2
410 tar xfj boost_
${VER_BOOST//./_}.
tar.bz2
411 cd boost_
${VER_BOOST//./_}
412 patch -p1 < ..
/..
/boost.
patch
413 CC
= .
/bootstrap.sh
--with-toolset=gcc
--with-libraries=filesystem
,system
,thread
--without-icu
414 echo "using gcc : $NDK_TOOLCHAIN_VERSION : \"${TOOLCHAIN_TRIPLET}-g++\" : <cxxflags>\"$SYSROOT -I$PREFIX/include $CPPFLAGS_STL\" <linkflags>\"$SYSROOT -L$PREFIX/lib $LDFLAGS_STL -lgnustl_shared\" ;" > user-config.jam
415 .
/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 $PARALLEL
418 # Qt (needed for PulseView)
419 $WGET http
://download.qt-project.org
/official_releases
/qt
/${VER_QT%.*}/${VER_QT}/single/qt-everywhere-opensource-src-${VER_QT}.
tar.gz
420 tar xfz qt-everywhere-opensource-src-
${VER_QT}.
tar.gz
421 cd qt-everywhere-opensource-src-
${VER_QT}
422 patch -p1 < ..
/..
/android-qt.
patch
423 CC
= CXX
= .
/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
424 make module-qtbase module-qtandroidextras module-qtsvg module-qtimageformats
$PARALLEL
428 # sigrok-androidutils
429 $GIT_CLONE git
://sigrok.org
/sigrok-androidutils
430 cd sigrok-androidutils
432 .
/configure
$C --with-android-sdk="${ANDROID_SDK}"
437 # Strip all shared libs to reduce size.
438 find $PREFIX -iname "*.so" -exec ${TOOLCHAIN_TRIPLET}-strip -S {} \
;
441 $GIT_CLONE git
://sigrok.org
/pulseview
444 make $PARALLEL VERBOSE
=1
446 ${TOOLCHAIN_TRIPLET}-strip -S libs
/$TARGET_ARCH/libpulseview.so
448 "${ANDROID_SDK}/tools/android" update project
-p .
-t android-14
-n PulseView