[libpng10] Imported from libpng-1.0.14.tar
diff --git a/ANNOUNCE b/ANNOUNCE
index 81519c7..fb80b32 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,49 +1,55 @@
 
-Libpng 1.0.13 - April 15, 2002
+Libpng 1.0.14 - July 8, 2002
 
 This is a public release of libpng, intended for use in production codes.
 
-Changes since the last public release (1.2.1):
+Changes since the last public release (1.0.13):
 
-  Fixed a bug with reading the length of iCCP profiles (Larry Reeves).
-  Revised makefile.linux, makefile.gcmmx, and others to generate
-    libpng.a, libpngNN.so, libpng.so.NN, and libpngNN/png.h
-  Revised makefile.darwin to remove "-undefined suppress" option.
-  Added checks for gamma and chromaticity values over 21474.83, which exceed
-    the limit for PNG unsigned 32-bit integers when encoded.
-  Revised calls to png_create_read_struct() and png_create_write_struct()
-    for simpler debugging.
-  Revised png_zalloc() so zlib handles errors (uses PNG_FLAG_MALLOC_NULL_MEM_OK)
-  Check chunk_length and idat_size for invalid (over PNG_MAX_UINT) lengths.
-  Check for invalid image dimensions in png_get_IHDR.
-  Added install-shared and install-static targets to all makefiles that make
-    shared libraries.
-  Always do gamma compensation when image is partially transparent.
-  Modified shared-library makefiles to install pkgconfig/libpngNN.pc.
-  Export (with PNGAPI) png_zalloc, png_zfree, and png_handle_as_unknown
-  Removed unused png_write_destroy_info prototype from png.h
-  Eliminated incorrect use of width_mmx from pnggccrd.c in pixel_bytes == 8 case
-  Stopped a double free of palette, hist, and trans when not using free_me.
-  Added makefile.32sunu for Sun Ultra 32 and makefile.64sunu for Sun Ultra 64.
-  Compute background.gray and background_1.gray even when color_type is RGB
-    in case image gets reduced to gray later (Jason Summers).
-  Added PNG_1_0_X macro which can be used to build a 1.0.x-compatible library.
-  Added missing PNGAPI to several function definitions.
-  Check for invalid bit_depth or color_type in png_get_IHDR(), and
-    check for missing PLTE or IHDR in png_push_read_chunk() (Matthias Clasen).
-  Revised iTXt support to accept NULL for lang and lang_key.
-  Compute gamma for color components of background even when color_type is gray.
-  Revised makefiles to put png.h and pngconf.h only in $prefix/include/libpngNN
-  Revised makefiles to make symlink to libpng.so.NN in addition to libpngNN.so
-  Prevent png_zalloc() from trying to memset memory that it failed to acquire.
-  Add typecasts of PNG_MAX_UINT in pngset_cHRM_fixed() (Matt Holgate).
-  Ensure that the right function (user or default) is used to free the
-    png_struct after an error in png_create_read_struct_2().
-  Save the ebx register in pnggccrd.c (Sami Farin)
-  Add "mem_ptr = png_ptr->mem_ptr" in png_destroy_write_struct() (Paul Gardner).
-  Updated makefiles to put headers in include/libpng and remove old include/*.h.
-  Revised description of png_set_filter() in libpng.3/libpng.txt.
-  Revised makefile.netbsd and added makefile.neNNbsd and makefile.freebsd
+  Changed ${PNGMAJ}.${PNGVER} bug to ${PNGVER} in makefile.sgi and makefile.sggcc
+  Fixed VER -> PNGVER typo in makefile.macosx and added install-static to install
+  Added install: target to makefile.32sunu and makefile.64sunu
+  Revised 15 makefiles to link libpng.a to libpngNN.a and the include libpng
+    subdirectory to libpngNN subdirectory without the full pathname.
+  Moved generation of libpng.pc from "install" to "all" in 15 makefiles.
+  Added install-man target to 15 makefiles (Dimitri Papadopolous-Orfanos).
+  Added $(DESTDIR) feature to 24 makefiles (Tim Mooney)
+  Fixed bug with $prefix, should be $(prefix) in makefile.hpux.
+  Updated cygwin-specific portion of pngconf.h and revised makefile.cygwin
+  Added a link from libpngNN.pc to libpng.pc in 15 makefiles.
+  Added links from include/libpngNN/*.h to include/*.h in 24 makefiles.
+  Revised makefile.darwin to make relative links without full pathname.
+  Added setjmp() at the end of png_create_*_struct_2() in case user forgets
+    to put one in their application.
+  Fixed bug in reporting number of channels in pngget.c, introduced in
+    version 1.2.2
+  Added "libpng.pc" dependency to the "install-shared" target in 15 makefiles.
+  Remove old libpng.pc and libpngNN.pc before installing new ones.
+  Revised 15 makefiles to build libpng-config and libpngNN-config from
+    libpng-config-*.in.
+  Added "Win32 DLL VB" configuration to projects/msvc/libpng.dsp
+  Changed "error" and "message" in prototypes to "error_message" and
+    "warning_message" to avoid namespace conflict.
+  Restored png_zalloc and png_zfree to nonexported form as in libpng-1.2.1.
+  Removed description of png_set_mem_fn() from documentation.
+  Revised projects/msvc/README.txt
+  Added libpng.pc and libpng-config to "all:" target in 16 makefiles.
+  Fixed bug in 16 makefiles: $(DESTDIR)/$(LIBPATH) to $(DESTDIR)$(LIBPATH)
+  Added missing "\" before closing double quote in makefile.gcmmx.
+  Plugged various memory leaks; added png_malloc_warn() and png_set_text_2()
+    functions.
+  Plugged memory leak of png_ptr->current_text (Matt Holgate).
+  Check for buffer overflow before reading CRC in pngpread.c (Warwick Allison)
+  Added -soname to the loader flags in makefile.dec, makefile.sgi, and
+    makefile.sggcc.
+  Added "test-installed" targets to makefile.linux, makefile.gcmmx,
+    makefile.sgi, makefile.sggcc, makefile.32sunu, makefile.64sunu,
+    makefile.beos, makefile.darwin, makefile.dec, makefile.macosx, 
+    makefile.solaris, makefile.sco, makefile.cygwin, makefile.hpux,
+    makefile.hpgcc, and makefile.so9.
+  Plugged memory leak of row_buf in pngtest.c when there is a png_error().
+  Detect buffer overflow in pngpread.c when IDAT is corrupted with extra data.
+  Revised pnggccrd.c to be able to back out version 1.0.x via PNG_1_0_X macro.
+  Changed png_warning() to png_error() when width is too large to process.
 
 Send comments/corrections/commendations to
 png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu
diff --git a/CHANGES b/CHANGES
index fc60d7e..6233c0e 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1008,7 +1008,6 @@
   Updated various makefiles so "make clean" does not remove previous major
     version of the shared library.
 version 1.2.1rc2 [December 4, 2001]
-  Added a pop/push operation to pngvcrd.c, to preserve Eflag.
   Always allocate 256-entry internal palette, hist, and trans arrays, to
     avoid out-of-bounds memory reference caused by invalid PNG datastreams.
   Added a check for prefix_length > data_length in iCCP chunk handler.
@@ -1065,9 +1064,91 @@
   Save the ebx register in pnggccrd.c (Sami Farin)
   Add "mem_ptr = png_ptr->mem_ptr" in png_destroy_write_struct() (Paul Gardner).
   Updated makefiles to put headers in include/libpng and remove old include/*.h.
+version 1.2.2 [April 15, 2002]
 version 1.0.13 [April 15, 2002]
   Revised description of png_set_filter() in libpng.3/libpng.txt.
   Revised makefile.netbsd and added makefile.neNNbsd and makefile.freebsd
+version 1.0.13patch01 [April 17, 2002]
+version 1.2.2patch01 [April 17, 2002]
+  Changed ${PNGMAJ}.${PNGVER} bug to ${PNGVER} in makefile.sgi and makefile.sggcc
+  Fixed VER -> PNGVER typo in makefile.macosx and added install-static to install
+  Added install: target to makefile.32sunu and makefile.64sunu
+version 1.0.13patch03 [April 18, 2002]
+version 1.2.2patch03 [April 18, 2002]
+  Revised 15 makefiles to link libpng.a to libpngNN.a and the include libpng
+  subdirectory to libpngNN subdirectory without the full pathname.
+  Moved generation of libpng.pc from "install" to "all" in 15 makefiles.
+version 1.2.3rc1 [April 28, 2002]
+  Added install-man target to 15 makefiles (Dimitri Papadopolous-Orfanos).
+  Added $(DESTDIR) feature to 24 makefiles (Tim Mooney)
+  Fixed bug with $prefix, should be $(prefix) in makefile.hpux.
+  Updated cygwin-specific portion of pngconf.h and revised makefile.cygwin
+  Added a link from libpngNN.pc to libpng.pc in 15 makefiles.
+  Added links from include/libpngNN/*.h to include/*.h in 24 makefiles.
+  Revised makefile.darwin to make relative links without full pathname.
+  Added setjmp() at the end of png_create_*_struct_2() in case user forgets
+    to put one in their application.
+  Restored png_zalloc() and png_zfree() prototypes to version 1.2.1 and
+    removed them from module definition files.
+version 1.2.3rc2 [May 1, 2002]
+  Fixed bug in reporting number of channels in pngget.c and pngset.c,
+    that was introduced in version 1.2.2beta5.
+  Exported png_zalloc(), png_zfree(), png_default_read(), png_default_write(),
+    png_default_flush(), and png_push_fill_buffer() and included them in
+    module definition files.
+  Added "libpng.pc" dependency to the "install-shared" target in 15 makefiles.
+version 1.2.3rc3 [May 1, 2002]
+  Revised prototype for png_default_flush()
+  Remove old libpng.pc and libpngNN.pc before installing new ones.
+version 1.2.3rc4 [May 2, 2002]
+  Typos in *.def files (png_default_read|write -> png_default_read|write_data)
+  In makefiles, changed rm libpng.NN.pc to rm libpngNN.pc
+  Added libpng-config and libpngNN-config and modified makefiles to install them.
+  Changed $(MANPATH) to $(DESTDIR)$(MANPATH) in makefiles
+  Added "Win32 DLL VB" configuration to projects/msvc/libpng.dsp
+version 1.2.3rc5 [May 11, 2002]
+  Changed "error" and "message" in prototypes to "error_message" and
+    "warning_message" to avoid namespace conflict.
+  Revised 15 makefiles to build libpng-config from libpng-config-*.in
+  Once more restored png_zalloc and png_zfree to regular nonexported form.
+  Restored png_default_read|write_data, png_default_flush, png_read_fill_buffer
+    to nonexported form, but with PNGAPI, and removed them from module def files.
+version 1.2.3rc6 [May 14, 2002]
+  Removed "PNGAPI" from png_zalloc() and png_zfree() in png.c
+  Changed "Gz" to "Gd" in projects/msvc/libpng.dsp and zlib.dsp.
+  Removed leftover libpng-config "sed" script from four makefiles.
+  Revised libpng-config creating script in 16 makefiles.
+version 1.2.3 [May 22, 2002]
+  Revised libpng-config target in makefile.cygwin.
+  Removed description of png_set_mem_fn() from documentation.
+  Revised makefile.freebsd.
+  Minor cosmetic changes to 15 makefiles, e.g., $(DI) = $(DESTDIR)/$(INCDIR).
+  Revised projects/msvc/README.txt
+  Changed -lpng to -lpngNN in LDFLAGS in several makefiles.
+version 1.2.4beta1 [May 24, 2002]
+  Added libpng.pc and libpng-config to "all:" target in 16 makefiles.
+  Fixed bug in 16 makefiles: $(DESTDIR)/$(LIBPATH) to $(DESTDIR)$(LIBPATH)
+  Added missing "\" before closing double quote in makefile.gcmmx.
+  Plugged various memory leaks; added png_malloc_warn() and png_set_text_2()
+    functions.
+version 1.2.4beta2 [June 25, 2002]
+  Plugged memory leak of png_ptr->current_text (Matt Holgate).
+  Check for buffer overflow before reading CRC in pngpread.c (Warwick Allison)
+  Added -soname to the loader flags in makefile.dec, makefile.sgi, and
+    makefile.sggcc.
+  Added "test-installed" target to makefile.linux, makefile.gcmmx,
+    makefile.sgi, and makefile.sggcc.
+version 1.2.4beta3 [June 28, 2002]
+  Plugged memory leak of row_buf in pngtest.c when there is a png_error().
+  Detect buffer overflow in pngpread.c when IDAT is corrupted with extra data.
+  Added "test-installed" target to makefile.32sunu, makefile.64sunu,
+    makefile.beos, makefile.darwin, makefile.dec, makefile.macosx, 
+    makefile.solaris, makefile.hpux, makefile.hpgcc, and makefile.so9.
+version 1.2.4rc1 [July 2, 2002]
+  Added "test-installed" target to makefile.cygwin and makefile.sco.
+  Revised pnggccrd.c to be able to back out version 1.0.x via PNG_1_0_X macro.
+version 1.0.14 [July 8, 2002]
+  Changed png_warning() to png_error() when width is too large to process.
 
 Send comments/corrections/commendations to
 png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu
diff --git a/INSTALL b/INSTALL
index 2070549..7450db3 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,5 +1,5 @@
 
-Installing libpng version 1.0.13 - April 15, 2002
+Installing libpng version 1.0.14 - July 8, 2002
 
 Before installing libpng, you must first install zlib.  zlib
 can usually be found wherever you got libpng.  zlib can be
@@ -10,7 +10,7 @@
 version of zlib that's installed.
 
 You can rename the directories that you downloaded (they
-might be called "libpng-1.0.13" or "lpng109" and "zlib-1.1.3"
+might be called "libpng-1.0.14" or "lpng109" and "zlib-1.1.3"
 or "zlib113") so that you have directories called "zlib" and "libpng".
 
 Your directory structure should look like this:
@@ -64,8 +64,8 @@
 include
 
  makefile.std      =>  Generic UNIX makefile (cc, creates static libpng.a)
- makefile.linux    =>  Linux/ELF makefile (gcc, creates libpng10.so.0.1.0.13)
- makefile.gcmmx    =>  Linux/ELF makefile (gcc, creates libpng10.so.0.1.0.13,
+ makefile.linux    =>  Linux/ELF makefile (gcc, creates libpng10.so.0.1.0.14)
+ makefile.gcmmx    =>  Linux/ELF makefile (gcc, creates libpng10.so.0.1.0.14,
                        uses assembler code tuned for Intel MMX platform)
  makefile.gcc      =>  Generic makefile (gcc, creates static libpng.a)
  makefile.knr      =>  Archaic UNIX Makefile that converts files with
@@ -75,19 +75,21 @@
  makefile.cygwin   =>  Cygwin/gcc makefile
  makefile.darwin   =>  Darwin makefile
  makefile.dec      =>  DEC Alpha UNIX makefile
+ makefile.hpgcc    =>  FreeBSD makefile
  makefile.hpgcc    =>  HPUX makefile using gcc
  makefile.hpux     =>  HPUX (10.20 and 11.00) makefile
  makefile.ibmc     =>  IBM C/C++ version 3.x for Win32 and OS/2 (static)
  makefile.intel    =>  Intel C/C++ version 4.0 and later
  libpng.icc        =>  Project file for IBM VisualAge/C++ version 4.0 or later
  makefile.macosx   =>  MACOS X Makefile
- makefile.netbsd   =>  NetBSD/cc makefile, uses PNGGCCRD
+ makefile.netbsd   =>  NetBSD/cc makefile, uses PNGGCCRD, makes libpng.so.
+ makefile.ne0bsd  =>  NetBSD/cc makefile, uses PNGGCCRD, makes libpng0.so
  makefile.openbsd  =>  OpenBSD makefile
  makefile.sgi      =>  Silicon Graphics IRIX makefile (cc, creates static lib)
- makefile.sggcc    =>  Silicon Graphics (gcc, creates libpng10.so.0.1.0.13)
+ makefile.sggcc    =>  Silicon Graphics (gcc, creates libpng10.so.0.1.0.14)
  makefile.sunos    =>  Sun makefile
- makefile.solaris  =>  Solaris 2.X makefile (gcc, creates libpng10.so.0.1.0.13)
- makefile.so9      =>  Solaris 9 makefile (gcc, creates libpng10.so.0.1.0.13)
+ makefile.solaris  =>  Solaris 2.X makefile (gcc, creates libpng10.so.0.1.0.14)
+ makefile.so9      =>  Solaris 9 makefile (gcc, creates libpng10.so.0.1.0.14)
  makefile.32sunu   =>  Sun Ultra 32-bit makefile
  makefile.64sunu   =>  Sun Ultra 64-bit makefile
  makefile.sco      =>  For SCO OSr5  ELF and Unixware 7 with Native cc
diff --git a/KNOWNBUG b/KNOWNBUG
index 40c98b6..34452c6 100644
--- a/KNOWNBUG
+++ b/KNOWNBUG
@@ -1,9 +1,11 @@
 
-Known bugs in libpng version 1.0.13
+Known bugs in libpng version 1.0.14
 
 1. April 22, 2001: pnggccrd.c has been reported to crash on NetBSD when
-   reading interlaced PNG files, when assembler code is enabled.
+   reading interlaced PNG files, when assembler code is enabled but running
+   on a non-MMX i386 platform.
 
    STATUS: Under investigation.  The change to pnggccrd.c in libpng-1.2.1
-   fixed a problem under FreeBSD but not the problem with NetBSD.
+   fixed a problem under FreeBSD but not the problem with NetBSD, which
+   still fails as of libpng-1.2.2rc1.
 
diff --git a/LICENSE b/LICENSE
index 9011bba..f0b6cab 100644
--- a/LICENSE
+++ b/LICENSE
@@ -8,7 +8,7 @@
 If you modify libpng you may insert additional notices immediately following
 this sentence.
 
-libpng versions 1.0.7, July 1, 2000, through 1.0.13, April 15, 2002, are
+libpng versions 1.0.7, July 1, 2000, through 1.0.14, July 8, 2002, are
 Copyright (c) 2000-2002 Glenn Randers-Pehrson
 and are distributed according to the same disclaimer and license as libpng-1.0.6
 with the following individuals added to the list of Contributing Authors
@@ -99,4 +99,4 @@
 
 Glenn Randers-Pehrson
 randeg@alum.rpi.edu
-April 15, 2002
+July 8, 2002
diff --git a/README b/README
index 944c3f0..cb7e40b 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-README for libpng 1.0.13 - April 15, 2002 (shared library 2.1)
+README for libpng 1.0.14 - July 8, 2002 (shared library 2.1)
 See the note about version numbers near the top of png.h
 
 See INSTALL for instructions on how to install libpng.
@@ -187,9 +187,9 @@
        descrip.mms      =>  VMS makefile for MMS or MMK
        makefile.std     =>  Generic UNIX makefile (cc, creates static libpng.a)
        makefile.linux   =>  Linux/ELF makefile
-                            (gcc, creates libpng10.so.0.1.0.13)
+                            (gcc, creates libpng10.so.0.1.0.14)
        makefile.gcmmx   =>  Linux/ELF makefile (gcc, creates
-                            libpng10.so.0.1.0.13, uses assembler code
+                            libpng10.so.0.1.0.14, uses assembler code
                             tuned for Intel MMX platform)
        makefile.gcc     =>  Generic makefile (gcc, creates static libpng.a)
        makefile.knr     =>  Archaic UNIX Makefile that converts files with
@@ -199,21 +199,23 @@
        makefile.cygwin  =>  Cygwin/gcc makefile
        makefile.darwin  =>  Darwin makefile
        makefile.dec     =>  DEC Alpha UNIX makefile
+       makefile.freebsd =>  FreeBSD makefile
        makefile.hpgcc   =>  HPUX makefile using gcc
        makefile.hpux    =>  HPUX (10.20 and 11.00) makefile
        makefile.ibmc    =>  IBM C/C++ version 3.x for Win32 and OS/2 (static)
        makefile.intel   =>  Intel C/C++ version 4.0 and later
        libpng.icc       =>  Project file, IBM VisualAge/C++ 4.0 or later
        makefile.macosx  =>  MACOS X Makefile
-       makefile.netbsd  =>  NetBSD/cc makefile, uses PNGGCCRD
+       makefile.netbsd  =>  NetBSD/cc makefile, PNGGCCRD, makes libpng.so.
+       makefile.ne0bsd =>  NetBSD/cc makefile, PNGGCCRD, makes libpng0.so
        makefile.openbsd =>  OpenBSD makefile
        makefile.sgi     =>  Silicon Graphics IRIX (cc, creates static lib)
-       makefile.sggcc   =>  Silicon Graphics (gcc, creates libpng10.so.0.1.0.13)
+       makefile.sggcc   =>  Silicon Graphics (gcc, creates libpng10.so.0.1.0.14)
        makefile.sunos   =>  Sun makefile
        makefile.solaris =>  Solaris 2.X makefile
-                            (gcc, creates libpng10.so.0.1.0.13)
+                            (gcc, creates libpng10.so.0.1.0.14)
        makefile.so9     =>  Solaris 9 makefile
-                            (gcc, creates libpng10.so.0.1.0.13)
+                            (gcc, creates libpng10.so.0.1.0.14)
        makefile.32sunu  =>  Sun Ultra 32-bit makefile
        makefile.64sunu  =>  Sun Ultra 64-bit makefile
        makefile.sco     =>  For SCO OSr5  ELF and Unixware 7 with Native cc
diff --git a/Y2KINFO b/Y2KINFO
index 67d4e7e..3da50dc 100644
--- a/Y2KINFO
+++ b/Y2KINFO
@@ -1,13 +1,13 @@
    Y2K compliance in libpng:
    =========================
 
-      April 15, 2002
+      July 8, 2002
 
       Since the PNG Development group is an ad-hoc body, we can't make
       an official declaration.
 
       This is your unofficial assurance that libpng from version 0.71 and
-      upward through 1.0.13 are Y2K compliant.  It is my belief that earlier
+      upward through 1.0.14 are Y2K compliant.  It is my belief that earlier
       versions were also Y2K compliant.
 
       Libpng only has three year fields.  One is a 2-byte unsigned integer
diff --git a/configure b/configure
index 6fc27d0..f9fd7f3 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 echo "
-  There is no \"configure\" script for Libpng-1.0.13.  Instead, please
+  There is no \"configure\" script for Libpng-1.0.14.  Instead, please
   copy the appropriate makefile for your system from the \"scripts\"
   directory.  Read the INSTALL file for more details.
 "
diff --git a/example.c b/example.c
index a72bedc..1cc450f 100644
--- a/example.c
+++ b/example.c
@@ -169,11 +169,11 @@
    png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
        &interlace_type, int_p_NULL, int_p_NULL);
 
-/**** Set up the data transformations you want.  Note that these are all
- **** optional.  Only call them if you want/need them.  Many of the
- **** transformations only work on specific types of images, and many
- **** are mutually exclusive.
- ****/
+/* Set up the data transformations you want.  Note that these are all
+ * optional.  Only call them if you want/need them.  Many of the
+ * transformations only work on specific types of images, and many
+ * are mutually exclusive.
+ */
 
    /* tell libpng to strip 16 bit/color files down to 8 bits/color */
    png_set_strip_16(png_ptr);
diff --git a/libpng.3 b/libpng.3
index 5019a72..dd6444a 100644
--- a/libpng.3
+++ b/libpng.3
@@ -1,6 +1,6 @@
-.TH LIBPNG 3 "April 15, 2002"
+.TH LIBPNG 3 "July 8, 2002"
 .SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.0.13
+libpng \- Portable Network Graphics (PNG) Reference Library 1.0.14
 .SH SYNOPSIS
 \fI\fB
 
@@ -761,7 +761,7 @@
 .SH LIBPNG.TXT
 libpng.txt - A description on how to use and modify libpng
 
- libpng version 1.0.13 - April 15, 2002
+ libpng version 1.0.14 - July 8, 2002
  Updated and distributed by Glenn Randers-Pehrson
  <randeg@alum.rpi.edu>
  Copyright (c) 1998-2002 Glenn Randers-Pehrson
@@ -3062,18 +3062,16 @@
 in pngmem.c, pngrio.c, pngwio.c, and pngerror.c, respectively.  To change
 these functions, call the appropriate png_set_*_fn() function.
 
-Memory allocation is done through the functions png_malloc(), png_zalloc(),
+Memory allocation is done through the functions png_malloc()
 and png_free().  These currently just call the standard C functions.  If
 your pointers can't access more then 64K at a time, you will want to set
 MAXSEG_64K in zlib.h.  Since it is unlikely that the method of handling
 memory allocation on a platform will change between applications, these
 functions must be modified in the library at compile time.  If you prefer
 to use a different method of allocating and freeing data, you can use
-
-    png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr,
-       png_malloc_ptr malloc_fn, png_free_ptr free_fn)
-
-This function also provides a void pointer that can be retrieved via
+png_create_read_struct_2() or png_create_write_struct_2() to register
+your own functions as described above.
+These functions also provide a void pointer that can be retrieved via
 
     mem_ptr=png_get_mem_ptr(png_ptr);
 
@@ -3083,7 +3081,7 @@
        png_size_t size);
     void free_fn(png_structp png_ptr, png_voidp ptr);
 
-Your malloc_fn() can return NULL in case of failure.  The png_malloc()
+Your malloc_fn() should return NULL in case of failure.  The png_malloc()
 function will call png_error() if it receives a NULL from the system
 memory allocator or from your replacement malloc_fn().
 
@@ -3109,9 +3107,9 @@
 The replacement I/O functions must have prototypes as follows:
 
     void user_read_data(png_structp png_ptr,
-        png_bytep data, png_uint_32 length);
+        png_bytep data, png_size_t length);
     void user_write_data(png_structp png_ptr,
-        png_bytep data, png_uint_32 length);
+        png_bytep data, png_size_t length);
     void user_flush_data(png_structp png_ptr);
 
 Supplying NULL for the read, write, or flush functions sets them back
@@ -3492,13 +3490,13 @@
 
 .SH VII. Y2K Compliance in libpng
 
-April 15, 2002
+July 8, 2002
 
 Since the PNG Development group is an ad-hoc body, we can't make
 an official declaration.
 
 This is your unofficial assurance that libpng from version 0.71 and
-upward through 1.0.13 are Y2K compliant.  It is my belief that earlier
+upward through 1.0.14 are Y2K compliant.  It is my belief that earlier
 versions were also Y2K compliant.
 
 Libpng only has three year fields.  One is a 2-byte unsigned integer that
@@ -3623,10 +3621,16 @@
  1.2.1                3    10201  3.1.2.1
  1.2.2beta1-6        12    10202  12.so.0.1.2.2beta1-6
  1.0.13beta1         10    10013  10.so.0.1.0.13beta1
- 1.2.2rc1            12    10202  12.so.0.1.2.2rc1
  1.0.13rc1           10    10013  10.so.0.1.0.13rc1
+ 1.2.2rc1            12    10202  12.so.0.1.2.2rc1
+ 1.0.13              10    10013  10.so.0.1.0.13
  1.2.2               12    10202  12.so.0.1.2.2
- 1.0.13              10    10013  10.so.0.1.0.13rc1
+ 1.2.3rc1-6          12    10203  12.so.0.1.2.3rc1-6
+ 1.2.3               12    10203  12.so.0.1.2.3
+ 1.2.4beta1-3        13    10204  12.so.0.1.2.4beta1-3
+ 1.2.4rc1            13    10204  12.so.0.1.2.4rc1
+ 1.0.14              10    10014  10.so.0.1.0.14
+ 1.2.4               13    10204  12.so.0.1.2.4
 
 Henceforth the source version will match the shared-library minor
 and patch numbers; the shared-library major version number will be
@@ -3684,7 +3688,7 @@
 
 Thanks to Frank J. T. Wojcik for helping with the documentation.
 
-Libpng version 1.0.13 - April 15, 2002:
+Libpng version 1.0.14 - July 8, 2002:
 Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
 Currently maintained by Glenn Randers-Pehrson (randeg@alum.rpi.edu).
 
@@ -3701,7 +3705,7 @@
 If you modify libpng you may insert additional notices immediately following
 this sentence.
 
-libpng versions 1.0.7, July 1, 2000, through 1.0.13, April 15, 2002, are
+libpng versions 1.0.7, July 1, 2000, through 1.0.14, July 8, 2002, are
 Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
 distributed according to the same disclaimer and license as libpng-1.0.6
 with the following individuals added to the list of Contributing Authors
@@ -3793,7 +3797,7 @@
 
 Glenn Randers-Pehrson
 randeg@alum.rpi.edu
-April 15, 2002
+July 8, 2002
 
 .\" end of man page
 
diff --git a/libpng.txt b/libpng.txt
index 075f2bb..67ca249 100644
--- a/libpng.txt
+++ b/libpng.txt
@@ -1,6 +1,6 @@
 libpng.txt - A description on how to use and modify libpng
 
- libpng version 1.0.13 - April 15, 2002
+ libpng version 1.0.14 - July 8, 2002
  Updated and distributed by Glenn Randers-Pehrson
  <randeg@alum.rpi.edu>
  Copyright (c) 1998-2002 Glenn Randers-Pehrson
@@ -2301,18 +2301,16 @@
 in pngmem.c, pngrio.c, pngwio.c, and pngerror.c, respectively.  To change
 these functions, call the appropriate png_set_*_fn() function.
 
-Memory allocation is done through the functions png_malloc(), png_zalloc(),
+Memory allocation is done through the functions png_malloc()
 and png_free().  These currently just call the standard C functions.  If
 your pointers can't access more then 64K at a time, you will want to set
 MAXSEG_64K in zlib.h.  Since it is unlikely that the method of handling
 memory allocation on a platform will change between applications, these
 functions must be modified in the library at compile time.  If you prefer
 to use a different method of allocating and freeing data, you can use
-
-    png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr,
-       png_malloc_ptr malloc_fn, png_free_ptr free_fn)
-
-This function also provides a void pointer that can be retrieved via
+png_create_read_struct_2() or png_create_write_struct_2() to register
+your own functions as described above.
+These functions also provide a void pointer that can be retrieved via
 
     mem_ptr=png_get_mem_ptr(png_ptr);
 
@@ -2322,7 +2320,7 @@
        png_size_t size);
     void free_fn(png_structp png_ptr, png_voidp ptr);
 
-Your malloc_fn() can return NULL in case of failure.  The png_malloc()
+Your malloc_fn() should return NULL in case of failure.  The png_malloc()
 function will call png_error() if it receives a NULL from the system
 memory allocator or from your replacement malloc_fn().
 
@@ -2348,9 +2346,9 @@
 The replacement I/O functions must have prototypes as follows:
 
     void user_read_data(png_structp png_ptr,
-        png_bytep data, png_uint_32 length);
+        png_bytep data, png_size_t length);
     void user_write_data(png_structp png_ptr,
-        png_bytep data, png_uint_32 length);
+        png_bytep data, png_size_t length);
     void user_flush_data(png_structp png_ptr);
 
 Supplying NULL for the read, write, or flush functions sets them back
@@ -2731,13 +2729,13 @@
 
 VII. Y2K Compliance in libpng
 
-April 15, 2002
+July 8, 2002
 
 Since the PNG Development group is an ad-hoc body, we can't make
 an official declaration.
 
 This is your unofficial assurance that libpng from version 0.71 and
-upward through 1.0.13 are Y2K compliant.  It is my belief that earlier
+upward through 1.0.14 are Y2K compliant.  It is my belief that earlier
 versions were also Y2K compliant.
 
 Libpng only has three year fields.  One is a 2-byte unsigned integer that
diff --git a/libpngpf.3 b/libpngpf.3
index 3234eb9..3f56b29 100644
--- a/libpngpf.3
+++ b/libpngpf.3
@@ -1,6 +1,6 @@
-.TH LIBPNGPF 3 "April 15, 2002"
+.TH LIBPNGPF 3 "July 8, 2002"
 .SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.0.13
+libpng \- Portable Network Graphics (PNG) Reference Library 1.0.14
 (private functions)
 .SH SYNOPSIS
 \fB#include <png.h>\fP
diff --git a/png.5 b/png.5
index d61d281..c3c7e80 100644
--- a/png.5
+++ b/png.5
@@ -1,4 +1,4 @@
-.TH PNG 5 "April 15, 2002"
+.TH PNG 5 "July 8, 2002"
 .SH NAME
 png \- Portable Network Graphics (PNG) format
 .SH DESCRIPTION
diff --git a/png.c b/png.c
index 1d2aba1..3efcce9 100644
--- a/png.c
+++ b/png.c
@@ -1,7 +1,7 @@
 
 /* png.c - location for general purpose libpng functions
  *
- * libpng version 1.0.13 - April 15, 2002
+ * libpng version 1.0.14 - July 8, 2002
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -13,14 +13,14 @@
 #include "png.h"
 
 /* Generate a compiler error if there is an old png.h in the search path. */
-typedef version_1_0_13 Your_png_h_is_not_version_1_0_13;
+typedef version_1_0_14 Your_png_h_is_not_version_1_0_14;
 
 /* Version information for C files.  This had better match the version
  * string defined in png.h.  */
 
 #ifdef PNG_USE_GLOBAL_ARRAYS
 /* png_libpng_ver was changed to a function in version 1.0.5c */
-const char png_libpng_ver[18] = "1.0.13";
+const char png_libpng_ver[18] = "1.0.14";
 
 /* png_sig was changed to a function in version 1.0.5c */
 /* Place to hold the signature string for a PNG file. */
@@ -135,7 +135,11 @@
 }
 
 /* Function to allocate memory for zlib and clear it to 0. */
+#ifdef PNG_1_0_X
 voidpf PNGAPI
+#else
+voidpf /* private */
+#endif
 png_zalloc(voidpf png_ptr, uInt items, uInt size)
 {
    png_uint_32 num_bytes = (png_uint_32)items * size;
@@ -166,7 +170,11 @@
 }
 
 /* function to free memory for zlib */
+#ifdef PNG_1_0_X
 void PNGAPI
+#else
+void /* private */
+#endif
 png_zfree(voidpf png_ptr, voidpf ptr)
 {
    png_free((png_structp)png_ptr, (png_voidp)ptr);
@@ -663,7 +671,7 @@
 png_get_copyright(png_structp png_ptr)
 {
    if (png_ptr != NULL || png_ptr == NULL)  /* silence compiler warning */
-   return ((png_charp) "\n libpng version 1.0.13 - April 15, 2002\n\
+   return ((png_charp) "\n libpng version 1.0.14 - July 8, 2002\n\
    Copyright (c) 1998-2002 Glenn Randers-Pehrson\n\
    Copyright (c) 1996-1997 Andreas Dilger\n\
    Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n");
@@ -681,8 +689,8 @@
 {
    /* Version of *.c files used when building libpng */
    if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */
-      return((png_charp) "1.0.13");
-   return((png_charp) "1.0.13");
+      return((png_charp) "1.0.14");
+   return((png_charp) "1.0.14");
 }
 
 png_charp PNGAPI
@@ -732,7 +740,7 @@
 png_access_version_number(void)
 {
    /* Version of *.c files used when building libpng */
-   return((png_uint_32) 10013L);
+   return((png_uint_32) 10014L);
 }
 
 
diff --git a/png.h b/png.h
index 8c6d6c8..d60a4dd 100644
--- a/png.h
+++ b/png.h
@@ -1,7 +1,6 @@
-
 /* png.h - header file for PNG reference library
  *
- * libpng version 1.0.13 - April 15, 2002
+ * libpng version 1.0.14 - July 8, 2002
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -9,7 +8,7 @@
  * Authors and maintainers:
  *  libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
  *  libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
- *  libpng versions 0.97, January 1998, through 1.0.13 - April 15, 2002: Glenn
+ *  libpng versions 0.97, January 1998, through 1.0.14 - July 8, 2002: Glenn
  *  See also "Contributing Authors", below.
  *
  * Note about libpng version numbers:
@@ -83,10 +82,17 @@
  *    1.2.1                    3    10201  3.1.2.1
  *    1.2.2beta1-6            12    10202  12.so.0.1.2.2beta1-6
  *    1.0.13beta1             10    10013  10.so.0.1.0.13beta1
- *    1.2.2rc1                12    10202  12.so.0.1.2.2rc1
  *    1.0.13rc1               10    10013  10.so.0.1.0.13rc1
- *    1.2.2                   12    10202  12.so.0.1.2.2
+ *    1.2.2rc1                12    10202  12.so.0.1.2.2rc1
  *    1.0.13                  10    10013  10.so.0.1.0.13
+ *    1.2.2                   12    10202  12.so.0.1.2.2
+ *    1.2.3rc1-6              12    10203  12.so.0.1.2.3rc1-6
+ *    1.2.3                   12    10203  12.so.0.1.2.3
+ *    1.2.4beta1-3            13    10204  12.so.0.1.2.4beta1-3
+ *    1.0.14rc1               13    10014  10.so.0.1.0.14rc1
+ *    1.2.4rc1                13    10204  12.so.0.1.2.4rc1
+ *    1.0.14                  10    10014  10.so.0.1.0.14
+ *    1.2.4                   13    10204  12.so.0.1.2.4
  *
  *    Henceforth the source version will match the shared-library major
  *    and minor numbers; the shared-library major version number will be
@@ -116,8 +122,8 @@
  * If you modify libpng you may insert additional notices immediately following
  * this sentence.
  *
- * libpng versions 1.0.7, July 1, 2000, through 1.0.13, April 15, 2002, are
- * Copyright (c) 2000-2001 Glenn Randers-Pehrson, and are
+ * libpng versions 1.0.7, July 1, 2000, through 1.0.14, July 8, 2002, are
+ * Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
  * distributed according to the same disclaimer and license as libpng-1.0.6
  * with the following individuals added to the list of Contributing Authors
  *
@@ -221,13 +227,13 @@
  * Y2K compliance in libpng:
  * =========================
  *
- *    April 15, 2002
+ *    July 8, 2002
  *
  *    Since the PNG Development group is an ad-hoc body, we can't make
  *    an official declaration.
  *
  *    This is your unofficial assurance that libpng from version 0.71 and
- *    upward through 1.0.13 are Y2K compliant.  It is my belief that earlier
+ *    upward through 1.0.14 are Y2K compliant.  It is my belief that earlier
  *    versions were also Y2K compliant.
  *
  *    Libpng only has three year fields.  One is a 2-byte unsigned integer
@@ -283,7 +289,7 @@
  */
 
 /* Version information for png.h - this should match the version in png.c */
-#define PNG_LIBPNG_VER_STRING "1.0.13"
+#define PNG_LIBPNG_VER_STRING "1.0.14"
 
 #define PNG_LIBPNG_VER_SONUM   0
 #define PNG_LIBPNG_VER_DLLNUM  %DLLNUM%
@@ -291,7 +297,7 @@
 /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
 #define PNG_LIBPNG_VER_MAJOR   1
 #define PNG_LIBPNG_VER_MINOR   0
-#define PNG_LIBPNG_VER_RELEASE 13
+#define PNG_LIBPNG_VER_RELEASE 14
 /* This should match the numeric part of the final component of
  * PNG_LIBPNG_VER_STRING, omitting any leading zero: */
 
@@ -310,7 +316,7 @@
  * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
  * version 1.0.0 was mis-numbered 100 instead of 10000).  From
  * version 1.0.1 it's    xxyyzz, where x=major, y=minor, z=release */
-#define PNG_LIBPNG_VER 10013 /* 1.0.13 */
+#define PNG_LIBPNG_VER 10014 /* 1.0.14 */
 
 #ifndef PNG_VERSION_INFO_ONLY
 
@@ -372,7 +378,7 @@
  */
 #ifdef PNG_USE_GLOBAL_ARRAYS
 PNG_EXPORT_VAR (const char) png_libpng_ver[18];
-  /* need room for 99.99.99beta99z*/
+  /* need room for 99.99.99beta99z */
 #else
 #define png_libpng_ver png_get_header_ver(NULL)
 #endif
@@ -598,7 +604,7 @@
    png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
 
    /* The following is informational only on read, and not used on writes. */
-   png_byte channels;       /* number of data channels per pixel (1, 2, 3, 4)*/
+   png_byte channels;       /* number of data channels per pixel (1, 2, 3, 4) */
    png_byte pixel_depth;    /* number of bits per pixel */
    png_byte spare_byte;     /* to align the data, and for future use */
    png_byte signature[8];   /* magic bytes read by libpng from start of file */
@@ -888,7 +894,7 @@
 #define PNG_KEYWORD_MAX_LENGTH     79
 
 /* Maximum number of entries in PLTE/sPLT/tRNS arrays */
-#define PNG_MAX_PALETTE_LENGTH	   256
+#define PNG_MAX_PALETTE_LENGTH    256
 
 /* These determine if an ancillary chunk's data has been successfully read
  * from the PNG header, or if the application has filled in the corresponding
@@ -1007,7 +1013,7 @@
    png_voidp error_ptr;       /* user supplied struct for error functions */
    png_rw_ptr write_data_fn;  /* function for writing output data */
    png_rw_ptr read_data_fn;   /* function for reading input data */
-   png_voidp io_ptr;          /* ptr to application struct for I/O functions*/
+   png_voidp io_ptr;          /* ptr to application struct for I/O functions */
 
 #if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
    png_user_transform_ptr read_user_transform_fn; /* user read transform */
@@ -1257,15 +1263,25 @@
    png_free_ptr free_fn;             /* function for freeing memory */
 #endif
 
+/* New member added in libpng-1.0.13 and 1.2.0 */
    png_bytep big_row_buf;         /* buffer to save current (unfiltered) row */
 
+#if defined(PNG_READ_DITHER_SUPPORTED)
+/* The following three members were added at version 1.0.14 and 1.2.4 */
+   png_bytep dither_sort;            /* working sort array */
+   png_bytep index_to_palette;       /* where the original index currently is */
+                                     /* in the palette */
+   png_bytep palette_to_index;       /* which original index points to this */
+                                     /* palette color */
+#endif
+
 };
 
 
 /* This prevents a compiler error in png.c if png.c and png.h are both at
-   version 1.0.13
+   version 1.0.14
  */
-typedef png_structp version_1_0_13;
+typedef png_structp version_1_0_14;
 
 typedef png_struct FAR * FAR * png_structpp;
 
@@ -1349,6 +1365,7 @@
 
 /* Initialize the info structure (old interface - DEPRECATED) */
 extern PNG_EXPORT(void,png_info_init) PNGARG((png_infop info_ptr));
+#undef png_info_init
 #define png_info_init(info_ptr) png_info_init_3(&info_ptr, sizeof(png_info));
 extern PNG_EXPORT(void,png_info_init_3) PNGARG((png_infopp info_ptr,
     png_size_t png_info_struct_size));
@@ -1524,11 +1541,11 @@
 extern PNG_EXPORT(void,png_read_update_info) PNGARG((png_structp png_ptr,
    png_infop info_ptr));
 
-/* read a one or more rows of image data.*/
+/* read one or more rows of image data. */
 extern PNG_EXPORT(void,png_read_rows) PNGARG((png_structp png_ptr,
    png_bytepp row, png_bytepp display_row, png_uint_32 num_rows));
 
-/* read a row of data.*/
+/* read a row of data. */
 extern PNG_EXPORT(void,png_read_row) PNGARG((png_structp png_ptr,
    png_bytep row,
    png_bytep display_row));
@@ -1814,15 +1831,25 @@
 extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr,
    png_uint_32 size));
 
+#if defined(PNG_1_0_X)
+#  define png_malloc_warn png_malloc
+#else
+/* Added at libpng version 1.2.4 */
+extern PNG_EXPORT(png_voidp,png_malloc_warn) PNGARG((png_structp png_ptr,
+   png_uint_32 size));
+#endif
+
 /* frees a pointer allocated by png_malloc() */
 extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr));
 
+#if defined(PNG_1_0_X)
 /* Function to allocate memory for zlib. */
 extern PNG_EXPORT(voidpf,png_zalloc) PNGARG((voidpf png_ptr, uInt items,
    uInt size));
 
 /* Function to free memory for zlib */
 extern PNG_EXPORT(void,png_zfree) PNGARG((voidpf png_ptr, voidpf ptr));
+#endif
 
 /* Free data that was allocated internally */
 extern PNG_EXPORT(void,png_free_data) PNGARG((png_structp png_ptr,
@@ -1872,19 +1899,19 @@
 
 /* Fatal error in PNG image of libpng - can't continue */
 extern PNG_EXPORT(void,png_error) PNGARG((png_structp png_ptr,
-   png_const_charp error));
+   png_const_charp error_message));
 
 /* The same, but the chunk name is prepended to the error string. */
 extern PNG_EXPORT(void,png_chunk_error) PNGARG((png_structp png_ptr,
-   png_const_charp error));
+   png_const_charp error_message));
 
 /* Non-fatal error in libpng.  Can continue, but may have a problem. */
 extern PNG_EXPORT(void,png_warning) PNGARG((png_structp png_ptr,
-   png_const_charp message));
+   png_const_charp warning_message));
 
 /* Non-fatal error in libpng, chunk name is prepended to message. */
 extern PNG_EXPORT(void,png_chunk_warning) PNGARG((png_structp png_ptr,
-   png_const_charp message));
+   png_const_charp warning_message));
 
 /* The png_set_<chunk> functions are for storing values in the png_info_struct.
  * Similarly, the png_get_<chunk> calls are used to read values from the
@@ -2319,15 +2346,15 @@
 
 /* Added to version 1.2.0 */
 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
-#define PNG_ASM_FLAG_MMX_SUPPORT_COMPILED  0x01		/* not user-settable */
-#define PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU    0x02		/* not user-settable */
+#define PNG_ASM_FLAG_MMX_SUPPORT_COMPILED  0x01  /* not user-settable */
+#define PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU    0x02  /* not user-settable */
 #define PNG_ASM_FLAG_MMX_READ_COMBINE_ROW  0x04
 #define PNG_ASM_FLAG_MMX_READ_INTERLACE    0x08
 #define PNG_ASM_FLAG_MMX_READ_FILTER_SUB   0x10
 #define PNG_ASM_FLAG_MMX_READ_FILTER_UP    0x20
 #define PNG_ASM_FLAG_MMX_READ_FILTER_AVG   0x40
 #define PNG_ASM_FLAG_MMX_READ_FILTER_PAETH 0x80
-#define PNG_ASM_FLAGS_INITIALIZED          0x80000000	/* not user-settable */
+#define PNG_ASM_FLAGS_INITIALIZED          0x80000000  /* not user-settable */
 
 #define PNG_MMX_READ_FLAGS ( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW  \
                            | PNG_ASM_FLAG_MMX_READ_INTERLACE    \
@@ -2394,7 +2421,7 @@
 /* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */
 
 #define PNG_HEADER_VERSION_STRING \
-   " libpng version 1.0.13 - April 15, 2002 (header)\n"
+   " libpng version 1.0.14 - July 8, 2002 (header)\n"
 
 #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
 /* With these routines we avoid an integer divide, which will be slower on
@@ -2628,6 +2655,7 @@
  * (old interface - DEPRECATED - use png_create_read_struct instead).
  */
 extern PNG_EXPORT(void,png_read_init) PNGARG((png_structp png_ptr));
+#undef png_read_init
 #define png_read_init(png_ptr) png_read_init_3(&png_ptr, \
     PNG_LIBPNG_VER_STRING,  sizeof(png_struct));
 extern PNG_EXPORT(void,png_read_init_3) PNGARG((png_structpp ptr_ptr,
@@ -2640,6 +2668,7 @@
  * (old interface - DEPRECATED - use png_create_write_struct instead).
  */
 extern PNG_EXPORT(void,png_write_init) PNGARG((png_structp png_ptr));
+#undef png_write_init
 #define png_write_init(png_ptr) png_write_init_3(&png_ptr, \
     PNG_LIBPNG_VER_STRING, sizeof(png_struct));
 extern PNG_EXPORT(void,png_write_init_3) PNGARG((png_structpp ptr_ptr,
@@ -2663,6 +2692,39 @@
 PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr,
    png_infop info_ptr));
 
+#ifndef PNG_1_0_X
+/* Function to allocate memory for zlib. */
+PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items, uInt size));
+
+/* Function to free memory for zlib */
+PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr));
+
+/* Next four functions are used internally as callbacks.  PNGAPI is required
+ * but not PNG_EXPORT.  PNGAPI added at libpng version 1.2.3. */
+
+PNG_EXTERN void PNGAPI png_default_read_data PNGARG((png_structp png_ptr,
+   png_bytep data, png_size_t length));
+
+#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
+PNG_EXTERN void PNGAPI png_push_fill_buffer PNGARG((png_structp png_ptr,
+   png_bytep buffer, png_size_t length));
+#endif
+
+PNG_EXTERN void PNGAPI png_default_write_data PNGARG((png_structp png_ptr,
+   png_bytep data, png_size_t length));
+
+#if defined(PNG_WRITE_FLUSH_SUPPORTED)
+#if !defined(PNG_NO_STDIO)
+PNG_EXTERN void PNGAPI png_default_flush PNGARG((png_structp png_ptr));
+#endif
+#endif
+#else /* PNG_1_0_X */
+#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
+PNG_EXTERN void png_push_fill_buffer PNGARG((png_structp png_ptr,
+   png_bytep buffer, png_size_t length));
+#endif
+#endif /* PNG_1_0_X */
+
 /* Reset the CRC variable */
 PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr));
 
@@ -2703,6 +2765,7 @@
 PNG_EXTERN void png_flush PNGARG((png_structp png_ptr));
 #endif
 
+
 /* Place a 32-bit number into a buffer in PNG byte order (big-endian).
  * The only currently known PNG chunks that use signed numbers are
  * the ancillary extension chunks, oFFs and pCAL.
@@ -2825,6 +2888,11 @@
    png_charp text));
 #endif
 
+#if defined(PNG_TEXT_SUPPORTED)  /* Added at version 1.0.14 and 1.2.4 */
+PNG_EXTERN int png_set_text_2 PNGARG((png_structp png_ptr,
+   png_infop info_ptr, png_textp text_ptr, int num_text));
+#endif
+
 #if defined(PNG_WRITE_oFFs_SUPPORTED)
 PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr,
    png_int_32 x_offset, png_int_32 y_offset, int unit_type));
@@ -3146,8 +3214,6 @@
 PNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr,
    png_uint_32 length));
 PNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr));
-PNG_EXTERN void png_push_fill_buffer PNGARG((png_structp png_ptr,
-   png_bytep buffer, png_size_t length));
 PNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr));
 PNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr,
    png_bytep buffer, png_size_t buffer_length));
diff --git a/pngasmrd.h b/pngasmrd.h
index 715e4ca..badf894 100644
--- a/pngasmrd.h
+++ b/pngasmrd.h
@@ -1,6 +1,6 @@
 /* pngasmrd.h - assembler version of utilities to read a PNG file
  *
- * libpng 1.0.13 - April 15, 2002
+ * libpng 1.0.14 - July 8, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 2002 Glenn Randers-Pehrson
  *
diff --git a/pngconf.h b/pngconf.h
index 88e86a9..6fa77c4 100644
--- a/pngconf.h
+++ b/pngconf.h
@@ -1,6 +1,6 @@
 /* pngconf.h - machine configurable file for libpng
  *
- * libpng 1.0.13 - April 15, 2002
+ * libpng 1.0.14 - July 8, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -80,12 +80,12 @@
  *   (no define)   -- building static library, or building an
  *                    application and linking to the static lib
  * 'Cygwin' defines/defaults:
- *   PNG_BUILD_DLL -- building the dll
- *   (no define)   -- building an application, linking to the dll
- *   PNG_STATIC    -- building the static lib, or building an application
- *                    that links to the static lib.
- *   ALL_STATIC    -- building various static libs, or building an application
- *                    that links to the static libs.
+ *   PNG_BUILD_DLL -- (ignored) building the dll
+ *   (no define)   -- (ignored) building an application, linking to the dll
+ *   PNG_STATIC    -- (ignored) building the static lib, or building an 
+ *                    application that links to the static lib.
+ *   ALL_STATIC    -- (ignored) building various static libs, or building an 
+ *                    application that links to the static libs.
  * Thus,
  * a cygwin user should define either PNG_BUILD_DLL or PNG_STATIC, and
  * this bit of #ifdefs will define the 'correct' config variables based on
@@ -96,7 +96,15 @@
  *   ALL_STATIC (since we can't #undef something outside our namespace)
  *   PNG_BUILD_DLL
  *   PNG_STATIC
- *   (nothing) == PNG_USE_DLL 
+ *   (nothing) == PNG_USE_DLL
+ * 
+ * CYGWIN (2002-01-20): The preceding is now obsolete. With the advent
+ *   of auto-import in binutils, we no longer need to worry about 
+ *   __declspec(dllexport) / __declspec(dllimport) and friends.  Therefore,
+ *   we don't need to worry about PNG_STATIC or ALL_STATIC when it comes
+ *   to __declspec() stuff.  However, we DO need to worry about 
+ *   PNG_BUILD_DLL and PNG_STATIC because those change some defaults
+ *   such as CONSOLE_IO and whether GLOBAL_ARRAYS are allowed.
  */
 #if defined(__CYGWIN__)
 #  if defined(ALL_STATIC)
@@ -1151,10 +1159,23 @@
 #  endif
 #endif
 
+#if defined(__CYGWIN__)
+#  undef PNGAPI
+#  define PNGAPI __cdecl
+#  undef PNG_IMPEXP
+#  define PNG_IMPEXP
+#endif  
+
+/* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall",
+ * you may get warnings regarding the linkage of png_zalloc and png_zfree.
+ * Don't ignore those warnings; you must also reset the default calling
+ * convention in your compiler to match your PNGAPI, and you must build
+ * zlib and your applications the same way you build libpng.
+ */
 
 #ifndef PNGAPI
 
-#if defined(__MINGW32__) || defined(__CYGWIN__) && !defined(PNG_MODULEDEF)
+#if defined(__MINGW32__) && !defined(PNG_MODULEDEF)
 #  ifndef PNG_NO_MODULEDEF
 #    define PNG_NO_MODULEDEF
 #  endif
@@ -1166,8 +1187,7 @@
 
 #if defined(PNG_DLL) || defined(_DLL) || defined(__DLL__ ) || \
     (( defined(_Windows) || defined(_WINDOWS) || \
-       defined(WIN32) || defined(_WIN32) || defined(__WIN32__) \
-	  ) && !defined(__CYGWIN__))
+       defined(WIN32) || defined(_WIN32) || defined(__WIN32__) ))
 
 #  if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800))
 #    define PNGAPI __cdecl
@@ -1194,8 +1214,8 @@
 #           if defined(PNG_BUILD_DLL)
 #              define PNG_IMPEXP __export
 #           else
-#              define PNG_IMPEXP /*__import*/ /* doesn't exist AFAIK in
-                                                 VC++*/
+#              define PNG_IMPEXP /*__import */ /* doesn't exist AFAIK in
+                                                 VC++ */
 #           endif                             /* Exists in Borland C++ for
                                                  C++ classes (== huge) */
 #        endif
@@ -1210,12 +1230,6 @@
 #     endif
 #  endif  /* PNG_IMPEXP */
 #else /* !(DLL || non-cygwin WINDOWS) */
-#  if defined(__CYGWIN__) && !defined(PNG_DLL)
-#    if !defined(PNG_IMPEXP)
-#      define PNG_IMPEXP
-#    endif
-#    define PNGAPI __cdecl
-#  else
 #    if (defined(__IBMC__) || defined(IBMCPP__)) && defined(__OS2__)
 #      define PNGAPI _System
 #      define PNG_IMPEXP
@@ -1226,7 +1240,6 @@
 #        define PNG_IMPEXP
 #      endif
 #    endif
-#  endif
 #endif
 #endif
 
diff --git a/pngerror.c b/pngerror.c
index 16837f7..db88ec3 100644
--- a/pngerror.c
+++ b/pngerror.c
@@ -1,7 +1,7 @@
 
 /* pngerror.c - stub functions for i/o and memory allocation
  *
- * libpng 1.0.13 - April 15, 2002
+ * libpng 1.0.14 - July 8, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -18,10 +18,10 @@
 
 static void /* PRIVATE */
 png_default_error PNGARG((png_structp png_ptr,
-                                      png_const_charp message));
+  png_const_charp error_message));
 static void /* PRIVATE */
 png_default_warning PNGARG((png_structp png_ptr,
-                                        png_const_charp message));
+  png_const_charp warning_message));
 
 /* This function is called whenever there is a fatal error.  This function
  * should not be changed.  If there is a need to handle errors differently,
@@ -29,28 +29,28 @@
  * to replace the error function at run-time.
  */
 void PNGAPI
-png_error(png_structp png_ptr, png_const_charp message)
+png_error(png_structp png_ptr, png_const_charp error_message)
 {
 #ifdef PNG_ERROR_NUMBERS_SUPPORTED
    char msg[16];
    if (png_ptr->flags&(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
    {
      int offset = 0;
-     if (*message == '#')
+     if (*error_message == '#')
      {
          for (offset=1; offset<15; offset++)
-            if (*(message+offset) == ' ')
+            if (*(error_message+offset) == ' ')
                 break;
          if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
          {
             int i;
             for (i=0; i<offset-1; i++)
-               msg[i]=message[i+1];
+               msg[i]=error_message[i+1];
             msg[i]='\0';
-            message=msg;
+            error_message=msg;
          }
          else
-            message+=offset;
+            error_message+=offset;
      }
      else
      {
@@ -58,17 +58,17 @@
          {
             msg[0]='0';        
             msg[1]='\0';
-            message=msg;
+            error_message=msg;
          }
      }
    }
 #endif
    if (png_ptr->error_fn != NULL)
-      (*(png_ptr->error_fn))(png_ptr, message);
+      (*(png_ptr->error_fn))(png_ptr, error_message);
 
    /* if the following returns or doesn't exist, use the default function,
       which will not return */
-   png_default_error(png_ptr, message);
+   png_default_error(png_ptr, error_message);
 }
 
 /* This function is called whenever there is a non-fatal error.  This function
@@ -77,24 +77,25 @@
  * png_set_error_fn() to replace the warning function at run-time.
  */
 void PNGAPI
-png_warning(png_structp png_ptr, png_const_charp message)
+png_warning(png_structp png_ptr, png_const_charp warning_message)
 {
      int offset = 0;
 #ifdef PNG_ERROR_NUMBERS_SUPPORTED
    if (png_ptr->flags&(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
 #endif
    {
-     if (*message == '#')
+     if (*warning_message == '#')
      {
          for (offset=1; offset<15; offset++)
-            if (*(message+offset) == ' ')
+            if (*(warning_message+offset) == ' ')
                 break;
      }
    }
    if (png_ptr->warning_fn != NULL)
-      (*(png_ptr->warning_fn))(png_ptr, (png_const_charp)(message+offset));
+      (*(png_ptr->warning_fn))(png_ptr,
+         (png_const_charp)(warning_message+offset));
    else
-      png_default_warning(png_ptr, (png_const_charp)(message+offset));
+      png_default_warning(png_ptr, (png_const_charp)(warning_message+offset));
 }
 
 /* These utilities are used internally to build an error message that relates
@@ -110,7 +111,7 @@
 
 static void /* PRIVATE */
 png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
-   message)
+   error_message)
 {
    int iout = 0, iin = 0;
 
@@ -130,30 +131,30 @@
       }
    }
 
-   if (message == NULL)
+   if (error_message == NULL)
       buffer[iout] = 0;
    else
    {
       buffer[iout++] = ':';
       buffer[iout++] = ' ';
-      png_memcpy(buffer+iout, message, 64);
+      png_memcpy(buffer+iout, error_message, 64);
       buffer[iout+63] = 0;
    }
 }
 
 void PNGAPI
-png_chunk_error(png_structp png_ptr, png_const_charp message)
+png_chunk_error(png_structp png_ptr, png_const_charp error_message)
 {
    char msg[18+64];
-   png_format_buffer(png_ptr, msg, message);
+   png_format_buffer(png_ptr, msg, error_message);
    png_error(png_ptr, msg);
 }
 
 void PNGAPI
-png_chunk_warning(png_structp png_ptr, png_const_charp message)
+png_chunk_warning(png_structp png_ptr, png_const_charp warning_message)
 {
    char msg[18+64];
-   png_format_buffer(png_ptr, msg, message);
+   png_format_buffer(png_ptr, msg, warning_message);
    png_warning(png_ptr, msg);
 }
 
@@ -163,33 +164,34 @@
  * error function pointer in png_set_error_fn().
  */
 static void /* PRIVATE */
-png_default_error(png_structp png_ptr, png_const_charp message)
+png_default_error(png_structp png_ptr, png_const_charp error_message)
 {
 #ifndef PNG_NO_CONSOLE_IO
 #ifdef PNG_ERROR_NUMBERS_SUPPORTED
-   if (*message == '#')
+   if (*error_message == '#')
    {
      int offset;
      char error_number[16];
      for (offset=0; offset<15; offset++)
      {
-         error_number[offset] = *(message+offset+1);
-         if (*(message+offset) == ' ')
+         error_number[offset] = *(error_message+offset+1);
+         if (*(error_message+offset) == ' ')
              break;
      }
      if((offset > 1) && (offset < 15))
      {
        error_number[offset-1]='\0';
-       fprintf(stderr, "libpng error no. %s: %s\n", error_number, message+offset);
+       fprintf(stderr, "libpng error no. %s: %s\n", error_number,
+          error_message+offset);
      }
      else
-       fprintf(stderr, "libpng error: %s, offset=%d\n", message,offset);
+       fprintf(stderr, "libpng error: %s, offset=%d\n", error_message,offset);
    }
    else
 #endif
-   fprintf(stderr, "libpng error: %s\n", message);
+   fprintf(stderr, "libpng error: %s\n", error_message);
 #else
-   if (message)
+   if (error_message)
      /* make compiler happy */ ;
 #endif
 
@@ -216,34 +218,34 @@
  * not used, but it is passed in case it may be useful.
  */
 static void /* PRIVATE */
-png_default_warning(png_structp png_ptr, png_const_charp message)
+png_default_warning(png_structp png_ptr, png_const_charp warning_message)
 {
 #ifndef PNG_NO_CONSOLE_IO
 #  ifdef PNG_ERROR_NUMBERS_SUPPORTED
-   if (*message == '#')
+   if (*warning_message == '#')
    {
      int offset;
      char warning_number[16];
      for (offset=0; offset<15; offset++)
      {
-        warning_number[offset]=*(message+offset+1);
-        if (*(message+offset) == ' ')
+        warning_number[offset]=*(warning_message+offset+1);
+        if (*(warning_message+offset) == ' ')
             break;
      }
      if((offset > 1) && (offset < 15))
      {
        warning_number[offset-1]='\0';
        fprintf(stderr, "libpng warning no. %s: %s\n", warning_number,
-          message+offset);
+          warning_message+offset);
      }
      else
-       fprintf(stderr, "libpng warning: %s\n", message);
+       fprintf(stderr, "libpng warning: %s\n", warning_message);
    }
    else
 #  endif
-     fprintf(stderr, "libpng warning: %s\n", message);
+     fprintf(stderr, "libpng warning: %s\n", warning_message);
 #else
-   if (message)
+   if (warning_message)
      /* appease compiler */ ;
 #endif
    if (png_ptr)
diff --git a/pnggccrd.c b/pnggccrd.c
index b0e2312..2887823 100644
--- a/pnggccrd.c
+++ b/pnggccrd.c
@@ -6,7 +6,7 @@
  *     and http://www.intel.com/drg/pentiumII/appnotes/923/923.htm
  *     for Intel's performance analysis of the MMX vs. non-MMX code.
  *
- * libpng version 1.0.13 - April 15, 2002
+ * libpng version 1.0.14 - July 8, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * Copyright (c) 1998, Intel Corporation
@@ -338,7 +338,7 @@
 static png_uint_32  _FullLength;
 static png_uint_32  _MMXLength;
 static int          _dif;
-static int          _patemp;	// temp variables for Paeth routine
+static int          _patemp; // temp variables for Paeth routine
 static int          _pbtemp;
 static int          _pctemp;
 #endif
@@ -386,9 +386,9 @@
 #if defined(PNG_HAVE_ASSEMBLER_COMBINE_ROW)
 
 #define BPP2  2
-#define BPP3  3		/* bytes per pixel (a.k.a. pixel_bytes) */
+#define BPP3  3 /* bytes per pixel (a.k.a. pixel_bytes) */
 #define BPP4  4
-#define BPP6  6		/* (defined only to help avoid cut-and-paste errors) */
+#define BPP6  6 /* (defined only to help avoid cut-and-paste errors) */
 #define BPP8  8
 
 /* Combines the row recently read in with the previous row.
@@ -1504,8 +1504,10 @@
 
 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
    if (_mmx_supported == 2) {
+#if !defined(PNG_1_0_X)
        /* this should have happened in png_init_mmx_flags() already */
        png_warning(png_ptr, "asm_flags may not have been initialized");
+#endif
        png_mmx_support();
    }
 #endif
@@ -4825,7 +4827,7 @@
       }
       break;
 
-      default:                // bpp greater than 8 bytes	GRR BOGUS
+      default:                // bpp greater than 8 bytes   GRR BOGUS
       {
          __asm__ __volatile__ (
             "movl _dif, %%edx             \n\t"
@@ -5135,11 +5137,11 @@
 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK)
 #if !defined(PNG_1_0_X)
          if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB) &&
-#else
-         if (
-#endif
              (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) &&
              (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold))
+#else
+         if (_mmx_supported)
+#endif
          {
             png_read_filter_row_mmx_sub(row_info, row);
          }
@@ -5164,11 +5166,11 @@
 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
 #if !defined(PNG_1_0_X)
          if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP) &&
-#else
-         if (
-#endif
              (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) &&
              (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold))
+#else
+         if (_mmx_supported)
+#endif
          {
             png_read_filter_row_mmx_up(row_info, row, prev_row);
          }
@@ -5192,11 +5194,11 @@
 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK)
 #if !defined(PNG_1_0_X)
          if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG) &&
-#else
-         if (
-#endif
              (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) &&
              (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold))
+#else
+         if (_mmx_supported)
+#endif
          {
             png_read_filter_row_mmx_avg(row_info, row, prev_row);
          }
@@ -5230,11 +5232,11 @@
 #if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && defined(PNG_THREAD_UNSAFE_OK)
 #if !defined(PNG_1_0_X)
          if ((png_ptr->asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH) &&
-#else
-         if (
-#endif
              (row_info->pixel_depth >= png_ptr->mmx_bitdepth_threshold) &&
              (row_info->rowbytes >= png_ptr->mmx_rowbytes_threshold))
+#else
+         if (_mmx_supported)
+#endif
          {
             png_read_filter_row_mmx_paeth(row_info, row, prev_row);
          }
diff --git a/pngget.c b/pngget.c
index 0b75c35..dd7038f 100644
--- a/pngget.c
+++ b/pngget.c
@@ -1,7 +1,7 @@
 
 /* pngget.c - retrieval of values from info struct
  *
- * libpng 1.0.13 - April 15, 2002
+ * libpng 1.0.14 - July 8, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -560,7 +560,9 @@
          *interlace_type = info_ptr->interlace_type;
 
       /* check for potential overflow of rowbytes */
-      if (*color_type & PNG_COLOR_MASK_COLOR)
+      if (*color_type == PNG_COLOR_TYPE_PALETTE)
+         channels = 1;
+      else if (*color_type & PNG_COLOR_MASK_COLOR)
          channels = 3;
       else
          channels = 1;
@@ -572,9 +574,9 @@
         png_error(png_ptr, "Invalid image width");
       if (height == 0 || *height > PNG_MAX_UINT)
         png_error(png_ptr, "Invalid image height");
-      if ((*width > PNG_MAX_UINT/rowbytes_per_pixel))
+      if (*width > PNG_MAX_UINT/rowbytes_per_pixel - 64)
       {
-         png_warning(png_ptr,
+         png_error(png_ptr,
             "Width too large for libpng to process image data.");
       }
       return (1);
@@ -835,7 +837,7 @@
 
 #ifndef PNG_1_0_X
 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED
-/* this function was added to libpng 1.2.0 and should exist by default*/
+/* this function was added to libpng 1.2.0 and should exist by default */
 png_uint_32 PNGAPI
 png_get_asm_flags (png_structp png_ptr)
 {
diff --git a/pngmem.c b/pngmem.c
index 6e46c0c..78f806a 100644
--- a/pngmem.c
+++ b/pngmem.c
@@ -1,7 +1,7 @@
 
 /* pngmem.c - stub functions for memory allocation
  *
- * libpng 1.0.13 - April 15, 2002
+ * libpng 1.0.14 - July 8, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -110,12 +110,12 @@
  * result, we would be truncating potentially larger memory requests
  * (which should cause a fatal error) and introducing major problems.
  */
+
 png_voidp PNGAPI
 png_malloc(png_structp png_ptr, png_uint_32 size)
 {
-#ifndef PNG_USER_MEM_SUPPORTED
    png_voidp ret;
-#endif
+
    if (png_ptr == NULL || size == 0)
       return (NULL);
 
@@ -306,7 +306,7 @@
 
 /* Allocate memory for a png_struct or a png_info.  The malloc and
    memset can be replaced by a single call to calloc() if this is thought
-   to improve performance noticably.*/
+   to improve performance noticably. */
 png_voidp /* PRIVATE */
 png_create_struct(int type)
 {
@@ -316,7 +316,7 @@
 
 /* Allocate memory for a png_struct or a png_info.  The malloc and
    memset can be replaced by a single call to calloc() if this is thought
-   to improve performance noticably.*/
+   to improve performance noticably. */
 png_voidp /* PRIVATE */
 png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)
 {
@@ -399,7 +399,6 @@
    }
 }
 
-
 /* Allocate memory.  For reasonable files, size should never exceed
    64K.  However, zlib may allocate more then 64K if you don't tell
    it not to.  See zconf.h and png.h for more information.  zlib does
@@ -410,13 +409,14 @@
 png_malloc(png_structp png_ptr, png_uint_32 size)
 {
    png_voidp ret;
+
    if (png_ptr == NULL || size == 0)
       return (NULL);
 
 #ifdef PNG_USER_MEM_SUPPORTED
    if(png_ptr->malloc_fn != NULL)
    {
-       ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, size));
+       ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size));
        if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
           png_error(png_ptr, "Out of Memory!");
        return (ret);
@@ -424,6 +424,7 @@
    else
        return (png_malloc_default(png_ptr, size));
 }
+
 png_voidp PNGAPI
 png_malloc_default(png_structp png_ptr, png_uint_32 size)
 {
@@ -493,6 +494,26 @@
 
 #endif /* Not Borland DOS special memory handler */
 
+#if defined(PNG_1_0_X)
+#  define png_malloc_warn png_malloc
+#else
+/* This function was added at libpng version 1.2.3.  The png_malloc_warn()
+ * function will issue a png_warning and return NULL instead of issuing a
+ * png_error, if it fails to allocate the requested memory.
+ */
+png_voidp PNGAPI
+png_malloc_warn(png_structp png_ptr, png_uint_32 size)
+{
+   png_voidp ptr;
+   png_uint_32 save_flags=png_ptr->flags;
+
+   png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK;
+   ptr = (png_voidp)png_malloc((png_structp)png_ptr, size);
+   png_ptr->flags=save_flags;
+   return(ptr);
+}
+#endif
+
 png_voidp PNGAPI
 png_memcpy_check (png_structp png_ptr, png_voidp s1, png_voidp s2,
    png_uint_32 length)
diff --git a/pngpread.c b/pngpread.c
index be859da..b8baa59 100644
--- a/pngpread.c
+++ b/pngpread.c
@@ -1,7 +1,7 @@
 
 /* pngpread.c - read a png file in push mode
  *
- * libpng 1.0.13 - April 15, 2002
+ * libpng 1.0.14 - July 8, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -221,7 +221,6 @@
          png_push_save_buffer(png_ptr);
          return;
       }
-
       png_handle_IHDR(png_ptr, info_ptr, png_ptr->push_length);
    }
    else if (!png_memcmp(png_ptr->chunk_name, png_PLTE, 4))
@@ -231,7 +230,6 @@
          png_push_save_buffer(png_ptr);
          return;
       }
-
       png_handle_PLTE(png_ptr, info_ptr, png_ptr->push_length);
    }
    else if (!png_memcmp(png_ptr->chunk_name, (png_bytep)png_IDAT, 4))
@@ -243,7 +241,7 @@
      if (!(png_ptr->mode & PNG_HAVE_IHDR))
        png_error(png_ptr, "Missing IHDR before IDAT");
      else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
-	      !(png_ptr->mode & PNG_HAVE_PLTE))
+         !(png_ptr->mode & PNG_HAVE_PLTE))
        png_error(png_ptr, "Missing PLTE before IDAT");
 
       if (png_ptr->mode & PNG_HAVE_IDAT)
@@ -270,8 +268,8 @@
          png_push_save_buffer(png_ptr);
          return;
       }
-
       png_handle_IEND(png_ptr, info_ptr, png_ptr->push_length);
+
       png_ptr->process_mode = PNG_READ_DONE_MODE;
       png_push_have_end(png_ptr, info_ptr);
    }
@@ -283,7 +281,6 @@
          png_push_save_buffer(png_ptr);
          return;
       }
-
       png_handle_gAMA(png_ptr, info_ptr, png_ptr->push_length);
    }
 #endif
@@ -295,7 +292,6 @@
          png_push_save_buffer(png_ptr);
          return;
       }
-
       png_handle_sBIT(png_ptr, info_ptr, png_ptr->push_length);
    }
 #endif
@@ -307,7 +303,6 @@
          png_push_save_buffer(png_ptr);
          return;
       }
-
       png_handle_cHRM(png_ptr, info_ptr, png_ptr->push_length);
    }
 #endif
@@ -319,7 +314,6 @@
          png_push_save_buffer(png_ptr);
          return;
       }
-
       png_handle_sRGB(png_ptr, info_ptr, png_ptr->push_length);
    }
 #endif
@@ -331,7 +325,6 @@
          png_push_save_buffer(png_ptr);
          return;
       }
-
       png_handle_iCCP(png_ptr, info_ptr, png_ptr->push_length);
    }
 #endif
@@ -343,7 +336,6 @@
          png_push_save_buffer(png_ptr);
          return;
       }
-
       png_handle_sPLT(png_ptr, info_ptr, png_ptr->push_length);
    }
 #endif
@@ -355,7 +347,6 @@
          png_push_save_buffer(png_ptr);
          return;
       }
-
       png_handle_tRNS(png_ptr, info_ptr, png_ptr->push_length);
    }
 #endif
@@ -367,7 +358,6 @@
          png_push_save_buffer(png_ptr);
          return;
       }
-
       png_handle_bKGD(png_ptr, info_ptr, png_ptr->push_length);
    }
 #endif
@@ -379,7 +369,6 @@
          png_push_save_buffer(png_ptr);
          return;
       }
-
       png_handle_hIST(png_ptr, info_ptr, png_ptr->push_length);
    }
 #endif
@@ -391,7 +380,6 @@
          png_push_save_buffer(png_ptr);
          return;
       }
-
       png_handle_pHYs(png_ptr, info_ptr, png_ptr->push_length);
    }
 #endif
@@ -403,7 +391,6 @@
          png_push_save_buffer(png_ptr);
          return;
       }
-
       png_handle_oFFs(png_ptr, info_ptr, png_ptr->push_length);
    }
 #endif
@@ -415,7 +402,6 @@
          png_push_save_buffer(png_ptr);
          return;
       }
-
       png_handle_pCAL(png_ptr, info_ptr, png_ptr->push_length);
    }
 #endif
@@ -427,7 +413,6 @@
          png_push_save_buffer(png_ptr);
          return;
       }
-
       png_handle_sCAL(png_ptr, info_ptr, png_ptr->push_length);
    }
 #endif
@@ -439,30 +424,49 @@
          png_push_save_buffer(png_ptr);
          return;
       }
-
       png_handle_tIME(png_ptr, info_ptr, png_ptr->push_length);
    }
 #endif
 #if defined(PNG_READ_tEXt_SUPPORTED)
    else if (!png_memcmp(png_ptr->chunk_name, png_tEXt, 4))
    {
+      if (png_ptr->push_length + 4 > png_ptr->buffer_size)
+      {
+         png_push_save_buffer(png_ptr);
+         return;
+      }
       png_push_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length);
    }
 #endif
 #if defined(PNG_READ_zTXt_SUPPORTED)
    else if (!png_memcmp(png_ptr->chunk_name, png_zTXt, 4))
    {
+      if (png_ptr->push_length + 4 > png_ptr->buffer_size)
+      {
+         png_push_save_buffer(png_ptr);
+         return;
+      }
       png_push_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length);
    }
 #endif
 #if defined(PNG_READ_iTXt_SUPPORTED)
    else if (!png_memcmp(png_ptr->chunk_name, png_iTXt, 4))
    {
+      if (png_ptr->push_length + 4 > png_ptr->buffer_size)
+      {
+         png_push_save_buffer(png_ptr);
+         return;
+      }
       png_push_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length);
    }
 #endif
    else
    {
+      if (png_ptr->push_length + 4 > png_ptr->buffer_size)
+      {
+         png_push_save_buffer(png_ptr);
+         return;
+      }
       png_push_handle_unknown(png_ptr, info_ptr, png_ptr->push_length);
    }
 
@@ -524,7 +528,7 @@
    }
 }
 
-void /* PRIVATE */
+void PNGAPI
 png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
 {
    png_bytep ptr;
@@ -742,6 +746,13 @@
       }
       if (!(png_ptr->zstream.avail_out))
       {
+         if ((
+#if defined(PNG_READ_INTERLACING_SUPPORTED)
+             png_ptr->interlaced && png_ptr->pass > 6) ||
+             (!png_ptr->interlaced &&
+#endif
+             png_ptr->row_number == png_ptr->num_rows-1))
+           png_error(png_ptr, "Too much data in IDAT chunks");
          png_push_process_row(png_ptr);
          png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes;
          png_ptr->zstream.next_out = png_ptr->row_buf;
@@ -802,13 +813,13 @@
                   png_read_push_finish_row(png_ptr);
                }
             }
-	    if (png_ptr->pass == 4 && png_ptr->height <= 4)
-	    {
-	        for (i = 0; i < 2 && png_ptr->pass == 4; i++)
-                {
-                   png_push_have_row(png_ptr, png_bytep_NULL);
-                   png_read_push_finish_row(png_ptr);
-                }
+            if (png_ptr->pass == 4 && png_ptr->height <= 4)
+            {
+               for (i = 0; i < 2 && png_ptr->pass == 4; i++)
+               {
+                  png_push_have_row(png_ptr, png_bytep_NULL);
+                  png_read_push_finish_row(png_ptr);
+               }
             }
             if (png_ptr->pass == 6 && png_ptr->height <= 4)
             {
@@ -1051,6 +1062,7 @@
       png_textp text_ptr;
       png_charp text;
       png_charp key;
+      int ret;
 
       if (png_ptr->buffer_size < 4)
       {
@@ -1066,7 +1078,6 @@
 #endif
 
       key = png_ptr->current_text;
-      png_ptr->current_text = 0;
 
       for (text = key; *text; text++)
          /* empty loop */ ;
@@ -1083,10 +1094,14 @@
 #endif
       text_ptr->text = text;
 
-      png_set_text(png_ptr, info_ptr, text_ptr, 1);
+      ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
 
       png_free(png_ptr, key);
       png_free(png_ptr, text_ptr);
+      png_ptr->current_text = NULL;
+
+      if (ret)
+        png_warning(png_ptr, "Insufficient memory to store text chunk.");
    }
 }
 #endif
@@ -1157,7 +1172,6 @@
       png_push_crc_finish(png_ptr);
 
       key = png_ptr->current_text;
-      png_ptr->current_text = 0;
 
       for (text = key; *text; text++)
          /* empty loop */ ;
@@ -1165,6 +1179,7 @@
       /* zTXt can't have zero text */
       if (text == key + png_ptr->current_text_size)
       {
+         png_ptr->current_text = NULL;
          png_free(png_ptr, key);
          return;
       }
@@ -1173,6 +1188,7 @@
 
       if (*text != PNG_TEXT_COMPRESSION_zTXt) /* check compression byte */
       {
+         png_ptr->current_text = NULL;
          png_free(png_ptr, key);
          return;
       }
@@ -1197,6 +1213,7 @@
          {
             inflateReset(&png_ptr->zstream);
             png_ptr->zstream.avail_in = 0;
+            png_ptr->current_text = NULL;
             png_free(png_ptr, key);
             png_free(png_ptr, text);
             return;
@@ -1250,11 +1267,13 @@
 
       if (ret != Z_STREAM_END)
       {
+         png_ptr->current_text = NULL;
          png_free(png_ptr, key);
          png_free(png_ptr, text);
          return;
       }
 
+      png_ptr->current_text = NULL;
       png_free(png_ptr, key);
       key = text;
       text += key_size;
@@ -1268,10 +1287,13 @@
 #endif
       text_ptr->text = text;
 
-      png_set_text(png_ptr, info_ptr, text_ptr, 1);
+      ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
 
       png_free(png_ptr, key);
       png_free(png_ptr, text_ptr);
+
+      if (ret)
+        png_warning(png_ptr, "Insufficient memory to store text chunk.");
    }
 }
 #endif
@@ -1332,6 +1354,7 @@
       png_charp lang;
       png_charp lang_key;
       png_charp text;
+      int ret;
 
       if (png_ptr->buffer_size < 4)
       {
@@ -1347,7 +1370,6 @@
 #endif
 
       key = png_ptr->current_text;
-      png_ptr->current_text = 0;
 
       for (lang = key; *lang; lang++)
          /* empty loop */ ;
@@ -1377,9 +1399,13 @@
       text_ptr->text_length = 0;
       text_ptr->itxt_length = png_strlen(text);
 
-      png_set_text(png_ptr, info_ptr, text_ptr, 1);
+      ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
+
+      png_ptr->current_text = NULL;
 
       png_free(png_ptr, text_ptr);
+      if (ret)
+        png_warning(png_ptr, "Insufficient memory to store iTXt chunk.");
    }
 }
 #endif
@@ -1497,7 +1523,7 @@
    png_ptr->row_fn = row_fn;
    png_ptr->end_fn = end_fn;
 
-   png_set_read_fn(png_ptr, progressive_ptr, (png_rw_ptr)png_push_fill_buffer);
+   png_set_read_fn(png_ptr, progressive_ptr, png_push_fill_buffer);
 }
 
 png_voidp PNGAPI
diff --git a/pngread.c b/pngread.c
index c3954e5..018b922 100644
--- a/pngread.c
+++ b/pngread.c
@@ -1,7 +1,7 @@
 
 /* pngread.c - read a PNG file
  *
- * libpng 1.0.13 - April 15, 2002
+ * libpng 1.0.14 - July 8, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -70,8 +70,7 @@
       png_ptr->zbuf=NULL;
 #ifdef PNG_USER_MEM_SUPPORTED
       png_destroy_struct_2((png_voidp)png_ptr, 
-			   (png_free_ptr)free_fn,
-			   (png_voidp)mem_ptr);
+         (png_free_ptr)free_fn, (png_voidp)mem_ptr);
 #else
       png_destroy_struct((png_voidp)png_ptr);
 #endif
@@ -148,6 +147,19 @@
 
    png_set_read_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL);
 
+#ifdef PNG_SETJMP_SUPPORTED
+/* Applications that neglect to set up their own setjmp() and then encounter
+   a png_error() will longjmp here.  Since the jmpbuf is then meaningless we
+   abort instead of returning. */
+#ifdef USE_FAR_KEYWORD
+   if (setjmp(jmpbuf))
+      PNG_ABORT();
+   png_memcpy(png_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf));
+#else
+   if (setjmp(png_ptr->jmpbuf))
+      PNG_ABORT();
+#endif
+#endif
    return (png_ptr);
 }
 
@@ -162,7 +174,6 @@
    png_read_init_2(png_ptr, "1.0.6 or earlier", 0, 0);
 }
 
-#undef png_read_init_2
 void PNGAPI
 png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver,
    png_size_t png_struct_size, png_size_t png_info_size)
@@ -289,7 +300,6 @@
 png_read_info(png_structp png_ptr, png_infop info_ptr)
 {
    png_debug(1, "in png_read_info\n");
-   /* save jump buffer and error functions */
    /* If we haven't checked all of the PNG signature bytes, do so now. */
    if (png_ptr->sig_bytes < 8)
    {
@@ -503,7 +513,6 @@
 png_read_update_info(png_structp png_ptr, png_infop info_ptr)
 {
    png_debug(1, "in png_read_update_info\n");
-   /* save jump buffer and error functions */
    if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
       png_read_start_row(png_ptr);
    else
@@ -521,7 +530,6 @@
 png_start_read_image(png_structp png_ptr)
 {
    png_debug(1, "in png_start_read_image\n");
-   /* save jump buffer and error functions */
    if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
       png_read_start_row(png_ptr);
 }
@@ -537,7 +545,6 @@
    int ret;
    png_debug2(1, "in png_read_row (row %lu, pass %d)\n",
       png_ptr->row_number, png_ptr->pass);
-   /* save jump buffer and error functions */
    if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
       png_read_start_row(png_ptr);
    if (png_ptr->row_number == 0 && png_ptr->pass == 0)
@@ -782,7 +789,7 @@
  * not called png_set_interlace_handling(), the display_row buffer will
  * be ignored, so pass NULL to it.
  *
- * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.13
+ * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.14
  */
 
 void PNGAPI
@@ -794,7 +801,6 @@
    png_bytepp dp;
 
    png_debug(1, "in png_read_rows\n");
-   /* save jump buffer and error functions */
    rp = row;
    dp = display_row;
    if (rp != NULL && dp != NULL)
@@ -831,7 +837,7 @@
  * only call this function once.  If you desire to have an image for
  * each pass of a interlaced image, use png_read_rows() instead.
  *
- * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.13
+ * [*] png_handle_alpha() does not exist yet, as of libpng version 1.0.14
  */
 void PNGAPI
 png_read_image(png_structp png_ptr, png_bytepp image)
@@ -841,7 +847,6 @@
    png_bytepp rp;
 
    png_debug(1, "in png_read_image\n");
-   /* save jump buffer and error functions */
 
 #ifdef PNG_READ_INTERLACING_SUPPORTED
    pass = png_set_interlace_handling(png_ptr);
@@ -878,7 +883,6 @@
    png_uint_32 length;
 
    png_debug(1, "in png_read_end\n");
-   /* save jump buffer and error functions */
    png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */
 
    do
@@ -1068,7 +1072,6 @@
 #endif
 
    png_debug(1, "in png_destroy_read_struct\n");
-   /* save jump buffer and error functions */
    if (png_ptr_ptr != NULL)
       png_ptr = *png_ptr_ptr;
 
@@ -1141,7 +1144,6 @@
 #endif
 
    png_debug(1, "in png_read_destroy\n");
-   /* save jump buffer and error functions */
    if (info_ptr != NULL)
       png_info_destroy(png_ptr, info_ptr);
 
@@ -1237,6 +1239,12 @@
    png_free(png_ptr, png_ptr->save_buffer);
 #endif
 
+#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
+#ifdef PNG_TEXT_SUPPORTED
+   png_free(png_ptr, png_ptr->current_text);
+#endif /* PNG_TEXT_SUPPORTED */
+#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
+
    /* Save the important info out of the png_struct, in case it is
     * being used again.
     */
diff --git a/pngrio.c b/pngrio.c
index 9f0e9e3..f03f328 100644
--- a/pngrio.c
+++ b/pngrio.c
@@ -1,7 +1,7 @@
 
 /* pngrio.c - functions for data input
  *
- * libpng 1.0.13 - April 15, 2002
+ * libpng 1.0.14 - July 8, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -39,7 +39,7 @@
    read_data function and use it at run time with png_set_read_fn(), rather
    than changing the library. */
 #ifndef USE_FAR_KEYWORD
-static void /* PRIVATE */
+void PNGAPI
 png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
 {
    png_size_t check;
@@ -140,7 +140,7 @@
    if (read_data_fn != NULL)
       png_ptr->read_data_fn = read_data_fn;
    else
-      png_ptr->read_data_fn = (png_rw_ptr)png_default_read_data;
+      png_ptr->read_data_fn = png_default_read_data;
 #else
    png_ptr->read_data_fn = read_data_fn;
 #endif
diff --git a/pngrtran.c b/pngrtran.c
index c7a693c..fbe2d2c 100644
--- a/pngrtran.c
+++ b/pngrtran.c
@@ -1,7 +1,7 @@
 
 /* pngrtran.c - transforms the data in a row for PNG readers
  *
- * libpng 1.0.13 - April 15, 2002
+ * libpng 1.0.14 - July 8, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -167,15 +167,14 @@
             Perhaps not the best solution, but good enough. */
 
          int i;
-         png_bytep sort;
 
          /* initialize an array to sort colors */
-         sort = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_palette
-            * sizeof (png_byte)));
+         png_ptr->dither_sort = (png_bytep)png_malloc(png_ptr,
+            (png_uint_32)(num_palette * sizeof (png_byte)));
 
-         /* initialize the sort array */
+         /* initialize the dither_sort array */
          for (i = 0; i < num_palette; i++)
-            sort[i] = (png_byte)i;
+            png_ptr->dither_sort[i] = (png_byte)i;
 
          /* Find the least used palette entries by starting a
             bubble sort, and running it until we have sorted
@@ -191,13 +190,14 @@
             done = 1;
             for (j = 0; j < i; j++)
             {
-               if (histogram[sort[j]] < histogram[sort[j + 1]])
+               if (histogram[png_ptr->dither_sort[j]]
+                   < histogram[png_ptr->dither_sort[j + 1]])
                {
                   png_byte t;
 
-                  t = sort[j];
-                  sort[j] = sort[j + 1];
-                  sort[j + 1] = t;
+                  t = png_ptr->dither_sort[j];
+                  png_ptr->dither_sort[j] = png_ptr->dither_sort[j + 1];
+                  png_ptr->dither_sort[j + 1] = t;
                   done = 0;
                }
             }
@@ -214,11 +214,11 @@
                move the others */
             for (i = 0; i < maximum_colors; i++)
             {
-               if ((int)sort[i] >= maximum_colors)
+               if ((int)png_ptr->dither_sort[i] >= maximum_colors)
                {
                   do
                      j--;
-                  while ((int)sort[j] >= maximum_colors);
+                  while ((int)png_ptr->dither_sort[j] >= maximum_colors);
                   palette[i] = palette[j];
                }
             }
@@ -232,13 +232,13 @@
             for (i = 0; i < maximum_colors; i++)
             {
                /* only move the colors we need to */
-               if ((int)sort[i] >= maximum_colors)
+               if ((int)png_ptr->dither_sort[i] >= maximum_colors)
                {
                   png_color tmp_color;
 
                   do
                      j--;
-                  while ((int)sort[j] >= maximum_colors);
+                  while ((int)png_ptr->dither_sort[j] >= maximum_colors);
 
                   tmp_color = palette[j];
                   palette[j] = palette[i];
@@ -276,7 +276,8 @@
                }
             }
          }
-         png_free(png_ptr, sort);
+         png_free(png_ptr, png_ptr->dither_sort);
+         png_ptr->dither_sort=NULL;
       }
       else
       {
@@ -291,23 +292,22 @@
          int i;
          int max_d;
          int num_new_palette;
+         png_dsortp t;
          png_dsortpp hash;
-         png_bytep index_to_palette;
-            /* where the original index currently is in the palette */
-         png_bytep palette_to_index;
-            /* which original index points to this palette color */
+
+         t=NULL;
 
          /* initialize palette index arrays */
-         index_to_palette = (png_bytep)png_malloc(png_ptr,
+         png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr,
             (png_uint_32)(num_palette * sizeof (png_byte)));
-         palette_to_index = (png_bytep)png_malloc(png_ptr,
+         png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr,
             (png_uint_32)(num_palette * sizeof (png_byte)));
 
          /* initialize the sort array */
          for (i = 0; i < num_palette; i++)
          {
-            index_to_palette[i] = (png_byte)i;
-            palette_to_index[i] = (png_byte)i;
+            png_ptr->index_to_palette[i] = (png_byte)i;
+            png_ptr->palette_to_index[i] = (png_byte)i;
          }
 
          hash = (png_dsortpp)png_malloc(png_ptr, (png_uint_32)(769 *
@@ -342,18 +342,22 @@
 
                   if (d <= max_d)
                   {
-                     png_dsortp t;
 
-                     t = (png_dsortp)png_malloc(png_ptr, (png_uint_32)(sizeof
-                         (png_dsort)));
+                     t = (png_dsortp)png_malloc_warn(png_ptr,
+                         (png_uint_32)(sizeof(png_dsort)));
+                     if (t == NULL)
+                         break;
                      t->next = hash[d];
                      t->left = (png_byte)i;
                      t->right = (png_byte)j;
                      hash[d] = t;
                   }
                }
+               if (t == NULL)
+                  break;
             }
 
+            if (t != NULL)
             for (i = 0; i <= max_d; i++)
             {
                if (hash[i] != NULL)
@@ -362,8 +366,10 @@
 
                   for (p = hash[i]; p; p = p->next)
                   {
-                     if ((int)index_to_palette[p->left] < num_new_palette &&
-                        (int)index_to_palette[p->right] < num_new_palette)
+                     if ((int)png_ptr->index_to_palette[p->left]
+                        < num_new_palette &&
+                        (int)png_ptr->index_to_palette[p->right]
+                        < num_new_palette)
                      {
                         int j, next_j;
 
@@ -379,7 +385,8 @@
                         }
 
                         num_new_palette--;
-                        palette[index_to_palette[j]] = palette[num_new_palette];
+                        palette[png_ptr->index_to_palette[j]]
+                          = palette[num_new_palette];
                         if (!full_dither)
                         {
                            int k;
@@ -387,23 +394,23 @@
                            for (k = 0; k < num_palette; k++)
                            {
                               if (png_ptr->dither_index[k] ==
-                                 index_to_palette[j])
+                                 png_ptr->index_to_palette[j])
                                  png_ptr->dither_index[k] =
-                                    index_to_palette[next_j];
+                                    png_ptr->index_to_palette[next_j];
                               if ((int)png_ptr->dither_index[k] ==
                                  num_new_palette)
                                  png_ptr->dither_index[k] =
-                                    index_to_palette[j];
+                                    png_ptr->index_to_palette[j];
                            }
                         }
 
-                        index_to_palette[palette_to_index[num_new_palette]] =
-                           index_to_palette[j];
-                        palette_to_index[index_to_palette[j]] =
-                           palette_to_index[num_new_palette];
+                        png_ptr->index_to_palette[png_ptr->palette_to_index
+                           [num_new_palette]] = png_ptr->index_to_palette[j];
+                        png_ptr->palette_to_index[png_ptr->index_to_palette[j]]
+                           = png_ptr->palette_to_index[num_new_palette];
 
-                        index_to_palette[j] = (png_byte)num_new_palette;
-                        palette_to_index[num_new_palette] = (png_byte)j;
+                        png_ptr->index_to_palette[j] = (png_byte)num_new_palette;
+                        png_ptr->palette_to_index[num_new_palette] = (png_byte)j;
                      }
                      if (num_new_palette <= maximum_colors)
                         break;
@@ -420,8 +427,6 @@
                   png_dsortp p = hash[i];
                   while (p)
                   {
-                     png_dsortp t;
-
                      t = p->next;
                      png_free(png_ptr, p);
                      p = t;
@@ -432,8 +437,10 @@
             max_d += 96;
          }
          png_free(png_ptr, hash);
-         png_free(png_ptr, palette_to_index);
-         png_free(png_ptr, index_to_palette);
+         png_free(png_ptr, png_ptr->palette_to_index);
+         png_free(png_ptr, png_ptr->index_to_palette);
+         png_ptr->palette_to_index=NULL;
+         png_ptr->index_to_palette=NULL;
       }
       num_palette = maximum_colors;
    }
@@ -872,7 +879,7 @@
                }
             }
          }
-         /* if (png_ptr->background_gamma_type!=PNG_BACKGROUND_GAMMA_UNKNOWN)*/
+         /* if (png_ptr->background_gamma_type!=PNG_BACKGROUND_GAMMA_UNKNOWN) */
          else
          /* color_type != PNG_COLOR_TYPE_PALETTE */
          {
diff --git a/pngrutil.c b/pngrutil.c
index 1f3bab2..f59e35a 100644
--- a/pngrutil.c
+++ b/pngrutil.c
@@ -1,7 +1,7 @@
 
 /* pngrutil.c - utilities to read a PNG file
  *
- * libpng 1.0.13 - April 15, 2002
+ * libpng 1.0.14 - July 8, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -200,7 +200,12 @@
             if (text ==  NULL)
             {
                text_size = prefix_size + sizeof(msg) + 1;
-               text = (png_charp)png_malloc(png_ptr, text_size);
+               text = (png_charp)png_malloc_warn(png_ptr, text_size);
+               if (text ==  NULL)
+                 {
+                    png_free(png_ptr,chunkdata);
+                    png_error(png_ptr,"Not enough memory to decompress chunk");
+                 }
                png_memcpy(text, chunkdata, prefix_size);
             }
 
@@ -218,7 +223,12 @@
             {
                text_size = prefix_size +
                    png_ptr->zbuf_size - png_ptr->zstream.avail_out;
-               text = (png_charp)png_malloc(png_ptr, text_size + 1);
+               text = (png_charp)png_malloc_warn(png_ptr, text_size + 1);
+               if (text ==  NULL)
+                 {
+                    png_free(png_ptr,chunkdata);
+                    png_error(png_ptr,"Not enough memory to decompress chunk.");
+                 }
                png_memcpy(text + prefix_size, png_ptr->zbuf,
                     text_size - prefix_size);
                png_memcpy(text, chunkdata, prefix_size);
@@ -229,8 +239,15 @@
                png_charp tmp;
 
                tmp = text;
-               text = (png_charp)png_malloc(png_ptr, (png_uint_32)(text_size +
+               text = (png_charp)png_malloc_warn(png_ptr,
+                  (png_uint_32)(text_size +
                   png_ptr->zbuf_size - png_ptr->zstream.avail_out + 1));
+               if (text == NULL)
+               {
+                  png_free(png_ptr, tmp);
+                  png_free(png_ptr, chunkdata);
+                  png_error(png_ptr,"Not enough memory to decompress chunk..");
+               }
                png_memcpy(text, tmp, text_size);
                png_free(png_ptr, tmp);
                png_memcpy(text + text_size, png_ptr->zbuf,
@@ -269,7 +286,12 @@
          text_size=prefix_size;
          if (text ==  NULL)
          {
-            text = (png_charp)png_malloc(png_ptr, text_size+1);
+            text = (png_charp)png_malloc_warn(png_ptr, text_size+1);
+            if (text == NULL)
+              {
+                png_free(png_ptr, chunkdata);
+                png_error(png_ptr,"Not enough memory for text.");
+              }
             png_memcpy(text, chunkdata, prefix_size);
          }
          *(text + text_size) = 0x00;
@@ -1193,7 +1215,7 @@
 void /* PRIVATE */
 png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
 {
-   png_byte	readbuf[PNG_MAX_PALETTE_LENGTH];
+   png_byte readbuf[PNG_MAX_PALETTE_LENGTH];
 
    png_debug(1, "in png_handle_tRNS\n");
 
@@ -1376,7 +1398,7 @@
 png_handle_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
 {
    int num, i;
-   png_uint_16	readbuf[PNG_MAX_PALETTE_LENGTH];
+   png_uint_16 readbuf[PNG_MAX_PALETTE_LENGTH];
 
    png_debug(1, "in png_handle_hIST\n");
 
@@ -1542,7 +1564,12 @@
 
    png_debug1(2, "Allocating and reading pCAL chunk data (%lu bytes)\n",
       length + 1);
-   purpose = (png_charp)png_malloc(png_ptr, length + 1);
+   purpose = (png_charp)png_malloc_warn(png_ptr, length + 1);
+   if (purpose == NULL)
+     {
+       png_warning(png_ptr, "No memory for pCAL purpose.");
+       return;
+     }
    slength = (png_size_t)length;
    png_crc_read(png_ptr, (png_bytep)purpose, slength);
 
@@ -1597,8 +1624,14 @@
       /* Empty loop to move past the units string. */ ;
 
    png_debug(3, "Allocating pCAL parameters array\n");
-   params = (png_charpp)png_malloc(png_ptr, (png_uint_32)(nparams
+   params = (png_charpp)png_malloc_warn(png_ptr, (png_uint_32)(nparams
       *sizeof(png_charp))) ;
+   if (params == NULL)
+     {
+       png_free(png_ptr, purpose);
+       png_warning(png_ptr, "No memory for pCAL params.");
+       return;
+     }
 
    /* Get pointers to the start of each parameter string. */
    for (i = 0; i < (int)nparams; i++)
@@ -1662,7 +1695,12 @@
 
    png_debug1(2, "Allocating and reading sCAL chunk data (%lu bytes)\n",
       length + 1);
-   buffer = (png_charp)png_malloc(png_ptr, length + 1);
+   buffer = (png_charp)png_malloc_warn(png_ptr, length + 1);
+   if (buffer == NULL)
+     {
+       png_warning(png_ptr, "Out of memory while processing sCAL chunk");
+       return;
+     }
    slength = (png_size_t)length;
    png_crc_read(png_ptr, (png_bytep)buffer, slength);
 
@@ -1685,7 +1723,12 @@
    }
 #else
 #ifdef PNG_FIXED_POINT_SUPPORTED
-   swidth = (png_charp)png_malloc(png_ptr, png_strlen(ep) + 1);
+   swidth = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1);
+   if (swidth == NULL)
+     {
+       png_warning(png_ptr, "Out of memory while processing sCAL chunk width");
+       return;
+     }
    png_memcpy(swidth, ep, (png_size_t)png_strlen(ep));
 #endif
 #endif
@@ -1703,7 +1746,12 @@
    }
 #else
 #ifdef PNG_FIXED_POINT_SUPPORTED
-   sheight = (png_charp)png_malloc(png_ptr, png_strlen(ep) + 1);
+   sheight = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1);
+   if (swidth == NULL)
+     {
+       png_warning(png_ptr, "Out of memory while processing sCAL chunk height");
+       return;
+     }
    png_memcpy(sheight, ep, (png_size_t)png_strlen(ep));
 #endif
 #endif
@@ -1793,6 +1841,7 @@
    png_charp text;
    png_uint_32 skip = 0;
    png_size_t slength;
+   int ret;
 
    png_debug(1, "in png_handle_tEXt\n");
 
@@ -1811,7 +1860,12 @@
    }
 #endif
 
-   key = (png_charp)png_malloc(png_ptr, length + 1);
+   key = (png_charp)png_malloc_warn(png_ptr, length + 1);
+   if (key == NULL)
+   {
+     png_warning(png_ptr, "No memory to process text chunk.");
+     return;
+   }
    slength = (png_size_t)length;
    png_crc_read(png_ptr, (png_bytep)key, slength);
 
@@ -1829,7 +1883,13 @@
    if (text != key + slength)
       text++;
 
-   text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
+   text_ptr = (png_textp)png_malloc_warn(png_ptr, (png_uint_32)sizeof(png_text));
+   if (text_ptr == NULL)
+   {
+     png_warning(png_ptr, "Not enough memory to process text chunk.");
+     png_free(png_ptr, key);
+     return;
+   }
    text_ptr->compression = PNG_TEXT_COMPRESSION_NONE;
    text_ptr->key = key;
 #ifdef PNG_iTXt_SUPPORTED
@@ -1840,10 +1900,12 @@
    text_ptr->text = text;
    text_ptr->text_length = png_strlen(text);
 
-   png_set_text(png_ptr, info_ptr, text_ptr, 1);
+   ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
 
    png_free(png_ptr, key);
    png_free(png_ptr, text_ptr);
+   if (ret)
+     png_warning(png_ptr, "Insufficient memory to process text chunk.");
 }
 #endif
 
@@ -1856,6 +1918,7 @@
    png_charp chunkdata;
    png_charp text;
    int comp_type;
+   int ret;
    png_size_t slength, prefix_len, data_len;
 
    png_debug(1, "in png_handle_zTXt\n");
@@ -1876,8 +1939,13 @@
    }
 #endif
 
-   chunkdata = (png_charp)png_malloc(png_ptr, length + 1);
-     slength = (png_size_t)length;
+   chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);
+   if (chunkdata == NULL)
+   {
+     png_warning(png_ptr,"Out of memory processing zTXt chunk.");
+     return;
+   }
+   slength = (png_size_t)length;
    png_crc_read(png_ptr, (png_bytep)chunkdata, slength);
    if (png_crc_finish(png_ptr, 0))
    {
@@ -1911,7 +1979,13 @@
    chunkdata = (png_charp)png_decompress_chunk(png_ptr, comp_type, chunkdata,
                                     (png_size_t)length, prefix_len, &data_len);
 
-   text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
+   text_ptr = (png_textp)png_malloc_warn(png_ptr, (png_uint_32)sizeof(png_text));
+   if (text_ptr == NULL)
+   {
+     png_warning(png_ptr,"Not enough memory to process zTXt chunk.");
+     png_free(png_ptr, chunkdata);
+     return;
+   }
    text_ptr->compression = comp_type;
    text_ptr->key = chunkdata;
 #ifdef PNG_iTXt_SUPPORTED
@@ -1922,10 +1996,12 @@
    text_ptr->text = chunkdata + prefix_len;
    text_ptr->text_length = data_len;
 
-   png_set_text(png_ptr, info_ptr, text_ptr, 1);
+   ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
 
    png_free(png_ptr, text_ptr);
    png_free(png_ptr, chunkdata);
+   if (ret)
+     png_error(png_ptr, "Insufficient memory to store zTXt chunk.");
 }
 #endif
 
@@ -1939,6 +2015,7 @@
    png_charp key, lang, text, lang_key;
    int comp_flag;
    int comp_type = 0;
+   int ret;
    png_size_t slength, prefix_len, data_len;
 
    png_debug(1, "in png_handle_iTXt\n");
@@ -1960,7 +2037,12 @@
    }
 #endif
 
-   chunkdata = (png_charp)png_malloc(png_ptr, length + 1);
+   chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);
+   if (chunkdata == NULL)
+   {
+     png_warning(png_ptr, "No memory to process iTXt chunk.");
+     return;
+   }
    slength = (png_size_t)length;
    png_crc_read(png_ptr, (png_bytep)chunkdata, slength);
    if (png_crc_finish(png_ptr, 0))
@@ -2006,7 +2088,13 @@
           (size_t)length, prefix_len, &data_len);
    else
        data_len=png_strlen(chunkdata + prefix_len);
-   text_ptr = (png_textp)png_malloc(png_ptr, (png_uint_32)sizeof(png_text));
+   text_ptr = (png_textp)png_malloc_warn(png_ptr, (png_uint_32)sizeof(png_text));
+   if (text_ptr == NULL)
+   {
+     png_warning(png_ptr,"Not enough memory to process iTXt chunk.");
+     png_free(png_ptr, chunkdata);
+     return;
+   }
    text_ptr->compression = (int)comp_flag + 1;
    text_ptr->lang_key = chunkdata+(lang_key-key);
    text_ptr->lang = chunkdata+(lang-key);
@@ -2015,10 +2103,12 @@
    text_ptr->key = chunkdata;
    text_ptr->text = chunkdata + prefix_len;
 
-   png_set_text(png_ptr, info_ptr, text_ptr, 1);
+   ret=png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
 
    png_free(png_ptr, text_ptr);
    png_free(png_ptr, chunkdata);
+   if (ret)
+     png_error(png_ptr, "Insufficient memory to store iTXt chunk.");
 }
 #endif
 
@@ -2084,7 +2174,10 @@
              if (!(png_ptr->chunk_name[0] & 0x20))
                 if(png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
                      HANDLE_CHUNK_ALWAYS)
+                 {
+                   png_free(png_ptr, chunk.data);
                    png_chunk_error(png_ptr, "unknown critical chunk");
+                 }
              png_set_unknown_chunks(png_ptr, info_ptr, &chunk, 1);
           }
        }
diff --git a/pngset.c b/pngset.c
index cc40bdc..5d43720 100644
--- a/pngset.c
+++ b/pngset.c
@@ -1,7 +1,7 @@
 
 /* pngset.c - storage of image information into info struct
  *
- * libpng 1.0.13 - April 15, 2002
+ * libpng 1.0.14 - July 8, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -200,7 +200,7 @@
 void PNGAPI
 png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist)
 {
-   int	i;
+   int i;
 
    png_debug1(1, "in %s storage function\n", "hIST");
    if (png_ptr == NULL || info_ptr == NULL)
@@ -216,8 +216,13 @@
    png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0);
 #endif
    /* Changed from info->num_palette to 256 in version 1.2.1 */
-   png_ptr->hist = (png_uint_16p)png_malloc(png_ptr,
+   png_ptr->hist = (png_uint_16p)png_malloc_warn(png_ptr,
       (png_uint_32)(256 * sizeof (png_uint_16)));
+   if (png_ptr->hist == NULL)
+     {
+       png_warning(png_ptr, "Insufficient memory for hIST chunk data.");
+       return;
+     }
 
    for (i = 0; i < info_ptr->num_palette; i++)
        png_ptr->hist[i] = hist[i];
@@ -305,7 +310,9 @@
    info_ptr->compression_type = (png_byte)compression_type;
    info_ptr->filter_type = (png_byte)filter_type;
    info_ptr->interlace_type = (png_byte)interlace_type;
-   if (info_ptr->color_type & PNG_COLOR_MASK_COLOR)
+   if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
+      info_ptr->channels = 1;
+   else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR)
       info_ptr->channels = 3;
    else
       info_ptr->channels = 1;
@@ -315,7 +322,7 @@
 
    /* check for overflow */
    rowbytes_per_pixel = (info_ptr->pixel_depth + 7) >> 3;
-   if (( width > PNG_MAX_UINT/rowbytes_per_pixel))
+   if ( width > PNG_MAX_UINT/rowbytes_per_pixel - 64)
    {
       png_warning(png_ptr,
          "Width too large to process image data; rowbytes will overflow.");
@@ -356,7 +363,12 @@
 
    length = png_strlen(purpose) + 1;
    png_debug1(3, "allocating purpose for info (%lu bytes)\n", length);
-   info_ptr->pcal_purpose = (png_charp)png_malloc(png_ptr, length);
+   info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length);
+   if (info_ptr->pcal_purpose == NULL)
+     {
+       png_warning(png_ptr, "Insufficient memory for pCAL purpose.");
+       return;
+     }
    png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length);
 
    png_debug(3, "storing X0, X1, type, and nparams in info\n");
@@ -367,11 +379,21 @@
 
    length = png_strlen(units) + 1;
    png_debug1(3, "allocating units for info (%lu bytes)\n", length);
-   info_ptr->pcal_units = (png_charp)png_malloc(png_ptr, length);
+   info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length);
+   if (info_ptr->pcal_units == NULL)
+     {
+       png_warning(png_ptr, "Insufficient memory for pCAL units.");
+       return;
+     }
    png_memcpy(info_ptr->pcal_units, units, (png_size_t)length);
 
-   info_ptr->pcal_params = (png_charpp)png_malloc(png_ptr,
+   info_ptr->pcal_params = (png_charpp)png_malloc_warn(png_ptr,
       (png_uint_32)((nparams + 1) * sizeof(png_charp)));
+   if (info_ptr->pcal_params == NULL)
+     {
+       png_warning(png_ptr, "Insufficient memory for pCAL params.");
+       return;
+     }
 
    info_ptr->pcal_params[nparams] = NULL;
 
@@ -379,7 +401,12 @@
    {
       length = png_strlen(params[i]) + 1;
       png_debug2(3, "allocating parameter %d for info (%lu bytes)\n", i, length);
-      info_ptr->pcal_params[i] = (png_charp)png_malloc(png_ptr, length);
+      info_ptr->pcal_params[i] = (png_charp)png_malloc_warn(png_ptr, length);
+      if (info_ptr->pcal_params[i] == NULL)
+        {
+          png_warning(png_ptr, "Insufficient memory for pCAL parameter.");
+          return;
+        }
       png_memcpy(info_ptr->pcal_params[i], params[i], (png_size_t)length);
    }
 
@@ -626,13 +653,23 @@
 png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
    int num_text)
 {
+   int ret;
+   ret=png_set_text_2(png_ptr, info_ptr, text_ptr, num_text);
+   if (ret)
+     png_error(png_ptr, "Insufficient memory to store text");
+}
+
+int /* PRIVATE */
+png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
+   int num_text)
+{
    int i;
 
    png_debug1(1, "in %s storage function\n", (png_ptr->chunk_name[0] == '\0' ?
       "text" : (png_const_charp)png_ptr->chunk_name));
 
    if (png_ptr == NULL || info_ptr == NULL || num_text == 0)
-      return;
+      return(0);
 
    /* Make sure we have enough space in the "text" array in info_struct
     * to hold all of the incoming text_ptr objects.
@@ -647,8 +684,13 @@
          old_max = info_ptr->max_text;
          info_ptr->max_text = info_ptr->num_text + num_text + 8;
          old_text = info_ptr->text;
-         info_ptr->text = (png_textp)png_malloc(png_ptr,
+         info_ptr->text = (png_textp)png_malloc_warn(png_ptr,
             (png_uint_32)(info_ptr->max_text * sizeof (png_text)));
+         if (info_ptr->text == NULL)
+           {
+             png_free(png_ptr, old_text);
+             return(1);
+           }
          png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max *
             sizeof(png_text)));
          png_free(png_ptr, old_text);
@@ -657,8 +699,10 @@
       {
          info_ptr->max_text = num_text + 8;
          info_ptr->num_text = 0;
-         info_ptr->text = (png_textp)png_malloc(png_ptr,
+         info_ptr->text = (png_textp)png_malloc_warn(png_ptr,
             (png_uint_32)(info_ptr->max_text * sizeof (png_text)));
+         if (info_ptr->text == NULL)
+           return(1);
 #ifdef PNG_FREE_ME_SUPPORTED
          info_ptr->free_me |= PNG_FREE_TEXT;
 #endif
@@ -718,8 +762,10 @@
          textp->compression = text_ptr[i].compression;
       }
 
-      textp->key = (png_charp)png_malloc(png_ptr,
+      textp->key = (png_charp)png_malloc_warn(png_ptr,
          (png_uint_32)(key_len + text_length + lang_len + lang_key_len + 4));
+      if (textp->key == NULL)
+        return(1);
       png_debug2(2, "Allocated %lu bytes at %x in png_set_text\n",
          (png_uint_32)(key_len + lang_len + lang_key_len + text_length + 4),
          (int)textp->key);
@@ -770,6 +816,7 @@
       info_ptr->num_text++;
       png_debug1(3, "transferred text chunk %d\n", info_ptr->num_text);
    }
+   return(0);
 }
 #endif
 
@@ -799,10 +846,10 @@
    if (trans != NULL)
    {
        /*
-	* It may not actually be necessary to set png_ptr->trans here;
-	* we do it for backward compatibility with the way the png_handle_tRNS
-	* function used to do the allocation.
-	*/
+        * It may not actually be necessary to set png_ptr->trans here;
+        * we do it for backward compatibility with the way the png_handle_tRNS
+        * function used to do the allocation.
+        */
 #ifdef PNG_FREE_ME_SUPPORTED
        png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0);
 #endif
@@ -837,8 +884,13 @@
     png_sPLT_tp np;
     int i;
 
-    np = (png_sPLT_tp)png_malloc(png_ptr,
+    np = (png_sPLT_tp)png_malloc_warn(png_ptr,
         (info_ptr->splt_palettes_num + nentries) * sizeof(png_sPLT_t));
+    if (np == NULL)
+    {
+      png_warning(png_ptr, "No memory for sPLT palettes.");
+      return;
+    }
 
     png_memcpy(np, info_ptr->splt_palettes,
            info_ptr->splt_palettes_num * sizeof(png_sPLT_t));
@@ -881,9 +933,14 @@
     if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0)
         return;
 
-    np = (png_unknown_chunkp)png_malloc(png_ptr,
+    np = (png_unknown_chunkp)png_malloc_warn(png_ptr,
         (info_ptr->unknown_chunks_num + num_unknowns) *
         sizeof(png_unknown_chunk));
+    if (np == NULL)
+    {
+       png_warning(png_ptr, "Out of memory while processing unknown chunk.");
+       return;
+    }
 
     png_memcpy(np, info_ptr->unknown_chunks,
            info_ptr->unknown_chunks_num * sizeof(png_unknown_chunk));
@@ -897,11 +954,16 @@
 
         png_strcpy((png_charp)to->name, (png_charp)from->name);
         to->data = (png_bytep)png_malloc(png_ptr, from->size);
-        png_memcpy(to->data, from->data, from->size);
-        to->size = from->size;
+        if (to->data == NULL)
+           png_warning(png_ptr, "Out of memory while processing unknown chunk.");
+        else
+        {
+          png_memcpy(to->data, from->data, from->size);
+          to->size = from->size;
 
-        /* note our location in the read or write sequence */
-        to->location = (png_byte)(png_ptr->mode & 0xff);
+          /* note our location in the read or write sequence */
+          to->location = (png_byte)(png_ptr->mode & 0xff);
+        }
     }
 
     info_ptr->unknown_chunks = np;
@@ -1079,8 +1141,8 @@
      * so first zero them out of the master copy, then logical-OR in the
      * allowed subset that was requested */
 
-    png_ptr->asm_flags &= ~settable_asm_flags;			/* zero them */
-    png_ptr->asm_flags |= (asm_flags & settable_asm_flags);	/* set them */
+    png_ptr->asm_flags &= ~settable_asm_flags;               /* zero them */
+    png_ptr->asm_flags |= (asm_flags & settable_asm_flags);  /* set them */
 }
 #endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
 
diff --git a/pngtest.c b/pngtest.c
index 0c53b7d..156e3d0 100644
--- a/pngtest.c
+++ b/pngtest.c
@@ -1,7 +1,7 @@
 
 /* pngtest.c - a simple test program to test libpng
  *
- * libpng 1.0.13 - April 15, 2002
+ * libpng 1.0.14 - July 8, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -64,7 +64,7 @@
 #endif
 
 #if !PNG_DEBUG
-#  define SINGLE_ROWBUF_ALLOC	/* makes buffer overruns easier to nail */
+#  define SINGLE_ROWBUF_ALLOC  /* makes buffer overruns easier to nail */
 #endif
 
 /* Turn on CPU timing
@@ -117,7 +117,13 @@
 static int status_dots=1;
 
 void
+#ifdef PNG_1_0_X
+PNGAPI
+#endif
 read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass);
+#ifdef PNG_1_0_X
+PNGAPI
+#endif
 void
 read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
 {
@@ -137,8 +143,14 @@
     fprintf(stdout, "r");
 }
 
+#ifdef PNG_1_0_X
+PNGAPI
+#endif
 void
 write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass);
+#ifdef PNG_1_0_X
+PNGAPI
+#endif
 void
 write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
 {
@@ -153,8 +165,14 @@
    5 in case illegal filter values are present.) */
 static png_uint_32 filters_used[256];
 void
+#ifdef PNG_1_0_X
+PNGAPI
+#endif
 count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data);
 void
+#ifdef PNG_1_0_X
+PNGAPI
+#endif
 count_filters(png_structp png_ptr, png_row_infop row_info, png_bytep data)
 {
     if(png_ptr != NULL && row_info != NULL)
@@ -169,8 +187,14 @@
 static png_uint_32 zero_samples;
 
 void
+#ifdef PNG_1_0_X
+PNGAPI
+#endif
 count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data);
 void
+#ifdef PNG_1_0_X
+PNGAPI
+#endif
 count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
 {
    png_bytep dp = data;
@@ -663,6 +687,8 @@
 #endif
    {
       fprintf(STDERR, "%s -> %s: libpng read error\n", inname, outname);
+      if (row_buf)
+         png_free(read_ptr, row_buf);
       png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
 #ifdef PNG_WRITE_SUPPORTED
       png_destroy_info_struct(write_ptr, &write_end_info_ptr);
@@ -1512,4 +1538,4 @@
 }
 
 /* Generate a compiler error if there is an old png.h in the search path. */
-typedef version_1_0_13 your_png_h_is_not_version_1_0_13;
+typedef version_1_0_14 your_png_h_is_not_version_1_0_14;
diff --git a/pngtrans.c b/pngtrans.c
index 63a6672..8f883a1 100644
--- a/pngtrans.c
+++ b/pngtrans.c
@@ -1,7 +1,7 @@
 
 /* pngtrans.c - transforms the data in a row (used by both readers and writers)
  *
- * libpng 1.0.13 - April 15, 2002
+ * libpng 1.0.14 - July 8, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
diff --git a/pngvcrd.c b/pngvcrd.c
index 2f343af..939ada9 100644
--- a/pngvcrd.c
+++ b/pngvcrd.c
@@ -2,7 +2,7 @@
  *
  * For Intel x86 CPU and Microsoft Visual C++ compiler
  *
- * libpng version 1.0.13 - April 15, 2002
+ * libpng version 1.0.14 - July 8, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * Copyright (c) 1998, Intel Corporation
diff --git a/pngwio.c b/pngwio.c
index 6ef97bb..005e51c 100644
--- a/pngwio.c
+++ b/pngwio.c
@@ -1,7 +1,7 @@
 
 /* pngwio.c - functions for data output
  *
- * libpng 1.0.13 - April 15, 2002
+ * libpng 1.0.14 - July 8, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -40,7 +40,7 @@
    write_data function and use it at run time with png_set_write_fn(), rather
    than changing the library. */
 #ifndef USE_FAR_KEYWORD
-static void /* PRIVATE */
+void PNGAPI
 png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
 {
    png_uint_32 check;
@@ -63,7 +63,7 @@
 #define NEAR_BUF_SIZE 1024
 #define MIN(a,b) (a <= b ? a : b)
 
-static void /* PRIVATE */
+void PNGAPI
 png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
 {
    png_uint_32 check;
@@ -126,7 +126,7 @@
 }
 
 #if !defined(PNG_NO_STDIO)
-static void /* PRIVATE */
+void PNGAPI
 png_default_flush(png_structp png_ptr)
 {
 #if !defined(_WIN32_WCE)
@@ -171,7 +171,7 @@
    if (write_data_fn != NULL)
       png_ptr->write_data_fn = write_data_fn;
    else
-      png_ptr->write_data_fn = (png_rw_ptr)png_default_write_data;
+      png_ptr->write_data_fn = png_default_write_data;
 #else
    png_ptr->write_data_fn = write_data_fn;
 #endif
@@ -181,7 +181,7 @@
    if (output_flush_fn != NULL)
       png_ptr->output_flush_fn = output_flush_fn;
    else
-      png_ptr->output_flush_fn = (png_flush_ptr)png_default_flush;
+      png_ptr->output_flush_fn = png_default_flush;
 #else
    png_ptr->output_flush_fn = output_flush_fn;
 #endif
diff --git a/pngwrite.c b/pngwrite.c
index 238ac0a..dda6998 100644
--- a/pngwrite.c
+++ b/pngwrite.c
@@ -1,7 +1,7 @@
 
 /* pngwrite.c - general routines to write a PNG file
  *
- * libpng 1.0.13 - April 15, 2002
+ * libpng 1.0.14 - July 8, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -530,7 +530,20 @@
       1, png_doublep_NULL, png_doublep_NULL);
 #endif
 
-   return ((png_structp)png_ptr);
+#ifdef PNG_SETJMP_SUPPORTED
+/* Applications that neglect to set up their own setjmp() and then encounter
+   a png_error() will longjmp here.  Since the jmpbuf is then meaningless we
+   abort instead of returning. */
+#ifdef USE_FAR_KEYWORD
+   if (setjmp(jmpbuf))
+      PNG_ABORT();
+   png_memcpy(png_ptr->jmpbuf,jmpbuf,sizeof(jmp_buf));
+#else
+   if (setjmp(png_ptr->jmpbuf))
+      PNG_ABORT();
+#endif
+#endif
+   return (png_ptr);
 }
 
 /* Initialize png_ptr structure, and allocate any memory needed */
@@ -542,7 +555,6 @@
    png_write_init_2(png_ptr, "1.0.6 or earlier", 0, 0);
 }
 
-#undef png_write_init_2
 void PNGAPI
 png_write_init_2(png_structp png_ptr, png_const_charp user_png_ver,
    png_size_t png_struct_size, png_size_t png_info_size)
diff --git a/pngwtran.c b/pngwtran.c
index dd90031..2eeb294 100644
--- a/pngwtran.c
+++ b/pngwtran.c
@@ -1,7 +1,7 @@
 
 /* pngwtran.c - transforms the data in a row for PNG writers
  *
- * libpng 1.0.13 - April 15, 2002
+ * libpng 1.0.14 - July 8, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
diff --git a/pngwutil.c b/pngwutil.c
index 9c65f95..d08af9f 100644
--- a/pngwutil.c
+++ b/pngwutil.c
@@ -1,7 +1,7 @@
 
 /* pngwutil.c - utilities to write a PNG file
  *
- * libpng 1.0.13 - April 15, 2002
+ * libpng 1.0.14 - July 8, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2002 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
diff --git a/projects/msvc/README.txt b/projects/msvc/README.txt
index c0436f5..d5e6edf 100644
--- a/projects/msvc/README.txt
+++ b/projects/msvc/README.txt
@@ -1,5 +1,5 @@
 Microsoft Developer Studio Build File, Format Version 6.00 for
-libpng 1.0.13 (April 15, 2002) and zlib
+libpng 1.0.14 (July 8, 2002) and zlib
 
 Copyright (C) 2000 Simon-Pierre Cadieux
 For conditions of distribution and use, see copyright notice in png.h
diff --git a/projects/msvc/png32ms.def b/projects/msvc/png32ms.def
index 52d2731..1130342 100644
--- a/projects/msvc/png32ms.def
+++ b/projects/msvc/png32ms.def
@@ -6,7 +6,7 @@
 DESCRIPTION "PNG image compression library for Windows"
 
 EXPORTS
-;Version 1.0.13
+;Version 1.0.14
   png_build_grayscale_palette  @1
   png_check_sig        @2
   png_chunk_error      @3
diff --git a/projects/netware.txt b/projects/netware.txt
index d693042..6323b3c 100644
--- a/projects/netware.txt
+++ b/projects/netware.txt
@@ -1,6 +1,6 @@
 A set of project files is available for Netware.  Get
-libpng-1.0.13-project-netware.zip from a libpng distribution
+libpng-1.0.14-project-netware.zip from a libpng distribution
 site such as http://libpng.sourceforge.net
 
 Put the zip file in this directory (projects) and then run
-"unzip -a libpng-1.0.13-project-netware.zip"
+"unzip -a libpng-1.0.14-project-netware.zip"
diff --git a/projects/wince.txt b/projects/wince.txt
index ad89533..0be6ef9 100644
--- a/projects/wince.txt
+++ b/projects/wince.txt
@@ -1,6 +1,6 @@
 A set of project files is available for WinCE.  Get
-libpng-1.0.13-project-wince.zip from a libpng distribution
+libpng-1.0.14-project-wince.zip from a libpng distribution
 site such as http://libpng.sourceforge.net
 
 Put the zip file in this directory (projects) and then run
-"unzip -a libpng-1.0.13-project-wince.zip"
+"unzip -a libpng-1.0.14-project-wince.zip"
diff --git a/scripts/libpng-config-body.in b/scripts/libpng-config-body.in
new file mode 100755
index 0000000..8995df8
--- /dev/null
+++ b/scripts/libpng-config-body.in
@@ -0,0 +1,70 @@
+
+usage()
+{
+    cat <<EOF
+Usage: libpng-config [OPTION] ...
+
+Known values for OPTION are:
+
+  --prefix              print libpng prefix
+  --libs                print library linking information
+  --cflags              print compiler flags
+  --cppflags            print pre-processor flags
+  --ldflags             print loader flags
+  --rpath               print path to shared library
+  --help                display this help and exit
+  --version             output version information
+EOF
+
+    exit $1
+}
+
+if test $# -eq 0; then
+    usage 1
+fi
+
+while test $# -gt 0; do
+    case "$1" in
+
+    --prefix)
+        echo ${prefix}
+        ;;
+
+    --version)
+        echo ${version}
+        exit 0
+        ;;
+
+    --help)
+        usage 0
+        ;;
+
+    --cflags)
+        echo ${cflags}
+        ;;
+
+    --cppflags)
+        echo ${cppflags}
+        ;;
+
+    --libs)
+        echo ${libs}
+        ;;
+
+    --rpath)
+        echo ${rpath}
+        ;;
+
+    --ldflags)
+        echo ${ldflags}
+        ;;
+
+    *)
+        usage
+        exit 1
+        ;;
+    esac
+    shift
+done
+
+exit 0
diff --git a/scripts/libpng-config-head.in b/scripts/libpng-config-head.in
new file mode 100755
index 0000000..ed66ca9
--- /dev/null
+++ b/scripts/libpng-config-head.in
@@ -0,0 +1,18 @@
+#! /bin/sh
+
+# libpng-config
+# provides configuration info for libpng.
+
+# Copyright (C) 2002 Glenn Randers-Pehrson
+# For conditions of distribution and use, see copyright notice in png.h
+
+# Modeled after libxml-config.
+
+version=1.0.14
+prefix=""
+cppflags=""
+cflags=""
+ldflags=""
+libs=""
+rpath=""
+
diff --git a/scripts/libpng.pc.in b/scripts/libpng.pc.in
index bcaa155..e4b3ce3 100644
--- a/scripts/libpng.pc.in
+++ b/scripts/libpng.pc.in
@@ -6,6 +6,6 @@
 
 Name: libpng10
 Description: Loads and saves PNG files
-Version: 1.0.13
-Libs: -L${libdir} -lpng10
+Version: 1.0.14
+Libs: -L${libdir} -lpng10 -lz -lm
 Cflags: -I${includedir}/libpng10
diff --git a/scripts/makefile.32sunu b/scripts/makefile.32sunu
index eda3e8f..11277fa 100644
--- a/scripts/makefile.32sunu
+++ b/scripts/makefile.32sunu
@@ -1,4 +1,4 @@
-# makefile for libpng on Solaris 2.x with gcc
+# makefile for libpng on Solaris 2.x with cc
 # Contributed by William L. Sebok, based on makefile.linux
 # Copyright (C) 2002 Glenn Randers-Pehrson
 # Copyright (C) 1998 Greg Roelofs
@@ -33,11 +33,28 @@
 
 LIBNAME=libpng10
 PNGMAJ = 0
-PNGMIN = 1.0.13
+PNGMIN = 1.0.14
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 INCPATH=$(prefix)/include
 LIBPATH=$(prefix)/lib
+MANPATH=$(prefix)/man
+BINPATH=$(prefix)/bin
+
+# override DESTDIR= on the make install command line to easily support
+# installing into a temporary location.  Example:
+#
+#    make install DESTDIR=/tmp/build/libpng
+#
+# If you're going to install into a temporary location
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
+# you execute make install.
+DESTDIR=
+
+DB=$(DESTDIR)$(BINPATH)
+DI=$(DESTDIR)$(INCPATH)
+DL=$(DESTDIR)$(LIBPATH)
+DM=$(DESTDIR)$(MANPATH)
 
 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
 	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
@@ -50,12 +67,25 @@
 .c.pic.o:
 	$(CC) -c $(CFLAGS) -KPIC -o $@ $*.c
 
-all: libpng.a $(LIBNAME).so pngtest
+all: libpng.a $(LIBNAME).so pngtest libpng.pc libpng-config
 
 libpng.a: $(OBJS)
 	ar rc $@ $(OBJS)
 	$(RANLIB) $@
 
+libpng.pc:
+	cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
+
+libpng-config:
+	( cat scripts/libpng-config-head.in; \
+	echo prefix=\"$(prefix)\"; \
+	echo cppflags=\"-I$(INCPATH)/$(LIBNAME)\"; \
+	echo cflags=\"-xtarget=ultra\"; \
+	echo ldflags=\"-xtarget=ultra -L$(LIBPATH) -R$(LIBPATH)\"; \
+	echo libs=\"-lpng10 -lz -lm\"; \
+	cat scripts/libpng-config-body.in ) > libpng-config
+	chmod +x libpng-config
+
 $(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ)
 	ln -f -s $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so
 
@@ -85,42 +115,78 @@
 	./pngtest
 
 install-headers: png.h pngconf.h
-	-@if [ ! -d $(INCPATH) ]; then mkdir $(INCPATH); fi
-	-@if [ ! -d $(INCPATH)/$(LIBNAME) ]; then mkdir $(INCPATH)/$(LIBNAME); fi
-	cp png.h pngconf.h $(INCPATH)/$(LIBNAME)
-	chmod 644 $(INCPATH)/$(LIBNAME)/png.h $(INCPATH)/$(LIBNAME)/pngconf.h
-	-@/bin/rm -f $(INCPATH)/png.h $(INCPATH)/pngconf.h
-	-@/bin/rm $(INCPATH)/libpng
-	ln -f -s $(INCPATH)/$(LIBNAME) $(INCPATH)/libpng
+	-@if [ ! -d $(DI) ]; then mkdir $(DI); fi
+	-@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
+	cp png.h pngconf.h $(DI)/$(LIBNAME)
+	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
+	-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
+	-@/bin/rm $(DI)/libpng
+	(cd $(DI); ln -f -s $(LIBNAME) libpng; ln -f -s $(LIBNAME)/* .)
 
 install-static: install-headers libpng.a
-	-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
-	cp libpng.a $(LIBPATH)/$(LIBNAME).a
-	chmod 644 $(LIBPATH)/$(LIBNAME).a
-	-@/bin/rm -f $(LIBPATH)/libpng.a
-	ln -f -s $(LIBPATH)/$(LIBNAME).a $(LIBPATH)/libpng.a
+	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
+	cp libpng.a $(DL)/$(LIBNAME).a
+	chmod 644 $(DL)/$(LIBNAME).a
+	-@/bin/rm -f $(DL)/libpng.a
+	(cd $(DL); ln -f -s $(LIBNAME).a libpng.a)
 
-install-shared: install-headers $(LIBNAME).so.$(PNGVER)
-	-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
-	-@/bin/rm -f $(LIBPATH)/$(LIBNAME).so.$(PNGMAJ)* $(LIBPATH)/$(LIBNAME).so
-	-@/bin/rm -f $(LIBPATH)/libpng.so
-	-@/bin/rm -f $(LIBPATH)/libpng.so.2
-	-@/bin/rm -f $(LIBPATH)/libpng.so.2.*
-	cp $(LIBNAME).so.$(PNGVER) $(LIBPATH)
-	chmod 755 $(LIBPATH)/$(LIBNAME).so.$(PNGVER)
-	(cd $(LIBPATH); \
+install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc
+	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
+	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* $(DL)/$(LIBNAME).so
+	-@/bin/rm -f $(DL)/libpng.so
+	-@/bin/rm -f $(DL)/libpng.so.2
+	-@/bin/rm -f $(DL)/libpng.so.2.*
+	cp $(LIBNAME).so.$(PNGVER) $(DL)
+	chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER)
+	(cd $(DL); \
 	ln -f -s $(LIBNAME).so.$(PNGVER) libpng.so; \
 	ln -f -s $(LIBNAME).so.$(PNGVER) libpng.so.2; \
 	ln -f -s $(LIBNAME).so.$(PNGVER) libpng.so.2.$(PNGMIN); \
 	ln -f -s $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \
 	ln -f -s $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so)
-	-@if [ ! -d $(LIBPATH)/pkgconfig ]; then mkdir $(LIBPATH)/pkgconfig; fi
-	cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
-	cp libpng.pc $(LIBPATH)/pkgconfig/libpng10.pc
-	chmod 644 $(LIBPATH)/pkgconfig/libpng10.pc
+	-@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig
+	-@/bin/rm -f $(DL)/pkgconfig/libpng10.pc
+	-@/bin/rm -f $(DL)/pkgconfig/libpng.pc
+	cp libpng.pc $(DL)/pkgconfig/libpng10.pc
+	chmod 644 $(DL)/pkgconfig/libpng10.pc
+	(cd $(DL)/pkgconfig; ln -f -s libpng10.pc libpng.pc)
+
+install-man: libpng.3 libpngpf.3 png.5
+	-@if [ ! -d $(DM) ]; then mkdir $(DM); fi
+	-@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi
+	-@/bin/rm -f $(DM)/man3/libpng.3
+	-@/bin/rm -f $(DM)/man3/libpngpf.3
+	cp libpng.3 $(DM)/man3
+	cp libpngpf.3 $(DM)/man3
+	-@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi
+	-@/bin/rm -f $(DM)/man5/png.5
+	cp png.5 $(DM)/man5
+
+install-config: libpng-config
+	-@if [ ! -d $(DB) ]; then mkdir $(DB); fi
+	-@/bin/rm -f $(DB)/libpng-config
+	-@/bin/rm -f $(DB)/libpng10-config
+	cp libpng-config $(DB)/libpng10-config
+	chmod 755 $(DB)/libpng10-config
+	(cd $(DB); ln -sf libpng10-config libpng-config)
+
+install: install-static install-shared install-man install-config
+
+# If you installed in $(DESTDIR), test-installed won't work until you
+# move the library to its final location.
+
+test-installed:
+	echo
+	echo Testing installed dynamic shared library.
+	$(CC) $(SUN_CC_FLAGS) -I$(ZLIBINC) \
+	   `$(BINPATH)/libpng10-config --cppflags --cflags` pngtest.c \
+	   -o pngtesti `$(BINPATH)/libpng10-config --ldflags --libs` \
+	   $(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB)
+	./pngtesti pngtest.png
 
 clean:
-	/bin/rm -f *.o libpng.a $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* pngtest pngout.png
+	/bin/rm -f *.o libpng.a pngtest pngtesti pngout.png libpng.pc \
+	libpng-config $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)*
 
 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
 writelock:
diff --git a/scripts/makefile.64sunu b/scripts/makefile.64sunu
index 60b8f53..9c377ec 100644
--- a/scripts/makefile.64sunu
+++ b/scripts/makefile.64sunu
@@ -1,4 +1,4 @@
-# makefile for libpng on Solaris 2.x with gcc
+# makefile for libpng on Solaris 2.x with cc
 # Contributed by William L. Sebok, based on makefile.linux
 # Copyright (C) 2002 Glenn Randers-Pehrson
 # Copyright (C) 1998 Greg Roelofs
@@ -33,11 +33,28 @@
 
 LIBNAME=libpng10
 PNGMAJ = 0
-PNGMIN = 1.0.13
+PNGMIN = 1.0.14
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 INCPATH=$(prefix)/include
 LIBPATH=$(prefix)/lib
+MANPATH=$(prefix)/man
+BINPATH=$(prefix)/bin
+
+# override DESTDIR= on the make install command line to easily support
+# installing into a temporary location.  Example:
+#
+#    make install DESTDIR=/tmp/build/libpng
+#
+# If you're going to install into a temporary location
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
+# you execute make install.
+DESTDIR=
+
+DB=$(DESTDIR)$(BINPATH)
+DI=$(DESTDIR)$(INCPATH)
+DL=$(DESTDIR)$(LIBPATH)
+DM=$(DESTDIR)$(MANPATH)
 
 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
 	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
@@ -50,12 +67,25 @@
 .c.pic.o:
 	$(CC) -c $(CFLAGS) -KPIC -o $@ $*.c
 
-all: libpng.a $(LIBNAME).so pngtest
+all: libpng.a $(LIBNAME).so pngtest libpng.pc libpng-config
 
 libpng.a: $(OBJS)
 	ar rc $@ $(OBJS)
 	$(RANLIB) $@
 
+libpng.pc:
+	cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
+
+libpng-config:
+	( cat scripts/libpng-config-head.in; \
+	echo prefix=\"$(prefix)\"; \
+	echo cppflags=\"-I$(INCPATH)/$(LIBNAME)\"; \
+	echo cflags=\"-xtarget=ultra -xarch=v9\"; \
+	echo ldflags=\"-xtarget=ultra -xarch=v9 -L$(LIBPATH) -R$(LIBPATH)\"; \
+	echo libs=\"-lpng10 -lz -lm\"; \
+	cat scripts/libpng-config-body.in ) > libpng-config
+	chmod +x libpng-config
+
 $(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ)
 	ln -f -s $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so
 
@@ -85,42 +115,78 @@
 	./pngtest
 
 install-headers: png.h pngconf.h
-	-@if [ ! -d $(INCPATH) ]; then mkdir $(INCPATH); fi
-	-@if [ ! -d $(INCPATH)/$(LIBNAME) ]; then mkdir $(INCPATH)/$(LIBNAME); fi
-	cp png.h pngconf.h $(INCPATH)/$(LIBNAME)
-	chmod 644 $(INCPATH)/$(LIBNAME)/png.h $(INCPATH)/$(LIBNAME)/pngconf.h
-	-@/bin/rm -f $(INCPATH)/png.h $(INCPATH)/pngconf.h
-	-@/bin/rm $(INCPATH)/libpng
-	ln -f -s $(INCPATH)/$(LIBNAME) $(INCPATH)/libpng
+	-@if [ ! -d $(DI) ]; then mkdir $(DI); fi
+	-@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
+	cp png.h pngconf.h $(DI)/$(LIBNAME)
+	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
+	-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
+	-@/bin/rm $(DI)/libpng
+	(cd $(DI); ln -f -s $(LIBNAME) libpng; ln -f -s $(LIBNAME)/* .)
 
 install-static: install-headers libpng.a
-	-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
-	cp libpng.a $(LIBPATH)/$(LIBNAME).a
-	chmod 644 $(LIBPATH)/$(LIBNAME).a
-	-@/bin/rm -f $(LIBPATH)/libpng.a
-	ln -f -s $(LIBPATH)/$(LIBNAME).a $(LIBPATH)/libpng.a
+	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
+	cp libpng.a $(DL)/$(LIBNAME).a
+	chmod 644 $(DL)/$(LIBNAME).a
+	-@/bin/rm -f $(DL)/libpng.a
+	(cd $(DL); ln -f -s $(LIBNAME).a libpng.a)
 
-install-shared: install-headers $(LIBNAME).so.$(PNGVER)
-	-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
-	-@/bin/rm -f $(LIBPATH)/$(LIBNAME).so.$(PNGMAJ)* $(LIBPATH)/$(LIBNAME).so
-	-@/bin/rm -f $(LIBPATH)/libpng.so
-	-@/bin/rm -f $(LIBPATH)/libpng.so.2
-	-@/bin/rm -f $(LIBPATH)/libpng.so.2.*
-	cp $(LIBNAME).so.$(PNGVER) $(LIBPATH)
-	chmod 755 $(LIBPATH)/$(LIBNAME).so.$(PNGVER)
-	(cd $(LIBPATH); \
-	ln -sf $(LIBNAME).so.$(PNGVER) libpng.so; \
+install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc
+	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
+	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* $(DL)/$(LIBNAME).so
+	-@/bin/rm -f $(DL)/libpng.so
+	-@/bin/rm -f $(DL)/libpng.so.2
+	-@/bin/rm -f $(DL)/libpng.so.2.*
+	cp $(LIBNAME).so.$(PNGVER) $(DL)
+	chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER)
+	(cd $(DL); \
+	ln -f -s $(LIBNAME).so.$(PNGVER) libpng.so; \
 	ln -f -s $(LIBNAME).so.$(PNGVER) libpng.so.2; \
 	ln -f -s $(LIBNAME).so.$(PNGVER) libpng.so.2.$(PNGMIN); \
 	ln -f -s $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \
 	ln -f -s $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so)
-	-@if [ ! -d $(LIBPATH)/pkgconfig ]; then mkdir $(LIBPATH)/pkgconfig; fi
-	cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
-	cp libpng.pc $(LIBPATH)/pkgconfig/libpng10.pc
-	chmod 644 $(LIBPATH)/pkgconfig/libpng10.pc
+	-@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi
+	-@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
+	-@/bin/rm -f $(DL)/pkgconfig/libpng.pc
+	cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
+	chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
+	(cd $(DL)/pkgconfig; ln -f -s $(LIBNAME).pc libpng.pc)
+
+install-man: libpng.3 libpngpf.3 png.5
+	-@if [ ! -d $(DM) ]; then mkdir $(DM); fi
+	-@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi
+	-@/bin/rm -f $(DM)/man3/libpng.3
+	-@/bin/rm -f $(DM)/man3/libpngpf.3
+	cp libpng.3 $(DM)/man3
+	cp libpngpf.3 $(DM)/man3
+	-@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi
+	-@/bin/rm -f $(DM)/man5/png.5
+	cp png.5 $(DM)/man5
+
+install-config: libpng-config
+	-@if [ ! -d $(DB) ]; then mkdir $(DB); fi
+	-@/bin/rm -f $(DB)/libpng-config
+	-@/bin/rm -f $(DB)/$(LIBNAME)-config
+	cp libpng-config $(DB)/$(LIBNAME)-config
+	chmod 755 $(DB)/$(LIBNAME)-config
+	(cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
+
+install: install-static install-shared install-man install-config
+
+# If you installed in $(DESTDIR), test-installed won't work until you
+# move the library to its final location.
+
+test-installed:
+	echo
+	echo Testing installed dynamic shared library.
+	$(CC) $(SUN_CC_FLAGS) -I$(ZLIBINC) \
+	   `$(BINPATH)/libpng10-config --cppflags --cflags` pngtest.c \
+	   -o pngtesti `$(BINPATH)/libpng10-config --ldflags --libs` \
+	   $(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB)
+	./pngtesti pngtest.png
 
 clean:
-	/bin/rm -f *.o libpng.a $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* pngtest pngout.png
+	/bin/rm -f *.o libpng.a pngtest pngtesti pngout.png libpng.pc \
+	libpng-config $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)*
 
 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
 writelock:
diff --git a/scripts/makefile.aix b/scripts/makefile.aix
index bfbc53c..9d7c8e0 100644
--- a/scripts/makefile.aix
+++ b/scripts/makefile.aix
@@ -1,7 +1,8 @@
 # makefile for libpng using gcc (generic, static library)
-# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
+# Copyright (C) 2002 Glenn Randers-Pehrson
 # Copyright (C) 2000 Cosmin Truta
 # Copyright (C) 2000 Marc O. Gloor (AIX support added, from makefile.gcc)
+# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
 # For conditions of distribution and use, see copyright notice in png.h
 
 # Location of the zlib library and include files
@@ -15,16 +16,27 @@
 RANLIB = ranlib
 RM = rm -f
 
-# read libpng.txt or png.h to see why PNGMAJ is 0.  You should not
-# have to change it.
 PNGMAJ = 0
-PNGMIN = 1.0.13
+PNGMIN = 1.0.14
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 prefix=/usr/local
 INCPATH=$(prefix)/include
 LIBPATH=$(prefix)/lib
 
+# override DESTDIR= on the make install command line to easily support
+# installing into a temporary location.  Example:
+#
+#    make install DESTDIR=/tmp/build/libpng
+#
+# If you're going to install into a temporary location
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
+# you execute make install.
+DESTDIR=
+
+DI=$(DESTDIR)/$(INCPATH)
+DL=$(DESTDIR)/$(LIBPATH)
+
 CDEBUG = -g -DPNG_DEBUG=5
 LDDEBUG =
 CRELEASE = -O2
@@ -56,14 +68,16 @@
 	$(LD) -o $@ pngtest$(O) $(LDFLAGS)
 
 install: libpng.a
-	-@if [ ! -d $(INCPATH)  ]; then mkdir $(INCPATH); fi
-	-@if [ ! -d $(INCPATH)/libpng  ]; then mkdir $(INCPATH)/libpng; fi
-	-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
-	-@rm $(INCPATH)/png.h
-	-@rm $(INCPATH)/pngconf.h
-	cp png.h pngconf.h $(INCPATH)/libpng
-	chmod 644 $(INCPATH)/libpng/png.h $(INCPATH)/libpng/pngconf.h
-	cp libpng.a $(LIBPATH)
+	-@if [ ! -d $(DI)  ]; then mkdir $(DI); fi
+	-@if [ ! -d $(DI)/libpng  ]; then mkdir $(DI)/libpng; fi
+	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
+	-@rm $(DI)/png.h
+	-@rm $(DI)/pngconf.h
+	cp png.h pngconf.h $(DI)/libpng
+	chmod 644 $(DI)/libpng/png.h \
+	$(DI)/libpng/pngconf.h
+	(cd $(DI); ln -f -s libpng/* .)
+	cp libpng.a $(DL)
 
 clean:
 	/bin/rm -f *.o libpng.a pngtest pngout.png
diff --git a/scripts/makefile.atari b/scripts/makefile.atari
index c51ad6e..9566d5d 100644
--- a/scripts/makefile.atari
+++ b/scripts/makefile.atari
@@ -1,4 +1,5 @@
 # makefile for libpng
+# Copyright (C) 2002 Glenn Randers-Pehrson
 # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
 # For conditions of distribution and use, see copyright notice in png.h
 # modified for LC56/ATARI assumes libz.lib is in same dir and uses default
@@ -10,6 +11,18 @@
 
 # where make install puts libpng.a and png.h
 prefix=/usr/local
+INCPATH=$(prefix)/include
+LIBPATH=$(prefix)/lib
+
+# override DESTDIR= on the make install command line to easily support
+# installing into a temporary location.  Example:
+#
+#    make install DESTDIR=/tmp/build/libpng
+#
+# If you're going to install into a temporary location
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
+# you execute make install.
+DESTDIR=
 
 OBJS = $(LBR)(png.o) $(LBR)(pngset.o) $(LBR)(pngget.o) $(LBR)(pngrutil.o)\
 	$(LBR)(pngtrans.o) $(LBR)(pngwutil.o)\
@@ -25,12 +38,14 @@
 	$(CC) $(CFLAGS) $(LDFLAGS) -o$@ pngtest.o
 
 install: libpng.a
-	-@mkdir $(prefix)/include
-	-@mkdir $(prefix)/include/libpng
-	-@mkdir $(prefix)/lib
-	-@rm -f $(prefix)/include/png.h
-	-@rm -f $(prefix)/include/pngconf.h
-	cp png.h $(prefix)/include/libpng
-	cp pngconf.h $(prefix)/include/libpng
-	chmod 644 $(prefix)/include/libpng/png.h
-	chmod 644 $(prefix)/include/libpng/pngconf.h
+	-@mkdir $(DESTDIR)$(INCPATH)
+	-@mkdir $(DESTDIR)$(INCPATH)/libpng
+	-@mkdir $(DESTDIR)$(LIBPATH)
+	-@rm -f $(DESTDIR)$(INCPATH)/png.h
+	-@rm -f $(DESTDIR)$(INCPATH)/pngconf.h
+	cp png.h $(DESTDIR)$(INCPATH)/libpng
+	cp pngconf.h $(DESTDIR)$(INCPATH)/libpng
+	chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h
+	chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h
+	(cd $(DESTDIR)$(INCPATH); ln -f -s $(LIBNAME) libpng; \
+	ln -f -s $(LIBNAME)/* .)
diff --git a/scripts/makefile.beos b/scripts/makefile.beos
index d589a7c..e72a41b 100644
--- a/scripts/makefile.beos
+++ b/scripts/makefile.beos
@@ -11,10 +11,8 @@
 ZLIBLIB=/usr/local/lib
 ZLIBINC=/usr/local/include
 
-# read libpng.txt or png.h to see why PNGMAJ is 0.  You should not
-# have to change it.
 PNGMAJ = 0
-PNGMIN = 1.0.13
+PNGMIN = 1.0.14
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 ALIGN=
@@ -39,6 +37,24 @@
 prefix=/usr/local
 INCPATH=$(prefix)/include
 LIBPATH=$(prefix)/lib
+MANPATH=$(prefix)/man
+BINPATH=$(prefix)/bin
+
+# override DESTDIR= on the make install command line to easily support
+# installing into a temporary location.  Example:
+#
+#    make install DESTDIR=/tmp/build/libpng
+#
+# If you're going to install into a temporary location
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
+# you execute make install.
+DESTDIR=
+
+DB=$(DESTDIR)$(BINPATH)
+DI=$(DESTDIR)$(INCPATH)
+DL=$(DESTDIR)$(LIBPATH)
+DM=$(DESTDIR)$(MANPATH)
+
 LIBNAME=libpng10
 
 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
@@ -49,12 +65,25 @@
 
 .SUFFIXES:      .c .o
 
-all: libpng.a $(LIBNAME).so pngtest
+all: libpng.a $(LIBNAME).so pngtest libpng.pc libpng-config
 
 libpng.a: $(OBJS)
 	ar rc $@ $(OBJS)
 	$(RANLIB) $@
 
+libpng.pc:
+	cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
+
+libpng-config:
+	( cat scripts/libpng-config-head.in; \
+	echo prefix=\"$(prefix)\"; \
+	echo cppflags=\"-I$(INCPATH)/$(LIBNAME)\"; \
+	echo cflags=\"\"; \
+	echo ldflags=\"-Wl,-soname=$(LIBNAME).so.$(PNGMAJ)\"; \
+	echo libs=\"-lpng10 -lz -lm\"; \
+	cat scripts/libpng-config-body.in ) > libpng-config
+	chmod +x libpng-config
+
 $(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ)
 	ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so
 	cp $(LIBNAME).so* /boot/home/config/lib
@@ -74,45 +103,76 @@
 	./pngtest
 
 install-headers: png.h pngconf.h
-	-@if [ ! -d $(INCPATH) ]; then mkdir $(INCPATH); fi
-	-@if [ ! -d $(INCPATH)/$(LIBNAME) ]; then mkdir $(INCPATH)/$(LIBNAME); fi
-	cp png.h pngconf.h $(INCPATH)/$(LIBNAME)
-	chmod 644 $(INCPATH)/$(LIBNAME)/png.h $(INCPATH)/$(LIBNAME)/pngconf.h
-	-@/bin/rm -f $(INCPATH)/png.h $(INCPATH)/pngconf.h
-	-@/bin/rm -f $(INCPATH)/libpng
-	ln -sf $(INCPATH)/$(LIBNAME) $(INCPATH)/libpng
+	-@if [ ! -d $(DI) ]; then mkdir $(DI); fi
+	-@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
+	cp png.h pngconf.h $(DI)/$(LIBNAME)
+	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
+	-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
+	-@/bin/rm -f $(DI)/libpng
+	(cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
 
 install-static: install-headers libpng.a
-	-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
-	cp libpng.a $(LIBPATH)/$(LIBNAME).a
-	chmod 644 $(LIBPATH)/$(LIBNAME).a
-	-@/bin/rm -f $(LIBPATH)/libpng.a
-	ln -sf $(LIBPATH)/$(LIBNAME).a $(LIBPATH)/libpng.a
+	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
+	cp libpng.a $(DL)/$(LIBNAME).a
+	chmod 644 $(DL)/$(LIBNAME).a
+	-@/bin/rm -f $(DL)/libpng.a
+	(cd $(DL); ln -sf $(LIBNAME).a libpng.a)
 
-install-shared: install-headers $(LIBNAME).so.$(PNGVER)
-	-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
-	-@/bin/rm -f $(LIBPATH)/$(LIBNAME).so.$(PNGMAJ)* $(LIBPATH)/$(LIBNAME).so
-	-@/bin/rm -f $(LIBPATH)/libpng.so
-	-@/bin/rm -f $(LIBPATH)/libpng.so.2
-	-@/bin/rm -f $(LIBPATH)/libpng.so.2.*
-	cp $(LIBNAME).so.$(PNGVER) $(LIBPATH)
-	chmod 755 $(LIBPATH)/$(LIBNAME).so.$(PNGVER)
-	(cd $(LIBPATH); \
+install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc
+	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
+	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* $(DL)/$(LIBNAME).so
+	-@/bin/rm -f $(DL)/libpng.so
+	-@/bin/rm -f $(DL)/libpng.so.2
+	-@/bin/rm -f $(DL)/libpng.so.2.*
+	cp $(LIBNAME).so.$(PNGVER) $(DL)
+	chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER)
+	(cd $(DL); \
 	ln -sf $(LIBNAME).so.$(PNGVER) libpng.so; \
 	ln -sf $(LIBNAME).so.$(PNGVER) libpng.so.2; \
 	ln -sf $(LIBNAME).so.$(PNGVER) libpng.so.2.$(PNGMIN); \
 	ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \
 	ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so)
-	-@if [ ! -d $(LIBPATH)/pkgconfig ]; then mkdir $(LIBPATH)/pkgconfig; fi
-	cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
-	cp libpng.pc $(LIBPATH)/pkgconfig/libpng10.pc
-	chmod 644 $(LIBPATH)/pkgconfig/libpng10.pc
+	-@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi
+	-@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
+	-@/bin/rm -f $(DL)/pkgconfig/libpng.pc
+	cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
+	chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
+	(cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc)
 
-install: install-static install-shared
+install-man: libpng.3 libpngpf.3 png.5
+	-@if [ ! -d $(DM) ]; then mkdir $(DM); fi
+	-@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi
+	-@/bin/rm -f $(DM)/man3/libpng.3
+	-@/bin/rm -f $(DM)/man3/libpngpf.3
+	cp libpng.3 $(DM)/man3
+	cp libpngpf.3 $(DM)/man3
+	-@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi
+	-@/bin/rm -f $(DM)/man5/png.5
+	cp png.5 $(DM)/man5
+
+install-config: libpng-config
+	-@if [ ! -d $(DB) ]; then mkdir $(DB); fi
+	-@/bin/rm -f $(DB)/libpng-config
+	-@/bin/rm -f $(DB)/$(LIBNAME)-config
+	cp libpng-config $(DB)/$(LIBNAME)-config
+	chmod 755 $(DB)/$(LIBNAME)-config
+	(cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
+
+install: install-static install-shared install-man install-config
+
+# If you installed in $(DESTDIR), test-installed won't work until you
+# move the library to its final location.
+
+test-installed:
+	$(CC) $(CFLAGS) \
+	   `$(BINPATH)/libpng10-config --cppflags --cflags` pngtest.c \
+	   -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \
+	   -o pngtesti `$(BINPATH)/libpng10-config --ldflags --libs`
+	./pngtesti pngtest.png
 
 clean:
-	/bin/rm -f *.o libpng.a $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* \
-	pngtest pngout.png
+	/bin/rm -f *.o libpng.a pngtest pngout.png libpng.pc libpng-config \
+	$(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* pngtesti
 
 # DO NOT DELETE THIS LINE -- make depend depends on it.
 
diff --git a/scripts/makefile.cygwin b/scripts/makefile.cygwin
index 1454bb1..dae82cb 100644
--- a/scripts/makefile.cygwin
+++ b/scripts/makefile.cygwin
@@ -1,15 +1,39 @@
 # makefile for cygwin on x86
-#   builds both dll (with import lib) and static lib versions
+#   Builds both dll (with import lib) and static lib versions
 #   of the library, and builds two copies of pngtest: one
 #   statically linked and one dynamically linked.
 #
+# Copyright (C) 2002 Soren Anderson, Charles Wilson, and Glenn Randers-Pehrson
 #   based on makefile for linux-elf w/mmx by:
 # Copyright (C) 1998-2000 Greg Roelofs
 # Copyright (C) 1996, 1997 Andreas Dilger
 # For conditions of distribution and use, see copyright notice in png.h
 
+# This makefile intends to support building outside the src directory
+# if desired. When invoking it, specify an argument to SRCDIR on the
+# command line that points to the top of the directory where your source
+# is located.
+
+ifdef SRCDIR
+VPATH = $(SRCDIR)
+else
+SRCDIR = .
+endif
+
+# Override DESTDIR= on the make install command line to easily support
+# installing into a temporary location.  Example:
+#
+#    make install DESTDIR=/tmp/build/libpng
+#
+# If you're going to install into a temporary location
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
+# you execute make install.
+
+DESTDIR=
+
 # To enable assembler optimizations, add '-DPNG_USE_PNGGCCRD' to
-# $CFLAGS, and include pnggccrd.o in $OBJS, below.
+# $CFLAGS, and include pnggccrd.o in $OBJS, below, and in the dependency
+# list at the bottom of this makefile.
 
 CC=gcc
 ifdef MINGW
@@ -17,12 +41,15 @@
 MINGW_LDFLAGS=-mno-cygwin -L/usr/lib/mingw
 endif
 
-# where "make install" puts libpng.a, libpng.so*, png.h, and pngconf.h
+# Where "make install" puts libpng*.a, *png*.dll, png.h, and pngconf.h
+ifndef prefix
 prefix=/usr
+$(warning You haven't specified a 'prefix=' location. Defaulting to "/usr")
+endif
 
 # Where the zlib library and include files are located
-ZLIBLIB=${prefix}/lib
-ZLIBINC=${prefix}/include
+ZLIBLIB= /usr/lib
+ZLIBINC=
 #ZLIBLIB=../zlib
 #ZLIBINC=../zlib
 
@@ -34,15 +61,25 @@
 	-Wmissing-declarations -Wtraditional -Wcast-align \
 	-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
 
-#CFLAGS=-DPNG_USE_PNGGCCRD -I$(ZLIBINC) -Wall -O3 $(ALIGN) -funroll-loops \
-#        -fomit-frame-pointer  # $(WARNMORE) -g -DPNG_DEBUG=5
-CFLAGS=$(MINGW_CCFLAGS) -I$(ZLIBINC) -Wall -O3 $(ALIGN) -funroll-loops \
-	-fomit-frame-pointer
+### if you use the asm, add pnggccrd.o to the OBJS list
+###
+### if you don't need thread safety, but want the asm accel
+#CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD \
+#	$(addprefix -I,$(ZLIBINC)) -Wall -O3 $(ALIGN) -funroll-loops \
+#	-fomit-frame-pointer)  # $(WARNMORE) -g -DPNG_DEBUG=5
+### if you need thread safety and want (minimal) asm accel
+#CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_USE_PNGGCCRD $(addprefix -I,$(ZLIBINC)) \
+#	-Wall -O3 $(ALIGN) -funroll-loops \
+#	-fomit-frame-pointer)  # $(WARNMORE) -g -DPNG_DEBUG=5
+### Normal (non-asm) compilation
+CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \
+        -Wall -O3 $(ALIGN) -funroll-loops \
+	-fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5
 
+LIBNAME = libpng10
 PNGMAJ = 0
-#PNGDLL = $10
-PNGMIN = 1.0.13
-PNGMIN_BASE = 1.0.13
+PNGDLL = 10
+PNGMIN = 1.0.14
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 SHAREDLIB=cygpng$(PNGDLL).dll
@@ -52,19 +89,28 @@
 LIBS=$(SHAREDLIB) $(STATLIB)
 EXE=.exe
 
-LDFLAGS=-L. $(MINGW_LDFLAGS) -L$(ZLIBLIB) -lpng -lz
-LDSFLAGS=-shared -L.  $(MINGW_LDFLAGS) -Wl,--enable-auto-image-base
-LDEXTRA=-Wl,--out-implib=$(IMPLIB) $(SHAREDDEF)
+LDFLAGS=$(strip -L. $(MINGW_LDFLAGS) -lpng $(addprefix -L,$(ZLIBLIB)) -lz)
+LDSFLAGS=$(strip -shared -L.  $(MINGW_LDFLAGS) -Wl,--export-all)
+LDEXTRA=-Wl,--out-implib=$(IMPLIB) $(addprefix -L,$(ZLIBLIB)) -lz
 
+MKDIR=/bin/mkdir -pv
 RANLIB=ranlib
 #RANLIB=echo
 
 INCPATH=$(prefix)/include
 LIBPATH=$(prefix)/lib
+
 BINPATH=$(prefix)/bin
 MANPATH=$(prefix)/man
 MAN3PATH=$(MANPATH)/man3
-DOCPATH=$(prefix)/doc/libpng-$(PNGMIN_BASE)
+MAN5PATH=$(MANPATH)/man5
+
+# cosmetic: shortened strings:
+S =$(SRCDIR)
+D =$(DESTDIR)
+DB =$(D)$(BINPATH)
+DI =$(D)$(INCPATH)
+DL =$(D)$(LIBPATH)
 
 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
 	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
@@ -72,37 +118,60 @@
 
 OBJSDLL = $(OBJS:.o=.pic.o)
 
-.SUFFIXES:      .c .o .pic.o
+.SUFFIXES: .c .o .pic.o
 
 %.o : %.c
-	$(CC) -c $(CFLAGS) -DPNG_STATIC -DZLIB_STATIC -o $@ $<
-
+	$(CC) -c $(CFLAGS) -o $@ $<
+%.pic.o : CFLAGS += -DPNG_BUILD_DLL
 %.pic.o : %.c
-	$(CC) -c $(CFLAGS) -DPNG_BUILD_DLL -o $@ $<
+	$(CC) -c $(CFLAGS) -o $@ $<
 
-all: all-static all-shared
+all: all-static all-shared libpng.pc libpng-config libpng.pc libpng-config
+
+# Make this to verify that "make [...] install" will do what you want.
+buildsetup-tell:
+	@echo  VPATH is set to: \"$(VPATH)\"
+	@echo  prefix is set to: \"$(prefix)\"
+	@echo -e INCPATH,LIBPATH, etc. are set to:'\n' \
+ $(addprefix $(D),$(INCPATH)'\n' $(LIBPATH)'\n' $(BINPATH)'\n' \
+   $(MANPATH)'\n' $(MAN3PATH)'\n' $(MAN5PATH)'\n')'\n'
+
+libpng.pc: scripts/libpng.pc.in
+	@echo -e Making pkg-config file for this libpng installation..'\n' \
+           using PREFIX=\"$(prefix)\"'\n'
+	cat $(S)/scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! | \
+	   sed -e s/-lm// > libpng.pc
+
+libpng-config: scripts/libpng-config-head.in scripts/libpng-config-body.in
+	@echo -e Making $(LIBNAME) libpng-config file for this libpng \
+ installation..'\n' using PREFIX=\"$(prefix)\"'\n'
+	( cat $(S)/scripts/libpng-config-head.in; \
+	echo prefix=\"$(prefix)\"; \
+	echo cppflags=\"-I$(INCPATH)/$(LIBNAME)\"; \
+	echo cflags=\"\"; \
+	echo ldflags=\"-L$(LIBPATH)\"; \
+	echo libs=\"-lpng$(PNGMAJ) -lz\"; \
+	cat $(S)/scripts/libpng-config-body.in ) > libpng-config
+	chmod +x libpng-config
 
 static: all-static
-
 shared: all-shared
-
 all-static: $(STATLIB) pngtest-stat$(EXE)
-
 all-shared: $(SHAREDLIB) pngtest$(EXE)
 
-pnggccrd.o:	png.h pngconf.h
+pnggccrd.o: pnggccrd.c png.h pngconf.h
 	@echo ""
-	@echo '    You can ignore the single "control reaches end of non-void function"'
-	@echo '    warning and multiple "<variable> defined but not used" warnings:'
+	@echo '    You can ignore the "control reaches end of non-void function"'
+	@echo '    warning and "<variable> defined but not used" warnings:'
 	@echo ""
-	$(CC) -c $(CFLAGS) -DPNG_STATIC -DZLIB_STATIC -o $@ $*.c
+	$(CC) -c $(CFLAGS) -o $@ $<
 
-pnggccrd.pic.o:	png.h pngconf.h
+pnggccrd.pic.o:	pnggccrd.c png.h pngconf.h
 	@echo ""
-	@echo '    You can ignore the single "control reaches end of non-void function"'
-	@echo '    warning and multiple "<variable> defined but not used" warnings:'
+	@echo '    You can ignore the "control reaches end of non-void function"'
+	@echo '    warning and "<variable> defined but not used" warnings:'
 	@echo ""
-	$(CC) -c $(CFLAGS) -DPNG_BUILD_DLL -o $@ pnggccrd.c
+	$(CC) -c $(CFLAGS) -DPNG_BUILD_DLL -o $@ $<
 
 $(STATLIB): $(OBJS)
 	ar rc $@ $(OBJS)
@@ -113,7 +182,7 @@
 	sed -e 's/\([^;]*\);/;/' > $@
 
 $(SHAREDLIB): $(OBJSDLL) $(SHAREDDEF)
-	$(CC) $(LDSFLAGS) -o $@ $(LDEXTRA) $(OBJSDLL) -L. -L$(ZLIBLIB) -lz
+	$(CC) $(LDSFLAGS) -o $@ $(OBJSDLL) -L. $(LDEXTRA)
 
 pngtest$(EXE): pngtest.pic.o $(SHAREDLIB)
 	$(CC) $(CFLAGS) $< $(LDFLAGS) -o $@
@@ -125,51 +194,93 @@
 	$(CC) $(CFLAGS) -c $< -o $@
 
 pngtest.o: pngtest.c
-	$(CC) $(CFLAGS) -DPNG_STATIC -DZLIB_STATIC -c $< -o $@
+	$(CC) $(CFLAGS) -c $< -o $@
 
 test: test-static test-shared
 
 test-static: pngtest-stat$(EXE)
-	./pngtest-stat
+	./pngtest-stat $(S)/pngtest.png
 
 test-shared: pngtest$(EXE)
-	./pngtest
+	./pngtest $(S)/pngtest.png
 
-install: install-static install-shared
+install-static: $(STATLIB) install-headers install-man
+	-@if [ ! -d $(DL) ]; then $(MKDIR) $(DL); fi
+	install -m 644 $(STATLIB) $(DL)/$(LIBNAME).a
+	-@rm -f $(DL)/$(STATLIB)
+	(cd $(DL); ln -sf $(LIBNAME).a $(STATLIB))
 
-install-static: $(STATLIB) install-headers install-docs install-man
-	-@if [ ! -d $(LIBPATH) ]; then mkdir -p $(LIBPATH); fi
-	install -m 755 $(STATLIB) $(LIBPATH)
-
-install-shared: $(SHAREDLIB) install-headers install-docs install-man
-	-@if [ ! -d $(LIBPATH) ]; then mkdir -p $(LIBPATH); fi
-	-@if [ ! -d $(BINPATH) ]; then mkdir -p $(BINPATH); fi
-	install -m 755 $(IMPLIB) $(LIBPATH)
-	install -s -m 755 $(SHAREDLIB) $(BINPATH)
+install-shared: $(SHAREDLIB) libpng.pc libpng-config install-headers install-man
+	-@if [ ! -d $(DL) ]; then $(MKDIR) $(DL); fi
+	-@if [ ! -d $(DB) ]; then $(MKDIR) $(DB); fi
+	-@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR) $(DL)/pkgconfig; fi
+	-@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
+	-@/bin/rm -f $(DL)/pkgconfig/libpng.pc
+	install -m 644 $(IMPLIB) $(DL)/$(LIBNAME).dll.a
+	-@rm -f $(DL)/$(IMPLIB)
+	(cd $(DL); ln -sf $(LIBNAME).dll.a $(IMPLIB))
+	install -s -m 755 $(SHAREDLIB) $(DB)
+	install -m 644 libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
+	(cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc)
 
 install-headers:
-	-@if [ ! -d $(INCPATH)]; then mkdir -p $(INCPATH); fi
-	-@if [ ! -d $(INCPATH)/libpng  ]; then mkdir -p $(INCPATH)/libpng; fi
-	-@rm -f ${INCPATH)/png.h
-	-@rm -f ${INCPATH)/pngconf.h
-	install -m 644 png.h pngconf.h $(INCPATH)
-
-install-docs:
-	-@if [ ! -d $(DOCPATH) ]; then mkdir -p $(DOCPATH); fi
-	install -m 644 $(DOCS) $(DOCPATH)
+	-@if [ ! -d $(DI) ]; then $(MKDIR) $(DI); fi
+	-@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR) $(DI)/$(LIBNAME); fi
+	-@rm -f $(DI)/png.h
+	-@rm -f $(DI)/pngconf.h
+	install -m 644 $(S)/png.h $(S)/pngconf.h $(DI)/$(LIBNAME)
+	-@rm -f $(DI)/libpng
+	(cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
 
 install-man:
-	-@if [ ! -d $(MAN3PATH) ]; then mkdir -p $(MAN3PATH); fi
-	install -m 644 libpngpf.3 libpng.3 $(MAN3PATH)
+	-@if [ ! -d $(D)$(MAN3PATH) ]; then $(MKDIR) $(D)$(MAN3PATH); fi
+	-@if [ ! -d $(D)$(MAN5PATH) ]; then $(MKDIR) $(D)$(MAN5PATH); fi
+	install -m 644 $(S)/libpngpf.3 $(S)/libpng.3 $(D)$(MAN3PATH)
+	install -m 644 $(S)/png.5 $(D)$(MAN5PATH)
+
+install-config: libpng-config
+	-@if [ ! -d $(DB) ]; then mkdir $(DB); fi
+	-@/bin/rm -f $(DB)/libpng-config
+	-@/bin/rm -f $(DB)/$(LIBNAME)-config
+	cp libpng-config $(DB)/$(LIBNAME)-config
+	chmod 755 $(DB)/$(LIBNAME)-config
+	(cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
+
+# Run this to verify that a future `configure' run will pick up the settings
+# you want.
+test-config-install: SHELL=/bin/bash
+test-config-install: $(DB)/libpng-config
+	@echo -e Testing libpng-config functions...'\n'
+	@ for TYRA in LDFLAGS CPPFLAGS CFLAGS LIBS VERSION; \
+   do \
+    printf "(%d)\t %10s =%s\n" $$(($$gytiu + 1)) $$TYRA \
+    "$$($(DB)/libpng-config `echo --$$TYRA |tr '[:upper:]' '[:lower:]'`)"; \
+    gytiu=$$(( $$gytiu + 1 )); \
+   done
+
+install: install-static install-shared install-man install-config
+
+# If you installed in $(DESTDIR), test-installed won't work until you
+# move the library to its final location.
+
+test-installed:
+	$(CC) $(CFLAGS) \
+	   `$(BINPATH)/libpng10-config --cppflags --cflags` pngtest.c \
+	   -L$(ZLIBLIB) \
+	   -o pngtesti$(EXE) `$(BINPATH)/libpng10-config --ldflags --libs`
+	./pngtesti$(EXE) pngtest.png
 
 clean:
 	/bin/rm -f *.pic.o *.o $(STATLIB) $(IMPLIB) $(SHAREDLIB) \
-	pngtest-stat$(EXE) pngtest$(EXE) pngout.png $(SHAREDDEF)
+	pngtest-stat$(EXE) pngtest$(EXE) pngout.png $(SHAREDDEF) \
+	libpng-config libpng.pc pngtesti$(EXE)
 
 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
 writelock:
 	chmod a-w *.[ch35] $(DOCS) scripts/*
 
+.PHONY: buildsetup-tell libpng.pc libpng-config test-config-install clean
+
 # DO NOT DELETE THIS LINE -- make depend depends on it.
 
 png.o png.pic.o:		png.h pngconf.h png.c
@@ -190,3 +301,6 @@
 
 pngtest.o:			png.h pngconf.h pngtest.c
 pngtest-stat.o:			png.h pngconf.h pngtest.c
+
+
+
diff --git a/scripts/makefile.darwin b/scripts/makefile.darwin
index 2cca991..23ce2bd 100644
--- a/scripts/makefile.darwin
+++ b/scripts/makefile.darwin
@@ -17,20 +17,35 @@
 
 CC=cc
 CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops
-LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz
+LDFLAGS=-L. -L$(ZLIBLIB) -lpng10 -lz
 
 #RANLIB=echo
 RANLIB=ranlib
 
-# read libpng.txt or png.h to see why PNGMAJ is 0.  You should not
-# have to change it.
 PNGMAJ = 0
-PNGMIN = 1.0.13
+PNGMIN = 1.0.14
 PNGVER = $(PNGMAJ).$(PNGMIN)
 LIBNAME = libpng10
 
 INCPATH=$(prefix)/include
 LIBPATH=$(prefix)/lib
+MANPATH=$(prefix)/man
+BINPATH=$(prefix)/bin
+
+# override DESTDIR= on the make install command line to easily support
+# installing into a temporary location.  Example:
+#
+#    make install DESTDIR=/tmp/build/libpng
+#
+# If you're going to install into a temporary location
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
+# you execute make install.
+DESTDIR=
+
+DB=$(DESTDIR)$(BINPATH)
+DI=$(DESTDIR)$(INCPATH)
+DL=$(DESTDIR)$(LIBPATH)
+DM=$(DESTDIR)$(MANPATH)
 
 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
 	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
@@ -43,12 +58,26 @@
 .c.pic.o:
 	$(CC) -c $(CFLAGS) -fno-common -o $@ $*.c
 
-all: libpng.a $(LIBNAME).dylib pngtest
+all: libpng.a $(LIBNAME).dylib pngtest libpng.pc libpng-config
 
 libpng.a: $(OBJS)
 	ar rc $@ $(OBJS)
 	$(RANLIB) $@
 
+libpng.pc:
+	cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! | \
+	   sed -e s/-lm// > libpng.pc
+
+libpng-config:
+	( cat scripts/libpng-config-head.in; \
+	echo prefix=\"$(prefix)\"; \
+	echo cppflags=\"-I$(INCPATH)/$(LIBNAME)\"; \
+	echo cflags=\"\"; \
+	echo ldflags=\"-L$(LIBPATH)\"; \
+	echo libs=\"-lpng10 -lz\"; \
+	cat scripts/libpng-config-body.in ) > libpng-config
+	chmod +x libpng-config
+
 $(LIBNAME).dylib: $(LIBNAME).$(PNGMAJ).dylib
 	ln -sf $(LIBNAME).$(PNGMAJ).dylib $(LIBNAME).dylib
 
@@ -57,7 +86,7 @@
 
 $(LIBNAME).$(PNGVER).dylib: $(OBJSDLL)
 	$(CC) -dynamiclib \
-	 -install_name $(LIBPATH)/$(LIBNAME).$(PNGMAJ).dylib \
+	 -install_name $(DL)/$(LIBNAME).$(PNGMAJ).dylib \
 	 -current_version $(PNGMIN) -compatibility_version $(PNGMIN) \
 	 -o $(LIBNAME).$(PNGVER).dylib \
 	 $(OBJSDLL) -L$(ZLIBLIB) -lz
@@ -69,45 +98,77 @@
 	./pngtest
 
 install-headers: png.h pngconf.h
-	-@if [ ! -d $(INCPATH) ]; then mkdir $(INCPATH); fi
-	-@if [ ! -d $(INCPATH)/$(LIBNAME) ]; then mkdir $(INCPATH)/$(LIBNAME); fi
-	cp png.h pngconf.h $(INCPATH)/$(LIBNAME)
-	chmod 644 $(INCPATH)/$(LIBNAME)/png.h $(INCPATH)/$(LIBNAME)/pngconf.h
-	-@/bin/rm -f $(INCPATH)/png.h $(INCPATH)/pngconf.h
-	-@/bin/rm -f $(INCPATH)/libpng
-	ln -sf $(INCPATH)/$(LIBNAME) $(INCPATH)/libpng
+	-@if [ ! -d $(DI) ]; then mkdir $(DI); fi
+	-@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
+	cp png.h pngconf.h $(DI)/$(LIBNAME)
+	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
+	-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
+	-@/bin/rm -f $(DI)/libpng
+	(cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
 
 install-static: install-headers libpng.a
-	-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
-	cp libpng.a $(LIBPATH)/$(LIBNAME).a
-	chmod 644 $(LIBPATH)/$(LIBNAME).a
-	-@/bin/rm -f $(LIBPATH)/libpng.a
-	ln -sf $(LIBPATH)/$(LIBNAME).a $(LIBPATH)/libpng.a
+	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
+	cp libpng.a $(DL)/$(LIBNAME).a
+	chmod 644 $(DL)/$(LIBNAME).a
+	-@/bin/rm -f $(DL)/libpng.a
+	(cd $(DL); ln -sf $(LIBNAME).a libpng.a)
 
-install-shared: install-headers $(LIBNAME).dylib
-	-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
-	-@/bin/rm -f $(LIBPATH)/$(LIBNAME).$(PNGMAJ)*.dylib
-	-@/bin/rm -f $(LIBPATH)/$(LIBNAME).dylib
-	-@/bin/rm -f $(LIBPATH)/libpng.dylib
-	-@/bin/rm -f $(LIBPATH)/libpng.2.dylib
-	-@/bin/rm -f $(LIBPATH)/libpng.2.*.dylib
-	cp $(LIBNAME).$(PNGVER).dylib $(LIBPATH)
-	chmod 755 $(LIBPATH)/$(LIBNAME).$(PNGVER).dylib
-	(cd $(LIBPATH); \
+install-shared: install-headers $(LIBNAME).dylib libpng.pc
+	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
+	-@/bin/rm -f $(DL)/$(LIBNAME).$(PNGMAJ)*.dylib
+	-@/bin/rm -f $(DL)/$(LIBNAME).dylib
+	-@/bin/rm -f $(DL)/libpng.dylib
+	-@/bin/rm -f $(DL)/libpng.3.dylib
+	-@/bin/rm -f $(DL)/libpng.3.*.dylib
+	cp $(LIBNAME).$(PNGVER).dylib $(DL)
+	chmod 755 $(DL)/$(LIBNAME).$(PNGVER).dylib
+	(cd $(DL); \
 	ln -sf $(LIBNAME).$(PNGVER).dylib libpng.dylib; \
-	ln -sf $(LIBNAME).$(PNGVER).dylib libpng.2.dylib; \
-	ln -sf $(LIBNAME).$(PNGVER).dylib libpng.2.$(PNGMIN).dylib; \
+	ln -sf $(LIBNAME).$(PNGVER).dylib libpng.3.dylib; \
+	ln -sf $(LIBNAME).$(PNGVER).dylib libpng.3.$(PNGMIN).dylib; \
 	ln -sf $(LIBNAME).$(PNGVER).dylib $(LIBNAME).$(PNGMAJ).dylib; \
 	ln -sf $(LIBNAME).$(PNGMAJ).dylib $(LIBNAME).dylib)
-	-@if [ ! -d $(LIBPATH)/pkgconfig ]; then mkdir $(LIBPATH)/pkgconfig; fi
-	cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
-	cp libpng.pc $(LIBPATH)/pkgconfig/libpng10.pc
-	chmod 644 $(LIBPATH)/pkgconfig/libpng10.pc
+	-@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi
+	-@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
+	-@/bin/rm -f $(DL)/pkgconfig/libpng.pc
+	cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
+	chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
+	(cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc)
 
-install: install-static install-shared
+install-man: libpng.3 libpngpf.3 png.5
+	-@if [ ! -d $(DM) ]; then mkdir $(DM); fi
+	-@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi
+	-@/bin/rm -f $(DM)/man3/libpng.3
+	-@/bin/rm -f $(DM)/man3/libpngpf.3
+	cp libpng.3 $(DM)/man3
+	cp libpngpf.3 $(DM)/man3
+	-@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi
+	-@/bin/rm -f $(DM)/man5/png.5
+	cp png.5 $(DM)/man5
+
+install-config: libpng-config
+	-@if [ ! -d $(DB) ]; then mkdir $(DB); fi
+	-@/bin/rm -f $(DB)/libpng-config
+	-@/bin/rm -f $(DB)/$(LIBNAME)-config
+	cp libpng-config $(DB)/$(LIBNAME)-config
+	chmod 755 $(DB)/$(LIBNAME)-config
+	(cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
+
+install: install-static install-shared install-man install-config
+
+# If you installed in $(DESTDIR), test-installed won't work until you
+# move the library to its final location.
+
+test-installed:
+	$(CC) $(CFLAGS) \
+	   `$(BINPATH)/libpng10-config --cppflags --cflags` pngtest.c \
+	   -L$(ZLIBLIB) \
+	   -o pngtesti `$(BINPATH)/libpng10-config --ldflags --libs`
+	./pngtesti pngtest.png
 
 clean:
-	rm -f *.o libpng.a $(LIBNAME).*dylib pngtest pngout.png
+	rm -f *.o libpng.a pngtest pngout.png libpng.pc libpng-config \
+	$(LIBNAME).*dylib pngtesti
 
 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
 writelock:
diff --git a/scripts/makefile.dec b/scripts/makefile.dec
index c90993f..83c6a70 100644
--- a/scripts/makefile.dec
+++ b/scripts/makefile.dec
@@ -1,5 +1,5 @@
 # makefile for libpng on DEC Alpha Unix
-# Copyright (C) 2000 Glenn Randers-Pehrson
+# Copyright (C) 2000-2002 Glenn Randers-Pehrson
 # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
 # For conditions of distribution and use, see copyright notice in png.h
 
@@ -7,6 +7,23 @@
 prefix=/usr/local
 INCPATH=$(prefix)/include
 LIBPATH=$(prefix)/lib
+MANPATH=$(prefix)/man
+BINPATH=$(prefix)/bin
+
+# override DESTDIR= on the make install command line to easily support
+# installing into a temporary location.  Example:
+#
+#    make install DESTDIR=/tmp/build/libpng
+#
+# If you're going to install into a temporary location
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
+# you execute make install.
+DESTDIR=
+
+DB=$(DESTDIR)$(BINPATH)
+DI=$(DESTDIR)$(INCPATH)
+DL=$(DESTDIR)$(LIBPATH)
+DM=$(DESTDIR)$(MANPATH)
 
 # Where the zlib library and include files are located
 #ZLIBLIB=/usr/local/lib
@@ -14,10 +31,8 @@
 ZLIBLIB=../zlib
 ZLIBINC=../zlib
 
-# read libpng.txt or png.h to see why PNGMAJ is 0.  You should not
-# have to change it.
 PNGMAJ = 0
-PNGMIN = 1.0.13
+PNGMIN = 1.0.14
 PNGVER = $(PNGMAJ).$(PNGMIN)
 LIBNAME = libpng10
 
@@ -32,12 +47,25 @@
 	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
 	pngwtran.o pngmem.o pngerror.o pngpread.o
 
-all: $(LIBNAME).so libpng.a pngtest
+all: $(LIBNAME).so libpng.a pngtest libpng.pc libpng-config
 
 libpng.a: $(OBJS)
 	ar rc $@  $(OBJS)
 	$(RANLIB) $@
 
+libpng.pc:
+	cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
+
+libpng-config:
+	( cat scripts/libpng-config-head.in; \
+	echo prefix=\"$(prefix)\"; \
+	echo cppflags=\"-I$(INCPATH)/$(LIBNAME)\"; \
+	echo cflags=\"-std\"; \
+	echo ldflags=\"-L$(LIBPATH)\"; \
+	echo libs=\"-lpng10 -lz -lm\"; \
+	cat scripts/libpng-config-body.in ) > libpng-config
+	chmod +x libpng-config
+
 $(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ)
 	ln -f -s $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so
 
@@ -45,7 +73,8 @@
 	ln -f -s $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ)
 
 $(LIBNAME).so.$(PNGVER): $(OBJS)
-	$(CC) -shared -o $@ $(OBJS) -L$(ZLIBLIB) -lz -lm
+	$(CC) -shared -o $@ $(OBJS) -L$(ZLIBLIB)
+	-soname $(LIBNAME).so.$(PNGMAJ) -lz -lm
 
 pngtest: pngtest.o libpng.a
 	$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
@@ -54,44 +83,78 @@
 	./pngtest
 
 install-headers: png.h pngconf.h
-	-@if [ ! -d $(INCPATH) ]; then mkdir $(INCPATH); fi
-	-@if [ ! -d $(INCPATH)/$(LIBNAME) ]; then mkdir $(INCPATH)/$(LIBNAME); fi
-	cp png.h pngconf.h $(INCPATH)/$(LIBNAME)
-	chmod 644 $(INCPATH)/$(LIBNAME)/png.h $(INCPATH)/$(LIBNAME)/pngconf.h
-	-@/bin/rm -f $(INCPATH)/png.h $(INCPATH)/pngconf.h
-	-@/bin/rm -f $(INCPATH)/libpng
-	ln -sf $(INCPATH)/$(LIBNAME) $(INCPATH)/libpng
+	-@if [ ! -d $(DI) ]; then mkdir $(DI); fi
+	-@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
+	cp png.h pngconf.h $(DI)/$(LIBNAME)
+	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
+	-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
+	-@/bin/rm -f $(DI)/libpng
+	(cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
 
 install-static: install-headers libpng.a
-	-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
-	cp libpng.a $(LIBPATH)/$(LIBNAME).a
-	chmod 644 $(LIBPATH)/$(LIBNAME).a
-	-@/bin/rm -f $(LIBPATH)/libpng.a
-	ln -sf $(LIBPATH)/$(LIBNAME).a $(LIBPATH)/libpng.a
+	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
+	cp libpng.a $(DL)/$(LIBNAME).a
+	chmod 644 $(DL)/$(LIBNAME).a
+	-@/bin/rm -f $(DL)/libpng.a
+	(cd $(DL); ln -sf $(LIBNAME).a libpng.a)
 
-install-shared: install-headers $(LIBNAME).so.$(PNGVER)
-	-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
-	-@/bin/rm -f $(LIBPATH)/$(LIBNAME).so.$(PNGMAJ)* $(LIBPATH)/$(LIBNAME).so
-	-@/bin/rm -f $(LIBPATH)/libpng.so
-	-@/bin/rm -f $(LIBPATH)/libpng.so.2
-	-@/bin/rm -f $(LIBPATH)/libpng.so.2.*
-	cp $(LIBNAME).so.$(PNGVER) $(LIBPATH)
-	chmod 755 $(LIBPATH)/$(LIBNAME).so.$(PNGVER)
-	(cd $(LIBPATH); \
+install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc
+	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
+	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* $(DL)/$(LIBNAME).so
+	-@/bin/rm -f $(DL)/libpng.so
+	-@/bin/rm -f $(DL)/libpng.so.2
+	-@/bin/rm -f $(DL)/libpng.so.2.*
+	cp $(LIBNAME).so.$(PNGVER) $(DL)
+	chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER)
+	(cd $(DL); \
 	ln -sf $(LIBNAME).so.$(PNGVER) libpng.so; \
 	ln -sf $(LIBNAME).so.$(PNGVER) libpng.so.2; \
 	ln -sf $(LIBNAME).so.$(PNGVER) libpng.so.2.$(PNGMIN); \
 	ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \
 	ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so)
-	-@if [ ! -d $(LIBPATH)/pkgconfig ]; then mkdir $(LIBPATH)/pkgconfig; fi
-	cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
-	cp libpng.pc $(LIBPATH)/pkgconfig/libpng10.pc
-	chmod 644 $(LIBPATH)/pkgconfig/libpng10.pc
+	-@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi
+	-@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
+	-@/bin/rm -f $(DL)/pkgconfig/libpng.pc
+	cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
+	chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
+	(cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc)
 
-install: install-static install-shared
+install-man: libpng.3 libpngpf.3 png.5
+	-@if [ ! -d $(DM) ]; then mkdir $(DM); fi
+	-@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi
+	-@/bin/rm -f $(DM)/man3/libpng.3
+	-@/bin/rm -f $(DM)/man3/libpngpf.3
+	cp libpng.3 $(DM)/man3
+	cp libpngpf.3 $(DM)/man3
+	-@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi
+	-@/bin/rm -f $(DM)/man5/png.5
+	cp png.5 $(DM)/man5
+
+install-config: libpng-config
+	-@if [ ! -d $(DB) ]; then mkdir $(DB); fi
+	-@/bin/rm -f $(DB)/libpng-config
+	-@/bin/rm -f $(DB)/$(LIBNAME)-config
+	cp libpng-config $(DB)/$(LIBNAME)-config
+	chmod 755 $(DB)/$(LIBNAME)-config
+	(cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
+
+install: install-static install-shared install-man install-config
+
+# If you installed in $(DESTDIR), test-installed won't work until you
+# move the library to its final location.
+
+test-installed:
+	echo
+	echo Testing installed dynamic shared library.
+	$(CC) -std -w1 -I$(ZLIBINC) \
+	   `$(BINPATH)/libpng10-config --cppflags --cflags` pngtest.c \
+	   -L$(ZLIBLIB) -R$(ZLIBLIB) \
+	   -o pngtesti `$(BINPATH)/libpng10-config --ldflags --libs`
+	./pngtesti pngtest.png
 
 clean:
-	/bin/rm -f *.o libpng.a $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* pngtest pngout.png
+	/bin/rm -f *.o libpng.a pngtest pngtesti pngout.png libpng.pc \
+	libpng-config $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)*
 
 # DO NOT DELETE THIS LINE -- make depend depends on it.
 
diff --git a/scripts/makefile.dj2 b/scripts/makefile.dj2
index 8ba1770..09045c2 100644
--- a/scripts/makefile.dj2
+++ b/scripts/makefile.dj2
@@ -1,10 +1,13 @@
 # DJGPP (DOS gcc) makefile for libpng
+# Copyright (C) 2002 Glenn Randers-Pehrson
 # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
 # For conditions of distribution and use, see copyright notice in png.h
 
-# where make install puts libpng.a and png.h
+# where make install will put libpng.a and png.h
 #prefix=/usr/local
 prefix=.
+INCPATH=$(prefix)/include
+LIBPATH=$(prefix)/lib
 
 CC=gcc
 CFLAGS=-I../zlib -O
diff --git a/scripts/makefile.freebsd b/scripts/makefile.freebsd
index 3423768..d7d5fae 100644
--- a/scripts/makefile.freebsd
+++ b/scripts/makefile.freebsd
@@ -1,93 +1,48 @@
 # makefile for libpng under FreeBSD
 # Copyright (C) 2002 Glenn Randers-Pehrson and Andrey A. Chernov
-# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
 # For conditions of distribution and use, see copyright notice in png.h
 
-# where make install puts libpng.a and png.h
-prefix=/usr/local
+PREFIX?=        /usr/local
+SHLIB_VER?=     5
 
-PNGMAJ= 5
-.if (${OBJFORMAT} == "elf")
-PNGVER= $(PNGMAJ)
-.else
-PNGMIN= 0
-PNGVER= $(PNGMAJ).$(PNGMIN)
-.endif
+LIB=		png
+SHLIB_MAJOR=	${SHLIB_VER}
+SHLIB_MINOR=	0
+NOPROFILE=	YES
+NOOBJ=          YES
+
+# where make install puts libpng.a and png.h
+DESTDIR=	${PREFIX}
+LIBDIR=		/lib
+INCS=		png.h pngconf.h
+INCSDIR=	/include/libpng
+INCDIR=		${INCSDIR}		# for 4.x bsd.lib.mk
+MAN=		libpng.3 libpngpf.3 png.5
+MANDIR=		/man/man
+SYMLINKS=       libpng/png.h ${INCSDIR}/../png.h \
+		libpng/pngconf.h ${INCSDIR}/../pngconf.h
+LDADD+=         -lm -lz
+DPADD+=         ${LIBM} ${LIBZ}
 
 CFLAGS+= -I. -DPNG_USE_PNGGCCRD
 .if (${MACHINE_ARCH} != "i386")
 CFLAGS+= -DPNG_NO_ASSEMBLER_CODE
 .endif
-LDFLAGS+=-L. -lpng -lz -lm -static
 
-OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
-	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
-	pngwtran.o pngmem.o pngerror.o pngpread.o pnggccrd.o
-
-.SUFFIXES: .c .so .o
-
-.c.so:
-	${CC} ${CFLAGS} -fPIC -DPIC -o $@ -c $<
-
-all: libpng.a libpng.so.${PNGVER} pngtest
-
-libpng.a: $(OBJS)
-	ar rc $@  $(OBJS)
-	$(RANLIB) $@
-
-libpng.so.${PNGVER}: $(OBJS:S/o$/so/g)
-.if (${OBJFORMAT} == "elf")
-	${CC} -shared -Wl,-x,-soname,$@ -o $@ $(OBJS:S/o$/so/g) -lz -lm
-.else
-	${CC} -shared -Wl,-x -o $@ $(OBJS:S/o$/so/g) -lz -lm
-.endif
+SRCS=	png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
+	pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
+	pngwtran.c pngmem.c pngerror.c pngpread.c pnggccrd.c
 
 pngtest: pngtest.o libpng.a
-	$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
+	${CC} ${CFLAGS} -L. -static -o pngtest pngtest.o -lpng -lz -lm
+
+CLEANFILES= pngtest pngtest.o pngout.png
 
 test: pngtest
 	./pngtest
 
-install: libpng.a libpng.so.${PNGVER}
-	-@mkdir $(prefix)/include/libpng
-	${INSTALL} -o ${INCOWN} -g ${INCGRP} -m ${INCMODE} \
-		png.h pngconf.h $(prefix)/include/libpng
-	ln -sf libpng/png.h $(prefix)/include/png.h
-	ln -sf libpng/pngconf.h $(prefix)/include/pngconf.h
-	${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
-		libpng.a libpng.so.${PNGVER} $(prefix)/lib
-	$(RANLIB) $(prefix)/lib/libpng.a
-	ln -sf libpng.so.${PNGVER} $(prefix)/lib/libpng.so
-	/sbin/ldconfig -R
-	${INSTALL} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \
-		libpng.3 libpngpf.3 $(prefix)/man/man3
-	${INSTALL} -o ${MANOWN} -g ${MANGRP} -m ${MANMODE} \
-		png.5 $(prefix)/man/man5
-
-clean:
-	rm -f *.o libpng.a libpng.so libpng.so.${PNGVER} pngtest pngout.png
-
 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
 writelock:
 	chmod a-w *.[ch35] $(DOCS) scripts/*
 
-# DO NOT DELETE THIS LINE -- make depend depends on it.
-
-png.o: png.h pngconf.h
-pngerror.o: png.h pngconf.h
-pngrio.o: png.h pngconf.h
-pngwio.o: png.h pngconf.h
-pngmem.o: png.h pngconf.h
-pngset.o: png.h pngconf.h
-pngget.o: png.h pngconf.h
-pngread.o: png.h pngconf.h
-pngrtran.o: png.h pngconf.h
-pngrutil.o: png.h pngconf.h
-pngtest.o: png.h pngconf.h
-pngtrans.o: png.h pngconf.h
-pngwrite.o: png.h pngconf.h
-pngwtran.o: png.h pngconf.h
-pngwutil.o: png.h pngconf.h
-pngpread.o: png.h pngconf.h
-pnggccrd.o: png.h pngconf.h
-
+.include <bsd.lib.mk>
diff --git a/scripts/makefile.gcmmx b/scripts/makefile.gcmmx
index b7bc007..117f80b 100644
--- a/scripts/makefile.gcmmx
+++ b/scripts/makefile.gcmmx
@@ -15,16 +15,17 @@
 
 LIBNAME = libpng10
 PNGMAJ = 0
-PNGMIN = 1.0.13
+PNGMIN = 1.0.14
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 CC=gcc
 
-# where "make install" puts libpng.a, libpng10/libpng10.so*,
-# $(LIBNAME)/png.h and $(LIBNAME)/pngconf.h
+# where "make install" puts libpng10.a, libpng10.so*,
+# libpng10/png.h and libpng10/pngconf.h
+# Prefix must be a full pathname.
 prefix=/usr/local
 
-# Where the zlib library and include files are located
+# Where the zlib library and include files are located.
 #ZLIBLIB=/usr/local/lib
 #ZLIBINC=/usr/local/include
 ZLIBLIB=../zlib
@@ -62,6 +63,23 @@
 
 INCPATH=$(prefix)/include
 LIBPATH=$(prefix)/lib
+MANPATH=$(prefix)/man
+BINPATH=$(prefix)/bin
+
+# override DESTDIR= on the make install command line to easily support
+# installing into a temporary location.  Example:
+#
+#    make install DESTDIR=/tmp/build/libpng
+#
+# If you're going to install into a temporary location
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
+# you execute make install.
+DESTDIR=
+
+DB=$(DESTDIR)$(BINPATH)
+DI=$(DESTDIR)$(INCPATH)
+DL=$(DESTDIR)$(LIBPATH)
+DM=$(DESTDIR)$(MANPATH)
 
 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
 	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
@@ -74,7 +92,25 @@
 .c.pic.o:
 	$(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
 
-all: libpng.a $(LIBNAME).so pngtest pngtest-static
+all: libpng.a $(LIBNAME).so pngtest pngtest-static libpng.pc libpng-config
+
+libpng.a: $(OBJS)
+	ar rc $@ $(OBJS)
+	$(RANLIB) $@
+
+libpng.pc:
+	cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
+
+libpng-config:
+	( cat scripts/libpng-config-head.in; \
+	echo prefix=\"$(prefix)\"; \
+	echo cppflags=\"-I$(INCPATH)/$(LIBNAME) -DPNG_THREAD_UNSAFE_OK \
+	   -DPNG_USE_PNGGCCRD\"; \
+	echo cflags=\"\"; \
+	echo ldflags=\"-L$(LIBPATH) -Wl,-rpath,$(LIBPATH)\"; \
+	echo libs=\"-lpng10 -lz -lm\"; \
+	cat scripts/libpng-config-body.in ) > libpng-config
+	chmod +x libpng-config
 
 pnggccrd.o:	pnggccrd.c png.h pngconf.h
 	$(CC) -c $(CFLAGS) -o $@ $*.c
@@ -82,10 +118,6 @@
 pnggccrd.pic.o:	pnggccrd.c png.h pngconf.h
 	$(CC) -c $(CFLAGS) -fPIC -o $@ pnggccrd.c
 
-$(LIBNAME).a: $(OBJS)
-	ar rc $@ $(OBJS)
-	$(RANLIB) $@
-
 $(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ)
 	ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so
 
@@ -93,18 +125,19 @@
 	ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ)
 
 $(LIBNAME).so.$(PNGVER): $(OBJSDLL)
-	$(CC) -shared -Wl,-soname,$(LIBNAME).so.$(PNGMAJ) -o $(LIBNAME).so.$(PNGVER) \
-	 $(OBJSDLL) -L$(ZLIBLIB) -lz -lm -lc
+	$(CC) -shared -Wl,-soname,$(LIBNAME).so.$(PNGMAJ) \
+	-o $(LIBNAME).so.$(PNGVER) \
+	$(OBJSDLL) -L$(ZLIBLIB) -lz -lm -lc
 
 pngtest: pngtest.o $(LIBNAME).so
 	$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
 
-pngtest-static: pngtest.o $(LIBNAME).a
+pngtest-static: pngtest.o libpng.a
 	$(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A)
 
 test: pngtest pngtest-static
 	@echo ""
-	@echo "   Running pngtest dynamically linked with libpng10.so:"
+	@echo "   Running pngtest dynamically linked with $(LIBNAME).so:"
 	@echo ""
 	./pngtest
 	@echo ""
@@ -113,45 +146,76 @@
 	./pngtest-static
 
 install-headers: png.h pngconf.h
-	-@if [ ! -d $(INCPATH) ]; then mkdir $(INCPATH); fi
-	-@if [ ! -d $(INCPATH)/$(LIBNAME) ]; then mkdir $(INCPATH)/$(LIBNAME); fi
-	cp png.h pngconf.h $(INCPATH)/$(LIBNAME)
-	chmod 644 $(INCPATH)/$(LIBNAME)/png.h $(INCPATH)/$(LIBNAME)/pngconf.h
-	-@/bin/rm -f $(INCPATH)/png.h $(INCPATH)/pngconf.h
-	-@/bin/rm -f $(INCPATH)/libpng
-	ln -sf $(INCPATH)/$(LIBNAME) $(INCPATH)/libpng
+	-@if [ ! -d $(DI) ]; then mkdir $(DI); fi
+	-@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
+	cp png.h pngconf.h $(DI)/$(LIBNAME)
+	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
+	-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
+	-@/bin/rm -f $(DI)/libpng
+	(cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
 
 install-static: install-headers libpng.a
-	-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
-	cp libpng.a $(LIBPATH)/$(LIBNAME).a
-	chmod 644 $(LIBPATH)/$(LIBNAME).a
-	-@/bin/rm -f $(LIBPATH)/libpng.a
-	ln -sf $(LIBPATH)/$(LIBNAME).a $(LIBPATH)/libpng.a
+	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
+	cp libpng.a $(DL)/$(LIBNAME).a
+	chmod 644 $(DL)/$(LIBNAME).a
+	-@/bin/rm -f $(DL)/libpng.a
+	(cd $(DL); ln -sf $(LIBNAME).a libpng.a)
 
-install-shared: install-headers $(LIBNAME).so.$(PNGVER)
-	-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
-	-@/bin/rm -f $(LIBPATH)/$(LIBNAME).so.$(PNGMAJ)* $(LIBPATH)/$(LIBNAME).so
-	-@/bin/rm -f $(LIBPATH)/libpng.so
-	-@/bin/rm -f $(LIBPATH)/libpng.so.2
-	-@/bin/rm -f $(LIBPATH)/libpng.so.2.*
-	cp $(LIBNAME).so.$(PNGVER) $(LIBPATH)
-	chmod 755 $(LIBPATH)/$(LIBNAME).so.$(PNGVER)
-	(cd $(LIBPATH); \
+install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc
+	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
+	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* $(DL)/$(LIBNAME).so
+	-@/bin/rm -f $(DL)/libpng.so
+	-@/bin/rm -f $(DL)/libpng.so.2
+	-@/bin/rm -f $(DL)/libpng.so.2.*
+	cp $(LIBNAME).so.$(PNGVER) $(DL)
+	chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER)
+	(cd $(DL); \
 	ln -sf $(LIBNAME).so.$(PNGVER) libpng.so; \
 	ln -sf $(LIBNAME).so.$(PNGVER) libpng.so.2; \
 	ln -sf $(LIBNAME).so.$(PNGVER) libpng.so.2.$(PNGMIN); \
 	ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \
 	ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so)
-	-@if [ ! -d $(LIBPATH)/pkgconfig ]; then mkdir $(LIBPATH)/pkgconfig; fi
-	cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
-	cp libpng.pc $(LIBPATH)/pkgconfig/libpng10.pc
-	chmod 644 $(LIBPATH)/pkgconfig/libpng10.pc
+	-@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi
+	-@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
+	-@/bin/rm -f $(DL)/pkgconfig/libpng.pc
+	cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
+	chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
+	(cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc)
 
-install: install-static install-shared
+install-man: libpng.3 libpngpf.3 png.5
+	-@if [ ! -d $(DM) ]; then mkdir $(DM); fi
+	-@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi
+	-@/bin/rm -f $(DM)/man3/libpng.3
+	-@/bin/rm -f $(DM)/man3/libpngpf.3
+	cp libpng.3 $(DM)/man3
+	cp libpngpf.3 $(DM)/man3
+	-@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi
+	-@/bin/rm -f $(DM)/man5/png.5
+	cp png.5 $(DM)/man5
+
+install-config: libpng-config
+	-@if [ ! -d $(DB) ]; then mkdir $(DB); fi
+	-@/bin/rm -f $(DB)/libpng-config
+	-@/bin/rm -f $(DB)/$(LIBNAME)-config
+	cp libpng-config $(DB)/$(LIBNAME)-config
+	chmod 755 $(DB)/$(LIBNAME)-config
+	(cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
+
+install: install-static install-shared install-man install-config
+
+# If you installed in $(DESTDIR), test-installed won't work until you
+# move the library to its final location.
+
+test-installed:
+	$(CC) -I$(ZLIBINC) \
+	   `$(BINPATH)/libpng10-config --cppflags --cflags` pngtest.c \
+	   -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \
+	   -o pngtesti `$(BINPATH)/libpng10-config --ldflags --libs`
+	./pngtesti pngtest.png
 
 clean:
-	/bin/rm -f *.o libpng.a $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* \
-	pngtest pngout.png
+	/bin/rm -f *.o libpng.a pngtest pngout.png libpng.pc libpng-config \
+	$(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* pngtest-static pngtesti
 
 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
 writelock:
diff --git a/scripts/makefile.hpgcc b/scripts/makefile.hpgcc
index 57c7202..129a026 100644
--- a/scripts/makefile.hpgcc
+++ b/scripts/makefile.hpgcc
@@ -26,21 +26,36 @@
 
 CFLAGS=-I$(ZLIBINC) -Wall -O3 -funroll-loops \
 	$(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
-#LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng -lz -lm
-LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
+#LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng10 -lz -lm
+LDFLAGS=-L. -L$(ZLIBLIB) -lpng10 -lz -lm
 
 RANLIB=ranlib
 #RANLIB=echo
 
-# read libpng.txt or png.h to see why PNGMAJ is 0.  You should not
-# have to change it.
 PNGMAJ = 0
-PNGMIN = 1.0.13
+PNGMIN = 1.0.14
 PNGVER = $(PNGMAJ).$(PNGMIN)
 LIBNAME = libpng10
 
 INCPATH=$(prefix)/include
 LIBPATH=$(prefix)/lib
+MANPATH=$(prefix)/man
+BINPATH=$(prefix)/bin
+
+# override DESTDIR= on the make install command line to easily support
+# installing into a temporary location.  Example:
+#
+#    make install DESTDIR=/tmp/build/libpng
+#
+# If you're going to install into a temporary location
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
+# you execute make install.
+DESTDIR=
+
+DB=$(DESTDIR)$(BINPATH)
+DI=$(DESTDIR)$(INCPATH)
+DL=$(DESTDIR)$(LIBPATH)
+DM=$(DESTDIR)$(MANPATH)
 
 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
 	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
@@ -53,12 +68,25 @@
 .c.pic.o:
 	$(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
 
-all: libpng.a $(LIBNAME).sl pngtest
+all: libpng.a $(LIBNAME).sl pngtest libpng.pc libpng-config
 
 libpng.a: $(OBJS)
 	ar rc $@ $(OBJS)
 	$(RANLIB) $@
 
+libpng.pc:
+	cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
+
+libpng-config:
+	( cat scripts/libpng-config-head.in; \
+	echo prefix=\"$(prefix)\"; \
+	echo cppflags=\"-I$(INCPATH)/$(LIBNAME)\"; \
+	echo cflags=\"\"; \
+	echo ldflags=\"\"; \
+	echo libs=\"-lpng10 -lz -lm\"; \
+	cat scripts/libpng-config-body.in ) > libpng-config
+	chmod +x libpng-config
+
 $(LIBNAME).sl: $(LIBNAME).sl.$(PNGMAJ)
 	ln -f -s $(LIBNAME).sl.$(PNGMAJ) $(LIBNAME).sl
 
@@ -77,41 +105,79 @@
 
 
 install-headers: png.h pngconf.h
-	-@if [ ! -d $(INCPATH) ]; then mkdir $(INCPATH); fi
-	-@if [ ! -d $(INCPATH)/$(LIBNAME) ]; then mkdir $(INCPATH)/$(LIBNAME); fi
-	cp png.h pngconf.h $(INCPATH)/$(LIBNAME)
-	chmod 644 $(INCPATH)/$(LIBNAME)/png.h $(INCPATH)/$(LIBNAME)/pngconf.h
-	-@/bin/rm -f $(INCPATH)/png.h $(INCPATH)/pngconf.h
-	-@/bin/rm -f $(INCPATH)/libpng
-	ln -sf $(INCPATH)/$(LIBNAME) $(INCPATH)/libpng
+	-@if [ ! -d $(DI) ]; then mkdir $(DI); fi
+	-@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
+	cp png.h pngconf.h $(DI)/$(LIBNAME)
+	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
+	-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
+	-@/bin/rm -f $(DI)/libpng
+	(cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
 
 install-static: install-headers libpng.a
-	-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
-	cp libpng.a $(LIBPATH)/$(LIBNAME).a
-	chmod 644 $(LIBPATH)/$(LIBNAME).a
-	-@/bin/rm -f $(LIBPATH)/libpng.a
-	ln -sf $(LIBPATH)/$(LIBNAME).a $(LIBPATH)/libpng.a
+	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
+	cp libpng.a $(DL)/$(LIBNAME).a
+	chmod 644 $(DL)/$(LIBNAME).a
+	-@/bin/rm -f $(DL)/libpng.a
+	(cd $(DL); ln -sf $(LIBNAME).a libpng.a)
 
-install-shared: install-headers $(LIBNAME).sl.$(PNGVER)
-	-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
-	-@/bin/rm -f $(LIBPATH)/$(LIBNAME).sl.$(PNGMAJ)* $(LIBPATH)/$(LIBNAME).sl
-	-@/bin/rm -f $(LIBPATH)/libpng.so
-	-@/bin/rm -f $(LIBPATH)/libpng.so.2
-	-@/bin/rm -f $(LIBPATH)/libpng.so.2.*
-	cp $(LIBNAME).sl.$(PNGVER) $(LIBPATH)
-	chmod 755 $(LIBPATH)/$(LIBNAME).sl.$(PNGVER)
-	(cd $(LIBPATH); \
+install-shared: install-headers $(LIBNAME).sl.$(PNGVER) libpng.pc
+	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
+	-@/bin/rm -f $(DL)/$(LIBNAME).sl.$(PNGMAJ)* $(DL)/$(LIBNAME).sl
+	-@/bin/rm -f $(DL)/libpng.so
+	-@/bin/rm -f $(DL)/libpng.so.2
+	-@/bin/rm -f $(DL)/libpng.so.2.*
+	cp $(LIBNAME).sl.$(PNGVER) $(DL)
+	chmod 755 $(DL)/$(LIBNAME).sl.$(PNGVER)
+	(cd $(DL); \
 	ln -sf $(LIBNAME).so.$(PNGVER) libpng.so; \
-	ln -sf $(LIBNAME).sl.$(PNGVER) libpng.sl.2; \
-	ln -sf $(LIBNAME).sl.$(PNGVER) libpng.sl.2.$(PNGMIN); \
+	ln -sf $(LIBNAME).sl.$(PNGVER) libpng.sl.3; \
+	ln -sf $(LIBNAME).sl.$(PNGVER) libpng.sl.3.$(PNGMIN); \
 	ln -sf $(LIBNAME).sl.$(PNGVER) $(LIBNAME).sl.$(PNGMAJ); \
 	ln -sf $(LIBNAME).sl.$(PNGMAJ) $(LIBNAME).sl)
-	-@if [ ! -d $(LIBPATH)/pkgconfig ]; then mkdir $(LIBPATH)/pkgconfig; fi
-	cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
-	cp libpng.pc $(LIBPATH)/pkgconfig/libpng10.pc
-	chmod 644 $(LIBPATH)/pkgconfig/libpng10.pc
+	-@if [ ! -d $(DL)/pkgconfig ]; then mkdir \
+	$(DL)/pkgconfig; fi
+	-@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
+	-@/bin/rm -f $(DL)/pkgconfig/libpng.pc
+	cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
+	chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
+	(cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc)
 
-install: install-static install-shared
+install-man: libpng.3 libpngpf.3 png.5
+	-@if [ ! -d $(DM) ]; then mkdir $(DM); fi
+	-@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi
+	-@/bin/rm -f $(DM)/man3/libpng.3
+	-@/bin/rm -f $(DM)/man3/libpngpf.3
+	cp libpng.3 $(DM)/man3
+	cp libpngpf.3 $(DM)/man3
+	-@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi
+	-@/bin/rm -f $(DM)/man5/png.5
+	cp png.5 $(DM)/man5
+
+install-config: libpng-config
+	-@if [ ! -d $(DB) ]; then mkdir $(DB); fi
+	-@/bin/rm -f $(DB)/libpng-config
+	-@/bin/rm -f $(DB)/$(LIBNAME)-config
+	cp libpng-config $(DB)/$(LIBNAME)-config
+	chmod 755 $(DB)/$(LIBNAME)-config
+	(cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
+
+install: install-static install-shared install-man install-config
+
+# If you installed in $(DESTDIR), test-installed won't work until you
+# move the library to its final location.
+
+test-installed:
+	echo
+	echo Testing installed dynamic shared library.
+	$(CC) -I$(ZLIBINC) \
+	   `$(BINPATH)/libpng10-config --cppflags --cflags` pngtest.c \
+	   -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \
+	   -o pngtesti `$(BINPATH)/libpng10-config --ldflags --libs`
+	./pngtesti pngtest.png
+
+clean:
+	/bin/rm -f *.o libpng.a pngtest pngtesti pngout.png libpng.pc \
+	libpng-config $(LIBNAME).sl $(LIBNAME).sl.$(PNGMAJ)*
 
 clean:
 	/bin/rm -f *.o libpng.a $(SHAREDLIB).sl $(SHAREDLIB).sl.$(PNGMAJ)* \
diff --git a/scripts/makefile.hpux b/scripts/makefile.hpux
index ce91b96..3a6323b 100644
--- a/scripts/makefile.hpux
+++ b/scripts/makefile.hpux
@@ -16,17 +16,32 @@
 
 RANLIB=ranlib
 
-# read libpng.txt or png.h to see why PNGMAJ is 0.  You should not
-# have to change it.
 PNGMAJ = 0
-PNGMIN = 1.0.13
+PNGMIN = 1.0.14
 PNGVER = $(PNGMAJ).$(PNGMIN)
 LIBNAME = libpng10
 
 # where make install puts libpng.a, libpng10.sl, and png.h
 prefix=/opt/libpng
-LIBPATH=$prefix/lib
-INCPATH=$prefix/include
+INCPATH=$(prefix)/include
+LIBPATH=$(prefix)/lib
+MANPATH=$(prefix)/man
+BINPATH=$(prefix)/bin
+
+# override DESTDIR= on the make install command line to easily support
+# installing into a temporary location.  Example:
+#
+#    make install DESTDIR=/tmp/build/libpng
+#
+# If you're going to install into a temporary location
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
+# you execute make install.
+DESTDIR=
+
+DB=$(DESTDIR)$(BINPATH)
+DI=$(DESTDIR)$(INCPATH)
+DL=$(DESTDIR)$(LIBPATH)
+DM=$(DESTDIR)$(MANPATH)
 
 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
 	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
@@ -39,12 +54,25 @@
 .c.pic.o:
 	$(CC) -c $(CFLAGS) +z -o $@ $*.c
 
-all: libpng.a $(LIBNAME).sl pngtest
+all: libpng.a $(LIBNAME).sl pngtest libpng.pc libpng-config
 
 libpng.a: $(OBJS)
 	ar rc $@  $(OBJS)
 	$(RANLIB) $@
 
+libpng.pc:
+	cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
+
+libpng-config:
+	( cat scripts/libpng-config-head.in; \
+	echo prefix=\"$(prefix)\"; \
+	echo cppflags=\"-I$(INCPATH)/$(LIBNAME)\"; \
+	echo cflags=\"-Ae +DA1.1 +DS2.0"; \
+	echo ldflags=\"-L$(LIBPATH)\"; \
+	echo libs=\"-lpng10 -lz -lm\"; \
+	cat scripts/libpng-config-body.in ) > libpng-config
+	chmod +x libpng-config
+
 $(LIBNAME).sl: $(LIBNAME).sl.$(PNGMAJ)
 	ln -sf $(LIBNAME).sl.$(PNGMAJ) $(LIBNAME).sl
 
@@ -63,45 +91,78 @@
 	./pngtest
 
 install-headers: png.h pngconf.h
-	-@if [ ! -d $(INCPATH) ]; then mkdir $(INCPATH); fi
-	-@if [ ! -d $(INCPATH)/$(LIBNAME) ]; then mkdir $(INCPATH)/$(LIBNAME); fi
-	cp png.h pngconf.h $(INCPATH)/$(LIBNAME)
-	chmod 644 $(INCPATH)/$(LIBNAME)/png.h $(INCPATH)/$(LIBNAME)/pngconf.h
-	-@/bin/rm -f $(INCPATH)/png.h $(INCPATH)/pngconf.h
-	-@/bin/rm -f $(INCPATH)/libpng
-	ln -sf $(INCPATH)/$(LIBNAME) $(INCPATH)/libpng
+	-@if [ ! -d $(DI) ]; then mkdir $(DI); fi
+	-@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
+	cp png.h pngconf.h $(DI)/$(LIBNAME)
+	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
+	-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
+	-@/bin/rm -f $(DI)/libpng
+	(cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
 
 install-static: install-headers libpng.a
-	-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
-	cp libpng.a $(LIBPATH)/$(LIBNAME).a
-	chmod 644 $(LIBPATH)/$(LIBNAME).a
-	-@/bin/rm -f $(LIBPATH)/libpng.a
-	ln -sf $(LIBPATH)/$(LIBNAME).a $(LIBPATH)/libpng.a
+	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
+	cp libpng.a $(DL)/$(LIBNAME).a
+	chmod 644 $(DL)/$(LIBNAME).a
+	-@/bin/rm -f $(DL)/libpng.a
+	(cd $(DL); ln -sf $(LIBNAME).a libpng.a)
 
-install-shared: install-headers $(LIBNAME).sl.$(PNGVER)
-	-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
-	-@/bin/rm -f $(LIBPATH)/$(LIBNAME).sl.$(PNGMAJ)* $(LIBPATH)/$(LIBNAME).sl
-	-@/bin/rm -f $(LIBPATH)/libpng.sl
-	-@/bin/rm -f $(LIBPATH)/libpng.sl.2
-	-@/bin/rm -f $(LIBPATH)/libpng.sl.2.*
-	cp $(LIBNAME).sl.$(PNGVER) $(LIBPATH)
-	chmod 755 $(LIBPATH)/$(LIBNAME).sl.$(PNGVER)
-	(cd $(LIBPATH); \
+install-shared: install-headers $(LIBNAME).sl.$(PNGVER) libpng.pc
+	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
+	-@/bin/rm -f $(DL)/$(LIBNAME).sl.$(PNGMAJ)* $(DL)/$(LIBNAME).sl
+	-@/bin/rm -f $(DL)/libpng.sl
+	-@/bin/rm -f $(DL)/libpng.sl.3
+	-@/bin/rm -f $(DL)/libpng.sl.3.*
+	cp $(LIBNAME).sl.$(PNGVER) $(DL)
+	chmod 755 $(DL)/$(LIBNAME).sl.$(PNGVER)
+	(cd $(DL); \
 	ln -sf $(LIBNAME).sl.$(PNGVER) libpng.sl; \
-	ln -sf $(LIBNAME).sl.$(PNGVER) libpng.sl.2; \
-	ln -sf $(LIBNAME).sl.$(PNGVER) libpng.sl.2.$(PNGMIN); \
+	ln -sf $(LIBNAME).sl.$(PNGVER) libpng.sl.3; \
+	ln -sf $(LIBNAME).sl.$(PNGVER) libpng.sl.3.$(PNGMIN); \
 	ln -sf $(LIBNAME).sl.$(PNGVER) $(LIBNAME).sl.$(PNGMAJ); \
 	ln -sf $(LIBNAME).sl.$(PNGMAJ) $(LIBNAME).sl)
-	-@if [ ! -d $(LIBPATH)/pkgconfig ]; then mkdir $(LIBPATH)/pkgconfig; fi
-	cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
-	cp libpng.pc $(LIBPATH)/pkgconfig/libpng10.pc
-	chmod 644 $(LIBPATH)/pkgconfig/libpng10.pc
+	-@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi
+	-@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
+	-@/bin/rm -f $(DL)/pkgconfig/libpng.pc
+	cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
+	chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
+	(cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc)
 
-install: install-static install-shared
+install-man: libpng.3 libpngpf.3 png.5
+	-@if [ ! -d $(DM) ]; then mkdir $(DM); fi
+	-@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi
+	-@/bin/rm -f $(DM)/man3/libpng.3
+	-@/bin/rm -f $(DM)/man3/libpngpf.3
+	cp libpng.3 $(DM)/man3
+	cp libpngpf.3 $(DM)/man3
+	-@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi
+	-@/bin/rm -f $(DM)/man5/png.5
+	cp png.5 $(DM)/man5
+
+install-config: libpng-config
+	-@if [ ! -d $(DB) ]; then mkdir $(DB); fi
+	-@/bin/rm -f $(DB)/libpng-config
+	-@/bin/rm -f $(DB)/$(LIBNAME)-config
+	cp libpng-config $(DB)/$(LIBNAME)-config
+	chmod 755 $(DB)/$(LIBNAME)-config
+	(cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
+
+install: install-static install-shared install-man install-config
+
+# If you installed in $(DESTDIR), test-installed won't work until you
+# move the library to its final location.
+
+test-installed:
+	echo
+	echo Testing installed dynamic shared library.
+	$(CC) $(CCFLAGS) \
+	   `$(BINPATH)/libpng10-config --cppflags --cflags` pngtest.c \
+	   -L$(ZLIBLIB) \
+	   -o pngtesti `$(BINPATH)/libpng10-config --ldflags --libs`
+	./pngtesti pngtest.png
 
 clean:
-	/bin/rm -f *.o libpng.a $(LIBNAME).sl $(LIBNAME).sl.$(PNGMAJ)* \
-	pngtest pngout.png
+	/bin/rm -f *.o libpng.a pngtest pngtesti pngout.png libpng.pc \
+	libpng-config $(LIBNAME).sl $(LIBNAME).sl.$(PNGMAJ)*
 
 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
 writelock:
diff --git a/scripts/makefile.knr b/scripts/makefile.knr
index 4d7707b..44ee538 100644
--- a/scripts/makefile.knr
+++ b/scripts/makefile.knr
@@ -1,4 +1,5 @@
 # makefile for libpng
+# Copyright (C) 2002 Glenn Randers-Pehrson
 # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
 # For conditions of distribution and use, see copyright notice in png.h
 
@@ -9,6 +10,18 @@
 
 # where make install puts libpng.a and png.h
 prefix=/usr/local
+INCPATH=$(prefix)/include
+LIBPATH=$(prefix)/lib
+
+# override DESTDIR= on the make install command line to easily support
+# installing into a temporary location.  Example:
+#
+#    make install DESTDIR=/tmp/build/libpng
+#
+# If you're going to install into a temporary location
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
+# you execute make install.
+DESTDIR=
 
 CC=cc
 CFLAGS=-I../zlib -O
@@ -46,17 +59,18 @@
 	./pngtest
 
 install: libpng.a
-	-@mkdir $(prefix)/include
-	-@mkdir $(prefix)/include/libpng
-	-@mkdir $(prefix)/lib
-	-@rm -f $(prefix)/include/png.h
-	-@rm -f $(prefix)/include/pngconf.h
-	cp png.h $(prefix)/include/libpng
-	cp pngconf.h $(prefix)/include/libpng
-	chmod 644 $(prefix)/include/libpng/png.h
-	chmod 644 $(prefix)/include/libpng/pngconf.h
-	cp libpng.a $(prefix)/lib
-	chmod 644 $(prefix)/lib/libpng.a
+	-@mkdir $(DESTDIR)$(INCPATH)
+	-@mkdir $(DESTDIR)$(INCPATH)/libpng
+	-@mkdir $(DESTDIR)$(LIBPATH)
+	-@rm -f $(DESTDIR)$(INCPATH)/png.h
+	-@rm -f $(DESTDIR)$(INCPATH)/pngconf.h
+	cp png.h $(DESTDIR)$(INCPATH)/libpng
+	cp pngconf.h $(DESTDIR)$(INCPATH)/libpng
+	chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h
+	chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h
+	(cd $(DESTDIR)$(INCPATH); ln -f -s libpng/* .)
+	cp libpng.a $(DESTDIR)$(LIBPATH)
+	chmod 644 $(DESTDIR)$(LIBPATH)/libpng.a
 
 clean:
 	rm -f *.o libpng.a pngtest pngout.png ansi2knr
diff --git a/scripts/makefile.linux b/scripts/makefile.linux
index 67087b1..550b7cc 100644
--- a/scripts/makefile.linux
+++ b/scripts/makefile.linux
@@ -5,16 +5,17 @@
 
 LIBNAME = libpng10
 PNGMAJ = 0
-PNGMIN = 1.0.13
+PNGMIN = 1.0.14
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 CC=gcc
 
-# where "make install" puts libpng.a, libpng10/libpng10.so*,
+# where "make install" puts libpng10.a, libpng10.so*,
 # libpng10/png.h and libpng10/pngconf.h
+# Prefix must be a full pathname.
 prefix=/usr/local
 
-# Where the zlib library and include files are located
+# Where the zlib library and include files are located.
 #ZLIBLIB=/usr/local/lib
 #ZLIBINC=/usr/local/include
 ZLIBLIB=../zlib
@@ -41,6 +42,23 @@
 
 INCPATH=$(prefix)/include
 LIBPATH=$(prefix)/lib
+MANPATH=$(prefix)/man
+BINPATH=$(prefix)/bin
+
+# override DESTDIR= on the make install command line to easily support
+# installing into a temporary location.  Example:
+#
+#    make install DESTDIR=/tmp/build/libpng
+#
+# If you're going to install into a temporary location
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
+# you execute make install.
+DESTDIR=
+
+DB=$(DESTDIR)$(BINPATH)
+DI=$(DESTDIR)$(INCPATH)
+DL=$(DESTDIR)$(LIBPATH)
+DM=$(DESTDIR)$(MANPATH)
 
 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
 	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
@@ -53,12 +71,25 @@
 .c.pic.o:
 	$(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
 
-all: libpng.a $(LIBNAME).so pngtest
+all: libpng.a $(LIBNAME).so pngtest pngtest-static libpng.pc libpng-config
 
 libpng.a: $(OBJS)
 	ar rc $@ $(OBJS)
 	$(RANLIB) $@
 
+libpng.pc:
+	cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
+
+libpng-config:
+	( cat scripts/libpng-config-head.in; \
+	echo prefix=\"$(prefix)\"; \
+	echo cppflags=\"-I$(INCPATH)/$(LIBNAME)\"; \
+	echo cflags=\"\"; \
+	echo ldflags=\"-L$(LIBPATH) -Wl,-rpath,$(LIBPATH)\"; \
+	echo libs=\"-lpng10 -lz -lm\"; \
+	cat scripts/libpng-config-body.in ) > libpng-config
+	chmod +x libpng-config
+
 $(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ)
 	ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so
 
@@ -73,12 +104,12 @@
 pngtest: pngtest.o $(LIBNAME).so
 	$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
 
-pngtest-static: pngtest.o $(LIBNAME).a
+pngtest-static: pngtest.o libpng.a
 	$(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A)
 
 test: pngtest pngtest-static
 	@echo ""
-	@echo "   Running pngtest dynamically linked with libpng10.so:"
+	@echo "   Running pngtest dynamically linked with $(LIBNAME).so:"
 	@echo ""
 	./pngtest
 	@echo ""
@@ -87,46 +118,76 @@
 	./pngtest-static
 
 install-headers: png.h pngconf.h
-	-@if [ ! -d $(INCPATH) ]; then mkdir $(INCPATH); fi
-	-@if [ ! -d $(INCPATH)/$(LIBNAME) ]; then mkdir $(INCPATH)/$(LIBNAME); fi
-	cp png.h pngconf.h $(INCPATH)/$(LIBNAME)
-	chmod 644 $(INCPATH)/$(LIBNAME)/png.h $(INCPATH)/$(LIBNAME)/pngconf.h
-	-@/bin/rm -f $(INCPATH)/png.h $(INCPATH)/pngconf.h
-	-@/bin/rm -f $(INCPATH)/libpng
-	ln -sf $(INCPATH)/$(LIBNAME) $(INCPATH)/libpng
+	-@if [ ! -d $(DI) ]; then mkdir $(DI); fi
+	-@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
+	cp png.h pngconf.h $(DI)/$(LIBNAME)
+	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
+	-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
+	-@/bin/rm -f $(DI)/libpng
+	(cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
 
 install-static: install-headers libpng.a
-	-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
-	cp libpng.a $(LIBPATH)/$(LIBNAME).a
-	chmod 644 $(LIBPATH)/$(LIBNAME).a
-	-@/bin/rm -f $(LIBPATH)/libpng.a
-	ln -sf $(LIBPATH)/$(LIBNAME).a $(LIBPATH)/libpng.a
+	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
+	cp libpng.a $(DL)/$(LIBNAME).a
+	chmod 644 $(DL)/$(LIBNAME).a
+	-@/bin/rm -f $(DL)/libpng.a
+	(cd $(DL); ln -sf $(LIBNAME).a libpng.a)
 
-install-shared: install-headers $(LIBNAME).so.$(PNGVER)
-	-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
-	-@/bin/rm -f $(LIBPATH)/$(LIBNAME).so.$(PNGMAJ)* $(LIBPATH)/$(LIBNAME).so
-	-@/bin/rm -f $(LIBPATH)/libpng.so
-	-@/bin/rm -f $(LIBPATH)/libpng.so.2
-	-@/bin/rm -f $(LIBPATH)/libpng.so.2.*
-	cp $(LIBNAME).so.$(PNGVER) $(LIBPATH)
-	chmod 755 $(LIBPATH)/$(LIBNAME).so.$(PNGVER)
-	(cd $(LIBPATH); \
+install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc
+	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
+	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* $(DL)/$(LIBNAME).so
+	-@/bin/rm -f $(DL)/libpng.so
+	-@/bin/rm -f $(DL)/libpng.so.2
+	-@/bin/rm -f $(DL)/libpng.so.2.*
+	cp $(LIBNAME).so.$(PNGVER) $(DL)
+	chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER)
+	(cd $(DL); \
 	ln -sf $(LIBNAME).so.$(PNGVER) libpng.so; \
 	ln -sf $(LIBNAME).so.$(PNGVER) libpng.so.2; \
 	ln -sf $(LIBNAME).so.$(PNGVER) libpng.so.2.$(PNGMIN); \
 	ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \
 	ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so)
-	-@if [ ! -d $(LIBPATH)/pkgconfig ]; then mkdir $(LIBPATH)/pkgconfig; fi
-	cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
-	cp libpng.pc $(LIBPATH)/pkgconfig/libpng10.pc
-	chmod 644 $(LIBPATH)/pkgconfig/libpng10.pc
+	-@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi
+	-@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
+	-@/bin/rm -f $(DL)/pkgconfig/libpng.pc
+	cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
+	chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
+	(cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc)
 
-install: install-static install-shared
+install-man: libpng.3 libpngpf.3 png.5
+	-@if [ ! -d $(DM) ]; then mkdir $(DM); fi
+	-@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi
+	-@/bin/rm -f $(DM)/man3/libpng.3
+	-@/bin/rm -f $(DM)/man3/libpngpf.3
+	cp libpng.3 $(DM)/man3
+	cp libpngpf.3 $(DM)/man3
+	-@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi
+	-@/bin/rm -f $(DM)/man5/png.5
+	cp png.5 $(DM)/man5
 
+install-config: libpng-config
+	-@if [ ! -d $(DB) ]; then mkdir $(DB); fi
+	-@/bin/rm -f $(DB)/libpng-config
+	-@/bin/rm -f $(DB)/$(LIBNAME)-config
+	cp libpng-config $(DB)/$(LIBNAME)-config
+	chmod 755 $(DB)/$(LIBNAME)-config
+	(cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
+
+install: install-static install-shared install-man install-config
+
+# If you installed in $(DESTDIR), test-installed won't work until you
+# move the library to its final location.
+
+test-installed:
+	$(CC) -I$(ZLIBINC) \
+	   `$(BINPATH)/libpng10-config --cppflags --cflags` pngtest.c \
+	   -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) \
+	   -o pngtesti `$(BINPATH)/libpng10-config --ldflags --libs`
+	./pngtesti pngtest.png
 
 clean:
-	/bin/rm -f *.o libpng.a $(LIBNAME).so $(LIBNAME).so.$(PNMAJ)* \
-	pngtest pngout.png
+	/bin/rm -f *.o libpng.a pngtest pngout.png libpng.pc libpng-config \
+	$(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* pngtest-static pngtesti
 
 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
 writelock:
diff --git a/scripts/makefile.macosx b/scripts/makefile.macosx
index fe3ef9f..1051236 100644
--- a/scripts/makefile.macosx
+++ b/scripts/makefile.macosx
@@ -15,17 +15,37 @@
 ZLIBINC=../zlib
 
 CC=cc
-CFLAGS=-fno-common -I$(ZLIBINC) -O # -g -DPNG_DEBUG=5
-LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz
-LDSHARED=cc -lz -dynamiclib -compatibility_version $(VER) -current_version $(VER)
 
 PNGMAJ = 0
-PNGMIN = 1.0.13
-VER = $(PNGMAJ).$(PNGMIN)
+PNGMIN = 1.0.14
+PNGVER = $(PNGMAJ).$(PNGMIN)
+
+CFLAGS=-fno-common -I$(ZLIBINC) -O # -g -DPNG_DEBUG=5
+LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz
+LDSHARED=cc -lz -dynamiclib -compatibility_version $(PNGVER) \
+-current_version $(PNGVER)
+
 LIBNAME=libpng10
 SHAREDLIB_POSTFIX=dylib
-LIBPATH=$(prefix)/lib
 INCPATH=$(prefix)/include
+LIBPATH=$(prefix)/lib
+MANPATH=$(prefix)/man
+BINPATH=$(prefix)/bin
+
+# override DESTDIR= on the make install command line to easily support
+# installing into a temporary location.  Example:
+#
+#    make install DESTDIR=/tmp/build/libpng
+#
+# If you're going to install into a temporary location
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
+# you execute make install.
+DESTDIR=
+
+DB=$(DESTDIR)$(BINPATH)
+DI=$(DESTDIR)$(INCPATH)
+DL=$(DESTDIR)$(LIBPATH)
+DM=$(DESTDIR)$(MANPATH)
 
 #RANLIB=echo
 RANLIB=ranlib
@@ -34,15 +54,29 @@
 	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
 	pngwtran.o pngmem.o pngerror.o pngpread.o
 
-all: libpng.a pngtest shared
+all: libpng.a pngtest shared libpng.pc libpng-config
 
-shared: $(LIBNAME).$(VER).$(SHAREDLIB_POSTFIX)
+shared: $(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX)
+
+libpng.pc:
+	cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! | \
+	   sed -e s/-lm// > libpng.pc
+
+libpng-config:
+	( cat scripts/libpng-config-head.in; \
+	echo prefix=\"$(prefix)\"; \
+	echo cppflags=\"-I$(INCPATH)/$(LIBNAME)\"; \
+	echo cflags=\"\"; \
+	echo ldflags=\"-L$(LIBPATH)\"; \
+	echo libs=\"-lpng10 -lz\"; \
+	cat scripts/libpng-config-body.in ) > libpng-config
+	chmod +x libpng-config
 
 libpng.a: $(OBJS)
 	ar rc $@  $(OBJS)
 	$(RANLIB) $@
 
-$(LIBNAME).$(VER).$(SHAREDLIB_POSTFIX): $(OBJS)
+$(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX): $(OBJS)
 	$(LDSHARED) -o $@ $(OBJS)
 
 pngtest: pngtest.o libpng.a
@@ -51,53 +85,84 @@
 test: pngtest
 	./pngtest
 
-
 install-headers: png.h pngconf.h
-	-@if [ ! -d $(INCPATH) ]; then mkdir $(INCPATH); fi
-	-@if [ ! -d $(INCPATH)/$(LIBNAME) ]; then mkdir $(INCPATH)/$(LIBNAME); fi
-	cp png.h pngconf.h $(INCPATH)/$(LIBNAME)
-	chmod 644 $(INCPATH)/$(LIBNAME)/png.h $(INCPATH)/$(LIBNAME)/pngconf.h
-	-@/bin/rm -f $(INCPATH)/png.h $(INCPATH)/pngconf.h
-	-@/bin/rm -f $(INCPATH)/libpng
-	ln -f -s $(INCPATH)/$(LIBNAME) $(INCPATH)/libpng
+	-@if [ ! -d $(DI) ]; then mkdir $(DI); fi
+	-@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
+	cp png.h pngconf.h $(DI)/$(LIBNAME)
+	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
+	-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
+	-@/bin/rm -f $(DI)/libpng
+	(cd $(DI); ln -f -s $(LIBNAME) libpng; ln -f -s $(LIBNAME)/* .)
 
 install-static: install-headers libpng.a
-	-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
-	cp libpng.a $(LIBPATH)/$(LIBNAME).a
-	chmod 644 $(LIBPATH)/$(LIBNAME).a
-	-@/bin/rm -f $(LIBPATH)/libpng.a
-	ln -f -s $(LIBPATH)/$(LIBNAME).a $(LIBPATH)/libpng.a
+	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
+	cp libpng.a $(DL)/$(LIBNAME).a
+	chmod 644 $(DL)/$(LIBNAME).a
+	-@/bin/rm -f $(DL)/libpng.a
+	(cd $(DL); ln -f -s $(LIBNAME).a libpng.a)
 
-install-shared: install-headers $(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX)
-	-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
-	-@/bin/rm -f $(LIBPATH)/$(LIBNAME).$(PNGMAJ)*.$(SHAREDLIB_POSTFIX)
-	-@/bin/rm -f $(LIBPATH)/$(LIBNAME).$(SHAREDLIB_POSTFIX)
+install-shared: install-headers $(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX) libpng.pc
+	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
+	-@/bin/rm -f \
+	$(DL)/$(LIBNAME).$(PNGMAJ)*.$(SHAREDLIB_POSTFIX)
+	-@/bin/rm -f $(DL)/$(LIBNAME).$(SHAREDLIB_POSTFIX)
 	-@/bin/rm -f libpng.$(SHARED_POSTFIX)
-	-@/bin/rm -f libpng.2.$(SHARED_POSTFIX)
-	-@/bin/rm -f libpng.2.*.$(SHARED_POSTFIX)
-	cp $(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX) $(LIBPATH)
-	chmod 755 $(LIBPATH)/$(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX)
-	(cd $(LIBPATH); \
-	ln -f -s $(LIBNAME).$(PNGVER).$(SHARED_POSTFIX) ]
+	-@/bin/rm -f libpng.3.$(SHARED_POSTFIX)
+	-@/bin/rm -f libpng.3.*.$(SHARED_POSTFIX)
+	cp $(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX) $(DL)
+	chmod 755 $(DL)/$(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX)
+	(cd $(DL); \
+	ln -f -s $(LIBNAME).$(PNGVER).$(SHARED_POSTFIX) \
 	libpng.$(SHARED_POSTFIX); \
-	ln -f -s $(LIBNAME).$(PNGVER).$(SHARED_POSTFIX) ]
-	libpng.2.$(SHARED_POSTFIX); \
-	ln -f -s $(LIBNAME).$(PNGVER).$(SHARED_POSTFIX) ]
-	libpng.2.$(PNGMIN).$(SHARED_POSTFIX); \
-	ln -sf $(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX) \
+	ln -f -s $(LIBNAME).$(PNGVER).$(SHARED_POSTFIX) \
+	libpng.3.$(SHARED_POSTFIX); \
+	ln -f -s $(LIBNAME).$(PNGVER).$(SHARED_POSTFIX) \
+	libpng.3.$(PNGMIN).$(SHARED_POSTFIX); \
+	ln -f -s $(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX) \
 	$(LIBNAME).$(PNGMAJ).$(SHAREDLIB_POSTFIX); \
-	ln -sf $(LIBNAME).$(PNGMAJ).$(SHAREDLIB_POSTFIX) \
+	ln -f -s $(LIBNAME).$(PNGMAJ).$(SHAREDLIB_POSTFIX) \
 	$(LIBNAME).$(SHAREDLIB_POSTFIX))
-	-@if [ ! -d $(LIBPATH)/pkgconfig ]; then mkdir $(LIBPATH)/pkgconfig; fi
-	cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
-	cp libpng.pc $(LIBPATH)/pkgconfig/libpng10.pc
-	chmod 644 $(LIBPATH)/pkgconfig/libpng10.pc
+	-@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi
+	-@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
+	-@/bin/rm -f $(DL)/pkgconfig/libpng.pc
+	cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
+	chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
+	(cd $(DL)/pkgconfig; ln -f -s $(LIBNAME).pc libpng.pc)
 
-install: install-shared
+install-man: libpng.3 libpngpf.3 png.5
+	-@if [ ! -d $(DM) ]; then mkdir $(DM); fi
+	-@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi
+	-@/bin/rm -f $(DM)/man3/libpng.3
+	-@/bin/rm -f $(DM)/man3/libpngpf.3
+	cp libpng.3 $(DM)/man3
+	cp libpngpf.3 $(DM)/man3
+	-@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi
+	-@/bin/rm -f $(DM)/man5/png.5
+	cp png.5 $(DM)/man5
+
+install-config: libpng-config
+	-@if [ ! -d $(DB) ]; then mkdir $(DB); fi
+	-@/bin/rm -f $(DB)/libpng-config
+	-@/bin/rm -f $(DB)/$(LIBNAME)-config
+	cp libpng-config $(DB)/$(LIBNAME)-config
+	chmod 755 $(DB)/$(LIBNAME)-config
+	(cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
+
+install: install-static install-shared install-man install-config
+
+# If you installed in $(DESTDIR), test-installed won't work until you
+# move the library to its final location.
+
+test-installed:
+	$(CC) $(CFLAGS) \
+	   `$(BINPATH)/libpng10-config --cppflags --cflags` pngtest.c \
+	   -L$(ZLIBLIB) \
+	   -o pngtesti `$(BINPATH)/libpng10-config --ldflags --libs`
+	./pngtesti pngtest.png
 
 clean:
-	rm -f *.o libpng.a pngtest pngout.png \
-	$(LIBNAME).$(VER).$(SHAREDLIB_POSTFIX) \
+	rm -f *.o libpng.a pngtest pngout.png libpng.pc libpng-config \
+	$(LIBNAME).$(PNGVER).$(SHAREDLIB_POSTFIX) \
 	$(LIBNAME).$(SHAREDLIB_POSTFIX)
 
 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
diff --git a/scripts/makefile.mips b/scripts/makefile.mips
index 602a2f9..f1a557d 100644
--- a/scripts/makefile.mips
+++ b/scripts/makefile.mips
@@ -1,9 +1,22 @@
 # makefile for libpng
+# Copyright (C) Glenn Randers-Pehrson
 # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
 # For conditions of distribution and use, see copyright notice in png.h
 
 # where make install puts libpng.a and png.h
 prefix=/usr/local
+INCPATH=$(prefix)/include
+LIBPATH=$(prefix)/lib
+
+# override DESTDIR= on the make install command line to easily support
+# installing into a temporary location.  Example:
+#
+#    make install DESTDIR=/tmp/build/libpng
+#
+# If you're going to install into a temporary location
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
+# you execute make install.
+DESTDIR=
 
 CC=cc
 CFLAGS=-I../zlib -O -systype sysv -DSYSV -w -Dmips
@@ -30,17 +43,18 @@
 	./pngtest
 
 install: libpng.a
-	-@mkdir $(prefix)/include
-	-@mkdir $(prefix)/include/libpng
-	-@mkdir $(prefix)/lib
-	-@rm -f $(prefix)/include/png.h
-	-@rm -f $(prefix)/include/pngconf.h
-	cp png.h $(prefix)/include/libpng
-	cp pngconf.h $(prefix)/include/libpng
-	chmod 644 $(prefix)/include/libpng/png.h
-	chmod 644 $(prefix)/include/libpng/pngconf.h
-	cp libpng.a $(prefix)/lib
-	chmod 644 $(prefix)/lib/libpng.a
+	-@mkdir $(DESTDIR)$(INCPATH)
+	-@mkdir $(DESTDIR)$(INCPATH)/libpng
+	-@mkdir $(DESTDIR)$(LIBPATH)
+	-@rm -f $(DESTDIR)$(INCPATH)/png.h
+	-@rm -f $(DESTDIR)$(INCPATH)/pngconf.h
+	cp png.h $(DESTDIR)$(INCPATH)/libpng
+	cp pngconf.h $(DESTDIR)$(INCPATH)/libpng
+	chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h
+	chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h
+	(cd $(DESTDIR)$(INCPATH); ln -f -s libpng/* .)
+	cp libpng.a $(DESTDIR)$(LIBPATH)
+	chmod 644 $(DESTDIR)$(LIBPATH)/libpng.a
 
 clean:
 	rm -f *.o libpng.a pngtest pngout.png
diff --git a/scripts/makefile.ne10bsd b/scripts/makefile.ne10bsd
new file mode 100644
index 0000000..1a036fe
--- /dev/null
+++ b/scripts/makefile.ne10bsd
@@ -0,0 +1,44 @@
+# makefile for libpng for NetBSD for the standard
+# make obj && make depend && make && make test
+# make includes && make install
+# Copyright (C) 2002 Patrick R.L. Welche
+# For conditions of distribution and use, see copyright notice in png.h
+
+# You should also run makefile.netbsd
+
+LOCALBASE?=/usr/local
+LIBDIR=	${LOCALBASE}/lib
+MANDIR= ${LOCALBASE}/man
+INCSDIR=${LOCALBASE}/include/libpng10
+
+LIB=	png10
+SHLIB_MAJOR=	0
+SHLIB_MINOR=	1.0.14
+SRCS=	pnggccrd.c png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
+		pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
+		pngwtran.c pngmem.c pngerror.c pngpread.c
+INCS=	png.h pngconf.h
+MAN=	libpng.3 libpngpf.3 png.5
+
+CPPFLAGS+=-I${.CURDIR} -DPNG_USE_PNGGCCRD
+
+# something like this for mmx assembler, but it core dumps for me at the moment
+# .if ${MACHINE_ARCH} == "i386"
+#   CPPFLAGS+=-DPNG_THREAD_UNSAFE_OK
+#   MKLINT= no
+# .else
+    CPPFLAGS+=-DPNG_NO_ASSEMBLER_CODE
+# .endif
+
+CLEANFILES+=pngtest.o pngtest
+
+pngtest.o:	pngtest.c
+	${CC} -c ${CPPFLAGS} ${CFLAGS} ${.ALLSRC} -o ${.TARGET}
+
+pngtest:	pngtest.o libpng.a
+	${CC} ${LDFLAGS} ${.ALLSRC} -o${.TARGET} -lz -lm
+
+test:	pngtest
+	cd ${.CURDIR} && ${.OBJDIR}/pngtest
+
+.include <bsd.lib.mk>
diff --git a/scripts/makefile.ne12bsd b/scripts/makefile.ne12bsd
index 5816f97..1a036fe 100644
--- a/scripts/makefile.ne12bsd
+++ b/scripts/makefile.ne12bsd
@@ -13,7 +13,7 @@
 
 LIB=	png10
 SHLIB_MAJOR=	0
-SHLIB_MINOR=	1.0.13
+SHLIB_MINOR=	1.0.14
 SRCS=	pnggccrd.c png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
 		pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
 		pngwtran.c pngmem.c pngerror.c pngpread.c
diff --git a/scripts/makefile.netbsd b/scripts/makefile.netbsd
index ab336f9..22cfd71 100644
--- a/scripts/makefile.netbsd
+++ b/scripts/makefile.netbsd
@@ -13,7 +13,7 @@
 
 LIB=	png
 SHLIB_MAJOR=	2
-SHLIB_MINOR=	1.0.13
+SHLIB_MINOR=	1.0.14
 SRCS=	pnggccrd.c png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
 		pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
 		pngwtran.c pngmem.c pngerror.c pngpread.c
diff --git a/scripts/makefile.openbsd b/scripts/makefile.openbsd
index 3839ce1..f6a3e76 100644
--- a/scripts/makefile.openbsd
+++ b/scripts/makefile.openbsd
@@ -7,7 +7,7 @@
 MANDIR= ${PREFIX}/man/cat
 
 SHLIB_MAJOR=	0
-SHLIB_MINOR=	1.0.13
+SHLIB_MINOR=	1.0.14
 
 LIB=	png
 SRCS=	png.c pngerror.c pnggccrd.c pngget.c pngmem.c pngpread.c \
@@ -65,6 +65,8 @@
 	${INSTALL} ${INSTALL_COPY} -o ${SHAREOWN} -g ${SHAREGRP} \
 		-m ${NONBINMODE} ${HDRS} ${DESTDIR}${PREFIX}/include/libpng
 	${INSTALL} ${INSTALL_COPY} -o ${SHAREOWN} -g ${SHAREGRP} \
+		-m ${NONBINMODE} ${HDRS} ${DESTDIR}${PREFIX}/include
+	${INSTALL} ${INSTALL_COPY} -o ${SHAREOWN} -g ${SHAREGRP} \
 		-m ${NONBINMODE} ${DOCS} ${DESTDIR}${PREFIX}/share/doc/png
 
 .include <bsd.lib.mk>
diff --git a/scripts/makefile.sco b/scripts/makefile.sco
index cd053cc..67e1d62 100644
--- a/scripts/makefile.sco
+++ b/scripts/makefile.sco
@@ -1,6 +1,7 @@
 # makefile for SCO OSr5  ELF and Unixware 7 with Native cc
 # Contributed by Mike Hopkirk (hops@sco.com) modified from Makefile.lnx
 #   force ELF build dynamic linking, SONAME setting in lib and RPATH in app
+# Copyright (C) 2002 Glenn Randers-Pehrson
 # Copyright (C) 1998 Greg Roelofs
 # Copyright (C) 1996, 1997 Andreas Dilger
 # For conditions of distribution and use, see copyright notice in png.h
@@ -17,20 +18,35 @@
 ZLIBINC=../zlib
 
 CFLAGS= -dy -belf -I$(ZLIBINC) -O3
-LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
+LDFLAGS=-L. -L$(ZLIBLIB) -lpng10 -lz -lm
 
 #RANLIB=ranlib
 RANLIB=echo
 
-# read libpng.txt or png.h to see why PNGMAJ is 0.  You should not
-# have to change it.
 PNGMAJ = 0
-PNGMIN = 1.0.13
+PNGMIN = 1.0.14
 PNGVER = $(PNGMAJ).$(PNGMIN)
 LIBNAME = libpng10
 
 INCPATH=$(prefix)/include/libpng
 LIBPATH=$(prefix)/lib
+MANPATH=$(prefix)/man
+BINPATH=$(prefix)/bin
+
+# override DESTDIR= on the make install command line to easily support
+# installing into a temporary location.  Example:
+#
+#    make install DESTDIR=/tmp/build/libpng
+#
+# If you're going to install into a temporary location
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
+# you execute make install.
+DESTDIR=
+
+DB=$(DESTDIR)$(BINPATH)
+DI=$(DESTDIR)$(INCPATH)
+DL=$(DESTDIR)$(LIBPATH)
+DM=$(DESTDIR)$(MANPATH)
 
 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
 	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
@@ -43,12 +59,25 @@
 .c.pic.o:
 	$(CC) -c $(CFLAGS) -KPIC -o $@ $*.c
 
-all: libpng.a $(LIBNAME).so pngtest
+all: libpng.a $(LIBNAME).so pngtest libpng.pc libpng-config
 
 libpng.a: $(OBJS)
 	ar rc $@ $(OBJS)
 	$(RANLIB) $@
 
+libpng.pc:
+	cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
+
+libpng-config:
+	( cat scripts/libpng-config-head.in; \
+	echo prefix=\"$(prefix)\"; \
+	echo cppflags=\"-I$(INCPATH)/$(LIBNAME)\"; \
+	echo cflags=\"-belf\"; \
+	echo ldflags=\"-L$(LIBPATH)\"; \
+	echo libs=\"-lpng10 -lz -lm\"; \
+	cat scripts/libpng-config-body.in ) > libpng-config
+	chmod +x libpng-config
+
 $(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ)
 	ln -f -s $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so
 
@@ -65,45 +94,80 @@
 test: pngtest
 	./pngtest
 
-
 install-headers: png.h pngconf.h
-	-@if [ ! -d $(INCPATH) ]; then mkdir $(INCPATH); fi
-	-@if [ ! -d $(INCPATH)/$(LIBNAME) ]; then mkdir $(INCPATH)/$(LIBNAME); fi
-	-@/bin/rm -f $(INCPATH)/png.h
-	-@/bin/rm -f $(INCPATH)/pngconf.h
-	cp png.h pngconf.h $(INCPATH)/$(LIBNAME)
-	chmod 644 $(INCPATH)/$(LIBNAME)/png.h $(INCPATH)/$(LIBNAME)/pngconf.h
-	-@/bin/rm -f $(INCPATH)/png.h $(INCPATH)/pngconf.h
-	-@/bin/rm -f $(INCPATH)/libpng
-	ln -f -s $(INCPATH)/$(LIBNAME) $(INCPATH)/libpng
+	-@if [ ! -d $(DI) ]; then mkdir $(DI); fi
+	-@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
+	-@/bin/rm -f $(DI)/png.h
+	-@/bin/rm -f $(DI)/pngconf.h
+	cp png.h pngconf.h $(DI)/$(LIBNAME)
+	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
+	-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
+	-@/bin/rm -f $(DI)/libpng
+	(cd $(DI); ln -f -s $(LIBNAME) libpng; ln -f -s $(LIBNAME)/* .)
 
 install-static: install-headers libpng.a
-	-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
-	cp libpng.a $(LIBPATH)/$(LIBNAME).a
-	chmod 644 $(LIBPATH)/$(LIBNAME).a
-	-@/bin/rm -f $(LIBPATH)/libpng.a
-	ln -f -s $(LIBPATH)/$(LIBNAME).a $(LIBPATH)/libpng.a
+	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
+	cp libpng.a $(DL)/$(LIBNAME).a
+	chmod 644 $(DL)/$(LIBNAME).a
+	-@/bin/rm -f $(DL)/libpng.a
+	(cd $(DL); ln -f -s $(LIBNAME).a libpng.a)
 
-install-shared: install-headers $(LIBNAME).so.$(PNGVER)
-	-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
-	-@/bin/rm -f $(LIBPATH)/$(LIBNAME).so.$(PNGMAJ)* $(LIBPATH)/$(LIBNAME).so
-	-@/bin/rm -f $(LIBPATH)/libpng.so
-	-@/bin/rm -f $(LIBPATH)/libpng.so.2
-	-@/bin/rm -f $(LIBPATH)/libpng.so.2.*
-	cp $(LIBNAME).so.$(PNGVER) $(LIBPATH)
-	chmod 755 $(LIBPATH)/$(LIBNAME).so.$(PNGVER)
-	(cd $(LIBPATH); \
+install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc
+	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
+	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* $(DL)/$(LIBNAME).so
+	-@/bin/rm -f $(DL)/libpng.so
+	-@/bin/rm -f $(DL)/libpng.so.2
+	-@/bin/rm -f $(DL)/libpng.so.2.*
+	cp $(LIBNAME).so.$(PNGVER) $(DL)
+	chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER)
+	(cd $(DL); \
 	ln -f -s $(LIBNAME).so.$(PNGVER) libpng.so; \
 	ln -f -s $(LIBNAME).so.$(PNGVER) libpng.so.2; \
 	ln -f -s $(LIBNAME).so.$(PNGVER) libpng.so.2.$(PNGMIN); \
 	ln -f -s $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \
 	ln -f -s $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so)
-	-@if [ ! -d $(LIBPATH)/pkgconfig ]; then mkdir $(LIBPATH)/pkgconfig; fi
-	cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
-	cp libpng.pc $(LIBPATH)/pkgconfig/libpng10.pc
-	chmod 644 $(LIBPATH)/pkgconfig/libpng10.pc
+	-@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi
+	-@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
+	-@/bin/rm -f $(DL)/pkgconfig/libpng.pc
+	cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
+	chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
+	(cd $(DL)/pkgconfig; ln -f -s $(LIBNAME).pc libpng.pc)
 
-install: install-static install-shared
+install-man: libpng.3 libpngpf.3 png.5
+	-@if [ ! -d $(DM) ]; then mkdir $(DM); fi
+	-@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi
+	-@/bin/rm -f $(DM)/man3/libpng.3
+	-@/bin/rm -f $(DM)/man3/libpngpf.3
+	cp libpng.3 $(DM)/man3
+	cp libpngpf.3 $(DM)/man3
+	-@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi
+	-@/bin/rm -f $(DM)/man5/png.5
+	cp png.5 $(DM)/man5
+
+install-config: libpng-config
+	-@if [ ! -d $(DB) ]; then mkdir $(DB); fi
+	-@/bin/rm -f $(DB)/libpng-config
+	-@/bin/rm -f $(DB)/$(LIBNAME)-config
+	cp libpng-config $(DB)/$(LIBNAME)-config
+	chmod 755 $(DB)/$(LIBNAME)-config
+	(cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
+
+install: install-static install-shared install-man install-config
+
+# If you installed in $(DESTDIR), test-installed won't work until you
+# move the library to its final location.
+
+test-installed:
+	$(CC) $(CFLAGS) \
+	   `$(BINPATH)/libpng10-config --cppflags --cflags` pngtest.c \
+	   -L$(ZLIBLIB) \
+	   -o pngtesti `$(BINPATH)/libpng10-config --ldflags --libs`
+	./pngtesti pngtest.png
+
+clean:
+	/bin/rm -f *.o libpng.a pngtest pngout.png libpng.pc libpng-config \
+	$(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* pngtest-static pngtesti
+
 
 clean:
 	/bin/rm -f *.o libpng.a $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* pngtest pngout.png
diff --git a/scripts/makefile.sggcc b/scripts/makefile.sggcc
index 452290f..031b03e 100644
--- a/scripts/makefile.sggcc
+++ b/scripts/makefile.sggcc
@@ -1,101 +1,184 @@
-# makefile for libpng, SGI IRIX with gcc
-# Copyright (C) 2002 Glenn Randers-Pehrson
+# makefile for libpng.a and libpng10.so, SGI IRIX with 'cc'
+# Copyright (C) 2001-2002 Glenn Randers-Pehrson
 # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
 # For conditions of distribution and use, see copyright notice in png.h
 
-# where make install puts libpng.a and png.h
+# Where make install puts libpng.a, libpng10.so, and libpng10/png.h
+# Prefix must be a full pathname.
+
 prefix=/usr/local
 
 # Where the zlib library and include files are located
-ZLIBLIB=/usr/local/lib32
-ZLIBINC=/usr/local/include
-#ZLIBLIB=../zlib
-#ZLIBINC=../zlib
+#ZLIBLIB=/usr/local/lib32
+#ZLIBINC=/usr/local/include
+#ZLIBLIB=/usr/local/lib
+#ZLIBINC=/usr/local/include
+ZLIBLIB=../zlib
+ZLIBINC=../zlib
+
+LIBNAME=libpng10
+PNGMAJ = 0
+PNGMIN = 1.0.14
+PNGVER = $(PNGMAJ).$(PNGMIN)
+CC=gcc
 
 # ABI can be blank to use default for your system, -32, -o32, -n32, or -64
 # See "man abi".  zlib must be built with the same ABI.
 ABI=
 
-CC=gcc
-
 WARNMORE= # -g -DPNG_DEBUG=5
 CFLAGS=$(ABI) -I$(ZLIBINC) -O2 $(WARNMORE) -fPIC -mabi=n32
 LDFLAGS=$(ABI) -L. -L$(ZLIBLIB) -lpng -lz -lm
-LDSHARED=CC $(ABI) -shared
-
-PNGMAJ = 0
-PNGMIN = 1.0.13
-PNGVER = $(PNGMAJ).$(PNGMIN)
+LDSHARED=cc $(ABI) -shared -soname $(LIBNAME).so.$(PNGMAJ)
 # See "man dso" for info about shared objects
-LIBS=libpng10.so.$(PNGMAJ).$(PNGVER)
-LIBNAME=libpng10
-LIBPATH=$(prefix)/lib32
 
 RANLIB=echo
 #RANLIB=ranlib
 
-OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
+INCPATH=$(prefix)/include
+LIBPATH=$(prefix)/lib
+#LIBPATH=$(prefix)/lib32
+MANPATH=$(prefix)/man
+BINPATH=$(prefix)/bin
+
+# override DESTDIR= on the make install command line to easily support
+# installing into a temporary location.  Example:
+#
+#    make install DESTDIR=/tmp/build/libpng
+#
+# If you're going to install into a temporary location
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
+# you execute make install.
+DESTDIR=
+
+DB=$(DESTDIR)$(BINPATH)
+DI=$(DESTDIR)$(INCPATH)
+DL=$(DESTDIR)$(LIBPATH)
+DM=$(DESTDIR)$(MANPATH)
+
+OBJS = pnggccrd.o png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
 	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
 	pngwtran.o pngmem.o pngerror.o pngpread.o
 
-all: libpng.a $(LIBNAME).so.$(PNGVER) pngtest
+all: libpng.a pngtest shared libpng.pc libpng-config
 
 libpng.a: $(OBJS)
-	ar rc $@  $(OBJS)
+	ar rc $@ $(OBJS)
 	$(RANLIB) $@
 
+shared: $(LIBNAME).so.$(PNGVER)
+
+libpng.pc:
+	cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > \
+	libpng.pc
+
+libpng-config:
+	( cat scripts/libpng-config-head.in; \
+	echo prefix=\"$(prefix)\"; \
+	echo cppflags=\"-I$(INCPATH)/$(LIBNAME) -DPNG_USE_PNGGCCRD \
+		-DPNG_NO_ASSEMBLER_CODE\"; \
+	echo cflags=\"$(ABI)\"; \
+	echo ldflags=\"-L$(LIBPATH)\"; \
+	echo rpath=\"$(LIBPATH)\"; \
+	echo libs=\"-lpng10 -lz -lm\"; \
+	cat scripts/libpng-config-body.in ) > libpng-config
+	chmod +x libpng-config
+
+$(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ)
+	ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so
+
+$(LIBNAME).so.$(PNGMAJ): $(LIBNAME).so.$(PNGVER)
+	ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ)
+
 $(LIBNAME).so.$(PNGVER): $(OBJS)
 	$(LDSHARED) -o $@ $(OBJS)
 	rm -f $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)
-	ln -s $@ $(LIBNAME).so
-	ln -s $@ $(LIBNAME).so.$(PNGMAJ)
 
 pngtest: pngtest.o libpng.a
 	$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
 
 test: pngtest
+	echo
+	echo Testing local static library.
 	./pngtest
 
-
 install-headers: png.h pngconf.h
-	-@if [ ! -d $(INCPATH) ]; then mkdir $(INCPATH); fi
-	-@if [ ! -d $(INCPATH)/$(LIBNAME) ]; then mkdir $(INCPATH)/$(LIBNAME); fi
-	cp png.h pngconf.h $(INCPATH)/$(LIBNAME)
-	chmod 644 $(INCPATH)/$(LIBNAME)/png.h $(INCPATH)/$(LIBNAME)/pngconf.h
-	-@/bin/rm -f $(INCPATH)/png.h $(INCPATH)/pngconf.h
-	-@/bin/rm -f $(INCPATH)/libpng
-	ln -f -s $(INCPATH)/$(LIBNAME) $(INCPATH)/libpng
+	-@if [ ! -d $(DI) ]; then mkdir $(DI); fi
+	-@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
+	cp png.h pngconf.h $(DI)/$(LIBNAME)
+	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
+	-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
+	-@/bin/rm -f $(DI)/libpng
+	(cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
 
 install-static: install-headers libpng.a
-	-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
-	cp libpng.a $(LIBPATH)/$(LIBNAME).a
-	chmod 644 $(LIBPATH)/$(LIBNAME).a
-	-@/bin/rm -f $(LIBPATH)/libpng.a
-	ln -f -s $(LIBPATH)/$(LIBNAME).a $(LIBPATH)/libpng.a
+	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
+	cp libpng.a $(DL)/$(LIBNAME).a
+	chmod 644 $(DL)/$(LIBNAME).a
+	-@/bin/rm -f $(DL)/libpng.a
+	(cd $(DL); ln -sf $(LIBNAME).a libpng.a)
 
-install-shared: install-headers $(LIBNAME).so.$(PNGVER)
-	-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
-	-@/bin/rm -f $(LIBPATH)/$(LIBNAME).so.$(PNGMAJ)* $(LIBPATH)/$(LIBNAME).so
-	-@/bin/rm -f $(LIBPATH)/libpng.so
-	-@/bin/rm -f $(LIBPATH)/libpng.so.2
-	-@/bin/rm -f $(LIBPATH)/libpng.so.2.*
-	cp $(LIBNAME).so.$(PNGVER) $(LIBPATH)
-	chmod 755 $(LIBPATH)/$(LIBNAME).so.$(PNGVER)
-	(cd $(LIBPATH); \
-	ln -f -s $(LIBNAME).so.$(PNGVER) libpng.so; \
-	ln -f -s $(LIBNAME).so.$(PNGVER) libpng.so.2; \
-	ln -f -s $(LIBNAME).so.$(PNGVER) libpng.so.2.$(PNGMIN); \
-	ln -f -s $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \
-	ln -f -s $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so)
-	-@if [ ! -d $(LIBPATH)/pkgconfig ]; then mkdir $(LIBPATH)/pkgconfig; fi
-	cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
-	cp libpng.pc $(LIBPATH)/pkgconfig/libpng10.pc
-	chmod 644 $(LIBPATH)/pkgconfig/libpng10.pc
+install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc
+	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
+	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* $(DL)/$(LIBNAME).so
+	-@/bin/rm -f $(DL)/libpng.so
+	-@/bin/rm -f $(DL)/libpng.so.2
+	-@/bin/rm -f $(DL)/libpng.so.2.*
+	cp $(LIBNAME).so.$(PNGVER) $(DL)
+	chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER)
+	(cd $(DL); \
+	ln -sf $(LIBNAME).so.$(PNGVER) libpng.so; \
+	ln -sf $(LIBNAME).so.$(PNGVER) libpng.so.2; \
+	ln -sf $(LIBNAME).so.$(PNGVER) libpng.so.2.$(PNGMIN); \
+	ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \
+	ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so)
+	-@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi
+	-@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
+	-@/bin/rm -f $(DL)/pkgconfig/libpng.pc
+	cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
+	chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
+	(cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc)
 
-install: install-static install-shared
+install-man: libpng.3 libpngpf.3 png.5
+	-@if [ ! -d $(DM) ]; then mkdir $(DM); fi
+	-@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi
+	-@/bin/rm -f $(DM)/man3/libpng.3
+	-@/bin/rm -f $(DM)/man3/libpngpf.3
+	cp libpng.3 $(DM)/man3
+	cp libpngpf.3 $(DM)/man3
+	-@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi
+	-@/bin/rm -f $(DM)/man5/png.5
+	cp png.5 $(DM)/man5
+
+install-config: libpng-config
+	-@if [ ! -d $(DB) ]; then mkdir $(DB); fi
+	-@/bin/rm -f $(DB)/libpng-config
+	-@/bin/rm -f $(DB)/$(LIBNAME)-config
+	cp libpng-config $(DB)/$(LIBNAME)-config
+	chmod 755 $(DB)/$(LIBNAME)-config
+	(cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
+
+install: install-static install-shared install-man install-config
+
+# If you installed in $(DESTDIR), test-installed won't work until you
+# move the library to its final location.
+
+test-installed:
+	$(CC) -I$(ZLIBINC) \
+	   `$(BINPATH)/libpng10-config --cppflags --cflags` pngtest.c \
+	   -L$(ZLIBLIB) -rpath $(ZLIBLIB):`$(BINPATH)/libpng10-config --rpath` \
+	   -o pngtesti `$(BINPATH)/libpng10-config --ldflags --libs`
+	echo
+	echo Testing installed dynamic shared library.
+	./pngtesti pngtest.png
 
 clean:
-	rm -f *.o libpng.a pngtest pngout.png
+	rm -f *.o libpng.a pngtest pngout.png libpng.pc libpng-config \
+	$(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* so_locations
+
+DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
+writelock:
+	chmod a-w *.[ch35] $(DOCS) scripts/*
 
 # DO NOT DELETE THIS LINE -- make depend depends on it.
 
@@ -115,4 +198,5 @@
 pngwtran.o: png.h pngconf.h
 pngwutil.o: png.h pngconf.h
 pngpread.o: png.h pngconf.h
+pnggccrd.o: png.h pngconf.h
 
diff --git a/scripts/makefile.sgi b/scripts/makefile.sgi
index 251a036..9c586fe 100644
--- a/scripts/makefile.sgi
+++ b/scripts/makefile.sgi
@@ -3,7 +3,14 @@
 # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
 # For conditions of distribution and use, see copyright notice in png.h
 
-# where make install puts libpng.a, libpng10.so and libpng10/png.h
+LIBNAME=libpng10
+PNGMAJ = 0
+PNGMIN = 1.0.14
+PNGVER = $(PNGMAJ).$(PNGMIN)
+
+# Where make install puts libpng.a, libpng10.so, and libpng10/png.h
+# Prefix must be a full pathname.
+
 prefix=/usr/local
 
 # Where the zlib library and include files are located
@@ -26,13 +33,8 @@
 CFLAGS=$(ABI) -I$(ZLIBINC) -O $(WARNMORE) -DPNG_USE_PNGGCCRD -DPNG_NO_ASSEMBLER_CODE
 LDFLAGS_A=$(ABI) -L. -L$(ZLIBLIB) -lpng10 -lz -lm
 LDFLAGS=$(ABI) -L. -L$(ZLIBLIB) -lpng -lz -lm
-LDSHARED=cc $(ABI) -shared
-
+LDSHARED=cc $(ABI) -shared -soname $(LIBNAME).so.$(PNGMAJ)
 # See "man dso" for info about shared objects
-LIBNAME=libpng10
-PNGMAJ = 0
-PNGMIN = 1.0.13
-PNGVER = $(PNGMAJ).$(PNGMIN)
 
 RANLIB=echo
 #RANLIB=ranlib
@@ -40,71 +42,141 @@
 INCPATH=$(prefix)/include
 LIBPATH=$(prefix)/lib
 #LIBPATH=$(prefix)/lib32
+MANPATH=$(prefix)/man
+BINPATH=$(prefix)/bin
+
+# override DESTDIR= on the make install command line to easily support
+# installing into a temporary location.  Example:
+#
+#    make install DESTDIR=/tmp/build/libpng
+#
+# If you're going to install into a temporary location
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
+# you execute make install.
+DESTDIR=
+
+DB=$(DESTDIR)$(BINPATH)
+DI=$(DESTDIR)$(INCPATH)
+DL=$(DESTDIR)$(LIBPATH)
+DM=$(DESTDIR)$(MANPATH)
 
 OBJS = pnggccrd.o png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
 	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
 	pngwtran.o pngmem.o pngerror.o pngpread.o
 
-all: libpng.a pngtest shared
-
-shared: $(LIBNAME).so.$(PNGMAJ).$(PNGVER)
+all: libpng.a pngtest shared libpng.pc libpng-config
 
 libpng.a: $(OBJS)
-	ar rc $@  $(OBJS)
+	ar rc $@ $(OBJS)
 	$(RANLIB) $@
 
+shared: $(LIBNAME).so.$(PNGVER)
+
+libpng.pc:
+	cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
+
+libpng-config:
+	( cat scripts/libpng-config-head.in; \
+	echo prefix=\"$(prefix)\"; \
+	echo cppflags=\"-I$(INCPATH)/$(LIBNAME) -DPNG_USE_PNGGCCRD \
+		-DPNG_NO_ASSEMBLER_CODE\"; \
+	echo cflags=\"$(ABI)\"; \
+	echo ldflags=\"-L$(LIBPATH) -rpath $(LIBPATH) \"; \
+	echo libs=\"-lpng10 -lz -lm\"; \
+	cat scripts/libpng-config-body.in ) > libpng-config
+	chmod +x libpng-config
+
+$(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ)
+	ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so
+
+$(LIBNAME).so.$(PNGMAJ): $(LIBNAME).so.$(PNGVER)
+	ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ)
+
 $(LIBNAME).so.$(PNGVER): $(OBJS)
 	$(LDSHARED) -o $@ $(OBJS)
 	rm -f $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)
-	ln -s $@ $(LIBNAME).so
-	ln -s $@ $(LIBNAME).so.$(PNGMAJ)
 
 pngtest: pngtest.o libpng.a
 	$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
 
 test: pngtest
+	echo
+	echo Testing local static library.
 	./pngtest
 
 install-headers: png.h pngconf.h
-	-@if [ ! -d $(INCPATH) ]; then mkdir $(INCPATH); fi
-	-@if [ ! -d $(INCPATH)/$(LIBNAME) ]; then mkdir $(INCPATH)/$(LIBNAME); fi
-	cp png.h pngconf.h $(INCPATH)/$(LIBNAME)
-	chmod 644 $(INCPATH)/$(LIBNAME)/png.h $(INCPATH)/$(LIBNAME)/pngconf.h
-	-@/bin/rm -f $(INCPATH)/png.h $(INCPATH)/pngconf.h
-	-@/bin/rm -f $(INCPATH)/libpng
-	ln -f -s $(INCPATH)/$(LIBNAME) $(INCPATH)/libpng
+	-@if [ ! -d $(DI) ]; then mkdir $(DI); fi
+	-@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
+	cp png.h pngconf.h $(DI)/$(LIBNAME)
+	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
+	-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
+	-@/bin/rm -f $(DI)/libpng
+	(cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
 
 install-static: install-headers libpng.a
-	-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
-	cp libpng.a $(LIBPATH)/$(LIBNAME).a
-	chmod 644 $(LIBPATH)/$(LIBNAME).a
-	-@/bin/rm -f $(LIBPATH)/libpng.a
-	ln -f -s $(LIBPATH)/$(LIBNAME).a $(LIBPATH)/libpng.a
+	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
+	cp libpng.a $(DL)/$(LIBNAME).a
+	chmod 644 $(DL)/$(LIBNAME).a
+	-@/bin/rm -f $(DL)/libpng.a
+	(cd $(DL); ln -sf $(LIBNAME).a libpng.a)
 
-install-shared: install-headers $(LIBNAME).so.$(PNGVER)
-	-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
-	-@/bin/rm -f $(LIBPATH)/$(LIBNAME).so.$(PNGMAJ)* $(LIBPATH)/$(LIBNAME).so
-	-@/bin/rm -f $(LIBPATH)/libpng.so
-	-@/bin/rm -f $(LIBPATH)/libpng.so.2
-	-@/bin/rm -f $(LIBPATH)/libpng.so.2.*
-	cp $(LIBNAME).so.$(PNGVER) $(LIBPATH)
-	chmod 755 $(LIBPATH)/$(LIBNAME).so.$(PNGVER)
-	(cd $(LIBPATH); \
-	ln -f -s $(LIBNAME).so.$(PNGVER) libpng.so; \
-	ln -f -s $(LIBNAME).so.$(PNGVER) libpng.so.2; \
-	ln -f -s $(LIBNAME).so.$(PNGVER) libpng.so.2.$(PNGMIN); \
-	ln -f -s $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \
-	ln -f -s $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so)
-	-@if [ ! -d $(LIBPATH)/pkgconfig ]; then mkdir $(LIBPATH)/pkgconfig; fi
-	cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
-	cp libpng.pc $(LIBPATH)/pkgconfig/libpng10.pc
-	chmod 644 $(LIBPATH)/pkgconfig/libpng10.pc
+install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc
+	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
+	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* $(DL)/$(LIBNAME).so
+	-@/bin/rm -f $(DL)/libpng.so
+	-@/bin/rm -f $(DL)/libpng.so.2
+	-@/bin/rm -f $(DL)/libpng.so.2.*
+	cp $(LIBNAME).so.$(PNGVER) $(DL)
+	chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER)
+	(cd $(DL); \
+	ln -sf $(LIBNAME).so.$(PNGVER) libpng.so; \
+	ln -sf $(LIBNAME).so.$(PNGVER) libpng.so.2; \
+	ln -sf $(LIBNAME).so.$(PNGVER) libpng.so.2.$(PNGMIN); \
+	ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \
+	ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so)
+	-@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi
+	-@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
+	-@/bin/rm -f $(DL)/pkgconfig/libpng.pc
+	cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
+	chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
+	(cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc)
 
-install: install-static install-shared
+install-man: libpng.3 libpngpf.3 png.5
+	-@if [ ! -d $(DM) ]; then mkdir $(DM); fi
+	-@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi
+	-@/bin/rm -f $(DM)/man3/libpng.3
+	-@/bin/rm -f $(DM)/man3/libpngpf.3
+	cp libpng.3 $(DM)/man3
+	cp libpngpf.3 $(DM)/man3
+	-@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi
+	-@/bin/rm -f $(DM)/man5/png.5
+	cp png.5 $(DM)/man5
+
+install-config: libpng-config
+	-@if [ ! -d $(DB) ]; then mkdir $(DB); fi
+	-@/bin/rm -f $(DB)/libpng-config
+	-@/bin/rm -f $(DB)/$(LIBNAME)-config
+	cp libpng-config $(DB)/$(LIBNAME)-config
+	chmod 755 $(DB)/$(LIBNAME)-config
+	(cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
+
+install: install-static install-shared install-man install-config
+
+# If you installed in $(DESTDIR), test-installed won't work until you
+# move the library to its final location.
+
+test-installed:
+	echo
+	echo Testing installed dynamic shared library.
+	$(CC) -I$(ZLIBINC) \
+	   `$(BINPATH)/libpng10-config --cppflags --cflags` pngtest.c \
+	   -L$(ZLIBLIB) -rpath $(ZLIBLIB) \
+	   -o pngtesti `$(BINPATH)/libpng10-config --ldflags --libs`
+	./pngtesti pngtest.png
 
 clean:
-	rm -f *.o libpng.a pngtest pngout.png $(LIBNAME).so \
-	$(LIBNAME).so.$(PNGMAJ)*
+	rm -f *.o libpng.a pngtest pngtesti pngout.png libpng.pc libpng-config \
+	$(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* so_locations
 
 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
 writelock:
diff --git a/scripts/makefile.so9 b/scripts/makefile.so9
index c713f39..1921934 100644
--- a/scripts/makefile.so9
+++ b/scripts/makefile.so9
@@ -1,6 +1,7 @@
 # makefile for libpng on Solaris 9 (beta) with Forte cc
 # Updated by Chad Schrock for Solaris 9
 # Contributed by William L. Sebok, based on makefile.linux
+# Copyright (C) 2002 Glenn Randers-Pehrson
 # Copyright (C) 1998-2001 Greg Roelofs
 # Copyright (C) 1996-1997 Andreas Dilger
 # For conditions of distribution and use, see copyright notice in png.h
@@ -27,20 +28,35 @@
 	-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
 #CFLAGS=-I$(ZLIBINC) -Wall -O3 $(WARNMORE) -g -DPNG_DEBUG=5
 CFLAGS=-I$(ZLIBINC) -O3
-LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng -lz -lm
+LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng10 -lz -lm
 
 #RANLIB=ranlib
 RANLIB=echo
 
-# read libpng.txt or png.h to see why PNGMAJ is 0.  You should not
-# have to change it.
 PNGMAJ = 0
-PNGMIN = 1.0.13
+PNGMIN = 1.0.14
 PNGVER = $(PNGMAJ).$(PNGMIN)
 LIBNAME = libpng10
 
 INCPATH=$(prefix)/include
 LIBPATH=$(prefix)/lib
+MANPATH=$(prefix)/man
+BINPATH=$(prefix)/bin
+
+# override DESTDIR= on the make install command line to easily support
+# installing into a temporary location.  Example:
+#
+#    make install DESTDIR=/tmp/build/libpng
+#
+# If you're going to install into a temporary location
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
+# you execute make install.
+DESTDIR=
+
+DB=$(DESTDIR)$(BINPATH)
+DI=$(DESTDIR)$(INCPATH)
+DL=$(DESTDIR)$(LIBPATH)
+DM=$(DESTDIR)$(MANPATH)
 
 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
 	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
@@ -53,12 +69,25 @@
 .c.pic.o:
 	$(CC) -c $(CFLAGS) -KPIC -o $@ $*.c
 
-all: libpng.a $(LIBNAME).so pngtest
+all: libpng.a $(LIBNAME).so pngtest libpng.pc libpng-config
 
 libpng.a: $(OBJS)
 	ar rc $@ $(OBJS)
 	$(RANLIB) $@
 
+libpng.pc:
+	cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
+
+libpng-config:
+	( cat scripts/libpng-config-head.in; \
+	echo prefix=\"$(prefix)\"; \
+	echo cppflags=\"-I$(INCPATH)/$(LIBNAME)\"; \
+	echo cflags=\"\"; \
+	echo ldflags=\"-L$(LIBPATH) -R$(LIBPATH)\"; \
+	echo libs=\"-lpng10 -lz -lm\"; \
+	cat scripts/libpng-config-body.in ) > libpng-config
+	chmod +x libpng-config
+
 $(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ)
 	ln -f -s $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so
 
@@ -88,45 +117,78 @@
 	./pngtest
 
 install-headers: png.h pngconf.h
-	-@if [ ! -d $(INCPATH) ]; then mkdir $(INCPATH); fi
-	-@if [ ! -d $(INCPATH)/$(LIBNAME) ]; then mkdir $(INCPATH)/$(LIBNAME); fi
-	cp png.h pngconf.h $(INCPATH)/$(LIBNAME)
-	chmod 644 $(INCPATH)/$(LIBNAME)/png.h $(INCPATH)/$(LIBNAME)/pngconf.h
-	-@/bin/rm -f $(INCPATH)/png.h $(INCPATH)/pngconf.h
-	-@/bin/rm -f $(INCPATH)/libpng
-	ln -f -s $(INCPATH)/$(LIBNAME) $(INCPATH)/libpng
+	-@if [ ! -d $(DI) ]; then mkdir $(DI); fi
+	-@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
+	cp png.h pngconf.h $(DI)/$(LIBNAME)
+	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
+	-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
+	-@/bin/rm -f $(DI)/libpng
+	(cd $(DI); ln -f -s $(LIBNAME) libpng; ln -f -s $(LIBNAME)/* .)
 
 install-static: install-headers libpng.a
-	-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
-	cp libpng.a $(LIBPATH)/$(LIBNAME).a
-	chmod 644 $(LIBPATH)/$(LIBNAME).a
-	-@/bin/rm -f $(LIBPATH)/libpng.a
-	ln -f -s $(LIBPATH)/$(LIBNAME).a $(LIBPATH)/libpng.a
+	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
+	cp libpng.a $(DL)/$(LIBNAME).a
+	chmod 644 $(DL)/$(LIBNAME).a
+	-@/bin/rm -f $(DL)/libpng.a
+	(cd $(DL); ln -f -s $(LIBNAME).a libpng.a)
 
-install-shared: install-headers $(LIBNAME).so.$(PNGVER)
-	-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
-	-@/bin/rm -f $(LIBPATH)/$(LIBNAME).so.$(PNGMAJ)* $(LIBPATH)/$(LIBNAME).so
-	-@/bin/rm -f $(LIBPATH)/libpng.so
-	-@/bin/rm -f $(LIBPATH)/libpng.so.2
-	-@/bin/rm -f $(LIBPATH)/libpng.so.2.*
-	cp $(LIBNAME).so.$(PNGVER) $(LIBPATH)
-	chmod 755 $(LIBPATH)/$(LIBNAME).so.$(PNGVER)
-	(cd $(LIBPATH); \
+install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc
+	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
+	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* $(DL)/$(LIBNAME).so
+	-@/bin/rm -f $(DL)/libpng.so
+	-@/bin/rm -f $(DL)/libpng.so.2
+	-@/bin/rm -f $(DL)/libpng.so.2.*
+	cp $(LIBNAME).so.$(PNGVER) $(DL)
+	chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER)
+	(cd $(DL); \
 	ln -f -s $(LIBNAME).so.$(PNGVER) libpng.so; \
 	ln -f -s $(LIBNAME).so.$(PNGVER) libpng.so.2; \
 	ln -f -s $(LIBNAME).so.$(PNGVER) libpng.so.2.$(PNGMIN); \
 	ln -f -s $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \
 	ln -f -s $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so)
-	-@if [ ! -d $(LIBPATH)/pkgconfig ]; then mkdir $(LIBPATH)/pkgconfig; fi
-	cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
-	cp libpng.pc $(LIBPATH)/pkgconfig/libpng10.pc
-	chmod 644 $(LIBPATH)/pkgconfig/libpng10.pc
+	-@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi
+	-@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
+	-@/bin/rm -f $(DL)/pkgconfig/libpng.pc
+	cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
+	chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
+	(cd $(DL)/pkgconfig; ln -f -s $(LIBNAME).pc libpng.pc)
 
-install: install-static install-shared
+install-man: libpng.3 libpngpf.3 png.5
+	-@if [ ! -d $(DM) ]; then mkdir $(DM); fi
+	-@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi
+	-@/bin/rm -f $(DM)/man3/libpng.3
+	-@/bin/rm -f $(DM)/man3/libpngpf.3
+	cp libpng.3 $(DM)/man3
+	cp libpngpf.3 $(DM)/man3
+	-@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi
+	-@/bin/rm -f $(DM)/man5/png.5
+	cp png.5 $(DM)/man5
+
+install-config: libpng-config
+	-@if [ ! -d $(DB) ]; then mkdir $(DB); fi
+	-@/bin/rm -f $(DB)/libpng-config
+	-@/bin/rm -f $(DB)/$(LIBNAME)-config
+	cp libpng-config $(DB)/$(LIBNAME)-config
+	chmod 755 $(DB)/$(LIBNAME)-config
+	(cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
+
+install: install-static install-shared install-man install-config
+
+# If you installed in $(DESTDIR), test-installed won't work until you
+# move the library to its final location.
+
+test-installed:
+	echo
+	echo Testing installed dynamic shared library.
+	$(CC) -I$(ZLIBINC) \
+	   `$(BINPATH)/libpng10-config --cppflags --cflags` pngtest.c \
+	   -o pngtesti `$(BINPATH)/libpng10-config --ldflags --libs` \
+	   -L$(ZLIBLIB) -R$(ZLIBLIB)
+	./pngtesti pngtest.png
 
 clean:
-	/bin/rm -f *.o libpng.a $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* \
-	pngtest pngout.png
+	/bin/rm -f *.o libpng.a pngtest pngtesti pngout.png libpng.pc \
+	libpng-config $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)*
 
 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
 writelock:
diff --git a/scripts/makefile.solaris b/scripts/makefile.solaris
index d3a69ad..d6e0838 100644
--- a/scripts/makefile.solaris
+++ b/scripts/makefile.solaris
@@ -24,20 +24,35 @@
 	-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
 CFLAGS=-I$(ZLIBINC) -Wall -O3 \
 	# $(WARNMORE) -g -DPNG_DEBUG=5
-LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng -lz -lm
+LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng10 -lz -lm
 
 #RANLIB=ranlib
 RANLIB=echo
 
-# read libpng.txt or png.h to see why PNGMAJ is 0.  You should not
-# have to change it.
 PNGMAJ = 0
-PNGMIN = 1.0.13
+PNGMIN = 1.0.14
 PNGVER = $(PNGMAJ).$(PNGMIN)
 LIBNAME = libpng10
 
 INCPATH=$(prefix)/include
 LIBPATH=$(prefix)/lib
+MANPATH=$(prefix)/man
+BINPATH=$(prefix)/bin
+
+# override DESTDIR= on the make install command line to easily support
+# installing into a temporary location.  Example:
+#
+#    make install DESTDIR=/tmp/build/libpng
+#
+# If you're going to install into a temporary location
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
+# you execute make install.
+DESTDIR=
+
+DB=$(DESTDIR)$(BINPATH)
+DI=$(DESTDIR)$(INCPATH)
+DL=$(DESTDIR)$(LIBPATH)
+DM=$(DESTDIR)$(MANPATH)
 
 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
 	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
@@ -50,12 +65,26 @@
 .c.pic.o:
 	$(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
 
-all: libpng.a $(LIBNAME).so pngtest
+all: libpng.a $(LIBNAME).so pngtest libpng.pc libpng-config
 
 libpng.a: $(OBJS)
 	ar rc $@ $(OBJS)
 	$(RANLIB) $@
 
+libpng.pc:
+	cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
+
+libpng-config:
+	( cat scripts/libpng-config-head.in; \
+	echo prefix=\"$(prefix)\"; \
+	echo cppflags=\"-I$(INCPATH)/$(LIBNAME) -DPNG_USE_PNGGCCRD \
+		-DPNG_NO_ASSEMBLER_CODE\"; \
+	echo cflags=\"$(ABI)\"; \
+	echo ldflags=\"-L$(LIBPATH) -R$(LIBPATH)\"; \
+	echo libs=\"-lpng10 -lz -lm\"; \
+	cat scripts/libpng-config-body.in ) > libpng-config
+	chmod +x libpng-config
+
 $(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ)
 	ln -f -s $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so
 
@@ -85,45 +114,78 @@
 	./pngtest
 
 install-headers: png.h pngconf.h
-	-@if [ ! -d $(INCPATH) ]; then mkdir $(INCPATH); fi
-	-@if [ ! -d $(INCPATH)/$(LIBNAME) ]; then mkdir $(INCPATH)/$(LIBNAME); fi
-	cp png.h pngconf.h $(INCPATH)/$(LIBNAME)
-	chmod 644 $(INCPATH)/$(LIBNAME)/png.h $(INCPATH)/$(LIBNAME)/pngconf.h
-	-@/bin/rm -f $(INCPATH)/png.h $(INCPATH)/pngconf.h
-	-@/bin/rm -f $(INCPATH)/libpng
-	ln -f -s $(INCPATH)/$(LIBNAME) $(INCPATH)/libpng
+	-@if [ ! -d $(DI) ]; then mkdir $(DI); fi
+	-@if [ ! -d $(DI)/$(LIBNAME) ]; then mkdir $(DI)/$(LIBNAME); fi
+	cp png.h pngconf.h $(DI)/$(LIBNAME)
+	chmod 644 $(DI)/$(LIBNAME)/png.h $(DI)/$(LIBNAME)/pngconf.h
+	-@/bin/rm -f $(DI)/png.h $(DI)/pngconf.h
+	-@/bin/rm -f $(DI)/libpng
+	(cd $(DI); ln -f -s $(LIBNAME) libpng; ln -f -s $(LIBNAME)/* .)
 
 install-static: install-headers libpng.a
-	-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
-	cp libpng.a $(LIBPATH)/$(LIBNAME).a
-	chmod 644 $(LIBPATH)/$(LIBNAME).a
-	-@/bin/rm -f $(LIBPATH)/libpng.a
-	ln -f -s $(LIBPATH)/$(LIBNAME).a $(LIBPATH)/libpng.a
+	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
+	cp libpng.a $(DL)/$(LIBNAME).a
+	chmod 644 $(DL)/$(LIBNAME).a
+	-@/bin/rm -f $(DL)/libpng.a
+	(cd $(DL); ln -f -s $(LIBNAME).a libpng.a)
 
-install-shared: install-headers $(LIBNAME).so.$(PNGVER)
-	-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
-	-@/bin/rm -f $(LIBPATH)/$(LIBNAME).so.$(PNGMAJ)* $(LIBPATH)/$(LIBNAME).so
-	-@/bin/rm -f $(LIBPATH)/libpng.so
-	-@/bin/rm -f $(LIBPATH)/libpng.so.2
-	-@/bin/rm -f $(LIBPATH)/libpng.so.2.*
-	cp $(LIBNAME).so.$(PNGVER) $(LIBPATH)
-	chmod 755 $(LIBPATH)/$(LIBNAME).so.$(PNGVER)
-	(cd $(LIBPATH); \
+install-shared: install-headers $(LIBNAME).so.$(PNGVER) libpng.pc
+	-@if [ ! -d $(DL) ]; then mkdir $(DL); fi
+	-@/bin/rm -f $(DL)/$(LIBNAME).so.$(PNGMAJ)* $(DL)/$(LIBNAME).so
+	-@/bin/rm -f $(DL)/libpng.so
+	-@/bin/rm -f $(DL)/libpng.so.2
+	-@/bin/rm -f $(DL)/libpng.so.2.*
+	cp $(LIBNAME).so.$(PNGVER) $(DL)
+	chmod 755 $(DL)/$(LIBNAME).so.$(PNGVER)
+	(cd $(DL); \
 	ln -f -s $(LIBNAME).so.$(PNGVER) libpng.so; \
 	ln -f -s $(LIBNAME).so.$(PNGVER) libpng.so.2; \
 	ln -f -s $(LIBNAME).so.$(PNGVER) libpng.so.2.$(PNGMIN); \
 	ln -f -s $(LIBNAME).so.$(PNGVER) $(LIBNAME).so; \
 	ln -f -s $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ))
-	-@if [ ! -d $(LIBPATH)/pkgconfig ]; then mkdir $(LIBPATH)/pkgconfig; fi
-	cat scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! > libpng.pc
-	cp libpng.pc $(LIBPATH)/pkgconfig/libpng10.pc
-	chmod 644 $(LIBPATH)/pkgconfig/libpng10.pc
+	-@if [ ! -d $(DL)/pkgconfig ]; then mkdir $(DL)/pkgconfig; fi
+	-@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
+	-@/bin/rm -f $(DL)/pkgconfig/libpng.pc
+	cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
+	chmod 644 $(DL)/pkgconfig/$(LIBNAME).pc
+	(cd $(DL)/pkgconfig; ln -f -s $(LIBNAME).pc libpng.pc)
 
-install: install-static install-shared
+install-man: libpng.3 libpngpf.3 png.5
+	-@if [ ! -d $(DM) ]; then mkdir $(DM); fi
+	-@if [ ! -d $(DM)/man3 ]; then mkdir $(DM)/man3; fi
+	-@/bin/rm -f $(DM)/man3/libpng.3
+	-@/bin/rm -f $(DM)/man3/libpngpf.3
+	cp libpng.3 $(DM)/man3
+	cp libpngpf.3 $(DM)/man3
+	-@if [ ! -d $(DM)/man5 ]; then mkdir $(DM)/man5; fi
+	-@/bin/rm -f $(DM)/man5/png.5
+	cp png.5 $(DM)/man5
+
+install-config: libpng-config
+	-@if [ ! -d $(DB) ]; then mkdir $(DB); fi
+	-@/bin/rm -f $(DB)/libpng-config
+	-@/bin/rm -f $(DB)/$(LIBNAME)-config
+	cp libpng-config $(DB)/$(LIBNAME)-config
+	chmod 755 $(DB)/$(LIBNAME)-config
+	(cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
+
+install: install-static install-shared install-man install-config
+
+# If you installed in $(DESTDIR), test-installed won't work until you
+# move the library to its final location.
+
+test-installed:
+	echo
+	echo Testing installed dynamic shared library.
+	$(CC) -I$(ZLIBINC) \
+	   `$(BINPATH)/libpng10-config --cppflags --cflags` pngtest.c \
+	   -o pngtesti `$(BINPATH)/libpng10-config --ldflags --libs` \
+	   -L$(ZLIBLIB) -R$(ZLIBLIB)
+	./pngtesti pngtest.png
 
 clean:
-	/bin/rm -f *.o libpng.a $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* \
-	pngtest pngout.png
+	/bin/rm -f *.o libpng.a pngtest pngtesti pngout.png libpng.pc \
+	libpng-config $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)*
 
 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
 writelock:
diff --git a/scripts/makefile.std b/scripts/makefile.std
index 15e569a..5d1f529 100644
--- a/scripts/makefile.std
+++ b/scripts/makefile.std
@@ -1,9 +1,22 @@
 # makefile for libpng
+# Copyright (C) 2002 Glenn Randers-Pehrson
 # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
 # For conditions of distribution and use, see copyright notice in png.h
 
 # where make install puts libpng.a and png.h
 prefix=/usr/local
+INCPATH=$(prefix)/include
+LIBPATH=$(prefix)/lib
+
+# override DESTDIR= on the make install command line to easily support
+# installing into a temporary location.  Example:
+#
+#    make install DESTDIR=/tmp/build/libpng
+#
+# If you're going to install into a temporary location
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
+# you execute make install.
+DESTDIR=
 
 # Where the zlib library and include files are located
 #ZLIBLIB=/usr/local/lib
@@ -35,17 +48,18 @@
 	./pngtest
 
 install: libpng.a
-	-@mkdir $(prefix)/include
-	-@mkdir $(prefix)/include/libpng
-	-@mkdir $(prefix)/lib
-	-@rm -f $(prefix)/include/png.h
-	-@rm -f $(prefix)/include/pngconf.h
-	cp png.h $(prefix)/include/libpng
-	cp pngconf.h $(prefix)/include/libpng
-	chmod 644 $(prefix)/include/libpng/png.h
-	chmod 644 $(prefix)/include/libpng/pngconf.h
-	cp libpng.a $(prefix)/lib
-	chmod 644 $(prefix)/lib/libpng.a
+	-@mkdir $(DESTDIR)$(INCPATH)
+	-@mkdir $(DESTDIR)$(INCPATH)/libpng
+	-@mkdir $(DESTDIR)$(LIBPATH)
+	-@rm -f $(DESTDIR)$(INCPATH)/png.h
+	-@rm -f $(DESTDIR)$(INCPATH)/pngconf.h
+	cp png.h $(DESTDIR)$(INCPATH)/libpng
+	cp pngconf.h $(DESTDIR)$(INCPATH)/libpng
+	chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h
+	chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h
+	(cd $(DESTDIR)$(INCPATH); ln -f -s libpng/* .)
+	cp libpng.a $(DESTDIR)$(LIBPATH)
+	chmod 644 $(DESTDIR)$(LIBPATH)/libpng.a
 
 clean:
 	rm -f *.o libpng.a pngtest pngout.png
diff --git a/scripts/makefile.sunos b/scripts/makefile.sunos
index cdce372..70a6e88 100644
--- a/scripts/makefile.sunos
+++ b/scripts/makefile.sunos
@@ -1,9 +1,22 @@
 # makefile for libpng
+# Copyright (C) 2002 Glenn Randers-Pehrson
 # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
 # For conditions of distribution and use, see copyright notice in png.h
 
 # where make install puts libpng.a and png.h
 prefix=/usr/local
+INCPATH=$(prefix)/include
+LIBPATH=$(prefix)/lib
+
+# override DESTDIR= on the make install command line to easily support
+# installing into a temporary location.  Example:
+#
+#    make install DESTDIR=/tmp/build/libpng
+#
+# If you're going to install into a temporary location
+# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
+# you execute make install.
+DESTDIR=
 
 # Where the zlib library and include files are located
 #ZLIBLIB=/usr/local/lib
@@ -39,17 +52,18 @@
 	./pngtest
 
 install: libpng.a
-	-@mkdir $(prefix)/include
-	-@mkdir $(prefix)/include/libpng
-	-@mkdir $(prefix)/lib
-	-@rm -f $(prefix)/include/png.h
-	-@rm -f $(prefix)/include/pngconf.h
-	cp png.h $(prefix)/include/libpng
-	cp pngconf.h $(prefix)/include/libpng
-	chmod 644 $(prefix)/include/libpng/png.h
-	chmod 644 $(prefix)/include/libpng/pngconf.h
-	cp libpng.a $(prefix)/lib
-	chmod 644 $(prefix)/lib/libpng.a
+	-@mkdir $(DESTDIR)$(INCPATH)
+	-@mkdir $(DESTDIR)$(INCPATH)/libpng
+	-@mkdir $(DESTDIR)$(LIBPATH)
+	-@rm -f $(DESTDIR)$(INCPATH)/png.h
+	-@rm -f $(DESTDIR)$(INCPATH)/pngconf.h
+	cp png.h $(DESTDIR)$(INCPATH)/libpng
+	cp pngconf.h $(DESTDIR)$(INCPATH)/libpng
+	chmod 644 $(DESTDIR)$(INCPATH)/libpng/png.h
+	chmod 644 $(DESTDIR)$(INCPATH)/libpng/pngconf.h
+	(cd $(DESTDIR)$(INCPATH); ln -f -s libpng/* .)
+	cp libpng.a $(DESTDIR)$(LIBPATH)
+	chmod 644 $(DESTDIR)$(LIBPATH)/libpng.a
 
 clean:
 	rm -f *.o libpng.a pngtest pngout.png
diff --git a/scripts/pngdef.pas b/scripts/pngdef.pas
index 0fac3f4..67d68c4 100644
--- a/scripts/pngdef.pas
+++ b/scripts/pngdef.pas
@@ -7,8 +7,8 @@
 interface
 
 const
-  PNG_LIBPNG_VER_STRING = '1.0.13';
-  PNG_LIBPNG_VER        =  10013;
+  PNG_LIBPNG_VER_STRING = '1.0.14';
+  PNG_LIBPNG_VER        =  10014;
 
 type
   png_uint_32 = Cardinal;
diff --git a/scripts/pngos2.def b/scripts/pngos2.def
index a7be284..c0ca619 100644
--- a/scripts/pngos2.def
+++ b/scripts/pngos2.def
@@ -2,7 +2,7 @@
 ; PNG.LIB module definition file for OS/2
 ;----------------------------------------
 
-; Version 1.0.13
+; Version 1.0.14
 
 LIBRARY		PNG
 DESCRIPTION	"PNG image compression library for OS/2"
@@ -185,22 +185,27 @@
   png_set_invalid
 
 ; Added at version 1.2.0:
-; png_mmx_support
-; png_permit_empty_plte
-; png_permit_mng_features
-; png_get_mmx_flagmask
-; png_get_asm_flagmask
-; png_get_asm_flags
-; png_get_mmx_bitdepth_threshold
-; png_get_mmx_rowbytes_threshold
-; png_set_asm_flags
-; png_init_mmx_flags
+  png_mmx_support
+  png_permit_empty_plte
+  png_permit_mng_features
+  png_get_mmx_flagmask
+  png_get_asm_flagmask
+  png_get_asm_flags
+  png_get_mmx_bitdepth_threshold
+  png_get_mmx_rowbytes_threshold
+  png_set_asm_flags
+  png_init_mmx_flags
 
 ; Added at version 1.2.2:
-  png_zalloc
-  png_zfree
   png_handle_as_unknown
 
+; Added at version 1.2.2 and deleted from 1.2.3:
+; png_zalloc
+; png_zfree
+
+; Added at version 1.2.4
+  png_malloc_warn
+
 ; These are not present when libpng is compiled with PNG_NO_GLOBAL_ARRAYS
   png_libpng_ver
   png_pass_start