This removes the cups flavor from ghostscript and instead enables the cups driver for all flavors, using dlopen(3) to load the cups libraries.
ajacoutot@ already tested the modified cups driver with a previous version of the diff; this new one just adds the necessary changes to actually get rid of -cups. ok? Ciao, Kili Index: Makefile =================================================================== RCS file: /cvs/ports/print/ghostscript/gnu/Makefile,v retrieving revision 1.58 diff -u -p -r1.58 Makefile --- Makefile 28 Oct 2008 17:53:42 -0000 1.58 +++ Makefile 12 Nov 2008 15:08:47 -0000 @@ -4,6 +4,7 @@ COMMENT= GNU PostScript interpreter VERSION= 8.63 DISTNAME= ghostscript-${VERSION} +PKGNAME= ${DISTNAME}p0 CATEGORIES= print lang SHARED_LIBS= gs 11.0 @@ -13,7 +14,7 @@ HOMEPAGE= http://www.cs.wisc.edu/~ghost/ MAINTAINER= Matthias Kilian <[EMAIL PROTECTED]> -FLAVORS= a4 gtk no_x11 cups +FLAVORS= a4 gtk no_x11 FLAVOR?= FLAVOR_STRING= ${FLAVOR_EXT:S/-/,/g} @@ -32,7 +33,7 @@ WANTLIB= m c pthread z MODULES= converters/libiconv RUN_DEPENDS= :ghostscript-fonts-*:print/ghostscript/gnu-fonts - +BUILD_DEPENDS= ::print/cups LIB_DEPENDS= jpeg.>=62::graphics/jpeg \ png.>=6::graphics/png \ ijs::print/ijs @@ -46,6 +47,10 @@ CFLAGS+= -DSYS_TYPES_HAS_STDINT_TYPES \ MAKE_FLAGS= BINDIR=./obj \ CFLAGS_STANDARD='${CFLAGS} -fPIC' \ + CUPSCFLAGS="$$(cups-config --cflags)" \ + CUPSSERVERBIN="$$(cups-config --serverbin)" \ + CUPSSERVERROOT="$$(cups-config --serverroot)" \ + CUPSDATA="$$(cups-config --datadir)" \ DEVICE_DEVS='${DEVICES:=$(DD)%.dev}' \ EXTRALIBS="${EXTRALIBS}" \ GLGENDIR=./obj \ @@ -98,11 +103,8 @@ WANTLIB+= Xcomposite Xcursor Xdamage Xau Xrandr Xrender atk-1.0 cairo expat fontconfig freetype \ glib-2.0 glitz gmodule-2.0 gobject-2.0 pango-1.0 \ pangocairo-1.0 pangoft2-1.0 pixman-1 -MAKE_FLAGS+= SOC_CFLAGS="$$(pkg-config gtk+-2.0 --cflags)" -# This one is used in the addition of SOC_LIBS to MAKE_FLAGS later. -# We need this stunt to get gsc and gsx linked correctly when the cups -# flavor is enabled. -SOC_LIBS= $$(pkg-config gtk+-2.0 --libs) -pthread +MAKE_FLAGS+= SOC_CFLAGS="$$(pkg-config gtk+-2.0 --cflags)" \ + SOC_LIBS="$$(pkg-config gtk+-2.0 --libs) -pthread" ALL_TARGET= so INSTALL_TARGET= install install-so NOT_FOR_ARCHS= ${NO_SHARED_ARCHS} @@ -115,22 +117,6 @@ WANTLIB+= X11 Xt Xext DEVICES+= ${X11_DEVICES} .endif -.if ${FLAVOR:L:Mcups} -LIB_DEPENDS+= cups.>=3,cupsimage.>=2::print/cups -CUPSLIBS= $$(cups-config --image --libs) -EXTRALIBS+= ${CUPSLIBS} -SOC_LIBS+= ${CUPSLIBS} -DEVICES+= ${CUPS_DEVICES} -WANTLIB+= crypto ssl tiff -MAKE_FLAGS+= CUPSCFLAGS="$$(cups-config --cflags)" \ - CUPSSERVERBIN="$$(cups-config --serverbin)" \ - CUPSSERVERROOT="$$(cups-config --serverroot)" \ - CUPSDATA="$$(cups-config --datadir)" -.endif - -SOC_LIBS?= -MAKE_FLAGS+= SOC_LIBS="${SOC_LIBS}" - NO_REGRESS= Yes # Avoid surprises in update-patches. @@ -174,11 +160,7 @@ post-install: ln -sf ps2pdf.1 ps2pdf13.1 && \ ln -sf ps2pdf.1 ps2pdf14.1 && \ ln -sf ps2ps.1 eps2eps.1 -.if ${FLAVOR:L:Mcups} mv ${DESTDIR}/etc/cups/* ${PREFIX}/share/ghostscript/${VERSION}/examples -.else - rm -rf ${PREFIX}/libexec/cups -.endif rm -rf ${DESTDIR}/etc/cups # Device list based on configure.ac: @@ -291,7 +273,7 @@ DEVICES+= bit bitcmyk bitrgb bitrgbtags DEVICES+= ijs # Cups -CUPS_DEVICES= cups +DEVICES+= cups # gtk (display driver) GTK_DEVICES= display Index: patches/patch-cups_gdevcups_c =================================================================== RCS file: patches/patch-cups_gdevcups_c diff -N patches/patch-cups_gdevcups_c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ patches/patch-cups_gdevcups_c 12 Nov 2008 15:08:47 -0000 @@ -0,0 +1,150 @@ +$OpenBSD$ +--- cups/gdevcups.c.orig Mon May 14 20:22:09 2007 ++++ cups/gdevcups.c Thu Oct 30 15:47:00 2008 +@@ -69,6 +69,7 @@ + #include "gsexit.h" + #include "arch.h" + ++#include <dlfcn.h> + #include <stdlib.h> + #include <ctype.h> + #include <cups/raster.h> +@@ -87,7 +88,7 @@ + + #ifdef CUPS_RASTER_SYNCv1 + # define cups_page_header_t cups_page_header2_t +-# define cupsRasterWriteHeader cupsRasterWriteHeader2 ++# define cupsRasterWriteHeader cups->cupsRasterWriteHeader2 + #else + /* The RGBW colorspace is not defined until CUPS 1.2... */ + # define CUPS_CSPACE_RGBW 17 +@@ -204,6 +205,14 @@ typedef struct gx_device_cups_s + cups_raster_t *stream; /* Raster stream */ + cups_page_header_t header; /* PostScript page device info */ + int landscape; /* Non-zero if this is landscape */ ++ ++ /* cups stubs, initialized in cups_open() */ ++ int libCupsReady; ++ void (*cupsRasterClose) (cups_raster_t *); ++ cups_raster_t *(*cupsRasterOpen) (int, cups_mode_t); ++ unsigned (*cupsRasterWriteHeader2) (cups_raster_t *, cups_page_header2_t *); ++ unsigned (*cupsRasterWritePixels) (cups_raster_t *, unsigned char *, unsigned); ++ ppd_file_t *(*ppdOpenFile) (const char *); + } gx_device_cups; + + private gx_device_procs cups_procs = +@@ -352,7 +361,14 @@ gx_device_cups gs_cups_device = + 0, /* cupsRowCount */ + 0, /* cupsRowFeed */ + 0 /* cupsRowStep */ +- } ++ }, ++ 0, /* landscape */ ++ 0, /* libCupsReady */ ++ NULL, /* cupsRasterClose */ ++ NULL, /* cupsRasterOpen */ ++ NULL, /* cupsRasterWriteHeader2 */ ++ NULL, /* cupsRasterWritePixels */ ++ NULL /* ppdOpenFile */ + }; + + /* +@@ -426,7 +442,7 @@ cups_close(gx_device *pdev) /* I - Device info */ + + if (cups->stream != NULL) + { +- cupsRasterClose(cups->stream); ++ cups->cupsRasterClose(cups->stream); + cups->stream = NULL; + } + +@@ -2496,6 +2512,35 @@ cups_open(gx_device *pdev) /* I - Device info */ + + dprintf1("DEBUG2: cups_open(%p)\n", pdev); + ++ if (!cups->libCupsReady) { ++ void *handle; ++ if (!(handle = dlopen("libcupsimage.so.2", 0))) { ++ eprintf1("ERROR: libcupsimage.so.2: %s\n", dlerror()); ++ return -1; ++ } ++ if (!(cups->cupsRasterClose = dlsym(handle, "cupsRasterClose"))) { ++ eprintf1("ERROR: cupsRasterClose: %s\n", dlerror()); ++ return -1; ++ } ++ if (!(cups->cupsRasterOpen = dlsym(handle, "cupsRasterOpen"))) { ++ eprintf1("ERROR: cupsRasterOpen: %s\n", dlerror()); ++ return -1; ++ } ++ if (!(cups->cupsRasterWriteHeader2 = dlsym(handle, "cupsRasterWriteHeader2"))) { ++ eprintf1("ERROR: cupsRasterWriteHeader2: %s\n", dlerror()); ++ return -1; ++ } ++ if (!(cups->cupsRasterWritePixels = dlsym(handle, "cupsRasterWritePixels"))) { ++ eprintf1("ERROR: cupsRasterWritePixels: %s\n", dlerror()); ++ return -1; ++ } ++ if (!(cups->ppdOpenFile = dlsym(handle, "ppdOpenFile"))) { ++ eprintf1("ERROR: ppdOpenFile: %s\n", dlerror()); ++ return -1; ++ } ++ cups->libCupsReady = 1; ++ } ++ + cups->printer_procs.get_space_params = cups_get_space_params; + + if (cups->page == 0) +@@ -2510,7 +2555,7 @@ cups_open(gx_device *pdev) /* I - Device info */ + return (code); + + if (cupsPPD == NULL) +- cupsPPD = ppdOpenFile(getenv("PPD")); ++ cupsPPD = cups->ppdOpenFile(getenv("PPD")); + + return (0); + } +@@ -2597,7 +2642,7 @@ cups_print_pages(gx_device_printer *pdev, + + if (cups->stream == NULL) + { +- if ((cups->stream = cupsRasterOpen(fileno(cups->file), ++ if ((cups->stream = cups->cupsRasterOpen(fileno(cups->file), + CUPS_RASTER_WRITE)) == NULL) + { + perror("ERROR: Unable to open raster stream - "); +@@ -3669,7 +3714,7 @@ cups_print_chunked(gx_device_printer *pdev, + * Write the bitmap data to the raster stream... + */ + +- cupsRasterWritePixels(cups->stream, dst, cups->header.cupsBytesPerLine); ++ cups->cupsRasterWritePixels(cups->stream, dst, cups->header.cupsBytesPerLine); + } + else + { +@@ -3677,7 +3722,7 @@ cups_print_chunked(gx_device_printer *pdev, + * Write the scanline data to the raster stream... + */ + +- cupsRasterWritePixels(cups->stream, srcptr, cups->header.cupsBytesPerLine); ++ cups->cupsRasterWritePixels(cups->stream, srcptr, cups->header.cupsBytesPerLine); + } + } + } +@@ -4345,7 +4390,7 @@ cups_print_banded(gx_device_printer *pdev, + * Write the bitmap data to the raster stream... + */ + +- cupsRasterWritePixels(cups->stream, dst, cups->header.cupsBytesPerLine); ++ cups->cupsRasterWritePixels(cups->stream, dst, cups->header.cupsBytesPerLine); + } + } + +@@ -4716,7 +4761,7 @@ cups_print_planar(gx_device_printer *pdev, + * Write the bitmap data to the raster stream... + */ + +- cupsRasterWritePixels(cups->stream, dst, cups->header.cupsBytesPerLine); ++ cups->cupsRasterWritePixels(cups->stream, dst, cups->header.cupsBytesPerLine); + } + } + Index: pkg/DESCR =================================================================== RCS file: /cvs/ports/print/ghostscript/gnu/pkg/DESCR,v retrieving revision 1.7 diff -u -p -r1.7 DESCR --- pkg/DESCR 19 Nov 2007 20:06:56 -0000 1.7 +++ pkg/DESCR 12 Nov 2008 15:08:47 -0000 @@ -4,6 +4,5 @@ many different printers, file formats an Flavors: a4 - Build with support for A4 page size - cups - Build with the cups device and ps2raster gtk - Build with Gtk+ support no_x11 - Build without X support Index: pkg/PFRAG.cups =================================================================== RCS file: pkg/PFRAG.cups diff -N pkg/PFRAG.cups --- pkg/PFRAG.cups 19 Nov 2007 20:06:56 -0000 1.1 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -1,11 +0,0 @@ [EMAIL PROTECTED] $OpenBSD: PFRAG.cups,v 1.1 2007/11/19 20:06:56 kili Exp $ -libexec/cups/ -libexec/cups/filter/ -libexec/cups/filter/pstopxl -libexec/cups/filter/pstoraster -share/cups/ -share/cups/model/ -share/cups/model/pxlcolor.ppd -share/cups/model/pxlmono.ppd -share/ghostscript/${VERSION}/examples/pstoraster.convs [EMAIL PROTECTED] ${SYSCONFDIR}/cups/pstroaster.convs Index: pkg/PLIST =================================================================== RCS file: /cvs/ports/print/ghostscript/gnu/pkg/PLIST,v retrieving revision 1.14 diff -u -p -r1.14 PLIST --- pkg/PLIST 28 Oct 2008 17:53:42 -0000 1.14 +++ pkg/PLIST 12 Nov 2008 15:08:47 -0000 @@ -1,5 +1,6 @@ @comment $OpenBSD: PLIST,v 1.14 2008/10/28 17:53:42 kili Exp $ @pkgpath print/ghostscript/afpl${FLAVOR_STRING} [EMAIL PROTECTED] print/ghostscript/gnu${FLAVOR_STRING},cups bin/bdftops bin/dumphint bin/dvipdf @@ -32,6 +33,10 @@ bin/ps2ps2 bin/pv.sh bin/unix-lpr.sh bin/wftopfa +libexec/cups/ +libexec/cups/filter/ +libexec/cups/filter/pstopxl +libexec/cups/filter/pstoraster man/de/ man/de/man1/ @man man/de/man1/dvipdf.1 @@ -74,6 +79,10 @@ man/de/man1/ @man man/man1/ps2pdfwr.1 @man man/man1/ps2ps.1 @man man/man1/wftopfa.1 +share/cups/ +share/cups/model/ +share/cups/model/pxlcolor.ppd +share/cups/model/pxlmono.ppd share/ghostscript/${VERSION}/ share/ghostscript/${VERSION}/Resource/ share/ghostscript/${VERSION}/Resource/CMap/ @@ -423,6 +432,7 @@ share/ghostscript/${VERSION}/examples/do share/ghostscript/${VERSION}/examples/escher.ps share/ghostscript/${VERSION}/examples/golfer.eps share/ghostscript/${VERSION}/examples/grayalph.ps +share/ghostscript/${VERSION}/examples/pstoraster.convs share/ghostscript/${VERSION}/examples/ridt91.eps share/ghostscript/${VERSION}/examples/snowflak.ps share/ghostscript/${VERSION}/examples/tiger.eps @@ -658,5 +668,4 @@ share/ghostscript/${VERSION}/lib/winmaps share/ghostscript/${VERSION}/lib/wrfont.ps share/ghostscript/${VERSION}/lib/xlatmap share/ghostscript/${VERSION}/lib/zeroline.ps -%%cups%% %%gtk%%