Skip to content

Commit bfb61fc

Browse files
AdeshDeshmukhtillkamppeter
authored andcommitted
Support CUPS 3.x and PAPPL 2.x
1 parent 4afd157 commit bfb61fc

2 files changed

Lines changed: 30 additions & 8 deletions

File tree

‎Makefile‎

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,35 @@ statedir = $(localstatedir)/lib/ghostscript-printer-app
2121
spooldir = $(localstatedir)/spool/ghostscript-printer-app
2222
serverbin = $(prefix)/lib/ghostscript-printer-app
2323
resourcedir = $(prefix)/share/ghostscript-printer-app
24-
cupsserverbin = `cups-config --serverbin`
25-
unitdir := $(DESTDIR)`pkg-config --variable=systemdsystemunitdir systemd`
24+
# CUPS detection: prioritize CUPS 3.x (cups3), then CUPS 2.5 (cups), then legacy cups-config
25+
CUPS_PKG := $(shell pkg-config --exists cups3 && echo cups3 || (pkg-config --exists cups && echo cups || echo ""))
26+
27+
ifneq ($(CUPS_PKG),)
28+
CUPS_CFLAGS := $(shell pkg-config --cflags $(CUPS_PKG))
29+
CUPS_LDFLAGS :=
30+
CUPS_LIBS := $(shell pkg-config --libs $(CUPS_PKG))
31+
cupsserverbin := $(shell pkg-config --variable=prefix $(CUPS_PKG))/lib/cups
32+
else
33+
CUPSCONFIG := $(shell which cups-config 2>/dev/null)
34+
ifneq ($(CUPSCONFIG),)
35+
CUPS_CFLAGS := $(shell cups-config --cflags)
36+
CUPS_LDFLAGS := $(shell cups-config --ldflags)
37+
CUPS_LIBS := $(shell cups-config --image --libs 2>/dev/null || cups-config --libs)
38+
cupsserverbin := $(shell cups-config --serverbin)
39+
else
40+
cupsserverbin :=
41+
endif
42+
endif
43+
44+
# PAPPL detection: prioritize PAPPL 2.x (pappl2), fallback to PAPPL 1.x (pappl)
45+
PAPPL_PKG := $(shell pkg-config --exists pappl2 && echo pappl2 || echo pappl)
46+
47+
unitdir := $(DESTDIR)`pkg-config --variable=systemdsystemunitdir systemd 2>/dev/null || echo ""`
2648

2749

2850
# Compiler/linker options...
2951
OPTIM = -Os -g
30-
CFLAGS += `pkg-config --cflags pappl` `cups-config --cflags` `pkg-config --cflags libppd` `pkg-config --cflags libcupsfilters` `pkg-config --cflags libpappl-retrofit` $(OPTIM)
52+
CFLAGS += `pkg-config --cflags $(PAPPL_PKG)` $(CUPS_CFLAGS) `pkg-config --cflags libppd` `pkg-config --cflags libcupsfilters` `pkg-config --cflags libpappl-retrofit` $(OPTIM)
3153
ifdef VERSION
3254
CFLAGS += -DSYSTEM_VERSION_STR="\"$(VERSION)\""
3355
ifndef MAJOR
@@ -58,8 +80,8 @@ endif
5880
ifdef SNAP
5981
CFLAGS += -DSNAP=$(SNAP)
6082
endif
61-
LDFLAGS += $(OPTIM) `cups-config --ldflags`
62-
LIBS += `pkg-config --libs pappl` `cups-config --image --libs` `pkg-config --libs libppd` `pkg-config --libs libcupsfilters` `pkg-config --libs libpappl-retrofit`
83+
LDFLAGS += $(OPTIM) $(CUPS_LDFLAGS)
84+
LIBS += `pkg-config --libs $(PAPPL_PKG)` $(CUPS_LIBS) `pkg-config --libs libppd` `pkg-config --libs libcupsfilters` `pkg-config --libs libpappl-retrofit`
6385

6486

6587
# Targets...

‎ghostscript-printer-app.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ main(int argc, // I - Number of command-line arguments
149149
// Keeping vector formats (like PS -> PDF) is usually more desirable
150150
// but as many printers have buggy PS interpreters we prefer converting
151151
// PDF to Raster and not to PS
152-
spooling_conversions = cupsArrayNew(NULL, NULL);
152+
spooling_conversions = cupsArrayNew(NULL, NULL, NULL, 0, NULL, NULL);
153153

154154
// Special conversion rule for fxlinuxprint driver (Fuji Xerox
155155
// non-IPP-driverless PDF printers)
@@ -168,14 +168,14 @@ main(int argc, // I - Number of command-line arguments
168168
// PDF comes last because it is generally not streamable.
169169
// PostScript comes second as it is Ghostscript's streamable
170170
// input format.
171-
stream_formats = cupsArrayNew(NULL, NULL);
171+
stream_formats = cupsArrayNew(NULL, NULL, NULL, 0, NULL, NULL);
172172
cupsArrayAdd(stream_formats, (void *)&PR_STREAM_CUPS_RASTER);
173173
cupsArrayAdd(stream_formats, (void *)&PR_STREAM_POSTSCRIPT);
174174
cupsArrayAdd(stream_formats, (void *)&PR_STREAM_PDF);
175175

176176
// Array of regular expressions for driver priorization
177177
// For some printers the "(recommended)" is missing ...
178-
driver_selection_regex_list = cupsArrayNew(NULL, NULL);
178+
driver_selection_regex_list = cupsArrayNew(NULL, NULL, NULL, 0, NULL, NULL);
179179
cupsArrayAdd(driver_selection_regex_list, "-recommended-");
180180
cupsArrayAdd(driver_selection_regex_list, "-pdf-");
181181
cupsArrayAdd(driver_selection_regex_list, "-postscript-");

0 commit comments

Comments
 (0)