#Maintainer: George Vlahavas (vlahavas~at~gmail~dot~com)

pkgname=prboom
pkgver=2.5.0
pkgrel=2gv
source=("http://downloads.sourceforge.net/prboom/prboom-$pkgver.tar.gz" "http://ftp.cc.uoc.gr/mirrors/nongnu.org/freedoom/freedoom-iwad/freedoom-iwad-0.7.zip" "icons.tar.gz" "prboom.desktop" "libpng-1.4.patch")
docs=("readme*" "install" "copying" "changelog" "authors" "news" "todo" "maintainers" "*.txt")
url=http://prboom.sourceforge.net/index.html

slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"prboom (a much enhanced port of Doom)"
"PrBoom is made up of the combined projects DosDoom, Boom, MBF, LxDoom"
"and lSDLDoom. Free maps from the freedoom project are included in the"
"package."
)


build() {
	cd $startdir/src/$pkgname-$pkgver

	patch -p1 < $startdir/src/libpng-1.4.patch || exit 1

	./configure --prefix=/usr --libdir=/usr/lib${LIBDIRSUFFIX} --localstatedir=/var --sysconfdir=/etc --with-waddir=/usr/share/prboom --build=$arch-slackware-linux
	make || return 1
	make install DESTDIR=$startdir/pkg
	mkdir -p $startdir/pkg/usr/bin
	mv $startdir/pkg/usr/games/* $startdir/pkg/usr/bin
	rmdir $startdir/pkg/usr/games

	mv $startdir/src/freedoom-iwad-0.7/*.wad $startdir/pkg/usr/share/prboom
	mkdir -p $startdir/pkg/usr/doc/$pkgname-$pkgver/freedoom-iwad-0.7
	mv $startdir/src/freedoom-iwad-0.7/* $startdir/pkg/usr/doc/$pkgname-$pkgver/freedoom-iwad-0.7

	mkdir -p $startdir/pkg/usr/share/applications
	cp $startdir/src/prboom.desktop $startdir/pkg/usr/share/applications/

	# Copy icons to the right place
	ICONSIZES="64 48 32 24 22 16"
	for i in $ICONSIZES; do
		mkdir -p $startdir/pkg/usr/share/icons/hicolor/$i\x$i/apps;
		mv $startdir/src/$pkgname-$i.png $startdir/pkg/usr/share/icons/hicolor/$i\x$i/apps/$pkgname.png;
	done;

	# Remove not needed doc dir
	rm -rf $startdir/pkg/usr/share/doc
}