# Template file for 'SDL2_mixer'
pkgname=SDL2_mixer
version=2.0.2
revision=1
build_style=gnu-configure
hostmakedepends="pkg-config"
makedepends="SDL2-devel libvorbis-devel libmikmod-devel libflac-devel
 libmodplug-devel mpg123-devel smpeg2-devel fluidsynth-devel"
# The following deps are dlopen(3)ed at runtime.
depends="libvorbis libmikmod libmpg123 libmodplug libflac smpeg2"
short_desc="Multi-channel audio mixer library (SDL 2.x)"
maintainer="Juan RP <xtraeme@voidlinux.eu>"
license="BSD"
homepage="http://www.libsdl.org/projects/SDL_mixer/"
distfiles="http://www.libsdl.org/projects/SDL_mixer/release/$pkgname-$version.tar.gz"
checksum=4e615e27efca4f439df9af6aa2c6de84150d17cbfd12174b54868c12f19c83bb

# Package build options
build_options="gles"

case "$XBPS_TARGET_MACHINE" in
	arm*)
		# Enable OpenGL/ES on rpi platforms
		build_options_default="gles"
		;;
esac


if [ "$build_option_gles" ]; then
	case "$XBPS_TARGET_MACHINE" in
	armv[67]*)
		# RaspberryPi, use Videocore IV
		makedepends+=" rpi-userland-devel"
		LDFLAGS="-L${XBPS_CROSS_BASE}/opt/vc/lib -lbcm_host"
		;;
	esac
fi

pre_configure() {
	sed -e "/CONFIG_FILE_ETC/s|/etc/timidity.cfg|/etc/timidity++/timidity.cfg|" \
		-e "/DEFAULT_PATH/s|/etc/timidity|/etc/timidity++|" \
		-e "/DEFAULT_PATH2/s|/usr/local/lib/timidity|/usr/lib/timidity|" \
		-i timidity/options.h
}

post_install() {
	vlicense COPYING.txt COPYING
}

SDL2_mixer-devel_package() {
	depends="SDL2-devel ${sourcepkg}>=${version}_${revision}"
	short_desc+=" - development files"
	pkg_install() {
		vmove usr/include
		vmove usr/lib/pkgconfig
		vmove "usr/lib/*.so"
		vmove "usr/lib/*.a"
	}
}
