#!/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.2
pkgrel=01
pkgdesc="A real-time software synthesizer based on the SoundFont 2 specifications w/o systemd"
url="https://www.fluidsynth.org/"
groups=(pro-audio)
depends=(glibc sdl2 gcc-libs)
makedepends=(alsa-lib cmake dbus doxygen glib2 jack ladspa libinstpatch
libpulse libpipewire 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 check -k -C build
}

package() {
  depends+=(alsa-lib libasound.so dbus libdbus-1.so glib2 libglib-2.0.so libgmodule-2.0.so libgobject-2.0.so
  jack libjack.so libinstpatch libinstpatch-1.0.so libpipewire libpipewire-0.3.so libpulse libpulse-simple.so
  libsndfile libsndfile.so portaudio libportaudio.so readline libreadline.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/"
}

#---- arch license gpg-key & sha256sums ----

arch=(x86_64)

license=(LGPL2.1)

sha256sums=(cd610810f30566e28fb98c36501f00446a06fa6bae3dc562c8cd3868fe1c0fc7) #  fluidsynth-2.3.2.tar.gz

##  ab10d840b7dddf763e13a833112aa7acfde156682882cc4a820456507393a850  fluidsynth-2.3.2-01-x86_64.pkg.tar.lz


