# Template file for 'freedroidRPG'.
pkgname=freedroidRPG
version=0.16.1
revision=1
wrksrc=${pkgname,,}-${version}
build_style=gnu-configure
hostmakedepends="pkg-config python"
makedepends="SDL_gfx-devel SDL_image-devel SDL_mixer-devel
 libjpeg-turbo-devel libvorbis-devel lua-devel libpng-devel"
depends="${pkgname}-data>=${version}_${revision}"
short_desc="Role playing game featuring Tux and evil robots"
maintainer="Jürgen Buchmüller <pullmoll@t-online.de>"
license="GPL-3"
homepage="http://www.freedroid.org/"
distfiles="http://ftp.osuosl.org/pub/freedroid/${pkgname}-${version%.*}/${pkgname}-${version}.tar.gz"
checksum=426df175034b12095e7498fd80c907e507667c960ee1da331d9e5566d1b09358

case "$XBPS_TARGET_MACHINE" in
	*-musl)	configure_args+=" --disable-backtrace"
esac

post_install() {
	local script=freedroid

	# Remove the .UTF-8 suffix from the user's LANG setting,
	# or otherwise the internal font is wrong when rendering
	# non-ASCII characters. My assumption is the game expects
	# ISO-8859-1 (aka Latin1).
	echo "#!/bin/sh" > ${script}
	echo "# Strip .UTF-8 extension from the user's LANG" >> ${script}
	echo "LANG=$(echo \"$LANG\" | sed -e's;\.[Uu][Tt][Ff]-8;;')" >> ${script}
	echo "exec ${pkgname} $*" >> ${script}

	# install the wrapper script
	vbin ${script}

	# Start the wrapper script from the desktop file
	sed -i ${PKGDESTDIR}/usr/share/applications/${pkgname,,}.desktop \
		-e "/^Exec/s;=${pkgname};=${script};"
}

freedroidRPG-data_package() {
	short_desc+=" - data files"
	noarch=yes
	pkg_install() {
		vmove usr/share/freedroidrpg
	}
}
