# Template file for 'boswars'
pkgname=boswars
version=2.8
revision=2
hostmakedepends="pkg-config libpng-progs python3"
makedepends="sdl12-compat-devel glu-devel libpng-devel
 libtheora-devel libvorbis-devel lua51-devel"
depends="${pkgname}-data"
short_desc="Futuristic real-time strategy game (RTS)"
maintainer="Orphaned <orphan@voidlinux.org>"
license="GPL-2.0-or-later"
homepage="https://www.boswars.org"
distfiles="https://www.boswars.org/dist/releases/boswars-${version}-src.tar.gz"
checksum=5185206990bf6765c7a5d3802ce6e6048a1087cf4c307b099a5691a3eec6b86a
python_version=3

do_build() {
	# Patch make.py to respect our $CXXFLAGS and $LDFLAGS
	sed -i make.py \
		-e "s;^gccflags = '\(.*\)'.split();gccflags = '${CXXFLAGS} \1'.split();" \
		-e "/^gccflags.*/a gldflags = '${LDFLAGS}'.split()" \
		-e "s;self.ldflags = list(ldflags);self.ldflags = gldflags + list(ldflags);" \
		-e "s/cc='g++'/cc='$CXX'/"
	python3 make.py
}

do_install() {
	vmkdir usr/libexec/boswars
	vcopy fbuild/release/boswars usr/libexec/boswars/

	vmkdir usr/share/boswars
	vcopy campaigns usr/share/boswars/
	vcopy doc usr/share/boswars/
	vcopy graphics usr/share/boswars/
	vcopy intro usr/share/boswars/
	vcopy languages usr/share/boswars/
	vcopy maps usr/share/boswars/
	vcopy patches usr/share/boswars/
	vcopy scripts usr/share/boswars/
	vcopy sounds usr/share/boswars/
	vcopy units usr/share/boswars/

	vbin ${FILESDIR}/boswars

	vinstall ${FILESDIR}/boswars.desktop 644 usr/share/applications/
	vinstall ${FILESDIR}/boswars.png 644 usr/share/pixmaps/
}

boswars-data_package() {
	short_desc+=" - data files"
	pkg_install() {
		vmove usr/share/boswars/campaigns
		vmove usr/share/boswars/doc
		vmove usr/share/boswars/graphics
		vmove usr/share/boswars/intro
		vmove usr/share/boswars/languages
		vmove usr/share/boswars/maps
		vmove usr/share/boswars/patches
		vmove usr/share/boswars/scripts
		vmove usr/share/boswars/sounds
		vmove usr/share/boswars/units
	}
}
