# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: speps <speps at aur dot archlinux dot org>
# Contributor: Alessio Biancalana <dottorblaster@gmail.com>

pkgname=amsynth
pkgver=1.12.2
pkgrel=1
pkgdesc="Analogue Modeling SYNTHesizer"
arch=('x86_64')
url="https://amsynth.github.io/"
license=('GPL2')
groups=('dssi-plugins' 'lv2-plugins' 'pro-audio' 'vst-plugins')
depends=('cairo' 'gcc-libs' 'glibc')
makedepends=('atk' 'autoconf-archive' 'dssi' 'fontconfig' 'freetype2'
'gdk-pixbuf2' 'glib2' 'gtk2' 'harfbuzz' 'intltool' 'jack' 'ladspa' 'liblo'
'lv2' 'pandoc')
checkdepends=('lv2lint')
optdepends=('alsa-lib: for standalone application'
            'dssi-host: for DSSI plugin'
            'jack: for standalone application'
            'liblo: for standalone application and DSSI plugin'
            'new-session-manager: for session management with the standalone application'
            'lv2-host: for LV2 plugin'
            'vst-host: for VST plugin')
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/amsynth/amsynth/archive/release-${pkgver}.tar.gz")
sha512sums=('6e272f562f1318ee936ec7f175ddacc0fda1021b350693aa7d9c7e1676a6ec657beb767e9fefdfe6e9869579445cbcda9ffe3f5fc1ad2be336a26ca8c93e7872')
b2sums=('726348a845a71b7c9bdd0fbcafbb82f90d9afa3379b92a55204888b0c98c753c3808fefbbcfae875139600e0b38b950da16ebe9828acb4309427d5ee7ae8ff99')

prepare() {
  mv -v "${pkgname}-release-${pkgver}" "${pkgname}-${pkgver}"
  cd "${pkgname}-${pkgver}"
  autoreconf -vfi
  intltoolize -f
}

build() {
  cd "${pkgname}-${pkgver}"
  ./configure --prefix=/usr \
              --with-alsa \
              --with-jack \
              --with-dssi \
              --with-lv2 \
              --with-vst \
              --with-pandoc
  make
}

check() {
  cd "${pkgname}-${pkgver}"
  cp .libs/${pkgname}_lv2*.so data/${pkgname}.lv2/
  lv2lint -Mpack \
          -I "data/${pkgname}.lv2" \
          "http://code.google.com/p/amsynth/amsynth"
}

package() {
  depends+=('libatk-1.0.so' 'libfontconfig.so' 'libfreetype.so'
  'libgdk_pixbuf-2.0.so' 'libgdk-x11-2.0.so' 'libgio-2.0.so' 'libglib-2.0.so'
  'libgobject-2.0.so' 'libgtk-x11-2.0.so' 'libharfbuzz.so'
  'libpangocairo-1.0.so' 'libpangoft2-1.0.so' 'libpango-1.0.so')
  cd "${pkgname}-${pkgver}"
  make DESTDIR="$pkgdir/" install
  install -vDm 644 {AUTHORS,NEWS,README} \
    -t "${pkgdir}/usr/share/doc/${pkgname}/"
}
