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

@SET_MAKE@

AM_CFLAGS = $(GUTENPRINT_CFLAGS)

bin_PROGRAMS = stpimage
stpimage_SOURCES = stpimage.c
stpimage_LDADD = $(GUTENPRINT_LIBS)

MAINTAINERCLEANFILES = Makefile.in</PRE
></TD
></TR
></TABLE
><P
></P
></DIV
><P
>&#13;        That's all there is to it!  Please note that this example also
	requires the macro <CODE
CLASS="function"
>AC_PROG_MAKE_SET</CODE
> to be
	used in <TT
CLASS="filename"
>configure.ac</TT
>.
      </P
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="x67.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="book1.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="c194.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Linking with libgutenprint</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="c48.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Reporting Bugs</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>