maintainer="Bart Ribbers <bribbers@disroot.org>"
pkgname=fluidsynth
pkgver=2.4.4
pkgrel=3
arch="all"
url="https://www.fluidsynth.org/"
pkgdesc="A real-time software synthesizer based on the SoundFont 2 specifications"
license="LGPL-2.1-or-later"
# CMake script fails without /usr/bin/fluidsynth
depends_dev="$pkgname"
depends_libs="soundfont-timgm"
makedepends="
	$depends_libs
	alsa-lib-dev
	cmake
	dbus-dev
	doxygen
	glib-dev
	graphviz
	jack-dev
	ladspa-dev
	libsndfile-dev
	pipewire-dev
	portaudio-dev
	pulseaudio-dev
	readline-dev
	samurai
	"
source="https://github.com/fluidsynth/fluidsynth/archive/v$pkgver/fluidsynth-v$pkgver.tar.gz"
subpackages="$pkgname-dev $pkgname-libs $pkgname-doc"

# tests are broken on s390x
case "$CARCH" in
	s390x) options="!check"
esac

build() {
	# need to set gnu_source globally to fix implicit decls
	CFLAGS="$CFLAGS -D_GNU_SOURCE" \
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=RelWithDebInfo \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_MODULE_PATH=/usr/lib/cmake \
		-DLIB_INSTALL_DIR=lib \
		-DFLUID_DAEMON_ENV_FILE=/etc/conf.d/fluidsynth \
		-Denable-ladspa=ON \
		-Denable-portaudio=ON
	cmake --build build
}

check() {
	# ctest can't currently be used https://github.com/FluidSynth/fluidsynth/issues/881
	ninja -C build check
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
a380bd710c4b7fe83fc6799c56f51c9d4c3d21516b9366f8381c7fdb899c195472fe4bded9c25ab9de9c76fc95a4e727a8b0305ab92b5ede025fd03585036aa3  fluidsynth-v2.4.4.tar.gz
"
