# Template file for 'xonotic'
pkgname=xonotic
version=0.7.0
revision=1
wrksrc="Xonotic"
homepage="http://xonotic.org"
license="GPL-2, GPL-3"
distfiles="http://dl.xonotic.org/xonotic-${version}-source.zip"
short_desc="A free, fast-paced crossplatform first-person shooter"
maintainer="Juan RP <xtraeme@gmail.com>"
checksum=f1a527de67ab2bfd2b17414614301a783ad04e00dbd0d8abb516505e4ee9f88c

hostmakedepends="unzip automake libtool"
makedepends="gmp-devel MesaLib-devel SDL-devel libcurl-devel alsa-lib-devel
 libmodplug-devel libvorbis-devel libXpm-devel libjpeg-turbo-devel
 xonotic-data>=${version}"

do_build() {
	make ${makejobs} -C source/darkplaces CPUOPTIMIZATIONS="${CFLAGS}" \
		DP_FS_BASEDIR=/usr/share/xonotic/ DP_LINK_TO_LIBJPEG=1 cl-release
	make ${makejobs} -C source/darkplaces CPUOPTIMIZATIONS="${CFLAGS}" \
		DP_FS_BASEDIR=/usr/share/xonotic/ DP_LINK_TO_LIBJPEG=1 sdl-release
	make ${makejobs} -C source/darkplaces CPUOPTIMIZATIONS="${CFLAGS}" \
		DP_FS_BASEDIR=/usr/share/xonotic/ DP_LINK_TO_LIBJPEG=1 sv-release

	cd source/d0_blind_id
	autoreconf -fi
	./configure --prefix=/usr --disable-rijndael
	make ${makejobs}
}

do_install() {
	# binaries
	vinstall source/darkplaces/darkplaces-dedicated 755 usr/bin xonotic-dedicated
	vinstall source/darkplaces/darkplaces-glx 755 usr/bin xonotic-glx
	vinstall source/darkplaces/darkplaces-sdl 755 usr/bin xonotic-sdl

	# convenience files
	vmkdir usr/share/applications
	install -Dm644 $FILESDIR/*.desktop -t $DESTDIR/usr/share/applications
	install -Dm644 misc/logos/icons_png/xonotic_512.png \
		$DESTDIR/usr/share/pixmaps/xonotic.png

	# crypto stuff
	cd source/d0_blind_id
	make DESTDIR=$DESTDIR install

	# Remove devel stuff
	rm -rf $DESTDIR/usr/include $DESTDIR/usr/lib/pkgconfig $DESTDIR/usr/lib/*.a
}

xonotic_package() {
	depends="desktop-file-utils xonotic-data>=${version}"
	pkg_install() {
		vmove all
	}
}