# Maintainer: David Runge <dvzrv@archlinux.org>

pkgname=freewheeling
pkgver=0.6.6
pkgrel=3
pkgdesc="A live looper"
arch=('x86_64')
url="https://github.com/free-wheeling/freewheeling"
license=('GPL2')
groups=('pro-audio')
depends=('gcc-libs' 'glibc' 'libogg' 'libx11' 'libxml2' 'nettle' 'sdl'
'sdl_gfx' 'sdl_ttf')
makedepends=('alsa-lib' 'fluidsynth' 'gendesk' 'jack' 'liblo' 'libsndfile'
'libvorbis')
source=("$pkgname-$pkgver.tar.gz::https://github.com/free-wheeling/${pkgname}/archive/v${pkgver}.tar.gz"
        "$pkgname.jpg::https://raw.githubusercontent.com/wiki/free-wheeling/${pkgname}/${pkgname}-logo-1.jpg")
sha512sums=('c2b51b44f2dfc6e0f97a52f9be1c24b61516719b56eb3f641c5b29616f626c09f0d211ecef23b4857dabab04950e31c2ab45b73a1e4d4b7dfd534e3fffc09f57'
            '9f8386bff7b34c8ca44d0ad5b87d4e74a0b901a64e50bc5d8d99dd1f1ad10eb5b6b29f7b6fc8f106c425b2de0285517af3158472654abb2c914d48645dab0913')

prepare() {
  cd "$pkgname-$pkgver"
  autoreconf -vfi
  # XDG desktop file
  gendesk -n \
          --pkgname ${pkgname} \
          --pkgdesc "${pkgdesc}" \
          --name Freewheeling \
          --exec fweelin \
          --categories "Audio;Sequencer"
}

build() {
  cd "$pkgname-$pkgver"
  ./configure --prefix=/usr
  make
}

package() {
  depends+=('libasound.so' 'libfluidsynth.so' 'libjack.so' 'liblo.so'
  'libsndfile.so' 'libvorbis.so' 'libvorbisenc.so' 'libvorbisfile.so')
  cd "$pkgname-$pkgver"
  make DESTDIR="$pkgdir/" install
  # XDG desktop integration
  install -vDm 644 "${pkgname}.desktop" -t "${pkgdir}/usr/share/applications/"
  install -vDm 644 "../${pkgname}.jpg" -t "${pkgdir}/usr/share/pixmaps/"
  #docs
  install -vDm 644 {AUTHORS,ChangeLog,NEWS,README.md,THANKS,TUNING} \
    -t "${pkgdir}/usr/share/doc/${pkgname}"
  #examples
  install -vDm 644 examples/* -t "${pkgdir}/usr/share/doc/${pkgname}/examples"
}
