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