| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| 2 | <HTML |
| 3 | ><HEAD |
| 4 | ><TITLE |
| 5 | >Integrating libgutenprint</TITLE |
| 6 | ><META |
| 7 | NAME="GENERATOR" |
| 8 | CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK |
| 9 | REL="HOME" |
| 10 | TITLE="The Developer's Guide to Gutenprint" |
| 11 | HREF="book1.html"><LINK |
| 12 | REL="UP" |
| 13 | TITLE="Using libgutenprint" |
| 14 | HREF="c47.html"><LINK |
| 15 | REL="PREVIOUS" |
| 16 | TITLE="Linking with libgutenprint" |
| 17 | HREF="x66.html"><LINK |
| 18 | REL="NEXT" |
| 19 | TITLE="Reporting Bugs" |
| 20 | HREF="c193.html"></HEAD |
| 21 | ><BODY |
| 22 | CLASS="sect1" |
| 23 | BGCOLOR="#FFFFFF" |
| 24 | TEXT="#000000" |
| 25 | LINK="#0000FF" |
| 26 | VLINK="#840084" |
| 27 | ALINK="#0000FF" |
| 28 | ><DIV |
| 29 | CLASS="NAVHEADER" |
| 30 | ><TABLE |
| 31 | SUMMARY="Header navigation table" |
| 32 | WIDTH="100%" |
| 33 | BORDER="0" |
| 34 | CELLPADDING="0" |
| 35 | CELLSPACING="0" |
| 36 | ><TR |
| 37 | ><TH |
| 38 | COLSPAN="3" |
| 39 | ALIGN="center" |
| 40 | >The Developer's Guide to Gutenprint</TH |
| 41 | ></TR |
| 42 | ><TR |
| 43 | ><TD |
| 44 | WIDTH="10%" |
| 45 | ALIGN="left" |
| 46 | VALIGN="bottom" |
| 47 | ><A |
| 48 | HREF="x66.html" |
| 49 | ACCESSKEY="P" |
| 50 | ><<< Previous</A |
| 51 | ></TD |
| 52 | ><TD |
| 53 | WIDTH="80%" |
| 54 | ALIGN="center" |
| 55 | VALIGN="bottom" |
| 56 | >Using libgutenprint</TD |
| 57 | ><TD |
| 58 | WIDTH="10%" |
| 59 | ALIGN="right" |
| 60 | VALIGN="bottom" |
| 61 | ><A |
| 62 | HREF="c193.html" |
| 63 | ACCESSKEY="N" |
| 64 | >Next >>></A |
| 65 | ></TD |
| 66 | ></TR |
| 67 | ></TABLE |
| 68 | ><HR |
| 69 | ALIGN="LEFT" |
| 70 | WIDTH="100%"></DIV |
| 71 | ><DIV |
| 72 | CLASS="sect1" |
| 73 | ><H1 |
| 74 | CLASS="sect1" |
| 75 | ><A |
| 76 | NAME="AEN78" |
| 77 | >Integrating libgutenprint</A |
| 78 | ></H1 |
| 79 | ><P |
| 80 | > This section describes how to integrate the compiling and |
| 81 | linking of programs using libgutenprint with build |
| 82 | scripts. Commonly used systems include <B |
| 83 | CLASS="command" |
| 84 | >make</B |
| 85 | >, |
| 86 | but often <TT |
| 87 | CLASS="filename" |
| 88 | >Makefile</TT |
| 89 | > files are generated by |
| 90 | using tools such as <B |
| 91 | CLASS="command" |
| 92 | >autoconf</B |
| 93 | > and |
| 94 | <B |
| 95 | CLASS="command" |
| 96 | >automake</B |
| 97 | >. |
| 98 | </P |
| 99 | ><DIV |
| 100 | CLASS="sect2" |
| 101 | ><H2 |
| 102 | CLASS="sect2" |
| 103 | ><A |
| 104 | NAME="AEN85" |
| 105 | ><B |
| 106 | CLASS="command" |
| 107 | >pkg-config</B |
| 108 | ></A |
| 109 | ></H2 |
| 110 | ><P |
| 111 | > Depending on the nature of the computer system Gutenprint was |
| 112 | installed on, as well as the options passed to |
| 113 | <B |
| 114 | CLASS="command" |
| 115 | >configure</B |
| 116 | > when configuring the package when |
| 117 | it was built, the <CODE |
| 118 | CLASS="varname" |
| 119 | >CFLAGS</CODE |
| 120 | > and |
| 121 | <CODE |
| 122 | CLASS="varname" |
| 123 | >LIBS</CODE |
| 124 | > parameters needed to compile and link |
| 125 | programs with libgutenprint may vary. To make it simple to |
| 126 | determine what these are on any given system, a |
| 127 | <B |
| 128 | CLASS="command" |
| 129 | >pkg-config</B |
| 130 | > datafile was created when |
| 131 | Gutenprint was built. <B |
| 132 | CLASS="command" |
| 133 | >pkg-config</B |
| 134 | > will |
| 135 | output the correct parameters for the setup on your system. |
| 136 | See the |
| 137 | <SPAN |
| 138 | CLASS="citerefentry" |
| 139 | ><SPAN |
| 140 | CLASS="refentrytitle" |
| 141 | >pkg-config(1)</SPAN |
| 142 | ></SPAN |
| 143 | > manual page for a compete synopsis. |
| 144 | </P |
| 145 | ><P |
| 146 | > The correct <CODE |
| 147 | CLASS="varname" |
| 148 | >CFLAGS</CODE |
| 149 | > to use can be obtained |
| 150 | with the <CODE |
| 151 | CLASS="option" |
| 152 | >--cflags</CODE |
| 153 | > option: |
| 154 | </P |
| 155 | ><TABLE |
| 156 | BORDER="0" |
| 157 | BGCOLOR="#E0E0E0" |
| 158 | WIDTH="100%" |
| 159 | ><TR |
| 160 | ><TD |
| 161 | ><PRE |
| 162 | CLASS="screen" |
| 163 | ><TT |
| 164 | CLASS="prompt" |
| 165 | >$</TT |
| 166 | > <KBD |
| 167 | CLASS="userinput" |
| 168 | >pkg-config --cflags gutenprint</KBD |
| 169 | > |
| 170 | -I/usr/local/include</PRE |
| 171 | ></TD |
| 172 | ></TR |
| 173 | ></TABLE |
| 174 | ><P |
| 175 | > The correct <CODE |
| 176 | CLASS="varname" |
| 177 | >LIBS</CODE |
| 178 | > to use can the obtained |
| 179 | with the <CODE |
| 180 | CLASS="option" |
| 181 | >--libs</CODE |
| 182 | > option: |
| 183 | </P |
| 184 | ><TABLE |
| 185 | BORDER="0" |
| 186 | BGCOLOR="#E0E0E0" |
| 187 | WIDTH="100%" |
| 188 | ><TR |
| 189 | ><TD |
| 190 | ><PRE |
| 191 | CLASS="screen" |
| 192 | ><TT |
| 193 | CLASS="prompt" |
| 194 | >$</TT |
| 195 | > <KBD |
| 196 | CLASS="userinput" |
| 197 | >pkg-config --libs gutenprint</KBD |
| 198 | > |
| 199 | -L/usr/local/lib -lgutenprint -lm -ldl</PRE |
| 200 | ></TD |
| 201 | ></TR |
| 202 | ></TABLE |
| 203 | ><P |
| 204 | > Lastly, the installed version of Gutenprint can be obtained with the |
| 205 | <CODE |
| 206 | CLASS="varname" |
| 207 | >--version</CODE |
| 208 | > option: |
| 209 | </P |
| 210 | ><TABLE |
| 211 | BORDER="0" |
| 212 | BGCOLOR="#E0E0E0" |
| 213 | WIDTH="100%" |
| 214 | ><TR |
| 215 | ><TD |
| 216 | ><PRE |
| 217 | CLASS="screen" |
| 218 | ><TT |
| 219 | CLASS="prompt" |
| 220 | >$</TT |
| 221 | > <KBD |
| 222 | CLASS="userinput" |
| 223 | >pkg-config --modversion gutenprint</KBD |
| 224 | > |
| 225 | 4.3.23</PRE |
| 226 | ></TD |
| 227 | ></TR |
| 228 | ></TABLE |
| 229 | ><P |
| 230 | > The command can be used from the shell by enclosing it in |
| 231 | backquotes ‘`’: |
| 232 | </P |
| 233 | ><TABLE |
| 234 | BORDER="0" |
| 235 | BGCOLOR="#E0E0E0" |
| 236 | WIDTH="100%" |
| 237 | ><TR |
| 238 | ><TD |
| 239 | ><PRE |
| 240 | CLASS="screen" |
| 241 | ><TT |
| 242 | CLASS="prompt" |
| 243 | >$</TT |
| 244 | > <KBD |
| 245 | CLASS="userinput" |
| 246 | >gcc `pkg-config --cflags gutenprint` -c stpimage.c</KBD |
| 247 | > |
| 248 | <TT |
| 249 | CLASS="prompt" |
| 250 | >$</TT |
| 251 | > <KBD |
| 252 | CLASS="userinput" |
| 253 | >gcc `pkg-config --libs gutenprint` -o |
| 254 | stpimage stpimage.o</KBD |
| 255 | ></PRE |
| 256 | ></TD |
| 257 | ></TR |
| 258 | ></TABLE |
| 259 | ><P |
| 260 | > However, this is not the way it it typically used. Normally |
| 261 | it is used in a <TT |
| 262 | CLASS="filename" |
| 263 | >Makefile</TT |
| 264 | > or by an m4 |
| 265 | macro in a <B |
| 266 | CLASS="command" |
| 267 | >configure</B |
| 268 | > script. |
| 269 | </P |
| 270 | ></DIV |
| 271 | ><DIV |
| 272 | CLASS="sect2" |
| 273 | ><H2 |
| 274 | CLASS="sect2" |
| 275 | ><A |
| 276 | NAME="AEN122" |
| 277 | ><B |
| 278 | CLASS="command" |
| 279 | >make</B |
| 280 | ></A |
| 281 | ></H2 |
| 282 | ><P |
| 283 | > If you use <B |
| 284 | CLASS="command" |
| 285 | >make</B |
| 286 | > with your own |
| 287 | <TT |
| 288 | CLASS="filename" |
| 289 | >Makefile</TT |
| 290 | > files, then you are on your |
| 291 | own. This manual offers no assistance with doing this. Only |
| 292 | the following suggestion is offered, for use with GNU |
| 293 | <B |
| 294 | CLASS="command" |
| 295 | >make</B |
| 296 | >: |
| 297 | </P |
| 298 | ><TABLE |
| 299 | BORDER="0" |
| 300 | BGCOLOR="#E0E0E0" |
| 301 | WIDTH="100%" |
| 302 | ><TR |
| 303 | ><TD |
| 304 | ><PRE |
| 305 | CLASS="programlisting" |
| 306 | >GUTENPRINT_VERSION = $(shell pkg-config --version gutenprint) |
| 307 | GUTENPRINT_CFLAGS = $(shell pkg-config --cflags gutenprint) |
| 308 | GUTENPRINT_LIBS = $(shell pkg-config --libs gutenprint)</PRE |
| 309 | ></TD |
| 310 | ></TR |
| 311 | ></TABLE |
| 312 | ><P |
| 313 | > How you choose to use these variables is entirely up to |
| 314 | you. See the GNU <B |
| 315 | CLASS="command" |
| 316 | >make</B |
| 317 | > manual for more |
| 318 | information. |
| 319 | </P |
| 320 | ></DIV |
| 321 | ><DIV |
| 322 | CLASS="sect2" |
| 323 | ><H2 |
| 324 | CLASS="sect2" |
| 325 | ><A |
| 326 | NAME="AEN132" |
| 327 | ><B |
| 328 | CLASS="command" |
| 329 | >autoconf</B |
| 330 | ></A |
| 331 | ></H2 |
| 332 | ><P |
| 333 | > The <B |
| 334 | CLASS="command" |
| 335 | >autoconf</B |
| 336 | > program produces a Bourne |
| 337 | shell script called <TT |
| 338 | CLASS="filename" |
| 339 | >configure</TT |
| 340 | > from a |
| 341 | template file called <TT |
| 342 | CLASS="filename" |
| 343 | >configure.ac</TT |
| 344 | >. |
| 345 | <TT |
| 346 | CLASS="filename" |
| 347 | >configure.ac</TT |
| 348 | > contains both Bourne shell |
| 349 | script, and m4 macros. <B |
| 350 | CLASS="command" |
| 351 | >autoconf</B |
| 352 | > expands |
| 353 | the m4 macros into ‘real’ shell script. The |
| 354 | resulting <B |
| 355 | CLASS="command" |
| 356 | >configure</B |
| 357 | > script performs various |
| 358 | checks for installed programs, compiler characteristics and |
| 359 | other system information such as available headers and |
| 360 | libraries. See the GNU <B |
| 361 | CLASS="command" |
| 362 | >autoconf</B |
| 363 | > manual for |
| 364 | more information. |
| 365 | </P |
| 366 | ><P |
| 367 | > <B |
| 368 | CLASS="command" |
| 369 | >pkg-config</B |
| 370 | > provides an m4 macro, |
| 371 | <TT |
| 372 | CLASS="function" |
| 373 | >PKG_CHECK_MODULES</TT |
| 374 | >, suitable for use in a |
| 375 | <TT |
| 376 | CLASS="filename" |
| 377 | >configure.ac</TT |
| 378 | > script. It defines the |
| 379 | environment variables required for building libgutenprint-based |
| 380 | programs. For example, to set GUTENPRINT_CFLAGS and |
| 381 | GUTENPRINT_LIBS: |
| 382 | </P |
| 383 | ><DIV |
| 384 | CLASS="informalexample" |
| 385 | ><P |
| 386 | ></P |
| 387 | ><A |
| 388 | NAME="AEN147" |
| 389 | ></A |
| 390 | ><TABLE |
| 391 | BORDER="0" |
| 392 | BGCOLOR="#E0E0E0" |
| 393 | WIDTH="100%" |
| 394 | ><TR |
| 395 | ><TD |
| 396 | ><PRE |
| 397 | CLASS="programlisting" |
| 398 | >PKG_CHECK_MODULES(GUTENPRINT, gutenprint)</PRE |
| 399 | ></TD |
| 400 | ></TR |
| 401 | ></TABLE |
| 402 | ><P |
| 403 | ></P |
| 404 | ></DIV |
| 405 | ></DIV |
| 406 | ><DIV |
| 407 | CLASS="sect2" |
| 408 | ><H2 |
| 409 | CLASS="sect2" |
| 410 | ><A |
| 411 | NAME="AEN149" |
| 412 | ><B |
| 413 | CLASS="command" |
| 414 | >automake</B |
| 415 | ></A |
| 416 | ></H2 |
| 417 | ><P |
| 418 | > The <B |
| 419 | CLASS="command" |
| 420 | >automake</B |
| 421 | > program can be used to |
| 422 | generate <TT |
| 423 | CLASS="filename" |
| 424 | >Makefile.in</TT |
| 425 | > files suitable for |
| 426 | use with a <TT |
| 427 | CLASS="filename" |
| 428 | >configure</TT |
| 429 | > script generated by |
| 430 | <B |
| 431 | CLASS="command" |
| 432 | >autoconf</B |
| 433 | >. As <B |
| 434 | CLASS="command" |
| 435 | >automake</B |
| 436 | > |
| 437 | <I |
| 438 | CLASS="emphasis" |
| 439 | >requires</I |
| 440 | > <B |
| 441 | CLASS="command" |
| 442 | >autoconf</B |
| 443 | >, |
| 444 | this section will assume the use of a |
| 445 | <TT |
| 446 | CLASS="filename" |
| 447 | >configure.ac</TT |
| 448 | > script which uses the |
| 449 | <TT |
| 450 | CLASS="function" |
| 451 | >PKG_CHECK_MODULES</TT |
| 452 | > macro described above |
| 453 | (there is little point in <I |
| 454 | CLASS="emphasis" |
| 455 | >not</I |
| 456 | > using it!). |
| 457 | </P |
| 458 | ><P |
| 459 | > It is highly recommended that you use GNU |
| 460 | <B |
| 461 | CLASS="command" |
| 462 | >autoconf</B |
| 463 | > and |
| 464 | <B |
| 465 | CLASS="command" |
| 466 | >automake</B |
| 467 | >. They will allow you to make your |
| 468 | software build on most platforms with most compilers. |
| 469 | <B |
| 470 | CLASS="command" |
| 471 | >automake</B |
| 472 | > makes writing complex |
| 473 | <TT |
| 474 | CLASS="filename" |
| 475 | >Makefile</TT |
| 476 | >'s very easy, by expressing how |
| 477 | to build your packages in terms of what files are required to |
| 478 | build a project and the installation locations of the files. |
| 479 | It imposes a few limitations over using plain |
| 480 | <TT |
| 481 | CLASS="filename" |
| 482 | >Makefile</TT |
| 483 | >'s, such as in the use of |
| 484 | conditionals, but these problems are vastly outweighed by the |
| 485 | benefits it brings. It also creates many extra targets in the |
| 486 | generated <TT |
| 487 | CLASS="filename" |
| 488 | >Makefile.in</TT |
| 489 | > files such as |
| 490 | <CODE |
| 491 | CLASS="option" |
| 492 | >dist</CODE |
| 493 | >, <CODE |
| 494 | CLASS="option" |
| 495 | >distcheck</CODE |
| 496 | >, |
| 497 | <CODE |
| 498 | CLASS="option" |
| 499 | >clean</CODE |
| 500 | >, <CODE |
| 501 | CLASS="option" |
| 502 | >distclean</CODE |
| 503 | >, |
| 504 | <CODE |
| 505 | CLASS="option" |
| 506 | >maintainer-clean</CODE |
| 507 | > and <CODE |
| 508 | CLASS="option" |
| 509 | >tags</CODE |
| 510 | >, |
| 511 | and there are many more more available. See the GNU |
| 512 | <B |
| 513 | CLASS="command" |
| 514 | >automake</B |
| 515 | > manual for more information. |
| 516 | </P |
| 517 | ><P |
| 518 | > Because <TT |
| 519 | CLASS="function" |
| 520 | >PKG_CHECK_MODULES</TT |
| 521 | > calls |
| 522 | <TT |
| 523 | CLASS="function" |
| 524 | >AC_SUBST</TT |
| 525 | > to substitute |
| 526 | <CODE |
| 527 | CLASS="varname" |
| 528 | >GUTENPRINT_CFLAGS</CODE |
| 529 | > and |
| 530 | <CODE |
| 531 | CLASS="varname" |
| 532 | >GUTENPRINT_LIBS</CODE |
| 533 | >, <B |
| 534 | CLASS="command" |
| 535 | >automake</B |
| 536 | > |
| 537 | will automatically set these variables in the |
| 538 | <TT |
| 539 | CLASS="filename" |
| 540 | >Makefile.in</TT |
| 541 | > files it generates, requiring |
| 542 | no additional effort on your part! |
| 543 | </P |
| 544 | ><P |
| 545 | > As in previous examples, we will make a program |
| 546 | <B |
| 547 | CLASS="command" |
| 548 | >stpimage</B |
| 549 | > from |
| 550 | <TT |
| 551 | CLASS="filename" |
| 552 | >stpimage.c</TT |
| 553 | >. This is how one might build |
| 554 | write a <TT |
| 555 | CLASS="filename" |
| 556 | >Makefile.am</TT |
| 557 | > to do this: |
| 558 | </P |
| 559 | ><DIV |
| 560 | CLASS="informalexample" |
| 561 | ><P |
| 562 | ></P |
| 563 | ><A |
| 564 | NAME="AEN188" |
| 565 | ></A |
| 566 | ><TABLE |
| 567 | BORDER="0" |
| 568 | BGCOLOR="#E0E0E0" |
| 569 | WIDTH="100%" |
| 570 | ><TR |
| 571 | ><TD |
| 572 | ><PRE |
| 573 | CLASS="programlisting" |
| 574 | >@SET_MAKE@ |
| 575 | |
| 576 | AM_CFLAGS = $(GUTENPRINT_CFLAGS) |
| 577 | |
| 578 | bin_PROGRAMS = stpimage |
| 579 | stpimage_SOURCES = stpimage.c |
| 580 | stpimage_LDADD = $(GUTENPRINT_LIBS) |
| 581 | |
| 582 | MAINTAINERCLEANFILES = Makefile.in</PRE |
| 583 | ></TD |
| 584 | ></TR |
| 585 | ></TABLE |
| 586 | ><P |
| 587 | ></P |
| 588 | ></DIV |
| 589 | ><P |
| 590 | > That's all there is to it! Please note that this example also |
| 591 | requires the macro <TT |
| 592 | CLASS="function" |
| 593 | >AC_PROG_MAKE_SET</TT |
| 594 | > to be |
| 595 | used in <TT |
| 596 | CLASS="filename" |
| 597 | >configure.ac</TT |
| 598 | >. |
| 599 | </P |
| 600 | ></DIV |
| 601 | ></DIV |
| 602 | ><DIV |
| 603 | CLASS="NAVFOOTER" |
| 604 | ><HR |
| 605 | ALIGN="LEFT" |
| 606 | WIDTH="100%"><TABLE |
| 607 | SUMMARY="Footer navigation table" |
| 608 | WIDTH="100%" |
| 609 | BORDER="0" |
| 610 | CELLPADDING="0" |
| 611 | CELLSPACING="0" |
| 612 | ><TR |
| 613 | ><TD |
| 614 | WIDTH="33%" |
| 615 | ALIGN="left" |
| 616 | VALIGN="top" |
| 617 | ><A |
| 618 | HREF="x66.html" |
| 619 | ACCESSKEY="P" |
| 620 | ><<< Previous</A |
| 621 | ></TD |
| 622 | ><TD |
| 623 | WIDTH="34%" |
| 624 | ALIGN="center" |
| 625 | VALIGN="top" |
| 626 | ><A |
| 627 | HREF="book1.html" |
| 628 | ACCESSKEY="H" |
| 629 | >Home</A |
| 630 | ></TD |
| 631 | ><TD |
| 632 | WIDTH="33%" |
| 633 | ALIGN="right" |
| 634 | VALIGN="top" |
| 635 | ><A |
| 636 | HREF="c193.html" |
| 637 | ACCESSKEY="N" |
| 638 | >Next >>></A |
| 639 | ></TD |
| 640 | ></TR |
| 641 | ><TR |
| 642 | ><TD |
| 643 | WIDTH="33%" |
| 644 | ALIGN="left" |
| 645 | VALIGN="top" |
| 646 | >Linking with libgutenprint</TD |
| 647 | ><TD |
| 648 | WIDTH="34%" |
| 649 | ALIGN="center" |
| 650 | VALIGN="top" |
| 651 | ><A |
| 652 | HREF="c47.html" |
| 653 | ACCESSKEY="U" |
| 654 | >Up</A |
| 655 | ></TD |
| 656 | ><TD |
| 657 | WIDTH="33%" |
| 658 | ALIGN="right" |
| 659 | VALIGN="top" |
| 660 | >Reporting Bugs</TD |
| 661 | ></TR |
| 662 | ></TABLE |
| 663 | ></DIV |
| 664 | ></BODY |
| 665 | ></HTML |
| 666 | > |