#Packager: George Vlahavas <vlahavas~at~gmail~dot~com>
#
# Requires ftjam/jam to compile

pkgname=gargoyle
pkgver=2010.1
pkgrel=1gv
source=("http://garglk.googlecode.com/files/gargoyle-$pkgver-sources.zip" "icons.tar.gz")
docs=("readme" "install" "copying" "changelog" "authors" "news" "todo" "license.txt" "charterbt.txt")
url=http://ccxvii.net/gargoyle/

slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"gargoyle (An interactive fiction player)"
"Gargoyle is an IF player that supports all the major interactive"
"fiction formats. Most interactive fiction is distributed as portable"
"game files. These portable game files come in many formats. In the"
"past, you used to have to download a separate player (interpreter) for"
"each format of IF you wanted to play. Gargoyle is based on the"
"standard interpreters for the formats it supports." 
)


build() {
	cd $startdir/src

	sed -i "s/#define T_\(.*\)\( *\)\"\(.*\)\"/#define T_\1\2\"gargoyle-\3\"/" garglk/launcher.c

	jam
	DESTDIR=$startdir/pkg _APPDIR=/usr/bin/ _LIBDIR=/usr/lib${LIBDIRSUFFIX} _BINDIR=/usr/bin jam install

	mkdir -p $startdir/pkg/etc
	cp garglk/garglk.ini $startdir/pkg/etc/
	# rename all engines so they don't conflict with other binaries
	for i in `ls $startdir/pkg/usr/bin/ | grep -v gargoyle`; do
		mv $startdir/pkg/usr/bin/$i $startdir/pkg/usr/bin/gargoyle-$i
	done
	chmod 755 $startdir/pkg/usr/bin/*

	# Copy icons to the right place
	ICONSIZES="128 96 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;

	mkdir -p $startdir/pkg/usr/share/applications
	sed "s/^Icon=.*/Icon=gargoyle/" garglk/gargoyle.desktop > $startdir/pkg/usr/share/applications/gargoyle.desktop
}