# $Id: Portfile,v 1.10 2005/04/21 15:58:09 jberry Exp $

PortSystem 1.0

name               espgs 
version            7.07.1
categories         print textproc
description        Interpreter for PostScript and PDF 
maintainers        michaelm@opendarwin.org
homepage           http://www.cups.org/ghostscript.php
master_sites       sourceforge \
                     http://mirror.cs.wisc.edu/pub/mirrors/ghost/AFPL/fonts/:fonts \
                     http://www.ijg.org/files/:jpeg \
                     sourceforge:libpng:libpng

                   
distname           ${name}-${version}-source
set std_fonts      ghostscript-fonts-std-8.11
set other_fonts    ghostscript-fonts-other-6.0
set png_src        libpng-1.2.8

distfiles		   ${distname}${extract.suffix} \
                     ${std_fonts}${extract.suffix}:fonts \
                     ${other_fonts}${extract.suffix}:fonts \
                     ${png_src}${extract.suffix}:libpng 

                   
checksums         ${name}-${version}-source${extract.suffix} md5 20dfdc45c3aeb9893b75d41087f828d9 \
                    ${std_fonts}${extract.suffix} md5 6865682b095f8c4500c54b285ff05ef6 \
                      ${other_fonts}${extract.suffix} md5 1a643ae62ef166562e4d422b1a601272 \
				      ${png_src}${extract.suffix} md5 cac1512878fb98f2456df6dc50bc9bc7 


depends_lib        port:jpeg port:libpng port:zlib
platforms          darwin
worksrcdir         ${name}-${version}

# Should be depends_extract, but that isn't implemented
# To understand why doing this, please check official document:
# http://www.ghostscript.com/doc/AFPL/8.00/Make.htm#Third-party_libraries
post-extract    {
    cd ${workpath}
    system "mv ${png_src} ${worksrcdir}/libpng"
}
      
configure.env      LDFLAGS='-L${prefix}/lib'  CFLAGS=-I'${prefix}/include'
configure.args     --without-gimp-print --disable-cups \
				   --mandir='\${prefix}/share/man' \
                   --with-fontpath="${prefix}/share/ghostscript/fonts:/usr/share/ghostscript/fonts"

build.target
destroot.destdir   prefix=${destroot}${prefix} datadir=${destroot}${prefix}/share

post-destroot      { system "mkdir -p ${destroot}/${prefix}/share/ghostscript/"
                  system "cd ${workpath} && \
                        tar -cf - fonts | \
                        tar -xf - -C ${destroot}/${prefix}/share/ghostscript/"
                   }


variant     x11 {
                  depends_lib-append      lib:libX11:XFree86
                  configure.args-append   --with-x
                }
                
variant extra_fonts {
                  set other_fonts    ghostscript-fonts-other-6.0
                  distfiles-append   ${other_fonts}${extract.suffix}:fonts
                  checksums-append   ${other_fonts}${extract.suffix} md5 1a643ae62ef166562e4d422b1a601272
                  }
                 
                 
long_description Easy Software Products now produces maintenance updates of GNU Ghostscript under \
the name ESP Ghostscript. These updates incorporate bug fixes to the current GNU version of \
Ghostscript as well as the latest CUPS, GIMP-print, and other add-ons to Ghostscript.
