### this file is sourced not run
pkgname=alure
PKGVER=1.2
PKGARCH=x86_64
PKGBUILD=1

# source: james
TARBALL=alure-$PKGVER.tar.bz2
MD5SUM=3088aba074ad02d95ea51e705053b9f5
SRC_URL=https://kcat.tomasu.net/alure-releases/$TARBALL
BUNDLE=

SLACKREQ='openal libsndfile libogg libvorbis libflac libdumb'
SLACKDESC="$pkgname: $pkgname $PKGVER (C++ 3D Audio API)
$pkgname: 
$pkgname: Alure is a C++ 3D audio API. It uses OpenAL for audio rendering, and 
$pkgname: provides common higher-level features such as file loading and 
$pkgname: decoding, buffer caching, background streaming, and source management 
$pkgname: for virtually unlimited sound source handles.
$pkgname:
$pkgname: https://kcat.tomasu.net/alure.html
$pkgname: https://github.com/kcat/alure
$pkgname: https://repo.or.cz/w/alure.git
$pkgname: 
"

### default pkg_download
### prepare
pkg_prepare() {
	pkg_prepare_default &&
	cd tmp/alure* &&
	# patches are from debian (version 9)
	#patch -Np1 -i ../pkg/fix-build-with-gcc-4.7.patch && # same as out fluidsynth sed below
	patch -Np1 -i ../pkg/Link-FLAC-correctly.patch &&
	#patch -Np1 -i ../pkg/dumb-2.patch && # this one is from Arch
	true
}

### default pkg_package

### build
pkg_build() {
	cd /tmp/alure* && rm -r build &&
	
	# add missing header file
	sed -i -e '/fluidsynth\.h/ a#include <unistd.h>' src/codec_fluidsynth.cpp &&
	
	# no static lib needed
	cmake -B build -S "$PWD" \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_CXX_FLAGS="$CXXFLAGS -std=c++11 -fpermissive" \
		-DDYNLOAD=OFF              \
		-DBUILD_STATIC=OFF         \
		-DLIB_SUFFIX=64            \
		-DALURE_BUILD_EXAMPLES=OFF \
    &&

	# Fix build with fluidsynth 2.4
	find -name build.make | xargs sed -e 's|\;| |g' -i &&

	# build and install
	cmake --build build   &&
	cmake --install build &&

	pkg_build_slackdesc
}

# vim:ft=sh:

