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 Android NDK is located.
25 ANDROID_NDK=$HOME/android/android-ndk-r10c
27 # The path where the Android SDK is located.
28 ANDROID_SDK=$HOME/android/android-sdk-linux
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
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
41 # The path where the cross-compiled packages will be installed.
42 PREFIX=$HOME/sr_android
44 # The path where to download files to and where to build packages.
47 # Edit this to enable/disable/modify parallel compiles.
50 # You usually don't need to change anything below this line.
52 # -----------------------------------------------------------------------------
62 VER_LIBSIGCXX_SHORT=2.3
70 SF_MIRROR=switch.dl.sourceforge.net
73 GIT_CLONE="git clone --depth=1"
75 case "$TOOLCHAIN_TRIPLET" in
76 arm*) TARGET_ARCH=armeabi;;
77 mips*) TARGET_ARCH=mips;;
78 i686*) TARGET_ARCH=x86;;
79 *) echo >&2 "Unknown prefix for TOOLCHAIN_TRIPLET."; exit 1;;
82 # -----------------------------------------------------------------------------
84 # Remove build directory contents (if any) and create a new build dir.
89 # -----------------------------------------------------------------------------
91 # Build host Python before we start messing with the environment.
92 # Don't do parallel builds, this doesn't seem to work well.
93 $WGET http://python.org/ftp/python/$VER_PYTHON/Python-$VER_PYTHON.tar.xz
94 tar xfJ Python-$VER_PYTHON.tar.xz
101 # -----------------------------------------------------------------------------
103 # We need to find tools in the toolchain.
104 export PATH=$TOOLCHAIN/bin:$PATH
106 # Tell pkg-config to only look for our cross-built stuff.
107 export PKG_CONFIG_LIBDIR="$PREFIX/lib/pkgconfig"
108 export -n PKG_CONFIG_PATH
110 # Define some helper variables.
111 C="--host=$TOOLCHAIN_TRIPLET --prefix=$PREFIX"
112 CM="-Wno-dev -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake -DANDROID_ABI=${TARGET_ARCH} -DCMAKE_INSTALL_PREFIX=${PREFIX} -DANDROID_STANDALONE_TOOLCHAIN=${TOOLCHAIN}"
114 # Look for STL, needed to build bindings
115 NDK_TOOLCHAIN_VERSION=`${TOOLCHAIN_TRIPLET}-gcc --version | head -1 | sed -e 's/.* \([0-9]\+\.[0-9.]\+\)\( \|.*\)$/\1/'`
116 STL_BASE="${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${NDK_TOOLCHAIN_VERSION}"
117 if [ -d ${STL_BASE}/include ]; then
118 CPPFLAGS_STL="-I${STL_BASE}/include -I${STL_BASE}/libs/${TARGET_ARCH}/include"
119 LDFLAGS_STL="-L${STL_BASE}/libs/${TARGET_ARCH} -Wl,-rpath=${STL_BASE}/libs/${TARGET_ARCH}"
120 BINDINGS_CONFIG="--enable-bindings"
122 echo "Warning: STL unavailable, libsigrok bindings will not be built."
125 BINDINGS_CONFIG="--disable-bindings"
128 # -----------------------------------------------------------------------------
130 # Get the latest versions of config.guess/config.sub that know about Android.
131 $GIT_CLONE git://git.savannah.gnu.org/config.git
133 # Get a toolchain for cmake that knows about Android.
134 $WGET https://android-cmake.googlecode.com/hg/toolchain/android.toolchain.cmake
135 patch < ../android.toolchain.cmake.patch android.toolchain.cmake
137 # -----------------------------------------------------------------------------
139 # Python (needed for libsigrokdecode)
140 # Don't do parallel Python builds, this doesn't seem to work well.
141 cd Python-$VER_PYTHON
144 patch -p1 < ../../Python-$VER_PYTHON.patch
145 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
146 sed -i "s/^#zlib/zlib/g" Modules/Setup
147 make PYTHON_FOR_BUILD=./hostpython install
150 # libiconv (needed for glib)
151 $WGET http://ftp.gnu.org/pub/gnu/libiconv/libiconv-$VER_LIBICONV.tar.gz
152 tar xfz libiconv-$VER_LIBICONV.tar.gz
153 cd libiconv-$VER_LIBICONV
154 cp -f ../config/config.guess build-aux
155 cp -f ../config/config.sub build-aux
156 cp -f ../config/config.guess libcharset/build-aux
157 cp -f ../config/config.sub libcharset/build-aux
158 ./configure $C --enable-shared
159 make lib/localcharset.h
167 test -d $PREFIX/include || mkdir $PREFIX/include
168 cp include/iconv.h.inst $PREFIX/include/iconv.h
171 # gettext (needed for glib)
172 $WGET http://ftp.gnu.org/pub/gnu/gettext/gettext-$VER_GETTEXT.tar.gz
173 tar xfz gettext-$VER_GETTEXT.tar.gz
174 cd gettext-$VER_GETTEXT
175 ./configure $C --enable-shared --disable-libasprintf
181 # zlib (needed for glib and libzip)
182 $WGET http://zlib.net/zlib-$VER_ZLIB.tar.gz
183 tar xfz zlib-$VER_ZLIB.tar.gz
185 # Note: zlib's configure doesn't understand --host, we need to pass $CC.
186 CC=$TOOLCHAIN_TRIPLET-gcc ./configure --prefix=$PREFIX
191 # pcre (needed for glib)
192 $WGET ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-$VER_PCRE.tar.gz
193 tar xfz pcre-$VER_PCRE.tar.gz
195 ./configure $C --disable-cpp
200 # libffi (needed for glib)
201 $WGET ftp://sourceware.org/pub/libffi/libffi-$VER_LIBFFI.tar.gz
202 tar xfz libffi-$VER_LIBFFI.tar.gz
203 cd libffi-$VER_LIBFFI
209 # glib (needed for libsigrok)
210 $WGET http://ftp.gnome.org/pub/gnome/sources/glib/$VER_GLIB_SHORT/glib-$VER_GLIB.tar.xz
211 tar xfJ glib-$VER_GLIB.tar.xz
214 # Note: Manual LDFLAGS/CPPFLAGS needed for libiconv, rest uses pkg-config.
215 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
220 # libzip (needed for libsigrok)
221 $WGET http://www.nih.at/libzip/libzip-$VER_LIBZIP.tar.gz
222 tar xfz libzip-$VER_LIBZIP.tar.gz
223 cd libzip-$VER_LIBZIP
224 cp -f ../config/config.guess .
225 cp -f ../config/config.sub .
231 # libusb-1.0 (needed for libsigrok)
232 $WGET http://$SF_MIRROR/project/libusb/libusb-1.0/libusb-$VER_LIBUSB/libusb-$VER_LIBUSB.tar.bz2
233 tar xfj libusb-$VER_LIBUSB.tar.bz2
234 cd libusb-$VER_LIBUSB
235 patch -p1 < ../../libusb-1.0.patch
236 ./configure $C --disable-udev
241 # libftdi1 (needed for libsigrok)
242 $WGET http://www.intra2net.com/en/developer/libftdi/download/libftdi1-$VER_LIBFTDI1.tar.bz2
243 tar xfj libftdi1-$VER_LIBFTDI1.tar.bz2
244 cd libftdi1-$VER_LIBFTDI1
245 cmake $CM -DFTDIPP=no -DDOCUMENTATION=no -DEXAMPLES=no -DFTDI_EEPROM=no -DPYTHON_BINDINGS=no .
251 $GIT_CLONE git://sigrok.org/libserialport
261 # Build dependencies for libsigrok bindings if needed
263 if [ x"$CPPFLAGS_STL" != x ]; then
265 # libsigc++ (needed for glibmm)
266 $WGET http://ftp.gnome.org/pub/gnome/sources/libsigc++/$VER_LIBSIGCXX_SHORT/libsigc++-$VER_LIBSIGCXX.tar.xz
267 tar xfJ libsigc++-$VER_LIBSIGCXX.tar.xz
268 cd libsigc++-$VER_LIBSIGCXX
269 cp -f ../config/config.guess build
270 cp -f ../config/config.sub build
271 CPPFLAGS="$CPPFLAGS_STL" LDFLAGS="$LDFLAGS_STL -lgnustl_shared" ./configure --disable-documentation $C
276 # glibmm (needed for libsigrok bindings)
277 $WGET http://ftp.gnome.org/pub/gnome/sources/glibmm/$VER_GLIB_SHORT/glibmm-$VER_GLIB.tar.xz
278 tar xfJ glibmm-$VER_GLIB.tar.xz
280 CPPFLAGS="$CPPFLAGS_STL" LDFLAGS="$LDFLAGS_STL -lgnustl_shared" ./configure --disable-documentation $C
288 $GIT_CLONE git://sigrok.org/libsigrok
293 CPPFLAGS="$CPPFLAGS_STL" LDFLAGS="$LDFLAGS_STL" ../configure $C $BINDINGS_CONFIG --datadir=/sdcard
295 make datadir='$(datarootdir)' install
299 $GIT_CLONE git://sigrok.org/libsigrokdecode
310 $GIT_CLONE git://sigrok.org/sigrok-cli
320 # Check if we have all requirements to build PulseView:
322 if [ -z "$ANDROID_NDK" -o ! -d "$ANDROID_NDK" ]; then
323 echo "Android NDK not available, not building PulseView."
327 if [ -z "$ANDROID_SDK" -o \
328 ! -d "$ANDROID_SDK"/platforms/android-8 -o \
329 ! -d "$ANDROID_SDK"/platforms/android-10 -o \
330 ! -d "$ANDROID_SDK"/platforms/android-11 -o \
331 ! -d "$ANDROID_SDK"/platforms/android-14 -o \
332 ! -d "$ANDROID_SDK"/platforms/android-16 ]; then
333 echo "Android SDK with platforms 8 10 11 14 16 not available, not building PulseView."
337 if [ ! -e "${ANDROID_SDK}/tools/android" ]; then
338 echo "Essential Android build tools not available, not building PulseView."
342 NDK_HOST=`"$ANDROID_NDK/ndk-build" -p 2>/dev/null | awk '$1 == "HOST_TAG" { print $3 }'`
344 # Boost (needed for PulseView)
345 $WGET http://$SF_MIRROR/project/boost/boost/$VER_BOOST/boost_${VER_BOOST//./_}.tar.bz2
346 tar xfj boost_${VER_BOOST//./_}.tar.bz2
347 cd boost_${VER_BOOST//./_}
348 patch -p1 < ../../boost.patch
349 ./bootstrap.sh --with-toolset=gcc --with-libraries=filesystem,system --without-icu
350 echo "using gcc : $NDK_TOOLCHAIN_VERSION : \"${TOOLCHAIN_TRIPLET}-g++\" : <cxxflags>\"-I$PREFIX/include $CPPFLAGS_STL\" <linkflags>\"-L$PREFIX/lib $LDFLAGS_STL -lgnustl_shared\" ;" > user-config.jam
351 ./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
354 # Qt (needed for PulseView)
355 $WGET http://download.qt-project.org/official_releases/qt/${VER_QT%.*}/${VER_QT}/single/qt-everywhere-opensource-src-${VER_QT}.tar.gz
356 tar xfz qt-everywhere-opensource-src-${VER_QT}.tar.gz
357 cd qt-everywhere-opensource-src-${VER_QT}
358 patch -p1 < ../../android-qt.patch
359 ./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
360 make module-qtbase module-qtandroidextras module-qtsvg module-qtimageformats $PARALLEL
364 # sigrok-androidutils
365 $GIT_CLONE git://sigrok.org/sigrok-androidutils
366 cd sigrok-androidutils
368 ./configure $C --with-android-sdk="${ANDROID_SDK}"
374 $GIT_CLONE git://sigrok.org/pulseview
376 cmake $CM -DANDROID_STL_PATH=${ANDROID_NDK}/sources/cxx-stl .
377 make $PARALLEL VERBOSE=1
379 "${ANDROID_SDK}/tools/android" update project -p . -t android-14 -n PulseView