+# libftdi1 (needed for libsigrok)
+$WGET http://www.intra2net.com/en/developer/libftdi/download/libftdi1-$VER_LIBFTDI1.tar.bz2
+tar xfj libftdi1-$VER_LIBFTDI1.tar.bz2
+cd libftdi1-$VER_LIBFTDI1
+cmake $CM -DFTDIPP=no -DDOCUMENTATION=no -DEXAMPLES=no -DFTDI_EEPROM=no -DPYTHON_BINDINGS=no .
+make $PARALLEL
+make install
+cd ..
+
+# libserialport
+$GIT_CLONE git://sigrok.org/libserialport
+cd libserialport
+./autogen.sh
+mkdir build
+cd build
+../configure $C
+make $PARALLEL V=1
+make install
+cd ../..
+
+# Build dependencies for libsigrok bindings if needed
+
+if [ x"$CPPFLAGS_STL" != x ]; then
+
+ # libsigc++ (needed for glibmm)
+ $WGET http://ftp.gnome.org/pub/gnome/sources/libsigc++/$VER_LIBSIGCXX_SHORT/libsigc++-$VER_LIBSIGCXX.tar.xz
+ tar xfJ libsigc++-$VER_LIBSIGCXX.tar.xz
+ cd libsigc++-$VER_LIBSIGCXX
+ cp -f ../config/config.guess build
+ cp -f ../config/config.sub build
+ CPPFLAGS="$CPPFLAGS_STL" LDFLAGS="$LDFLAGS_STL -lgnustl_shared" ./configure --disable-documentation $C
+ make $PARALLEL
+ make install
+ cd ..
+
+ # glibmm (needed for libsigrok bindings)
+ $WGET http://ftp.gnome.org/pub/gnome/sources/glibmm/$VER_GLIB_SHORT/glibmm-$VER_GLIB.tar.xz
+ tar xfJ glibmm-$VER_GLIB.tar.xz
+ cd glibmm-$VER_GLIB
+ CPPFLAGS="$CPPFLAGS_STL" LDFLAGS="$LDFLAGS_STL -lgnustl_shared" ./configure --disable-documentation $C
+ make $PARALLEL
+ make install
+ cd ..
+
+fi
+
+# libsigrok
+$GIT_CLONE git://sigrok.org/libsigrok
+cd libsigrok
+./autogen.sh
+mkdir build
+cd build
+CPPFLAGS="$CPPFLAGS_STL" LDFLAGS="$LDFLAGS_STL" ../configure $C $BINDINGS_CONFIG --datadir=/sdcard
+make $PARALLEL V=1
+make datadir='$(datarootdir)' install
+cd ../..
+
+# libsigrokdecode
+$GIT_CLONE git://sigrok.org/libsigrokdecode
+cd libsigrokdecode
+./autogen.sh
+mkdir build
+cd build
+../configure $C
+make $PARALLEL V=1
+make install
+cd ../..
+
+# sigrok-cli
+$GIT_CLONE git://sigrok.org/sigrok-cli
+cd sigrok-cli
+./autogen.sh
+mkdir build
+cd build
+../configure $C
+make $PARALLEL V=1
+make install
+cd ../..
+
+# Check if we have all requirements to build PulseView:
+
+if [ -z "$ANDROID_NDK" -o ! -d "$ANDROID_NDK" ]; then
+ echo "Android NDK not available, not building PulseView."
+ exit 0
+fi
+
+if [ -z "$ANDROID_SDK" -o \
+ ! -d "$ANDROID_SDK"/platforms/android-8 -o \
+ ! -d "$ANDROID_SDK"/platforms/android-10 -o \
+ ! -d "$ANDROID_SDK"/platforms/android-11 -o \
+ ! -d "$ANDROID_SDK"/platforms/android-14 -o \
+ ! -d "$ANDROID_SDK"/platforms/android-16 ]; then
+ echo "Android SDK with platforms 8 10 11 14 16 not available, not building PulseView."
+ exit 0
+fi
+
+if [ ! -e "${ANDROID_SDK}/tools/android" ]; then
+ echo "Essential Android build tools not available, not building PulseView."
+ exit 0
+fi
+
+NDK_HOST=`"$ANDROID_NDK/ndk-build" -p 2>/dev/null | awk '$1 == "HOST_TAG" { print $3 }'`
+
+# Boost (needed for PulseView)
+$WGET http://$SF_MIRROR/project/boost/boost/$VER_BOOST/boost_${VER_BOOST//./_}.tar.bz2
+tar xfj boost_${VER_BOOST//./_}.tar.bz2
+cd boost_${VER_BOOST//./_}
+CC= ./bootstrap.sh --with-toolset=gcc --with-libraries=filesystem,system,thread --without-icu
+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
+./b2 -q -d+2 --ignore-site-config --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
+cd ..
+
+# Qt (needed for PulseView)
+$WGET http://download.qt-project.org/official_releases/qt/${VER_QT%.*}/${VER_QT}/single/qt-everywhere-opensource-src-${VER_QT}.tar.gz
+tar xfz qt-everywhere-opensource-src-${VER_QT}.tar.gz
+cd qt-everywhere-opensource-src-${VER_QT}
+patch -p1 < ../../android-qt.patch
+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
+make module-qtbase module-qtandroidextras module-qtsvg module-qtimageformats $PARALLEL