#Packager: Maximus (maximuus[at]gmail[dot]com)

pkgname=celestia
pkgver=r5016
pkgrel=1mb
arch=i686
source=(http://people.salixos.org/maximus/$pkgname/$pkgver/$pkgname-$pkgver.tar.gz)
sourcetemplate=http://people.salixos.org/maximus/$pkgname/$pkgver/$arch
docs=("readme" "install" "copying" "changelog" "authors" "news" "translators" "about-nls")
url=http://www.shatters.net/celestia/

slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"celestia - a real-time space simulation"
"Unlike most planetarium software, Celestia doesn't confine you to the"
"surface of the Earth. You can travel throughout the solar system, to"
"any of over 100,000 stars, or even beyond the galaxy."
"All movement in Celestia is seamless; the exponential zoom feature"
"lets you explore space across a huge range of scales, from galaxy"
"clusters down to spacecraft only a few meters across."
"Celestia is expandable. Celestia comes with a large catalog of stars,"
"galaxies, planets, moons, asteroids, comets, and spacecraft. If that's"
"not enough, you can download easy to install addons with more objects." 
)


build() {	

 	cd $startdir/src/$pkgname-$pkgver
	autoreconf -iv
	
	#fix pkgconfg can't find lua
	sed -i -e "s|lua5.1|lua-5.1|" $startdir/src/$pkgname-$pkgver/configure || exit 1
	
	#fix compile error related to libpng
	sed -i -e "s|png_set_gray|png_set_expand_gray|" $startdir/src/$pkgname-$pkgver/src/celengine/image.cpp || exit 1
	
	./configure \
		--prefix=/usr \
		--libdir=/usr/lib${LIBDIRSUFFIX} \
		--localstatedir=/var \
		--sysconfdir=/etc \
		--build=$arch-slackware-linux \
		--with-gtk \
		--with-lua \
		--enable-libsuffix \
	    --enable-theora \
	    --enable-cairo
	    
	make || return 1
	make install DESTDIR=$startdir/pkg
	
	#fix icon location
	mkdir -p $startdir/pkg/usr/share/icons/hicolor/48x48/apps
	mv $startdir/pkg/usr/share/pixmaps/celestia.png $startdir/pkg/usr/share/icons/hicolor/48x48/apps/
	rm -rf $startdir/pkg/usr/share/pixmaps
	
} 
