summaryrefslogtreecommitdiff
path: root/print/ghostscript9-x11
diff options
context:
space:
mode:
authorHiroki Sato <hrs@FreeBSD.org>2015-08-22 17:48:35 +0000
committerHiroki Sato <hrs@FreeBSD.org>2015-08-22 17:48:35 +0000
commit27470e1676e69455acf06ae25ebd42ebd5bdecdb (patch)
tree445c3e315f03aa972de87391f921c655e4634f60 /print/ghostscript9-x11
parentRemove textproc/prosper. The latest version is included in (diff)
- Split ghostscript into X11-independent and -dependent parts:
* print/ghostscript{7,8,9,9-agpl}-base Installs Ghostscript binary, libgs, and related files. These ports do not depend on X11 libraries (i.e. x11* devices are not available). USES=ghostscript will set dependency on one of them depending on GHOSTSCRIPT_DEFAULT. The default device is set to "display" or "bbox". * print/ghostscript{7,8,9,9-agpl}-x11 Installs a shared library which provides X11 support to the installed Ghostscript binaries. x11* devices will be enabled when the library is available. This depends on *-base (RUN_DEPENDS). USES=ghostscript:x11 will set dependency on one of them. - Fix integer overflow reported as CVE-2015-3228. - Update Uses/ghostscript.mk: * Add x11 keyword. nox11 keyword is now obsolete. * Use packagename in *_DEPENDS line to prevent relationship between -base and -x11 packages from being broken. - Fix x11/nox11 keyword and bump PORTREVISION in ports using USES=ghostscript to update dependency of pre-compiled packages.
Diffstat (limited to 'print/ghostscript9-x11')
-rw-r--r--print/ghostscript9-x11/Makefile58
-rw-r--r--print/ghostscript9-x11/distinfo4
-rw-r--r--print/ghostscript9-x11/files/patch-base-Makefile.in141
-rw-r--r--print/ghostscript9-x11/files/patch-base-configure.ac121
-rw-r--r--print/ghostscript9-x11/files/patch-base-devs.mak33
-rw-r--r--print/ghostscript9-x11/files/patch-base-gdevl256.c15
-rw-r--r--print/ghostscript9-x11/files/patch-base-gdevperm.c19
-rw-r--r--print/ghostscript9-x11/files/patch-base-gdevplib.c14
-rw-r--r--print/ghostscript9-x11/files/patch-base-gp_unix.c47
-rw-r--r--print/ghostscript9-x11/files/patch-base-gs.mak11
-rw-r--r--print/ghostscript9-x11/files/patch-base-gsicc_create.c10
-rw-r--r--print/ghostscript9-x11/files/patch-base-gsmalloc.c11
-rw-r--r--print/ghostscript9-x11/files/patch-base-gxobj.h18
-rw-r--r--print/ghostscript9-x11/files/patch-base-lib.mak11
-rw-r--r--print/ghostscript9-x11/files/patch-base-unix-dll.mak13
-rw-r--r--print/ghostscript9-x11/files/patch-base-unixinst.mak20
-rw-r--r--print/ghostscript9-x11/pkg-descr8
17 files changed, 554 insertions, 0 deletions
diff --git a/print/ghostscript9-x11/Makefile b/print/ghostscript9-x11/Makefile
new file mode 100644
index 000000000000..67d427aa4a4f
--- /dev/null
+++ b/print/ghostscript9-x11/Makefile
@@ -0,0 +1,58 @@
+# $FreeBSD$
+
+PORTNAME= ghostscript
+PORTVERSION= 9.06
+PORTREVISION= 11
+CATEGORIES= print
+MASTER_SITES= http://downloads.ghostscript.com/public/ \
+ SF/ghostscript/GPL%20Ghostscript/${PORTVERSION}/
+PKGNAMESUFFIX= 9-x11
+DIST_SUBDIR= ${PORTNAME}
+
+MAINTAINER= doceng@FreeBSD.org
+COMMENT= Ghostscript 9.x PostScript interpreter, X11 support
+
+LICENSE= GPLv3
+
+CONFLICTS_INSTALL= \
+ gambc-[0-9]* \
+ ghostscript[789]-[0-9]* \
+ ghostscript[789]-nox11-[0-9]* \
+ ghostscript9-agpl-[0-9]* \
+ ghostscript9-agpl-nox11-[0-9]*
+
+USES= autoreconf ghostscript:9 gmake tar:bzip2
+USE_LDCONFIG= yes
+USE_XORG= ice sm x11 xext xt
+EXTRACT_AFTER_ARGS= ${EXCLUDE_DIRS:S/^/--exclude /}
+GNU_CONFIGURE= yes
+MAKE_ENV= CFLAGS_STANDARD="${CFLAGS}" \
+ XLDFLAGS="${XLDFLAGS}"
+CONFIGURE_ENV= ${MAKE_ENV}
+CONFIGURE_ARGS= --disable-compile-inits \
+ --disable-contrib \
+ --enable-dynamic \
+ --disable-freetype \
+ --without-system-libtiff \
+ --without-ijs \
+ --without-libidn \
+ --without-jasper \
+ --without-libpaper \
+ --with-x \
+ --x-includes=${LOCALBASE}/include \
+ --x-libraries=${LOCALBASE}/lib \
+ --with-drivers=""
+CPPFLAGS+= -I${LOCALBASE}/include
+LDFLAGS+= -L${LOCALBASE}/lib
+XLDFLAGS= -lpthread
+ALL_TARGET= ./obj/X11.so
+INSTALL_TARGET= install-shared
+PLIST_FILES= ${GS_LIBDIR}/X11.so
+
+GS_LIBDIR= lib/${PORTNAME}/${PORTVERSION}
+EXCLUDE_DIRS= freetype jbig2dec jpeg expat jasper lcms lcms2 libpng tiff zlib
+
+pre-build:
+ ${MKDIR} ${WRKSRC}/obj
+
+.include <bsd.port.mk>
diff --git a/print/ghostscript9-x11/distinfo b/print/ghostscript9-x11/distinfo
new file mode 100644
index 000000000000..9fc6dde08cfd
--- /dev/null
+++ b/print/ghostscript9-x11/distinfo
@@ -0,0 +1,4 @@
+SHA256 (ghostscript/ghostscript-9.06.tar.bz2) = 05acd1b576899572ef8ecbc25637cf73cbd0be267e651732db3012db33088e04
+SIZE (ghostscript/ghostscript-9.06.tar.bz2) = 29246039
+SHA256 (ghostscript/epag-3.09.tar.gz) = ad10eca44c781a5851d5a8993dcd95b2e2b99392cbf2c8372a5a658f3b991b3b
+SIZE (ghostscript/epag-3.09.tar.gz) = 12858
diff --git a/print/ghostscript9-x11/files/patch-base-Makefile.in b/print/ghostscript9-x11/files/patch-base-Makefile.in
new file mode 100644
index 000000000000..8d8299fcb21d
--- /dev/null
+++ b/print/ghostscript9-x11/files/patch-base-Makefile.in
@@ -0,0 +1,141 @@
+--- base/Makefile.in.orig 2012-08-08 17:01:36.000000000 +0900
++++ base/Makefile.in 2015-08-21 12:42:47.554688000 +0900
+@@ -49,9 +49,9 @@
+ # the directories also define the default search path for the
+ # initialization files (gs_*.ps) and the fonts.
+
+-INSTALL = $(GLSRCDIR)/instcopy -c
+-INSTALL_PROGRAM = $(INSTALL) -m 755
+-INSTALL_DATA = $(INSTALL) -m 644
++INSTALL_PROGRAM = ${BSD_INSTALL_PROGRAM}
++INSTALL_SCRIPT = ${BSD_INSTALL_SCRIPT}
++INSTALL_DATA = ${BSD_INSTALL_DATA}
+ INSTALL_SHARED = @INSTALL_SHARED@
+
+ prefix = @prefix@
+@@ -202,7 +202,7 @@
+ # some older JPEG streams that violate the standard. If the JPEG
+ # library built from local sources, the patch will be applied.
+
+-SHARE_JPEG=@SHARE_LIBJPEG@
++SHARE_JPEG=1
+ JPEG_NAME=jpeg
+
+ # Define the directory where the PNG library sources are stored,
+@@ -210,12 +210,12 @@
+ # You may need to change this if the libpng version changes.
+ # See png.mak for more information.
+
+-SHARE_LIBPNG=@SHARE_LIBPNG@
++SHARE_LIBPNG=1
+ PNGSRCDIR=@LIBPNGDIR@
+ LIBPNG_NAME=png
+
+ # libtiff
+-SHARE_LIBTIFF=@SHARE_LIBTIFF@
++SHARE_LIBTIFF=1
+ TIFFSRCDIR=@LIBTIFFDIR@
+ TIFFPLATFORM=unix
+ TIFFCONFIG_SUFFIX=
+@@ -224,7 +224,7 @@
+ # Define the directory where the zlib sources are stored.
+ # See zlib.mak for more information.
+
+-SHARE_ZLIB=@SHARE_ZLIB@
++SHARE_ZLIB=1
+ ZSRCDIR=@ZLIBDIR@
+ #ZLIB_NAME=gz
+ ZLIB_NAME=z
+@@ -251,7 +251,7 @@
+ JPX_LIB=@JPX_DECODER@
+ SHARE_JPX=@SHARE_JPX@
+ JPXSRCDIR=@JPXDIR@
+-JPX_CFLAGS=@JPX_AUTOCONF_CFLAGS@
++JPX_CFLAGS=@JPX_AUTOCONF_CFLAGS@ -ffast-math -DOPJ_STATIC -std=c99
+
+ # uncomment the following three lines and one of the last two to
+ # compile in the Luratech lwf_jp2 codec
+@@ -331,7 +331,7 @@
+ # Define the added flags for standard, debugging, profiling
+ # and shared object builds.
+
+-CFLAGS_STANDARD=@OPT_CFLAGS@
++CFLAGS_STANDARD?=@OPT_CFLAGS@
+ CFLAGS_DEBUG=@DBG_CFLAGS@
+ CFLAGS_PROFILE=-pg @OPT_CFLAGS@
+ CFLAGS_SO=@DYNAMIC_CFLAGS@
+@@ -382,7 +382,7 @@
+ # Solaris may need -lnsl -lsocket -lposix4.
+ # (Libraries required by individual drivers are handled automatically.)
+
+-EXTRALIBS=$(XTRALIBS) @LIBS@ @DYNAMIC_LIBS@ @FONTCONFIG_LIBS@ @FT_LIBS@
++EXTRALIBS=$(XTRALIBS) @LIBS@ @DYNAMIC_LIBS@ @FONTCONFIG_LIBS@ @FT_LIBS@ -Wl,-export-dynamic
+
+ # Define the standard libraries to search at the end of linking.
+ # Most platforms require -lpthread for the POSIX threads library;
+@@ -426,7 +426,7 @@
+ # the pthread library. Otherwise use SYNC=nosync
+ #SYNC=posync
+ #SYNC=nosync
+-SYNC=@SYNC@
++SYNC=nosync
+
+ # programs we use
+ RM=rm -f
+@@ -518,27 +518,27 @@
+ #DEVICE_DEVS20=$(DD)cljet5.dev $(DD)cljet5c.dev
+ #DEVICE_DEVS21=$(DD)spotcmyk.dev $(DD)devicen.dev $(DD)xcf.dev $(DD)psdcmyk.dev $(DD)psdrgb.dev
+ DEVICE_DEVS=$(DISPLAY_DEV) @X11_DEVS@
+-DEVICE_DEVS1=@F_DEVS@
+-DEVICE_DEVS2=@P_DEVS@
+-DEVICE_DEVS3=@CUPS_DEVS@
+-DEVICE_DEVS4=@IJS_DEVS@
+-DEVICE_DEVS5=@OMNIDEVS@
+-DEVICE_DEVS6=@PNG_DEVS@
+-DEVICE_DEVS7=@JBIG2_DEVS@
+-DEVICE_DEVS8=@SVG_DEVS@
+-DEVICE_DEVS9=
+-DEVICE_DEVS10=
+-DEVICE_DEVS11=
+-DEVICE_DEVS12=
+-DEVICE_DEVS13=
+-DEVICE_DEVS14=
+-DEVICE_DEVS15=
+-DEVICE_DEVS16=
+-DEVICE_DEVS17=
+-DEVICE_DEVS18=
+-DEVICE_DEVS19=
+-DEVICE_DEVS20=
+-DEVICE_DEVS21=
++#DEVICE_DEVS1=@F_DEVS@
++#DEVICE_DEVS2=@P_DEVS@
++#DEVICE_DEVS3=@CUPS_DEVS@
++#DEVICE_DEVS4=@IJS_DEVS@
++#DEVICE_DEVS5=@OMNIDEVS@
++#DEVICE_DEVS6=@PNG_DEVS@
++#DEVICE_DEVS7=@JBIG2_DEVS@
++#DEVICE_DEVS8=@SVG_DEVS@
++#DEVICE_DEVS9=
++#DEVICE_DEVS10=
++#DEVICE_DEVS11=
++#DEVICE_DEVS12=
++#DEVICE_DEVS13=
++#DEVICE_DEVS14=
++#DEVICE_DEVS15=
++#DEVICE_DEVS16=
++#DEVICE_DEVS17=
++#DEVICE_DEVS18=
++#DEVICE_DEVS19=
++#DEVICE_DEVS20=
++#DEVICE_DEVS21=
+
+
+ # Shared library target to build.
+@@ -601,7 +601,6 @@
+ include $(GLSRCDIR)/lwf_jp2.mak
+ include $(GLSRCDIR)/openjpeg.mak
+ include $(GLSRCDIR)/icclib.mak
+-include $(GLSRCDIR)/$(WHICH_CMS).mak
+ include $(GLSRCDIR)/ijs.mak
+ @LCUPSINCLUDE@
+ @LCUPSIINCLUDE@
diff --git a/print/ghostscript9-x11/files/patch-base-configure.ac b/print/ghostscript9-x11/files/patch-base-configure.ac
new file mode 100644
index 000000000000..10d21bc83a3a
--- /dev/null
+++ b/print/ghostscript9-x11/files/patch-base-configure.ac
@@ -0,0 +1,121 @@
+--- base/configure.ac.orig 2012-08-08 17:01:36.000000000 +0900
++++ base/configure.ac 2015-08-21 12:40:57.576690000 +0900
+@@ -623,35 +623,6 @@
+ AC_SUBST(FT_CFLAGS)
+ AC_SUBST(FT_LIBS)
+
+-AC_MSG_CHECKING([for local jpeg library source])
+-dnl At present, we give the local source priority over the shared
+-dnl build, so that the D_MAX_BLOCKS_IN_MCU patch will be applied.
+-dnl A more sophisticated approach would be to test the shared lib
+-dnl to see whether it has already been patched.
+-LIBJPEGDIR=src
+-if test -f jpeg/jpeglib.h; then
+- AC_MSG_RESULT([jpeg])
+- SHARE_LIBJPEG=0
+- LIBJPEGDIR=jpeg
+-elif test -f jpeg-6b/jpeglib.h; then
+- AC_MSG_RESULT([jpeg-6b])
+- SHARE_LIBJPEG=0
+- LIBJPEGDIR=jpeg-6b
+-else
+- AC_MSG_RESULT([no])
+- AC_CHECK_LIB(jpeg, jpeg_set_defaults, [
+- AC_CHECK_HEADERS([jpeglib.h], [SHARE_LIBJPEG=1])
+- ])
+-fi
+-if test -z "$SHARE_LIBJPEG"; then
+- AC_MSG_ERROR([I wasn't able to find a copy
+- of the jpeg library. This is required for compiling
+- ghostscript. Please download a copy of the source,
+- e.g. from http://www.ijg.org/, unpack it at the
+- top level of the gs source tree, and rename
+- the directory to 'jpeg'.
+- ])
+-fi
+ AC_SUBST(SHARE_LIBJPEG)
+ AC_SUBST(LIBJPEGDIR)
+ dnl check for the internal jpeg memory header
+@@ -731,44 +702,6 @@
+ AC_SUBST(LIBPNGDIR)
+ #AC_SUBST(PNGDEVS)
+
+-WHICHLCMS=
+-
+-AC_ARG_WITH([lcms], AC_HELP_STRING([--with-lcms],
+- [try to use LittleCMS 1.x instead of the default of LittleCMS 2.x]))
+-
+-if test x$with_lcms != xyes; then
+- AC_MSG_CHECKING([for local lcms2 library source])
+- LCMS2DIR=lcms2
+- if test -f $LCMS2DIR/include/lcms2.h; then
+- AC_MSG_RESULT([yes])
+- SHARELCMS=0
+- WHICHLCMS=lcms2
+- else
+- AC_MSG_RESULT([no])
+- AC_MSG_CHECKING([for system lcms2 library])
+- AC_CHECK_LIB(lcms2, cmsCreateXYZProfile, [
+- AC_CHECK_HEADERS([lcms2.h], [LCMS2DIR="";SHARELCMS=1;WHICHLCMS=lcms2])
+- ])
+- fi
+-fi
+-
+-if test x$WHICHLCMS = x; then
+- AC_MSG_CHECKING([for local lcms library source])
+- LCMSDIR=lcms
+- SHARELCMS=0
+- if test -f $LCMSDIR/include/lcms.h; then
+- AC_MSG_RESULT([yes])
+- SHARELCMS=0
+- WHICHLCMS=lcms
+- else
+-
+- AC_MSG_ERROR([LittleCMS source not found!])
+- #AC_CHECK_LIB(lcms, cmsCreateXYZProfile, [
+- # AC_CHECK_HEADERS([lcms.h], [SHARELCMS=1;LCMSDIR=""])
+- # ])
+- fi
+-fi
+-
+ AC_SUBST(SHARELCMS)
+ AC_SUBST(WHICHLCMS)
+ AC_SUBST(LCMSDIR)
+@@ -1303,7 +1236,7 @@
+ X_DEVS=""
+ X_LIBS=""
+
+-if test x$no_x != xyes; then
++if test x$with_x != xno; then
+ if test "$x_libraries" = "/usr/lib"; then
+ echo "Ignoring X library directory \"$x_libraries\" requested by configure."
+ x_libraries="NONE"
+@@ -1701,7 +1634,12 @@
+ DBG_CFLAGS="$DYNAMIC_CFLAGS $DBG_CFLAGS"
+ ;;
+ *BSD)
+- DYNAMIC_DEVS="\$(GLOBJDIR)/X11.so"
++ if test "x$X_DEVS" != x; then
++ DYNAMIC_DEVS="\$(GLOBJDIR)/X11.so"
++ INSTALL_SHARED="install-shared"
++ else
++ DYNAMIC_DEVS=""
++ fi
+ DYNAMIC_FLAGS="-DGS_DEVS_SHARED -DGS_DEVS_SHARED_DIR=\\\"\$(gssharedir)\\\""
+ X11_DEVS=""
+ OPT_CFLAGS="$DYNAMIC_CFLAGS $OPT_CFLAGS"
+@@ -1758,11 +1696,11 @@
+ fontpath="${fontpath}:$datadir/fonts/default/TrueType"
+
+ # These font directories are used by IRIX...
+- fontpath="${fontpath}:/usr/lib/DPS/outline/base"
++ # fontpath="${fontpath}:/usr/lib/DPS/outline/base"
+
+ # These font directories are used by Solaris...
+- fontpath="${fontpath}:/usr/openwin/lib/X11/fonts/Type1"
+- fontpath="${fontpath}:/usr/openwin/lib/X11/fonts/TrueType"
++ # fontpath="${fontpath}:/usr/openwin/lib/X11/fonts/Type1"
++ # fontpath="${fontpath}:/usr/openwin/lib/X11/fonts/TrueType"
+
+ # This font directory is used by CUPS...
+ if test "x$CUPSCONFIG" != x; then
diff --git a/print/ghostscript9-x11/files/patch-base-devs.mak b/print/ghostscript9-x11/files/patch-base-devs.mak
new file mode 100644
index 000000000000..8a606f1e9588
--- /dev/null
+++ b/print/ghostscript9-x11/files/patch-base-devs.mak
@@ -0,0 +1,33 @@
+--- base/devs.mak.orig 2012-08-08 17:01:36.000000000 +0900
++++ base/devs.mak 2015-08-21 12:18:59.546901000 +0900
+@@ -434,10 +434,10 @@
+ ### NON PORTABLE, ONLY UNIX WITH GCC SUPPORT
+
+ $(GLOBJ)lvga256.so : $(lvga256_)
+- $(CCLD) $(LDFLAGS) -shared -o $(GLOBJ)lvga256.so $(lvga256_) -lvga -lvgagl
++ $(CCLD) $(LDFLAGS) -shared -o $(GLOBJ)lvga256.so $(lvga256_) -lvga -lvgagl $(XLDFLAGS)
+
+ $(GLOBJ)vgalib.so : $(vgalib_)
+- $(CCLD) $(LDFLAGS) -shared -o $(GLOBJ)vgalib.so $(vgalib_) -lvga -lvgagl
++ $(CCLD) $(LDFLAGS) -shared -o $(GLOBJ)vgalib.so $(vgalib_) -lvga -lvgagl $(XLDFLAGS)
+
+ ### -------------------------- The X11 device -------------------------- ###
+
+@@ -479,7 +479,7 @@
+ # const/non-const cast required by the X headers that we can't work around.
+ $(GLOBJ)gdevxres.$(OBJ) : $(GLSRC)gdevxres.c $(std_h) $(x__h)\
+ $(gsmemory_h) $(gstypes_h) $(gxdevice_h) $(gdevx_h)
+- $(CC_NO_WARN) $(GLCCFLAGS) $(XINCLUDE) $(GLO_)gdevxres.$(OBJ) $(C_) $(GLSRC)gdevxres.c
++ $(GLCCSHARED) $(XINCLUDE) $(GLO_)gdevxres.$(OBJ) $(C_) $(GLSRC)gdevxres.c
+
+ # Alternate X11-based devices to help debug other drivers.
+ # x11alpha pretends to have 4 bits of alpha channel.
+@@ -535,7 +535,7 @@
+ ### NON PORTABLE, ONLY UNIX WITH GCC SUPPORT
+
+ $(GLOBJ)X11.so : $(x11alt_) $(x11_)
+- $(CCLD) $(LDFLAGS) -shared -o $(GLOBJ)X11.so $(x11alt_) $(x11_) -L/usr/X11R6/lib -lXt -lSM -lICE -lXext -lX11 $(XLIBDIRS)
++ $(CCLD) $(LDFLAGS) -shared -o $(GLOBJ)X11.so $(x11alt_) $(x11_) -L$(LOCALBASE)/lib -lXt -lSM -lICE -lXext -lX11 $(XLIBDIRS)
+
+ ###### --------------- Memory-buffered printer devices --------------- ######
+
diff --git a/print/ghostscript9-x11/files/patch-base-gdevl256.c b/print/ghostscript9-x11/files/patch-base-gdevl256.c
new file mode 100644
index 000000000000..d2fcd1b42baa
--- /dev/null
+++ b/print/ghostscript9-x11/files/patch-base-gdevl256.c
@@ -0,0 +1,15 @@
+--- base/gdevl256.c.orig 2011-07-17 19:57:32.000000000 +0900
++++ base/gdevl256.c 2011-07-17 19:57:39.000000000 +0900
+@@ -302,12 +302,3 @@
+ gl_line(x0, y0, x1, y1, color);
+ return 0;
+ }
+-
+-#ifdef GS_DEVS_SHARED
+-extern void gs_lib_register_device(const gx_device *dev);
+-void
+-gs_shared_init(void)
+-{
+- gs_lib_register_device(&gs_lvga256_device);
+-}
+-#endif
diff --git a/print/ghostscript9-x11/files/patch-base-gdevperm.c b/print/ghostscript9-x11/files/patch-base-gdevperm.c
new file mode 100644
index 000000000000..07870f314ac4
--- /dev/null
+++ b/print/ghostscript9-x11/files/patch-base-gdevperm.c
@@ -0,0 +1,19 @@
+--- base/gdevperm.c.orig 2012-02-08 17:48:48.000000000 +0900
++++ base/gdevperm.c 2012-02-13 00:44:23.000000000 +0900
+@@ -285,7 +285,7 @@
+ (strncmp((const char *)name, (const char *)str, name_size) == 0))
+
+ static int
+-perm_get_color_comp_index(const gx_device *pdev, const char *pname,
++perm_get_color_comp_index(gx_device *pdev, const char *pname,
+ int name_size, int component_type)
+ {
+ const gx_device_perm_t * const dev = (const gx_device_perm_t *)pdev;
+@@ -332,7 +332,6 @@
+ perm_decode_color(gx_device *dev, gx_color_index color, gx_color_value *out)
+ {
+ int bpc = 8;
+- int drop = sizeof(gx_color_value) * 8 - bpc;
+ int mask = (1 << bpc) - 1;
+ int i = 0;
+ int ncomp = dev->color_info.num_components;
diff --git a/print/ghostscript9-x11/files/patch-base-gdevplib.c b/print/ghostscript9-x11/files/patch-base-gdevplib.c
new file mode 100644
index 000000000000..96a096337dd3
--- /dev/null
+++ b/print/ghostscript9-x11/files/patch-base-gdevplib.c
@@ -0,0 +1,14 @@
+--- base/gdevplib.c.orig 2012-02-08 17:48:47.000000000 +0900
++++ base/gdevplib.c 2012-02-13 01:23:46.000000000 +0900
+@@ -151,7 +151,11 @@
+
+ #ifdef TESTING_WITH_NO_BAND_DONOR
+
++#if !defined(__FreeBSD__)
+ #include <malloc.h>
++#else
++#include <stdlib.h>
++#endif
+
+ static void *my_buffer;
+
diff --git a/print/ghostscript9-x11/files/patch-base-gp_unix.c b/print/ghostscript9-x11/files/patch-base-gp_unix.c
new file mode 100644
index 000000000000..277ef51a22ab
--- /dev/null
+++ b/print/ghostscript9-x11/files/patch-base-gp_unix.c
@@ -0,0 +1,47 @@
+--- base/gp_unix.c.orig 2012-08-08 17:01:36.000000000 +0900
++++ base/gp_unix.c 2015-08-20 15:15:51.166042000 +0900
+@@ -52,6 +52,7 @@
+ * and applied as a patch (preferable).
+ */
+ #include <sys/types.h>
++#include <limits.h>
+ #include <dirent.h>
+ #include <dlfcn.h>
+ #include <string.h>
+@@ -61,26 +62,25 @@
+ {
+ DIR* dir = NULL;
+ struct dirent* dirent;
+- char buff[1024];
++ char buff[PATH_MAX];
+ char* pbuff;
+ void* handle;
+ void (*gs_shared_init)(void);
+
+- strncpy(buff, GS_DEVS_SHARED_DIR, sizeof(buff) - 2);
+- pbuff = buff + strlen(buff);
+- *pbuff++ = '/'; *pbuff = '\0';
+-
+ dir = opendir(GS_DEVS_SHARED_DIR);
+ if (dir == 0) return;
+
+ while ((dirent = readdir(dir)) != 0) {
+- strncpy(pbuff, dirent->d_name, sizeof(buff) - (pbuff - buff) - 1);
+- if ((handle = dlopen(buff, RTLD_NOW)) != 0) {
+- if ((gs_shared_init = dlsym(handle, "gs_shared_init")) != 0) {
++ snprintf(buff, sizeof(buff), "%s/%s", GS_DEVS_SHARED_DIR, dirent->d_name);
++ pbuff = buff + strlen(buff) - 3;
++ if (strcmp(pbuff, ".so") != 0)
++ continue;
++ handle = dlopen(buff, RTLD_NOW);
++ if (handle == NULL)
++ continue;
++ gs_shared_init = dlsym(handle, "gs_shared_init");
++ if (gs_shared_init != NULL)
+ (*gs_shared_init)();
+- } else {
+- }
+- }
+ }
+
+ closedir(dir);
diff --git a/print/ghostscript9-x11/files/patch-base-gs.mak b/print/ghostscript9-x11/files/patch-base-gs.mak
new file mode 100644
index 000000000000..50d31a63a2d2
--- /dev/null
+++ b/print/ghostscript9-x11/files/patch-base-gs.mak
@@ -0,0 +1,11 @@
+--- base/gs.mak.orig 2012-08-08 17:01:36.000000000 +0900
++++ base/gs.mak 2012-10-14 02:29:03.000000000 +0900
+@@ -437,7 +437,7 @@
+ ld_tr=$(GLGENDIR)$(D)ld.tr
+ $(ld_tr) : \
+ $(GS_MAK) $(TOP_MAKEFILES) $(GLSRCDIR)$(D)version.mak $(GENCONF_XE) $(ECHOGS_XE) $(devs_tr) $(DEVS_ALL) $(GLGENDIR)$(D)libcore.dev
+- $(EXP)$(GENCONF_XE) $(devs_tr) -h $(gconfxx_h) $(CONFILES) $(CONFLDTR) $(ld_tr)
++ $(EXP)$(GENCONF_XE) $(devs_tr) -h /dev/stdout $(CONFILES) $(CONFLDTR) $(ld_tr) | awk 'BEGIN{j=0; p=1;} /jpeg_device/ {if(j++ > 0) p=0;} // { if(p==1) { print; } else { p=1 } }' > $(gconfxx_h)
+ $(EXP)$(ECHOGS_XE) -a $(gconfxx_h) $(GCONFIG_EXTRAS)
+
+ $(gconfxx_h) : $(ld_tr)
diff --git a/print/ghostscript9-x11/files/patch-base-gsicc_create.c b/print/ghostscript9-x11/files/patch-base-gsicc_create.c
new file mode 100644
index 000000000000..82bfee6c37ef
--- /dev/null
+++ b/print/ghostscript9-x11/files/patch-base-gsicc_create.c
@@ -0,0 +1,10 @@
+--- base/gsicc_create.c.orig 2011-08-05 20:12:20.000000000 +0900
++++ base/gsicc_create.c 2011-12-06 15:23:14.000000000 +0900
+@@ -113,6 +113,7 @@
+
+ */
+
++#include <sys/types.h>
+ #include "icc34.h" /* Note this header is needed even if lcms is not
+ compiled as default CMS */
+ #include "string_.h"
diff --git a/print/ghostscript9-x11/files/patch-base-gsmalloc.c b/print/ghostscript9-x11/files/patch-base-gsmalloc.c
new file mode 100644
index 000000000000..93bb2a449788
--- /dev/null
+++ b/print/ghostscript9-x11/files/patch-base-gsmalloc.c
@@ -0,0 +1,11 @@
+--- base/gsmalloc.c.orig 2015-07-24 09:41:05.295969000 +0900
++++ base/gsmalloc.c 2015-07-24 09:41:15.146305000 +0900
+@@ -178,7 +178,7 @@
+ } else {
+ uint added = size + sizeof(gs_malloc_block_t);
+
+- if (mmem->limit - added < mmem->used)
++ if (added <= size || mmem->limit - added < mmem->used)
+ set_msg("exceeded limit");
+ else if ((ptr = (byte *) Memento_label(malloc(added), cname)) == 0)
+ set_msg("failed");
diff --git a/print/ghostscript9-x11/files/patch-base-gxobj.h b/print/ghostscript9-x11/files/patch-base-gxobj.h
new file mode 100644
index 000000000000..529efe379df2
--- /dev/null
+++ b/print/ghostscript9-x11/files/patch-base-gxobj.h
@@ -0,0 +1,18 @@
+--- base/gxobj.h.orig Tue Mar 14 01:18:19 2006
++++ base/gxobj.h Fri Mar 23 14:41:44 2007
+@@ -109,11 +109,15 @@
+ * required by the hardware, regardless of the value of obj_align_mod.
+ * See gsmemraw.h for more information about this.
+ */
++#if !defined(__ia64__) && !defined(__amd64__)
+ #define obj_align_mod\
+ (((ARCH_ALIGN_MEMORY_MOD - 1) |\
+ (align_bitmap_mod - 1) |\
+ (obj_back_scale - 1)) + 1)
+ /* The only possible values for obj_align_mod are 4, 8, or 16.... */
++#else
++#define obj_align_mod 16
++#endif
+ #if obj_align_mod == 4
+ # define log2_obj_align_mod 2
+ #else
diff --git a/print/ghostscript9-x11/files/patch-base-lib.mak b/print/ghostscript9-x11/files/patch-base-lib.mak
new file mode 100644
index 000000000000..033be0a928e3
--- /dev/null
+++ b/print/ghostscript9-x11/files/patch-base-lib.mak
@@ -0,0 +1,11 @@
+--- base/lib.mak.orig 2015-08-21 12:20:36.687050000 +0900
++++ base/lib.mak 2015-08-21 12:20:57.497755000 +0900
+@@ -990,7 +990,7 @@
+ $(GLOBJ)gsparamx.$(OBJ) : $(AK) $(GLSRC)gsparamx.c $(string__h)\
+ $(gserrors_h) $(gsmemory_h) $(gsparam_h) $(gsparamx_h)\
+ $(gstypes_h) $(MAKEDIRS)
+- $(GLCC) $(GLO_)gsparamx.$(OBJ) $(C_) $(GLSRC)gsparamx.c
++ $(GLCCSHARED) $(GLO_)gsparamx.$(OBJ) $(C_) $(GLSRC)gsparamx.c
+
+ # Future replacement for gsparams.c
+ $(GLOBJ)gsparam2.$(OBJ) : $(GLSRC)gsparam2.c $(AK) $(gx_h)\
diff --git a/print/ghostscript9-x11/files/patch-base-unix-dll.mak b/print/ghostscript9-x11/files/patch-base-unix-dll.mak
new file mode 100644
index 000000000000..58a428806c59
--- /dev/null
+++ b/print/ghostscript9-x11/files/patch-base-unix-dll.mak
@@ -0,0 +1,13 @@
+--- base/unix-dll.mak.orig 2012-08-08 02:01:36.000000000 -0600
++++ base/unix-dll.mak 2014-04-18 12:12:34.000000000 -0600
+@@ -162,8 +162,8 @@
+ -mkdir -p $(DESTDIR)$(bindir)
+ -mkdir -p $(DESTDIR)$(libdir)
+ -mkdir -p $(DESTDIR)$(gsincludedir)
+- $(INSTALL_PROGRAM) $(GSSOC) $(DESTDIR)$(bindir)/$(GSSOC_XENAME)
+- $(INSTALL_PROGRAM) $(GSSOX) $(DESTDIR)$(bindir)/$(GSSOX_XENAME)
++ $(INSTALL_PROGRAM) -s $(GSSOC) $(DESTDIR)$(bindir)/$(GSSOC_XENAME)
++ $(INSTALL_PROGRAM) -s $(GSSOX) $(DESTDIR)$(bindir)/$(GSSOX_XENAME)
+ $(INSTALL_PROGRAM) $(BINDIR)/$(GS_SONAME_MAJOR_MINOR) $(DESTDIR)$(libdir)/$(GS_SONAME_MAJOR_MINOR)
+ $(RM_) $(DESTDIR)$(libdir)/$(GS_SONAME)
+ ln -s $(GS_SONAME_MAJOR_MINOR) $(DESTDIR)$(libdir)/$(GS_SONAME)
diff --git a/print/ghostscript9-x11/files/patch-base-unixinst.mak b/print/ghostscript9-x11/files/patch-base-unixinst.mak
new file mode 100644
index 000000000000..51d6baa31dad
--- /dev/null
+++ b/print/ghostscript9-x11/files/patch-base-unixinst.mak
@@ -0,0 +1,20 @@
+--- base/unixinst.mak.orig 2012-08-08 17:01:36.000000000 +0900
++++ base/unixinst.mak 2014-11-23 17:29:15.000000000 +0900
+@@ -45,7 +45,7 @@
+ wftopfa fixmswrd.pl lprsetup.sh pj-gs.sh pv.sh sysvlp.sh unix-lpr.sh ;\
+ do if ( test -f $(PSLIBDIR)/$$f ); then \
+ (cat $(PSLIBDIR)/$$f | sed -e "s/GS_EXECUTABLE=gs/GS_EXECUTABLE=$(GS)/" > $(PSOBJDIR)/$$f); \
+- $(INSTALL_PROGRAM) $(PSOBJDIR)/$$f $(DESTDIR)$(scriptdir)/$$f; \
++ $(INSTALL_SCRIPT) $(PSOBJDIR)/$$f $(DESTDIR)$(scriptdir)/$$f; \
+ fi;\
+ done'
+
+@@ -142,7 +142,7 @@
+ done'
+
+ # install the man pages for each locale
+-MAN_LCDIRS=. de
++MAN_LCDIRS=.
+ MAN1_LINKS_PS2PS=eps2eps
+ MAN1_LINKS_PS2PDF=ps2pdf12 ps2pdf13 ps2pdf14
+ MAN1_LINKS_GSLP=gsbj gsdj gsdj500 gslj
diff --git a/print/ghostscript9-x11/pkg-descr b/print/ghostscript9-x11/pkg-descr
new file mode 100644
index 000000000000..8f9b84cf413c
--- /dev/null
+++ b/print/ghostscript9-x11/pkg-descr
@@ -0,0 +1,8 @@
+This package installs X11 support library which adds the following
+devices to the installed Ghostscript:
+
+ x11, x11alpha. x11cmyk, x11mono, x11_, x11alt_, x11cmyk2, x11cmyk4,
+ x11cmyk8, x11rg16x, x11rg32x, x11gray2, and x11gray4.
+
+WWW: http://www.cs.wisc.edu/~ghost/doc/GPL/index.htm
+ http://www.ghostscript.com/