Imported from libpng-1.2.2beta1.tar
diff --git a/ANNOUNCE b/ANNOUNCE
index 5ec2579..5987489 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,29 +1,21 @@
 
-Libpng 1.2.1 - December 12, 2001
+Libpng 1.2.2beta1 - February 22, 2002
 
-This is a public release of libpng, intended for use in production codes.
+This is not intended to be a public release.  It will be replaced
+within a few weeks by a public version or by another test version.
 
-Changes since the last public release (1.2.0):
+Changes since the last public release (1.2.1):
 
-  Revised makefile.std in contrib/pngminus
-  Include background_1 in png_struct regardless of gamma support.
-  Revised makefile.netbsd and makefile.macosx, added makefile.darwin.
-  Revised example.c to provide more details about using row_callback().
-  Added makefile.so9.
-  Removed type casts from all NULLs, except for those appearing in function
-    calls when PNG_NO_TYPECAST_NULL is defined.
-  Simplified png_create_info_struct() and png_creat_struct_2().
-  Added error message if png_write_info() was omitted.
-  Changed typecast of "size" argument to png_size_t in pngmem.c calls to
-    the user malloc_fn, to agree with the prototype in png.h
-  Added a pop/push operation to pnggccrd.c, to preserve Eflag (Maxim Sobolev)
-  Updated makefile.sgi to recognize LIBPATH and INCPATH.
-  Updated various makefiles so "make clean" does not remove previous major
-    version of the shared library.
-  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.
+version 1.2.2beta1 [February 22, 2002]
+  Fixed a bug with reading the length of iCCP profiles (Larry Reeves).
+  Revised makefile.linux, makefile.gcmmx, and makefile.sgi to generate
+    libpng.a, libpng12.so (not libpng.so.3), and libpng12/png.h (not 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)
 
 Send comments/corrections/commendations to
 png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu
diff --git a/CHANGES b/CHANGES
index 9a81ab7..5fdaae2 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1012,8 +1012,18 @@
   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.
-version 1.2.1 [December 12, 2001]
+version 1.2.1 [December 7, 2001]
   None.
+version 1.2.2beta1 [February 22, 2002]
+  Fixed a bug with reading the length of iCCP profiles (Larry Reeves).
+  Revised makefile.linux, makefile.gcmmx, and makefile.sgi to generate
+    libpng.a, libpng12.so (not libpng.so.3), and libpng12/png.h (not 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)
 
 Send comments/corrections/commendations to
 png-implement@ccrc.wustl.edu or to randeg@alum.rpi.edu
diff --git a/INSTALL b/INSTALL
index 5a7d4bb..217c2ae 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,5 +1,5 @@
 
-Installing libpng version 1.2.1 - December 12, 2001
+Installing libpng version 1.2.2beta1 - February 22, 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.2.1" or "lpng109" and "zlib-1.1.3"
+might be called "libpng-1.2.2beta1" 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 libpng.so.3.1.2.1)
- makefile.gcmmx    =>  Linux/ELF makefile (gcc, creates libpng.so.3.1.2.1,
+ makefile.linux    =>  Linux/ELF makefile (gcc, creates libpng.so.0.1.2.2beta1)
+ makefile.gcmmx    =>  Linux/ELF makefile (gcc, creates libpng.so.0.1.2.2beta1,
                        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
@@ -83,10 +83,10 @@
  makefile.macosx   =>  MACOS X Makefile
  makefile.netbsd   =>  NetBSD/cc makefile, uses PNGGCCRD
  makefile.sgi      =>  Silicon Graphics IRIX makefile (cc, creates static lib)
- makefile.sggcc    =>  Silicon Graphics (gcc, creates libpng.so.3.1.2.1)
+ makefile.sggcc    =>  Silicon Graphics (gcc, creates libpng.so.0.1.2.2beta1)
  makefile.sunos    =>  Sun makefile
- makefile.solaris  =>  Solaris 2.X makefile (gcc, creates libpng.so.3.1.2.1)
- makefile.so9      =>  Solaris 9 makefile (gcc, creates libpng.so.3.1.2.1)
+ makefile.solaris  =>  Solaris 2.X makefile (gcc, creates libpng.so.0.1.2.2beta1)
+ makefile.so9      =>  Solaris 9 makefile (gcc, creates libpng.so.0.1.2.2beta1)
  makefile.sco      =>  For SCO OSr5  ELF and Unixware 7 with Native cc
  makefile.mips     =>  MIPS makefile
  makefile.acorn    =>  Acorn makefile
diff --git a/KNOWNBUG b/KNOWNBUG
index 7844cbc..6f37ada 100644
--- a/KNOWNBUG
+++ b/KNOWNBUG
@@ -1,5 +1,5 @@
 
-Known bugs in libpng version 1.2.1
+Known bugs in libpng version 1.2.2beta1
 
 1. April 22, 2001: pnggccrd.c has been reported to crash on NetBSD when
    reading interlaced PNG files, when assembler code is enabled.
diff --git a/LICENSE b/LICENSE
index c11dd4f..c049e9c 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.2.1, December 12, 2001, are
+libpng versions 1.0.7, July 1, 2000, through 1.2.2beta1, February 22, 2002, are
 Copyright (c) 2000 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
-December 12, 2001
+February 22, 2002
diff --git a/README b/README
index ffaae47..00d0840 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-README for libpng 1.2.1 - December 12, 2001 (shared library 2.1)
+README for libpng 1.2.2beta1 - February 22, 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 libpng.so.3.1.2.1)
+                            (gcc, creates libpng.so.0.1.2.2beta1)
        makefile.gcmmx   =>  Linux/ELF makefile (gcc, creates
-                            libpng.so.3.1.2.1, uses assembler code
+                            libpng.so.0.1.2.2beta1, 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
@@ -207,12 +207,12 @@
        makefile.macosx  =>  MACOS X Makefile
        makefile.netbsd  =>  NetBSD/cc makefile, uses PNGGCCRD
        makefile.sgi     =>  Silicon Graphics IRIX (cc, creates static lib)
-       makefile.sggcc   =>  Silicon Graphics (gcc, creates libpng.so.3.1.2.1)
+       makefile.sggcc   =>  Silicon Graphics (gcc, creates libpng.so.0.1.2.2beta1)
        makefile.sunos   =>  Sun makefile
        makefile.solaris =>  Solaris 2.X makefile
-                            (gcc, creates libpng.so.3.1.2.1)
+                            (gcc, creates libpng.so.0.1.2.2beta1)
        makefile.so9     =>  Solaris 9 makefile
-                            (gcc, creates libpng.so.3.1.2.1)
+                            (gcc, creates libpng.so.0.1.2.2beta1)
        makefile.sco     =>  For SCO OSr5  ELF and Unixware 7 with Native cc
        makefile.mips    =>  MIPS makefile
        makefile.acorn   =>  Acorn makefile
diff --git a/Y2KINFO b/Y2KINFO
index 6e6ab78..92e48be 100644
--- a/Y2KINFO
+++ b/Y2KINFO
@@ -1,13 +1,13 @@
    Y2K compliance in libpng:
    =========================
 
-      December 12, 2001
+      February 22, 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.2.1 are Y2K compliant.  It is my belief that earlier
+      upward through 1.2.2beta1 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 aa1718d..3855269 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 echo "
-  There is no \"configure\" script for Libpng-1.2.1.  Instead, please
+  There is no \"configure\" script for Libpng-1.2.2beta1.  Instead, please
   copy the appropriate makefile for your system from the \"scripts\"
   directory.  Read the INSTALL file for more details.
 "
diff --git a/contrib/msvctest/msvctest.dsp b/contrib/msvctest/msvctest.dsp
index 01c1dcf..5a8fcc2 100644
--- a/contrib/msvctest/msvctest.dsp
+++ b/contrib/msvctest/msvctest.dsp
@@ -54,7 +54,7 @@
 # ADD BSC32 /nologo
 LINK32=link.exe
 # ADD BASE LINK32 /nologo /subsystem:console /machine:I386
-# ADD LINK32 ..\..\projects\msvc\win32\libpng\dll\libpng3.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 ..\..\projects\msvc\win32\libpng\dll\libpng12.lib /nologo /subsystem:console /machine:I386
 # Begin Special Build Tool
 OutDir=.\dll
 SOURCE="$(InputPath)"
@@ -84,7 +84,7 @@
 # ADD BSC32 /nologo
 LINK32=link.exe
 # ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 ..\..\projects\msvc\win32\libpng\dll_dbg\libpng3d.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 ..\..\projects\msvc\win32\libpng\dll_dbg\libpng12d.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
 # Begin Special Build Tool
 OutDir=.\dll_dbg
 SOURCE="$(InputPath)"
@@ -114,7 +114,7 @@
 # ADD BSC32 /nologo
 LINK32=link.exe
 # ADD BASE LINK32 /nologo /subsystem:console /machine:I386
-# ADD LINK32 ..\..\projects\msvc\win32\libpng\dll_asm\libpng3a.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 ..\..\projects\msvc\win32\libpng\dll_asm\libpng12a.lib /nologo /subsystem:console /machine:I386
 # Begin Special Build Tool
 OutDir=.\dll_asm
 SOURCE="$(InputPath)"
@@ -144,7 +144,7 @@
 # ADD BSC32 /nologo
 LINK32=link.exe
 # ADD BASE LINK32 /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 ..\..\projects\msvc\win32\libpng\dll_dbga\libpng3b.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 ..\..\projects\msvc\win32\libpng\dll_dbga\libpng12b.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
 # Begin Special Build Tool
 OutDir=.\dll_dbga
 SOURCE="$(InputPath)"
diff --git a/contrib/visupng/VisualPng.dsp b/contrib/visupng/VisualPng.dsp
index 3fbac02..7eb9932 100644
--- a/contrib/visupng/VisualPng.dsp
+++ b/contrib/visupng/VisualPng.dsp
@@ -59,8 +59,8 @@
 # ADD BASE BSC32 /nologo
 # ADD BSC32 /nologo
 LINK32=link.exe
-# ADD BASE LINK32 libpng3.lib zlibd.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /libpath:"libpng" /libpath:"zlib"
-# ADD LINK32 libpng3.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /libpath:"..\..\projects\msvc\win32\libpng\dll"
+# ADD BASE LINK32 libpng12.lib zlibd.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /libpath:"libpng" /libpath:"zlib"
+# ADD LINK32 libpng12.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /libpath:"..\..\projects\msvc\win32\libpng\dll"
 # Begin Special Build Tool
 OutDir=.\dll
 SOURCE="$(InputPath)"
@@ -92,9 +92,9 @@
 # ADD BASE BSC32 /nologo
 # ADD BSC32 /nologo
 LINK32=link.exe
-# ADD BASE LINK32 libpng3.lib zlibd.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libc" /pdbtype:sept /libpath:"libpng" /libpath:"zlib"
+# ADD BASE LINK32 libpng12.lib zlibd.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libc" /pdbtype:sept /libpath:"libpng" /libpath:"zlib"
 # SUBTRACT BASE LINK32 /nodefaultlib
-# ADD LINK32 libpng3d.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libc" /pdbtype:sept /libpath:"..\..\projects\msvc\win32\libpng\dll_dbg"
+# ADD LINK32 libpng12d.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libc" /pdbtype:sept /libpath:"..\..\projects\msvc\win32\libpng\dll_dbg"
 # SUBTRACT LINK32 /nodefaultlib
 # Begin Special Build Tool
 OutDir=.\dll_dbg
@@ -128,7 +128,7 @@
 # ADD BASE BSC32 /nologo
 # ADD BSC32 /nologo
 LINK32=link.exe
-# ADD BASE LINK32 libpng3.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /libpath:"..\..\projects\msvc\win32\libpng\dll"
+# ADD BASE LINK32 libpng12.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /libpath:"..\..\projects\msvc\win32\libpng\dll"
 # ADD LINK32 libpng.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386 /libpath:"..\..\projects\msvc\win32\libpng\lib"
 # Begin Special Build Tool
 OutDir=.\lib
@@ -161,7 +161,7 @@
 # ADD BASE BSC32 /nologo
 # ADD BSC32 /nologo
 LINK32=link.exe
-# ADD BASE LINK32 libpng3d.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libc" /pdbtype:sept /libpath:"..\..\projects\msvc\win32\libpng\dll_dbg"
+# ADD BASE LINK32 libpng12d.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libc" /pdbtype:sept /libpath:"..\..\projects\msvc\win32\libpng\dll_dbg"
 # SUBTRACT BASE LINK32 /nodefaultlib
 # ADD LINK32 libpng.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /nodefaultlib:"libc" /pdbtype:sept /libpath:"..\..\projects\msvc\win32\libpng\lib_dbg"
 # SUBTRACT LINK32 /nodefaultlib
diff --git a/libpng.3 b/libpng.3
index 2af5d67..96835ed 100644
--- a/libpng.3
+++ b/libpng.3
@@ -1,6 +1,6 @@
-.TH LIBPNG 3 "December 12, 2001"
+.TH LIBPNG 3 "February 22, 2002"
 .SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.2.1
+libpng \- Portable Network Graphics (PNG) Reference Library 1.2.2beta1
 .SH SYNOPSIS
 \fI\fB
 
@@ -787,7 +787,7 @@
 .SH LIBPNG.TXT
 libpng.txt - A description on how to use and modify libpng
 
- libpng version 1.2.1 - December 12, 2001
+ libpng version 1.2.2beta1 - February 22, 2002
  Updated and distributed by Glenn Randers-Pehrson
  <randeg@alum.rpi.edu>
  Copyright (c) 1998-2001 Glenn Randers-Pehrson
@@ -3635,13 +3635,13 @@
 
 .SH IX. Y2K Compliance in libpng
 
-December 12, 2001
+February 22, 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.2.1 are Y2K compliant.  It is my belief that earlier
+upward through 1.2.2beta1 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
@@ -3764,6 +3764,7 @@
  1.2.1beta-4          3    10201  3.1.2.1beta1-4
  1.2.1rc1-2           3    10201  3.1.2.1rc1-2
  1.2.1                3    10201  3.1.2.1
+ 1.2.2beta1          12    10202  12.so.0.1.2.2beta1
 
 Henceforth the source version will match the shared-library minor
 and patch numbers; the shared-library major version number will be
@@ -3821,7 +3822,7 @@
 
 Thanks to Frank J. T. Wojcik for helping with the documentation.
 
-Libpng version 1.2.1 - December 12, 2001:
+Libpng version 1.2.2beta1 - February 22, 2002:
 Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
 Currently maintained by Glenn Randers-Pehrson (randeg@alum.rpi.edu).
 
@@ -3838,7 +3839,7 @@
 If you modify libpng you may insert additional notices immediately following
 this sentence.
 
-libpng versions 1.0.7, July 1, 2000, through  1.2.1, December 12, 2001, are
+libpng versions 1.0.7, July 1, 2000, through  1.2.2beta1, February 22, 2002, are
 Copyright (c) 2000-2001 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
@@ -3930,7 +3931,7 @@
 
 Glenn Randers-Pehrson
 randeg@alum.rpi.edu
-December 12, 2001
+February 22, 2002
 
 .\" end of man page
 
diff --git a/libpng.txt b/libpng.txt
index 9b0f8df..74e315a 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.2.1 - December 12, 2001
+ libpng version 1.2.2beta1 - February 22, 2002
  Updated and distributed by Glenn Randers-Pehrson
  <randeg@alum.rpi.edu>
  Copyright (c) 1998-2001 Glenn Randers-Pehrson
@@ -2848,13 +2848,13 @@
 
 IX. Y2K Compliance in libpng
 
-December 12, 2001
+February 22, 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.2.1 are Y2K compliant.  It is my belief that earlier
+upward through 1.2.2beta1 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 7da41d1..216bc61 100644
--- a/libpngpf.3
+++ b/libpngpf.3
@@ -1,6 +1,6 @@
-.TH LIBPNGPF 3 "December 12, 2001"
+.TH LIBPNGPF 3 "February 22, 2002"
 .SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.2.1
+libpng \- Portable Network Graphics (PNG) Reference Library 1.2.2beta1
 (private functions)
 .SH SYNOPSIS
 \fB#include <png.h>\fP
diff --git a/png.5 b/png.5
index cd9d0c4..9af27fe 100644
--- a/png.5
+++ b/png.5
@@ -1,4 +1,4 @@
-.TH PNG 5 "December 12, 2001"
+.TH PNG 5 "February 22, 2002"
 .SH NAME
 png \- Portable Network Graphics (PNG) format
 .SH DESCRIPTION
diff --git a/png.c b/png.c
index 72bd00e..c9bce38 100644
--- a/png.c
+++ b/png.c
@@ -1,7 +1,7 @@
 
 /* png.c - location for general purpose libpng functions
  *
- * libpng version 1.2.1 - December 12, 2001
+ * libpng version 1.2.2beta1 - February 22, 2002
  * Copyright (c) 1998-2001 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_2_1 Your_png_h_is_not_version_1_2_1;
+typedef version_1_2_2beta1 Your_png_h_is_not_version_1_2_2beta1;
 
 /* 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.2.1";
+const char png_libpng_ver[18] = "1.2.2beta1";
 
 /* png_sig was changed to a function in version 1.0.5c */
 /* Place to hold the signature string for a PNG file. */
@@ -139,7 +139,13 @@
 png_zalloc(voidpf png_ptr, uInt items, uInt size)
 {
    png_uint_32 num_bytes = (png_uint_32)items * size;
-   png_voidp ptr = (png_voidp)png_malloc((png_structp)png_ptr, num_bytes);
+   png_voidp ptr;
+   png_structp p=png_ptr;
+   png_uint_32 save_flags=p->flags;
+
+   p->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK;
+   ptr = (png_voidp)png_malloc((png_structp)png_ptr, num_bytes);
+   p->flags=save_flags;
 
 #ifndef PNG_NO_ZALLOC_ZERO
    if (num_bytes > (png_uint_32)0x8000L)
@@ -645,7 +651,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.2.1 - December 12, 2001\n\
+   return ((png_charp) "\n libpng version 1.2.2beta1 - February 22, 2002\n\
    Copyright (c) 1998-2001 Glenn Randers-Pehrson\n\
    Copyright (c) 1996, 1997 Andreas Dilger\n\
    Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.\n");
@@ -663,8 +669,8 @@
 {
    /* Version of *.c files used when building libpng */
    if(png_ptr != NULL) /* silence compiler warning about unused png_ptr */
-      return((png_charp) "1.2.1");
-   return((png_charp) "1.2.1");
+      return((png_charp) "1.2.2beta1");
+   return((png_charp) "1.2.2beta1");
 }
 
 png_charp PNGAPI
@@ -714,7 +720,7 @@
 png_access_version_number(void)
 {
    /* Version of *.c files used when building libpng */
-   return((png_uint_32) 10201L);
+   return((png_uint_32) 10202L);
 }
 
 
diff --git a/png.h b/png.h
index 77fc420..a27de57 100644
--- a/png.h
+++ b/png.h
@@ -1,7 +1,7 @@
 
 /* png.h - header file for PNG reference library
  *
- * libpng version 1.2.1 - December 12, 2001
+ * libpng version 1.2.2beta1 - February 22, 2002
  * Copyright (c) 1998-2001 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 +9,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.2.1 - December 12, 2001: Glenn
+ *  libpng versions 0.97, January 1998, through 1.2.2beta1 - February 22, 2002: Glenn
  *  See also "Contributing Authors", below.
  *
  * Note about libpng version numbers:
@@ -81,6 +81,7 @@
  *    1.2.1beta1-4             3    10201  3.1.2.1beta1-4
  *    1.2.1rc1-2               3    10201  3.1.2.1rc1-2
  *    1.2.1                    3    10201  3.1.2.1
+ *    1.2.2beta1              12    10202  12.so.0.1.2.2beta1
  *
  *    Henceforth the source version will match the shared-library major
  *    and minor numbers; the shared-library major version number will be
@@ -110,7 +111,7 @@
  * If you modify libpng you may insert additional notices immediately following
  * this sentence.
  *
- * libpng versions 1.0.7, July 1, 2000, through  1.2.1, December 12, 2001, are
+ * libpng versions 1.0.7, July 1, 2000, through  1.2.2beta1, February 22, 2002, are
  * Copyright (c) 2000, 2001 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
@@ -215,13 +216,13 @@
  * Y2K compliance in libpng:
  * =========================
  *
- *    December 12, 2001
+ *    February 22, 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.2.1 are Y2K compliant.  It is my belief that earlier
+ *    upward through 1.2.2beta1 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
@@ -277,19 +278,19 @@
  */
 
 /* Version information for png.h - this should match the version in png.c */
-#define PNG_LIBPNG_VER_STRING "1.2.1"
+#define PNG_LIBPNG_VER_STRING "1.2.2beta1"
 
-#define PNG_LIBPNG_VER_SONUM   3
+#define PNG_LIBPNG_VER_SONUM   0
 #define PNG_LIBPNG_VER_DLLNUM  %DLLNUM%
 
 /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
 #define PNG_LIBPNG_VER_MAJOR   1
 #define PNG_LIBPNG_VER_MINOR   2
-#define PNG_LIBPNG_VER_RELEASE 1
+#define PNG_LIBPNG_VER_RELEASE 2
 /* This should match the numeric part of the final component of
  * PNG_LIBPNG_VER_STRING, omitting any leading zero: */
 
-#define PNG_LIBPNG_VER_BUILD  0
+#define PNG_LIBPNG_VER_BUILD  1
 
 #define PNG_LIBPNG_BUILD_ALPHA    1
 #define PNG_LIBPNG_BUILD_BETA     2
@@ -297,14 +298,14 @@
 #define PNG_LIBPNG_BUILD_STABLE   4
 #define PNG_LIBPNG_BUILD_TYPEMASK 7
 #define PNG_LIBPNG_BUILD_PATCH    8 /* Can be OR'ed with STABLE only */
-#define PNG_LIBPNG_BUILD_TYPE 4
+#define PNG_LIBPNG_BUILD_TYPE 2
 
 /* Careful here.  At one time, Guy wanted to use 082, but that would be octal.
  * We must not include leading zeros.
  * 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 10201 /* 1.2.1 */
+#define PNG_LIBPNG_VER 10202 /* 1.2.2 */
 
 #ifndef PNG_VERSION_INFO_ONLY
 
@@ -1253,9 +1254,9 @@
 
 
 /* This prevents a compiler error in png_get_copyright() in png.c if png.c
-   and png.h are both at version 1.2.1
+   and png.h are both at version 1.2.2beta1
  */
-typedef png_structp version_1_2_1;
+typedef png_structp version_1_2_2beta1;
 
 typedef png_struct FAR * FAR * png_structpp;
 
@@ -2372,7 +2373,7 @@
 /* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */
 
 #define PNG_HEADER_VERSION_STRING \
-   " libpng version 1.2.1 - December 12, 2001 (header)\n"
+   " libpng version 1.2.2beta1 - February 22, 2002 (header)\n"
 
 #ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
 /* With these routines we avoid an integer divide, which will be slower on
@@ -2497,6 +2498,7 @@
 #define PNG_FLAG_LIBRARY_MISMATCH         0x20000L
 #define PNG_FLAG_STRIP_ERROR_NUMBERS      0x40000L
 #define PNG_FLAG_STRIP_ERROR_TEXT         0x80000L
+#define PNG_FLAG_MALLOC_NULL_MEM_OK       0x100000L
 
 /* For use in png_set_keep_unknown, png_handle_as_unknown */
 #define HANDLE_CHUNK_AS_DEFAULT   0
diff --git a/pngasmrd.h b/pngasmrd.h
index b96a464..39fb138 100644
--- a/pngasmrd.h
+++ b/pngasmrd.h
@@ -1,6 +1,6 @@
 /* pngasmrd.h - assembler version of utilities to read a PNG file
  *
- * libpng 1.2.1 - December 12, 2001
+ * libpng 1.2.2beta1 - February 22, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 2001 Glenn Randers-Pehrson
  *
diff --git a/pngconf.h b/pngconf.h
index e482748..b78aef6 100644
--- a/pngconf.h
+++ b/pngconf.h
@@ -1,6 +1,6 @@
 /* pngconf.h - machine configurable file for libpng
  *
- * libpng 1.2.1 - December 12, 2001
+ * libpng 1.2.2beta1 - February 22, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
diff --git a/pngerror.c b/pngerror.c
index b6ad8d8..ace326d 100644
--- a/pngerror.c
+++ b/pngerror.c
@@ -1,7 +1,7 @@
 
 /* pngerror.c - stub functions for i/o and memory allocation
  *
- * libpng 1.2.1 - December 12, 2001
+ * libpng 1.2.2beta1 - February 22, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
diff --git a/pnggccrd.c b/pnggccrd.c
index e4540c5..b59be97 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.2.1 - December 12, 2001
+ * libpng version 1.2.2beta1 - February 22, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 Glenn Randers-Pehrson
  * Copyright (c) 1998, Intel Corporation
diff --git a/pngget.c b/pngget.c
index f180f3d..fbea578 100644
--- a/pngget.c
+++ b/pngget.c
@@ -1,7 +1,7 @@
 
 /* pngget.c - retrieval of values from info struct
  *
- * libpng 1.2.1 - December 12, 2001
+ * libpng 1.2.2beta1 - February 22, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
diff --git a/pngmem.c b/pngmem.c
index b1741a4..5d2dff6 100644
--- a/pngmem.c
+++ b/pngmem.c
@@ -1,7 +1,7 @@
 
 /* pngmem.c - stub functions for memory allocation
  *
- * libpng 1.2.1 - December 12, 2001
+ * libpng 1.2.2beta1 - February 22, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -123,7 +123,7 @@
    if(png_ptr->malloc_fn != NULL)
    {
        ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size));
-       if (ret == NULL)
+       if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
           png_error(png_ptr, "Out of memory!");
        return (ret);
    }
@@ -177,12 +177,22 @@
 
             if (table == NULL)
             {
-               png_error(png_ptr, "Out Of Memory."); /* Note "O" and "M" */
+               if (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
+                  png_error(png_ptr, "Out Of Memory."); /* Note "O" and "M" */
+               else
+                  png_warning(png_ptr, "Out Of Memory.");
+               return (NULL);
             }
 
             if ((png_size_t)table & 0xfff0)
             {
-               png_error(png_ptr, "Farmalloc didn't return normalized pointer");
+               if (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
+                  png_error(png_ptr,
+                    "Farmalloc didn't return normalized pointer");
+               else
+                  png_warning(png_ptr,
+                    "Farmalloc didn't return normalized pointer");
+               return (NULL);
             }
 
             png_ptr->offset_table = table;
@@ -191,7 +201,11 @@
 
             if (png_ptr->offset_table_ptr == NULL)
             {
-               png_error(png_ptr, "Out Of memory.");
+               if (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
+                  png_error(png_ptr, "Out Of memory."); /* Note "O" and "M" */
+               else
+                  png_warning(png_ptr, "Out Of memory.");
+               return (NULL);
             }
 
             hptr = (png_byte huge *)table;
@@ -213,7 +227,13 @@
       }
 
       if (png_ptr->offset_table_count >= png_ptr->offset_table_number)
-         png_error(png_ptr, "Out of Memory.");
+      {
+         if (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
+            png_error(png_ptr, "Out of Memory."); /* Note "o" and "M" */
+         else
+            png_warning(png_ptr, "Out of Memory.");
+         return (NULL);
+      }
 
       ret = png_ptr->offset_table_ptr[png_ptr->offset_table_count++];
    }
@@ -222,7 +242,10 @@
 
    if (ret == NULL)
    {
-      png_error(png_ptr, "Out of memory."); /* Note "o" and "m" */
+      if (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
+         png_error(png_ptr, "Out of memory."); /* Note "o" and "m" */
+      else
+         png_warning(png_ptr, "Out of memory."); /* Note "o" and "m" */
    }
 
    return (ret);
@@ -394,7 +417,7 @@
    if(png_ptr->malloc_fn != NULL)
    {
        ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, size));
-       if (ret == NULL)
+       if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
           png_error(png_ptr, "Out of Memory!");
        return (ret);
    }
@@ -409,7 +432,12 @@
 
 #ifdef PNG_MAX_MALLOC_64K
    if (size > (png_uint_32)65536L)
-      png_error(png_ptr, "Cannot Allocate > 64K");
+   {
+      if(png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
+         png_error(png_ptr, "Cannot Allocate > 64K");
+      else
+         return NULL;
+   }
 #endif
 
 #if defined(__TURBOC__) && !defined(__FLAT__)
@@ -422,7 +450,7 @@
 # endif
 #endif
 
-   if (ret == NULL)
+   if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
       png_error(png_ptr, "Out of Memory");
 
    return (ret);
diff --git a/pngpread.c b/pngpread.c
index 9207cbd..8d59aa4 100644
--- a/pngpread.c
+++ b/pngpread.c
@@ -1,7 +1,7 @@
 
 /* pngpread.c - read a png file in push mode
  *
- * libpng 1.2.1 - December 12, 2001
+ * libpng 1.2.2beta1 - February 22, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
diff --git a/pngread.c b/pngread.c
index c47df62..9a6169c 100644
--- a/pngread.c
+++ b/pngread.c
@@ -1,7 +1,7 @@
 
 /* pngread.c - read a PNG file
  *
- * libpng 1.2.1 - December 12, 2001
+ * libpng 1.2.2beta1 - February 22, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -45,11 +45,12 @@
 
    png_debug(1, "in png_create_read_struct\n");
 #ifdef PNG_USER_MEM_SUPPORTED
-   if ((png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG,
-      (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr)) == NULL)
+   png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG,
+      (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr);
 #else
-   if ((png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG)) == NULL)
+   png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG);
 #endif
+   if (png_ptr == NULL)
       return (NULL);
 
 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED
@@ -767,7 +768,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.2.1
+ * [*] png_handle_alpha() does not exist yet, as of libpng version 1.2.2beta1
  */
 
 void PNGAPI
@@ -816,7 +817,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.2.1
+ * [*] png_handle_alpha() does not exist yet, as of libpng version 1.2.2beta1
  */
 void PNGAPI
 png_read_image(png_structp png_ptr, png_bytepp image)
diff --git a/pngrio.c b/pngrio.c
index 79755b4..54f2be9 100644
--- a/pngrio.c
+++ b/pngrio.c
@@ -1,7 +1,7 @@
 
 /* pngrio.c - functions for data input
  *
- * libpng 1.2.1 - December 12, 2001
+ * libpng 1.2.2beta1 - February 22, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
diff --git a/pngrtran.c b/pngrtran.c
index 2d62779..8f846c9 100644
--- a/pngrtran.c
+++ b/pngrtran.c
@@ -1,7 +1,7 @@
 
 /* pngrtran.c - transforms the data in a row for PNG readers
  *
- * libpng 1.2.1 - December 12, 2001
+ * libpng 1.2.2beta1 - February 22, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
diff --git a/pngrutil.c b/pngrutil.c
index dca7c65..4db4016 100644
--- a/pngrutil.c
+++ b/pngrutil.c
@@ -1,7 +1,7 @@
 
 /* pngrutil.c - utilities to read a PNG file
  *
- * libpng 1.2.1 - December 12, 2001
+ * libpng 1.2.2beta1 - February 22, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -691,6 +691,8 @@
    png_fixed_point int_x_white, int_y_white, int_x_red, int_y_red, int_x_green,
       int_y_green, int_x_blue, int_y_blue;
 
+   png_uint_32 uint_x, uint_y;
+
    png_debug(1, "in png_handle_cHRM\n");
 
    if (!(png_ptr->mode & PNG_HAVE_IHDR))
@@ -724,60 +726,69 @@
    }
 
    png_crc_read(png_ptr, buf, 4);
-   int_x_white = (png_fixed_point)png_get_uint_32(buf);
+   uint_x = png_get_uint_32(buf);
 
    png_crc_read(png_ptr, buf, 4);
-   int_y_white = (png_fixed_point)png_get_uint_32(buf);
+   uint_y = png_get_uint_32(buf);
 
-   if (int_x_white > 80000L || int_y_white > 80000L ||
-      int_x_white + int_y_white > 100000L)
+   if (uint_x > 80000L || uint_y > 80000L ||
+      uint_x + uint_y > 100000L)
    {
       png_warning(png_ptr, "Invalid cHRM white point");
       png_crc_finish(png_ptr, 24);
       return;
    }
+   int_x_white = (png_fixed_point)uint_x;
+   int_y_white = (png_fixed_point)uint_y;
 
    png_crc_read(png_ptr, buf, 4);
-   int_x_red = (png_fixed_point)png_get_uint_32(buf);
+   uint_x = png_get_uint_32(buf);
 
    png_crc_read(png_ptr, buf, 4);
-   int_y_red = (png_fixed_point)png_get_uint_32(buf);
+   uint_y = png_get_uint_32(buf);
 
-   if (int_x_red > 80000L || int_y_red > 80000L ||
-      int_x_red + int_y_red > 100000L)
+   if (uint_x > 80000L || uint_y > 80000L ||
+      uint_x + uint_y > 100000L)
    {
       png_warning(png_ptr, "Invalid cHRM red point");
       png_crc_finish(png_ptr, 16);
       return;
    }
+   int_x_red = (png_fixed_point)uint_x;
+   int_y_red = (png_fixed_point)uint_y;
 
    png_crc_read(png_ptr, buf, 4);
-   int_x_green = (png_fixed_point)png_get_uint_32(buf);
+   uint_x = png_get_uint_32(buf);
 
    png_crc_read(png_ptr, buf, 4);
-   int_y_green = (png_fixed_point)png_get_uint_32(buf);
+   uint_y = png_get_uint_32(buf);
 
-   if (int_x_green > 80000L || int_y_green > 80000L ||
-      int_x_green + int_y_green > 100000L)
+   if (uint_x > 80000L || uint_y > 80000L ||
+      uint_x + uint_y > 100000L)
    {
       png_warning(png_ptr, "Invalid cHRM green point");
       png_crc_finish(png_ptr, 8);
       return;
    }
+   int_x_green = (png_fixed_point)uint_x;
+   int_y_green = (png_fixed_point)uint_y;
 
    png_crc_read(png_ptr, buf, 4);
-   int_x_blue = (png_fixed_point)png_get_uint_32(buf);
+   uint_x = png_get_uint_32(buf);
 
    png_crc_read(png_ptr, buf, 4);
-   int_y_blue = (png_fixed_point)png_get_uint_32(buf);
+   uint_y = png_get_uint_32(buf);
 
-   if (int_x_blue > 80000L || int_y_blue > 80000L ||
-      int_x_blue + int_y_blue > 100000L)
+   if (uint_x > 80000L || uint_y > 80000L ||
+      uint_x + uint_y > 100000L)
    {
       png_warning(png_ptr, "Invalid cHRM blue point");
       png_crc_finish(png_ptr, 0);
       return;
    }
+   int_x_blue = (png_fixed_point)uint_x;
+   int_y_blue = (png_fixed_point)uint_y;
+
 #ifdef PNG_FLOATING_POINT_SUPPORTED
    white_x = (float)int_x_white / (float)100000.0;
    white_y = (float)int_y_white / (float)100000.0;
@@ -895,17 +906,6 @@
       igamma=(int)(info_ptr->gamma * 100000.);
 #  endif
 #endif
-#if 0 && defined(PNG_cHRM_SUPPORTED) && !defined(PNG_FIXED_POINT_SUPPORTED)
-/* We need to define these here because they aren't in png.h */
-   png_fixed_point int_x_white;
-   png_fixed_point int_y_white;
-   png_fixed_point int_x_red;
-   png_fixed_point int_y_red;
-   png_fixed_point int_x_green;
-   png_fixed_point int_y_green;
-   png_fixed_point int_x_blue;
-   png_fixed_point int_y_blue;
-#endif
       if(igamma < 45000L || igamma > 46000L)
       {
          png_warning(png_ptr,
@@ -952,6 +952,7 @@
 {
    png_charp chunkdata;
    png_byte compression_type;
+   png_bytep pC;
    png_charp profile;
    png_uint_32 skip = 0;
    png_uint_32 profile_size = 0;
@@ -1037,10 +1038,11 @@
    }
 
    /* Check the profile_size recorded in the first 32 bits of the ICC profile */
-   profile_size = ((*(chunkdata+prefix_length))<<24) |
-                  ((*(chunkdata+prefix_length+1))<<16) |
-                  ((*(chunkdata+prefix_length+2))<< 8) |
-                  ((*(chunkdata+prefix_length+3))    );
+   pC = (png_bytep)(chunkdata+prefix_length);
+   profile_size = ((*(pC  ))<<24) |
+                  ((*(pC+1))<<16) |
+                  ((*(pC+2))<< 8) |
+                  ((*(pC+3))    );
 
    if(profile_size < profile_length)
       profile_length = profile_size;
diff --git a/pngset.c b/pngset.c
index 7878f37..aeb3a44 100644
--- a/pngset.c
+++ b/pngset.c
@@ -1,7 +1,7 @@
 
 /* pngset.c - storage of image information into info struct
  *
- * libpng 1.2.1 - December 12, 2001
+ * libpng 1.2.2beta1 - February 22, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -40,6 +40,25 @@
    if (png_ptr == NULL || info_ptr == NULL)
       return;
 
+   if (white_x < 0.0 || white_y < 0.0 ||
+         red_x < 0.0 ||   red_y < 0.0 ||
+       green_x < 0.0 || green_y < 0.0 ||
+        blue_x < 0.0 ||  blue_y < 0.0)
+   {
+      png_warning(png_ptr,
+        "Ignoring attempt to set negative chromaticity value");
+      return;
+   }
+   if (white_x > 21474.83 || white_y > 21474.83 ||
+         red_x > 21474.83 ||   red_y > 21474.83 ||
+       green_x > 21474.83 || green_y > 21474.83 ||
+        blue_x > 21474.83 ||  blue_y > 21474.83)
+   {
+      png_warning(png_ptr,
+        "Ignoring attempt to set chromaticity value exceeding 21474.83");
+      return;
+   }
+
    info_ptr->x_white = (float)white_x;
    info_ptr->y_white = (float)white_y;
    info_ptr->x_red   = (float)red_x;
@@ -51,12 +70,12 @@
 #ifdef PNG_FIXED_POINT_SUPPORTED
    info_ptr->int_x_white = (png_fixed_point)(white_x*100000.+0.5);
    info_ptr->int_y_white = (png_fixed_point)(white_y*100000.+0.5);
-   info_ptr->int_x_red   = (png_fixed_point)(red_x*100000.+0.5);
-   info_ptr->int_y_red   = (png_fixed_point)(red_y*100000.+0.5);
+   info_ptr->int_x_red   = (png_fixed_point)(  red_x*100000.+0.5);
+   info_ptr->int_y_red   = (png_fixed_point)(  red_y*100000.+0.5);
    info_ptr->int_x_green = (png_fixed_point)(green_x*100000.+0.5);
    info_ptr->int_y_green = (png_fixed_point)(green_y*100000.+0.5);
-   info_ptr->int_x_blue  = (png_fixed_point)(blue_x*100000.+0.5);
-   info_ptr->int_y_blue  = (png_fixed_point)(blue_y*100000.+0.5);
+   info_ptr->int_x_blue  = (png_fixed_point)( blue_x*100000.+0.5);
+   info_ptr->int_y_blue  = (png_fixed_point)( blue_y*100000.+0.5);
 #endif
    info_ptr->valid |= PNG_INFO_cHRM;
 }
@@ -72,6 +91,24 @@
    if (png_ptr == NULL || info_ptr == NULL)
       return;
 
+   if (white_x < 0 || white_y < 0 ||
+         red_x < 0 ||   red_y < 0 ||
+       green_x < 0 || green_y < 0 ||
+        blue_x < 0 ||  blue_y < 0)
+   {
+      png_warning(png_ptr,
+        "Ignoring attempt to set negative chromaticity value");
+      return;
+   }
+   if (white_x > PNG_MAX_UINT || white_y > PNG_MAX_UINT ||
+         red_x > PNG_MAX_UINT ||   red_y > PNG_MAX_UINT ||
+       green_x > PNG_MAX_UINT || green_y > PNG_MAX_UINT ||
+        blue_x > PNG_MAX_UINT ||  blue_y > PNG_MAX_UINT)
+   {
+      png_warning(png_ptr,
+        "Ignoring attempt to set chromaticity value exceeding 21474.83");
+      return;
+   }
    info_ptr->int_x_white = white_x;
    info_ptr->int_y_white = white_y;
    info_ptr->int_x_red   = red_x;
@@ -83,12 +120,12 @@
 #ifdef PNG_FLOATING_POINT_SUPPORTED
    info_ptr->x_white = (float)(white_x/100000.);
    info_ptr->y_white = (float)(white_y/100000.);
-   info_ptr->x_red   = (float)(red_x/100000.);
-   info_ptr->y_red   = (float)(red_y/100000.);
+   info_ptr->x_red   = (float)(  red_x/100000.);
+   info_ptr->y_red   = (float)(  red_y/100000.);
    info_ptr->x_green = (float)(green_x/100000.);
    info_ptr->y_green = (float)(green_y/100000.);
-   info_ptr->x_blue  = (float)(blue_x/100000.);
-   info_ptr->y_blue  = (float)(blue_y/100000.);
+   info_ptr->x_blue  = (float)( blue_x/100000.);
+   info_ptr->y_blue  = (float)( blue_y/100000.);
 #endif
    info_ptr->valid |= PNG_INFO_cHRM;
 }
@@ -100,16 +137,25 @@
 void PNGAPI
 png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma)
 {
+   double gamma;
    png_debug1(1, "in %s storage function\n", "gAMA");
    if (png_ptr == NULL || info_ptr == NULL)
       return;
 
-   info_ptr->gamma = (float)file_gamma;
+   /* Check for overflow */
+   if (file_gamma > 21474.83)
+   {
+      png_warning(png_ptr, "Limiting gamma to 21474.83");
+      gamma=21474.83;
+   }
+   else
+      gamma=file_gamma;
+   info_ptr->gamma = (float)gamma;
 #ifdef PNG_FIXED_POINT_SUPPORTED
-   info_ptr->int_gamma = (int)(file_gamma*100000.+.5);
+   info_ptr->int_gamma = (int)(gamma*100000.+.5);
 #endif
    info_ptr->valid |= PNG_INFO_gAMA;
-   if(file_gamma == 0.0)
+   if(gamma == 0.0)
       png_warning(png_ptr, "Setting gamma=0");
 }
 #endif
@@ -117,18 +163,35 @@
 png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point
    int_gamma)
 {
+   png_fixed_point gamma;
+
    png_debug1(1, "in %s storage function\n", "gAMA");
    if (png_ptr == NULL || info_ptr == NULL)
       return;
 
+   if (int_gamma > PNG_MAX_UINT)
+   {
+     png_warning(png_ptr, "Limiting gamma to 21474.83");
+     gamma=PNG_MAX_UINT;
+   }
+   else
+   {
+     if (int_gamma < 0)
+     {
+       png_warning(png_ptr, "Setting negative gamma to zero");
+       gamma=0;
+     }
+     else
+       gamma=int_gamma;
+   }
 #ifdef PNG_FLOATING_POINT_SUPPORTED
-   info_ptr->gamma = (float)(int_gamma/100000.);
+   info_ptr->gamma = (float)(gamma/100000.);
 #endif
 #ifdef PNG_FIXED_POINT_SUPPORTED
-   info_ptr->int_gamma = int_gamma;
+   info_ptr->int_gamma = gamma;
 #endif
    info_ptr->valid |= PNG_INFO_gAMA;
-   if(int_gamma == 0)
+   if(gamma == 0)
       png_warning(png_ptr, "Setting gamma=0");
 }
 #endif
@@ -415,6 +478,8 @@
       in case of an invalid PNG file that has too-large sample values. */
    png_ptr->palette = (png_colorp)png_zalloc(png_ptr, (uInt)256,
       sizeof (png_color));
+   if (png_ptr->palette == NULL)
+      png_error(png_ptr, "Unable to malloc palette");
    png_memcpy(png_ptr->palette, palette, num_palette * sizeof (png_color));
    info_ptr->palette = png_ptr->palette;
    info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette;
diff --git a/pngtest.c b/pngtest.c
index 62d9349..828eabf 100644
--- a/pngtest.c
+++ b/pngtest.c
@@ -1,7 +1,7 @@
 
 /* pngtest.c - a simple test program to test libpng
  *
- * libpng 1.2.1 - December 12, 2001
+ * libpng 1.2.2beta1 - February 22, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -1512,4 +1512,4 @@
 }
 
 /* Generate a compiler error if there is an old png.h in the search path. */
-typedef version_1_2_1 your_png_h_is_not_version_1_2_1;
+typedef version_1_2_2beta1 your_png_h_is_not_version_1_2_2beta1;
diff --git a/pngtrans.c b/pngtrans.c
index 6eee9fb..f0cebb4 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.2.1 - December 12, 2001
+ * libpng 1.2.2beta1 - February 22, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
diff --git a/pngvcrd.c b/pngvcrd.c
index d0aa58b..52e6c72 100644
--- a/pngvcrd.c
+++ b/pngvcrd.c
@@ -2,7 +2,7 @@
  *
  * For Intel x86 CPU and Microsoft Visual C++ compiler
  *
- * libpng version 1.2.1 - December 12, 2001
+ * libpng version 1.2.2beta1 - February 22, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 Glenn Randers-Pehrson
  * Copyright (c) 1998, Intel Corporation
diff --git a/pngwio.c b/pngwio.c
index 01ebbcf..3fb9e56 100644
--- a/pngwio.c
+++ b/pngwio.c
@@ -1,7 +1,7 @@
 
 /* pngwio.c - functions for data output
  *
- * libpng 1.2.1 - December 12, 2001
+ * libpng 1.2.2beta1 - February 22, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
diff --git a/pngwrite.c b/pngwrite.c
index f46ce0f..827e9af 100644
--- a/pngwrite.c
+++ b/pngwrite.c
@@ -1,7 +1,7 @@
 
 /* pngwrite.c - general routines to write a PNG file
  *
- * libpng 1.2.1 - December 12, 2001
+ * libpng 1.2.2beta1 - February 22, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -443,11 +443,12 @@
    int i;
    png_debug(1, "in png_create_write_struct\n");
 #ifdef PNG_USER_MEM_SUPPORTED
-   if ((png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG,
-      (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr)) == NULL)
+   png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG,
+      (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr);
 #else
-   if ((png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG)) == NULL)
+   png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG);
 #endif /* PNG_USER_MEM_SUPPORTED */
+   if (png_ptr == NULL)
       return (NULL);
 
 #ifdef PNG_ASSEMBLER_CODE_SUPPORTED
diff --git a/pngwtran.c b/pngwtran.c
index 55e691d..97cb181 100644
--- a/pngwtran.c
+++ b/pngwtran.c
@@ -1,7 +1,7 @@
 
 /* pngwtran.c - transforms the data in a row for PNG writers
  *
- * libpng 1.2.1 - December 12, 2001
+ * libpng 1.2.2beta1 - February 22, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
diff --git a/pngwutil.c b/pngwutil.c
index 1f2d724..6c4f15e 100644
--- a/pngwutil.c
+++ b/pngwutil.c
@@ -1,7 +1,7 @@
 
 /* pngwutil.c - utilities to write a PNG file
  *
- * libpng 1.2.1 - December 12, 2001
+ * libpng 1.2.2beta1 - February 22, 2002
  * For conditions of distribution and use, see copyright notice in png.h
  * Copyright (c) 1998-2001 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 63d2595..2993e8f 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.2.1 (December 12, 2001) and zlib
+libpng 1.2.2beta1 (February 22, 2002) and zlib
 
 Copyright (C) 2000 Simon-Pierre Cadieux
 For conditions of distribution and use, see copyright notice in png.h
@@ -24,12 +24,12 @@
 This project will build the PNG Development Group's "official" versions of
 libpng and zlib libraries:
 
-   libpng3.dll          (default version, currently C code only)
-   libpng3.dll         (C + Assembler version)
-   libpng3.dll         (C + Assembler debug version)
-   libpng3.dll         (C code debug version)
-   libpng3[c,e-m].dll   (reserved for official versions) 
-   libpng3[n-z].dll     (available for private versions)
+   libpng12.dll          (default version, currently C code only)
+   libpng12.dll         (C + Assembler version)
+   libpng12.dll         (C + Assembler debug version)
+   libpng12.dll         (C code debug version)
+   libpng12[c,e-m].dll   (reserved for official versions) 
+   libpng12[n-z].dll     (available for private versions)
    zlib.dll             (default version, currently C code only)
    zlibd.dll            (debug version)
 
diff --git a/projects/msvc/libpng.dsp b/projects/msvc/libpng.dsp
index 779aea7..fd9bb4f 100644
--- a/projects/msvc/libpng.dsp
+++ b/projects/msvc/libpng.dsp
@@ -56,7 +56,7 @@
 # ADD BSC32 /nologo
 LINK32=link.exe
 # ADD BASE LINK32 /nologo /dll /machine:I386
-# ADD LINK32 /nologo /dll /machine:I386 /out:".\win32\libpng\dll\libpng3.dll"
+# ADD LINK32 /nologo /dll /machine:I386 /out:".\win32\libpng\dll\libpng12.dll"
 # SUBTRACT LINK32 /pdb:none
 
 !ELSEIF  "$(CFG)" == "libpng - Win32 DLL Debug"
@@ -84,7 +84,7 @@
 # ADD BSC32 /nologo
 LINK32=link.exe
 # ADD BASE LINK32 /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 /nologo /dll /debug /machine:I386 /out:".\win32\libpng\dll_dbg\libpng3d.dll"
+# ADD LINK32 /nologo /dll /debug /machine:I386 /out:".\win32\libpng\dll_dbg\libpng12d.dll"
 
 !ELSEIF  "$(CFG)" == "libpng - Win32 DLL ASM"
 
@@ -111,7 +111,7 @@
 # ADD BSC32 /nologo
 LINK32=link.exe
 # ADD BASE LINK32 /nologo /dll /machine:I386
-# ADD LINK32 /nologo /dll /machine:I386 /out:".\win32\libpng\dll_asm\libpng3a.dll"
+# ADD LINK32 /nologo /dll /machine:I386 /out:".\win32\libpng\dll_asm\libpng12a.dll"
 # SUBTRACT LINK32 /pdb:none
 
 !ELSEIF  "$(CFG)" == "libpng - Win32 DLL Debug ASM"
@@ -139,7 +139,7 @@
 # ADD BSC32 /nologo
 LINK32=link.exe
 # ADD BASE LINK32 /nologo /dll /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 /nologo /dll /debug /machine:I386 /out:".\win32\libpng\dll_dbga\libpng3b.dll"
+# ADD LINK32 /nologo /dll /debug /machine:I386 /out:".\win32\libpng\dll_dbga\libpng12b.dll"
 
 !ELSEIF  "$(CFG)" == "libpng - Win32 LIB"
 
diff --git a/projects/msvc/png32ms.def b/projects/msvc/png32ms.def
index e94f0f6..2ee8502 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.2.1
+;Version 1.2.2beta1
   png_build_grayscale_palette  @1
   png_check_sig        @2
   png_chunk_error      @3
diff --git a/projects/netware.txt b/projects/netware.txt
index 4e1f5f0..439b136 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.2.1-project-netware.zip from a libpng distribution
+libpng-1.2.2beta1-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.2.1-project-netware.zip"
+"unzip -a libpng-1.2.2beta1-project-netware.zip"
diff --git a/projects/wince.txt b/projects/wince.txt
index 1a229a0..3d4f1d7 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.2.1-project-wince.zip from a libpng distribution
+libpng-1.2.2beta1-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.2.1-project-wince.zip"
+"unzip -a libpng-1.2.2beta1-project-wince.zip"
diff --git a/scripts/makefile.aix b/scripts/makefile.aix
index 01b4cda..52ded49 100644
--- a/scripts/makefile.aix
+++ b/scripts/makefile.aix
@@ -15,10 +15,10 @@
 RANLIB = ranlib
 RM = rm -f
 
-# read libpng.txt or png.h to see why PNGMAJ is 3.  You should not
+# read libpng.txt or png.h to see why PNGMAJ is 0.  You should not
 # have to change it.
-PNGMAJ = 3
-PNGMIN = 1.2.1
+PNGMAJ = 0
+PNGMIN = 1.2.2beta1
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 prefix=/usr/local
diff --git a/scripts/makefile.beos b/scripts/makefile.beos
index 3656efc..130a7ef 100644
--- a/scripts/makefile.beos
+++ b/scripts/makefile.beos
@@ -10,10 +10,10 @@
 ZLIBLIB=/usr/local/lib
 ZLIBINC=/usr/local/include
 
-# read libpng.txt or png.h to see why PNGMAJ is 3.  You should not
+# read libpng.txt or png.h to see why PNGMAJ is 0.  You should not
 # have to change it.
-PNGMAJ = 3
-PNGMIN = 1.2.1
+PNGMAJ = 0
+PNGMIN = 1.2.2beta1
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 ALIGN=
@@ -29,15 +29,16 @@
 CFLAGS=-I$(ZLIBINC) -Wall -O1 -funroll-loops \
 	$(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
 # LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng -lz -lm
-LDFLAGS=-L. -Wl,-soname=libpng.so.$(PNGMAJ) -L$(ZLIBLIB) -lz -lm
+LDFLAGS=-L. -Wl,-soname=$(LIBNAME).so.$(PNGMAJ) -L$(ZLIBLIB) -lz -lm
 
 RANLIB=ranlib
 #RANLIB=echo
 
-# where make install puts libpng.a, libpng.so*, and png.h
+# where make install puts libpng.a, libpng12.so*, and png.h
 prefix=/usr/local
 INCPATH=$(prefix)/include
 LIBPATH=$(prefix)/lib
+LIBNAME=libpng12
 
 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
 	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
@@ -47,42 +48,45 @@
 
 .SUFFIXES:      .c .o
 
-all: libpng.a libpng.so pngtest
+all: libpng.a $(LIBNAME).so pngtest
 
 libpng.a: $(OBJS)
 	ar rc $@ $(OBJS)
 	$(RANLIB) $@
 
-libpng.so: libpng.so.$(PNGMAJ)
-	ln -sf libpng.so.$(PNGMAJ) libpng.so
-	cp libpng.so* /boot/home/config/lib
+$(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ)
+	ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so
+	cp $(LIBNAME).so* /boot/home/config/lib
 
-libpng.so.$(PNGMAJ): libpng.so.$(PNGVER)
-	ln -sf libpng.so.$(PNGVER) libpng.so.$(PNGMAJ)
+$(LIBNAME).so.$(PNGMAJ): $(LIBNAME).so.$(PNGVER)
+	ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ)
 
-libpng.so.$(PNGVER): $(OBJSDLL)
-	$(CC) -L$(ZLIBLIB) -lz -nostart -Wl,-soname,libpng.so.$(PNGMAJ) -o
-libpng.so.$(PNGVER) \
+$(LIBNAME).so.$(PNGVER): $(OBJSDLL)
+	$(CC) -L$(ZLIBLIB) -lz -nostart -Wl,-soname,$(LIBNAME).so.$(PNGMAJ) -o
+$(LIBNAME).so.$(PNGVER) \
 	 $(OBJSDLL)
 
-pngtest: pngtest.o libpng.so
+pngtest: pngtest.o $(LIBNAME).so
 	$(CC) -L$(ZLIBLIB) -lz -lpng -o pngtest pngtest.o
 
 test: pngtest
 	./pngtest
 
-install: libpng.a libpng.so.$(PNGVER)
+install: libpng.a $(LIBNAME).so.$(PNGVER)
 	-@mkdir $(INCPATH) $(LIBPATH)
 	cp png.h pngconf.h $(INCPATH)
 	chmod 644 $(INCPATH)/png.h $(INCPATH)/pngconf.h
-	cp libpng.a libpng.so.$(PNGVER) $(LIBPATH)
-	chmod 755 $(LIBPATH)/libpng.so.$(PNGVER)
-	-@/bin/rm -f $(LIBPATH)/libpng.so.$(PNGMAJ) $(LIBPATH)/libpng.so
-	(cd $(LIBPATH); ln -sf libpng.so.$(PNGVER) libpng.so.$(PNGMAJ); \
-	 ln -sf libpng.so.$(PNGMAJ) libpng.so)
+	-@mkdir $(INCPATH) $(LIBPATH)/$(LIBNAME)
+	cp png.h pngconf.h $(INCPATH)/$(LIBNAME)
+	chmod 644 $(INCPATH)/$(LIBNAME)/png.h $(INCPATH)/$(LIBNAME)/pngconf.h
+	cp libpng.a $(LIBNAME).so.$(PNGVER) $(LIBPATH)
+	chmod 755 $(LIBPATH)/$(LIBNAME).so.$(PNGVER)
+	-@/bin/rm -f $(LIBPATH)/$(LIBNAME).so.$(PNGMAJ) $(LIBPATH)/$(LIBNAME).so
+	(cd $(LIBPATH); ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \
+	 ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so)
 
 clean:
-	/bin/rm -f *.o libpng.a libpng.so libpng.so.$(PNGMAJ)* pngtest pngout.png
+	/bin/rm -f *.o libpng.a $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* pngtest pngout.png
 
 # DO NOT DELETE THIS LINE -- make depend depends on it.
 
diff --git a/scripts/makefile.cygwin b/scripts/makefile.cygwin
index a5587a0..4defb96 100644
--- a/scripts/makefile.cygwin
+++ b/scripts/makefile.cygwin
@@ -35,12 +35,12 @@
 CFLAGS=-I$(ZLIBINC) -Wall -O3 $(ALIGN) -funroll-loops \
 	-fomit-frame-pointer
 
-# read libpng.txt or png.h to see why PNGMAJ is 3.  You should not
+# read libpng.txt or png.h to see why PNGMAJ is 0.  You should not
 # have to change it.
-PNGMAJ = 3
-#PNGDLL = $3
-PNGMIN = 1.2.1
-PNGMIN_BASE = 1.2.1
+PNGMAJ = 0
+#PNGDLL = $12
+PNGMIN = 1.2.2beta1
+PNGMIN_BASE = 1.2.2
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 SHAREDLIB=cygpng$(PNGDLL).dll
diff --git a/scripts/makefile.darwin b/scripts/makefile.darwin
index 87f9d31..d1369ea 100644
--- a/scripts/makefile.darwin
+++ b/scripts/makefile.darwin
@@ -1,11 +1,12 @@
 # makefile for libpng on Darwin / Mac OS X
+# Copyright (C) 2002 Glenn Randers-Pehrson
 # Copyright (C) 2001 Christoph Pfisterer
 # derived from makefile.linux:
 #  Copyright (C) 1998, 1999 Greg Roelofs
 #  Copyright (C) 1996, 1997 Andreas Dilger
 # For conditions of distribution and use, see copyright notice in png.h
 
-# where "make install" puts libpng.a, libpng.dylib, png.h and pngconf.h
+# where "make install" puts libpng.a, libpng12.dylib, png.h and pngconf.h
 prefix=/usr/local
 
 # Where the zlib library and include files are located
@@ -21,11 +22,12 @@
 #RANLIB=echo
 RANLIB=ranlib
 
-# read libpng.txt or png.h to see why PNGMAJ is 3.  You should not
+# read libpng.txt or png.h to see why PNGMAJ is 0.  You should not
 # have to change it.
-PNGMAJ = 3
-PNGMIN = 1.2.1
+PNGMAJ = 0
+PNGMIN = 1.2.2beta1
 PNGVER = $(PNGMAJ).$(PNGMIN)
+LIBNAME = libpng12
 
 INCPATH=$(prefix)/include
 LIBPATH=$(prefix)/lib
@@ -41,45 +43,50 @@
 .c.pic.o:
 	$(CC) -c $(CFLAGS) -fno-common -o $@ $*.c
 
-all: libpng.a libpng.dylib pngtest
+all: libpng.a $(LIBNAME).dylib pngtest
 
 libpng.a: $(OBJS)
 	ar rc $@ $(OBJS)
 	$(RANLIB) $@
 
-libpng.dylib: libpng.$(PNGMAJ).dylib
-	ln -sf libpng.$(PNGMAJ).dylib libpng.dylib
+$(LIBNAME).dylib: $(LIBNAME).$(PNGMAJ).dylib
+	ln -sf $(LIBNAME).$(PNGMAJ).dylib $(LIBNAME).dylib
 
-libpng.$(PNGMAJ).dylib: libpng.$(PNGVER).dylib
-	ln -sf libpng.$(PNGVER).dylib libpng.$(PNGMAJ).dylib
+$(LIBNAME).$(PNGMAJ).dylib: $(LIBNAME).$(PNGVER).dylib
+	ln -sf $(LIBNAME).$(PNGVER).dylib $(LIBNAME).$(PNGMAJ).dylib
 
-libpng.$(PNGVER).dylib: $(OBJSDLL)
-	$(CC) -dynamiclib -undefined suppress \
-	 -install_name $(LIBPATH)/libpng.$(PNGMAJ).dylib \
+$(LIBNAME).$(PNGVER).dylib: $(OBJSDLL)
+	$(CC) -dynamiclib \
+	 -install_name $(LIBPATH)/$(LIBNAME).$(PNGMAJ).dylib \
 	 -current_version $(PNGMIN) -compatibility_version $(PNGMIN) \
-	 -o libpng.$(PNGVER).dylib \
+	 -o $(LIBNAME).$(PNGVER).dylib \
 	 $(OBJSDLL) -L$(ZLIBLIB) -lz
 
-pngtest: pngtest.o libpng.dylib
+pngtest: pngtest.o $(LIBNAME).dylib
 	$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
 
 test: pngtest
 	./pngtest
 
-install: libpng.a libpng.dylib
+install: libpng.a $(LIBNAME).dylib
 	-@if [ ! -d $(INCPATH)  ]; then mkdir $(INCPATH); fi
 	-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
+	-@if [ ! -d $(INCPATH)/$(LIBNAME)  ]; then mkdir $(INCPATH)/$(LIBNAME); fi
 	cp png.h pngconf.h $(INCPATH)
+	cp png.h pngconf.h $(INCPATH)/$(LIBNAME)
 	chmod 644 $(INCPATH)/png.h $(INCPATH)/pngconf.h
-	cp libpng.a libpng.$(PNGVER).dylib $(LIBPATH)
-	chmod 755 $(LIBPATH)/libpng.$(PNGVER).dylib
+	chmod 644 $(INCPATH)/$(LIBNAME)/png.h $(INCPATH)/$(LIBNAME)/pngconf.h
+	cp libpng.a $(LIBNAME).$(PNGVER).dylib $(LIBPATH)
+	chmod 755 $(LIBPATH)/$(LIBNAME).$(PNGVER).dylib
 	ranlib $(LIBPATH)/libpng.a
-	-@/bin/rm -f $(LIBPATH)/libpng.$(PNGMAJ).dylib $(LIBPATH)/libpng.dylib
-	(cd $(LIBPATH); ln -sf libpng.$(PNGVER).dylib libpng.$(PNGMAJ).dylib; \
-	 ln -sf libpng.$(PNGMAJ).dylib libpng.dylib)
+	-@/bin/rm -f $(LIBPATH)/$(LIBNAME).$(PNGMAJ).dylib
+	-@/bin/rm -f $(LIBPATH)/$(LIBNAME).dylib
+	(cd $(LIBPATH); \
+	ln -sf $(LIBNAME).$(PNGVER).dylib $(LIBNAME).$(PNGMAJ).dylib; \
+	ln -sf $(LIBNAME).$(PNGMAJ).dylib $(LIBNAME).dylib)
 
 clean:
-	rm -f *.o libpng.a libpng.*dylib pngtest pngout.png
+	rm -f *.o libpng.a $(LIBNAME).*dylib pngtest pngout.png
 
 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
 writelock:
diff --git a/scripts/makefile.dec b/scripts/makefile.dec
index 5e87403..bd8c4be 100644
--- a/scripts/makefile.dec
+++ b/scripts/makefile.dec
@@ -14,11 +14,12 @@
 ZLIBLIB=../zlib
 ZLIBINC=../zlib
 
-# read libpng.txt or png.h to see why PNGMAJ is 3.  You should not
+# read libpng.txt or png.h to see why PNGMAJ is 0.  You should not
 # have to change it.
-PNGMAJ = 3
-PNGMIN = 1.2.1
+PNGMAJ = 0
+PNGMIN = 1.2.2beta1
 PNGVER = $(PNGMAJ).$(PNGMIN)
+LIBNAME = libpng12
 
 CC=cc
 CFLAGS=-std -w1 -I$(ZLIBINC) -O # -g -DPNG_DEBUG=1
@@ -31,19 +32,19 @@
 	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
 	pngwtran.o pngmem.o pngerror.o pngpread.o
 
-all: libpng.so libpng.a pngtest
+all: $(LIBNAME).so libpng.a pngtest
 
 libpng.a: $(OBJS)
 	ar rc $@  $(OBJS)
 	$(RANLIB) $@
 
-libpng.so: libpng.so.$(PNGMAJ)
-	ln -f -s libpng.so.$(PNGMAJ) libpng.so
+$(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ)
+	ln -f -s $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so
 
-libpng.so.$(PNGMAJ): libpng.so.$(PNGVER)
-	ln -f -s libpng.so.$(PNGVER) libpng.so.$(PNGMAJ)
+$(LIBNAME).so.$(PNGMAJ): $(LIBNAME).so.$(PNGVER)
+	ln -f -s $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ)
 
-libpng.so.$(PNGVER): $(OBJS)
+$(LIBNAME).so.$(PNGVER): $(OBJS)
 	$(CC) -shared -o $@ $(OBJS) -L$(ZLIBLIB) -lz -lm
 
 pngtest: pngtest.o libpng.a
@@ -52,23 +53,28 @@
 test: pngtest
 	./pngtest
 
-install: libpng.a libpng.so.$(PNGVER)
+install: libpng.a $(LIBNAME).so.$(PNGVER)
 	-@mkdir $(INCPATH)
 	-@mkdir $(LIBPATH)
+	-@mkdir $(INCPATH)/$(LIBNAME)
 	cp png.h $(INCPATH)
 	cp pngconf.h $(INCPATH)
 	chmod 644 $(INCPATH)/png.h
 	chmod 644 $(INCPATH)/pngconf.h
+	cp png.h $(INCPATH)/$(LIBNAME)
+	cp pngconf.h $(INCPATH)/$(LIBNAME)
+	chmod 644 $(INCPATH)/$(LIBNAME)/png.h
+	chmod 644 $(INCPATH)/$(LIBNAME)/pngconf.h
 	cp libpng.a $(LIBPATH)
-	cp libpng.so.$(PNGVER) $(LIBPATH)
+	cp $(LIBNAME).so.$(PNGVER) $(LIBPATH)
 	chmod 644 $(LIBPATH)/libpng.a
-	chmod 644 $(LIBPATH)/libpng.so.$(PNGVER)
-	-@/bin/rm -f $(LIBPATH)/libpng.so.$(PNGMAJ) $(LIBPATH)/libpng.so
-	(cd $(LIBPATH); ln -f -s libpng.so.$(PNGVER) libpng.so.$(PNGMAJ); \
-	 ln -f -s libpng.so.$(PNGMAJ) libpng.so)
+	chmod 644 $(LIBPATH)/$(LIBNAME).so.$(PNGVER)
+	-@/bin/rm -f $(LIBPATH)/$(LIBNAME).so.$(PNGMAJ) $(LIBPATH)/$(LIBNAME).so
+	(cd $(LIBPATH); ln -f -s $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \
+	 ln -f -s $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so)
 
 clean:
-	/bin/rm -f *.o libpng.a libpng.so libpng.so.$(PNGMAJ)* pngtest pngout.png
+	/bin/rm -f *.o libpng.a $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* pngtest pngout.png
 
 # DO NOT DELETE THIS LINE -- make depend depends on it.
 
diff --git a/scripts/makefile.gcmmx b/scripts/makefile.gcmmx
index 071effc..abd7aa5 100644
--- a/scripts/makefile.gcmmx
+++ b/scripts/makefile.gcmmx
@@ -1,6 +1,8 @@
-# makefile for libpng on Linux ELF with gcc using MMX assembler code
-# Copyright 1996-1997 Andreas Dilger
+# makefile for libpng.a and libpng12.so on Linux ELF with gcc using MMX
+# assembler code
+# Copyright 2002 Greg Roelofs and Glenn Randers-Pehrson
 # Copyright 1998-2001 Greg Roelofs
+# Copyright 1996-1997 Andreas Dilger
 # For conditions of distribution and use, see copyright notice in png.h
 
 # CAUTION: Do not use this makefile with gcc versions 2.7.2.2 and earlier.
@@ -11,9 +13,15 @@
 #        there are no floating-point programs (e.g., SETI@Home) running in
 #        the background!  Context switches between MMX and FPU are expensive.
 
+LIBNAME = libpng12
+PNGMAJ = 0
+PNGMIN = 1.2.2beta1
+PNGVER = $(PNGMAJ).$(PNGMIN)
+
 CC=gcc
 
-# where "make install" puts libpng.a, libpng.so*, png.h, and pngconf.h
+# where "make install" puts libpng.a, libpng12/libpng12.so*,
+# $(LIBNAME)/png.h and $(LIBNAME)/pngconf.h
 prefix=/usr/local
 
 # Where the zlib library and include files are located
@@ -46,18 +54,12 @@
 #	-m486 -malign-double -ffast-math \
 #	$(ALIGN) -funroll-loops -funroll-all-loops -fomit-frame-pointer 
 
-LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng -lz -lm
+LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng12 -lz -lm
 LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm
 
 RANLIB=ranlib
 #RANLIB=echo
 
-# read libpng.txt or png.h to see why PNGMAJ is 3.  You should not
-# have to change it.
-PNGMAJ = 3
-PNGMIN = 1.2.1
-PNGVER = $(PNGMAJ).$(PNGMIN)
-
 INCPATH=$(prefix)/include
 LIBPATH=$(prefix)/lib
 
@@ -72,7 +74,7 @@
 .c.pic.o:
 	$(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
 
-all: libpng.a libpng.so pngtest pngtest-static
+all: libpng.a $(LIBNAME).so pngtest pngtest-static
 
 pnggccrd.o:	pnggccrd.c png.h pngconf.h
 	$(CC) -c $(CFLAGS) -o $@ $*.c
@@ -80,49 +82,54 @@
 pnggccrd.pic.o:	pnggccrd.c png.h pngconf.h
 	$(CC) -c $(CFLAGS) -fPIC -o $@ pnggccrd.c
 
-libpng.a: $(OBJS)
+$(LIBNAME).a: $(OBJS)
 	ar rc $@ $(OBJS)
 	$(RANLIB) $@
 
-libpng.so: libpng.so.$(PNGMAJ)
-	ln -sf libpng.so.$(PNGMAJ) libpng.so
+$(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ)
+	ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so
 
-libpng.so.$(PNGMAJ): libpng.so.$(PNGVER)
-	ln -sf libpng.so.$(PNGVER) libpng.so.$(PNGMAJ)
+$(LIBNAME).so.$(PNGMAJ): $(LIBNAME).so.$(PNGVER)
+	ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ)
 
-libpng.so.$(PNGVER): $(OBJSDLL)
-	$(CC) -shared -Wl,-soname,libpng.so.$(PNGMAJ) -o libpng.so.$(PNGVER) \
+$(LIBNAME).so.$(PNGVER): $(OBJSDLL)
+	$(CC) -shared -Wl,-soname,$(LIBNAME).so.$(PNGMAJ) -o $(LIBNAME).so.$(PNGVER) \
 	 $(OBJSDLL) -L$(ZLIBLIB) -lz -lm -lc
 
-pngtest: pngtest.o libpng.so
+pngtest: pngtest.o $(LIBNAME).so
 	$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
 
-pngtest-static: pngtest.o libpng.a
+pngtest-static: pngtest.o $(LIBNAME).a
 	$(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A)
 
 test: pngtest pngtest-static
 	@echo ""
-	@echo "   Testing dynamically linked version:"
+	@echo "   Running pngtest dynamically linked with libpng12.so:"
 	@echo ""
 	./pngtest
 	@echo ""
-	@echo "   Testing statically linked version:"
+	@echo "   Running pngtest statically linked with libpng.a:"
 	@echo ""
 	./pngtest-static
 
-install: libpng.a libpng.so.$(PNGVER)
+install: libpng.a $(LIBNAME).so.$(PNGVER)
 	-@if [ ! -d $(INCPATH)  ]; then mkdir $(INCPATH); fi
 	-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
+	-@if [ ! -d $(INCPATH)/$(LIBNAME)  ]; then mkdir $(INCPATH)/$(LIBNAME); fi
 	cp png.h pngconf.h $(INCPATH)
+	cp png.h pngconf.h $(INCPATH)/$(LIBNAME)
 	chmod 644 $(INCPATH)/png.h $(INCPATH)/pngconf.h
-	cp libpng.a libpng.so.$(PNGVER) $(LIBPATH)
-	chmod 755 $(LIBPATH)/libpng.so.$(PNGVER)
-	-@/bin/rm -f $(LIBPATH)/libpng.so.$(PNGMAJ) $(LIBPATH)/libpng.so
-	(cd $(LIBPATH); ln -sf libpng.so.$(PNGVER) libpng.so.$(PNGMAJ); \
-	 ln -sf libpng.so.$(PNGMAJ) libpng.so)
+	chmod 644 $(INCPATH)/$(LIBNAME)/png.h $(INCPATH)/$(LIBNAME)/pngconf.h
+	cp libpng.a $(LIBNAME).so.$(PNGVER) $(LIBPATH)
+	chmod 755 $(LIBPATH)/$(LIBNAME).so.$(PNGVER)
+	-@/bin/rm -f $(LIBPATH)/$(LIBNAME).so.$(PNGMAJ) \
+	$(LIBPATH)/$(LIBNAME).so
+	(cd $(LIBPATH); ln -sf $(LIBNAME).so.$(PNGVER) \
+	$(LIBNAME).so.$(PNGMAJ); \
+	ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so)
 
 clean:
-	/bin/rm -f *.o libpng.a libpng.so libpng.so.$(PNGMAJ)* pngtest pngout.png
+	/bin/rm -f *.o libpng.a $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* pngtest pngout.png
 
 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
 writelock:
diff --git a/scripts/makefile.hpgcc b/scripts/makefile.hpgcc
index 926a7dd..0c620ae 100644
--- a/scripts/makefile.hpgcc
+++ b/scripts/makefile.hpgcc
@@ -1,4 +1,5 @@
 # makefile for libpng on HP-UX using GCC
+# Copyright (C) 2002, Glenn Randers-Pehrson
 # Copyright (C) 2001, Laurent faillie
 # Copyright (C) 1998, 1999 Greg Roelofs
 # Copyright (C) 1996, 1997 Andreas Dilger
@@ -31,11 +32,12 @@
 RANLIB=ranlib
 #RANLIB=echo
 
-# read libpng.txt or png.h to see why PNGMAJ is 3.  You should not
+# read libpng.txt or png.h to see why PNGMAJ is 0.  You should not
 # have to change it.
-PNGMAJ = 3
-PNGMIN = 1.2.1
+PNGMAJ = 0
+PNGMIN = 1.2.2beta1
 PNGVER = $(PNGMAJ).$(PNGMIN)
+SHAREDLIB = libpng12
 
 INCPATH=$(prefix)/include
 LIBPATH=$(prefix)/lib
@@ -51,41 +53,47 @@
 .c.pic.o:
 	$(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
 
-all: libpng.a libpng.sl pngtest
+all: libpng.a $(SHAREDLIB).sl pngtest
 
 libpng.a: $(OBJS)
 	ar rc $@ $(OBJS)
 	$(RANLIB) $@
 
-libpng.sl: libpng.sl.$(PNGMAJ)
-	ln -f -s libpng.sl.$(PNGMAJ) libpng.sl
+$(SHAREDLIB).sl: $(SHAREDLIB).sl.$(PNGMAJ)
+	ln -f -s $(SHAREDLIB).sl.$(PNGMAJ) $(SHAREDLIB).sl
 
-libpng.sl.$(PNGMAJ): libpng.sl.$(PNGVER)
-	ln -f -s libpng.sl.$(PNGVER) libpng.sl.$(PNGMAJ)
+$(SHAREDLIB).sl.$(PNGMAJ): $(SHAREDLIB).sl.$(PNGVER)
+	ln -f -s $(SHAREDLIB).sl.$(PNGVER) $(SHAREDLIB).sl.$(PNGMAJ)
 
-libpng.sl.$(PNGVER): $(OBJSDLL)
+$(SHAREDLIB).sl.$(PNGVER): $(OBJSDLL)
 	$(LD) -b -L$(ZLIBLIB) +s +b $(ZLIBLIB) \
 	+h libpng.sl.$(PNGMAJ) -o libpng.sl.$(PNGVER) $(OBJSDLL) -lz
 
-pngtest: pngtest.o libpng.sl
+pngtest: pngtest.o $(SHAREDLIB).sl
 	$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
 
 test: pngtest
 	./pngtest
 
-install: libpng.a libpng.sl.$(PNGVER)
+install: libpng.a $(SHAREDLIB).sl.$(PNGVER)
 	-@if [ ! -d $(INCPATH)  ]; then mkdir $(INCPATH); fi
 	-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
+	-@if [ ! -d $(INCPATH)/$(LIBNAME)  ]; then mkdir $(INCPATH)/$(LIBNAME); fi
 	cp png.h pngconf.h $(INCPATH)
+	cp png.h pngconf.h $(INCPATH)/$(LIBNAME)
 	chmod 644 $(INCPATH)/png.h $(INCPATH)/pngconf.h
-	cp libpng.a libpng.sl.$(PNGVER) $(LIBPATH)
-	chmod 755 $(LIBPATH)/libpng.sl.$(PNGVER)
-	-@/bin/rm -f $(LIBPATH)/libpng.sl.$(PNGMAJ) $(LIBPATH)/libpng.sl
-	(cd $(LIBPATH); ln -sf libpng.sl.$(PNGVER) libpng.sl.$(PNGMAJ); \
-	 ln -sf libpng.sl.$(PNGMAJ) libpng.sl)
+	chmod 644 $(INCPATH)/$(LIBNAME)/png.h $(INCPATH)/$(LIBNAME)/pngconf.h
+	cp libpng.a $(SHAREDLIB).sl.$(PNGVER) $(LIBPATH)
+	chmod 755 $(LIBPATH)/$(SHAREDLIB).sl.$(PNGVER)
+	-@/bin/rm -f $(LIBPATH)/$(SHAREDLIB).sl.$(PNGMAJ) \
+	$(LIBPATH)/$(SHAREDLIB).sl
+	(cd $(LIBPATH); ln -sf $(SHAREDLIB).sl.$(PNGVER) \
+	$(SHAREDLIB).sl.$(PNGMAJ); \
+	 ln -sf $(SHAREDLIB).sl.$(PNGMAJ) $(SHAREDLIB).sl)
 
 clean:
-	/bin/rm -f *.o libpng.a libpng.sl libpng.sl.$(PNGMAJ)* pngtest pngout.png
+	/bin/rm -f *.o libpng.a $(SHAREDLIB).sl $(SHAREDLIB).sl.$(PNGMAJ)* \
+	pngtest pngout.png
 
 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
 writelock:
diff --git a/scripts/makefile.hpux b/scripts/makefile.hpux
index e9c7c11..14b7315 100644
--- a/scripts/makefile.hpux
+++ b/scripts/makefile.hpux
@@ -1,5 +1,5 @@
 # makefile for libpng, HPUX (10.20 and 11.00)
-# Copyright (C) 1999, 2000 Glenn Randers-Pehrson
+# Copyright (C) 1999-2002 Glenn Randers-Pehrson
 # Copyright (C) 1995 Guy Eric Schalnat, Group 42
 # contributed by Jim Rice and updated by Chris Schleicher, Hewlett Packard
 # For conditions of distribution and use, see copyright notice in png.h
@@ -16,13 +16,14 @@
 
 RANLIB=ranlib
 
-# read libpng.txt or png.h to see why PNGMAJ is 3.  You should not
+# read libpng.txt or png.h to see why PNGMAJ is 0.  You should not
 # have to change it.
-PNGMAJ = 3
-PNGMIN = 1.2.1
+PNGMAJ = 0
+PNGMIN = 1.2.2beta1
 PNGVER = $(PNGMAJ).$(PNGMIN)
+LIBNAME = libpng12
 
-# where make install puts libpng.a and png.h
+# where make install puts libpng.a, libpng12.sl, and png.h
 prefix=/opt/libpng
 
 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
@@ -36,21 +37,22 @@
 .c.pic.o:
 	$(CC) -c $(CFLAGS) +z -o $@ $*.c
 
-all: libpng.a libpng.sl pngtest
+all: libpng.a $(LIBNAME).sl pngtest
 
 libpng.a: $(OBJS)
 	ar rc $@  $(OBJS)
 	$(RANLIB) $@
 
-libpng.sl: libpng.sl.$(PNGMAJ)
-	ln -f -s libpng.sl.$(PNGMAJ) libpng.sl
+$(LIBNAME).sl: $(LIBNAME).sl.$(PNGMAJ)
+	ln -f -s $(LIBNAME).sl.$(PNGMAJ) $(LIBNAME).sl
 
-libpng.sl.$(PNGMAJ): libpng.sl.$(PNGVER)
-	ln -f -s libpng.sl.$(PNGVER) libpng.sl.$(PNGMAJ)
+$(LIBNAME).sl.$(PNGMAJ): $(LIBNAME).sl.$(PNGVER)
+	ln -f -s $(LIBNAME).sl.$(PNGVER) $(LIBNAME).sl.$(PNGMAJ)
 
-libpng.sl.$(PNGVER): $(OBJSDLL)
+$(LIBNAME).sl.$(PNGVER): $(OBJSDLL)
 	$(LD) -b -L$(ZLIBLIB) +s +b $(ZLIBLIB) \
-	+h libpng.sl.$(PNGMAJ) -o libpng.sl.$(PNGVER) $(OBJSDLL) -lz
+	+h $(LIBNAME).sl.$(PNGMAJ) -o $(LIBNAME).sl.$(PNGVER) \
+	$(OBJSDLL) -lz
 
 pngtest: pngtest.o libpng.a
 	$(CC) -o pngtest $(CCFLAGS) pngtest.o $(LDFLAGS)
@@ -60,19 +62,26 @@
 
 install: libpng.a
 	-@mkdir $(prefix)/include
+	-@mkdir $(prefix)/include/$(LIBNAME)
 	-@mkdir $(prefix)/lib
 	cp png.h $(prefix)/include
 	cp pngconf.h $(prefix)/include
+	cp png.h $(prefix)/include/$(LIBNAME)
+	cp pngconf.h $(prefix)/include/$(LIBNAME)
 	chmod 644 $(prefix)/include/png.h
 	chmod 644 $(prefix)/include/pngconf.h
-	cp libpng.a libpng.sl.$(PNGVER) $(prefix)/lib
+	chmod 644 $(prefix)/include/$(LIBNAME)/png.h
+	chmod 644 $(prefix)/include/$(LIBNAME)/pngconf.h
+	cp libpng.a $(LIBNAME).sl.$(PNGVER) $(prefix)/lib
 	chmod 644 $(prefix)/lib/libpng.a
-	chmod 755 $(prefix)/lib/libpng.sl.$(PNGVER)
-	(cd $(prefix)/lib; ln -f -s libpng.sl.$(PNGVER) libpng.sl.$(PNGMAJ); \
-	ln -f -s libpng.sl.$(PNGMAJ) libpng.sl)
+	chmod 755 $(prefix)/lib/$(LIBNAME).sl.$(PNGVER)
+	(cd $(prefix)/lib; \
+	ln -f -s $(LIBNAME).sl.$(PNGVER) $(LIBNAME).sl.$(PNGMAJ); \
+	ln -f -s $(LIBNAME).sl.$(PNGMAJ) $(LIBNAME).sl)
 
 clean:
-	/bin/rm -f *.o libpng.a libpng.sl libpng.sl.$(PNGMAJ)* pngtest pngout.png
+	/bin/rm -f *.o libpng.a $(LIBNAME).sl $(LIBNAME).sl.$(PNGMAJ)* \
+	pngtest pngout.png
 
 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
 writelock:
diff --git a/scripts/makefile.linux b/scripts/makefile.linux
index 7f60728..e747109 100644
--- a/scripts/makefile.linux
+++ b/scripts/makefile.linux
@@ -1,11 +1,17 @@
-# makefile for libpng on Linux ELF with gcc
-# Copyright (C) 1998, 1999 Greg Roelofs
+# makefile for libpng.a and libpng12.so on Linux ELF with gcc
+# Copyright (C) 1998, 1999, 2002 Greg Roelofs and Glenn Randers-Pehrson
 # Copyright (C) 1996, 1997 Andreas Dilger
 # For conditions of distribution and use, see copyright notice in png.h
 
+LIBNAME = libpng12
+PNGMAJ = 0
+PNGMIN = 1.2.2beta1
+PNGVER = $(PNGMAJ).$(PNGMIN)
+
 CC=gcc
 
-# where "make install" puts libpng.a, libpng.so*, png.h and pngconf.h
+# where "make install" puts libpng.a, libpng12/libpng12.so*,
+# libpng12/png.h and libpng12/pngconf.h
 prefix=/usr/local
 
 # Where the zlib library and include files are located
@@ -26,17 +32,13 @@
 
 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. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng12 -lz -lm
+LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm
 
 RANLIB=ranlib
 #RANLIB=echo
 
-# read libpng.txt or png.h to see why PNGMAJ is 3.  You should not
-# have to change it.
-PNGMAJ = 3
-PNGMIN = 1.2.1
-PNGVER = $(PNGMAJ).$(PNGMIN)
-
 INCPATH=$(prefix)/include
 LIBPATH=$(prefix)/lib
 
@@ -51,41 +53,58 @@
 .c.pic.o:
 	$(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
 
-all: libpng.a libpng.so pngtest
+all: libpng.a $(LIBNAME).so pngtest
 
 libpng.a: $(OBJS)
 	ar rc $@ $(OBJS)
 	$(RANLIB) $@
 
-libpng.so: libpng.so.$(PNGMAJ)
-	ln -sf libpng.so.$(PNGMAJ) libpng.so
+$(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ)
+	ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so
 
-libpng.so.$(PNGMAJ): libpng.so.$(PNGVER)
-	ln -sf libpng.so.$(PNGVER) libpng.so.$(PNGMAJ)
+$(LIBNAME).so.$(PNGMAJ): $(LIBNAME).so.$(PNGVER)
+	ln -sf $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ)
 
-libpng.so.$(PNGVER): $(OBJSDLL)
-	$(CC) -shared -Wl,-soname,libpng.so.$(PNGMAJ) -o libpng.so.$(PNGVER) \
-	 $(OBJSDLL) -L$(ZLIBLIB) -lz -lm -lc
+$(LIBNAME).so.$(PNGVER): $(OBJSDLL)
+	$(CC) -shared -Wl,-soname,$(LIBNAME).so.$(PNGMAJ) \
+	-o $(LIBNAME).so.$(PNGVER) \
+	$(OBJSDLL) -L$(ZLIBLIB) -lz -lm -lc
 
-pngtest: pngtest.o libpng.so
+pngtest: pngtest.o $(LIBNAME).so
 	$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
 
-test: pngtest
-	./pngtest
+pngtest-static: pngtest.o $(LIBNAME).a
+	$(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A)
 
-install: libpng.a libpng.so.$(PNGVER)
+test: pngtest pngtest-static
+	@echo ""
+	@echo "   Running pngtest dynamically linked with libpng12.so:"
+	@echo ""
+	./pngtest
+	@echo ""
+	@echo "   Running pngtest statically linked with libpng.a:"
+	@echo ""
+	./pngtest-static
+
+install: libpng.a $(LIBNAME).so.$(PNGVER)
 	-@if [ ! -d $(INCPATH)  ]; then mkdir $(INCPATH); fi
 	-@if [ ! -d $(LIBPATH) ]; then mkdir $(LIBPATH); fi
+	-@if [ ! -d $(INCPATH)/$(LIBNAME)  ]; then mkdir $(INCPATH)/$(LIBNAME); fi
 	cp png.h pngconf.h $(INCPATH)
+	cp png.h pngconf.h $(INCPATH)/$(LIBNAME)
 	chmod 644 $(INCPATH)/png.h $(INCPATH)/pngconf.h
-	cp libpng.a libpng.so.$(PNGVER) $(LIBPATH)
-	chmod 755 $(LIBPATH)/libpng.so.$(PNGVER)
-	-@/bin/rm -f $(LIBPATH)/libpng.so.$(PNGMAJ) $(LIBPATH)/libpng.so
-	(cd $(LIBPATH); ln -sf libpng.so.$(PNGVER) libpng.so.$(PNGMAJ); \
-	 ln -sf libpng.so.$(PNGMAJ) libpng.so)
+	chmod 644 $(INCPATH)/$(LIBNAME)/png.h $(INCPATH)/$(LIBNAME)/pngconf.h
+	cp libpng.a $(LIBNAME).so.$(PNGVER) $(LIBPATH)
+	chmod 755 $(LIBPATH)/$(LIBNAME).so.$(PNGVER)
+	-@/bin/rm -f $(LIBPATH)/$(LIBNAME).so.$(PNGMAJ) \
+	$(LIBPATH)/$(LIBNAME).so
+	(cd $(LIBPATH); ln -sf $(LIBNAME).so.$(PNGVER) \
+	$(LIBNAME).so.$(PNGMAJ); \
+	ln -sf $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so)
 
 clean:
-	/bin/rm -f *.o libpng.a libpng.so libpng.so.$(PNGMAJ)* pngtest pngout.png
+	/bin/rm -f *.o libpng.a $(LIBNAME).so $(LIBNAME).so.$(PNMAJ)* \
+	pngtest pngout.png
 
 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
 writelock:
diff --git a/scripts/makefile.macosx b/scripts/makefile.macosx
index 6384c20..bf8f76a 100644
--- a/scripts/makefile.macosx
+++ b/scripts/makefile.macosx
@@ -1,4 +1,5 @@
 # makefile for libpng, MACOS X
+# Copyright (C) 2002 Glenn Randers-Pehrson
 # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
 # Modified by Karin Kosina <kyrah@sim.no> 20011010:
 # build shared library (*.dylib)
@@ -18,10 +19,10 @@
 LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz
 LDSHARED=cc -lz -dynamiclib -compatibility_version $(VER) -current_version $(VER)
 
-PNGMAJ = 3
-PNGMIN = 1.2.1
+PNGMAJ = 0
+PNGMIN = 1.2.2beta1
 VER = $(PNGMAJ).$(PNGMIN)
-SHAREDLIB=libpng
+SHAREDLIB=libpng12
 SHAREDLIB_POSTFIX=dylib
 libdir=$(prefix)/lib
 
@@ -52,20 +53,28 @@
 install: libpng.a
 	-@mkdir $(prefix)/include
 	-@mkdir $(prefix)/lib
+	-@mkdir $(prefix)/include/$(SHAREDLIB)
 	cp png.h $(prefix)/include
 	cp pngconf.h $(prefix)/include
+	cp png.h $(prefix)/include/$(SHAREDLIB)
+	cp pngconf.h $(prefix)/include/$(SHAREDLIB)
 	chmod 644 $(prefix)/include/png.h
 	chmod 644 $(prefix)/include/pngconf.h
+	chmod 644 $(prefix)/include/$(SHAREDLIB)/png.h
+	chmod 644 $(prefix)/include/$(SHAREDLIB)/pngconf.h
 	cp libpng.a $(prefix)/lib
 	chmod 644 $(prefix)/lib/libpng.a
 
 install-shared: $(SHAREDLIB).$(VER).$(SHAREDLIB_POSTFIX)
 	cp $(SHAREDLIB).$(VER).$(SHAREDLIB_POSTFIX) $(libdir)
 	(cd $(libdir); \
-	ln -s $(SHAREDLIB).$(VER).$(SHAREDLIB_POSTFIX) $(SHAREDLIB).$(SHAREDLIB_POSTFIX)) 
+	ln -s $(SHAREDLIB).$(VER).$(SHAREDLIB_POSTFIX) \
+	$(SHAREDLIB).$(SHAREDLIB_POSTFIX)) 
 
 clean:
-	rm -f *.o libpng.a pngtest pngout.png $(SHAREDLIB).$(VER).$(SHAREDLIB_POSTFIX) $(SHAREDLIB).$(SHAREDLIB_POSTFIX)
+	rm -f *.o libpng.a pngtest pngout.png \
+	$(SHAREDLIB).$(VER).$(SHAREDLIB_POSTFIX) \
+	$(SHAREDLIB).$(SHAREDLIB_POSTFIX)
 
 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
 writelock:
diff --git a/scripts/makefile.netbsd b/scripts/makefile.netbsd
index cf65f54..615c80f 100644
--- a/scripts/makefile.netbsd
+++ b/scripts/makefile.netbsd
@@ -8,10 +8,12 @@
 LIBDIR=	${LOCALBASE}/lib
 MANDIR= ${LOCALBASE}/man
 INCSDIR=${LOCALBASE}/include
+# Should also copy png.h and pngconf.h to $(INCSDIR)/libpng12.
 
 LIB=png
-SHLIB_MAJOR= 3
-SHLIB_MINOR= 1.2.1
+# Shared lib name should be png12.
+SHLIB_MAJOR= 0
+SHLIB_MINOR= 1.2.2beta1
 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.sco b/scripts/makefile.sco
index 6a650d1..5eb1b37 100644
--- a/scripts/makefile.sco
+++ b/scripts/makefile.sco
@@ -22,11 +22,12 @@
 #RANLIB=ranlib
 RANLIB=echo
 
-# read libpng.txt or png.h to see why PNGMAJ is 3.  You should not
+# read libpng.txt or png.h to see why PNGMAJ is 0.  You should not
 # have to change it.
-PNGMAJ = 3
-PNGMIN = 1.2.1
+PNGMAJ = 0
+PNGMIN = 1.2.2beta1
 PNGVER = $(PNGMAJ).$(PNGMIN)
+LIBNAME = libpng12
 
 INCPATH=$(prefix)/include
 LIBPATH=$(prefix)/lib
@@ -42,40 +43,43 @@
 .c.pic.o:
 	$(CC) -c $(CFLAGS) -KPIC -o $@ $*.c
 
-all: libpng.a libpng.so pngtest
+all: libpng.a $(LIBNAME).so pngtest
 
 libpng.a: $(OBJS)
 	ar rc $@ $(OBJS)
 	$(RANLIB) $@
 
-libpng.so: libpng.so.$(PNGMAJ)
-	ln -f -s libpng.so.$(PNGMAJ) libpng.so
+$(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ)
+	ln -f -s $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so
 
-libpng.so.$(PNGMAJ): libpng.so.$(PNGVER)
-	ln -f -s libpng.so.$(PNGVER) libpng.so.$(PNGMAJ)
+$(LIBNAME).so.$(PNGMAJ): $(LIBNAME).so.$(PNGVER)
+	ln -f -s $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ)
 
-libpng.so.$(PNGVER): $(OBJSDLL)
-	$(CC) -G  -Wl,-h,libpng.so.$(PNGMAJ) -o libpng.so.$(PNGVER) \
+$(LIBNAME).so.$(PNGVER): $(OBJSDLL)
+	$(CC) -G  -Wl,-h,$(LIBNAME).so.$(PNGMAJ) -o $(LIBNAME).so.$(PNGVER) \
 	 $(OBJSDLL)
 
-pngtest: pngtest.o libpng.so
+pngtest: pngtest.o $(LIBNAME).so
 	LD_RUN_PATH=.:$(ZLIBLIB) $(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
 
 test: pngtest
 	./pngtest
 
-install: libpng.a libpng.so.$(PNGVER)
-	-@mkdir $(INCPATH) $(LIBPATH)
+install: libpng.a $(LIBNAME).so.$(PNGVER)
+	-@mkdir $(INCPATH) $(LIBPATH) $(INCPATH)/$(LIBNAME)
 	cp png.h pngconf.h $(INCPATH)
+	cp png.h pngconf.h $(INCPATH)/$(LIBNAME)
 	chmod 644 $(INCPATH)/png.h $(INCPATH)/pngconf.h
-	cp libpng.a libpng.so.$(PNGVER) $(LIBPATH)
-	chmod 755 $(LIBPATH)/libpng.so.$(PNGVER)
-	-@/bin/rm -f $(LIBPATH)/libpng.so.$(PNGMAJ) $(LIBPATH)/libpng.so
-	(cd $(LIBPATH); ln -f -s libpng.so.$(PNGVER) libpng.so.$(PNGMAJ); \
-	 ln -f -s libpng.so.$(PNGMAJ) libpng.so)
+	chmod 644 $(INCPATH)/$(LIBNAME)/png.h $(INCPATH)/$(LIBNAME)/pngconf.h
+	cp libpng.a $(LIBNAME).so.$(PNGVER) $(LIBPATH)
+	chmod 755 $(LIBPATH)/$(LIBNAME).so.$(PNGVER)
+	-@/bin/rm -f $(LIBPATH)/$(LIBNAME).so.$(PNGMAJ) $(LIBPATH)/$(LIBNAME).so
+	(cd $(LIBPATH); \
+	ln -f -s $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \
+	ln -f -s $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so)
 
 clean:
-	/bin/rm -f *.o libpng.a libpng.so libpng.so.$(PNGMAJ)* pngtest pngout.png
+	/bin/rm -f *.o libpng.a $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* pngtest pngout.png
 
 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
 writelock:
diff --git a/scripts/makefile.sggcc b/scripts/makefile.sggcc
index 0a096cc..ffd46a5 100644
--- a/scripts/makefile.sggcc
+++ b/scripts/makefile.sggcc
@@ -1,4 +1,5 @@
 # makefile for libpng, SGI IRIX with gcc
+# 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
 
@@ -22,11 +23,11 @@
 LDFLAGS=$(ABI) -L. -L$(ZLIBLIB) -lpng -lz -lm
 LDSHARED=CC $(ABI) -shared
 
-VER=1.2.1
+VER=1.2.2beta1
 # See "man dso" for info about shared objects
-SONUM=3
-LIBS=libpng.so.$(SONUM).$(VER)
-SHAREDLIB=libpng.so
+SONUM=0
+LIBS=libpng12.so.$(SONUM).$(VER)
+SHAREDLIB=libpng12.so
 libdir=$(prefix)/lib32
 
 RANLIB=echo
@@ -57,14 +58,17 @@
 install: libpng.a
 	-@mkdir $(prefix)/include
 	-@mkdir $(prefix)/lib
-	cp png.h $(prefix)/include
-	cp pngconf.h $(prefix)/include
+	cp png.h pngconf.h $(prefix)/include
 	chmod 644 $(prefix)/include/png.h
 	chmod 644 $(prefix)/include/pngconf.h
 	cp libpng.a $(prefix)/lib
 	chmod 644 $(prefix)/lib/libpng.a
 
 install-shared: $(SHAREDLIB).$(VER)
+	-@mkdir $(prefix)/include/libpng12
+	cp png.h pngconf.h $(prefix)/include/libpng12
+	chmod 644 $(prefix)/include/libpng12/png.h
+	chmod 644 $(prefix)/include/libpng12/pngconf.h
 	cp $(SHAREDLIB).$(VER) $(libdir); chmod 755 $(SHAREDLIB).$(VER)
 	(cd $(libdir); if test -f $(SHAREDLIB).$(VER); then \
 	rm -f $(SHAREDLIB) $(SHAREDLIB).$(SONUM); \
diff --git a/scripts/makefile.sgi b/scripts/makefile.sgi
index 73380e6..d96a7f2 100644
--- a/scripts/makefile.sgi
+++ b/scripts/makefile.sgi
@@ -1,9 +1,9 @@
-# makefile for libpng (.a and .so), SGI IRIX with 'cc'
-# Copyright (C) 2001 Glenn Randers-Pehrson
+# makefile for libpng.a and libpng12.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, libpng12.so and libpng12/png.h
 prefix=/usr/local
 
 # Where the zlib library and include files are located
@@ -24,13 +24,14 @@
 # Note: -KPIC is the default anyhow
 #CFLAGS= $(ABI) -I$(ZLIBINC) -O $(WARNMORE) -KPIC -DPNG_USE_PNGGCCRD # -g -DPNG_DEBUG=5
 CFLAGS=$(ABI) -I$(ZLIBINC) -O $(WARNMORE) -DPNG_USE_PNGGCCRD -DPNG_NO_ASSEMBLER_CODE
+LDFLAGS_A=$(ABI) -L. -L$(ZLIBLIB) -lpng12 -lz -lm
 LDFLAGS=$(ABI) -L. -L$(ZLIBLIB) -lpng -lz -lm
 LDSHARED=cc $(ABI) -shared
 
-VER=1.2.1
+VER=1.2.2beta1
 # See "man dso" for info about shared objects
-SONUM=3
-SHAREDLIB=libpng.so
+SONUM=0
+SHAREDLIB=libpng12.so
 
 RANLIB=echo
 #RANLIB=ranlib
@@ -74,6 +75,13 @@
 	chmod 644 $(LIBPATH)/libpng.a
 
 install-shared: $(SHAREDLIB).$(SONUM).$(VER)
+	-@mkdir $(LIBPATH)
+	-@mkdir $(INCPATH)
+	-@mkdir $(INCPATH)/libpng12
+	cp png.h $(INCPATH)/libpng12
+	cp pngconf.h $(INCPATH)/libpng12
+	chmod 644 $(INCPATH)/libpng12/png.h
+	chmod 644 $(INCPATH)/libpng12/pngconf.h
 	cp $(SHAREDLIB).$(SONUM).$(VER) $(LIBPATH)
 	chmod 755 $(SHAREDLIB).$(SONUM).$(VER)
 	(cd $(LIBPATH); if test -f $(SHAREDLIB).$(SONUM).$(VER); then \
diff --git a/scripts/makefile.so9 b/scripts/makefile.so9
index 18be7c9..b4ae0b4 100644
--- a/scripts/makefile.so9
+++ b/scripts/makefile.so9
@@ -32,11 +32,12 @@
 #RANLIB=ranlib
 RANLIB=echo
 
-# read libpng.txt or png.h to see why PNGMAJ is 3.  You should not
+# read libpng.txt or png.h to see why PNGMAJ is 0.  You should not
 # have to change it.
-PNGMAJ = 3
-PNGMIN = 1.2.1
+PNGMAJ = 0
+PNGMIN = 1.2.2beta1
 PNGVER = $(PNGMAJ).$(PNGMIN)
+LIBNAME = libpng12
 
 INCPATH=$(prefix)/include
 LIBPATH=$(prefix)/lib
@@ -52,19 +53,19 @@
 .c.pic.o:
 	$(CC) -c $(CFLAGS) -KPIC -o $@ $*.c
 
-all: libpng.a libpng.so pngtest
+all: libpng.a $(LIBNAME).so pngtest
 
 libpng.a: $(OBJS)
 	ar rc $@ $(OBJS)
 	$(RANLIB) $@
 
-libpng.so: libpng.so.$(PNGMAJ)
-	ln -f -s libpng.so.$(PNGMAJ) libpng.so
+$(LIBNAME).so: $(LIBNAME).so.$(PNGMAJ)
+	ln -f -s $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so
 
-libpng.so.$(PNGMAJ): libpng.so.$(PNGVER)
-	ln -f -s libpng.so.$(PNGVER) libpng.so.$(PNGMAJ)
+$(LIBNAME).so.$(PNGMAJ): $(LIBNAME).so.$(PNGVER)
+	ln -f -s $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ)
 
-libpng.so.$(PNGVER): $(OBJSDLL)
+$(LIBNAME).so.$(PNGVER): $(OBJSDLL)
 	@case "`type ld`" in *ucb*) \
 	echo; \
 	echo '## WARNING:'; \
@@ -77,27 +78,32 @@
 	echo; \
 	;; \
 	esac
-	$(LD) -G -L$(ZLIBLIB) -R$(ZLIBLIB) -h libpng.so.$(PNGMAJ) \
-	 -o libpng.so.$(PNGVER) $(OBJSDLL) -lz
+	$(LD) -G -L$(ZLIBLIB) -R$(ZLIBLIB) -h $(LIBNAME).so.$(PNGMAJ) \
+	 -o $(LIBNAME).so.$(PNGVER) $(OBJSDLL) -lz
 
-pngtest: pngtest.o libpng.so
+pngtest: pngtest.o $(LIBNAME).so
 	$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
 
 test: pngtest
 	./pngtest
 
-install: libpng.a libpng.so.$(PNGVER)
+install: libpng.a $(LIBNAME).so.$(PNGVER)
 	-@mkdir $(INCPATH) $(LIBPATH)
+	-@mkdir $(INCPATH)/$(LIBNAME)
 	cp png.h pngconf.h $(INCPATH)
+	cp png.h pngconf.h $(INCPATH)/$(LIBNAME)
 	chmod 644 $(INCPATH)/png.h $(INCPATH)/pngconf.h
-	cp libpng.a libpng.so.$(PNGVER) $(LIBPATH)
-	chmod 755 $(LIBPATH)/libpng.so.$(PNGVER)
-	-@/bin/rm -f $(LIBPATH)/libpng.so.$(PNGMAJ) $(LIBPATH)/libpng.so
-	(cd $(LIBPATH); ln -f -s libpng.so.$(PNGVER) libpng.so.$(PNGMAJ); \
-	 ln -f -s libpng.so.$(PNGMAJ) libpng.so)
+	chmod 644 $(INCPATH)/$(LIBNAME)/png.h $(INCPATH)/$(LIBNAME)/pngconf.h
+	cp libpng.a $(LIBNAME).so.$(PNGVER) $(LIBPATH)
+	chmod 755 $(LIBPATH)/$(LIBNAME).so.$(PNGVER)
+	-@/bin/rm -f $(LIBPATH)/$(LIBNAME).so.$(PNGMAJ) $(LIBPATH)/$(LIBNAME).so
+	(cd $(LIBPATH); \
+	ln -f -s $(LIBNAME).so.$(PNGVER) $(LIBNAME).so.$(PNGMAJ); \
+	ln -f -s $(LIBNAME).so.$(PNGMAJ) $(LIBNAME).so)
 
 clean:
-	/bin/rm -f *.o libpng.a libpng.so libpng.so.$(PNGMAJ)* pngtest pngout.png
+	/bin/rm -f *.o libpng.a $(LIBNAME).so $(LIBNAME).so.$(PNGMAJ)* \
+	pngtest pngout.png
 
 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
 writelock:
diff --git a/scripts/makefile.solaris b/scripts/makefile.solaris
index fbe5ec9..b69abb7 100644
--- a/scripts/makefile.solaris
+++ b/scripts/makefile.solaris
@@ -1,4 +1,5 @@
 # makefile for libpng on Solaris 2.x with gcc
+# Copyright (C) 2002 Glenn Randers-Pehrson
 # Contributed by William L. Sebok, based on makefile.linux
 # Copyright (C) 1998 Greg Roelofs
 # Copyright (C) 1996, 1997 Andreas Dilger
@@ -6,7 +7,7 @@
 
 CC=gcc
 
-# Where make install puts libpng.a, libpng.so*, and png.h
+# Where make install puts libpng.a, libpng12.so*, and png.h
 prefix=/usr/local
 
 # Where the zlib library and include files are located
@@ -28,10 +29,10 @@
 #RANLIB=ranlib
 RANLIB=echo
 
-# read libpng.txt or png.h to see why PNGMAJ is 3.  You should not
+# read libpng.txt or png.h to see why PNGMAJ is 0.  You should not
 # have to change it.
-PNGMAJ = 3
-PNGMIN = 1.2.1
+PNGMAJ = 0
+PNGMIN = 1.2.2beta1
 PNGVER = $(PNGMAJ).$(PNGMIN)
 
 INCPATH=$(prefix)/include
@@ -48,19 +49,19 @@
 .c.pic.o:
 	$(CC) -c $(CFLAGS) -fPIC -o $@ $*.c
 
-all: libpng.a libpng.so pngtest
+all: libpng.a libpng12.so pngtest
 
 libpng.a: $(OBJS)
 	ar rc $@ $(OBJS)
 	$(RANLIB) $@
 
-libpng.so: libpng.so.$(PNGMAJ)
-	ln -f -s libpng.so.$(PNGMAJ) libpng.so
+libpng12.so: libpng12.so.$(PNGMAJ)
+	ln -f -s libpng12.so.$(PNGMAJ) libpng12.so
 
-libpng.so.$(PNGMAJ): libpng.so.$(PNGVER)
-	ln -f -s libpng.so.$(PNGVER) libpng.so.$(PNGMAJ)
+libpng12.so.$(PNGMAJ): libpng12.so.$(PNGVER)
+	ln -f -s libpng12.so.$(PNGVER) libpng12.so.$(PNGMAJ)
 
-libpng.so.$(PNGVER): $(OBJSDLL)
+libpng12.so.$(PNGVER): $(OBJSDLL)
 	@case "`type ld`" in *ucb*) \
 	echo; \
 	echo '## WARNING:'; \
@@ -73,27 +74,34 @@
 	echo; \
 	;; \
 	esac
-	$(LD) -G -L$(ZLIBLIB) -R$(ZLIBLIB) -h libpng.so.$(PNGMAJ) \
-	 -o libpng.so.$(PNGVER) $(OBJSDLL) -lz
+	$(LD) -G -L$(ZLIBLIB) -R$(ZLIBLIB) -h libpng12.so.$(PNGMAJ) \
+	 -o libpng12.so.$(PNGVER) $(OBJSDLL) -lz
 
-pngtest: pngtest.o libpng.so
+pngtest: pngtest.o libpng12.so
 	$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
 
 test: pngtest
 	./pngtest
 
-install: libpng.a libpng.so.$(PNGVER)
+install: libpng.a libpng12.so.$(PNGVER)
 	-@mkdir $(INCPATH) $(LIBPATH)
-	cp png.h pngconf.h $(INCPATH)
+	-@mkdir $(INCPATH)/libpng12
+	cp png.h pngconf.h $(INCPATH)/libpng12
+	cp png.h pngconf.h $(INCPATH)/libpng12
 	chmod 644 $(INCPATH)/png.h $(INCPATH)/pngconf.h
-	cp libpng.a libpng.so.$(PNGVER) $(LIBPATH)
-	chmod 755 $(LIBPATH)/libpng.so.$(PNGVER)
-	-@/bin/rm -f $(LIBPATH)/libpng.so.$(PNGMAJ) $(LIBPATH)/libpng.so
-	(cd $(LIBPATH); ln -f -s libpng.so.$(PNGVER) libpng.so.$(PNGMAJ); \
-	 ln -f -s libpng.so.$(PNGMAJ) libpng.so)
+	chmod 644 $(INCPATH)/libpng12/png.h \
+	$(INCPATH)/libpng12/pngconf.h
+	cp libpng.a libpng12.so.$(PNGVER) $(LIBPATH)
+	chmod 755 $(LIBPATH)/libpng12.so.$(PNGVER)
+	-@/bin/rm -f $(LIBPATH)/libpng12.so.$(PNGMAJ) \
+	$(LIBPATH)/libpng12.so
+	(cd $(LIBPATH); \
+	ln -f -s libpng12.so.$(PNGVER) libpng12.so.$(PNGMAJ); \
+	ln -f -s libpng12.so.$(PNGMAJ) libpng12.so)
 
 clean:
-	/bin/rm -f *.o libpng.a libpng.so libpng.so.$(PNGMAJ)* pngtest pngout.png
+	/bin/rm -f *.o libpng.a libpng12.so libpng12.so.$(PNGMAJ)* \
+	pngtest pngout.png
 
 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
 writelock:
diff --git a/scripts/pngdef.pas b/scripts/pngdef.pas
index 7b1b18f..cec3517 100644
--- a/scripts/pngdef.pas
+++ b/scripts/pngdef.pas
@@ -7,8 +7,8 @@
 interface
 
 const
-  PNG_LIBPNG_VER_STRING = '1.2.1';
-  PNG_LIBPNG_VER        =  10201;
+  PNG_LIBPNG_VER_STRING = '1.2.2beta1';
+  PNG_LIBPNG_VER        =  10202;
 
 type
   png_uint_32 = Cardinal;
diff --git a/scripts/pngos2.def b/scripts/pngos2.def
index 91a1ca4..c50b1b3 100644
--- a/scripts/pngos2.def
+++ b/scripts/pngos2.def
@@ -2,7 +2,7 @@
 ; PNG.LIB module definition file for OS/2
 ;----------------------------------------
 
-; Version 1.2.1
+; Version 1.2.2beta1
 
 LIBRARY		PNG
 DESCRIPTION	"PNG image compression library for OS/2"