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

pkgname=fluidsynth
pkgver=2.3.1
pkgrel=1
pkgdesc="A real-time software synthesizer based on the SoundFont 2 specifications"
arch=(x86_64)
url="https://www.fluidsynth.org/"
license=(LGPL2.1)
groups=(pro-audio)
depends=(glibc sdl2)
makedepends=(alsa-lib cmake dbus doxygen glib2 jack ladspa libinstpatch
libpulse libsndfile pipewire portaudio readline systemd-libs)
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=('1633294bf6c714361c381151b62d9dd2c8f388490153e7964bfa14fd647a681db9ebfe1de0a06279972d6c5b30377f67361feb4db186b1faa235600f0ae02b22')
b2sums=('a1501303e02b3ea64d87be5cff08d5f2f2be170b38faedc8e6bc4fd18c0dafe268fa6110708664ef0659df9f0e9680551ac483d30364977e768af60dfdff7e83')

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

check() {
  make -C build -k check
}

package() {
  depends+=(libasound.so libdbus-1.so libglib-2.0.so libgmodule-2.0.so
  libgobject-2.0.so libinstpatch-1.0.so libjack.so libpipewire-0.3.so
  libportaudio.so libpulse-simple.so libreadline.so libsndfile.so
  libsystemd.so)

  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 $pkgname-$pkgver/{AUTHORS,ChangeLog,{CONTRIBUTING,README}.md,THANKS,TODO} -t "$pkgdir/usr/share/doc/$pkgname/"
}
