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

pkgname=wesnoth
pkgver=1.6.5
pkgrel=1gv
arch=x86_64
source=("http://prdownloads.sourceforge.net/wesnoth/wesnoth-$pkgver.tar.bz2" "icons.tar.gz")
docs=("about-nls" "copying" "install" "readme" "changelog" "copyright")
url=http://wesnoth.org/

slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"wesnoth (Turn based strategy game)"
"The Battle for Wesnoth is a turn-based strategy game with a fantasy"
"theme. Build up a great army, gradually turning raw recruits into"
"hardened veterans.  In later games, recall your toughest warriors and"
"form a deadly host against whom none can stand! Choose units from a"
"large pool of specialists, and hand-pick a force with the right"
"strengths to fight well on different terrains against all manner of"
"opposition."
)

build() {
	cd $startdir/src/$pkgname-$pkgver
	./configure --prefix=/usr --libdir=/usr/lib${LIBDIRSUFFIX} --localstatedir=/var --sysconfdir=/etc --enable-server --enable-campaign-server --enable-editor
	make || return 1
	make install DESTDIR=$startdir/pkg
	
	# Copy icons to the right place
	ICONSIZES="128 96 72 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}-icon-$i.png $startdir/pkg/usr/share/icons/hicolor/$i\x$i/apps/${pkgname}-icon.png;
		mv $startdir/src/${pkgname}_editor-icon-$i.png $startdir/pkg/usr/share/icons/hicolor/$i\x$i/apps/${pkgname}_editor-icon.png;
	done;
	
	# .desktop files
	sed -i 's|.png||' $startdir/pkg/usr/share/applications/${pkgname}_editor.desktop
	sed -i 's|.png||' $startdir/pkg/usr/share/applications/${pkgname}.desktop
	
	# Remove unwanted files
	rm $startdir/pkg/usr/share/icons/*.png
	
	# Move docs
	mkdir -p $startdir/pkg/usr/doc/$pkgname-$pkgver
	mv $startdir/pkg/usr/share/doc/$pkgname/manual $startdir/pkg/usr/doc/$pkgname-$pkgver
	rm -r $startdir/pkg/usr/share/doc

	# Fix permissions
	chmod 755 $startdir/pkg/var/run/wesnothd
}