Index: files/patch-src_unix-aux.mak.diff
===================================================================
--- files/patch-src_unix-aux.mak.diff	(revision 0)
+++ files/patch-src_unix-aux.mak.diff	(revision 0)
@@ -0,0 +1,11 @@
+--- src/unix-aux.mak.orig	2007-10-20 09:55:55.000000000 +0900
++++ src/unix-aux.mak	2007-11-23 18:29:40.000000000 +0900
+@@ -83,7 +83,7 @@
+  $(GLOBJ)gp_stdia.$(OBJ) $(GLOBJ)gsutil.$(OBJ)
+ 
+ $(MKROMFS_XE): $(GLSRC)mkromfs.c $(MKROMFS_COMMON_DEPS) $(MKROMFS_OBJS)
+-	$(CCAUX) $(GENOPT) $(CFLAGS_DEBUG) $(I_)$(GLSRCDIR)$(_I) $(I_)$(GLOBJ)$(_I) $(I_)$(ZSRCDIR)$(_I) $(GLSRC)mkromfs.c $(O_)$(MKROMFS_XE) $(MKROMFS_OBJS) -lm $(EXTRALIBS)
++	$(CCAUX) $(GENOPT) $(CFLAGS_DEBUG) $(I_)$(GLSRCDIR)$(_I) $(I_)$(GLOBJ)$(_I) $(I_)$(ZSRCDIR)$(_I) $(GLSRC)mkromfs.c $(O_)$(MKROMFS_XE) $(MKROMFS_OBJS) -lm $(EXTRALIBS) $(LDFLAGS)
+ 
+ # Query the environment to construct gconfig_.h.
+ # The "else true;" is required because Ultrix's implementation of sh -e
Index: files/patch-configure.diff
===================================================================
--- files/patch-configure.diff	(revision 0)
+++ files/patch-configure.diff	(revision 0)
@@ -0,0 +1,11 @@
+--- configure.orig	2007-11-22 05:16:00.000000000 +0900
++++ configure	2007-11-24 00:03:39.000000000 +0900
+@@ -7022,7 +7022,7 @@
+ fi
+ if test $ac_cv_header_fontconfig_fontconfig_h = yes; then
+ 
+-		    FONTCONFIG_LIBS="-lfontconfg"
++		    FONTCONFIG_LIBS="-lfontconfig"
+ 		    HAVE_FONTCONFIG="-DHAVE_FONTCONFIG"
+ 
+ fi
Index: files/patch-src_macosx.mak.diff
===================================================================
--- files/patch-src_macosx.mak.diff	(revision 0)
+++ files/patch-src_macosx.mak.diff	(revision 0)
@@ -0,0 +1,11 @@
+--- src/macosx.mak.orig	2007-11-10 06:18:04.000000000 +0900
++++ src/macosx.mak	2007-11-24 02:24:40.000000000 +0900
+@@ -54,7 +54,7 @@
+ 
+ FRAMEWORK_NAME=Ghostscript
+ FRAMEWORK_EXT=.framework
+-prefix = /Library/Frameworks/$(FRAMEWORK_NAME)$(FRAMEWORK_EXT)
++prefix = @@DESTROOT@@@@PREFIX@@/Library/Frameworks/$(FRAMEWORK_NAME)$(FRAMEWORK_EXT)
+ exec_prefix = $(prefix)
+ bindir = $(exec_prefix)/bin
+ scriptdir = $(bindir)
Index: files/patch-src_macos-fw.mak.diff
===================================================================
--- files/patch-src_macos-fw.mak.diff	(revision 0)
+++ files/patch-src_macos-fw.mak.diff	(revision 0)
@@ -0,0 +1,11 @@
+--- src/macos-fw.mak.orig	2007-06-06 07:23:38.000000000 +0900
++++ src/macos-fw.mak	2007-11-24 02:24:12.000000000 +0900
+@@ -78,7 +78,7 @@
+ # a separate .dylib target if we're going to build them at all
+ # we should also be passing compatibility versions
+ 
+-SODEFS=LDFLAGS='$(LDFLAGS) $(CFLAGS_SO) -dynamiclib -install_name $(prefix)/$(FRAMEWORK_NAME)'\
++SODEFS=LDFLAGS='$(LDFLAGS) $(CFLAGS_SO) -dynamiclib -install_name @@PREFIX@@/Library/Frameworks/$(FRAMEWORK_NAME)$(FRAMEWORK_EXT)/$(FRAMEWORK_NAME)'\
+  GS_XE=$(BINDIR)/$(SOBINRELDIR)/$(GS_SONAME_MAJOR_MINOR)\
+  STDIO_IMPLEMENTATION=c\
+  DISPLAY_DEV=$(DD)$(SOOBJRELDIR)/display.dev\
Index: Portfile
===================================================================
--- Portfile	(revision 31281)
+++ Portfile	(working copy)
@@ -2,7 +2,7 @@
 
 PortSystem 1.0
 name        ghostscript
-version     8.60
+version     8.61
 homepage    http://www.cs.wisc.edu/~ghost/
 description GPL Ghostscript, An interpreter for PostScript and PDF
 categories  print
@@ -19,8 +19,12 @@
 distfiles   ${distname}.tar.gz:source \
         ghostscript-fonts-std-8.11.tar.gz:fonts \
         ghostscript-fonts-other-6.0.tar.gz:fonts
+patchfiles  patch-configure.diff \
+            patch-src_macos-fw.mak.diff \
+            patch-src_macosx.mak.diff \
+            patch-src_unix-aux.mak.diff
 
-checksums   ${distname}.tar.gz md5 ce7c276891411e0865e006f0310ea1ec \
+checksums   ${distname}.tar.gz md5 aa55ca90b891c1b3b7402a09a2146a87 \
         ghostscript-fonts-std-8.11.tar.gz md5 6865682b095f8c4500c54b285ff05ef6 \
         ghostscript-fonts-other-6.0.tar.gz md5 1a643ae62ef166562e4d422b1a601272
 
@@ -40,37 +44,63 @@
 
 build.target
 
-destroot.destdir    prefix=${destroot}/${prefix}
+destroot.violate_mtree  yes
 
 post-destroot   {
-        file copy ${workpath}/fonts ${destroot}/${prefix}/share/ghostscript
+        copy ${workpath}/fonts ${destroot}${prefix}/share/ghostscript/fonts
         }
 
+pre-activate {
+    # remove some files accidentally installed by gs 8.60. (#12637)
+    if {![variant_isset no_cups]} {
+        set renamed_files {}
+        foreach f {/private/etc/cups/pstoraster.convs
+                   /usr/libexec/cups/filter/pstopxl
+                   /usr/libexec/cups/filter/pstoraster
+                   /usr/share/cups/model/pxlcolor.ppd
+                   /usr/share/cups/model/pxlmono.ppd} {
+            if {[file exists ${f}]} {
+                if {[file exists ${f}.old]} {
+                    delete ${f}.old
+                }
+                move ${f} ${f}.old
+                lpush renamed_files ${f}
+            }
+        }
+        if {[llength ${renamed_files}]} {
+            ui_msg "\nThe following files have been renamed (and should be removed):"
+            foreach f ${renamed_files} {
+                ui_msg "    ${f} -> ${f}.old"
+            }
+            ui_msg ""
+        }
+    }
+}
+
 # Added variant that build the Ghostscript framework. (Thanks, Sal!)
 variant gslib   {
         post-patch {
-            cd ${workpath}/${name}-${version}
-            reinplace "s|/Library/Frameworks|${destroot}${prefix}/Library/Frameworks|" \
-                        src/macosx.mak
+            foreach f {src/macosx.mak src/macos-fw.mak} {
+                reinplace "s|@@DESTROOT@@|${destroot}|" ${worksrcpath}/${f}
+                reinplace "s|@@PREFIX@@|${prefix}|" ${worksrcpath}/${f}
+            }
         }
       
         post-build {
-            cd ${workpath}/${name}-${version}
-            file rename Makefile Makefile.CONFIGURE
-            file link Makefile src/macosx.mak
-            system "make framework"
-            file delete Makefile
-            file rename Makefile.CONFIGURE Makefile
+            move ${worksrcpath}/Makefile ${worksrcpath}/Makefile.CONFIGURE
+            ln -s ${worksrcpath}/src/macosx.mak ${worksrcpath}/Makefile
+            system "cd ${worksrcpath} && make framework"
+            delete ${worksrcpath}/Makefile
+            move ${worksrcpath}/Makefile.CONFIGURE ${worksrcpath}/Makefile
         }
       
         post-destroot {
-            cd ${workpath}/${name}-${version}
             xinstall -m 755 -d ${destroot}${prefix}/Library/Frameworks
-            file rename Makefile Makefile.CONFIGURE
-            file link Makefile src/macosx.mak
-            system "make framework_install"
-            file delete Makefile
-            file rename Makefile.CONFIGURE Makefile
+            move ${worksrcpath}/Makefile ${worksrcpath}/Makefile.CONFIGURE
+            ln -s ${worksrcpath}/src/macosx.mak ${worksrcpath}/Makefile
+            system "cd ${worksrcpath} && make framework_install"
+            delete ${worksrcpath}/Makefile
+            move ${worksrcpath}/Makefile.CONFIGURE ${worksrcpath}/Makefile
         }
 }
 
