Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
132 lines (116 loc) · 3.74 KB
/
Copy pathMakefile
File metadata and controls
132 lines (116 loc) · 3.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#
# Makefile for the Ghostscript Printer Application
#
# Copyright © 2020-2021 by Till Kamppeter
# Copyright © 2020 by Michael R Sweet
#
# Licensed under Apache License v2.0. See the file "LICENSE" for more
# information.
#
# Version and
VERSION = 1.0
prefix = $(DESTDIR)/usr
localstatedir = $(DESTDIR)/var
includedir = $(prefix)/include
bindir = $(prefix)/bin
libdir = $(prefix)/lib
mandir = $(prefix)/share/man
ppddir = $(prefix)/share/ppd
statedir = $(localstatedir)/lib/ghostscript-printer-app
spooldir = $(localstatedir)/spool/ghostscript-printer-app
serverbin = $(prefix)/lib/ghostscript-printer-app
resourcedir = $(prefix)/share/ghostscript-printer-app
# CUPS detection: prioritize CUPS 3.x (cups3), then CUPS 2.5 (cups), then legacy cups-config
CUPS_PKG := $(shell pkg-config --exists cups3 && echo cups3 || (pkg-config --exists cups && echo cups || echo ""))
ifneq ($(CUPS_PKG),)
CUPS_CFLAGS := $(shell pkg-config --cflags $(CUPS_PKG))
CUPS_LDFLAGS :=
CUPS_LIBS := $(shell pkg-config --libs $(CUPS_PKG))
cupsserverbin := $(shell pkg-config --variable=prefix $(CUPS_PKG))/lib/cups
else
CUPSCONFIG := $(shell which cups-config 2>/dev/null)
ifneq ($(CUPSCONFIG),)
CUPS_CFLAGS := $(shell cups-config --cflags)
CUPS_LDFLAGS := $(shell cups-config --ldflags)
CUPS_LIBS := $(shell cups-config --image --libs 2>/dev/null || cups-config --libs)
cupsserverbin := $(shell cups-config --serverbin)
else
cupsserverbin :=
endif
endif
# PAPPL detection: prioritize PAPPL 2.x (pappl2), fallback to PAPPL 1.x (pappl)
PAPPL_PKG := $(shell pkg-config --exists pappl2 && echo pappl2 || echo pappl)
unitdir := $(DESTDIR)`pkg-config --variable=systemdsystemunitdir systemd 2>/dev/null || echo ""`
# Compiler/linker options...
OPTIM = -Os -g
CFLAGS += `pkg-config --cflags $(PAPPL_PKG)` $(CUPS_CFLAGS) `pkg-config --cflags libppd` `pkg-config --cflags libcupsfilters` `pkg-config --cflags libpappl-retrofit` $(OPTIM)
ifdef VERSION
CFLAGS += -DSYSTEM_VERSION_STR="\"$(VERSION)\""
ifndef MAJOR
MAJOR = `echo $(VERSION) | perl -p -e 's/^(\d+).*$$/\1/'`
endif
ifndef MINOR
MINOR = `echo $(VERSION) | perl -p -e 's/^\d+\D+(\d+).*$$/\1/'`
endif
ifndef PATCH
PATCH = `echo $(VERSION) | perl -p -e 's/^\d+\D+\d+\D+(\d+).*$$/\1/'`
endif
ifndef PACKAGE
PACKAGE = `echo $(VERSION) | perl -p -e 's/^\d+\D+\d+\D+\d+\D+(\d+).*$$/\1/'`
endif
endif
ifdef MAJOR
CFLAGS += -DSYSTEM_VERSION_ARR_0=$(MAJOR)
endif
ifdef MINOR
CFLAGS += -DSYSTEM_VERSION_ARR_1=$(MINOR)
endif
ifdef PATCH
CFLAGS += -DSYSTEM_VERSION_ARR_2=$(PATCH)
endif
ifdef PACKAGE
CFLAGS += -DSYSTEM_VERSION_ARR_3=$(PACKAGE)
endif
ifdef SNAP
CFLAGS += -DSNAP=$(SNAP)
endif
LDFLAGS += $(OPTIM) $(CUPS_LDFLAGS)
LIBS += `pkg-config --libs $(PAPPL_PKG)` $(CUPS_LIBS) `pkg-config --libs libppd` `pkg-config --libs libcupsfilters` `pkg-config --libs libpappl-retrofit`
# Targets...
OBJS = ghostscript-printer-app.o
TARGETS = ghostscript-printer-app
# General build rules...
.SUFFIXES: .c .o
.c.o:
$(CC) $(CFLAGS) -c -o $@ $<
# Targets...
all: $(TARGETS)
clean:
rm -f $(TARGETS) $(OBJS)
install: $(TARGETS)
mkdir -p $(bindir)
cp $(TARGETS) $(bindir)
mkdir -p $(mandir)/man1
cp ghostscript-printer-app.1 $(mandir)/man1
mkdir -p $(ppddir)
mkdir -p $(statedir)/ppd
mkdir -p $(spooldir)
mkdir -p $(resourcedir)
cp testpage.ps $(resourcedir)
if test "x$(cupsserverbin)" != x; then \
mkdir -p $(libdir); \
touch $(serverbin) 2> /dev/null || :; \
if rm $(serverbin) 2> /dev/null; then \
ln -s $(cupsserverbin) $(serverbin); \
fi; \
else \
mkdir -p $(serverbin)/filter; \
mkdir -p $(serverbin)/backend; \
fi
if test "x$(unitdir)" != x; then \
mkdir -p $(unitdir); \
cp ghostscript-printer-app.service $(unitdir); \
fi
ghostscript-printer-app: $(OBJS)
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
$(OBJS): Makefile