# Contributor: Peter Shkenev <santurysim@gmail.com>
# Maintainer: Antoni Aloy <aaloytorrens@gmail.com>
pkgname=zmusic
pkgver=1.1.12
pkgrel=1
pkgdesc="GZDoom's music system as a standalone library"
url="https://github.com/ZDoom/ZMusic"
arch="all !ppc64le" # ftbfs
license="GPL-3.0-or-later AND LGPL-3.0-or-later AND LGPL-2.1-or-later AND custom"
makedepends="
	alsa-lib-dev
	cmake
	fluidsynth-dev
	libsndfile-dev
	mpg123-dev
	samurai
	zlib-dev
	"
subpackages="$pkgname-dev $pkgname-doc"
options="!check"    # No test suite
source="https://github.com/ZDoom/ZMusic/archive/refs/tags/$pkgver/zmusic-$pkgver.tar.gz
	system-fluidsynth.patch
	"
builddir="$srcdir/ZMusic-$pkgver"

prepare() {
	default_prepare

	rm -r thirdparty/zlib
	rm -r thirdparty/fluidsynth
}

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=True \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		$CMAKE_CROSSOPTS
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
	install -Dm644 licenses/dumb.txt "$pkgdir"/usr/share/licenses/$pkgname/dumb.txt
}

sha512sums="
7777cd2611557bb7f1acdb94c68e66327b2843df41a164e64dd45045f2a1a8cc6b71b8af344a75ae41390604655fb839698d6656f17d6b1107991d616029fc63  zmusic-1.1.12.tar.gz
9b2322ad00dc37debe73f591a2b8c5c2dc1577644f24a3f900a4f5b63e12f8ccff419d361694015815d33e57a15297f352a640ac646cc0e4a9017fe40b8ff388  system-fluidsynth.patch
"
