# $Id: Portfile,v 1.5 2006/05/06 14:32:16 yves Exp $

PortSystem 1.0
name		gplghostscript
version		8.50
homepage	http://www.cs.wisc.edu/~ghost/
description	GPL Ghostscript, An interpreter for PostScript and PDF
long_description	Ghostscript is the well-known PostScript interpreter \
			which is available for all common and most esoteric \
			platforms and supports many different printers and some \
			displays. This provides the GPL version.

categories	print
platforms	darwin
maintainers	yves@opendarwin.org

master_sites	sourceforge:ghostscript:source \
				sourceforge:gs-fonts:fonts

distname	ghostscript-${version}-gpl
use_bzip2	yes
set gplgs_file	${distname}${extract.suffix}
set gplgs_fonts	ghostscript-fonts-std-8.11.tar.gz
distfiles	${gplgs_file}:source ${gplgs_fonts}:fonts
extract.only	${gplgs_file}

checksums	${gplgs_file} md5 02afa3b3c5f4c2a0e023cb908f489d55 \
			${gplgs_fonts} md5 6865682b095f8c4500c54b285ff05ef6

depends_lib	port:gtk1 port:libpng port:zlib

post-extract	{
	cd ${worksrcpath}
	system "ln -s src/unix-gcc.mak makefile"
	cd ${workpath}
	system "gunzip -c ${distpath}/${gplgs_fonts} | tar xf -"
}

patchfiles	patch-src-unix-dll.mak
post-patch {
	reinplace "s|XLIBS=Xt|XLIBS=Xt SM ICE|g" ${worksrcpath}/src/unix-gcc.mak
	reinplace "s|@@FILESPATH@@|${filespath}|" ${worksrcpath}/src/unix-dll.mak
}

use_configure	no

build.target	so
build.args	SHARE_LIBPNG=1 \
		SHARE_ZLIB=1 \
		XCFLAGS="-I${prefix}/include -no-cpp-precomp" \
		XLDFLAGS="-L${prefix}/lib" \
		prefix=${prefix} \
		mandir=${prefix}/share/man

destroot.target	soinstall
destroot.destdir	prefix=${destroot}${prefix}
destroot.args	SHARE_LIBPNG=1 \
		SHARE_ZLIB=1 \
		XCFLAGS="-I${prefix}/include -no-cpp-precomp" \
		XLDFLAGS="-L${prefix}/lib" \
		mandir=${destroot}${prefix}/share/man

post-destroot	{
	file mkdir ${destroot}${prefix}/share/ghostscript/ \
		${destroot}${prefix}/include/ghostscript
	file copy ${workpath}/fonts ${destroot}${prefix}/share/ghostscript
	file copy ${worksrcpath}/src/iapi.h ${worksrcpath}/src/errors.h \
		${worksrcpath}/src/gdevdsp.h ${worksrcpath}/src/ierrors.h \
		${destroot}${prefix}/include/ghostscript
	system "ln -s gsc ${destroot}${prefix}/bin/gs"
}

