Fixed package groups
[platform/upstream/libpng.git] / INSTALL
1
2 Installing libpng
3
4 Contents
5
6    I. Simple installation
7   II. Rebuilding the configure scripts
8  III. Using scripts/makefile*
9   IV. Using cmake
10    V. Directory structure
11   VI. Building with project files
12  VII. Building with makefiles
13 VIII. Configuring libpng for 16-bit platforms
14   IX. Configuring for DOS
15    X. Configuring for Medium Model
16   XI. Prepending a prefix to exported symbols
17  XII. Configuring for compiler xxx:
18 XIII. Removing unwanted object code
19  XIV. Changes to the build and configuration of libpng in libpng-1.5.x
20   XV. Configuring libpng for multiprocessing
21  XVI. Other sources of information about libpng:
22
23 I. Simple installation
24
25 On Unix/Linux and similar systems, you can simply type
26
27     ./configure [--prefix=/path]
28     make check
29     make install
30
31 and ignore the rest of this document.  "/path" is the path to the directory
32 where you want to install the libpng "lib", "include", and "bin"
33 subdirectories.
34
35 II. Rebuilding the configure scripts
36
37 If configure does not work on your system, or if you have a need to
38 change configure.ac or Makefile.am, and you have a reasonably
39 up-to-date set of tools, running ./autogen.sh in a git clone before
40 running ./configure may fix the problem.  To be really sure that you
41 aren't using any of the included pre-built scripts, you can do this:
42
43     ./configure --enable-maintainer-mode
44     make maintainer-clean
45     ./autogen.sh --maintainer --clean
46     ./autogen.sh --maintainer
47     ./configure [--prefix=/path] [other options]
48     make
49     make install
50     make check
51
52 III. Using scripts/makefile*
53
54 Instead, you can use one of the custom-built makefiles in the
55 "scripts" directory
56
57     cp scripts/pnglibconf.h.prebuilt pnglibconf.h
58     cp scripts/makefile.system makefile
59     make test
60     make install
61
62 The files that are presently available in the scripts directory
63 are listed and described in scripts/README.txt.
64
65 Or you can use one of the "projects" in the "projects" directory.
66
67 Before installing libpng, you must first install zlib, if it
68 is not already on your system.  zlib can usually be found
69 wherever you got libpng; otherwise go to http://zlib.net.  You can place
70 zlib in in the same directory as libpng or in another directory.
71
72 If your system already has a preinstalled zlib you will still need
73 to have access to the zlib.h and zconf.h include files that
74 correspond to the version of zlib that's installed.
75
76 If you wish to test with a particular zlib that is not first in the
77 standard library search path, put ZLIBLIB, ZLIBINC, CPPFLAGS, LDFLAGS,
78 and LD_LIBRARY_PATH in your environment before running "make test"
79 or "make distcheck":
80
81 ZLIBLIB=/path/to/lib export ZLIBLIB
82 ZLIBINC=/path/to/include export ZLIBINC
83 CPPFLAGS="-I$ZLIBINC" export CPPFLAGS
84 LDFLAGS="-L$ZLIBLIB" export LDFLAGS
85 LD_LIBRARY_PATH="$ZLIBLIB:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH
86
87 If you are using one of the makefile scripts, put ZLIBLIB and ZLIBINC
88 in your environment and type "make ZLIBLIB=$ZLIBLIB ZLIBINC=$ZLIBINC test".
89
90 IV. Using cmake
91
92 If you want to use "cmake" (see www.cmake.org), type
93
94    cmake . -DCMAKE_INSTALL_PREFIX=/path
95    make
96    make install
97
98 As when using the simple configure method described above, "/path" points to
99 the installation directory where you want to put the libpng "lib", "include",
100 and "bin" subdirectories.
101
102 V. Directory structure
103
104 You can rename the directories that you downloaded (they
105 might be called "libpng-x.y.z" or "libpngNN" and "zlib-1.2.8"
106 or "zlib128") so that you have directories called "zlib" and "libpng".
107
108 Your directory structure should look like this:
109
110    ..       (the parent directory)
111       libpng  (this directory)
112           INSTALL (this file)
113           README
114           *.h
115           *.c
116           CMakeLists.txt    =>  "cmake" script
117           configuration files:
118              configure.ac, configure, Makefile.am, Makefile.in,
119              autogen.sh, config.guess, ltmain.sh, missing, libpng.pc.in,
120              libpng-config.in, aclocal.m4, config.h.in, config.sub,
121              depcomp, install-sh, mkinstalldirs, test-pngtest.sh
122           contrib
123              gregbook
124              libtests
125              pngminim
126              pngminus
127              pngsuite
128              visupng
129           projects
130              visualc71
131              vstudio
132           scripts
133              makefile.*
134              *.def (module definition files)
135              etc.
136           pngtest.png
137           etc.
138       zlib
139           README
140           *.h
141           *.c
142           contrib
143           etc.
144
145 If the line endings in the files look funny, you may wish to get the other
146 distribution of libpng.  It is available in both tar.gz (UNIX style line
147 endings) and zip (DOS style line endings) formats.
148
149 VI. Building with project files
150
151 If you are building libpng with MSVC, you can enter the
152 libpng projects\visualc6 or visualc71 directory and follow the instructions
153 in README.txt.
154
155 Otherwise enter the zlib directory and follow the instructions in zlib/README,
156 then come back here and run "configure" or choose the appropriate
157 makefile.sys in the scripts directory.
158
159 VII. Building with makefiles
160
161 Copy the file (or files) that you need from the
162 scripts directory into this directory, for example
163
164    MSDOS example: copy scripts\makefile.msc makefile
165                   copy scripts\pnglibconf.h.prebuilt pnglibconf.h
166    UNIX example:  cp scripts/makefile.std makefile
167                   cp scripts/pnglibconf.h.prebuilt pnglibconf.h
168
169 Read the makefile to see if you need to change any source or
170 target directories to match your preferences.
171
172 Then read pnglibconf.dfa to see if you want to make any configuration
173 changes.
174
175 Then just run "make" which will create the libpng library in
176 this directory and "make test" which will run a quick test that reads
177 the "pngtest.png" file and writes a "pngout.png" file that should be
178 identical to it.  Look for "9782 zero samples" in the output of the
179 test.  For more confidence, you can run another test by typing
180 "pngtest pngnow.png" and looking for "289 zero samples" in the output.
181 Also, you can run "pngtest -m contrib/pngsuite/*.png" and compare
182 your output with the result shown in contrib/pngsuite/README.
183
184 Most of the makefiles will allow you to run "make install" to
185 put the library in its final resting place (if you want to
186 do that, run "make install" in the zlib directory first if necessary).
187 Some also allow you to run "make test-installed" after you have
188 run "make install".
189
190 VIII. Configuring libpng for 16-bit platforms
191
192 You will want to look into zconf.h to tell zlib (and thus libpng) that
193 it cannot allocate more then 64K at a time.  Even if you can, the memory
194 won't be accessible.  So limit zlib and libpng to 64K by defining MAXSEG_64K.
195
196 IX. Configuring for DOS
197
198 For DOS users who only have access to the lower 640K, you will
199 have to limit zlib's memory usage via a png_set_compression_mem_level()
200 call.  See zlib.h or zconf.h in the zlib library for more information.
201
202 X. Configuring for Medium Model
203
204 Libpng's support for medium model has been tested on most of the popular
205 compilers.  Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets
206 defined, and FAR gets defined to far in pngconf.h, and you should be
207 all set.  Everything in the library (except for zlib's structure) is
208 expecting far data.  You must use the typedefs with the p or pp on
209 the end for pointers (or at least look at them and be careful).  Make
210 note that the rows of data are defined as png_bytepp, which is
211 an "unsigned char far * far *".
212
213 XI. Prepending a prefix to exported symbols
214
215 Starting with libpng-1.6.0, you can configure libpng (when using the
216 "configure" script) to prefix all exported symbols by means of the
217 configuration option "--with-libpng-prefix=FOO_", where FOO_ can be any
218 string beginning with a letter and containing only uppercase
219 and lowercase letters, digits, and the underscore (i.e., a C language
220 identifier).  This creates a set of macros in pnglibconf.h, so this is
221 transparent to applications; their function calls get transformed by
222 the macros to use the modified names.
223
224 XII. Configuring for compiler xxx:
225
226 All includes for libpng are in pngconf.h.  If you need to add, change
227 or delete an include, this is the place to do it.
228 The includes that are not needed outside libpng are placed in pngpriv.h,
229 which is only used by the routines inside libpng itself.
230 The files in libpng proper only include pngpriv.h and png.h, which
231 in turn includes pngconf.h and, as of libpng-1.5.0, pnglibconf.h.
232 As of libpng-1.5.0, pngpriv.h also includes three other private header
233 files, pngstruct.h, pnginfo.h, and pngdebug.h, which contain material
234 that previously appeared in the public headers.
235
236 XIII. Removing unwanted object code
237
238 There are a bunch of #define's in pngconf.h that control what parts of
239 libpng are compiled.  All the defines end in _SUPPORTED.  If you are
240 never going to use a capability, you can change the #define to #undef
241 before recompiling libpng and save yourself code and data space, or
242 you can turn off individual capabilities with defines that begin with
243 PNG_NO_.
244
245 In libpng-1.5.0 and later, the #define's are in pnglibconf.h instead.
246
247 You can also turn all of the transforms and ancillary chunk capabilities
248 off en masse with compiler directives that define
249 PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS,
250 or all four, along with directives to turn on any of the capabilities that
251 you do want.  The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable the
252 extra transformations but still leave the library fully capable of reading
253 and writing PNG files with all known public chunks. Use of the
254 PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive produces a library
255 that is incapable of reading or writing ancillary chunks.  If you are
256 not using the progressive reading capability, you can turn that off
257 with PNG_NO_PROGRESSIVE_READ (don't confuse this with the INTERLACING
258 capability, which you'll still have).
259
260 All the reading and writing specific code are in separate files, so the
261 linker should only grab the files it needs.  However, if you want to
262 make sure, or if you are building a stand alone library, all the
263 reading files start with "pngr" and all the writing files start with "pngw".
264 The files that don't match either (like png.c, pngtrans.c, etc.)
265 are used for both reading and writing, and always need to be included.
266 The progressive reader is in pngpread.c
267
268 If you are creating or distributing a dynamically linked library (a .so
269 or DLL file), you should not remove or disable any parts of the library,
270 as this will cause applications linked with different versions of the
271 library to fail if they call functions not available in your library.
272 The size of the library itself should not be an issue, because only
273 those sections that are actually used will be loaded into memory.
274
275 XIV. Changes to the build and configuration of libpng in libpng-1.5.x
276
277 Details of internal changes to the library code can be found in the CHANGES
278 file and in the GIT repository logs.  These will be of no concern to the vast
279 majority of library users or builders; however, the few who configure libpng
280 to a non-default feature set may need to change how this is done.
281
282 There should be no need for library builders to alter build scripts if
283 these use the distributed build support - configure or the makefiles -
284 however, users of the makefiles may care to update their build scripts
285 to build pnglibconf.h where the corresponding makefile does not do so.
286
287 Building libpng with a non-default configuration has changed completely.
288 The old method using pngusr.h should still work correctly even though the
289 way pngusr.h is used in the build has been changed; however, library
290 builders will probably want to examine the changes to take advantage of
291 new capabilities and to simplify their build system.
292
293 A. Specific changes to library configuration capabilities
294
295 The exact mechanism used to control attributes of API functions has
296 changed.  A single set of operating system independent macro definitions
297 is used and operating system specific directives are defined in
298 pnglibconf.h
299
300 As part of this the mechanism used to choose procedure call standards on
301 those systems that allow a choice has been changed.  At present this only
302 affects certain Microsoft (DOS, Windows) and IBM (OS/2) operating systems
303 running on Intel processors.  As before, PNGAPI is defined where required
304 to control the exported API functions; however, two new macros, PNGCBAPI
305 and PNGCAPI, are used instead for callback functions (PNGCBAPI) and
306 (PNGCAPI) for functions that must match a C library prototype (currently
307 only png_longjmp_ptr, which must match the C longjmp function.)  The new
308 approach is documented in pngconf.h
309
310 Despite these changes, libpng 1.5.0 only supports the native C function
311 calling standard on those platforms tested so far (__cdecl on Microsoft
312 Windows).  This is because the support requirements for alternative
313 calling conventions seem to no longer exist.  Developers who find it
314 necessary to set PNG_API_RULE to 1 should advise the mailing list
315 (png-mng-implement) of this and library builders who use Openwatcom and
316 therefore set PNG_API_RULE to 2 should also contact the mailing list.
317
318 B. Changes to the configuration mechanism
319
320 Prior to libpng-1.5.0 library builders who needed to configure libpng
321 had either to modify the exported pngconf.h header file to add system
322 specific configuration or had to write feature selection macros into
323 pngusr.h and cause this to be included into pngconf.h by defining
324 PNG_USER_CONFIG. The latter mechanism had the disadvantage that an
325 application built without PNG_USER_CONFIG defined would see the
326 unmodified, default, libpng API and thus would probably fail to link.
327
328 These mechanisms still work in the configure build and in any makefile
329 build that builds pnglibconf.h, although the feature selection macros
330 have changed somewhat as described above.  In 1.5.0, however, pngusr.h is
331 processed only once, at the time the exported header file pnglibconf.h is
332 built.  pngconf.h no longer includes pngusr.h; therefore, pngusr.h is ignored
333 after the build of pnglibconf.h and it is never included in an application
334 build.
335
336 The rarely used alternative of adding a list of feature macros to the
337 CPPFLAGS setting in the build also still works; however, the macros will be
338 copied to pnglibconf.h and this may produce macro redefinition warnings
339 when the individual C files are compiled.
340
341 All configuration now only works if pnglibconf.h is built from
342 scripts/pnglibconf.dfa.  This requires the program awk.  Brian Kernighan
343 (the original author of awk) maintains C source code of that awk and this
344 and all known later implementations (often called by subtly different
345 names - nawk and gawk for example) are adequate to build pnglibconf.h.
346 The Sun Microsystems (now Oracle) program 'awk' is an earlier version
347 and does not work; this may also apply to other systems that have a
348 functioning awk called 'nawk'.
349
350 Configuration options are now documented in scripts/pnglibconf.dfa.  This
351 file also includes dependency information that ensures a configuration is
352 consistent; that is, if a feature is switched off dependent features are
353 also removed.  As a recommended alternative to using feature macros in
354 pngusr.h a system builder may also define equivalent options in pngusr.dfa
355 (or, indeed, any file) and add that to the configuration by setting
356 DFA_XTRA to the file name.  The makefiles in contrib/pngminim illustrate
357 how to do this, and illustrate a case where pngusr.h is still required.
358
359 XV. Configuring libpng for multiprocessing
360
361 Libpng uses setjmp()/longjmp() for error handling.  Unfortunately setjmp()
362 is known to be not thread-safe on some platforms and we don't know of
363 any platform where it is guaranteed to be thread-safe.  Therefore, if
364 your application is going to be using multiple threads, you should
365 configure libpng with PNG_NO_SETJMP in your pngusr.dfa file, with
366 -DPNG_NO_SETJMP on your compile line, or with
367
368   #undef PNG_SETJMP_SUPPORTED
369
370 in your pnglibconf.h or pngusr.h.
371
372 XVI. Other sources of information about libpng:
373
374 Further information can be found in the README and libpng-manual.txt
375 files, in the individual makefiles, in png.h, and the manual pages
376 libpng.3 and png.5.
377
378 Using the ./configure script -- 16 December 2002.
379 =================================================
380
381 The ./configure script should work compatibly with what scripts/makefile.*
382 did, however there are some options you might need to add to configure
383 explicitly, which previously was done semi-automatically (if you didn't edit
384 scripts/makefile.* yourself, that is)
385
386 CFLAGS="-Wall -O -funroll-loops \
387 -malign-loops=2 -malign-functions=2" ./configure --prefix=/usr/include \
388 --with-pkgconfigdir=/usr/lib/pkgconfig --includedir=/usr/include
389
390 You can alternatively specify --includedir=/usr/include, /usr/local/include,
391 /usr/include/libpng%NN%, or whatever.
392
393 If you find that the configure script is out-of-date or is not supporting
394 your platform properly, try running autogen.sh to regenerate "configure",
395 "Makefile.in", and the other configuration files. Then try configure again.
396