# Maintainer: David Runge <dave@sleepmap.de>
# Contributor: Ray Rashif <schiv@archlinux.org>
# Contributor: damir <damir@archlinux.org>

pkgname=fluidsynth
pkgver=2.0.6
pkgrel=1
pkgdesc="A real-time software synthesizer based on the SoundFont 2 specifications"
arch=('x86_64')
url="http://www.fluidsynth.org/"
license=('LGPL2.1')
groups=('pro-audio')
depends=('glib2' 'libpulse' 'portaudio')
makedepends=('cmake' 'ladspa' 'doxygen')
optdepends=('pulseaudio: PulseAudio sound support')
provides=('libfluidsynth.so' 'soundfont-synthesizer')
backup=("etc/conf.d/$pkgname")
source=("$pkgname-$pkgver.tar.gz::https://github.com/${pkgname}/${pkgname}/archive/v$pkgver.tar.gz")
sha512sums=('c160e3d7c6ad62d5cc014642eb18a0f65eb90b5ad91db4049e1b45446034e989a4f9e5b805270967d4eaf47a6e2da0e81bdb5ae95500cc80d7021e8e61cd7107')

prepare() {
  cd "${pkgname}-${pkgver}"
  mkdir build
}

build() {
  cd "${pkgname}-${pkgver}"
  (
    cd build
    cmake .. -DCMAKE_INSTALL_PREFIX=/usr \
             -DFLUID_DAEMON_ENV_FILE=/etc/conf.d/fluidsynth \
             -Denable-ladspa=ON \
             -Denable-portaudio=ON \
             -DLIB_SUFFIX=""
  )
  make -C build VERBOSE=1
}

check() {
  cd "${pkgname}-${pkgver}"
  make -C build -k check
}

package() {
  cd "${pkgname}-${pkgver}"
  make -C build DESTDIR="$pkgdir" install
  # systemd user unit
  install -vDm 644 "build/${pkgname}.service" \
    -t "$pkgdir/usr/lib/systemd/user/"
  # system-wide configuration file
  install -vDm 644 "build/${pkgname}.conf" "${pkgdir}/etc/conf.d/${pkgname}"
  # docs
  install -vDm 644 {AUTHORS,ChangeLog,NEWS,README.md,THANKS,TODO} \
    -t "${pkgdir}/usr/share/doc/${pkgname}"
}

