tlbuild: png library
6.4.1 The 'png' library in 'libs/libpng'
----------------------------------------
The "generic" 'png' library uses the source tree in the subdirectory
'libpng-src/', with all modifications for TL recorded in 'TLpatches/*'.
The 'configure.ac' fragment 'ac/withenable.ac' contains
KPSE_WITH_LIB([libpng], [zlib])
to specify the module name and indicate the dependency on 'zlib'. A
third literal argument ''tree'' would specify that the library from the
TeX Live tree cannot be replaced by a system version. That not being
the case here, a second fragment 'ac/libpng.ac' contains
KPSE_TRY_LIB([libpng],
[#include <png.h>],
[png_structp png; png_voidp io; png_rw_ptr fn;
png_set_read_fn(png, io, fn);])
thus providing the simple C code
#include <png.h>
int main ()
{ png_structp png; png_voidp io; png_rw_ptr fn;
png_set_read_fn(png, io, fn);
return 0; }
which Autoconf uses to verify the usability of a system version with C
code. The analogous macro 'KPSE_TRY_LIBXX' would check using C++.
These fragments are included by the 'configure.ac' at the top level of
TL ('Build/source/configure.ac').
For this library, like many other modules, a proxy build system for
TL is used, consisting of our own 'configure.ac', 'Makefile.am',
'include/Makefile.am'; the distributed build system is not used.
(Consequently, a few generated files and auxiliary scripts are removed
from the distributed source tree.)
The public headers 'png.h', 'pngconf.h', and 'pnglibconf.h' are
"installed" (as symlinks) under 'include/' in the build tree exactly as
they are for a system version under, e.g., '/usr/include/'.
The module is supplemented by the file 'm4/kpse-libpng-flags.m4' that
defines the M4 macro 'KPSE_LIBPNG_FLAGS' used by all modules depending
on this library in their 'configure.ac' to generate the 'make' variables
'LIBPNG_INCLUDES' for use in 'CPPFLAGS', 'LIBPNG_LIBS' for use in
'LDADD', 'LIBPNG_DEPEND' for use as dependencies, and 'LIBPNG_RULE' for
the 'make' rules to rebuild the library.
'm4/kpse-libpng-flags.m4' also supplies the configure option
'--with-system-libpng', which then uses 'pkg-config' to determine the
flags required for the system library.