# Maintainer (arch): Kyle Keen <keenerd@gmail.com?>
# Contributor: Dominik Heidler <dheidler@gmail.com>
# Contributor: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
pkgname=gnuradio-osmosdr-xtrx
_pkgname=gr-osmosdr
pkgver=r433.ge239811
pkgrel=2
pkgdesc="Source block for Funcube Dongle, RTL-SDR, USRP, OsmoSDR, BladeRF, HackRF and AirSpy devices"
url="http://sdr.osmocom.org/trac/"
arch=('armv7h' 'i686' 'x86_64')
license=('GPL')
depends=('gnuradio' 'gnuradio-iqbal' 'rtl-sdr' 'gnuradio-fcdproplus' 'hackrf' 'bladerf' 'airspy' 'libxtrx')
optdepends=('python2-opengl: osmocom_fft')
makedepends=('git' 'cmake' 'boost' 'python2-cheetah' 'swig')
conflicts=('gr-osmosdr-git' 'gnuradio-osmosdr')
commit=e239811df16e9bfdbfa904fab1b235d63ea724d8
source=("git://github.com/xtrx-sdr/gr-osmosdr.git#commit=$commit")
sha512sums=('SKIP')

# add support for miri, osmo?

pkgver() {
    cd $_pkgname
    echo r$(git rev-list --count HEAD).g$(git rev-parse --short HEAD)
}
prepare() {
  cd "$srcdir/$_pkgname"
  sed -i 's/python$/python2/' apps/osmocom_siggen_base.py
}

build() {
  cd "$srcdir/$_pkgname"
  mkdir build
  cd build
  cmake \
    -Wno-dev \
    -DCMAKE_BUILD_TYPE=Release \
    -DENABLE_XTRX=ON \
    -DPYTHON_EXECUTABLE=$(which python2) \
    -DPYTHON_INCLUDE_DIR=$(echo /usr/include/python2*) \
    -DPYTHON_LIBRARY=$(echo /usr/lib/libpython2.*.so) \
    -DCMAKE_INSTALL_PREFIX=/usr ../
  make
}

package() {
  cd "$srcdir/$_pkgname/build/"
  make DESTDIR="${pkgdir}" install
}
