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