+# -----------------------------------------------------------------------------
+
+# Build host Python before we start messing with the environment.
+# Don't do parallel builds, this doesn't seem to work well.
+$WGET http://python.org/ftp/python/$VER_PYTHON/Python-$VER_PYTHON.tar.xz
+tar xJf Python-$VER_PYTHON.tar.xz
+cd Python-$VER_PYTHON
+./configure
+make python
+mv python hostpython
+cd ..
+
+# -----------------------------------------------------------------------------
+
+# We need to find tools in the toolchain.
+export PATH=$TOOLCHAIN/bin:$PATH
+
+# Tell pkg-config to only look for our cross-built stuff.
+export PKG_CONFIG_LIBDIR="$PREFIX/lib/pkgconfig"
+export -n PKG_CONFIG_PATH
+
+# Define some helper variables.
+C="--host=$TOOLCHAIN_TRIPLET --prefix=$PREFIX"
+CM="-Wno-dev -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake -DANDROID_ABI=${TARGET_ARCH} -DCMAKE_INSTALL_PREFIX=${PREFIX} -DANDROID_STANDALONE_TOOLCHAIN=${TOOLCHAIN}"
+
+# Look for STL, needed to build bindings
+NDK_TOOLCHAIN_VERSION=`${TOOLCHAIN_TRIPLET}-gcc --version | head -1 | sed -e 's/.* \([0-9]\+\.[0-9.]\+\)\( \|.*\)$/\1/'`
+STL_BASE="${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${NDK_TOOLCHAIN_VERSION}"
+if [ -d ${STL_BASE}/include ]; then
+ CPPFLAGS_STL="-I${STL_BASE}/include -I${STL_BASE}/libs/${TARGET_ARCH}/include"
+ LDFLAGS_STL="-L${STL_BASE}/libs/${TARGET_ARCH} -Wl,-rpath=${STL_BASE}/libs/${TARGET_ARCH}"
+ BINDINGS_CONFIG="--enable-bindings"
+else
+ echo "Warning: STL unavailable, libsigrok bindings will not be built."
+ CPPFLAGS_STL=
+ LDFLAGS_STL=
+ BINDINGS_CONFIG="--disable-bindings"
+fi
+
+# -----------------------------------------------------------------------------
+