[libpng15] Imported from libpng-1.5.16beta06.tar
diff --git a/ANNOUNCE b/ANNOUNCE
index ed58821..875c382 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,5 +1,5 @@
 
-Libpng 1.5.15beta06 - February 22, 2013
+Libpng 1.5.16beta06 - May 12, 2013
 
 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.
@@ -9,58 +9,59 @@
 Source files with LF line endings (for Unix/Linux) and with a
 "configure" script
 
-   1.5.15beta06.tar.xz (LZMA-compressed, recommended)
-   1.5.15beta06.tar.gz
-   1.5.15beta06.tar.bz2
+   1.5.16beta06.tar.xz (LZMA-compressed, recommended)
+   1.5.16beta06.tar.gz
+   1.5.16beta06.tar.bz2
 
 Source files with CRLF line endings (for Windows), without the
 "configure" script
 
-   lp1515b06.7z  (LZMA-compressed, recommended)
-   lp1515b06.zip
+   lp1516b06.7z  (LZMA-compressed, recommended)
+   lp1516b06.zip
 
 Other information:
 
-   1.5.15beta06-README.txt
-   1.5.15beta06-LICENSE.txt
+   1.5.16beta06-README.txt
+   1.5.16beta06-LICENSE.txt
 
-Changes since the last public release (1.5.14):
+Changes since the last public release (1.5.15):
 
-Version 1.5.15beta01 [February 4, 2013]
-  Enabled renaming of the extern (but not DLL exported) ARM filter functions.
-    Also enabled inclusion of pngpriv.h in non-C files by preventing C/C++
-    specific definitions if PNG_VERSION_INFO_ONLY is defined.
-  Added png_get_palette_max() function.
+Version 1.5.16beta01 [April 25, 2013]
+  Corrected a misplaced closing bracket in contrib/libtests/pngvalid.c
+    (Flavio Medeiros).
+  Revised stack marking in arm/filter_neon.S and configure.ac
+  Ensure that NEON filter stuff is completely disabled when switched 'off'.
+    Previously the ARM NEON specific files were still built if the option
+    was switched 'off' as opposed to being explicitly disabled.
+  Avoid a compiler warning about unused png_ptr in translate_gamma_flags()
 
-Version 1.5.15beta02 [February 5, 2013]
-  Made a probably general fix for the preprocessing used to generate source
-    files. This change might make the check for a special C preprocessor
-    unnecessary, and it also eliminates the requirement for sed in the
-    configure build process.
-  Fix typo in Makefile.am, fix scripts/pnglibconf.mak and makefile.std
-  Rebuilt Makefile.in, configure, etc., with autoconf-2.69 and automake-1.13
-  Fix 'setting' handling in options.awk and fixed palette_max API
+Version 1.5.16beta02 [April 26, 2013]
+  Revise pngtest.c to skip tests of unsupported features.
+  Regenerated configure files.
 
-Version 1.5.15beta03 [February 7, 2013]
-  Remove SUN OS cc -E workround - no longer required
-  Turn serial tests back on (recently turned off by autotools upgrade).
+Version 1.5.16beta03 [April 26, 2013]
+  Test for 'arm*' not just 'arm' in the host_cpu configure variable.
 
-Version 1.5.15beta04 [February 15, 2013]
-  Enclosed the new png_get_palette_max in #ifdef PNG_GET_PALETTE_MAX_SUPPORTED
-    block, and revised pnglibconf.h and pnglibconf.h.prebuilt accordingly.
+Version 1.5.16beta04 [May 1, 2013]
+  Expanded manual paragraph about writing private chunks, particularly
+    the need to call png_set_keep_unknown_chunks() when writing them.
 
-Version 1.5.15beta05 [February 17, 2013]
-  Use approved/supported Android method to check for NEON, use Linux/POSIX
-    1003.1 API to check /proc/self/auxv avoiding buffer allocation and other
-    library calls.
-  Fixed a race condition in the creation of the build 'scripts' directory
-    while building with a parallel make.
-  Use parentheses more consistently in "#if defined(MACRO)" tests.
+Version 1.5.16beta05 [May 9, 2013]
+  Updated contrib/pngminus/pnm2png.c (Paul Stewart):
+    Check for EOF
+    Ignore "#" delimited comments in input file to pnm2png.c.
+    Fixed whitespace handling
+    Added a call to png_set_packing()
+    Initialize dimension values so if sscanf fails at least we have known
+      invalid values.
 
-Version 1.5.15beta06 [February 22, 2013]
-  Fixed PNG_ALIGN(ED)_MEMORY and add ability to turn off ARM_NEON
-    runtime checks
-  Updated INSTALL.
+Version 1.5.16beta06 [May 12, 2013]
+  Allow contrib/pnminus/pnm2png.c to compile without WRITE_INVERT and WRITE_PACK
+    supported (writes error message that it can't read P1 or P4 PBM files).
+  Revised contrib/pngminim/*/makefile to separate CPPFLAGS and CPFLAGS, and
+    to generate pnglibconf.h with the right zlib header files.
+  Ported contrib/pngminus/pnm2png.c changes back from libpng-1.6.3beta06,
+    to use unsigned long, not png_uint_32 arguments to sscanf().
 
 Send comments/corrections/commendations to png-mng-implement at lists.sf.net
 (subscription required; visit
diff --git a/CHANGES b/CHANGES
index a866137..0d45ec5 100644
--- a/CHANGES
+++ b/CHANGES
@@ -4018,13 +4018,94 @@
 Version 1.5.15beta06 [February 22, 2013]
   Fixed PNG_ALIGN(ED)_MEMORY and add ability to turn off ARM_NEON
     runtime checks
-  Updated INSTALL.
+  Updated the INSTALL document.
 
-  ===========================================================================
-                       NOTICE November 17, 2012:
-     The location of the git repository at SourceForge has changed.
-               Visit http://libpng.sf.net/ for details.
-  ===========================================================================
+Version 1.5.15beta07 [February 27, 2013]
+  Revised INSTALL to recommend using CPPFLAGS instead of INCLUDES.
+  Revised scripts/makefile.freebsd to respect ZLIBLIB and ZLIBINC.
+  Revised scripts/dfn.awk to work with the buggy MSYS awk that has trouble
+    with CRLF line endings.
+
+Version 1.5.15beta08 [March 5, 2013]
+  Avoid a possible memory leak in contrib/gregbook/readpng.c
+  Made the _SUPPORTED macro definitions consistent. The change made in
+    libpng15 to #define *_SUPPORTED 1, to match the use of -D*_SUPPORTED
+    (which means -D*_SUPPORTED=1) and avoid compiler warnings from GCC was made
+    inconsistently and causes problems as a result, also some additions in
+    pnglibconf.h.prebuilt were inconsistent (omitting the 1). This changes 1.5
+    back to the scheme used both before (1.4) and after (1.6). This might cause
+    some build scripts to issue warnings, and might, in the extreme, cause some
+    applications to fail (but they would fail anyway against 1.6).  It seems
+    safer to go for consistency, given the change in 1.6, not correctness here,
+    particularly as 'make check' currently warns anyway on the symbols.dfn check
+    because of the inconsistencies.
+  Corrected Android builds and corrected libpng.vers with symbol
+    prefixing This adds an API to set optimization options externally,
+    providing an alternative and general solution for the non-portable
+    run-time tests used by the ARM Neon code.  It also makes those tests
+    compile and link on Android.
+  The order of settings vs options in pnglibconf.h is reversed to allow
+    settings to depend on options and options can now set (or override) the
+    defaults for settings.
+
+Version 1.5.15beta09 [March 13, 2013]
+  Fixed CMakelists.txt to allow building a single variant of the library
+    (Claudio Bley):
+  Introduced a PNG_LIB_TARGETS variable that lists all activated library
+    targets.  It is an error if this variable ends up empty, ie. you have
+    to build at least one library variant.
+  Made the *_COPY targets only depend on library targets actually being build.
+  Use PNG_LIB_TARGETS to unify a code path.
+  Changed the CREATE_SYMLINK macro to expect the full path to a file as the
+    first argument. When symlinking the filename component of that path is
+    determined and used as the link target.
+  Use copy_if_different in the CREATE_SYMLINK macro.
+  Eliminated two warnings from the Intel C compiler. The warnings are
+    technically valid, although a reasonable treatment of division would
+    show it to be incorrect.
+
+Version 1.5.15rc01 [March 21, 2013]
+  No changes.
+
+Version 1.5.15 [March 28, 2013]
+  No changes.
+
+Version 1.5.16beta01 [April 25, 2013]
+  Corrected a misplaced closing bracket in contrib/libtests/pngvalid.c
+    (Flavio Medeiros).
+  Revised stack marking in arm/filter_neon.S and configure.ac.
+  Ensure that NEON filter stuff is completely disabled when switched 'off'.
+    Previously the ARM NEON specific files were still built if the option
+    was switched 'off' as opposed to being explicitly disabled.
+  Avoid a compiler warning about unused png_ptr in translate_gamma_flags()
+
+Version 1.5.16beta02 [April 26, 2013]
+  Revise pngtest.c to skip tests of unsupported features.
+  Regenerated configure files.
+
+Version 1.5.16beta03 [April 26, 2013]
+  Test for 'arm*' not just 'arm' in the host_cpu configure variable.
+
+Version 1.5.16beta04 [May 1, 2013]
+  Expanded manual paragraph about writing private chunks, particularly
+    the need to call png_set_keep_unknown_chunks() when writing them.
+
+Version 1.5.16beta05 [May 9, 2013]
+  Updated contrib/pngminus/pnm2png.c (Paul Stewart):
+    Check for EOF
+    Ignore "#" delimited comments in input file to pnm2png.c.
+    Fixed whitespace handling
+    Added a call to png_set_packing()
+    Initialize dimension values so if sscanf fails at least we have known
+      invalid values.
+
+Version 1.5.16beta06 [May 12, 2013]
+  Allow contrib/pnminus/pnm2png.c to compile without WRITE_INVERT and WRITE_PACK
+    supported (writes error message that it can't read P1 or P4 PBM files).
+  Revised contrib/pngminim/*/makefile to separate CPPFLAGS and CPFLAGS, and
+    to generate pnglibconf.h with the right zlib header files.
+  Ported contrib/pngminus/pnm2png.c changes back from libpng-1.6.3beta06,
+    to use unsigned long, not png_uint_32 arguments to sscanf().
 
 Send comments/corrections/commendations to png-mng-implement at lists.sf.net
 (subscription required; visit
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 91d9300..ae64bab 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -35,7 +35,7 @@
 
 set(PNGLIB_MAJOR 1)
 set(PNGLIB_MINOR 5)
-set(PNGLIB_RELEASE 15)
+set(PNGLIB_RELEASE 16)
 set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
 set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
 
@@ -138,8 +138,11 @@
 # NOW BUILD OUR TARGET
 include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${ZLIB_INCLUDE_DIR})
 
+unset(PNG_LIB_TARGETS)
+
 if(PNG_SHARED)
   add_library(${PNG_LIB_NAME} SHARED ${libpng_sources})
+  set(PNG_LIB_TARGETS ${PNG_LIB_NAME})
   if(MSVC)
     # msvc does not append 'lib' - do it here to have consistent name
     set_target_properties(${PNG_LIB_NAME} PROPERTIES PREFIX "lib")
@@ -152,6 +155,7 @@
 # does not work without changing name
   set(PNG_LIB_NAME_STATIC ${PNG_LIB_NAME}_static)
   add_library(${PNG_LIB_NAME_STATIC} STATIC ${libpng_sources})
+  list(APPEND PNG_LIB_TARGETS ${PNG_LIB_NAME_STATIC})
   if(MSVC)
     # msvc does not append 'lib' - do it here to have consistent name
     set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES PREFIX "lib")
@@ -159,6 +163,12 @@
   target_link_libraries(${PNG_LIB_NAME_STATIC} ${ZLIB_LIBRARY} ${M_LIBRARY})
 endif()
 
+if(NOT PNG_LIB_TARGETS)
+  message(SEND_ERROR
+    "No library variant selected to build. "
+    "Please enable at least one of the following options: PNG_STATIC, PNG_SHARED")
+endif()
+
 if(PNG_SHARED AND WIN32)
   set_target_properties(${PNG_LIB_NAME} PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL)
 endif()
@@ -187,14 +197,15 @@
   if(WIN32 AND NOT CYGWIN AND NOT MSYS)
     ADD_CUSTOM_COMMAND(
         OUTPUT ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE}   ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE}
-        COMMAND ${CMAKE_COMMAND} -E copy        ${CMAKE_CURRENT_BINARY_DIR}/${SRC_FILE} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE}
-        COMMAND ${CMAKE_COMMAND} -E copy        ${CMAKE_CURRENT_BINARY_DIR}/${SRC_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE}
-        DEPENDS ${PNG_LIB_NAME} ${PNG_LIB_NAME_STATIC}
+        COMMAND ${CMAKE_COMMAND} -E copy_if_different  "${SRC_FILE}" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE}
+        COMMAND ${CMAKE_COMMAND} -E copy_if_different  "${SRC_FILE}" ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE}
+        DEPENDS ${PNG_LIB_TARGETS}
         )
     ADD_CUSTOM_TARGET(${DEST_FILE}_COPY ALL DEPENDS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE})
   else(WIN32 AND NOT CYGWIN AND NOT MSYS)
-    execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${SRC_FILE} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
-    execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${SRC_FILE} ${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+    get_filename_component(LINK_TARGET "${SRC_FILE}" NAME)
+    execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${LINK_TARGET}" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+    execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${LINK_TARGET}" ${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
   endif(WIN32 AND NOT CYGWIN AND NOT MSYS)
 endmacro()
 
@@ -225,7 +236,7 @@
 # SET UP LINKS
 if(PNG_SHARED)
   set_target_properties(${PNG_LIB_NAME} PROPERTIES
-#   VERSION 15.${PNGLIB_RELEASE}.1.5.15beta06
+#   VERSION 15.${PNGLIB_RELEASE}.1.5.16beta06
     VERSION 15.${PNGLIB_RELEASE}.0
     SOVERSION 15
     CLEAN_DIRECT_OUTPUT 1)
@@ -252,40 +263,33 @@
 
 # INSTALL
 if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
-  if(PNG_SHARED)
-    install(TARGETS ${PNG_LIB_NAME}
-        ${PNG_EXPORT_RULE}
-        RUNTIME DESTINATION bin
-        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
-        ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
+  install(TARGETS ${PNG_LIB_TARGETS}
+      ${PNG_EXPORT_RULE}
+      RUNTIME DESTINATION bin
+      LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+      ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
 
+  if(PNG_SHARED)
     # Create a symlink for libpng.dll.a => libpng15.dll.a on Cygwin
     if(CYGWIN OR MINGW)
        get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME} LOCATION_${CMAKE_BUILD_TYPE})
-       get_filename_component(BUILD_TARGET_FILE ${BUILD_TARGET_LOCATION} NAME)
-       CREATE_SYMLINK(${BUILD_TARGET_FILE} libpng${CMAKE_IMPORT_LIBRARY_SUFFIX})
+       CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_IMPORT_LIBRARY_SUFFIX})
        install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX}
          DESTINATION ${CMAKE_INSTALL_LIBDIR})
     endif(CYGWIN OR MINGW)
 
     if(NOT WIN32)
       get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME} LOCATION_${CMAKE_BUILD_TYPE})
-      get_filename_component(BUILD_TARGET_FILE ${BUILD_TARGET_LOCATION} NAME)
-      CREATE_SYMLINK(${BUILD_TARGET_FILE} libpng${CMAKE_SHARED_LIBRARY_SUFFIX})
+      CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_SHARED_LIBRARY_SUFFIX})
       install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_SHARED_LIBRARY_SUFFIX}
          DESTINATION ${CMAKE_INSTALL_LIBDIR})
     endif(NOT WIN32)
   endif(PNG_SHARED)
 
   if(PNG_STATIC)
-    install(TARGETS ${PNG_LIB_NAME_STATIC}
-        ${PNG_EXPORT_RULE}
-        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
-        ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
     if(NOT WIN32 OR CYGWIN OR MINGW)
       get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME_STATIC} LOCATION_${CMAKE_BUILD_TYPE})
-      get_filename_component(BUILD_TARGET_FILE ${BUILD_TARGET_LOCATION} NAME)
-      CREATE_SYMLINK(${BUILD_TARGET_FILE} libpng${CMAKE_STATIC_LIBRARY_SUFFIX})
+      CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_STATIC_LIBRARY_SUFFIX})
       install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_STATIC_LIBRARY_SUFFIX}
          DESTINATION ${CMAKE_INSTALL_LIBDIR})
     endif(NOT WIN32 OR CYGWIN OR MINGW)
diff --git a/INSTALL b/INSTALL
index 972a472..f987378 100644
--- a/INSTALL
+++ b/INSTALL
@@ -46,15 +46,14 @@
 correspond to the version of zlib that's installed.
 
 If you wish to test with a particular zlib that is not first in the
-standard library search path, put ZLIBLIB, ZLIBINC, INCLUDES, LDFLAGS,
-LIBS, and LD_LIBRARY_PATH in your environment before running "make test"
+standard library search path, put ZLIBLIB, ZLIBINC, CPPFLAGS, LDFLAGS,
+and LD_LIBRARY_PATH in your environment before running "make test"
 or "make distcheck":
 
 ZLIBLIB=/path/to/lib export ZLIBLIB
 ZLIBINC=/path/to/include export ZLIBINC
-INCLUDES="-I$ZLIBINC" export INCLUDES
+CPPFLAGS="-I$ZLIBINC" export CPPFLAGS
 LDFLAGS="-L$ZLIBLIB" export LDFLAGS
-LIBS=$ZLIBLIB/libz.a export LIBS
 LD_LIBRARY_PATH="$ZLIBLIB:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH
 
 If you are using one of the makefile scripts, put ZLIBLIB and ZLIBINC
@@ -67,8 +66,8 @@
    make install
 
 You can rename the directories that you downloaded (they
-might be called "libpng-x.y.z" or "libpngNN" and "zlib-1.2.5"
-or "zlib125") so that you have directories called "zlib" and "libpng".
+might be called "libpng-x.y.z" or "libpngNN" and "zlib-1.2.7"
+or "zlib127") so that you have directories called "zlib" and "libpng".
 
 Your directory structure should look like this:
 
diff --git a/LICENSE b/LICENSE
index ab824ca..9c8aac2 100644
--- a/LICENSE
+++ b/LICENSE
@@ -10,7 +10,7 @@
 
 This code is released under the libpng license.
 
-libpng versions 1.2.6, August 15, 2004, through 1.5.15beta06, February 22, 2013, are
+libpng versions 1.2.6, August 15, 2004, through 1.5.16beta06, May 12, 2013, are
 Copyright (c) 2004, 2006-2012 Glenn Randers-Pehrson, and are
 distributed according to the same disclaimer and license as libpng-1.2.5
 with the following individual added to the list of Contributing Authors
@@ -108,4 +108,4 @@
 
 Glenn Randers-Pehrson
 glennrp at users.sourceforge.net
-February 22, 2013
+May 12, 2013
diff --git a/Makefile.am b/Makefile.am
index 9ea9707..c3fb718 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -174,7 +174,7 @@
 	rm -f $@ dfn?.out
 	test -z "$(CPPFLAGS)"
 	echo "com @PNGLIB_VERSION@ STANDARD API DEFINITION" |\
-	$(AWK) -f ${srcdir}/scripts/options.awk out=dfn1.out logunsupported=1
+	$(AWK) -f ${srcdir}/scripts/options.awk out=dfn1.out logunsupported=1\
 		version=search ${srcdir}/pngconf.h -\
 		${srcdir}/scripts/pnglibconf.dfa 1>&2
 	$(AWK) -f ${srcdir}/scripts/options.awk out=dfn2.out dfn1.out 1>&2
diff --git a/Makefile.in b/Makefile.in
index bc1c954..e5a9b8e 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -288,7 +288,6 @@
 pkgincludedir = $(includedir)/$(PNGLIB_BASENAME)
 ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
-AM_CCASFLAGS = @AM_CCASFLAGS@
 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
 AR = @AR@
 AS = @AS@
@@ -1526,7 +1525,7 @@
 	rm -f $@ dfn?.out
 	test -z "$(CPPFLAGS)"
 	echo "com @PNGLIB_VERSION@ STANDARD API DEFINITION" |\
-	$(AWK) -f ${srcdir}/scripts/options.awk out=dfn1.out logunsupported=1
+	$(AWK) -f ${srcdir}/scripts/options.awk out=dfn1.out logunsupported=1\
 		version=search ${srcdir}/pngconf.h -\
 		${srcdir}/scripts/pnglibconf.dfa 1>&2
 	$(AWK) -f ${srcdir}/scripts/options.awk out=dfn2.out dfn1.out 1>&2
diff --git a/README b/README
index 5d9a229..ba2e12a 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-README for libpng version 1.5.15beta06 - February 22, 2013 (shared library 15.0)
+README for libpng version 1.5.16beta06 - May 12, 2013 (shared library 15.0)
 See the note about version numbers near the top of png.h
 
 See INSTALL for instructions on how to install libpng.
diff --git a/arm/arm_init.c b/arm/arm_init.c
index 78750d6..c24b2a0 100644
--- a/arm/arm_init.c
+++ b/arm/arm_init.c
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 2013 Glenn Randers-Pehrson
  * Written by Mans Rullgard, 2011.
- * Last changed in libpng 1.5.15 [%RDATE%]
+ * Last changed in libpng 1.5.16 [(PENDING RELEASE)]
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
@@ -16,16 +16,7 @@
 
 #include "../pngpriv.h"
 
-#if defined(PNG_FILTER_OPTIMIZATIONS) && defined(__arm__) && \
-   defined(__ARM_NEON__)
-/* __arm__ is defined by GCC, MSVC defines _M_ARM to the ARM version number,
- * Andoid intends to define __ANDROID__, however there are bugs in their
- * toolchain; use -D__ANDROID__ to work round this.
- *
- * __ARM_NEON__ is used to ensure that the compiler has the appropriate ARM
- * NEON support
- */
-
+#ifdef PNG_ARM_NEON_SUPPORTED
 #ifdef PNG_ARM_NEON_CHECK_SUPPORTED /* Do run-time checks */
 #include <signal.h> /* for sig_atomic_t */
 
@@ -45,7 +36,8 @@
     * implemented as below, therefore it is better to cache the result (these
     * function calls may be slow!)
     */
-   return andoid_getCpuFamily() == ANDROID_CPU_FAMILY_ARM &&
+   PNG_UNUSED(png_ptr)
+   return android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM &&
       (android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0;
 }
 #elif defined(__linux__)
@@ -161,15 +153,39 @@
 void
 png_init_filter_functions_neon(png_structp pp, unsigned int bpp)
 {
+#ifdef PNG_ARM_NEON_API_SUPPORTED
+   switch ((pp->options >> PNG_ARM_NEON) & 3)
+   {
+      case PNG_OPTION_UNSET:
+         /* Allow the run-time check to execute if it has been enabled -
+          * thus both API and CHECK can be turned on.  If it isn't supported
+          * this case will fall through to the 'default' below, which just
+          * returns.
+          */
+#endif /* PNG_ARM_NEON_API_SUPPORTED */
 #ifdef PNG_ARM_NEON_CHECK_SUPPORTED
-   static volatile sig_atomic_t no_neon = -1; /* not checked */
+         {
+            static volatile sig_atomic_t no_neon = -1; /* not checked */
 
-   if (no_neon < 0)
-      no_neon = !png_have_neon(pp);
+            if (no_neon < 0)
+               no_neon = !png_have_neon(pp);
 
-   if (no_neon)
-      return;
+            if (no_neon)
+               return;
+         }
+#ifdef PNG_ARM_NEON_API_SUPPORTED
+         break;
+#endif
 #endif /* PNG_ARM_NEON_CHECK_SUPPORTED */
+#ifdef PNG_ARM_NEON_API_SUPPORTED
+      case PNG_OPTION_ON:
+         /* Option turned on */
+         break;
+
+      default: /* OFF or INVALID */
+         return;
+   }
+#endif
 
    /* IMPORTANT: any new external functions used here must be declared using
     * PNG_INTERNAL_FUNCTION in ../pngpriv.h.  This is required so that the
@@ -200,4 +216,4 @@
           png_read_filter_row_paeth4_neon;
    }
 }
-#endif /* FILTER_OPTIMIZATIONS && __arm__ && __ARM_NEON__ */
+#endif /* PNG_ARM_NEON_SUPPORTED */
diff --git a/arm/filter_neon.S b/arm/filter_neon.S
index 72420a9..827d1a3 100644
--- a/arm/filter_neon.S
+++ b/arm/filter_neon.S
@@ -1,9 +1,9 @@
 
 /* filter_neon.S - NEON optimised filter functions
  *
- * Copyright (c) 2011 Glenn Randers-Pehrson
+ * Copyright (c) 2013 Glenn Randers-Pehrson
  * Written by Mans Rullgard, 2011.
- * Last changed in libpng 1.5.7 [December 15, 2011]
+ * Last changed in libpng 1.5.16 [(PENDING RELEASE)]
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
@@ -11,17 +11,17 @@
  */
 
 /* This is required to get the symbol renames, which are #defines, and also
- * includes the value of PNG_FILTER_OPTIMIZATIONS.
+ * includes the definition (or not) of PNG_ARM_NEON_SUPPORTED.
  */
 #define PNG_VERSION_INFO_ONLY
 #include "../pngpriv.h"
 
-#if defined(PNG_FILTER_OPTIMIZATIONS) && defined(__arm__) && \
-   defined(__ARM_NEON__)
 #if defined(__linux__) && defined(__ELF__)
 .section .note.GNU-stack,"",%progbits /* mark stack as non-executable */
 #endif
 
+#ifdef PNG_ARM_NEON_SUPPORTED
+
 #ifdef __ELF__
 #   define ELF
 #else
@@ -232,4 +232,4 @@
 
         pop             {r4,pc}
 endfunc
-#endif /* FILTER_OPTIMIZATIONS && __arm__ && __ARM_NEON__ */
+#endif /* PNG_ARM_NEON_SUPPORTED */
diff --git a/config.h.in b/config.h.in
index 8905c19..cad335d 100644
--- a/config.h.in
+++ b/config.h.in
@@ -73,14 +73,17 @@
 /* Define to the version of this package. */
 #undef PACKAGE_VERSION
 
-/* Align row buffers */
-#undef PNG_ALIGNED_MEMORY_SUPPORTED
+/* Turn on ARM Neon optimizations at run-time */
+#undef PNG_ARM_NEON_API_SUPPORTED
 
-/* ARM NEON filter initialization function */
-#undef PNG_FILTER_OPTIMIZATIONS
+/* Check for ARM Neon support at run-time */
+#undef PNG_ARM_NEON_CHECK_SUPPORTED
 
-/* Turn off run-time checking for ARM NEON support */
-#undef PNG_NO_ARM_NEON_CHECK
+/* Enable ARM Neon optimizations */
+#undef PNG_ARM_NEON_SUPPORTED
+
+/* Disable ARM Neon optimizations */
+#undef PNG_NO_ARM_NEON
 
 /* Define to 1 if you have the ANSI C header files. */
 #undef STDC_HEADERS
diff --git a/configure b/configure
index 3c7d78c..7bc89f5 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for libpng 1.5.15beta06.
+# Generated by GNU Autoconf 2.69 for libpng 1.5.16beta06.
 #
 # Report bugs to <png-mng-implement@lists.sourceforge.net>.
 #
@@ -590,8 +590,8 @@
 # Identity of this package.
 PACKAGE_NAME='libpng'
 PACKAGE_TARNAME='libpng'
-PACKAGE_VERSION='1.5.15beta06'
-PACKAGE_STRING='libpng 1.5.15beta06'
+PACKAGE_VERSION='1.5.16beta06'
+PACKAGE_STRING='libpng 1.5.16beta06'
 PACKAGE_BUGREPORT='png-mng-implement@lists.sourceforge.net'
 PACKAGE_URL=''
 
@@ -637,7 +637,6 @@
 LTLIBOBJS
 PNG_ARM_NEON_FALSE
 PNG_ARM_NEON_TRUE
-AM_CCASFLAGS
 binconfigs
 pkgconfigdir
 PNGLIB_RELEASE
@@ -1343,7 +1342,7 @@
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures libpng 1.5.15beta06 to adapt to many kinds of systems.
+\`configure' configures libpng 1.5.16beta06 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1413,7 +1412,7 @@
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of libpng 1.5.15beta06:";;
+     short | recursive ) echo "Configuration of libpng 1.5.16beta06:";;
    esac
   cat <<\_ACEOF
 
@@ -1435,8 +1434,12 @@
   --enable-fast-install[=PKGS]
                           optimize for fast installation [default=yes]
   --disable-libtool-lock  avoid locking (might break parallel builds)
-  --enable-arm-neon     Enable ARM NEON optimizations: use 'always' to turn
-                          off run-time checks
+  --enable-arm-neon     Enable ARM NEON optimizations: =no/off, check, api,
+                          yes/on: no/off: disable the optimizations; check:
+                          use internal checking code (deprecated and poorly
+                          supported); api: disable by default, enable by a
+                          call to png_set_option; yes/on: turn on
+                          unconditionally.
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
@@ -1530,7 +1533,7 @@
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-libpng configure 1.5.15beta06
+libpng configure 1.5.16beta06
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1953,7 +1956,7 @@
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by libpng $as_me 1.5.15beta06, which was
+It was created by libpng $as_me 1.5.16beta06, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -2816,7 +2819,7 @@
 
 # Define the identity of the package.
  PACKAGE='libpng'
- VERSION='1.5.15beta06'
+ VERSION='1.5.16beta06'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -2886,10 +2889,10 @@
 
 
 
-PNGLIB_VERSION=1.5.15beta06
+PNGLIB_VERSION=1.5.16beta06
 PNGLIB_MAJOR=1
 PNGLIB_MINOR=5
-PNGLIB_RELEASE=15
+PNGLIB_RELEASE=16
 
 
 
@@ -12804,30 +12807,51 @@
 
 
 
-# Because GCC by default assembles code with an executable stack, even though it
-# compiles C code with a non-executable stack, it is necessary to do a fixup
-# here (this may by GCC specific)
-AM_CCASFLAGS=-Wa,--noexecstack
-
+# HOST SPECIFIC OPTIONS
+# =====================
+#
+# ARM
+# ===
+#
+# ARM NEON (SIMD) support.
 
 # Check whether --enable-arm-neon was given.
 if test "${enable_arm_neon+set}" = set; then :
-  enableval=$enable_arm_neon; if test "${enableval}" = "yes" -o "${enableval}" = "always"; then
+  enableval=$enable_arm_neon; case "$enableval" in
+      no|off)
+         # disable the default enabling on __ARM_NEON__ systems:
 
-$as_echo "#define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_neon" >>confdefs.h
+$as_echo "#define PNG_NO_ARM_NEON /**/" >>confdefs.h
 
+         # Prevent inclusion of the assembler files below:
+         enable_arm_neon=no;;
+      check)
 
-$as_echo "#define PNG_ALIGNED_MEMORY_SUPPORTED 1" >>confdefs.h
+$as_echo "#define PNG_ARM_NEON_CHECK_SUPPORTED /**/" >>confdefs.h
+;;
+      api)
 
-      if test "${enableval}" = "always"; then
+$as_echo "#define PNG_ARM_NEON_API_SUPPORTED /**/" >>confdefs.h
+;;
+      yes|on)
 
-$as_echo "#define PNG_NO_ARM_NEON_CHECK /**/" >>confdefs.h
-
-      fi
-    fi
+$as_echo "#define PNG_ARM_NEON_SUPPORTED /**/" >>confdefs.h
+;;
+      *)
+         as_fn_error $? "--enable-arm-neon=${enable_arm_neon}: invalid value" "$LINENO" 5
+   esac
 fi
 
- if test "${enable_arm_neon:-no}" != "no"; then
+
+# Add ARM specific files to all builds where the host_cpu is arm ('arm*') or
+# where ARM optimizations were explicitly requested (this allows a fallback if a
+# future host CPU does not match 'arm*')
+
+ if test "$enable_arm_neon" != 'no' &&
+    case "$host_cpu" in
+      arm*) :;;
+      *)    test "$enable_arm_neon" != '';;
+    esac; then
   PNG_ARM_NEON_TRUE=
   PNG_ARM_NEON_FALSE='#'
 else
@@ -12836,7 +12860,7 @@
 fi
 
 
- { $as_echo "$as_me:${as_lineno-$LINENO}: Extra options for compiler: $PNG_COPTS" >&5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: Extra options for compiler: $PNG_COPTS" >&5
 $as_echo "$as_me: Extra options for compiler: $PNG_COPTS" >&6;}
 
 # Config files, substituting as above
@@ -13395,7 +13419,7 @@
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by libpng $as_me 1.5.15beta06, which was
+This file was extended by libpng $as_me 1.5.16beta06, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -13461,7 +13485,7 @@
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-libpng config.status 1.5.15beta06
+libpng config.status 1.5.16beta06
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff --git a/configure.ac b/configure.ac
index f2d8645..b104750 100644
--- a/configure.ac
+++ b/configure.ac
@@ -18,15 +18,15 @@
 
 dnl Version number stuff here:
 
-AC_INIT([libpng], [1.5.15beta06], [png-mng-implement@lists.sourceforge.net])
+AC_INIT([libpng], [1.5.16beta06], [png-mng-implement@lists.sourceforge.net])
 AM_INIT_AUTOMAKE([serial-tests])
 dnl stop configure from automagically running automake
 AM_MAINTAINER_MODE
 
-PNGLIB_VERSION=1.5.15beta06
+PNGLIB_VERSION=1.5.16beta06
 PNGLIB_MAJOR=1
 PNGLIB_MINOR=5
-PNGLIB_RELEASE=15
+PNGLIB_RELEASE=16
 
 dnl End of version number stuff
 
@@ -166,28 +166,52 @@
 	[binconfigs='${binconfigs}'])
 AC_SUBST([binconfigs])
 
-# Because GCC by default assembles code with an executable stack, even though it
-# compiles C code with a non-executable stack, it is necessary to do a fixup
-# here (this may by GCC specific)
-AC_SUBST([AM_CCASFLAGS], [-Wa,--noexecstack])
+# HOST SPECIFIC OPTIONS
+# =====================
+#
+# ARM
+# ===
+#
+# ARM NEON (SIMD) support.
 
 AC_ARG_ENABLE([arm-neon],
    AS_HELP_STRING([[[--enable-arm-neon]]],
-      [Enable ARM NEON optimizations: use 'always' to turn off run-time checks]),
-   [if test "${enableval}" = "yes" -o "${enableval}" = "always"; then
-       AC_DEFINE([PNG_FILTER_OPTIMIZATIONS],
-                 [png_init_filter_functions_neon],
-                 [ARM NEON filter initialization function])
-      AC_DEFINE([PNG_ALIGNED_MEMORY_SUPPORTED], [1],
-                [Align row buffers])
-      if test "${enableval}" = "always"; then
-         AC_DEFINE([PNG_NO_ARM_NEON_CHECK], [],
-                   [Turn off run-time checking for ARM NEON support])
-      fi
-    fi])
-AM_CONDITIONAL([PNG_ARM_NEON], [test "${enable_arm_neon:-no}" != "no"])
+      [Enable ARM NEON optimizations: =no/off, check, api, yes/on:]
+      [no/off: disable the optimizations; check: use internal checking code]
+      [(deprecated and poorly supported); api: disable by default, enable by]
+      [a call to png_set_option; yes/on: turn on unconditionally.]),
+   [case "$enableval" in
+      no|off)
+         # disable the default enabling on __ARM_NEON__ systems:
+         AC_DEFINE([PNG_NO_ARM_NEON], [],
+                   [Disable ARM Neon optimizations])
+         # Prevent inclusion of the assembler files below:
+         enable_arm_neon=no;;
+      check)
+         AC_DEFINE([PNG_ARM_NEON_CHECK_SUPPORTED], [],
+                   [Check for ARM Neon support at run-time]);;
+      api)
+         AC_DEFINE([PNG_ARM_NEON_API_SUPPORTED], [],
+                   [Turn on ARM Neon optimizations at run-time]);;
+      yes|on)
+         AC_DEFINE([PNG_ARM_NEON_SUPPORTED], [],
+                   [Enable ARM Neon optimizations]);;
+      *)
+         AC_MSG_ERROR([--enable-arm-neon=${enable_arm_neon}: invalid value])
+   esac])
+
+# Add ARM specific files to all builds where the host_cpu is arm ('arm*') or
+# where ARM optimizations were explicitly requested (this allows a fallback if a
+# future host CPU does not match 'arm*')
+
+AM_CONDITIONAL([PNG_ARM_NEON],
+   [test "$enable_arm_neon" != 'no' &&
+    case "$host_cpu" in
+      arm*) :;;
+      *)    test "$enable_arm_neon" != '';;
+    esac])
  
- AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]])
+AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]])
 
 # Config files, substituting as above
 AC_CONFIG_FILES([Makefile libpng.pc:libpng.pc.in])
diff --git a/contrib/gregbook/readpng.c b/contrib/gregbook/readpng.c
index 0b75fac..f5e1fb1 100644
--- a/contrib/gregbook/readpng.c
+++ b/contrib/gregbook/readpng.c
@@ -215,6 +215,10 @@
      * libpng function */
 
     if (setjmp(png_jmpbuf(png_ptr))) {
+        free(image_data);
+        image_data = NULL;
+        free(row_pointers);
+        row_pointers = NULL;
         png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
         return NULL;
     }
diff --git a/contrib/libtests/pngvalid.c b/contrib/libtests/pngvalid.c
index c436d23..71545a3 100644
--- a/contrib/libtests/pngvalid.c
+++ b/contrib/libtests/pngvalid.c
@@ -1,7 +1,7 @@
 
 /* pngvalid.c - validate libpng by constructing then reading png files.
  *
- * Last changed in libpng 1.5.14 [%RDATE%]
+ * Last changed in libpng 1.5.15 [March 28, 2013]
  * Copyright (c) 2013 Glenn Randers-Pehrson
  * Written by John Cunningham Bowler
  *
@@ -4599,9 +4599,13 @@
       }
       else
          png_progressive_combine_row(pp, row, new_row);
-   } else if (dp->interlace_type == PNG_INTERLACE_ADAM7 &&
-      PNG_ROW_IN_INTERLACE_PASS(y, pass) &&
-      PNG_PASS_COLS(dp->w, pass) > 0)
+#endif /* PNG_READ_INTERLACING_SUPPORTED */
+   }
+
+#ifdef PNG_READ_INTERLACING_SUPPORTED
+   else if (dp->interlace_type == PNG_INTERLACE_ADAM7 &&
+       PNG_ROW_IN_INTERLACE_PASS(y, pass) &&
+       PNG_PASS_COLS(dp->w, pass) > 0)
       png_error(pp, "missing row in progressive de-interlacing");
 #endif /* PNG_READ_INTERLACING_SUPPORTED */
 }
diff --git a/contrib/pngminim/decoder/makefile b/contrib/pngminim/decoder/makefile
index dafba64..25e2ee0 100644
--- a/contrib/pngminim/decoder/makefile
+++ b/contrib/pngminim/decoder/makefile
@@ -14,7 +14,8 @@
 RM=rm -f
 COPY=cp
 
-CFLAGS=-DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP -I. -O1
+CPPFLAGS=-I. -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP
+CFLAGS=-O1
 
 C=.c
 O=.o
@@ -81,7 +82,7 @@
 
 # note: dependencies do not work on implicit rule lines
 .c$(O):
-	$(CC) -c $(CFLAGS) $<
+	$(CC) $(CPPFLAGS) -c $(CFLAGS) $<
 
 # dependencies
 
@@ -95,12 +96,12 @@
 # The CPP_FLAGS setting causes pngusr.h to be included in
 # both the build of pnglibconf.h and, subsequently, when
 # building libpng itself.
-$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak\
+$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak $(ZH)\
 	$(PNGSRC)/scripts/pnglibconf.dfa \
 	$(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa
 	$(RM) pnglibconf.h pnglibconf.dfn
 	$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
-	    srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG"\
+	    srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG -I."\
 	    DFA_XTRA="pngusr.dfa" $@
 
 clean:
diff --git a/contrib/pngminim/encoder/makefile b/contrib/pngminim/encoder/makefile
index 810b8c8..e2ccbbc 100644
--- a/contrib/pngminim/encoder/makefile
+++ b/contrib/pngminim/encoder/makefile
@@ -14,7 +14,8 @@
 RM=rm -f
 COPY=cp
 
-CFLAGS=-DPNG_USER_CONFIG -DZ_SOLO -DNO_GZIP -I. -O1
+CPPFLAGS=-I. -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP
+CFLAGS=-O1
 
 C=.c
 O=.o
@@ -80,7 +81,7 @@
 # implicit make rules -------------------------------------------------------
 
 .c$(O):
-	$(CC) -c $(CFLAGS) $<
+	$(CC) $(CPPFLAGS) -c $(CFLAGS) $<
 
 # dependencies
 
@@ -94,12 +95,12 @@
 # The CPP_FLAGS setting causes pngusr.h to be included in
 # both the build of pnglibconf.h and, subsequently, when
 # building libpng itself.
-$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak\
+$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak $(ZH)\
 	$(PNGSRC)/scripts/pnglibconf.dfa \
 	$(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa
 	$(RM) pnglibconf.h pnglibconf.dfn
 	$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
-	    srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG"\
+	    srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG -I."\
 	    DFA_XTRA="pngusr.dfa" $@
 
 clean:
diff --git a/contrib/pngminim/encoder/pngusr.dfa b/contrib/pngminim/encoder/pngusr.dfa
index ee88443..334d5e3 100644
--- a/contrib/pngminim/encoder/pngusr.dfa
+++ b/contrib/pngminim/encoder/pngusr.dfa
@@ -1,6 +1,6 @@
 # pngminim/encoder/pngusr.dfa
 #
-# Copyright (c) 2010-2011 Glenn Randers-Pehrson
+# Copyright (c) 2010-2013 Glenn Randers-Pehrson
 #
 # This code is released under the libpng license.
 # For conditions of distribution and use, see the disclaimer
@@ -13,6 +13,9 @@
 # Switch on the write code - this makes a minimalist encoder
 
 option WRITE on
+# These 2 options are required if you need to read PGM (P1 or P4) PGM files.
+# option WRITE_INVERT on
+# option WRITE_PACK on
 
 # You must choose fixed or floating point arithmetic:
 # option FLOATING_POINT on
diff --git a/contrib/pngminim/preader/makefile b/contrib/pngminim/preader/makefile
index ecc05c7..e9bb303 100644
--- a/contrib/pngminim/preader/makefile
+++ b/contrib/pngminim/preader/makefile
@@ -30,7 +30,8 @@
 #LIBS = $(XLIB)
 LIBS = $(XLIB) -lm                      #platforms that need libm
 
-CFLAGS=-DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP -I. $(XINC) -O1
+CPPFLAGS=-I. $(XINC) -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP
+CFLAGS=-O1
 
 C=.c
 O=.o
@@ -96,7 +97,7 @@
 # implicit make rules -------------------------------------------------------
 
 .c$(O):
-	$(CC) -c $(CFLAGS) $<
+	$(CC) $(CPPFLAGS) -c $(CFLAGS) $<
 
 # dependencies
 
@@ -110,12 +111,12 @@
 # The CPP_FLAGS setting causes pngusr.h to be included in
 # both the build of pnglibconf.h and, subsequently, when
 # building libpng itself.
-$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak\
+$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak $(ZH)\
 	$(PNGSRC)/scripts/pnglibconf.dfa \
 	$(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa
 	$(RM) pnglibconf.h pnglibconf.dfn
 	$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
-	    srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG"\
+	    srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG -I."\
 	    DFA_XTRA="pngusr.dfa" $@
 
 clean:
diff --git a/contrib/pngminus/pnm2png.c b/contrib/pngminus/pnm2png.c
index 4cdfad8..f9903dd 100644
--- a/contrib/pngminus/pnm2png.c
+++ b/contrib/pngminus/pnm2png.c
@@ -18,6 +18,7 @@
 #include <mem.h>
 #include <fcntl.h>
 #endif
+#include <zlib.h>
 
 #ifndef BOOL
 #define BOOL unsigned char
@@ -197,6 +198,9 @@
   char          height_token[16];
   char          maxval_token[16];
   int           color_type;
+  unsigned long   ul_width=0, ul_alpha_width=0;
+  unsigned long   ul_height=0, ul_alpha_height=0;
+  unsigned long   ul_maxval=0;
   png_uint_32   width, alpha_width;
   png_uint_32   height, alpha_height;
   png_uint_32   maxval;
@@ -206,6 +210,9 @@
   int           alpha_present;
   int           row, col;
   BOOL          raw, alpha_raw = FALSE;
+#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
+  BOOL          packed_bitmap = FALSE;
+#endif
   png_uint_32   tmp16;
   int           i;
 
@@ -218,20 +225,36 @@
   }
   else if ((type_token[1] == '1') || (type_token[1] == '4'))
   {
+#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
     raw = (type_token[1] == '4');
     color_type = PNG_COLOR_TYPE_GRAY;
+    get_token(pnm_file, width_token);
+    sscanf (width_token, "%lu", &ul_width);
+    width = (png_uint_32) ul_width;
+    get_token(pnm_file, height_token);
+    sscanf (height_token, "%lu", &ul_height);
+    height = (png_uint_32) ul_height;
     bit_depth = 1;
+    packed_bitmap = TRUE;
+#else
+    fprintf (stderr, "PNM2PNG built without PNG_WRITE_INVERT_SUPPORTED and \n");
+    fprintf (stderr, "PNG_WRITE_PACK_SUPPORTED can't read PBM (P1,P4) files\n");
+#endif
   }
   else if ((type_token[1] == '2') || (type_token[1] == '5'))
   {
     raw = (type_token[1] == '5');
     color_type = PNG_COLOR_TYPE_GRAY;
     get_token(pnm_file, width_token);
-    sscanf (width_token, "%lu", &width);
+    sscanf (width_token, "%lu", &ul_width);
+    width = (png_uint_32) ul_width;
     get_token(pnm_file, height_token);
-    sscanf (height_token, "%lu", &height);
+    sscanf (height_token, "%lu", &ul_height);
+    height = (png_uint_32) ul_height;
     get_token(pnm_file, maxval_token);
-    sscanf (maxval_token, "%lu", &maxval);
+    sscanf (maxval_token, "%lu", &ul_maxval);
+    maxval = (png_uint_32) ul_maxval;
+
     if (maxval <= 1)
       bit_depth = 1;
     else if (maxval <= 3)
@@ -248,11 +271,14 @@
     raw = (type_token[1] == '6');
     color_type = PNG_COLOR_TYPE_RGB;
     get_token(pnm_file, width_token);
-    sscanf (width_token, "%lu", &width);
+    sscanf (width_token, "%lu", &ul_width);
+    width = (png_uint_32) ul_width;
     get_token(pnm_file, height_token);
-    sscanf (height_token, "%lu", &height);
+    sscanf (height_token, "%lu", &ul_height);
+    height = (png_uint_32) ul_height;
     get_token(pnm_file, maxval_token);
-    sscanf (maxval_token, "%lu", &maxval);
+    sscanf (maxval_token, "%lu", &ul_maxval);
+    maxval = (png_uint_32) ul_maxval;
     if (maxval <= 1)
       bit_depth = 1;
     else if (maxval <= 3)
@@ -287,15 +313,18 @@
     {
       alpha_raw = (type_token[1] == '5');
       get_token(alpha_file, width_token);
-      sscanf (width_token, "%lu", &alpha_width);
+      sscanf (width_token, "%lu", &ul_alpha_width);
+      alpha_width=(png_uint_32) ul_alpha_width;
       if (alpha_width != width)
         return FALSE;
       get_token(alpha_file, height_token);
-      sscanf (height_token, "%lu", &alpha_height);
+      sscanf (height_token, "%lu", &ul_alpha_height);
+      alpha_height = (png_uint_32) ul_alpha_height;
       if (alpha_height != height)
         return FALSE;
       get_token(alpha_file, maxval_token);
-      sscanf (maxval_token, "%lu", &maxval);
+      sscanf (maxval_token, "%lu", &ul_maxval);
+      maxval = (png_uint_32) ul_maxval;
       if (maxval <= 1)
         alpha_depth = 1;
       else if (maxval <= 3)
@@ -329,8 +358,14 @@
 
   alpha_present = (channels - 1) % 2;
 
-  /* row_bytes is the width x number of channels x (bit-depth / 8) */
-  row_bytes = width * channels * ((bit_depth <= 8) ? 1 : 2);
+#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
+  if (packed_bitmap)
+    /* row data is as many bytes as can fit width x channels x bit_depth */
+    row_bytes = (width * channels * bit_depth + 7) / 8;
+  else
+#endif
+    /* row_bytes is the width x number of channels x (bit-depth / 8) */
+    row_bytes = width * channels * ((bit_depth <= 8) ? 1 : 2);
 
   if ((png_pixels = (png_byte *) malloc (row_bytes * height * sizeof (png_byte))) == NULL)
     return FALSE;
@@ -340,40 +375,48 @@
 
   for (row = 0; row < height; row++)
   {
-    for (col = 0; col < width; col++)
+#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
+    if (packed_bitmap) {
+      for (i = 0; i < row_bytes; i++)
+        /* png supports this format natively so no conversion is needed */
+        *pix_ptr++ = get_data (pnm_file, 8);
+    } else
+#endif
     {
-      for (i = 0; i < (channels - alpha_present); i++)
+      for (col = 0; col < width; col++)
       {
-        if (raw)
-          *pix_ptr++ = get_data (pnm_file, bit_depth);
-        else
-          if (bit_depth <= 8)
-            *pix_ptr++ = get_value (pnm_file, bit_depth);
+        for (i = 0; i < (channels - alpha_present); i++)
+        {
+          if (raw)
+            *pix_ptr++ = get_data (pnm_file, bit_depth);
           else
-          {
-            tmp16 = get_value (pnm_file, bit_depth);
-            *pix_ptr = (png_byte) ((tmp16 >> 8) & 0xFF);
-            pix_ptr++;
-            *pix_ptr = (png_byte) (tmp16 & 0xFF);
-            pix_ptr++;
-          }
-      }
+            if (bit_depth <= 8)
+              *pix_ptr++ = get_value (pnm_file, bit_depth);
+            else
+            {
+              tmp16 = get_value (pnm_file, bit_depth);
+              *pix_ptr = (png_byte) ((tmp16 >> 8) & 0xFF);
+              pix_ptr++;
+              *pix_ptr = (png_byte) (tmp16 & 0xFF);
+              pix_ptr++;
+            }
+        }
 
-      if (alpha) /* read alpha-channel from pgm file */
-      {
-        if (alpha_raw)
-          *pix_ptr++ = get_data (alpha_file, alpha_depth);
-        else
-          if (alpha_depth <= 8)
-            *pix_ptr++ = get_value (alpha_file, bit_depth);
+        if (alpha) /* read alpha-channel from pgm file */
+        {
+          if (alpha_raw)
+            *pix_ptr++ = get_data (alpha_file, alpha_depth);
           else
-          {
-            tmp16 = get_value (alpha_file, bit_depth);
-            *pix_ptr++ = (png_byte) ((tmp16 >> 8) & 0xFF);
-            *pix_ptr++ = (png_byte) (tmp16 & 0xFF);
-          }
-      } /* if alpha */
-
+            if (alpha_depth <= 8)
+              *pix_ptr++ = get_value (alpha_file, bit_depth);
+            else
+            {
+              tmp16 = get_value (alpha_file, bit_depth);
+              *pix_ptr++ = (png_byte) ((tmp16 >> 8) & 0xFF);
+              *pix_ptr++ = (png_byte) (tmp16 & 0xFF);
+            }
+        } /* if alpha */
+      } /* if packed_bitmap */
     } /* end for col */
   } /* end for row */
 
@@ -390,6 +433,14 @@
     return FALSE;
   }
 
+#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
+  if (packed_bitmap == TRUE)
+  {
+    png_set_packing (png_ptr);
+    png_set_invert_mono (png_ptr);
+  }
+#endif
+
   /* setjmp() must be called in every function that calls a PNG-reading libpng function */
   if (setjmp (png_jmpbuf(png_ptr)))
   {
@@ -446,19 +497,32 @@
 void get_token(FILE *pnm_file, char *token)
 {
   int i = 0;
+  int ret;
 
-  /* remove white-space */
+  /* remove white-space and comment lines */
   do
   {
-    token[i] = (unsigned char) fgetc (pnm_file);
+    ret = fgetc(pnm_file);
+    if (ret == '#') {
+      /* the rest of this line is a comment */
+      do
+      {
+        ret = fgetc(pnm_file);
+      }
+      while ((ret != '\n') && (ret != '\r') && (ret != EOF));
+    }
+    if (ret == EOF) break;
+    token[i] = (unsigned char) ret;
   }
   while ((token[i] == '\n') || (token[i] == '\r') || (token[i] == ' '));
 
   /* read string */
   do
   {
+    ret = fgetc(pnm_file);
+    if (ret == EOF) break;
     i++;
-    token[i] = (unsigned char) fgetc (pnm_file);
+    token[i] = (unsigned char) ret;
   }
   while ((token[i] != '\n') && (token[i] != '\r') && (token[i] != ' '));
 
@@ -510,6 +574,7 @@
 {
   static png_uint_32 mask = 0;
   png_byte token[16];
+  unsigned long ul_ret_value;
   png_uint_32 ret_value;
   int i = 0;
 
@@ -518,7 +583,8 @@
       mask = (mask << 1) | 0x01;
 
   get_token (pnm_file, (char *) token);
-  sscanf ((const char *) token, "%lu", &ret_value);
+  sscanf ((const char *) token, "%lu", &ul_ret_value);
+  ret_value = (png_uint_32) ul_ret_value;
 
   ret_value &= mask;
 
diff --git a/libpng-manual.txt b/libpng-manual.txt
index ac7705d..8a5e525 100644
--- a/libpng-manual.txt
+++ b/libpng-manual.txt
@@ -1,6 +1,6 @@
 Libpng-manual.txt - A description on how to use and modify libpng
 
- libpng version 1.5.15beta06 - February 22, 2013
+ libpng version 1.5.16beta06 - May 12, 2013
  Updated and distributed by Glenn Randers-Pehrson
  <glennrp at users.sourceforge.net>
  Copyright (c) 1998-2013 Glenn Randers-Pehrson
@@ -11,7 +11,7 @@
 
  Based on:
 
- libpng versions 0.97, January 1998, through 1.5.15beta06 - February 22, 2013
+ libpng versions 0.97, January 1998, through 1.5.16beta06 - May 12, 2013
  Updated and distributed by Glenn Randers-Pehrson
  Copyright (c) 1998-2013 Glenn Randers-Pehrson
 
@@ -31,9 +31,7 @@
 I. Introduction
 
 This file describes how to use and modify the PNG reference library
-(known as libpng) for your own use.  There are five sections to this
-file: introduction, structures, reading, writing, and modification and
-configuration notes for various special platforms.  In addition to this
+(known as libpng) for your own use.  In addition to this
 file, example.c is a good starting point for using the library, as
 it is heavily commented and should include everything most people
 will need.  We assume that libpng is already installed; see the
@@ -509,8 +507,7 @@
 
 If you call the png_set_read_user_chunk_fn() function, then all unknown
 chunks will be saved when read, in case your callback function will need
-one or more of them.  This behavior can be changed with the
-png_set_keep_unknown_chunks() function, described below.
+one or more of them.
 
 At this point, you can set up a callback function that will be
 called after each row has been read, which you can use to control
@@ -604,7 +601,11 @@
 
     #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
       /* ignore all unknown chunks: */
+    #  if PNG_LIBPNG_VER < 10700
+      png_set_keep_unknown_chunks(read_ptr, 2, NULL, 0);
+    #  else
       png_set_keep_unknown_chunks(read_ptr, 1, NULL, 0);
+    #  endif
 
       /* except for vpAg: */
       png_set_keep_unknown_chunks(read_ptr, 2, vpAg, 1);
@@ -3034,13 +3035,45 @@
 
 Writing unknown chunks
 
-You can use the png_set_unknown_chunks function to queue up chunks
-for writing.  You give it a chunk name, raw data, and a size; that's
-all there is to it.  The chunks will be written by the next following
-png_write_info_before_PLTE, png_write_info, or png_write_end function.
-Any chunks previously read into the info structure's unknown-chunk
-list will also be written out in a sequence that satisfies the PNG
-specification's ordering rules.
+You can use the png_set_unknown_chunks function to queue up private chunks
+for writing.  You give it a chunk name, location, raw data, and a size.  You
+also must use png_set_keep_unknown_chunks() to ensure that libpng will
+handle them.  That's all there is to it.  The chunks will be written by the
+next following png_write_info_before_PLTE, png_write_info, or png_write_end
+function, depending upon the specified location.  Any chunks previously
+read into the info structure's unknown-chunk list will also be written out
+in a sequence that satisfies the PNG specification's ordering rules.
+
+Here is an example of writing two private chunks, prVt and miNE:
+
+    #ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
+    /* Set unknown chunk data */
+    png_unknown_chunk unk_chunk[2];
+    strcpy((char *) unk_chunk[0].name, "prVt";
+    unk_chunk[0].data = (unsigned char *) "PRIVATE DATA";
+    unk_chunk[0].size = strlen(unk_chunk[0].data)+1;
+    unk_chunk[0].location = PNG_HAVE_IHDR;
+    strcpy((char *) unk_chunk[1].name, "miNE";
+    unk_chunk[1].data = (unsigned char *) "MY CHUNK DATA";
+    unk_chunk[1].size = strlen(unk_chunk[0].data)+1;
+    unk_chunk[1].location = PNG_AFTER_IDAT;
+    png_set_unknown_chunks(write_ptr, write_info_ptr,
+        unk_chunk, 2);
+    /* Needed because miNE is not safe-to-copy */
+    png_set_keep_unknown_chunks(png, PNG_HANDLE_CHUNK_ALWAYS,
+       (png_bytep) "miNE", 1);
+    /* Deal with unknown chunk location bug in 1.5.x and earlier */
+    png_set_unknown_chunk_location(png, info, 0, PNG_HAVE_IHDR);
+    png_set_unknown_chunk_location(png, info, 1, PNG_AFTER_IDAT);
+    # if PNG_LIBPNG_VER < 10500
+      /* PNG_AFTER_IDAT writes two copies of the chunk prior to libpng-1.5.0,
+       * one before IDAT and another after IDAT, so don't use it; only use
+       * PNG_HAVE_IHDR location.  This call resets the location previously
+       * set by assignment and png_set_unknown_chunk_location() for chunk 1.
+       */
+      png_set_unknown_chunk_location(png, info, 1, PNG_HAVE_IHDR);
+    # endif
+    #endif
 
 The high-level write interface
 
@@ -4490,11 +4523,11 @@
 going back to version 0.70.  You can access the git repository (read only)
 at
 
-    git://libpng.git.sourceforge.net/gitroot/libpng
+    git://git.code.sf.net/p/libpng/code
 
-or you can browse it via "gitweb" at
+or you can browse it with a web browser by selecting the "code" button at
 
-    http://libpng.git.sourceforge.net/git/gitweb.cgi?p=libpng
+    https://sourceforge.net/projects/libpng/
 
 Patches can be sent to glennrp at users.sourceforge.net or to
 png-mng-implement at lists.sourceforge.net or you can upload them to
@@ -4622,13 +4655,13 @@
 
 XIV. Y2K Compliance in libpng
 
-February 22, 2013
+May 12, 2013
 
 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.5.15beta06 are Y2K compliant.  It is my belief that earlier
+upward through 1.5.16beta06 are Y2K compliant.  It is my belief that earlier
 versions were also Y2K compliant.
 
 Libpng only has two year fields.  One is a 2-byte unsigned integer that
diff --git a/libpng.3 b/libpng.3
index 12d80f5..6e1241d 100644
--- a/libpng.3
+++ b/libpng.3
@@ -1,6 +1,6 @@
-.TH LIBPNG 3 "February 22, 2013"
+.TH LIBPNG 3 "May 12, 2013"
 .SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.5.15beta06
+libpng \- Portable Network Graphics (PNG) Reference Library 1.5.16beta06
 .SH SYNOPSIS
 \fB
 #include <png.h>\fP
@@ -277,7 +277,7 @@
 
 \fBvoid png_set_bKGD (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, png_color_16p \fIbackground\fP\fB);\fP
 
-\fBvoid png_set_check_for_invalid_index(png_structrp \fP\fIpng_ptr\fP\fB, int \fIallowed\fP\fB);\fP
+\fBvoid png_set_check_for_invalid_index(png_structp \fP\fIpng_ptr\fP\fB, int \fIallowed\fP\fB);\fP
 
 \fBvoid png_set_cHRM (png_structp \fP\fIpng_ptr\fP\fB, png_infop \fP\fIinfo_ptr\fP\fB, double \fP\fIwhite_x\fP\fB, double \fP\fIwhite_y\fP\fB, double \fP\fIred_x\fP\fB, double \fP\fIred_y\fP\fB, double \fP\fIgreen_x\fP\fB, double \fP\fIgreen_y\fP\fB, double \fP\fIblue_x\fP\fB, double \fIblue_y\fP\fB);\fP
 
@@ -492,7 +492,7 @@
 .SH LIBPNG.TXT
 Libpng-manual.txt - A description on how to use and modify libpng
 
- libpng version 1.5.15beta06 - February 22, 2013
+ libpng version 1.5.16beta06 - May 12, 2013
  Updated and distributed by Glenn Randers-Pehrson
  <glennrp at users.sourceforge.net>
  Copyright (c) 1998-2013 Glenn Randers-Pehrson
@@ -503,7 +503,7 @@
 
  Based on:
 
- libpng versions 0.97, January 1998, through 1.5.15beta06 - February 22, 2013
+ libpng versions 0.97, January 1998, through 1.5.16beta06 - May 12, 2013
  Updated and distributed by Glenn Randers-Pehrson
  Copyright (c) 1998-2013 Glenn Randers-Pehrson
 
@@ -523,9 +523,7 @@
 .SH I. Introduction
 
 This file describes how to use and modify the PNG reference library
-(known as libpng) for your own use.  There are five sections to this
-file: introduction, structures, reading, writing, and modification and
-configuration notes for various special platforms.  In addition to this
+(known as libpng) for your own use.  In addition to this
 file, example.c is a good starting point for using the library, as
 it is heavily commented and should include everything most people
 will need.  We assume that libpng is already installed; see the
@@ -1001,8 +999,7 @@
 
 If you call the png_set_read_user_chunk_fn() function, then all unknown
 chunks will be saved when read, in case your callback function will need
-one or more of them.  This behavior can be changed with the
-png_set_keep_unknown_chunks() function, described below.
+one or more of them.
 
 At this point, you can set up a callback function that will be
 called after each row has been read, which you can use to control
@@ -1096,7 +1093,11 @@
 
     #if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
       /* ignore all unknown chunks: */
+    #  if PNG_LIBPNG_VER < 10700
+      png_set_keep_unknown_chunks(read_ptr, 2, NULL, 0);
+    #  else
       png_set_keep_unknown_chunks(read_ptr, 1, NULL, 0);
+    #  endif
 
       /* except for vpAg: */
       png_set_keep_unknown_chunks(read_ptr, 2, vpAg, 1);
@@ -3526,13 +3527,45 @@
 
 .SS Writing unknown chunks
 
-You can use the png_set_unknown_chunks function to queue up chunks
-for writing.  You give it a chunk name, raw data, and a size; that's
-all there is to it.  The chunks will be written by the next following
-png_write_info_before_PLTE, png_write_info, or png_write_end function.
-Any chunks previously read into the info structure's unknown-chunk
-list will also be written out in a sequence that satisfies the PNG
-specification's ordering rules.
+You can use the png_set_unknown_chunks function to queue up private chunks
+for writing.  You give it a chunk name, location, raw data, and a size.  You
+also must use png_set_keep_unknown_chunks() to ensure that libpng will
+handle them.  That's all there is to it.  The chunks will be written by the
+next following png_write_info_before_PLTE, png_write_info, or png_write_end
+function, depending upon the specified location.  Any chunks previously
+read into the info structure's unknown-chunk list will also be written out
+in a sequence that satisfies the PNG specification's ordering rules.
+
+Here is an example of writing two private chunks, prVt and miNE:
+
+    #ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
+    /* Set unknown chunk data */
+    png_unknown_chunk unk_chunk[2];
+    strcpy((char *) unk_chunk[0].name, "prVt";
+    unk_chunk[0].data = (unsigned char *) "PRIVATE DATA";
+    unk_chunk[0].size = strlen(unk_chunk[0].data)+1;
+    unk_chunk[0].location = PNG_HAVE_IHDR;
+    strcpy((char *) unk_chunk[1].name, "miNE";
+    unk_chunk[1].data = (unsigned char *) "MY CHUNK DATA";
+    unk_chunk[1].size = strlen(unk_chunk[0].data)+1;
+    unk_chunk[1].location = PNG_AFTER_IDAT;
+    png_set_unknown_chunks(write_ptr, write_info_ptr,
+        unk_chunk, 2);
+    /* Needed because miNE is not safe-to-copy */
+    png_set_keep_unknown_chunks(png, PNG_HANDLE_CHUNK_ALWAYS,
+       (png_bytep) "miNE", 1);
+    /* Deal with unknown chunk location bug in 1.5.x and earlier */
+    png_set_unknown_chunk_location(png, info, 0, PNG_HAVE_IHDR);
+    png_set_unknown_chunk_location(png, info, 1, PNG_AFTER_IDAT);
+    # if PNG_LIBPNG_VER < 10500
+      /* PNG_AFTER_IDAT writes two copies of the chunk prior to libpng-1.5.0,
+       * one before IDAT and another after IDAT, so don't use it; only use
+       * PNG_HAVE_IHDR location.  This call resets the location previously
+       * set by assignment and png_set_unknown_chunk_location() for chunk 1.
+       */
+      png_set_unknown_chunk_location(png, info, 1, PNG_HAVE_IHDR);
+    # endif
+    #endif
 
 .SS The high-level write interface
 
@@ -4983,11 +5016,11 @@
 going back to version 0.70.  You can access the git repository (read only)
 at
 
-    git://libpng.git.sourceforge.net/gitroot/libpng
+    git://git.code.sf.net/p/libpng/code
 
-or you can browse it via "gitweb" at
+or you can browse it with a web browser by selecting the "code" button at
 
-    http://libpng.git.sourceforge.net/git/gitweb.cgi?p=libpng
+    https://sourceforge.net/projects/libpng/
 
 Patches can be sent to glennrp at users.sourceforge.net or to
 png-mng-implement at lists.sourceforge.net or you can upload them to
@@ -5115,13 +5148,13 @@
 
 .SH XIV. Y2K Compliance in libpng
 
-February 22, 2013
+May 12, 2013
 
 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.5.15beta06 are Y2K compliant.  It is my belief that earlier
+upward through 1.5.16beta06 are Y2K compliant.  It is my belief that earlier
 versions were also Y2K compliant.
 
 Libpng only has two year fields.  One is a 2-byte unsigned integer that
@@ -5344,7 +5377,10 @@
  1.5.14beta01-08     15    10514  15.so.15.14[.0]
  1.5.14rc01-03       15    10514  15.so.15.14[.0]
  1.5.14              15    10514  15.so.15.14[.0]
- 1.5.15beta01-06     15    10515  15.so.15.15[.0]
+ 1.5.15beta01-09     15    10515  15.so.15.15[.0]
+ 1.5.15rc01          15    10515  15.so.15.15[.0]
+ 1.5.15              15    10515  15.so.15.15[.0]
+ 1.5.16beta01-06     15    10516  15.so.15.16[.0]
 
 Henceforth the source version will match the shared-library minor
 and patch numbers; the shared-library major version number will be
@@ -5401,7 +5437,7 @@
 
 Thanks to Frank J. T. Wojcik for helping with the documentation.
 
-Libpng version 1.5.15beta06 - February 22, 2013:
+Libpng version 1.5.16beta06 - May 12, 2013:
 Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
 Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
 
@@ -5424,7 +5460,7 @@
 
 This code is released under the libpng license.
 
-libpng versions 1.2.6, August 15, 2004, through 1.5.15beta06, February 22, 2013, are
+libpng versions 1.2.6, August 15, 2004, through 1.5.16beta06, May 12, 2013, are
 Copyright (c) 2004,2006-2007 Glenn Randers-Pehrson, and are
 distributed according to the same disclaimer and license as libpng-1.2.5
 with the following individual added to the list of Contributing Authors
@@ -5523,7 +5559,7 @@
 
 Glenn Randers-Pehrson
 glennrp at users.sourceforge.net
-February 22, 2013
+May 12, 2013
 
 .\" end of man page
 
diff --git a/libpngpf.3 b/libpngpf.3
index b8ae147..d421d26 100644
--- a/libpngpf.3
+++ b/libpngpf.3
@@ -1,6 +1,6 @@
-.TH LIBPNGPF 3 "February 22, 2013"
+.TH LIBPNGPF 3 "May 12, 2013"
 .SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.5.15beta06
+libpng \- Portable Network Graphics (PNG) Reference Library 1.5.16beta06
 (private functions)
 .SH SYNOPSIS
 \fB#include \fI"pngpriv.h"
diff --git a/png.5 b/png.5
index a644a15..4ee4e1f 100644
--- a/png.5
+++ b/png.5
@@ -1,4 +1,4 @@
-.TH PNG 5 "February 22, 2013"
+.TH PNG 5 "May 12, 2013"
 .SH NAME
 png \- Portable Network Graphics (PNG) format
 .SH DESCRIPTION
diff --git a/png.c b/png.c
index 8b9424d..2019f53 100644
--- a/png.c
+++ b/png.c
@@ -1,7 +1,7 @@
 
 /* png.c - location for general purpose libpng functions
  *
- * Last changed in libpng 1.5.15 [(PENDING RELEASE)]
+ * Last changed in libpng 1.5.15 [March 28, 2013]
  * Copyright (c) 1998-2013 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.)
@@ -14,7 +14,7 @@
 #include "pngpriv.h"
 
 /* Generate a compiler error if there is an old png.h in the search path. */
-typedef png_libpng_version_1_5_15beta06 Your_png_h_is_not_version_1_5_15beta06;
+typedef png_libpng_version_1_5_16beta06 Your_png_h_is_not_version_1_5_16beta06;
 
 /* Tells libpng that we have already handled the first "num_bytes" bytes
  * of the PNG file signature.  If the PNG data is embedded into another
@@ -658,13 +658,13 @@
 #else
 #  ifdef __STDC__
    return PNG_STRING_NEWLINE \
-     "libpng version 1.5.15beta06 - February 22, 2013" PNG_STRING_NEWLINE \
+     "libpng version 1.5.16beta06 - May 12, 2013" PNG_STRING_NEWLINE \
      "Copyright (c) 1998-2013 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
      "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
      "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
      PNG_STRING_NEWLINE;
 #  else
-      return "libpng version 1.5.15beta06 - February 22, 2013\
+      return "libpng version 1.5.16beta06 - May 12, 2013\
       Copyright (c) 1998-2013 Glenn Randers-Pehrson\
       Copyright (c) 1996-1997 Andreas Dilger\
       Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
@@ -2878,3 +2878,24 @@
 }
 #endif /* READ_GAMMA */
 #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
+
+/* HARDWARE OPTION SUPPORT */
+#ifdef PNG_SET_OPTION_SUPPORTED
+int PNGAPI
+png_set_option(png_structp png_ptr, int option, int onoff)
+{
+   if (png_ptr != NULL && option >= 0 && option < PNG_OPTION_NEXT &&
+      (option & 1) == 0)
+   {
+      int mask = 3 << option;
+      int setting = (2 + (onoff != 0)) << option;
+      int current = png_ptr->options;
+
+      png_ptr->options = (png_byte)((current & ~mask) | setting);
+
+      return (current & mask) >> option;
+   }
+
+   return PNG_OPTION_INVALID;
+}
+#endif
diff --git a/png.h b/png.h
index 38e4321..9064def 100644
--- a/png.h
+++ b/png.h
@@ -1,7 +1,7 @@
 
 /* png.h - header file for PNG reference library
  *
- * libpng version 1.5.15beta06 - February 22, 2013
+ * libpng version 1.5.16beta06 - May 12, 2013
  * Copyright (c) 1998-2013 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.)
@@ -11,7 +11,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.5.15beta06 - February 22, 2013: Glenn
+ *   libpng versions 0.97, January 1998, through 1.5.16beta06 - May 12, 2013: Glenn
  *   See also "Contributing Authors", below.
  *
  * Note about libpng version numbers:
@@ -184,7 +184,10 @@
  *    1.5.14beta01-08         15    10514  15.so.15.14[.0]
  *    1.5.14rc01-03           15    10514  15.so.15.14[.0]
  *    1.5.14                  15    10514  15.so.15.14[.0]
- *    1.5.15beta01-06         15    10515  15.so.15.15[.0]
+ *    1.5.15beta01-09         15    10515  15.so.15.15[.0]
+ *    1.5.15rc01              15    10515  15.so.15.15[.0]
+ *    1.5.15                  15    10515  15.so.15.15[.0]
+ *    1.5.16beta01-06         15    10516  15.so.15.16[.0]
  *
  *   Henceforth the source version will match the shared-library major
  *   and minor numbers; the shared-library major version number will be
@@ -216,7 +219,7 @@
  *
  * This code is released under the libpng license.
  *
- * libpng versions 1.2.6, August 15, 2004, through 1.5.15beta06, February 22, 2013, are
+ * libpng versions 1.2.6, August 15, 2004, through 1.5.16beta06, May 12, 2013, are
  * Copyright (c) 2004, 2006-2013 Glenn Randers-Pehrson, and are
  * distributed according to the same disclaimer and license as libpng-1.2.5
  * with the following individual added to the list of Contributing Authors:
@@ -328,13 +331,13 @@
  * Y2K compliance in libpng:
  * =========================
  *
- *    February 22, 2013
+ *    May 12, 2013
  *
  *    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.5.15beta06 are Y2K compliant.  It is my belief that
+ *    upward through 1.5.16beta06 are Y2K compliant.  It is my belief that
  *    earlier versions were also Y2K compliant.
  *
  *    Libpng only has two year fields.  One is a 2-byte unsigned integer
@@ -393,9 +396,9 @@
  */
 
 /* Version information for png.h - this should match the version in png.c */
-#define PNG_LIBPNG_VER_STRING "1.5.15beta06"
+#define PNG_LIBPNG_VER_STRING "1.5.16beta06"
 #define PNG_HEADER_VERSION_STRING \
-     " libpng version 1.5.15beta06 - February 22, 2013\n"
+     " libpng version 1.5.16beta06 - May 12, 2013\n"
 
 #define PNG_LIBPNG_VER_SONUM   15
 #define PNG_LIBPNG_VER_DLLNUM  15
@@ -403,7 +406,7 @@
 /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
 #define PNG_LIBPNG_VER_MAJOR   1
 #define PNG_LIBPNG_VER_MINOR   5
-#define PNG_LIBPNG_VER_RELEASE 15
+#define PNG_LIBPNG_VER_RELEASE 16
 
 /* This should match the numeric part of the final component of
  * PNG_LIBPNG_VER_STRING, omitting any leading zero:
@@ -434,7 +437,7 @@
  * 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 10515 /* 1.5.15 */
+#define PNG_LIBPNG_VER 10516 /* 1.5.16 */
 
 /* Library configuration: these options cannot be changed after
  * the library has been built.
@@ -556,7 +559,7 @@
 /* This triggers a compiler error in png.c, if png.c and png.h
  * do not agree upon the version number.
  */
-typedef char* png_libpng_version_1_5_15beta06;
+typedef char* png_libpng_version_1_5_16beta06;
 
 /* Three color definitions.  The order of the red, green, and blue, (and the
  * exact size) is not important, although the size of the fields need to
@@ -2660,6 +2663,47 @@
 #  endif
 #endif /* CHECK_FOR_INVALID_INDEX */
 
+/*******************************************************************************
+ *  IMPLEMENTATION OPTIONS
+ *******************************************************************************
+ *
+ * Support for arbitrary implementation-specific optimizations.  The API allows
+ * particular options to be turned on or off.  'Option' is the number of the
+ * option and 'onoff' is 0 (off) or non-0 (on).  The value returned is given
+ * by the PNG_OPTION_ defines below.
+ *
+ * HARDWARE: normally hardware capabilites, such as the Intel SSE instructions,
+ *           are detected at run time, however sometimes it may be impossible
+ *           to do this in user mode, in which case it is necessary to discover
+ *           the capabilities in an OS specific way.  Such capabilities are
+ *           listed here when libpng has support for them and must be turned
+ *           ON by the application if present.
+ *
+ * SOFTWARE: sometimes software optimizations actually result in performance
+ *           decrease on some architectures or systems, or with some sets of
+ *           PNG images.  'Software' options allow such optimizations to be
+ *           selected at run time.
+ */
+#ifdef PNG_SET_OPTION_SUPPORTED
+#ifdef PNG_ARM_NEON_API_SUPPORTED
+#  define PNG_ARM_NEON   0 /* HARDWARE: ARM Neon SIMD instructions supported */
+#endif
+#define PNG_OPTION_NEXT  2 /* Next option - numbers must be even */
+
+/* Return values: NOTE: there are four values and 'off' is *not* zero */
+#define PNG_OPTION_UNSET   0 /* Unset - defaults to off */
+#define PNG_OPTION_INVALID 1 /* Option number out of range */
+#define PNG_OPTION_OFF     2
+#define PNG_OPTION_ON      3
+
+PNG_EXPORT(236, int, png_set_option, (png_structp png_ptr, int option,
+   int onoff));
+#endif
+
+/*******************************************************************************
+ *  END OF HARDWARE OPTIONS
+ ******************************************************************************/
+
 /* Maintainer: Put new public prototypes here ^, in libpng.3, and project
  * defs
  */
@@ -2669,7 +2713,7 @@
  * scripts/symbols.def as well.
  */
 #ifdef PNG_EXPORT_LAST_ORDINAL
-  PNG_EXPORT_LAST_ORDINAL(235);
+  PNG_EXPORT_LAST_ORDINAL(236);
 #endif
 
 #ifdef __cplusplus
diff --git a/pngconf.h b/pngconf.h
index 78321ca..23fee0e 100644
--- a/pngconf.h
+++ b/pngconf.h
@@ -1,7 +1,7 @@
 
 /* pngconf.h - machine configurable file for libpng
  *
- * libpng version 1.5.15beta06 - February 22, 2013
+ * libpng version 1.5.16beta06 - May 12, 2013
  *
  * Copyright (c) 1998-2013 Glenn Randers-Pehrson
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
diff --git a/pngget.c b/pngget.c
index 025db2e..1eafae0 100644
--- a/pngget.c
+++ b/pngget.c
@@ -1,7 +1,7 @@
 
 /* pngget.c - retrieval of values from info struct
  *
- * Last changed in libpng 1.5.15 [(PENDING RELEASE)]
+ * Last changed in libpng 1.5.15 [March 28, 2013]
  * Copyright (c) 1998-2013 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.)
diff --git a/pngpriv.h b/pngpriv.h
index 7785bdb..ad40225 100644
--- a/pngpriv.h
+++ b/pngpriv.h
@@ -6,7 +6,7 @@
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
- * Last changed in libpng 1.5.15 [(PENDING RELEASE)]
+ * Last changed in libpng 1.5.15 [March 28, 2013]
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
diff --git a/pngrtran.c b/pngrtran.c
index bca3b68..6a46441 100644
--- a/pngrtran.c
+++ b/pngrtran.c
@@ -1,7 +1,7 @@
 
 /* pngrtran.c - transforms the data in a row for PNG readers
  *
- * Last changed in libpng 1.5.15 [(PENDING RELEASE)]
+ * Last changed in libpng 1.5.15 [March 28, 2013]
  * Copyright (c) 1998-2013 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.)
@@ -194,6 +194,8 @@
        */
 #     ifdef PNG_READ_sRGB_SUPPORTED
          png_ptr->flags |= PNG_FLAG_ASSUME_sRGB;
+#     else
+         PNG_UNUSED(png_ptr)
 #     endif
       if (is_screen)
          output_gamma = PNG_GAMMA_sRGB;
diff --git a/pngrutil.c b/pngrutil.c
index 5ee452d..844c6d8 100644
--- a/pngrutil.c
+++ b/pngrutil.c
@@ -1,7 +1,7 @@
 
 /* pngrutil.c - utilities to read a PNG file
  *
- * Last changed in libpng 1.5.14 [January 24, 2013]
+ * Last changed in libpng 1.5.15 [March 28, 2013]
  * Copyright (c) 1998-2013 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.)
@@ -18,8 +18,6 @@
 
 #ifdef PNG_READ_SUPPORTED
 
-#define png_strtod(p,a,b) strtod(a,b)
-
 png_uint_32 PNGAPI
 png_get_uint_31(png_structp png_ptr, png_const_bytep buf)
 {
@@ -3161,7 +3159,7 @@
                   {
                      png_uint_32p dp32 = (png_uint_32p)dp;
                      png_const_uint_32p sp32 = (png_const_uint_32p)sp;
-                     unsigned int skip = (bytes_to_jump-bytes_to_copy) /
+                     size_t skip = (bytes_to_jump-bytes_to_copy) /
                         sizeof (png_uint_32);
 
                      do
@@ -3202,7 +3200,7 @@
                   {
                      png_uint_16p dp16 = (png_uint_16p)dp;
                      png_const_uint_16p sp16 = (png_const_uint_16p)sp;
-                     unsigned int skip = (bytes_to_jump-bytes_to_copy) /
+                     size_t skip = (bytes_to_jump-bytes_to_copy) /
                         sizeof (png_uint_16);
 
                      do
diff --git a/pngset.c b/pngset.c
index 9fe476e..6e9358b 100644
--- a/pngset.c
+++ b/pngset.c
@@ -1,7 +1,7 @@
 
 /* pngset.c - storage of image information into info struct
  *
- * Last changed in libpng 1.5.15 [(PENDING RELEASE)]
+ * Last changed in libpng 1.5.14 [January 24, 2013]
  * Copyright (c) 1998-2013 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.)
diff --git a/pngstruct.h b/pngstruct.h
index 684e630..21911de 100644
--- a/pngstruct.h
+++ b/pngstruct.h
@@ -5,7 +5,7 @@
  * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
  * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
  *
- * Last changed in libpng 1.5.15 [(PENDING RELEASE)]
+ * Last changed in libpng 1.5.15 [March 28, 2013]
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
@@ -355,5 +355,10 @@
 /* New member added in libpng-1.5.7 */
    void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info,
       png_bytep row, png_const_bytep prev_row);
+
+   /* Options */
+#ifdef PNG_SET_OPTION_SUPPORTED
+   png_byte options;           /* On/off state (up to 4 options) */
+#endif
 };
 #endif /* PNGSTRUCT_H */
diff --git a/pngtest.c b/pngtest.c
index 8625dea..4c445d6 100644
--- a/pngtest.c
+++ b/pngtest.c
@@ -1,7 +1,7 @@
 
 /* pngtest.c - a simple test program to test libpng
  *
- * Last changed in libpng 1.5.15 [(PENDING RELEASE)]
+ * Last changed in libpng 1.5.15 [March 28, 2013]
  * Copyright (c) 1998-2013 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.)
@@ -43,7 +43,20 @@
 
 #include "png.h"
 
-#ifdef PNG_READ_SUPPORTED /* else nothing can be done */
+#if defined PNG_READ_SUPPORTED && /* else nothing can be done */\
+   defined PNG_READ_bKGD_SUPPORTED &&\
+   defined PNG_READ_cHRM_SUPPORTED &&\
+   defined PNG_READ_gAMA_SUPPORTED &&\
+   defined PNG_READ_oFFs_SUPPORTED &&\
+   defined PNG_READ_pCAL_SUPPORTED &&\
+   defined PNG_READ_pHYs_SUPPORTED &&\
+   defined PNG_READ_sBIT_SUPPORTED &&\
+   defined PNG_READ_sCAL_SUPPORTED &&\
+   defined PNG_READ_sRGB_SUPPORTED &&\
+   defined PNG_READ_tEXt_SUPPORTED &&\
+   defined PNG_READ_tIME_SUPPORTED &&\
+   defined PNG_READ_zTXt_SUPPORTED
+
 #include "zlib.h"
 /* Copied from pngpriv.h but only used in error messages below. */
 #ifndef PNG_ZBUF_SIZE
@@ -1949,4 +1962,4 @@
 #endif
 
 /* Generate a compiler error if there is an old png.h in the search path. */
-typedef png_libpng_version_1_5_15beta06 Your_png_h_is_not_version_1_5_15beta06;
+typedef png_libpng_version_1_5_16beta06 Your_png_h_is_not_version_1_5_16beta06;
diff --git a/pngwrite.c b/pngwrite.c
index 402e4fc..680878d 100644
--- a/pngwrite.c
+++ b/pngwrite.c
@@ -1,7 +1,7 @@
 
 /* pngwrite.c - general routines to write a PNG file
  *
- * Last changed in libpng 1.5.15 [(PENDING RELEASE)]
+ * Last changed in libpng 1.5.15 [March 28, 2013]
  * Copyright (c) 1998-2013 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.)
diff --git a/projects/vstudio/readme.txt b/projects/vstudio/readme.txt
index a99ab37..537fbcd 100644
--- a/projects/vstudio/readme.txt
+++ b/projects/vstudio/readme.txt
@@ -1,7 +1,7 @@
 
 VisualStudio instructions
 
-libpng version 1.5.15beta06 - February 22, 2013
+libpng version 1.5.16beta06 - May 12, 2013
 
 Copyright (c) 1998-2010 Glenn Randers-Pehrson
 
diff --git a/projects/vstudio/zlib.props b/projects/vstudio/zlib.props
index a048f2e..9547c51 100644
--- a/projects/vstudio/zlib.props
+++ b/projects/vstudio/zlib.props
@@ -2,7 +2,7 @@
 <!--
  * zlib.props - location of zlib source
  *
- * libpng version 1.5.15beta06 - February 22, 2013
+ * libpng version 1.5.16beta06 - May 12, 2013
  *
  * Copyright (c) 1998-2011 Glenn Randers-Pehrson
  *
diff --git a/scripts/README.txt b/scripts/README.txt
index 914f6ad..7476a73 100644
--- a/scripts/README.txt
+++ b/scripts/README.txt
@@ -1,9 +1,9 @@
 
-Makefiles for  libpng version 1.5.15beta06 - February 22, 2013
+Makefiles for  libpng version 1.5.16beta06 - May 12, 2013
 
 pnglibconf.h.prebuilt       =>  Stores configuration settings
  makefile.linux    =>  Linux/ELF makefile
-                       (gcc, creates libpng15.so.15.1.5.15beta06)
+                       (gcc, creates libpng15.so.15.1.5.16beta06)
  makefile.gcc      =>  Generic makefile (gcc, creates static libpng.a)
  makefile.knr      =>  Archaic UNIX Makefile that converts files with
                        ansi2knr (Requires ansi2knr.c from
@@ -21,7 +21,7 @@
  makefile.dec      =>  DEC Alpha UNIX makefile
  makefile.dj2      =>  DJGPP 2 makefile
  makefile.elf      =>  Linux/ELF makefile symbol versioning,
-                       (gcc, creates libpng15.so.15.1.5.15beta06)
+                       (gcc, creates libpng15.so.15.1.5.16beta06)
  makefile.freebsd  =>  FreeBSD makefile
  makefile.gcc      =>  Generic gcc makefile
  makefile.hpgcc    =>  HPUX makefile using gcc
@@ -36,12 +36,12 @@
  makefile.os2      =>  OS/2 Makefile (gcc and emx, requires libpng.def)
  makefile.sco      =>  For SCO OSr5  ELF and Unixware 7 with Native cc
  makefile.sggcc    =>  Silicon Graphics (gcc,
-                       creates libpng15.so.15.1.5.15beta06)
+                       creates libpng15.so.15.1.5.16beta06)
  makefile.sgi      =>  Silicon Graphics IRIX makefile (cc, creates static lib)
  makefile.solaris  =>  Solaris 2.X makefile (gcc,
-                       creates libpng15.so.15.1.5.15beta06)
+                       creates libpng15.so.15.1.5.16beta06)
  makefile.so9      =>  Solaris 9 makefile (gcc,
-                       creates libpng15.so.15.1.5.15beta06)
+                       creates libpng15.so.15.1.5.16beta06)
  makefile.std      =>  Generic UNIX makefile (cc, creates static libpng.a)
  makefile.sunos    =>  Sun makefile
  makefile.32sunu   =>  Sun Ultra 32-bit makefile
diff --git a/scripts/checksym.awk b/scripts/checksym.awk
index ba4c99b..fe3af55 100755
--- a/scripts/checksym.awk
+++ b/scripts/checksym.awk
@@ -5,8 +5,9 @@
 # awk -f checksym.awk official-def list-to-check
 #
 # Output is a file in the current directory called 'symbols.new',
-# stdout holds error messages.  Error code indicates success or
-# failure.
+# the value of the awk variable "of" (which can be changed on the
+# command line if required.)  stdout holds error messages.  Error
+# code indicates success or failure.
 #
 # NOTE: this is a pure, old fashioned, awk script.  It will
 # work with any awk
@@ -21,6 +22,7 @@
    mastero = 0      # highest ordinal in master file
    symbolo = 0      # highest ordinal in png.h
    missing = "error"# log an error on missing symbols
+   of="symbols.new" # default to a fixed name
 }
 
 # Read existing definitions from the master file (the first
@@ -111,6 +113,16 @@
       err = 1
    }
    unexported=0
+   # Add a standard header to symbols.new:
+   print ";Version INSERT-VERSION-HERE" >of
+   print ";--------------------------------------------------------------" >of
+   print "; LIBPNG symbol list as a Win32 DEF file" >of
+   print "; Contains all the symbols that can be exported from libpng" >of
+   print ";--------------------------------------------------------------" >of
+   print "LIBRARY" >of
+   print "" >of
+   print "EXPORTS" >of
+
    for (o=1; o<=lasto; ++o) {
       if (symbol[o] == "" && removed[o] == "") {
          if (unexported == 0) unexported = o
@@ -151,11 +163,11 @@
 
       # Finally generate symbols.new
       if (symbol[o] != "")
-         print " " symbol[o], "@" o > "symbols.new"
+         print " " symbol[o], "@" o > of
    }
 
    if (err != 0) {
-      print "*** A new list is in symbols.new ***"
+      print "*** A new list is in", of, "***"
       exit 1
    }
 }
diff --git a/scripts/dfn.awk b/scripts/dfn.awk
index 8a5dab6..89b92d5 100644
--- a/scripts/dfn.awk
+++ b/scripts/dfn.awk
Binary files differ
diff --git a/scripts/libpng-config-head.in b/scripts/libpng-config-head.in
index 34a07e2..8335c2e 100755
--- a/scripts/libpng-config-head.in
+++ b/scripts/libpng-config-head.in
@@ -11,7 +11,7 @@
 
 # Modeled after libxml-config.
 
-version=1.5.15beta06
+version=1.5.16beta06
 prefix=""
 libdir=""
 libs=""
diff --git a/scripts/libpng.pc.in b/scripts/libpng.pc.in
index 4260ca8..d5fa420 100644
--- a/scripts/libpng.pc.in
+++ b/scripts/libpng.pc.in
@@ -5,6 +5,6 @@
 
 Name: libpng
 Description: Loads and saves PNG files
-Version: 1.5.15beta06
+Version: 1.5.16beta06
 Libs: -L${libdir} -lpng15
 Cflags: -I${includedir}
diff --git a/scripts/makefile.cegcc b/scripts/makefile.cegcc
index f36fcbc..2c71e75 100644
--- a/scripts/makefile.cegcc
+++ b/scripts/makefile.cegcc
@@ -23,7 +23,7 @@
 
 VERMAJ = 1
 VERMIN = 5
-VERMIC = 15
+VERMIC = 16
 VER = $(VERMAJ).$(VERMIN).$(VERMIC)
 NAME = libpng
 PACKAGE = $(NAME)-$(VER)
diff --git a/scripts/makefile.freebsd b/scripts/makefile.freebsd
index 38cd921..0eb1eee 100644
--- a/scripts/makefile.freebsd
+++ b/scripts/makefile.freebsd
@@ -26,19 +26,24 @@
 		libpng/pngconf.h ${INCSDIR}/../pngconf.h \
 		libpng/pnglibconf.h ${INCSDIR}/../pnglibconf.h
 
-LDADD+=         -lm -lz
-#LDADD+=         -lm -lz -lssp_nonshared   # for OSVERSION >= 800000 ?
+# where make install finds libz.a and zlib.h
+ZLIBLIB=	/usr/lib
+ZLIBINC=	/usr/include
+
+LDADD+=        -lm -lz
+#LDADD+=       -lm -lz -lssp_nonshared   # for OSVERSION < 800000 ?
 
 DPADD+=         ${LIBM} ${LIBZ}
 
-CFLAGS+= -I.
+CFLAGS+= -I. -I${ZLIBINC}
 
 SRCS=	png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
 	pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
 	pngwtran.c pngmem.c pngerror.c pngpread.c
 
 pngtest: pngtest.o libpng.a
-	${CC} ${CFLAGS} -L. -static -o pngtest pngtest.o -lpng -lz -lm
+	${CC} ${CFLAGS} -L. -static -o pngtest pngtest.o -L${ZLIBLIB} \
+	-lpng ${LDADD}
 
 CLEANFILES= pngtest pngtest.o pngout.png
 
diff --git a/scripts/makefile.linux b/scripts/makefile.linux
index 56fbab8..b216448 100644
--- a/scripts/makefile.linux
+++ b/scripts/makefile.linux
@@ -10,7 +10,7 @@
 # Library name:
 LIBNAME = libpng15
 PNGMAJ = 15
-RELEASE = 15
+RELEASE = 16
 
 # Shared library names:
 LIBSO=$(LIBNAME).so
diff --git a/scripts/makefile.msys b/scripts/makefile.msys
index eeb88d4..960555f 100644
--- a/scripts/makefile.msys
+++ b/scripts/makefile.msys
@@ -18,7 +18,7 @@
 # Library name:
 LIBNAME = libpng15
 PNGMAJ = 15
-RELEASE = 15
+RELEASE = 16
 
 # Shared library names:
 LIBSO=$(LIBNAME).dll
diff --git a/scripts/makefile.ne12bsd b/scripts/makefile.ne12bsd
index 70bc04b..4f5a4fe 100644
--- a/scripts/makefile.ne12bsd
+++ b/scripts/makefile.ne12bsd
@@ -17,7 +17,7 @@
 
 LIB=	png15
 SHLIB_MAJOR=	0
-SHLIB_MINOR=	1.5.15beta06
+SHLIB_MINOR=	1.5.16beta06
 SRCS=	png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
 	pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
 	pngwtran.c pngmem.c pngerror.c pngpread.c
diff --git a/scripts/makefile.netbsd b/scripts/makefile.netbsd
index d91d8f3..f3c6cbf 100644
--- a/scripts/makefile.netbsd
+++ b/scripts/makefile.netbsd
@@ -17,7 +17,7 @@
 
 LIB=	png
 SHLIB_MAJOR=	15
-SHLIB_MINOR=	1.5.15beta06
+SHLIB_MINOR=	1.5.16beta06
 SRCS=	png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
 	pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
 	pngwtran.c pngmem.c pngerror.c pngpread.c
diff --git a/scripts/makefile.openbsd b/scripts/makefile.openbsd
index aa8ca96..44ee2b4 100644
--- a/scripts/makefile.openbsd
+++ b/scripts/makefile.openbsd
@@ -11,7 +11,7 @@
 MANDIR= ${PREFIX}/man/cat
 
 SHLIB_MAJOR=	15
-SHLIB_MINOR=	1.5.15beta06
+SHLIB_MINOR=	1.5.16beta06
 
 LIB=	png
 SRCS=	png.c pngerror.c pngget.c pngmem.c pngpread.c \
diff --git a/scripts/options.awk b/scripts/options.awk
index 4b8a419..c3a8501 100755
--- a/scripts/options.awk
+++ b/scripts/options.awk
@@ -53,7 +53,7 @@
    comment=start "/*"           # Comment start
    cend="*/" end                # Comment end
    def=start "#define PNG_"     # Arbitrary define
-   sup="_SUPPORTED 1" end       # end supported option
+   sup="_SUPPORTED" end         # end supported option
    und=comment "#undef PNG_"    # Unsupported option
    une="_SUPPORTED" cend        # end unsupported option
    error=start "ERROR:"         # error message, terminate with 'end'
@@ -64,11 +64,15 @@
    logunsupported=0             # write unsupported options too
 
    # Precreate arrays
+   # for each option:
    option[""] = ""    # list of all options: default enabled/disabled
    done[""] = 1       # marks option as having been output
    requires[""] = ""  # requires by option
    iffs[""] = ""      # if by option
    enabledby[""] = "" # options that enable it by option
+   sets[""] = ""      # settings set by each option
+   setval[""] = ""    # value to set (indexed: 'option sets[option]')
+   # for each setting:
    setting[""] = ""   # requires by setting
    defaults[""] = ""  # used for a defaulted value
    doneset[""] = 1    # marks setting as having been output
@@ -200,7 +204,7 @@
    if (NF > 1) {
       # sub(/^[ 	]*com[ 	]*/, "")
       $1 = ""
-      print comment, $0, cend >out
+      print comment $0, cend >out
    } else
       print start end >out
    next
@@ -237,7 +241,9 @@
    next
 }
 
-# option NAME ( (requires|enables|if) NAME* | on | off | disabled )*
+# option NAME ( (requires|enables|if) NAME* | on | off | disabled |
+#                sets SETTING VALUE+ )*
+#     
 #   Declares an option 'NAME' and describes its default setting (disabled)
 #   and its relationship to other options.  The option is disabled
 #   unless *all* the options listed after 'requires' are set and at
@@ -252,95 +258,152 @@
 #   be later) entry may turn an option on or off explicitly.
 
 $1 == "option" && NF >= 2{
-   onoff = option[$2]  # records current (and the default is "", enabled)
+   opt = $2
+   sub(/,$/,"",opt)
+   onoff = option[opt]  # records current (and the default is "", enabled)
    key = ""
-   for (i=3; i<=NF; ++i) {
-      if ($(i) == "on" || $(i) == "off" || $(i) == "disabled") {
-         key = ""
-         if (onoff != $(i)) {
-            # on or off can zap disabled or enabled:
-            if (onoff == "" || (onoff == "disabled" || onoff == "enabled") && ($(i) == "on" || $(i) == "off")) {
-               # It's easy to mis-spell the option when turning it
-               # on or off, so warn about it here:
-               if (onoff == "" && ($(i) == "on" || $(i) == "off")) {
-                  print $2 ": ERROR: turning unrecognized option", $(i)
-                  # For the moment error out - it is safer
-                  err = 1 # prevent END{} running
-                  exit 1
-               }
-               onoff = $(i)
-            } else {
-               # Print a message, otherwise the error
-               # below is incomprehensible
-               print $2 ": currently", onoff ": attempt to turn", $(i)
-               break
-            }
+   istart = 3
+   do {
+      if (istart == 1) {     # continuation line
+         val = getline
+
+         if (val != 1) { # error reading it
+            if (val == 0)
+               print "option", opt ": ERROR: missing contination line"
+            else
+               print "option", opt ": ERROR: error reading continuation line"
+
+            # This is a hard error
+            err = 1 # prevent END{} running
+            exit 1
          }
-      } else if ($(i) == "requires" || $(i) == "if" || $(i) == "enables") {
-         key = $(i)
-      } else if (key == "requires") {
-         requires[$2] = requires[$2] " " $(i)
-      } else if (key == "if") {
-         iffs[$2] = iffs[$2] " " $(i)
-      } else if (key == "enables") {
-         enabledby[$(i)] = enabledby[$(i)] " " $2
-      } else
-         break # bad line format
-   }
+      }
+
+      for (i=istart; i<=NF; ++i) {
+         val=$(i)
+         sub(/,$/,"",val)
+         if (val == "on" || val == "off" || val == "disabled") {
+            key = ""
+            if (onoff != val) {
+               # on or off can zap disabled or enabled:
+               if (onoff == "" || (onoff == "disabled" || onoff == "enabled") &&
+                   (val == "on" || val == "off")) {
+                  # It's easy to mis-spell the option when turning it
+                  # on or off, so warn about it here:
+                  if (onoff == "" && (val == "on" || val == "off")) {
+                     print "option", opt ": ERROR: turning unrecognized option", val
+                     # For the moment error out - it is safer
+                     err = 1 # prevent END{} running
+                     exit 1
+                  }
+                  onoff = val
+               } else {
+                  # Print a message, otherwise the error
+                  # below is incomprehensible
+                  print "option", opt ": currently", onoff ": attempt to turn", val
+                  break
+               }
+            }
+         } else if (val == "requires" || val == "if" || val == "enables" || val =="sets") {
+            key = val
+         } else if (key == "requires") {
+            requires[opt] = requires[opt] " " val
+         } else if (key == "if") {
+            iffs[opt] = iffs[opt] " " val
+         } else if (key == "enables") {
+            enabledby[val] = enabledby[val] " " opt
+         } else if (key == "sets") {
+            sets[opt] = sets[opt] " " val
+            key = "setval"
+            set = val
+         } else if (key == "setval") {
+            setval[opt " " set] = setval[opt " " set] " " val
+         } else
+            break # bad line format
+      }
+
+      istart = 1
+   } while (i > NF && $0 ~ /,$/)
 
    if (i > NF) {
       # Set the option, defaulting to 'enabled'
       if (onoff == "") onoff = "enabled"
-      option[$2] = onoff
+      option[opt] = onoff
       next
    }
    # Else fall through to the error handler
 }
 
-# chunk NAME [requires OPT] [on|off|disabled]
+# chunk NAME [requires OPT] [enables LIST] [on|off|disabled]
 #   Expands to the 'option' settings appropriate to the reading and
 #   writing of an ancilliary PNG chunk 'NAME':
 #
 #   option READ_NAME requires READ_ANCILLARY_CHUNKS [READ_OPT]
-#   option READ_NAME enables NAME
+#   option READ_NAME enables NAME LIST
 #   [option READ_NAME off]
 #   option WRITE_NAME requires WRITE_ANCILLARY_CHUNKS [WRITE_OPT]
-#   option WRITE_NAME enables NAME
+#   option WRITE_NAME enables NAME LIST
 #   [option WRITE_NAME off]
 
 pre != 0 && $1 == "chunk" && NF >= 2{
    # 'chunk' is handled on the first pass by writing appropriate
    # 'option' lines into the intermediate file.
+   opt = $2
+   sub(/,$/,"",opt)
    onoff = ""
    reqread = ""
    reqwrite = ""
-   i = 3 # indicates format error
-   if (NF > 2) {
+   enables = ""
+   req = 0
+   istart = 3
+   do {
+      if (istart == 1) {     # continuation line
+         val = getline
+
+         if (val != 1) { # error reading it
+            if (val == 0)
+               print "chunk", opt ": ERROR: missing contination line"
+            else
+               print "chunk", opt ": ERROR: error reading continuation line"
+
+            # This is a hard error
+            err = 1 # prevent END{} running
+            exit 1
+         }
+      }
+
       # read the keywords/additional OPTS
-      req = 0
-      for (i=3; i<=NF; ++i) {
-         if ($(i) == "on" || $(i) == "off" || $(i) == "disabled") {
-            if (onoff != $(i)) {
+      for (i=istart; i<=NF; ++i) {
+         val = $(i)
+         sub(/,$/,"",val)
+         if (val == "on" || val == "off" || val == "disabled") {
+            if (onoff != val) {
                if (onoff == "")
-                  onoff = $(i)
+                  onoff = val
                else
                   break # on/off conflict
             }
-         } else if ($(i) == "requires")
+            req = 0
+         } else if (val == "requires")
             req = 1
-         else if (req != 1)
+         else if (val == "enables")
+            req = 2
+         else if (req == 1){
+            reqread = reqread " READ_" val
+            reqwrite = reqwrite " WRITE_" val
+         } else if (req == 2)
+            enables = enables " " val
+         else
             break # bad line: handled below
-         else {
-            reqread = reqread " READ_" $(i)
-            reqwrite = reqwrite " WRITE_" $(i)
-         }
       }
-   }
+
+      istart = 1
+   } while (i > NF && $0 ~ /,$/)
 
    if (i > NF) {
       # Output new 'option' lines to the intermediate file (out)
-      print "option READ_" $2, "requires READ_ANCILLARY_CHUNKS" reqread, "enables", $2, onoff >out
-      print "option WRITE_" $2, "requires WRITE_ANCILLARY_CHUNKS" reqwrite, "enables", $2, onoff >out
+      print "option READ_" opt, "requires READ_ANCILLARY_CHUNKS" reqread, "enables", opt enables , onoff >out
+      print "option WRITE_" opt, "requires WRITE_ANCILLARY_CHUNKS" reqwrite, "enables", opt enables, onoff >out
       next
    }
    # Else hit the error handler below - bad line format!
@@ -471,83 +534,7 @@
       exit 0
    }
 
-   # Do the 'setting' values first, the algorithm the standard
-   # tree walk (O(1)) done in an O(2) while/for loop; interations
-   # settings x depth, outputing the deepest required macros
-   # first.
-   print "" >out
-   print "/* SETTINGS */" >out
-   print comment, "settings", cend >out
-   # Sort (in dfn.awk) on field 2, the setting name
-   print "PNG_DFN_START_SORT 2" >out
-   finished = 0
-   while (!finished) {
-      finished = 1
-      movement = 0 # done nothing
-      for (i in setting) if (!doneset[i]) {
-         nreqs = split(setting[i], r)
-         if (nreqs > 0) {
-            for (j=1; j<=nreqs; ++j) if (!doneset[r[j]]) {
-               break
-            }
-            if (j<=nreqs) {
-               finished = 0
-               continue # try a different setting
-            }
-         }
-
-         # All the requirements have been processed, output
-         # this setting.
-         if (deb) print "setting", i
-         deflt = defaults[i]
-         # A leading @ means leave it unquoted so the preprocessor
-         # can substitute the build time value
-         if (deflt ~ /^ @/)
-            deflt = " " subs substr(deflt, 3) sube
-         # Remove any spurious trailing spaces
-         sub(/ *$/,"",deflt)
-         print "" >out
-         print "/* setting: ", i >out
-         print " *   requires:" setting[i] >out
-         print " *   default: ", defaults[i] defltinfo, "*/" >out
-         if (defaults[i] == "") { # no default, only check if defined
-            print "#ifdef PNG_" i >out
-         }
-         for (j=1; j<=nreqs; ++j) {
-            print "# ifndef PNG_" r[j] >out
-            print error, i, "requires", r[j] end >out
-            print "# endif" >out
-         }
-         if (defaults[i] != "") { # default handling
-            print "#ifdef PNG_" i >out
-         }
-         # PNG_<i> is defined, so substitute the value:
-         print def i, subs "PNG_" i sube end >out
-         if (defaults[i] != "") {
-            print "#else /*default*/" >out
-            # And add the default definition for the benefit
-            # of later settings an options test:
-            print "# define PNG_" i deflt >out
-            print def i deflt end >out
-         }
-         print "#endif" >out
-
-         doneset[i] = 1
-         ++movement
-      }
-
-      if (!finished && !movement) {
-         print "setting: loop or missing setting in 'requires', cannot process:"
-         for (i in setting) if (!doneset[i]) {
-            print "  setting", i, "requires" setting[i]
-         }
-         exit 1
-      }
-   }
-   print "PNG_DFN_END_SORT" >out
-   print comment, "end of settings", cend >out
-
-   # Now do the options - somewhat more complex.  The dependency
+   # Do the options first (allowing options to set settings).  The dependency
    # tree is thus:
    #
    #   name     >     name
@@ -639,7 +626,7 @@
    }
    if (err) exit 1
 
-   # Sort options too
+   # Sort options:
    print "PNG_DFN_START_SORT 2" >out
 
    # option[i] is now the complete list of all the tokens we may
@@ -679,8 +666,9 @@
          print "" >out
          print "/* option:", i, option[i] >out
          print " *   requires:  " requires[i] >out
-         print " *   if:      " iffs[i] >out
-         print " *   enabled-by:" enabledby[i], "*/" >out
+         print " *   if:        " iffs[i] >out
+         print " *   enabled-by:" enabledby[i] >out
+         print " *   sets:      " sets[i], "*/" >out
          print "#undef PNG_on" >out
          print "#define PNG_on 1" >out
 
@@ -763,6 +751,21 @@
             print error, i, "is on: enabled by:" iffs[i] enabledby[i] ", requires" requires[i] end >out
          } else if (i !~ /^ok_/) {
             print def i sup >out
+            # Supported option, set required settings
+            nreqs = split(sets[i], r)
+            for (j=1; j<=nreqs; ++j) {
+               print "#    ifdef PNG_set_" r[j] >out
+               # Some other option has already set a value:
+               print error, i, "sets", r[j] ": duplicate setting" end >out
+               print error, "   previous value: " end "PNG_set_" r[j] >out
+               print "#    else" >out
+               # Else set the default: note that this won't accept arbitrary
+               # values, the setval string must be acceptable to all the C
+               # compilers we use.  That means it must be VERY simple; a number,
+               # a name or a string.
+               print "#     define PNG_set_" r[j], setval[i " " r[j]] >out
+               print "#    endif" >out
+            }
          }
          print "#   endif /* definition */" >out
          print "#endif /*requires, if*/" >out
@@ -796,6 +799,93 @@
    print "PNG_DFN_END_SORT" >out
    print comment, "end of options", cend >out
 
+   # Do the 'setting' values second, the algorithm the standard
+   # tree walk (O(1)) done in an O(2) while/for loop; interations
+   # settings x depth, outputing the deepest required macros
+   # first.
+   print "" >out
+   print "/* SETTINGS */" >out
+   print comment, "settings", cend >out
+   # Sort (in dfn.awk) on field 2, the setting name
+   print "PNG_DFN_START_SORT 2" >out
+   finished = 0
+   while (!finished) {
+      finished = 1
+      movement = 0 # done nothing
+      for (i in setting) if (!doneset[i]) {
+         nreqs = split(setting[i], r)
+         if (nreqs > 0) {
+            # By default assume the requires values are options, but if there
+            # is no option with that name check for a setting
+            for (j=1; j<=nreqs; ++j) if (option[r[j]] == "" && !doneset[r[j]]) {
+               break
+            }
+            if (j<=nreqs) {
+               finished = 0
+               continue # try a different setting
+            }
+         }
+
+         # All the requirements have been processed, output
+         # this setting.
+         if (deb) print "setting", i
+         deflt = defaults[i]
+         # Remove any spurious trailing spaces
+         sub(/ *$/,"",deflt)
+         # A leading @ means leave it unquoted so the preprocessor
+         # can substitute the build time value
+         if (deflt ~ /^ @/)
+            deflt = " " subs substr(deflt, 3) sube
+         print "" >out
+         print "/* setting: ", i >out
+         print " *   requires:" setting[i] >out
+         print " *   default: ", defaults[i] deflt, "*/" >out
+         for (j=1; j<=nreqs; ++j) {
+            if (option[r[j]] != "")
+               print "#ifndef PNG_" r[j] "_SUPPORTED" >out
+            else
+               print "#ifndef PNG_" r[j] >out
+            print error, i, "requires", r[j] end >out
+            print "# endif" >out
+         }
+         # The precedence is:
+         #
+         #  1) External definition; trumps:
+         #  2) Option 'sets' value; trumps:
+         #  3) Setting 'default'
+         #
+         print "#ifdef PNG_" i >out
+         # PNG_<i> is defined, so substitute the value:
+         print def i, subs "PNG_" i sube end >out
+         print "#else /* use default */" >out
+         print "# ifdef PNG_set_" i >out
+         # Value from an option 'sets' argument
+         print def i, subs "PNG_set_" i sube end >out
+         # This is so that subsequent tests on the setting work:
+         print "#  define PNG_" i, "1" >out
+         if (defaults[i] != "") {
+            print "# else /*default*/" >out
+            print def i deflt end >out
+            print "#  define PNG_" i, "1" >out
+         }
+         print "# endif /* defaults */" >out
+         print "#endif /* setting", i, "*/" >out
+
+         doneset[i] = 1
+         ++movement
+      }
+
+      if (!finished && !movement) {
+         print "setting: loop or missing setting in 'requires', cannot process:"
+         for (i in setting) if (!doneset[i]) {
+            print "  setting", i, "requires" setting[i]
+         }
+         exit 1
+      }
+   }
+   print "PNG_DFN_END_SORT" >out
+   print comment, "end of settings", cend >out
+
    # Regular end - everything looks ok
    if (protect != "") {
       print start "#endif", "/*", protect, "*/" end >out
diff --git a/scripts/pnglibconf.dfa b/scripts/pnglibconf.dfa
index 62764e0..dd6331f 100644
--- a/scripts/pnglibconf.dfa
+++ b/scripts/pnglibconf.dfa
@@ -27,7 +27,7 @@
 # The syntax is detailed in scripts/options.awk, this is a summary
 # only:
 #
-# setting <name> [default]
+# setting <name> [requires ...] [default]
 #    #define PNG_<name> <value>  /* value comes from current setting */
 # option <name> [requires ...] [if ...] [enables ...] [disabled]
 #    #define PNG_<name>_SUPPORTED if the requirements are met and
@@ -191,12 +191,23 @@
 
 setting FILTER_OPTIMIZATIONS
 
-# This option turns on runtime checks for ARM NEON support, it is irrelevant
-# on other platforms and it is irrelevant unless NEON code is turned on.  Checks
-# are on by default
-
-option ARM_NEON_CHECK
-
+# Implementation specific control of the optimizations, enabled by those
+# hardware or software options that need it (typically when run-time choices
+# must be made by the user)
+option SET_OPTION disabled
+ 
+# These options are specific to the ARM NEON hardware optimizations:
+#
+# ARM_NEON: the optimization itself
+# ARM_NEON_API: allow the optimization to be switched on with png_set_hardware
+# ARM_NEON_CHECK: compile a run-time check to see if Neon extensions are
+#                 supported, this is poorly supported and deprectated - use the
+#                 png_set_hardware API.
+option ARM_NEON disabled,
+   sets FILTER_OPTIMIZATIONS png_init_filter_functions_neon
+option ARM_NEON_API disabled enables SET_OPTION ARM_NEON
+option ARM_NEON_CHECK disabled enables ARM_NEON
+ 
 # Generic options - affect both read and write.
 
 option WARNINGS
@@ -369,6 +380,12 @@
 
 option BUILD_GRAYSCALE_PALETTE
 
+# This changes the default for the ARM NEON optimizations according to
+# __ARM_NEON__
+@#ifdef __ARM_NEON__
+@#  define PNG_ARM_NEON_SUPPORTED
+@#endif
+
 # IN DEVELOPMENT
 # These are currently experimental features; define them if you want
 
diff --git a/scripts/pnglibconf.h.prebuilt b/scripts/pnglibconf.h.prebuilt
index 800143f..9f562e7 100644
--- a/scripts/pnglibconf.h.prebuilt
+++ b/scripts/pnglibconf.h.prebuilt
@@ -1,25 +1,176 @@
-
-/* libpng STANDARD API DEFINITION */
-
+/* 1.5.16beta06 STANDARD API DEFINITION */
 /* pnglibconf.h - library build configuration */
 
-/* Libpng 1.5.15beta06 - February 22, 2013 */
+/* libpng version 1.5.16beta06 - May 12, 2013 */
 
-/* Copyright (c) 1998-2012 Glenn Randers-Pehrson */
+/* Copyright (c) 1998-2013 Glenn Randers-Pehrson */
 
 /* This code is released under the libpng license. */
 /* For conditions of distribution and use, see the disclaimer */
 /* and license in png.h */
 
 /* pnglibconf.h */
+/* Machine generated file: DO NOT EDIT */
 /* Derived from: scripts/pnglibconf.dfa */
-/* If you edit this file by hand you must obey the rules expressed in */
-/* pnglibconf.dfa with respect to the dependencies between the following */
-/* symbols.  It is much better to generate a new file using */
-/* scripts/libpngconf.mak */
-
 #ifndef PNGLCONF_H
 #define PNGLCONF_H
+/* options */
+#define PNG_16BIT_SUPPORTED
+#define PNG_ALIGNED_MEMORY_SUPPORTED
+/*#undef PNG_ARM_NEON_API_SUPPORTED*/
+/*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/
+/*#undef PNG_ARM_NEON_SUPPORTED*/
+#define PNG_BENIGN_ERRORS_SUPPORTED
+#define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED
+#define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
+#define PNG_CHECK_cHRM_SUPPORTED
+#define PNG_CONSOLE_IO_SUPPORTED
+#define PNG_CONVERT_tIME_SUPPORTED
+#define PNG_EASY_ACCESS_SUPPORTED
+/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/
+#define PNG_ERROR_TEXT_SUPPORTED
+#define PNG_FIXED_POINT_SUPPORTED
+#define PNG_FLOATING_ARITHMETIC_SUPPORTED
+#define PNG_FLOATING_POINT_SUPPORTED
+#define PNG_GET_PALETTE_MAX_SUPPORTED
+#define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
+#define PNG_INCH_CONVERSIONS_SUPPORTED
+#define PNG_INFO_IMAGE_SUPPORTED
+#define PNG_IO_STATE_SUPPORTED
+#define PNG_MNG_FEATURES_SUPPORTED
+#define PNG_POINTER_INDEXING_SUPPORTED
+#define PNG_PROGRESSIVE_READ_SUPPORTED
+#define PNG_READ_16BIT_SUPPORTED
+#define PNG_READ_ALPHA_MODE_SUPPORTED
+#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
+#define PNG_READ_BACKGROUND_SUPPORTED
+#define PNG_READ_BGR_SUPPORTED
+#define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
+#define PNG_READ_COMPOSITE_NODIV_SUPPORTED
+#define PNG_READ_COMPRESSED_TEXT_SUPPORTED
+#define PNG_READ_EXPAND_16_SUPPORTED
+#define PNG_READ_EXPAND_SUPPORTED
+#define PNG_READ_FILLER_SUPPORTED
+#define PNG_READ_GAMMA_SUPPORTED
+#define PNG_READ_GET_PALETTE_MAX_SUPPORTED
+#define PNG_READ_GRAY_TO_RGB_SUPPORTED
+#define PNG_READ_INTERLACING_SUPPORTED
+#define PNG_READ_INT_FUNCTIONS_SUPPORTED
+#define PNG_READ_INVERT_ALPHA_SUPPORTED
+#define PNG_READ_INVERT_SUPPORTED
+#define PNG_READ_OPT_PLTE_SUPPORTED
+#define PNG_READ_PACKSWAP_SUPPORTED
+#define PNG_READ_PACK_SUPPORTED
+#define PNG_READ_QUANTIZE_SUPPORTED
+#define PNG_READ_RGB_TO_GRAY_SUPPORTED
+#define PNG_READ_SCALE_16_TO_8_SUPPORTED
+#define PNG_READ_SHIFT_SUPPORTED
+#define PNG_READ_STRIP_16_TO_8_SUPPORTED
+#define PNG_READ_STRIP_ALPHA_SUPPORTED
+#define PNG_READ_SUPPORTED
+#define PNG_READ_SWAP_ALPHA_SUPPORTED
+#define PNG_READ_SWAP_SUPPORTED
+#define PNG_READ_TEXT_SUPPORTED
+#define PNG_READ_TRANSFORMS_SUPPORTED
+#define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
+#define PNG_READ_USER_CHUNKS_SUPPORTED
+#define PNG_READ_USER_TRANSFORM_SUPPORTED
+#define PNG_READ_bKGD_SUPPORTED
+#define PNG_READ_cHRM_SUPPORTED
+#define PNG_READ_gAMA_SUPPORTED
+#define PNG_READ_hIST_SUPPORTED
+#define PNG_READ_iCCP_SUPPORTED
+#define PNG_READ_iTXt_SUPPORTED
+#define PNG_READ_oFFs_SUPPORTED
+#define PNG_READ_pCAL_SUPPORTED
+#define PNG_READ_pHYs_SUPPORTED
+#define PNG_READ_sBIT_SUPPORTED
+#define PNG_READ_sCAL_SUPPORTED
+#define PNG_READ_sPLT_SUPPORTED
+#define PNG_READ_sRGB_SUPPORTED
+#define PNG_READ_tEXt_SUPPORTED
+#define PNG_READ_tIME_SUPPORTED
+#define PNG_READ_tRNS_SUPPORTED
+#define PNG_READ_zTXt_SUPPORTED
+/*#undef PNG_SAFE_LIMITS_SUPPORTED*/
+#define PNG_SAVE_INT_32_SUPPORTED
+#define PNG_SEQUENTIAL_READ_SUPPORTED
+#define PNG_SETJMP_SUPPORTED
+#define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED
+#define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
+/*#undef PNG_SET_OPTION_SUPPORTED*/
+#define PNG_SET_USER_LIMITS_SUPPORTED
+#define PNG_STDIO_SUPPORTED
+#define PNG_TEXT_SUPPORTED
+#define PNG_TIME_RFC1123_SUPPORTED
+#define PNG_UNKNOWN_CHUNKS_SUPPORTED
+#define PNG_USER_CHUNKS_SUPPORTED
+#define PNG_USER_LIMITS_SUPPORTED
+#define PNG_USER_MEM_SUPPORTED
+#define PNG_USER_TRANSFORM_INFO_SUPPORTED
+#define PNG_USER_TRANSFORM_PTR_SUPPORTED
+#define PNG_WARNINGS_SUPPORTED
+#define PNG_WRITE_16BIT_SUPPORTED
+#define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
+#define PNG_WRITE_BGR_SUPPORTED
+#define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
+#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
+#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
+#define PNG_WRITE_FILLER_SUPPORTED
+#define PNG_WRITE_FILTER_SUPPORTED
+#define PNG_WRITE_FLUSH_SUPPORTED
+#define PNG_WRITE_GET_PALETTE_MAX_SUPPORTED
+#define PNG_WRITE_INTERLACING_SUPPORTED
+#define PNG_WRITE_INT_FUNCTIONS_SUPPORTED
+#define PNG_WRITE_INVERT_ALPHA_SUPPORTED
+#define PNG_WRITE_INVERT_SUPPORTED
+#define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
+#define PNG_WRITE_PACKSWAP_SUPPORTED
+#define PNG_WRITE_PACK_SUPPORTED
+#define PNG_WRITE_SHIFT_SUPPORTED
+#define PNG_WRITE_SUPPORTED
+#define PNG_WRITE_SWAP_ALPHA_SUPPORTED
+#define PNG_WRITE_SWAP_SUPPORTED
+#define PNG_WRITE_TEXT_SUPPORTED
+#define PNG_WRITE_TRANSFORMS_SUPPORTED
+#define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
+#define PNG_WRITE_USER_TRANSFORM_SUPPORTED
+#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
+#define PNG_WRITE_bKGD_SUPPORTED
+#define PNG_WRITE_cHRM_SUPPORTED
+#define PNG_WRITE_gAMA_SUPPORTED
+#define PNG_WRITE_hIST_SUPPORTED
+#define PNG_WRITE_iCCP_SUPPORTED
+#define PNG_WRITE_iTXt_SUPPORTED
+#define PNG_WRITE_oFFs_SUPPORTED
+#define PNG_WRITE_pCAL_SUPPORTED
+#define PNG_WRITE_pHYs_SUPPORTED
+#define PNG_WRITE_sBIT_SUPPORTED
+#define PNG_WRITE_sCAL_SUPPORTED
+#define PNG_WRITE_sPLT_SUPPORTED
+#define PNG_WRITE_sRGB_SUPPORTED
+#define PNG_WRITE_tEXt_SUPPORTED
+#define PNG_WRITE_tIME_SUPPORTED
+#define PNG_WRITE_tRNS_SUPPORTED
+#define PNG_WRITE_zTXt_SUPPORTED
+#define PNG_bKGD_SUPPORTED
+#define PNG_cHRM_SUPPORTED
+#define PNG_gAMA_SUPPORTED
+#define PNG_hIST_SUPPORTED
+#define PNG_iCCP_SUPPORTED
+#define PNG_iTXt_SUPPORTED
+#define PNG_oFFs_SUPPORTED
+#define PNG_pCAL_SUPPORTED
+#define PNG_pHYs_SUPPORTED
+#define PNG_sBIT_SUPPORTED
+#define PNG_sCAL_SUPPORTED
+#define PNG_sPLT_SUPPORTED
+#define PNG_sRGB_SUPPORTED
+#define PNG_tEXt_SUPPORTED
+#define PNG_tIME_SUPPORTED
+#define PNG_tRNS_SUPPORTED
+#define PNG_zTXt_SUPPORTED
+/* end of options */
 /* settings */
 #define PNG_API_RULE 0
 #define PNG_CALLOC_SUPPORTED
@@ -34,158 +185,4 @@
 #define PNG_ZBUF_SIZE 8192
 #define PNG_sCAL_PRECISION 5
 /* end of settings */
-/* options */
-#define PNG_16BIT_SUPPORTED 1
-#define PNG_ALIGNED_MEMORY_SUPPORTED
-#define PNG_ARM_NEON_CHECK_SUPPORTED
-#define PNG_BENIGN_ERRORS_SUPPORTED 1
-#define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED 1
-#define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED 1
-#define PNG_CHECK_cHRM_SUPPORTED 1
-#define PNG_CONSOLE_IO_SUPPORTED 1
-#define PNG_CONVERT_tIME_SUPPORTED 1
-#define PNG_EASY_ACCESS_SUPPORTED 1
-/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/
-#define PNG_ERROR_TEXT_SUPPORTED 1
-#define PNG_FIXED_POINT_SUPPORTED 1
-#define PNG_FLOATING_ARITHMETIC_SUPPORTED 1
-#define PNG_FLOATING_POINT_SUPPORTED 1
-#define PNG_GET_PALETTE_MAX_SUPPORTED 1
-#define PNG_HANDLE_AS_UNKNOWN_SUPPORTED 1
-#define PNG_INCH_CONVERSIONS_SUPPORTED 1
-#define PNG_INFO_IMAGE_SUPPORTED 1
-#define PNG_IO_STATE_SUPPORTED 1
-#define PNG_MNG_FEATURES_SUPPORTED 1
-#define PNG_POINTER_INDEXING_SUPPORTED 1
-#define PNG_PROGRESSIVE_READ_SUPPORTED 1
-#define PNG_READ_16BIT_SUPPORTED 1
-#define PNG_READ_ALPHA_MODE_SUPPORTED 1
-#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED 1
-#define PNG_READ_BACKGROUND_SUPPORTED 1
-#define PNG_READ_BGR_SUPPORTED 1
-#define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED 1
-#define PNG_READ_COMPOSITE_NODIV_SUPPORTED 1
-#define PNG_READ_COMPRESSED_TEXT_SUPPORTED 1
-#define PNG_READ_EXPAND_16_SUPPORTED 1
-#define PNG_READ_EXPAND_SUPPORTED 1
-#define PNG_READ_FILLER_SUPPORTED 1
-#define PNG_READ_GAMMA_SUPPORTED 1
-#define PNG_READ_GET_PALETTE_MAX_SUPPORTED 1
-#define PNG_READ_GRAY_TO_RGB_SUPPORTED 1
-#define PNG_READ_INTERLACING_SUPPORTED 1
-#define PNG_READ_INT_FUNCTIONS_SUPPORTED 1
-#define PNG_READ_INVERT_ALPHA_SUPPORTED 1
-#define PNG_READ_INVERT_SUPPORTED 1
-#define PNG_READ_OPT_PLTE_SUPPORTED 1
-#define PNG_READ_PACKSWAP_SUPPORTED 1
-#define PNG_READ_PACK_SUPPORTED 1
-#define PNG_READ_QUANTIZE_SUPPORTED 1
-#define PNG_READ_RGB_TO_GRAY_SUPPORTED 1
-#define PNG_READ_SCALE_16_TO_8_SUPPORTED 1
-#define PNG_READ_SHIFT_SUPPORTED 1
-#define PNG_READ_STRIP_16_TO_8_SUPPORTED 1
-#define PNG_READ_STRIP_ALPHA_SUPPORTED 1
-#define PNG_READ_SUPPORTED 1
-#define PNG_READ_SWAP_ALPHA_SUPPORTED 1
-#define PNG_READ_SWAP_SUPPORTED 1
-#define PNG_READ_TEXT_SUPPORTED 1
-#define PNG_READ_TRANSFORMS_SUPPORTED 1
-#define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED 1
-#define PNG_READ_USER_CHUNKS_SUPPORTED 1
-#define PNG_READ_USER_TRANSFORM_SUPPORTED 1
-#define PNG_READ_bKGD_SUPPORTED 1
-#define PNG_READ_cHRM_SUPPORTED 1
-#define PNG_READ_gAMA_SUPPORTED 1
-#define PNG_READ_hIST_SUPPORTED 1
-#define PNG_READ_iCCP_SUPPORTED 1
-#define PNG_READ_iTXt_SUPPORTED 1
-#define PNG_READ_oFFs_SUPPORTED 1
-#define PNG_READ_pCAL_SUPPORTED 1
-#define PNG_READ_pHYs_SUPPORTED 1
-#define PNG_READ_sBIT_SUPPORTED 1
-#define PNG_READ_sCAL_SUPPORTED 1
-#define PNG_READ_sPLT_SUPPORTED 1
-#define PNG_READ_sRGB_SUPPORTED 1
-#define PNG_READ_tEXt_SUPPORTED 1
-#define PNG_READ_tIME_SUPPORTED 1
-#define PNG_READ_tRNS_SUPPORTED 1
-#define PNG_READ_zTXt_SUPPORTED 1
-/*#undef PNG_SAFE_LIMITS_SUPPORTED*/
-#define PNG_SAVE_INT_32_SUPPORTED 1
-#define PNG_SEQUENTIAL_READ_SUPPORTED 1
-#define PNG_SETJMP_SUPPORTED 1
-#define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED 1
-#define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED 1
-#define PNG_SET_USER_LIMITS_SUPPORTED 1
-#define PNG_STDIO_SUPPORTED 1
-#define PNG_TEXT_SUPPORTED 1
-#define PNG_TIME_RFC1123_SUPPORTED 1
-#define PNG_UNKNOWN_CHUNKS_SUPPORTED 1
-#define PNG_USER_CHUNKS_SUPPORTED 1
-#define PNG_USER_LIMITS_SUPPORTED 1
-#define PNG_USER_MEM_SUPPORTED 1
-#define PNG_USER_TRANSFORM_INFO_SUPPORTED 1
-#define PNG_USER_TRANSFORM_PTR_SUPPORTED 1
-#define PNG_WARNINGS_SUPPORTED 1
-#define PNG_WRITE_16BIT_SUPPORTED 1
-#define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED 1
-#define PNG_WRITE_BGR_SUPPORTED 1
-#define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED 1
-#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED 1
-#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED 1
-#define PNG_WRITE_FILLER_SUPPORTED 1
-#define PNG_WRITE_FILTER_SUPPORTED 1
-#define PNG_WRITE_FLUSH_SUPPORTED 1
-#define PNG_WRITE_GET_PALETTE_MAX_SUPPORTED 1
-#define PNG_WRITE_INTERLACING_SUPPORTED 1
-#define PNG_WRITE_INT_FUNCTIONS_SUPPORTED 1
-#define PNG_WRITE_INVERT_ALPHA_SUPPORTED 1
-#define PNG_WRITE_INVERT_SUPPORTED 1
-#define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED 1
-#define PNG_WRITE_PACKSWAP_SUPPORTED 1
-#define PNG_WRITE_PACK_SUPPORTED 1
-#define PNG_WRITE_SHIFT_SUPPORTED 1
-#define PNG_WRITE_SUPPORTED 1
-#define PNG_WRITE_SWAP_ALPHA_SUPPORTED 1
-#define PNG_WRITE_SWAP_SUPPORTED 1
-#define PNG_WRITE_TEXT_SUPPORTED 1
-#define PNG_WRITE_TRANSFORMS_SUPPORTED 1
-#define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED 1
-#define PNG_WRITE_USER_TRANSFORM_SUPPORTED 1
-#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED 1
-#define PNG_WRITE_bKGD_SUPPORTED 1
-#define PNG_WRITE_cHRM_SUPPORTED 1
-#define PNG_WRITE_gAMA_SUPPORTED 1
-#define PNG_WRITE_hIST_SUPPORTED 1
-#define PNG_WRITE_iCCP_SUPPORTED 1
-#define PNG_WRITE_iTXt_SUPPORTED 1
-#define PNG_WRITE_oFFs_SUPPORTED 1
-#define PNG_WRITE_pCAL_SUPPORTED 1
-#define PNG_WRITE_pHYs_SUPPORTED 1
-#define PNG_WRITE_sBIT_SUPPORTED 1
-#define PNG_WRITE_sCAL_SUPPORTED 1
-#define PNG_WRITE_sPLT_SUPPORTED 1
-#define PNG_WRITE_sRGB_SUPPORTED 1
-#define PNG_WRITE_tEXt_SUPPORTED 1
-#define PNG_WRITE_tIME_SUPPORTED 1
-#define PNG_WRITE_tRNS_SUPPORTED 1
-#define PNG_WRITE_zTXt_SUPPORTED 1
-#define PNG_bKGD_SUPPORTED 1
-#define PNG_cHRM_SUPPORTED 1
-#define PNG_gAMA_SUPPORTED 1
-#define PNG_hIST_SUPPORTED 1
-#define PNG_iCCP_SUPPORTED 1
-#define PNG_iTXt_SUPPORTED 1
-#define PNG_oFFs_SUPPORTED 1
-#define PNG_pCAL_SUPPORTED 1
-#define PNG_pHYs_SUPPORTED 1
-#define PNG_sBIT_SUPPORTED 1
-#define PNG_sCAL_SUPPORTED 1
-#define PNG_sPLT_SUPPORTED 1
-#define PNG_sRGB_SUPPORTED 1
-#define PNG_tEXt_SUPPORTED 1
-#define PNG_tIME_SUPPORTED 1
-#define PNG_tRNS_SUPPORTED 1
-#define PNG_zTXt_SUPPORTED 1
-/* end of options */
 #endif /* PNGLCONF_H */
diff --git a/scripts/symbols.def b/scripts/symbols.def
index 7e52956..fe9d9ca 100644
--- a/scripts/symbols.def
+++ b/scripts/symbols.def
@@ -1,3 +1,4 @@
+;Version 1.5.16beta06
 ;--------------------------------------------------------------
 ; LIBPNG symbol list as a Win32 DEF file
 ; Contains all the symbols that can be exported from libpng
@@ -5,7 +6,6 @@
 LIBRARY
 
 EXPORTS
-;Version 1.5.15beta06
  png_access_version_number @1
  png_set_sig_bytes @2
  png_sig_cmp @3
@@ -241,3 +241,4 @@
  png_set_cHRM_XYZ_fixed @233
  png_set_check_for_invalid_index @234
  png_get_palette_max @235
+ png_set_option @236
diff --git a/scripts/symbols.dfn b/scripts/symbols.dfn
index ca45b74..0341268 100644
--- a/scripts/symbols.dfn
+++ b/scripts/symbols.dfn
@@ -35,13 +35,14 @@
  * defaulted to 'off' in scripts/pnglibconf.dfa
  *
  * Maintenance: if scripts/pnglibconf.dfa options are changed
- * from, or to, 'off' this needs updating!
+ * from, or to, 'disabled' this needs updating!
  */
 #define PNG_BENIGN_ERRORS_SUPPORTED
 #define PNG_ERROR_NUMBERS_SUPPORTED
 #define PNG_READ_BIG_ENDIAN_SUPPORTED  /* should do nothing! */
 #define PNG_INCH_CONVERSIONS_SUPPORTED
 #define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
+#define PNG_SET_OPTION_SUPPORTED
 
 #undef PNG_H
 #include "../png.h"