|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
Installing libpng
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
Contents
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
I. Simple installation
|
|
fukasawa |
e60969 |
II. Rebuilding the configure scripts
|
|
fukasawa |
e60969 |
III. Using scripts/makefile*
|
|
fukasawa |
e60969 |
IV. Using cmake
|
|
fukasawa |
e60969 |
V. Directory structure
|
|
fukasawa |
e60969 |
VI. Building with project files
|
|
fukasawa |
e60969 |
VII. Building with makefiles
|
|
fukasawa |
e60969 |
VIII. Configuring libpng for 16-bit platforms
|
|
fukasawa |
e60969 |
IX. Configuring for DOS
|
|
fukasawa |
e60969 |
X. Configuring for Medium Model
|
|
fukasawa |
e60969 |
XI. Prepending a prefix to exported symbols
|
|
fukasawa |
e60969 |
XII. Configuring for compiler xxx:
|
|
fukasawa |
e60969 |
XIII. Removing unwanted object code
|
|
fukasawa |
e60969 |
XIV. Changes to the build and configuration of libpng in libpng-1.5.x
|
|
fukasawa |
e60969 |
XV. Setjmp/longjmp issues
|
|
fukasawa |
e60969 |
XVI. Other sources of information about libpng
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
I. Simple installation
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
On Unix/Linux and similar systems, you can simply type
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
./configure [--prefix=/path]
|
|
fukasawa |
e60969 |
make check
|
|
fukasawa |
e60969 |
make install
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
and ignore the rest of this document. "/path" is the path to the directory
|
|
fukasawa |
e60969 |
where you want to install the libpng "lib", "include", and "bin"
|
|
fukasawa |
e60969 |
subdirectories.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
If you downloaded a GIT clone, you will need to run ./autogen.sh before
|
|
fukasawa |
e60969 |
running ./configure, to create "configure" and "Makefile.in" which are
|
|
fukasawa |
e60969 |
not included in the GIT repository.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
Note that "configure" is only included in the "*.tar" distributions and not
|
|
fukasawa |
e60969 |
in the "*.zip" or "*.7z" distributions. If you downloaded one of those
|
|
fukasawa |
e60969 |
distributions, see "Building with project files" or "Building with makefiles",
|
|
fukasawa |
e60969 |
below.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
II. Rebuilding the configure scripts
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
If configure does not work on your system, or if you have a need to
|
|
fukasawa |
e60969 |
change configure.ac or Makefile.am, and you have a reasonably
|
|
fukasawa |
e60969 |
up-to-date set of tools, running ./autogen.sh in a git clone before
|
|
fukasawa |
e60969 |
running ./configure may fix the problem. To be really sure that you
|
|
fukasawa |
e60969 |
aren't using any of the included pre-built scripts, you can do this:
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
./configure --enable-maintainer-mode
|
|
fukasawa |
e60969 |
make maintainer-clean
|
|
fukasawa |
e60969 |
./autogen.sh --maintainer --clean
|
|
fukasawa |
e60969 |
./autogen.sh --maintainer
|
|
fukasawa |
e60969 |
./configure [--prefix=/path] [other options]
|
|
fukasawa |
e60969 |
make
|
|
fukasawa |
e60969 |
make install
|
|
fukasawa |
e60969 |
make check
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
III. Using scripts/makefile*
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
Instead, you can use one of the custom-built makefiles in the
|
|
fukasawa |
e60969 |
"scripts" directory
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
cp scripts/pnglibconf.h.prebuilt pnglibconf.h
|
|
fukasawa |
e60969 |
cp scripts/makefile.system makefile
|
|
fukasawa |
e60969 |
make test
|
|
fukasawa |
e60969 |
make install
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
The files that are presently available in the scripts directory
|
|
fukasawa |
e60969 |
are listed and described in scripts/README.txt.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
Or you can use one of the "projects" in the "projects" directory.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
Before installing libpng, you must first install zlib, if it
|
|
fukasawa |
e60969 |
is not already on your system. zlib can usually be found
|
|
fukasawa |
e60969 |
wherever you got libpng; otherwise go to http://zlib.net. You can place
|
|
fukasawa |
e60969 |
zlib in in the same directory as libpng or in another directory.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
If your system already has a preinstalled zlib you will still need
|
|
fukasawa |
e60969 |
to have access to the zlib.h and zconf.h include files that
|
|
fukasawa |
e60969 |
correspond to the version of zlib that's installed.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
If you wish to test with a particular zlib that is not first in the
|
|
fukasawa |
e60969 |
standard library search path, put ZLIBLIB, ZLIBINC, CPPFLAGS, LDFLAGS,
|
|
fukasawa |
e60969 |
and LD_LIBRARY_PATH in your environment before running "make test"
|
|
fukasawa |
e60969 |
or "make distcheck":
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
ZLIBLIB=/path/to/lib export ZLIBLIB
|
|
fukasawa |
e60969 |
ZLIBINC=/path/to/include export ZLIBINC
|
|
fukasawa |
e60969 |
CPPFLAGS="-I$ZLIBINC" export CPPFLAGS
|
|
fukasawa |
e60969 |
LDFLAGS="-L$ZLIBLIB" export LDFLAGS
|
|
fukasawa |
e60969 |
LD_LIBRARY_PATH="$ZLIBLIB:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
If you are using one of the makefile scripts, put ZLIBLIB and ZLIBINC
|
|
fukasawa |
e60969 |
in your environment and type "make ZLIBLIB=$ZLIBLIB ZLIBINC=$ZLIBINC test".
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
IV. Using cmake
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
If you want to use "cmake" (see www.cmake.org), type
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
cmake . -DCMAKE_INSTALL_PREFIX=/path
|
|
fukasawa |
e60969 |
make
|
|
fukasawa |
e60969 |
make install
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
As when using the simple configure method described above, "/path" points to
|
|
fukasawa |
e60969 |
the installation directory where you want to put the libpng "lib", "include",
|
|
fukasawa |
e60969 |
and "bin" subdirectories.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
V. Directory structure
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
You can rename the directories that you downloaded (they
|
|
fukasawa |
e60969 |
might be called "libpng-x.y.z" or "libpngNN" and "zlib-1.2.8"
|
|
fukasawa |
e60969 |
or "zlib128") so that you have directories called "zlib" and "libpng".
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
Your directory structure should look like this:
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
.. (the parent directory)
|
|
fukasawa |
e60969 |
libpng (this directory)
|
|
fukasawa |
e60969 |
INSTALL (this file)
|
|
fukasawa |
e60969 |
README
|
|
fukasawa |
e60969 |
*.h, *.c => libpng source files
|
|
fukasawa |
e60969 |
CMakeLists.txt => "cmake" script
|
|
fukasawa |
e60969 |
configuration files:
|
|
fukasawa |
e60969 |
configure.ac, configure, Makefile.am, Makefile.in,
|
|
fukasawa |
e60969 |
autogen.sh, config.guess, ltmain.sh, missing, libpng.pc.in,
|
|
fukasawa |
e60969 |
libpng-config.in, aclocal.m4, config.h.in, config.sub,
|
|
fukasawa |
e60969 |
depcomp, install-sh, mkinstalldirs, test-pngtest.sh
|
|
fukasawa |
e60969 |
contrib
|
|
fukasawa |
e60969 |
arm-neon, conftest, examples, gregbook, libtests, pngminim,
|
|
fukasawa |
e60969 |
pngminus, pngsuite, tools, visupng
|
|
fukasawa |
e60969 |
projects
|
|
fukasawa |
e60969 |
cbuilder5, owatcom, visualc71, vstudio, xcode
|
|
fukasawa |
e60969 |
scripts
|
|
fukasawa |
e60969 |
makefile.*
|
|
fukasawa |
e60969 |
*.def (module definition files)
|
|
fukasawa |
e60969 |
etc.
|
|
fukasawa |
e60969 |
pngtest.png
|
|
fukasawa |
e60969 |
etc.
|
|
fukasawa |
e60969 |
zlib
|
|
fukasawa |
e60969 |
README, *.h, *.c contrib, etc.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
If the line endings in the files look funny, you may wish to get the other
|
|
fukasawa |
e60969 |
distribution of libpng. It is available in both tar.gz (UNIX style line
|
|
fukasawa |
e60969 |
endings) and zip (DOS style line endings) formats.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
VI. Building with project files
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
If you are building libpng with MSVC, you can enter the
|
|
fukasawa |
e60969 |
libpng projects\visualc71 or vstudio directory and follow the instructions
|
|
fukasawa |
e60969 |
in README.txt.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
Otherwise enter the zlib directory and follow the instructions in zlib/README,
|
|
fukasawa |
e60969 |
then come back here and run "configure" or choose the appropriate
|
|
fukasawa |
e60969 |
makefile.sys in the scripts directory.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
VII. Building with makefiles
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
Copy the file (or files) that you need from the
|
|
fukasawa |
e60969 |
scripts directory into this directory, for example
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
MSDOS example: copy scripts\makefile.msc makefile
|
|
fukasawa |
e60969 |
copy scripts\pnglibconf.h.prebuilt pnglibconf.h
|
|
fukasawa |
e60969 |
UNIX example: cp scripts/makefile.std makefile
|
|
fukasawa |
e60969 |
cp scripts/pnglibconf.h.prebuilt pnglibconf.h
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
Read the makefile to see if you need to change any source or
|
|
fukasawa |
e60969 |
target directories to match your preferences.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
Then read pnglibconf.dfa to see if you want to make any configuration
|
|
fukasawa |
e60969 |
changes.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
Then just run "make" which will create the libpng library in
|
|
fukasawa |
e60969 |
this directory and "make test" which will run a quick test that reads
|
|
fukasawa |
e60969 |
the "pngtest.png" file and writes a "pngout.png" file that should be
|
|
fukasawa |
e60969 |
identical to it. Look for "9782 zero samples" in the output of the
|
|
fukasawa |
e60969 |
test. For more confidence, you can run another test by typing
|
|
fukasawa |
e60969 |
"pngtest pngnow.png" and looking for "289 zero samples" in the output.
|
|
fukasawa |
e60969 |
Also, you can run "pngtest -m contrib/pngsuite/*.png" and compare
|
|
fukasawa |
e60969 |
your output with the result shown in contrib/pngsuite/README.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
Most of the makefiles will allow you to run "make install" to
|
|
fukasawa |
e60969 |
put the library in its final resting place (if you want to
|
|
fukasawa |
e60969 |
do that, run "make install" in the zlib directory first if necessary).
|
|
fukasawa |
e60969 |
Some also allow you to run "make test-installed" after you have
|
|
fukasawa |
e60969 |
run "make install".
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
VIII. Configuring libpng for 16-bit platforms
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
You will want to look into zconf.h to tell zlib (and thus libpng) that
|
|
fukasawa |
e60969 |
it cannot allocate more than 64K at a time. Even if you can, the memory
|
|
fukasawa |
e60969 |
won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
IX. Configuring for DOS
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
For DOS users who only have access to the lower 640K, you will
|
|
fukasawa |
e60969 |
have to limit zlib's memory usage via a png_set_compression_mem_level()
|
|
fukasawa |
e60969 |
call. See zlib.h or zconf.h in the zlib library for more information.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
X. Configuring for Medium Model
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
Libpng's support for medium model has been tested on most of the popular
|
|
fukasawa |
e60969 |
compilers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets
|
|
fukasawa |
e60969 |
defined, and FAR gets defined to far in pngconf.h, and you should be
|
|
fukasawa |
e60969 |
all set. Everything in the library (except for zlib's structure) is
|
|
fukasawa |
e60969 |
expecting far data. You must use the typedefs with the p or pp on
|
|
fukasawa |
e60969 |
the end for pointers (or at least look at them and be careful). Make
|
|
fukasawa |
e60969 |
note that the rows of data are defined as png_bytepp, which is
|
|
fukasawa |
e60969 |
an "unsigned char far * far *".
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
XI. Prepending a prefix to exported symbols
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
Starting with libpng-1.6.0, you can configure libpng (when using the
|
|
fukasawa |
e60969 |
"configure" script) to prefix all exported symbols by means of the
|
|
fukasawa |
e60969 |
configuration option "--with-libpng-prefix=FOO_", where FOO_ can be any
|
|
fukasawa |
e60969 |
string beginning with a letter and containing only uppercase
|
|
fukasawa |
e60969 |
and lowercase letters, digits, and the underscore (i.e., a C language
|
|
fukasawa |
e60969 |
identifier). This creates a set of macros in pnglibconf.h, so this is
|
|
fukasawa |
e60969 |
transparent to applications; their function calls get transformed by
|
|
fukasawa |
e60969 |
the macros to use the modified names.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
XII. Configuring for compiler xxx:
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
All includes for libpng are in pngconf.h. If you need to add, change
|
|
fukasawa |
e60969 |
or delete an include, this is the place to do it.
|
|
fukasawa |
e60969 |
The includes that are not needed outside libpng are placed in pngpriv.h,
|
|
fukasawa |
e60969 |
which is only used by the routines inside libpng itself.
|
|
fukasawa |
e60969 |
The files in libpng proper only include pngpriv.h and png.h, which
|
|
fukasawa |
e60969 |
in turn includes pngconf.h and, as of libpng-1.5.0, pnglibconf.h.
|
|
fukasawa |
e60969 |
As of libpng-1.5.0, pngpriv.h also includes three other private header
|
|
fukasawa |
e60969 |
files, pngstruct.h, pnginfo.h, and pngdebug.h, which contain material
|
|
fukasawa |
e60969 |
that previously appeared in the public headers.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
XIII. Removing unwanted object code
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
There are a bunch of #define's in pngconf.h that control what parts of
|
|
fukasawa |
e60969 |
libpng are compiled. All the defines end in _SUPPORTED. If you are
|
|
fukasawa |
e60969 |
never going to use a capability, you can change the #define to #undef
|
|
fukasawa |
e60969 |
before recompiling libpng and save yourself code and data space, or
|
|
fukasawa |
e60969 |
you can turn off individual capabilities with defines that begin with
|
|
fukasawa |
e60969 |
PNG_NO_.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
In libpng-1.5.0 and later, the #define's are in pnglibconf.h instead.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
You can also turn all of the transforms and ancillary chunk capabilities
|
|
fukasawa |
e60969 |
off en masse with compiler directives that define
|
|
fukasawa |
e60969 |
PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS,
|
|
fukasawa |
e60969 |
or all four, along with directives to turn on any of the capabilities that
|
|
fukasawa |
e60969 |
you do want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable the
|
|
fukasawa |
e60969 |
extra transformations but still leave the library fully capable of reading
|
|
fukasawa |
e60969 |
and writing PNG files with all known public chunks. Use of the
|
|
fukasawa |
e60969 |
PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive produces a library
|
|
fukasawa |
e60969 |
that is incapable of reading or writing ancillary chunks. If you are
|
|
fukasawa |
e60969 |
not using the progressive reading capability, you can turn that off
|
|
fukasawa |
e60969 |
with PNG_NO_PROGRESSIVE_READ (don't confuse this with the INTERLACING
|
|
fukasawa |
e60969 |
capability, which you'll still have).
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
All the reading and writing specific code are in separate files, so the
|
|
fukasawa |
e60969 |
linker should only grab the files it needs. However, if you want to
|
|
fukasawa |
e60969 |
make sure, or if you are building a stand alone library, all the
|
|
fukasawa |
e60969 |
reading files start with "pngr" and all the writing files start with "pngw".
|
|
fukasawa |
e60969 |
The files that don't match either (like png.c, pngtrans.c, etc.)
|
|
fukasawa |
e60969 |
are used for both reading and writing, and always need to be included.
|
|
fukasawa |
e60969 |
The progressive reader is in pngpread.c
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
If you are creating or distributing a dynamically linked library (a .so
|
|
fukasawa |
e60969 |
or DLL file), you should not remove or disable any parts of the library,
|
|
fukasawa |
e60969 |
as this will cause applications linked with different versions of the
|
|
fukasawa |
e60969 |
library to fail if they call functions not available in your library.
|
|
fukasawa |
e60969 |
The size of the library itself should not be an issue, because only
|
|
fukasawa |
e60969 |
those sections that are actually used will be loaded into memory.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
XIV. Changes to the build and configuration of libpng in libpng-1.5.x
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
Details of internal changes to the library code can be found in the CHANGES
|
|
fukasawa |
e60969 |
file and in the GIT repository logs. These will be of no concern to the vast
|
|
fukasawa |
e60969 |
majority of library users or builders; however, the few who configure libpng
|
|
fukasawa |
e60969 |
to a non-default feature set may need to change how this is done.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
There should be no need for library builders to alter build scripts if
|
|
fukasawa |
e60969 |
these use the distributed build support - configure or the makefiles -
|
|
fukasawa |
e60969 |
however, users of the makefiles may care to update their build scripts
|
|
fukasawa |
e60969 |
to build pnglibconf.h where the corresponding makefile does not do so.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
Building libpng with a non-default configuration has changed completely.
|
|
fukasawa |
e60969 |
The old method using pngusr.h should still work correctly even though the
|
|
fukasawa |
e60969 |
way pngusr.h is used in the build has been changed; however, library
|
|
fukasawa |
e60969 |
builders will probably want to examine the changes to take advantage of
|
|
fukasawa |
e60969 |
new capabilities and to simplify their build system.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
A. Specific changes to library configuration capabilities
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
The exact mechanism used to control attributes of API functions has
|
|
fukasawa |
e60969 |
changed. A single set of operating system independent macro definitions
|
|
fukasawa |
e60969 |
is used and operating system specific directives are defined in
|
|
fukasawa |
e60969 |
pnglibconf.h
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
As part of this the mechanism used to choose procedure call standards on
|
|
fukasawa |
e60969 |
those systems that allow a choice has been changed. At present this only
|
|
fukasawa |
e60969 |
affects certain Microsoft (DOS, Windows) and IBM (OS/2) operating systems
|
|
fukasawa |
e60969 |
running on Intel processors. As before, PNGAPI is defined where required
|
|
fukasawa |
e60969 |
to control the exported API functions; however, two new macros, PNGCBAPI
|
|
fukasawa |
e60969 |
and PNGCAPI, are used instead for callback functions (PNGCBAPI) and
|
|
fukasawa |
e60969 |
(PNGCAPI) for functions that must match a C library prototype (currently
|
|
fukasawa |
e60969 |
only png_longjmp_ptr, which must match the C longjmp function.) The new
|
|
fukasawa |
e60969 |
approach is documented in pngconf.h
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
Despite these changes, libpng 1.5.0 only supports the native C function
|
|
fukasawa |
e60969 |
calling standard on those platforms tested so far (__cdecl on Microsoft
|
|
fukasawa |
e60969 |
Windows). This is because the support requirements for alternative
|
|
fukasawa |
e60969 |
calling conventions seem to no longer exist. Developers who find it
|
|
fukasawa |
e60969 |
necessary to set PNG_API_RULE to 1 should advise the mailing list
|
|
fukasawa |
e60969 |
(png-mng-implement) of this and library builders who use Openwatcom and
|
|
fukasawa |
e60969 |
therefore set PNG_API_RULE to 2 should also contact the mailing list.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
B. Changes to the configuration mechanism
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
Prior to libpng-1.5.0 library builders who needed to configure libpng
|
|
fukasawa |
e60969 |
had either to modify the exported pngconf.h header file to add system
|
|
fukasawa |
e60969 |
specific configuration or had to write feature selection macros into
|
|
fukasawa |
e60969 |
pngusr.h and cause this to be included into pngconf.h by defining
|
|
fukasawa |
e60969 |
PNG_USER_CONFIG. The latter mechanism had the disadvantage that an
|
|
fukasawa |
e60969 |
application built without PNG_USER_CONFIG defined would see the
|
|
fukasawa |
e60969 |
unmodified, default, libpng API and thus would probably fail to link.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
These mechanisms still work in the configure build and in any makefile
|
|
fukasawa |
e60969 |
build that builds pnglibconf.h, although the feature selection macros
|
|
fukasawa |
e60969 |
have changed somewhat as described above. In 1.5.0, however, pngusr.h is
|
|
fukasawa |
e60969 |
processed only once, at the time the exported header file pnglibconf.h is
|
|
fukasawa |
e60969 |
built. pngconf.h no longer includes pngusr.h; therefore, pngusr.h is ignored
|
|
fukasawa |
e60969 |
after the build of pnglibconf.h and it is never included in an application
|
|
fukasawa |
e60969 |
build.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
The formerly used alternative of adding a list of feature macros to the
|
|
fukasawa |
e60969 |
CPPFLAGS setting in the build also still works; however, the macros will be
|
|
fukasawa |
e60969 |
copied to pnglibconf.h and this may produce macro redefinition warnings
|
|
fukasawa |
e60969 |
when the individual C files are compiled.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
All configuration now only works if pnglibconf.h is built from
|
|
fukasawa |
e60969 |
scripts/pnglibconf.dfa. This requires the program awk. Brian Kernighan
|
|
fukasawa |
e60969 |
(the original author of awk) maintains C source code of that awk and this
|
|
fukasawa |
e60969 |
and all known later implementations (often called by subtly different
|
|
fukasawa |
e60969 |
names - nawk and gawk for example) are adequate to build pnglibconf.h.
|
|
fukasawa |
e60969 |
The Sun Microsystems (now Oracle) program 'awk' is an earlier version
|
|
fukasawa |
e60969 |
and does not work; this may also apply to other systems that have a
|
|
fukasawa |
e60969 |
functioning awk called 'nawk'.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
Configuration options are now documented in scripts/pnglibconf.dfa. This
|
|
fukasawa |
e60969 |
file also includes dependency information that ensures a configuration is
|
|
fukasawa |
e60969 |
consistent; that is, if a feature is switched off, dependent features are
|
|
fukasawa |
e60969 |
also switched off. As a recommended alternative to using feature macros in
|
|
fukasawa |
e60969 |
pngusr.h a system builder may also define equivalent options in pngusr.dfa
|
|
fukasawa |
e60969 |
(or, indeed, any file) and add that to the configuration by setting
|
|
fukasawa |
e60969 |
DFA_XTRA to the file name. The makefiles in contrib/pngminim illustrate
|
|
fukasawa |
e60969 |
how to do this, and also illustrate a case where pngusr.h is still required.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
After you have built libpng, the definitions that were recorded in
|
|
fukasawa |
e60969 |
pnglibconf.h are available to your application (pnglibconf.h is included
|
|
fukasawa |
e60969 |
in png.h and gets installed alongside png.h and pngconf.h in your
|
|
fukasawa |
e60969 |
$PREFIX/include directory). Do not edit pnglibconf.h after you have built
|
|
fukasawa |
e60969 |
libpng, because than the settings would not accurately reflect the settings
|
|
fukasawa |
e60969 |
that were used to build libpng.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
XV. Setjmp/longjmp issues
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
Libpng uses setjmp()/longjmp() for error handling. Unfortunately setjmp()
|
|
fukasawa |
e60969 |
is known to be not thread-safe on some platforms and we don't know of
|
|
fukasawa |
e60969 |
any platform where it is guaranteed to be thread-safe. Therefore, if
|
|
fukasawa |
e60969 |
your application is going to be using multiple threads, you should
|
|
fukasawa |
e60969 |
configure libpng with PNG_NO_SETJMP in your pngusr.dfa file, with
|
|
fukasawa |
e60969 |
-DPNG_NO_SETJMP on your compile line, or with
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
#undef PNG_SETJMP_SUPPORTED
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
in your pnglibconf.h or pngusr.h.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
Starting with libpng-1.6.0, the library included a "simplified API".
|
|
fukasawa |
e60969 |
This requires setjmp/longjmp, so you must either build the library
|
|
fukasawa |
e60969 |
with PNG_SETJMP_SUPPORTED defined, or with PNG_SIMPLIFIED_READ_SUPPORTED
|
|
fukasawa |
e60969 |
and PNG_SIMPLIFIED_WRITE_SUPPORTED undefined.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
XVI. Other sources of information about libpng:
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
Further information can be found in the README and libpng-manual.txt
|
|
fukasawa |
e60969 |
files, in the individual makefiles, in png.h, and the manual pages
|
|
fukasawa |
e60969 |
libpng.3 and png.5.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
Using the ./configure script -- 16 December 2002.
|
|
fukasawa |
e60969 |
=================================================
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
The ./configure script should work compatibly with what scripts/makefile.*
|
|
fukasawa |
e60969 |
did, however there are some options you might need to add to configure
|
|
fukasawa |
e60969 |
explicitly, which previously was done semi-automatically (if you didn't edit
|
|
fukasawa |
e60969 |
scripts/makefile.* yourself, that is)
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
CFLAGS="-Wall -O -funroll-loops \
|
|
fukasawa |
e60969 |
-malign-loops=2 -malign-functions=2" ./configure --prefix=/usr/include \
|
|
fukasawa |
e60969 |
--with-pkgconfigdir=/usr/lib/pkgconfig --includedir=/usr/include
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
You can alternatively specify --includedir=/usr/include, /usr/local/include,
|
|
fukasawa |
e60969 |
/usr/include/libpng16, or whatever.
|
|
fukasawa |
e60969 |
|
|
fukasawa |
e60969 |
If you find that the configure script is out-of-date or is not supporting
|
|
fukasawa |
e60969 |
your platform properly, try running autogen.sh to regenerate "configure",
|
|
fukasawa |
e60969 |
"Makefile.in", and the other configuration files. Then try configure again.
|
|
fukasawa |
e60969 |
|