# SliTaz package receipt.

PACKAGE="ghostscript"
VERSION="9.02"
CATEGORY="office"
SHORT_DESC="Ghostscript tools and utilities."
MAINTAINER="jozee@slitaz.org"
TARBALL="$PACKAGE-$VERSION.tar.bz2"
DEPENDS="gtk+ expat fontconfig freetype gnutls jpeg libgcrypt libgpg-error \
libpng tiff zlib cups xorg-libICE xorg-libSM xorg-libX11 xorg-libXau \
xorg-libXdmcp xorg-libXext xorg-libXt gcc-lib-base jasper jbig2dec" 
# build depends are optional ; ghostscripts still build but does not compile in cups support
BUILD_DEPENDS="cairo-dev gtk+-dev expat-dev fontconfig-dev freetype-dev gnutls-dev jpeg-dev libgcrypt-dev libgpg-error-dev libpng-dev tiff-dev zlib-dev cups-dev jbig2dec jasper-dev"
WEB_SITE="http://pages.cs.wisc.edu/~ghost/"
#WGET_URL="http://mirror.cs.wisc.edu/pub/mirrors/ghost/GPL/gs862/$TARBALL"
WGET_URL="http://downloads.ghostscript.com/public/$TARBALL"


# Rules to configure and make the package.
compile_rules()
{
	cd $src
	# force it to use system-libs
	rm -rf jpeg libpng zlib jasper expat tiff

	# --disable-compile-inits is needed for linking with system-zlib

	./configure \
		--prefix=/usr \
		--infodir=/usr/share/info \
		--mandir=/usr/share/man \
		--disable-compile-inits \
		--enable-dynamic \
		--enable-cups \
		--enable-cairo \
		--enable-gtk \
		--with-fontpath=/usr/share/fonts/truetype/:/usr/share/fonts \
		--disable-compile-inits \
		$CONFIGURE_ARGS &&
	make $MAKEFLAGS &&
	make DESTDIR=$PWD/_pkg install soinstall
	
}

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
	mkdir -p $fs/usr/share
	mkdir -p $fs/usr/lib
	cp -a $_pkg/usr/bin $fs/usr
	cp -a $_pkg/usr/lib $fs/usr
	cp -a $_pkg/usr/share/$PACKAGE $fs/usr/share
	# if cups-dev installed
	cp -a $_pkg/usr/share/cups $fs/usr/share
	cp -a $_pkg/etc $fs
	# Remove doc and examples
	rm -rf $fs/usr/share/$PACKAGE/$VERSION/doc
	rm -rf $fs/usr/share/$PACKAGE/$VERSION/examples
	# Remove CMAPs (Non-free : not covered under GPL) : moved to non-free package get-ghostscript-CMAP
	rm -rf $fs/usr/share/$PACKAGE/$VERSION/Resource/CMap/*
	
	# already compiled as a shared lib; gsc is same as gs
	rm -rf $fs/usr/bin/gs
}

post_install()
{
	ln -s /usr/bin/gsc $1/usr/bin/gs
}