1#
2# Scheduler Makefile for CUPS.
3#
4# Copyright © 2007-2019 by Apple Inc.
5# Copyright © 1997-2007 by Easy Software Products, all rights reserved.
6#
7# Licensed under Apache License v2.0.  See the file "LICENSE" for more
8# information.
9#
10
11include ../Makedefs
12
13CUPSDOBJS =	\
14		auth.o \
15		banners.o \
16		cert.o \
17		classes.o \
18		client.o \
19		colorman.o \
20		conf.o \
21		dirsvc.o \
22		env.o \
23		file.o \
24		main.o \
25		ipp.o \
26		listen.o \
27		job.o \
28		log.o \
29		network.o \
30		policy.o \
31		printers.o \
32		process.o \
33		quotas.o \
34		select.o \
35		server.o \
36		statbuf.o \
37		subscriptions.o \
38		sysman.o
39LIBOBJS =	\
40		filter.o \
41		mime.o \
42		type.o
43COBJS	=	\
44		$(CUPSDOBJS) \
45		$(LIBOBJS) \
46		cupsfilter.o \
47		cups-deviced.o \
48		cups-exec.o \
49		cups-lpd.o \
50		testlpd.o \
51		testmime.o \
52		testspeed.o \
53		testsub.o \
54		util.o
55CXXOBJS	=	\
56		cups-driverd.o
57OBJS	=	\
58		$(COBJS) \
59		$(CXXOBJS)
60LIBTARGETS =	\
61		libcupsmime.a
62
63UNITTARGETS =	\
64		testlpd \
65		testmime \
66		testspeed \
67		testsub
68
69PROGRAMS =	\
70		cupsd \
71		cupsfilter \
72		cups-deviced \
73		cups-driverd \
74		cups-exec \
75		cups-lpd
76
77TARGETS	=	\
78		$(LIBTARGETS) \
79		$(PROGRAMS)
80
81
82#
83# Make everything...
84#
85
86all:		$(TARGETS)
87
88
89#
90# Make library targets...
91#
92
93libs:
94
95
96#
97# Make unit tests...
98#
99
100unittests:	$(UNITTARGETS)
101
102
103#
104# Clean all object files...
105#
106
107clean:
108	$(RM) $(OBJS)
109	$(RM) $(TARGETS) $(UNITTARGETS) convert
110
111
112#
113# Update dependencies (without system header dependencies...)
114#
115
116depend:
117	$(CC) -MM $(ALL_CFLAGS) $(COBJS:.o=.c) >Dependencies
118	$(CXX) -MM $(ALL_CXXFLAGS) $(CXXOBJS:.o=.cxx) >>Dependencies
119
120
121#
122# Run oclint to check code coverage...
123#
124
125oclint:
126	oclint -o=oclint.html -html $(CUPSDOBJS:.o=.c) $(LIBOBJS:.o=.c) -- $(ALL_CFLAGS)
127
128
129#
130# Install all targets...
131#
132
133install:	all install-data install-headers install-libs install-exec
134
135
136#
137# Install data files...
138#
139
140install-data:
141	echo Creating $(SERVERBIN)/driver...
142	$(INSTALL_DIR) -m 755 $(SERVERBIN)/driver
143	echo Creating $(SERVERROOT)...
144	$(INSTALL_DIR) -m 755 -g $(CUPS_GROUP) $(SERVERROOT)
145	echo Creating $(SERVERROOT)/ppd...
146	$(INSTALL_DIR) -m 755 -g $(CUPS_GROUP) $(SERVERROOT)/ppd
147	if test "x`uname`" != xDarwin; then \
148		echo Creating $(SERVERROOT)/ssl...; \
149		$(INSTALL_DIR) -m 700 -g $(CUPS_GROUP) $(SERVERROOT)/ssl; \
150	fi
151	if test "$(STATEDIR)" != "$(SERVERROOT)"; then \
152		echo Creating $(STATEDIR)...; \
153		$(INSTALL_DIR) -m 755 $(STATEDIR); \
154	fi
155	echo Creating $(STATEDIR)/certs...
156	$(INSTALL_DIR) -m 511 -o $(CUPS_USER) -g $(CUPS_PRIMARY_SYSTEM_GROUP) \
157		$(STATEDIR)/certs
158	echo Creating $(LOGDIR)...
159	$(INSTALL_DIR) -m 755 $(LOGDIR)
160	echo Creating $(REQUESTS)...
161	$(INSTALL_DIR) -m 710 -g $(CUPS_GROUP) $(REQUESTS)
162	echo Creating $(REQUESTS)/tmp...
163	$(INSTALL_DIR) -m 1770 -g $(CUPS_GROUP) $(REQUESTS)/tmp
164	echo Creating $(CACHEDIR)...
165	$(INSTALL_DIR) -m 770 -g $(CUPS_GROUP) $(CACHEDIR)
166	if test "x$(INITDIR)" != x; then \
167		echo Installing init scripts...; \
168		$(INSTALL_DIR) -m 755 $(BUILDROOT)$(INITDIR)/init.d; \
169		$(INSTALL_SCRIPT) cups.sh $(BUILDROOT)$(INITDIR)/init.d/cups; \
170		for level in $(RCLEVELS); do \
171			$(INSTALL_DIR) -m 755 $(BUILDROOT)$(INITDIR)/rc$${level}.d; \
172			$(LN) ../init.d/cups $(BUILDROOT)$(INITDIR)/rc$${level}.d/S$(RCSTART)cups; \
173			$(LN) ../init.d/cups $(BUILDROOT)$(INITDIR)/rc$${level}.d/K$(RCSTOP)cups; \
174		done; \
175		$(INSTALL_DIR) -m 755 $(BUILDROOT)$(INITDIR)/rc0.d; \
176		$(LN) ../init.d/cups $(BUILDROOT)$(INITDIR)/rc0.d/K$(RCSTOP)cups; \
177	fi
178	if test "x$(INITDDIR)" != x; then \
179		echo Installing init script...; \
180		$(INSTALL_DIR) -m 755 $(BUILDROOT)$(INITDDIR); \
181		$(INSTALL_SCRIPT) cups.sh $(BUILDROOT)$(INITDDIR); \
182	fi
183	if test "x$(LAUNCHD_DIR)" != x; then \
184		echo Installing launchd configuration files...; \
185		$(INSTALL_DIR) $(BUILDROOT)$(LAUNCHD_DIR); \
186		$(INSTALL_DATA) org.cups.cupsd.plist $(BUILDROOT)$(LAUNCHD_DIR); \
187		$(INSTALL_DATA) org.cups.cups-lpd.plist $(BUILDROOT)$(LAUNCHD_DIR); \
188	fi
189	if test "x$(SMFMANIFESTDIR)" != x; then \
190		echo Installing SMF manifest in $(SMFMANIFESTDIR)...;\
191		$(INSTALL_DIR) $(BUILDROOT)/$(SMFMANIFESTDIR); \
192		$(INSTALL_SCRIPT) cups.xml $(BUILDROOT)$(SMFMANIFESTDIR)/cups.xml; \
193	fi
194	if test "x$(SYSTEMD_DIR)" != x; then \
195		echo Installing systemd configuration files...; \
196		$(INSTALL_DIR) $(BUILDROOT)$(SYSTEMD_DIR); \
197		$(INSTALL_DATA) org.cups.cupsd.path $(BUILDROOT)$(SYSTEMD_DIR); \
198		$(INSTALL_DATA) org.cups.cupsd.service $(BUILDROOT)$(SYSTEMD_DIR); \
199		$(INSTALL_DATA) org.cups.cupsd.socket $(BUILDROOT)$(SYSTEMD_DIR); \
200		$(INSTALL_DATA) org.cups.cups-lpdAT.service $(BUILDROOT)$(SYSTEMD_DIR)/org.cups.cups-lpd@.service; \
201		$(INSTALL_DATA) org.cups.cups-lpd.socket $(BUILDROOT)$(SYSTEMD_DIR); \
202	elif test "x$(XINETD)" != x; then \
203		echo Installing xinetd configuration file for cups-lpd...; \
204		$(INSTALL_DIR) -m 755 $(BUILDROOT)$(XINETD); \
205		$(INSTALL_DATA) cups-lpd.xinetd $(BUILDROOT)$(XINETD)/cups-lpd; \
206	fi
207
208
209#
210# Install programs...
211#
212
213install-exec:
214	echo Installing programs in $(SBINDIR)...
215	$(INSTALL_DIR) -m 755 $(SBINDIR)
216	$(INSTALL_BIN) -m $(CUPS_CUPSD_FILE_PERM) cupsd $(SBINDIR)
217	$(INSTALL_BIN) cupsfilter $(SBINDIR)
218	echo Installing programs in $(SERVERBIN)/daemon...
219	$(INSTALL_DIR) -m 755 $(SERVERBIN)
220	$(INSTALL_DIR) -m 755 $(SERVERBIN)/daemon
221	$(INSTALL_BIN) cups-deviced $(SERVERBIN)/daemon
222	$(INSTALL_BIN) cups-driverd $(SERVERBIN)/daemon
223	$(INSTALL_BIN) cups-exec $(SERVERBIN)/daemon
224	$(INSTALL_BIN) cups-lpd $(SERVERBIN)/daemon
225	if test "x$(SYMROOT)" != "x"; then \
226		$(INSTALL_DIR) $(SYMROOT); \
227		for file in $(PROGRAMS); do \
228			cp $$file $(SYMROOT); \
229			dsymutil $(SYMROOT)/$$file; \
230		done \
231	fi
232
233
234#
235# Install headers...
236#
237
238install-headers:
239
240
241#
242# Install libraries...
243#
244
245install-libs:
246
247
248#
249# Uninstall the scheduler...
250#
251
252uninstall:
253	$(RM) $(SBINDIR)/cupsd
254	$(RM) $(SBINDIR)/cupsfilter
255	$(RM) $(SERVERBIN)/daemon/cups-deviced
256	$(RM) $(SERVERBIN)/daemon/cups-driverd
257	$(RM) $(SERVERBIN)/daemon/cups-exec
258	$(RM) $(SERVERBIN)/daemon/cups-lpd
259	-$(RMDIR) $(STATEDIR)/certs
260	-$(RMDIR) $(STATEDIR)
261	-$(RMDIR) $(SERVERROOT)/ppd
262	-$(RMDIR) $(SERVERROOT)/interfaces
263	-$(RMDIR) $(SERVERROOT)
264	-$(RMDIR) $(SERVERBIN)/driver
265	-$(RMDIR) $(SERVERBIN)/daemon
266	-$(RMDIR) $(SERVERBIN)
267	-$(RMDIR) $(SBINDIR)
268	-$(RMDIR) $(REQUESTS)/tmp
269	-$(RMDIR) $(REQUESTS)
270	-$(RMDIR) $(LOGDIR)
271	-$(RMDIR) $(CACHEDIR)
272	if test "x$(INITDIR)" != x; then \
273		echo Uninstalling init scripts...; \
274		$(RM) $(BUILDROOT)$(INITDIR)/init.d/cups; \
275		$(RMDIR) $(BUILDROOT)$(INITDIR)/init.d; \
276		$(RM)  $(BUILDROOT)$(INITDIR)/rc0.d/K00cups; \
277		$(RMDIR) $(BUILDROOT)$(INITDIR)/rc0.d; \
278		$(RM) $(BUILDROOT)$(INITDIR)/rc2.d/S99cups; \
279		$(RMDIR) $(BUILDROOT)$(INITDIR)/rc2.d; \
280		$(RM) $(BUILDROOT)$(INITDIR)/rc3.d/S99cups; \
281		$(RMDIR) $(BUILDROOT)$(INITDIR)/rc3.d; \
282		$(RM) $(BUILDROOT)$(INITDIR)/rc5.d/S99cups; \
283		$(RMDIR) $(BUILDROOT)$(INITDIR)/rc5.d; \
284	fi
285	if test "x$(INITDDIR)" != x; then \
286		echo Uninstalling startup script...; \
287		$(RM) $(BUILDROOT)$(INITDDIR)/cups.sh; \
288		$(RMDIR) $(BUILDROOT)$(INITDDIR); \
289	fi
290	if test "x$LAUNCHD_DIR" != x; then \
291		echo Uninstalling launchd files...; \
292		$(RM) $(BUILDROOT)$(LAUNCHD_DIR)/org.cups.cupsd.plist; \
293		$(RM) $(BUILDROOT)$(LAUNCHD_DIR)/org.cups.cups-lpd.plist; \
294	fi
295	if test "x$SYSTEMD_DIR" != x; then \
296		echo Uninstalling systemd files...; \
297		$(RM) $(BUILDROOT)$(SYSTEMD_DIR)/org.cups.cupsd.path; \
298		$(RM) $(BUILDROOT)$(SYSTEMD_DIR)/org.cups.cupsd.service; \
299		$(RM) $(BUILDROOT)$(SYSTEMD_DIR)/org.cups.cupsd.socket; \
300	fi
301	if test "x$(SMFMANIFESTDIR)" != x; then \
302		echo Uninstalling SMF manifest file...;\
303		$(RM) $(BUILDROOT)$(SMFMANIFESTDIR)/cups.xml; \
304	fi
305	if test "x$(XINETD)" != x; then \
306		echo Uninstalling xinetd configuration file for cups-lpd...; \
307		$(RM) $(BUILDROOT)$(XINETD)/cups-lpd; \
308	fi
309
310
311#
312# Make the scheduler executable, "cupsd".
313#
314
315cupsd:	$(CUPSDOBJS) libcupsmime.a ../cups/$(LIBCUPS)
316	echo Linking $@...
317	$(LD_CC) $(ALL_LDFLAGS) -o cupsd $(CUPSDOBJS) libcupsmime.a \
318		$(PAMLIBS) $(LIBPAPER) $(LIBMALLOC) $(DNSSDLIBS) $(SERVERLIBS) \
319		$(ONDEMANDLIBS) $(LIBWRAP) $(LIBGSSAPI) $(COMMONLIBS) $(LINKCUPS)
320	$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
321
322cupsd-static:	$(CUPSDOBJS) libcupsmime.a ../cups/$(LIBCUPSSTATIC)
323	echo Linking $@...
324	$(LD_CC) $(ALL_LDFLAGS) -o cupsd-static $(CUPSDOBJS) libcupsmime.a \
325		$(PAMLIBS) $(LIBPAPER) $(LIBMALLOC) $(SERVERLIBS) $(ONDEMANDLIBS) \ $(LIBWRAP) $(LINKCUPSSTATIC)
326	$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
327
328
329#
330# Make the cupsfilter utility.
331#
332
333cupsfilter:	cupsfilter.o libcupsmime.a ../cups/$(LIBCUPS)
334	echo Linking $@...
335	$(LD_CC) $(ALL_LDFLAGS) -o cupsfilter cupsfilter.o libcupsmime.a $(LINKCUPS)
336	$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
337	$(RM) convert
338	$(LN) cupsfilter convert
339
340cupsfilter-static:	cupsfilter.o libcupsmime.a ../cups/$(LIBCUPSSTATIC)
341	echo Linking $@...
342	$(LD_CC) $(ALL_LDFLAGS) -o cupsfilter-static cupsfilter.o libcupsmime.a \
343		$(LINKCUPSSTATIC)
344	$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
345
346
347#
348# Make the device daemon, "cups-deviced".
349#
350
351cups-deviced:	cups-deviced.o util.o ../cups/$(LIBCUPS)
352	echo Linking $@...
353	$(LD_CC) $(ALL_LDFLAGS) -o cups-deviced cups-deviced.o util.o $(LINKCUPS)
354	$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
355
356
357#
358# Make the driver daemon, "cups-driverd".
359#
360
361cups-driverd:	cups-driverd.o util.o ../cups/$(LIBCUPS) ../ppdc/libcupsppdc.a
362	echo Linking $@...
363	$(LD_CXX) $(ALL_LDFLAGS) -o cups-driverd cups-driverd.o util.o \
364		../ppdc/libcupsppdc.a $(COMMONLIBS) $(LINKCUPS)
365	$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
366
367
368#
369# Make the sandbox execution helper, "cups-exec".
370#
371
372cups-exec:	cups-exec.o
373	echo Linking $@...
374	$(LD_CC) $(ALL_LDFLAGS) -o cups-exec cups-exec.o $(LINKCUPS)
375	$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
376
377
378#
379# Make the line printer daemon, "cups-lpd".
380#
381
382cups-lpd:	cups-lpd.o ../cups/$(LIBCUPS)
383	echo Linking $@...
384	$(LD_CC) $(ALL_LDFLAGS) -o cups-lpd cups-lpd.o $(LINKCUPS)
385	$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
386
387
388#
389# libcupsmime.a
390#
391
392libcupsmime.a:	$(LIBOBJS)
393	echo Archiving $@...
394	$(RM) $@
395	$(AR) $(ARFLAGS) $@ $(LIBOBJS)
396	$(RANLIB) $@
397
398
399#
400# Make the test program, "testlpd".
401#
402
403testlpd:	testlpd.o ../cups/$(LIBCUPSSTATIC) cups-lpd
404	echo Linking $@...
405	$(LD_CC) $(ALL_LDFLAGS) -o testlpd testlpd.o $(LINKCUPSSTATIC)
406
407
408#
409# testmime
410#
411
412testmime:	testmime.o libcupsmime.a ../cups/$(LIBCUPSSTATIC)
413	echo Linking $@...
414	$(LD_CC) $(ARCHFLAGS) $(ALL_LDFLAGS) -o $@ testmime.o libcupsmime.a \
415		$(LINKCUPSSTATIC)
416	$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
417	echo Running MIME tests...
418	./testmime
419
420
421#
422# Make the test program, "testspeed".
423#
424
425testspeed:	testspeed.o ../cups/$(LIBCUPSSTATIC)
426	echo Linking $@...
427	$(LD_CC) $(ALL_LDFLAGS) -o testspeed testspeed.o $(LINKCUPSSTATIC)
428	$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
429
430
431#
432# Make the test program, "testsub".
433#
434
435testsub:	testsub.o ../cups/$(LIBCUPSSTATIC)
436	echo Linking $@...
437	$(LD_CC) $(ALL_LDFLAGS) -o testsub testsub.o $(LINKCUPSSTATIC)
438	$(CODE_SIGN) -s "$(CODE_SIGN_IDENTITY)" $@
439
440
441#
442# Lines of code computation...
443#
444
445sloc:
446	echo "cupsd: \c"
447	sloccount $(CUPSDOBJS:.o=.c) $(LIBOBJS:.o=.c) cups-driverd.cxx cups-lpd.c 2>/dev/null | grep "Total Physical" | awk '{print $$9}'
448
449
450#
451# Dependencies...
452#
453
454include Dependencies
455