# Template file for 'klystrack'
pkgname=klystrack
version=1.7.2
revision=1
_klystronsha=f5114db4de299ece73852becbef56d7d461bf421
create_wrksrc=yes
hostmakedepends="SDL2-devel"
makedepends="SDL2_image-devel SDL2_mixer-devel"
short_desc="Chiptune music tracker"
maintainer="allan <mail@may.mooo.com>"
license="BSD"
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="96b46fca5cd150a7ca0ea27cc339eb2b2394e48580ced1d43b0083bb8a628d5c
 877bf4b7dc506ede2309c5c9c838d58d52ff031fef7415e9b491ce584078e2f5"

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 linux/copyright
}
