X-Git-Url: https://sigrok.org/gitweb/?p=sigrok-util.git;a=blobdiff_plain;f=cross-compile%2Fandroid%2Fsigrok-cross-android;h=57ab3d1f1115cc026c836a806accdb9fcfcfadc1;hp=2004fb40d8e94e9b73da747e8d5dd38e9663a0e6;hb=3bdccc5597806fd4d6fb057b0d4d05f030694c9a;hpb=510f5ccb4e0804b50a537cfacf6f742f0003c8ee diff --git a/cross-compile/android/sigrok-cross-android b/cross-compile/android/sigrok-cross-android index 2004fb4..57ab3d1 100755 --- a/cross-compile/android/sigrok-cross-android +++ b/cross-compile/android/sigrok-cross-android @@ -2,7 +2,7 @@ ## ## This file is part of the sigrok-util project. ## -## Copyright (C) 2013 Uwe Hermann +## Copyright (C) 2013-2014 Uwe Hermann ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -21,16 +21,19 @@ set -e +# The path where the NDK, SDK, and toolchains are located. +ANDROID_PATH=$HOME/android + # The path where the Android NDK is located. -ANDROID_NDK=$HOME/android/android-ndk-r9d +ANDROID_NDK=$ANDROID_PATH/android-ndk-r10c # The path where the Android SDK is located. -ANDROID_SDK=$HOME/android/android-sdk-linux +ANDROID_SDK=$ANDROID_PATH/android-sdk-linux # The path where your Android toolchain directory is located. -TOOLCHAIN=$HOME/android/android-arm-toolchain -# TOOLCHAIN=$HOME/android/android-mipsel-toolchain -# TOOLCHAIN=$HOME/android/android-i686-toolchain +TOOLCHAIN=$ANDROID_PATH/android-arm-toolchain +# TOOLCHAIN=$ANDROID_PATH/android-mipsel-toolchain +# TOOLCHAIN=$ANDROID_PATH/android-i686-toolchain # Select which Android toolchain to use. # Don't forget to also adapt TOOLCHAIN above if you change TOOLCHAIN_TRIPLET! @@ -52,18 +55,22 @@ PARALLEL="-j 2" # ----------------------------------------------------------------------------- VER_LIBICONV=1.14 -VER_GETTEXT=0.18.3 +VER_GETTEXT=0.19.2 VER_ZLIB=1.2.8 -VER_PCRE=8.33 -VER_LIBFFI=3.0.13 -VER_GLIB=2.38.2 -VER_GLIB_SHORT=2.38 -VER_LIBZIP=0.11.1 +VER_PCRE=8.35 +VER_LIBFFI=3.1 +VER_GLIB=2.41.3 +VER_GLIB_SHORT=2.41 +VER_LIBSIGCXX=2.3.2 +VER_LIBSIGCXX_SHORT=2.3 +VER_LIBZIP=0.11.2 VER_LIBFTDI1=1.1 -VER_LIBUSBX=1.0.17 +VER_LIBUSB=1.0.19 VER_PYTHON=3.3.3 VER_BOOST=1.55.0 VER_QT=5.3.1 +VER_NDK=10c +VER_SDK=23.0.2 SF_MIRROR=switch.dl.sourceforge.net @@ -79,6 +86,33 @@ esac # ----------------------------------------------------------------------------- +# Get the Android NDK and SDK, install required packages and toolchains. +if [ "x$1" = "xprepare" ]; then + mkdir -p $ANDROID_PATH + cd $ANDROID_PATH + + # NDK + $WGET http://dl.google.com/android/ndk/android-ndk-r$VER_NDK-linux-x86.bin + chmod 700 android-ndk-r$VER_NDK-linux-x86.bin + ./android-ndk-r$VER_NDK-linux-x86.bin + cd android-ndk-r$VER_NDK + ./build/tools/make-standalone-toolchain.sh --platform=android-16 \ + --toolchain=arm-linux-androideabi-4.9 \ + --install-dir=$ANDROID_PATH/android-arm-toolchain + cd .. + + # SDK + $WGET http://dl.google.com/android/android-sdk_r$VER_SDK-linux.tgz + tar xfz android-sdk_r$VER_SDK-linux.tgz + cd android-sdk-linux + ./tools/android update sdk --no-ui --filter platform-tools,build-tools-21.1.0,android-8,android-10,android-11,android-14,android-16 + cd .. + + exit +fi + +# ----------------------------------------------------------------------------- + # Remove build directory contents (if any) and create a new build dir. rm -rf $BUILDDIR mkdir $BUILDDIR @@ -89,7 +123,7 @@ cd $BUILDDIR # 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 +tar xfJ Python-$VER_PYTHON.tar.xz cd Python-$VER_PYTHON ./configure make python @@ -109,6 +143,20 @@ export -n PKG_CONFIG_PATH 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 + # ----------------------------------------------------------------------------- # Get the latest versions of config.guess/config.sub that know about Android. @@ -164,7 +212,7 @@ cd ../.. # zlib (needed for glib and libzip) $WGET http://zlib.net/zlib-$VER_ZLIB.tar.gz -tar xfvz zlib-$VER_ZLIB.tar.gz +tar xfz zlib-$VER_ZLIB.tar.gz cd zlib-$VER_ZLIB # Note: zlib's configure doesn't understand --host, we need to pass $CC. CC=$TOOLCHAIN_TRIPLET-gcc ./configure --prefix=$PREFIX @@ -174,7 +222,7 @@ cd .. # pcre (needed for glib) $WGET ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-$VER_PCRE.tar.gz -tar xfvz pcre-$VER_PCRE.tar.gz +tar xfz pcre-$VER_PCRE.tar.gz cd pcre-$VER_PCRE ./configure $C --disable-cpp make $PARALLEL @@ -192,7 +240,7 @@ cd .. # glib (needed for libsigrok) $WGET http://ftp.gnome.org/pub/gnome/sources/glib/$VER_GLIB_SHORT/glib-$VER_GLIB.tar.xz -tar xJf glib-$VER_GLIB.tar.xz +tar xfJ glib-$VER_GLIB.tar.xz cd glib-$VER_GLIB ./autogen.sh # Note: Manual LDFLAGS/CPPFLAGS needed for libiconv, rest uses pkg-config. @@ -213,9 +261,9 @@ make install cd .. # libusb-1.0 (needed for libsigrok) -$WGET http://$SF_MIRROR/project/libusbx/releases/$VER_LIBUSBX/source/libusbx-$VER_LIBUSBX.tar.bz2 -tar xfj libusbx-$VER_LIBUSBX.tar.bz2 -cd libusbx-$VER_LIBUSBX +$WGET http://$SF_MIRROR/project/libusb/libusb-1.0/libusb-$VER_LIBUSB/libusb-$VER_LIBUSB.tar.bz2 +tar xfj libusb-$VER_LIBUSB.tar.bz2 +cd libusb-$VER_LIBUSB patch -p1 < ../../libusb-1.0.patch ./configure $C --disable-udev make $PARALLEL @@ -226,7 +274,7 @@ cd .. $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 . +cmake $CM -DFTDIPP=no -DDOCUMENTATION=no -DEXAMPLES=no -DFTDI_EEPROM=no -DPYTHON_BINDINGS=no . make $PARALLEL make install cd .. @@ -235,37 +283,71 @@ cd .. $GIT_CLONE git://sigrok.org/libserialport cd libserialport ./autogen.sh -./configure $C +mkdir build +cd build +../configure $C make $PARALLEL V=1 make install -cd .. +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 -./configure $C --datadir=/sdcard +mkdir build +cd build +CPPFLAGS="$CPPFLAGS_STL" LDFLAGS="$LDFLAGS_STL" ../configure $C $BINDINGS_CONFIG --datadir=/sdcard make $PARALLEL V=1 -make install -cd .. +make datadir='$(datarootdir)' install +cd ../.. # libsigrokdecode $GIT_CLONE git://sigrok.org/libsigrokdecode cd libsigrokdecode ./autogen.sh -./configure $C +mkdir build +cd build +../configure $C make $PARALLEL V=1 make install -cd .. +cd ../.. # sigrok-cli $GIT_CLONE git://sigrok.org/sigrok-cli cd sigrok-cli ./autogen.sh -./configure $C +mkdir build +cd build +../configure $C make $PARALLEL V=1 make install -cd .. +cd ../.. # Check if we have all requirements to build PulseView: @@ -289,7 +371,6 @@ if [ ! -e "${ANDROID_SDK}/tools/android" ]; then exit 0 fi -NDK_TOOLCHAIN_VERSION=`${TOOLCHAIN_TRIPLET}-gcc --version | head -1 | sed -e 's/.* \([0-9]\+\.[0-9.]\+\)\( \|.*\)$/\1/'` NDK_HOST=`"$ANDROID_NDK/ndk-build" -p 2>/dev/null | awk '$1 == "HOST_TAG" { print $3 }'` # Boost (needed for PulseView) @@ -298,7 +379,7 @@ tar xfj boost_${VER_BOOST//./_}.tar.bz2 cd boost_${VER_BOOST//./_} patch -p1 < ../../boost.patch ./bootstrap.sh --with-toolset=gcc --with-libraries=filesystem,system --without-icu -echo "using gcc : $NDK_TOOLCHAIN_VERSION : \"${TOOLCHAIN_TRIPLET}-g++\" : \"-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\" \"-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 +echo "using gcc : $NDK_TOOLCHAIN_VERSION : \"${TOOLCHAIN_TRIPLET}-g++\" : \"-I$PREFIX/include $CPPFLAGS_STL\" \"-L$PREFIX/lib $LDFLAGS_STL -lgnustl_shared\" ;" > user-config.jam ./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 cd .. @@ -321,11 +402,16 @@ make $PARALLEL V=1 make install cd .. +# Strip all shared libs to reduce size. +find $PREFIX -iname "*.so" -exec ${TOOLCHAIN_TRIPLET}-strip -S {} \; + # PulseView $GIT_CLONE git://sigrok.org/pulseview cd pulseview cmake $CM -DANDROID_STL_PATH=${ANDROID_NDK}/sources/cxx-stl . make $PARALLEL VERBOSE=1 +make install +${TOOLCHAIN_TRIPLET}-strip -S libs/$TARGET_ARCH/libpulseview.so cd android "${ANDROID_SDK}/tools/android" update project -p . -t android-14 -n PulseView ant debug