Debian Codegraph @

doc/INSTALL

raw
1 HOW TO INSTALL NETPBM
2 ---------------------
3
4 For most typical platforms, you can just do
5
6 ./configure
7
8 followed by
9
10 make
11
12 To build all the programs. Then
13
14 make package
15
16 to gather all the installable parts into a specified directory, and
17 finally
18
19 ./installnetpbm
20
21 to install it into your system.
22
23 If you have a Debian-like system, that uses Dpkg for package management,
24 it's better to create a Debian package file and install it as follows in
25 place of the 'installnetpbm' step above.
26
27 make deb
28 dpkg --install netpbm-sf-*.deb
29
30 More information on building and installing on Debian are in the file
31 buildtools/debian/README in the source tree.
32
33
34 The 'configure' program is not GNU Autoconf -- it is a simple program
35 specific to Netpbm that prompts you for information about your system.
36 If your system is not typical enough, you'll have to do a little more
37 work, as described below under "custom building."
38
39 You need to use GNU Make even if nothing else on your system is GNU,
40 because the Netpbm make files exploit many advanced features of GNU
41 Make. Often, systems have both GNU Make and a native Make. In this
42 case, GNU Make is named 'gmake'. If you don't have it yet, see
43 www.gnu.org/software. GNU Make is free, easy to install, and works
44 just about anywhere.
45
46 The only tricky part about installing is setting up the shared
47 libraries that are part of Netpbm. Simply putting the library files
48 in place may not be enough. If you get mysterious "file not found"
49 kinds of errors and are not an expert with shared libraries, see the
50 section "SHARED LIBRARIES" below.
51
52 The --keep-going option to Make is handy, because it causes Make to
53 make anything it can, as opposed to quitting as soon as something goes
54 wrong. With so many parts having so many requirements, it's not
55 unusual for a few things to fail to build, but that doesn't affect
56 everything else. You can work on the failed parts and repeat the make
57 and it will attempt to build whatever it hasn't successfully built
58 yet.
59
60
61 CHECKING THE BUILD
62 ------------------
63
64 The package comes with a test facility, which you can run after packaging,
65 against the package you created. The typical sequence is
66
67 make
68
69 make package
70
71 make check
72
73 ./installnetpbm
74
75 To capture all the messages from "make check" do:
76
77 make check > test.log 2>&1
78
79 The test facility was new in Netpbm 10.61 (December 2012).
80
81 For further information on the tests read the document TESTS.
82
83
84 OVERRIDING INTERNAL LIBRARIES
85 -----------------------------
86
87 There are a few esoteric libraries that are distributed separately from Netpbm
88 but of which Netpbm contains a copy too, for convenience. The build normally
89 uses the internal Netpbm copy, but you can configure the build to use a
90 version of the library that is installed on your system.
91
92 For the JBIG library, set the JBIGLIB and JBIGHDR_DIR variables in
93 config.mk to the appropriate values.
94
95 For the Utah Raster Toolkit (aka URT aka RLE) library, set the URTLIB and
96 URTHDR_DIR vairables in config.mk to the appropriate values.
97
98 The appropriate value for the xxxLIB variable is the full file name of the
99 link library (e.g. "/usr/local/lib/jbigkit/libjbig.so") or just the file name
100 part of it (e.g. "libjbig.so") if the library is in your linker's default
101 search path.
102
103 The appropriate value for the xxxHDR_DIR variable is the full directory name
104 of the directory that contains the interface header files for the library
105 identified by the xxxLIB variable (E.g. "usr/local/include/jbigkit") or a null
106 string if those header files are in your compiler's default search path.
107
108 If you use the 'configure' program, be sure to edit config.mk _after_ you
109 run 'configure', since 'configure' generates config.mk.
110
111
112 COMPILED-IN BUILD DATETIME AND USER
113 -----------------------------------
114
115 By default, the Netpbm build system builds the datetime that you built it
116 into libnetpbm, so the --version global command line option can display it.
117 It's actually just when you began building from a clean build tree; if you
118 modify code and rebuild, the build datetime does not change.
119
120 This is problematic for any of various reasons you might want to compare two
121 versions of libnetpbm, or anything of which it is part, for equality. Two
122 libnetpbms that are identical except that they were built at different times
123 would compare as different.
124
125 Furthermore, as version information, the modification datetime of the source
126 code is often more useful than the build datetime.
127
128 For these reasons, it is possible to change this timestamping behavior by
129 setting the environment variable 'SOURCE_DATE_EPOCH'. That is supposed to be
130 the POSIX datetime value (decimal number of seconds since 1969, excluding leap
131 seconds) for when the source code was last modified. When you set this,
132 before doing 'make' for the first time in a clean build tree, the resulting
133 libnetpbm contains that information and not build datetime information, and
134 the --version global option causes a different message.
135
136 The name and meaning of the environment variable is taken from a standard
137 described at https://reproducible-builds.org/specs/source-date-epoch/ on March
138 16, 2017.
139
140 Likewise, the Netpbm build system builds the identity of the party who did the
141 build in libnetpbm. This is normally a userid, the output of the 'whoami'
142 program, unless overridden by USER or LOGNAME environment variables. You can
143 also override 'whoami', USER, and LOGNAME with the COMPILED_BY environment
144 variable. This value is just for display, so it need not be a userid; any
145 single word that does not contain quotation marks is acceptable.
146
147
148 AUTOMATING THE BUILD
149 --------------------
150
151 The build is already as automatic as Netpbm developers know how to make
152 it without sacrificing your ability to build it a wide variety of ways.
153 But if you're building for a specific range of applications, e.g. a
154 particular standard system configuration, then you may want to write
155 programs to automate the build further.
156
157 PLEASE don't do this by writing a program that invokes Netpbm's Configure
158 program and tries to maintain a dialogue with Configure. This is more work
159 than you need to do and you will be disappointed with Configure's
160 unpredictability, especially from one release to the next. Configure is
161 specifically intended to talk to an intelligent human being.
162
163 Rather, just write a program to generate the file config.mk. That's
164 all Configure does in the end anyway. Like Configure, your program can
165 simply copy config.mk.in and add overrides to the bottom. Or you
166 can just package up a complete config.mk and not run any program at
167 all at build time. Comments in config.mk.in explain the entire
168 contents. You can also run Configure interactively and use its output
169 as an example.
170
171
172 COMPILER REQUIREMENTS
173 ---------------------
174
175 The compiler must be able to compile C99 code.
176
177
178 THE PREREQUISITE LIBRARIES
179 --------------------------
180
181 Netpbm uses lots of external libraries, but you don't necessarily have
182 to install them all. See http://netpbm.sourceforge.net/prereq.html .
183 You do, however, have to tell Configure accurately whether you have the
184 library installed and if so, where.
185
186
187 WINDOWS
188 -------
189
190 For notes on building Netpbm on Windows using Cygwin, see the file
191 README.CYGWIN. With Cygwin, you can build Netpbm programs that use
192 Cygwin or Netpbm programs that use Mingw.
193
194 Netpbm has also been built for Windows using Djgpp, as late as 2001.
195
196 See also the general installation instructions above.
197
198 Mingw Modification
199 -------------------
200
201 With at least some versions of MinGW, you have to make a small change to
202 _mingw.h or you get a compilation failure for invalid syntax in that file
203 where it expands the macro _XOPEN_SOURCE.
204
205 The problem is that many Netpbm programs declare that they need a C library
206 that conforms to any version of the X/Open (XPG, XSI, SUS) standard. The way
207 they do that is, in accordance with the earliest version of that standard, by
208 defining the macro _XOPEN_SOURCE with a null (zero-length) body. But MinGW is
209 not designed to work with programs that request anything earlier than Issue
210 (version) 5 of this standard, and in fact _mingw.h will not compile if the
211 macro expands to something other than a number.
212
213 But it is easy to add pre-Issue 5 function to MinGW and having done so, your
214 MinGW installation will also work with lots of other code. All you have to do
215 is change
216
217 if _XOPEN_SOURCE < 500
218
219 to
220
221 if (_XOPEN_SOURCE + 0) < 500
222
223 in _mingw.h. This is the trick other C libraries use.
224
225 (A user proposed that this change be distributed in _mingw.h, in April 2017 on
226 the mingw-users mailing list, but the maintainer was opposed to accommodating
227 programs written for the older standards).
228
229 If you cannot change _mingw.h, you can alternatively change Netpbm. Find all
230 instances of
231
232 #define _XOPEN_SOURCE
233
234 and change them to
235
236 #define _XOPEN_SOURCE 0
237
238
239 MAKING ONLY THE PARTS YOU NEED
240 ------------------------------
241
242 If you don't need the whole package, but just want one tool in it that you
243 heard about, you can make just that one. For example, to make Pnmtojpeg,
244 just do
245
246 configure
247 cd converter/other
248 make pnmtojpeg
249
250 It will build Pnmtojpeg and any of its dependencies, but nothing else.
251 You have to install it manually.
252
253 When you build just one program, you should request a static Netpbm
254 library in the configure step, because for just one program, the
255 shared library would be pure masochism.
256
257
258 CUSTOM BUILDING
259 ---------------
260
261 This section explains how to customize the installation in the case
262 that your platform is, or your requirements are, not among the simple
263 cases that 'configure' understands. 'configure' is really just a
264 convenient way to build the config.mk file, and in the most
265 general case, you build that file manually.
266
267 config.mk contains settings for various things that vary from
268 one system to the next, like file paths. Start with the distributed
269 file config.mk.in. Copy it as config.mk, then edit it.
270 Search for your platform name (Solaris, SunOS, NetBSD, Cygwin, BeOS,
271 and Tru64 are among those mentioned) to see recommended settings for
272 your platform.
273
274 If your system is even too exotic to accommodate with settings in
275 config.mk, you may need to modify things in the main make files
276 or pm_config.h.in.
277
278 If you figure out how to install on other platforms, contact the
279 Netpbm maintainer to have the 'configure' program or these
280 instructions improved for the next person.
281
282 If you want to use a compiler other than your system default, set
283 the CC value in config.mk to the shell command name for your compiler,
284 e.g.
285
286 CC=clang-3
287
288 You can also override it on the Make command line, which is especially
289 useful if you want to build some parts with one compiler and other parts
290 with another compiler:
291
292 $ make pamflip CC=clang-3
293
294 To get appropriate defaults when you run 'configure', you can also set what
295 compiler Configure assumes you will be using to build, with an environment
296 variable:
297
298 $ CC=clang-3 ./configure
299
300 Likewise, you can add compiler flags with a CFLAGS make variable, either set
301 in config.mk or on the make command line and you can get better get more
302 appropriate defaults from Configure if you pass the same CFLAGS to Configure
303 via environment variable. LDFLAGS (linker options) and CPPFLAGS (C
304 preprocessor options) are similar.
305
306 $ make CFLAGS=-O0
307
308
309 AUTOMATED AND CUSTOM INSTALLATION
310 ---------------------------------
311
312 If you want to have a program install Netpbm, don't use 'installnetpbm'. Just
313 write your own program to install from the package that 'make package'
314 generates. That package is just a directory full of files, and you should be
315 able to tell by inspection what to do with those files (copy to /bin, etc).
316 If not, there is a README file in the package that explains everything. Your
317 install program will probably just be shell script that issues about five
318 commands.
319
320 Likewise, even if you're installing interactively, if the Installnetpbm
321 program doesn't install the way you want, just install manually from the
322 package, using a few commands such as 'cp'.
323
324
325 INSTALLATION - SHARED LIBRARIES
326 -------------------------------
327
328 There are over 240 programs in the Netpbm package and they do a lot of
329 common things. In order to avoid the expense of copying the code for
330 those common things into every program, Netpbm places them in a shared
331 library: libnetpbm. When you invoke a Netpbm program, your system
332 notices that it needs this library and accesses it too.
333
334 The tricky part of installing the shared (runtime) library is telling
335 your system where to find it in the event that you invoke a Netpbm
336 program. And that varies from one system to the next.
337
338 On a GNU libc system (essentially, any Linux system), if you put the
339 Netpbm shared library in a conventional spot (say, /lib) and reboot
340 your system, chances are you will have no trouble running Netpbm
341 programs. But if you want to fine tune things, read up on ld-linux.so
342 (GNU libc's dynamic linker) and Ldconfig and consider the
343 /etc/ld.so.conf file and LD_LIBRARY_PATH environment variables. Use
344 'ldd' to see if you have a shared library issue. If it shows any
345 shared library as "not found", you've got library trouble.
346
347 On a Solaris system, use 'crle' to set the default search path for
348 shared libraries (which is kept in /var/ld/ld.config). Make sure that
349 path includes the directory in which you installed the Netpbm shared
350 library. You can also use the LD_LIBRARY_PATH environment variable.
351
352 On AIX, the environment variable LIBPATH affects the shared library search
353 path. On AIX 5.3 and newer, you can use LD_LIBRARY_PATH as well.
354
355 Besides the Netpbm shared library, libnetpbm, several of the converter
356 programs, e.g. Jpegtopnm, use separately distributed libraries that
357 understand the graphics format involved. You need to make sure your
358 system knows how to find those libraries at run time too (or cause the
359 Netpbm build to statically bind the libraries into the Netpbm programs).
360
361 Another thing you can do is forget about library search paths and just
362 build into each Netpbm executable the location of the Netpbm shared
363 library. (I'm talking about the classic -R linker option) You set
364 this up with variables in config.mk. If you use Configure to
365 build config.mk, then for some platforms where this method is
366 common, the Configure dialog asks you what directory, if any, you want
367 built into Netpbm executables.
368
369 One final note: New Netpbm executables often can run OK with an old
370 Netpbm shared library. This means if you don't correctly install
371 the new library, you may run what you think is a new Netpbm program,
372 but in actuality be accessing the old Netpbm library, and you may not
373 even notice a problem right away. But eventually, you may find some
374 things not working the way they should. Again, 'ldd' will give you
375 peace of mind.
376
377
378 INSTALLATION WITHOUT SHARED LIBRARIES
379 -------------------------------------
380
381 Since shared libraries can be such a pain, and in fact some systems
382 don't even have them, you can build Netpbm with a static library
383 instead. Just answer "static" to the static/shared question when you
384 run 'configure' (if you don't use 'configure', set NETPBMLIBTYPE as
385 directed in config.mk.in).
386
387 If you do this, you probably want to do a merge build instead of the
388 normal build (there's a question for that in the Configure program).
389 See below.
390
391
392 SEPARATE BUILD TREE
393 -------------------
394
395 While it's traditional to build a Unix package by adding object files
396 to the same tree with the source files, it's actually much cleaner to
397 keep your source tree exactly as you got it and put the built files in
398 a separate directory, called the build tree.
399
400 To do this, just create an empty directory and run 'configure' in it,
401 then 'make':
402
403 mkdir netpbmbuild
404 cd netpbmbuild
405 /usr/src/netpbm/configure
406 ...
407 make
408
409 But if you plan to work on Netpbm source code, you'll probably find it
410 more convenient to build the traditional way, with a single tree for
411 source and build.
412
413 In the source tree, you can type 'make' in any directory to do the
414 default make for that directory, or make FILENAME to make the file of
415 that name there. In the separate build tree, there are special
416 facilities to allow you to do a simple make from the _top level
417 directory_, but if you want to make a subcomponent or individual part,
418 you have to have a -f option and set SRCDIR and BLDDIR on your 'make'
419 command.
420
421
422 MERGE BUILD
423 -----------
424
425 There are two ways to build Netpbm: the standard or nonmerge build,
426 and the merge build. There are different make file targets for them
427 and which one is default is controlled by the DEFAULT_TARGET make
428 variable in config.mk, and its value is one of the choices you
429 make via the Configure dialog.
430
431 The standard build is the conventional one. The merge build is a way to
432 reduce disk space and other resource usage in some configurations. These are
433 rare configurations, mostly antique ones. The advent of shared libraries
434 largely obsoleted the merge build. In some configurations, Netpbm uses _more_
435 resources with the merge build.
436
437 In the standard build, hundreds of separate programs get built: ppmtogif,
438 pamcomp, etc.
439
440 But the merge build creates a single large program called 'netpbm'
441 instead. That single 'netpbm' program contains the functions of all
442 the individual programs that the standard build builds, and selects
443 one of them to execute based on what command name you use to invoke
444 'netpbm'.
445
446 For example, if you install 'netpbm' with a symbolic link to it named
447 'ppmtogif' and you invoke the program by typing 'ppmtogif' at a shell
448 prompt, 'netpbm' executes Ppmtogif.
449
450 Hence, 'make package' creates a package containing the one 'netpbm'
451 program and lots of symbolic links to it. With all these links
452 properly installed, a typical user cannot tell the merge build from the
453 standard build.
454
455
456 DOCUMENTATION
457 -------------
458
459 Documentation is not packaged with the program source code. See the
460 file doc/USERDOC for information on installing documentation.
461
462
463 COMMON PROBLEMS
464 ---------------
465
466 Improper -config files
467 ----------------------
468
469 The most common problem building Netpbm is one of improperly installed
470 prerequisite libraries, such as Libpng. Such a library is designed to be
471 installed along with a -config program (e.g. libpng-config) that tells
472 builders of dependent packages (such as Netpbm) how to use it. When the
473 -config program is wrong, you get Netpbm build failures with messages about
474 undefined references.
475
476 The exact nature of the problems with -config programs can be quite
477 involved, especially since there is no guarantee that a -config
478 program can do what's required of it in every situation. But I'll
479 explain the basic problem. For simplicity, I'll talk specifically
480 about Libpng, but the principles apply to any library that has a -config
481 program.
482
483 The point of libpng-config is to describe how Libpng is installed on your
484 particular system. You have choices of where to install the various parts
485 and what prerequisites to build into them, and libpng-config is how you
486 communicate those choices to the Netpbm make files.
487
488 Libpng's builder automatically creates a libpng-config program for you,
489 but you should not think of it as part of Libpng. It's really a
490 configuration file -- something that tells how your particular system
491 is put together. The Libpng builder is not smart enough to know exactly
492 what to put in libpng-config; it just builds one that works for most
493 people. The local system administrator is actually responsible for
494 the contents of libpng-config.
495
496 One rather complex way in which the libpng-config that the Libpng builder
497 builds can be wrong is that it often indicates that to link to the
498 Libpng library, you need a "-L /usr/lib" option (or something like that
499 -- an option that adds to the linker's search path a directory that is
500 already in it). This is usually unnecessary because the directory is
501 already in the search path, and often breaks things because it puts
502 the directory too early in the search path. If your libpng-config says to
503 link with -L /usr/lib, you should normally edit it to remove that.
504
505 As an example of how -L /usr/lib breaks things, here is a problem that is
506 often reported: The user has Netpbm installed on his system, but wants to
507 build a new one to replace it, or to use for a particular project instead of
508 the system version. But the build of the new version fails with undefined
509 references to symbol "pm_foo". pm_foo is a new symbol - it was added to
510 Netpbm in a recent release. The version of Netpbm installed on the system is
511 too old to have it. The make file obviously specifies the path to the current
512 libraries that the user just built in the link library search order, but the
513 link is picking up the old system version instead. Why? Because the link
514 options say to search /usr/lib _before_ the local build directory. And they
515 do that because libpng-config erroneously says that you need a -L /usr/lib
516 link option to find the Libpng library.