#!/usr/bin/bash
# JOBoRun		: Jwm OpenBox Obarun RUNit
# Maintainer	: Joe Bo Run <joborun@disroot.org>
# PkgSource		: url="https://gittea.disroot.org/joborun-pkg/jobextra/$pkgname"
# Website		: https://pozol.eu
#-----------------------------------------| DESCRIPTION |---------------------------------------

pkgname=fluidsynth
pkgver=2.3.1
pkgrel=01
pkgdesc="A real-time software synthesizer based on the SoundFont 2 specifications w/o systemd"
arch=(x86_64)
url="https://www.fluidsynth.org/"
groups=(pro-audio)
depends=(glibc sdl2)
makedepends=(alsa-lib cmake dbus doxygen glib2 jack ladspa libinstpatch
libpulse libsndfile portaudio readline )
provides=(libfluidsynth.so soundfont-synthesizer)
backup=(etc/conf.d/$pkgname)
# options=(debug)   ## uncomment this to produce the debug package for fluidsynth
source=($pkgname-$pkgver.tar.gz::https://github.com/$pkgname/$pkgname/archive/v$pkgver.tar.gz)
install="$pkgname.install"

#prepare() {
#  # remove sandboxing options only available to systemd system services: https://github.com/FluidSynth/fluidsynth/issues/1147
#  patch -Np1 -d $pkgname-$pkgver -i ../$pkgname-2.2.9-user_service_hardening.patch
#}

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 libportaudio.so
  libpulse-simple.so libreadline.so libsndfile.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/"
}

#---- license gpg-key sha256sums ----

license=(LGPL2.1)

sha256sums=(d734e4cf488be763cf123e5976f3154f0094815093eecdf71e0e9ae148431883) # fluidsynth-2.3.1.tar.gz
