# Template file for 'klystrack'
pkgname=klystrack
version=1.7.3
revision=2
_klystronsha=f5114db4de299ece73852becbef56d7d461bf421
create_wrksrc=yes
hostmakedepends="SDL2-devel"
makedepends="SDL2_image-devel SDL2_mixer-devel"
short_desc="Chiptune music tracker"
maintainer="Orphaned <orphan@voidlinux.org>"
license="MIT"
homepage="http://kometbomb.github.io/klystrack/"
distfiles="https://github.com/kometbomb/klystrack/archive/${version}.tar.gz
 https://github.com/kometbomb/klystron/archive/${_klystronsha}.tar.gz"
checksum="569dc552ffdfcef94cb1ed993b41494e0c52a7ec15d0cdf614490b92f6611efb
 877bf4b7dc506ede2309c5c9c838d58d52ff031fef7415e9b491ce584078e2f5"

CFLAGS="-fcommon"

do_build() {
	test -d klystron ||
		mv klystron-${_klystronsha} klystron
	cd klystrack-${version}

	sed -i \
		-e 's/\r$//' \
		-e "/^CFLAGS/s,\$, ${CFLAGS}," \
		-e "/^LDFLAGS/s:\$: ${LDFLAGS}:" \
		-e 's/^CC := gcc/CC := $(CC)/' \
		-e '37s/$/ -lSDL2_mixer/' \
		Makefile
	sed -i \
		-e 's/\r$//' \
		-e 's/^CC = gcc/CC = $(CC)/' \
		../klystron/Makefile

	make CC=$CC $makejobs CFG=release
}

do_install() {
	cd klystrack-${version}
	vbin bin.release/klystrack
	vmkdir usr/lib/klystrack
	vcopy res usr/lib/klystrack
	vcopy key usr/lib/klystrack
	vmkdir usr/share/examples/klystrack
	vcopy examples usr/share/examples/klystrack
	vlicense doc/LICENSE
}
