# Template file for 'stk'
pkgname=stk
version=4.6.1
revision=5
build_style=gnu-configure
configure_args="--with-alsa
 --libexecdir=/usr/libexec/stk
 --with-jack RAWWAVE_PATH=/usr/share/stk/rawwaves/"
make_install_args="prefix=/usr exec_prefix=\${prefix}"
hostmakedepends="automake libtool pkg-config"
makedepends="alsa-lib-devel jack-devel"
depends="libstk-${version}_${revision} stk-data-${version}_${revision}"
short_desc="Synthesis ToolKit in C++"
maintainer="Orphaned <orphan@voidlinux.org>"
license="custom:MIT-like"
homepage="https://ccrma.stanford.edu/software/stk/"
distfiles="https://github.com/thestk/stk/archive/${version}.tar.gz>${pkgname}-${version}.tar.gz"
checksum=8e0c362dd82421bae8f3e789d238a1c27aeac1a2697d7830eb51abc90fc17281

pre_configure() {
	NOCONFIGURE=1 autoreconf -fi
}

post_install() {
	# Create a pkg-config file
	vmkdir usr/lib/pkgconfig
	sed ${FILESDIR}/stk.pc \
		-e "s;@VERSION@;${version};" \
		> ${DESTDIR}/usr/lib/pkgconfig/stk.pc

	# Install binaries
	vmkdir usr/libexec/stk
	vinstall projects/demo/stk-demo 755 usr/libexec/stk
	vinstall projects/effects/effects 755 usr/libexec/stk
	vinstall projects/eguitar/eguitar 755 usr/libexec/stk
	vinstall projects/ragamatic/ragamat 755 usr/libexec/stk

	# Install examples
	vmkdir usr/libexec/stk/examples
	for f in play record audioprobe midiprobe duplex inetIn inetOut \
		 rtsine crtsine bethree controlbee three bees playsmf grains; do
		if [ -x "projects/examples/$f" ]; then
			vinstall projects/examples/$f 755 usr/libexec/stk/examples
		fi
	done

	# Install examples data
	vcopy projects/examples/midifiles usr/libexec/stk/examples
	vcopy projects/examples/rawwaves usr/libexec/stk/examples
	vcopy projects/examples/scores usr/libexec/stk/examples

	# Install stk data
	vmkdir usr/share/stk
	vcopy rawwaves usr/share/stk

	# Documentation
	vdoc doc/README-Linux.txt
	vdoc doc/SKINI.txt
	vdoc doc/hierarchy.txt
	vdoc doc/treesed.html

	vlicense LICENSE
}

stk-data_package() {
	short_desc+=" - data files"
	pkg_install() {
		vmove usr/share/stk
	}
}

stk-examples_package() {
	short_desc+=" - examples"
	depends="${sourcepkg}>=${version}_${revision}"
	pkg_install() {
		vmove usr/libexec/stk/examples
	}
}

libstk_package() {
	short_desc+=" - library"
	pkg_install() {
		vmove usr/lib/libstk-${version}.so
	}
}

libstk-devel_package() {
	short_desc+=" - development files"
	depends="libstk-${version}_${revision} ${makedepends}"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/libstk.so
		vmove usr/lib/pkgconfig
	}
}
