1#
2# Library Makefile for CUPS.
3#
4# Copyright 2007-2017 by Apple Inc.
5# Copyright 1997-2006 by Easy Software Products, all rights reserved.
6#
7# These coded instructions, statements, and computer programs are the
8# property of Apple Inc. and are protected by Federal copyright
9# law.  Distribution and use rights are outlined in the file "LICENSE.txt"
10# which should have been included with this file.  If this file is
11# missing or damaged, see the license at "http://www.cups.org/".
12#
13# This file is subject to the Apple OS-Developed Software exception.
14#
15
16include ../Makedefs
17
18
19#
20# Options to build libcups without the use of deprecated APIs...
21#
22
23OPTIONS	=	-D_CUPS_NO_DEPRECATED=1 -D_PPD_DEPRECATED=""
24
25
26#
27# Object files...
28#
29
30LIBOBJS	=	\
31		adminutil.o \
32		array.o \
33		auth.o \
34		backchannel.o \
35		backend.o \
36		debug.o \
37		dest.o \
38		dest-job.o \
39		dest-localization.o \
40		dest-options.o \
41		dir.o \
42		encode.o \
43		file.o \
44		getdevices.o \
45		getifaddrs.o \
46		getputfile.o \
47		globals.o \
48		hash.o \
49		http.o \
50		http-addr.o \
51		http-addrlist.o \
52		http-support.o \
53		ipp.o \
54		ipp-support.o \
55		langprintf.o \
56		language.o \
57		md5.o \
58		md5passwd.o \
59		notify.o \
60		options.o \
61		ppd.o \
62		ppd-attr.o \
63		ppd-cache.o \
64		ppd-conflicts.o \
65		ppd-custom.o \
66		ppd-emit.o \
67		ppd-localize.o \
68		ppd-mark.o \
69		ppd-page.o \
70		ppd-util.o \
71		pwg-media.o \
72		request.o \
73		sidechannel.o \
74		snmp.o \
75		snprintf.o \
76		string.o \
77		tempfile.o \
78		thread.o \
79		tls.o \
80		transcode.o \
81		usersys.o \
82		util.o
83TESTOBJS	= \
84		testadmin.o \
85		testarray.o \
86		testcache.o \
87		testconflicts.o \
88		testcreds.o \
89		testcups.o \
90		testdest.o \
91		testfile.o \
92		testgetdests.o \
93		testhttp.o \
94		testi18n.o \
95		testipp.o \
96		testoptions.o \
97		testlang.o \
98		testppd.o \
99		testpwg.o \
100		testsnmp.o \
101		tlscheck.o
102OBJS	=	\
103		$(LIBOBJS) \
104		$(TESTOBJS)
105
106
107#
108# Header files to install...
109#
110
111HEADERS	=	\
112		adminutil.h \
113		array.h \
114		backend.h \
115		cups.h \
116		dir.h \
117		file.h \
118		http.h \
119		ipp.h \
120		language.h \
121		ppd.h \
122		pwg.h \
123		raster.h \
124		sidechannel.h \
125		transcode.h \
126		versioning.h
127
128HEADERSPRIV =	\
129		array-private.h \
130		cups-private.h \
131		debug-private.h \
132		file-private.h \
133		http-private.h \
134		ipp-private.h \
135		language-private.h \
136		md5-private.h \
137		ppd-private.h \
138		pwg-private.h \
139		raster-private.h \
140		snmp-private.h \
141		string-private.h \
142		thread-private.h
143
144
145#
146# Targets in this directory...
147#
148
149LIBTARGETS =	\
150		$(LIBCUPSSTATIC) \
151		$(LIBCUPS)
152
153UNITTARGETS =	\
154		testadmin \
155		testarray \
156		testcache \
157		testconflicts \
158		testcreds \
159		testcups \
160		testdest \
161		testfile \
162		testgetdests \
163		testhttp \
164		testi18n \
165		testipp \
166		testlang \
167		testoptions \
168		testppd \
169		testpwg \
170		testsnmp \
171		tlscheck
172
173TARGETS	=	\
174		$(LIBTARGETS)
175
176
177#
178# Make all targets...
179#
180
181all:		$(TARGETS)
182
183
184#
185# Make library targets...
186#
187
188libs:		$(LIBTARGETS)
189
190
191#
192# Make unit tests...
193#
194
195unittests:	$(UNITTARGETS)
196
197
198#
199# Remove object and target files...
200#
201
202clean:
203	$(RM) $(OBJS) $(TARGETS) $(UNITTARGETS)
204	$(RM) libcups.so libcups.dylib
205
206
207#
208# Update dependencies (without system header dependencies...)
209#
210
211depend:
212	$(CC) -MM $(ALL_CFLAGS) $(OBJS:.o=.c) >Dependencies
213
214
215#
216# Run oclint to check code coverage...
217#
218
219oclint:
220	oclint -o=oclint.html -html $(LIBOBJS:.o=.c) -- $(ALL_CFLAGS)
221
222
223#
224# Install all targets...
225#
226
227install:	all install-data install-headers install-libs install-exec
228
229
230#
231# Install data files...
232#
233
234install-data:
235
236
237#
238# Install programs...
239#
240
241install-exec:
242
243
244#
245# Install headers...
246#
247
248install-headers:
249	echo Installing header files into $(INCLUDEDIR)/cups...
250	$(INSTALL_DIR) -m 755 $(INCLUDEDIR)/cups
251	for file in $(HEADERS); do \
252		$(INSTALL_DATA) $$file $(INCLUDEDIR)/cups; \
253	done
254	if test "x$(privateinclude)" != x; then \
255		echo Installing private header files into $(PRIVATEINCLUDE)...; \
256		$(INSTALL_DIR) -m 755 $(PRIVATEINCLUDE); \
257		for file in $(HEADERSPRIV); do \
258			$(INSTALL_DATA) $$file $(PRIVATEINCLUDE)/$$file; \
259		done; \
260	fi
261
262
263#
264# Install libraries...
265#
266
267install-libs: $(INSTALLSTATIC)
268	echo Installing libraries in $(LIBDIR)...
269	$(INSTALL_DIR) -m 755 $(LIBDIR)
270	$(INSTALL_LIB) $(LIBCUPS) $(LIBDIR)
271	if test $(LIBCUPS) = "libcups.so.2"; then \
272		$(RM) $(LIBDIR)/`basename $(LIBCUPS) .2`; \
273		$(LN) $(LIBCUPS) $(LIBDIR)/`basename $(LIBCUPS) .2`; \
274	fi
275	if test $(LIBCUPS) = "libcups.2.dylib"; then \
276		$(RM) $(LIBDIR)/libcups.dylib; \
277		$(LN) $(LIBCUPS) $(LIBDIR)/libcups.dylib; \
278	fi
279	if test "x$(SYMROOT)" != "x"; then \
280		$(INSTALL_DIR) $(SYMROOT); \
281		cp $(LIBCUPS) $(SYMROOT); \
282		dsymutil $(SYMROOT)/$(LIBCUPS); \
283	fi
284
285installstatic:
286	$(INSTALL_DIR) -m 755 $(LIBDIR)
287	$(INSTALL_LIB) -m 755 $(LIBCUPSSTATIC) $(LIBDIR)
288	$(RANLIB) $(LIBDIR)/$(LIBCUPSSTATIC)
289	$(CHMOD) 555 $(LIBDIR)/$(LIBCUPSSTATIC)
290
291
292#
293# Uninstall object and target files...
294#
295
296uninstall:
297	$(RM) $(LIBDIR)/libcups.2.dylib
298	$(RM) $(LIBDIR)/$(LIBCUPSSTATIC)
299	$(RM) $(LIBDIR)/libcups.dylib
300	$(RM) $(LIBDIR)/libcups.so
301	$(RM) $(LIBDIR)/libcups.so.2
302	-$(RMDIR) $(LIBDIR)
303	for file in $(HEADERS); do \
304		$(RM) $(INCLUDEDIR)/cups/$$file; \
305	done
306	-$(RMDIR) $(INCLUDEDIR)/cups
307
308
309#
310# libcups.so.2
311#
312
313libcups.so.2:	$(LIBOBJS)
314	echo Linking $@...
315	$(DSO) $(ARCHFLAGS) $(DSOFLAGS) -o $@ $(LIBOBJS) $(LIBGSSAPI) \
316		$(SSLLIBS) $(DNSSDLIBS) $(COMMONLIBS) $(LIBZ)
317	$(RM) `basename $@ .2`
318	$(LN) $@ `basename $@ .2`
319
320
321#
322# libcups.2.dylib
323#
324
325libcups.2.dylib:	$(LIBOBJS) $(LIBCUPSORDER)
326	echo Creating export list for $@...
327	nm -gm $(LIBOBJS) 2>/dev/null | grep "__text" | grep -v weak | \
328		awk '{print $$NF}' | \
329		grep -v -E -e '^(_cupsConnect|_cupsCharset|_cupsEncodingName|_cupsSetDefaults|_cupsSetHTTPError|_cupsUserDefault)$$' | \
330		sort >t.exp
331	echo Linking $@...
332	$(DSO) $(ARCHFLAGS) $(DSOFLAGS) -o $@ \
333		-install_name $(libdir)/$@ \
334		-current_version 2.12.0 \
335		-compatibility_version 2.0.0 \
336		-exported_symbols_list t.exp \
337		$(LIBOBJS) $(LIBGSSAPI) $(SSLLIBS) $(DNSSDLIBS) \
338		$(COMMONLIBS) $(LIBZ)
339	$(RM) libcups.dylib t.exp
340	$(LN) $@ libcups.dylib
341
342
343#
344# libcups.la
345#
346
347libcups.la:    $(LIBOBJS)
348	echo Linking $@...
349	$(LD_CC) $(ARCHFLAGS) $(DSOFLAGS) -o $@ $(LIBOBJS:.o=.lo) \
350		-rpath $(LIBDIR) -version-info 2:12 $(LIBGSSAPI) $(SSLLIBS) \
351		$(DNSSDLIBS) $(COMMONLIBS) $(LIBZ)
352
353
354#
355# libcups.a
356#
357
358libcups.a:	$(LIBOBJS)
359	echo Archiving $@...
360	$(RM) $@
361	$(AR) $(ARFLAGS) $@ $(LIBOBJS)
362	$(RANLIB) $@
363
364
365#
366# libcups2.def (Windows DLL exports file...)
367#
368
369libcups2.def: $(LIBOBJS) Makefile
370	echo Generating $@...
371	echo "LIBRARY libcups2" >libcups2.def
372	echo "VERSION 2.12" >>libcups2.def
373	echo "EXPORTS" >>libcups2.def
374	(nm $(LIBOBJS) 2>/dev/null | grep "T _" | awk '{print $$3}'; \
375	 echo __cups_strcpy; echo __cups_strlcat; echo __cups_strlcpy) | \
376		grep -v -E \
377		    -e 'cups_debug|Apple|BackChannel|Backend|FileCheck|Filter|GSSService|SetNegotiate|SideChannel' \
378		    -e 'Block$$' | \
379		sed -e '1,$$s/^_//' | sort >>libcups2.def
380
381
382#
383# testadmin (dependency on static CUPS library is intentional)
384#
385
386testadmin:	testadmin.o $(LIBCUPSSTATIC)
387	echo Linking $@...
388	$(LD_CC) $(LDFLAGS) -o $@ testadmin.o $(LIBCUPSSTATIC) \
389		$(LIBGSSAPI) $(SSLLIBS) $(DNSSDLIBS) $(COMMONLIBS) $(LIBZ)
390
391
392#
393# testarray (dependency on static CUPS library is intentional)
394#
395
396testarray:	testarray.o $(LIBCUPSSTATIC)
397	echo Linking $@...
398	$(LD_CC) $(ARCHFLAGS) $(LDFLAGS) -o $@ testarray.o $(LIBCUPSSTATIC) \
399		$(LIBGSSAPI) $(SSLLIBS) $(DNSSDLIBS) $(COMMONLIBS) $(LIBZ)
400	echo Running array API tests...
401	./testarray
402
403
404#
405# testcache (dependency on static CUPS library is intentional)
406#
407
408testcache:	testcache.o $(LIBCUPSSTATIC)
409	echo Linking $@...
410	$(LD_CC) $(LDFLAGS) -o $@ testcache.o $(LIBCUPSSTATIC) \
411		$(LIBGSSAPI) $(SSLLIBS) $(DNSSDLIBS) $(COMMONLIBS) $(LIBZ)
412
413
414#
415# testconflicts (dependency on static CUPS library is intentional)
416#
417
418testconflicts:	testconflicts.o $(LIBCUPSSTATIC)
419	echo Linking $@...
420	$(LD_CC) $(LDFLAGS) -o $@ testconflicts.o $(LIBCUPSSTATIC) \
421		$(LIBGSSAPI) $(SSLLIBS) $(DNSSDLIBS) $(COMMONLIBS) $(LIBZ)
422
423
424#
425# testcreds (dependency on static CUPS library is intentional)
426#
427
428testcreds:	testcreds.o $(LIBCUPSSTATIC)
429	echo Linking $@...
430	$(LD_CC) $(ARCHFLAGS) $(LDFLAGS) -o $@ testcreds.o $(LIBCUPSSTATIC) \
431		$(LIBGSSAPI) $(SSLLIBS) $(DNSSDLIBS) $(COMMONLIBS) $(LIBZ)
432
433
434#
435# testcups (dependency on static CUPS library is intentional)
436#
437
438testcups:	testcups.o $(LIBCUPSSTATIC)
439	echo Linking $@...
440	$(LD_CC) $(LDFLAGS) -o $@ testcups.o $(LIBCUPSSTATIC) \
441		$(LIBGSSAPI) $(SSLLIBS) $(DNSSDLIBS) $(COMMONLIBS) $(LIBZ)
442
443
444#
445# testdest (dependency on static CUPS library is intentional)
446#
447
448testdest:	testdest.o $(LIBCUPSSTATIC)
449	echo Linking $@...
450	$(LD_CC) $(LDFLAGS) -o $@ testdest.o $(LIBCUPSSTATIC) \
451		$(LIBGSSAPI) $(SSLLIBS) $(DNSSDLIBS) $(COMMONLIBS) $(LIBZ)
452
453
454#
455# testfile (dependency on static CUPS library is intentional)
456#
457
458testfile:	testfile.o $(LIBCUPSSTATIC)
459	echo Linking $@...
460	$(LD_CC) $(ARCHFLAGS) $(LDFLAGS) -o $@ testfile.o $(LIBCUPSSTATIC) \
461		$(LIBGSSAPI) $(SSLLIBS) $(DNSSDLIBS) $(COMMONLIBS) $(LIBZ)
462	echo Running file API tests...
463	./testfile
464
465
466#
467# testgetdests (dependency on static CUPS library is intentional)
468#
469
470testgetdests:	testgetdests.o $(LIBCUPSSTATIC)
471	echo Linking $@...
472	$(LD_CC) $(LDFLAGS) -o $@ testgetdests.o $(LIBCUPSSTATIC) \
473		$(LIBGSSAPI) $(SSLLIBS) $(DNSSDLIBS) $(COMMONLIBS) $(LIBZ)
474
475
476#
477# testhttp (dependency on static CUPS library is intentional)
478#
479
480testhttp:	testhttp.o $(LIBCUPSSTATIC)
481	echo Linking $@...
482	$(LD_CC) $(ARCHFLAGS) $(LDFLAGS) -o $@ testhttp.o $(LIBCUPSSTATIC) \
483		$(LIBGSSAPI) $(SSLLIBS) $(DNSSDLIBS) $(COMMONLIBS) $(LIBZ)
484	echo Running HTTP API tests...
485	./testhttp
486
487
488#
489# testipp (dependency on static CUPS library is intentional)
490#
491
492testipp:	testipp.o $(LIBCUPSSTATIC)
493	echo Linking $@...
494	$(LD_CC) $(ARCHFLAGS) $(LDFLAGS) -o $@ testipp.o $(LIBCUPSSTATIC) \
495		$(LIBGSSAPI) $(SSLLIBS) $(DNSSDLIBS) $(COMMONLIBS) $(LIBZ)
496	echo Running IPP API tests...
497	./testipp
498
499
500#
501# testi18n (dependency on static CUPS library is intentional)
502#
503
504testi18n:	testi18n.o $(LIBCUPSSTATIC)
505	echo Linking $@...
506	$(LD_CC) $(ARCHFLAGS) $(LDFLAGS) -o $@ testi18n.o $(LIBCUPSSTATIC) \
507		$(LIBGSSAPI) $(SSLLIBS) $(DNSSDLIBS) $(COMMONLIBS) $(LIBZ)
508	echo Running internationalization API tests...
509	./testi18n
510
511
512#
513# testlang (dependency on static CUPS library is intentional)
514#
515
516testlang:	testlang.o $(LIBCUPSSTATIC)
517	echo Linking $@...
518	$(LD_CC) $(ARCHFLAGS) $(LDFLAGS) -o $@ testlang.o $(LIBCUPSSTATIC) \
519		$(LIBGSSAPI) $(SSLLIBS) $(DNSSDLIBS) $(COMMONLIBS) $(LIBZ)
520	echo Creating locale directory structure...
521	$(RM) -r locale
522	$(MKDIR) locale/en
523	echo 'msgid "No"' > locale/en/cups_en.po
524	echo 'msgstr "No"' >> locale/en/cups_en.po
525	echo 'msgid "Yes"' >> locale/en/cups_en.po
526	echo 'msgstr "Yes"' >> locale/en/cups_en.po
527	for po in ../locale/cups_*.po; do \
528		lang=`basename $$po .po | sed -e '1,$$s/^cups_//'`; \
529		$(MKDIR) locale/$$lang; \
530		$(LN) ../../$$po locale/$$lang; \
531	done
532	echo Running language API tests...
533	LOCALEDIR=locale ./testlang
534
535
536#
537# testoptions (dependency on static CUPS library is intentional)
538#
539
540testoptions:	testoptions.o $(LIBCUPSSTATIC)
541	echo Linking $@...
542	$(LD_CC) $(ARCHFLAGS) $(LDFLAGS) -o $@ testoptions.o $(LIBCUPSSTATIC) \
543		$(LIBGSSAPI) $(SSLLIBS) $(DNSSDLIBS) $(COMMONLIBS) $(LIBZ)
544	echo Running option API tests...
545	./testoptions
546
547
548#
549# testppd (dependency on static CUPS library is intentional)
550#
551
552testppd:	testppd.o $(LIBCUPSSTATIC) test.ppd test2.ppd
553	echo Linking $@...
554	$(LD_CC) $(ARCHFLAGS) $(LDFLAGS) -o $@ testppd.o $(LIBCUPSSTATIC) \
555		$(LIBGSSAPI) $(SSLLIBS) $(DNSSDLIBS) $(COMMONLIBS) $(LIBZ)
556	echo Running PPD API tests...
557	./testppd
558
559
560#
561# testpwg (dependency on static CUPS library is intentional)
562#
563
564testpwg:	testpwg.o $(LIBCUPSSTATIC) test.ppd
565	echo Linking $@...
566	$(LD_CC) $(ARCHFLAGS) $(LDFLAGS) -o $@ testpwg.o $(LIBCUPSSTATIC) \
567		$(LIBGSSAPI) $(SSLLIBS) $(DNSSDLIBS) $(COMMONLIBS) $(LIBZ)
568	echo Running PWG API tests...
569	./testpwg test.ppd
570
571
572#
573# testsnmp (dependency on static CUPS library is intentional)
574#
575
576testsnmp:	testsnmp.o $(LIBCUPSSTATIC)
577	echo Linking $@...
578	$(LD_CC) $(LDFLAGS) -o $@ testsnmp.o $(LIBCUPSSTATIC) \
579		$(LIBGSSAPI) $(SSLLIBS) $(DNSSDLIBS) $(COMMONLIBS) $(LIBZ)
580
581
582#
583# tlscheck (dependency on static CUPS library is intentional)
584#
585
586tlscheck:	tlscheck.o $(LIBCUPSSTATIC)
587	echo Linking $@...
588	$(LD_CC) $(ARCHFLAGS) $(LDFLAGS) -o $@ tlscheck.o $(LIBCUPSSTATIC) \
589		$(LIBGSSAPI) $(SSLLIBS) $(DNSSDLIBS) $(COMMONLIBS) $(LIBZ)
590
591
592#
593# Automatic API help files...
594#
595
596apihelp:
597	echo Generating CUPS API help files...
598	$(RM) cupspm.xml
599	mxmldoc --section "Programming" --body cupspm.md \
600		cupspm.xml \
601		auth.c cups.h dest*.c encode.c http.h http*.c ipp.h ipp*.c \
602		options.c tls-darwin.c usersys.c util.c \
603		--coverimage cupspm.png \
604		--epub ../doc/help/cupspm.epub
605	mxmldoc --section "Programming" --body cupspm.md \
606		cupspm.xml > ../doc/help/cupspm.html
607	$(RM) cupspm.xml
608	mxmldoc --section "Programming" --title "Administration APIs" \
609		--css ../doc/cups-printable.css \
610		--header api-admin.header --intro api-admin.shtml \
611		api-admin.xml \
612		adminutil.c adminutil.h getdevices.c >../doc/help/api-admin.html
613	$(RM) api-admin.xml
614	mxmldoc --section "Programming" --title "PPD API (DEPRECATED)" \
615		--css ../doc/cups-printable.css \
616		--header api-ppd.header --intro api-ppd.shtml \
617		api-ppd.xml ppd.h ppd-*.c >../doc/help/api-ppd.html
618	$(RM) api-ppd.xml
619	mxmldoc --section "Programming" \
620		--title "Filter and Backend Programming" \
621		--css ../doc/cups-printable.css \
622		--header api-filter.header --intro api-filter.shtml \
623		api-filter.xml \
624		backchannel.c backend.h backend.c sidechannel.c sidechannel.h \
625		>../doc/help/api-filter.html
626	$(RM) api-filter.xml
627
628
629#
630# Lines of code computation...
631#
632
633sloc:
634	echo "libcups: \c"
635	sloccount $(LIBOBJS:.o=.c) 2>/dev/null | grep "Total Physical" | awk '{print $$9}'
636
637
638#
639# Dependencies...
640#
641
642include Dependencies
643tls.o: tls-darwin.c tls-gnutls.c tls-sspi.c
644