3 ## This file is part of the sigrok-util project.
5 ## Copyright (C) 2013 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 Android NDK is located.
25 ANDROID_NDK=$HOME/android/android-ndk-r9d
27 # The path where 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 # -----------------------------------------------------------------------------
68 SF_MIRROR=switch.dl.sourceforge.net
71 GIT_CLONE="git clone --depth=1"
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;;
80 # -----------------------------------------------------------------------------
82 # Remove build directory contents (if any) and create a new build dir.
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
96 # -----------------------------------------------------------------------------
98 # We need to find tools in the toolchain.
99 export PATH=$TOOLCHAIN/bin:$PATH
101 # Tell pkg-config to only look for our cross-built stuff.
102 export PKG_CONFIG_LIBDIR="$PREFIX/lib/pkgconfig"
103 export -n PKG_CONFIG_PATH
105 # Define some helper variables.
106 C="--host=$TOOLCHAIN_TRIPLET --prefix=$PREFIX"
107 CM="-Wno-dev -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake -DANDROID_ABI=${TARGET_ARCH} -DCMAKE_INSTALL_PREFIX=${PREFIX} -DANDROID_STANDALONE_TOOLCHAIN=${TOOLCHAIN}"
109 # Get the latest versions of config.guess/config.sub that know about Android.
110 $GIT_CLONE git://git.savannah.gnu.org/config.git
112 # Get a toolchain for cmake that knows about Android
113 wget https://android-cmake.googlecode.com/hg/toolchain/android.toolchain.cmake
114 patch < ../android.toolchain.cmake.patch android.toolchain.cmake
116 # -----------------------------------------------------------------------------
118 # Python (needed for libsigrokdecode)
119 cd Python-$VER_PYTHON
122 patch -p1 < ../../Python-$VER_PYTHON.patch
123 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
124 sed -i "s/^#zlib/zlib/g" Modules/Setup
125 make PYTHON_FOR_BUILD=./hostpython install $PARALLEL
128 # libiconv (needed for glib)
129 $WGET http://ftp.gnu.org/pub/gnu/libiconv/libiconv-$VER_LIBICONV.tar.gz
130 tar xfz libiconv-$VER_LIBICONV.tar.gz
131 cd libiconv-$VER_LIBICONV
132 cp -f ../config/config.guess build-aux
133 cp -f ../config/config.sub build-aux
134 cp -f ../config/config.guess libcharset/build-aux
135 cp -f ../config/config.sub libcharset/build-aux
136 ./configure $C --enable-shared
137 make lib/localcharset.h
145 test -d $PREFIX/include || mkdir $PREFIX/include
146 cp include/iconv.h.inst $PREFIX/include/iconv.h
149 # gettext (needed for glib)
150 $WGET http://ftp.gnu.org/pub/gnu/gettext/gettext-$VER_GETTEXT.tar.gz
151 tar xfz gettext-$VER_GETTEXT.tar.gz
152 cd gettext-$VER_GETTEXT
153 ./configure $C --enable-shared --disable-libasprintf
159 # zlib (needed for glib and libzip)
160 $WGET http://zlib.net/zlib-$VER_ZLIB.tar.gz
161 tar xfvz zlib-$VER_ZLIB.tar.gz
163 # Note: zlib's configure doesn't understand --host, we need to pass $CC.
164 CC=$TOOLCHAIN_TRIPLET-gcc ./configure --prefix=$PREFIX
169 # pcre (needed for glib)
170 $WGET ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-$VER_PCRE.tar.gz
171 tar xfvz pcre-$VER_PCRE.tar.gz
173 ./configure $C --disable-cpp
178 # libffi (needed for glib)
179 $WGET ftp://sourceware.org/pub/libffi/libffi-$VER_LIBFFI.tar.gz
180 tar xfz libffi-$VER_LIBFFI.tar.gz
181 cd libffi-$VER_LIBFFI
188 $WGET http://ftp.gnome.org/pub/gnome/sources/glib/$VER_GLIB_SHORT/glib-$VER_GLIB.tar.xz
189 tar xJf glib-$VER_GLIB.tar.xz
192 # Note: Manual LDFLAGS/CPPFLAGS needed for libiconv, rest uses pkg-config.
193 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
199 $WGET http://www.nih.at/libzip/libzip-$VER_LIBZIP.tar.gz
200 tar xfz libzip-$VER_LIBZIP.tar.gz
201 cd libzip-$VER_LIBZIP
202 cp -f ../config/config.guess .
203 cp -f ../config/config.sub .
210 $WGET http://$SF_MIRROR/project/libusbx/releases/$VER_LIBUSBX/source/libusbx-$VER_LIBUSBX.tar.bz2
211 tar xfj libusbx-$VER_LIBUSBX.tar.bz2
212 cd libusbx-$VER_LIBUSBX
213 patch -p1 < ../../libusb-1.0.patch
214 ./configure $C --disable-udev
220 $WGET http://www.intra2net.com/en/developer/libftdi/download/libftdi1-$VER_LIBFTDI1.tar.bz2
221 tar xfj libftdi1-$VER_LIBFTDI1.tar.bz2
222 cd libftdi1-$VER_LIBFTDI1
229 $GIT_CLONE git://sigrok.org/libserialport
238 $GIT_CLONE git://sigrok.org/libsigrok
241 ./configure $C --datadir=/sdcard
247 $GIT_CLONE git://sigrok.org/libsigrokdecode
256 $GIT_CLONE git://sigrok.org/sigrok-cli
265 # Check if we have kit to build PulseView
267 if [ -z "$ANDROID_NDK" -o ! -d "$ANDROID_NDK" ]; then
268 echo "Android NDK not available, not building PulseView"
272 if [ -z "$ANDROID_SDK" -o ! -d "$ANDROID_SDK"/platforms/android-8 -o \
273 ! -d "$ANDROID_SDK"/platforms/android-10 -o \
274 ! -d "$ANDROID_SDK"/platforms/android-11 -o \
275 ! -d "$ANDROID_SDK"/platforms/android-14 -o \
276 ! -d "$ANDROID_SDK"/platforms/android-16 ]; then
277 echo "Android SDK with platforms 8 10 11 14 16 not available, not building PulseView"
281 ANDROID_TOOLS=${ANDROID_SDK}/tools
283 if [ ! -e "$ANDROID_TOOLS/android" ]; then
284 echo "Essential Android build tools not available, not building PulseView"
288 NDK_TOOLCHAIN_VERSION=`${TOOLCHAIN_TRIPLET}-gcc --version | head -1 | sed -e 's/.* \([0-9]\+\.[0-9.]\+\)\( \|.*\)$/\1/'`
289 NDK_HOST=`"$ANDROID_NDK/ndk-build" -p 2>/dev/null | awk '$1 == "HOST_TAG" { print $3 }'`
292 # boost (needed for PulseView)
293 $WGET http://$SF_MIRROR/project/boost/boost/$VER_BOOST/boost_${VER_BOOST//./_}.tar.bz2
294 tar xfj boost_${VER_BOOST//./_}.tar.bz2
295 cd boost_${VER_BOOST//./_}
296 patch -p1 < ../../boost.patch
297 ./bootstrap.sh --with-toolset=gcc --with-libraries=filesystem,system --without-icu
298 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} -Wl,-rpath=${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${NDK_TOOLCHAIN_VERSION}/libs/${TARGET_ARCH} -lgnustl_shared\" ;" > user-config.jam
299 ./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
302 # qt (needed for PulseView)
303 $WGET http://download.qt-project.org/official_releases/qt/${VER_QT%.*}/${VER_QT}/single/qt-everywhere-opensource-src-${VER_QT}.tar.gz
304 tar xfz qt-everywhere-opensource-src-${VER_QT}.tar.gz
305 cd qt-everywhere-opensource-src-${VER_QT}
306 patch -p1 < ../../android-qt.patch
307 ./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
312 # sigrok-androidutils
313 $GIT_CLONE git://github.com/zeldin/sigrok-androidutils
314 cd sigrok-androidutils
316 ./configure $C --with-android-sdk="${ANDROID_SDK}"
322 $GIT_CLONE -b android git://github.com/zeldin/pulseview
323 # $GIT_CLONE git://sigrok.org/pulseview
325 cmake $CM -DANDROID_STL_PATH=${ANDROID_NDK}/sources/cxx-stl .
328 "$ANDROID_TOOLS/android" update project -p . -t android-14 -n PulseView