Browse Source

Merge pull request #38 from bmx-ng/task/libpng-update-1.6.48

Updated to libpng 1.6.48
Brucey 2 months ago
parent
commit
68bebaf3c6
100 changed files with 4888 additions and 1728 deletions
  1. 1 1
      png.mod/common.bmx
  2. 15 13
      png.mod/libpng/ANNOUNCE
  3. 21 11
      png.mod/libpng/AUTHORS
  4. 132 0
      png.mod/libpng/CHANGES
  5. 437 365
      png.mod/libpng/CMakeLists.txt
  6. 0 1
      png.mod/libpng/INSTALL
  7. 2 2
      png.mod/libpng/LICENSE
  8. 42 8
      png.mod/libpng/Makefile.am
  9. 326 225
      png.mod/libpng/Makefile.in
  10. 7 7
      png.mod/libpng/README
  11. 21 22
      png.mod/libpng/TODO
  12. 294 137
      png.mod/libpng/aclocal.m4
  13. 4 5
      png.mod/libpng/arm/arm_init.c
  14. 37 230
      png.mod/libpng/arm/filter_neon.S
  15. 0 1
      png.mod/libpng/arm/filter_neon_intrinsics.c
  16. 1 2
      png.mod/libpng/arm/palette_neon_intrinsics.c
  17. 3 2
      png.mod/libpng/autogen.sh
  18. 19 0
      png.mod/libpng/ci/LICENSE_MIT.txt
  19. 25 0
      png.mod/libpng/ci/README.md
  20. 142 0
      png.mod/libpng/ci/ci_lint.sh
  21. 143 114
      png.mod/libpng/ci/ci_verify_cmake.sh
  22. 125 71
      png.mod/libpng/ci/ci_verify_configure.sh
  23. 134 88
      png.mod/libpng/ci/ci_verify_makefiles.sh
  24. 191 0
      png.mod/libpng/ci/ci_verify_version.sh
  25. 111 0
      png.mod/libpng/ci/lib/ci.lib.sh
  26. 48 0
      png.mod/libpng/ci/libexec/ci_shellify_autoconf.sh
  27. 49 0
      png.mod/libpng/ci/libexec/ci_shellify_c.sh
  28. 49 0
      png.mod/libpng/ci/libexec/ci_shellify_cmake.sh
  29. 46 0
      png.mod/libpng/ci/libexec/ci_shellify_shell.sh
  30. 16 0
      png.mod/libpng/ci/targets/android/ci_env.aarch64-linux-android.sh
  31. 16 0
      png.mod/libpng/ci/targets/android/ci_env.armv7a-linux-androideabi.sh
  32. 16 0
      png.mod/libpng/ci/targets/android/ci_env.i686-linux-android.sh
  33. 16 0
      png.mod/libpng/ci/targets/android/ci_env.x86_64-linux-android.sh
  34. 18 0
      png.mod/libpng/ci/targets/cygwin/ci_env.i686-pc-cygwin.sh
  35. 18 0
      png.mod/libpng/ci/targets/cygwin/ci_env.x86_64-pc-cygwin.sh
  36. 15 0
      png.mod/libpng/ci/targets/darwin/ci_env.arm64-apple-darwin.sh
  37. 15 0
      png.mod/libpng/ci/targets/darwin/ci_env.x86_64-apple-darwin.sh
  38. 14 0
      png.mod/libpng/ci/targets/freebsd/ci_env.aarch64-unknown-freebsd.sh
  39. 14 0
      png.mod/libpng/ci/targets/freebsd/ci_env.i686-unknown-freebsd.sh
  40. 14 0
      png.mod/libpng/ci/targets/freebsd/ci_env.riscv64-unknown-freebsd.sh
  41. 14 0
      png.mod/libpng/ci/targets/freebsd/ci_env.x86_64-unknown-freebsd.sh
  42. 21 0
      png.mod/libpng/ci/targets/linux/ci_env.aarch64-linux-gnu.sh
  43. 21 0
      png.mod/libpng/ci/targets/linux/ci_env.arm-linux-gnueabi.sh
  44. 21 0
      png.mod/libpng/ci/targets/linux/ci_env.arm-linux-gnueabihf.sh
  45. 21 0
      png.mod/libpng/ci/targets/linux/ci_env.i686-linux-gnu.sh
  46. 21 0
      png.mod/libpng/ci/targets/linux/ci_env.mips-linux-gnu.sh
  47. 21 0
      png.mod/libpng/ci/targets/linux/ci_env.mips64-linux-gnuabi64.sh
  48. 21 0
      png.mod/libpng/ci/targets/linux/ci_env.mips64el-linux-gnuabi64.sh
  49. 21 0
      png.mod/libpng/ci/targets/linux/ci_env.mipsel-linux-gnu.sh
  50. 21 0
      png.mod/libpng/ci/targets/linux/ci_env.mipsisa32r6-linux-gnu.sh
  51. 21 0
      png.mod/libpng/ci/targets/linux/ci_env.mipsisa32r6el-linux-gnu.sh
  52. 21 0
      png.mod/libpng/ci/targets/linux/ci_env.mipsisa64r6-linux-gnuabi64.sh
  53. 21 0
      png.mod/libpng/ci/targets/linux/ci_env.mipsisa64r6el-linux-gnuabi64.sh
  54. 21 0
      png.mod/libpng/ci/targets/linux/ci_env.powerpc-linux-gnu.sh
  55. 21 0
      png.mod/libpng/ci/targets/linux/ci_env.powerpc64-linux-gnu.sh
  56. 21 0
      png.mod/libpng/ci/targets/linux/ci_env.powerpc64le-linux-gnu.sh
  57. 21 0
      png.mod/libpng/ci/targets/linux/ci_env.riscv64-linux-gnu.sh
  58. 21 0
      png.mod/libpng/ci/targets/linux/ci_env.x86_64-linux-gnu.sh
  59. 18 0
      png.mod/libpng/ci/targets/msdos/ci_env.i386-pc-msdoswatcom.sh
  60. 18 0
      png.mod/libpng/ci/targets/msdos/ci_env.i586-pc-msdosdjgpp.sh
  61. 19 0
      png.mod/libpng/ci/targets/msdos/ci_env.i86-pc-msdoswatcom.sh
  62. 18 0
      png.mod/libpng/ci/targets/windows/ci_env.aarch64-windows-llvm.sh
  63. 21 0
      png.mod/libpng/ci/targets/windows/ci_env.i686-w64-mingw32.sh
  64. 18 0
      png.mod/libpng/ci/targets/windows/ci_env.i686-windows-llvm.sh
  65. 21 0
      png.mod/libpng/ci/targets/windows/ci_env.x86_64-w64-mingw32.sh
  66. 18 0
      png.mod/libpng/ci/targets/windows/ci_env.x86_64-windows-llvm.sh
  67. 7 4
      png.mod/libpng/compile
  68. 88 24
      png.mod/libpng/config.guess
  69. 18 6
      png.mod/libpng/config.h.in
  70. 169 82
      png.mod/libpng/config.sub
  71. 351 140
      png.mod/libpng/configure
  72. 212 68
      png.mod/libpng/configure.ac
  73. 2 0
      png.mod/libpng/contrib/README.txt
  74. 133 0
      png.mod/libpng/contrib/conftest/basic.dfa
  75. 15 0
      png.mod/libpng/contrib/conftest/fixed.dfa
  76. 14 0
      png.mod/libpng/contrib/conftest/float-fixed.dfa
  77. 21 0
      png.mod/libpng/contrib/conftest/nocompile-limits.dfa
  78. 19 0
      png.mod/libpng/contrib/conftest/nolimits.dfa
  79. 13 0
      png.mod/libpng/contrib/conftest/read-full.dfa
  80. 13 0
      png.mod/libpng/contrib/conftest/write-full.dfa
  81. 0 1
      png.mod/libpng/contrib/examples/README.txt
  82. 2 2
      png.mod/libpng/contrib/examples/iccfrompng.c
  83. 5 5
      png.mod/libpng/contrib/examples/pngpixel.c
  84. 1 1
      png.mod/libpng/contrib/gregbook/rpng-x.c
  85. 1 1
      png.mod/libpng/contrib/gregbook/rpng2-x.c
  86. 20 7
      png.mod/libpng/contrib/libtests/pngimage.c
  87. 3 3
      png.mod/libpng/contrib/libtests/pngstest.c
  88. 24 1
      png.mod/libpng/contrib/libtests/pngunknown.c
  89. 55 38
      png.mod/libpng/contrib/libtests/pngvalid.c
  90. 0 1
      png.mod/libpng/contrib/libtests/readpng.c
  91. 0 1
      png.mod/libpng/contrib/libtests/tarith.c
  92. 0 1
      png.mod/libpng/contrib/libtests/timepng.c
  93. 141 0
      png.mod/libpng/contrib/mips-mmi/linux.c
  94. 23 36
      png.mod/libpng/contrib/mips-msa/linux.c
  95. 16 1
      png.mod/libpng/contrib/oss-fuzz/libpng_read_fuzzer.cc
  96. 19 0
      png.mod/libpng/contrib/pngexif/LICENSE_MIT.txt
  97. 20 0
      png.mod/libpng/contrib/pngexif/README.md
  98. 48 0
      png.mod/libpng/contrib/pngexif/bytepack.py
  99. 306 0
      png.mod/libpng/contrib/pngexif/exifinfo.py
  100. 10 0
      png.mod/libpng/contrib/pngexif/pngexifinfo

+ 1 - 1
png.mod/common.bmx

@@ -1,4 +1,4 @@
-' Copyright (c) 2022-2023 Bruce A Henderson
+' Copyright (c) 2022-2025 Bruce A Henderson
 ' Copyright (c) 2007- Blitz Research Ltd
 '
 ' This software is provided 'as-is', without any express or implied

+ 15 - 13
png.mod/libpng/ANNOUNCE

@@ -1,5 +1,5 @@
-libpng 1.6.40 - June 21, 2023
-=============================
+libpng 1.6.48 - April 30, 2025
+==============================
 
 This is a public release of libpng, intended for use in production code.
 
@@ -9,13 +9,13 @@ Files available for download
 
 Source files with LF line endings (for Unix/Linux):
 
- * libpng-1.6.40.tar.xz (LZMA-compressed, recommended)
- * libpng-1.6.40.tar.gz
+ * libpng-1.6.48.tar.xz (LZMA-compressed, recommended)
+ * libpng-1.6.48.tar.gz (deflate-compressed)
 
 Source files with CRLF line endings (for Windows):
 
- * lpng1640.7z (LZMA-compressed, recommended)
- * lpng1640.zip
+ * lpng1648.7z (LZMA-compressed, recommended)
+ * lpng1648.zip (deflate-compressed)
 
 Other information:
 
@@ -25,15 +25,17 @@ Other information:
  * TRADEMARK.md
 
 
-Changes from version 1.6.39 to version 1.6.40
+Changes from version 1.6.47 to version 1.6.48
 ---------------------------------------------
 
- * Fixed the eXIf chunk multiplicity checks.
- * Fixed a memory leak in pCAL processing.
- * Corrected the validity report about tRNS inside png_get_valid().
- * Fixed various build issues on *BSD, Mac and Windows.
- * Updated the configurations and the scripts for continuous integration.
- * Cleaned up the code, the build scripts, and the documentation.
+ * Fixed the floating-point version of the mDCv setter `png_set_mDCv`.
+   (Reported by Mohit Bakshi; fixed by John Bowler)
+ * Added #error directives to discourage the inclusion of private
+   libpng implementation header files in PNG-supporting applications.
+ * Added the CMake build option `PNG_LIBCONF_HEADER`, to be used as an
+   alternative to `DFA_XTRA`.
+ * Removed the Travis CI configuration files, with heartfelt thanks for
+   their generous support of our project over the past five years!
 
 
 Send comments/corrections/commendations to png-mng-implement at lists.sf.net.

+ 21 - 11
png.mod/libpng/AUTHORS

@@ -4,7 +4,9 @@ PNG REFERENCE LIBRARY AUTHORS
 This is the list of PNG Reference Library ("libpng") Contributing
 Authors, for copyright and licensing purposes.
 
+ * Adam Richter
  * Andreas Dilger
+ * Chris Blume
  * Cosmin Truta
  * Dave Martindale
  * Eric S. Raymond
@@ -15,6 +17,7 @@ Authors, for copyright and licensing purposes.
  * James Yu
  * John Bowler
  * Kevin Bracey
+ * Lucas Chollet
  * Magnus Holmgren
  * Mandar Sahastrabuddhe
  * Mans Rullgard
@@ -33,20 +36,27 @@ Authors, for copyright and licensing purposes.
  * Vadim Barkov
  * Willem van Schaik
  * Zhijie Liang
+ * Apple Inc.
+    - Zixu Wang (王子旭)
  * Arm Holdings
-   - Richard Townsend
+    - Richard Townsend
  * Google Inc.
-   - Dan Field
-   - Leon Scroggins III
-   - Matt Sarett
-   - Mike Klein
-   - Sami Boukortt
-   - Wan-Teh Chang
+    - Dan Field
+    - Leon Scroggins III
+    - Matt Sarett
+    - Mike Klein
+    - Sami Boukortt
+    - Wan-Teh Chang
+ * Loongson Technology Corporation Ltd.
+    - GuXiWei (顾希伟)
+    - JinBo (金波)
+    - ZhangLixia (张利霞)
 
 The build projects, the build scripts, the test scripts, and other
-files in the "ci", "projects", "scripts" and "tests" directories, have
+files in the "projects", "scripts" and "tests" directories, have
 other copyright owners, but are released under the libpng license.
 
-Some files in the "contrib" directory, and some tools-generated files
-that are distributed with libpng, have other copyright owners, and are
-released under other open source licenses.
+Some files in the "ci" and "contrib" directories, as well as some
+of the tools-generated files that are distributed with libpng, have
+other copyright owners, and are released under other open source
+licenses.

+ 132 - 0
png.mod/libpng/CHANGES

@@ -6129,6 +6129,138 @@ Version 1.6.40 [June 21, 2023]
   Updated the configurations and the scripts for continuous integration.
   Cleaned up the code, the build scripts, and the documentation.
 
+Version 1.6.41 [January 24, 2024]
+  Added SIMD-optimized code for the LoongArch LSX hardware.
+    (Contributed by GuXiWei, JinBo and ZhangLixia)
+  Fixed the run-time discovery of MIPS MSA hardware.
+    (Contributed by Sui Jingfeng)
+  Fixed an off-by-one error in the function png_do_check_palette_indexes(),
+    which failed to recognize errors that might have existed in the first
+    column of a broken palette-encoded image. This was a benign regression
+    accidentally introduced in libpng-1.6.33. No pixel was harmed.
+    (Contributed by Adam Richter; reviewed by John Bowler)
+  Fixed, improved and modernized the contrib/pngminus programs, i.e.,
+    png2pnm.c and pnm2png.c
+  Removed old and peculiar portability hacks that were meant to silence
+    warnings issued by gcc version 7.1 alone.
+    (Contributed by John Bowler)
+  Fixed and modernized the CMake file, and raised the minimum required
+    CMake version from 3.1 to 3.6.
+    (Contributed by Clinton Ingram, Timothy Lyanguzov, Tyler Kropp, et al.)
+  Allowed the configure script to disable the building of auxiliary tools
+    and tests, thus catching up with the CMake file.
+    (Contributed by Carlo Bramini)
+  Fixed a build issue on Mac.
+    (Contributed by Zixu Wang)
+  Moved the Autoconf macro files to scripts/autoconf.
+  Moved the CMake files (except for the main CMakeLists.txt) to
+    scripts/cmake and moved the list of their contributing authors to
+    scripts/cmake/AUTHORS.md
+  Updated the CI configurations and scripts.
+  Relicensed the CI scripts to the MIT License.
+  Improved the test coverage.
+    (Contributed by John Bowler)
+
+Version 1.6.42 [January 29, 2024]
+  Fixed the implementation of the macro function png_check_sig().
+    This was an API regression, introduced in libpng-1.6.41.
+    (Reported by Matthieu Darbois)
+  Fixed and updated the libpng manual.
+
+Version 1.6.43 [February 23, 2024]
+  Fixed the row width check in png_check_IHDR().
+    This corrected a bug that was specific to the 16-bit platforms,
+    and removed a spurious compiler warning from the 64-bit builds.
+    (Reported by Jacek Caban; fixed by John Bowler)
+  Added eXIf chunk support to the push-mode reader in pngpread.c.
+    (Contributed by Chris Blume)
+  Added contrib/pngexif for the benefit of the users who would like
+    to inspect the content of eXIf chunks.
+  Added contrib/conftest/basic.dfa, a basic build-time configuration.
+    (Contributed by John Bowler)
+  Fixed a preprocessor condition in pngread.c that broke build-time
+    configurations like contrib/conftest/pngcp.dfa.
+    (Contributed by John Bowler)
+  Added CMake build support for LoongArch LSX.
+    (Contributed by GuXiWei)
+  Fixed a CMake build error that occurred under a peculiar state of the
+    dependency tree. This was a regression introduced in libpng-1.6.41.
+    (Contributed by Dan Rosser)
+  Marked the installed libpng headers as system headers in CMake.
+    (Contributed by Benjamin Buch)
+  Updated the build support for RISCOS.
+    (Contributed by Cameron Cawley)
+  Updated the makefiles to allow cross-platform builds to initialize
+    conventional make variables like AR and ARFLAGS.
+  Added various improvements to the CI scripts in areas like version
+    consistency verification and text linting.
+  Added version consistency verification to pngtest.c also.
+
+Version 1.6.44 [September 12, 2024]
+  Hardened calculations in chroma handling to prevent overflows, and
+    relaxed a constraint in cHRM validation to accomodate the standard
+    ACES AP1 set of color primaries.
+    (Contributed by John Bowler)
+  Removed the ASM implementation of ARM Neon optimizations and updated
+    the build accordingly. Only the remaining C implementation shall be
+    used from now on, thus ensuring the support of the PAC/BTI security
+    features on ARM64.
+    (Contributed by Ross Burton and John Bowler)
+  Fixed the pickup of the PNG_HARDWARE_OPTIMIZATIONS option in the
+    CMake build on FreeBSD/amd64. This is an important performance fix
+    on this platform.
+  Applied various fixes and improvements to the CMake build.
+    (Contributed by Eric Riff, Benjamin Buch and Erik Scholz)
+  Added fuzzing targets for the simplified read API.
+    (Contributed by Mikhail Khachayants)
+  Fixed a build error involving pngtest.c under a custom config.
+    This was a regression introduced in a code cleanup in libpng-1.6.43.
+    (Contributed by Ben Wagner)
+  Fixed and improved the config files for AppVeyor CI and Travis CI.
+
+Version 1.6.45 [January 7, 2025]
+  Added support for the cICP chunk.
+    (Contributed by Lucas Chollet and John Bowler)
+  Adjusted and improved various checks in colorspace calculations.
+    (Contributed by John Bowler)
+  Rearranged the write order of colorspace chunks for better conformance
+    with the PNG v3 draft specification.
+    (Contributed by John Bowler)
+  Raised the minimum required CMake version from 3.6 to 3.14.
+  Forked off a development branch for libpng version 1.8.
+
+Version 1.6.46 [January 23, 2025]
+  Added support for the mDCV and cLLI chunks.
+    (Contributed by John Bowler)
+  Fixed a build issue affecting C89 compilers.
+    This was a regression introduced in libpng-1.6.45.
+    (Contributed by John Bowler)
+  Added makefile.c89, specifically for testing C89 compilers.
+  Cleaned up contrib/pngminus: corrected an old typo, removed an old
+    workaround, and updated the CMake file.
+
+Version 1.6.47 [February 18, 2025]
+  Modified the behaviour of colorspace chunks in order to adhere
+    to the new precedence rules formulated in the latest draft of
+    the PNG Specification.
+    (Contributed by John Bowler)
+  Fixed a latent bug in `png_write_iCCP`.
+    This would have been a read-beyond-end-of-malloc vulnerability,
+    introduced early in the libpng-1.6.0 development, yet (fortunately!)
+    it was inaccessible before the above-mentioned modification of the
+    colorspace precedence rules, due to pre-existing colorspace checks.
+    (Reported by Bob Friesenhahn; fixed by John Bowler)
+
+Version 1.6.48 [April 30, 2025]
+  Fixed the floating-point version of the mDCv setter `png_set_mDCv`.
+    (Reported by Mohit Bakshi; fixed by John Bowler)
+  Added #error directives to discourage the inclusion of private
+    libpng implementation header files in PNG-supporting applications.
+  Added the CMake build option `PNG_LIBCONF_HEADER`, to be used as an
+    alternative to `DFA_XTRA`.
+  Removed the Travis CI configuration files, with heartfelt thanks for
+    their generous support of our project over the past five years!
+
 Send comments/corrections/commendations to png-mng-implement at lists.sf.net.
 Subscription is required; visit
 https://lists.sourceforge.net/lists/listinfo/png-mng-implement

File diff suppressed because it is too large
+ 437 - 365
png.mod/libpng/CMakeLists.txt


+ 0 - 1
png.mod/libpng/INSTALL

@@ -1,4 +1,3 @@
-
     Installing libpng
 
 Contents

+ 2 - 2
png.mod/libpng/LICENSE

@@ -4,8 +4,8 @@ COPYRIGHT NOTICE, DISCLAIMER, and LICENSE
 PNG Reference Library License version 2
 ---------------------------------------
 
- * Copyright (c) 1995-2023 The PNG Reference Library Authors.
- * Copyright (c) 2018-2023 Cosmin Truta.
+ * Copyright (c) 1995-2025 The PNG Reference Library Authors.
+ * Copyright (c) 2018-2025 Cosmin Truta.
  * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.
  * Copyright (c) 1996-1997 Andreas Dilger.
  * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.

+ 42 - 8
png.mod/libpng/Makefile.am

@@ -1,6 +1,6 @@
 # Makefile.am, the source file for Makefile.in (and hence Makefile), is
 #
-# Copyright (c) 2018 Cosmin Truta
+# Copyright (c) 2018-2025 Cosmin Truta
 # Copyright (c) 2004-2016 Glenn Randers-Pehrson
 #
 # This code is released under the libpng license.
@@ -9,16 +9,24 @@
 
 PNGLIB_BASENAME= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@
 
-ACLOCAL_AMFLAGS = -I scripts
+ACLOCAL_AMFLAGS = -I scripts/autoconf
 
 # test programs - run on make check, make distcheck
+if ENABLE_TESTS
 check_PROGRAMS= pngtest pngunknown pngstest pngvalid pngimage pngcp
 if HAVE_CLOCK_GETTIME
 check_PROGRAMS += timepng
 endif
+else
+check_PROGRAMS=
+endif
 
 # Utilities - installed
+if ENABLE_TOOLS
 bin_PROGRAMS= pngfix png-fix-itxt
+else
+bin_PROGRAMS=
+endif
 
 # This ensures that pnglibconf.h gets built at the start of 'make all' or
 # 'make check', but it does not add dependencies to the individual programs,
@@ -30,6 +38,7 @@ bin_PROGRAMS= pngfix png-fix-itxt
 # always wrong and always very confusing.
 BUILT_SOURCES = pnglibconf.h
 
+if ENABLE_TESTS
 pngtest_SOURCES = pngtest.c
 pngtest_LDADD = libpng@PNGLIB_MAJOR@@[email protected]
 
@@ -48,16 +57,20 @@ pngimage_LDADD = libpng@PNGLIB_MAJOR@@[email protected]
 timepng_SOURCES = contrib/libtests/timepng.c
 timepng_LDADD = libpng@PNGLIB_MAJOR@@[email protected]
 
+pngcp_SOURCES = contrib/tools/pngcp.c
+pngcp_LDADD = libpng@PNGLIB_MAJOR@@[email protected]
+endif
+
+if ENABLE_TOOLS
 pngfix_SOURCES = contrib/tools/pngfix.c
 pngfix_LDADD = libpng@PNGLIB_MAJOR@@[email protected]
 
 png_fix_itxt_SOURCES = contrib/tools/png-fix-itxt.c
-
-pngcp_SOURCES = contrib/tools/pngcp.c
-pngcp_LDADD = libpng@PNGLIB_MAJOR@@[email protected]
+endif
 
 # Generally these are single line shell scripts to run a test with a particular
 # set of parameters:
+if ENABLE_TESTS
 TESTS =\
    tests/pngtest-all\
    tests/pngvalid-gamma-16-to-8 tests/pngvalid-gamma-alpha-mode\
@@ -75,6 +88,7 @@ TESTS =\
    tests/pngunknown-discard tests/pngunknown-if-safe tests/pngunknown-sAPI\
    tests/pngunknown-sTER tests/pngunknown-save tests/pngunknown-vpAg\
    tests/pngimage-quick tests/pngimage-full
+endif
 
 # man pages
 dist_man_MANS= libpng.3 libpngpf.3 png.5
@@ -94,7 +108,7 @@ libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = png.c pngerror.c\
 
 if PNG_ARM_NEON
 libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += arm/arm_init.c\
-	arm/filter_neon.S arm/filter_neon_intrinsics.c \
+	arm/filter_neon_intrinsics.c \
 	arm/palette_neon_intrinsics.c
 endif
 
@@ -103,6 +117,13 @@ libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += mips/mips_init.c\
 	mips/filter_msa_intrinsics.c
 endif
 
+if PNG_MIPS_MMI
+if !PNG_MIPS_MSA
+libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += mips/mips_init.c
+endif
+libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += mips/filter_mmi_inline_assembly.c
+endif
+
 if PNG_INTEL_SSE
 libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += intel/intel_init.c\
 	intel/filter_sse2_intrinsics.c
@@ -113,6 +134,15 @@ libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += powerpc/powerpc_init.c\
         powerpc/filter_vsx_intrinsics.c
 endif
 
+if PNG_LOONGARCH_LSX
+noinst_LTLIBRARIES= libpng@PNGLIB_MAJOR@@[email protected]
+libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la_SOURCES = loongarch/loongarch_lsx_init.c\
+	loongarch/filter_lsx_intrinsics.c
+libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la_CFLAGS = -mlsx
+libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LIBADD = libpng@PNGLIB_MAJOR@@[email protected]
+# libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng@PNGLIB_MAJOR@@[email protected]
+endif
+
 nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h
 
 libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS = -no-undefined -export-dynamic \
@@ -133,6 +163,10 @@ else
   libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng.sym
 endif
 
+if PNG_LOONGARCH_LSX
+  libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES += libpng@PNGLIB_MAJOR@@[email protected]
+endif
+
 #distribute headers in /usr/include/libpng/*
 pkgincludedir= $(includedir)/$(PNGLIB_BASENAME)
 pkginclude_HEADERS= png.h pngconf.h
@@ -149,7 +183,7 @@ pkgconfig_DATA = libpng@PNGLIB_MAJOR@@[email protected]
 EXTRA_DIST= \
 	ANNOUNCE AUTHORS CHANGES INSTALL LICENSE README TODO TRADEMARK \
 	pngtest.png pngbar.png pngnow.png pngbar.jpg autogen.sh \
-	${srcdir}/contrib ${srcdir}/projects ${srcdir}/scripts \
+	${srcdir}/ci ${srcdir}/contrib ${srcdir}/projects ${srcdir}/scripts \
 	$(TESTS) $(XFAIL_TESTS) tests/pngstest \
 	CMakeLists.txt example.c libpng-manual.txt
 
@@ -165,7 +199,7 @@ MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess config.h.in \
 config.sub configure depcomp install-sh ltmain.sh missing
 
 # PNG_COPTS give extra options for the C compiler to be used on all compilation
-# steps (unless targe_CFLAGS is specified; that will take precedence over
+# steps (unless target_CFLAGS is specified; that will take precedence over
 # AM_CFLAGS)
 PNG_COPTS = @PNG_COPTS@
 AM_CFLAGS = ${PNG_COPTS}

File diff suppressed because it is too large
+ 326 - 225
png.mod/libpng/Makefile.in


+ 7 - 7
png.mod/libpng/README

@@ -1,4 +1,4 @@
-README for libpng version 1.6.40
+README for libpng version 1.6.48
 ================================
 
 See the note about version numbers near the top of `png.h`.
@@ -142,10 +142,11 @@ Files included in this distribution
     pngwrite.c    =>  High-level write functions
     pngwtran.c    =>  Write data transformations
     pngwutil.c    =>  Write utility functions
-    arm/          =>  Optimized code for the ARM platform
-    intel/        =>  Optimized code for the INTEL-SSE2 platform
-    mips/         =>  Optimized code for the MIPS platform
-    powerpc/      =>  Optimized code for the PowerPC platform
+    arm/          =>  Optimized code for ARM Neon
+    intel/        =>  Optimized code for INTEL SSE2
+    loongarch/    =>  Optimized code for LoongArch LSX
+    mips/         =>  Optimized code for MIPS MSA and MIPS MMI
+    powerpc/      =>  Optimized code for PowerPC VSX
     ci/           =>  Scripts for continuous integration
     contrib/      =>  External contributions
         arm-neon/     =>  Optimized code for the ARM-NEON platform
@@ -156,8 +157,7 @@ Files included in this distribution
                           "PNG: The Definitive Guide" by Greg Roelofs,
                           O'Reilly, 1999
         libtests/     =>  Test programs
-        oss-fuzz/     =>  Files used by the OSS-Fuzz project for fuzz-testing
-                          libpng
+        pngexif/      =>  Program to inspect the EXIF information in PNG files
         pngminim/     =>  Minimal decoder, encoder, and progressive decoder
                           programs demonstrating the use of pngusr.dfa
         pngminus/     =>  Simple pnm2png and png2pnm programs

+ 21 - 22
png.mod/libpng/TODO

@@ -1,23 +1,22 @@
-TODO - list of things to do for libpng:
+TODO list for libpng
+--------------------
 
-* Fix all defects (duh!)
-* Better C++ wrapper / full C++ implementation (?)
-* Fix the problems with C++ and 'extern "C"'.
-* cHRM transformation.
-* Palette creation.
-* "grayscale->palette" transformation and "palette->grayscale" detection.
-* Improved dithering.
-* Multi-lingual error and warning message support.
-* Complete sRGB transformation.  (Currently it simply uses gamma=0.45455.)
-* Man pages for function calls.
-* Better documentation.
-* Better filter selection
-  (e.g., counting huffman bits/precompression; filter inertia; filter costs).
-* Histogram creation.
-* Text conversion between different code pages (e.g., Latin-1 -> Mac).
-* Avoid building gamma tables whenever possible.
-* Greater precision in changing to linear gamma for compositing against
-  background, and in doing rgb-to-gray transformations.
-* Investigate pre-incremented loop counters and other loop constructions.
-* Interpolated method of handling interlacing.
-* More validations for libpng transformations.
+ * Fix all defects (duh!)
+ * cHRM transformation.
+ * Palette creation.
+ * "grayscale->palette" transformation and "palette->grayscale" detection.
+ * Improved dithering.
+ * Multi-lingual error and warning message support.
+ * Complete sRGB transformation.  (Currently it simply uses gamma=0.45455.)
+ * Man pages for function calls.
+ * Better documentation.
+ * Better filter selection
+   (e.g., counting huffman bits/precompression; filter inertia; filter costs).
+ * Histogram creation.
+ * Text conversion between different code pages (e.g., Latin-1 to Mac).
+ * Avoid building gamma tables whenever possible.
+ * Greater precision in changing to linear gamma for compositing against
+   background, and in doing rgb-to-gray transformations.
+ * Investigate pre-incremented loop counters and other loop constructions.
+ * Interpolated method of handling interlacing.
+ * More validations for libpng transformations.

+ 294 - 137
png.mod/libpng/aclocal.m4

@@ -1,6 +1,6 @@
-# generated automatically by aclocal 1.16.5 -*- Autoconf -*-
+# generated automatically by aclocal 1.17 -*- Autoconf -*-
 
-# Copyright (C) 1996-2021 Free Software Foundation, Inc.
+# Copyright (C) 1996-2024 Free Software Foundation, Inc.
 
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -14,13 +14,13 @@
 m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
 m4_ifndef([AC_AUTOCONF_VERSION],
   [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
-m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.71],,
-[m4_warning([this file was generated for autoconf 2.71.
+m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.72],,
+[m4_warning([this file was generated for autoconf 2.72.
 You have another version of autoconf.  It may work, but is not guaranteed to.
 If you have problems, you may need to regenerate the build system entirely.
 To do so, use the procedure documented by the package, typically 'autoreconf'.])])
 
-# Copyright (C) 2002-2021 Free Software Foundation, Inc.
+# Copyright (C) 2002-2024 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -32,10 +32,10 @@ To do so, use the procedure documented by the package, typically 'autoreconf'.])
 # generated from the m4 files accompanying Automake X.Y.
 # (This private macro should not be called outside this file.)
 AC_DEFUN([AM_AUTOMAKE_VERSION],
-[am__api_version='1.16'
+[am__api_version='1.17'
 dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
 dnl require some minimum version.  Point them to the right macro.
-m4_if([$1], [1.16.5], [],
+m4_if([$1], [1.17], [],
       [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
 ])
 
@@ -51,14 +51,14 @@ m4_define([_AM_AUTOCONF_VERSION], [])
 # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
 # This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-[AM_AUTOMAKE_VERSION([1.16.5])dnl
+[AM_AUTOMAKE_VERSION([1.17])dnl
 m4_ifndef([AC_AUTOCONF_VERSION],
   [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
 _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
 
 # Figure out how to run the assembler.                      -*- Autoconf -*-
 
-# Copyright (C) 2001-2021 Free Software Foundation, Inc.
+# Copyright (C) 2001-2024 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -78,7 +78,7 @@ _AM_IF_OPTION([no-dependencies],, [_AM_DEPENDENCIES([CCAS])])dnl
 
 # AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
 
-# Copyright (C) 2001-2021 Free Software Foundation, Inc.
+# Copyright (C) 2001-2024 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -130,7 +130,7 @@ am_aux_dir=`cd "$ac_aux_dir" && pwd`
 
 # AM_CONDITIONAL                                            -*- Autoconf -*-
 
-# Copyright (C) 1997-2021 Free Software Foundation, Inc.
+# Copyright (C) 1997-2024 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -161,7 +161,7 @@ AC_CONFIG_COMMANDS_PRE(
 Usually this means the macro was only invoked conditionally.]])
 fi])])
 
-# Copyright (C) 1999-2021 Free Software Foundation, Inc.
+# Copyright (C) 1999-2024 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -293,7 +293,7 @@ AC_CACHE_CHECK([dependency style of $depcc],
       # icc doesn't choke on unknown options, it will just issue warnings
       # or remarks (even with -Werror).  So we grep stderr for any message
       # that says an option was ignored or not supported.
-      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      # When given -MP, icc 7.0 and 7.1 complain thus:
       #   icc: Command line warning: ignoring option '-M'; no argument required
       # The diagnosis changed in icc 8.0:
       #   icc: Command line remark: option '-MP' not supported
@@ -352,7 +352,7 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl
 
 # Generate code to set up dependency tracking.              -*- Autoconf -*-
 
-# Copyright (C) 1999-2021 Free Software Foundation, Inc.
+# Copyright (C) 1999-2024 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -420,7 +420,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
 
 # Do all the work for Automake.                             -*- Autoconf -*-
 
-# Copyright (C) 1996-2021 Free Software Foundation, Inc.
+# Copyright (C) 1996-2024 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -554,7 +554,7 @@ if test -z "$CSCOPE"; then
 fi
 AC_SUBST([CSCOPE])
 
-AC_REQUIRE([AM_SILENT_RULES])dnl
+AC_REQUIRE([_AM_SILENT_RULES])dnl
 dnl The testsuite driver may need to know about EXEEXT, so add the
 dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen.  This
 dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below.
@@ -562,47 +562,9 @@ AC_CONFIG_COMMANDS_PRE(dnl
 [m4_provide_if([_AM_COMPILER_EXEEXT],
   [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
 
-# POSIX will say in a future version that running "rm -f" with no argument
-# is OK; and we want to be able to make that assumption in our Makefile
-# recipes.  So use an aggressive probe to check that the usage we want is
-# actually supported "in the wild" to an acceptable degree.
-# See automake bug#10828.
-# To make any issue more visible, cause the running configure to be aborted
-# by default if the 'rm' program in use doesn't match our expectations; the
-# user can still override this though.
-if rm -f && rm -fr && rm -rf; then : OK; else
-  cat >&2 <<'END'
-Oops!
-
-Your 'rm' program seems unable to run without file operands specified
-on the command line, even when the '-f' option is present.  This is contrary
-to the behaviour of most rm programs out there, and not conforming with
-the upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542>
-
-Please tell [email protected] about your system, including the value
-of your $PATH and any error possibly output before this message.  This
-can help us improve future automake versions.
+AC_REQUIRE([_AM_PROG_RM_F])
+AC_REQUIRE([_AM_PROG_XARGS_N])
 
-END
-  if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then
-    echo 'Configuration will proceed anyway, since you have set the' >&2
-    echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2
-    echo >&2
-  else
-    cat >&2 <<'END'
-Aborting the configuration process, to ensure you take notice of the issue.
-
-You can download and install GNU coreutils to get an 'rm' implementation
-that behaves properly: <https://www.gnu.org/software/coreutils/>.
-
-If you want to complete the configuration process using your problematic
-'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
-to "yes", and re-run configure.
-
-END
-    AC_MSG_ERROR([Your 'rm' program is bad, sorry.])
-  fi
-fi
 dnl The trailing newline in this macro's definition is deliberate, for
 dnl backward compatibility and to allow trailing 'dnl'-style comments
 dnl after the AM_INIT_AUTOMAKE invocation. See automake bug#16841.
@@ -635,7 +597,7 @@ for _am_header in $config_headers :; do
 done
 echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
 
-# Copyright (C) 2001-2021 Free Software Foundation, Inc.
+# Copyright (C) 2001-2024 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -656,7 +618,7 @@ if test x"${install_sh+set}" != xset; then
 fi
 AC_SUBST([install_sh])])
 
-# Copyright (C) 2003-2021 Free Software Foundation, Inc.
+# Copyright (C) 2003-2024 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -678,7 +640,7 @@ AC_SUBST([am__leading_dot])])
 # Add --enable-maintainer-mode option to configure.         -*- Autoconf -*-
 # From Jim Meyering
 
-# Copyright (C) 1996-2021 Free Software Foundation, Inc.
+# Copyright (C) 1996-2024 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -713,7 +675,7 @@ AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
 
 # Check to see how 'make' treats includes.	            -*- Autoconf -*-
 
-# Copyright (C) 2001-2021 Free Software Foundation, Inc.
+# Copyright (C) 2001-2024 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -756,7 +718,7 @@ AC_SUBST([am__quote])])
 
 # Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
 
-# Copyright (C) 1997-2021 Free Software Foundation, Inc.
+# Copyright (C) 1997-2024 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -790,7 +752,7 @@ fi
 
 # Helper functions for option handling.                     -*- Autoconf -*-
 
-# Copyright (C) 2001-2021 Free Software Foundation, Inc.
+# Copyright (C) 2001-2024 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -819,7 +781,7 @@ AC_DEFUN([_AM_SET_OPTIONS],
 AC_DEFUN([_AM_IF_OPTION],
 [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
 
-# Copyright (C) 1999-2021 Free Software Foundation, Inc.
+# Copyright (C) 1999-2024 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -866,7 +828,23 @@ AC_LANG_POP([C])])
 # For backward compatibility.
 AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
 
-# Copyright (C) 2001-2021 Free Software Foundation, Inc.
+# Copyright (C) 2022-2024 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# _AM_PROG_RM_F
+# ---------------
+# Check whether 'rm -f' without any arguments works.
+# https://bugs.gnu.org/10828
+AC_DEFUN([_AM_PROG_RM_F],
+[am__rm_f_notfound=
+AS_IF([(rm -f && rm -fr && rm -rf) 2>/dev/null], [], [am__rm_f_notfound='""'])
+AC_SUBST(am__rm_f_notfound)
+])
+
+# Copyright (C) 2001-2024 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -885,16 +863,169 @@ AC_DEFUN([AM_RUN_LOG],
 
 # Check to make sure that the build environment is sane.    -*- Autoconf -*-
 
-# Copyright (C) 1996-2021 Free Software Foundation, Inc.
+# Copyright (C) 1996-2024 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
+# _AM_SLEEP_FRACTIONAL_SECONDS
+# ----------------------------
+AC_DEFUN([_AM_SLEEP_FRACTIONAL_SECONDS], [dnl
+AC_CACHE_CHECK([whether sleep supports fractional seconds],
+               am_cv_sleep_fractional_seconds, [dnl
+AS_IF([sleep 0.001 2>/dev/null], [am_cv_sleep_fractional_seconds=yes],
+                                 [am_cv_sleep_fractional_seconds=no])
+])])
+
+# _AM_FILESYSTEM_TIMESTAMP_RESOLUTION
+# -----------------------------------
+# Determine the filesystem's resolution for file modification
+# timestamps.  The coarsest we know of is FAT, with a resolution
+# of only two seconds, even with the most recent "exFAT" extensions.
+# The finest (e.g. ext4 with large inodes, XFS, ZFS) is one
+# nanosecond, matching clock_gettime.  However, it is probably not
+# possible to delay execution of a shell script for less than one
+# millisecond, due to process creation overhead and scheduling
+# granularity, so we don't check for anything finer than that. (See below.)
+AC_DEFUN([_AM_FILESYSTEM_TIMESTAMP_RESOLUTION], [dnl
+AC_REQUIRE([_AM_SLEEP_FRACTIONAL_SECONDS])
+AC_CACHE_CHECK([filesystem timestamp resolution],
+               am_cv_filesystem_timestamp_resolution, [dnl
+# Default to the worst case.
+am_cv_filesystem_timestamp_resolution=2
+
+# Only try to go finer than 1 sec if sleep can do it.
+# Don't try 1 sec, because if 0.01 sec and 0.1 sec don't work,
+# - 1 sec is not much of a win compared to 2 sec, and
+# - it takes 2 seconds to perform the test whether 1 sec works.
+# 
+# Instead, just use the default 2s on platforms that have 1s resolution,
+# accept the extra 1s delay when using $sleep in the Automake tests, in
+# exchange for not incurring the 2s delay for running the test for all
+# packages.
+#
+am_try_resolutions=
+if test "$am_cv_sleep_fractional_seconds" = yes; then
+  # Even a millisecond often causes a bunch of false positives,
+  # so just try a hundredth of a second. The time saved between .001 and
+  # .01 is not terribly consequential.
+  am_try_resolutions="0.01 0.1 $am_try_resolutions"
+fi
+
+# In order to catch current-generation FAT out, we must *modify* files
+# that already exist; the *creation* timestamp is finer.  Use names
+# that make ls -t sort them differently when they have equal
+# timestamps than when they have distinct timestamps, keeping
+# in mind that ls -t prints the *newest* file first.
+rm -f conftest.ts?
+: > conftest.ts1
+: > conftest.ts2
+: > conftest.ts3
+
+# Make sure ls -t actually works.  Do 'set' in a subshell so we don't
+# clobber the current shell's arguments. (Outer-level square brackets
+# are removed by m4; they're present so that m4 does not expand
+# <dollar><star>; be careful, easy to get confused.)
+if (
+     set X `[ls -t conftest.ts[12]]` &&
+     {
+       test "$[]*" != "X conftest.ts1 conftest.ts2" ||
+       test "$[]*" != "X conftest.ts2 conftest.ts1";
+     }
+); then :; else
+  # If neither matched, then we have a broken ls.  This can happen
+  # if, for instance, CONFIG_SHELL is bash and it inherits a
+  # broken ls alias from the environment.  This has actually
+  # happened.  Such a system could not be considered "sane".
+  _AS_ECHO_UNQUOTED(
+    ["Bad output from ls -t: \"`[ls -t conftest.ts[12]]`\""],
+    [AS_MESSAGE_LOG_FD])
+  AC_MSG_FAILURE([ls -t produces unexpected output.
+Make sure there is not a broken ls alias in your environment.])
+fi
+
+for am_try_res in $am_try_resolutions; do
+  # Any one fine-grained sleep might happen to cross the boundary
+  # between two values of a coarser actual resolution, but if we do
+  # two fine-grained sleeps in a row, at least one of them will fall
+  # entirely within a coarse interval.
+  echo alpha > conftest.ts1
+  sleep $am_try_res
+  echo beta > conftest.ts2
+  sleep $am_try_res
+  echo gamma > conftest.ts3
+
+  # We assume that 'ls -t' will make use of high-resolution
+  # timestamps if the operating system supports them at all.
+  if (set X `ls -t conftest.ts?` &&
+      test "$[]2" = conftest.ts3 &&
+      test "$[]3" = conftest.ts2 &&
+      test "$[]4" = conftest.ts1); then
+    #
+    # Ok, ls -t worked. If we're at a resolution of 1 second, we're done,
+    # because we don't need to test make.
+    make_ok=true
+    if test $am_try_res != 1; then
+      # But if we've succeeded so far with a subsecond resolution, we
+      # have one more thing to check: make. It can happen that
+      # everything else supports the subsecond mtimes, but make doesn't;
+      # notably on macOS, which ships make 3.81 from 2006 (the last one
+      # released under GPLv2). https://bugs.gnu.org/68808
+      # 
+      # We test $MAKE if it is defined in the environment, else "make".
+      # It might get overridden later, but our hope is that in practice
+      # it does not matter: it is the system "make" which is (by far)
+      # the most likely to be broken, whereas if the user overrides it,
+      # probably they did so with a better, or at least not worse, make.
+      # https://lists.gnu.org/archive/html/automake/2024-06/msg00051.html
+      #
+      # Create a Makefile (real tab character here):
+      rm -f conftest.mk
+      echo 'conftest.ts1: conftest.ts2' >conftest.mk
+      echo '	touch conftest.ts2' >>conftest.mk
+      #
+      # Now, running
+      #   touch conftest.ts1; touch conftest.ts2; make
+      # should touch ts1 because ts2 is newer. This could happen by luck,
+      # but most often, it will fail if make's support is insufficient. So
+      # test for several consecutive successes.
+      #
+      # (We reuse conftest.ts[12] because we still want to modify existing
+      # files, not create new ones, per above.)
+      n=0
+      make=${MAKE-make}
+      until test $n -eq 3; do
+        echo one > conftest.ts1
+        sleep $am_try_res
+        echo two > conftest.ts2 # ts2 should now be newer than ts1
+        if $make -f conftest.mk | grep 'up to date' >/dev/null; then
+          make_ok=false
+          break # out of $n loop
+        fi
+        n=`expr $n + 1`
+      done
+    fi
+    #
+    if $make_ok; then
+      # Everything we know to check worked out, so call this resolution good.
+      am_cv_filesystem_timestamp_resolution=$am_try_res
+      break # out of $am_try_res loop
+    fi
+    # Otherwise, we'll go on to check the next resolution.
+  fi
+done
+rm -f conftest.ts?
+# (end _am_filesystem_timestamp_resolution)
+])])
+
 # AM_SANITY_CHECK
 # ---------------
 AC_DEFUN([AM_SANITY_CHECK],
-[AC_MSG_CHECKING([whether build environment is sane])
+[AC_REQUIRE([_AM_FILESYSTEM_TIMESTAMP_RESOLUTION])
+# This check should not be cached, as it may vary across builds of
+# different projects.
+AC_MSG_CHECKING([whether build environment is sane])
 # Reject unsafe characters in $srcdir or the absolute working directory
 # name.  Accept space and tab only in the latter.
 am_lf='
@@ -913,49 +1044,40 @@ esac
 # symlink; some systems play weird games with the mod time of symlinks
 # (eg FreeBSD returns the mod time of the symlink's containing
 # directory).
-if (
-   am_has_slept=no
-   for am_try in 1 2; do
-     echo "timestamp, slept: $am_has_slept" > conftest.file
-     set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
-     if test "$[*]" = "X"; then
-	# -L didn't work.
-	set X `ls -t "$srcdir/configure" conftest.file`
-     fi
-     if test "$[*]" != "X $srcdir/configure conftest.file" \
-	&& test "$[*]" != "X conftest.file $srcdir/configure"; then
-
-	# If neither matched, then we have a broken ls.  This can happen
-	# if, for instance, CONFIG_SHELL is bash and it inherits a
-	# broken ls alias from the environment.  This has actually
-	# happened.  Such a system could not be considered "sane".
-	AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
-  alias in your environment])
-     fi
-     if test "$[2]" = conftest.file || test $am_try -eq 2; then
-       break
-     fi
-     # Just in case.
-     sleep 1
-     am_has_slept=yes
-   done
-   test "$[2]" = conftest.file
-   )
-then
-   # Ok.
-   :
-else
-   AC_MSG_ERROR([newly created file is older than distributed files!
+am_build_env_is_sane=no
+am_has_slept=no
+rm -f conftest.file
+for am_try in 1 2; do
+  echo "timestamp, slept: $am_has_slept" > conftest.file
+  if (
+    set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
+    if test "$[]*" = "X"; then
+      # -L didn't work.
+      set X `ls -t "$srcdir/configure" conftest.file`
+    fi
+    test "$[]2" = conftest.file
+  ); then
+    am_build_env_is_sane=yes
+    break
+  fi
+  # Just in case.
+  sleep "$am_cv_filesystem_timestamp_resolution"
+  am_has_slept=yes
+done
+
+AC_MSG_RESULT([$am_build_env_is_sane])
+if test "$am_build_env_is_sane" = no; then
+  AC_MSG_ERROR([newly created file is older than distributed files!
 Check your system clock])
 fi
-AC_MSG_RESULT([yes])
+
 # If we didn't sleep, we still need to ensure time stamps of config.status and
 # generated files are strictly newer.
 am_sleep_pid=
-if grep 'slept: no' conftest.file >/dev/null 2>&1; then
-  ( sleep 1 ) &
+AS_IF([test -e conftest.file || grep 'slept: no' conftest.file >/dev/null 2>&1],, [dnl
+  ( sleep "$am_cv_filesystem_timestamp_resolution" ) &
   am_sleep_pid=$!
-fi
+])
 AC_CONFIG_COMMANDS_PRE(
   [AC_MSG_CHECKING([that generated files are newer than configure])
    if test -n "$am_sleep_pid"; then
@@ -966,18 +1088,18 @@ AC_CONFIG_COMMANDS_PRE(
 rm -f conftest.file
 ])
 
-# Copyright (C) 2009-2021 Free Software Foundation, Inc.
+# Copyright (C) 2009-2024 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# AM_SILENT_RULES([DEFAULT])
-# --------------------------
-# Enable less verbose build rules; with the default set to DEFAULT
-# ("yes" being less verbose, "no" or empty being verbose).
-AC_DEFUN([AM_SILENT_RULES],
-[AC_ARG_ENABLE([silent-rules], [dnl
+# _AM_SILENT_RULES
+# ----------------
+# Enable less verbose build rules support.
+AC_DEFUN([_AM_SILENT_RULES],
+[AM_DEFAULT_VERBOSITY=1
+AC_ARG_ENABLE([silent-rules], [dnl
 AS_HELP_STRING(
   [--enable-silent-rules],
   [less verbose build output (undo: "make V=1")])
@@ -985,11 +1107,6 @@ AS_HELP_STRING(
   [--disable-silent-rules],
   [verbose build output (undo: "make V=0")])dnl
 ])
-case $enable_silent_rules in @%:@ (((
-  yes) AM_DEFAULT_VERBOSITY=0;;
-   no) AM_DEFAULT_VERBOSITY=1;;
-    *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);;
-esac
 dnl
 dnl A few 'make' implementations (e.g., NonStop OS and NextStep)
 dnl do not support nested variable expansions.
@@ -1008,14 +1125,6 @@ am__doit:
 else
   am_cv_make_support_nested_variables=no
 fi])
-if test $am_cv_make_support_nested_variables = yes; then
-  dnl Using '$V' instead of '$(V)' breaks IRIX make.
-  AM_V='$(V)'
-  AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
-else
-  AM_V=$AM_DEFAULT_VERBOSITY
-  AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
-fi
 AC_SUBST([AM_V])dnl
 AM_SUBST_NOTMAKE([AM_V])dnl
 AC_SUBST([AM_DEFAULT_V])dnl
@@ -1024,9 +1133,33 @@ AC_SUBST([AM_DEFAULT_VERBOSITY])dnl
 AM_BACKSLASH='\'
 AC_SUBST([AM_BACKSLASH])dnl
 _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
+dnl Delay evaluation of AM_DEFAULT_VERBOSITY to the end to allow multiple calls
+dnl to AM_SILENT_RULES to change the default value.
+AC_CONFIG_COMMANDS_PRE([dnl
+case $enable_silent_rules in @%:@ (((
+  yes) AM_DEFAULT_VERBOSITY=0;;
+   no) AM_DEFAULT_VERBOSITY=1;;
+esac
+if test $am_cv_make_support_nested_variables = yes; then
+  dnl Using '$V' instead of '$(V)' breaks IRIX make.
+  AM_V='$(V)'
+  AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
+else
+  AM_V=$AM_DEFAULT_VERBOSITY
+  AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
+fi
+])dnl
 ])
 
-# Copyright (C) 2001-2021 Free Software Foundation, Inc.
+# AM_SILENT_RULES([DEFAULT])
+# --------------------------
+# Set the default verbosity level to DEFAULT ("yes" being less verbose, "no" or
+# empty being verbose).
+AC_DEFUN([AM_SILENT_RULES],
+[AC_REQUIRE([_AM_SILENT_RULES])
+AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1])])
+
+# Copyright (C) 2001-2024 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1054,7 +1187,7 @@ fi
 INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
 AC_SUBST([INSTALL_STRIP_PROGRAM])])
 
-# Copyright (C) 2006-2021 Free Software Foundation, Inc.
+# Copyright (C) 2006-2024 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1073,7 +1206,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
 
 # Check how to create a tarball.                            -*- Autoconf -*-
 
-# Copyright (C) 2004-2021 Free Software Foundation, Inc.
+# Copyright (C) 2004-2024 Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
@@ -1119,15 +1252,19 @@ m4_if([$1], [v7],
       am_uid=`id -u || echo unknown`
       am_gid=`id -g || echo unknown`
       AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format])
-      if test $am_uid -le $am_max_uid; then
-         AC_MSG_RESULT([yes])
+      if test x$am_uid = xunknown; then
+        AC_MSG_WARN([ancient id detected; assuming current UID is ok, but dist-ustar might not work])
+      elif test $am_uid -le $am_max_uid; then
+        AC_MSG_RESULT([yes])
       else
-         AC_MSG_RESULT([no])
-         _am_tools=none
+        AC_MSG_RESULT([no])
+        _am_tools=none
       fi
       AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format])
-      if test $am_gid -le $am_max_gid; then
-         AC_MSG_RESULT([yes])
+      if test x$gm_gid = xunknown; then
+        AC_MSG_WARN([ancient id detected; assuming current GID is ok, but dist-ustar might not work])
+      elif test $am_gid -le $am_max_gid; then
+        AC_MSG_RESULT([yes])
       else
         AC_MSG_RESULT([no])
         _am_tools=none
@@ -1204,8 +1341,28 @@ AC_SUBST([am__tar])
 AC_SUBST([am__untar])
 ]) # _AM_PROG_TAR
 
-m4_include([scripts/libtool.m4])
-m4_include([scripts/ltoptions.m4])
-m4_include([scripts/ltsugar.m4])
-m4_include([scripts/ltversion.m4])
-m4_include([scripts/lt~obsolete.m4])
+# Copyright (C) 2022-2024 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# _AM_PROG_XARGS_N
+# ----------------
+# Check whether 'xargs -n' works.  It should work everywhere, so the fallback
+# is not optimized at all as we never expect to use it.
+AC_DEFUN([_AM_PROG_XARGS_N],
+[AC_CACHE_CHECK([xargs -n works], am_cv_xargs_n_works, [dnl
+AS_IF([test "`echo 1 2 3 | xargs -n2 echo`" = "1 2
+3"], [am_cv_xargs_n_works=yes], [am_cv_xargs_n_works=no])])
+AS_IF([test "$am_cv_xargs_n_works" = yes], [am__xargs_n='xargs -n'], [dnl
+  am__xargs_n='am__xargs_n () { shift; sed "s/ /\\n/g" | while read am__xargs_n_arg; do "$@" "$am__xargs_n_arg"; done; }'
+])dnl
+AC_SUBST(am__xargs_n)
+])
+
+m4_include([scripts/autoconf/libtool.m4])
+m4_include([scripts/autoconf/ltoptions.m4])
+m4_include([scripts/autoconf/ltsugar.m4])
+m4_include([scripts/autoconf/ltversion.m4])
+m4_include([scripts/autoconf/lt~obsolete.m4])

+ 4 - 5
png.mod/libpng/arm/arm_init.c

@@ -1,4 +1,3 @@
-
 /* arm_init.c - NEON optimised filter functions
  *
  * Copyright (c) 2018-2022 Cosmin Truta
@@ -36,14 +35,14 @@
 #ifndef PNG_ARM_NEON_FILE
 #  if defined(__aarch64__) || defined(_M_ARM64)
      /* ARM Neon is expected to be unconditionally available on ARM64. */
-#    error "PNG_ARM_NEON_CHECK_SUPPORTED must not be defined on ARM64"
+#    error PNG_ARM_NEON_CHECK_SUPPORTED must not be defined on ARM64
 #  elif defined(__ARM_NEON__) || defined(__ARM_NEON)
      /* ARM Neon is expected to be available on the target CPU architecture. */
-#    error "PNG_ARM_NEON_CHECK_SUPPORTED must not be defined on this CPU arch"
+#    error PNG_ARM_NEON_CHECK_SUPPORTED must not be defined on this CPU arch
 #  elif defined(__linux__)
 #    define PNG_ARM_NEON_FILE "contrib/arm-neon/linux.c"
 #  else
-#    error "No support for run-time ARM Neon checking; use compile-time options"
+#    error No support for run-time ARM Neon checking; use compile-time options
 #  endif
 #endif
 
@@ -54,7 +53,7 @@ static int png_have_neon(png_structp png_ptr);
 #endif /* PNG_ARM_NEON_CHECK_SUPPORTED */
 
 #ifndef PNG_ALIGNED_MEMORY_SUPPORTED
-#  error "ALIGNED_MEMORY is required; set: -DPNG_ALIGNED_MEMORY_SUPPORTED"
+#  error ALIGNED_MEMORY is required; please define PNG_ALIGNED_MEMORY_SUPPORTED
 #endif
 
 void

+ 37 - 230
png.mod/libpng/arm/filter_neon.S

@@ -1,253 +1,60 @@
-
-/* filter_neon.S - NEON optimised filter functions
+/* filter_neon.S - placeholder file
  *
- * Copyright (c) 2018 Cosmin Truta
- * Copyright (c) 2014,2017 Glenn Randers-Pehrson
- * Written by Mans Rullgard, 2011.
+ * Copyright (c) 2024 Cosmin Truta
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
  * and license in png.h
  */
 
+/* IMPORTANT NOTE:
+ *
+ * Historically, the hand-coded assembler implementation of Neon optimizations
+ * in this module had not been in sync with the intrinsics-based implementation
+ * in filter_neon_intrinsics.c and palette_neon_intrinsics.c, at least since
+ * the introduction of riffled palette optimizations. Moreover, the assembler
+ * code used to work on 32-bit ARM only, and it caused problems, even if empty,
+ * on 64-bit ARM.
+ *
+ * All references to this module from our internal build scripts and projects
+ * have been removed.
+ *
+ * For the external projects that might still expect this module to be present,
+ * we leave this stub in place, for the remaining lifetime of libpng-1.6.x.
+ * Everything should continue to function normally, as long as there are no
+ * deliberate attempts to use the old hand-made assembler code. A build error
+ * will be raised otherwise.
+ */
+
 /* This is required to get the symbol renames, which are #defines, and the
  * definitions (or not) of PNG_ARM_NEON_OPT and PNG_ARM_NEON_IMPLEMENTATION.
  */
 #define PNG_VERSION_INFO_ONLY
 #include "../pngpriv.h"
 
-#if (defined(__linux__) || defined(__FreeBSD__)) && defined(__ELF__)
-.section .note.GNU-stack,"",%progbits /* mark stack as non-executable */
-#endif
-
 #ifdef PNG_READ_SUPPORTED
-
-/* Assembler NEON support - only works for 32-bit ARM (i.e. it does not work for
- * ARM64).  The code in arm/filter_neon_intrinsics.c supports ARM64, however it
- * only works if -mfpu=neon is specified on the GCC command line.  See pngpriv.h
- * for the logic which sets PNG_USE_ARM_NEON_ASM:
- */
 #if PNG_ARM_NEON_IMPLEMENTATION == 2 /* hand-coded assembler */
-
 #if PNG_ARM_NEON_OPT > 0
 
-#ifdef __ELF__
-#   define ELF
+#if defined(__clang__)
+#define GNUC_VERSION 0 /* not gcc, although it might pretend to be */
+#elif defined(__GNUC__)
+#define GNUC_MAJOR (__GNUC__ + 0)
+#define GNUC_MINOR (__GNUC_MINOR__ + 0)
+#define GNUC_PATCHLEVEL (__GNUC_PATCHLEVEL__ + 0)
+#define GNUC_VERSION (GNUC_MAJOR * 10000 + GNUC_MINOR * 100 + GNUC_PATCHLEVEL)
 #else
-#   define ELF @
+#define GNUC_VERSION 0 /* not gcc */
 #endif
 
-        .arch armv7-a
-        .fpu  neon
-
-.macro  func    name, export=0
-    .macro endfunc
-ELF     .size   \name, . - \name
-        .endfunc
-        .purgem endfunc
-    .endm
-        .text
-
-        /* Explicitly specifying alignment here because some versions of
-         * GAS don't align code correctly.  This is harmless in correctly
-         * written versions of GAS.
-         */
-        .align 2
-
-    .if \export
-        .global \name
-    .endif
-ELF     .type   \name, STT_FUNC
-        .func   \name
-\name:
-.endm
-
-func    png_read_filter_row_sub4_neon, export=1
-        ldr             r3,  [r0, #4]           @ rowbytes
-        vmov.i8         d3,  #0
-1:
-        vld4.32         {d4[],d5[],d6[],d7[]},    [r1,:128]
-        vadd.u8         d0,  d3,  d4
-        vadd.u8         d1,  d0,  d5
-        vadd.u8         d2,  d1,  d6
-        vadd.u8         d3,  d2,  d7
-        vst4.32         {d0[0],d1[0],d2[0],d3[0]},[r1,:128]!
-        subs            r3,  r3,  #16
-        bgt             1b
-
-        bx              lr
-endfunc
-
-func    png_read_filter_row_sub3_neon, export=1
-        ldr             r3,  [r0, #4]           @ rowbytes
-        vmov.i8         d3,  #0
-        mov             r0,  r1
-        mov             r2,  #3
-        mov             r12, #12
-        vld1.8          {q11},    [r0], r12
-1:
-        vext.8          d5,  d22, d23, #3
-        vadd.u8         d0,  d3,  d22
-        vext.8          d6,  d22, d23, #6
-        vadd.u8         d1,  d0,  d5
-        vext.8          d7,  d23, d23, #1
-        vld1.8          {q11},    [r0], r12
-        vst1.32         {d0[0]},  [r1,:32], r2
-        vadd.u8         d2,  d1,  d6
-        vst1.32         {d1[0]},  [r1], r2
-        vadd.u8         d3,  d2,  d7
-        vst1.32         {d2[0]},  [r1], r2
-        vst1.32         {d3[0]},  [r1], r2
-        subs            r3,  r3,  #12
-        bgt             1b
-
-        bx              lr
-endfunc
-
-func    png_read_filter_row_up_neon, export=1
-        ldr             r3,  [r0, #4]           @ rowbytes
-1:
-        vld1.8          {q0}, [r1,:128]
-        vld1.8          {q1}, [r2,:128]!
-        vadd.u8         q0,  q0,  q1
-        vst1.8          {q0}, [r1,:128]!
-        subs            r3,  r3,  #16
-        bgt             1b
-
-        bx              lr
-endfunc
-
-func    png_read_filter_row_avg4_neon, export=1
-        ldr             r12, [r0, #4]           @ rowbytes
-        vmov.i8         d3,  #0
-1:
-        vld4.32         {d4[],d5[],d6[],d7[]},    [r1,:128]
-        vld4.32         {d16[],d17[],d18[],d19[]},[r2,:128]!
-        vhadd.u8        d0,  d3,  d16
-        vadd.u8         d0,  d0,  d4
-        vhadd.u8        d1,  d0,  d17
-        vadd.u8         d1,  d1,  d5
-        vhadd.u8        d2,  d1,  d18
-        vadd.u8         d2,  d2,  d6
-        vhadd.u8        d3,  d2,  d19
-        vadd.u8         d3,  d3,  d7
-        vst4.32         {d0[0],d1[0],d2[0],d3[0]},[r1,:128]!
-        subs            r12, r12, #16
-        bgt             1b
-
-        bx              lr
-endfunc
-
-func    png_read_filter_row_avg3_neon, export=1
-        push            {r4,lr}
-        ldr             r12, [r0, #4]           @ rowbytes
-        vmov.i8         d3,  #0
-        mov             r0,  r1
-        mov             r4,  #3
-        mov             lr,  #12
-        vld1.8          {q11},    [r0], lr
-1:
-        vld1.8          {q10},    [r2], lr
-        vext.8          d5,  d22, d23, #3
-        vhadd.u8        d0,  d3,  d20
-        vext.8          d17, d20, d21, #3
-        vadd.u8         d0,  d0,  d22
-        vext.8          d6,  d22, d23, #6
-        vhadd.u8        d1,  d0,  d17
-        vext.8          d18, d20, d21, #6
-        vadd.u8         d1,  d1,  d5
-        vext.8          d7,  d23, d23, #1
-        vld1.8          {q11},    [r0], lr
-        vst1.32         {d0[0]},  [r1,:32], r4
-        vhadd.u8        d2,  d1,  d18
-        vst1.32         {d1[0]},  [r1], r4
-        vext.8          d19, d21, d21, #1
-        vadd.u8         d2,  d2,  d6
-        vhadd.u8        d3,  d2,  d19
-        vst1.32         {d2[0]},  [r1], r4
-        vadd.u8         d3,  d3,  d7
-        vst1.32         {d3[0]},  [r1], r4
-        subs            r12, r12, #12
-        bgt             1b
-
-        pop             {r4,pc}
-endfunc
-
-.macro  paeth           rx,  ra,  rb,  rc
-        vaddl.u8        q12, \ra, \rb           @ a + b
-        vaddl.u8        q15, \rc, \rc           @ 2*c
-        vabdl.u8        q13, \rb, \rc           @ pa
-        vabdl.u8        q14, \ra, \rc           @ pb
-        vabd.u16        q15, q12, q15           @ pc
-        vcle.u16        q12, q13, q14           @ pa <= pb
-        vcle.u16        q13, q13, q15           @ pa <= pc
-        vcle.u16        q14, q14, q15           @ pb <= pc
-        vand            q12, q12, q13           @ pa <= pb && pa <= pc
-        vmovn.u16       d28, q14
-        vmovn.u16       \rx, q12
-        vbsl            d28, \rb, \rc
-        vbsl            \rx, \ra, d28
-.endm
-
-func    png_read_filter_row_paeth4_neon, export=1
-        ldr             r12, [r0, #4]           @ rowbytes
-        vmov.i8         d3,  #0
-        vmov.i8         d20, #0
-1:
-        vld4.32         {d4[],d5[],d6[],d7[]},    [r1,:128]
-        vld4.32         {d16[],d17[],d18[],d19[]},[r2,:128]!
-        paeth           d0,  d3,  d16, d20
-        vadd.u8         d0,  d0,  d4
-        paeth           d1,  d0,  d17, d16
-        vadd.u8         d1,  d1,  d5
-        paeth           d2,  d1,  d18, d17
-        vadd.u8         d2,  d2,  d6
-        paeth           d3,  d2,  d19, d18
-        vmov            d20, d19
-        vadd.u8         d3,  d3,  d7
-        vst4.32         {d0[0],d1[0],d2[0],d3[0]},[r1,:128]!
-        subs            r12, r12, #16
-        bgt             1b
-
-        bx              lr
-endfunc
-
-func    png_read_filter_row_paeth3_neon, export=1
-        push            {r4,lr}
-        ldr             r12, [r0, #4]           @ rowbytes
-        vmov.i8         d3,  #0
-        vmov.i8         d4,  #0
-        mov             r0,  r1
-        mov             r4,  #3
-        mov             lr,  #12
-        vld1.8          {q11},    [r0], lr
-1:
-        vld1.8          {q10},    [r2], lr
-        paeth           d0,  d3,  d20, d4
-        vext.8          d5,  d22, d23, #3
-        vadd.u8         d0,  d0,  d22
-        vext.8          d17, d20, d21, #3
-        paeth           d1,  d0,  d17, d20
-        vst1.32         {d0[0]},  [r1,:32], r4
-        vext.8          d6,  d22, d23, #6
-        vadd.u8         d1,  d1,  d5
-        vext.8          d18, d20, d21, #6
-        paeth           d2,  d1,  d18, d17
-        vext.8          d7,  d23, d23, #1
-        vld1.8          {q11},    [r0], lr
-        vst1.32         {d1[0]},  [r1], r4
-        vadd.u8         d2,  d2,  d6
-        vext.8          d19, d21, d21, #1
-        paeth           d3,  d2,  d19, d18
-        vst1.32         {d2[0]},  [r1], r4
-        vmov            d4,  d19
-        vadd.u8         d3,  d3,  d7
-        vst1.32         {d3[0]},  [r1], r4
-        subs            r12, r12, #12
-        bgt             1b
+#if (GNUC_VERSION > 0) && (GNUC_VERSION < 40300)
+#error "PNG_ARM_NEON is not supported with gcc versions earlier than 4.3.0"
+#elif GNUC_VERSION == 40504
+#error "PNG_ARM_NEON is not supported with gcc version 4.5.4"
+#else
+#error "Please use 'arm/*_neon_intrinsics.c' for PNG_ARM_NEON support"
+#endif
 
-        pop             {r4,pc}
-endfunc
 #endif /* PNG_ARM_NEON_OPT > 0 */
-#endif /* PNG_ARM_NEON_IMPLEMENTATION == 2 (assembler) */
+#endif /* PNG_ARM_NEON_IMPLEMENTATION == 2 */
 #endif /* READ */

+ 0 - 1
png.mod/libpng/arm/filter_neon_intrinsics.c

@@ -1,4 +1,3 @@
-
 /* filter_neon_intrinsics.c - NEON optimised filter functions
  *
  * Copyright (c) 2018 Cosmin Truta

+ 1 - 2
png.mod/libpng/arm/palette_neon_intrinsics.c

@@ -1,4 +1,3 @@
-
 /* palette_neon_intrinsics.c - NEON optimised palette expansion functions
  *
  * Copyright (c) 2018-2019 Cosmin Truta
@@ -64,7 +63,7 @@ png_do_expand_palette_rgba8_neon(png_structrp png_ptr, png_row_infop row_info,
 {
    png_uint_32 row_width = row_info->width;
    const png_uint_32 *riffled_palette =
-      (const png_uint_32 *)png_ptr->riffled_palette;
+      png_aligncastconst(png_const_uint_32p, png_ptr->riffled_palette);
    const png_uint_32 pixels_per_chunk = 4;
    png_uint_32 i;
 

+ 3 - 2
png.mod/libpng/autogen.sh

@@ -82,8 +82,9 @@ libpng_autotools_files="Makefile.in aclocal.m4 config.guess config.h.in
 libpng_autotools_extra="compile config.h.in~"
 #
 # These are separate because 'maintainer-clean' does not remove them.
-libpng_libtool_files="scripts/libtool.m4 scripts/ltoptions.m4\
-   scripts/ltsugar.m4 scripts/ltversion.m4 scripts/lt~obsolete.m4"
+libpng_libtool_files="scripts/autoconf/libtool.m4 scripts/autoconf/ltoptions.m4\
+   scripts/autoconf/ltsugar.m4 scripts/autoconf/ltversion.m4\
+   scripts/autoconf/lt~obsolete.m4"
 
 libpng_autotools_dirs="autom4te.cache" # not required
 #

+ 19 - 0
png.mod/libpng/ci/LICENSE_MIT.txt

@@ -0,0 +1,19 @@
+MIT License
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.

+ 25 - 0
png.mod/libpng/ci/README.md

@@ -0,0 +1,25 @@
+Scripts for the Continuous Integration of the PNG Reference Library
+===================================================================
+
+Copyright Notice
+----------------
+
+Copyright (c) 2019-2025 Cosmin Truta.
+
+Use, modification and distribution are subject to the MIT License.
+Please see the accompanying file `LICENSE_MIT.txt` or visit
+https://opensource.org/license/mit
+
+File List
+---------
+
+    LICENSE_MIT.txt         ==>  The License file
+    README.md               ==>  This file
+    ci_lint.sh              ==>  Lint the source code
+    ci_shellify.sh          ==>  Convert select definitions to shell syntax
+    ci_verify_cmake.sh      ==>  Verify the build driven by CMakeLists.txt
+    ci_verify_configure.sh  ==>  Verify the build driven by configure
+    ci_verify_makefiles.sh  ==>  Verify the build driven by scripts/makefile.*
+    ci_verify_version.sh    ==>  Verify the consistency of version definitions
+    lib/ci.lib.sh           ==>  Shell utilities for the main ci_*.sh scripts
+    targets/*/ci_env.*.sh   ==>  Shell environments for cross-platform testing

+ 142 - 0
png.mod/libpng/ci/ci_lint.sh

@@ -0,0 +1,142 @@
+#!/usr/bin/env bash
+set -o errexit -o pipefail -o posix
+
+# Copyright (c) 2019-2025 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+# shellcheck source=ci/lib/ci.lib.sh
+source "$(dirname "$0")/lib/ci.lib.sh"
+cd "$CI_TOPLEVEL_DIR"
+
+# Initialize the global constants CI_{...}{CHECK,CHECKER,LINT}.
+CI_SHELLCHECK="${CI_SHELLCHECK:-shellcheck}"
+CI_EDITORCONFIG_CHECKER="${CI_EDITORCONFIG_CHECKER:-editorconfig-checker}"
+CI_YAMLLINT="${CI_YAMLLINT:-yamllint}"
+
+# Initialize the global lint status.
+CI_LINT_STATUS=0
+
+function ci_init_lint {
+    ci_info "## START OF LINTING ##"
+    local my_program
+    # Complete the initialization of CI_SHELLCHECK.
+    # Set it to the empty string if the shellcheck program is unavailable.
+    my_program="$(command -v "$CI_SHELLCHECK")" || {
+        ci_warn "program not found: '$CI_SHELLCHECK'"
+    }
+    CI_SHELLCHECK="$my_program"
+    # Complete the initialization of CI_EDITORCONFIG_CHECKER.
+    # Set it to the empty string if the editorconfig-checker program is unavailable.
+    my_program="$(command -v "$CI_EDITORCONFIG_CHECKER")" || {
+        ci_warn "program not found: '$CI_EDITORCONFIG_CHECKER'"
+    }
+    CI_EDITORCONFIG_CHECKER="$my_program"
+    # Complete the initialization of CI_YAMLLINT.
+    # Set it to the empty string if the yamllint program is unavailable.
+    my_program="$(command -v "$CI_YAMLLINT")" || {
+        ci_warn "program not found: '$CI_YAMLLINT'"
+    }
+    CI_YAMLLINT="$my_program"
+}
+
+function ci_finish_lint {
+    ci_info "## END OF LINTING ##"
+    if [[ $CI_LINT_STATUS -eq 0 ]]
+    then
+        ci_info "## SUCCESS ##"
+    else
+        ci_info "linting failed"
+    fi
+    return "$CI_LINT_STATUS"
+}
+
+function ci_lint_ci_scripts {
+    [[ -x $CI_SHELLCHECK ]] || {
+        ci_warn "## NOT LINTING: CI scripts ##"
+        return 0
+    }
+    ci_info "## LINTING: CI scripts ##"
+    ci_spawn "$CI_SHELLCHECK" --version
+    find ./ci -name "ci_*.sh" -not -name "ci_env.*.sh" | {
+        local my_file
+        while IFS="" read -r my_file
+        do
+            ci_spawn "$CI_SHELLCHECK" -x "$my_file" || {
+                # Linting failed.
+                return 1
+            }
+        done
+    }
+}
+
+function ci_lint_text_files {
+    [[ -x $CI_EDITORCONFIG_CHECKER ]] || {
+        ci_warn "## NOT LINTING: text files ##"
+        return 0
+    }
+    ci_info "## LINTING: text files ##"
+    ci_spawn "$CI_EDITORCONFIG_CHECKER" --version
+    ci_spawn "$CI_EDITORCONFIG_CHECKER" --config .editorconfig-checker.json || {
+        # Linting failed.
+        return 1
+    }
+}
+
+function ci_lint_yaml_files {
+    [[ -x $CI_YAMLLINT ]] || {
+        ci_warn "## NOT LINTING: YAML files ##"
+        return 0
+    }
+    ci_info "## LINTING: YAML files ##"
+    ci_spawn "$CI_YAMLLINT" --version
+    # Considering that the YAML format is an extension of the JSON format,
+    # we can lint both the YAML files and the plain JSON files here.
+    find . \( -iname "*.yml" -o -iname "*.yaml" -o -iname "*.json" \) -not -path "./out/*" | {
+        local my_file
+        while IFS="" read -r my_file
+        do
+            ci_spawn "$CI_YAMLLINT" --strict "$my_file" || {
+                # Linting failed.
+                return 1
+            }
+        done
+    }
+}
+
+function ci_lint {
+    ci_init_lint
+    ci_lint_ci_scripts || CI_LINT_STATUS=1
+    ci_lint_text_files || CI_LINT_STATUS=1
+    ci_lint_yaml_files || CI_LINT_STATUS=1
+    # TODO: ci_lint_png_files, etc.
+    ci_finish_lint
+}
+
+function usage {
+    echo "usage: $CI_SCRIPT_NAME [<options>]"
+    echo "options: -?|-h|--help"
+    exit "${@:-0}"
+}
+
+function main {
+    local opt
+    while getopts ":" opt
+    do
+        # This ain't a while-loop. It only pretends to be.
+        [[ $1 == -[?h]* || $1 == --help || $1 == --help=* ]] && usage 0
+        ci_err "unknown option: '$1'"
+    done
+    shift $((OPTIND - 1))
+    [[ $# -eq 0 ]] || {
+        echo >&2 "error: unexpected argument: '$1'"
+        usage 2
+    }
+    # And... go!
+    ci_lint
+}
+
+main "$@"

+ 143 - 114
png.mod/libpng/ci/ci_verify_cmake.sh

@@ -1,51 +1,27 @@
 #!/usr/bin/env bash
-set -e
+set -o errexit -o pipefail -o posix
 
-# ci_verify_cmake.sh
-# Continuously integrate libpng using CMake.
+# Copyright (c) 2019-2025 Cosmin Truta.
 #
-# Copyright (c) 2019-2023 Cosmin Truta.
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
 #
-# This software is released under the libpng license.
-# For conditions of distribution and use, see the disclaimer
-# and license in png.h.
+# SPDX-License-Identifier: MIT
 
-CI_SCRIPTNAME="$(basename "$0")"
-CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)"
-CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")"
-CI_BUILDDIR="$CI_SRCDIR/out/ci_verify_cmake.build"
-CI_INSTALLDIR="$CI_SRCDIR/out/ci_verify_cmake.install"
+# shellcheck source=ci/lib/ci.lib.sh
+source "$(dirname "$0")/lib/ci.lib.sh"
+cd "$CI_TOPLEVEL_DIR"
 
-# Keep the following relative paths in sync with the absolute paths.
-# We use them for the benefit of native Windows tools that might be
-# otherwise confused by the path encoding used by Bash-on-Windows.
-CI_SRCDIR_FROM_BUILDDIR="../.."
-CI_INSTALLDIR_FROM_BUILDDIR="../ci_verify_cmake.install"
+CI_SRC_DIR="$CI_TOPLEVEL_DIR"
+CI_OUT_DIR="$CI_TOPLEVEL_DIR/out"
+CI_BUILD_DIR="$CI_OUT_DIR/ci_verify_cmake.$CI_TARGET_SYSTEM.$CI_TARGET_ARCH.build"
+CI_INSTALL_DIR="$CI_OUT_DIR/ci_verify_cmake.$CI_TARGET_SYSTEM.$CI_TARGET_ARCH.install"
 
-function ci_info {
-    printf >&2 "%s: %s\\n" "$CI_SCRIPTNAME" "$*"
-}
-
-function ci_err {
-    printf >&2 "%s: error: %s\\n" "$CI_SCRIPTNAME" "$*"
-    exit 2
-}
-
-function ci_spawn {
-    printf >&2 "%s: executing:" "$CI_SCRIPTNAME"
-    printf >&2 " %q" "$@"
-    printf >&2 "\\n"
-    "$@"
-}
-
-function ci_init_cmake_build {
-    CI_SYSTEM_NAME="$(uname -s)"
-    CI_MACHINE_NAME="$(uname -m)"
+function ci_init_build {
+    # Ensure that the mandatory variables are initialized.
     CI_CMAKE="${CI_CMAKE:-cmake}"
     CI_CTEST="${CI_CTEST:-ctest}"
     CI_CMAKE_BUILD_TYPE="${CI_CMAKE_BUILD_TYPE:-Release}"
-    [[ -x $(command -v ninja) ]] &&
-        CI_CMAKE_GENERATOR="${CI_CMAKE_GENERATOR:-Ninja}"
     if [[ $CI_CMAKE_GENERATOR == "Visual Studio"* ]]
     then
         # Clean up incidental mixtures of Windows and Bash-on-Windows
@@ -53,18 +29,26 @@ function ci_init_cmake_build {
         [[ $TEMP && ( $Temp || $temp ) ]] && unset TEMP
         [[ $TMP && ( $Tmp || $tmp ) ]] && unset TMP
         # Ensure that CI_CMAKE_GENERATOR_PLATFORM is initialized for this generator.
-        [[ $CI_CMAKE_GENERATOR_PLATFORM ]] ||
-            ci_err "missing: \$CI_CMAKE_GENERATOR_PLATFORM"
+        [[ $CI_CMAKE_GENERATOR_PLATFORM ]] || {
+            ci_err_internal "missing \$CI_CMAKE_GENERATOR_PLATFORM"
+        }
+    elif [[ -x $(command -v ninja) ]]
+    then
+        CI_CMAKE_GENERATOR="${CI_CMAKE_GENERATOR:-Ninja}"
     fi
 }
 
-function ci_trace_cmake_build {
+function ci_trace_build {
     ci_info "## START OF CONFIGURATION ##"
-    ci_info "system name: $CI_SYSTEM_NAME"
-    ci_info "machine hardware name: $CI_MACHINE_NAME"
-    ci_info "source directory: $CI_SRCDIR"
-    ci_info "build directory: $CI_BUILDDIR"
-    ci_info "install directory: $CI_INSTALLDIR"
+    ci_info "build arch: $CI_BUILD_ARCH"
+    ci_info "build system: $CI_BUILD_SYSTEM"
+    [[ "$CI_TARGET_SYSTEM.$CI_TARGET_ARCH" != "$CI_BUILD_SYSTEM.$CI_BUILD_ARCH" ]] && {
+        ci_info "target arch: $CI_TARGET_ARCH"
+        ci_info "target system: $CI_TARGET_SYSTEM"
+    }
+    ci_info "source directory: $CI_SRC_DIR"
+    ci_info "build directory: $CI_BUILD_DIR"
+    ci_info "install directory: $CI_INSTALL_DIR"
     ci_info "environment option: \$CI_CMAKE: '$CI_CMAKE'"
     ci_info "environment option: \$CI_CMAKE_GENERATOR: '$CI_CMAKE_GENERATOR'"
     ci_info "environment option: \$CI_CMAKE_GENERATOR_PLATFORM: '$CI_CMAKE_GENERATOR_PLATFORM'"
@@ -79,102 +63,147 @@ function ci_trace_cmake_build {
     ci_info "environment option: \$CI_AR: '$CI_AR'"
     ci_info "environment option: \$CI_RANLIB: '$CI_RANLIB'"
     ci_info "environment option: \$CI_SANITIZERS: '$CI_SANITIZERS'"
+    ci_info "environment option: \$CI_FORCE: '$CI_FORCE'"
+    ci_info "environment option: \$CI_NO_BUILD: '$CI_NO_BUILD'"
     ci_info "environment option: \$CI_NO_TEST: '$CI_NO_TEST'"
     ci_info "environment option: \$CI_NO_INSTALL: '$CI_NO_INSTALL'"
     ci_info "environment option: \$CI_NO_CLEAN: '$CI_NO_CLEAN'"
     ci_info "executable: \$CI_CMAKE: $(command -V "$CI_CMAKE")"
     ci_info "executable: \$CI_CTEST: $(command -V "$CI_CTEST")"
-    [[ $CI_CC ]] &&
+    [[ $CI_CC ]] && {
         ci_info "executable: \$CI_CC: $(command -V "$CI_CC")"
-    [[ $CI_AR ]] &&
+    }
+    [[ $CI_AR ]] && {
         ci_info "executable: \$CI_AR: $(command -V "$CI_AR")"
-    [[ $CI_RANLIB ]] &&
+    }
+    [[ $CI_RANLIB ]] && {
         ci_info "executable: \$CI_RANLIB: $(command -V "$CI_RANLIB")"
+    }
     ci_info "## END OF CONFIGURATION ##"
 }
 
-function ci_cleanup_old_cmake_build {
-    [[ ! -e $CI_BUILDDIR ]] ||
-        ci_spawn rm -fr "$CI_BUILDDIR"
-    [[ ! -e $CI_INSTALLDIR ]] ||
-        ci_spawn rm -fr "$CI_INSTALLDIR"
+function ci_cleanup_old_build {
+    ci_info "## START OF PRE-BUILD CLEANUP ##"
+    [[ ! -e $CI_BUILD_DIR && ! -e $CI_INSTALL_DIR ]] || {
+        ci_spawn rm -fr "$CI_BUILD_DIR"
+        ci_spawn rm -fr "$CI_INSTALL_DIR"
+    }
+    ci_info "## END OF PRE-BUILD CLEANUP ##"
 }
 
-function ci_build_cmake {
+function ci_build {
     ci_info "## START OF BUILD ##"
-    ci_spawn "$(command -v "$CI_CMAKE")" --version
-    ci_spawn "$(command -v "$CI_CTEST")" --version
-    [[ $CI_CMAKE_GENERATOR == *"Ninja"* ]] &&
-        ci_spawn "$(command -v ninja)" --version
-    # Initialize ALL_CC_FLAGS as a string.
-    local ALL_CC_FLAGS="$CI_CC_FLAGS"
-    [[ $CI_SANITIZERS ]] &&
-        ALL_CC_FLAGS="-fsanitize=$CI_SANITIZERS $ALL_CC_FLAGS"
-    # Initialize ALL_CMAKE_VARS, ALL_CMAKE_BUILD_FLAGS and ALL_CTEST_FLAGS as arrays.
-    local ALL_CMAKE_VARS=()
-    [[ $CI_CMAKE_TOOLCHAIN_FILE ]] &&
-        ALL_CMAKE_VARS+=(-DCMAKE_TOOLCHAIN_FILE="$CI_CMAKE_TOOLCHAIN_FILE")
-    [[ $CI_CC ]] &&
-        ALL_CMAKE_VARS+=(-DCMAKE_C_COMPILER="$CI_CC")
-    [[ $ALL_CC_FLAGS ]] &&
-        ALL_CMAKE_VARS+=(-DCMAKE_C_FLAGS="$ALL_CC_FLAGS")
-    [[ $CI_AR ]] &&
-        ALL_CMAKE_VARS+=(-DCMAKE_AR="$CI_AR")
-    [[ $CI_RANLIB ]] &&
-        ALL_CMAKE_VARS+=(-DCMAKE_RANLIB="$CI_RANLIB")
-    ALL_CMAKE_VARS+=(-DCMAKE_BUILD_TYPE="$CI_CMAKE_BUILD_TYPE")
-    ALL_CMAKE_VARS+=(-DCMAKE_VERBOSE_MAKEFILE=ON)
-    [[ $CI_NO_TEST ]] &&
-        ALL_CMAKE_VARS+=(-DPNG_TESTS=OFF)
-    ALL_CMAKE_VARS+=($CI_CMAKE_VARS)
-    local ALL_CMAKE_BUILD_FLAGS=($CI_CMAKE_BUILD_FLAGS)
-    local ALL_CTEST_FLAGS=($CI_CTEST_FLAGS)
+    # Adjust the CI environment variables, as needed.
+    CI_CMAKE="$(command -v "$CI_CMAKE")" || ci_err "bad or missing \$CI_CMAKE"
+    ci_spawn "$CI_CMAKE" --version
+    CI_CTEST="$(command -v "$CI_CTEST")" || ci_err "bad or missing \$CI_CTEST"
+    ci_spawn "$CI_CTEST" --version
+    [[ $CI_CMAKE_GENERATOR == *"Ninja"* ]] && {
+        CI_NINJA="$(command -v ninja)" || ci_err "bad or missing ninja, no pun intended"
+        ci_spawn "$CI_NINJA" --version
+    }
+    [[ $CI_AR ]] && {
+        # Use the full path of CI_AR to work around a mysterious CMake error.
+        CI_AR="$(command -v "$CI_AR")" || ci_err "bad or missing \$CI_AR"
+    }
+    [[ $CI_RANLIB ]] && {
+        # Use the full path of CI_RANLIB to work around a mysterious CMake error.
+        CI_RANLIB="$(command -v "$CI_RANLIB")" || ci_err "bad or missing \$CI_RANLIB"
+    }
     # Export the CMake environment variables.
-    [[ $CI_CMAKE_GENERATOR ]] &&
+    [[ $CI_CMAKE_GENERATOR ]] && {
         ci_spawn export CMAKE_GENERATOR="$CI_CMAKE_GENERATOR"
-    [[ $CI_CMAKE_GENERATOR_PLATFORM ]] &&
+    }
+    [[ $CI_CMAKE_GENERATOR_PLATFORM ]] && {
         ci_spawn export CMAKE_GENERATOR_PLATFORM="$CI_CMAKE_GENERATOR_PLATFORM"
-    # Build and install.
-    # Use $CI_SRCDIR_FROM_BUILDDIR and $CI_INSTALLDIR_FROM_BUILDDIR
-    # instead of $CI_SRCDIR and $CI_INSTALLDIR from this point onwards.
-    ci_spawn mkdir -p "$CI_BUILDDIR"
-    ci_spawn cd "$CI_BUILDDIR"
-    [[ $CI_SRCDIR -ef $CI_SRCDIR_FROM_BUILDDIR ]] ||
-        ci_err "assertion failed: testing: '$CI_SRCDIR' -ef '$CI_SRCDIR_FROM_BUILDDIR'"
-    ci_spawn mkdir -p "$CI_INSTALLDIR"
-    [[ $CI_INSTALLDIR -ef $CI_INSTALLDIR_FROM_BUILDDIR ]] ||
-        ci_err "assertion failed: testing: '$CI_INSTALLDIR' -ef '$CI_INSTALLDIR_FROM_BUILDDIR'"
-    ci_spawn "$CI_CMAKE" -DCMAKE_INSTALL_PREFIX="$CI_INSTALLDIR_FROM_BUILDDIR" \
-                         "${ALL_CMAKE_VARS[@]}" \
-                         "$CI_SRCDIR_FROM_BUILDDIR"
-    ci_spawn "$CI_CMAKE" --build . \
-                         --config "$CI_CMAKE_BUILD_TYPE" \
-                         "${ALL_CMAKE_BUILD_FLAGS[@]}"
-    [[ $CI_NO_TEST ]] ||
+    }
+    # Initialize and populate the local arrays.
+    local all_cmake_vars=()
+    local all_cmake_build_flags=()
+    local all_ctest_flags=()
+    [[ $CI_CMAKE_TOOLCHAIN_FILE ]] && {
+        all_cmake_vars+=("-DCMAKE_TOOLCHAIN_FILE=$CI_CMAKE_TOOLCHAIN_FILE")
+    }
+    [[ $CI_CC ]] && {
+        all_cmake_vars+=("-DCMAKE_C_COMPILER=$CI_CC")
+    }
+    [[ $CI_CC_FLAGS || $CI_SANITIZERS ]] && {
+        [[ $CI_SANITIZERS ]] && CI_CC_FLAGS+="${CI_CC_FLAGS:+" "}-fsanitize=$CI_SANITIZERS"
+        all_cmake_vars+=("-DCMAKE_C_FLAGS=$CI_CC_FLAGS")
+    }
+    [[ $CI_AR ]] && {
+        all_cmake_vars+=("-DCMAKE_AR=$CI_AR")
+    }
+    [[ $CI_RANLIB ]] && {
+        all_cmake_vars+=("-DCMAKE_RANLIB=$CI_RANLIB")
+    }
+    all_cmake_vars+=("-DCMAKE_BUILD_TYPE=$CI_CMAKE_BUILD_TYPE")
+    all_cmake_vars+=("-DCMAKE_VERBOSE_MAKEFILE=ON")
+    all_cmake_vars+=($CI_CMAKE_VARS)
+    all_cmake_build_flags+=($CI_CMAKE_BUILD_FLAGS)
+    all_ctest_flags+=($CI_CTEST_FLAGS)
+    # And... build!
+    ci_spawn mkdir -p "$CI_BUILD_DIR"
+    # Spawn "cmake ...".
+    ci_spawn "$CI_CMAKE" -B "$CI_BUILD_DIR" \
+                         -S . \
+                         -DCMAKE_INSTALL_PREFIX="$CI_INSTALL_DIR" \
+                         "${all_cmake_vars[@]}"
+    ci_expr $((CI_NO_BUILD)) || {
+        # Spawn "cmake --build ...".
+        ci_spawn "$CI_CMAKE" --build "$CI_BUILD_DIR" \
+                             --config "$CI_CMAKE_BUILD_TYPE" \
+                             "${all_cmake_build_flags[@]}"
+    }
+    ci_expr $((CI_NO_TEST)) || {
+        # Spawn "ctest" if testing is not disabled.
+        ci_spawn pushd "$CI_BUILD_DIR"
         ci_spawn "$CI_CTEST" --build-config "$CI_CMAKE_BUILD_TYPE" \
-                             "${ALL_CTEST_FLAGS[@]}"
-    [[ $CI_NO_INSTALL ]] ||
-        ci_spawn "$CI_CMAKE" --build . \
+                             "${all_ctest_flags[@]}"
+        ci_spawn popd
+    }
+    ci_expr $((CI_NO_INSTALL)) || {
+        # Spawn "cmake --build ... --target install" if installation is not disabled.
+        ci_spawn "$CI_CMAKE" --build "$CI_BUILD_DIR" \
                              --config "$CI_CMAKE_BUILD_TYPE" \
                              --target install \
-                             "${ALL_CMAKE_BUILD_FLAGS[@]}"
-    [[ $CI_NO_CLEAN ]] ||
-        ci_spawn "$CI_CMAKE" --build . \
+                             "${all_cmake_build_flags[@]}"
+    }
+    ci_expr $((CI_NO_CLEAN)) || {
+        # Spawn "make --build ... --target clean" if cleaning is not disabled.
+        ci_spawn "$CI_CMAKE" --build "$CI_BUILD_DIR" \
                              --config "$CI_CMAKE_BUILD_TYPE" \
                              --target clean \
-                             "${ALL_CMAKE_BUILD_FLAGS[@]}"
+                             "${all_cmake_build_flags[@]}"
+    }
     ci_info "## END OF BUILD ##"
 }
 
+function usage {
+    echo "usage: $CI_SCRIPT_NAME [<options>]"
+    echo "options: -?|-h|--help"
+    exit "${@:-0}"
+}
+
 function main {
+    local opt
+    while getopts ":" opt
+    do
+        # This ain't a while-loop. It only pretends to be.
+        [[ $1 == -[?h]* || $1 == --help || $1 == --help=* ]] && usage 0
+        ci_err "unknown option: '$1'"
+    done
+    shift $((OPTIND - 1))
+    # And... go!
+    ci_init_build
+    ci_trace_build
     [[ $# -eq 0 ]] || {
-        ci_info "note: this program accepts environment options only"
-        ci_err "unexpected command arguments: '$*'"
+        echo >&2 "error: unexpected argument: '$1'"
+        echo >&2 "note: this program accepts environment options only"
+        usage 2
     }
-    ci_init_cmake_build
-    ci_trace_cmake_build
-    ci_cleanup_old_cmake_build
-    ci_build_cmake
+    ci_cleanup_old_build
+    ci_build
 }
 
 main "$@"

+ 125 - 71
png.mod/libpng/ci/ci_verify_configure.sh

@@ -1,56 +1,50 @@
 #!/usr/bin/env bash
-set -e
+set -o errexit -o pipefail -o posix
 
-# ci_verify_configure.sh
-# Continuously integrate libpng using the configure script.
+# Copyright (c) 2019-2025 Cosmin Truta.
 #
-# Copyright (c) 2019-2023 Cosmin Truta.
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
 #
-# This software is released under the libpng license.
-# For conditions of distribution and use, see the disclaimer
-# and license in png.h.
+# SPDX-License-Identifier: MIT
 
-CI_SCRIPTNAME="$(basename "$0")"
-CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)"
-CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")"
-CI_BUILDDIR="$CI_SRCDIR/out/ci_verify_configure.build"
-CI_INSTALLDIR="$CI_SRCDIR/out/ci_verify_configure.install"
+# shellcheck source=ci/lib/ci.lib.sh
+source "$(dirname "$0")/lib/ci.lib.sh"
+cd "$CI_TOPLEVEL_DIR"
 
-function ci_info {
-    printf >&2 "%s: %s\\n" "$CI_SCRIPTNAME" "$*"
-}
-
-function ci_err {
-    printf >&2 "%s: error: %s\\n" "$CI_SCRIPTNAME" "$*"
-    exit 2
-}
+CI_SRC_DIR="$CI_TOPLEVEL_DIR"
+CI_OUT_DIR="$CI_TOPLEVEL_DIR/out"
+CI_BUILD_DIR="$CI_OUT_DIR/ci_verify_configure.$CI_TARGET_SYSTEM.$CI_TARGET_ARCH.build"
+CI_INSTALL_DIR="$CI_OUT_DIR/ci_verify_configure.$CI_TARGET_SYSTEM.$CI_TARGET_ARCH.install"
 
-function ci_spawn {
-    printf >&2 "%s: executing:" "$CI_SCRIPTNAME"
-    printf >&2 " %q" "$@"
-    printf >&2 "\\n"
-    "$@"
-}
-
-function ci_init_configure_build {
-    CI_SYSTEM_NAME="$(uname -s)"
-    CI_MACHINE_NAME="$(uname -m)"
+function ci_init_build {
+    # Ensure that the mandatory variables are initialized.
     CI_MAKE="${CI_MAKE:-make}"
-    # Set CI_CC to cc by default, if the cc command is available.
-    # The configure script defaults CC to gcc, which is not always a good idea.
-    [[ -x $(command -v cc) ]] && CI_CC="${CI_CC:-cc}"
+    [[ "$CI_TARGET_SYSTEM.$CI_TARGET_ARCH" != "$CI_BUILD_SYSTEM.$CI_BUILD_ARCH" ]] || {
+        # For native builds, set CI_CC to "cc" by default if the cc command is available.
+        # The configure script defaults CC to "gcc", which is not always a good idea.
+        [[ -x $(command -v cc) ]] && CI_CC="${CI_CC:-cc}"
+    }
     # Ensure that the CI_ variables that cannot be customized reliably are not initialized.
-    [[ ! $CI_CONFIGURE_VARS ]] || ci_err "unexpected: \$CI_CONFIGURE_VARS='$CI_CONFIGURE_VARS'"
-    [[ ! $CI_MAKE_VARS ]] || ci_err "unexpected: \$CI_MAKE_VARS='$CI_MAKE_VARS'"
+    [[ ! $CI_CONFIGURE_VARS ]] || {
+        ci_err "unsupported: \$CI_CONFIGURE_VARS='$CI_CONFIGURE_VARS'"
+    }
+    [[ ! $CI_MAKE_VARS ]] || {
+        ci_err "unsupported: \$CI_MAKE_VARS='$CI_MAKE_VARS'"
+    }
 }
 
-function ci_trace_configure_build {
+function ci_trace_build {
     ci_info "## START OF CONFIGURATION ##"
-    ci_info "system name: $CI_SYSTEM_NAME"
-    ci_info "machine hardware name: $CI_MACHINE_NAME"
-    ci_info "source directory: $CI_SRCDIR"
-    ci_info "build directory: $CI_BUILDDIR"
-    ci_info "install directory: $CI_INSTALLDIR"
+    ci_info "build arch: $CI_BUILD_ARCH"
+    ci_info "build system: $CI_BUILD_SYSTEM"
+    [[ "$CI_TARGET_SYSTEM.$CI_TARGET_ARCH" != "$CI_BUILD_SYSTEM.$CI_BUILD_ARCH" ]] && {
+        ci_info "target arch: $CI_TARGET_ARCH"
+        ci_info "target system: $CI_TARGET_SYSTEM"
+    }
+    ci_info "source directory: $CI_SRC_DIR"
+    ci_info "build directory: $CI_BUILD_DIR"
+    ci_info "install directory: $CI_INSTALL_DIR"
     ci_info "environment option: \$CI_CONFIGURE_FLAGS: '$CI_CONFIGURE_FLAGS'"
     ci_info "environment option: \$CI_MAKE: '$CI_MAKE'"
     ci_info "environment option: \$CI_MAKE_FLAGS: '$CI_MAKE_FLAGS'"
@@ -63,31 +57,58 @@ function ci_trace_configure_build {
     ci_info "environment option: \$CI_LD: '$CI_LD'"
     ci_info "environment option: \$CI_LD_FLAGS: '$CI_LD_FLAGS'"
     ci_info "environment option: \$CI_SANITIZERS: '$CI_SANITIZERS'"
+    ci_info "environment option: \$CI_FORCE: '$CI_FORCE'"
+    ci_info "environment option: \$CI_NO_BUILD: '$CI_NO_BUILD'"
     ci_info "environment option: \$CI_NO_TEST: '$CI_NO_TEST'"
     ci_info "environment option: \$CI_NO_INSTALL: '$CI_NO_INSTALL'"
     ci_info "environment option: \$CI_NO_CLEAN: '$CI_NO_CLEAN'"
     ci_info "executable: \$CI_MAKE: $(command -V "$CI_MAKE")"
-    [[ $CI_CC ]] &&
+    [[ $CI_CC ]] && {
         ci_info "executable: \$CI_CC: $(command -V "$CI_CC")"
-    [[ $CI_CPP ]] &&
+    }
+    [[ $CI_CPP ]] && {
         ci_info "executable: \$CI_CPP: $(command -V "$CI_CPP")"
-    [[ $CI_AR ]] &&
+    }
+    [[ $CI_AR ]] && {
         ci_info "executable: \$CI_AR: $(command -V "$CI_AR")"
-    [[ $CI_RANLIB ]] &&
+    }
+    [[ $CI_RANLIB ]] && {
         ci_info "executable: \$CI_RANLIB: $(command -V "$CI_RANLIB")"
-    [[ $CI_LD ]] &&
+    }
+    [[ $CI_LD ]] && {
         ci_info "executable: \$CI_LD: $(command -V "$CI_LD")"
+    }
     ci_info "## END OF CONFIGURATION ##"
 }
 
-function ci_cleanup_old_configure_build {
-    [[ ! -e $CI_BUILDDIR ]] ||
-        ci_spawn rm -fr "$CI_BUILDDIR"
-    [[ ! -e $CI_INSTALLDIR ]] ||
-        ci_spawn rm -fr "$CI_INSTALLDIR"
+function ci_cleanup_old_build {
+    ci_info "## START OF PRE-BUILD CLEANUP ##"
+    [[ ! -e $CI_BUILD_DIR && ! -e $CI_INSTALL_DIR ]] || {
+        ci_spawn rm -fr "$CI_BUILD_DIR"
+        ci_spawn rm -fr "$CI_INSTALL_DIR"
+    }
+    [[ ! -e "$CI_SRC_DIR/config.status" ]] || {
+        ci_warn "unexpected build configuration file: '$CI_SRC_DIR/config.status'"
+        if ci_expr $((CI_FORCE))
+        then
+            # Delete the old config and (possibly) the old build.
+            ci_info "note: forcing an in-tree build cleanup"
+            if [[ -f $CI_SRC_DIR/Makefile ]]
+            then
+                ci_spawn make -C "$CI_SRC_DIR" distclean
+            else
+                ci_spawn rm -fr "$CI_SRC_DIR"/config.{log,status}
+            fi
+        else
+            # Alert the user, but do not delete their files.
+            ci_warn "the configure script might fail"
+            ci_info "hint: consider using the option \$CI_FORCE=1"
+        fi
+    }
+    ci_info "## END OF PRE-BUILD CLEANUP ##"
 }
 
-function ci_build_configure {
+function ci_build {
     ci_info "## START OF BUILD ##"
     # Export the configure build environment.
     [[ $CI_CC ]] && ci_spawn export CC="$CI_CC"
@@ -96,33 +117,66 @@ function ci_build_configure {
     [[ $CI_CPP_FLAGS ]] && ci_spawn export CPPFLAGS="$CI_CPP_FLAGS"
     [[ $CI_AR ]] && ci_spawn export AR="$CI_AR"
     [[ $CI_RANLIB ]] && ci_spawn export RANLIB="$CI_RANLIB"
-    [[ $CI_LD ]] && ci_spawn export CPP="$CI_LD"
+    [[ $CI_LD ]] && ci_spawn export LD="$CI_LD"
     [[ $CI_LD_FLAGS ]] && ci_spawn export LDFLAGS="$CI_LD_FLAGS"
     [[ $CI_SANITIZERS ]] && {
-        ci_spawn export CFLAGS="-fsanitize=$CI_SANITIZERS ${CFLAGS:-"-O2"}"
-        ci_spawn export LDFLAGS="-fsanitize=$CI_SANITIZERS $LDFLAGS"
-    }
-    # Build and install.
-    ci_spawn mkdir -p "$CI_BUILDDIR"
-    ci_spawn cd "$CI_BUILDDIR"
-    ci_spawn "$CI_SRCDIR/configure" --prefix="$CI_INSTALLDIR" $CI_CONFIGURE_FLAGS
-    ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS
-    [[ $CI_NO_TEST ]] || ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS test
-    [[ $CI_NO_INSTALL ]] || ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS install
-    [[ $CI_NO_CLEAN ]] || ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS clean
-    [[ $CI_NO_CLEAN ]] || ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS distclean
+        ci_spawn export CFLAGS="${CFLAGS:-"-O2"} -fsanitize=$CI_SANITIZERS"
+        ci_spawn export LDFLAGS="${LDFLAGS}${LDFLAGS:+" "}-fsanitize=$CI_SANITIZERS"
+    }
+    # Spawn "autogen.sh" if the configure script is not available.
+    [[ -x "$CI_SRC_DIR/configure" ]] || {
+        ci_spawn "$CI_SRC_DIR/autogen.sh" --maintainer
+    }
+    # And... build!
+    ci_spawn mkdir -p "$CI_BUILD_DIR"
+    ci_spawn cd "$CI_BUILD_DIR"
+    # Spawn "configure".
+    ci_spawn "$CI_SRC_DIR/configure" --prefix="$CI_INSTALL_DIR" $CI_CONFIGURE_FLAGS
+    ci_expr $((CI_NO_BUILD)) || {
+        # Spawn "make".
+        ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS
+    }
+    ci_expr $((CI_NO_TEST)) || {
+        # Spawn "make test" if testing is not disabled.
+        ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS test
+    }
+    ci_expr $((CI_NO_INSTALL)) || {
+        # Spawn "make install" if installation is not disabled.
+        ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS install
+    }
+    ci_expr $((CI_NO_CLEAN)) || {
+        # Spawn "make clean" and "make distclean" if cleaning is not disabled.
+        ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS clean
+        ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS distclean
+    }
     ci_info "## END OF BUILD ##"
 }
 
+function usage {
+    echo "usage: $CI_SCRIPT_NAME [<options>]"
+    echo "options: -?|-h|--help"
+    exit "${@:-0}"
+}
+
 function main {
+    local opt
+    while getopts ":" opt
+    do
+        # This ain't a while-loop. It only pretends to be.
+        [[ $1 == -[?h]* || $1 == --help || $1 == --help=* ]] && usage 0
+        ci_err "unknown option: '$1'"
+    done
+    shift $((OPTIND - 1))
+    # And... go!
+    ci_init_build
+    ci_trace_build
     [[ $# -eq 0 ]] || {
-        ci_info "note: this program accepts environment options only"
-        ci_err "unexpected command arguments: '$*'"
+        echo >&2 "error: unexpected argument: '$1'"
+        echo >&2 "note: this program accepts environment options only"
+        usage 2
     }
-    ci_init_configure_build
-    ci_trace_configure_build
-    ci_cleanup_old_configure_build
-    ci_build_configure
+    ci_cleanup_old_build
+    ci_build
 }
 
 main "$@"

+ 134 - 88
png.mod/libpng/ci/ci_verify_makefiles.sh

@@ -1,38 +1,21 @@
 #!/usr/bin/env bash
-set -e
+set -o errexit -o pipefail -o posix
 
-# ci_verify_makefiles.sh
-# Continuously integrate libpng using the legacy makefiles.
+# Copyright (c) 2019-2025 Cosmin Truta.
 #
-# Copyright (c) 2019-2023 Cosmin Truta.
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
 #
-# This software is released under the libpng license.
-# For conditions of distribution and use, see the disclaimer
-# and license in png.h.
+# SPDX-License-Identifier: MIT
 
-CI_SCRIPTNAME="$(basename "$0")"
-CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)"
-CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")"
+# shellcheck source=ci/lib/ci.lib.sh
+source "$(dirname "$0")/lib/ci.lib.sh"
+cd "$CI_TOPLEVEL_DIR"
 
-function ci_info {
-    printf >&2 "%s: %s\\n" "$CI_SCRIPTNAME" "$*"
-}
-
-function ci_err {
-    printf >&2 "%s: error: %s\\n" "$CI_SCRIPTNAME" "$*"
-    exit 2
-}
+CI_SRC_DIR="$CI_TOPLEVEL_DIR"
 
-function ci_spawn {
-    printf >&2 "%s: executing:" "$CI_SCRIPTNAME"
-    printf >&2 " %q" "$@"
-    printf >&2 "\\n"
-    "$@"
-}
-
-function ci_init_makefiles_build {
-    CI_SYSTEM_NAME="$(uname -s)"
-    CI_MACHINE_NAME="$(uname -m)"
+function ci_init_build {
+    # Ensure that the mandatory variables are initialized.
     CI_MAKE="${CI_MAKE:-make}"
     case "$CI_CC" in
     ( *clang* )
@@ -44,11 +27,15 @@ function ci_init_makefiles_build {
     esac
 }
 
-function ci_trace_makefiles_build {
+function ci_trace_build {
     ci_info "## START OF CONFIGURATION ##"
-    ci_info "system name: $CI_SYSTEM_NAME"
-    ci_info "machine hardware name: $CI_MACHINE_NAME"
-    ci_info "source directory: $CI_SRCDIR"
+    ci_info "build arch: $CI_BUILD_ARCH"
+    ci_info "build system: $CI_BUILD_SYSTEM"
+    [[ "$CI_TARGET_SYSTEM.$CI_TARGET_ARCH" != "$CI_BUILD_SYSTEM.$CI_BUILD_ARCH" ]] && {
+        ci_info "target arch: $CI_TARGET_ARCH"
+        ci_info "target system: $CI_TARGET_SYSTEM"
+    }
+    ci_info "source directory: $CI_SRC_DIR"
     ci_info "environment option: \$CI_MAKEFILES: '$CI_MAKEFILES'"
     ci_info "environment option: \$CI_MAKE: '$CI_MAKE'"
     ci_info "environment option: \$CI_MAKE_FLAGS: '$CI_MAKE_FLAGS'"
@@ -63,92 +50,151 @@ function ci_trace_makefiles_build {
     ci_info "environment option: \$CI_LD_FLAGS: '$CI_LD_FLAGS'"
     ci_info "environment option: \$CI_LIBS: '$CI_LIBS'"
     ci_info "environment option: \$CI_SANITIZERS: '$CI_SANITIZERS'"
+    ci_info "environment option: \$CI_FORCE: '$CI_FORCE'"
+    ci_info "environment option: \$CI_NO_BUILD: '$CI_NO_BUILD'"
     ci_info "environment option: \$CI_NO_TEST: '$CI_NO_TEST'"
     ci_info "environment option: \$CI_NO_CLEAN: '$CI_NO_CLEAN'"
     ci_info "executable: \$CI_MAKE: $(command -V "$CI_MAKE")"
-    [[ $CI_CC ]] &&
+    [[ $CI_CC ]] && {
         ci_info "executable: \$CI_CC: $(command -V "$CI_CC")"
-    [[ $CI_CPP ]] &&
+    }
+    [[ $CI_CPP ]] && {
         ci_info "executable: \$CI_CPP: $(command -V "$CI_CPP")"
-    [[ $CI_AR ]] &&
+    }
+    [[ $CI_AR ]] && {
         ci_info "executable: \$CI_AR: $(command -V "$CI_AR")"
-    [[ $CI_RANLIB ]] &&
+    }
+    [[ $CI_RANLIB ]] && {
         ci_info "executable: \$CI_RANLIB: $(command -V "$CI_RANLIB")"
-    [[ $CI_LD ]] &&
+    }
+    [[ $CI_LD ]] && {
         ci_info "executable: \$CI_LD: $(command -V "$CI_LD")"
+    }
     ci_info "## END OF CONFIGURATION ##"
 }
 
-function ci_cleanup_old_makefiles_build {
+function ci_cleanup_old_build {
     # Any old makefile-based build will most likely leave a mess
     # of object files behind if interrupted, e.g., via Ctrl+C.
     # There may be other files behind, depending on what makefile
     # had been used. We cannot easily enumerate all of those.
     # Fortunately, for a clean makefiles-based build, it should be
     # sufficient to remove the old object files only.
-    [[ -z $(find "$CI_SRCDIR" -maxdepth 1 -name "*.o") ]] ||
-        ci_spawn rm -f "$CI_SRCDIR"/*.o
-    [[ -z $(find "$CI_SRCDIR" -maxdepth 1 -name "*.obj") ]] ||
-        ci_spawn rm -f "$CI_SRCDIR"/*.obj
+    ci_info "## START OF PRE-BUILD CLEANUP ##"
+    local find_args=(-maxdepth 1 \( -iname "*.o" -o -iname "*.obj" \))
+    [[ ! $(find "$CI_SRC_DIR" "${find_args[@]}" | head -n1) ]] || {
+        ci_warn "unexpected build found in '$CI_SRC_DIR'"
+        if ci_expr $((CI_FORCE))
+        then
+            # Delete the old build.
+            local my_file
+            find "$CI_SRC_DIR" "${find_args[@]}" |
+                while IFS="" read -r my_file
+                do
+                    ci_spawn rm -fr "$my_file"
+                done
+            ci_info "## END OF PRE-BUILD CLEANUP ##"
+        else
+            # Alert the user, but do not delete their existing files,
+            # and do not mess up their existing build.
+            ci_info "hint: consider using the option \$CI_FORCE=1"
+            ci_err "unable to continue"
+        fi
+    }
 }
 
-function ci_build_makefiles {
+function ci_build {
     ci_info "## START OF BUILD ##"
-    # Initialize ALL_CC_FLAGS and ALL_LD_FLAGS as strings.
-    local ALL_CC_FLAGS="$CI_CC_FLAGS"
-    local ALL_LD_FLAGS="$CI_LD_FLAGS"
-    [[ $CI_SANITIZERS ]] && {
-        ALL_CC_FLAGS="-fsanitize=$CI_SANITIZERS ${ALL_CC_FLAGS:-"-O2"}"
-        ALL_LD_FLAGS="-fsanitize=$CI_SANITIZERS $ALL_LD_FLAGS"
-    }
-    # Initialize ALL_MAKE_FLAGS and ALL_MAKE_VARS as arrays.
-    local ALL_MAKE_FLAGS=($CI_MAKE_FLAGS)
-    local ALL_MAKE_VARS=()
-    [[ $CI_CC ]] && ALL_MAKE_VARS+=(CC="$CI_CC")
-    [[ $ALL_CC_FLAGS ]] && ALL_MAKE_VARS+=(CFLAGS="$ALL_CC_FLAGS")
-    [[ $CI_CPP ]] && ALL_MAKE_VARS+=(CPP="$CI_CPP")
-    [[ $CI_CPP_FLAGS ]] && ALL_MAKE_VARS+=(CPPFLAGS="$CI_CPP_FLAGS")
-    [[ $CI_AR ]] && ALL_MAKE_VARS+=(
-        AR="${CI_AR:-ar}"
-        AR_RC="${CI_AR:-ar} rc"
-    )
-    [[ $CI_RANLIB ]] && ALL_MAKE_VARS+=(RANLIB="$CI_RANLIB")
-    [[ $CI_LD ]] && ALL_MAKE_VARS+=(LD="$CI_LD")
-    [[ $ALL_LD_FLAGS ]] && ALL_MAKE_VARS+=(LDFLAGS="$ALL_LD_FLAGS")
-    [[ $CI_LIBS ]] && ALL_MAKE_VARS+=(LIBS="$CI_LIBS")
-    ALL_MAKE_VARS+=($CI_MAKE_VARS)
-    # Build!
-    cd "$CI_SRCDIR"
-    local MY_MAKEFILE
-    for MY_MAKEFILE in $CI_MAKEFILES
+    # Initialize and populate the local arrays.
+    local all_make_flags=()
+    local all_make_vars=()
+    [[ $CI_MAKE_FLAGS ]] && {
+        all_make_flags+=($CI_MAKE_FLAGS)
+    }
+    [[ $CI_CC ]] && {
+        all_make_vars+=("CC=$CI_CC")
+    }
+    [[ $CI_CC_FLAGS || $CI_SANITIZERS ]] && {
+        [[ $CI_SANITIZERS ]] && CI_CC_FLAGS="${CI_CC_FLAGS:-"-O2"} -fsanitize=$CI_SANITIZERS"
+        all_make_vars+=("CFLAGS=$CI_CC_FLAGS")
+    }
+    [[ $CI_CPP ]] && {
+        all_make_vars+=("CPP=$CI_CPP")
+    }
+    [[ $CI_CPP_FLAGS ]] && {
+        all_make_vars+=("CPPFLAGS=$CI_CPP_FLAGS")
+    }
+    [[ $CI_AR ]] && {
+        all_make_vars+=("AR=$CI_AR")
+    }
+    [[ $CI_RANLIB ]] && {
+        all_make_vars+=("RANLIB=$CI_RANLIB")
+    }
+    [[ $CI_LD ]] && {
+        all_make_vars+=("LD=$CI_LD")
+    }
+    [[ $CI_LD_FLAGS || $CI_SANITIZERS ]] && {
+        [[ $CI_SANITIZERS ]] && CI_LD_FLAGS+="${CI_LD_FLAGS:+" "}-fsanitize=$CI_SANITIZERS"
+        all_make_vars+=("LDFLAGS=$CI_LD_FLAGS")
+    }
+    [[ $CI_LIBS ]] && {
+        all_make_vars+=("LIBS=$CI_LIBS")
+    }
+    all_make_vars+=($CI_MAKE_VARS)
+    # And... build!
+    local my_makefile
+    for my_makefile in $CI_MAKEFILES
     do
-        ci_info "using makefile: $MY_MAKEFILE"
-        ci_spawn "$CI_MAKE" -f "$MY_MAKEFILE" \
-                            "${ALL_MAKE_FLAGS[@]}" \
-                            "${ALL_MAKE_VARS[@]}"
-        [[ $CI_NO_TEST ]] ||
-            ci_spawn "$CI_MAKE" -f "$MY_MAKEFILE" \
-                                "${ALL_MAKE_FLAGS[@]}" \
-                                "${ALL_MAKE_VARS[@]}" \
+        ci_info "using makefile: $my_makefile"
+        ci_expr $((CI_NO_BUILD)) || {
+            # Spawn "make".
+            ci_spawn "$CI_MAKE" -f "$my_makefile" \
+                                "${all_make_flags[@]}" \
+                                "${all_make_vars[@]}"
+        }
+        ci_expr $((CI_NO_TEST)) || {
+            # Spawn "make test" if testing is not disabled.
+            ci_spawn "$CI_MAKE" -f "$my_makefile" \
+                                "${all_make_flags[@]}" \
+                                "${all_make_vars[@]}" \
                                 test
-        [[ $CI_NO_CLEAN ]] ||
-            ci_spawn "$CI_MAKE" -f "$MY_MAKEFILE" \
-                                "${ALL_MAKE_FLAGS[@]}" \
-                                "${ALL_MAKE_VARS[@]}" \
+        }
+        ci_expr $((CI_NO_CLEAN)) || {
+            # Spawn "make clean" if cleaning is not disabled.
+            ci_spawn "$CI_MAKE" -f "$my_makefile" \
+                                "${all_make_flags[@]}" \
+                                "${all_make_vars[@]}" \
                                 clean
+        }
     done
     ci_info "## END OF BUILD ##"
 }
 
+function usage {
+    echo "usage: $CI_SCRIPT_NAME [<options>]"
+    echo "options: -?|-h|--help"
+    exit "${@:-0}"
+}
+
 function main {
+    local opt
+    while getopts ":" opt
+    do
+        # This ain't a while-loop. It only pretends to be.
+        [[ $1 == -[?h]* || $1 == --help || $1 == --help=* ]] && usage 0
+        ci_err "unknown option: '$1'"
+    done
+    shift $((OPTIND - 1))
+    # And... go!
+    ci_init_build
+    ci_trace_build
     [[ $# -eq 0 ]] || {
-        ci_info "note: this program accepts environment options only"
-        ci_err "unexpected command arguments: '$*'"
+        echo >&2 "error: unexpected argument: '$1'"
+        echo >&2 "note: this program accepts environment options only"
+        usage 2
     }
-    ci_init_makefiles_build
-    ci_trace_makefiles_build
-    ci_cleanup_old_makefiles_build
-    ci_build_makefiles
+    ci_cleanup_old_build
+    ci_build
 }
 
 main "$@"

+ 191 - 0
png.mod/libpng/ci/ci_verify_version.sh

@@ -0,0 +1,191 @@
+#!/usr/bin/env bash
+set -o errexit -o pipefail -o posix
+
+# Copyright (c) 2019-2025 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+# shellcheck source=ci/lib/ci.lib.sh
+source "$(dirname "$0")/lib/ci.lib.sh"
+cd "$CI_TOPLEVEL_DIR"
+
+# Declare the global environments collected from various sources.
+declare CI_ENV_LIBPNG_VER        # collected from png.h
+declare CI_ENV_AUTOCONF_VER      # collected from configure.ac
+declare CI_ENV_CMAKE_VER         # collected from CMakeLists.txt
+declare CI_ENV_LIBPNGCONFIG_VER  # collected from scripts/libpng-config-head.in
+
+function ci_run_shellify {
+    local my_script my_result
+    my_script="$CI_SCRIPT_DIR/libexec/ci_shellify_${1#--}.sh"
+    shift 1
+    [[ -f $my_script ]] || {
+        ci_err_internal "missing script: '$my_script'"
+    }
+    ci_info "shellifying:" "$@"
+    "$BASH" "$my_script" "$@"
+    echo "$my_result" | "$BASH" --posix || ci_err "bad shellify output"
+    echo "$my_result"
+}
+
+function ci_init_version_verification {
+    ci_info "## START OF VERIFICATION ##"
+    CI_ENV_LIBPNG_VER="$(ci_run_shellify --c png.h)"
+    echo "$CI_ENV_LIBPNG_VER"
+    CI_ENV_AUTOCONF_VER="$(ci_run_shellify --autoconf configure.ac)"
+    echo "$CI_ENV_AUTOCONF_VER"
+    CI_ENV_CMAKE_VER="$(ci_run_shellify --cmake CMakeLists.txt)"
+    echo "$CI_ENV_CMAKE_VER"
+    CI_ENV_LIBPNGCONFIG_VER="$(ci_run_shellify --shell scripts/libpng-config-head.in)"
+    echo "$CI_ENV_LIBPNGCONFIG_VER"
+}
+
+# shellcheck disable=SC2154
+function ci_do_version_verification {
+    local my_expect
+    ci_info "## VERIFYING: version definitions in 'png.h' ##"
+    eval "$CI_ENV_LIBPNG_VER"
+    my_expect="${PNG_LIBPNG_VER_MAJOR}.${PNG_LIBPNG_VER_MINOR}.${PNG_LIBPNG_VER_RELEASE}"
+    if [[ "$PNG_LIBPNG_VER_STRING" == "$my_expect"* ]]
+    then
+        ci_info "matched: \$PNG_LIBPNG_VER_STRING == $my_expect*"
+    else
+        ci_err "mismatched: \$PNG_LIBPNG_VER_STRING != $my_expect*"
+    fi
+    my_expect=$((PNG_LIBPNG_VER_MAJOR*10000 + PNG_LIBPNG_VER_MINOR*100 + PNG_LIBPNG_VER_RELEASE))
+    if [[ "$PNG_LIBPNG_VER" == "$my_expect" ]]
+    then
+        ci_info "matched: \$PNG_LIBPNG_VER == $my_expect"
+    else
+        ci_err "mismatched: \$PNG_LIBPNG_VER != $my_expect"
+    fi
+    my_expect=$((PNG_LIBPNG_VER_MAJOR*10 + PNG_LIBPNG_VER_MINOR))
+    if [[ "$PNG_LIBPNG_VER_SHAREDLIB" == "$my_expect" ]]
+    then
+        ci_info "matched: \$PNG_LIBPNG_VER_SHAREDLIB == $my_expect"
+    else
+        ci_err "mismatched: \$PNG_LIBPNG_VER_SHAREDLIB != $my_expect"
+    fi
+    if [[ "$PNG_LIBPNG_VER_SONUM" == "$my_expect" ]]
+    then
+        ci_info "matched: \$PNG_LIBPNG_VER_SONUM == $my_expect"
+    else
+        ci_err "mismatched: \$PNG_LIBPNG_VER_SONUM != $my_expect"
+    fi
+    if [[ "$PNG_LIBPNG_VER_DLLNUM" == "$my_expect" ]]
+    then
+        ci_info "matched: \$PNG_LIBPNG_VER_DLLNUM == $my_expect"
+    else
+        ci_err "mismatched: \$PNG_LIBPNG_VER_DLLNUM != $my_expect"
+    fi
+    if [[ "$PNG_LIBPNG_VER_BUILD" == [01] ]]
+    then
+        ci_info "matched: \$PNG_LIBPNG_VER_BUILD == [01]"
+    else
+        ci_err "mismatched: \$PNG_LIBPNG_VER_BUILD != [01]"
+    fi
+    ci_info "## VERIFYING: build definitions in 'png.h' ##"
+    my_expect="${PNG_LIBPNG_VER_MAJOR}.${PNG_LIBPNG_VER_MINOR}.${PNG_LIBPNG_VER_RELEASE}"
+    if [[ "$PNG_LIBPNG_VER_STRING" == "$my_expect" ]]
+    then
+        if [[ $PNG_LIBPNG_VER_BUILD -eq 0 ]]
+        then
+            ci_info "matched: \$PNG_LIBPNG_VER_BUILD -eq 0"
+        else
+            ci_err "mismatched: \$PNG_LIBPNG_VER_BUILD -ne 0"
+        fi
+        if [[ $PNG_LIBPNG_BUILD_BASE_TYPE -eq $PNG_LIBPNG_BUILD_STABLE ]]
+        then
+            ci_info "matched: \$PNG_LIBPNG_BUILD_BASE_TYPE -eq \$PNG_LIBPNG_BUILD_STABLE"
+        else
+            ci_err "mismatched: \$PNG_LIBPNG_BUILD_BASE_TYPE -ne \$PNG_LIBPNG_BUILD_STABLE"
+        fi
+    elif [[ "$PNG_LIBPNG_VER_STRING" == "$my_expect".git ]]
+    then
+        if [[ $PNG_LIBPNG_VER_BUILD -ne 0 ]]
+        then
+            ci_info "matched: \$PNG_LIBPNG_VER_BUILD -ne 0"
+        else
+            ci_err "mismatched: \$PNG_LIBPNG_VER_BUILD -eq 0"
+        fi
+        if [[ $PNG_LIBPNG_BUILD_BASE_TYPE -ne $PNG_LIBPNG_BUILD_STABLE ]]
+        then
+            ci_info "matched: \$PNG_LIBPNG_BUILD_BASE_TYPE -ne \$PNG_LIBPNG_BUILD_STABLE"
+        else
+            ci_err "mismatched: \$PNG_LIBPNG_BUILD_BASE_TYPE -eq \$PNG_LIBPNG_BUILD_STABLE"
+        fi
+    else
+        ci_err "unexpected: \$PNG_LIBPNG_VER_STRING == '$PNG_LIBPNG_VER_STRING'"
+    fi
+    ci_info "## VERIFYING: type definitions in 'png.h' ##"
+    my_expect="$(echo "png_libpng_version_${PNG_LIBPNG_VER_STRING}" | tr . _)"
+    ci_spawn grep -w -e "$my_expect" png.h
+    ci_info "## VERIFYING: version definitions in 'configure.ac' ##"
+    eval "$CI_ENV_AUTOCONF_VER"
+    if [[ "$PNGLIB_VERSION" == "$PNG_LIBPNG_VER_STRING" ]]
+    then
+        ci_info "matched: \$PNGLIB_VERSION == \$PNG_LIBPNG_VER_STRING"
+    else
+        ci_err "mismatched: \$PNGLIB_VERSION != \$PNG_LIBPNG_VER_STRING"
+    fi
+    ci_info "## VERIFYING: version definitions in 'CMakeLists.txt' ##"
+    eval "$CI_ENV_CMAKE_VER"
+    if [[ "$PNGLIB_VERSION" == "$PNG_LIBPNG_VER_STRING" && "$PNGLIB_SUBREVISION" == 0 ]]
+    then
+        ci_info "matched: \$PNGLIB_VERSION == \$PNG_LIBPNG_VER_STRING"
+        ci_info "matched: \$PNGLIB_SUBREVISION == 0"
+    elif [[ "$PNGLIB_VERSION.$PNGLIB_SUBREVISION" == "$PNG_LIBPNG_VER_STRING" ]]
+    then
+        ci_info "matched: \$PNGLIB_VERSION.\$PNGLIB_SUBREVISION == \$PNG_LIBPNG_VER_STRING"
+    else
+        ci_err "mismatched: \$PNGLIB_VERSION != \$PNG_LIBPNG_VER_STRING"
+    fi
+    ci_info "## VERIFYING: version definitions in 'scripts/libpng-config-head.in' ##"
+    eval "$CI_ENV_LIBPNGCONFIG_VER"
+    if [[ "$version" == "$PNG_LIBPNG_VER_STRING" ]]
+    then
+        ci_info "matched: \$version == \$PNG_LIBPNG_VER_STRING"
+    else
+        ci_err "mismatched: \$version != \$PNG_LIBPNG_VER_STRING"
+    fi
+}
+
+function ci_finish_version_verification {
+    ci_info "## END OF VERIFICATION ##"
+    # Relying on "set -o errexit" to not reach here in case of error.
+    ci_info "## SUCCESS ##"
+}
+
+function ci_verify_version {
+    ci_init_version_verification
+    ci_do_version_verification
+    ci_finish_version_verification
+}
+
+function usage {
+    echo "usage: $CI_SCRIPT_NAME [<options>]"
+    echo "options: -?|-h|--help"
+    exit "${@:-0}"
+}
+
+function main {
+    local opt
+    while getopts ":" opt
+    do
+        # This ain't a while-loop. It only pretends to be.
+        [[ $1 == -[?h]* || $1 == --help || $1 == --help=* ]] && usage 0
+        ci_err "unknown option: '$1'"
+    done
+    shift $((OPTIND - 1))
+    [[ $# -eq 0 ]] || {
+        echo >&2 "error: unexpected argument: '$1'"
+        usage 2
+    }
+    # And... go!
+    ci_verify_version
+}
+
+main "$@"

+ 111 - 0
png.mod/libpng/ci/lib/ci.lib.sh

@@ -0,0 +1,111 @@
+# Copyright (c) 2019-2025 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+test -f "$BASH_SOURCE" || {
+    echo >&2 "warning: this module requires Bash version 3 or newer"
+}
+test "${#BASH_SOURCE[@]}" -gt 1 || {
+    echo >&2 "warning: this module should be sourced from a Bash script"
+}
+
+# Reset the locale to avoid surprises from locale-dependent commands.
+export LC_ALL=C
+export LANG=C
+export LANGUAGE=C
+
+# Reset CDPATH to avoid surprises from the "cd" command.
+export CDPATH=""
+
+# Initialize the global constants CI_SCRIPT_{NAME,DIR} and CI_TOPLEVEL_DIR.
+CI_SCRIPT_NAME="$(basename -- "$0")"
+CI_SCRIPT_DIR="$(cd "$(dirname -- "$0")" && pwd)"
+CI_TOPLEVEL_DIR="$(cd "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)"
+
+# Initialize the global constants CI_BUILD_{...} for the host build platform.
+CI_BUILD_ARCH="${CI_BUILD_ARCH:-"$(uname -m | tr 'A-Z/\.-' 'a-z____')"}"
+CI_BUILD_SYSTEM="${CI_BUILD_SYSTEM:-"$(uname -s | tr 'A-Z/\.-' 'a-z____')"}"
+
+# Initialize the global constants CI_TARGET_{...} for the target platform.
+CI_TARGET_ARCH="${CI_TARGET_ARCH:-"$CI_BUILD_ARCH"}"
+CI_TARGET_SYSTEM="${CI_TARGET_SYSTEM:-"$CI_BUILD_SYSTEM"}"
+
+function ci_info {
+    printf >&2 "%s: %s\\n" "$CI_SCRIPT_NAME" "$*"
+}
+
+function ci_warn {
+    printf >&2 "%s: warning: %s\\n" "$CI_SCRIPT_NAME" "$*"
+}
+
+function ci_err {
+    printf >&2 "%s: error: %s\\n" "$CI_SCRIPT_NAME" "$*"
+    exit 2
+}
+
+function ci_err_internal {
+    printf >&2 "%s: internal error: %s\\n" "$CI_SCRIPT_NAME" "$*"
+    printf >&2 "ABORTED\\n"
+    # Exit with the conventional SIGABRT code.
+    exit 134
+}
+
+function ci_expr {
+    if [[ ${*:-0} == [0-9] ]]
+    then
+        # This is the same as in the else-branch below, albeit much faster
+        # for our intended use cases.
+        return $((!$1))
+    else
+        # The funny-looking compound command "... && return $? || return $?"
+        # allows the execution to continue uninterrupted under "set -e".
+        expr >/dev/null "$@" && return $? || return $?
+    fi
+}
+
+function ci_spawn {
+    printf >&2 "%s: executing:" "$CI_SCRIPT_NAME"
+    printf >&2 " %q" "$@"
+    printf >&2 "\\n"
+    "$@"
+}
+
+# Ensure that the internal initialization is correct.
+[[ $CI_TOPLEVEL_DIR/ci/lib/ci.lib.sh -ef ${BASH_SOURCE[0]} ]] || {
+    ci_err_internal "bad or missing \$CI_TOPLEVEL_DIR"
+}
+[[ $CI_SCRIPT_DIR/$CI_SCRIPT_NAME -ef $0 ]] || {
+    ci_err_internal "bad or missing \$CI_SCRIPT_DIR/\$CI_SCRIPT_NAME"
+}
+[[ $CI_BUILD_ARCH && $CI_BUILD_SYSTEM ]] || {
+    ci_err_internal "missing \$CI_BUILD_ARCH or \$CI_BUILD_SYSTEM"
+}
+[[ $CI_TARGET_ARCH && $CI_TARGET_SYSTEM ]] || {
+    ci_err_internal "missing \$CI_TARGET_ARCH or \$CI_TARGET_SYSTEM"
+}
+
+# Ensure that the user initialization is correct.
+[[ ${CI_FORCE:-0} == [01] ]] || {
+    ci_err "bad boolean option: \$CI_FORCE: '$CI_FORCE'"
+}
+[[ ${CI_NO_BUILD:-0} == [01] ]] || {
+    ci_err "bad boolean option: \$CI_NO_BUILD: '$CI_NO_BUILD'"
+}
+[[ ${CI_NO_TEST:-0} == [01] ]] || {
+    ci_err "bad boolean option: \$CI_NO_TEST: '$CI_NO_TEST'"
+}
+[[ ${CI_NO_INSTALL:-0} == [01] ]] || {
+    ci_err "bad boolean option: \$CI_NO_INSTALL: '$CI_NO_INSTALL'"
+}
+[[ ${CI_NO_CLEAN:-0} == [01] ]] || {
+    ci_err "bad boolean option: \$CI_NO_CLEAN: '$CI_NO_CLEAN'"
+}
+if ci_expr $((CI_NO_BUILD))
+then
+    ci_expr $((CI_NO_TEST && CI_NO_INSTALL)) || {
+        ci_err "\$CI_NO_BUILD requires \$CI_NO_TEST and \$CI_NO_INSTALL"
+    }
+fi

+ 48 - 0
png.mod/libpng/ci/libexec/ci_shellify_autoconf.sh

@@ -0,0 +1,48 @@
+#!/usr/bin/env bash
+set -o errexit -o pipefail -o posix
+
+# Copyright (c) 2019-2025 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+# shellcheck source=ci/lib/ci.lib.sh
+source "$(dirname "$0")/../lib/ci.lib.sh"
+
+function ci_shellify_autoconf {
+    # Convert autoconf (M4) text, specifically originating
+    # from configure.ac, to shell scripting text.
+    # Select only the easy-to-parse definitions of PNGLIB_*.
+    sed -n -e '/^ *PNGLIB_[^ ]*=[$"0-9A-Za-z_]/ p' |
+        sed -e 's/^ *PNG\([0-9A-Za-z_]*\)=\([^# ]*\).*$/PNG\1=\2/' \
+            -e 's/^\([^ ]*=[^ ]*\).*$/export \1;/'
+}
+
+function usage {
+    echo "usage: $CI_SCRIPT_NAME [<options>] configure.ac"
+    echo "options: -?|-h|--help"
+    exit "${@:-0}"
+}
+
+function main {
+    local opt
+    while getopts ":" opt
+    do
+        # This ain't a while-loop. It only pretends to be.
+        [[ $1 == -[?h]* || $1 == --help || $1 == --help=* ]] && usage 0
+        ci_err "unknown option: '$1'"
+    done
+    shift $((OPTIND - 1))
+    [[ $# -eq 0 ]] && usage 2
+    [[ $# -eq 1 ]] || ci_err "too many operands"
+    # And... go!
+    test -e "$1" || ci_err "no such file: '$1'"
+    [[ $(basename -- "$1") == configure.ac ]] || {
+        ci_err "incorrect operand: '$1' (expecting: 'configure.ac')"
+    }
+    ci_shellify_autoconf <"$1"
+}
+
+main "$@"

+ 49 - 0
png.mod/libpng/ci/libexec/ci_shellify_c.sh

@@ -0,0 +1,49 @@
+#!/usr/bin/env bash
+set -o errexit -o pipefail -o posix
+
+# Copyright (c) 2019-2025 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+# shellcheck source=ci/lib/ci.lib.sh
+source "$(dirname "$0")/../lib/ci.lib.sh"
+
+function ci_shellify_c {
+    # Convert C preprocessor text, specifically originating
+    # from png.h, to shell scripting text.
+    # Select only the easy-to-parse definitions of PNG_LIBPNG_*.
+    sed -n -e '/^\# *define * PNG_LIBPNG_[^ ]* * ["0-9A-Za-z_]/ p' |
+        sed -e 's/^\# *define * PNG\([^ ]*\) * \([^ ]*\)/PNG\1=\2/' \
+            -e 's/=PNG\([0-9A-Za-z_]*\)/=\${PNG\1}/' \
+            -e 's/^\([^ ]*=[^ ]*\).*$/export \1;/'
+}
+
+function usage {
+    echo "usage: $CI_SCRIPT_NAME [<options>] png.h"
+    echo "options: -?|-h|--help"
+    exit "${@:-0}"
+}
+
+function main {
+    local opt
+    while getopts ":" opt
+    do
+        # This ain't a while-loop. It only pretends to be.
+        [[ $1 == -[?h]* || $1 == --help || $1 == --help=* ]] && usage 0
+        ci_err "unknown option: '$1'"
+    done
+    shift $((OPTIND - 1))
+    [[ $# -eq 0 ]] && usage 2
+    [[ $# -eq 1 ]] || ci_err "too many operands"
+    # And... go!
+    test -e "$1" || ci_err "no such file: '$1'"
+    [[ $(basename -- "$1") == png.h ]] || {
+        ci_err "incorrect operand: '$1' (expecting: 'png.h')"
+    }
+    ci_shellify_c <"$1"
+}
+
+main "$@"

+ 49 - 0
png.mod/libpng/ci/libexec/ci_shellify_cmake.sh

@@ -0,0 +1,49 @@
+#!/usr/bin/env bash
+set -o errexit -o pipefail -o posix
+
+# Copyright (c) 2019-2025 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+# shellcheck source=ci/lib/ci.lib.sh
+source "$(dirname "$0")/../lib/ci.lib.sh"
+
+function ci_shellify_cmake {
+    # Convert CMake lists text, specifically originating
+    # from CMakeLists.txt, to shell scripting text.
+    # Select only the easy-to-parse definitions of PNGLIB_*.
+    sed -n -e '/^ *set *(PNGLIB_[^ ]* * [$"0-9A-Za-z_].*)/ p' |
+        sed -e 's/^ *set *(PNG\([^ ]*\) * \([^() ]*\)).*$/PNG\1=\2/' \
+            -e 's/^\([^ ]*=[^ ]*\).*$/export \1;/'
+}
+
+function usage {
+    echo "usage: $CI_SCRIPT_NAME [<options>] CMakeLists.txt"
+    echo "options: -?|-h|--help"
+    exit "${@:-0}"
+}
+
+function main {
+    local opt
+    while getopts ":" opt
+    do
+        # This ain't a while-loop. It only pretends to be.
+        [[ $1 == -[?h]* || $1 == --help || $1 == --help=* ]] && usage 0
+        ci_err "unknown option: '$1'"
+    done
+    shift $((OPTIND - 1))
+    [[ $# -eq 0 ]] && usage 2
+    [[ $# -eq 1 ]] || ci_err "too many operands"
+    # And... go!
+    test -e "$1" || ci_err "no such file: '$1'"
+    filename="$(basename -- "$1")"
+    [[ $filename == [Cc][Mm]ake[Ll]ists.txt ]] || {
+        ci_err "incorrect operand: '$1' (expecting: 'CMakeLists.txt')"
+    }
+    ci_shellify_cmake <"$1"
+}
+
+main "$@"

+ 46 - 0
png.mod/libpng/ci/libexec/ci_shellify_shell.sh

@@ -0,0 +1,46 @@
+#!/usr/bin/env bash
+set -o errexit -o pipefail -o posix
+
+# Copyright (c) 2019-2025 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+# shellcheck source=ci/lib/ci.lib.sh
+source "$(dirname "$0")/../lib/ci.lib.sh"
+
+function ci_shellify_shell {
+    # Convert shell scripting text to shell scripting text.
+    # Select only the easy-to-parse version definitions.
+    sed -n -e '/^ *[A-Za-z_][0-9A-Za-z_]*=[0-9][^ #]* *$/ p' |
+        sed -e 's/^ *\([^ ]*=[^ ]*\) *$/export \1;/'
+}
+
+function usage {
+    echo "usage: $CI_SCRIPT_NAME [<options>] libpng-config-head.in"
+    echo "options: -?|-h|--help"
+    exit "${@:-0}"
+}
+
+function main {
+    local opt
+    while getopts ":" opt
+    do
+        # This ain't a while-loop. It only pretends to be.
+        [[ $1 == -[?h]* || $1 == --help || $1 == --help=* ]] && usage 0
+        ci_err "unknown option: '$1'"
+    done
+    shift $((OPTIND - 1))
+    [[ $# -eq 0 ]] && usage 2
+    [[ $# -eq 1 ]] || ci_err "too many operands"
+    # And... go!
+    test -e "$1" || ci_err "no such file: '$1'"
+    [[ $(basename -- "$1") == libpng-config-head.in ]] || {
+        ci_err "incorrect operand: '$1' (expecting: 'libpng-config-head.in')"
+    }
+    ci_shellify_shell <"$1"
+}
+
+main "$@"

+ 16 - 0
png.mod/libpng/ci/targets/android/ci_env.aarch64-linux-android.sh

@@ -0,0 +1,16 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=aarch64
+export CI_TARGET_ARCHVER=aarch64
+export CI_TARGET_SYSTEM=linux
+export CI_TARGET_ABI=android
+export CI_TARGET_ABIVER=android29
+
+export CI_CC="$CI_TARGET_ARCHVER-$CI_TARGET_SYSTEM-$CI_TARGET_ABIVER-clang"
+export CI_AR="llvm-ar"
+export CI_RANLIB="llvm-ranlib"

+ 16 - 0
png.mod/libpng/ci/targets/android/ci_env.armv7a-linux-androideabi.sh

@@ -0,0 +1,16 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=arm
+export CI_TARGET_ARCHVER=armv7a
+export CI_TARGET_SYSTEM=linux
+export CI_TARGET_ABI=androideabi
+export CI_TARGET_ABIVER=androideabi29
+
+export CI_CC="$CI_TARGET_ARCHVER-$CI_TARGET_SYSTEM-$CI_TARGET_ABIVER-clang"
+export CI_AR="llvm-ar"
+export CI_RANLIB="llvm-ranlib"

+ 16 - 0
png.mod/libpng/ci/targets/android/ci_env.i686-linux-android.sh

@@ -0,0 +1,16 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=i686
+export CI_TARGET_ARCHVER=i686
+export CI_TARGET_SYSTEM=linux
+export CI_TARGET_ABI=android
+export CI_TARGET_ABIVER=android29
+
+export CI_CC="$CI_TARGET_ARCHVER-$CI_TARGET_SYSTEM-$CI_TARGET_ABIVER-clang"
+export CI_AR="llvm-ar"
+export CI_RANLIB="llvm-ranlib"

+ 16 - 0
png.mod/libpng/ci/targets/android/ci_env.x86_64-linux-android.sh

@@ -0,0 +1,16 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=x86_64
+export CI_TARGET_ARCHVER=x86_64
+export CI_TARGET_SYSTEM=linux
+export CI_TARGET_ABI=android
+export CI_TARGET_ABIVER=android29
+
+export CI_CC="$CI_TARGET_ARCHVER-$CI_TARGET_SYSTEM-$CI_TARGET_ABIVER-clang"
+export CI_AR="llvm-ar"
+export CI_RANLIB="llvm-ranlib"

+ 18 - 0
png.mod/libpng/ci/targets/cygwin/ci_env.i686-pc-cygwin.sh

@@ -0,0 +1,18 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=i686
+export CI_TARGET_SYSTEM=cygwin
+
+export CI_CC="$CI_TARGET_ARCH-pc-$CI_TARGET_SYSTEM-gcc"
+export CI_AR="$CI_CC-ar"
+export CI_RANLIB="$CI_CC-ranlib"
+
+export CI_CMAKE_VARS="
+    -DCMAKE_SYSTEM_NAME=CYGWIN
+    -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH
+"

+ 18 - 0
png.mod/libpng/ci/targets/cygwin/ci_env.x86_64-pc-cygwin.sh

@@ -0,0 +1,18 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=x86_64
+export CI_TARGET_SYSTEM=cygwin
+
+export CI_CC="$CI_TARGET_ARCH-pc-$CI_TARGET_SYSTEM-gcc"
+export CI_AR="$CI_CC-ar"
+export CI_RANLIB="$CI_CC-ranlib"
+
+export CI_CMAKE_VARS="
+    -DCMAKE_SYSTEM_NAME=CYGWIN
+    -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH
+"

+ 15 - 0
png.mod/libpng/ci/targets/darwin/ci_env.arm64-apple-darwin.sh

@@ -0,0 +1,15 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=arm64
+export CI_TARGET_SYSTEM=darwin
+
+export CI_CMAKE_VARS="
+    -DCMAKE_SYSTEM_NAME=Darwin
+    -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH
+    -DCMAKE_OSX_ARCHITECTURES=$CI_TARGET_ARCH
+"

+ 15 - 0
png.mod/libpng/ci/targets/darwin/ci_env.x86_64-apple-darwin.sh

@@ -0,0 +1,15 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=x86_64
+export CI_TARGET_SYSTEM=darwin
+
+export CI_CMAKE_VARS="
+    -DCMAKE_SYSTEM_NAME=Darwin
+    -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH
+    -DCMAKE_OSX_ARCHITECTURES=$CI_TARGET_ARCH
+"

+ 14 - 0
png.mod/libpng/ci/targets/freebsd/ci_env.aarch64-unknown-freebsd.sh

@@ -0,0 +1,14 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=aarch64
+export CI_TARGET_SYSTEM=freebsd
+
+export CI_CMAKE_VARS="
+    -DCMAKE_SYSTEM_NAME=FreeBSD
+    -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH
+"

+ 14 - 0
png.mod/libpng/ci/targets/freebsd/ci_env.i686-unknown-freebsd.sh

@@ -0,0 +1,14 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=i686
+export CI_TARGET_SYSTEM=freebsd
+
+export CI_CMAKE_VARS="
+    -DCMAKE_SYSTEM_NAME=FreeBSD
+    -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH
+"

+ 14 - 0
png.mod/libpng/ci/targets/freebsd/ci_env.riscv64-unknown-freebsd.sh

@@ -0,0 +1,14 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=riscv64
+export CI_TARGET_SYSTEM=freebsd
+
+export CI_CMAKE_VARS="
+    -DCMAKE_SYSTEM_NAME=FreeBSD
+    -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH
+"

+ 14 - 0
png.mod/libpng/ci/targets/freebsd/ci_env.x86_64-unknown-freebsd.sh

@@ -0,0 +1,14 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=x86_64
+export CI_TARGET_SYSTEM=freebsd
+
+export CI_CMAKE_VARS="
+    -DCMAKE_SYSTEM_NAME=FreeBSD
+    -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH
+"

+ 21 - 0
png.mod/libpng/ci/targets/linux/ci_env.aarch64-linux-gnu.sh

@@ -0,0 +1,21 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=aarch64
+export CI_TARGET_SYSTEM=linux
+export CI_TARGET_ABI=gnu
+
+export CI_GCC="${CI_GCC-gcc}"
+
+export CI_CC="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-$CI_GCC"
+export CI_AR="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ar"
+export CI_RANLIB="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ranlib"
+
+export CI_CMAKE_VARS="
+    -DCMAKE_SYSTEM_NAME=Linux
+    -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH
+"

+ 21 - 0
png.mod/libpng/ci/targets/linux/ci_env.arm-linux-gnueabi.sh

@@ -0,0 +1,21 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=arm
+export CI_TARGET_SYSTEM=linux
+export CI_TARGET_ABI=gnueabi
+
+export CI_GCC="${CI_GCC-gcc}"
+
+export CI_CC="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-$CI_GCC"
+export CI_AR="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ar"
+export CI_RANLIB="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ranlib"
+
+export CI_CMAKE_VARS="
+    -DCMAKE_SYSTEM_NAME=Linux
+    -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH
+"

+ 21 - 0
png.mod/libpng/ci/targets/linux/ci_env.arm-linux-gnueabihf.sh

@@ -0,0 +1,21 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=arm
+export CI_TARGET_SYSTEM=linux
+export CI_TARGET_ABI=gnueabihf
+
+export CI_GCC="${CI_GCC-gcc}"
+
+export CI_CC="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-$CI_GCC"
+export CI_AR="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ar"
+export CI_RANLIB="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ranlib"
+
+export CI_CMAKE_VARS="
+    -DCMAKE_SYSTEM_NAME=Linux
+    -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH
+"

+ 21 - 0
png.mod/libpng/ci/targets/linux/ci_env.i686-linux-gnu.sh

@@ -0,0 +1,21 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=i686
+export CI_TARGET_SYSTEM=linux
+export CI_TARGET_ABI=gnu
+
+export CI_GCC="${CI_GCC-gcc}"
+
+export CI_CC="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-$CI_GCC"
+export CI_AR="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ar"
+export CI_RANLIB="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ranlib"
+
+export CI_CMAKE_VARS="
+    -DCMAKE_SYSTEM_NAME=Linux
+    -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH
+"

+ 21 - 0
png.mod/libpng/ci/targets/linux/ci_env.mips-linux-gnu.sh

@@ -0,0 +1,21 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=mips
+export CI_TARGET_SYSTEM=linux
+export CI_TARGET_ABI=gnu
+
+export CI_GCC="${CI_GCC-gcc}"
+
+export CI_CC="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-$CI_GCC"
+export CI_AR="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ar"
+export CI_RANLIB="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ranlib"
+
+export CI_CMAKE_VARS="
+    -DCMAKE_SYSTEM_NAME=Linux
+    -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH
+"

+ 21 - 0
png.mod/libpng/ci/targets/linux/ci_env.mips64-linux-gnuabi64.sh

@@ -0,0 +1,21 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=mips64
+export CI_TARGET_SYSTEM=linux
+export CI_TARGET_ABI=gnuabi64
+
+export CI_GCC="${CI_GCC-gcc}"
+
+export CI_CC="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-$CI_GCC"
+export CI_AR="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ar"
+export CI_RANLIB="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ranlib"
+
+export CI_CMAKE_VARS="
+    -DCMAKE_SYSTEM_NAME=Linux
+    -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH
+"

+ 21 - 0
png.mod/libpng/ci/targets/linux/ci_env.mips64el-linux-gnuabi64.sh

@@ -0,0 +1,21 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=mips64el
+export CI_TARGET_SYSTEM=linux
+export CI_TARGET_ABI=gnuabi64
+
+export CI_GCC="${CI_GCC-gcc}"
+
+export CI_CC="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-$CI_GCC"
+export CI_AR="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ar"
+export CI_RANLIB="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ranlib"
+
+export CI_CMAKE_VARS="
+    -DCMAKE_SYSTEM_NAME=Linux
+    -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH
+"

+ 21 - 0
png.mod/libpng/ci/targets/linux/ci_env.mipsel-linux-gnu.sh

@@ -0,0 +1,21 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=mipsel
+export CI_TARGET_SYSTEM=linux
+export CI_TARGET_ABI=gnu
+
+export CI_GCC="${CI_GCC-gcc}"
+
+export CI_CC="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-$CI_GCC"
+export CI_AR="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ar"
+export CI_RANLIB="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ranlib"
+
+export CI_CMAKE_VARS="
+    -DCMAKE_SYSTEM_NAME=Linux
+    -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH
+"

+ 21 - 0
png.mod/libpng/ci/targets/linux/ci_env.mipsisa32r6-linux-gnu.sh

@@ -0,0 +1,21 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=mipsisa32r6
+export CI_TARGET_SYSTEM=linux
+export CI_TARGET_ABI=gnu
+
+export CI_GCC="${CI_GCC-gcc}"
+
+export CI_CC="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-$CI_GCC"
+export CI_AR="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ar"
+export CI_RANLIB="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ranlib"
+
+export CI_CMAKE_VARS="
+    -DCMAKE_SYSTEM_NAME=Linux
+    -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH
+"

+ 21 - 0
png.mod/libpng/ci/targets/linux/ci_env.mipsisa32r6el-linux-gnu.sh

@@ -0,0 +1,21 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=mipsisa32r6el
+export CI_TARGET_SYSTEM=linux
+export CI_TARGET_ABI=gnu
+
+export CI_GCC="${CI_GCC-gcc}"
+
+export CI_CC="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-$CI_GCC"
+export CI_AR="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ar"
+export CI_RANLIB="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ranlib"
+
+export CI_CMAKE_VARS="
+    -DCMAKE_SYSTEM_NAME=Linux
+    -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH
+"

+ 21 - 0
png.mod/libpng/ci/targets/linux/ci_env.mipsisa64r6-linux-gnuabi64.sh

@@ -0,0 +1,21 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=mipsisa64r6
+export CI_TARGET_SYSTEM=linux
+export CI_TARGET_ABI=gnuabi64
+
+export CI_GCC="${CI_GCC-gcc}"
+
+export CI_CC="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-$CI_GCC"
+export CI_AR="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ar"
+export CI_RANLIB="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ranlib"
+
+export CI_CMAKE_VARS="
+    -DCMAKE_SYSTEM_NAME=Linux
+    -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH
+"

+ 21 - 0
png.mod/libpng/ci/targets/linux/ci_env.mipsisa64r6el-linux-gnuabi64.sh

@@ -0,0 +1,21 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=mipsisa64r6el
+export CI_TARGET_SYSTEM=linux
+export CI_TARGET_ABI=gnuabi64
+
+export CI_GCC="${CI_GCC-gcc}"
+
+export CI_CC="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-$CI_GCC"
+export CI_AR="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ar"
+export CI_RANLIB="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ranlib"
+
+export CI_CMAKE_VARS="
+    -DCMAKE_SYSTEM_NAME=Linux
+    -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH
+"

+ 21 - 0
png.mod/libpng/ci/targets/linux/ci_env.powerpc-linux-gnu.sh

@@ -0,0 +1,21 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=powerpc
+export CI_TARGET_SYSTEM=linux
+export CI_TARGET_ABI=gnu
+
+export CI_GCC="${CI_GCC-gcc}"
+
+export CI_CC="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-$CI_GCC"
+export CI_AR="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ar"
+export CI_RANLIB="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ranlib"
+
+export CI_CMAKE_VARS="
+    -DCMAKE_SYSTEM_NAME=Linux
+    -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH
+"

+ 21 - 0
png.mod/libpng/ci/targets/linux/ci_env.powerpc64-linux-gnu.sh

@@ -0,0 +1,21 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=powerpc64
+export CI_TARGET_SYSTEM=linux
+export CI_TARGET_ABI=gnu
+
+export CI_GCC="${CI_GCC-gcc}"
+
+export CI_CC="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-$CI_GCC"
+export CI_AR="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ar"
+export CI_RANLIB="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ranlib"
+
+export CI_CMAKE_VARS="
+    -DCMAKE_SYSTEM_NAME=Linux
+    -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH
+"

+ 21 - 0
png.mod/libpng/ci/targets/linux/ci_env.powerpc64le-linux-gnu.sh

@@ -0,0 +1,21 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=powerpc64le
+export CI_TARGET_SYSTEM=linux
+export CI_TARGET_ABI=gnu
+
+export CI_GCC="${CI_GCC-gcc}"
+
+export CI_CC="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-$CI_GCC"
+export CI_AR="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ar"
+export CI_RANLIB="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ranlib"
+
+export CI_CMAKE_VARS="
+    -DCMAKE_SYSTEM_NAME=Linux
+    -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH
+"

+ 21 - 0
png.mod/libpng/ci/targets/linux/ci_env.riscv64-linux-gnu.sh

@@ -0,0 +1,21 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=riscv64
+export CI_TARGET_SYSTEM=linux
+export CI_TARGET_ABI=gnu
+
+export CI_GCC="${CI_GCC-gcc}"
+
+export CI_CC="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-$CI_GCC"
+export CI_AR="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ar"
+export CI_RANLIB="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ranlib"
+
+export CI_CMAKE_VARS="
+    -DCMAKE_SYSTEM_NAME=Linux
+    -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH
+"

+ 21 - 0
png.mod/libpng/ci/targets/linux/ci_env.x86_64-linux-gnu.sh

@@ -0,0 +1,21 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=x86_64
+export CI_TARGET_SYSTEM=linux
+export CI_TARGET_ABI=gnu
+
+export CI_GCC="${CI_GCC-gcc}"
+
+export CI_CC="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-$CI_GCC"
+export CI_AR="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ar"
+export CI_RANLIB="$CI_TARGET_ARCH-$CI_TARGET_SYSTEM-$CI_TARGET_ABI-ranlib"
+
+export CI_CMAKE_VARS="
+    -DCMAKE_SYSTEM_NAME=Linux
+    -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH
+"

+ 18 - 0
png.mod/libpng/ci/targets/msdos/ci_env.i386-pc-msdoswatcom.sh

@@ -0,0 +1,18 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=i386
+export CI_TARGET_SYSTEM=msdoswatcom
+
+export CI_CC="wcl386"
+
+# Open Watcom V2 CMake build
+# https://github.com/open-watcom/open-watcom-v2/discussions/716
+export CI_CMAKE_GENERATOR="Watcom WMake"
+export CI_CMAKE_VARS="
+    -DCMAKE_SYSTEM_NAME=DOS
+"

+ 18 - 0
png.mod/libpng/ci/targets/msdos/ci_env.i586-pc-msdosdjgpp.sh

@@ -0,0 +1,18 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=i586
+export CI_TARGET_SYSTEM=msdosdjgpp
+
+export CI_CC="$CI_TARGET_ARCH-pc-$CI_TARGET_SYSTEM-gcc"
+export CI_AR="$CI_CC-ar"
+export CI_RANLIB="$CI_CC-ranlib"
+
+export CI_CMAKE_VARS="
+    -DCMAKE_SYSTEM_NAME=Generic
+    -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH
+"

+ 19 - 0
png.mod/libpng/ci/targets/msdos/ci_env.i86-pc-msdoswatcom.sh

@@ -0,0 +1,19 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=i86
+export CI_TARGET_SYSTEM=msdoswatcom
+
+export CI_CC="wcl"
+
+# Open Watcom V2 CMake build
+# https://github.com/open-watcom/open-watcom-v2/discussions/716
+export CI_CMAKE_GENERATOR="Watcom WMake"
+export CI_CMAKE_VARS="
+    -DCMAKE_SYSTEM_NAME=DOS
+    -DCMAKE_SYSTEM_PROCESSOR=I86
+"

+ 18 - 0
png.mod/libpng/ci/targets/windows/ci_env.aarch64-windows-llvm.sh

@@ -0,0 +1,18 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=aarch64
+export CI_TARGET_SYSTEM=windows
+
+export CI_CC="clang"
+export CI_AR="llvm-ar"
+export CI_RANLIB="llvm-ranlib"
+
+export CI_CMAKE_VARS="
+    -DCMAKE_SYSTEM_NAME=Windows
+    -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH
+"

+ 21 - 0
png.mod/libpng/ci/targets/windows/ci_env.i686-w64-mingw32.sh

@@ -0,0 +1,21 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=i686
+export CI_TARGET_SYSTEM=mingw32
+
+# The output of `uname -s` on MSYS2 is understandable, and so is
+# CI_TARGET_SYSTEM above, in simplified form. (See also Cygwin.)
+# But aside from that, the Mingw-w64 nomenclature is rather messy.
+export CI_CC="$CI_TARGET_ARCH-w64-mingw32-gcc"
+export CI_AR="$CI_CC-ar"
+export CI_RANLIB="$CI_CC-ranlib"
+
+export CI_CMAKE_VARS="
+    -DCMAKE_SYSTEM_NAME=Windows
+    -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH
+"

+ 18 - 0
png.mod/libpng/ci/targets/windows/ci_env.i686-windows-llvm.sh

@@ -0,0 +1,18 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=i686
+export CI_TARGET_SYSTEM=windows
+
+export CI_CC="clang"
+export CI_AR="llvm-ar"
+export CI_RANLIB="llvm-ranlib"
+
+export CI_CMAKE_VARS="
+    -DCMAKE_SYSTEM_NAME=Windows
+    -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH
+"

+ 21 - 0
png.mod/libpng/ci/targets/windows/ci_env.x86_64-w64-mingw32.sh

@@ -0,0 +1,21 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=x86_64
+export CI_TARGET_SYSTEM=mingw64
+
+# The output of `uname -s` on MSYS2 is understandable, and so is
+# CI_TARGET_SYSTEM above, in simplified form. (See also Cygwin.)
+# But aside from that, the Mingw-w64 nomenclature is rather messy.
+export CI_CC="$CI_TARGET_ARCH-w64-mingw32-gcc"
+export CI_AR="$CI_CC-ar"
+export CI_RANLIB="$CI_CC-ranlib"
+
+export CI_CMAKE_VARS="
+    -DCMAKE_SYSTEM_NAME=Windows
+    -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH
+"

+ 18 - 0
png.mod/libpng/ci/targets/windows/ci_env.x86_64-windows-llvm.sh

@@ -0,0 +1,18 @@
+# Copyright (c) 2023-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+export CI_TARGET_ARCH=x86_64
+export CI_TARGET_SYSTEM=windows
+
+export CI_CC="clang"
+export CI_AR="llvm-ar"
+export CI_RANLIB="llvm-ranlib"
+
+export CI_CMAKE_VARS="
+    -DCMAKE_SYSTEM_NAME=Windows
+    -DCMAKE_SYSTEM_PROCESSOR=$CI_TARGET_ARCH
+"

+ 7 - 4
png.mod/libpng/compile

@@ -1,9 +1,9 @@
 #! /bin/sh
 # Wrapper for compilers which do not understand '-c -o'.
 
-scriptversion=2018-03-07.03; # UTC
+scriptversion=2024-06-19.01; # UTC
 
-# Copyright (C) 1999-2021 Free Software Foundation, Inc.
+# Copyright (C) 1999-2024 Free Software Foundation, Inc.
 # Written by Tom Tromey <[email protected]>.
 #
 # This program is free software; you can redistribute it and/or modify
@@ -143,7 +143,7 @@ func_cl_wrapper ()
 	  # configure might choose to run compile as 'compile cc -o foo foo.c'.
 	  eat=1
 	  case $2 in
-	    *.o | *.[oO][bB][jJ])
+	    *.o | *.lo | *.[oO][bB][jJ])
 	      func_file_conv "$2"
 	      set x "$@" -Fo"$file"
 	      shift
@@ -248,14 +248,17 @@ If you are trying to build a whole package this is not the
 right script to run: please start by reading the file 'INSTALL'.
 
 Report bugs to <[email protected]>.
+GNU Automake home page: <https://www.gnu.org/software/automake/>.
+General help using GNU software: <https://www.gnu.org/gethelp/>.
 EOF
     exit $?
     ;;
   -v | --v*)
-    echo "compile $scriptversion"
+    echo "compile (GNU Automake) $scriptversion"
     exit $?
     ;;
   cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \
+  clang-cl | *[/\\]clang-cl | clang-cl.exe | *[/\\]clang-cl.exe | \
   icl | *[/\\]icl | icl.exe | *[/\\]icl.exe )
     func_cl_wrapper "$@"      # Doesn't return...
     ;;

+ 88 - 24
png.mod/libpng/config.guess

@@ -1,14 +1,14 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
-#   Copyright 1992-2021 Free Software Foundation, Inc.
+#   Copyright 1992-2024 Free Software Foundation, Inc.
 
 # shellcheck disable=SC2006,SC2268 # see below for rationale
 
-timestamp='2021-06-03'
+timestamp='2024-01-01'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
+# the Free Software Foundation, either version 3 of the License, or
 # (at your option) any later version.
 #
 # This program is distributed in the hope that it will be useful, but
@@ -47,7 +47,7 @@ me=`echo "$0" | sed -e 's,.*/,,'`
 usage="\
 Usage: $0 [OPTION]
 
-Output the configuration name of the system \`$me' is run on.
+Output the configuration name of the system '$me' is run on.
 
 Options:
   -h, --help         print this help, then exit
@@ -60,13 +60,13 @@ version="\
 GNU config.guess ($timestamp)
 
 Originally written by Per Bothner.
-Copyright 1992-2021 Free Software Foundation, Inc.
+Copyright 1992-2024 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
 
 help="
-Try \`$me --help' for more information."
+Try '$me --help' for more information."
 
 # Parse command line
 while test $# -gt 0 ; do
@@ -102,8 +102,8 @@ GUESS=
 # temporary files to be created and, as you can see below, it is a
 # headache to deal with in a portable fashion.
 
-# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
-# use `HOST_CC' if defined, but it is deprecated.
+# Historically, 'CC_FOR_BUILD' used to be named 'HOST_CC'. We still
+# use 'HOST_CC' if defined, but it is deprecated.
 
 # Portable tmp directory creation inspired by the Autoconf team.
 
@@ -155,6 +155,9 @@ Linux|GNU|GNU/*)
 
 	set_cc_for_build
 	cat <<-EOF > "$dummy.c"
+	#if defined(__ANDROID__)
+	LIBC=android
+	#else
 	#include <features.h>
 	#if defined(__UCLIBC__)
 	LIBC=uclibc
@@ -162,6 +165,8 @@ Linux|GNU|GNU/*)
 	LIBC=dietlibc
 	#elif defined(__GLIBC__)
 	LIBC=gnu
+	#elif defined(__LLVM_LIBC__)
+	LIBC=llvm
 	#else
 	#include <stdarg.h>
 	/* First heuristic to detect musl libc.  */
@@ -169,6 +174,7 @@ Linux|GNU|GNU/*)
 	LIBC=musl
 	#endif
 	#endif
+	#endif
 	EOF
 	cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
 	eval "$cc_set_libc"
@@ -437,7 +443,7 @@ case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in
 	# This test works for both compilers.
 	if test "$CC_FOR_BUILD" != no_compiler_found; then
 	    if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
-		(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
+		(CCOPTS="" $CC_FOR_BUILD -m64 -E - 2>/dev/null) | \
 		grep IS_64BIT_ARCH >/dev/null
 	    then
 		SUN_ARCH=x86_64
@@ -459,7 +465,7 @@ case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in
 		UNAME_RELEASE=`uname -v`
 		;;
 	esac
-	# Japanese Language versions have a version number like `4.1.3-JL'.
+	# Japanese Language versions have a version number like '4.1.3-JL'.
 	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'`
 	GUESS=sparc-sun-sunos$SUN_REL
 	;;
@@ -904,7 +910,7 @@ EOF
 	fi
 	;;
     *:FreeBSD:*:*)
-	UNAME_PROCESSOR=`/usr/bin/uname -p`
+	UNAME_PROCESSOR=`uname -p`
 	case $UNAME_PROCESSOR in
 	    amd64)
 		UNAME_PROCESSOR=x86_64 ;;
@@ -929,6 +935,9 @@ EOF
     i*:PW*:*)
 	GUESS=$UNAME_MACHINE-pc-pw32
 	;;
+    *:SerenityOS:*:*)
+        GUESS=$UNAME_MACHINE-pc-serenity
+        ;;
     *:Interix*:*)
 	case $UNAME_MACHINE in
 	    x86)
@@ -963,11 +972,37 @@ EOF
 	GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
 	GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC
 	;;
+    x86_64:[Mm]anagarm:*:*|i?86:[Mm]anagarm:*:*)
+	GUESS="$UNAME_MACHINE-pc-managarm-mlibc"
+	;;
+    *:[Mm]anagarm:*:*)
+	GUESS="$UNAME_MACHINE-unknown-managarm-mlibc"
+	;;
     *:Minix:*:*)
 	GUESS=$UNAME_MACHINE-unknown-minix
 	;;
     aarch64:Linux:*:*)
-	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+	set_cc_for_build
+	CPU=$UNAME_MACHINE
+	LIBCABI=$LIBC
+	if test "$CC_FOR_BUILD" != no_compiler_found; then
+	    ABI=64
+	    sed 's/^	    //' << EOF > "$dummy.c"
+	    #ifdef __ARM_EABI__
+	    #ifdef __ARM_PCS_VFP
+	    ABI=eabihf
+	    #else
+	    ABI=eabi
+	    #endif
+	    #endif
+EOF
+	    cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'`
+	    eval "$cc_set_abi"
+	    case $ABI in
+		eabi | eabihf) CPU=armv8l; LIBCABI=$LIBC$ABI ;;
+	    esac
+	fi
+	GUESS=$CPU-unknown-linux-$LIBCABI
 	;;
     aarch64_be:Linux:*:*)
 	UNAME_MACHINE=aarch64_be
@@ -1033,7 +1068,16 @@ EOF
     k1om:Linux:*:*)
 	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
 	;;
-    loongarch32:Linux:*:* | loongarch64:Linux:*:* | loongarchx32:Linux:*:*)
+    kvx:Linux:*:*)
+	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
+	;;
+    kvx:cos:*:*)
+	GUESS=$UNAME_MACHINE-unknown-cos
+	;;
+    kvx:mbr:*:*)
+	GUESS=$UNAME_MACHINE-unknown-mbr
+	;;
+    loongarch32:Linux:*:* | loongarch64:Linux:*:*)
 	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
 	;;
     m32r*:Linux:*:*)
@@ -1148,16 +1192,27 @@ EOF
 	;;
     x86_64:Linux:*:*)
 	set_cc_for_build
+	CPU=$UNAME_MACHINE
 	LIBCABI=$LIBC
 	if test "$CC_FOR_BUILD" != no_compiler_found; then
-	    if (echo '#ifdef __ILP32__'; echo IS_X32; echo '#endif') | \
-		(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
-		grep IS_X32 >/dev/null
-	    then
-		LIBCABI=${LIBC}x32
-	    fi
+	    ABI=64
+	    sed 's/^	    //' << EOF > "$dummy.c"
+	    #ifdef __i386__
+	    ABI=x86
+	    #else
+	    #ifdef __ILP32__
+	    ABI=x32
+	    #endif
+	    #endif
+EOF
+	    cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'`
+	    eval "$cc_set_abi"
+	    case $ABI in
+		x86) CPU=i686 ;;
+		x32) LIBCABI=${LIBC}x32 ;;
+	    esac
 	fi
-	GUESS=$UNAME_MACHINE-pc-linux-$LIBCABI
+	GUESS=$CPU-pc-linux-$LIBCABI
 	;;
     xtensa*:Linux:*:*)
 	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
@@ -1177,7 +1232,7 @@ EOF
 	GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION
 	;;
     i*86:OS/2:*:*)
-	# If we were able to find `uname', then EMX Unix compatibility
+	# If we were able to find 'uname', then EMX Unix compatibility
 	# is probably installed.
 	GUESS=$UNAME_MACHINE-pc-os2-emx
 	;;
@@ -1318,7 +1373,7 @@ EOF
 		GUESS=ns32k-sni-sysv
 	fi
 	;;
-    PENTIUM:*:4.0*:*)	# Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+    PENTIUM:*:4.0*:*)	# Unisys 'ClearPath HMP IX 4000' SVR4/MP effort
 			# says <[email protected]>
 	GUESS=i586-unisys-sysv4
 	;;
@@ -1364,8 +1419,11 @@ EOF
     BePC:Haiku:*:*)	# Haiku running on Intel PC compatible.
 	GUESS=i586-pc-haiku
 	;;
-    x86_64:Haiku:*:*)
-	GUESS=x86_64-unknown-haiku
+    ppc:Haiku:*:*)	# Haiku running on Apple PowerPC
+	GUESS=powerpc-apple-haiku
+	;;
+    *:Haiku:*:*)	# Haiku modern gcc (not bound by BeOS compat)
+	GUESS=$UNAME_MACHINE-unknown-haiku
 	;;
     SX-4:SUPER-UX:*:*)
 	GUESS=sx4-nec-superux$UNAME_RELEASE
@@ -1522,6 +1580,9 @@ EOF
     i*86:rdos:*:*)
 	GUESS=$UNAME_MACHINE-pc-rdos
 	;;
+    i*86:Fiwix:*:*)
+	GUESS=$UNAME_MACHINE-pc-fiwix
+	;;
     *:AROS:*:*)
 	GUESS=$UNAME_MACHINE-unknown-aros
 	;;
@@ -1534,6 +1595,9 @@ EOF
     *:Unleashed:*:*)
 	GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE
 	;;
+    *:Ironclad:*:*)
+	GUESS=$UNAME_MACHINE-unknown-ironclad
+	;;
 esac
 
 # Do we have a guess based on uname results?

+ 18 - 6
png.mod/libpng/config.h.in

@@ -3,19 +3,19 @@
 /* Define to 1 if you have the <dlfcn.h> header file. */
 #undef HAVE_DLFCN_H
 
-/* Define to 1 if you have the `feenableexcept' function. */
+/* Define to 1 if you have the 'feenableexcept' function. */
 #undef HAVE_FEENABLEEXCEPT
 
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
-/* Define to 1 if you have the `m' library (-lm). */
+/* Define to 1 if you have the 'm' library (-lm). */
 #undef HAVE_LIBM
 
-/* Define to 1 if you have the `z' library (-lz). */
+/* Define to 1 if you have the 'z' library (-lz). */
 #undef HAVE_LIBZ
 
-/* Define to 1 if you have the `pow' function. */
+/* Define to 1 if you have the 'pow' function. */
 #undef HAVE_POW
 
 /* Define to 1 if you have the <stdint.h> header file. */
@@ -78,6 +78,18 @@
 /* Enable Intel SSE optimizations */
 #undef PNG_INTEL_SSE_OPT
 
+/* Enable LOONGARCH LSX optimizations */
+#undef PNG_LOONGARCH_LSX_OPT
+
+/* Turn on MIPS MMI optimizations at run-time */
+#undef PNG_MIPS_MMI_API_SUPPORTED
+
+/* Check for MIPS MMI support at run-time */
+#undef PNG_MIPS_MMI_CHECK_SUPPORTED
+
+/* Enable MIPS MMI optimizations */
+#undef PNG_MIPS_MMI_OPT
+
 /* Turn on MIPS MSA optimizations at run-time */
 #undef PNG_MIPS_MSA_API_SUPPORTED
 
@@ -96,12 +108,12 @@
 /* Enable POWERPC VSX optimizations */
 #undef PNG_POWERPC_VSX_OPT
 
-/* Define to 1 if all of the C90 standard headers exist (not just the ones
+/* Define to 1 if all of the C89 standard headers exist (not just the ones
    required in a freestanding environment). This macro is provided for
    backward compatibility; new code need not use it. */
 #undef STDC_HEADERS
 
-/* Define to 1 if your <sys/time.h> declares `struct tm'. */
+/* Define to 1 if your <sys/time.h> declares 'struct tm'. */
 #undef TM_IN_SYS_TIME
 
 /* Version number of package */

+ 169 - 82
png.mod/libpng/config.sub

@@ -1,14 +1,14 @@
 #! /bin/sh
 # Configuration validation subroutine script.
-#   Copyright 1992-2021 Free Software Foundation, Inc.
+#   Copyright 1992-2024 Free Software Foundation, Inc.
 
 # shellcheck disable=SC2006,SC2268 # see below for rationale
 
-timestamp='2021-08-14'
+timestamp='2024-01-01'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
+# the Free Software Foundation, either version 3 of the License, or
 # (at your option) any later version.
 #
 # This program is distributed in the hope that it will be useful, but
@@ -76,13 +76,13 @@ Report bugs and patches to <[email protected]>."
 version="\
 GNU config.sub ($timestamp)
 
-Copyright 1992-2021 Free Software Foundation, Inc.
+Copyright 1992-2024 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
 
 help="
-Try \`$me --help' for more information."
+Try '$me --help' for more information."
 
 # Parse command line
 while test $# -gt 0 ; do
@@ -130,7 +130,7 @@ IFS=$saved_IFS
 # Separate into logical components for further validation
 case $1 in
 	*-*-*-*-*)
-		echo Invalid configuration \`"$1"\': more than four components >&2
+		echo "Invalid configuration '$1': more than four components" >&2
 		exit 1
 		;;
 	*-*-*-*)
@@ -145,7 +145,8 @@ case $1 in
 			nto-qnx* | linux-* | uclinux-uclibc* \
 			| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
 			| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
-			| storm-chaos* | os2-emx* | rtmk-nova*)
+			| storm-chaos* | os2-emx* | rtmk-nova* | managarm-* \
+			| windows-* )
 				basic_machine=$field1
 				basic_os=$maybe_os
 				;;
@@ -943,7 +944,7 @@ $basic_machine
 EOF
 		IFS=$saved_IFS
 		;;
-	# We use `pc' rather than `unknown'
+	# We use 'pc' rather than 'unknown'
 	# because (1) that's what they normally are, and
 	# (2) the word "unknown" tends to confuse beginning users.
 	i*86 | x86_64)
@@ -1020,6 +1021,11 @@ case $cpu-$vendor in
 		;;
 
 	# Here we normalize CPU types with a missing or matching vendor
+	armh-unknown | armh-alt)
+		cpu=armv7l
+		vendor=alt
+		basic_os=${basic_os:-linux-gnueabihf}
+		;;
 	dpx20-unknown | dpx20-bull)
 		cpu=rs6000
 		vendor=bull
@@ -1070,7 +1076,7 @@ case $cpu-$vendor in
 	pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
 		cpu=i586
 		;;
-	pentiumpro-* | p6-* | 6x86-* | athlon-* | athalon_*-*)
+	pentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_*-*)
 		cpu=i686
 		;;
 	pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
@@ -1121,7 +1127,7 @@ case $cpu-$vendor in
 	xscale-* | xscalee[bl]-*)
 		cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
 		;;
-	arm64-*)
+	arm64-* | aarch64le-*)
 		cpu=aarch64
 		;;
 
@@ -1175,7 +1181,7 @@ case $cpu-$vendor in
 		case $cpu in
 			1750a | 580 \
 			| a29k \
-			| aarch64 | aarch64_be \
+			| aarch64 | aarch64_be | aarch64c | arm64ec \
 			| abacus \
 			| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
 			| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
@@ -1194,50 +1200,29 @@ case $cpu-$vendor in
 			| d10v | d30v | dlx | dsp16xx \
 			| e2k | elxsi | epiphany \
 			| f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
+			| javascript \
 			| h8300 | h8500 \
 			| hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
 			| hexagon \
 			| i370 | i*86 | i860 | i960 | ia16 | ia64 \
 			| ip2k | iq2000 \
 			| k1om \
+			| kvx \
 			| le32 | le64 \
 			| lm32 \
-			| loongarch32 | loongarch64 | loongarchx32 \
+			| loongarch32 | loongarch64 \
 			| m32c | m32r | m32rle \
 			| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
 			| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
 			| m88110 | m88k | maxq | mb | mcore | mep | metag \
 			| microblaze | microblazeel \
-			| mips | mipsbe | mipseb | mipsel | mipsle \
-			| mips16 \
-			| mips64 | mips64eb | mips64el \
-			| mips64octeon | mips64octeonel \
-			| mips64orion | mips64orionel \
-			| mips64r5900 | mips64r5900el \
-			| mips64vr | mips64vrel \
-			| mips64vr4100 | mips64vr4100el \
-			| mips64vr4300 | mips64vr4300el \
-			| mips64vr5000 | mips64vr5000el \
-			| mips64vr5900 | mips64vr5900el \
-			| mipsisa32 | mipsisa32el \
-			| mipsisa32r2 | mipsisa32r2el \
-			| mipsisa32r3 | mipsisa32r3el \
-			| mipsisa32r5 | mipsisa32r5el \
-			| mipsisa32r6 | mipsisa32r6el \
-			| mipsisa64 | mipsisa64el \
-			| mipsisa64r2 | mipsisa64r2el \
-			| mipsisa64r3 | mipsisa64r3el \
-			| mipsisa64r5 | mipsisa64r5el \
-			| mipsisa64r6 | mipsisa64r6el \
-			| mipsisa64sb1 | mipsisa64sb1el \
-			| mipsisa64sr71k | mipsisa64sr71kel \
-			| mipsr5900 | mipsr5900el \
-			| mipstx39 | mipstx39el \
+			| mips* \
 			| mmix \
 			| mn10200 | mn10300 \
 			| moxie \
 			| mt \
 			| msp430 \
+			| nanomips* \
 			| nds32 | nds32le | nds32be \
 			| nfp \
 			| nios | nios2 | nios2eb | nios2el \
@@ -1269,6 +1254,7 @@ case $cpu-$vendor in
 			| ubicom32 \
 			| v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
 			| vax \
+			| vc4 \
 			| visium \
 			| w65 \
 			| wasm32 | wasm64 \
@@ -1280,7 +1266,7 @@ case $cpu-$vendor in
 				;;
 
 			*)
-				echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2
+				echo "Invalid configuration '$1': machine '$cpu-$vendor' not recognized" 1>&2
 				exit 1
 				;;
 		esac
@@ -1301,11 +1287,12 @@ esac
 
 # Decode manufacturer-specific aliases for certain operating systems.
 
-if test x$basic_os != x
+if test x"$basic_os" != x
 then
 
-# First recognize some ad-hoc caes, or perhaps split kernel-os, or else just
+# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just
 # set os.
+obj=
 case $basic_os in
 	gnu/linux*)
 		kernel=linux
@@ -1336,6 +1323,10 @@ EOF
 		kernel=linux
 		os=`echo "$basic_os" | sed -e 's|linux|gnu|'`
 		;;
+	managarm*)
+		kernel=managarm
+		os=`echo "$basic_os" | sed -e 's|managarm|mlibc|'`
+		;;
 	*)
 		kernel=
 		os=$basic_os
@@ -1501,10 +1492,16 @@ case $os in
 			os=eabi
 			;;
 		    *)
-			os=elf
+			os=
+			obj=elf
 			;;
 		esac
 		;;
+	aout* | coff* | elf* | pe*)
+		# These are machine code file formats, not OSes
+		obj=$os
+		os=
+		;;
 	*)
 		# No normalization, but not necessarily accepted, that comes below.
 		;;
@@ -1523,12 +1520,15 @@ else
 # system, and we'll never get to this point.
 
 kernel=
+obj=
 case $cpu-$vendor in
 	score-*)
-		os=elf
+		os=
+		obj=elf
 		;;
 	spu-*)
-		os=elf
+		os=
+		obj=elf
 		;;
 	*-acorn)
 		os=riscix1.2
@@ -1538,28 +1538,35 @@ case $cpu-$vendor in
 		os=gnu
 		;;
 	arm*-semi)
-		os=aout
+		os=
+		obj=aout
 		;;
 	c4x-* | tic4x-*)
-		os=coff
+		os=
+		obj=coff
 		;;
 	c8051-*)
-		os=elf
+		os=
+		obj=elf
 		;;
 	clipper-intergraph)
 		os=clix
 		;;
 	hexagon-*)
-		os=elf
+		os=
+		obj=elf
 		;;
 	tic54x-*)
-		os=coff
+		os=
+		obj=coff
 		;;
 	tic55x-*)
-		os=coff
+		os=
+		obj=coff
 		;;
 	tic6x-*)
-		os=coff
+		os=
+		obj=coff
 		;;
 	# This must come before the *-dec entry.
 	pdp10-*)
@@ -1581,19 +1588,24 @@ case $cpu-$vendor in
 		os=sunos3
 		;;
 	m68*-cisco)
-		os=aout
+		os=
+		obj=aout
 		;;
 	mep-*)
-		os=elf
+		os=
+		obj=elf
 		;;
 	mips*-cisco)
-		os=elf
+		os=
+		obj=elf
 		;;
-	mips*-*)
-		os=elf
+	mips*-*|nanomips*-*)
+		os=
+		obj=elf
 		;;
 	or32-*)
-		os=coff
+		os=
+		obj=coff
 		;;
 	*-tti)	# must be before sparc entry or we get the wrong os.
 		os=sysv3
@@ -1602,7 +1614,8 @@ case $cpu-$vendor in
 		os=sunos4.1.1
 		;;
 	pru-*)
-		os=elf
+		os=
+		obj=elf
 		;;
 	*-be)
 		os=beos
@@ -1683,10 +1696,12 @@ case $cpu-$vendor in
 		os=uxpv
 		;;
 	*-rom68k)
-		os=coff
+		os=
+		obj=coff
 		;;
 	*-*bug)
-		os=coff
+		os=
+		obj=coff
 		;;
 	*-apple)
 		os=macos
@@ -1704,10 +1719,11 @@ esac
 
 fi
 
-# Now, validate our (potentially fixed-up) OS.
+# Now, validate our (potentially fixed-up) individual pieces (OS, OBJ).
+
 case $os in
 	# Sometimes we do "kernel-libc", so those need to count as OSes.
-	musl* | newlib* | relibc* | uclibc*)
+	llvm* | musl* | newlib* | relibc* | uclibc*)
 		;;
 	# Likewise for "kernel-abi"
 	eabi* | gnueabi*)
@@ -1715,6 +1731,9 @@ case $os in
 	# VxWorks passes extra cpu info in the 4th filed.
 	simlinux | simwindows | spe)
 		;;
+	# See `case $cpu-$os` validation below
+	ghcjs)
+		;;
 	# Now accept the basic system types.
 	# The portable systems comes first.
 	# Each alternative MUST end in a * to match a version number.
@@ -1723,7 +1742,7 @@ case $os in
 	     | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
 	     | sym* |  plan9* | psp* | sim* | xray* | os68k* | v88r* \
 	     | hiux* | abug | nacl* | netware* | windows* \
-	     | os9* | macos* | osx* | ios* \
+	     | os9* | macos* | osx* | ios* | tvos* | watchos* \
 	     | mpw* | magic* | mmixware* | mon960* | lnews* \
 	     | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
 	     | aos* | aros* | cloudabi* | sortix* | twizzler* \
@@ -1732,11 +1751,11 @@ case $os in
 	     | mirbsd* | netbsd* | dicos* | openedition* | ose* \
 	     | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \
 	     | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
-	     | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
-	     | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
+	     | bosx* | nextstep* | cxux* | oabi* \
+	     | ptx* | ecoff* | winnt* | domain* | vsta* \
 	     | udi* | lites* | ieee* | go32* | aux* | hcos* \
 	     | chorusrdb* | cegcc* | glidix* | serenity* \
-	     | cygwin* | msys* | pe* | moss* | proelf* | rtems* \
+	     | cygwin* | msys* | moss* | proelf* | rtems* \
 	     | midipix* | mingw32* | mingw64* | mint* \
 	     | uxpv* | beos* | mpeix* | udk* | moxiebox* \
 	     | interix* | uwin* | mks* | rhapsody* | darwin* \
@@ -1748,49 +1767,117 @@ case $os in
 	     | skyos* | haiku* | rdos* | toppers* | drops* | es* \
 	     | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
 	     | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
-	     | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr*)
+	     | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
+	     | fiwix* | mlibc* | cos* | mbr* | ironclad* )
 		;;
 	# This one is extra strict with allowed versions
 	sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
 		# Don't forget version if it is 3.2v4 or newer.
 		;;
+	# This refers to builds using the UEFI calling convention
+	# (which depends on the architecture) and PE file format.
+	# Note that this is both a different calling convention and
+	# different file format than that of GNU-EFI
+	# (x86_64-w64-mingw32).
+	uefi)
+		;;
 	none)
 		;;
+	kernel* | msvc* )
+		# Restricted further below
+		;;
+	'')
+		if test x"$obj" = x
+		then
+			echo "Invalid configuration '$1': Blank OS only allowed with explicit machine code file format" 1>&2
+		fi
+		;;
 	*)
-		echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2
+		echo "Invalid configuration '$1': OS '$os' not recognized" 1>&2
+		exit 1
+		;;
+esac
+
+case $obj in
+	aout* | coff* | elf* | pe*)
+		;;
+	'')
+		# empty is fine
+		;;
+	*)
+		echo "Invalid configuration '$1': Machine code format '$obj' not recognized" 1>&2
+		exit 1
+		;;
+esac
+
+# Here we handle the constraint that a (synthetic) cpu and os are
+# valid only in combination with each other and nowhere else.
+case $cpu-$os in
+	# The "javascript-unknown-ghcjs" triple is used by GHC; we
+	# accept it here in order to tolerate that, but reject any
+	# variations.
+	javascript-ghcjs)
+		;;
+	javascript-* | *-ghcjs)
+		echo "Invalid configuration '$1': cpu '$cpu' is not valid with os '$os$obj'" 1>&2
 		exit 1
 		;;
 esac
 
 # As a final step for OS-related things, validate the OS-kernel combination
 # (given a valid OS), if there is a kernel.
-case $kernel-$os in
-	linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* \
-		   | linux-musl* | linux-relibc* | linux-uclibc* )
+case $kernel-$os-$obj in
+	linux-gnu*- | linux-android*- | linux-dietlibc*- | linux-llvm*- \
+		    | linux-mlibc*- | linux-musl*- | linux-newlib*- \
+		    | linux-relibc*- | linux-uclibc*- )
+		;;
+	uclinux-uclibc*- )
+		;;
+	managarm-mlibc*- | managarm-kernel*- )
 		;;
-	uclinux-uclibc* )
+	windows*-msvc*-)
 		;;
-	-dietlibc* | -newlib* | -musl* | -relibc* | -uclibc* )
+	-dietlibc*- | -llvm*- | -mlibc*- | -musl*- | -newlib*- | -relibc*- \
+		    | -uclibc*- )
 		# These are just libc implementations, not actual OSes, and thus
 		# require a kernel.
-		echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2
+		echo "Invalid configuration '$1': libc '$os' needs explicit kernel." 1>&2
 		exit 1
 		;;
-	kfreebsd*-gnu* | kopensolaris*-gnu*)
+	-kernel*- )
+		echo "Invalid configuration '$1': '$os' needs explicit kernel." 1>&2
+		exit 1
 		;;
-	vxworks-simlinux | vxworks-simwindows | vxworks-spe)
+	*-kernel*- )
+		echo "Invalid configuration '$1': '$kernel' does not support '$os'." 1>&2
+		exit 1
 		;;
-	nto-qnx*)
+	*-msvc*- )
+		echo "Invalid configuration '$1': '$os' needs 'windows'." 1>&2
+		exit 1
 		;;
-	os2-emx)
+	kfreebsd*-gnu*- | kopensolaris*-gnu*-)
+		;;
+	vxworks-simlinux- | vxworks-simwindows- | vxworks-spe-)
+		;;
+	nto-qnx*-)
+		;;
+	os2-emx-)
 		;;
-	*-eabi* | *-gnueabi*)
+	*-eabi*- | *-gnueabi*-)
 		;;
-	-*)
+	none--*)
+		# None (no kernel, i.e. freestanding / bare metal),
+		# can be paired with an machine code file format
+		;;
+	-*-)
 		# Blank kernel with real OS is always fine.
 		;;
-	*-*)
-		echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2
+	--*)
+		# Blank kernel and OS with real machine code file format is always fine.
+		;;
+	*-*-*)
+		echo "Invalid configuration '$1': Kernel '$kernel' not known to work with OS '$os'." 1>&2
 		exit 1
 		;;
 esac
@@ -1873,7 +1960,7 @@ case $vendor in
 		;;
 esac
 
-echo "$cpu-$vendor-${kernel:+$kernel-}$os"
+echo "$cpu-$vendor${kernel:+-$kernel}${os:+-$os}${obj:+-$obj}"
 exit
 
 # Local variables:

File diff suppressed because it is too large
+ 351 - 140
png.mod/libpng/configure


+ 212 - 68
png.mod/libpng/configure.ac

@@ -1,6 +1,6 @@
 # configure.ac
 
-# Copyright (c) 2018-2022 Cosmin Truta
+# Copyright (c) 2018-2024 Cosmin Truta
 # Copyright (c) 2004-2016 Glenn Randers-Pehrson
 
 # This code is released under the libpng license.
@@ -25,8 +25,8 @@ AC_PREREQ([2.68])
 
 dnl Version number stuff here:
 
-AC_INIT([libpng],[1.6.40],[[email protected]])
-AC_CONFIG_MACRO_DIR([scripts])
+AC_INIT([libpng],[1.6.48],[[email protected]])
+AC_CONFIG_MACRO_DIR([scripts/autoconf])
 
 # libpng does not follow GNU file name conventions (hence 'foreign')
 # color-tests requires automake 1.11 or later
@@ -46,17 +46,17 @@ dnl automake, so the following is not necessary (and is not defined anyway):
 dnl AM_PREREQ([1.11.2])
 dnl stop configure from automagically running automake
 
-PNGLIB_VERSION=1.6.40
+PNGLIB_VERSION=1.6.48
 PNGLIB_MAJOR=1
 PNGLIB_MINOR=6
-PNGLIB_RELEASE=40
+PNGLIB_RELEASE=48
 
 dnl End of version number stuff
 
 AC_CONFIG_SRCDIR([pngget.c])
 AC_CONFIG_HEADERS([config.h])
 
-# Checks for programs.
+# Check the basic programs.
 AC_LANG([C])
 AC_PROG_CC
 AM_PROG_AS
@@ -72,16 +72,19 @@ dnl compatible later version may be used
 LT_INIT([win32-dll])
 LT_PREREQ([2.4.2])
 
-# Some awks crash when confronted with pnglibconf.dfa, do a test run now
-# to make sure this doesn't happen
-AC_MSG_CHECKING([that AWK works])
+dnl Declare the AWK variable.
+AC_ARG_VAR(AWK, [AWK language processor])
+
+# Some awk implementations crash when confronted with pnglibconf.dfa.
+# Run a test now, to make sure this doesn't happen.
+AC_MSG_CHECKING([if awk ($AWK) works])
 if ${AWK} -f ${srcdir}/scripts/options.awk out="/dev/null" version=search\
    ${srcdir}/pngconf.h ${srcdir}/scripts/pnglibconf.dfa\
    ${srcdir}/pngusr.dfa 1>&2
 then
-   AC_MSG_RESULT([ok])
+   AC_MSG_RESULT([yes])
 else
-   AC_MSG_FAILURE([failed], 1)
+   AC_MSG_FAILURE([no], 1)
 fi
 
 # This is a remnant of the old cc -E validation, where it may have been
@@ -89,11 +92,29 @@ fi
 DFNCPP="$CPP"
 AC_SUBST(DFNCPP)
 
+AC_ARG_ENABLE([tests],
+   AS_HELP_STRING([--disable-tests],
+      [do not build the test programs (default is to build)]),
+      [enable_tests="$enableval"],
+      [enable_tests=yes])
+
+AM_CONDITIONAL([ENABLE_TESTS],
+   [test "$enable_tests" != "no"])
+
+AC_ARG_ENABLE([tools],
+   AS_HELP_STRING([--disable-tools],
+      [do not build the auxiliary tools (default is to build)]),
+      [enable_tools="$enableval"],
+      [enable_tools=yes])
+
+AM_CONDITIONAL([ENABLE_TOOLS],
+   [test "$enable_tools" != "no"])
+
 # -Werror cannot be passed to GCC in CFLAGS because configure will fail
 # (it checks the compiler with a program that generates a warning).
 # Add the following option to deal with this:
 AC_ARG_VAR(PNG_COPTS,
-   [additional flags for the C compiler, use this for options that would]
+   [additional flags for the C compiler, to be used for options that would]
    [cause configure itself to fail])
 AC_ARG_ENABLE(werror,
    AS_HELP_STRING([[[--enable-werror[=OPT]]]],
@@ -205,9 +226,9 @@ AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
 if test "$have_ld_version_script" = "yes"; then
     AC_MSG_CHECKING([for symbol prefix])
     SYMBOL_PREFIX=`echo "PREFIX=__USER_LABEL_PREFIX__" \
-                  | ${CPP-${CC-gcc} -E} - 2>&1 \
-                  | ${EGREP-grep} "^PREFIX=" \
-                  | ${SED-sed} -e "s:^PREFIX=::" -e "s:__USER_LABEL_PREFIX__::"`
+                  | ${CPP:-${CC:-gcc} -E} - 2>&1 \
+                  | ${EGREP:-grep} "^PREFIX=" \
+                  | ${SED:-sed} -e "s:^PREFIX=::" -e "s:__USER_LABEL_PREFIX__::"`
     AC_SUBST(SYMBOL_PREFIX)
     AC_MSG_RESULT($SYMBOL_PREFIX)
 fi
@@ -300,7 +321,7 @@ AM_CONDITIONAL([DO_INSTALL_LIBPNG_CONFIG],
 #
 AC_ARG_ENABLE([hardware-optimizations],
    AS_HELP_STRING([[[--enable-hardware-optimizations]]],
-      [Enable hardware optimizations: =no/off, yes/on:]),
+      [Enable hardware optimizations: =no/off, yes/on.]),
    [case "$enableval" in
       no|off)
          # disable hardware optimization on all systems:
@@ -310,12 +331,18 @@ AC_ARG_ENABLE([hardware-optimizations],
          enable_mips_msa=no
          AC_DEFINE([PNG_MIPS_MSA_OPT], [0],
            [Disable MIPS_MSA optimizations])
+         enable_mips_mmi=no
+         AC_DEFINE([PNG_MIPS_MMI_OPT], [0],
+           [Disable MIPS_MMI optimizations])
          enable_powerpc_vsx=no
          AC_DEFINE([PNG_POWERPC_VSX_OPT], [0],
            [Disable POWERPC VSX optimizations])
          enable_intel_sse=no
          AC_DEFINE([PNG_INTEL_SSE_OPT], [0],
            [Disable INTEL_SSE optimizations])
+         enable_loongarch_lsx=no
+         AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [0],
+           [Disable LOONGARCH_LSX optimizations])
          ;;
       *)
          # allow enabling hardware optimization on any system:
@@ -326,7 +353,10 @@ AC_ARG_ENABLE([hardware-optimizations],
                 [Enable ARM_NEON optimizations])
               ;;
             mipsel*|mips64el*)
+              enable_mips_mmi=yes
               enable_mips_msa=yes
+              AC_DEFINE([PNG_MIPS_MMI_OPT], [1],
+                [Enable MIPS_MMI optimizations])
               AC_DEFINE([PNG_MIPS_MSA_OPT], [2],
                 [Enable MIPS_MSA optimizations])
               ;;
@@ -340,21 +370,25 @@ AC_ARG_ENABLE([hardware-optimizations],
               AC_DEFINE([PNG_POWERPC_VSX_OPT], [2],
                 [Enable POWERPC VSX optimizations])
               ;;
+            loongarch*)
+              enable_loongarch_lsx=yes
+              AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [1],
+                [Enable LOONGARCH_LSX optimizations])
+              ;;
          esac
          ;;
    esac])
 
-# ARM
-# ===
-#
-# ARM NEON (SIMD) support.
+# ARM NEON
+# ========
 
 AC_ARG_ENABLE([arm-neon],
    AS_HELP_STRING([[[--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.]
+      [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.]
       [If not specified: determined by the compiler.]),
    [case "$enableval" in
       no|off)
@@ -372,16 +406,17 @@ AC_ARG_ENABLE([arm-neon],
       yes|on)
          AC_DEFINE([PNG_ARM_NEON_OPT], [2],
                    [Enable ARM Neon optimizations])
-         AC_MSG_WARN([--enable-arm-neon: please specify 'check' or 'api', if]
-            [you want the optimizations unconditionally pass -mfpu=neon]
-            [to the compiler.]);;
+         AC_MSG_WARN([--enable-arm-neon: please specify 'check' or 'api';]
+            [if you want the optimizations unconditionally,]
+            [pass '-mfpu=neon' to the compiler.]);;
       *)
-         AC_MSG_ERROR([--enable-arm-neon=${enable_arm_neon}: invalid value])
+         AC_MSG_ERROR([--enable-arm-neon=${enable_arm_neon}:]
+                      [invalid argument])
    esac])
 
 # Add ARM-specific files to all builds where $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*')
+# 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' &&
@@ -390,17 +425,16 @@ AM_CONDITIONAL([PNG_ARM_NEON],
       *)    test "$enable_arm_neon" != '' ;;
     esac])
 
-# MIPS
-# ====
-#
-# MIPS MSA (SIMD) support.
+# MIPS MSA
+# ========
 
 AC_ARG_ENABLE([mips-msa],
    AS_HELP_STRING([[[--enable-mips-msa]]],
-      [Enable MIPS MSA 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.]
+      [Enable MIPS MSA 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.]
       [If not specified: determined by the compiler.]),
    [case "$enableval" in
       no|off)
@@ -418,16 +452,17 @@ AC_ARG_ENABLE([mips-msa],
       yes|on)
          AC_DEFINE([PNG_MIPS_MSA_OPT], [2],
                    [Enable MIPS MSA optimizations])
-         AC_MSG_WARN([--enable-mips-msa: please specify 'check' or 'api', if]
-            [you want the optimizations unconditionally pass '-mmsa -mfp64']
-            [to the compiler.]);;
+         AC_MSG_WARN([--enable-mips-msa: please specify 'check' or 'api';]
+            [if you want the optimizations unconditionally,]
+            [pass '-mmsa -mfp64' to the compiler.]);;
       *)
-         AC_MSG_ERROR([--enable-mips-msa=${enable_mips_msa}: invalid value])
+         AC_MSG_ERROR([--enable-mips-msa=${enable_mips_msa}:]
+                      [invalid argument])
    esac])
 
 # Add MIPS-specific files to all builds where $host_cpu is mips ('mips*') or
-# where MIPS optimizations were explicitly requested (this allows a fallback
-# if a future host CPU does not match 'mips*')
+# where MIPS optimizations were explicitly requested. (This allows a fallback
+# if a future host CPU does not match 'mips*'.)
 
 AM_CONDITIONAL([PNG_MIPS_MSA],
    [test "$enable_mips_msa" != 'no' &&
@@ -435,14 +470,57 @@ AM_CONDITIONAL([PNG_MIPS_MSA],
       mipsel*|mips64el*) : ;;
     esac])
 
-# INTEL
-# =====
-#
-# INTEL SSE (SIMD) support.
+# MIPS MMI
+# ========
+
+AC_ARG_ENABLE([mips-mmi],
+   AS_HELP_STRING([[[--enable-mips-mmi]]],
+      [Enable MIPS MMI 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.]
+      [If not specified: determined by the compiler.]),
+   [case "$enableval" in
+      no|off)
+         # disable the default enabling on __mips_mmi systems:
+         AC_DEFINE([PNG_MIPS_MMI_OPT], [0],
+                   [Disable MIPS MMI optimizations])
+         # Prevent inclusion of the assembler files below:
+         enable_mips_mmi=no;;
+      check)
+         AC_DEFINE([PNG_MIPS_MMI_CHECK_SUPPORTED], [],
+                   [Check for MIPS MMI support at run-time]);;
+      api)
+         AC_DEFINE([PNG_MIPS_MMI_API_SUPPORTED], [],
+                   [Turn on MIPS MMI optimizations at run-time]);;
+      yes|on)
+         AC_DEFINE([PNG_MIPS_MMI_OPT], [1],
+                   [Enable MIPS MMI optimizations])
+         AC_MSG_WARN([--enable-mips-mmi: please specify 'check' or 'api';]
+            [if you want the optimizations unconditionally]
+            [pass '-mloongson-mmi -march=loongson3a' to the compiler.]);;
+      *)
+         AC_MSG_ERROR([--enable-mips-mmi=${enable_mips_mmi}:]
+                      [invalid argument])
+   esac])
+
+# Add MIPS specific files to all builds where the host_cpu is mips ('mips*') or
+# where MIPS optimizations were explicitly requested. (This allows a fallback
+# if a future host CPU does not match 'mips*'.)
+
+AM_CONDITIONAL([PNG_MIPS_MMI],
+   [test "$enable_mips_mmi" != 'no' &&
+    case "$host_cpu" in
+      mipsel*|mips64el*) : ;;
+    esac])
+
+# INTEL SSE
+# =========
 
 AC_ARG_ENABLE([intel-sse],
    AS_HELP_STRING([[[--enable-intel-sse]]],
-      [Enable Intel SSE optimizations: =no/off, yes/on:]
+      [Enable Intel SSE optimizations: =no/off, yes/on.]
       [no/off: disable the optimizations;]
       [yes/on: enable the optimizations.]
       [If not specified: determined by the compiler.]),
@@ -457,12 +535,13 @@ AC_ARG_ENABLE([intel-sse],
          AC_DEFINE([PNG_INTEL_SSE_OPT], [1],
                    [Enable Intel SSE optimizations]);;
       *)
-         AC_MSG_ERROR([--enable-intel-sse=${enable_intel_sse}: invalid value])
+         AC_MSG_ERROR([--enable-intel-sse=${enable_intel_sse}:]
+                      [invalid argument])
    esac])
 
 # Add Intel-specific files to all builds where $host_cpu is Intel ('x86*') or
-# where Intel optimizations were explicitly requested (this allows a fallback
-# if a future host CPU does not match 'x86*')
+# where Intel optimizations were explicitly requested. (This allows a fallback
+# if a future host CPU does not match 'x86*'.)
 AM_CONDITIONAL([PNG_INTEL_SSE],
    [test "$enable_intel_sse" != 'no' &&
     case "$host_cpu" in
@@ -470,16 +549,15 @@ AM_CONDITIONAL([PNG_INTEL_SSE],
       *)    test "$enable_intel_sse" != '' ;;
     esac])
 
-# PowerPC
-# =======
-#
-# PowerPC VSX (SIMD) support.
+# POWERPC VSX
+# ===========
 
 AC_ARG_ENABLE([powerpc-vsx],
 AS_HELP_STRING([[[--enable-powerpc-vsx]]],
-      [Enable POWERPC VSX optimizations: =no/off, check, api, yes/on:]
-      [no/off: disable the optimizations; check: use internal checking code]
-      [api: disable by default, enable by a call to png_set_option]
+      [Enable POWERPC VSX optimizations: =no/off, check, api, yes/on.]
+      [no/off: disable the optimizations;]
+      [check: use internal checking code;]
+      [api: disable by default, enable by a call to png_set_option;]
       [yes/on: turn on unconditionally.]
       [If not specified: determined by the compiler.]),
    [case "$enableval" in
@@ -492,24 +570,25 @@ AS_HELP_STRING([[[--enable-powerpc-vsx]]],
       check)
          AC_DEFINE([PNG_POWERPC_VSX_CHECK_SUPPORTED], [],
                    [Check for POWERPC VSX support at run-time])
-         AC_MSG_WARN([--enable-powerpc-vsx Please check contrib/powerpc/README file]
-            [for the list of supported OSes.]);;
+         AC_MSG_WARN([--enable-powerpc-vsx: please see contrib/powerpc/README]
+                     [for the list of supported systems.]);;
       api)
          AC_DEFINE([PNG_POWERPC_VSX_API_SUPPORTED], [],
                    [Turn on POWERPC VSX optimizations at run-time]);;
       yes|on)
          AC_DEFINE([PNG_POWERPC_VSX_OPT], [2],
                    [Enable POWERPC VSX optimizations])
-         AC_MSG_WARN([--enable-powerpc-vsx: please specify 'check' or 'api', if]
-            [you want the optimizations unconditionally pass '-maltivec -mvsx']
-            [or '-mcpu=power8' to the compiler.]);;
+         AC_MSG_WARN([--enable-powerpc-vsx: please specify 'check' or 'api';]
+            [if you want the optimizations unconditionally,]
+            [pass '-maltivec -mvsx' or '-mcpu=power8' to the compiler.]);;
       *)
-         AC_MSG_ERROR([--enable-powerpc-vsx=${enable_powerpc_vsx}: invalid value])
+         AC_MSG_ERROR([--enable-powerpc-vsx=${enable_powerpc_vsx}:]
+                      [invalid argument])
    esac])
 
-# Add PowerPC-specific files to all builds where $host_cpu is powerpc('powerpc*')
-# or where PowerPC optimizations were explicitly requested (this allows a fallback
-# if a future host CPU does not match 'powerpc*')
+# Add PowerPC-specific files to all builds where $host_cpu is powerpc
+# ('powerpc*') or where PowerPC optimizations were explicitly requested.
+# (This allows a fallback if a future host CPU does not match 'powerpc*'.)
 
 AM_CONDITIONAL([PNG_POWERPC_VSX],
    [test "$enable_powerpc_vsx" != 'no' &&
@@ -517,6 +596,71 @@ AM_CONDITIONAL([PNG_POWERPC_VSX],
       powerpc*|ppc64*) : ;;
     esac])
 
+# LOONGARCH LSX
+# =============
+
+AC_ARG_ENABLE([loongarch-lsx],
+   AS_HELP_STRING([[[--enable-loongarch-lsx]]],
+      [Enable LOONGARCH LSX optimizations: =no/off, yes/on:]
+      [no/off: disable the optimizations;]
+      [yes/on: turn on unconditionally.]
+      [If not specified: determined by the compiler.]),
+   [case "$enableval" in
+      no|off)
+         # disable the default enabling on __loongarch_simd systems:
+         AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [0],
+                   [Disable LOONGARCH LSX optimizations])
+         # Prevent inclusion of the assembler files below:
+         enable_loongarch_lsx=no;;
+      yes|on)
+         AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [1],
+                   [Enable LOONGARCH LSX optimizations])
+         ;;
+      *)
+         AC_MSG_ERROR([--enable-loongarch-lsx=${enable_loongarch_lsx}:]
+                      [invalid argument])
+   esac])
+
+if test "$enable_loongarch_lsx" != "no" &&
+   case "$host_cpu" in
+      loongarch*) : ;;
+      *)    test "$enable_loongarch_lsx" != '' ;;
+   esac
+then
+   compiler_support_loongarch_lsx=no
+   AC_MSG_CHECKING(whether to use LoongArch LSX intrinsics)
+   save_CFLAGS="$CFLAGS"
+   LSX_CFLAGS="${LSX_CFLAGS:-"-mlsx"}"
+   CFLAGS="$CFLAGS $LSX_CFLAGS"
+   AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+#include <lsxintrin.h>
+int main(){
+   __m128i a, b, c;
+   a = __lsx_vadd_w(b, c);
+   return 0;
+}]])],compiler_support_loongarch_lsx=yes)
+   CFLAGS="$save_CFLAGS"
+   AC_MSG_RESULT($compiler_support_loongarch_lsx)
+   if test "$compiler_support_loongarch_lsx" = "yes"; then
+      AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [1],
+                [Enable LOONGARCH LSX optimizations])
+   else
+      AC_MSG_WARN([Compiler does not support loongarch LSX.])
+   fi
+fi
+
+# Add LoongArch specific files to all builds where the host_cpu is loongarch
+# ('loongarch*') or where LoongArch optimizations were explicitly requested.
+# (This allows a fallback if a future host CPU does not match 'loongarch*'.)
+
+AM_CONDITIONAL([PNG_LOONGARCH_LSX],
+   [test "$enable_loongarch_lsx" != "no" &&
+    test "$compiler_support_loongarch_lsx" = "yes" &&
+    case "$host_cpu" in
+      loongarch*) : ;;
+      *)    test "$enable_loongarch_lsx" != '' ;;
+    esac])
+
 AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]])
 
 # Config files, substituting as above

+ 2 - 0
png.mod/libpng/contrib/README.txt

@@ -1,3 +1,5 @@
+External contributions to libpng
+--------------------------------
 
 This "contrib" directory contains contributions which are not necessarily under
 the libpng license, although all are open source.  They are not part of

+ 133 - 0
png.mod/libpng/contrib/conftest/basic.dfa

@@ -0,0 +1,133 @@
+# basic.dfa
+#  Build time configuration of libpng
+#
+# Author: John Bowler
+# Copyright: (c) John Bowler, 2024
+# Usage rights:
+#  To the extent possible under law, the author has waived all copyright and
+#  related or neighboring rights to this work.  This work is published from:
+#  United States.
+#
+# Build libpng with basic read and write support.  This enables the lowest
+# level libpng read and write APIs - the "row-by-row" ones.
+#
+# Support is enabled only for those transformations that are observed to be
+# required by widely used apps or are in the v3 specification.
+#
+
+everything = off
+
+# The sequential read code is enabled here; the progressive code can be used
+# instead but there is no point enabling both.
+
+option READ on
+option SEQUENTIAL_READ on
+option EASY_ACCESS on
+option SET_USER_LIMITS on
+option INFO_IMAGE on
+option READ_16BIT on
+
+# Errors: these can be disabled but then there won't be any error messages
+# just failures and the error messages are really needed for apps:
+option WARNINGS on
+option ERROR_TEXT on
+option BENIGN_READ_ERRORS on
+
+# Required for many display programs such as web browsers:
+option PROGRESSIVE_READ on
+
+# Switch on the write code - this makes a minimalist encoder but with
+# interlace support turned on; otherwise png_read_png..png_write_png will
+# fail on an interlaced image.
+option WRITE on
+option WRITE_INTERLACING on
+option WRITE_16BIT on
+
+# Usages of the 'fixed' APIs are relatively rare but they do occur
+# one or the other for both the API and the internal math.
+
+#Fixed point:
+option FIXED_POINT on
+
+#Floating point:
+option FLOATING_POINT on
+option FLOATING_ARITHMETIC on
+
+# Basic error handling, IO and user memory support.  The latter allows the
+# application program to provide its own implementations of 'malloc' and 'free'.
+option SETJMP on
+option STDIO on
+option USER_MEM on
+
+# Gamma handling: this needs to be on for the gamma handling
+option READ_GAMMA on
+
+# The supported chunks
+chunk bKGD on
+chunk cHRM on
+chunk eXIf on
+chunk gAMA on
+chunk iCCP on
+chunk iTXt on
+chunk pHYs on
+chunk sBIT on
+chunk sRGB on
+chunk tEXt on
+chunk tIME on
+chunk tRNS on
+chunk zTXt on
+
+# These don't seem to be used anywhere:
+# chunk pCAL
+# chunk sCAL
+# chunk sPLT
+
+# The rest of this is app dependent: none of these options are required for
+# read/write of the full range of PNG files and the normal chunk handling on
+# read.
+option WRITE_CUSTOMIZE_ZTXT_COMPRESSION on
+option WRITE_CUSTOMIZE_COMPRESSION on
+
+option READ_EXPAND on
+option READ_FILLER on
+option READ_GRAY_TO_RGB on
+option READ_INVERT on
+option READ_PACK on
+option READ_RGB_TO_GRAY on
+option READ_SCALE_16_TO_8 on
+option READ_SHIFT on
+option READ_STRIP_16_TO_8 on
+option READ_STRIP_ALPHA on
+option READ_SWAP on
+
+option CONVERT_tIME on
+
+# optipng
+option IO_STATE on
+option STORE_UNKNOWN_CHUNKS on
+option HANDLE_AS_UNKNOWN on
+
+# pngcrush
+option READ_USER_TRANSFORM on
+option WRITE_FLUSH on
+
+# pnmtopng
+chunk hIST on
+
+# cairo
+option WRITE_PACKSWAP on
+option WRITE_USER_TRANSFORM on
+
+# graphicsmagick
+option READ_USER_CHUNKS on
+
+# Qt5.15 qtgui (gentoo package split) Qt6.6 qtbase
+option READ_BGR on
+option WRITE_BGR on
+option READ_SWAP_ALPHA on
+option WRITE_SWAP_ALPHA on
+chunk oFFs on
+
+# ghostscript-gpl
+option WRITE_INVERT_ALPHA on
+option WRITE_INVERT on

+ 15 - 0
png.mod/libpng/contrib/conftest/fixed.dfa

@@ -0,0 +1,15 @@
+# fixed.dfa
+#  Build time configuration of libpng
+#
+# Author: John Bowler
+# Copyright: (c) John Bowler, 2025
+# Usage rights:
+#  To the extent possible under law, the author has waived all copyright and
+#  related or neighboring rights to this work.  This work is published from:
+#  United States.
+#
+# Test the standard libpng configuration without floating point (the internal
+# fixed point implementations are used instead).
+#
+option FLOATING_ARITHMETIC off
+option FLOATING_POINT off

+ 14 - 0
png.mod/libpng/contrib/conftest/float-fixed.dfa

@@ -0,0 +1,14 @@
+# fixed-float.dfa
+#  Build time configuration of libpng
+#
+# Author: John Bowler
+# Copyright: (c) John Bowler, 2025
+# Usage rights:
+#  To the extent possible under law, the author has waived all copyright and
+#  related or neighboring rights to this work.  This work is published from:
+#  United States.
+#
+# Test the standard libpng configuration with the fixed point internal
+# implementation in place of the default floating point
+#
+option FLOATING_ARITHMETIC off

+ 21 - 0
png.mod/libpng/contrib/conftest/nocompile-limits.dfa

@@ -0,0 +1,21 @@
+# nolimits.dfa
+#  Build time configuration of libpng
+#
+# Author: John Bowler
+# Copyright: (c) John Bowler, 2025
+#
+# Usage rights:
+#  To the extent possible under law, the author has waived all copyright and
+#  related or neighboring rights to this work.  This work is published from:
+#  United States.
+#
+# Build libpng without any limits and without run-time settable limits.  Turning
+# USER_LIMITS off reduces libpng code size by allowing compile-time elimination
+# of some checking code.
+#
+option USER_LIMITS off
+
+@# define PNG_USER_WIDTH_MAX PNG_UINT_31_MAX
+@# define PNG_USER_HEIGHT_MAX PNG_UINT_31_MAX
+@# define PNG_USER_CHUNK_CACHE_MAX 0
+@# define PNG_USER_CHUNK_MALLOC_MAX 0

+ 19 - 0
png.mod/libpng/contrib/conftest/nolimits.dfa

@@ -0,0 +1,19 @@
+# nolimits.dfa
+#  Build time configuration of libpng
+#
+# Author: John Bowler
+# Copyright: (c) John Bowler, 2025
+#
+# Usage rights:
+#  To the extent possible under law, the author has waived all copyright and
+#  related or neighboring rights to this work.  This work is published from:
+#  United States.
+#
+# Build libpng without any limits.  With these settigs run-time limits are still
+# possible.
+#
+@# define PNG_USER_WIDTH_MAX PNG_UINT_31_MAX
+@# define PNG_USER_HEIGHT_MAX PNG_UINT_31_MAX
+@# define PNG_USER_CHUNK_CACHE_MAX 0
+@# define PNG_USER_CHUNK_MALLOC_MAX 0
+

+ 13 - 0
png.mod/libpng/contrib/conftest/read-full.dfa

@@ -0,0 +1,13 @@
+# read-full.dfa
+#  Build time configuration of libpng
+#
+# Author: John Bowler
+# Copyright: (c) John Bowler, 2025
+# Usage rights:
+#  To the extent possible under law, the author has waived all copyright and
+#  related or neighboring rights to this work.  This work is published from:
+#  United States.
+#
+# Build libpng with no write support and full read support.
+#
+option WRITE off

+ 13 - 0
png.mod/libpng/contrib/conftest/write-full.dfa

@@ -0,0 +1,13 @@
+# write-full.dfa
+#  Build time configuration of libpng
+#
+# Author: John Bowler
+# Copyright: (c) John Bowler, 2025
+# Usage rights:
+#  To the extent possible under law, the author has waived all copyright and
+#  related or neighboring rights to this work.  This work is published from:
+#  United States.
+#
+# Build libpng with no read support and full write support.
+#
+option READ off

+ 0 - 1
png.mod/libpng/contrib/examples/README.txt

@@ -1,4 +1,3 @@
-
 This directory (contrib/examples) contains examples of libpng usage.
 
 NO COPYRIGHT RIGHTS ARE CLAIMED TO ANY OF THE FILES IN THIS DIRECTORY.

+ 2 - 2
png.mod/libpng/contrib/examples/iccfrompng.c

@@ -80,7 +80,7 @@ extract(FILE *fp, png_uint_32 *proflen)
       }
 
       else
-	result = no_profile;
+         result = no_profile;
    }
 
    png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
@@ -155,7 +155,7 @@ extract_one_file(const char *filename)
       }
 
       else if (verbose && profile == no_profile)
-	printf("%s has no profile\n", filename);
+         printf("%s has no profile\n", filename);
    }
 
    else

+ 5 - 5
png.mod/libpng/contrib/examples/pngpixel.c

@@ -184,11 +184,11 @@ int main(int argc, const char **argv)
                      compression_method, filter_method;
                   png_bytep row_tmp;
 
-                  /* Now associate the recently opened (FILE*) with the default
-                   * libpng initialization functions.  Sometimes libpng is
-                   * compiled without stdio support (it can be difficult to do
-                   * in some environments); in that case you will have to write
-                   * your own read callback to read data from the (FILE*).
+                  /* Now associate the recently opened FILE object with the
+                   * default libpng initialization functions.  Sometimes libpng
+                   * is compiled without stdio support (it can be difficult to
+                   * do in some environments); in that case you will have to
+                   * write your own read callback to read data from the stream.
                    */
                   png_init_io(png_ptr, f);
 

+ 1 - 1
png.mod/libpng/contrib/gregbook/rpng-x.c

@@ -21,7 +21,7 @@
     - 1.10:  added support for non-default visuals; fixed X pixel-conversion
     - 1.11:  added extra set of parentheses to png_jmpbuf() macro; fixed
               command-line parsing bug
-    - 1.12:  fixed some small X memory leaks (thanks to François Petitjean)
+    - 1.12:  fixed some small X memory leaks (thanks to François Petitjean)
     - 1.13:  fixed XFreeGC() crash bug (thanks to Patrick Welche)
     - 1.14:  added support for X resources (thanks to Gerhard Niklasch)
     - 2.00:  dual-licensed (added GNU GPL)

+ 1 - 1
png.mod/libpng/contrib/gregbook/rpng2-x.c

@@ -27,7 +27,7 @@
     - 1.11:  added -usleep option for demos; fixed command-line parsing bug
     - 1.12:  added -pause option for demos and testing
     - 1.20:  added runtime MMX-enabling/disabling and new -mmx* options
-    - 1.21:  fixed some small X memory leaks (thanks to François Petitjean)
+    - 1.21:  fixed some small X memory leaks (thanks to François Petitjean)
     - 1.22:  fixed XFreeGC() crash bug (thanks to Patrick Welche)
     - 1.23:  added -bgpat 0 mode (std white/gray checkerboard, 8x8 squares)
     - 1.30:  added -loop option for -bgpat (ifdef FEATURE_LOOP); fixed bpp =

+ 20 - 7
png.mod/libpng/contrib/libtests/pngimage.c

@@ -1,4 +1,3 @@
-
 /* pngimage.c
  *
  * Copyright (c) 2021 Cosmin Truta
@@ -543,6 +542,7 @@ typedef enum
 struct display
 {
    jmp_buf        error_return;      /* Where to go to on error */
+   error_level    error_code;        /* Set before longjmp */
 
    const char    *filename;          /* The name of the original file */
    const char    *operation;         /* Operation being performed */
@@ -763,7 +763,10 @@ display_log(struct display *dp, error_level level, const char *fmt, ...)
 
    /* Errors cause this routine to exit to the fail code */
    if (level > APP_FAIL || (level > ERRORS && !(dp->options & CONTINUE)))
+   {
+      dp->error_code = level;
       longjmp(dp->error_return, level);
+    }
 }
 
 /* error handler callbacks for libpng */
@@ -1019,7 +1022,12 @@ compare_read(struct display *dp, int applied_transforms)
    C(height);
    C(bit_depth);
    C(color_type);
-   C(interlace_method);
+#  ifdef PNG_WRITE_INTERLACING_SUPPORTED
+      /* If write interlace has been disabled, the PNG file is still
+       * written correctly, but as a regular (not-interlaced) PNG.
+       */
+      C(interlace_method);
+#  endif
    C(compression_method);
    C(filter_method);
 
@@ -1566,18 +1574,19 @@ static int
 do_test(struct display *dp, const char *file)
    /* Exists solely to isolate the setjmp clobbers */
 {
-   int ret = setjmp(dp->error_return);
+   dp->error_code = VERBOSE; /* The "lowest" level */
 
-   if (ret == 0)
+   if (setjmp(dp->error_return) == 0)
    {
       test_one_file(dp, file);
       return 0;
    }
 
-   else if (ret < ERRORS) /* shouldn't longjmp on warnings */
-      display_log(dp, INTERNAL_ERROR, "unexpected return code %d", ret);
+   else if (dp->error_code < ERRORS) /* shouldn't longjmp on warnings */
+      display_log(dp, INTERNAL_ERROR, "unexpected return code %d",
+                  dp->error_code);
 
-   return ret;
+   return dp->error_code;
 }
 
 int
@@ -1677,7 +1686,11 @@ main(int argc, char **argv)
             int ret = do_test(&d, argv[i]);
 
             if (ret > QUIET) /* abort on user or internal error */
+            {
+               display_clean(&d);
+               display_destroy(&d);
                return 99;
+            }
          }
 
          /* Here on any return, including failures, except user/internal issues

+ 3 - 3
png.mod/libpng/contrib/libtests/pngstest.c

@@ -1,4 +1,3 @@
-
 /* pngstest.c
  *
  * Copyright (c) 2021 Cosmin Truta
@@ -596,7 +595,8 @@ newimage(Image *image)
    memset(image, 0, sizeof *image);
 }
 
-/* Reset the image to be read again - only needs to rewind the FILE* at present.
+/* Reset the image to be read again - only needs to rewind the FILE object at
+ * present.
  */
 static void
 resetimage(Image *image)
@@ -3500,7 +3500,7 @@ main(int argc, char **argv)
    int retval = 0;
    int c;
 
-#if PNG_LIBPNG_VER >= 10700
+#if PNG_LIBPNG_VER == 10700
       /* This error should not exist in 1.7 or later: */
       opts |= GBG_ERROR;
 #endif

+ 24 - 1
png.mod/libpng/contrib/libtests/pngunknown.c

@@ -1,4 +1,3 @@
-
 /* pngunknown.c - test the read side unknown chunk handling
  *
  * Copyright (c) 2021 Cosmin Truta
@@ -114,6 +113,8 @@ typedef png_byte *png_const_bytep;
 #define png_PLTE PNG_U32( 80,  76,  84,  69)
 #define png_bKGD PNG_U32( 98,  75,  71,  68)
 #define png_cHRM PNG_U32( 99,  72,  82,  77)
+#define png_cICP PNG_U32( 99,  73,  67,  80) /* PNGv3 */
+#define png_cLLI PNG_U32( 99,  76,  76,  73) /* PNGv3 */
 #define png_eXIf PNG_U32(101,  88,  73, 102) /* registered July 2017 */
 #define png_fRAc PNG_U32(102,  82,  65,  99) /* registered, not defined */
 #define png_gAMA PNG_U32(103,  65,  77,  65)
@@ -123,6 +124,7 @@ typedef png_byte *png_const_bytep;
 #define png_hIST PNG_U32(104,  73,  83,  84)
 #define png_iCCP PNG_U32(105,  67,  67,  80)
 #define png_iTXt PNG_U32(105,  84,  88, 116)
+#define png_mDCV PNG_U32(109,  68,  67,  86) /* PNGv3 */
 #define png_oFFs PNG_U32(111,  70,  70, 115)
 #define png_pCAL PNG_U32(112,  67,  65,  76)
 #define png_pHYs PNG_U32(112,  72,  89, 115)
@@ -209,6 +211,20 @@ static struct
          0,
 #     else
          1,
+#     endif
+      1,  START, 0 },
+   { "cICP", PNG_INFO_cICP, png_cICP,
+#     ifdef PNG_READ_cICP_SUPPORTED
+         0,
+#     else
+         1,
+#     endif
+      1,  START, 0 },
+   { "cLLI", PNG_INFO_cLLI, png_cLLI,
+#     ifdef PNG_READ_cLLI_SUPPORTED
+         0,
+#     else
+         1,
 #     endif
       1,  START, 0 },
    { "eXIf", PNG_INFO_eXIf, png_eXIf,
@@ -246,6 +262,13 @@ static struct
          1,
 #     endif
       1, ABSENT, 0 },
+   { "mDCV", PNG_INFO_mDCV, png_mDCV,
+#     ifdef PNG_READ_mDCV_SUPPORTED
+         0,
+#     else
+         1,
+#     endif
+      1,  START, 0 },
    { "oFFs", PNG_INFO_oFFs, png_oFFs,
 #     ifdef PNG_READ_oFFs_SUPPORTED
          0,

+ 55 - 38
png.mod/libpng/contrib/libtests/pngvalid.c

@@ -1,4 +1,3 @@
-
 /* pngvalid.c - validate libpng by constructing then reading png files.
  *
  * Copyright (c) 2021 Cosmin Truta
@@ -70,9 +69,12 @@
 #endif
 
 /* pngvalid requires write support and one of the fixed or floating point APIs.
+ * progressive read is also required currently as the progressive read pointer
+ * is used to record the 'display' structure.
  */
-#if defined(PNG_WRITE_SUPPORTED) &&\
-   (defined(PNG_FIXED_POINT_SUPPORTED) || defined(PNG_FLOATING_POINT_SUPPORTED))
+#if defined PNG_WRITE_SUPPORTED &&\
+   (defined PNG_PROGRESSIVE_READ_SUPPORTED) &&\
+   (defined PNG_FIXED_POINT_SUPPORTED || defined PNG_FLOATING_POINT_SUPPORTED)
 
 #if PNG_LIBPNG_VER < 10500
 /* This deliberately lacks the const. */
@@ -301,20 +303,20 @@ make_four_random_bytes(png_uint_32* seed, png_bytep bytes)
 #if defined PNG_READ_SUPPORTED || defined PNG_WRITE_tRNS_SUPPORTED ||\
     defined PNG_WRITE_FILTER_SUPPORTED
 static void
-randomize(void *pv, size_t size)
+randomize_bytes(void *pv, size_t size)
 {
    static png_uint_32 random_seed[2] = {0x56789abc, 0xd};
    make_random_bytes(random_seed, pv, size);
 }
 
-#define R8(this) randomize(&(this), sizeof (this))
+#define R8(this) randomize_bytes(&(this), sizeof (this))
 
 #ifdef PNG_READ_SUPPORTED
 static png_byte
 random_byte(void)
 {
    unsigned char b1[1];
-   randomize(b1, sizeof b1);
+   randomize_bytes(b1, sizeof b1);
    return b1[0];
 }
 #endif /* READ */
@@ -323,7 +325,7 @@ static png_uint_16
 random_u16(void)
 {
    unsigned char b2[2];
-   randomize(b2, sizeof b2);
+   randomize_bytes(b2, sizeof b2);
    return png_get_uint_16(b2);
 }
 
@@ -333,7 +335,7 @@ static png_uint_32
 random_u32(void)
 {
    unsigned char b4[4];
-   randomize(b4, sizeof b4);
+   randomize_bytes(b4, sizeof b4);
    return png_get_uint_32(b4);
 }
 #endif /* READ_FILLER || READ_RGB_TO_GRAY */
@@ -2571,7 +2573,7 @@ modifier_init(png_modifier *pm)
  * in the rgb_to_gray check, replacing it with an exact copy of the libpng 1.5
  * algorithm.
  */
-#define DIGITIZE PNG_LIBPNG_VER < 10700
+#define DIGITIZE PNG_LIBPNG_VER != 10700
 
 /* If pm->calculations_use_input_precision is set then operations will happen
  * with the precision of the input, not the precision of the output depth.
@@ -3983,7 +3985,7 @@ transform_row(png_const_structp pp, png_byte buffer[TRANSFORM_ROWMAX],
 #  define check_interlace_type(type) ((void)(type))
 #  define set_write_interlace_handling(pp,type) png_set_interlace_handling(pp)
 #  define do_own_interlace 0
-#elif PNG_LIBPNG_VER < 10700
+#elif PNG_LIBPNG_VER != 10700
 #  define set_write_interlace_handling(pp,type) (1)
 static void
 check_interlace_type(int const interlace_type)
@@ -4011,7 +4013,7 @@ check_interlace_type(int const interlace_type)
 #  define do_own_interlace 1
 #endif /* WRITE_INTERLACING tests */
 
-#if PNG_LIBPNG_VER >= 10700 || defined PNG_WRITE_INTERLACING_SUPPORTED
+#if PNG_LIBPNG_VER == 10700 || defined PNG_WRITE_INTERLACING_SUPPORTED
 #   define CAN_WRITE_INTERLACE 1
 #else
 #   define CAN_WRITE_INTERLACE 0
@@ -4630,10 +4632,10 @@ static const struct
     {
        /* no warnings makes these errors undetectable prior to 1.7.0 */
        { sBIT0_error_fn, "sBIT(0): failed to detect error",
-         PNG_LIBPNG_VER < 10700 },
+         PNG_LIBPNG_VER != 10700 },
 
        { sBIT_error_fn, "sBIT(too big): failed to detect error",
-         PNG_LIBPNG_VER < 10700 },
+         PNG_LIBPNG_VER != 10700 },
     };
 
 static void
@@ -6233,7 +6235,7 @@ image_pixel_add_alpha(image_pixel *this, const standard_display *display,
    {
       if (this->colour_type == PNG_COLOR_TYPE_GRAY)
       {
-#        if PNG_LIBPNG_VER < 10700
+#        if PNG_LIBPNG_VER != 10700
             if (!for_background && this->bit_depth < 8)
                this->bit_depth = this->sample_depth = 8;
 #        endif
@@ -6243,7 +6245,7 @@ image_pixel_add_alpha(image_pixel *this, const standard_display *display,
             /* After 1.7 the expansion of bit depth only happens if there is a
              * tRNS chunk to expand at this point.
              */
-#           if PNG_LIBPNG_VER >= 10700
+#           if PNG_LIBPNG_VER == 10700
                if (!for_background && this->bit_depth < 8)
                   this->bit_depth = this->sample_depth = 8;
 #           endif
@@ -7124,7 +7126,7 @@ image_transform_png_set_tRNS_to_alpha_mod(const image_transform *this,
    image_pixel *that, png_const_structp pp,
    const transform_display *display)
 {
-#if PNG_LIBPNG_VER < 10700
+#if PNG_LIBPNG_VER != 10700
    /* LIBPNG BUG: this always forces palette images to RGB. */
    if (that->colour_type == PNG_COLOR_TYPE_PALETTE)
       image_pixel_convert_PLTE(that);
@@ -7134,13 +7136,13 @@ image_transform_png_set_tRNS_to_alpha_mod(const image_transform *this,
     * convert to an alpha channel.
     */
    if (that->have_tRNS)
-#     if PNG_LIBPNG_VER >= 10700
+#     if PNG_LIBPNG_VER == 10700
          if (that->colour_type != PNG_COLOR_TYPE_PALETTE &&
              (that->colour_type & PNG_COLOR_MASK_ALPHA) == 0)
 #     endif
       image_pixel_add_alpha(that, &display->this, 0/*!for background*/);
 
-#if PNG_LIBPNG_VER < 10700
+#if PNG_LIBPNG_VER != 10700
    /* LIBPNG BUG: otherwise libpng still expands to 8 bits! */
    else
    {
@@ -7169,7 +7171,7 @@ image_transform_png_set_tRNS_to_alpha_add(image_transform *this,
     * any action on a palette image.
     */
    return
-#  if PNG_LIBPNG_VER >= 10700
+#  if PNG_LIBPNG_VER == 10700
       colour_type != PNG_COLOR_TYPE_PALETTE &&
 #  endif
    (colour_type & PNG_COLOR_MASK_ALPHA) == 0;
@@ -7310,7 +7312,7 @@ image_transform_png_set_expand_gray_1_2_4_to_8_mod(
     const image_transform *this, image_pixel *that, png_const_structp pp,
     const transform_display *display)
 {
-#if PNG_LIBPNG_VER < 10700
+#if PNG_LIBPNG_VER != 10700
    image_transform_png_set_expand_mod(this, that, pp, display);
 #else
    /* Only expand grayscale of bit depth less than 8: */
@@ -7326,7 +7328,7 @@ static int
 image_transform_png_set_expand_gray_1_2_4_to_8_add(image_transform *this,
     const image_transform **that, png_byte colour_type, png_byte bit_depth)
 {
-#if PNG_LIBPNG_VER < 10700
+#if PNG_LIBPNG_VER != 10700
    return image_transform_png_set_expand_add(this, that, colour_type,
       bit_depth);
 #else
@@ -7356,7 +7358,7 @@ image_transform_png_set_expand_16_set(const image_transform *this,
    png_set_expand_16(pp);
 
    /* NOTE: prior to 1.7 libpng does SET_EXPAND as well, so tRNS is expanded. */
-#  if PNG_LIBPNG_VER < 10700
+#  if PNG_LIBPNG_VER != 10700
       if (that->this.has_tRNS)
          that->this.is_transparent = 1;
 #  endif
@@ -7409,7 +7411,7 @@ image_transform_png_set_scale_16_set(const image_transform *this,
     transform_display *that, png_structp pp, png_infop pi)
 {
    png_set_scale_16(pp);
-#  if PNG_LIBPNG_VER < 10700
+#  if PNG_LIBPNG_VER != 10700
       /* libpng will limit the gamma table size: */
       that->max_gamma_8 = PNG_MAX_GAMMA_8;
 #  endif
@@ -7457,7 +7459,7 @@ image_transform_png_set_strip_16_set(const image_transform *this,
     transform_display *that, png_structp pp, png_infop pi)
 {
    png_set_strip_16(pp);
-#  if PNG_LIBPNG_VER < 10700
+#  if PNG_LIBPNG_VER != 10700
       /* libpng will limit the gamma table size: */
       that->max_gamma_8 = PNG_MAX_GAMMA_8;
 #  endif
@@ -7644,7 +7646,7 @@ image_transform_png_set_rgb_to_gray_ini(const image_transform *this,
    else
    {
       /* The default (built in) coefficients, as above: */
-#     if PNG_LIBPNG_VER < 10700
+#     if PNG_LIBPNG_VER != 10700
          data.red_coefficient = 6968 / 32768.;
          data.green_coefficient = 23434 / 32768.;
          data.blue_coefficient = 2366 / 32768.;
@@ -7727,7 +7729,7 @@ image_transform_png_set_rgb_to_gray_ini(const image_transform *this,
           *  conversion adds another +/-2 in the 16-bit case and
           *  +/-(1<<(15-PNG_MAX_GAMMA_8)) in the 8-bit case.
           */
-#        if PNG_LIBPNG_VER < 10700
+#        if PNG_LIBPNG_VER != 10700
             if (that->this.bit_depth < 16)
                that->max_gamma_8 = PNG_MAX_GAMMA_8;
 #        endif
@@ -7904,7 +7906,7 @@ image_transform_png_set_rgb_to_gray_mod(const image_transform *this,
    {
       double gray, err;
 
-#     if PNG_LIBPNG_VER < 10700
+#     if PNG_LIBPNG_VER != 10700
          if (that->colour_type == PNG_COLOR_TYPE_PALETTE)
             image_pixel_convert_PLTE(that);
 #     endif
@@ -8091,7 +8093,7 @@ image_transform_png_set_rgb_to_gray_mod(const image_transform *this,
          double b = that->bluef;
          double be = that->bluee;
 
-#        if PNG_LIBPNG_VER < 10700
+#        if PNG_LIBPNG_VER != 10700
             /* The true gray case involves no math in earlier versions (not
              * true, there was some if gamma correction was happening too.)
              */
@@ -9870,7 +9872,7 @@ gamma_component_validate(const char *name, const validate_info *vi,
              * lost.  This can result in up to a +/-1 error in the presence of
              * an sbit less than the bit depth.
              */
-#           if PNG_LIBPNG_VER < 10700
+#           if PNG_LIBPNG_VER != 10700
 #              define SBIT_ERROR .5
 #           else
 #              define SBIT_ERROR 1.
@@ -10009,9 +10011,12 @@ gamma_component_validate(const char *name, const validate_info *vi,
                case ALPHA_MODE_OFFSET + PNG_ALPHA_BROKEN:
                case ALPHA_MODE_OFFSET + PNG_ALPHA_OPTIMIZED:
 #           endif /* ALPHA_MODE_SUPPORTED */
+#           if (defined PNG_READ_BACKGROUND_SUPPORTED) ||\
+               (defined PNG_READ_ALPHA_MODE_SUPPORTED)
                do_compose = (alpha > 0 && alpha < 1);
                use_input = (alpha != 0);
                break;
+#           endif
 
             default:
                break;
@@ -10727,7 +10732,7 @@ static void perform_gamma_scale16_tests(png_modifier *pm)
 #  ifndef PNG_MAX_GAMMA_8
 #     define PNG_MAX_GAMMA_8 11
 #  endif
-#  if defined PNG_MAX_GAMMA_8 || PNG_LIBPNG_VER < 10700
+#  if defined PNG_MAX_GAMMA_8 || PNG_LIBPNG_VER != 10700
 #     define SBIT_16_TO_8 PNG_MAX_GAMMA_8
 #  else
 #     define SBIT_16_TO_8 16
@@ -11730,7 +11735,7 @@ int main(int argc, char **argv)
     * code that 16-bit arithmetic is used for 8-bit samples when it would make a
     * difference.
     */
-   pm.assume_16_bit_calculations = PNG_LIBPNG_VER >= 10700;
+   pm.assume_16_bit_calculations = PNG_LIBPNG_VER == 10700;
 
    /* Currently 16 bit expansion happens at the end of the pipeline, so the
     * calculations are done in the input bit depth not the output.
@@ -11754,13 +11759,13 @@ int main(int argc, char **argv)
    pm.test_lbg_gamma_threshold = 1;
    pm.test_lbg_gamma_transform = PNG_LIBPNG_VER >= 10600;
    pm.test_lbg_gamma_sbit = 1;
-   pm.test_lbg_gamma_composition = PNG_LIBPNG_VER >= 10700;
+   pm.test_lbg_gamma_composition = PNG_LIBPNG_VER == 10700;
 
    /* And the test encodings */
    pm.encodings = test_encodings;
    pm.nencodings = ARRAY_SIZE(test_encodings);
 
-#  if PNG_LIBPNG_VER < 10700
+#  if PNG_LIBPNG_VER != 10700
       pm.sbitlow = 8U; /* because libpng doesn't do sBIT below 8! */
 #  else
       pm.sbitlow = 1U;
@@ -11790,7 +11795,7 @@ int main(int argc, char **argv)
    pm.maxout16 = .499;  /* Error in *encoded* value */
    pm.maxabs16 = .00005;/* 1/20000 */
    pm.maxcalc16 =1./65535;/* +/-1 in 16 bits for compose errors */
-#  if PNG_LIBPNG_VER < 10700
+#  if PNG_LIBPNG_VER != 10700
       pm.maxcalcG = 1./((1<<PNG_MAX_GAMMA_8)-1);
 #  else
       pm.maxcalcG = 1./((1<<16)-1);
@@ -11924,7 +11929,14 @@ int main(int argc, char **argv)
          pm.test_gamma_alpha_mode = 0;
 
       else if (strcmp(*argv, "--expand16") == 0)
-         pm.test_gamma_expand16 = 1;
+      {
+#        ifdef PNG_READ_EXPAND_16_SUPPORTED
+            pm.test_gamma_expand16 = 1;
+#        else
+            fprintf(stderr, "pngvalid: --expand16: no read support\n");
+            return SKIP;
+#        endif
+      }
 
       else if (strcmp(*argv, "--noexpand16") == 0)
          pm.test_gamma_expand16 = 0;
@@ -11939,10 +11951,15 @@ int main(int argc, char **argv)
             pm.test_lbg_gamma_transform = pm.test_lbg_gamma_sbit =
             pm.test_lbg_gamma_composition = 0;
 
-#     ifdef PNG_WRITE_tRNS_SUPPORTED
-         else if (strcmp(*argv, "--tRNS") == 0)
+      else if (strcmp(*argv, "--tRNS") == 0)
+      {
+#        ifdef PNG_WRITE_tRNS_SUPPORTED
             pm.test_tRNS = 1;
-#     endif
+#        else
+            fprintf(stderr, "pngvalid: --tRNS: no write support\n");
+            return SKIP;
+#        endif
+      }
 
       else if (strcmp(*argv, "--notRNS") == 0)
          pm.test_tRNS = 0;

+ 0 - 1
png.mod/libpng/contrib/libtests/readpng.c

@@ -1,4 +1,3 @@
-
 /* readpng.c
  *
  * Copyright (c) 2013 John Cunningham Bowler

+ 0 - 1
png.mod/libpng/contrib/libtests/tarith.c

@@ -1,4 +1,3 @@
-
 /* tarith.c
  *
  * Copyright (c) 2021 Cosmin Truta

+ 0 - 1
png.mod/libpng/contrib/libtests/timepng.c

@@ -1,4 +1,3 @@
-
 /* timepng.c
  *
  * Copyright (c) 2013,2016 John Cunningham Bowler

+ 141 - 0
png.mod/libpng/contrib/mips-mmi/linux.c

@@ -0,0 +1,141 @@
+/* contrib/mips-mmi/linux.c
+ *
+ * Copyright (c) 2024 Cosmin Truta
+ * Written by guxiwei, 2023
+ *
+ * This code is released under the libpng license.
+ * For conditions of distribution and use, see the disclaimer
+ * and license in png.h
+ */
+
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/auxv.h>
+
+/*
+ * parse_r var, r - Helper assembler macro for parsing register names.
+ *
+ * This converts the register name in $n form provided in \r to the
+ * corresponding register number, which is assigned to the variable \var. It is
+ * needed to allow explicit encoding of instructions in inline assembly where
+ * registers are chosen by the compiler in $n form, allowing us to avoid using
+ * fixed register numbers.
+ *
+ * It also allows newer instructions (not implemented by the assembler) to be
+ * transparently implemented using assembler macros, instead of needing separate
+ * cases depending on toolchain support.
+ *
+ * Simple usage example:
+ * __asm__ __volatile__("parse_r __rt, %0\n\t"
+ *                      ".insn\n\t"
+ *                      "# di    %0\n\t"
+ *                      ".word   (0x41606000 | (__rt << 16))"
+ *                      : "=r" (status);
+ */
+
+/* Match an individual register number and assign to \var */
+#define _IFC_REG(n)                                \
+        ".ifc        \\r, $" #n "\n\t"             \
+        "\\var        = " #n "\n\t"                \
+        ".endif\n\t"
+
+__asm__(".macro        parse_r var r\n\t"
+        "\\var        = -1\n\t"
+        _IFC_REG(0)  _IFC_REG(1)  _IFC_REG(2)  _IFC_REG(3)
+        _IFC_REG(4)  _IFC_REG(5)  _IFC_REG(6)  _IFC_REG(7)
+        _IFC_REG(8)  _IFC_REG(9)  _IFC_REG(10) _IFC_REG(11)
+        _IFC_REG(12) _IFC_REG(13) _IFC_REG(14) _IFC_REG(15)
+        _IFC_REG(16) _IFC_REG(17) _IFC_REG(18) _IFC_REG(19)
+        _IFC_REG(20) _IFC_REG(21) _IFC_REG(22) _IFC_REG(23)
+        _IFC_REG(24) _IFC_REG(25) _IFC_REG(26) _IFC_REG(27)
+        _IFC_REG(28) _IFC_REG(29) _IFC_REG(30) _IFC_REG(31)
+        ".iflt        \\var\n\t"
+        ".error        \"Unable to parse register name \\r\"\n\t"
+        ".endif\n\t"
+        ".endm");
+
+#define HWCAP_LOONGSON_CPUCFG (1 << 14)
+
+static int cpucfg_available(void)
+{
+    return getauxval(AT_HWCAP) & HWCAP_LOONGSON_CPUCFG;
+}
+
+static int strstart(const char *str, const char *pfx, const char **ptr)
+{
+    while (*pfx && *pfx == *str) {
+        pfx++;
+        str++;
+    }
+    if (!*pfx && ptr)
+        *ptr = str;
+    return !*pfx;
+}
+
+/* Most toolchains have no CPUCFG support yet */
+static uint32_t read_cpucfg(uint32_t reg)
+{
+        uint32_t __res;
+
+        __asm__ __volatile__(
+                "parse_r __res,%0\n\t"
+                "parse_r reg,%1\n\t"
+                ".insn \n\t"
+                ".word (0xc8080118 | (reg << 21) | (__res << 11))\n\t"
+                :"=r"(__res)
+                :"r"(reg)
+                :
+                );
+        return __res;
+}
+
+#define LOONGSON_CFG1 0x1
+
+#define LOONGSON_CFG1_MMI    (1 << 4)
+
+static int cpu_flags_cpucfg(void)
+{
+    int flags = 0;
+    uint32_t cfg1 = read_cpucfg(LOONGSON_CFG1);
+
+    if (cfg1 & LOONGSON_CFG1_MMI)
+        flags = 1;
+
+    return flags;
+}
+
+static int cpu_flags_cpuinfo(void)
+{
+    FILE *f = fopen("/proc/cpuinfo", "r");
+    char buf[200];
+    int flags = 0;
+
+    if (!f)
+        return flags;
+
+    while (fgets(buf, sizeof(buf), f)) {
+        /* Legacy kernel may not export MMI in ASEs implemented */
+        if (strstart(buf, "cpu model", NULL)) {
+            if (strstr(buf, "Loongson-3 "))
+                flags = 1;
+            break;
+        }
+        if (strstart(buf, "ASEs implemented", NULL)) {
+            if (strstr(buf, " loongson-mmi"))
+                flags = 1;
+            break;
+        }
+    }
+    fclose(f);
+    return flags;
+}
+
+static int png_have_mmi()
+{
+    if (cpucfg_available())
+        return cpu_flags_cpucfg();
+    else
+        return cpu_flags_cpuinfo();
+    return 0;
+}

+ 23 - 36
png.mod/libpng/contrib/mips-msa/linux.c

@@ -1,67 +1,54 @@
-
 /* contrib/mips-msa/linux.c
  *
- * Copyright (c) 2020 Cosmin Truta
+ * Copyright (c) 2020-2023 Cosmin Truta
  * Copyright (c) 2016 Glenn Randers-Pehrson
  * Written by Mandar Sahastrabuddhe, 2016.
+ * Updated by Sui Jingfeng, 2021.
  *
  * This code is released under the libpng license.
  * For conditions of distribution and use, see the disclaimer
  * and license in png.h
  *
- * SEE contrib/mips-msa/README before reporting bugs
+ * On Linux, png_have_msa is implemented by reading the pseudo-file
+ * "/proc/self/auxv".
+ *
+ * See contrib/mips-msa/README before reporting bugs.
  *
  * STATUS: SUPPORTED
  * BUG REPORTS: [email protected]
- *
- * png_have_msa implemented for Linux by reading the widely available
- * pseudo-file /proc/cpuinfo.
- *
- * This code is strict ANSI-C and is probably moderately portable; it does
- * however use <stdio.h> and it assumes that /proc/cpuinfo is never localized.
  */
 
-#include <stdio.h>
-#include <string.h>
+#include <elf.h>
+#include <fcntl.h>
 #include <stdlib.h>
+#include <unistd.h>
 
 static int
 png_have_msa(png_structp png_ptr)
 {
-   FILE *f = fopen("/proc/cpuinfo", "rb");
-
-   char *string = "msa";
-   char word[10];
+   Elf64_auxv_t aux;
+   int fd;
+   int has_msa = 0;
 
-   if (f != NULL)
+   fd = open("/proc/self/auxv", O_RDONLY);
+   if (fd >= 0)
    {
-      while(!feof(f))
+      while (read(fd, &aux, sizeof(Elf64_auxv_t)) == sizeof(Elf64_auxv_t))
       {
-         int ch = fgetc(f);
-         static int i = 0;
-
-         while(!(ch <= 32))
+         if (aux.a_type == AT_HWCAP)
          {
-            word[i++] = ch;
-            ch = fgetc(f);
-         }
-
-         int val = strcmp(string, word);
+            uint64_t hwcap = aux.a_un.a_val;
 
-         if (val == 0) {
-            fclose(f);
-            return 1;
+            has_msa = (hwcap >> 1) & 1;
+            break;
          }
-
-         i = 0;
-         memset(word, 0, 10);
       }
-
-      fclose(f);
+      close(fd);
    }
 #ifdef PNG_WARNINGS_SUPPORTED
    else
-      png_warning(png_ptr, "/proc/cpuinfo open failed");
+      png_warning(png_ptr, "/proc/self/auxv open failed");
 #endif
-   return 0;
+
+   return has_msa;
 }

+ 16 - 1
png.mod/libpng/contrib/oss-fuzz/libpng_read_fuzzer.cc

@@ -1,4 +1,3 @@
-
 // libpng_read_fuzzer.cc
 // Copyright 2017-2018 Glenn Randers-Pehrson
 // Copyright 2015 The Chromium Authors. All rights reserved.
@@ -204,5 +203,21 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
   png_read_end(png_handler.png_ptr, png_handler.end_info_ptr);
 
   PNG_CLEANUP
+
+#ifdef PNG_SIMPLIFIED_READ_SUPPORTED
+  // Simplified READ API
+  png_image image;
+  memset(&image, 0, (sizeof image));
+  image.version = PNG_IMAGE_VERSION;
+
+  if (!png_image_begin_read_from_memory(&image, data, size)) {
+    return 0;
+  }
+
+  image.format = PNG_FORMAT_RGBA;
+  std::vector<png_byte> buffer(PNG_IMAGE_SIZE(image));
+  png_image_finish_read(&image, NULL, buffer.data(), 0, NULL);
+#endif
+
   return 0;
 }

+ 19 - 0
png.mod/libpng/contrib/pngexif/LICENSE_MIT.txt

@@ -0,0 +1,19 @@
+MIT License
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.

+ 20 - 0
png.mod/libpng/contrib/pngexif/README.md

@@ -0,0 +1,20 @@
+pngexifinfo
+===========
+
+Show the EXIF information embedded in a PNG file.
+
+
+Sample usage
+------------
+
+Show the EXIF info inside a PNG file:
+
+    pngexifinfo /path/to/file.png
+
+Show the EXIF info inside a raw `.exif` file, using base 16 for the EXIF tags:
+
+    pngexifinfo --hex /path/to/file.exif
+
+Show the help text:
+
+    pngexifinfo --help

+ 48 - 0
png.mod/libpng/contrib/pngexif/bytepack.py

@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+
+"""
+Byte packing and unpacking utilities.
+
+Copyright (C) 2017-2020 Cosmin Truta.
+
+Use, modification and distribution are subject to the MIT License.
+Please see the accompanying file LICENSE_MIT.txt
+"""
+
+from __future__ import absolute_import, division, print_function
+
+import struct
+
+
+def unpack_uint32be(buffer, offset=0):
+    """Unpack an unsigned int from its 32-bit big-endian representation."""
+    return struct.unpack(">I", buffer[offset:offset + 4])[0]
+
+
+def unpack_uint32le(buffer, offset=0):
+    """Unpack an unsigned int from its 32-bit little-endian representation."""
+    return struct.unpack("<I", buffer[offset:offset + 4])[0]
+
+
+def unpack_uint16be(buffer, offset=0):
+    """Unpack an unsigned int from its 16-bit big-endian representation."""
+    return struct.unpack(">H", buffer[offset:offset + 2])[0]
+
+
+def unpack_uint16le(buffer, offset=0):
+    """Unpack an unsigned int from its 16-bit little-endian representation."""
+    return struct.unpack("<H", buffer[offset:offset + 2])[0]
+
+
+def unpack_uint8(buffer, offset=0):
+    """Unpack an unsigned int from its 8-bit representation."""
+    return struct.unpack("B", buffer[offset:offset + 1])[0]
+
+
+if __name__ == "__main__":
+    # For testing only.
+    assert unpack_uint32be(b"ABCDEF", 1) == 0x42434445
+    assert unpack_uint32le(b"ABCDEF", 1) == 0x45444342
+    assert unpack_uint16be(b"ABCDEF", 1) == 0x4243
+    assert unpack_uint16le(b"ABCDEF", 1) == 0x4342
+    assert unpack_uint8(b"ABCDEF", 1) == 0x42

+ 306 - 0
png.mod/libpng/contrib/pngexif/exifinfo.py

@@ -0,0 +1,306 @@
+#!/usr/bin/env python
+
+"""
+Show the EXIF information.
+
+Copyright (C) 2017-2020 Cosmin Truta.
+
+Use, modification and distribution are subject to the MIT License.
+Please see the accompanying file LICENSE_MIT.txt
+"""
+
+from __future__ import absolute_import, division, print_function
+
+import sys
+
+from bytepack import (unpack_uint32be,
+                      unpack_uint32le,
+                      unpack_uint16be,
+                      unpack_uint16le,
+                      unpack_uint8)
+
+
+# Generously allow the TIFF file to occupy up to a quarter-gigabyte.
+# TODO: Reduce this limit to 64K and use file seeking for anything larger.
+_READ_DATA_SIZE_MAX = 256 * 1024 * 1024
+
+_TIFF_TAG_TYPES = {
+    1: "byte",
+    2: "ascii",
+    3: "short",
+    4: "long",
+    5: "rational",
+    6: "sbyte",
+    7: "undefined",
+    8: "sshort",
+    9: "slong",
+    10: "srational",
+    11: "float",
+    12: "double",
+}
+
+# See http://www.digitalpreservation.gov/formats/content/tiff_tags.shtml
+_TIFF_TAGS = {
+    0x00fe: "Subfile Type",
+    0x0100: "Width",
+    0x0101: "Height",
+    0x0102: "Bits per Sample",
+    0x0103: "Compression",
+    0x0106: "Photometric",
+    0x010d: "Document Name",
+    0x010e: "Image Description",
+    0x010f: "Make",
+    0x0110: "Model",
+    0x0111: "Strip Offsets",
+    0x0112: "Orientation",
+    0x0115: "Samples per Pixel",
+    0x0116: "Rows per Strip",
+    0x0117: "Strip Byte Counts",
+    0x0118: "Min Sample Value",
+    0x0119: "Max Sample Value",
+    0x011a: "X Resolution",
+    0x011b: "Y Resolution",
+    0x011c: "Planar Configuration",
+    0x011d: "Page Name",
+    0x011e: "X Position",
+    0x011f: "Y Position",
+    0x0128: "Resolution Unit",
+    0x0129: "Page Number",
+    0x0131: "Software",
+    0x0132: "Date Time",
+    0x013b: "Artist",
+    0x013c: "Host Computer",
+    0x013d: "Predictor",
+    0x013e: "White Point",
+    0x013f: "Primary Chromaticities",
+    0x0140: "Color Map",
+    0x0141: "Half-Tone Hints",
+    0x0142: "Tile Width",
+    0x0143: "Tile Length",
+    0x0144: "Tile Offsets",
+    0x0145: "Tile Byte Counts",
+    0x0211: "YCbCr Coefficients",
+    0x0212: "YCbCr Subsampling",
+    0x0213: "YCbCr Positioning",
+    0x0214: "Reference Black White",
+    0x022f: "Strip Row Counts",
+    0x02bc: "XMP",
+    0x8298: "Copyright",
+    0x83bb: "IPTC",
+    0x8769: "EXIF IFD",
+    0x8773: "ICC Profile",
+    0x8825: "GPS IFD",
+    0xa005: "Interoperability IFD",
+    0xc4a5: "Print IM",
+
+    # EXIF IFD tags
+    0x829a: "Exposure Time",
+    0x829d: "F-Number",
+    0x8822: "Exposure Program",
+    0x8824: "Spectral Sensitivity",
+    0x8827: "ISO Speed Ratings",
+    0x8828: "OECF",
+    0x9000: "EXIF Version",
+    0x9003: "DateTime Original",
+    0x9004: "DateTime Digitized",
+    0x9101: "Components Configuration",
+    0x9102: "Compressed Bits Per Pixel",
+    0x9201: "Shutter Speed Value",
+    0x9202: "Aperture Value",
+    0x9203: "Brightness Value",
+    0x9204: "Exposure Bias Value",
+    0x9205: "Max Aperture Value",
+    0x9206: "Subject Distance",
+    0x9207: "Metering Mode",
+    0x9208: "Light Source",
+    0x9209: "Flash",
+    0x920a: "Focal Length",
+    0x9214: "Subject Area",
+    0x927c: "Maker Note",
+    0x9286: "User Comment",
+    # ... TODO
+    0xa000: "Flashpix Version",
+    0xa001: "Color Space",
+    0xa002: "Pixel X Dimension",
+    0xa003: "Pixel Y Dimension",
+    0xa004: "Related Sound File",
+    # ... TODO
+
+    # GPS IFD tags
+    # ... TODO
+}
+
+_TIFF_EXIF_IFD = 0x8769
+_GPS_IFD = 0x8825
+_INTEROPERABILITY_IFD = 0xa005
+
+
+class ExifInfo:
+    """EXIF reader and information lister."""
+
+    _endian = None
+    _buffer = None
+    _offset = 0
+    _global_ifd_offset = 0
+    _exif_ifd_offset = 0
+    _gps_ifd_offset = 0
+    _interoperability_ifd_offset = 0
+    _hex = False
+
+    def __init__(self, buffer, **kwargs):
+        """Initialize the EXIF data reader."""
+        self._hex = kwargs.get("hex", False)
+        self._verbose = kwargs.get("verbose", False)
+        if not isinstance(buffer, bytes):
+            raise RuntimeError("invalid EXIF data type")
+        if buffer.startswith(b"MM\x00\x2a"):
+            self._endian = "MM"
+        elif buffer.startswith(b"II\x2a\x00"):
+            self._endian = "II"
+        else:
+            raise RuntimeError("invalid EXIF header")
+        self._buffer = buffer
+        self._offset = 4
+        self._global_ifd_offset = self._ui32()
+
+    def endian(self):
+        """Return the endianness of the EXIF data."""
+        return self._endian
+
+    def _tags_for_ifd(self, ifd_offset):
+        """Yield the tags found at the given TIFF IFD offset."""
+        if ifd_offset < 8:
+            raise RuntimeError("invalid TIFF IFD offset")
+        self._offset = ifd_offset
+        ifd_size = self._ui16()
+        for _ in range(0, ifd_size):
+            tag_id = self._ui16()
+            tag_type = self._ui16()
+            count = self._ui32()
+            value_or_offset = self._ui32()
+            if self._endian == "MM":
+                # FIXME:
+                # value_or_offset requires a fixup under big-endian encoding.
+                if tag_type == 2:
+                    # 2 --> "ascii"
+                    value_or_offset >>= 24
+                elif tag_type == 3:
+                    # 3 --> "short"
+                    value_or_offset >>= 16
+                else:
+                    # ... FIXME
+                    pass
+            if count == 0:
+                raise RuntimeError("unsupported count=0 in tag 0x%x" % tag_id)
+            if tag_id == _TIFF_EXIF_IFD:
+                if tag_type != 4:
+                    raise RuntimeError("incorrect tag type for EXIF IFD")
+                self._exif_ifd_offset = value_or_offset
+            elif tag_id == _GPS_IFD:
+                if tag_type != 4:
+                    raise RuntimeError("incorrect tag type for GPS IFD")
+                self._gps_ifd_offset = value_or_offset
+            elif tag_id == _INTEROPERABILITY_IFD:
+                if tag_type != 4:
+                    raise RuntimeError("incorrect tag type for Interop IFD")
+                self._interoperability_ifd_offset = value_or_offset
+            yield (tag_id, tag_type, count, value_or_offset)
+
+    def tags(self):
+        """Yield all TIFF/EXIF tags."""
+        if self._verbose:
+            print("TIFF IFD : 0x%08x" % self._global_ifd_offset)
+        for tag in self._tags_for_ifd(self._global_ifd_offset):
+            yield tag
+        if self._exif_ifd_offset > 0:
+            if self._verbose:
+                print("EXIF IFD : 0x%08x" % self._exif_ifd_offset)
+            for tag in self._tags_for_ifd(self._exif_ifd_offset):
+                yield tag
+        if self._gps_ifd_offset > 0:
+            if self._verbose:
+                print("GPS IFD : 0x%08x" % self._gps_ifd_offset)
+            for tag in self._tags_for_ifd(self._gps_ifd_offset):
+                yield tag
+        if self._interoperability_ifd_offset > 0:
+            if self._verbose:
+                print("Interoperability IFD : 0x%08x" %
+                      self._interoperability_ifd_offset)
+            for tag in self._tags_for_ifd(self._interoperability_ifd_offset):
+                yield tag
+
+    def tagid2str(self, tag_id):
+        """Return an informative string representation of a TIFF tag id."""
+        idstr = _TIFF_TAGS.get(tag_id, "[Unknown]")
+        if self._hex:
+            idnum = "0x%04x" % tag_id
+        else:
+            idnum = "%d" % tag_id
+        return "%s (%s)" % (idstr, idnum)
+
+    @staticmethod
+    def tagtype2str(tag_type):
+        """Return an informative string representation of a TIFF tag type."""
+        typestr = _TIFF_TAG_TYPES.get(tag_type, "[unknown]")
+        return "%d:%s" % (tag_type, typestr)
+
+    def tag2str(self, tag_id, tag_type, count, value_or_offset):
+        """Return an informative string representation of a TIFF tag tuple."""
+        return "%s (type=%s) (count=%d) : 0x%08x" \
+               % (self.tagid2str(tag_id), self.tagtype2str(tag_type), count,
+                  value_or_offset)
+
+    def _ui32(self):
+        """Decode a 32-bit unsigned int found at the current offset;
+           advance the offset by 4.
+        """
+        if self._offset + 4 > len(self._buffer):
+            raise RuntimeError("out-of-bounds uint32 access in EXIF")
+        if self._endian == "MM":
+            result = unpack_uint32be(self._buffer, self._offset)
+        else:
+            result = unpack_uint32le(self._buffer, self._offset)
+        self._offset += 4
+        return result
+
+    def _ui16(self):
+        """Decode a 16-bit unsigned int found at the current offset;
+           advance the offset by 2.
+        """
+        if self._offset + 2 > len(self._buffer):
+            raise RuntimeError("out-of-bounds uint16 access in EXIF")
+        if self._endian == "MM":
+            result = unpack_uint16be(self._buffer, self._offset)
+        else:
+            result = unpack_uint16le(self._buffer, self._offset)
+        self._offset += 2
+        return result
+
+    def _ui8(self):
+        """Decode an 8-bit unsigned int found at the current offset;
+           advance the offset by 1.
+        """
+        if self._offset + 1 > len(self._buffer):
+            raise RuntimeError("out-of-bounds uint8 access in EXIF")
+        result = unpack_uint8(self._buffer, self._offset)
+        self._offset += 1
+        return result
+
+
+def print_raw_exif_info(buffer, **kwargs):
+    """Print the EXIF information found in a raw byte stream."""
+    lister = ExifInfo(buffer, **kwargs)
+    print("EXIF (endian=%s)" % lister.endian())
+    for (tag_id, tag_type, count, value_or_offset) in lister.tags():
+        print(lister.tag2str(tag_id=tag_id,
+                             tag_type=tag_type,
+                             count=count,
+                             value_or_offset=value_or_offset))
+
+
+if __name__ == "__main__":
+    # For testing only.
+    for arg in sys.argv[1:]:
+        with open(arg, "rb") as test_stream:
+            test_buffer = test_stream.read(_READ_DATA_SIZE_MAX)
+            print_raw_exif_info(test_buffer, hex=True, verbose=True)

+ 10 - 0
png.mod/libpng/contrib/pngexif/pngexifinfo

@@ -0,0 +1,10 @@
+#!/bin/sh
+set -eu
+
+my_python="$(command -v python3 || command -v python)" || {
+    echo >&2 "error: program not found: Python interpreter"
+    exit 127
+}
+my_python_flags="-BES"
+
+exec "$my_python" "$my_python_flags" "$(dirname "$0")/pngexifinfo.py" "$@"

Some files were not shown because too many files changed in this diff