changeset 5994:f5bc246da8c3 release

maint: merge default to release.
author Markus Mützel <markus.muetzel@gmx.de>
date Tue, 30 Nov 2021 19:01:07 +0100
parents 312b454ec648 (current diff) bac4ef91ea7e (diff)
children b8d1edf82ec2
files
diffstat 286 files changed, 15918 insertions(+), 6696 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.in	Wed Nov 24 18:31:48 2021 +0100
+++ b/Makefile.in	Tue Nov 30 19:01:07 2021 +0100
@@ -80,6 +80,9 @@
 # Set to "yes" to use msys2
 USE_MSYS2 := @USE_MSYS2@
 
+# Set to "ucrt" or "msvcrt"
+HOST_MSVCRT := @HOST_MSVCRT@
+
 # Should match what config.guess prints for your system.
 # If cross compiling, you must set it manually (defaults are set by configure).
 ifeq ($(MXE_NATIVE_BUILD),yes)
@@ -271,7 +274,7 @@
 # some build tools are optional and added as explicit dependencies
 # to packages that need them
 BUILD_TOOLS_OPT := \
-  build-mako build-markupsafe build-meson build-ninja build-python3 \
+  build-libffi build-mako build-markupsafe build-meson build-ninja \
   build-python build-octave build-setuptools build-scons
 BUILD_TOOLS := $(filter-out $(BUILD_TOOLS_OPT), $(BUILD_TOOLS))
 # Building flex for native mingw fails, so disable it.
@@ -295,12 +298,12 @@
   REQUIREMENTS += makeinfo xz
   BUILD_TOOLS := $(filter-out build-texinfo build-xz, $(BUILD_TOOLS))
 endif
-# use the a native python in native mingw
+# use a native python in native mingw
 ifeq ($(MXE_NATIVE_MINGW_BUILD),yes)
   REQUIREMENTS += python3
-  BUILD_TOOLS := $(filter-out build-python3, $(BUILD_TOOLS))
+  BUILD_TOOLS := $(filter-out build-python, $(BUILD_TOOLS))
 endif
-PYTHON3 ?= python3
+MXE_PYTHON ?= python3
 
 # use the a native awk in native mingw
 ifeq ($(MXE_NATIVE_MINGW_BUILD),yes)
@@ -335,7 +338,7 @@
 
 ENV_PKG_CONFIG_PATH := $(PKG_CONFIG_PATH)
 
-BUILD_PKG_CONFIG_PATH ?= @BUILD_PKG_CONFIG_PATH@
+BUILD_PKG_CONFIG_PATH ?= $(BUILD_TOOLS_PREFIX)/lib/pkgconfig:@BUILD_PKG_CONFIG_PATH@
 
 CONFIGURE_CPPFLAGS := CPPFLAGS='-I$(HOST_PREFIX)/include'
 ifeq ($(MXE_USE_LIB64_DIRECTORY),yes)
@@ -478,7 +481,7 @@
     MSYS2_PACKAGES := $(shell $(SED) -n 's/^.* class="package">\([^<]*\)<.*$$/\1/p' '$(TOP_DIR)/index.html' | $(GREP) msys2-)
     MSYS2_SOURCES := $(addprefix src-,$(MSYS2_PACKAGES))
     PKGS += $(MSYS2_SOURCES)
-    MSYS2_BASE_URL := http://repo.msys2.org/msys
+    MSYS2_BASE_URL := https://repo.msys2.org/msys
     MSYS2_URL := $(MSYS2_BASE_URL)/$(MSYS2_ARCH)
     MSYS2_SRC_URL := $(MSYS2_BASE_URL)/sources
     MSYS2_DIR := $(TOP_BUILD_DIR)/msys2
@@ -532,9 +535,11 @@
 OCTAVE_FORGE_BASE_URL := 'https://sourceforge.net/projects/octave/files/Octave Forge Packages/Individual Package Releases'
 ## Packages removed from list because build is broken:
 ## None.
-OCTAVE_FORGE_PACKAGES := $(addprefix of-,miscellaneous struct optim general signal communications image io statistics control geometry windows linear-algebra sockets data-smoothing fuzzy-logic-toolkit quaternion fits tsa netcdf ltfat database instrument-control generate_html nurbs strings financial stk splines dataframe lssa queueing ga interval nan ocs mapping tisean video zeromq gsl optiminterp dicom sparsersb audio symbolic matgeom octproj)
+OCTAVE_FORGE_PACKAGES := $(addprefix of-,audio communications control database dataframe data-smoothing dicom financial fits fuzzy-logic-toolkit ga general generate_html geometry gsl image instrument-control interval io linear-algebra lssa ltfat mapping matgeom miscellaneous nan netcdf nurbs ocs octproj optim optiminterp quaternion queueing signal sockets sparsersb splines statistics stk strings struct symbolic tisean tsa video windows zeromq)
+OCTAVE_OTHER_PACKAGES := $(addprefix opkg-,biosig)
 # get ALL deps for all of- packages, regardless of whether building the actual forge package in the installer
 OCTAVE_FORGE_DEPS:= $(sort $(foreach p,$(addprefix $(TOP_DIR)/src/,$(addsuffix .mk,$(OCTAVE_FORGE_PACKAGES))),$(shell $(SED) -n 's/.*_DEPS.*:=\(.*\)/\1/p' $p)))
+OCTAVE_OTHER_PKG_DEPS:= $(sort $(foreach p,$(addprefix $(TOP_DIR)/src/,$(addsuffix .mk,$(OCTAVE_OTHER_PACKAGES))),$(shell $(SED) -n 's/.*_DEPS.*:=\(.*\)/\1/p' $p)))
 
 BLAS_PACKAGES := blas
 ifeq ($(ENABLE_OPENBLAS),yes)
@@ -578,8 +583,9 @@
     $(if $(filter %.tar.lz, $(1)),$(3) xaf '$(1)', \
     $(if $(filter %.tar.lzma,$(1)),xz -dc -F lzma '$(1)' | $(3) xf -, \
     $(if $(filter %.tar.xz,$(1)),xz -dc '$(1)' | $(3) xf -, \
+    $(if $(filter %.tar.zst,$(1)),zstd -dc '$(1)' | $(3) xf -, \
     $(if $(filter %.zip,     $(1)),unzip -q '$(1)', \
-    $(error Unknown archive format for $(2): $(1)))))))))
+    $(error Unknown archive format for $(2): $(1))))))))))
 
 UNPACK_PKG_ARCHIVE = \
     $(if $(value $(1)_FILE),$(call UNPACK_ARCHIVE,$(PKG_DIR)/$($(1)_FILE),$(1),$(2)),true)
@@ -689,7 +695,7 @@
 define MSYS2_PKG_UPDATE
   $(WGET) -q -O- '$(MSYS2_URL)/' | \
   $(GREP) $($(PKG)_NAME) | $(GREP) "$($(PKG)_FILTER)" | \
-  $(SED) -n 's,.*href="$($(PKG)_NAME)-\(r\?[0-9][^-]*-[0-9]*\)-[^\.]*\.pkg\.tar\.xz".*,\1,p' | \
+  $(SED) -n 's,.*href="$($(PKG)_NAME)-\(r\?[0-9][^-]*-[0-9]*\)-[^\.]*\.pkg\.tar.*,\1,p' | \
   $(SORT) -V | \
   tail -1
 endef
@@ -703,6 +709,9 @@
 .PHONY: octave-forge-packages
 octave-forge-packages: $(OCTAVE_FORGE_DEPS) $(OCTAVE_FORGE_PACKAGES)
 
+.PHONY: octave-other-packages
+octave-other-packages: $(OCTAVE_OTHER_PKG_DEPS) $(OCTAVE_OTHER_PACKAGES)
+
 .PHONY: blas-packages
 blas-packages: $(BLAS_PACKAGES)
 
@@ -837,18 +846,20 @@
       && $(INSTALL) -m644 '$($(PKG)_FILE)' '$(3)$(HOST_PREFIX)/src'
 endef
 
+# FIXME: The OCTAVE_FORGE_PKG_BUILD build rule probably works for *any* valid
+# Octave package (not only Octave Forge packages).  Consider renaming it.
 ifeq ($(MXE_SYSTEM),msvc)
-define OCTAVE_FORGE_PKG_BUILD
+  define OCTAVE_FORGE_PKG_BUILD
     $(INSTALL) -d '$(3)$(HOST_PREFIX)/local/octave-$(octave_VERSION)/share/octave'
     $(INSTALL) -d '$(3)$(HOST_PREFIX)/local/octave-$(octave_VERSION)/lib/octave'
     cd '$(1)/..' && tar cvfz $($(PKG)_FILE) $($(PKG)_SUBDIR)
     cd '$(1)/..' && $(HOST_PREFIX)/local/octave-$(octave_VERSION)/bin/octave-cli.exe -H -f -q \
-        --eval "more off;" \
-        --eval "pkg('prefix', '`cd "$(3)" && pwd -W`$(HOST_PREFIX)/local/octave-$(octave_VERSION)/share/octave/packages', '`cd "$(3)" && pwd -W`$(HOST_PREFIX)/local/octave-$(octave_VERSION)/lib/octave/packages');" \
-	--eval "pkg('install', '-verbose', '$($(PKG)_FILE)');"
+      --eval "more off;" \
+      --eval "pkg('prefix', '`cd "$(3)" && pwd -W`$(HOST_PREFIX)/local/octave-$(octave_VERSION)/share/octave/packages', '`cd "$(3)" && pwd -W`$(HOST_PREFIX)/local/octave-$(octave_VERSION)/lib/octave/packages');" \
+      --eval "pkg('install', '-verbose', '$($(PKG)_FILE)');"
 endef
 else
-define OCTAVE_FORGE_PKG_BUILD
+  define OCTAVE_FORGE_PKG_BUILD
     if [ $(ENABLE_BINARY_PACKAGES) = no ]; then \
       mkdir -p '$(3)$(HOST_PREFIX)/src'; \
       cd '$(1)/..' \
@@ -863,7 +874,7 @@
         CONFIGURE_OPTIONS="$(HOST_AND_BUILD_CONFIGURE_OPTIONS)" $(4) \
         $(PYTHON3) $(TOP_DIR)/tools/pkg-install.py install -verbose "$($(PKG)_FILE)"; \
      fi
-endef
+  endef
 endif
 
 define OCTAVE_FORGE_PKG_UPDATE
@@ -1015,6 +1026,11 @@
 update-build-tools:
 	$(foreach PKG,$(BUILD_TOOLS),$(call UPDATE,$(PKG),$(shell $($(PKG)_UPDATE))))
 
+.PHONY: update-general-pkgs
+update-general-pkgs:
+	$(foreach PKG,$(filter-out $(MSYS2_PACKAGES) $(MSYS_BASE_PACKAGES) $(OCTAVE_FORGE_PACKAGES), $(PKGS)),\
+		$(if $($(PKG)_UPDATE),$(call UPDATE,$(PKG),$(shell $($(PKG)_UPDATE))),$(info Warning: No update rule for $(PKG))))
+
 update-checksum-%:
 	$(call DOWNLOAD_PKG_ARCHIVE,$*)
 	$(SED) -i 's/^\([^ ]*_CHECKSUM *:=\).*/\1 '"`$(call PKG_CHECKSUM,$*)`"'/' '$(TOP_DIR)/src/$*.mk'
@@ -1060,7 +1076,7 @@
 define MSYS2_PKG_UPDATE_FILE
   cat $(MSYS2_UPDATE_TMP_FILE) | \
   $(GREP) $($(PKG)_NAME) | $(GREP) "$($(PKG)_FILTER)" | \
-  $(SED) -n 's,.*href="$($(PKG)_NAME)-\(r\?[0-9][^-]*-[0-9]*\)-[^\.]*\.pkg\.tar\.xz".*,\1,p' | \
+  $(SED) -n 's,.*href="$($(PKG)_NAME)-\(r\?[0-9][^-]*-[0-9]*\)-[^\.]*\.pkg\.tar.*,\1,p' | \
   $(SORT) -V | \
   tail -1
 endef
--- a/binary-dist-rules.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/binary-dist-rules.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -25,7 +25,10 @@
 ifeq ($(MXE_WINDOWS_BUILD),yes)
   TAR_H_OPTION := -h
   WINDOWS_BINARY_DIST_DEPS := \
-    win7appid blas_switch
+    octave-launch \
+    octave-launch-firsttime \
+    win7appid \
+    blas_switch
 
   ifeq ($(USE_MSYS2),yes)
     WINDOWS_BINARY_DIST_DEPS += \
@@ -49,16 +52,13 @@
       native-gcc \
       npp
   endif
-
-  # other packages we want to include
-  WINDOWS_BINARY_DIST_DEPS += \
-    biosig
 endif
 
 BINARY_DIST_DEPS := \
   $(OCTAVE_TARGET) \
   blas-packages \
   octave-forge-packages \
+  octave-other-packages \
   devel-packages \
   units \
   transfig \
@@ -87,6 +87,36 @@
   fi
 endef
 
+## FIXME: Maybe we should have a uniform way of dealing with the
+## creation of build-tree directories like this?
+installer-files/.dirstamp:
+	@mkdir -p installer-files
+	@: > installer-files/.dirstamp
+
+ifeq ($(MXE_WINDOWS_BUILD),yes)
+
+  ifeq ($(OCTAVE_TARGET),default-octave)
+    OCTAVE_LAUNCH_NO_SHORT_CPPFLAGS := -DNO_SHORT_PATH_NAMES
+  endif
+
+.PHONY: octave-launch
+octave-launch: installer-files/octave-launch.exe
+
+## FIXME: We aren't using VPATH?
+installer-files/octave-launch.exe: $(TOP_DIR)/installer-files/octave-launch.c installer-files/octave-launch.res | installer-files/.dirstamp
+	$(MXE_CC) $< -o $@ installer-files/octave-launch.res -Wl,--subsystem,windows -lshlwapi -municode -DUNICODE -D_UNICODE $(OCTAVE_LAUNCH_NO_SHORT_CPPFLAGS)
+
+.PHONY: octave-launch-firsttime
+octave-launch-firsttime: installer-files/octave-launch-firsttime.exe
+
+## FIXME: We aren't using VPATH?
+installer-files/octave-launch-firsttime.exe: $(TOP_DIR)/installer-files/octave-launch.c installer-files/octave-launch.res | installer-files/.dirstamp
+	$(MXE_CC) $< -o $@ installer-files/octave-launch.res -Wl,--subsystem,windows -lshlwapi -municode -DUNICODE -D_UNICODE -DFIRST_TIME $(OCTAVE_LAUNCH_NO_SHORT_CPPFLAGS)
+
+installer-files/octave-launch.res: $(TOP_DIR)/installer-files/octave-launch.rc | installer-files/.dirstamp
+	$(MXE_WINDRES) $< -o $@ -O coff
+endif
+
 ifeq ($(MXE_WINDOWS_BUILD),yes)
   ifeq ($(MXE_NATIVE_BUILD),no)
     define copy-windows-dist-files
@@ -113,16 +143,27 @@
       cp $(TOP_DIR)/installer-files/README.html $(OCTAVE_DIST_DIR)/
       echo "  refblas..."
       cp $(OCTAVE_DIST_DIR)$(OCTAVE_ADD_PATH)/bin/libblas.dll $(OCTAVE_DIST_DIR)$(OCTAVE_ADD_PATH)/bin/librefblas.dll
+      echo "  installing octave-launch.exe..."
+      cp $(TOP_BUILD_DIR)/installer-files/octave-launch.exe $(OCTAVE_DIST_DIR)/
+      cp $(TOP_BUILD_DIR)/installer-files/octave-launch-firsttime.exe $(OCTAVE_DIST_DIR)/
       echo "  octave.vbs..."
       cp $(TOP_DIR)/installer-files/octave.vbs $(OCTAVE_DIST_DIR)/
       cp $(TOP_DIR)/installer-files/octave-firsttime.vbs $(OCTAVE_DIST_DIR)/
       cp $(TOP_DIR)/installer-files/fc_update.bat $(OCTAVE_DIST_DIR)/
       cp $(TOP_DIR)/installer-files/post-install.bat $(OCTAVE_DIST_DIR)/
+      # This patch can be dropped as soon as those lines are removed from
+      # the startup scripts for all targets (including stable and release).
+      if [ "$(OCTAVE_TARGET)" = "default-octave" ]; then \
+        (cd '$(OCTAVE_DIST_DIR)' && $(PATCH) -p1 -u) < $(TOP_DIR)/installer-files/octave-no-short-path.patch; \
+      fi
       cp $(TOP_BUILD_DIR)/HG-ID $(OCTAVE_DIST_DIR)/
-      echo "  updating octave .exe to script files..."
-      rm -f $(OCTAVE_DIST_DIR)$(OCTAVE_ADD_PATH)/bin/octave.exe
-      rm -f $(OCTAVE_DIST_DIR)$(OCTAVE_ADD_PATH)/bin/octave-$($(OCTAVE_TARGET)_VERSION).exe
+      echo "  installing octave.bat script file..."
       cp $(TOP_DIR)/installer-files/octave.bat $(OCTAVE_DIST_DIR)$(OCTAVE_ADD_PATH)/bin/octave.bat
+      # This patch can be dropped as soon as those lines are removed from
+      # "octave.bat" for all targets (including stable and release).
+      if [ "$(OCTAVE_TARGET)" = "default-octave" ]; then \
+        (cd '$(OCTAVE_DIST_DIR)$(OCTAVE_ADD_PATH)/bin' && $(PATCH) -p1 -u) < $(TOP_DIR)/installer-files/octave-bat-no-short-path.patch; \
+      fi
       cp $(TOP_DIR)/installer-files/octave.bat $(OCTAVE_DIST_DIR)$(OCTAVE_ADD_PATH)/bin/octave-$($(OCTAVE_TARGET)_VERSION).bat
       echo "  updating libtool references..."
       find '$(OCTAVE_DIST_DIR)$(OCTAVE_ADD_PATH)/' -type f -name "*.la" \
@@ -132,6 +173,9 @@
         -exec $(SED) -i 's|$(HOST_PREFIX)|/usr|g;s|$(BUILD_TOOLS_PREFIX)|/usr|g' {} \; ;
       if [ "$(ENABLE_DEVEL_TOOLS)" = "yes" ]; then \
         cp $(TOP_DIR)/installer-files/cmdshell.bat $(OCTAVE_DIST_DIR)/; \
+        if [ "$(OCTAVE_TARGET)" = "default-octave" ]; then \
+          (cd '$(OCTAVE_DIST_DIR)' && $(PATCH) -p1 -u) < $(TOP_DIR)/installer-files/cmdshell-no-short-path.patch; \
+        fi; \
       fi
       echo "  updating script tool references..."
       #find '$(OCTAVE_DIST_DIR)$(OCTAVE_ADD_PATH)/bin' -type f ! -name "*.*" \
@@ -150,14 +194,15 @@
       cp $(TOP_DIR)/installer-files/README.html $(OCTAVE_DIST_DIR)/
       echo "  refblas..."
       cp $(OCTAVE_DIST_DIR)/bin/libblas.dll $(OCTAVE_DIST_DIR)/bin/librefblas.dll
+      echo "  installing octave-launch.exe..."
+      cp $(TOP_BUILD_DIR)/installer-files/octave-launch.exe $(OCTAVE_DIST_DIR)/
+      cp $(TOP_BUILD_DIR)/installer-files/octave-launch-firsttime.exe $(OCTAVE_DIST_DIR)/
       echo "  octave.vbs..."
       cp $(TOP_DIR)/installer-files/octave.vbs $(OCTAVE_DIST_DIR)/
       cp $(TOP_DIR)/installer-files/octave-firsttime.vbs $(OCTAVE_DIST_DIR)/
       cp $(TOP_DIR)/installer-files/fc_update.bat $(OCTAVE_DIST_DIR)/
       cp $(TOP_DIR)/installer-files/post-install.bat $(OCTAVE_DIST_DIR)/
-      echo "  updating octave .exe to script files..."
-      rm -f $(OCTAVE_DIST_DIR)/bin/octave.exe
-      rm -f $(OCTAVE_DIST_DIR)/bin/octave-$($(OCTAVE_TARGET)_VERSION).exe
+      echo "  installing octave.bat script files..."
       cp $(TOP_DIR)/installer-files/octave.bat $(OCTAVE_DIST_DIR)/bin/octave.bat
       cp $(TOP_DIR)/installer-files/octave.bat $(OCTAVE_DIST_DIR)/bin/octave-$($(OCTAVE_TARGET)_VERSION).bat
     endef
--- a/configure.ac	Wed Nov 24 18:31:48 2021 +0100
+++ b/configure.ac	Tue Nov 30 19:01:07 2021 +0100
@@ -99,6 +99,16 @@
    esac], [USE_MSYS2=yes])
 AC_SUBST(USE_MSYS2)
 
+# Use "msvcrt" or "ucrt" on Windows
+AC_ARG_WITH([windows-msvcrt],
+  [AS_HELP_STRING([--with-windows-msvcrt=msvcrt], [select C runtime for windows distribution (default: msvcrt)])],
+  [case $withval in
+     no) AC_MSG_ERROR([A runtime for Windows is required for --with-windows-msvcrt]) ;;
+     yes | "") HOST_MSVCRT=msvcrt ;;
+     *) HOST_MSVCRT="$withval" ;;
+   esac], [HOST_MSVCRT=msvcrt])
+AC_SUBST(HOST_MSVCRT)
+
 # try find pkg-config build paths
 BUILD_PKG_CONFIG_PATH=auto
 AC_ARG_WITH([build-pkg-config-path],
@@ -130,6 +140,10 @@
      *) AC_MSG_ERROR([bad value "$enableval" for --enable-windows-64]) ;;
    esac], [ENABLE_WINDOWS_64=yes])
 
+if test "$ENABLE_WINDOWS_64" = "no" && test "$HOST_MSVCRT" = "ucrt"; then
+  AC_MSG_NOTICE([UCRT is only supported with --enable-windows-64])
+fi
+
 AC_ARG_ENABLE([64],
   [AS_HELP_STRING([--enable-64],
     [use 64-bit integers for array dimensions and indexing])],
--- a/dist-files.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/dist-files.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -7,7 +7,6 @@
   armadillo-1-staticlib.patch \
   armadillo-test.cpp \
   armadillo.mk \
-  arpack-1-gcc10.patch \
   arpack.mk \
   atk-1-DllMain.patch \
   atk.mk \
@@ -15,7 +14,6 @@
   aubio-1-fix-pkg-config.patch \
   aubio.mk \
   bfd.mk \
-  biosig.mk \
   blas.mk \
   blas_switch.mk \
   boost-1-intrinsics-fix.patch \
@@ -33,9 +31,9 @@
   build-gcc.mk \
   build-gettext.mk \
   build-gperf.mk \
+  build-libffi.mk \
   build-libtool.mk \
   build-lzip.mk \
-  build-m4-glibc2-28.patch \
   build-m4.mk \
   build-mako.mk \
   build-markupsafe.mk \
@@ -47,10 +45,10 @@
   build-pkg-config-1-fixes.patch \
   build-pkg-config.mk \
   build-python.mk \
-  build-python3.mk \
   build-scons.mk \
   build-sed.mk \
   build-setuptools.mk \
+  build-zstd.mk \
   build-texinfo.mk \
   build-xz.mk \
   build-yasm.mk \
@@ -77,7 +75,6 @@
   dcmtk-1-fixes.patch \
   dcmtk-2-mingw-w64.patch \
   dcmtk-3-pointer-fixes.patch \
-  dcmtk-4-c++11-related-fixes.patch \
   dcmtk.mk \
   default-octave-1-gnulib.patch \
   default-octave.mk \
@@ -98,6 +95,7 @@
   file-test.c \
   file.mk \
   fixesproto.mk \
+  flac-1-ucrt.patch \
   flac.mk \
   fltk-2-uuid-mod.patch \
   fltk-test.cpp \
@@ -123,9 +121,13 @@
   gd-1-libpng15.patch \
   gd-test.c \
   gd.mk \
+  gdal-1-gcc11.patch \
+  gdal-2-ucrt.patch \
   gdal.mk \
   gdb.mk \
   gdcm-1-nosecapi.patch \
+  gdcm-2-getopt.patch \
+  gdcm-3-gcc11.patch \
   gdcm.mk \
   gdk-pixbuf-1-fixes.patch \
   gdk-pixbuf.mk \
@@ -142,6 +144,7 @@
   glew-test.c \
   glew.mk \
   glib-1-fixes.patch \
+  glib-2-fixes.patch \
   glib.mk \
   glibmm.mk \
   glpk-1-fixes.patch \
@@ -156,6 +159,7 @@
   gnutls.mk \
   graphicsmagick-1-fix-xml2-config.patch \
   graphicsmagick-2-dynamicpath.patch \
+  graphicsmagick-3-user32.patch \
   graphicsmagick-test.cpp \
   graphicsmagick.mk \
   gsl-test.c \
@@ -214,7 +218,6 @@
   lame.mk \
   lapack-test.f \
   lapack.mk \
-  lcms-1-fixes.patch \
   lcms.mk \
   lcms1-1-fixes.patch \
   lcms1.mk \
@@ -225,6 +228,8 @@
   libass-test.c \
   libass.mk \
   libb64.mk \
+  libbiosig-1-gcc11.patch \
+  libbiosig.mk \
   libcdio.mk \
   libcroco.mk \
   libdnet-1-fixes.patch \
@@ -245,6 +250,7 @@
   libglade.mk \
   libgnurx-1-build-static-lib.patch \
   libgnurx.mk \
+  libgomp-1-fixes.patch \
   libgomp-test.c \
   libgomp.mk \
   libgpg_error-1-fixes.patch \
@@ -306,6 +312,7 @@
   libsndfile.mk \
   libssh2-test.c \
   libssh2.mk \
+  libsodium.mk \
   libtasn1.mk \
   libtool.mk \
   libunistring.mk \
@@ -332,6 +339,7 @@
   matio.mk \
   mdbtools.mk \
   mesa-1-meson.patch \
+  mesa-2-ucrt.patch \
   mesa-proto.mk \
   mesa.mk \
   mingw-blas-1-xerbla.patch \
@@ -339,17 +347,21 @@
   mingw-cfitsio-1-fixes.patch \
   mingw-epstool-1-fixes.patch \
   mingw-glpk-1-fixes.patch \
+  mingw-graphicsmagick-1-dcraw.patch \
   mingw-hdf5-1.patch \
   mingw-lapack-1-xerbla.patch \
   mingw-libgcrypt-1-fixes.patch \
   mingw-libmng-1-noundefines.patch \
   mingw-openblas-1-xerbla.patch \
+  mingw-pkg-config-1-gnu-printf.patch \
   mingw-portaudio-1-pkgconfig.patch \
   mingw-s2tc-1-fixes.patch \
   mingw-texinfo-1-fixes.patch \
+  mingw-texinfo-2-makeinfo-non-ASCII-perl.patch \
   mingw-utils-1-portability-fix.patch \
   mingw-w64-1-float-h.patch \
   mingw-w64.mk \
+  mingw-zeromq-1-fixes.patch \
   mingwrt.mk \
   mman-win32-1-include_name_change.patch \
   mman-win32.mk \
@@ -442,6 +454,7 @@
   mxml-test.c \
   mxml.mk \
   native-binutils.mk \
+  native-gcc-1-canadian-cross.patch \
   native-gcc.mk \
   ncurses-1-gcc-5-fix.patch \
   ncurses.mk \
@@ -463,9 +476,12 @@
   of-actuarial.mk \
   of-audio.mk \
   of-communications-1-catop.patch \
+  of-communications-2-error_state.patch \
   of-communications.mk \
+  of-control-1-deprecated-warnings.patch \
   of-control.mk \
   of-data-smoothing.mk \
+  of-database-1-verror.patch \
   of-database.mk \
   of-dataframe.mk \
   of-dicom.mk \
@@ -479,18 +495,23 @@
   of-ga.mk \
   of-general.mk \
   of-generate_html.mk \
+  of-geometry-1-cxx17.patch \
   of-geometry.mk \
   of-gsl-1-cross-fixes.patch \
   of-gsl.mk \
+  of-image-1-namespace.patch \
+  of-image-1-no-jit.patch \
   of-image.mk \
   of-instrument-control.mk \
   of-interval-1-cross-fixes.patch \
   of-interval-2-subsref.patch \
+  of-interval-3-error_state.patch \
   of-interval.mk \
   of-io.mk \
   of-linear-algebra.mk \
   of-lssa.mk \
   of-ltfat-1-cross-fixes.patch \
+  of-ltfat-2-LDFLAGS.patch \
   of-ltfat.mk \
   of-matgeom.mk \
   of-mapping.mk \
@@ -503,6 +524,7 @@
   of-ocs-3-break-fixes.patch \
   of-ocs-4-pkgadd-fixes.patch \
   of-ocs-5-no-odepkg.patch \
+  of-ocs-6-error_state.patch \
   of-ocs.mk \
   of-octcdf.mk \
   of-octproj.mk \
@@ -510,14 +532,18 @@
   of-odepkg-2-fixes.patch \
   of-odepkg-3-deprecated.patch \
   of-odepkg.mk \
+  of-optim-1-verror.patch \
   of-optim.mk \
   of-optiminterp.mk \
   of-quaternion-1-cross-fixes.patch \
   of-quaternion-2-dev-fixes.patch \
   of-quaternion.mk \
   of-queueing.mk \
+  of-signal-1-deprecated-warnings.patch \
+  of-signal-2-error_state.patch \
   of-signal.mk \
   of-sockets.mk \
+  of-sparsersb-1-no-internal-mex-fcns.patch \
   of-sparsersb.mk \
   of-specfun-1-deprecated.patch \
   of-specfun.mk \
@@ -526,13 +552,15 @@
   of-statistics.mk \
   of-stk.mk \
   of-strings-1-fixes.patch \
+  of-strings-2-error_state.patch \
   of-strings.mk \
+  of-struct-1-verror.patch \
   of-struct.mk \
   of-symbolic.mk \
   of-tisean-1-fixes.patch \
+  of-tisean-2-error_state.patch \
   of-tisean.mk \
   of-tsa.mk \
-  of-video-1-fixes.patch \
   of-video.mk \
   of-windows.mk \
   of-zenity.mk \
@@ -549,10 +577,13 @@
   opencv-1-fixes.patch \
   opencv.mk \
   openexr.mk \
+  openjpeg.mk \
   openscenegraph-1-fixes.patch \
   openscenegraph.mk \
   openssl-1-fixes.patch \
   openssl.mk \
+  opkg-biosig.mk \
+  opus.mk \
   pango-1-fixes.patch \
   pango.mk \
   pangomm.mk \
@@ -579,7 +610,6 @@
   poppler.mk \
   popt-1-win32.patch \
   popt.mk \
-  portaudio-1-win32.patch \
   portaudio-test.c \
   portaudio.mk \
   postgresql.mk \
@@ -629,16 +659,12 @@
   qwtplot3d.mk \
   rapidjson-1-prettywriter.patch \
   rapidjson.mk \
-  readline-0-001.patch \
-  readline-0-002.patch \
-  readline-0-003.patch \
-  readline-0-004.patch \
+  readline-0-001-upstream.patch \
   readline-1-display.patch \
   readline-1-fixes.patch \
   readline-1-input.patch \
   readline-1-sigwinch.patch \
   readline-2-event-hook.patch \
-  readline-2-history.patch \
   readline.mk \
   release-octave-1-gnulib.patch \
   release-octave.mk \
@@ -709,6 +735,7 @@
   texinfo.mk \
   theora.mk \
   tiff.mk \
+  tinyxml-1-cmakelists.patch \
   tinyxml-test.cpp \
   tinyxml.mk \
   transfig-1-fixes.patch \
@@ -745,6 +772,7 @@
   winpcap.mk \
   wt-1-fixes.patch \
   wt.mk \
+  wxwidgets-1-fixes.patch \
   wxwidgets-test.cpp \
   wxwidgets.mk \
   x11.mk \
@@ -901,6 +929,7 @@
 
 SRC_MSYS2_FILES_1 := \
   msys2-bash.mk \
+  msys2-ca-certificates.mk \
   msys2-coreutils.mk \
   msys2-diffutils.mk \
   msys2-dos2unix.mk \
@@ -908,6 +937,7 @@
   msys2-findutils.mk \
   msys2-gawk.mk \
   msys2-gcc-libs.mk \
+  msys2-glib2.mk \
   msys2-gmp.mk \
   msys2-gnupg.mk \
   msys2-grep.mk \
@@ -945,11 +975,14 @@
   msys2-libunistring.mk \
   msys2-libutil-linux.mk \
   msys2-libxml2.mk \
+  msys2-libxslt.mk \
   msys2-make.mk \
   msys2-mintty.mk \
   msys2-mpdecimal.mk \
   msys2-mpfr.mk \
   msys2-ncurses.mk \
+  msys2-openssl.mk \
+  msys2-p11-kit.mk \
   msys2-pacman-mirrors.mk \
   msys2-pacman.mk \
   msys2-patch.mk \
@@ -960,6 +993,7 @@
   msys2-tar.mk \
   msys2-unzip.mk \
   msys2-wget.mk \
+  msys2-which.mk \
   msys2-zip.mk \
   msys2-zlib.mk
 
@@ -968,6 +1002,7 @@
 
 SRC_MSYS2_SRC_FILES_1 := \
   src-msys2-bash.mk \
+  src-msys2-ca-certificates.mk \
   src-msys2-coreutils.mk \
   src-msys2-diffutils.mk \
   src-msys2-dos2unix.mk \
@@ -975,6 +1010,7 @@
   src-msys2-findutils.mk \
   src-msys2-gawk.mk \
   src-msys2-gcc-libs.mk \
+  src-msys2-glib2.mk \
   src-msys2-gmp.mk \
   src-msys2-gnupg.mk \
   src-msys2-grep.mk \
@@ -1012,11 +1048,14 @@
   src-msys2-libunistring.mk \
   src-msys2-libutil-linux.mk \
   src-msys2-libxml2.mk \
+  src-msys2-libxslt.mk \
   src-msys2-make.mk \
   src-msys2-mintty.mk \
   src-msys2-mpdecimal.mk \
   src-msys2-mpfr.mk \
   src-msys2-ncurses.mk \
+  src-msys2-openssl.mk \
+  src-msys2-p11-kit.mk \
   src-msys2-pacman-mirrors.mk \
   src-msys2-pacman.mk \
   src-msys2-patch.mk \
@@ -1027,6 +1066,7 @@
   src-msys2-tar.mk \
   src-msys2-unzip.mk \
   src-msys2-wget.mk \
+  src-msys2-which.mk \
   src-msys2-zip.mk \
   src-msys2-zlib.mk
 
@@ -1070,15 +1110,20 @@
 
 INSTALL_FILES_1 := \
   cmdshell.bat \
+  cmdshell-no-short-path.patch \
   post-install.bat \
   fc_update.bat \
   gpl-3.0.txt \
   octave.bat \
   octave.bmp \
   octave.vbs \
+  octave-bat-no-short-path.patch \
   octave-firsttime.vbs \
   octave-hdr.bmp \
+  octave-launch.c \
+  octave-launch.rc \
   octave-logo.ico \
+  octave-no-short-path.patch \
   post-install.bat \
   README.html
 INSTALL_FILES := $(addprefix installer-files/, $(INSTALL_FILES_1))
@@ -1093,5 +1138,3 @@
   $(TOOLS_FILES) \
   $(FILES) \
   $(INSTALL_FILES)
-
-
--- a/hg-octave-dist.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/hg-octave-dist.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -26,7 +26,7 @@
 
 HG_OCTAVE_DIST_ENV_FLAGS := \
   PKG_CONFIG_PATH='$(ENV_PKG_CONFIG_PATH)' \
-  LD_LIBRARY_PATH='$(LD_LIBRARY_PATH)' \
+  LD_LIBRARY_PATH='$(ENV_LD_LIBRARY_PATH)' \
   PATH='$(ENV_PATH)'
 
 .PHONY: hg-octave-dist
--- a/index.html	Wed Nov 24 18:31:48 2021 +0100
+++ b/index.html	Tue Nov 30 19:01:07 2021 +0100
@@ -966,10 +966,6 @@
         <td class="website"><a href="http://www.gnu.org/software/binutils/">Binary File Descriptor library</a></td>
     </tr>
     <tr>
-        <td class="package">biosig</td>
-        <td class="website"><a href="https://biosig.sourceforge.io/">Biosig</a></td>
-    </tr>
-    <tr>
         <td class="package">blas</td>
         <td class="website"><a href="http://www.netlib.org/blas/">blas</a></td>
     </tr>
@@ -1022,6 +1018,10 @@
         <td class="website"><a href="http://www.gnu.org/software/gperf">gperf</a></td>
     </tr>
     <tr>
+        <td class="package">build-libffi</td>
+        <td class="website"><a href="http://sourceware.org/libffi/">libffi</a></td>
+    </tr>
+    <tr>
         <td class="package">build-libtool</td>
         <td class="website"><a href="http://www.gnu.org/software/libtool">libtool</a></td>
     </tr>
@@ -1067,11 +1067,7 @@
     </tr>
     <tr>
         <td class="package">build-python</td>
-        <td class="website"><a href="https://www.python.org/dev/peps/pep-0373/">python2</a></td>
-    </tr>
-    <tr>
-        <td class="package">build-python3</td>
-        <td class="website"><a href="http://www.python.org">python3</a></td>
+        <td class="website"><a href="http://www.python.org">python</a></td>
     </tr>
     <tr>
         <td class="package">build-scons</td>
@@ -1098,6 +1094,10 @@
         <td class="website"><a href="http://yasm.tortall.net/">Yasm</a></td>
     </tr>
     <tr>
+        <td class="package">build-zstd</td>
+        <td class="website"><a href="https://github.com/facebook/zstd">Yasm</a></td>
+    </tr>
+    <tr>
         <td class="package">bzip2</td>
         <td class="website"><a href="http://www.bzip.org/">bzip2</a></td>
     </tr>
@@ -1514,6 +1514,10 @@
         <td class="website"><a  href="https://libb64.sourceforge.io/">libb64</a></td>
     </tr>
     <tr>
+        <td class="package">libbiosig</td>
+        <td class="website"><a href="https://biosig.sourceforge.io/">Biosig library</a></td>
+    </tr>
+    <tr>
         <td class="package">libcdio</td>
         <td class="website"><a href="http://ftp.gnu.org/gnu/libcdio">Libcdio</a></td>
     </tr>
@@ -1714,6 +1718,10 @@
         <td class="website"><a href="http://www.libssh2.org">libssh2</a></td>
     </tr>
     <tr>
+        <td class="package">libsodium</td>
+        <td class="website"><a href="https://doc.libsodium.org/">libsodium</a></td>
+    </tr>
+    <tr>
         <td class="package">libtasn1</td>
         <td class="website"><a href="https://www.gnu.org/software/libtasn1/">libtasn1</a></td>
     </tr>
@@ -1910,6 +1918,10 @@
         <td class="website"><a href="https://www.msys2.org/">MSYS2 bash</a></td>
     </tr>
     <tr>
+        <td class="package">msys2-ca-certificates</td>
+        <td class="website"><a href="https://www.msys2.org/">MSYS2 ca-certificates</a></td>
+    </tr>
+    <tr>
         <td class="package">msys2-coreutils</td>
         <td class="website"><a href="https://www.msys2.org/">MSYS2 coreutils</a></td>
     </tr>
@@ -1938,6 +1950,10 @@
         <td class="website"><a href="https://www.msys2.org/">MSYS2 gcc libs</a></td>
     </tr>
     <tr>
+        <td class="package">msys2-glib2</td>
+        <td class="website"><a href="https://www.msys2.org/">MSYS2 glib2</a></td>
+    </tr>
+    <tr>
         <td class="package">msys2-gmp</td>
         <td class="website"><a href="https://www.msys2.org/">MSYS2 gmp</a></td>
     </tr>
@@ -2083,7 +2099,11 @@
     </tr>
     <tr>
         <td class="package">msys2-libxml2</td>
-        <td class="website"><a href="https://www.msys2.org/">MSYS2 libxm2</a></td>
+        <td class="website"><a href="https://www.msys2.org/">MSYS2 libxml2</a></td>
+    </tr>
+    <tr>
+        <td class="package">msys2-libxslt</td>
+        <td class="website"><a href="https://www.msys2.org/">MSYS2 libxslt</a></td>
     </tr>
     <tr>
         <td class="package">msys2-make</td>
@@ -2106,6 +2126,14 @@
         <td class="website"><a href="https://www.msys2.org/">MSYS2 ncurses</a></td>
     </tr>
     <tr>
+        <td class="package">msys2-openssl</td>
+        <td class="website"><a href="https://www.msys2.org/">MSYS2 openssl</a></td>
+    </tr>
+    <tr>
+        <td class="package">msys2-p11-kit</td>
+        <td class="website"><a href="https://www.msys2.org/">MSYS2 p11-kit</a></td>
+    </tr>
+    <tr>
         <td class="package">msys2-pacman-mirrors</td>
         <td class="website"><a href="https://www.msys2.org/">MSYS2 pacman mirrors</a></td>
     </tr>
@@ -2146,6 +2174,10 @@
         <td class="website"><a href="https://www.msys2.org/">MSYS2 wget</a></td>
     </tr>
     <tr>
+        <td class="package">msys2-which</td>
+        <td class="website"><a href="https://www.msys2.org/">MSYS2 which</a></td>
+    </tr>
+    <tr>
         <td class="package">msys2-zip</td>
         <td class="website"><a href="https://www.msys2.org/">MSYS2 zip</a></td>
     </tr>
@@ -2450,6 +2482,10 @@
         <td class="website"><a href="http://www.openexr.com/">OpenEXR</a></td>
     </tr>
     <tr>
+        <td class="package">openjpeg</td>
+        <td class="website"><a href="https://www.openjpeg.org/">OpenJPEG</a></td>
+    </tr>
+    <tr>
         <td class="package">openscenegraph</td>
         <td class="website"><a href="http://www.openscenegraph.org/">OpenSceneGraph</a></td>
     </tr>
@@ -2458,6 +2494,14 @@
         <td class="website"><a href="http://www.openssl.org/">openssl</a></td>
     </tr>
     <tr>
+        <td class="package">opkg-biosig</td>
+        <td class="website"><a href="https://biosig.sourceforge.io/">Biosig Octave Package</a></td>
+    </tr>
+    <tr>
+        <td class="package">opus</td>
+        <td class="website"><a href="https://opus-codec.org/">opus</a></td>
+    </tr>
+    <tr>
         <td class="package">mesa</td>
         <td class="website"><a href="http://www.mesa3d.org/osmesa.html">Mesa</a></td>
     </tr>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/installer-files/cmdshell-no-short-path.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,28 @@
+# HG changeset patch
+# User Markus Mützel <markus.muetzel@gmx.de>
+# Date 1612087592 -3600
+#      Sun Jan 31 11:06:32 2021 +0100
+# Node ID f08191da8e416c32d950679a78fe194e2753372e
+# Parent  fea266f67443b890a67f80336aee03c40d3a1faa
+Don't use short paths (bug #59923).
+
+diff -r fea266f67443 -r f08191da8e41 cmdshell.bat
+--- a/cmdshell.bat	Sun Jan 31 10:59:32 2021 +0100
++++ b/cmdshell.bat	Sun Jan 31 11:06:32 2021 +0100
+@@ -2,16 +2,11 @@
+ 
+ set OCTAVE_HOME=%~dp0
+ Rem NOTE: OCTAVE_HOME has a end \
+-Rem convert to 8.3 format
+-for %%I in ("%OCTAVE_HOME%") do set OCTAVE_HOME=%%~sI
+ 
+ Rem set home if not already set
+ if "%HOME%"=="" set HOME=%USERPROFILE%
+ if "%HOME%"=="" set HOME=%HOMEDRIVE%%HOMEPATH%
+ 
+-Rem set HOME to 8.3 format
+-for %%I in ("%HOME%") do set HOME=%%~sI
+-
+ set MSYSDIR=%OCTAVE_HOME%
+ set MSYSTEM=MSYS
+ 
--- a/installer-files/cmdshell.bat	Wed Nov 24 18:31:48 2021 +0100
+++ b/installer-files/cmdshell.bat	Tue Nov 30 19:01:07 2021 +0100
@@ -16,14 +16,14 @@
 set MSYSTEM=MSYS
 
 Rem if no msys-1.0, must be msys2
-if NOT EXIST %OCTAVE_HOME%bin\msys-1.0.dll set MSYSDIR=%OCTAVE_HOME%usr
+if NOT EXIST "%OCTAVE_HOME%bin\msys-1.0.dll" set MSYSDIR=%OCTAVE_HOME%usr
 
 Rem 32 or 64 bit
-if EXIST %OCTAVE_HOME%mingw32\bin\octave-cli.exe set MSYSTEM=MINGW32
-if EXIST %OCTAVE_HOME%mingw64\bin\octave-cli.exe set MSYSTEM=MINGW64
+if EXIST "%OCTAVE_HOME%mingw32\bin\octave-cli.exe" set MSYSTEM=MINGW32
+if EXIST "%OCTAVE_HOME%mingw64\bin\octave-cli.exe" set MSYSTEM=MINGW64
 
-if EXIST %OCTAVE_HOME%mingw32\bin\octave-cli.exe set OCTAVE_HOME=%OCTAVE_HOME%mingw32\
-if EXIST %OCTAVE_HOME%mingw64\bin\octave-cli.exe set OCTAVE_HOME=%OCTAVE_HOME%mingw64\
+if EXIST "%OCTAVE_HOME%mingw32\bin\octave-cli.exe" set OCTAVE_HOME=%OCTAVE_HOME%mingw32\
+if EXIST "%OCTAVE_HOME%mingw64\bin\octave-cli.exe" set OCTAVE_HOME=%OCTAVE_HOME%mingw64\
 
 Rem   Set up PATH. Make sure the octave bin dir
 Rem   comes first.
@@ -35,5 +35,5 @@
 Rem tell msys2 to use the paths we set here which matches what octave would do
 set MSYS2_PATH_TYPE=inherit
 
-%MSYSDIR%\bin\bash.exe --login -i
+"%MSYSDIR%\bin\bash.exe" --login -i
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/installer-files/octave-bat-no-short-path.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,30 @@
+# HG changeset patch
+# User Markus Mützel <markus.muetzel@gmx.de>
+# Date 1612087592 -3600
+#      Sun Jan 31 11:06:32 2021 +0100
+# Node ID f08191da8e416c32d950679a78fe194e2753372e
+# Parent  fea266f67443b890a67f80336aee03c40d3a1faa
+Don't use short paths (bug #59923).
+
+diff -r fea266f67443 -r f08191da8e41 octave.bat
+--- a/octave.bat	Sun Jan 31 10:59:32 2021 +0100
++++ b/octave.bat	Sun Jan 31 11:06:32 2021 +0100
+@@ -8,9 +8,6 @@
+ Rem   Note: the result ends with a backslash.
+ set OCT_HOME=%~dp0\.\..\
+ set ROOT_PATH=%~dp0\.\..\..\
+-Rem Convert to 8.3 format so we don't have to worry about spaces.
+-for %%I in ("%OCT_HOME%") do set OCT_HOME=%%~sI
+-for %%I in ("%ROOT_PATH%") do set ROOT_PATH=%%~sI
+ 
+ set MSYSTEM=MSYS
+ set MSYSPATH=%OCT_HOME%
+@@ -44,8 +41,6 @@
+ Rem set home if not already set
+ if "%HOME%"=="" set HOME=%USERPROFILE%
+ if "%HOME%"=="" set HOME=%HOMEDRIVE%%HOMEPATH%
+-Rem set HOME to 8.3 format
+-for %%I in ("%HOME%") do set HOME=%%~sI
+ 
+ Rem   Check for args to determine if GUI (--gui, --force-gui)
+ Rem   or CLI (--no-gui) should be started.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/installer-files/octave-launch.c	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,386 @@
+/*
+ * Wrapper application to set octave env variables and then run octave
+ *
+ * Copyright (C) 2020-2021 John Donoghue <john.donoghue@ieee.org>
+ *
+ * This program 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 (at your option) any later
+ * version.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, see <http: *www.gnu.org/licenses/>.
+*/
+
+#include <windows.h>
+#include <shlwapi.h>
+#include <strsafe.h>
+
+static int ParentDir (wchar_t *dir)
+{
+  int len = lstrlenW (dir);
+  while (len > 0 && dir[len] != L'\\')
+    len --;
+  dir[len] = 0;
+  return len;
+}
+
+static wchar_t * FilePart (wchar_t *dir)
+{
+  int len = lstrlenW (dir);
+  while (len > 0 && dir[len-1] != L'\\')
+    len --;
+  return &dir[len];
+}
+
+static size_t get_num_physical_cores (void)
+{
+  DWORD length;
+  char *lpi;
+  BOOL res;
+  size_t num_physical_cores;
+  size_t offset;
+
+  length = 0;
+  GetLogicalProcessorInformationEx (RelationProcessorCore, NULL, &length);
+  if (GetLastError () != ERROR_INSUFFICIENT_BUFFER)
+    return 0;
+
+  lpi = malloc (length);
+  res = GetLogicalProcessorInformationEx
+          (RelationProcessorCore,
+           (PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX) lpi,
+           &length);
+  if (! res)
+    {
+      free (lpi);
+      return 0;
+    }
+
+  num_physical_cores = 0;
+  offset = 0;
+  do
+    {
+      const PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX cur_lpi =
+        (PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX) (lpi + offset);
+      offset += cur_lpi->Size;
+      num_physical_cores++;
+    }
+  while (offset < length);
+
+  free (lpi);
+
+  return num_physical_cores;
+}
+
+// Set up environment and launch octave.exe with appropriate
+// arguments.  NOTE: There are corresponding VBS and BAT script
+// versions of this program so any changes here may need to be made in
+// those scripts as well.
+
+int wmain (int argc, wchar_t **argv)
+{
+  PROCESS_INFORMATION pi;
+
+  // FIXME: There are currently have no checks to ensure that the
+  // following fixed-size buffers are sufficiently large.  MAX_PATH is
+  // 260 on Winndows by default.  But a user might have increased that
+  // limit to 32767 characters by manually changing policy settings.
+  // Maybe it would be better if we used C++ and std::string objects?
+  // Note that the use of sizeof(path)-1 will fail if we switch to
+  // using
+  //
+  //   wchar_t *path = (wchar_t *) malloc (...);
+  //
+  // instead of literal character arrays.
+
+#define PATH_SZ 1024
+  wchar_t msyspath[PATH_SZ];
+  wchar_t rootpath[PATH_SZ];
+  wchar_t path[PATH_SZ];
+  wchar_t binpath[PATH_SZ];
+
+  int gui_arg_found = 0;
+  int no_gui_arg_found = 0;
+  int no_gui_libs = 0;
+  int i;
+
+  /* get path of us which we will assume is the root of the install */
+
+  DWORD nSize = GetModuleFileNameW (NULL, path, PATH_SZ-1);
+  if (nSize)
+    {
+      while (nSize > 0 && path[nSize] != L'\\')
+        nSize --;
+      path[nSize] = L'\0';
+    }
+
+#ifdef NO_SHORT_PATH_NAMES
+  StringCchCopyW (rootpath, PATH_SZ, path);
+#else
+  /* transform to short paths to work around issues with spaces in
+     paths */
+  /* FIXME: This won't help on systems with de-activated short paths */
+  nSize = GetShortPathNameW (path, rootpath, PATH_SZ-1);
+  if (nSize == 0)
+    StringCchCopyW (rootpath, PATH_SZ, path);
+#endif
+
+  SetEnvironmentVariableW (L"MXE_ROOT", rootpath);
+
+  /* get msys path and set env */
+
+  StringCchCopyW (msyspath, PATH_SZ, rootpath);
+
+  StringCchCopyW (path, PATH_SZ, rootpath);
+  StringCchCatW (path, PATH_SZ, L"\\mingw64\\bin\\octave.exe");
+  if (PathFileExistsW (path))
+    {
+      SetEnvironmentVariableW (L"MSYSTEM", L"MINGW64");
+      StringCchCatW (msyspath, PATH_SZ, L"\\usr");
+      SetEnvironmentVariableW (L"MSYSPATH", msyspath);
+
+      StringCchCatW (msyspath, PATH_SZ, L"\\bin");
+
+      StringCchCopyW (binpath, PATH_SZ, rootpath);
+      StringCchCatW (binpath, PATH_SZ, L"\\mingw64\\bin");
+    }
+  else
+    {
+      StringCchCopyW (path, PATH_SZ, rootpath);
+      StringCchCatW (path, PATH_SZ, L"\\mingw32\\bin\\octave.exe");
+      if (PathFileExistsW (path))
+        {
+          SetEnvironmentVariableW (L"MSYSTEM", L"MINGW32");
+          StringCchCatW (msyspath, PATH_SZ, L"\\usr");
+          SetEnvironmentVariableW (L"MSYSPATH", msyspath);
+
+          StringCchCatW (msyspath, PATH_SZ, L"\\bin");
+
+          StringCchCopyW (binpath, PATH_SZ, rootpath);
+          StringCchCatW (binpath, PATH_SZ, L"\\mingw32\\bin");
+        }
+      else
+        {
+          SetEnvironmentVariableW (L"MSYSTEM", L"MSYS");
+          SetEnvironmentVariableW (L"MSYSPATH", msyspath);
+
+          StringCchCatW (msyspath, PATH_SZ, L"\\bin");
+
+          StringCchCopyW (binpath, PATH_SZ, rootpath);
+          StringCchCatW (binpath, PATH_SZ, L"\\bin");
+        }
+    }
+
+  /* binpath is to the octave bin dir so get the parent */
+  StringCchCopyW (path, PATH_SZ, binpath);
+  ParentDir (path);
+
+#ifdef SHOW_PATHS
+  MessageBoxW (NULL, rootpath, L"octroot", MB_OK);
+  MessageBoxW (NULL, path, L"octhome", MB_OK);
+  MessageBoxW (NULL, binpath, L"octbin", MB_OK);
+  MessageBoxW (NULL, msyspath, L"msysbin", MB_OK);
+#endif
+
+  /* qt paths
+   * either %OCT_HOME%\qt5\plugins
+   * or %OCT_HOME\plugins
+   */
+  nSize = lstrlenW (path);
+  StringCchCatW (path, PATH_SZ, L"\\qt5\\plugins");
+  SetEnvironmentVariableW (L"QT_PLUGIN_PATH", path);
+
+  path[nSize] = L'\0';
+
+  /* exe paths */
+  {
+#define PATHBUF_SZ 8096
+    wchar_t pathbuffer[PATHBUF_SZ];
+    wchar_t newpathbuffer[PATHBUF_SZ];
+
+    nSize = GetEnvironmentVariableW (L"PATH", pathbuffer, PATHBUF_SZ-1);
+    pathbuffer[nSize] = '\0';
+
+    /* set our paths first */
+    StringCchCopyW (newpathbuffer, PATHBUF_SZ, binpath);
+    StringCchCatW (newpathbuffer, PATHBUF_SZ, L";");
+    StringCchCatW (newpathbuffer, PATHBUF_SZ, msyspath);
+    StringCchCatW (newpathbuffer, PATHBUF_SZ, L";");
+    StringCchCatW (newpathbuffer, PATHBUF_SZ, pathbuffer);
+
+    SetEnvironmentVariableW (L"PATH", newpathbuffer);
+  }
+
+  /* other env */
+  SetEnvironmentVariableW (L"TERM", L"cygwin");
+  SetEnvironmentVariableW (L"GNUTERM", L"wxt");
+  SetEnvironmentVariableW (L"GS", L"gs.exe");
+
+  /* home set */
+  nSize = GetEnvironmentVariableW (L"HOME", path, PATH_SZ-1);
+  if (nSize == 0 || path[0] == 0)
+    {
+      wchar_t newhome[PATH_SZ];
+
+      nSize = GetEnvironmentVariableW (L"USERPROFILE", path, PATH_SZ-1);
+      if (nSize == 0 || path[0] == 0)
+        {
+          /* build dir from drive and path */
+          wchar_t tmpbuff[PATH_SZ];
+          nSize = GetEnvironmentVariableW (L"HOMEDRIVE", tmpbuff, PATH_SZ-1);
+          if (nSize)
+            StringCchCopyW (path, PATH_SZ, tmpbuff);
+          else
+            path[0] = '\0';
+
+          nSize = GetEnvironmentVariableW (L"HOMEPATH", tmpbuff, PATH_SZ-1);
+          if (nSize)
+            StringCchCopyW (path, PATH_SZ, tmpbuff);
+        }
+
+#ifdef NO_SHORT_PATH_NAMES
+      StringCchCopyW (newhome, PATH_SZ, path);
+#else
+      /* transform to short paths to work around issues with spaces in
+         paths */
+      /* FIXME: This won't help on systems with de-activated short
+         paths */
+      nSize = GetShortPathNameW (path, newhome, PATH_SZ-1);
+
+      if (nSize == 0)
+        StringCchCopyW (newhome, PATH_SZ, path);
+#endif
+
+      SetEnvironmentVariableW (L"HOME", newhome);
+    }
+
+  /* set number of OpenBLAS threads */
+  nSize = GetEnvironmentVariableW (L"OPENBLAS_NUM_THREADS", NULL, 0);
+  if (nSize == 0)
+    {
+      /* Only set if it wasn't already set in the environment */
+      size_t num_threads;
+      num_threads = get_num_physical_cores ();
+
+      if (num_threads > 0)
+        {
+#define THREADS_SZ 64
+          wchar_t buffer[THREADS_SZ];
+          StringCchPrintfW (buffer, THREADS_SZ, L"%zu", num_threads);
+          SetEnvironmentVariableW (L"OPENBLAS_NUM_THREADS", buffer);
+        }
+    }
+
+  /* check for gui mode */
+  for (i = 1; i < argc; i++)
+    {
+      if (StrCmpW (argv[i], L"--no-gui-libs") == 0)
+        {
+          if (gui_arg_found)
+            {
+              /* Inconsistent options.  We can't start the GUI without gui libs.
+                 How should we fail?   For now, --no-gui-libs will
+                 override the other options.  */
+            }
+
+          no_gui_libs = 1;
+        }
+      else if (StrCmpW (argv[i], L"--gui") == 0
+               || StrCmpW (argv[i], L"--force-gui") == 0)
+        {
+          if (no_gui_libs)
+            {
+              /* Inconsistent options.  We can't start the GUI without gui libs.
+                 How should we fail?   For now, --no-gui-libs will
+                 override the other options.  */
+            }
+
+          gui_arg_found = 1;
+        }
+      else if (StrCmpW (argv[i], L"--no-gui") == 0)
+        no_gui_arg_found = 1;
+
+      /* NOTE: specifying both --no-gui and --gui is also an
+         inconsistent set of options but we leave it to octave.exe to
+         detect that.  */
+    }
+
+#ifdef FIRST_TIME
+  {
+    /* change directory to USERPROFILE before starting Octave */
+    wchar_t tmpbuff[PATH_SZ];
+    nSize = GetEnvironmentVariableW (L"USERPROFILE", tmpbuff, PATH_SZ-1);
+    if (nSize)
+      StringCchCopyW (path, PATH_SZ, tmpbuff);
+
+    SetCurrentDirectoryW (path);
+  }
+#endif
+
+  /* set up process args and start it */
+  {
+    STARTUPINFO si;
+#define ARGBUF_SZ 4096
+    wchar_t argbuffer[ARGBUF_SZ];
+
+    ZeroMemory (&si, sizeof (si));
+    si.cb = sizeof (si);
+    ZeroMemory (&pi, sizeof (pi));
+
+    StringCchCopyW (path, PATH_SZ, binpath);
+
+    StringCchCopyW (argbuffer, ARGBUF_SZ, L"octave.exe ");
+    StringCchCatW (path, PATH_SZ, L"\\octave.exe");
+
+    if (! (no_gui_libs || no_gui_arg_found))
+      {
+        /* Unless --no-gui or --no-gui-libs is specified, we will use a GUI window.  */
+        si.dwFlags = STARTF_USESHOWWINDOW;
+
+        /* If none of the options --no-gui, --gui, or --force-gui
+           were specified, then we'll add --gui to start the gui as
+           most Windows users would expect.  */
+
+        if (! gui_arg_found)
+          StringCchCatW (argbuffer, ARGBUF_SZ, L"--gui ");
+      }
+
+    /* quote and append each arg */
+    for (i = 1; i < argc; i++)
+      {
+        StringCchCatW (argbuffer, ARGBUF_SZ, L"\"");
+        StringCchCatW (argbuffer, ARGBUF_SZ, argv[i]);
+        StringCchCatW (argbuffer, ARGBUF_SZ, L"\" ");
+      }
+
+    /* Start the child process */
+    int status = CreateProcessW (path,      // Module name
+                                 argbuffer, // Command line
+                                 NULL,      // Process handle not inheritable
+                                 NULL,      // Thread handle not inheritable
+                                 FALSE,     // Set handle inheritance to FALSE
+                                 0,         // No creation flags
+                                 NULL,      // Use parent's environment block
+                                 NULL,      // Use parent's starting directory
+                                 &si,       // Pointer to STARTUPINFO
+                                 &pi);      // Pointer to PROCESS_INFORMATION
+
+    if (! status)
+      return 1;
+  }
+
+  /* Wait until child process exits. */
+  WaitForSingleObject (pi.hProcess, INFINITE);
+
+  /* Close process and thread handles */
+  CloseHandle (pi.hProcess);
+  CloseHandle (pi.hThread);
+
+  return 0;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/installer-files/octave-launch.rc	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,27 @@
+#include "winver.h"
+
+VS_VERSION_INFO VERSIONINFO
+FILEVERSION     1,0,0,0
+PRODUCTVERSION  1,0,0,0
+BEGIN
+  BLOCK "StringFileInfo"
+  BEGIN
+    BLOCK "040904B0"  // US-English, Unicode
+    BEGIN
+      VALUE "CompanyName", "GNU Octave"
+      VALUE "FileDescription", "GNU Octave Launcher"
+      VALUE "FileVersion", "1.0"
+      VALUE "InternalName", "octave-launcher.exe"
+      VALUE "LegalCopyright", " Copyright (C) 2021 The Octave Project Developers"
+      VALUE "OriginalFilename", "octave-launcher.exe"
+      VALUE "ProductName", "GNU Octave Launcher"
+      VALUE "ProductVersion", "1.0"
+    END
+  END
+  BLOCK "VarFileInfo"
+  BEGIN
+    VALUE "Translation", 0x0409, 0x04B0  // US-English, Unicode
+  END
+END
+
+11 ICON "octave-logo.ico"
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/installer-files/octave-no-short-path.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,70 @@
+# HG changeset patch
+# User Markus Mützel <markus.muetzel@gmx.de>
+# Date 1612087592 -3600
+#      Sun Jan 31 11:06:32 2021 +0100
+# Node ID f08191da8e416c32d950679a78fe194e2753372e
+# Parent  fea266f67443b890a67f80336aee03c40d3a1faa
+Don't use short paths (bug #59923).
+
+diff -r fea266f67443 -r f08191da8e41 octave-firsttime.vbs
+--- a/octave-firsttime.vbs	Sun Jan 31 10:59:32 2021 +0100
++++ b/octave-firsttime.vbs	Sun Jan 31 11:06:32 2021 +0100
+@@ -21,11 +21,6 @@
+   OctavePath = OctavePath & "\mingw32" 
+ End If
+ 
+-' get path as a 8.3 path
+-Set fo = fso.GetFolder(OctavePath)
+-OctavePath = fo.ShortPath
+-Set fo = Nothing
+-
+ ' set up path to ensure octave bin comes first
+ Set wshSystemEnv = wshShell.Environment( "PROCESS" )
+ if OctavePath <> MSysPath Then
+@@ -42,9 +37,6 @@
+ 
+ If wshShell.ExpandEnvironmentStrings("%HOME%") = "%HOME%" Then
+   Home = wshSystemEnv("USERPROFILE")
+-  Set fo = fso.GetFolder(Home)
+-  wshSystemEnv("HOME") = fo.ShortPath
+-  Set fo = Nothing
+ End If
+ 
+ ' set Qt plugin directory and path 
+diff -r fea266f67443 -r f08191da8e41 octave.vbs
+--- a/octave.vbs	Sun Jan 31 10:59:32 2021 +0100
++++ b/octave.vbs	Sun Jan 31 11:06:32 2021 +0100
+@@ -21,11 +21,6 @@
+   OctavePath = OctavePath & "\mingw32" 
+ End If
+ 
+-' get path as a 8.3 path
+-Set fo = fso.GetFolder(OctavePath)
+-OctavePath = fo.ShortPath
+-Set fo = Nothing
+-
+ ' set up path to ensure octave bin comes first
+ Set wshSystemEnv = wshShell.Environment( "PROCESS" )
+ if OctavePath <> MSysPath Then
+@@ -43,9 +38,6 @@
+ 
+ If wshShell.ExpandEnvironmentStrings("%HOME%") = "%HOME%" Then
+   Home = wshSystemEnv("USERPROFILE")
+-  Set fo = fso.GetFolder(Home)
+-  wshSystemEnv("HOME") = fo.ShortPath
+-  Set fo = Nothing
+ End If
+ 
+ ' set Qt plugin directory and path 
+diff -r fea266f67443 -r 64ff1a717a28 post-install.bat
+--- a/post-install.bat	Sun Jan 31 10:59:32 2021 +0100
++++ b/post-install.bat	Sun Jan 31 11:16:33 2021 +0100
+@@ -1,8 +1,6 @@
+ @echo off
+ Rem   Run on initial install /update
+ set ROOT_DIR=%~dp0
+-Rem Convert to 8.3 format so we don't have to worry about spaces.
+-for %%I in ("%ROOT_DIR%") do set ROOT_DIR=%%~sI
+ 
+ set MSYSDIR=%ROOT_DIR%
+ set MSYSTEM=MSYS
--- a/installer-files/post-install.bat	Wed Nov 24 18:31:48 2021 +0100
+++ b/installer-files/post-install.bat	Tue Nov 30 19:01:07 2021 +0100
@@ -7,9 +7,9 @@
 set MSYSDIR=%ROOT_DIR%
 set MSYSTEM=MSYS
 
-if NOT EXIST %ROOT_DIR%\bin\msys-1.0.dll set MSYSDIR=%ROOT_DIR%\usr
-if EXIST %ROOT_DIR%\mingw32\bin\octave.bat set MSYSTEM=MINGW32
-if EXIST %ROOT_DIR%\mingw64\bin\octave.bat set MSYSTEM=MINGW64
+if NOT EXIST "%ROOT_DIR%\bin\msys-1.0.dll" set MSYSDIR=%ROOT_DIR%\usr
+if EXIST "%ROOT_DIR%\mingw32\bin\octave.bat" set MSYSTEM=MINGW32
+if EXIST "%ROOT_DIR%\mingw64\bin\octave.bat" set MSYSTEM=MINGW64
 
 if %MSYSTEM%==MSYS (
  set OCTAVE_HOME=%ROOT_DIR%
@@ -29,15 +29,15 @@
 
 Rem Create qt.conf
 set QT_CONF=%OCTAVE_HOME%\bin\qt.conf
-echo [Paths] > %QT_CONF%
-echo Prefix=%OCTAVE_HOME:\=/% >> %QT_CONF%
-echo Documentation=%QT_SUBDIR%doc >> %QT_CONF%
-echo Headers=%QT_SUBDIR%include >> %QT_CONF%
-echo Libraries=%QT_SUBDIR%libs >> %QT_CONF%
-echo Plugins=%QT_SUBDIR%plugins >> %QT_CONF%
-echo Translations=%QT_SUBDIR%translations >> %QT_CONF%
+echo [Paths] > "%QT_CONF%"
+echo Prefix="%OCTAVE_HOME:\=/%" >> "%QT_CONF%"
+echo Documentation=%QT_SUBDIR%doc >> "%QT_CONF%"
+echo Headers=%QT_SUBDIR%include >> "%QT_CONF%"
+echo Libraries=%QT_SUBDIR%libs >> "%QT_CONF%"
+echo Plugins=%QT_SUBDIR%plugins >> "%QT_CONF%"
+echo Translations=%QT_SUBDIR%translations >> "%QT_CONF%"
 
-Rem run bash to to regitser the initial envorinment
+Rem Run bash to register the initial environment
 echo "Setting up MSYS system ..."
 "%MSYSDIR%\bin\bash.exe" --login -c echo
 echo "Updating fc-cache (may take a while) ..."
--- a/src/agg.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/agg.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -11,9 +11,8 @@
 $(PKG)_DEPS     := freetype sdl
 
 define $(PKG)_UPDATE
-    $(WGET) -q -O- 'https://web.archive.org/20150812005010/http://www.antigrain.com/download/index.html' | \
-    $(SED) -n 's,.*www.antigrain.com/agg-\([0-9.]*\).tar.gz".*,\1,p' | \
-    head -1
+    echo 'Warning: Updates are disabled for package $(PKG).' >&2;
+    echo $($(PKG)_VERSION)
 endef
 
 define $(PKG)_BUILD
--- a/src/arpack-1-gcc10.patch	Wed Nov 24 18:31:48 2021 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4438 +0,0 @@
-From 9418632214acf6d387896ab29a8f5bdff2d4e38a Mon Sep 17 00:00:00 2001
-From: =?UTF-8?q?David=20Schw=C3=B6rer?= <davidsch@fedoraproject.org>
-Date: Wed, 19 Feb 2020 20:07:47 +0000
-Subject: [PATCH] ?vout expects a vector, so make sure to pass a vector
-
-gcc10 throws an error otherwise
-
-diff --git a/SRC/cgetv0.f b/SRC/cgetv0.f
-index 322b35c7..a91ef926 100644
---- a/SRC/cgetv0.f
-+++ b/SRC/cgetv0.f
-@@ -361,9 +361,9 @@ subroutine cgetv0
- c     %--------------------------------------%
- c
-       if (msglvl .gt. 2) then
--          call svout (logfil, 1, rnorm0, ndigit,
-+          call svout (logfil, 1, [rnorm0], ndigit,
-      &                '_getv0: re-orthonalization ; rnorm0 is')
--          call svout (logfil, 1, rnorm, ndigit,
-+          call svout (logfil, 1, [rnorm], ndigit,
-      &                '_getv0: re-orthonalization ; rnorm is')
-       end if
- c
-@@ -394,7 +394,7 @@ subroutine cgetv0
-    50 continue
- c
-       if (msglvl .gt. 0) then
--         call svout (logfil, 1, rnorm, ndigit,
-+         call svout (logfil, 1, [rnorm], ndigit,
-      &        '_getv0: B-norm of initial / restarted starting vector')
-       end if
-       if (msglvl .gt. 2) then
-diff --git a/SRC/cnaitr.f b/SRC/cnaitr.f
-index 2bb93fff..bebd8236 100644
---- a/SRC/cnaitr.f
-+++ b/SRC/cnaitr.f
-@@ -378,9 +378,9 @@ subroutine cnaitr
-  1000 continue
- c
-          if (msglvl .gt. 1) then
--            call ivout (logfil, 1, j, ndigit,
-+            call ivout (logfil, 1, [j], ndigit,
-      &                  '_naitr: generating Arnoldi vector number')
--            call svout (logfil, 1, rnorm, ndigit,
-+            call svout (logfil, 1, [rnorm], ndigit,
-      &                  '_naitr: B-norm of the current residual is')
-          end if
- c
-@@ -400,7 +400,7 @@ subroutine cnaitr
- c           %---------------------------------------------------%
- c
-             if (msglvl .gt. 0) then
--               call ivout (logfil, 1, j, ndigit,
-+               call ivout (logfil, 1, [j], ndigit,
-      &                     '_naitr: ****** RESTART AT STEP ******')
-             end if
- c
-@@ -729,7 +729,7 @@ subroutine cnaitr
-          end if
- c
-          if (msglvl .gt. 0 .and. iter .gt. 0 ) then
--            call ivout (logfil, 1, j, ndigit,
-+            call ivout (logfil, 1, [j], ndigit,
-      &           '_naitr: Iterative refinement for Arnoldi residual')
-             if (msglvl .gt. 2) then
-                 rtemp(1) = rnorm
-diff --git a/SRC/cnapps.f b/SRC/cnapps.f
-index fdf878d8..c3a55623 100644
---- a/SRC/cnapps.f
-+++ b/SRC/cnapps.f
-@@ -268,9 +268,9 @@ subroutine cnapps
-          sigma = shift(jj)
- c
-          if (msglvl .gt. 2 ) then
--            call ivout (logfil, 1, jj, ndigit,
-+            call ivout (logfil, 1, [jj], ndigit,
-      &               '_napps: shift number.')
--            call cvout (logfil, 1, sigma, ndigit,
-+            call cvout (logfil, 1, [sigma], ndigit,
-      &               '_napps: Value of the shift ')
-          end if
- c
-@@ -291,9 +291,9 @@ subroutine cnapps
-             if ( abs(real(h(i+1,i)))
-      &           .le. max(ulp*tst1, smlnum) )  then
-                if (msglvl .gt. 0) then
--                  call ivout (logfil, 1, i, ndigit,
-+                  call ivout (logfil, 1, [i], ndigit,
-      &                 '_napps: matrix splitting at row/column no.')
--                  call ivout (logfil, 1, jj, ndigit,
-+                  call ivout (logfil, 1, [jj], ndigit,
-      &                 '_napps: matrix splitting with shift number.')
-                   call cvout (logfil, 1, h(i+1,i), ndigit,
-      &                 '_napps: off diagonal element.')
-@@ -307,9 +307,9 @@ subroutine cnapps
-    40    continue
- c
-          if (msglvl .gt. 2) then
--             call ivout (logfil, 1, istart, ndigit,
-+             call ivout (logfil, 1, [istart], ndigit,
-      &                   '_napps: Start of current block ')
--             call ivout (logfil, 1, iend, ndigit,
-+             call ivout (logfil, 1, [iend], ndigit,
-      &                   '_napps: End of current block ')
-          end if
- c
-@@ -485,7 +485,7 @@ subroutine cnapps
-      &        '_napps: sigmak = (e_{kev+p}^T*Q)*e_{kev}')
-          call cvout (logfil, 1, h(kev+1,kev), ndigit,
-      &        '_napps: betak = e_{kev+1}^T*H*e_{kev}')
--         call ivout (logfil, 1, kev, ndigit,
-+         call ivout (logfil, 1, [kev], ndigit,
-      &               '_napps: Order of the final Hessenberg matrix ')
-          if (msglvl .gt. 2) then
-             call cmout (logfil, kev, kev, h, ldh, ndigit,
-diff --git a/SRC/cnaup2.f b/SRC/cnaup2.f
-index e528a890..3f106f05 100644
---- a/SRC/cnaup2.f
-+++ b/SRC/cnaup2.f
-@@ -389,7 +389,7 @@ subroutine cnaup2
-          iter = iter + 1
- c
-          if (msglvl .gt. 0) then
--            call ivout (logfil, 1, iter, ndigit,
-+            call ivout (logfil, 1, [iter], ndigit,
-      &           '_naup2: **** Start of major iteration number ****')
-          end if
- c
-@@ -402,9 +402,9 @@ subroutine cnaup2
-          np  = kplusp - nev
- c
-          if (msglvl .gt. 1) then
--            call ivout (logfil, 1, nev, ndigit,
-+            call ivout (logfil, 1, [nev], ndigit,
-      &     '_naup2: The length of the current Arnoldi factorization')
--            call ivout (logfil, 1, np, ndigit,
-+            call ivout (logfil, 1, [np], ndigit,
-      &           '_naup2: Extend the Arnoldi factorization by')
-          end if
- c
-@@ -430,7 +430,7 @@ subroutine cnaup2
-          update = .false.
- c
-          if (msglvl .gt. 1) then
--            call svout (logfil, 1, rnorm, ndigit,
-+            call svout (logfil, 1, [rnorm], ndigit,
-      &           '_naup2: Corresponding B-norm of the residual')
-          end if
- c
-@@ -658,7 +658,7 @@ subroutine cnaup2
-          end if
- c
-          if (msglvl .gt. 0) then
--            call ivout (logfil, 1, nconv, ndigit,
-+            call ivout (logfil, 1, [nconv], ndigit,
-      &           '_naup2: no. of "converged" Ritz values at this iter.')
-             if (msglvl .gt. 1) then
-                kp(1) = nev
-@@ -698,7 +698,7 @@ subroutine cnaup2
-          end if
- c
-          if (msglvl .gt. 2) then
--            call ivout (logfil, 1, np, ndigit,
-+            call ivout (logfil, 1, [np], ndigit,
-      &                  '_naup2: The number of shifts to apply ')
-             call cvout (logfil, np, ritz, ndigit,
-      &                  '_naup2: values of the shifts')
-@@ -762,7 +762,7 @@ subroutine cnaup2
-          cnorm = .false.
- c
-          if (msglvl .gt. 2) then
--            call svout (logfil, 1, rnorm, ndigit,
-+            call svout (logfil, 1, [rnorm], ndigit,
-      &      '_naup2: B-norm of residual for compressed factorization')
-             call cmout (logfil, nev, nev, h, ldh, ndigit,
-      &        '_naup2: Compressed upper Hessenberg matrix H')
-diff --git a/SRC/cnaupd.f b/SRC/cnaupd.f
-index 7bf37fd1..57be328b 100644
---- a/SRC/cnaupd.f
-+++ b/SRC/cnaupd.f
-@@ -601,9 +601,9 @@ subroutine cnaupd
-       if (info .eq. 2) info = 3
- c
-       if (msglvl .gt. 0) then
--         call ivout (logfil, 1, mxiter, ndigit,
-+         call ivout (logfil, 1, [mxiter], ndigit,
-      &               '_naupd: Number of update iterations taken')
--         call ivout (logfil, 1, np, ndigit,
-+         call ivout (logfil, 1, [np], ndigit,
-      &               '_naupd: Number of wanted "converged" Ritz values')
-          call cvout (logfil, np, workl(ritz), ndigit,
-      &               '_naupd: The final Ritz values')
-diff --git a/SRC/cneupd.f b/SRC/cneupd.f
-index c557fa08..34a78f70 100644
---- a/SRC/cneupd.f
-+++ b/SRC/cneupd.f
-@@ -536,9 +536,9 @@ subroutine cneupd(rvec , howmny, select, d     ,
- c        %-----------------------------------------------------------%
- c
-          if (msglvl .gt. 2) then
--             call ivout(logfil, 1, numcnv, ndigit,
-+             call ivout(logfil, 1, [numcnv], ndigit,
-      &            '_neupd: Number of specified eigenvalues')
--             call ivout(logfil, 1, nconv, ndigit,
-+             call ivout(logfil, 1, [nconv], ndigit,
-      &            '_neupd: Number of "converged" eigenvalues')
-          end if
- c
-diff --git a/SRC/cngets.f b/SRC/cngets.f
-index 7686e133..20626a2d 100644
---- a/SRC/cngets.f
-+++ b/SRC/cngets.f
-@@ -161,8 +161,8 @@ subroutine cngets ( ishift, which, kev, np, ritz, bounds)
-       tcgets = tcgets + (t1 - t0)
- c
-       if (msglvl .gt. 0) then
--         call ivout (logfil, 1, kev, ndigit, '_ngets: KEV is')
--         call ivout (logfil, 1, np, ndigit, '_ngets: NP is')
-+         call ivout (logfil, 1, [kev], ndigit, '_ngets: KEV is')
-+         call ivout (logfil, 1, [np], ndigit, '_ngets: NP is')
-          call cvout (logfil, kev+np, ritz, ndigit,
-      &        '_ngets: Eigenvalues of current H matrix ')
-          call cvout (logfil, kev+np, bounds, ndigit,
-diff --git a/SRC/dgetv0.f b/SRC/dgetv0.f
-index fbb4fe2a..1d6dc01b 100644
---- a/SRC/dgetv0.f
-+++ b/SRC/dgetv0.f
-@@ -366,9 +366,9 @@ subroutine dgetv0
- c     %--------------------------------------%
- c
-       if (msglvl .gt. 2) then
--          call dvout (logfil, 1, rnorm0, ndigit,
-+          call dvout (logfil, 1, [rnorm0], ndigit,
-      &                '_getv0: re-orthonalization ; rnorm0 is')
--          call dvout (logfil, 1, rnorm, ndigit,
-+          call dvout (logfil, 1, [rnorm], ndigit,
-      &                '_getv0: re-orthonalization ; rnorm is')
-       end if
- c
-@@ -399,7 +399,7 @@ subroutine dgetv0
-    50 continue
- c
-       if (msglvl .gt. 0) then
--         call dvout (logfil, 1, rnorm, ndigit,
-+         call dvout (logfil, 1, [rnorm], ndigit,
-      &        '_getv0: B-norm of initial / restarted starting vector')
-       end if
-       if (msglvl .gt. 3) then
-diff --git a/SRC/dnaitr.f b/SRC/dnaitr.f
-index baaec038..c02cd390 100644
---- a/SRC/dnaitr.f
-+++ b/SRC/dnaitr.f
-@@ -371,9 +371,9 @@ subroutine dnaitr
-  1000 continue
- c
-          if (msglvl .gt. 1) then
--            call ivout (logfil, 1, j, ndigit,
-+            call ivout (logfil, 1, [j], ndigit,
-      &                  '_naitr: generating Arnoldi vector number')
--            call dvout (logfil, 1, rnorm, ndigit,
-+            call dvout (logfil, 1, [rnorm], ndigit,
-      &                  '_naitr: B-norm of the current residual is')
-          end if
- c
-@@ -393,7 +393,7 @@ subroutine dnaitr
- c           %---------------------------------------------------%
- c
-             if (msglvl .gt. 0) then
--               call ivout (logfil, 1, j, ndigit,
-+               call ivout (logfil, 1, [j], ndigit,
-      &                     '_naitr: ****** RESTART AT STEP ******')
-             end if
- c
-@@ -721,7 +721,7 @@ subroutine dnaitr
-          end if
- c
-          if (msglvl .gt. 0 .and. iter .gt. 0) then
--            call ivout (logfil, 1, j, ndigit,
-+            call ivout (logfil, 1, [j], ndigit,
-      &           '_naitr: Iterative refinement for Arnoldi residual')
-             if (msglvl .gt. 2) then
-                 xtemp(1) = rnorm
-diff --git a/SRC/dnapps.f b/SRC/dnapps.f
-index 872d35ae..7fb37d87 100644
---- a/SRC/dnapps.f
-+++ b/SRC/dnapps.f
-@@ -266,11 +266,11 @@ subroutine dnapps
-          sigmai = shifti(jj)
- c
-          if (msglvl .gt. 2 ) then
--            call ivout (logfil, 1, jj, ndigit,
-+            call ivout (logfil, 1, [jj], ndigit,
-      &               '_napps: shift number.')
--            call dvout (logfil, 1, sigmar, ndigit,
-+            call dvout (logfil, 1, [sigmar], ndigit,
-      &               '_napps: The real part of the shift ')
--            call dvout (logfil, 1, sigmai, ndigit,
-+            call dvout (logfil, 1, [sigmai], ndigit,
-      &               '_napps: The imaginary part of the shift ')
-          end if
- c
-@@ -335,9 +335,9 @@ subroutine dnapps
-      &         tst1 = dlanhs( '1', kplusp-jj+1, h, ldh, workl )
-             if( abs( h( i+1,i ) ).le.max( ulp*tst1, smlnum ) ) then
-                if (msglvl .gt. 0) then
--                  call ivout (logfil, 1, i, ndigit,
-+                  call ivout (logfil, 1, [i], ndigit,
-      &                 '_napps: matrix splitting at row/column no.')
--                  call ivout (logfil, 1, jj, ndigit,
-+                  call ivout (logfil, 1, [jj], ndigit,
-      &                 '_napps: matrix splitting with shift number.')
-                   call dvout (logfil, 1, h(i+1,i), ndigit,
-      &                 '_napps: off diagonal element.')
-@@ -351,9 +351,9 @@ subroutine dnapps
-    40    continue
- c
-          if (msglvl .gt. 2) then
--             call ivout (logfil, 1, istart, ndigit,
-+             call ivout (logfil, 1, [istart], ndigit,
-      &                   '_napps: Start of current block ')
--             call ivout (logfil, 1, iend, ndigit,
-+             call ivout (logfil, 1, [iend], ndigit,
-      &                   '_napps: End of current block ')
-          end if
- c
-@@ -627,7 +627,7 @@ subroutine dnapps
-      &        '_napps: sigmak = (e_{kev+p}^T*Q)*e_{kev}')
-          call dvout (logfil, 1, h(kev+1,kev), ndigit,
-      &        '_napps: betak = e_{kev+1}^T*H*e_{kev}')
--         call ivout (logfil, 1, kev, ndigit,
-+         call ivout (logfil, 1, [kev], ndigit,
-      &               '_napps: Order of the final Hessenberg matrix ')
-          if (msglvl .gt. 2) then
-             call dmout (logfil, kev, kev, h, ldh, ndigit,
-diff --git a/SRC/dnaup2.f b/SRC/dnaup2.f
-index 4c9948d4..18ad20a0 100644
---- a/SRC/dnaup2.f
-+++ b/SRC/dnaup2.f
-@@ -388,7 +388,7 @@ subroutine dnaup2
-          iter = iter + 1
- c
-          if (msglvl .gt. 0) then
--            call ivout (logfil, 1, iter, ndigit,
-+            call ivout (logfil, 1, [iter], ndigit,
-      &           '_naup2: **** Start of major iteration number ****')
-          end if
- c
-@@ -401,9 +401,9 @@ subroutine dnaup2
-          np  = kplusp - nev
- c
-          if (msglvl .gt. 1) then
--            call ivout (logfil, 1, nev, ndigit,
-+            call ivout (logfil, 1, [nev], ndigit,
-      &     '_naup2: The length of the current Arnoldi factorization')
--            call ivout (logfil, 1, np, ndigit,
-+            call ivout (logfil, 1, [np], ndigit,
-      &           '_naup2: Extend the Arnoldi factorization by')
-          end if
- c
-@@ -435,7 +435,7 @@ subroutine dnaup2
-          update = .false.
- c
-          if (msglvl .gt. 1) then
--            call dvout  (logfil, 1, rnorm, ndigit,
-+            call dvout  (logfil, 1, [rnorm], ndigit,
-      &           '_naup2: Corresponding B-norm of the residual')
-          end if
- c
-@@ -689,7 +689,7 @@ subroutine dnaup2
-          end if
- c
-          if (msglvl .gt. 0) then
--            call ivout (logfil, 1, nconv, ndigit,
-+            call ivout (logfil, 1, [nconv], ndigit,
-      &           '_naup2: no. of "converged" Ritz values at this iter.')
-             if (msglvl .gt. 1) then
-                kp(1) = nev
-@@ -741,7 +741,7 @@ subroutine dnaup2
-          end if
- c
-          if (msglvl .gt. 2) then
--            call ivout (logfil, 1, np, ndigit,
-+            call ivout (logfil, 1, [np], ndigit,
-      &                  '_naup2: The number of shifts to apply ')
-             call dvout  (logfil, np, ritzr, ndigit,
-      &                  '_naup2: Real part of the shifts')
-@@ -807,7 +807,7 @@ subroutine dnaup2
-          cnorm = .false.
- c
-          if (msglvl .gt. 2) then
--            call dvout  (logfil, 1, rnorm, ndigit,
-+            call dvout  (logfil, 1, [rnorm], ndigit,
-      &      '_naup2: B-norm of residual for compressed factorization')
-             call dmout  (logfil, nev, nev, h, ldh, ndigit,
-      &        '_naup2: Compressed upper Hessenberg matrix H')
-diff --git a/SRC/dnaupd.f b/SRC/dnaupd.f
-index 51d3018e..dcf1f77a 100644
---- a/SRC/dnaupd.f
-+++ b/SRC/dnaupd.f
-@@ -628,9 +628,9 @@ subroutine dnaupd
-       if (info .eq. 2) info = 3
- c
-       if (msglvl .gt. 0) then
--         call ivout (logfil, 1, mxiter, ndigit,
-+         call ivout (logfil, 1, [mxiter], ndigit,
-      &               '_naupd: Number of update iterations taken')
--         call ivout (logfil, 1, np, ndigit,
-+         call ivout (logfil, 1, [np], ndigit,
-      &               '_naupd: Number of wanted "converged" Ritz values')
-          call dvout  (logfil, np, workl(ritzr), ndigit,
-      &               '_naupd: Real part of the final Ritz values')
-diff --git a/SRC/dneupd.f b/SRC/dneupd.f
-index 424ad2bf..9c2ece0e 100644
---- a/SRC/dneupd.f
-+++ b/SRC/dneupd.f
-@@ -601,9 +601,9 @@ subroutine dneupd (rvec , howmny, select, dr    , di,
- c        %-----------------------------------------------------------%
- c
-          if (msglvl .gt. 2) then
--             call ivout(logfil, 1, numcnv, ndigit,
-+             call ivout(logfil, 1, [numcnv], ndigit,
-      &            '_neupd: Number of specified eigenvalues')
--             call ivout(logfil, 1, nconv, ndigit,
-+             call ivout(logfil, 1, [nconv], ndigit,
-      &            '_neupd: Number of "converged" eigenvalues')
-          end if
- c
-diff --git a/SRC/dngets.f b/SRC/dngets.f
-index a3145506..47d3ac2c 100644
---- a/SRC/dngets.f
-+++ b/SRC/dngets.f
-@@ -212,8 +212,8 @@ subroutine dngets ( ishift, which, kev, np, ritzr, ritzi, bounds,
-       tngets = tngets + (t1 - t0)
- c
-       if (msglvl .gt. 0) then
--         call ivout (logfil, 1, kev, ndigit, '_ngets: KEV is')
--         call ivout (logfil, 1, np, ndigit, '_ngets: NP is')
-+         call ivout (logfil, 1, [kev], ndigit, '_ngets: KEV is')
-+         call ivout (logfil, 1, [np], ndigit, '_ngets: NP is')
-          call dvout (logfil, kev+np, ritzr, ndigit,
-      &        '_ngets: Eigenvalues of current H matrix -- real part')
-          call dvout (logfil, kev+np, ritzi, ndigit,
-diff --git a/SRC/dsaitr.f b/SRC/dsaitr.f
-index 00dabfd2..3460d990 100644
---- a/SRC/dsaitr.f
-+++ b/SRC/dsaitr.f
-@@ -364,9 +364,9 @@ subroutine dsaitr
-  1000 continue
- c
-          if (msglvl .gt. 2) then
--            call ivout (logfil, 1, j, ndigit,
-+            call ivout (logfil, 1, [j], ndigit,
-      &                  '_saitr: generating Arnoldi vector no.')
--            call dvout (logfil, 1, rnorm, ndigit,
-+            call dvout (logfil, 1, [rnorm], ndigit,
-      &                  '_saitr: B-norm of the current residual =')
-          end if
- c
-@@ -384,7 +384,7 @@ subroutine dsaitr
- c           %---------------------------------------------------%
- c
-             if (msglvl .gt. 0) then
--               call ivout (logfil, 1, j, ndigit,
-+               call ivout (logfil, 1, [j], ndigit,
-      &                     '_saitr: ****** restart at step ******')
-             end if
- c
-@@ -735,7 +735,7 @@ subroutine dsaitr
-          end if
- c
-          if (msglvl .gt. 0 .and. iter .gt. 0) then
--            call ivout (logfil, 1, j, ndigit,
-+            call ivout (logfil, 1, [j], ndigit,
-      &           '_saitr: Iterative refinement for Arnoldi residual')
-             if (msglvl .gt. 2) then
-                 xtemp(1) = rnorm
-diff --git a/SRC/dsapps.f b/SRC/dsapps.f
-index 12108d0f..f84ef838 100644
---- a/SRC/dsapps.f
-+++ b/SRC/dsapps.f
-@@ -261,9 +261,9 @@ subroutine dsapps
-             big   = abs(h(i,2)) + abs(h(i+1,2))
-             if (h(i+1,1) .le. epsmch*big) then
-                if (msglvl .gt. 0) then
--                  call ivout (logfil, 1, i, ndigit,
-+                  call ivout (logfil, 1, [i], ndigit,
-      &                 '_sapps: deflation at row/column no.')
--                  call ivout (logfil, 1, jj, ndigit,
-+                  call ivout (logfil, 1, [jj], ndigit,
-      &                 '_sapps: occurred before shift number.')
-                   call dvout (logfil, 1, h(i+1,1), ndigit,
-      &                 '_sapps: the corresponding off diagonal element')
-@@ -432,7 +432,7 @@ subroutine dsapps
-          big   = abs(h(i,2)) + abs(h(i+1,2))
-          if (h(i+1,1) .le. epsmch*big) then
-             if (msglvl .gt. 0) then
--               call ivout (logfil, 1, i, ndigit,
-+               call ivout (logfil, 1, [i], ndigit,
-      &              '_sapps: deflation at row/column no.')
-                call dvout (logfil, 1, h(i+1,1), ndigit,
-      &              '_sapps: the corresponding off diagonal element')
-diff --git a/SRC/dsaup2.f b/SRC/dsaup2.f
-index f4c5f90c..f7d4a119 100644
---- a/SRC/dsaup2.f
-+++ b/SRC/dsaup2.f
-@@ -402,13 +402,13 @@ subroutine dsaup2
-          iter = iter + 1
- c
-          if (msglvl .gt. 0) then
--            call ivout (logfil, 1, iter, ndigit,
-+            call ivout (logfil, 1, [iter], ndigit,
-      &           '_saup2: **** Start of major iteration number ****')
-          end if
-          if (msglvl .gt. 1) then
--            call ivout (logfil, 1, nev, ndigit,
-+            call ivout (logfil, 1, [nev], ndigit,
-      &     '_saup2: The length of the current Lanczos factorization')
--            call ivout (logfil, 1, np, ndigit,
-+            call ivout (logfil, 1, [np], ndigit,
-      &           '_saup2: Extend the Lanczos factorization by')
-          end if
- c
-@@ -446,7 +446,7 @@ subroutine dsaup2
-          update = .false.
- c
-          if (msglvl .gt. 1) then
--            call dvout (logfil, 1, rnorm, ndigit,
-+            call dvout (logfil, 1, [rnorm], ndigit,
-      &           '_saup2: Current B-norm of residual for factorization')
-          end if
- c
-@@ -695,7 +695,7 @@ subroutine dsaup2
-          end if
- c
-          if (msglvl .gt. 0) then
--            call ivout (logfil, 1, nconv, ndigit,
-+            call ivout (logfil, 1, [nconv], ndigit,
-      &           '_saup2: no. of "converged" Ritz values at this iter.')
-             if (msglvl .gt. 1) then
-                kp(1) = nev
-@@ -743,7 +743,7 @@ subroutine dsaup2
-          if (ishift .eq. 0) call dcopy (np, workl, 1, ritz, 1)
- c
-          if (msglvl .gt. 2) then
--            call ivout (logfil, 1, np, ndigit,
-+            call ivout (logfil, 1, [np], ndigit,
-      &                  '_saup2: The number of shifts to apply ')
-             call dvout (logfil, np, workl, ndigit,
-      &                  '_saup2: shifts selected')
-@@ -810,7 +810,7 @@ subroutine dsaup2
-   130    continue
- c
-          if (msglvl .gt. 2) then
--            call dvout (logfil, 1, rnorm, ndigit,
-+            call dvout (logfil, 1, [rnorm], ndigit,
-      &      '_saup2: B-norm of residual for NEV factorization')
-             call dvout (logfil, nev, h(1,2), ndigit,
-      &           '_saup2: main diagonal of compressed H matrix')
-diff --git a/SRC/dsaupd.f b/SRC/dsaupd.f
-index bd4afc26..c5b08d6b 100644
---- a/SRC/dsaupd.f
-+++ b/SRC/dsaupd.f
-@@ -628,9 +628,9 @@ subroutine dsaupd
-       if (info .eq. 2) info = 3
- c
-       if (msglvl .gt. 0) then
--         call ivout (logfil, 1, mxiter, ndigit,
-+         call ivout (logfil, 1, [mxiter], ndigit,
-      &               '_saupd: number of update iterations taken')
--         call ivout (logfil, 1, np, ndigit,
-+         call ivout (logfil, 1, [np], ndigit,
-      &               '_saupd: number of "converged" Ritz values')
-          call dvout  (logfil, np, workl(Ritz), ndigit,
-      &               '_saupd: final Ritz values')
-diff --git a/SRC/dseupd.f b/SRC/dseupd.f
-index e89fdccf..ae123a20 100644
---- a/SRC/dseupd.f
-+++ b/SRC/dseupd.f
-@@ -513,9 +513,9 @@ subroutine dseupd (rvec  , howmny, select, d    ,
- c        %-----------------------------------------------------------%
- c
-          if (msglvl .gt. 2) then
--             call ivout(logfil, 1, numcnv, ndigit,
-+             call ivout(logfil, 1, [numcnv], ndigit,
-      &            '_seupd: Number of specified eigenvalues')
--             call ivout(logfil, 1, nconv, ndigit,
-+             call ivout(logfil, 1, [nconv], ndigit,
-      &            '_seupd: Number of "converged" eigenvalues')
-          end if
- c
-diff --git a/SRC/dsgets.f b/SRC/dsgets.f
-index 800a02f4..436a4fe8 100644
---- a/SRC/dsgets.f
-+++ b/SRC/dsgets.f
-@@ -202,8 +202,8 @@ subroutine dsgets ( ishift, which, kev, np, ritz, bounds, shifts )
-       tsgets = tsgets + (t1 - t0)
- c
-       if (msglvl .gt. 0) then
--         call ivout (logfil, 1, kev, ndigit, '_sgets: KEV is')
--         call ivout (logfil, 1, np, ndigit, '_sgets: NP is')
-+         call ivout (logfil, 1, [kev], ndigit, '_sgets: KEV is')
-+         call ivout (logfil, 1, [np], ndigit, '_sgets: NP is')
-          call dvout (logfil, kev+np, ritz, ndigit,
-      &        '_sgets: Eigenvalues of current H matrix')
-          call dvout (logfil, kev+np, bounds, ndigit,
-diff --git a/SRC/sgetv0.f b/SRC/sgetv0.f
-index c768daae..d861b2d6 100644
---- a/SRC/sgetv0.f
-+++ b/SRC/sgetv0.f
-@@ -366,9 +366,9 @@ subroutine sgetv0
- c     %--------------------------------------%
- c
-       if (msglvl .gt. 2) then
--          call svout (logfil, 1, rnorm0, ndigit,
-+          call svout (logfil, 1, [rnorm0], ndigit,
-      &                '_getv0: re-orthonalization ; rnorm0 is')
--          call svout (logfil, 1, rnorm, ndigit,
-+          call svout (logfil, 1, [rnorm], ndigit,
-      &                '_getv0: re-orthonalization ; rnorm is')
-       end if
- c
-@@ -399,7 +399,7 @@ subroutine sgetv0
-    50 continue
- c
-       if (msglvl .gt. 0) then
--         call svout (logfil, 1, rnorm, ndigit,
-+         call svout (logfil, 1, [rnorm], ndigit,
-      &        '_getv0: B-norm of initial / restarted starting vector')
-       end if
-       if (msglvl .gt. 3) then
-diff --git a/SRC/snaitr.f b/SRC/snaitr.f
-index 5ecdebb7..8a5d795b 100644
---- a/SRC/snaitr.f
-+++ b/SRC/snaitr.f
-@@ -371,9 +371,9 @@ subroutine snaitr
-  1000 continue
- c
-          if (msglvl .gt. 1) then
--            call ivout (logfil, 1, j, ndigit,
-+            call ivout (logfil, 1, [j], ndigit,
-      &                  '_naitr: generating Arnoldi vector number')
--            call svout (logfil, 1, rnorm, ndigit,
-+            call svout (logfil, 1, [rnorm], ndigit,
-      &                  '_naitr: B-norm of the current residual is')
-          end if
- c
-@@ -393,7 +393,7 @@ subroutine snaitr
- c           %---------------------------------------------------%
- c
-             if (msglvl .gt. 0) then
--               call ivout (logfil, 1, j, ndigit,
-+               call ivout (logfil, 1, [j], ndigit,
-      &                     '_naitr: ****** RESTART AT STEP ******')
-             end if
- c
-@@ -721,7 +721,7 @@ subroutine snaitr
-          end if
- c
-          if (msglvl .gt. 0 .and. iter .gt. 0) then
--            call ivout (logfil, 1, j, ndigit,
-+            call ivout (logfil, 1, [j], ndigit,
-      &           '_naitr: Iterative refinement for Arnoldi residual')
-             if (msglvl .gt. 2) then
-                 xtemp(1) = rnorm
-diff --git a/SRC/snapps.f b/SRC/snapps.f
-index 914c9b8b..9b767285 100644
---- a/SRC/snapps.f
-+++ b/SRC/snapps.f
-@@ -266,11 +266,11 @@ subroutine snapps
-          sigmai = shifti(jj)
- c
-          if (msglvl .gt. 2 ) then
--            call ivout (logfil, 1, jj, ndigit,
-+            call ivout (logfil, 1, [jj], ndigit,
-      &               '_napps: shift number.')
--            call svout (logfil, 1, sigmar, ndigit,
-+            call svout (logfil, 1, [sigmar], ndigit,
-      &               '_napps: The real part of the shift ')
--            call svout (logfil, 1, sigmai, ndigit,
-+            call svout (logfil, 1, [sigmai], ndigit,
-      &               '_napps: The imaginary part of the shift ')
-          end if
- c
-@@ -335,9 +335,9 @@ subroutine snapps
-      &         tst1 = slanhs( '1', kplusp-jj+1, h, ldh, workl )
-             if( abs( h( i+1,i ) ).le.max( ulp*tst1, smlnum ) ) then
-                if (msglvl .gt. 0) then
--                  call ivout (logfil, 1, i, ndigit,
-+                  call ivout (logfil, 1, [i], ndigit,
-      &                 '_napps: matrix splitting at row/column no.')
--                  call ivout (logfil, 1, jj, ndigit,
-+                  call ivout (logfil, 1, [jj], ndigit,
-      &                 '_napps: matrix splitting with shift number.')
-                   call svout (logfil, 1, h(i+1,i), ndigit,
-      &                 '_napps: off diagonal element.')
-@@ -351,9 +351,9 @@ subroutine snapps
-    40    continue
- c
-          if (msglvl .gt. 2) then
--             call ivout (logfil, 1, istart, ndigit,
-+             call ivout (logfil, 1, [istart], ndigit,
-      &                   '_napps: Start of current block ')
--             call ivout (logfil, 1, iend, ndigit,
-+             call ivout (logfil, 1, [iend], ndigit,
-      &                   '_napps: End of current block ')
-          end if
- c
-@@ -625,7 +625,7 @@ subroutine snapps
-      &        '_napps: sigmak = (e_{kev+p}^T*Q)*e_{kev}')
-          call svout (logfil, 1, h(kev+1,kev), ndigit,
-      &        '_napps: betak = e_{kev+1}^T*H*e_{kev}')
--         call ivout (logfil, 1, kev, ndigit,
-+         call ivout (logfil, 1, [kev], ndigit,
-      &               '_napps: Order of the final Hessenberg matrix ')
-          if (msglvl .gt. 2) then
-             call smout (logfil, kev, kev, h, ldh, ndigit,
-diff --git a/SRC/snaup2.f b/SRC/snaup2.f
-index 53e39461..12b2cfed 100644
---- a/SRC/snaup2.f
-+++ b/SRC/snaup2.f
-@@ -388,7 +388,7 @@ subroutine snaup2
-          iter = iter + 1
- c
-          if (msglvl .gt. 0) then
--            call ivout (logfil, 1, iter, ndigit,
-+            call ivout (logfil, 1, [iter], ndigit,
-      &           '_naup2: **** Start of major iteration number ****')
-          end if
- c
-@@ -401,9 +401,9 @@ subroutine snaup2
-          np  = kplusp - nev
- c
-          if (msglvl .gt. 1) then
--            call ivout (logfil, 1, nev, ndigit,
-+            call ivout (logfil, 1, [nev], ndigit,
-      &     '_naup2: The length of the current Arnoldi factorization')
--            call ivout (logfil, 1, np, ndigit,
-+            call ivout (logfil, 1, [np], ndigit,
-      &           '_naup2: Extend the Arnoldi factorization by')
-          end if
- c
-@@ -435,7 +435,7 @@ subroutine snaup2
-          update = .false.
- c
-          if (msglvl .gt. 1) then
--            call svout (logfil, 1, rnorm, ndigit,
-+            call svout (logfil, 1, [rnorm], ndigit,
-      &           '_naup2: Corresponding B-norm of the residual')
-          end if
- c
-@@ -690,7 +690,7 @@ subroutine snaup2
-          end if
- c
-          if (msglvl .gt. 0) then
--            call ivout (logfil, 1, nconv, ndigit,
-+            call ivout (logfil, 1, [nconv], ndigit,
-      &           '_naup2: no. of "converged" Ritz values at this iter.')
-             if (msglvl .gt. 1) then
-                kp(1) = nev
-@@ -742,7 +742,7 @@ subroutine snaup2
-          end if
- c
-          if (msglvl .gt. 2) then
--            call ivout (logfil, 1, np, ndigit,
-+            call ivout (logfil, 1, [np], ndigit,
-      &                  '_naup2: The number of shifts to apply ')
-             call svout (logfil, np, ritzr, ndigit,
-      &                  '_naup2: Real part of the shifts')
-@@ -808,7 +808,7 @@ subroutine snaup2
-          cnorm = .false.
- c
-          if (msglvl .gt. 2) then
--            call svout (logfil, 1, rnorm, ndigit,
-+            call svout (logfil, 1, [rnorm], ndigit,
-      &      '_naup2: B-norm of residual for compressed factorization')
-             call smout (logfil, nev, nev, h, ldh, ndigit,
-      &        '_naup2: Compressed upper Hessenberg matrix H')
-diff --git a/SRC/snaupd.f b/SRC/snaupd.f
-index 19284d06..e0be1bfd 100644
---- a/SRC/snaupd.f
-+++ b/SRC/snaupd.f
-@@ -628,9 +628,9 @@ subroutine snaupd
-       if (info .eq. 2) info = 3
- c
-       if (msglvl .gt. 0) then
--         call ivout (logfil, 1, mxiter, ndigit,
-+         call ivout (logfil, 1, [mxiter], ndigit,
-      &               '_naupd: Number of update iterations taken')
--         call ivout (logfil, 1, np, ndigit,
-+         call ivout (logfil, 1, [np], ndigit,
-      &               '_naupd: Number of wanted "converged" Ritz values')
-          call svout (logfil, np, workl(ritzr), ndigit,
-      &               '_naupd: Real part of the final Ritz values')
-diff --git a/SRC/sneupd.f b/SRC/sneupd.f
-index ecd8f164..4c472fef 100644
---- a/SRC/sneupd.f
-+++ b/SRC/sneupd.f
-@@ -601,9 +601,9 @@ subroutine sneupd(rvec , howmny, select, dr    , di,
- c        %-----------------------------------------------------------%
- c
-          if (msglvl .gt. 2) then
--             call ivout(logfil, 1, numcnv, ndigit,
-+             call ivout(logfil, 1, [numcnv], ndigit,
-      &            '_neupd: Number of specified eigenvalues')
--             call ivout(logfil, 1, nconv, ndigit,
-+             call ivout(logfil, 1, [nconv], ndigit,
-      &            '_neupd: Number of "converged" eigenvalues')
-          end if
- c
-diff --git a/SRC/sngets.f b/SRC/sngets.f
-index 800282f8..7e48c0bb 100644
---- a/SRC/sngets.f
-+++ b/SRC/sngets.f
-@@ -212,8 +212,8 @@ subroutine sngets ( ishift, which, kev, np, ritzr, ritzi, bounds,
-       tngets = tngets + (t1 - t0)
- c
-       if (msglvl .gt. 0) then
--         call ivout (logfil, 1, kev, ndigit, '_ngets: KEV is')
--         call ivout (logfil, 1, np, ndigit, '_ngets: NP is')
-+         call ivout (logfil, 1, [kev], ndigit, '_ngets: KEV is')
-+         call ivout (logfil, 1, [np], ndigit, '_ngets: NP is')
-          call svout (logfil, kev+np, ritzr, ndigit,
-      &        '_ngets: Eigenvalues of current H matrix -- real part')
-          call svout (logfil, kev+np, ritzi, ndigit,
-diff --git a/SRC/ssaitr.f b/SRC/ssaitr.f
-index 721bdb58..a5df2c2e 100644
---- a/SRC/ssaitr.f
-+++ b/SRC/ssaitr.f
-@@ -364,9 +364,9 @@ subroutine ssaitr
-  1000 continue
- c
-          if (msglvl .gt. 2) then
--            call ivout (logfil, 1, j, ndigit,
-+            call ivout (logfil, 1, [j], ndigit,
-      &                  '_saitr: generating Arnoldi vector no.')
--            call svout (logfil, 1, rnorm, ndigit,
-+            call svout (logfil, 1, [rnorm], ndigit,
-      &                  '_saitr: B-norm of the current residual =')
-          end if
- c
-@@ -384,7 +384,7 @@ subroutine ssaitr
- c           %---------------------------------------------------%
- c
-             if (msglvl .gt. 0) then
--               call ivout (logfil, 1, j, ndigit,
-+               call ivout (logfil, 1, [j], ndigit,
-      &                     '_saitr: ****** restart at step ******')
-             end if
- c
-@@ -735,7 +735,7 @@ subroutine ssaitr
-          end if
- c
-          if (msglvl .gt. 0 .and. iter .gt. 0) then
--            call ivout (logfil, 1, j, ndigit,
-+            call ivout (logfil, 1, [j], ndigit,
-      &           '_saitr: Iterative refinement for Arnoldi residual')
-             if (msglvl .gt. 2) then
-                 xtemp(1) = rnorm
-diff --git a/SRC/ssapps.f b/SRC/ssapps.f
-index c8143111..77bd9d52 100644
---- a/SRC/ssapps.f
-+++ b/SRC/ssapps.f
-@@ -261,9 +261,9 @@ subroutine ssapps
-             big   = abs(h(i,2)) + abs(h(i+1,2))
-             if (h(i+1,1) .le. epsmch*big) then
-                if (msglvl .gt. 0) then
--                  call ivout (logfil, 1, i, ndigit,
-+                  call ivout (logfil, 1, [i], ndigit,
-      &                 '_sapps: deflation at row/column no.')
--                  call ivout (logfil, 1, jj, ndigit,
-+                  call ivout (logfil, 1, [jj], ndigit,
-      &                 '_sapps: occurred before shift number.')
-                   call svout (logfil, 1, h(i+1,1), ndigit,
-      &                 '_sapps: the corresponding off diagonal element')
-@@ -432,7 +432,7 @@ subroutine ssapps
-          big   = abs(h(i,2)) + abs(h(i+1,2))
-          if (h(i+1,1) .le. epsmch*big) then
-             if (msglvl .gt. 0) then
--               call ivout (logfil, 1, i, ndigit,
-+               call ivout (logfil, 1, [i], ndigit,
-      &              '_sapps: deflation at row/column no.')
-                call svout (logfil, 1, h(i+1,1), ndigit,
-      &              '_sapps: the corresponding off diagonal element')
-diff --git a/SRC/ssaup2.f b/SRC/ssaup2.f
-index a73c9a58..8cc04638 100644
---- a/SRC/ssaup2.f
-+++ b/SRC/ssaup2.f
-@@ -402,13 +402,13 @@ subroutine ssaup2
-          iter = iter + 1
- c
-          if (msglvl .gt. 0) then
--            call ivout (logfil, 1, iter, ndigit,
-+            call ivout (logfil, 1, [iter], ndigit,
-      &           '_saup2: **** Start of major iteration number ****')
-          end if
-          if (msglvl .gt. 1) then
--            call ivout (logfil, 1, nev, ndigit,
-+            call ivout (logfil, 1, [nev], ndigit,
-      &     '_saup2: The length of the current Lanczos factorization')
--            call ivout (logfil, 1, np, ndigit,
-+            call ivout (logfil, 1, [np], ndigit,
-      &           '_saup2: Extend the Lanczos factorization by')
-          end if
- c
-@@ -446,7 +446,7 @@ subroutine ssaup2
-          update = .false.
- c
-          if (msglvl .gt. 1) then
--            call svout (logfil, 1, rnorm, ndigit,
-+            call svout (logfil, 1, [rnorm], ndigit,
-      &           '_saup2: Current B-norm of residual for factorization')
-          end if
- c
-@@ -694,7 +694,7 @@ subroutine ssaup2
-          end if
- c
-          if (msglvl .gt. 0) then
--            call ivout (logfil, 1, nconv, ndigit,
-+            call ivout (logfil, 1, [nconv], ndigit,
-      &           '_saup2: no. of "converged" Ritz values at this iter.')
-             if (msglvl .gt. 1) then
-                kp(1) = nev
-@@ -742,7 +742,7 @@ subroutine ssaup2
-          if (ishift .eq. 0) call scopy (np, workl, 1, ritz, 1)
- c
-          if (msglvl .gt. 2) then
--            call ivout (logfil, 1, np, ndigit,
-+            call ivout (logfil, 1, [np], ndigit,
-      &                  '_saup2: The number of shifts to apply ')
-             call svout (logfil, np, workl, ndigit,
-      &                  '_saup2: shifts selected')
-@@ -809,7 +809,7 @@ subroutine ssaup2
-   130    continue
- c
-          if (msglvl .gt. 2) then
--            call svout (logfil, 1, rnorm, ndigit,
-+            call svout (logfil, 1, [rnorm], ndigit,
-      &      '_saup2: B-norm of residual for NEV factorization')
-             call svout (logfil, nev, h(1,2), ndigit,
-      &           '_saup2: main diagonal of compressed H matrix')
-diff --git a/SRC/ssaupd.f b/SRC/ssaupd.f
-index d139ac53..a8d2f2d5 100644
---- a/SRC/ssaupd.f
-+++ b/SRC/ssaupd.f
-@@ -628,9 +628,9 @@ subroutine ssaupd
-       if (info .eq. 2) info = 3
- c
-       if (msglvl .gt. 0) then
--         call ivout (logfil, 1, mxiter, ndigit,
-+         call ivout (logfil, 1, [mxiter], ndigit,
-      &               '_saupd: number of update iterations taken')
--         call ivout (logfil, 1, np, ndigit,
-+         call ivout (logfil, 1, [np], ndigit,
-      &               '_saupd: number of "converged" Ritz values')
-          call svout (logfil, np, workl(Ritz), ndigit,
-      &               '_saupd: final Ritz values')
-diff --git a/SRC/sseupd.f b/SRC/sseupd.f
-index 9b94ed7c..03ba7ac5 100644
---- a/SRC/sseupd.f
-+++ b/SRC/sseupd.f
-@@ -513,9 +513,9 @@ subroutine sseupd(rvec  , howmny, select, d    ,
- c        %-----------------------------------------------------------%
- c
-          if (msglvl .gt. 2) then
--             call ivout(logfil, 1, numcnv, ndigit,
-+             call ivout(logfil, 1, [numcnv], ndigit,
-      &            '_seupd: Number of specified eigenvalues')
--             call ivout(logfil, 1, nconv, ndigit,
-+             call ivout(logfil, 1, [nconv], ndigit,
-      &            '_seupd: Number of "converged" eigenvalues')
-          end if
- c
-diff --git a/SRC/ssgets.f b/SRC/ssgets.f
-index ce84d673..f40ca76a 100644
---- a/SRC/ssgets.f
-+++ b/SRC/ssgets.f
-@@ -202,8 +202,8 @@ subroutine ssgets ( ishift, which, kev, np, ritz, bounds, shifts )
-       tsgets = tsgets + (t1 - t0)
- c
-       if (msglvl .gt. 0) then
--         call ivout (logfil, 1, kev, ndigit, '_sgets: KEV is')
--         call ivout (logfil, 1, np, ndigit, '_sgets: NP is')
-+         call ivout (logfil, 1, [kev], ndigit, '_sgets: KEV is')
-+         call ivout (logfil, 1, [np], ndigit, '_sgets: NP is')
-          call svout (logfil, kev+np, ritz, ndigit,
-      &        '_sgets: Eigenvalues of current H matrix')
-          call svout (logfil, kev+np, bounds, ndigit,
-diff --git a/SRC/zgetv0.f b/SRC/zgetv0.f
-index d71f3c03..ff5c2b19 100644
---- a/SRC/zgetv0.f
-+++ b/SRC/zgetv0.f
-@@ -361,9 +361,9 @@ subroutine zgetv0
- c     %--------------------------------------%
- c
-       if (msglvl .gt. 2) then
--          call dvout (logfil, 1, rnorm0, ndigit,
-+          call dvout (logfil, 1, [rnorm0], ndigit,
-      &                '_getv0: re-orthonalization ; rnorm0 is')
--          call dvout (logfil, 1, rnorm, ndigit,
-+          call dvout (logfil, 1, [rnorm], ndigit,
-      &                '_getv0: re-orthonalization ; rnorm is')
-       end if
- c
-@@ -394,7 +394,7 @@ subroutine zgetv0
-    50 continue
- c
-       if (msglvl .gt. 0) then
--         call dvout (logfil, 1, rnorm, ndigit,
-+         call dvout (logfil, 1, [rnorm], ndigit,
-      &        '_getv0: B-norm of initial / restarted starting vector')
-       end if
-       if (msglvl .gt. 2) then
-diff --git a/SRC/znaitr.f b/SRC/znaitr.f
-index b8331c06..1c5aa57f 100644
---- a/SRC/znaitr.f
-+++ b/SRC/znaitr.f
-@@ -378,9 +378,9 @@ subroutine znaitr
-  1000 continue
- c
-          if (msglvl .gt. 1) then
--            call ivout (logfil, 1, j, ndigit,
-+            call ivout (logfil, 1, [j], ndigit,
-      &                  '_naitr: generating Arnoldi vector number')
--            call dvout (logfil, 1, rnorm, ndigit,
-+            call dvout (logfil, 1, [rnorm], ndigit,
-      &                  '_naitr: B-norm of the current residual is')
-          end if
- c
-@@ -400,7 +400,7 @@ subroutine znaitr
- c           %---------------------------------------------------%
- c
-             if (msglvl .gt. 0) then
--               call ivout (logfil, 1, j, ndigit,
-+               call ivout (logfil, 1, [j], ndigit,
-      &                     '_naitr: ****** RESTART AT STEP ******')
-             end if
- c
-@@ -729,7 +729,7 @@ subroutine znaitr
-          end if
- c
-          if (msglvl .gt. 0 .and. iter .gt. 0 ) then
--            call ivout (logfil, 1, j, ndigit,
-+            call ivout (logfil, 1, [j], ndigit,
-      &           '_naitr: Iterative refinement for Arnoldi residual')
-             if (msglvl .gt. 2) then
-                 rtemp(1) = rnorm
-diff --git a/SRC/znapps.f b/SRC/znapps.f
-index a1f116d3..6d8d12a8 100644
---- a/SRC/znapps.f
-+++ b/SRC/znapps.f
-@@ -268,9 +268,9 @@ subroutine znapps
-          sigma = shift(jj)
- c
-          if (msglvl .gt. 2 ) then
--            call ivout (logfil, 1, jj, ndigit,
-+            call ivout (logfil, 1, [jj], ndigit,
-      &               '_napps: shift number.')
--            call zvout (logfil, 1, sigma, ndigit,
-+            call zvout (logfil, 1, [sigma], ndigit,
-      &               '_napps: Value of the shift ')
-          end if
- c
-@@ -291,9 +291,9 @@ subroutine znapps
-             if ( abs(dble(h(i+1,i)))
-      &           .le. max(ulp*tst1, smlnum) )  then
-                if (msglvl .gt. 0) then
--                  call ivout (logfil, 1, i, ndigit,
-+                  call ivout (logfil, 1, [i], ndigit,
-      &                 '_napps: matrix splitting at row/column no.')
--                  call ivout (logfil, 1, jj, ndigit,
-+                  call ivout (logfil, 1, [jj], ndigit,
-      &                 '_napps: matrix splitting with shift number.')
-                   call zvout (logfil, 1, h(i+1,i), ndigit,
-      &                 '_napps: off diagonal element.')
-@@ -307,9 +307,9 @@ subroutine znapps
-    40    continue
- c
-          if (msglvl .gt. 2) then
--             call ivout (logfil, 1, istart, ndigit,
-+             call ivout (logfil, 1, [istart], ndigit,
-      &                   '_napps: Start of current block ')
--             call ivout (logfil, 1, iend, ndigit,
-+             call ivout (logfil, 1, [iend], ndigit,
-      &                   '_napps: End of current block ')
-          end if
- c
-@@ -485,7 +485,7 @@ subroutine znapps
-      &        '_napps: sigmak = (e_{kev+p}^T*Q)*e_{kev}')
-          call zvout (logfil, 1, h(kev+1,kev), ndigit,
-      &        '_napps: betak = e_{kev+1}^T*H*e_{kev}')
--         call ivout (logfil, 1, kev, ndigit,
-+         call ivout (logfil, 1, [kev], ndigit,
-      &               '_napps: Order of the final Hessenberg matrix ')
-          if (msglvl .gt. 2) then
-             call zmout (logfil, kev, kev, h, ldh, ndigit,
-diff --git a/SRC/znaup2.f b/SRC/znaup2.f
-index 469aafb2..b814cf15 100644
---- a/SRC/znaup2.f
-+++ b/SRC/znaup2.f
-@@ -389,7 +389,7 @@ subroutine znaup2
-          iter = iter + 1
- c
-          if (msglvl .gt. 0) then
--            call ivout (logfil, 1, iter, ndigit,
-+            call ivout (logfil, 1, [iter], ndigit,
-      &           '_naup2: **** Start of major iteration number ****')
-          end if
- c
-@@ -402,9 +402,9 @@ subroutine znaup2
-          np  = kplusp - nev
- c
-          if (msglvl .gt. 1) then
--            call ivout (logfil, 1, nev, ndigit,
-+            call ivout (logfil, 1, [nev], ndigit,
-      &     '_naup2: The length of the current Arnoldi factorization')
--            call ivout (logfil, 1, np, ndigit,
-+            call ivout (logfil, 1, [np], ndigit,
-      &           '_naup2: Extend the Arnoldi factorization by')
-          end if
- c
-@@ -430,7 +430,7 @@ subroutine znaup2
-          update = .false.
- c
-          if (msglvl .gt. 1) then
--            call dvout  (logfil, 1, rnorm, ndigit,
-+            call dvout  (logfil, 1, [rnorm], ndigit,
-      &           '_naup2: Corresponding B-norm of the residual')
-          end if
- c
-@@ -658,7 +658,7 @@ subroutine znaup2
-          end if
- c
-          if (msglvl .gt. 0) then
--            call ivout (logfil, 1, nconv, ndigit,
-+            call ivout (logfil, 1, [nconv], ndigit,
-      &           '_naup2: no. of "converged" Ritz values at this iter.')
-             if (msglvl .gt. 1) then
-                kp(1) = nev
-@@ -698,7 +698,7 @@ subroutine znaup2
-          end if
- c
-          if (msglvl .gt. 2) then
--            call ivout (logfil, 1, np, ndigit,
-+            call ivout (logfil, 1, [np], ndigit,
-      &                  '_naup2: The number of shifts to apply ')
-             call zvout  (logfil, np, ritz, ndigit,
-      &                  '_naup2: values of the shifts')
-@@ -762,7 +762,7 @@ subroutine znaup2
-          cnorm = .false.
- c
-          if (msglvl .gt. 2) then
--            call dvout  (logfil, 1, rnorm, ndigit,
-+            call dvout  (logfil, 1, [rnorm], ndigit,
-      &      '_naup2: B-norm of residual for compressed factorization')
-             call zmout  (logfil, nev, nev, h, ldh, ndigit,
-      &        '_naup2: Compressed upper Hessenberg matrix H')
-diff --git a/SRC/znaupd.f b/SRC/znaupd.f
-index 779eb2bc..c7d58aaa 100644
---- a/SRC/znaupd.f
-+++ b/SRC/znaupd.f
-@@ -601,9 +601,9 @@ subroutine znaupd
-       if (info .eq. 2) info = 3
- c
-       if (msglvl .gt. 0) then
--         call ivout (logfil, 1, mxiter, ndigit,
-+         call ivout (logfil, 1, [mxiter], ndigit,
-      &               '_naupd: Number of update iterations taken')
--         call ivout (logfil, 1, np, ndigit,
-+         call ivout (logfil, 1, [np], ndigit,
-      &               '_naupd: Number of wanted "converged" Ritz values')
-          call zvout  (logfil, np, workl(ritz), ndigit,
-      &               '_naupd: The final Ritz values')
-diff --git a/SRC/zneupd.f b/SRC/zneupd.f
-index f1eb68a3..9889e30e 100644
---- a/SRC/zneupd.f
-+++ b/SRC/zneupd.f
-@@ -536,9 +536,9 @@ subroutine zneupd(rvec , howmny, select, d     ,
- c        %-----------------------------------------------------------%
- c
-          if (msglvl .gt. 2) then
--             call ivout(logfil, 1, numcnv, ndigit,
-+             call ivout(logfil, 1, [numcnv], ndigit,
-      &            '_neupd: Number of specified eigenvalues')
--             call ivout(logfil, 1, nconv, ndigit,
-+             call ivout(logfil, 1, [nconv], ndigit,
-      &            '_neupd: Number of "converged" eigenvalues')
-          end if
- c
-diff --git a/SRC/zngets.f b/SRC/zngets.f
-index 27f25803..e7d24334 100644
---- a/SRC/zngets.f
-+++ b/SRC/zngets.f
-@@ -161,8 +161,8 @@ subroutine zngets ( ishift, which, kev, np, ritz, bounds)
-       tcgets = tcgets + (t1 - t0)
- c
-       if (msglvl .gt. 0) then
--         call ivout (logfil, 1, kev, ndigit, '_ngets: KEV is')
--         call ivout (logfil, 1, np, ndigit, '_ngets: NP is')
-+         call ivout (logfil, 1, [kev], ndigit, '_ngets: KEV is')
-+         call ivout (logfil, 1, [np], ndigit, '_ngets: NP is')
-          call zvout (logfil, kev+np, ritz, ndigit,
-      &        '_ngets: Eigenvalues of current H matrix ')
-          call zvout (logfil, kev+np, bounds, ndigit,
-
-
-From ad82dcbc0beeed5616e2d5a28a089d9785f8b8b8 Mon Sep 17 00:00:00 2001
-From: dschwoerer <dschwoerer@users.noreply.github.com>
-Date: Mon, 24 Feb 2020 09:05:43 +0000
-Subject: [PATCH] gcc-10 (parpack) and mpich (#245)
-
-* port PARPACK also to gcc 10
-
-* Ensure that the output buffer is a rank-1 vector
-
-The vector should also not be a temporary, so that we
-can use the result.
-
-* use valid address of binary
-
-openmpi ignores this error, but mpich doesn't
-
-* Add travis test with gcc 10 and mpich
-
-* After pulling fedora:rawhide, use fedora:rawhide
-
-* simplify travis tests for fedora
-
-* run using bash -v (permissions issue otherwise)
-
-* run using bash -v (permissions issue otherwise)
-
-* fix permission of script
-
-* Add she-bang to allow execution
-
-* fix test for fedora
-
-Co-authored-by: Sylvestre Ledru <sledru@mozilla.com>
-
-diff --git a/PARPACK/SRC/BLACS/pcgetv0.f b/PARPACK/SRC/BLACS/pcgetv0.f
-index 0325fda3..191d70fd 100644
---- a/PARPACK/SRC/BLACS/pcgetv0.f
-+++ b/PARPACK/SRC/BLACS/pcgetv0.f
-@@ -406,9 +406,9 @@ subroutine pcgetv0
- c     %--------------------------------------%
- c
-       if (msglvl .gt. 2) then
--          call psvout (comm, logfil, 1, rnorm0, ndigit,
-+          call psvout (comm, logfil, 1, [rnorm0], ndigit,
-      &                '_getv0: re-orthonalization ; rnorm0 is')
--          call psvout (comm, logfil, 1, rnorm, ndigit,
-+          call psvout (comm, logfil, 1, [rnorm], ndigit,
-      &                '_getv0: re-orthonalization ; rnorm is')
-       end if
- c
-diff --git a/PARPACK/SRC/BLACS/pcnaitr.f b/PARPACK/SRC/BLACS/pcnaitr.f
-index a9f17ed8..04fa1cbe 100644
---- a/PARPACK/SRC/BLACS/pcnaitr.f
-+++ b/PARPACK/SRC/BLACS/pcnaitr.f
-@@ -401,9 +401,9 @@ subroutine pcnaitr
-  1000 continue
- c
-          if (msglvl .gt. 1) then
--            call pivout (comm, logfil, 1, j, ndigit,
-+            call pivout (comm, logfil, 1, [j], ndigit,
-      &                  '_naitr: generating Arnoldi vector number')
--            call pcvout (comm, logfil, 1, rnorm, ndigit,
-+            call pcvout (comm, logfil, 1, [rnorm], ndigit,
-      &                  '_naitr: B-norm of the current residual is')
-          end if
- c
-@@ -423,7 +423,7 @@ subroutine pcnaitr
- c           %---------------------------------------------------%
- c
-             if (msglvl .gt. 0) then
--               call pivout (comm, logfil, 1, j, ndigit,
-+               call pivout (comm, logfil, 1, [j], ndigit,
-      &                     '_naitr: ****** RESTART AT STEP ******')
-             end if
- c
-@@ -757,7 +757,7 @@ subroutine pcnaitr
-          end if
- c
-          if (msglvl .gt. 0 .and. iter .gt. 0 ) then
--            call pivout (comm, logfil, 1, j, ndigit,
-+            call pivout (comm, logfil, 1, [j], ndigit,
-      &           '_naitr: Iterative refinement for Arnoldi residual')
-             if (msglvl .gt. 2) then
-                 rtemp(1) = rnorm
-diff --git a/PARPACK/SRC/BLACS/pcnapps.f b/PARPACK/SRC/BLACS/pcnapps.f
-index 47fb7e70..e40793cf 100644
---- a/PARPACK/SRC/BLACS/pcnapps.f
-+++ b/PARPACK/SRC/BLACS/pcnapps.f
-@@ -284,9 +284,9 @@ subroutine pcnapps
-          sigma = shift(jj)
- c
-          if (msglvl .gt. 2 ) then
--            call pivout (comm, logfil, 1, jj, ndigit,
-+            call pivout (comm, logfil, 1, [jj], ndigit,
-      &               '_napps: shift number.')
--            call pcvout (comm, logfil, 1, sigma, ndigit,
-+            call pcvout (comm, logfil, 1, [sigma], ndigit,
-      &               '_napps: Value of the shift ')
-          end if
- c
-@@ -307,9 +307,9 @@ subroutine pcnapps
-             if ( abs(real(h(i+1,i)))
-      &           .le. max(ulp*tst1, smlnum) )  then
-                if (msglvl .gt. 0) then
--                  call pivout (comm, logfil, 1, i, ndigit,
-+                  call pivout (comm, logfil, 1, [i], ndigit,
-      &                 '_napps: matrix splitting at row/column no.')
--                  call pivout (comm, logfil, 1, jj, ndigit,
-+                  call pivout (comm, logfil, 1, [jj], ndigit,
-      &                 '_napps: matrix splitting with shift number.')
-                   call pcvout (comm, logfil, 1, h(i+1,i), ndigit,
-      &                 '_napps: off diagonal element.')
-@@ -323,9 +323,9 @@ subroutine pcnapps
-    40    continue
- c
-          if (msglvl .gt. 2) then
--             call pivout (comm, logfil, 1, istart, ndigit,
-+             call pivout (comm, logfil, 1, [istart], ndigit,
-      &                   '_napps: Start of current block ')
--             call pivout (comm, logfil, 1, iend, ndigit,
-+             call pivout (comm, logfil, 1, [iend], ndigit,
-      &                   '_napps: End of current block ')
-          end if
- c
-@@ -501,7 +501,7 @@ subroutine pcnapps
-      &        '_napps: sigmak = (e_{kev+p}^T*Q)*e_{kev}')
-          call pcvout (comm, logfil, 1, h(kev+1,kev), ndigit,
-      &        '_napps: betak = e_{kev+1}^T*H*e_{kev}')
--         call pivout (comm, logfil, 1, kev, ndigit,
-+         call pivout (comm, logfil, 1, [kev], ndigit,
-      &               '_napps: Order of the final Hessenberg matrix ')
-          if (msglvl .gt. 2) then
-             call pcmout (comm, logfil, kev, kev, h, ldh, ndigit,
-diff --git a/PARPACK/SRC/BLACS/pcnaup2.f b/PARPACK/SRC/BLACS/pcnaup2.f
-index 55868069..757b12c3 100644
---- a/PARPACK/SRC/BLACS/pcnaup2.f
-+++ b/PARPACK/SRC/BLACS/pcnaup2.f
-@@ -398,7 +398,7 @@ subroutine pcnaup2
-          iter = iter + 1
- c
-          if (msglvl .gt. 0) then
--            call pivout (comm, logfil, 1, iter, ndigit,
-+            call pivout (comm, logfil, 1, [iter], ndigit,
-      &           '_naup2: **** Start of major iteration number ****')
-          end if
- c
-@@ -411,9 +411,9 @@ subroutine pcnaup2
-          np  = kplusp - nev
- c
-          if (msglvl .gt. 1) then
--            call pivout (comm, logfil, 1, nev, ndigit,
-+            call pivout (comm, logfil, 1, [nev], ndigit,
-      &     '_naup2: The length of the current Arnoldi factorization')
--            call pivout (comm, logfil, 1, np, ndigit,
-+            call pivout (comm, logfil, 1, [np], ndigit,
-      &           '_naup2: Extend the Arnoldi factorization by')
-          end if
- c
-@@ -440,7 +440,7 @@ subroutine pcnaup2
-          update = .false.
- c
-          if (msglvl .gt. 1) then
--            call psvout (comm, logfil, 1, rnorm, ndigit,
-+            call psvout (comm, logfil, 1, [rnorm], ndigit,
-      &           '_naup2: Corresponding B-norm of the residual')
-          end if
- c
-@@ -671,7 +671,7 @@ subroutine pcnaup2
-          end if
- c
-          if (msglvl .gt. 0) then
--            call pivout (comm, logfil, 1, nconv, ndigit,
-+            call pivout (comm, logfil, 1, [nconv], ndigit,
-      &           '_naup2: no. of "converged" Ritz values at this iter.')
-             if (msglvl .gt. 1) then
-                kp(1) = nev
-@@ -711,7 +711,7 @@ subroutine pcnaup2
-          end if
- c
-          if (msglvl .gt. 2) then
--            call pivout (comm, logfil, 1, np, ndigit,
-+            call pivout (comm, logfil, 1, [np], ndigit,
-      &                  '_naup2: The number of shifts to apply ')
-             call pcvout (comm, logfil, np, ritz, ndigit,
-      &                  '_naup2: values of the shifts')
-@@ -776,7 +776,7 @@ subroutine pcnaup2
-          cnorm = .false.
- c
-          if (msglvl .gt. 2) then
--            call psvout (comm, logfil, 1, rnorm, ndigit,
-+            call psvout (comm, logfil, 1, [rnorm], ndigit,
-      &      '_naup2: B-norm of residual for compressed factorization')
-             call pcmout (comm, logfil, nev, nev, h, ldh, ndigit,
-      &        '_naup2: Compressed upper Hessenberg matrix H')
-diff --git a/PARPACK/SRC/BLACS/pcnaupd.f b/PARPACK/SRC/BLACS/pcnaupd.f
-index b350199e..55bb655d 100644
---- a/PARPACK/SRC/BLACS/pcnaupd.f
-+++ b/PARPACK/SRC/BLACS/pcnaupd.f
-@@ -618,9 +618,9 @@ subroutine pcnaupd
-       if (info .eq. 2) info = 3
- c
-       if (msglvl .gt. 0) then
--         call pivout (comm, logfil, 1, mxiter, ndigit,
-+         call pivout (comm, logfil, 1, [mxiter], ndigit,
-      &               '_naupd: Number of update iterations taken')
--         call pivout (comm, logfil, 1, np, ndigit,
-+         call pivout (comm, logfil, 1, [np], ndigit,
-      &               '_naupd: Number of wanted "converged" Ritz values')
-          call pcvout (comm, logfil, np, workl(ritz), ndigit,
-      &               '_naupd: The final Ritz values')
-diff --git a/PARPACK/SRC/BLACS/pcneupd.f b/PARPACK/SRC/BLACS/pcneupd.f
-index 53cf2d24..da4a9ec5 100644
---- a/PARPACK/SRC/BLACS/pcneupd.f
-+++ b/PARPACK/SRC/BLACS/pcneupd.f
-@@ -558,9 +558,9 @@ subroutine pcneupd
- c        %-----------------------------------------------------------%
- c
-          if (msglvl .gt. 2) then
--             call pivout(comm, logfil, 1, numcnv, ndigit,
-+             call pivout(comm, logfil, 1, [numcnv], ndigit,
-      &            '_neupd: Number of specified eigenvalues')
--             call pivout(comm, logfil, 1, nconv, ndigit,
-+             call pivout(comm, logfil, 1, [nconv], ndigit,
-      &            '_neupd: Number of "converged" eigenvalues')
-          end if
- c
-diff --git a/PARPACK/SRC/BLACS/pcngets.f b/PARPACK/SRC/BLACS/pcngets.f
-index f9cca353..89cd67ae 100644
---- a/PARPACK/SRC/BLACS/pcngets.f
-+++ b/PARPACK/SRC/BLACS/pcngets.f
-@@ -177,8 +177,8 @@ subroutine pcngets ( comm, ishift, which, kev, np, ritz, bounds)
-       tcgets = tcgets + (t1 - t0)
- c
-       if (msglvl .gt. 0) then
--         call pivout (comm, logfil, 1, kev, ndigit, '_ngets: KEV is')
--         call pivout (comm, logfil, 1, np, ndigit, '_ngets: NP is')
-+         call pivout (comm, logfil, 1, [kev], ndigit, '_ngets: KEV is')
-+         call pivout (comm, logfil, 1, [np], ndigit, '_ngets: NP is')
-          call pcvout (comm, logfil, kev+np, ritz, ndigit,
-      &        '_ngets: Eigenvalues of current H matrix ')
-          call pcvout (comm, logfil, kev+np, bounds, ndigit,
-diff --git a/PARPACK/SRC/BLACS/pdgetv0.f b/PARPACK/SRC/BLACS/pdgetv0.f
-index 9c3a1d99..237443dd 100644
---- a/PARPACK/SRC/BLACS/pdgetv0.f
-+++ b/PARPACK/SRC/BLACS/pdgetv0.f
-@@ -385,9 +385,9 @@ subroutine pdgetv0
- c     %--------------------------------------%
- c
-       if (msglvl .gt. 2) then
--          call pdvout (comm, logfil, 1, rnorm0, ndigit,
-+          call pdvout (comm, logfil, 1, [rnorm0], ndigit,
-      &                '_getv0: re-orthonalization ; rnorm0 is')
--          call pdvout (comm, logfil, 1, rnorm, ndigit,
-+          call pdvout (comm, logfil, 1, [rnorm], ndigit,
-      &                '_getv0: re-orthonalization ; rnorm is')
-       end if
- c
-@@ -418,7 +418,7 @@ subroutine pdgetv0
-    50 continue
- c
-       if (msglvl .gt. 0) then
--         call pdvout (comm, logfil, 1, rnorm, ndigit,
-+         call pdvout (comm, logfil, 1, [rnorm], ndigit,
-      &        '_getv0: B-norm of initial / restarted starting vector')
-       end if
-       if (msglvl .gt. 2) then
-diff --git a/PARPACK/SRC/BLACS/pdnaitr.f b/PARPACK/SRC/BLACS/pdnaitr.f
-index f6557560..fb46494f 100644
---- a/PARPACK/SRC/BLACS/pdnaitr.f
-+++ b/PARPACK/SRC/BLACS/pdnaitr.f
-@@ -390,9 +390,9 @@ subroutine pdnaitr
-  1000 continue
- c
-          if (msglvl .gt. 1) then
--            call pivout (comm, logfil, 1, j, ndigit,
-+            call pivout (comm, logfil, 1, [j], ndigit,
-      &                  '_naitr: generating Arnoldi vector number')
--            call pdvout (comm, logfil, 1, rnorm, ndigit,
-+            call pdvout (comm, logfil, 1, [rnorm], ndigit,
-      &                  '_naitr: B-norm of the current residual is')
-          end if
- c
-@@ -412,7 +412,7 @@ subroutine pdnaitr
- c           %---------------------------------------------------%
- c
-             if (msglvl .gt. 0) then
--               call pivout (comm, logfil, 1, j, ndigit,
-+               call pivout (comm, logfil, 1, [j], ndigit,
-      &                     '_naitr: ****** RESTART AT STEP ******')
-             end if
- c
-@@ -745,7 +745,7 @@ subroutine pdnaitr
-          end if
- c
-          if (msglvl .gt. 0 .and. iter .gt. 0) then
--            call pivout (comm, logfil, 1, j, ndigit,
-+            call pivout (comm, logfil, 1, [j], ndigit,
-      &           '_naitr: Iterative refinement for Arnoldi residual')
-             if (msglvl .gt. 2) then
-                 xtemp(1) = rnorm
-diff --git a/PARPACK/SRC/BLACS/pdnapps.f b/PARPACK/SRC/BLACS/pdnapps.f
-index 56e3414d..eadca320 100644
---- a/PARPACK/SRC/BLACS/pdnapps.f
-+++ b/PARPACK/SRC/BLACS/pdnapps.f
-@@ -276,11 +276,11 @@ subroutine pdnapps
-          sigmai = shifti(jj)
- c
-          if (msglvl .gt. 2 ) then
--            call pivout (comm, logfil, 1, jj, ndigit,
-+            call pivout (comm, logfil, 1, [jj], ndigit,
-      &               '_napps: shift number.')
--            call pdvout (comm, logfil, 1, sigmar, ndigit,
-+            call pdvout (comm, logfil, 1, [sigmar], ndigit,
-      &               '_napps: The real part of the shift ')
--            call pdvout (comm, logfil, 1, sigmai, ndigit,
-+            call pdvout (comm, logfil, 1, [sigmai], ndigit,
-      &               '_napps: The imaginary part of the shift ')
-          end if
- c
-@@ -347,7 +347,7 @@ subroutine pdnapps
-                if (msglvl .gt. 0) then
-                   call pivout (comm, logfil, 1, i, ndigit,
-      &                 '_napps: matrix splitting at row/column no.')
--                  call pivout (comm, logfil, 1, jj, ndigit,
-+                  call pivout (comm, logfil, 1, [jj], ndigit,
-      &                 '_napps: matrix splitting with shift number.')
-                   call pdvout (comm, logfil, 1, h(i+1,i), ndigit,
-      &                 '_napps: off diagonal element.')
-@@ -361,9 +361,9 @@ subroutine pdnapps
-    40    continue
- c
-          if (msglvl .gt. 2) then
--             call pivout (comm, logfil, 1, istart, ndigit,
-+             call pivout (comm, logfil, 1, [istart], ndigit,
-      &                   '_napps: Start of current block ')
--             call pivout (comm, logfil, 1, iend, ndigit,
-+             call pivout (comm, logfil, 1, [iend], ndigit,
-      &                   '_napps: End of current block ')
-          end if
- c
-@@ -635,7 +635,7 @@ subroutine pdnapps
-      &        '_napps: sigmak = (e_{kev+p}^T*Q)*e_{kev}')
-          call pdvout (comm, logfil, 1, h(kev+1,kev), ndigit,
-      &        '_napps: betak = e_{kev+1}^T*H*e_{kev}')
--         call pivout (comm, logfil, 1, kev, ndigit,
-+         call pivout (comm, logfil, 1, [kev], ndigit,
-      &               '_napps: Order of the final Hessenberg matrix ')
-          if (msglvl .gt. 2) then
-             call pdmout (comm, logfil, kev, kev, h, ldh, ndigit,
-diff --git a/PARPACK/SRC/BLACS/pdnaup2.f b/PARPACK/SRC/BLACS/pdnaup2.f
-index becea72d..a295dbbb 100644
---- a/PARPACK/SRC/BLACS/pdnaup2.f
-+++ b/PARPACK/SRC/BLACS/pdnaup2.f
-@@ -405,7 +405,7 @@ subroutine pdnaup2
-          iter = iter + 1
- c
-          if (msglvl .gt. 0) then
--            call pivout (comm, logfil, 1, iter, ndigit,
-+            call pivout (comm, logfil, 1, [iter], ndigit,
-      &           '_naup2: **** Start of major iteration number ****')
-          end if
- c
-@@ -418,9 +418,9 @@ subroutine pdnaup2
-          np  = kplusp - nev
- c
-          if (msglvl .gt. 1) then
--            call pivout (comm, logfil, 1, nev, ndigit,
-+            call pivout (comm, logfil, 1, [nev], ndigit,
-      &     '_naup2: The length of the current Arnoldi factorization')
--            call pivout (comm, logfil, 1, np, ndigit,
-+            call pivout (comm, logfil, 1, [np], ndigit,
-      &           '_naup2: Extend the Arnoldi factorization by')
-          end if
- c
-@@ -452,7 +452,7 @@ subroutine pdnaup2
-          update = .false.
- c
-          if (msglvl .gt. 1) then
--            call pdvout  (comm, logfil, 1, rnorm, ndigit,
-+            call pdvout  (comm, logfil, 1, [rnorm], ndigit,
-      &           '_naup2: Corresponding B-norm of the residual')
-          end if
- c
-@@ -696,7 +696,7 @@ subroutine pdnaup2
-          end if
- c
-          if (msglvl .gt. 0) then
--            call pivout (comm, logfil, 1, nconv, ndigit,
-+            call pivout (comm, logfil, 1, [nconv], ndigit,
-      &           '_naup2: no. of "converged" Ritz values at this iter.')
-             if (msglvl .gt. 1) then
-                kp(1) = nev
-@@ -748,7 +748,7 @@ subroutine pdnaup2
-          end if
- c
-          if (msglvl .gt. 2) then
--            call pivout (comm, logfil, 1, np, ndigit,
-+            call pivout (comm, logfil, 1, [np], ndigit,
-      &                  '_naup2: The number of shifts to apply ')
-             call pdvout  (comm, logfil, np, ritzr, ndigit,
-      &                  '_naup2: Real part of the shifts')
-@@ -815,7 +815,7 @@ subroutine pdnaup2
-          cnorm = .false.
- c
-          if (msglvl .gt. 2) then
--            call pdvout  (comm, logfil, 1, rnorm, ndigit,
-+            call pdvout  (comm, logfil, 1, [rnorm], ndigit,
-      &      '_naup2: B-norm of residual for compressed factorization')
-             call pdmout  (comm, logfil, nev, nev, h, ldh, ndigit,
-      &        '_naup2: Compressed upper Hessenberg matrix H')
-diff --git a/PARPACK/SRC/BLACS/pdnaupd.f b/PARPACK/SRC/BLACS/pdnaupd.f
-index d947755b..ed0fa20f 100644
---- a/PARPACK/SRC/BLACS/pdnaupd.f
-+++ b/PARPACK/SRC/BLACS/pdnaupd.f
-@@ -642,9 +642,9 @@ subroutine pdnaupd
-       if (info .eq. 2) info = 3
- c
-       if (msglvl .gt. 0) then
--         call pivout (comm, logfil, 1, mxiter, ndigit,
-+         call pivout (comm, logfil, 1, [mxiter], ndigit,
-      &               '_naupd: Number of update iterations taken')
--         call pivout (comm, logfil, 1, np, ndigit,
-+         call pivout (comm, logfil, 1, [np], ndigit,
-      &               '_naupd: Number of wanted "converged" Ritz values')
-          call pdvout  (comm, logfil, np, workl(ritzr), ndigit,
-      &               '_naupd: Real part of the final Ritz values')
-diff --git a/PARPACK/SRC/BLACS/pdneupd.f b/PARPACK/SRC/BLACS/pdneupd.f
-index 0ff911ff..321202f9 100644
---- a/PARPACK/SRC/BLACS/pdneupd.f
-+++ b/PARPACK/SRC/BLACS/pdneupd.f
-@@ -617,9 +617,9 @@ subroutine pdneupd
- c        %-----------------------------------------------------------%
- c
-          if (msglvl .gt. 2) then
--             call pivout(comm, logfil, 1, numcnv, ndigit,
-+             call pivout(comm, logfil, 1, [numcnv], ndigit,
-      &            '_neupd: Number of specified eigenvalues')
--             call pivout(comm, logfil, 1, nconv, ndigit,
-+             call pivout(comm, logfil, 1, [nconv], ndigit,
-      &            '_neupd: Number of "converged" eigenvalues')
-          end if
- c
-diff --git a/PARPACK/SRC/BLACS/pdngets.f b/PARPACK/SRC/BLACS/pdngets.f
-index 71ed6a7c..12a691f6 100644
---- a/PARPACK/SRC/BLACS/pdngets.f
-+++ b/PARPACK/SRC/BLACS/pdngets.f
-@@ -226,8 +226,8 @@ subroutine pdngets
-       tngets = tngets + (t1 - t0)
- c
-       if (msglvl .gt. 0) then
--         call pivout (comm, logfil, 1, kev, ndigit, '_ngets: KEV is')
--         call pivout (comm, logfil, 1, np, ndigit, '_ngets: NP is')
-+         call pivout (comm, logfil, 1, [kev], ndigit, '_ngets: KEV is')
-+         call pivout (comm, logfil, 1, [np], ndigit, '_ngets: NP is')
-          call pdvout (comm, logfil, kev+np, ritzr, ndigit,
-      &        '_ngets: Eigenvalues of current H matrix -- real part')
-          call pdvout (comm, logfil, kev+np, ritzi, ndigit,
-diff --git a/PARPACK/SRC/BLACS/pdsaitr.f b/PARPACK/SRC/BLACS/pdsaitr.f
-index 37ca61e8..9a2cdfc1 100644
---- a/PARPACK/SRC/BLACS/pdsaitr.f
-+++ b/PARPACK/SRC/BLACS/pdsaitr.f
-@@ -389,9 +389,9 @@ subroutine pdsaitr
-  1000 continue
- c
-          if (msglvl .gt. 2) then
--            call pivout (comm, logfil, 1, j, ndigit,
-+            call pivout (comm, logfil, 1, [j], ndigit,
-      &                  '_saitr: generating Arnoldi vector no.')
--            call pdvout (comm, logfil, 1, rnorm, ndigit,
-+            call pdvout (comm, logfil, 1, [rnorm], ndigit,
-      &                  '_saitr: B-norm of the current residual =')
-          end if
- c
-@@ -409,7 +409,7 @@ subroutine pdsaitr
- c           %---------------------------------------------------%
- c
-             if (msglvl .gt. 0) then
--               call pivout (comm, logfil, 1, j, ndigit,
-+               call pivout (comm, logfil, 1, [j], ndigit,
-      &                     '_saitr: ****** restart at step ******')
-             end if
- c
-@@ -767,7 +767,7 @@ subroutine pdsaitr
-          end if
- c
-          if (msglvl .gt. 0 .and. iter .gt. 0) then
--            call pivout (comm, logfil, 1, j, ndigit,
-+            call pivout (comm, logfil, 1, [j], ndigit,
-      &           '_naitr: Iterative refinement for Arnoldi residual')
-             if (msglvl .gt. 2) then
-                 xtemp(1) = rnorm
-diff --git a/PARPACK/SRC/BLACS/pdsapps.f b/PARPACK/SRC/BLACS/pdsapps.f
-index b3a05cf4..4e2c0760 100644
---- a/PARPACK/SRC/BLACS/pdsapps.f
-+++ b/PARPACK/SRC/BLACS/pdsapps.f
-@@ -272,9 +272,9 @@ subroutine pdsapps
-             big   = abs(h(i,2)) + abs(h(i+1,2))
-             if (h(i+1,1) .le. epsmch*big) then
-                if (msglvl .gt. 0) then
--                  call pivout (comm, logfil, 1, i, ndigit,
-+                  call pivout (comm, logfil, 1, [i], ndigit,
-      &                 '_sapps: deflation at row/column no.')
--                  call pivout (comm, logfil, 1, jj, ndigit,
-+                  call pivout (comm, logfil, 1, [jj], ndigit,
-      &                 '_sapps: occurred before shift number.')
-                   call pdvout (comm, logfil, 1, h(i+1,1), ndigit,
-      &                 '_sapps: the corresponding off diagonal element')
-@@ -443,7 +443,7 @@ subroutine pdsapps
-          big   = abs(h(i,2)) + abs(h(i+1,2))
-          if (h(i+1,1) .le. epsmch*big) then
-             if (msglvl .gt. 0) then
--               call pivout (comm, logfil, 1, i, ndigit,
-+               call pivout (comm, logfil, 1, [i], ndigit,
-      &              '_sapps: deflation at row/column no.')
-                call pdvout (comm, logfil, 1, h(i+1,1), ndigit,
-      &              '_sapps: the corresponding off diagonal element')
-diff --git a/PARPACK/SRC/BLACS/pdsaup2.f b/PARPACK/SRC/BLACS/pdsaup2.f
-index cf934016..599aad62 100644
---- a/PARPACK/SRC/BLACS/pdsaup2.f
-+++ b/PARPACK/SRC/BLACS/pdsaup2.f
-@@ -421,13 +421,13 @@ subroutine pdsaup2
-          iter = iter + 1
- c
-          if (msglvl .gt. 0) then
--            call pivout (comm, logfil, 1, iter, ndigit,
-+            call pivout (comm, logfil, 1, [iter], ndigit,
-      &           '_saup2: **** Start of major iteration number ****')
-          end if
-          if (msglvl .gt. 1) then
--            call pivout (comm, logfil, 1, nev, ndigit,
-+            call pivout (comm, logfil, 1, [nev], ndigit,
-      &     '_saup2: The length of the current Lanczos factorization')
--            call pivout (comm, logfil, 1, np, ndigit,
-+            call pivout (comm, logfil, 1, [np], ndigit,
-      &           '_saup2: Extend the Lanczos factorization by')
-          end if
- c
-@@ -466,7 +466,7 @@ subroutine pdsaup2
-          update = .false.
- c
-          if (msglvl .gt. 1) then
--            call pdvout (comm, logfil, 1, rnorm, ndigit,
-+            call pdvout (comm, logfil, 1, [rnorm], ndigit,
-      &           '_saup2: Current B-norm of residual for factorization')
-          end if
- c
-@@ -716,7 +716,7 @@ subroutine pdsaup2
-          end if
- c
-          if (msglvl .gt. 0) then
--            call pivout (comm, logfil, 1, nconv, ndigit,
-+            call pivout (comm, logfil, 1, [nconv], ndigit,
-      &           '_saup2: no. of "converged" Ritz values at this iter.')
-             if (msglvl .gt. 1) then
-                kp(1) = nev
-@@ -763,7 +763,7 @@ subroutine pdsaup2
-          if (ishift .eq. 0) call dcopy (np, workl, 1, ritz, 1)
- c
-          if (msglvl .gt. 2) then
--            call pivout (comm, logfil, 1, np, ndigit,
-+            call pivout (comm, logfil, 1, [np], ndigit,
-      &                  '_saup2: The number of shifts to apply ')
-             call pdvout (comm, logfil, np, workl, ndigit,
-      &                  '_saup2: shifts selected')
-@@ -831,7 +831,7 @@ subroutine pdsaup2
-   130    continue
- c
-          if (msglvl .gt. 2) then
--            call pdvout (comm, logfil, 1, rnorm, ndigit,
-+            call pdvout (comm, logfil, 1, [rnorm], ndigit,
-      &      '_saup2: B-norm of residual for NEV factorization')
-             call pdvout (comm, logfil, nev, h(1,2), ndigit,
-      &           '_saup2: main diagonal of compressed H matrix')
-diff --git a/PARPACK/SRC/BLACS/pdsaupd.f b/PARPACK/SRC/BLACS/pdsaupd.f
-index 5f606d59..cb021128 100644
---- a/PARPACK/SRC/BLACS/pdsaupd.f
-+++ b/PARPACK/SRC/BLACS/pdsaupd.f
-@@ -644,9 +644,9 @@ subroutine pdsaupd
-       if (info .eq. 2) info = 3
- c
-       if (msglvl .gt. 0) then
--         call pivout (comm, logfil, 1, mxiter, ndigit,
-+         call pivout (comm, logfil, 1, [mxiter], ndigit,
-      &               '_saupd: number of update iterations taken')
--         call pivout (comm, logfil, 1, np, ndigit,
-+         call pivout (comm, logfil, 1, [np], ndigit,
-      &               '_saupd: number of "converged" Ritz values')
-          call pdvout  (comm, logfil, np, workl(Ritz), ndigit,
-      &               '_saupd: final Ritz values')
-diff --git a/PARPACK/SRC/BLACS/pdseupd.f b/PARPACK/SRC/BLACS/pdseupd.f
-index 956891cd..074b195b 100644
---- a/PARPACK/SRC/BLACS/pdseupd.f
-+++ b/PARPACK/SRC/BLACS/pdseupd.f
-@@ -523,9 +523,9 @@ subroutine pdseupd
- c        %-----------------------------------------------------------%
- c
-          if (msglvl .gt. 2) then
--             call pivout(comm, logfil, 1, numcnv, ndigit,
-+             call pivout(comm, logfil, 1, [numcnv], ndigit,
-      &            '_neupd: Number of specified eigenvalues')
--             call pivout(comm, logfil, 1, nconv, ndigit,
-+             call pivout(comm, logfil, 1, [nconv], ndigit,
-      &            '_neupd: Number of "converged" eigenvalues')
-          end if
- c
-diff --git a/PARPACK/SRC/BLACS/pdsgets.f b/PARPACK/SRC/BLACS/pdsgets.f
-index aa549a25..d0f703bb 100644
---- a/PARPACK/SRC/BLACS/pdsgets.f
-+++ b/PARPACK/SRC/BLACS/pdsgets.f
-@@ -216,8 +216,8 @@ subroutine pdsgets
-       tsgets = tsgets + (t1 - t0)
- c
-       if (msglvl .gt. 0) then
--         call pivout (comm, logfil, 1, kev, ndigit, '_sgets: KEV is')
--         call pivout (comm, logfil, 1, np, ndigit, '_sgets: NP is')
-+         call pivout (comm, logfil, 1, [kev], ndigit, '_sgets: KEV is')
-+         call pivout (comm, logfil, 1, [np], ndigit, '_sgets: NP is')
-          call pdvout (comm, logfil, kev+np, ritz, ndigit,
-      &        '_sgets: Eigenvalues of current H matrix')
-          call pdvout (comm, logfil, kev+np, bounds, ndigit,
-diff --git a/PARPACK/SRC/BLACS/psgetv0.f b/PARPACK/SRC/BLACS/psgetv0.f
-index 9862d055..d48cb6db 100644
---- a/PARPACK/SRC/BLACS/psgetv0.f
-+++ b/PARPACK/SRC/BLACS/psgetv0.f
-@@ -385,9 +385,9 @@ subroutine psgetv0
- c     %--------------------------------------%
- c
-       if (msglvl .gt. 2) then
--          call psvout (comm, logfil, 1, rnorm0, ndigit,
-+          call psvout (comm, logfil, 1, [rnorm0], ndigit,
-      &                '_getv0: re-orthonalization ; rnorm0 is')
--          call psvout (comm, logfil, 1, rnorm, ndigit,
-+          call psvout (comm, logfil, 1, [rnorm], ndigit,
-      &                '_getv0: re-orthonalization ; rnorm is')
-       end if
- c
-@@ -418,7 +418,7 @@ subroutine psgetv0
-    50 continue
- c
-       if (msglvl .gt. 0) then
--         call psvout (comm, logfil, 1, rnorm, ndigit,
-+         call psvout (comm, logfil, 1, [rnorm], ndigit,
-      &        '_getv0: B-norm of initial / restarted starting vector')
-       end if
-       if (msglvl .gt. 2) then
-diff --git a/PARPACK/SRC/BLACS/psnaitr.f b/PARPACK/SRC/BLACS/psnaitr.f
-index 07aa0526..bbd2809c 100644
---- a/PARPACK/SRC/BLACS/psnaitr.f
-+++ b/PARPACK/SRC/BLACS/psnaitr.f
-@@ -390,9 +390,9 @@ subroutine psnaitr
-  1000 continue
- c
-          if (msglvl .gt. 1) then
--            call pivout (comm, logfil, 1, j, ndigit,
-+            call pivout (comm, logfil, 1, [j], ndigit,
-      &                  '_naitr: generating Arnoldi vector number')
--            call psvout (comm, logfil, 1, rnorm, ndigit,
-+            call psvout (comm, logfil, 1, [rnorm], ndigit,
-      &                  '_naitr: B-norm of the current residual is')
-          end if
- c
-@@ -412,7 +412,7 @@ subroutine psnaitr
- c           %---------------------------------------------------%
- c
-             if (msglvl .gt. 0) then
--               call pivout (comm, logfil, 1, j, ndigit,
-+               call pivout (comm, logfil, 1, [j], ndigit,
-      &                     '_naitr: ****** RESTART AT STEP ******')
-             end if
- c
-@@ -745,7 +745,7 @@ subroutine psnaitr
-          end if
- c
-          if (msglvl .gt. 0 .and. iter .gt. 0) then
--            call pivout (comm, logfil, 1, j, ndigit,
-+            call pivout (comm, logfil, 1, [j], ndigit,
-      &           '_naitr: Iterative refinement for Arnoldi residual')
-             if (msglvl .gt. 2) then
-                 xtemp(1) = rnorm
-diff --git a/PARPACK/SRC/BLACS/psnapps.f b/PARPACK/SRC/BLACS/psnapps.f
-index a515d0cd..ba668bba 100644
---- a/PARPACK/SRC/BLACS/psnapps.f
-+++ b/PARPACK/SRC/BLACS/psnapps.f
-@@ -276,11 +276,11 @@ subroutine psnapps
-          sigmai = shifti(jj)
- c
-          if (msglvl .gt. 2 ) then
--            call pivout (comm, logfil, 1, jj, ndigit,
-+            call pivout (comm, logfil, 1, [jj], ndigit,
-      &               '_napps: shift number.')
--            call psvout (comm, logfil, 1, sigmar, ndigit,
-+            call psvout (comm, logfil, 1, [sigmar], ndigit,
-      &               '_napps: The real part of the shift ')
--            call psvout (comm, logfil, 1, sigmai, ndigit,
-+            call psvout (comm, logfil, 1, [sigmai], ndigit,
-      &               '_napps: The imaginary part of the shift ')
-          end if
- c
-@@ -347,7 +347,7 @@ subroutine psnapps
-                if (msglvl .gt. 0) then
-                   call pivout (comm, logfil, 1, i, ndigit,
-      &                 '_napps: matrix splitting at row/column no.')
--                  call pivout (comm, logfil, 1, jj, ndigit,
-+                  call pivout (comm, logfil, 1, [jj], ndigit,
-      &                 '_napps: matrix splitting with shift number.')
-                   call psvout (comm, logfil, 1, h(i+1,i), ndigit,
-      &                 '_napps: off diagonal element.')
-@@ -361,9 +361,9 @@ subroutine psnapps
-    40    continue
- c
-          if (msglvl .gt. 2) then
--             call pivout (comm, logfil, 1, istart, ndigit,
-+             call pivout (comm, logfil, 1, [istart], ndigit,
-      &                   '_napps: Start of current block ')
--             call pivout (comm, logfil, 1, iend, ndigit,
-+             call pivout (comm, logfil, 1, [iend], ndigit,
-      &                   '_napps: End of current block ')
-          end if
- c
-@@ -635,7 +635,7 @@ subroutine psnapps
-      &        '_napps: sigmak = (e_{kev+p}^T*Q)*e_{kev}')
-          call psvout (comm, logfil, 1, h(kev+1,kev), ndigit,
-      &        '_napps: betak = e_{kev+1}^T*H*e_{kev}')
--         call pivout (comm, logfil, 1, kev, ndigit,
-+         call pivout (comm, logfil, 1, [kev], ndigit,
-      &               '_napps: Order of the final Hessenberg matrix ')
-          if (msglvl .gt. 2) then
-             call psmout (comm, logfil, kev, kev, h, ldh, ndigit,
-diff --git a/PARPACK/SRC/BLACS/psnaup2.f b/PARPACK/SRC/BLACS/psnaup2.f
-index eff2a136..e4603273 100644
---- a/PARPACK/SRC/BLACS/psnaup2.f
-+++ b/PARPACK/SRC/BLACS/psnaup2.f
-@@ -405,7 +405,7 @@ subroutine psnaup2
-          iter = iter + 1
- c
-          if (msglvl .gt. 0) then
--            call pivout (comm, logfil, 1, iter, ndigit,
-+            call pivout (comm, logfil, 1, [iter], ndigit,
-      &           '_naup2: **** Start of major iteration number ****')
-          end if
- c
-@@ -418,9 +418,9 @@ subroutine psnaup2
-          np  = kplusp - nev
- c
-          if (msglvl .gt. 1) then
--            call pivout (comm, logfil, 1, nev, ndigit,
-+            call pivout (comm, logfil, 1, [nev], ndigit,
-      &     '_naup2: The length of the current Arnoldi factorization')
--            call pivout (comm, logfil, 1, np, ndigit,
-+            call pivout (comm, logfil, 1, [np], ndigit,
-      &           '_naup2: Extend the Arnoldi factorization by')
-          end if
- c
-@@ -452,7 +452,7 @@ subroutine psnaup2
-          update = .false.
- c
-          if (msglvl .gt. 1) then
--            call psvout (comm, logfil, 1, rnorm, ndigit,
-+            call psvout (comm, logfil, 1, [rnorm], ndigit,
-      &           '_naup2: Corresponding B-norm of the residual')
-          end if
- c
-@@ -696,7 +696,7 @@ subroutine psnaup2
-          end if
- c
-          if (msglvl .gt. 0) then
--            call pivout (comm, logfil, 1, nconv, ndigit,
-+            call pivout (comm, logfil, 1, [nconv], ndigit,
-      &           '_naup2: no. of "converged" Ritz values at this iter.')
-             if (msglvl .gt. 1) then
-                kp(1) = nev
-@@ -748,7 +748,7 @@ subroutine psnaup2
-          end if
- c
-          if (msglvl .gt. 2) then
--            call pivout (comm, logfil, 1, np, ndigit,
-+            call pivout (comm, logfil, 1, [np], ndigit,
-      &                  '_naup2: The number of shifts to apply ')
-             call psvout (comm, logfil, np, ritzr, ndigit,
-      &                  '_naup2: Real part of the shifts')
-@@ -815,7 +815,7 @@ subroutine psnaup2
-          cnorm = .false.
- c
-          if (msglvl .gt. 2) then
--            call psvout (comm, logfil, 1, rnorm, ndigit,
-+            call psvout (comm, logfil, 1, [rnorm], ndigit,
-      &      '_naup2: B-norm of residual for compressed factorization')
-             call psmout (comm, logfil, nev, nev, h, ldh, ndigit,
-      &        '_naup2: Compressed upper Hessenberg matrix H')
-diff --git a/PARPACK/SRC/BLACS/psnaupd.f b/PARPACK/SRC/BLACS/psnaupd.f
-index 55f34ce6..4f2484f9 100644
---- a/PARPACK/SRC/BLACS/psnaupd.f
-+++ b/PARPACK/SRC/BLACS/psnaupd.f
-@@ -642,9 +642,9 @@ subroutine psnaupd
-       if (info .eq. 2) info = 3
- c
-       if (msglvl .gt. 0) then
--         call pivout (comm, logfil, 1, mxiter, ndigit,
-+         call pivout (comm, logfil, 1, [mxiter], ndigit,
-      &               '_naupd: Number of update iterations taken')
--         call pivout (comm, logfil, 1, np, ndigit,
-+         call pivout (comm, logfil, 1, [np], ndigit,
-      &               '_naupd: Number of wanted "converged" Ritz values')
-          call psvout (comm, logfil, np, workl(ritzr), ndigit,
-      &               '_naupd: Real part of the final Ritz values')
-diff --git a/PARPACK/SRC/BLACS/psneupd.f b/PARPACK/SRC/BLACS/psneupd.f
-index 49847ffe..cbdaba28 100644
---- a/PARPACK/SRC/BLACS/psneupd.f
-+++ b/PARPACK/SRC/BLACS/psneupd.f
-@@ -617,9 +617,9 @@ subroutine psneupd
- c        %-----------------------------------------------------------%
- c
-          if (msglvl .gt. 2) then
--             call pivout(comm, logfil, 1, numcnv, ndigit,
-+             call pivout(comm, logfil, 1, [numcnv], ndigit,
-      &            '_neupd: Number of specified eigenvalues')
--             call pivout(comm, logfil, 1, nconv, ndigit,
-+             call pivout(comm, logfil, 1, [nconv], ndigit,
-      &            '_neupd: Number of "converged" eigenvalues')
-          end if
- c
-diff --git a/PARPACK/SRC/BLACS/psngets.f b/PARPACK/SRC/BLACS/psngets.f
-index c0e30886..33d85dfe 100644
---- a/PARPACK/SRC/BLACS/psngets.f
-+++ b/PARPACK/SRC/BLACS/psngets.f
-@@ -226,8 +226,8 @@ subroutine psngets
-       tngets = tngets + (t1 - t0)
- c
-       if (msglvl .gt. 0) then
--         call pivout (comm, logfil, 1, kev, ndigit, '_ngets: KEV is')
--         call pivout (comm, logfil, 1, np, ndigit, '_ngets: NP is')
-+         call pivout (comm, logfil, 1, [kev], ndigit, '_ngets: KEV is')
-+         call pivout (comm, logfil, 1, [np], ndigit, '_ngets: NP is')
-          call psvout (comm, logfil, kev+np, ritzr, ndigit,
-      &        '_ngets: Eigenvalues of current H matrix -- real part')
-          call psvout (comm, logfil, kev+np, ritzi, ndigit,
-diff --git a/PARPACK/SRC/BLACS/pssaitr.f b/PARPACK/SRC/BLACS/pssaitr.f
-index 50816c4f..e57864a5 100644
---- a/PARPACK/SRC/BLACS/pssaitr.f
-+++ b/PARPACK/SRC/BLACS/pssaitr.f
-@@ -389,9 +389,9 @@ subroutine pssaitr
-  1000 continue
- c
-          if (msglvl .gt. 2) then
--            call pivout (comm, logfil, 1, j, ndigit,
-+            call pivout (comm, logfil, 1, [j], ndigit,
-      &                  '_saitr: generating Arnoldi vector no.')
--            call psvout (comm, logfil, 1, rnorm, ndigit,
-+            call psvout (comm, logfil, 1, [rnorm], ndigit,
-      &                  '_saitr: B-norm of the current residual =')
-          end if
- c
-@@ -409,7 +409,7 @@ subroutine pssaitr
- c           %---------------------------------------------------%
- c
-             if (msglvl .gt. 0) then
--               call pivout (comm, logfil, 1, j, ndigit,
-+               call pivout (comm, logfil, 1, [j], ndigit,
-      &                     '_saitr: ****** restart at step ******')
-             end if
- c
-@@ -767,7 +767,7 @@ subroutine pssaitr
-          end if
- c
-          if (msglvl .gt. 0 .and. iter .gt. 0) then
--            call pivout (comm, logfil, 1, j, ndigit,
-+            call pivout (comm, logfil, 1, [j], ndigit,
-      &           '_naitr: Iterative refinement for Arnoldi residual')
-             if (msglvl .gt. 2) then
-                 xtemp(1) = rnorm
-diff --git a/PARPACK/SRC/BLACS/pssapps.f b/PARPACK/SRC/BLACS/pssapps.f
-index 7c8465b3..5198a734 100644
---- a/PARPACK/SRC/BLACS/pssapps.f
-+++ b/PARPACK/SRC/BLACS/pssapps.f
-@@ -272,9 +272,9 @@ subroutine pssapps
-             big   = abs(h(i,2)) + abs(h(i+1,2))
-             if (h(i+1,1) .le. epsmch*big) then
-                if (msglvl .gt. 0) then
--                  call pivout (comm, logfil, 1, i, ndigit,
-+                  call pivout (comm, logfil, 1, [i], ndigit,
-      &                 '_sapps: deflation at row/column no.')
--                  call pivout (comm, logfil, 1, jj, ndigit,
-+                  call pivout (comm, logfil, 1, [jj], ndigit,
-      &                 '_sapps: occurred before shift number.')
-                   call psvout (comm, logfil, 1, h(i+1,1), ndigit,
-      &                 '_sapps: the corresponding off diagonal element')
-@@ -443,7 +443,7 @@ subroutine pssapps
-          big   = abs(h(i,2)) + abs(h(i+1,2))
-          if (h(i+1,1) .le. epsmch*big) then
-             if (msglvl .gt. 0) then
--               call pivout (comm, logfil, 1, i, ndigit,
-+               call pivout (comm, logfil, 1, [i], ndigit,
-      &              '_sapps: deflation at row/column no.')
-                call psvout (comm, logfil, 1, h(i+1,1), ndigit,
-      &              '_sapps: the corresponding off diagonal element')
-diff --git a/PARPACK/SRC/BLACS/pssaup2.f b/PARPACK/SRC/BLACS/pssaup2.f
-index 57ab391b..87cc3a81 100644
---- a/PARPACK/SRC/BLACS/pssaup2.f
-+++ b/PARPACK/SRC/BLACS/pssaup2.f
-@@ -421,13 +421,13 @@ subroutine pssaup2
-          iter = iter + 1
- c
-          if (msglvl .gt. 0) then
--            call pivout (comm, logfil, 1, iter, ndigit,
-+            call pivout (comm, logfil, 1, [iter], ndigit,
-      &           '_saup2: **** Start of major iteration number ****')
-          end if
-          if (msglvl .gt. 1) then
--            call pivout (comm, logfil, 1, nev, ndigit,
-+            call pivout (comm, logfil, 1, [nev], ndigit,
-      &     '_saup2: The length of the current Lanczos factorization')
--            call pivout (comm, logfil, 1, np, ndigit,
-+            call pivout (comm, logfil, 1, [np], ndigit,
-      &           '_saup2: Extend the Lanczos factorization by')
-          end if
- c
-@@ -466,7 +466,7 @@ subroutine pssaup2
-          update = .false.
- c
-          if (msglvl .gt. 1) then
--            call psvout (comm, logfil, 1, rnorm, ndigit,
-+            call psvout (comm, logfil, 1, [rnorm], ndigit,
-      &           '_saup2: Current B-norm of residual for factorization')
-          end if
- c
-@@ -716,7 +716,7 @@ subroutine pssaup2
-          end if
- c
-          if (msglvl .gt. 0) then
--            call pivout (comm, logfil, 1, nconv, ndigit,
-+            call pivout (comm, logfil, 1, [nconv], ndigit,
-      &           '_saup2: no. of "converged" Ritz values at this iter.')
-             if (msglvl .gt. 1) then
-                kp(1) = nev
-@@ -763,7 +763,7 @@ subroutine pssaup2
-          if (ishift .eq. 0) call scopy (np, workl, 1, ritz, 1)
- c
-          if (msglvl .gt. 2) then
--            call pivout (comm, logfil, 1, np, ndigit,
-+            call pivout (comm, logfil, 1, [np], ndigit,
-      &                  '_saup2: The number of shifts to apply ')
-             call psvout (comm, logfil, np, workl, ndigit,
-      &                  '_saup2: shifts selected')
-@@ -831,7 +831,7 @@ subroutine pssaup2
-   130    continue
- c
-          if (msglvl .gt. 2) then
--            call psvout (comm, logfil, 1, rnorm, ndigit,
-+            call psvout (comm, logfil, 1, [rnorm], ndigit,
-      &      '_saup2: B-norm of residual for NEV factorization')
-             call psvout (comm, logfil, nev, h(1,2), ndigit,
-      &           '_saup2: main diagonal of compressed H matrix')
-diff --git a/PARPACK/SRC/BLACS/pssaupd.f b/PARPACK/SRC/BLACS/pssaupd.f
-index 1b276e86..9d6061c1 100644
---- a/PARPACK/SRC/BLACS/pssaupd.f
-+++ b/PARPACK/SRC/BLACS/pssaupd.f
-@@ -644,9 +644,9 @@ subroutine pssaupd
-       if (info .eq. 2) info = 3
- c
-       if (msglvl .gt. 0) then
--         call pivout (comm, logfil, 1, mxiter, ndigit,
-+         call pivout (comm, logfil, 1, [mxiter], ndigit,
-      &               '_saupd: number of update iterations taken')
--         call pivout (comm, logfil, 1, np, ndigit,
-+         call pivout (comm, logfil, 1, [np], ndigit,
-      &               '_saupd: number of "converged" Ritz values')
-          call psvout (comm, logfil, np, workl(Ritz), ndigit,
-      &               '_saupd: final Ritz values')
-diff --git a/PARPACK/SRC/BLACS/psseupd.f b/PARPACK/SRC/BLACS/psseupd.f
-index 68edab15..e8c910e8 100644
---- a/PARPACK/SRC/BLACS/psseupd.f
-+++ b/PARPACK/SRC/BLACS/psseupd.f
-@@ -523,9 +523,9 @@ subroutine psseupd
- c        %-----------------------------------------------------------%
- c
-          if (msglvl .gt. 2) then
--             call pivout(comm, logfil, 1, numcnv, ndigit,
-+             call pivout(comm, logfil, 1, [numcnv], ndigit,
-      &            '_neupd: Number of specified eigenvalues')
--             call pivout(comm, logfil, 1, nconv, ndigit,
-+             call pivout(comm, logfil, 1, [nconv], ndigit,
-      &            '_neupd: Number of "converged" eigenvalues')
-          end if
- c
-diff --git a/PARPACK/SRC/BLACS/pssgets.f b/PARPACK/SRC/BLACS/pssgets.f
-index d138282a..660c274f 100644
---- a/PARPACK/SRC/BLACS/pssgets.f
-+++ b/PARPACK/SRC/BLACS/pssgets.f
-@@ -216,8 +216,8 @@ subroutine pssgets
-       tsgets = tsgets + (t1 - t0)
- c
-       if (msglvl .gt. 0) then
--         call pivout (comm, logfil, 1, kev, ndigit, '_sgets: KEV is')
--         call pivout (comm, logfil, 1, np, ndigit, '_sgets: NP is')
-+         call pivout (comm, logfil, 1, [kev], ndigit, '_sgets: KEV is')
-+         call pivout (comm, logfil, 1, [np], ndigit, '_sgets: NP is')
-          call psvout (comm, logfil, kev+np, ritz, ndigit,
-      &        '_sgets: Eigenvalues of current H matrix')
-          call psvout (comm, logfil, kev+np, bounds, ndigit,
-diff --git a/PARPACK/SRC/BLACS/pzgetv0.f b/PARPACK/SRC/BLACS/pzgetv0.f
-index 09723313..c1d173f0 100644
---- a/PARPACK/SRC/BLACS/pzgetv0.f
-+++ b/PARPACK/SRC/BLACS/pzgetv0.f
-@@ -406,9 +406,9 @@ subroutine pzgetv0
- c     %--------------------------------------%
- c
-       if (msglvl .gt. 2) then
--          call pdvout  (comm, logfil, 1, rnorm0, ndigit,
-+          call pdvout  (comm, logfil, 1, [rnorm0], ndigit,
-      &                '_getv0: re-orthonalization ; rnorm0 is')
--          call pdvout  (comm, logfil, 1, rnorm, ndigit,
-+          call pdvout  (comm, logfil, 1, [rnorm], ndigit,
-      &                '_getv0: re-orthonalization ; rnorm is')
-       end if
- c
-@@ -440,7 +440,7 @@ subroutine pzgetv0
- c
-       if (msglvl .gt. 0) then
-          cnorm2 = dcmplx (rnorm,rzero)
--         call pzvout  (comm, logfil, 1, cnorm2, ndigit,
-+         call pzvout  (comm, logfil, 1, [cnorm2], ndigit,
-      &        '_getv0: B-norm of initial / restarted starting vector')
-       end if
-       if (msglvl .gt. 2) then
-diff --git a/PARPACK/SRC/BLACS/pznaitr.f b/PARPACK/SRC/BLACS/pznaitr.f
-index 61f467a2..92db7fe7 100644
---- a/PARPACK/SRC/BLACS/pznaitr.f
-+++ b/PARPACK/SRC/BLACS/pznaitr.f
-@@ -401,9 +401,9 @@ subroutine pznaitr
-  1000 continue
- c
-          if (msglvl .gt. 1) then
--            call pivout (comm, logfil, 1, j, ndigit,
-+            call pivout (comm, logfil, 1, [j], ndigit,
-      &                  '_naitr: generating Arnoldi vector number')
--            call pzvout (comm, logfil, 1, rnorm, ndigit,
-+            call pzvout (comm, logfil, 1, [rnorm], ndigit,
-      &                  '_naitr: B-norm of the current residual is')
-          end if
- c
-@@ -423,7 +423,7 @@ subroutine pznaitr
- c           %---------------------------------------------------%
- c
-             if (msglvl .gt. 0) then
--               call pivout (comm, logfil, 1, j, ndigit,
-+               call pivout (comm, logfil, 1, [j], ndigit,
-      &                     '_naitr: ****** RESTART AT STEP ******')
-             end if
- c
-@@ -757,7 +757,7 @@ subroutine pznaitr
-          end if
- c
-          if (msglvl .gt. 0 .and. iter .gt. 0 ) then
--            call pivout (comm, logfil, 1, j, ndigit,
-+            call pivout (comm, logfil, 1, [j], ndigit,
-      &           '_naitr: Iterative refinement for Arnoldi residual')
-             if (msglvl .gt. 2) then
-                 rtemp(1) = rnorm
-diff --git a/PARPACK/SRC/BLACS/pznapps.f b/PARPACK/SRC/BLACS/pznapps.f
-index 796f4ded..155038d1 100644
---- a/PARPACK/SRC/BLACS/pznapps.f
-+++ b/PARPACK/SRC/BLACS/pznapps.f
-@@ -284,9 +284,9 @@ subroutine pznapps
-          sigma = shift(jj)
- c
-          if (msglvl .gt. 2 ) then
--            call pivout (comm, logfil, 1, jj, ndigit,
-+            call pivout (comm, logfil, 1, [jj], ndigit,
-      &               '_napps: shift number.')
--            call pzvout (comm, logfil, 1, sigma, ndigit,
-+            call pzvout (comm, logfil, 1, [sigma], ndigit,
-      &               '_napps: Value of the shift ')
-          end if
- c
-@@ -307,9 +307,9 @@ subroutine pznapps
-             if ( abs(dble(h(i+1,i)))
-      &           .le. max(ulp*tst1, smlnum) )  then
-                if (msglvl .gt. 0) then
--                  call pivout (comm, logfil, 1, i, ndigit,
-+                  call pivout (comm, logfil, 1, [i], ndigit,
-      &                 '_napps: matrix splitting at row/column no.')
--                  call pivout (comm, logfil, 1, jj, ndigit,
-+                  call pivout (comm, logfil, 1, [jj], ndigit,
-      &                 '_napps: matrix splitting with shift number.')
-                   call pzvout (comm, logfil, 1, h(i+1,i), ndigit,
-      &                 '_napps: off diagonal element.')
-@@ -323,9 +323,9 @@ subroutine pznapps
-    40    continue
- c
-          if (msglvl .gt. 2) then
--             call pivout (comm, logfil, 1, istart, ndigit,
-+             call pivout (comm, logfil, 1, [istart], ndigit,
-      &                   '_napps: Start of current block ')
--             call pivout (comm, logfil, 1, iend, ndigit,
-+             call pivout (comm, logfil, 1, [iend], ndigit,
-      &                   '_napps: End of current block ')
-          end if
- c
-@@ -501,7 +501,7 @@ subroutine pznapps
-      &        '_napps: sigmak = (e_{kev+p}^T*Q)*e_{kev}')
-          call pzvout (comm, logfil, 1, h(kev+1,kev), ndigit,
-      &        '_napps: betak = e_{kev+1}^T*H*e_{kev}')
--         call pivout (comm, logfil, 1, kev, ndigit,
-+         call pivout (comm, logfil, 1, [kev], ndigit,
-      &               '_napps: Order of the final Hessenberg matrix ')
-          if (msglvl .gt. 2) then
-             call pzmout (comm, logfil, kev, kev, h, ldh, ndigit,
-diff --git a/PARPACK/SRC/BLACS/pznaup2.f b/PARPACK/SRC/BLACS/pznaup2.f
-index 22b46dd2..1610a588 100644
---- a/PARPACK/SRC/BLACS/pznaup2.f
-+++ b/PARPACK/SRC/BLACS/pznaup2.f
-@@ -398,7 +398,7 @@ subroutine pznaup2
-          iter = iter + 1
- c
-          if (msglvl .gt. 0) then
--            call pivout (comm, logfil, 1, iter, ndigit,
-+            call pivout (comm, logfil, 1, [iter], ndigit,
-      &           '_naup2: **** Start of major iteration number ****')
-          end if
- c
-@@ -411,9 +411,9 @@ subroutine pznaup2
-          np  = kplusp - nev
- c
-          if (msglvl .gt. 1) then
--            call pivout (comm, logfil, 1, nev, ndigit,
-+            call pivout (comm, logfil, 1, [nev], ndigit,
-      &     '_naup2: The length of the current Arnoldi factorization')
--            call pivout (comm, logfil, 1, np, ndigit,
-+            call pivout (comm, logfil, 1, [np], ndigit,
-      &           '_naup2: Extend the Arnoldi factorization by')
-          end if
- c
-@@ -440,7 +440,7 @@ subroutine pznaup2
-          update = .false.
- c
-          if (msglvl .gt. 1) then
--            call pdvout (comm, logfil, 1, rnorm, ndigit,
-+            call pdvout (comm, logfil, 1, [rnorm], ndigit,
-      &           '_naup2: Corresponding B-norm of the residual')
-          end if
- c
-@@ -671,7 +671,7 @@ subroutine pznaup2
-          end if
- c
-          if (msglvl .gt. 0) then
--            call pivout (comm, logfil, 1, nconv, ndigit,
-+            call pivout (comm, logfil, 1, [nconv], ndigit,
-      &           '_naup2: no. of "converged" Ritz values at this iter.')
-             if (msglvl .gt. 1) then
-                kp(1) = nev
-@@ -711,7 +711,7 @@ subroutine pznaup2
-          end if
- c
-          if (msglvl .gt. 2) then
--            call pivout (comm, logfil, 1, np, ndigit,
-+            call pivout (comm, logfil, 1, [np], ndigit,
-      &                  '_naup2: The number of shifts to apply ')
-             call pzvout (comm, logfil, np, ritz, ndigit,
-      &                  '_naup2: values of the shifts')
-@@ -776,7 +776,7 @@ subroutine pznaup2
-          cnorm = .false.
- c
-          if (msglvl .gt. 2) then
--            call pdvout (comm, logfil, 1, rnorm, ndigit,
-+            call pdvout (comm, logfil, 1, [rnorm], ndigit,
-      &      '_naup2: B-norm of residual for compressed factorization')
-             call pzmout (comm, logfil, nev, nev, h, ldh, ndigit,
-      &        '_naup2: Compressed upper Hessenberg matrix H')
-diff --git a/PARPACK/SRC/BLACS/pznaupd.f b/PARPACK/SRC/BLACS/pznaupd.f
-index 0bf616f9..b46679a6 100644
---- a/PARPACK/SRC/BLACS/pznaupd.f
-+++ b/PARPACK/SRC/BLACS/pznaupd.f
-@@ -618,9 +618,9 @@ subroutine pznaupd
-       if (info .eq. 2) info = 3
- c
-       if (msglvl .gt. 0) then
--         call pivout (comm, logfil, 1, mxiter, ndigit,
-+         call pivout (comm, logfil, 1, [mxiter], ndigit,
-      &               '_naupd: Number of update iterations taken')
--         call pivout (comm, logfil, 1, np, ndigit,
-+         call pivout (comm, logfil, 1, [np], ndigit,
-      &               '_naupd: Number of wanted "converged" Ritz values')
-          call pzvout  (comm, logfil, np, workl(ritz), ndigit,
-      &               '_naupd: The final Ritz values')
-diff --git a/PARPACK/SRC/BLACS/pzneupd.f b/PARPACK/SRC/BLACS/pzneupd.f
-index 1970e488..c2f508f2 100644
---- a/PARPACK/SRC/BLACS/pzneupd.f
-+++ b/PARPACK/SRC/BLACS/pzneupd.f
-@@ -558,9 +558,9 @@ subroutine pzneupd
- c        %-----------------------------------------------------------%
- c
-          if (msglvl .gt. 2) then
--             call pivout(comm, logfil, 1, numcnv, ndigit,
-+             call pivout(comm, logfil, 1, [numcnv], ndigit,
-      &            '_neupd: Number of specified eigenvalues')
--             call pivout(comm, logfil, 1, nconv, ndigit,
-+             call pivout(comm, logfil, 1, [nconv], ndigit,
-      &            '_neupd: Number of "converged" eigenvalues')
-          end if
- c
-diff --git a/PARPACK/SRC/BLACS/pzngets.f b/PARPACK/SRC/BLACS/pzngets.f
-index 18e1518d..d880b4cc 100644
---- a/PARPACK/SRC/BLACS/pzngets.f
-+++ b/PARPACK/SRC/BLACS/pzngets.f
-@@ -177,8 +177,8 @@ subroutine pzngets ( comm, ishift, which, kev, np, ritz, bounds)
-       tcgets = tcgets + (t1 - t0)
- c
-       if (msglvl .gt. 0) then
--         call pivout (comm, logfil, 1, kev, ndigit, '_ngets: KEV is')
--         call pivout (comm, logfil, 1, np, ndigit, '_ngets: NP is')
-+         call pivout (comm, logfil, 1, [kev], ndigit, '_ngets: KEV is')
-+         call pivout (comm, logfil, 1, [np], ndigit, '_ngets: NP is')
-          call pzvout (comm, logfil, kev+np, ritz, ndigit,
-      &        '_ngets: Eigenvalues of current H matrix ')
-          call pzvout (comm, logfil, kev+np, bounds, ndigit,
-diff --git a/PARPACK/SRC/MPI/pcgetv0.f b/PARPACK/SRC/MPI/pcgetv0.f
-index aacfd046..72677a50 100644
---- a/PARPACK/SRC/MPI/pcgetv0.f
-+++ b/PARPACK/SRC/MPI/pcgetv0.f
-@@ -185,7 +185,7 @@ subroutine pcgetv0
-       save       first, iseed, inits, iter, msglvl, orth, rnorm0
- c
-       Complex
--     &           cnorm_buf
-+     &           cnorm_buf, buf2(1)
- c
- c     %----------------------%
- c     | External Subroutines |
-@@ -332,8 +332,9 @@ subroutine pcgetv0
-       first = .FALSE.
-       if (bmat .eq. 'G') then
-           cnorm_buf = cdotc (n, resid, 1, workd, 1)
--          call MPI_ALLREDUCE( cnorm_buf, cnorm, 1,
-+          call MPI_ALLREDUCE( [cnorm_buf], buf2, 1,
-      &          MPI_COMPLEX, MPI_SUM, comm, ierr )
-+          cnorm = buf2(1)
-           rnorm0 = sqrt(slapy2(real (cnorm),aimag(cnorm)))
-       else if (bmat .eq. 'I') then
-            rnorm0 = pscnorm2( comm, n, resid, 1)
-@@ -393,8 +394,9 @@ subroutine pcgetv0
- c
-       if (bmat .eq. 'G') then
-          cnorm_buf = cdotc (n, resid, 1, workd, 1)
--         call MPI_ALLREDUCE( cnorm_buf, cnorm, 1,
-+         call MPI_ALLREDUCE( [cnorm_buf], buf2, 1,
-      &            MPI_COMPLEX, MPI_SUM, comm, ierr )
-+         cnorm = buf2(1)
-          rnorm = sqrt(slapy2(real (cnorm),aimag(cnorm)))
-       else if (bmat .eq. 'I') then
-          rnorm = pscnorm2(comm, n, resid, 1)
-@@ -405,9 +407,9 @@ subroutine pcgetv0
- c     %--------------------------------------%
- c
-       if (msglvl .gt. 2) then
--          call psvout (comm, logfil, 1, rnorm0, ndigit,
-+          call psvout (comm, logfil, 1, [rnorm0], ndigit,
-      &                '_getv0: re-orthonalization ; rnorm0 is')
--          call psvout (comm, logfil, 1, rnorm, ndigit,
-+          call psvout (comm, logfil, 1, [rnorm], ndigit,
-      &                '_getv0: re-orthonalization ; rnorm is')
-       end if
- c
-@@ -439,7 +441,7 @@ subroutine pcgetv0
- c
-       if (msglvl .gt. 0) then
-          cnorm2 = cmplx(rnorm,rzero)
--         call pcvout (comm, logfil, 1, cnorm2, ndigit,
-+         call pcvout (comm, logfil, 1, [cnorm2], ndigit,
-      &        '_getv0: B-norm of initial / restarted starting vector')
-       end if
-       if (msglvl .gt. 2) then
-diff --git a/PARPACK/SRC/MPI/pcnaitr.f b/PARPACK/SRC/MPI/pcnaitr.f
-index 4a27960a..fe246ea0 100644
---- a/PARPACK/SRC/MPI/pcnaitr.f
-+++ b/PARPACK/SRC/MPI/pcnaitr.f
-@@ -293,7 +293,7 @@ subroutine pcnaitr
-      &           betaj, rnorm1, smlnum, ulp, unfl, wnorm
- c
-       Complex
--     &           cnorm_buf
-+     &           cnorm_buf, buf2(1)
- c
- c     %----------------------%
- c     | External Subroutines |
-@@ -404,9 +404,9 @@ subroutine pcnaitr
-  1000 continue
- c
-          if (msglvl .gt. 1) then
--            call pivout (comm, logfil, 1, j, ndigit,
-+            call pivout (comm, logfil, 1, [j], ndigit,
-      &                  '_naitr: generating Arnoldi vector number')
--            call pcvout (comm, logfil, 1, rnorm, ndigit,
-+            call pdvout (comm, logfil, 1, [rnorm], ndigit,
-      &                  '_naitr: B-norm of the current residual is')
-          end if
- c
-@@ -426,7 +426,7 @@ subroutine pcnaitr
- c           %---------------------------------------------------%
- c
-             if (msglvl .gt. 0) then
--               call pivout (comm, logfil, 1, j, ndigit,
-+               call pivout (comm, logfil, 1, [j], ndigit,
-      &                     '_naitr: ****** RESTART AT STEP ******')
-             end if
- c
-@@ -577,8 +577,9 @@ subroutine pcnaitr
- c
-          if (bmat .eq. 'G') then
-              cnorm_buf = cdotc (n, resid, 1, workd(ipj), 1)
--            call MPI_ALLREDUCE( cnorm_buf, cnorm, 1,
-+            call MPI_ALLREDUCE( [cnorm_buf], buf2, 1,
-      &           MPI_COMPLEX, MPI_SUM, comm, ierr )
-+             cnorm = buf2(1)
-              wnorm = sqrt( slapy2(real(cnorm),aimag(cnorm)) )
-          else if (bmat .eq. 'I') then
-              wnorm = pscnorm2(comm, n, resid, 1)
-@@ -653,8 +654,9 @@ subroutine pcnaitr
- c
-          if (bmat .eq. 'G') then
-             cnorm_buf = cdotc (n, resid, 1, workd(ipj), 1)
--            call MPI_ALLREDUCE( cnorm_buf, cnorm, 1,
-+            call MPI_ALLREDUCE( [cnorm_buf], buf2, 1,
-      &           MPI_COMPLEX, MPI_SUM, comm, ierr )
-+            cnorm = buf2(1)
-             rnorm = sqrt( slapy2(real(cnorm),aimag(cnorm)) )
-          else if (bmat .eq. 'I') then
-             rnorm = pscnorm2(comm, n, resid, 1)
-@@ -757,15 +759,16 @@ subroutine pcnaitr
- c
-          if (bmat .eq. 'G') then
-              cnorm_buf = cdotc (n, resid, 1, workd(ipj), 1)
--            call MPI_ALLREDUCE( cnorm_buf, cnorm, 1,
-+            call MPI_ALLREDUCE( [cnorm_buf], buf2, 1,
-      &           MPI_COMPLEX, MPI_SUM, comm, ierr )
-+             cnorm = buf2(1)
-              rnorm1 = sqrt( slapy2(real(cnorm),aimag(cnorm)) )
-          else if (bmat .eq. 'I') then
-              rnorm1 = pscnorm2(comm, n, resid, 1)
-          end if
- c
-          if (msglvl .gt. 0 .and. iter .gt. 0 ) then
--            call pivout (comm, logfil, 1, j, ndigit,
-+            call pivout (comm, logfil, 1, [j], ndigit,
-      &           '_naitr: Iterative refinement for Arnoldi residual')
-             if (msglvl .gt. 2) then
-                 rtemp(1) = rnorm
-diff --git a/PARPACK/SRC/MPI/pcnapps.f b/PARPACK/SRC/MPI/pcnapps.f
-index 76077b92..f17686d8 100644
---- a/PARPACK/SRC/MPI/pcnapps.f
-+++ b/PARPACK/SRC/MPI/pcnapps.f
-@@ -283,9 +283,9 @@ subroutine pcnapps
-          sigma = shift(jj)
- c
-          if (msglvl .gt. 2 ) then
--            call pivout (comm, logfil, 1, jj, ndigit,
-+            call pivout (comm, logfil, 1, [jj], ndigit,
-      &               '_napps: shift number.')
--            call pcvout (comm, logfil, 1, sigma, ndigit,
-+            call pcvout (comm, logfil, 1, [sigma], ndigit,
-      &               '_napps: Value of the shift ')
-          end if
- c
-@@ -306,9 +306,9 @@ subroutine pcnapps
-             if ( abs(real(h(i+1,i)))
-      &           .le. max(ulp*tst1, smlnum) )  then
-                if (msglvl .gt. 0) then
--                  call pivout (comm, logfil, 1, i, ndigit,
-+                  call pivout (comm, logfil, 1, [i], ndigit,
-      &                 '_napps: matrix splitting at row/column no.')
--                  call pivout (comm, logfil, 1, jj, ndigit,
-+                  call pivout (comm, logfil, 1, [jj], ndigit,
-      &                 '_napps: matrix splitting with shift number.')
-                   call pcvout (comm, logfil, 1, h(i+1,i), ndigit,
-      &                 '_napps: off diagonal element.')
-@@ -322,9 +322,9 @@ subroutine pcnapps
-    40    continue
- c
-          if (msglvl .gt. 2) then
--             call pivout (comm, logfil, 1, istart, ndigit,
-+             call pivout (comm, logfil, 1, [istart], ndigit,
-      &                   '_napps: Start of current block ')
--             call pivout (comm, logfil, 1, iend, ndigit,
-+             call pivout (comm, logfil, 1, [iend], ndigit,
-      &                   '_napps: End of current block ')
-          end if
- c
-@@ -500,7 +500,7 @@ subroutine pcnapps
-      &        '_napps: sigmak = (e_{kev+p}^T*Q)*e_{kev}')
-          call pcvout (comm, logfil, 1, h(kev+1,kev), ndigit,
-      &        '_napps: betak = e_{kev+1}^T*H*e_{kev}')
--         call pivout (comm, logfil, 1, kev, ndigit,
-+         call pivout (comm, logfil, 1, [kev], ndigit,
-      &               '_napps: Order of the final Hessenberg matrix ')
-          if (msglvl .gt. 2) then
-             call pcmout (comm, logfil, kev, kev, h, ldh, ndigit,
-diff --git a/PARPACK/SRC/MPI/pcnaup2.f b/PARPACK/SRC/MPI/pcnaup2.f
-index 91fe9293..4b0d6ceb 100644
---- a/PARPACK/SRC/MPI/pcnaup2.f
-+++ b/PARPACK/SRC/MPI/pcnaup2.f
-@@ -237,7 +237,7 @@ subroutine pcnaup2
-      &           nevbef, nev0 , np0,    eps23
- c
-       Real
--     &           cmpnorm_buf
-+     &           cmpnorm_buf, buf2(1)
- c
- c     %-----------------------%
- c     | Local array arguments |
-@@ -401,7 +401,7 @@ subroutine pcnaup2
-          iter = iter + 1
- c
-          if (msglvl .gt. 0) then
--            call pivout (comm, logfil, 1, iter, ndigit,
-+            call pivout (comm, logfil, 1, [iter], ndigit,
-      &           '_naup2: **** Start of major iteration number ****')
-          end if
- c
-@@ -414,9 +414,9 @@ subroutine pcnaup2
-          np  = kplusp - nev
- c
-          if (msglvl .gt. 1) then
--            call pivout (comm, logfil, 1, nev, ndigit,
-+            call pivout (comm, logfil, 1, [nev], ndigit,
-      &     '_naup2: The length of the current Arnoldi factorization')
--            call pivout (comm, logfil, 1, np, ndigit,
-+            call pivout (comm, logfil, 1, [np], ndigit,
-      &           '_naup2: Extend the Arnoldi factorization by')
-          end if
- c
-@@ -443,7 +443,7 @@ subroutine pcnaup2
-          update = .false.
- c
-          if (msglvl .gt. 1) then
--            call psvout (comm, logfil, 1, rnorm, ndigit,
-+            call psvout (comm, logfil, 1, [rnorm], ndigit,
-      &           '_naup2: Corresponding B-norm of the residual')
-          end if
- c
-@@ -674,7 +674,7 @@ subroutine pcnaup2
-          end if
- c
-          if (msglvl .gt. 0) then
--            call pivout (comm, logfil, 1, nconv, ndigit,
-+            call pivout (comm, logfil, 1, [nconv], ndigit,
-      &           '_naup2: no. of "converged" Ritz values at this iter.')
-             if (msglvl .gt. 1) then
-                kp(1) = nev
-@@ -714,7 +714,7 @@ subroutine pcnaup2
-          end if
- c
-          if (msglvl .gt. 2) then
--            call pivout (comm, logfil, 1, np, ndigit,
-+            call pivout (comm, logfil, 1, [np], ndigit,
-      &                  '_naup2: The number of shifts to apply ')
-             call pcvout (comm, logfil, np, ritz, ndigit,
-      &                  '_naup2: values of the shifts')
-@@ -771,8 +771,9 @@ subroutine pcnaup2
- c
-          if (bmat .eq. 'G') then
-             cmpnorm_buf = cdotc (n, resid, 1, workd, 1)
--            call MPI_ALLREDUCE( cmpnorm_buf, cmpnorm, 1,
-+            call MPI_ALLREDUCE( [cmpnorm_buf], buf2, 1,
-      &               MPI_COMPLEX, MPI_SUM, comm, ierr )
-+            cmpnorm = buf2(1)
-             rnorm = sqrt(slapy2(real(cmpnorm),aimag(cmpnorm)))
-          else if (bmat .eq. 'I') then
-             rnorm = pscnorm2(comm, n, resid, 1)
-@@ -780,7 +781,7 @@ subroutine pcnaup2
-          cnorm = .false.
- c
-          if (msglvl .gt. 2) then
--            call psvout (comm, logfil, 1, rnorm, ndigit,
-+            call psvout (comm, logfil, 1, [rnorm], ndigit,
-      &      '_naup2: B-norm of residual for compressed factorization')
-             call pcmout (comm, logfil, nev, nev, h, ldh, ndigit,
-      &        '_naup2: Compressed upper Hessenberg matrix H')
-diff --git a/PARPACK/SRC/MPI/pcnaupd.f b/PARPACK/SRC/MPI/pcnaupd.f
-index 5b8e1f5c..0bd6eb6c 100644
---- a/PARPACK/SRC/MPI/pcnaupd.f
-+++ b/PARPACK/SRC/MPI/pcnaupd.f
-@@ -626,9 +626,9 @@ subroutine pcnaupd
-       if (info .eq. 2) info = 3
- c
-       if (msglvl .gt. 0) then
--         call pivout (comm, logfil, 1, mxiter, ndigit,
-+         call pivout (comm, logfil, 1, [mxiter], ndigit,
-      &               '_naupd: Number of update iterations taken')
--         call pivout (comm, logfil, 1, np, ndigit,
-+         call pivout (comm, logfil, 1, [np], ndigit,
-      &               '_naupd: Number of wanted "converged" Ritz values')
-          call pcvout (comm, logfil, np, workl(ritz), ndigit,
-      &               '_naupd: The final Ritz values')
-diff --git a/PARPACK/SRC/MPI/pcneupd.f b/PARPACK/SRC/MPI/pcneupd.f
-index 2566f8a5..8ced1df6 100644
---- a/PARPACK/SRC/MPI/pcneupd.f
-+++ b/PARPACK/SRC/MPI/pcneupd.f
-@@ -558,9 +558,9 @@ subroutine pcneupd
- c        %-----------------------------------------------------------%
- c
-          if (msglvl .gt. 2) then
--             call pivout(comm, logfil, 1, numcnv, ndigit,
-+             call pivout(comm, logfil, 1, [numcnv], ndigit,
-      &            '_neupd: Number of specified eigenvalues')
--             call pivout(comm, logfil, 1, nconv, ndigit,
-+             call pivout(comm, logfil, 1, [nconv], ndigit,
-      &            '_neupd: Number of "converged" eigenvalues')
-          end if
- c
-diff --git a/PARPACK/SRC/MPI/pcngets.f b/PARPACK/SRC/MPI/pcngets.f
-index 34b9b047..5f672149 100644
---- a/PARPACK/SRC/MPI/pcngets.f
-+++ b/PARPACK/SRC/MPI/pcngets.f
-@@ -177,8 +177,8 @@ subroutine pcngets ( comm, ishift, which, kev, np, ritz, bounds)
-       tcgets = tcgets + (t1 - t0)
- c
-       if (msglvl .gt. 0) then
--         call pivout (comm, logfil, 1, kev, ndigit, '_ngets: KEV is')
--         call pivout (comm, logfil, 1, np, ndigit, '_ngets: NP is')
-+         call pivout (comm, logfil, 1, [kev], ndigit, '_ngets: KEV is')
-+         call pivout (comm, logfil, 1, [np], ndigit, '_ngets: NP is')
-          call pcvout (comm, logfil, kev+np, ritz, ndigit,
-      &        '_ngets: Eigenvalues of current H matrix ')
-          call pcvout (comm, logfil, kev+np, bounds, ndigit,
-diff --git a/PARPACK/SRC/MPI/pdgetv0.f b/PARPACK/SRC/MPI/pdgetv0.f
-index 3dc71c66..54ed850c 100644
---- a/PARPACK/SRC/MPI/pdgetv0.f
-+++ b/PARPACK/SRC/MPI/pdgetv0.f
-@@ -180,7 +180,7 @@ subroutine pdgetv0
-       logical    first, inits, orth
-       integer    idist, iseed(4), iter, msglvl, jj
-       Double precision
--     &           rnorm0
-+     &           rnorm0, buf2(1)
-       save       first, iseed, inits, iter, msglvl, orth, rnorm0
- c
-       Double precision
-@@ -318,9 +318,9 @@ subroutine pdgetv0
-       first = .FALSE.
-       if (bmat .eq. 'G') then
-           rnorm_buf = ddot (n, resid, 1, workd, 1)
--          call MPI_ALLREDUCE( rnorm_buf, rnorm0, 1,
-+          call MPI_ALLREDUCE( [rnorm_buf], buf2, 1,
-      &          MPI_DOUBLE_PRECISION, MPI_SUM, comm, ierr )
--          rnorm0 = sqrt(abs(rnorm0))
-+          rnorm0 = sqrt(abs(buf2(1)))
-       else if (bmat .eq. 'I') then
-           rnorm0 = pdnorm2( comm, n, resid, 1 )
-       end if
-@@ -379,9 +379,9 @@ subroutine pdgetv0
- c
-       if (bmat .eq. 'G') then
-          rnorm_buf = ddot (n, resid, 1, workd, 1)
--         call MPI_ALLREDUCE( rnorm_buf, rnorm, 1,
-+         call MPI_ALLREDUCE( [rnorm_buf], buf2, 1,
-      &            MPI_DOUBLE_PRECISION, MPI_SUM, comm, ierr )
--         rnorm = sqrt(abs(rnorm))
-+         rnorm = sqrt(abs(buf2(1)))
-       else if (bmat .eq. 'I') then
-          rnorm = pdnorm2( comm, n, resid, 1 )
-       end if
-@@ -391,9 +391,9 @@ subroutine pdgetv0
- c     %--------------------------------------%
- c
-       if (msglvl .gt. 2) then
--          call pdvout (comm, logfil, 1, rnorm0, ndigit,
-+          call pdvout (comm, logfil, 1, [rnorm0], ndigit,
-      &                '_getv0: re-orthonalization ; rnorm0 is')
--          call pdvout (comm, logfil, 1, rnorm, ndigit,
-+          call pdvout (comm, logfil, 1, [rnorm], ndigit,
-      &                '_getv0: re-orthonalization ; rnorm is')
-       end if
- c
-@@ -424,7 +424,7 @@ subroutine pdgetv0
-    50 continue
- c
-       if (msglvl .gt. 0) then
--         call pdvout (comm, logfil, 1, rnorm, ndigit,
-+         call pdvout (comm, logfil, 1, [rnorm], ndigit,
-      &        '_getv0: B-norm of initial / restarted starting vector')
-       end if
-       if (msglvl .gt. 2) then
-diff --git a/PARPACK/SRC/MPI/pdlamch10.f b/PARPACK/SRC/MPI/pdlamch10.f
-index fabfcbd1..64cd6666 100644
---- a/PARPACK/SRC/MPI/pdlamch10.f
-+++ b/PARPACK/SRC/MPI/pdlamch10.f
-@@ -57,7 +57,7 @@ DOUBLE PRECISION   FUNCTION PDLAMCH10( ICTXT, CMACH )
- *
- *     .. Local Scalars ..
-       INTEGER            IDUMM
--      DOUBLE PRECISION   TEMP, TEMP1
-+      DOUBLE PRECISION   TEMP, TEMP1, buf2(1)
- *     ..
- *     .. External Subroutines ..
- *      EXTERNAL           DGAMN2D, DGAMX2D
-@@ -73,19 +73,20 @@ DOUBLE PRECISION   FUNCTION PDLAMCH10( ICTXT, CMACH )
- *
-       IF( LSAME( CMACH, 'E' ).OR.LSAME( CMACH, 'S' ).OR.
-      $    LSAME( CMACH, 'M' ).OR.LSAME( CMACH, 'U' ) ) THEN
--          CALL MPI_ALLREDUCE( TEMP1, TEMP, 1, MPI_DOUBLE_PRECISION,
-+          CALL MPI_ALLREDUCE( [TEMP1], buf2, 1, MPI_DOUBLE_PRECISION,
-      $                        MPI_MAX, ICTXT, IDUMM )
--*         CALL DGAMX2D( ICTXT, 'All', ' ', 1, 1, TEMP, 1, IDUMM,
-+*         CALL DGAMX2D( ICTXT, 'All', ' ', 1, 1, buf2(1), 1, IDUMM,
- *     $                 IDUMM, 1, -1, IDUMM )
-       ELSE IF( LSAME( CMACH, 'L' ).OR.LSAME( CMACH, 'O' ) ) THEN
--          CALL MPI_ALLREDUCE( TEMP1, TEMP, 1, MPI_DOUBLE_PRECISION,
-+          CALL MPI_ALLREDUCE( [TEMP1], buf2, 1, MPI_DOUBLE_PRECISION,
-      $                        MPI_MIN, ICTXT, IDUMM )
--*         CALL DGAMN2D( ICTXT, 'All', ' ', 1, 1, TEMP, 1, IDUMM,
-+*         CALL DGAMN2D( ICTXT, 'All', ' ', 1, 1, buf2(1), 1, IDUMM,
- *     $                 IDUMM, 1, -1, IDUMM )
-       ELSE
--          TEMP = TEMP1
-+          buf2(1) = TEMP1
-       END IF
- *
-+      TEMP = buf2(1)
-       PDLAMCH10 = TEMP
- *
- *     End of PDLAMCH10
-diff --git a/PARPACK/SRC/MPI/pdnaitr.f b/PARPACK/SRC/MPI/pdnaitr.f
-index f531fe1e..3c71ff93 100644
---- a/PARPACK/SRC/MPI/pdnaitr.f
-+++ b/PARPACK/SRC/MPI/pdnaitr.f
-@@ -276,7 +276,7 @@ subroutine pdnaitr
-      &           betaj, rnorm1, smlnum, ulp, unfl, wnorm
- c
-       Double precision
--     &           rnorm_buf
-+     &           rnorm_buf, buf2(1)
- c
- c
- c     %-----------------------%
-@@ -393,9 +393,9 @@ subroutine pdnaitr
-  1000 continue
- c
-          if (msglvl .gt. 1) then
--            call pivout (comm, logfil, 1, j, ndigit,
-+            call pivout (comm, logfil, 1, [j], ndigit,
-      &                  '_naitr: generating Arnoldi vector number')
--            call pdvout (comm, logfil, 1, rnorm, ndigit,
-+            call pdvout (comm, logfil, 1, [rnorm], ndigit,
-      &                  '_naitr: B-norm of the current residual is')
-          end if
- c
-@@ -415,7 +415,7 @@ subroutine pdnaitr
- c           %---------------------------------------------------%
- c
-             if (msglvl .gt. 0) then
--               call pivout (comm, logfil, 1, j, ndigit,
-+               call pivout (comm, logfil, 1, [j], ndigit,
-      &                     '_naitr: ****** RESTART AT STEP ******')
-             end if
- c
-@@ -566,9 +566,9 @@ subroutine pdnaitr
- c
-          if (bmat .eq. 'G') then
-             rnorm_buf = ddot (n, resid, 1, workd(ipj), 1)
--            call MPI_ALLREDUCE( rnorm_buf, wnorm, 1,
-+            call MPI_ALLREDUCE( [rnorm_buf], buf2, 1,
-      &           MPI_DOUBLE_PRECISION, MPI_SUM, comm, ierr )
--            wnorm = sqrt(abs(wnorm))
-+            wnorm = sqrt(abs(buf2(1)))
-          else if (bmat .eq. 'I') then
-             wnorm = pdnorm2( comm, n, resid, 1 )
-          end if
-@@ -642,9 +642,9 @@ subroutine pdnaitr
- c
-          if (bmat .eq. 'G') then
-             rnorm_buf = ddot (n, resid, 1, workd(ipj), 1)
--            call MPI_ALLREDUCE( rnorm_buf, rnorm, 1,
-+            call MPI_ALLREDUCE( [rnorm_buf], buf2, 1,
-      &           MPI_DOUBLE_PRECISION, MPI_SUM, comm, ierr )
--            rnorm = sqrt(abs(rnorm))
-+            rnorm = sqrt(abs(buf2(1)))
-          else if (bmat .eq. 'I') then
-             rnorm = pdnorm2( comm, n, resid, 1 )
-          end if
-@@ -745,15 +745,15 @@ subroutine pdnaitr
- c
-          if (bmat .eq. 'G') then
-            rnorm_buf = ddot (n, resid, 1, workd(ipj), 1)
--           call MPI_ALLREDUCE( rnorm_buf, rnorm1, 1,
-+           call MPI_ALLREDUCE( [rnorm_buf], buf2, 1,
-      &          MPI_DOUBLE_PRECISION, MPI_SUM, comm, ierr )
--           rnorm1 = sqrt(abs(rnorm1))
-+           rnorm1 = sqrt(abs(buf2(1)))
-          else if (bmat .eq. 'I') then
-            rnorm1 = pdnorm2( comm, n, resid, 1 )
-          end if
- c
-          if (msglvl .gt. 0 .and. iter .gt. 0) then
--            call pivout (comm, logfil, 1, j, ndigit,
-+            call pivout (comm, logfil, 1, [j], ndigit,
-      &           '_naitr: Iterative refinement for Arnoldi residual')
-             if (msglvl .gt. 2) then
-                 xtemp(1) = rnorm
-diff --git a/PARPACK/SRC/MPI/pdnapps.f b/PARPACK/SRC/MPI/pdnapps.f
-index fb6f153f..b6ac3502 100644
---- a/PARPACK/SRC/MPI/pdnapps.f
-+++ b/PARPACK/SRC/MPI/pdnapps.f
-@@ -276,11 +276,11 @@ subroutine pdnapps
-          sigmai = shifti(jj)
- c
-          if (msglvl .gt. 2 ) then
--            call pivout (comm, logfil, 1, jj, ndigit,
-+            call pivout (comm, logfil, 1, [jj], ndigit,
-      &               '_napps: shift number.')
--            call pdvout (comm, logfil, 1, sigmar, ndigit,
-+            call pdvout (comm, logfil, 1, [sigmar], ndigit,
-      &               '_napps: The real part of the shift ')
--            call pdvout (comm, logfil, 1, sigmai, ndigit,
-+            call pdvout (comm, logfil, 1, [sigmai], ndigit,
-      &               '_napps: The imaginary part of the shift ')
-          end if
- c
-@@ -345,9 +345,9 @@ subroutine pdnapps
-      &         tst1 = dlanhs( '1', kplusp-jj+1, h, ldh, workl )
-             if( abs( h( i+1,i ) ).le.max( ulp*tst1, smlnum ) ) then
-                if (msglvl .gt. 0) then
--                  call pivout (comm, logfil, 1, i, ndigit,
-+                  call pivout (comm, logfil, 1, [i], ndigit,
-      &                 '_napps: matrix splitting at row/column no.')
--                  call pivout (comm, logfil, 1, jj, ndigit,
-+                  call pivout (comm, logfil, 1, [jj], ndigit,
-      &                 '_napps: matrix splitting with shift number.')
-                   call pdvout (comm, logfil, 1, h(i+1,i), ndigit,
-      &                 '_napps: off diagonal element.')
-@@ -361,9 +361,9 @@ subroutine pdnapps
-    40    continue
- c
-          if (msglvl .gt. 2) then
--             call pivout (comm, logfil, 1, istart, ndigit,
-+             call pivout (comm, logfil, 1, [istart], ndigit,
-      &                   '_napps: Start of current block ')
--             call pivout (comm, logfil, 1, iend, ndigit,
-+             call pivout (comm, logfil, 1, [iend], ndigit,
-      &                   '_napps: End of current block ')
-          end if
- c
-@@ -635,7 +635,7 @@ subroutine pdnapps
-      &        '_napps: sigmak = (e_{kev+p}^T*Q)*e_{kev}')
-          call pdvout (comm, logfil, 1, h(kev+1,kev), ndigit,
-      &        '_napps: betak = e_{kev+1}^T*H*e_{kev}')
--         call pivout (comm, logfil, 1, kev, ndigit,
-+         call pivout (comm, logfil, 1, [kev], ndigit,
-      &               '_napps: Order of the final Hessenberg matrix ')
-          if (msglvl .gt. 2) then
-             call pdmout (comm, logfil, kev, kev, h, ldh, ndigit,
-diff --git a/PARPACK/SRC/MPI/pdnaup2.f b/PARPACK/SRC/MPI/pdnaup2.f
-index d0f73738..c265380a 100644
---- a/PARPACK/SRC/MPI/pdnaup2.f
-+++ b/PARPACK/SRC/MPI/pdnaup2.f
-@@ -234,7 +234,7 @@ subroutine pdnaup2
-      &           nevbef, nev0 , np0   , nptemp, numcnv,
-      &           j
-       Double precision
--     &           rnorm , temp , eps23
-+     &           rnorm , temp , eps23, buf2(1)
-       save       cnorm , getv0, initv , update, ushift,
-      &           rnorm , iter , kplusp, msglvl, nconv,
-      &           nevbef, nev0 , np0   , eps23 , numcnv
-@@ -408,7 +408,7 @@ subroutine pdnaup2
-          iter = iter + 1
- c
-          if (msglvl .gt. 0) then
--            call pivout (comm, logfil, 1, iter, ndigit,
-+            call pivout (comm, logfil, 1, [iter], ndigit,
-      &           '_naup2: **** Start of major iteration number ****')
-          end if
- c
-@@ -421,9 +421,9 @@ subroutine pdnaup2
-          np  = kplusp - nev
- c
-          if (msglvl .gt. 1) then
--            call pivout (comm, logfil, 1, nev, ndigit,
-+            call pivout (comm, logfil, 1, [nev], ndigit,
-      &     '_naup2: The length of the current Arnoldi factorization')
--            call pivout (comm, logfil, 1, np, ndigit,
-+            call pivout (comm, logfil, 1, [np], ndigit,
-      &           '_naup2: Extend the Arnoldi factorization by')
-          end if
- c
-@@ -455,7 +455,7 @@ subroutine pdnaup2
-          update = .false.
- c
-          if (msglvl .gt. 1) then
--            call pdvout  (comm, logfil, 1, rnorm, ndigit,
-+            call pdvout  (comm, logfil, 1, [rnorm], ndigit,
-      &           '_naup2: Corresponding B-norm of the residual')
-          end if
- c
-@@ -699,7 +699,7 @@ subroutine pdnaup2
-          end if
- c
-          if (msglvl .gt. 0) then
--            call pivout (comm, logfil, 1, nconv, ndigit,
-+            call pivout (comm, logfil, 1, [nconv], ndigit,
-      &           '_naup2: no. of "converged" Ritz values at this iter.')
-             if (msglvl .gt. 1) then
-                kp(1) = nev
-@@ -751,7 +751,7 @@ subroutine pdnaup2
-          end if
- c
-          if (msglvl .gt. 2) then
--            call pivout (comm, logfil, 1, np, ndigit,
-+            call pivout (comm, logfil, 1, [np], ndigit,
-      &                  '_naup2: The number of shifts to apply ')
-             call pdvout  (comm, logfil, np, ritzr, ndigit,
-      &                  '_naup2: Real part of the shifts')
-@@ -810,16 +810,16 @@ subroutine pdnaup2
- c
-          if (bmat .eq. 'G') then
-             rnorm_buf = ddot  (n, resid, 1, workd, 1)
--            call MPI_ALLREDUCE( rnorm_buf, rnorm, 1,
-+            call MPI_ALLREDUCE( [rnorm_buf], buf2, 1,
-      &                MPI_DOUBLE_PRECISION , MPI_SUM, comm, ierr )
--            rnorm = sqrt(abs(rnorm))
-+            rnorm = sqrt(abs(buf2(1)))
-          else if (bmat .eq. 'I') then
-             rnorm = pdnorm2 ( comm, n, resid, 1 )
-          end if
-          cnorm = .false.
- c
-          if (msglvl .gt. 2) then
--            call pdvout  (comm, logfil, 1, rnorm, ndigit,
-+            call pdvout  (comm, logfil, 1, [rnorm], ndigit,
-      &      '_naup2: B-norm of residual for compressed factorization')
-             call pdmout  (comm, logfil, nev, nev, h, ldh, ndigit,
-      &        '_naup2: Compressed upper Hessenberg matrix H')
-diff --git a/PARPACK/SRC/MPI/pdnaupd.f b/PARPACK/SRC/MPI/pdnaupd.f
-index 1bf0fc12..231f9cab 100644
---- a/PARPACK/SRC/MPI/pdnaupd.f
-+++ b/PARPACK/SRC/MPI/pdnaupd.f
-@@ -650,9 +650,9 @@ subroutine pdnaupd
-       if (info .eq. 2) info = 3
- c
-       if (msglvl .gt. 0) then
--         call pivout (comm, logfil, 1, mxiter, ndigit,
-+         call pivout (comm, logfil, 1, [mxiter], ndigit,
-      &               '_naupd: Number of update iterations taken')
--         call pivout (comm, logfil, 1, np, ndigit,
-+         call pivout (comm, logfil, 1, [np], ndigit,
-      &               '_naupd: Number of wanted "converged" Ritz values')
-          call pdvout  (comm, logfil, np, workl(ritzr), ndigit,
-      &               '_naupd: Real part of the final Ritz values')
-diff --git a/PARPACK/SRC/MPI/pdneupd.f b/PARPACK/SRC/MPI/pdneupd.f
-index f80651e2..d5741956 100644
---- a/PARPACK/SRC/MPI/pdneupd.f
-+++ b/PARPACK/SRC/MPI/pdneupd.f
-@@ -617,9 +617,9 @@ subroutine pdneupd
- c        %-----------------------------------------------------------%
- c
-          if (msglvl .gt. 2) then
--             call pivout(comm, logfil, 1, numcnv, ndigit,
-+             call pivout(comm, logfil, 1, [numcnv], ndigit,
-      &            '_neupd: Number of specified eigenvalues')
--             call pivout(comm, logfil, 1, nconv, ndigit,
-+             call pivout(comm, logfil, 1, [nconv], ndigit,
-      &            '_neupd: Number of "converged" eigenvalues')
-          end if
- c
-diff --git a/PARPACK/SRC/MPI/pdngets.f b/PARPACK/SRC/MPI/pdngets.f
-index 4ff35165..c4294b8c 100644
---- a/PARPACK/SRC/MPI/pdngets.f
-+++ b/PARPACK/SRC/MPI/pdngets.f
-@@ -226,8 +226,8 @@ subroutine pdngets
-       tngets = tngets + (t1 - t0)
- c
-       if (msglvl .gt. 0) then
--         call pivout (comm, logfil, 1, kev, ndigit, '_ngets: KEV is')
--         call pivout (comm, logfil, 1, np, ndigit, '_ngets: NP is')
-+         call pivout (comm, logfil, 1, [kev], ndigit, '_ngets: KEV is')
-+         call pivout (comm, logfil, 1, [np], ndigit, '_ngets: NP is')
-          call pdvout (comm, logfil, kev+np, ritzr, ndigit,
-      &        '_ngets: Eigenvalues of current H matrix -- real part')
-          call pdvout (comm, logfil, kev+np, ritzi, ndigit,
-diff --git a/PARPACK/SRC/MPI/pdnorm2.f b/PARPACK/SRC/MPI/pdnorm2.f
-index 0e149585..5061d3d9 100644
---- a/PARPACK/SRC/MPI/pdnorm2.f
-+++ b/PARPACK/SRC/MPI/pdnorm2.f
-@@ -45,7 +45,7 @@ Double precision function pdnorm2 ( comm, n, x, inc )
- c     %---------------%
- c
-       Double precision
--     &             max, buf, zero
-+     &             max, buf, zero, buf2(1)
-       parameter    ( zero = 0.0 )
- c
- c     %---------------------%
-@@ -69,15 +69,16 @@ Double precision function pdnorm2 ( comm, n, x, inc )
-       pdnorm2 = dnrm2( n, x, inc)
- c
-       buf = pdnorm2
--      call MPI_ALLREDUCE( buf, max, 1, MPI_DOUBLE_PRECISION,
-+      call MPI_ALLREDUCE( [buf], buf2, 1, MPI_DOUBLE_PRECISION,
-      &                    MPI_MAX, comm, ierr )
-+      max = buf2(1)
-       if ( max .eq. zero ) then
-          pdnorm2 = zero
-       else
-          buf = (pdnorm2/max)**2.0
--         call MPI_ALLREDUCE( buf, pdnorm2, 1, MPI_DOUBLE_PRECISION,
-+         call MPI_ALLREDUCE( [buf], buf2, 1, MPI_DOUBLE_PRECISION,
-      &                       MPI_SUM, comm, ierr )
--         pdnorm2 = max * sqrt(abs(pdnorm2))
-+         pdnorm2 = max * sqrt(abs(buf2(1)))
-       endif
- c
- c     %----------------%
-diff --git a/PARPACK/SRC/MPI/pdsaitr.f b/PARPACK/SRC/MPI/pdsaitr.f
-index 5fe84b81..42396c11 100644
---- a/PARPACK/SRC/MPI/pdsaitr.f
-+++ b/PARPACK/SRC/MPI/pdsaitr.f
-@@ -264,7 +264,7 @@ subroutine pdsaitr
-       integer    i, ierr, ipj, irj, ivj, iter, itry, j, msglvl, infol,
-      &           jj
-       Double precision
--     &           rnorm1, wnorm, safmin, temp1
-+     &           rnorm1, wnorm, safmin, temp1, buf2(1)
-       save       orth1, orth2, rstart, step3, step4,
-      &           ierr, ipj, irj, ivj, iter, itry, j, msglvl,
-      &           rnorm1, safmin, wnorm
-@@ -392,9 +392,9 @@ subroutine pdsaitr
-  1000 continue
- c
-          if (msglvl .gt. 2) then
--            call pivout (comm, logfil, 1, j, ndigit,
-+            call pivout (comm, logfil, 1, [j], ndigit,
-      &                  '_saitr: generating Arnoldi vector no.')
--            call pdvout (comm, logfil, 1, rnorm, ndigit,
-+            call pdvout (comm, logfil, 1, [rnorm], ndigit,
-      &                  '_saitr: B-norm of the current residual =')
-          end if
- c
-@@ -412,7 +412,7 @@ subroutine pdsaitr
- c           %---------------------------------------------------%
- c
-             if (msglvl .gt. 0) then
--               call pivout (comm, logfil, 1, j, ndigit,
-+               call pivout (comm, logfil, 1, [j], ndigit,
-      &                     '_saitr: ****** restart at step ******')
-             end if
- c
-@@ -572,14 +572,14 @@ subroutine pdsaitr
- c           %----------------------------------%
- c
-             rnorm_buf = ddot (n, resid, 1, workd(ivj), 1)
--            call MPI_ALLREDUCE( rnorm_buf, wnorm, 1,
-+            call MPI_ALLREDUCE( [rnorm_buf], buf2, 1,
-      &           MPI_DOUBLE_PRECISION, MPI_SUM, comm, ierr )
--            wnorm = sqrt(abs(wnorm))
-+            wnorm = sqrt(abs(buf2(1)))
-          else if (bmat .eq. 'G') then
-             rnorm_buf = ddot (n, resid, 1, workd(ipj), 1)
--            call MPI_ALLREDUCE( rnorm_buf, wnorm, 1,
-+            call MPI_ALLREDUCE( [rnorm_buf], buf2, 1,
-      &           MPI_DOUBLE_PRECISION, MPI_SUM, comm, ierr )
--            wnorm = sqrt(abs(wnorm))
-+            wnorm = sqrt(abs(buf2(1)))
-          else if (bmat .eq. 'I') then
-             wnorm = pdnorm2( comm, n, resid, 1 )
-          end if
-@@ -669,9 +669,9 @@ subroutine pdsaitr
- c
-          if (bmat .eq. 'G') then
-             rnorm_buf = ddot (n, resid, 1, workd(ipj), 1)
--            call MPI_ALLREDUCE( rnorm_buf, rnorm, 1,
-+            call MPI_ALLREDUCE( [rnorm_buf], buf2, 1,
-      &           MPI_DOUBLE_PRECISION, MPI_SUM, comm, ierr )
--            rnorm = sqrt(abs(rnorm))
-+            rnorm = sqrt(abs(buf2(1)))
-          else if (bmat .eq. 'I') then
-             rnorm = pdnorm2( comm, n, resid, 1 )
-          end if
-@@ -769,15 +769,15 @@ subroutine pdsaitr
- c
-          if (bmat .eq. 'G') then
-            rnorm_buf = ddot (n, resid, 1, workd(ipj), 1)
--           call MPI_ALLREDUCE( rnorm_buf, rnorm1, 1,
-+           call MPI_ALLREDUCE( [rnorm_buf], buf2(1), 1,
-      &          MPI_DOUBLE_PRECISION, MPI_SUM, comm, ierr )
--           rnorm1 = sqrt(abs(rnorm1))
-+           rnorm1 = sqrt(abs(buf2(1)))
-          else if (bmat .eq. 'I') then
-            rnorm1 = pdnorm2( comm, n, resid, 1 )
-          end if
- c
-          if (msglvl .gt. 0 .and. iter .gt. 0) then
--            call pivout (comm, logfil, 1, j, ndigit,
-+            call pivout (comm, logfil, 1, [j], ndigit,
-      &           '_naitr: Iterative refinement for Arnoldi residual')
-             if (msglvl .gt. 2) then
-                 xtemp(1) = rnorm
-diff --git a/PARPACK/SRC/MPI/pdsapps.f b/PARPACK/SRC/MPI/pdsapps.f
-index e79db4e3..3feb8da0 100644
---- a/PARPACK/SRC/MPI/pdsapps.f
-+++ b/PARPACK/SRC/MPI/pdsapps.f
-@@ -272,9 +272,9 @@ subroutine pdsapps
-             big   = abs(h(i,2)) + abs(h(i+1,2))
-             if (h(i+1,1) .le. epsmch*big) then
-                if (msglvl .gt. 0) then
--                  call pivout (comm, logfil, 1, i, ndigit,
-+                  call pivout (comm, logfil, 1, [i], ndigit,
-      &                 '_sapps: deflation at row/column no.')
--                  call pivout (comm, logfil, 1, jj, ndigit,
-+                  call pivout (comm, logfil, 1, [jj], ndigit,
-      &                 '_sapps: occurred before shift number.')
-                   call pdvout (comm, logfil, 1, h(i+1,1), ndigit,
-      &                 '_sapps: the corresponding off diagonal element')
-@@ -443,7 +443,7 @@ subroutine pdsapps
-          big   = abs(h(i,2)) + abs(h(i+1,2))
-          if (h(i+1,1) .le. epsmch*big) then
-             if (msglvl .gt. 0) then
--               call pivout (comm, logfil, 1, i, ndigit,
-+               call pivout (comm, logfil, 1, [i], ndigit,
-      &              '_sapps: deflation at row/column no.')
-                call pdvout (comm, logfil, 1, h(i+1,1), ndigit,
-      &              '_sapps: the corresponding off diagonal element')
-diff --git a/PARPACK/SRC/MPI/pdsaup2.f b/PARPACK/SRC/MPI/pdsaup2.f
-index 820459b3..a575b33f 100644
---- a/PARPACK/SRC/MPI/pdsaup2.f
-+++ b/PARPACK/SRC/MPI/pdsaup2.f
-@@ -212,7 +212,7 @@ subroutine pdsaup2
-       integer    ido, info, ishift, iupd, ldh, ldq, ldv, mxiter,
-      &           n, mode, nev, np
-       Double precision
--     &           tol
-+     &           tol, buf2(1)
- c
- c     %-----------------%
- c     | Array Arguments |
-@@ -424,13 +424,13 @@ subroutine pdsaup2
-          iter = iter + 1
- c
-          if (msglvl .gt. 0) then
--            call pivout (comm, logfil, 1, iter, ndigit,
-+            call pivout (comm, logfil, 1, [iter], ndigit,
-      &           '_saup2: **** Start of major iteration number ****')
-          end if
-          if (msglvl .gt. 1) then
--            call pivout (comm, logfil, 1, nev, ndigit,
-+            call pivout (comm, logfil, 1, [nev], ndigit,
-      &     '_saup2: The length of the current Lanczos factorization')
--            call pivout (comm, logfil, 1, np, ndigit,
-+            call pivout (comm, logfil, 1, [np], ndigit,
-      &           '_saup2: Extend the Lanczos factorization by')
-          end if
- c
-@@ -469,7 +469,7 @@ subroutine pdsaup2
-          update = .false.
- c
-          if (msglvl .gt. 1) then
--            call pdvout (comm, logfil, 1, rnorm, ndigit,
-+            call pdvout (comm, logfil, 1, [rnorm], ndigit,
-      &           '_saup2: Current B-norm of residual for factorization')
-          end if
- c
-@@ -719,7 +719,7 @@ subroutine pdsaup2
-          end if
- c
-          if (msglvl .gt. 0) then
--            call pivout (comm, logfil, 1, nconv, ndigit,
-+            call pivout (comm, logfil, 1, [nconv], ndigit,
-      &           '_saup2: no. of "converged" Ritz values at this iter.')
-             if (msglvl .gt. 1) then
-                kp(1) = nev
-@@ -766,7 +766,7 @@ subroutine pdsaup2
-          if (ishift .eq. 0) call dcopy (np, workl, 1, ritz, 1)
- c
-          if (msglvl .gt. 2) then
--            call pivout (comm, logfil, 1, np, ndigit,
-+            call pivout (comm, logfil, 1, [np], ndigit,
-      &                  '_saup2: The number of shifts to apply ')
-             call pdvout (comm, logfil, np, workl, ndigit,
-      &                  '_saup2: shifts selected')
-@@ -825,9 +825,9 @@ subroutine pdsaup2
- c
-          if (bmat .eq. 'G') then
-             rnorm_buf = ddot (n, resid, 1, workd, 1)
--            call MPI_ALLREDUCE( rnorm_buf, rnorm, 1,
-+            call MPI_ALLREDUCE( [rnorm_buf], buf2, 1,
-      &                MPI_DOUBLE_PRECISION, MPI_SUM, comm, ierr )
--            rnorm = sqrt(abs(rnorm))
-+            rnorm = sqrt(abs(buf2(1)))
-          else if (bmat .eq. 'I') then
-             rnorm = pdnorm2( comm, n, resid, 1 )
-          end if
-@@ -835,7 +835,7 @@ subroutine pdsaup2
-   130    continue
- c
-          if (msglvl .gt. 2) then
--            call pdvout (comm, logfil, 1, rnorm, ndigit,
-+            call pdvout (comm, logfil, 1, [rnorm], ndigit,
-      &      '_saup2: B-norm of residual for NEV factorization')
-             call pdvout (comm, logfil, nev, h(1,2), ndigit,
-      &           '_saup2: main diagonal of compressed H matrix')
-diff --git a/PARPACK/SRC/MPI/pdsaupd.f b/PARPACK/SRC/MPI/pdsaupd.f
-index 47d05227..f505dc90 100644
---- a/PARPACK/SRC/MPI/pdsaupd.f
-+++ b/PARPACK/SRC/MPI/pdsaupd.f
-@@ -652,9 +652,9 @@ subroutine pdsaupd
-       if (info .eq. 2) info = 3
- c
-       if (msglvl .gt. 0) then
--         call pivout (comm, logfil, 1, mxiter, ndigit,
-+         call pivout (comm, logfil, 1, [mxiter], ndigit,
-      &               '_saupd: number of update iterations taken')
--         call pivout (comm, logfil, 1, np, ndigit,
-+         call pivout (comm, logfil, 1, [np], ndigit,
-      &               '_saupd: number of "converged" Ritz values')
-          call pdvout  (comm, logfil, np, workl(Ritz), ndigit,
-      &               '_saupd: final Ritz values')
-diff --git a/PARPACK/SRC/MPI/pdseupd.f b/PARPACK/SRC/MPI/pdseupd.f
-index 9e866ab7..66e85995 100644
---- a/PARPACK/SRC/MPI/pdseupd.f
-+++ b/PARPACK/SRC/MPI/pdseupd.f
-@@ -523,9 +523,9 @@ subroutine pdseupd
- c        %-----------------------------------------------------------%
- c
-          if (msglvl .gt. 2) then
--             call pivout(comm, logfil, 1, numcnv, ndigit,
-+             call pivout(comm, logfil, 1, [numcnv], ndigit,
-      &            '_neupd: Number of specified eigenvalues')
--             call pivout(comm, logfil, 1, nconv, ndigit,
-+             call pivout(comm, logfil, 1, [nconv], ndigit,
-      &            '_neupd: Number of "converged" eigenvalues')
-          end if
- c
-diff --git a/PARPACK/SRC/MPI/pdsgets.f b/PARPACK/SRC/MPI/pdsgets.f
-index 01b52394..c71421b4 100644
---- a/PARPACK/SRC/MPI/pdsgets.f
-+++ b/PARPACK/SRC/MPI/pdsgets.f
-@@ -216,8 +216,8 @@ subroutine pdsgets
-       tsgets = tsgets + (t1 - t0)
- c
-       if (msglvl .gt. 0) then
--         call pivout (comm, logfil, 1, kev, ndigit, '_sgets: KEV is')
--         call pivout (comm, logfil, 1, np, ndigit, '_sgets: NP is')
-+         call pivout (comm, logfil, 1, [kev], ndigit, '_sgets: KEV is')
-+         call pivout (comm, logfil, 1, [np], ndigit, '_sgets: NP is')
-          call pdvout (comm, logfil, kev+np, ritz, ndigit,
-      &        '_sgets: Eigenvalues of current H matrix')
-          call pdvout (comm, logfil, kev+np, bounds, ndigit,
-diff --git a/PARPACK/SRC/MPI/pdznorm2.f b/PARPACK/SRC/MPI/pdznorm2.f
-index 7a7173f3..4651679b 100644
---- a/PARPACK/SRC/MPI/pdznorm2.f
-+++ b/PARPACK/SRC/MPI/pdznorm2.f
-@@ -45,7 +45,7 @@ Double precision function pdznorm2 ( comm, n, x, inc )
- c     %---------------%
- c
-       Double precision
--     &             max, buf, zero
-+     &             max(1), buf, zero
-       parameter    ( zero = 0.0 )
- c
- c     %---------------------%
-@@ -59,7 +59,7 @@ Double precision function pdznorm2 ( comm, n, x, inc )
- c     %--------------------%
- c
-       Double precision
--     &             dznrm2
-+     &             dznrm2, buf2(1)
-       External     dznrm2
- c
- c     %-----------------------%
-@@ -69,15 +69,15 @@ Double precision function pdznorm2 ( comm, n, x, inc )
-       pdznorm2 = dznrm2( n, x, inc)
- c
-       buf = pdznorm2
--      call MPI_ALLREDUCE( buf, max, 1, MPI_DOUBLE_PRECISION,
-+      call MPI_ALLREDUCE( [buf], max, 1, MPI_DOUBLE_PRECISION,
-      &                    MPI_MAX, comm, ierr )
--      if ( max .eq. zero ) then
-+      if ( max(1) .eq. zero ) then
-          pdznorm2 = zero
-       else
--         buf = (pdznorm2/max)**2.0
--         call MPI_ALLREDUCE( buf, pdznorm2, 1, MPI_DOUBLE_PRECISION,
-+         buf = (pdznorm2/max(1))**2.0
-+         call MPI_ALLREDUCE( [buf], buf2, 1, MPI_DOUBLE_PRECISION,
-      &                       MPI_SUM, comm, ierr )
--         pdznorm2 = max * sqrt(abs(pdznorm2))
-+         pdznorm2 = max(1) * sqrt(abs(buf2(1)))
-       endif
- c
- c     %-----------------%
-diff --git a/PARPACK/SRC/MPI/pscnorm2.f b/PARPACK/SRC/MPI/pscnorm2.f
-index 2c64831e..50dea8bd 100644
---- a/PARPACK/SRC/MPI/pscnorm2.f
-+++ b/PARPACK/SRC/MPI/pscnorm2.f
-@@ -45,7 +45,7 @@ Real function pscnorm2 ( comm, n, x, inc )
- c     %---------------%
- c
-       Real
--     &             max, buf, zero
-+     &             max(1), buf, zero
-       parameter    ( zero = 0.0 )
- c
- c     %---------------------%
-@@ -61,6 +61,7 @@ Real function pscnorm2 ( comm, n, x, inc )
-       Real
-      &             scnrm2
-       External     scnrm2
-+      Real         buf2(1)
- c
- c     %-----------------------%
- c     | Executable Statements |
-@@ -69,15 +70,15 @@ Real function pscnorm2 ( comm, n, x, inc )
-       pscnorm2 = scnrm2( n, x, inc)
- c
-       buf = pscnorm2
--      call MPI_ALLREDUCE( buf, max, 1, MPI_REAL,
-+      call MPI_ALLREDUCE( [buf], max, 1, MPI_REAL,
-      &                    MPI_MAX, comm, ierr )
--      if ( max .eq. zero ) then
-+      if ( max(1) .eq. zero ) then
-          pscnorm2 = zero
-       else
--         buf = (pscnorm2/max)**2.0
--         call MPI_ALLREDUCE( buf, pscnorm2, 1, MPI_REAL,
-+         buf = (pscnorm2/max(1))**2.0
-+         call MPI_ALLREDUCE( [buf], buf2, 1, MPI_REAL,
-      &                       MPI_SUM, comm, ierr )
--         pscnorm2 = max * sqrt(abs(pscnorm2))
-+         pscnorm2 = max(1) * sqrt(abs(buf2(1)))
-       endif
- c
- c     %-----------------%
-diff --git a/PARPACK/SRC/MPI/psgetv0.f b/PARPACK/SRC/MPI/psgetv0.f
-index a721c9b9..597212b5 100644
---- a/PARPACK/SRC/MPI/psgetv0.f
-+++ b/PARPACK/SRC/MPI/psgetv0.f
-@@ -163,7 +163,7 @@ subroutine psgetv0
- c
-       integer    ipntr(3)
-       Real
--     &           resid(n), v(ldv,j), workd(2*n), workl(2*j)
-+     &           resid(n), v(ldv,j), workd(2*n), workl(2*j), buf2(1)
- c
- c     %------------%
- c     | Parameters |
-@@ -318,9 +318,9 @@ subroutine psgetv0
-       first = .FALSE.
-       if (bmat .eq. 'G') then
-           rnorm_buf = sdot (n, resid, 1, workd, 1)
--          call MPI_ALLREDUCE( rnorm_buf, rnorm0, 1,
-+          call MPI_ALLREDUCE( [rnorm_buf], buf2, 1,
-      &          MPI_REAL, MPI_SUM, comm, ierr )
--          rnorm0 = sqrt(abs(rnorm0))
-+          rnorm0 = sqrt(abs(buf2(1)))
-       else if (bmat .eq. 'I') then
-           rnorm0 = psnorm2( comm, n, resid, 1 )
-       end if
-@@ -379,9 +379,9 @@ subroutine psgetv0
- c
-       if (bmat .eq. 'G') then
-          rnorm_buf = sdot (n, resid, 1, workd, 1)
--         call MPI_ALLREDUCE( rnorm_buf, rnorm, 1,
-+         call MPI_ALLREDUCE( [rnorm_buf], buf2, 1,
-      &            MPI_REAL, MPI_SUM, comm, ierr )
--         rnorm = sqrt(abs(rnorm))
-+         rnorm = sqrt(abs(buf2(1)))
-       else if (bmat .eq. 'I') then
-          rnorm = psnorm2( comm, n, resid, 1 )
-       end if
-@@ -391,9 +391,9 @@ subroutine psgetv0
- c     %--------------------------------------%
- c
-       if (msglvl .gt. 2) then
--          call psvout (comm, logfil, 1, rnorm0, ndigit,
-+          call psvout (comm, logfil, 1, [rnorm0], ndigit,
-      &                '_getv0: re-orthonalization ; rnorm0 is')
--          call psvout (comm, logfil, 1, rnorm, ndigit,
-+          call psvout (comm, logfil, 1, [rnorm], ndigit,
-      &                '_getv0: re-orthonalization ; rnorm is')
-       end if
- c
-@@ -424,7 +424,7 @@ subroutine psgetv0
-    50 continue
- c
-       if (msglvl .gt. 0) then
--         call psvout (comm, logfil, 1, rnorm, ndigit,
-+         call psvout (comm, logfil, 1, [rnorm], ndigit,
-      &        '_getv0: B-norm of initial / restarted starting vector')
-       end if
-       if (msglvl .gt. 2) then
-diff --git a/PARPACK/SRC/MPI/pslamch10.f b/PARPACK/SRC/MPI/pslamch10.f
-index cd7215c5..c3c13b8e 100644
---- a/PARPACK/SRC/MPI/pslamch10.f
-+++ b/PARPACK/SRC/MPI/pslamch10.f
-@@ -53,7 +53,7 @@ REAL               FUNCTION PSLAMCH10( ICTXT, CMACH )
- *
- *     .. Local Scalars ..
-       INTEGER            IDUMM
--      REAL               TEMP, TEMP1
-+      REAL               TEMP, TEMP1, buf2(1)
- *     ..
- *     .. External Subroutines ..
- *      EXTERNAL           SGAMN2D, SGAMX2D
-@@ -69,14 +69,16 @@ REAL               FUNCTION PSLAMCH10( ICTXT, CMACH )
- *
-       IF( LSAME( CMACH, 'E' ).OR.LSAME( CMACH, 'S' ).OR.
-      $    LSAME( CMACH, 'M' ).OR.LSAME( CMACH, 'U' ) ) THEN
--          CALL MPI_ALLREDUCE( TEMP1, TEMP, 1, MPI_REAL,
-+          CALL MPI_ALLREDUCE( [TEMP1], buf2, 1, MPI_REAL,
-      $                        MPI_MAX, ICTXT, IDUMM )
--*         CALL SGAMX2D( ICTXT, 'All', ' ', 1, 1, TEMP, 1, IDUMM,
-+          TEMP = buf2(1)
-+*     CALL SGAMX2D( ICTXT, 'All', ' ', 1, 1, TEMP, 1, IDUMM,
- *     $                 IDUMM, 1, -1, IDUMM )
-       ELSE IF( LSAME( CMACH, 'L' ).OR.LSAME( CMACH, 'O' ) ) THEN
--          CALL MPI_ALLREDUCE( TEMP1, TEMP, 1, MPI_REAL,
-+          CALL MPI_ALLREDUCE( [TEMP1], buf2, 1, MPI_REAL,
-      $                        MPI_MIN, ICTXT, IDUMM )
--*         CALL SGAMN2D( ICTXT, 'All', ' ', 1, 1, TEMP, 1, IDUMM,
-+          TEMP = buf2(1)
-+*     CALL SGAMN2D( ICTXT, 'All', ' ', 1, 1, TEMP, 1, IDUMM,
- *     $                 IDUMM, 1, -1, IDUMM )
-       ELSE
-           TEMP = TEMP1
-diff --git a/PARPACK/SRC/MPI/psnaitr.f b/PARPACK/SRC/MPI/psnaitr.f
-index ab63f99a..8b5f635d 100644
---- a/PARPACK/SRC/MPI/psnaitr.f
-+++ b/PARPACK/SRC/MPI/psnaitr.f
-@@ -276,7 +276,7 @@ subroutine psnaitr
-      &           betaj, rnorm1, smlnum, ulp, unfl, wnorm
- c
-       Real
--     &           rnorm_buf
-+     &           rnorm_buf, buf2(1)
- c
- c
- c     %-----------------------%
-@@ -393,9 +393,9 @@ subroutine psnaitr
-  1000 continue
- c
-          if (msglvl .gt. 1) then
--            call pivout (comm, logfil, 1, j, ndigit,
-+            call pivout (comm, logfil, 1, [j], ndigit,
-      &                  '_naitr: generating Arnoldi vector number')
--            call psvout (comm, logfil, 1, rnorm, ndigit,
-+            call psvout (comm, logfil, 1, [rnorm], ndigit,
-      &                  '_naitr: B-norm of the current residual is')
-          end if
- c
-@@ -415,7 +415,7 @@ subroutine psnaitr
- c           %---------------------------------------------------%
- c
-             if (msglvl .gt. 0) then
--               call pivout (comm, logfil, 1, j, ndigit,
-+               call pivout (comm, logfil, 1, [j], ndigit,
-      &                     '_naitr: ****** RESTART AT STEP ******')
-             end if
- c
-@@ -566,9 +566,9 @@ subroutine psnaitr
- c
-          if (bmat .eq. 'G') then
-             rnorm_buf = sdot (n, resid, 1, workd(ipj), 1)
--            call MPI_ALLREDUCE( rnorm_buf, wnorm, 1,
-+            call MPI_ALLREDUCE( [rnorm_buf], buf2, 1,
-      &           MPI_REAL, MPI_SUM, comm, ierr )
--            wnorm = sqrt(abs(wnorm))
-+            wnorm = sqrt(abs(buf2(1)))
-          else if (bmat .eq. 'I') then
-             wnorm = psnorm2( comm, n, resid, 1 )
-          end if
-@@ -642,9 +642,9 @@ subroutine psnaitr
- c
-          if (bmat .eq. 'G') then
-             rnorm_buf = sdot (n, resid, 1, workd(ipj), 1)
--            call MPI_ALLREDUCE( rnorm_buf, rnorm, 1,
-+            call MPI_ALLREDUCE( [rnorm_buf], buf2, 1,
-      &           MPI_REAL, MPI_SUM, comm, ierr )
--            rnorm = sqrt(abs(rnorm))
-+            rnorm = sqrt(abs(buf2(1)))
-          else if (bmat .eq. 'I') then
-             rnorm = psnorm2( comm, n, resid, 1 )
-          end if
-@@ -745,15 +745,15 @@ subroutine psnaitr
- c
-          if (bmat .eq. 'G') then
-            rnorm_buf = sdot (n, resid, 1, workd(ipj), 1)
--           call MPI_ALLREDUCE( rnorm_buf, rnorm1, 1,
-+           call MPI_ALLREDUCE( [rnorm_buf], buf2, 1,
-      &          MPI_REAL, MPI_SUM, comm, ierr )
--           rnorm1 = sqrt(abs(rnorm1))
-+           rnorm1 = sqrt(abs(buf2(1)))
-          else if (bmat .eq. 'I') then
-            rnorm1 = psnorm2( comm, n, resid, 1 )
-          end if
- c
-          if (msglvl .gt. 0 .and. iter .gt. 0) then
--            call pivout (comm, logfil, 1, j, ndigit,
-+            call pivout (comm, logfil, 1, [j], ndigit,
-      &           '_naitr: Iterative refinement for Arnoldi residual')
-             if (msglvl .gt. 2) then
-                 xtemp(1) = rnorm
-diff --git a/PARPACK/SRC/MPI/psnapps.f b/PARPACK/SRC/MPI/psnapps.f
-index c06fba58..b6f8645b 100644
---- a/PARPACK/SRC/MPI/psnapps.f
-+++ b/PARPACK/SRC/MPI/psnapps.f
-@@ -276,11 +276,11 @@ subroutine psnapps
-          sigmai = shifti(jj)
- c
-          if (msglvl .gt. 2 ) then
--            call pivout (comm, logfil, 1, jj, ndigit,
-+            call pivout (comm, logfil, 1, [jj], ndigit,
-      &               '_napps: shift number.')
--            call psvout (comm, logfil, 1, sigmar, ndigit,
-+            call psvout (comm, logfil, 1, [sigmar], ndigit,
-      &               '_napps: The real part of the shift ')
--            call psvout (comm, logfil, 1, sigmai, ndigit,
-+            call psvout (comm, logfil, 1, [sigmai], ndigit,
-      &               '_napps: The imaginary part of the shift ')
-          end if
- c
-@@ -345,9 +345,9 @@ subroutine psnapps
-      &         tst1 = slanhs( '1', kplusp-jj+1, h, ldh, workl )
-             if( abs( h( i+1,i ) ).le.max( ulp*tst1, smlnum ) ) then
-                if (msglvl .gt. 0) then
--                  call pivout (comm, logfil, 1, i, ndigit,
-+                  call pivout (comm, logfil, 1, [i], ndigit,
-      &                 '_napps: matrix splitting at row/column no.')
--                  call pivout (comm, logfil, 1, jj, ndigit,
-+                  call pivout (comm, logfil, 1, [jj], ndigit,
-      &                 '_napps: matrix splitting with shift number.')
-                   call psvout (comm, logfil, 1, h(i+1,i), ndigit,
-      &                 '_napps: off diagonal element.')
-@@ -361,9 +361,9 @@ subroutine psnapps
-    40    continue
- c
-          if (msglvl .gt. 2) then
--             call pivout (comm, logfil, 1, istart, ndigit,
-+             call pivout (comm, logfil, 1, [istart], ndigit,
-      &                   '_napps: Start of current block ')
--             call pivout (comm, logfil, 1, iend, ndigit,
-+             call pivout (comm, logfil, 1, [iend], ndigit,
-      &                   '_napps: End of current block ')
-          end if
- c
-@@ -635,7 +635,7 @@ subroutine psnapps
-      &        '_napps: sigmak = (e_{kev+p}^T*Q)*e_{kev}')
-          call psvout (comm, logfil, 1, h(kev+1,kev), ndigit,
-      &        '_napps: betak = e_{kev+1}^T*H*e_{kev}')
--         call pivout (comm, logfil, 1, kev, ndigit,
-+         call pivout (comm, logfil, 1, [kev], ndigit,
-      &               '_napps: Order of the final Hessenberg matrix ')
-          if (msglvl .gt. 2) then
-             call psmout (comm, logfil, kev, kev, h, ldh, ndigit,
-diff --git a/PARPACK/SRC/MPI/psnaup2.f b/PARPACK/SRC/MPI/psnaup2.f
-index 6195d4b6..bfca7fb1 100644
---- a/PARPACK/SRC/MPI/psnaup2.f
-+++ b/PARPACK/SRC/MPI/psnaup2.f
-@@ -241,7 +241,7 @@ subroutine psnaup2
- c
- 
-       Real
--     &           rnorm_buf
-+     &           rnorm_buf, buf2(1)
- c
- c     %-----------------------%
- c     | Local array arguments |
-@@ -408,7 +408,7 @@ subroutine psnaup2
-          iter = iter + 1
- c
-          if (msglvl .gt. 0) then
--            call pivout (comm, logfil, 1, iter, ndigit,
-+            call pivout (comm, logfil, 1, [iter], ndigit,
-      &           '_naup2: **** Start of major iteration number ****')
-          end if
- c
-@@ -421,9 +421,9 @@ subroutine psnaup2
-          np  = kplusp - nev
- c
-          if (msglvl .gt. 1) then
--            call pivout (comm, logfil, 1, nev, ndigit,
-+            call pivout (comm, logfil, 1, [nev], ndigit,
-      &     '_naup2: The length of the current Arnoldi factorization')
--            call pivout (comm, logfil, 1, np, ndigit,
-+            call pivout (comm, logfil, 1, [np], ndigit,
-      &           '_naup2: Extend the Arnoldi factorization by')
-          end if
- c
-@@ -455,7 +455,7 @@ subroutine psnaup2
-          update = .false.
- c
-          if (msglvl .gt. 1) then
--            call psvout (comm, logfil, 1, rnorm, ndigit,
-+            call psvout (comm, logfil, 1, [rnorm], ndigit,
-      &           '_naup2: Corresponding B-norm of the residual')
-          end if
- c
-@@ -699,7 +699,7 @@ subroutine psnaup2
-          end if
- c
-          if (msglvl .gt. 0) then
--            call pivout (comm, logfil, 1, nconv, ndigit,
-+            call pivout (comm, logfil, 1, [nconv], ndigit,
-      &           '_naup2: no. of "converged" Ritz values at this iter.')
-             if (msglvl .gt. 1) then
-                kp(1) = nev
-@@ -751,7 +751,7 @@ subroutine psnaup2
-          end if
- c
-          if (msglvl .gt. 2) then
--            call pivout (comm, logfil, 1, np, ndigit,
-+            call pivout (comm, logfil, 1, [np], ndigit,
-      &                  '_naup2: The number of shifts to apply ')
-             call psvout (comm, logfil, np, ritzr, ndigit,
-      &                  '_naup2: Real part of the shifts')
-@@ -810,16 +810,16 @@ subroutine psnaup2
- c
-          if (bmat .eq. 'G') then
-             rnorm_buf = sdot (n, resid, 1, workd, 1)
--            call MPI_ALLREDUCE( rnorm_buf, rnorm, 1,
-+            call MPI_ALLREDUCE( [rnorm_buf], buf2, 1,
-      &                MPI_REAL, MPI_SUM, comm, ierr )
--            rnorm = sqrt(abs(rnorm))
-+            rnorm = sqrt(abs(buf2(1)))
-          else if (bmat .eq. 'I') then
-             rnorm = psnorm2( comm, n, resid, 1 )
-          end if
-          cnorm = .false.
- c
-          if (msglvl .gt. 2) then
--            call psvout (comm, logfil, 1, rnorm, ndigit,
-+            call psvout (comm, logfil, 1, [rnorm], ndigit,
-      &      '_naup2: B-norm of residual for compressed factorization')
-             call psmout (comm, logfil, nev, nev, h, ldh, ndigit,
-      &        '_naup2: Compressed upper Hessenberg matrix H')
-diff --git a/PARPACK/SRC/MPI/psnaupd.f b/PARPACK/SRC/MPI/psnaupd.f
-index a55f5fba..35e85b74 100644
---- a/PARPACK/SRC/MPI/psnaupd.f
-+++ b/PARPACK/SRC/MPI/psnaupd.f
-@@ -650,9 +650,9 @@ subroutine psnaupd
-       if (info .eq. 2) info = 3
- c
-       if (msglvl .gt. 0) then
--         call pivout (comm, logfil, 1, mxiter, ndigit,
-+         call pivout (comm, logfil, 1, [mxiter], ndigit,
-      &               '_naupd: Number of update iterations taken')
--         call pivout (comm, logfil, 1, np, ndigit,
-+         call pivout (comm, logfil, 1, [np], ndigit,
-      &               '_naupd: Number of wanted "converged" Ritz values')
-          call psvout (comm, logfil, np, workl(ritzr), ndigit,
-      &               '_naupd: Real part of the final Ritz values')
-diff --git a/PARPACK/SRC/MPI/psneupd.f b/PARPACK/SRC/MPI/psneupd.f
-index c7f939a4..d4090b66 100644
---- a/PARPACK/SRC/MPI/psneupd.f
-+++ b/PARPACK/SRC/MPI/psneupd.f
-@@ -617,9 +617,9 @@ subroutine psneupd
- c        %-----------------------------------------------------------%
- c
-          if (msglvl .gt. 2) then
--             call pivout(comm, logfil, 1, numcnv, ndigit,
-+             call pivout(comm, logfil, 1, [numcnv], ndigit,
-      &            '_neupd: Number of specified eigenvalues')
--             call pivout(comm, logfil, 1, nconv, ndigit,
-+             call pivout(comm, logfil, 1, [nconv], ndigit,
-      &            '_neupd: Number of "converged" eigenvalues')
-          end if
- c
-diff --git a/PARPACK/SRC/MPI/psngets.f b/PARPACK/SRC/MPI/psngets.f
-index c4bf9ac7..91a6d730 100644
---- a/PARPACK/SRC/MPI/psngets.f
-+++ b/PARPACK/SRC/MPI/psngets.f
-@@ -226,8 +226,8 @@ subroutine psngets
-       tngets = tngets + (t1 - t0)
- c
-       if (msglvl .gt. 0) then
--         call pivout (comm, logfil, 1, kev, ndigit, '_ngets: KEV is')
--         call pivout (comm, logfil, 1, np, ndigit, '_ngets: NP is')
-+         call pivout (comm, logfil, 1, [kev], ndigit, '_ngets: KEV is')
-+         call pivout (comm, logfil, 1, [np], ndigit, '_ngets: NP is')
-          call psvout (comm, logfil, kev+np, ritzr, ndigit,
-      &        '_ngets: Eigenvalues of current H matrix -- real part')
-          call psvout (comm, logfil, kev+np, ritzi, ndigit,
-diff --git a/PARPACK/SRC/MPI/psnorm2.f b/PARPACK/SRC/MPI/psnorm2.f
-index b5fbcd13..8e487b35 100644
---- a/PARPACK/SRC/MPI/psnorm2.f
-+++ b/PARPACK/SRC/MPI/psnorm2.f
-@@ -45,7 +45,7 @@ Real function psnorm2 ( comm, n, x, inc )
- c     %---------------%
- c
-       Real
--     &             max, buf, zero
-+     &             max, buf, zero, buf2(1)
-       parameter    ( zero = 0.0 )
- c
- c     %---------------------%
-@@ -69,15 +69,16 @@ Real function psnorm2 ( comm, n, x, inc )
-       psnorm2 = snrm2( n, x, inc)
- c
-       buf = psnorm2
--      call MPI_ALLREDUCE( buf, max, 1, MPI_REAL,
-+      call MPI_ALLREDUCE( [buf], buf2, 1, MPI_REAL,
-      &                    MPI_MAX, comm, ierr )
-+      max = buf2(1)
-       if ( max .eq. zero ) then
-          psnorm2 = zero
-       else
-          buf = (psnorm2/max)**2.0
--         call MPI_ALLREDUCE( buf, psnorm2, 1, MPI_REAL,
-+         call MPI_ALLREDUCE( [buf], buf2, 1, MPI_REAL,
-      &                       MPI_SUM, comm, ierr )
--         psnorm2 = max * sqrt(abs(psnorm2))
-+         psnorm2 = max * sqrt(abs(buf2(1)))
-       endif
- c
- c     %----------------%
-diff --git a/PARPACK/SRC/MPI/pssaitr.f b/PARPACK/SRC/MPI/pssaitr.f
-index a0fde737..8ceaebe4 100644
---- a/PARPACK/SRC/MPI/pssaitr.f
-+++ b/PARPACK/SRC/MPI/pssaitr.f
-@@ -264,7 +264,7 @@ subroutine pssaitr
-       integer    i, ierr, ipj, irj, ivj, iter, itry, j, msglvl, infol,
-      &           jj
-       Real
--     &           rnorm1, wnorm, safmin, temp1
-+     &           rnorm1, wnorm(1), safmin, temp1, temp2(1)
-       save       orth1, orth2, rstart, step3, step4,
-      &           ierr, ipj, irj, ivj, iter, itry, j, msglvl,
-      &           rnorm1, safmin, wnorm
-@@ -392,9 +392,9 @@ subroutine pssaitr
-  1000 continue
- c
-          if (msglvl .gt. 2) then
--            call pivout (comm, logfil, 1, j, ndigit,
-+            call pivout (comm, logfil, 1, [j], ndigit,
-      &                  '_saitr: generating Arnoldi vector no.')
--            call psvout (comm, logfil, 1, rnorm, ndigit,
-+            call psvout (comm, logfil, 1, [rnorm], ndigit,
-      &                  '_saitr: B-norm of the current residual =')
-          end if
- c
-@@ -412,7 +412,7 @@ subroutine pssaitr
- c           %---------------------------------------------------%
- c
-             if (msglvl .gt. 0) then
--               call pivout (comm, logfil, 1, j, ndigit,
-+               call pivout (comm, logfil, 1, [j], ndigit,
-      &                     '_saitr: ****** restart at step ******')
-             end if
- c
-@@ -572,16 +572,16 @@ subroutine pssaitr
- c           %----------------------------------%
- c
-             rnorm_buf = sdot (n, resid, 1, workd(ivj), 1)
--            call MPI_ALLREDUCE( rnorm_buf, wnorm, 1,
-+            call MPI_ALLREDUCE( [rnorm_buf], wnorm, 1,
-      &           MPI_REAL, MPI_SUM, comm, ierr )
--            wnorm = sqrt(abs(wnorm))
-+            wnorm(1) = sqrt(abs(wnorm(1)))
-          else if (bmat .eq. 'G') then
-             rnorm_buf = sdot (n, resid, 1, workd(ipj), 1)
--            call MPI_ALLREDUCE( rnorm_buf, wnorm, 1,
-+            call MPI_ALLREDUCE( [rnorm_buf], wnorm, 1,
-      &           MPI_REAL, MPI_SUM, comm, ierr )
-             wnorm = sqrt(abs(wnorm))
-          else if (bmat .eq. 'I') then
--            wnorm = psnorm2( comm, n, resid, 1 )
-+            wnorm(1) = psnorm2( comm, n, resid, 1 )
-          end if
- c
- c        %-----------------------------------------%
-@@ -669,9 +669,9 @@ subroutine pssaitr
- c
-          if (bmat .eq. 'G') then
-             rnorm_buf = sdot (n, resid, 1, workd(ipj), 1)
--            call MPI_ALLREDUCE( rnorm_buf, rnorm, 1,
-+            call MPI_ALLREDUCE( [rnorm_buf], temp2, 1,
-      &           MPI_REAL, MPI_SUM, comm, ierr )
--            rnorm = sqrt(abs(rnorm))
-+            rnorm = sqrt(abs(temp2(1)))
-          else if (bmat .eq. 'I') then
-             rnorm = psnorm2( comm, n, resid, 1 )
-          end if
-@@ -691,7 +691,7 @@ subroutine pssaitr
- c        | to enforce ||v(:,1:j)^T * r_{j}|| .le. eps * || r_{j} ||  |
- c        %-----------------------------------------------------------%
- c
--         if (rnorm .gt. 0.717*wnorm) go to 100
-+         if (rnorm .gt. 0.717*wnorm(1)) go to 100
-          nrorth = nrorth + 1
- c
- c        %---------------------------------------------------%
-@@ -704,7 +704,7 @@ subroutine pssaitr
-    80    continue
- c
-          if (msglvl .gt. 2) then
--            xtemp(1) = wnorm
-+            xtemp(1) = wnorm(1)
-             xtemp(2) = rnorm
-             call psvout (comm, logfil, 2, xtemp, ndigit,
-      &           '_naitr: re-orthonalization ; wnorm and rnorm are')
-@@ -769,15 +769,15 @@ subroutine pssaitr
- c
-          if (bmat .eq. 'G') then
-            rnorm_buf = sdot (n, resid, 1, workd(ipj), 1)
--           call MPI_ALLREDUCE( rnorm_buf, rnorm1, 1,
-+           call MPI_ALLREDUCE( [rnorm_buf], temp2, 1,
-      &          MPI_REAL, MPI_SUM, comm, ierr )
--           rnorm1 = sqrt(abs(rnorm1))
-+           rnorm1 = sqrt(abs(temp2(1)))
-          else if (bmat .eq. 'I') then
-            rnorm1 = psnorm2( comm, n, resid, 1 )
-          end if
- c
-          if (msglvl .gt. 0 .and. iter .gt. 0) then
--            call pivout (comm, logfil, 1, j, ndigit,
-+            call pivout (comm, logfil, 1, [j], ndigit,
-      &           '_naitr: Iterative refinement for Arnoldi residual')
-             if (msglvl .gt. 2) then
-                 xtemp(1) = rnorm
-diff --git a/PARPACK/SRC/MPI/pssapps.f b/PARPACK/SRC/MPI/pssapps.f
-index 481cc355..07f96452 100644
---- a/PARPACK/SRC/MPI/pssapps.f
-+++ b/PARPACK/SRC/MPI/pssapps.f
-@@ -271,9 +271,9 @@ subroutine pssapps
-             big   = abs(h(i,2)) + abs(h(i+1,2))
-             if (h(i+1,1) .le. epsmch*big) then
-                if (msglvl .gt. 0) then
--                  call pivout (comm, logfil, 1, i, ndigit,
-+                  call pivout (comm, logfil, 1, [i], ndigit,
-      &                 '_sapps: deflation at row/column no.')
--                  call pivout (comm, logfil, 1, jj, ndigit,
-+                  call pivout (comm, logfil, 1, [jj], ndigit,
-      &                 '_sapps: occurred before shift number.')
-                   call psvout (comm, logfil, 1, h(i+1,1), ndigit,
-      &                 '_sapps: the corresponding off diagonal element')
-@@ -442,7 +442,7 @@ subroutine pssapps
-          big   = abs(h(i,2)) + abs(h(i+1,2))
-          if (h(i+1,1) .le. epsmch*big) then
-             if (msglvl .gt. 0) then
--               call pivout (comm, logfil, 1, i, ndigit,
-+               call pivout (comm, logfil, 1, [i], ndigit,
-      &              '_sapps: deflation at row/column no.')
-                call psvout (comm, logfil, 1, h(i+1,1), ndigit,
-      &              '_sapps: the corresponding off diagonal element')
-diff --git a/PARPACK/SRC/MPI/pssaup2.f b/PARPACK/SRC/MPI/pssaup2.f
-index ab00ec77..25af8b7f 100644
---- a/PARPACK/SRC/MPI/pssaup2.f
-+++ b/PARPACK/SRC/MPI/pssaup2.f
-@@ -241,7 +241,7 @@ subroutine pssaup2
-       integer    ierr, iter, j, kplusp, msglvl, nconv, nevbef, nev0,
-      &           np0, nptemp, nevd2, nevm2, kp(3)
-       Real
--     &           rnorm, temp, eps23
-+     &           rnorm, temp, eps23, buf2(1)
-       save       cnorm, getv0, initv, update, ushift,
-      &           iter, kplusp, msglvl, nconv, nev0, np0,
-      &           rnorm, eps23
-@@ -424,13 +424,13 @@ subroutine pssaup2
-          iter = iter + 1
- c
-          if (msglvl .gt. 0) then
--            call pivout (comm, logfil, 1, iter, ndigit,
-+            call pivout (comm, logfil, 1, [iter], ndigit,
-      &           '_saup2: **** Start of major iteration number ****')
-          end if
-          if (msglvl .gt. 1) then
--            call pivout (comm, logfil, 1, nev, ndigit,
-+            call pivout (comm, logfil, 1, [nev], ndigit,
-      &     '_saup2: The length of the current Lanczos factorization')
--            call pivout (comm, logfil, 1, np, ndigit,
-+            call pivout (comm, logfil, 1, [np], ndigit,
-      &           '_saup2: Extend the Lanczos factorization by')
-          end if
- c
-@@ -469,7 +469,7 @@ subroutine pssaup2
-          update = .false.
- c
-          if (msglvl .gt. 1) then
--            call psvout (comm, logfil, 1, rnorm, ndigit,
-+            call psvout (comm, logfil, 1, [rnorm], ndigit,
-      &           '_saup2: Current B-norm of residual for factorization')
-          end if
- c
-@@ -719,7 +719,7 @@ subroutine pssaup2
-          end if
- c
-          if (msglvl .gt. 0) then
--            call pivout (comm, logfil, 1, nconv, ndigit,
-+            call pivout (comm, logfil, 1, [nconv], ndigit,
-      &           '_saup2: no. of "converged" Ritz values at this iter.')
-             if (msglvl .gt. 1) then
-                kp(1) = nev
-@@ -766,7 +766,7 @@ subroutine pssaup2
-          if (ishift .eq. 0) call scopy (np, workl, 1, ritz, 1)
- c
-          if (msglvl .gt. 2) then
--            call pivout (comm, logfil, 1, np, ndigit,
-+            call pivout (comm, logfil, 1, [np], ndigit,
-      &                  '_saup2: The number of shifts to apply ')
-             call psvout (comm, logfil, np, workl, ndigit,
-      &                  '_saup2: shifts selected')
-@@ -825,9 +825,9 @@ subroutine pssaup2
- c
-          if (bmat .eq. 'G') then
-             rnorm_buf = sdot (n, resid, 1, workd, 1)
--            call MPI_ALLREDUCE( rnorm_buf, rnorm, 1,
-+            call MPI_ALLREDUCE( [rnorm_buf], buf2, 1,
-      &                MPI_REAL, MPI_SUM, comm, ierr )
--            rnorm = sqrt(abs(rnorm))
-+            rnorm = sqrt(abs(buf2(1)))
-          else if (bmat .eq. 'I') then
-             rnorm = psnorm2( comm, n, resid, 1 )
-          end if
-@@ -835,7 +835,7 @@ subroutine pssaup2
-   130    continue
- c
-          if (msglvl .gt. 2) then
--            call psvout (comm, logfil, 1, rnorm, ndigit,
-+            call psvout (comm, logfil, 1, [rnorm], ndigit,
-      &      '_saup2: B-norm of residual for NEV factorization')
-             call psvout (comm, logfil, nev, h(1,2), ndigit,
-      &           '_saup2: main diagonal of compressed H matrix')
-diff --git a/PARPACK/SRC/MPI/pssaupd.f b/PARPACK/SRC/MPI/pssaupd.f
-index 7f616008..3077ff5f 100644
---- a/PARPACK/SRC/MPI/pssaupd.f
-+++ b/PARPACK/SRC/MPI/pssaupd.f
-@@ -652,9 +652,9 @@ subroutine pssaupd
-       if (info .eq. 2) info = 3
- c
-       if (msglvl .gt. 0) then
--         call pivout (comm, logfil, 1, mxiter, ndigit,
-+         call pivout (comm, logfil, 1, [mxiter], ndigit,
-      &               '_saupd: number of update iterations taken')
--         call pivout (comm, logfil, 1, np, ndigit,
-+         call pivout (comm, logfil, 1, [np], ndigit,
-      &               '_saupd: number of "converged" Ritz values')
-          call psvout (comm, logfil, np, workl(Ritz), ndigit,
-      &               '_saupd: final Ritz values')
-diff --git a/PARPACK/SRC/MPI/psseupd.f b/PARPACK/SRC/MPI/psseupd.f
-index 23e2caad..85175870 100644
---- a/PARPACK/SRC/MPI/psseupd.f
-+++ b/PARPACK/SRC/MPI/psseupd.f
-@@ -523,9 +523,9 @@ subroutine psseupd
- c        %-----------------------------------------------------------%
- c
-          if (msglvl .gt. 2) then
--             call pivout(comm, logfil, 1, numcnv, ndigit,
-+             call pivout(comm, logfil, 1, [numcnv], ndigit,
-      &            '_neupd: Number of specified eigenvalues')
--             call pivout(comm, logfil, 1, nconv, ndigit,
-+             call pivout(comm, logfil, 1, [nconv], ndigit,
-      &            '_neupd: Number of "converged" eigenvalues')
-          end if
- c
-diff --git a/PARPACK/SRC/MPI/pssgets.f b/PARPACK/SRC/MPI/pssgets.f
-index 487689b0..dcc08bcb 100644
---- a/PARPACK/SRC/MPI/pssgets.f
-+++ b/PARPACK/SRC/MPI/pssgets.f
-@@ -216,8 +216,8 @@ subroutine pssgets
-       tsgets = tsgets + (t1 - t0)
- c
-       if (msglvl .gt. 0) then
--         call pivout (comm, logfil, 1, kev, ndigit, '_sgets: KEV is')
--         call pivout (comm, logfil, 1, np, ndigit, '_sgets: NP is')
-+         call pivout (comm, logfil, 1, [kev], ndigit, '_sgets: KEV is')
-+         call pivout (comm, logfil, 1, [np], ndigit, '_sgets: NP is')
-          call psvout (comm, logfil, kev+np, ritz, ndigit,
-      &        '_sgets: Eigenvalues of current H matrix')
-          call psvout (comm, logfil, kev+np, bounds, ndigit,
-diff --git a/PARPACK/SRC/MPI/pzgetv0.f b/PARPACK/SRC/MPI/pzgetv0.f
-index 42cd0865..29f18f5b 100644
---- a/PARPACK/SRC/MPI/pzgetv0.f
-+++ b/PARPACK/SRC/MPI/pzgetv0.f
-@@ -185,7 +185,7 @@ subroutine pzgetv0
-       save       first, iseed, inits, iter, msglvl, orth, rnorm0
- c
-       Complex*16
--     &           cnorm_buf
-+     &           cnorm_buf, buf2(1)
- c
- c     %----------------------%
- c     | External Subroutines |
-@@ -332,8 +332,9 @@ subroutine pzgetv0
-       first = .FALSE.
-       if (bmat .eq. 'G') then
-           cnorm_buf = zdotc  (n, resid, 1, workd, 1)
--          call MPI_ALLREDUCE( cnorm_buf, cnorm, 1,
-+          call MPI_ALLREDUCE( [cnorm_buf], buf2, 1,
-      &          MPI_DOUBLE_COMPLEX , MPI_SUM, comm, ierr )
-+          cnorm = buf2(1)
-           rnorm0 = sqrt(dlapy2 (dble (cnorm),dimag (cnorm)))
-       else if (bmat .eq. 'I') then
-            rnorm0 = pdznorm2 ( comm, n, resid, 1)
-@@ -393,8 +394,9 @@ subroutine pzgetv0
- c
-       if (bmat .eq. 'G') then
-          cnorm_buf = zdotc  (n, resid, 1, workd, 1)
--         call MPI_ALLREDUCE( cnorm_buf, cnorm, 1,
-+         call MPI_ALLREDUCE( [cnorm_buf], buf2, 1,
-      &            MPI_DOUBLE_COMPLEX , MPI_SUM, comm, ierr )
-+         cnorm = buf2(1)
-          rnorm = sqrt(dlapy2 (dble (cnorm),dimag (cnorm)))
-       else if (bmat .eq. 'I') then
-          rnorm = pdznorm2 (comm, n, resid, 1)
-@@ -405,9 +407,9 @@ subroutine pzgetv0
- c     %--------------------------------------%
- c
-       if (msglvl .gt. 2) then
--          call pdvout  (comm, logfil, 1, rnorm0, ndigit,
-+          call pdvout  (comm, logfil, 1, [rnorm0], ndigit,
-      &                '_getv0: re-orthonalization ; rnorm0 is')
--          call pdvout  (comm, logfil, 1, rnorm, ndigit,
-+          call pdvout  (comm, logfil, 1, [rnorm], ndigit,
-      &                '_getv0: re-orthonalization ; rnorm is')
-       end if
- c
-@@ -439,7 +441,7 @@ subroutine pzgetv0
- c
-       if (msglvl .gt. 0) then
-          cnorm2 = dcmplx (rnorm,rzero)
--         call pzvout  (comm, logfil, 1, cnorm2, ndigit,
-+         call pzvout  (comm, logfil, 1, [cnorm2], ndigit,
-      &        '_getv0: B-norm of initial / restarted starting vector')
-       end if
-       if (msglvl .gt. 2) then
-diff --git a/PARPACK/SRC/MPI/pznaitr.f b/PARPACK/SRC/MPI/pznaitr.f
-index 0b8af181..4ec77e4e 100644
---- a/PARPACK/SRC/MPI/pznaitr.f
-+++ b/PARPACK/SRC/MPI/pznaitr.f
-@@ -293,7 +293,7 @@ subroutine pznaitr
-      &           betaj, rnorm1, smlnum, ulp, unfl, wnorm
- c
-       Complex*16
--     &           cnorm_buf
-+     &           cnorm_buf, buf2(1)
- c
- c     %----------------------%
- c     | External Subroutines |
-@@ -404,9 +404,9 @@ subroutine pznaitr
-  1000 continue
- c
-          if (msglvl .gt. 1) then
--            call pivout (comm, logfil, 1, j, ndigit,
-+            call pivout (comm, logfil, 1, [j], ndigit,
-      &                  '_naitr: generating Arnoldi vector number')
--            call pzvout (comm, logfil, 1, rnorm, ndigit,
-+            call pdvout (comm, logfil, 1, [rnorm], ndigit,
-      &                  '_naitr: B-norm of the current residual is')
-          end if
- c
-@@ -426,7 +426,7 @@ subroutine pznaitr
- c           %---------------------------------------------------%
- c
-             if (msglvl .gt. 0) then
--               call pivout (comm, logfil, 1, j, ndigit,
-+               call pivout (comm, logfil, 1, [j], ndigit,
-      &                     '_naitr: ****** RESTART AT STEP ******')
-             end if
- c
-@@ -577,9 +577,10 @@ subroutine pznaitr
- c
-          if (bmat .eq. 'G') then
-              cnorm_buf = zdotc (n, resid, 1, workd(ipj), 1)
--            call MPI_ALLREDUCE( cnorm_buf, cnorm, 1,
-+            call MPI_ALLREDUCE( [cnorm_buf], buf2, 1,
-      &           MPI_DOUBLE_COMPLEX, MPI_SUM, comm, ierr )
--             wnorm = sqrt( dlapy2(dble(cnorm),dimag(cnorm)) )
-+            cnorm = buf2(1)
-+            wnorm = sqrt( dlapy2(dble(cnorm),dimag(cnorm)) )
-          else if (bmat .eq. 'I') then
-              wnorm = pdznorm2(comm, n, resid, 1)
-          end if
-@@ -653,8 +654,9 @@ subroutine pznaitr
- c
-          if (bmat .eq. 'G') then
-             cnorm_buf = zdotc (n, resid, 1, workd(ipj), 1)
--            call MPI_ALLREDUCE( cnorm_buf, cnorm, 1,
-+            call MPI_ALLREDUCE( [cnorm_buf], buf2, 1,
-      &           MPI_DOUBLE_COMPLEX, MPI_SUM, comm, ierr )
-+            cnorm = buf2(1)
-             rnorm = sqrt( dlapy2(dble(cnorm),dimag(cnorm)) )
-          else if (bmat .eq. 'I') then
-             rnorm = pdznorm2(comm, n, resid, 1)
-@@ -757,15 +759,16 @@ subroutine pznaitr
- c
-          if (bmat .eq. 'G') then
-              cnorm_buf = zdotc (n, resid, 1, workd(ipj), 1)
--            call MPI_ALLREDUCE( cnorm_buf, cnorm, 1,
-+            call MPI_ALLREDUCE( [cnorm_buf], buf2, 1,
-      &           MPI_DOUBLE_COMPLEX, MPI_SUM, comm, ierr )
--             rnorm1 = sqrt( dlapy2(dble(cnorm),dimag(cnorm)) )
-+            cnorm = buf2(1)
-+            rnorm1 = sqrt( dlapy2(dble(cnorm),dimag(cnorm)) )
-          else if (bmat .eq. 'I') then
-              rnorm1 = pdznorm2(comm, n, resid, 1)
-          end if
- c
-          if (msglvl .gt. 0 .and. iter .gt. 0 ) then
--            call pivout (comm, logfil, 1, j, ndigit,
-+            call pivout (comm, logfil, 1, [j], ndigit,
-      &           '_naitr: Iterative refinement for Arnoldi residual')
-             if (msglvl .gt. 2) then
-                 rtemp(1) = rnorm
-diff --git a/PARPACK/SRC/MPI/pznapps.f b/PARPACK/SRC/MPI/pznapps.f
-index 3e00c903..4952544c 100644
---- a/PARPACK/SRC/MPI/pznapps.f
-+++ b/PARPACK/SRC/MPI/pznapps.f
-@@ -283,9 +283,9 @@ subroutine pznapps
-          sigma = shift(jj)
- c
-          if (msglvl .gt. 2 ) then
--            call pivout (comm, logfil, 1, jj, ndigit,
-+            call pivout (comm, logfil, 1, [jj], ndigit,
-      &               '_napps: shift number.')
--            call pzvout (comm, logfil, 1, sigma, ndigit,
-+            call pzvout (comm, logfil, 1, [sigma], ndigit,
-      &               '_napps: Value of the shift ')
-          end if
- c
-@@ -306,9 +306,9 @@ subroutine pznapps
-             if ( abs(dble(h(i+1,i)))
-      &           .le. max(ulp*tst1, smlnum) )  then
-                if (msglvl .gt. 0) then
--                  call pivout (comm, logfil, 1, i, ndigit,
-+                  call pivout (comm, logfil, 1, [i], ndigit,
-      &                 '_napps: matrix splitting at row/column no.')
--                  call pivout (comm, logfil, 1, jj, ndigit,
-+                  call pivout (comm, logfil, 1, [jj], ndigit,
-      &                 '_napps: matrix splitting with shift number.')
-                   call pzvout (comm, logfil, 1, h(i+1,i), ndigit,
-      &                 '_napps: off diagonal element.')
-@@ -322,9 +322,9 @@ subroutine pznapps
-    40    continue
- c
-          if (msglvl .gt. 2) then
--             call pivout (comm, logfil, 1, istart, ndigit,
-+             call pivout (comm, logfil, 1, [istart], ndigit,
-      &                   '_napps: Start of current block ')
--             call pivout (comm, logfil, 1, iend, ndigit,
-+             call pivout (comm, logfil, 1, [iend], ndigit,
-      &                   '_napps: End of current block ')
-          end if
- c
-@@ -500,7 +500,7 @@ subroutine pznapps
-      &        '_napps: sigmak = (e_{kev+p}^T*Q)*e_{kev}')
-          call pzvout (comm, logfil, 1, h(kev+1,kev), ndigit,
-      &        '_napps: betak = e_{kev+1}^T*H*e_{kev}')
--         call pivout (comm, logfil, 1, kev, ndigit,
-+         call pivout (comm, logfil, 1, [kev], ndigit,
-      &               '_napps: Order of the final Hessenberg matrix ')
-          if (msglvl .gt. 2) then
-             call pzmout (comm, logfil, kev, kev, h, ldh, ndigit,
-diff --git a/PARPACK/SRC/MPI/pznaup2.f b/PARPACK/SRC/MPI/pznaup2.f
-index bf3c2016..78521979 100644
---- a/PARPACK/SRC/MPI/pznaup2.f
-+++ b/PARPACK/SRC/MPI/pznaup2.f
-@@ -237,7 +237,7 @@ subroutine pznaup2
-      &           nevbef, nev0 , np0,    eps23
- c
-       Double precision
--     &           cmpnorm_buf
-+     &           cmpnorm_buf, buf2(1)
- c
- c     %-----------------------%
- c     | Local array arguments |
-@@ -401,7 +401,7 @@ subroutine pznaup2
-          iter = iter + 1
- c
-          if (msglvl .gt. 0) then
--            call pivout (comm, logfil, 1, iter, ndigit,
-+            call pivout (comm, logfil, 1, [iter], ndigit,
-      &           '_naup2: **** Start of major iteration number ****')
-          end if
- c
-@@ -414,9 +414,9 @@ subroutine pznaup2
-          np  = kplusp - nev
- c
-          if (msglvl .gt. 1) then
--            call pivout (comm, logfil, 1, nev, ndigit,
-+            call pivout (comm, logfil, 1, [nev], ndigit,
-      &     '_naup2: The length of the current Arnoldi factorization')
--            call pivout (comm, logfil, 1, np, ndigit,
-+            call pivout (comm, logfil, 1, [np], ndigit,
-      &           '_naup2: Extend the Arnoldi factorization by')
-          end if
- c
-@@ -443,7 +443,7 @@ subroutine pznaup2
-          update = .false.
- c
-          if (msglvl .gt. 1) then
--            call pdvout (comm, logfil, 1, rnorm, ndigit,
-+            call pdvout (comm, logfil, 1, [rnorm], ndigit,
-      &           '_naup2: Corresponding B-norm of the residual')
-          end if
- c
-@@ -674,7 +674,7 @@ subroutine pznaup2
-          end if
- c
-          if (msglvl .gt. 0) then
--            call pivout (comm, logfil, 1, nconv, ndigit,
-+            call pivout (comm, logfil, 1, [nconv], ndigit,
-      &           '_naup2: no. of "converged" Ritz values at this iter.')
-             if (msglvl .gt. 1) then
-                kp(1) = nev
-@@ -714,7 +714,7 @@ subroutine pznaup2
-          end if
- c
-          if (msglvl .gt. 2) then
--            call pivout (comm, logfil, 1, np, ndigit,
-+            call pivout (comm, logfil, 1, [np], ndigit,
-      &                  '_naup2: The number of shifts to apply ')
-             call pzvout (comm, logfil, np, ritz, ndigit,
-      &                  '_naup2: values of the shifts')
-@@ -771,8 +771,9 @@ subroutine pznaup2
- c
-          if (bmat .eq. 'G') then
-             cmpnorm_buf = zdotc (n, resid, 1, workd, 1)
--            call MPI_ALLREDUCE( cmpnorm_buf, cmpnorm, 1,
-+            call MPI_ALLREDUCE( [cmpnorm_buf], buf2, 1,
-      &               MPI_DOUBLE_COMPLEX, MPI_SUM, comm, ierr )
-+            cmpnorm = buf2(1)
-             rnorm = sqrt(dlapy2(dble(cmpnorm),dimag(cmpnorm)))
-          else if (bmat .eq. 'I') then
-             rnorm = pdznorm2(comm, n, resid, 1)
-@@ -780,7 +781,7 @@ subroutine pznaup2
-          cnorm = .false.
- c
-          if (msglvl .gt. 2) then
--            call pdvout (comm, logfil, 1, rnorm, ndigit,
-+            call pdvout (comm, logfil, 1, [rnorm], ndigit,
-      &      '_naup2: B-norm of residual for compressed factorization')
-             call pzmout (comm, logfil, nev, nev, h, ldh, ndigit,
-      &        '_naup2: Compressed upper Hessenberg matrix H')
-diff --git a/PARPACK/SRC/MPI/pznaupd.f b/PARPACK/SRC/MPI/pznaupd.f
-index 979402b3..7d6ea4c4 100644
---- a/PARPACK/SRC/MPI/pznaupd.f
-+++ b/PARPACK/SRC/MPI/pznaupd.f
-@@ -626,9 +626,9 @@ subroutine pznaupd
-       if (info .eq. 2) info = 3
- c
-       if (msglvl .gt. 0) then
--         call pivout (comm, logfil, 1, mxiter, ndigit,
-+         call pivout (comm, logfil, 1, [mxiter], ndigit,
-      &               '_naupd: Number of update iterations taken')
--         call pivout (comm, logfil, 1, np, ndigit,
-+         call pivout (comm, logfil, 1, [np], ndigit,
-      &               '_naupd: Number of wanted "converged" Ritz values')
-          call pzvout  (comm, logfil, np, workl(ritz), ndigit,
-      &               '_naupd: The final Ritz values')
-diff --git a/PARPACK/SRC/MPI/pzneupd.f b/PARPACK/SRC/MPI/pzneupd.f
-index 4bb1173a..7b6e7fe1 100644
---- a/PARPACK/SRC/MPI/pzneupd.f
-+++ b/PARPACK/SRC/MPI/pzneupd.f
-@@ -558,9 +558,9 @@ subroutine pzneupd
- c        %-----------------------------------------------------------%
- c
-          if (msglvl .gt. 2) then
--             call pivout(comm, logfil, 1, numcnv, ndigit,
-+             call pivout(comm, logfil, 1, [numcnv], ndigit,
-      &            '_neupd: Number of specified eigenvalues')
--             call pivout(comm, logfil, 1, nconv, ndigit,
-+             call pivout(comm, logfil, 1, [nconv], ndigit,
-      &            '_neupd: Number of "converged" eigenvalues')
-          end if
- c
-diff --git a/PARPACK/SRC/MPI/pzngets.f b/PARPACK/SRC/MPI/pzngets.f
-index 97bc4070..cb58f5ce 100644
---- a/PARPACK/SRC/MPI/pzngets.f
-+++ b/PARPACK/SRC/MPI/pzngets.f
-@@ -177,8 +177,8 @@ subroutine pzngets ( comm, ishift, which, kev, np, ritz, bounds)
-       tcgets = tcgets + (t1 - t0)
- c
-       if (msglvl .gt. 0) then
--         call pivout (comm, logfil, 1, kev, ndigit, '_ngets: KEV is')
--         call pivout (comm, logfil, 1, np, ndigit, '_ngets: NP is')
-+         call pivout (comm, logfil, 1, [kev], ndigit, '_ngets: KEV is')
-+         call pivout (comm, logfil, 1, [np], ndigit, '_ngets: NP is')
-          call pzvout (comm, logfil, kev+np, ritz, ndigit,
-      &        '_ngets: Eigenvalues of current H matrix ')
-          call pzvout (comm, logfil, kev+np, bounds, ndigit,
-diff --git a/scripts/travis_fedora.sh b/scripts/travis_fedora.sh
-new file mode 100755
-index 00000000..0bfa5736
---- /dev/null
-+++ b/scripts/travis_fedora.sh
-@@ -0,0 +1,51 @@
-+#!/bin/sh
-+## -e : Make sure all errors cause the script to fail
-+## -x be verbose; write what we are doing, as we do it
-+set -ex
-+## Should we init a container?
-+if [ ".$1" = .setup ]
-+then
-+  # fedora
-+  #   note: when you PR, docker-cp provides, in the container, the branch associated with the PR (not master where there's nothing new)
-+  #         1. docker create --name mobydick IMAGE CMD        <=> create a container (= instance of image) but container is NOT yet started
-+  #         2. docker cp -a ${TRAVIS_BUILD_DIR} mobydick:/tmp <=> copy git repository (CI worker, checkout-ed on PR branch) into the container
-+  #                                                               note: docker-cp works only if copy from/to containers (not images)
-+  #         3. docker start -a mobydick                       <=> start to run the container (initialized with docker-cp)
-+    test . != ".$2" && mpi="$2" || mpi=openmpi
-+    test . != ".$3" && version="$3" || version=latest
-+    time sudo docker pull registry.fedoraproject.org/fedora:$version ||
-+	sudo docker pull fedora:$version
-+    time sudo docker create --name mobydick fedora:$version \
-+	/tmp/arpack-ng/scripts/travis_fedora.sh $mpi
-+    time sudo docker cp -a ${TRAVIS_BUILD_DIR} mobydick:/tmp
-+    time sudo docker start -a mobydick ; e=$?
-+    exit $e
-+fi
-+
-+test . != ".$1" && mpi="$1" || mpi=openmpi
-+
-+## If we are called as root, setup everything
-+if [ $UID -eq 0 ]
-+then
-+    time dnf -y upgrade
-+    time dnf -y install environment-modules git \
-+        gfortran openblas-devel cmake ${mpi}-devel make gcc-c++
-+    useradd test
-+    chown -R test /tmp
-+    sudo -u test $0 $mpi
-+## If we are called as normal user, run test
-+else
-+    . /etc/profile.d/modules.sh
-+    module load mpi
-+    export OMPI_MCA_rmaps_base_oversubscribe=yes
-+    cd /tmp
-+    cd arpack-ng
-+    git status
-+    git log -2
-+    mkdir -p build && cd build
-+    time cmake -DEXAMPLES=ON -DMPI=ON -DICB=ON ..
-+    export VERBOSE=1
-+    time make all
-+    time make test
-+    tail -n 300 ./Testing/Temporary/LastTest.log
-+fi
--- a/src/arpack.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/arpack.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := arpack
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 3.7.0
-$(PKG)_CHECKSUM := cb5a6e1f3c5ab231440bbe30f4a0808d76215e93
+$(PKG)_VERSION  := 3.8.0
+$(PKG)_CHECKSUM := 6b89dc1b298e1db7df17094308fc3309afa49618
 $(PKG)_SUBDIR   := $(PKG)-ng-$($(PKG)_VERSION)
 $(PKG)_FILE     := arpack-ng_$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := https://github.com/opencollab/arpack-ng/archive/$($(PKG)_VERSION).tar.gz
@@ -28,8 +28,8 @@
 endif
 
 define $(PKG)_UPDATE
-    $(WGET) -q -O- 'https://github.com/opencollab/arpack-ng/releases' | \
-    $(SED) -n 's,.*href="/opencollab/arpack-ng/archive/\([0-9][^"]*\)\.tar.*,\1,p' | \
+    $(WGET) -q -O- 'https://github.com/opencollab/arpack-ng/tags' | \
+    $(SED) -n 's,.*releases/tag/\([^"]*\).*,\1,p' | \
     head -1
 endef
 
--- a/src/biosig.mk	Wed Nov 24 18:31:48 2021 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-# This file is part of MXE.
-# See index.html for further information.
-
-PKG             := biosig
-$(PKG)_WEBSITE  := http://biosig.sf.net/
-$(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 2.3.1
-$(PKG)_CHECKSUM := adaa0c2f8fb4e8ae0f7d96a79967b7ffae6a9848
-$(PKG)_SUBDIR   := biosig-$($(PKG)_VERSION)
-$(PKG)_FILE     := biosig-$($(PKG)_VERSION).src.tar.gz
-$(PKG)_URL      := https://sourceforge.net/projects/biosig/files/BioSig%20for%20C_C%2B%2B/src/$($(PKG)_FILE)
-$(PKG)_DEPS     := suitesparse zlib libb64 libiberty libiconv lapack tinyxml dcmtk
-
-define $(PKG)_UPDATE
-    $(WGET) -q -O- 'https://biosig.sourceforge.io/download.html' | \
-        $(SED) -n 's_.*>v\([0-9]\.[0-9]\.[0-9]\)<.*_\1_p' | \
-        head -1
-endef
-
-
-define $(PKG)_BUILD
-    cd '$(1)' && ./configure \
-        ac_cv_func_malloc_0_nonnull=yes \
-        ac_cv_func_realloc_0_nonnull=yes \
-        --prefix=$(HOST_PREFIX) \
-        $(HOST_AND_BUILD_CONFIGURE_OPTIONS)
-
-    # make sure NDEBUG is defined
-    $(SED) -i '/NDEBUG/ s|#||g' '$(1)'/biosig4c++/Makefile
-
-    TARGET=$(TARGET) CROSS=$(TARGET) $(MAKE) -C '$(1)' lib tools
-
-    # build mexbiosig package (does not install package)
-    # TARGET='$(TARGET)' $(MAKE) -C '$(1)'/biosig4c++ mexbiosig
-
-    # install library files
-    $(INSTALL) -m644 '$(1)/biosig4c++/biosig.h'             '$(HOST_INCDIR)/'
-    $(INSTALL) -m644 '$(1)/biosig4c++/biosig2.h'            '$(HOST_INCDIR)/'
-    $(INSTALL) -m644 '$(1)/biosig4c++/gdftime.h'            '$(HOST_INCDIR)/'
-    $(INSTALL) -m644 '$(1)/biosig4c++/biosig-dev.h'         '$(HOST_INCDIR)/'
-
-    $(INSTALL) -m644 '$(1)/biosig4c++/libbiosig.a'          '$(HOST_LIBDIR)/'
-    #$(INSTALL) -m644 '$(1)/biosig4c++/libbiosig.def'        '$(HOST_LIBDIR)/'
-    $(INSTALL) -m644 '$(1)/biosig4c++/libbiosig.dll.a'      '$(HOST_LIBDIR)/'
-    $(INSTALL) -m644 '$(1)/biosig4c++/libbiosig.dll'        '$(HOST_BINDIR)/'
-
-    $(INSTALL) -m644 '$(1)/biosig4c++/libgdf.a'             '$(HOST_LIBDIR)/'
-    #$(INSTALL) -m644 '$(1)/biosig4c++/libgdf.def'           '$(HOST_LIBDIR)/'
-    $(INSTALL) -m644 '$(1)/biosig4c++/libgdf.dll.a'         '$(HOST_LIBDIR)/'
-    $(INSTALL) -m644 '$(1)/biosig4c++/libgdf.dll'           '$(HOST_BINDIR)/'
-
-
-    $(INSTALL) -m644 '$(1)/biosig4c++/physicalunits.h'      '$(HOST_INCDIR)/'
-    $(INSTALL) -m644 '$(1)/biosig4c++/libphysicalunits.a'   '$(HOST_LIBDIR)/'
-    #$(INSTALL) -m644 '$(1)/biosig4c++/libphysicalunits.def' '$(HOST_LIBDIR)/'
-    $(INSTALL) -m644 '$(1)/biosig4c++/libphysicalunits.dll.a' '$(HOST_LIBDIR)/'
-    $(INSTALL) -m644 '$(1)/biosig4c++/libphysicalunits.dll' '$(HOST_BINDIR)/'
-
-    if [ "$(MXE_WINDOWS_BUILD)" == "yes" ]; then \
-        $(SED) -i '/^Libs:/ s/$$/ -liconv -lws2_32/' $(1)/biosig4c++/libbiosig.pc; \
-    fi
-    $(INSTALL) -m644 '$(1)/biosig4c++/libbiosig.pc'         '$(HOST_LIBDIR)/pkgconfig/'
-
-    # install biosig4matlab
-    # $(INSTALL) -d $(HOST_PREFIX)/share/biosig/matlab
-    # cp -r '$(1)'/biosig4matlab/* $(HOST_PREFIX)/share/biosig/matlab/
-endef
-
--- a/src/blas.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/blas.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := blas
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 3.8.0
-$(PKG)_CHECKSUM := ee21dc04e563f50ccf173c957f98d2ff47702cb4
+$(PKG)_VERSION  := 3.10.0
+$(PKG)_CHECKSUM := dbb9d61c51c322b5e19542aaa2bb4b02b95a774b
 $(PKG)_SUBDIR   := BLAS-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tgz
 $(PKG)_URL      := http://www.netlib.org/$(PKG)/$($(PKG)_FILE)
@@ -28,22 +28,27 @@
 endif
 
 define $(PKG)_BUILD
-    $(SED) -i 's,$$(FORTRAN),$(MXE_F77) $(MXE_F77_PICFLAG) $($(PKG)_DEFAULT_INTEGER_8_FLAG),g' '$(1)/Makefile'
-    $(MAKE) -C '$(1)' ARCH=$(MXE_AR) RANLIB=$(MXE_RANLIB) $($(PKG)_TARGETS) -j '$(JOBS)'
+  $(MAKE) -C '$(1)' \
+    FC=$(MXE_F77) \
+    FFLAGS='$(MXE_F77_PICFLAG) $($(PKG)_DEFAULT_INTEGER_8_FLAG)' \
+    AR=$(MXE_AR) \
+    RANLIB=$(MXE_RANLIB) \
+    $($(PKG)_TARGETS) \
+    -j '$(JOBS)'
 
-    if [ $(BUILD_SHARED) = yes ]; then \
-      if [ -n "$($(PKG)_LIBXERBLA)" ]; then \
-        $(MAKE_SHARED_FROM_STATIC) --ar '$(MXE_AR)' --ld '$(MXE_F77)' '$(1)/libxerbla.a' --install '$(INSTALL)' --libdir '$(3)$(HOST_LIBDIR)' --bindir '$(3)$(HOST_BINDIR)'; \
-        $(INSTALL) '$(3)/$(HOST_BINDIR)/libxerbla.dll' '$(3)$(HOST_BINDIR)/libxerbla-blas.dll'; \
-      fi; \
-      $(MAKE_SHARED_FROM_STATIC) --ar '$(MXE_AR)' --ld '$(MXE_F77)' '$(1)/libblas.a' --install '$(INSTALL)' --libdir '$(3)$(HOST_LIBDIR)' --bindir '$(3)$(HOST_BINDIR)' $($(PKG)_LIBXERBLA); \
-    fi
+  if [ $(BUILD_SHARED) = yes ]; then \
+    if [ -n "$($(PKG)_LIBXERBLA)" ]; then \
+      $(MAKE_SHARED_FROM_STATIC) --ar '$(MXE_AR)' --ld '$(MXE_F77)' '$(1)/libxerbla.a' --install '$(INSTALL)' --libdir '$(3)$(HOST_LIBDIR)' --bindir '$(3)$(HOST_BINDIR)'; \
+      $(INSTALL) '$(3)/$(HOST_BINDIR)/libxerbla.dll' '$(3)$(HOST_BINDIR)/libxerbla-blas.dll'; \
+    fi; \
+    $(MAKE_SHARED_FROM_STATIC) --ar '$(MXE_AR)' --ld '$(MXE_F77)' '$(1)/libblas.a' --install '$(INSTALL)' --libdir '$(3)$(HOST_LIBDIR)' --bindir '$(3)$(HOST_BINDIR)' $($(PKG)_LIBXERBLA); \
+  fi
 
-    if [ $(BUILD_STATIC) = yes ]; then \
-      $(INSTALL) -d '$(3)$(HOST_LIBDIR)'; \
-      $(INSTALL) '$(1)/libblas.a' '$(3)$(HOST_LIBDIR)/'; \
-      if [ -n "$($(PKG)_LIBXERBLA)" ]; then \
-        $(INSTALL) '$(1)/libxerbla.a' '$(3)$(HOST_LIBDIR)/'; \
-      fi; \
-    fi
+  if [ $(BUILD_STATIC) = yes ]; then \
+    $(INSTALL) -d '$(3)$(HOST_LIBDIR)'; \
+    $(INSTALL) '$(1)/libblas.a' '$(3)$(HOST_LIBDIR)/'; \
+    if [ -n "$($(PKG)_LIBXERBLA)" ]; then \
+      $(INSTALL) '$(1)/libxerbla.a' '$(3)$(HOST_LIBDIR)/'; \
+    fi; \
+  fi
 endef
--- a/src/build-cmake.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/build-cmake.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := build-cmake
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 3.18.4
-$(PKG)_CHECKSUM := 73ab5348c881f1a53c250b66848b6ee101c9fe1f
+$(PKG)_VERSION  := 3.21.4
+$(PKG)_CHECKSUM := 7d5bde583207dc205cba158ce46f0c389884b211
 $(PKG)_SUBDIR   := cmake-$($(PKG)_VERSION)
 $(PKG)_FILE     := cmake-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://www.cmake.org/files/v$(call SHORT_PKG_VERSION,$(PKG))/$($(PKG)_FILE)
--- a/src/build-gcc.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/build-gcc.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := build-gcc
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 9.3.0
-$(PKG)_CHECKSUM := b746688bf045a316fc92c3528138ad10d0822b6b
+$(PKG)_VERSION  := 11.2.0
+$(PKG)_CHECKSUM := f902ccacecf8949978d6261e9f1d034cff73ffdb
 $(PKG)_SUBDIR   := gcc-$($(PKG)_VERSION)
 $(PKG)_FILE     := gcc-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := ftp://ftp.gnu.org/pub/gnu/gcc/gcc-$($(PKG)_VERSION)/$($(PKG)_FILE)
@@ -32,6 +32,7 @@
     --without-x \
     --disable-win32-registry \
     --enable-threads=posix
+
   ifneq ($(TARGET),x86_64-w64-mingw32)
     $(PKG)_SYSDEP_CONFIGURE_OPTIONS += \
     --libdir='$(BUILD_TOOLS_PREFIX)/lib' \
@@ -47,41 +48,56 @@
       fi
     endef
   endif
+
+  ifneq ($(OCTAVE_TARGET),release-octave)
+    # FIXME: Set unconditionally for the first release candidate of Octave 7.
+    $(PKG)_WINAPI_VERSION_FLAGS := --with-default-win32-winnt=0x0601
+  endif
+
+  ifneq ($(HOST_MSVCRT),ucrt)
+    $(PKG)_DEFAULT_MSVCRT := --with-default-msvcrt=msvcrt
+  else
+    $(PKG)_DEFAULT_MSVCRT := --with-default-msvcrt=ucrt
+  endif
+
   define $(PKG)_INSTALL_SYSTEM_HEADERS
     $($(PKG)_PRE_BUILD)
     # install mingw-w64 headers
     $(call PREPARE_PKG_SOURCE,mingw-w64,$(1))
     mkdir '$(1).headers'
     cd '$(1).headers' && '$(1)/$(mingw-w64_SUBDIR)/mingw-w64-headers/configure' \
-        --host='$(TARGET)' \
-        --prefix='$(HOST_PREFIX)' \
-        --enable-sdk=all \
-        --enable-idl \
-        --enable-secure-api \
-        $(mingw-w64-headers_CONFIGURE_OPTS)
+      --host='$(TARGET)' \
+      --prefix='$(HOST_PREFIX)' \
+      --enable-sdk=all \
+      --enable-idl \
+      --enable-secure-api \
+      $($(PKG)_WINAPI_VERSION_FLAGS) \
+      $($(PKG)_DEFAULT_MSVCRT) \
+      $(mingw-w64-headers_CONFIGURE_OPTS)
     $(MAKE) -C '$(1).headers' install
   endef
+  
   define $(PKG)_BUILD_SYSTEM_RUNTIME
     # build standalone gcc
     $(MAKE) -C '$(1).build' -j '$(JOBS)' all-gcc
     $(MAKE) -C '$(1).build' -j 1 install-gcc
-
     # build mingw-w64-crt
     mkdir '$(1).crt-build'
     cd '$(1).crt-build' && '$(1)/$(mingw-w64_SUBDIR)/mingw-w64-crt/configure' \
-	--host='$(TARGET)' \
-	--prefix='$(HOST_PREFIX)' \
-	$(if $(filter $(TARGET), x86_64-w64-mingw32),--disable-lib32) \
-	--with-sysroot='$(HOST_PREFIX)'
+      --host='$(TARGET)' \
+      --prefix='$(HOST_PREFIX)' \
+      $(if $(filter $(TARGET), x86_64-w64-mingw32),--disable-lib32) \
+      --with-sysroot='$(HOST_PREFIX)' \
+      $($(PKG)_DEFAULT_MSVCRT)
     $(MAKE) -C '$(1).crt-build' -j '$(JOBS)' || $(MAKE) -C '$(1).crt-build' -j '$(JOBS)'
     $(MAKE) -C '$(1).crt-build' -j 1 install
 
     # build posix threads
     mkdir '$(1).pthreads'
     cd '$(1).pthreads' && '$(1)/$(mingw-w64_SUBDIR)/mingw-w64-libraries/winpthreads/configure' \
-        $(HOST_AND_BUILD_CONFIGURE_OPTIONS) \
-        --prefix='$(HOST_PREFIX)' \
-        $(ENABLE_SHARED_OR_STATIC)
+      $(HOST_AND_BUILD_CONFIGURE_OPTIONS) \
+      --prefix='$(HOST_PREFIX)' \
+      $(ENABLE_SHARED_OR_STATIC)
     $(MAKE) -C '$(1).pthreads' -j '$(JOBS)' || $(MAKE) -C '$(1).pthreads' -j '$(JOBS)'
     $(MAKE) -C '$(1).pthreads' -j 1 install
   endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/build-libffi.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,34 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+_PKG            := libffi
+PKG             := build-$(_PKG)
+$(PKG)_IGNORE   :=
+$(PKG)_VERSION  := 3.4.2
+$(PKG)_CHECKSUM := f5fbf0e8b643c4029a069faca32dd0df2c7dd0a2
+$(PKG)_SUBDIR   := $(_PKG)-$($(PKG)_VERSION)
+$(PKG)_FILE     := $(_PKG)-$($(PKG)_VERSION).tar.gz
+$(PKG)_URL      := https://github.com/$(_PKG)/$(_PKG)/archive/refs/tags/v$($(PKG)_VERSION).tar.gz
+$(PKG)_DEPS     := build-libtool
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- 'https://github.com/libffi/libffi/tags' | \
+    $(SED) -n 's,.*releases/tag/v\([0-9][^"]*\).*,\1,p' | \
+    head -1
+endef
+
+define $(PKG)_BUILD
+  cd '$(1)' && \
+    ./autogen.sh && \
+    ./configure \
+      --prefix='$(BUILD_TOOLS_PREFIX)' \
+      $(ENABLE_SHARED_OR_STATIC)
+
+  $(MAKE) -C '$(1)' -j '$(JOBS)'
+  $(MAKE) -C '$(1)' -j 1 install DESTDIR='$(3)' 
+
+  if [ "$(ENABLE_DEP_DOCS)" == "no" ]; then \
+    rm -rf "$(3)$(BUILD_TOOLS_PREFIX)/share"; \
+  fi
+
+endef
--- a/src/build-m4-glibc2-28.patch	Wed Nov 24 18:31:48 2021 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,123 +0,0 @@
-# This file is based on a Debian patch:
-# https://launchpadlibrarian.net/392968582/m4_1.4.18-1_1.4.18-1ubuntu1.diff.gz
-
-diff -upr a/lib/fflush.c b/lib/fflush.c
---- a/lib/fflush.c     2016-12-31 21:54:41.000000000 +0800
-+++ b/lib/fflush.c     2018-08-08 16:12:40.522952171 +0800
-@@ -33,7 +33,7 @@
- #undef fflush
- 
- 
--#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
-+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
- 
- /* Clear the stream's ungetc buffer, preserving the value of ftello (fp).  */
- static void
-@@ -72,7 +72,7 @@ clear_ungetc_buffer (FILE *fp)
- 
- #endif
- 
--#if ! (defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */)
-+#if ! (defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */)
- 
- # if (defined __sferror || defined __DragonFly__ || defined __ANDROID__) && defined __SNPT
- /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
-@@ -148,7 +148,7 @@ rpl_fflush (FILE *stream)
-   if (stream == NULL || ! freading (stream))
-     return fflush (stream);
- 
--#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
-+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
- 
-   clear_ungetc_buffer_preserving_position (stream);
-
-diff -upr a/lib/fpending.c b/lib/fpending.c
---- a/lib/fpending.c     2016-12-31 21:54:41.000000000 +0800
-+++ b/lib/fpending.c     2018-08-08 16:12:40.522952171 +0800
-@@ -32,7 +32,7 @@ __fpending (FILE *fp)
-   /* Most systems provide FILE as a struct and the necessary bitmask in
-      <stdio.h>, because they need it for implementing getc() and putc() as
-      fast macros.  */
--#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
-+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
-   return fp->_IO_write_ptr - fp->_IO_write_base;
- #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
-   /* FreeBSD, NetBSD, OpenBSD, DragonFly, Mac OS X, Cygwin, Android */
-
-diff -upr a/lib/fpurge.c b/lib/fpurge.c
---- a/lib/fpurge.c     2016-12-31 21:54:41.000000000 +0800
-+++ b/lib/fpurge.c     2018-08-08 16:12:40.522952171 +0800
-@@ -62,7 +62,7 @@ fpurge (FILE *fp)
-   /* Most systems provide FILE as a struct and the necessary bitmask in
-      <stdio.h>, because they need it for implementing getc() and putc() as
-      fast macros.  */
--# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
-+# if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
-   fp->_IO_read_end = fp->_IO_read_ptr;
-   fp->_IO_write_ptr = fp->_IO_write_base;
-   /* Avoid memory leak when there is an active ungetc buffer.  */
-
-diff -upr a/lib/freadahead.c b/lib/freadahead.c
---- a/lib/freadahead.c     2016-12-31 21:54:41.000000000 +0800
-+++ b/lib/freadahead.c     2018-08-08 16:12:40.522952171 +0800
-@@ -25,7 +25,7 @@
- size_t
- freadahead (FILE *fp)
- {
--#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
-+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
-   if (fp->_IO_write_ptr > fp->_IO_write_base)
-     return 0;
-   return (fp->_IO_read_end - fp->_IO_read_ptr)
-
-diff -upr a/lib/freading.c b/lib/freading.c
---- a/lib/freading.c    2016-12-31 21:54:41.000000000 +0800
-+++ b/lib/freading.c    2018-08-08 16:13:12.399618677 +0800
-@@ -31,7 +31,7 @@ freading (FILE *fp)
-   /* Most systems provide FILE as a struct and the necessary bitmask in
-      <stdio.h>, because they need it for implementing getc() and putc() as
-      fast macros.  */
--# if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
-+# if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
-   return ((fp->_flags & _IO_NO_WRITES) != 0
-           || ((fp->_flags & (_IO_NO_READS | _IO_CURRENTLY_PUTTING)) == 0
-               && fp->_IO_read_base != NULL));
-
-diff -upr a/lib/fseeko.c b/lib/fseeko.c
---- a/lib/fseeko.c    2016-12-31 21:54:41.000000000 +0800
-+++ b/lib/fseeko.c    2018-08-08 16:13:12.399618677 +0800
-@@ -47,7 +47,7 @@ fseeko (FILE *fp, off_t offset, int when
- #endif
- 
-   /* These tests are based on fpurge.c.  */
--#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
-+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
-   if (fp->_IO_read_end == fp->_IO_read_ptr
-       && fp->_IO_write_ptr == fp->_IO_write_base
-       && fp->_IO_save_base == NULL)
-@@ -123,7 +123,7 @@ fseeko (FILE *fp, off_t offset, int when
-           return -1;
-         }
- 
--#if defined _IO_ftrylockfile || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
-+#if defined _IO_EOF_SEEN || __GNU_LIBRARY__ == 1 /* GNU libc, BeOS, Haiku, Linux libc5 */
-       fp->_flags &= ~_IO_EOF_SEEN;
-       fp->_offset = pos;
- #elif defined __sferror || defined __DragonFly__ || defined __ANDROID__
-
-diff -upr a/lib/stdio-impl.h b/lib/stdio-impl.h
---- a/lib/stdio-impl.h    2016-12-31 21:54:41.000000000 +0800
-+++ b/lib/stdio-impl.h    2018-08-08 16:13:12.399618677 +0800
-@@ -18,6 +18,12 @@
-    the same implementation of stdio extension API, except that some fields
-    have different naming conventions, or their access requires some casts.  */
- 
-+/* Glibc 2.28 made _IO_IN_BACKUP private.  For now, work around this
-+   problem by defining it ourselves.  FIXME: Do not rely on glibc
-+   internals.  */
-+#if !defined _IO_IN_BACKUP && defined _IO_EOF_SEEN
-+# define _IO_IN_BACKUP 0x100
-+#endif
- 
- /* BSD stdio derived implementations.  */
-
--- a/src/build-m4.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/build-m4.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,10 +3,10 @@
 
 PKG             := build-m4
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 1.4.18
-$(PKG)_CHECKSUM := 2f76f8105a45b05c8cfede97b3193cd88b31c657
+$(PKG)_VERSION  := 1.4.19
+$(PKG)_CHECKSUM := b44b5c9746b69ee19204b7cb76d3a7b3eac69259
 $(PKG)_SUBDIR   := m4-$($(PKG)_VERSION)
-$(PKG)_FILE     := m4-$($(PKG)_VERSION).tar.gz
+$(PKG)_FILE     := m4-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := ftp://ftp.gnu.org/pub/gnu/m4/$($(PKG)_FILE)
 $(PKG)_DEPS     := 
 
--- a/src/build-mako.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/build-mako.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -8,7 +8,7 @@
 $(PKG)_SUBDIR   := Mako-$($(PKG)_VERSION)
 $(PKG)_FILE     := Mako-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := https://pypi.python.org/packages/eb/f3/67579bb486517c0d49547f9697e36582cd19dafb5df9e687ed8e22de57fa/$($(PKG)_FILE)
-$(PKG)_DEPS     := build-python3 build-markupsafe
+$(PKG)_DEPS     := build-python build-markupsafe
 
 define $(PKG)_UPDATE
     echo 'Warning: Updates are temporarily disabled for package $(PKG).' >&2;
@@ -16,5 +16,5 @@
 endef
 
 define $(PKG)_BUILD
-    cd '$(1)' && $(PYTHON3) setup.py install --prefix='$(BUILD_TOOLS_PREFIX)'
+    cd '$(1)' && $(MXE_PYTHON) setup.py install --prefix='$(BUILD_TOOLS_PREFIX)'
 endef
--- a/src/build-markupsafe.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/build-markupsafe.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,12 +3,12 @@
 
 PKG             := build-markupsafe
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 1.0
-$(PKG)_CHECKSUM := 9072e80a7faa0f49805737a48f3d871eb1c48728
+$(PKG)_VERSION  := 2.0.1
+$(PKG)_CHECKSUM := e1b766b2b1601fde67b3b19ed2f13b9746bb1cca
 $(PKG)_SUBDIR   := MarkupSafe-$($(PKG)_VERSION)
 $(PKG)_FILE     := MarkupSafe-$($(PKG)_VERSION).tar.gz
-$(PKG)_URL      := https://pypi.python.org/packages/4d/de/32d741db316d8fdb7680822dd37001ef7a448255de9699ab4bfcbdf4172b/$($(PKG)_FILE)
-$(PKG)_DEPS     := build-python3
+$(PKG)_URL      := https://files.pythonhosted.org/packages/bf/10/ff66fea6d1788c458663a84d88787bae15d45daa16f6b3ef33322a51fc7e/$($(PKG)_FILE)
+$(PKG)_DEPS     := build-python build-setuptools
 
 define $(PKG)_UPDATE
     echo 'Warning: Updates are temporarily disabled for package $(PKG).' >&2;
@@ -16,6 +16,6 @@
 endef
 
 define $(PKG)_BUILD
-    cd '$(1)' && $(PYTHON3) setup.py install --prefix='$(BUILD_TOOLS_PREFIX)'
+    cd '$(1)' && $(MXE_PYTHON) setup.py install --prefix='$(BUILD_TOOLS_PREFIX)'
 endef
 
--- a/src/build-meson.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/build-meson.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,12 +3,12 @@
 
 PKG             := build-meson
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 0.54.3
-$(PKG)_CHECKSUM := 741e42a3c8237abe74eb9f189cd8978897ef144d
+$(PKG)_VERSION  := 0.56.2
+$(PKG)_CHECKSUM := 88f30be08c968b0b8b9d2c6d3fe950fecff2658f
 $(PKG)_SUBDIR   := meson-$($(PKG)_VERSION)
 $(PKG)_FILE     := meson-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := https://github.com/mesonbuild/meson/archive/$($(PKG)_VERSION).tar.gz
-$(PKG)_DEPS     := build-python3 build-ninja
+$(PKG)_DEPS     := build-python
 
 define $(PKG)_UPDATE
     echo 'Warning: Updates are temporarily disabled for package $(PKG).' >&2;
@@ -29,7 +29,7 @@
 endif
 
 define $(PKG)_BUILD
-    cd '$(1)' && $(PYTHON3) setup.py install --prefix='$(BUILD_TOOLS_PREFIX)'
+    cd '$(1)' && $(MXE_PYTHON) setup.py install --prefix='$(BUILD_TOOLS_PREFIX)'
     
     # create file with compilation settings
     rm -f $(MESON_TOOLCHAIN_FILE) && mkdir -p '$(dir $(MESON_TOOLCHAIN_FILE))'
--- a/src/build-ninja.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/build-ninja.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,12 +3,12 @@
 
 PKG             := build-ninja
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 1.10.0
-$(PKG)_CHECKSUM := 7134bca607e17238d272e281ce1cae05d04be970
+$(PKG)_VERSION  := 1.10.2
+$(PKG)_CHECKSUM := 8d2e8c1c070c27fb9dc46b4a6345bbb1de7ccbaf
 $(PKG)_SUBDIR   := ninja-$($(PKG)_VERSION)
 $(PKG)_FILE     := ninja-$($(PKG)_VERSION).tar.gz
-$(PKG)_URL      := https://codeload.github.com/ninja-build/ninja/tar.gz/v$($(PKG)_VERSION)
-$(PKG)_DEPS     := build-python3
+$(PKG)_URL      := https://github.com/ninja-build/ninja/archive/refs/tags/v$($(PKG)_VERSION).tar.gz
+$(PKG)_DEPS     :=
 
 define $(PKG)_UPDATE
     echo 'Warning: Updates are temporarily disabled for package $(PKG).' >&2;
@@ -16,8 +16,12 @@
 endef
 
 define $(PKG)_BUILD
-    cd '$(1)' && $(PYTHON3) configure.py --bootstrap
+  mkdir '$(1)/.build' && cd '$(1)/.build' && cmake .. \
+    $($(PKG)_CMAKE_FLAGS) \
+    $(CMAKE_CCACHE_FLAGS) \
+    -DCMAKE_INSTALL_PREFIX='$(3)$(BUILD_TOOLS_PREFIX)' \
+    -DBUILD_TESTING=Off
 
-    $(INSTALL) -d '$(3)$(BUILD_TOOLS_PREFIX)/bin'
-    $(INSTALL) -m755 '$(1)/ninja' '$(3)$(BUILD_TOOLS_PREFIX)/bin';
+  cmake --build '$(1)/.build' -j '$(JOBS)'
+  cmake --install '$(1)/.build'
 endef
--- a/src/build-octave.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/build-octave.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -50,19 +50,17 @@
         $($(PKG)_ENV_FLAGS) '$(1)/configure' \
         --prefix=$(ROOT_PREFIX) \
         $($(PKG)_ENABLE_64_CONFIGURE_OPTIONS) \
-        --disable-docs --disable-fftw-threads --disable-java \
-        --disable-jit --disable-openmp --disable-readline --without-amd \
-        --without-arpack --without-bz2 --without-camd --without-ccolamd \
-        --without-cholmod --without-colamd --without-curl \
-        --without-cxsparse --without-fftw3 --without-fftw3f \
+        --disable-docs --disable-fftw-threads --disable-java --disable-openmp \
+        --disable-readline --without-amd --without-arpack  --without-bz2 \
+        --without-camd --without-ccolamd --without-cholmod --without-colamd \
+        --without-curl --without-cxsparse --without-fftw3 --without-fftw3f \
         --without-fltk --without-fontconfig --without-framework-opengl \
         --without-freetype --without-glpk --without-hdf5 --without-klu \
         --without-magick --without-opengl --without-openssl \
-        --without-osmesa --without-portaudio --without-qhull \
-        --without-qrupdate --without-qscintilla --without-qt \
-        --without-sndfile --without-sundials_ida \
-        --without-sundials_nvecserial --without-umfpack --without-x \
-        --without-z
+        --without-portaudio --without-qhull_r --without-qrupdate \
+        --without-qscintilla --without-qt --without-sndfile --without-spqr \
+        --without-suitesparseconfig --without-sundials_ida \
+        --without-sundials_nvecserial --without-umfpack --without-x --without-z
 
     $($(PKG)_ENV_FLAGS) $(MAKE) -C '$(1)/.build' all -j '$(JOBS)'
     $($(PKG)_ENV_FLAGS) $(MAKE) -C '$(1)/.build' install
--- a/src/build-python.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/build-python.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,25 +3,34 @@
 
 PKG             := build-python
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 2.7.15
-$(PKG)_CHECKSUM := f99348a095ec4a6411c84c0d15343d11920c9724
+$(PKG)_VERSION  := 3.8.12
+$(PKG)_CHECKSUM := 7643eccc15f5606bd0dc04affc7ea901e417165d
 $(PKG)_SUBDIR   := Python-$($(PKG)_VERSION)
 $(PKG)_FILE     := Python-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := http://www.python.org/ftp/python/$($(PKG)_VERSION)/$($(PKG)_FILE)
-$(PKG)_DEPS     := 
+
+## For now, assume that libffi is installed on the build system.
+$(PKG)_DEPS     := # build-libffi
 ifneq ($(USE_SYSTEM_GCC),yes)
-    $(PKG)_DEPS     += build-gcc
+  $(PKG)_DEPS     += build-gcc
 endif
 
 define $(PKG)_UPDATE
-    echo 'Warning: Updates are temporarily disabled for package $(PKG).' >&2;
-    echo $($(PKG)_VERSION)
+  echo 'Warning: Updates are temporarily disabled for package $(PKG).' >&2;
+  echo $($(PKG)_VERSION)
 endef
 
 define $(PKG)_BUILD
-    mkdir '$(1).build'
-    cd    '$(1).build' && '$(1)/configure' \
-        --prefix='$(BUILD_TOOLS_PREFIX)'
-    $(MAKE) -C '$(1).build' -j '$(JOBS)'
-    $(MAKE) -C '$(1).build' -j 1 install
+  mkdir '$(1)/.build'
+  cd '$(1)/.build' && \
+    PKG_CONFIG_PATH='$(BUILD_PKG_CONFIG_PATH)' \
+    LD_LIBRARY_PATH='$(LD_LIBRARY_PATH)' \
+    '$(1)/configure' \
+      --prefix='$(BUILD_TOOLS_PREFIX)'
+
+  $(MAKE) -C '$(1)/.build' -j '$(JOBS)'
+  $(MAKE) -C '$(1)/.build' -j 1 install
+
+  # install python3 as python
+  ln -sf '$(BUILD_TOOLS_PREFIX)/bin/python3' '$(BUILD_TOOLS_PREFIX)/bin/python'
 endef
--- a/src/build-python3.mk	Wed Nov 24 18:31:48 2021 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-# This file is part of MXE.
-# See index.html for further information.
-
-PKG             := build-python3
-$(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 3.8.3
-$(PKG)_CHECKSUM := 3bafa40df1cd069c112761c388a9f2e94b5d33dd
-$(PKG)_SUBDIR   := Python-$($(PKG)_VERSION)
-$(PKG)_FILE     := Python-$($(PKG)_VERSION).tar.xz
-$(PKG)_URL      := http://www.python.org/ftp/python/$($(PKG)_VERSION)/$($(PKG)_FILE)
-$(PKG)_DEPS     := 
-ifneq ($(USE_SYSTEM_GCC),yes)
-    $(PKG)_DEPS     += build-gcc
-endif
-
-define $(PKG)_UPDATE
-    echo 'Warning: Updates are temporarily disabled for package $(PKG).' >&2;
-    echo $($(PKG)_VERSION)
-endef
-
-define $(PKG)_BUILD
-    mkdir '$(1)/.build'
-    cd    '$(1)/.build' && '$(1)/configure' \
-        --prefix='$(BUILD_TOOLS_PREFIX)'
-    $(MAKE) -C '$(1)/.build' -j '$(JOBS)'
-    $(MAKE) -C '$(1)/.build' -j 1 install
-endef
--- a/src/build-scons.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/build-scons.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,16 +3,12 @@
 
 PKG             := build-scons
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 3.1.2
-$(PKG)_CHECKSUM := d7541717d503266b37004a33246b6688fe87dec0
-$(PKG)_SUBDIR   := scons-$($(PKG)_VERSION)
+$(PKG)_VERSION  := 4.1.0.post1
+$(PKG)_CHECKSUM := 47bb89c546804fd76724fd206817ae9a19d4f2bd
+$(PKG)_SUBDIR   := SCons-$($(PKG)_VERSION)
 $(PKG)_FILE     := scons-$($(PKG)_VERSION).tar.gz
-$(PKG)_URL      := http://prdownloads.sourceforge.net/scons/$($(PKG)_FILE)
-ifeq ($(MXE_NATIVE_MINGW_BUILD),yes)
-    $(PKG)_DEPS     := 
-else
-    $(PKG)_DEPS     := build-python
-endif
+$(PKG)_URL      := https://sourceforge.net/projects/scons/files/scons/$($(PKG)_VERSION)/$($(PKG)_FILE)
+$(PKG)_DEPS     := build-python
 
 define $(PKG)_UPDATE
     $(WGET) -q -O- https://sourceforge.net/projects/scons/files/scons/ | \
@@ -21,5 +17,5 @@
 endef
 
 define $(PKG)_BUILD
-    cd '$(1)' && python setup.py install --prefix='$(BUILD_TOOLS_PREFIX)'
+    cd '$(1)' && $(MXE_PYTHON) setup.py install --prefix='$(BUILD_TOOLS_PREFIX)'
 endef
--- a/src/build-setuptools.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/build-setuptools.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,11 +3,11 @@
 
 PKG             := build-setuptools
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 44.1.1
-$(PKG)_CHECKSUM := d1ba6f62520e09956bc3163291a26b185fdff2c6
+$(PKG)_VERSION  := 56.2.0
+$(PKG)_CHECKSUM := 93a2efe727c901cd140fad483b5e05d5f8117ec2
 $(PKG)_SUBDIR   := setuptools-$($(PKG)_VERSION)
-$(PKG)_FILE     := setuptools-$($(PKG)_VERSION).zip
-$(PKG)_URL      := https://files.pythonhosted.org/packages/b2/40/4e00501c204b457f10fe410da0c97537214b2265247bc9a5bc6edd55b9e4/$($(PKG)_FILE)
+$(PKG)_FILE     := setuptools-$($(PKG)_VERSION).tar.gz
+$(PKG)_URL      := https://files.pythonhosted.org/packages/fc/0a/b486efab52f8ad03c3eca0c998dd3deafba0c39b29e0c49c68a7152c8b2d/$($(PKG)_FILE)
 $(PKG)_DEPS     := build-python
 
 define $(PKG)_UPDATE
@@ -16,5 +16,5 @@
 endef
 
 define $(PKG)_BUILD
-    cd '$(1)' && python2 setup.py install --prefix='$(BUILD_TOOLS_PREFIX)'
+    cd '$(1)' && $(MXE_PYTHON) setup.py install --prefix='$(BUILD_TOOLS_PREFIX)'
 endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/build-zstd.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,31 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := build-zstd
+$(PKG)_IGNORE   := 
+$(PKG)_VERSION  := 1.5.0
+$(PKG)_CHECKSUM := c53019729e3a595f0104facab6533d78296a2945
+$(PKG)_SUBDIR   := zstd-$($(PKG)_VERSION)
+$(PKG)_FILE     := zstd-$($(PKG)_VERSION).tar.lz
+$(PKG)_URL      := https://github.com/facebook/zstd/releases/download/v$($(PKG)_VERSION)/zstd-$($(PKG)_VERSION).tar.gz
+$(PKG)_DEPS     := build-cmake
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- 'https://github.com/facebook/zstd/tags' | \
+    $(SED) -n 's|.*releases/tag/v\([^"]*\).*|\1|p' | $(SORT) -V | \
+    tail -1
+endef
+
+$(PKG)_CMAKE_FLAGS := -DZSTD_BUILD_TESTS=ON -DZSTD_BUILD_SHARED=OFF \
+	-DZSTD_BUILD_STATIC=ON -DZSTD_PROGRAMS_LINK_SHARED=OFF -DZSTD_MULTITHREAD_SUPPORT=OFF
+
+define $(PKG)_BUILD
+  mkdir '$(1)/.build' && cd '$(1)/.build' && cmake $(1)/build/cmake/ \
+    $($(PKG)_CMAKE_FLAGS) \
+    $(CMAKE_CCACHE_FLAGS) \
+    -DCMAKE_INSTALL_PREFIX='$(3)$(BUILD_TOOLS_PREFIX)' \
+    -DBUILD_TESTING=Off
+
+  cmake --build '$(1)/.build' -j '$(JOBS)'
+  cmake --install '$(1)/.build'
+endef
--- a/src/cgal-1-fixes.patch	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/cgal-1-fixes.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -1,349 +1,29 @@
-This file is part of MXE.
-See index.html for further information.
+This file is part of MXE. See LICENSE.md for licensing information.
+
+Contains ad hoc patches for cross building.
 
-From 036e8f90ce7f2f1302a2603b89ae7661211c090d Mon Sep 17 00:00:00 2001
-From: Mark Brand <mabrand@mabrand.nl>
-Date: Fri, 21 Oct 2011 23:08:52 +0200
-Subject: [PATCH 1/4] adjustments for mingw-cross-env
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Tony Theodore <tonyt@logyst.com>
+Date: Mon, 20 Nov 2017 10:25:44 +1100
+Subject: [PATCH 1/1] fix boost linking errors
 
 
-diff --git a/CMakeLists.txt b/CMakeLists.txt
-index af8be68..61a5ee7 100644
---- a/CMakeLists.txt
-+++ b/CMakeLists.txt
-@@ -400,6 +400,8 @@ message( STATUS "System: ${CMAKE_SYSTEM_NAME}" )
- #
- #--------------------------------------------------------------------------------------------------
+diff --git a/src/CGAL/CMakeLists.txt b/src/CGAL/CMakeLists.txt
+index 1111111..2222222 100644
+--- a/src/CGAL/CMakeLists.txt
++++ b/src/CGAL/CMakeLists.txt
+@@ -2,6 +2,14 @@ message("Configuring libCGAL")
+ 
+ use_essential_libs()
  
-+uniquely_add_flags( CXXFLAGS "-DBOOST_THREAD_USE_LIB;-DBoost_USE_STATIC_LIBS" )
-+SET(CMAKE_CXX_FLAGS_RELEASE "-DBOOST_THREAD_USE_LIB -DBoost_USE_STATIC_LIBS -O3 -DNDEBUG" CACHE STRING blah FORCE)
- if( MSVC )
-   
-   uniquely_add_flags ( CGAL_CXX_FLAGS "-D_CRT_SECURE_NO_DEPRECATE;-D_SCL_SECURE_NO_DEPRECATE;-D_CRT_SECURE_NO_WARNINGS;-D_SCL_SECURE_NO_WARNINGS" )
-diff --git a/TryRunResults.cgal.cmake b/TryRunResults.cgal.cmake
-new file mode 100644
-index 0000000..299de90
---- /dev/null
-+++ b/TryRunResults.cgal.cmake
-@@ -0,0 +1,198 @@
-+SET( GCC_RUN_RES
-+     0
-+     CACHE STRING "version=4.7.0" FORCE)
-+SET( GCC_RUN_RES__TRYRUN_OUTPUT
-+     0
-+     CACHE STRING "version=4.7.0" FORCE)
-+SET( GMP_RUN_RES
-+     0
-+     CACHE STRING "version=5.0.2" FORCE)
-+SET( GMP_RUN_RES__TRYRUN_OUTPUT
-+     0
-+     CACHE STRING "version=5.0.2" FORCE)
-+SET( MPFR_RUN_RES
-+     0
-+     CACHE STRING "version=3.1.0" FORCE)
-+SET( MPFR_RUN_RES__TRYRUN_OUTPUT
-+     0
-+     CACHE STRING "version=3.1.0" FORCE)
-+SET( CGAL_CFG_ARRAY_MEMBER_INITIALIZATION_BUG
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_ARRAY_MEMBER_INITIALIZATION_BUG__TRYRUN_OUTPUT
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_DENORMALS_COMPILE_BUG
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_DENORMALS_COMPILE_BUG__TRYRUN_OUTPUT
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_FPU_ROUNDING_MODE_UNWINDING_VC_BUG
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_FPU_ROUNDING_MODE_UNWINDING_VC_BUG__TRYRUN_OUTPUT
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_IEEE_754_BUG
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_IEEE_754_BUG__TRYRUN_OUTPUT
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_ISTREAM_INT_BUG
-+     0
-+     CACHE STRING "7812" FORCE)
-+SET( CGAL_CFG_ISTREAM_INT_BUG__TRYRUN_OUTPUT
-+     0
-+     CACHE STRING "7812" FORCE)
-+SET( CGAL_CFG_LONGNAME_BUG
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_LONGNAME_BUG__TRYRUN_OUTPUT
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_MATCHING_BUG_5
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_MATCHING_BUG_5__TRYRUN_OUTPUT
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_MATCHING_BUG_6
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_MATCHING_BUG_6__TRYRUN_OUTPUT
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_NESTED_CLASS_FRIEND_DECLARATION_BUG
-+     0
-+     CACHE STRING "A's do_something\nC's do_something\nB's do_something\nC's do_something" FORCE)
-+SET( CGAL_CFG_NESTED_CLASS_FRIEND_DECLARATION_BUG__TRYRUN_OUTPUT
-+     0
-+     CACHE STRING "A's do_something\nC's do_something\nB's do_something\nC's do_something" FORCE)
-+SET( CGAL_CFG_NO_CPP0X_DELETED_AND_DEFAULT_FUNCTIONS
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_NO_CPP0X_DELETED_AND_DEFAULT_FUNCTIONS__TRYRUN_OUTPUT
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_NO_CPP0X_ISFINITE
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_NO_CPP0X_ISFINITE__TRYRUN_OUTPUT
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_NO_CPP0X_LONG_LONG
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_NO_CPP0X_LONG_LONG__TRYRUN_OUTPUT
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_NO_CPP0X_DELEGATING_CONSTRUCTORS
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_NO_CPP0X_DELEGATING_CONSTRUCTORS__TRYRUN_OUTPUT
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_NO_LIMITS
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_NO_LIMITS__TRYRUN_OUTPUT
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_NO_LOGICAL_OPERATORS_ALTERNATIVES
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_NO_LOGICAL_OPERATORS_ALTERNATIVES__TRYRUN_OUTPUT
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_NO_MESSAGE_PRAGMA_BUG
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_NO_MESSAGE_PRAGMA_BUG__TRYRUN_OUTPUT
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_NO_NEXTAFTER
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_NO_NEXTAFTER__TRYRUN_OUTPUT
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_NO_STATEMENT_EXPRESSIONS
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_NO_STATEMENT_EXPRESSIONS__TRYRUN_OUTPUT
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_NO_STL
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_NO_STL__TRYRUN_OUTPUT
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_NO_TMPL_IN_TMPL_PARAM
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_NO_TMPL_IN_TMPL_PARAM__TRYRUN_OUTPUT
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_NO_TR1_ARRAY
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_NO_TR1_ARRAY__TRYRUN_OUTPUT
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_NO_TR1_TUPLE
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_NO_TR1_TUPLE__TRYRUN_OUTPUT
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_NO_WARNING_CPP_DIRECTIVE_BUG
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_NO_WARNING_CPP_DIRECTIVE_BUG__TRYRUN_OUTPUT
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_NUMERIC_LIMITS_BUG
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_NUMERIC_LIMITS_BUG__TRYRUN_OUTPUT
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_OUTOFLINE_MEMBER_DEFINITION_BUG
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_OUTOFLINE_MEMBER_DEFINITION_BUG__TRYRUN_OUTPUT
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_TEMPLATE_IN_DEFAULT_PARAMETER_BUG
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_TEMPLATE_IN_DEFAULT_PARAMETER_BUG__TRYRUN_OUTPUT
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_TYPENAME_BEFORE_DEFAULT_ARGUMENT_BUG
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_TYPENAME_BEFORE_DEFAULT_ARGUMENT_BUG__TRYRUN_OUTPUT
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_USING_BASE_MEMBER_BUG_2
-+     0
-+     CACHE STRING " " FORCE)
-+SET( CGAL_CFG_USING_BASE_MEMBER_BUG_2__TRYRUN_OUTPUT
-+     0
-+     CACHE STRING " " FORCE)
-+SET( ZLIB_RUN_RES
-+     0
-+     CACHE STRING "version=1.2.5" FORCE)
-+SET( ZLIB_RUN_RES__TRYRUN_OUTPUT
-+     0
-+     CACHE STRING "version=1.2.5" FORCE)
-+SET( QT4_RUN_RES
-+     0
-+     CACHE STRING "version=4.8.0" FORCE)
-+SET( QT4_RUN_RES__TRYRUN_OUTPUT
-+     0
-+     CACHE STRING "version=4.8.0" FORCE)
-diff --git a/cmake/modules/FindBoost.cmake b/cmake/modules/FindBoost.cmake
-index fbdde88..5d8a0a9 100644
---- a/cmake/modules/FindBoost.cmake
-+++ b/cmake/modules/FindBoost.cmake
-@@ -167,6 +167,7 @@
- #
- 
- include( CGAL_VersionUtils )
-+set(Boost_USE_STATIC_LIBS   ON)
- 
- 
- #-------------------------------------------------------------------------------
-@@ -706,7 +707,9 @@ ELSE (_boost_IN_CACHE)
-     ENDIF( Boost_USE_STATIC_LIBS )
- 
-     # Find libraries (search in user defined directories first)
-+    SET ( _boost_COMPILER "_win32")
-     SET ( _boost_${UPPERCOMPONENT}_LIBRARY_RELEASE_NAMES   
-+      ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}
-       ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}-${Boost_LIB_VERSION}
-       ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_COMPILER}${_boost_MULTITHREADED}${_boost_STATIC_TAG}-${Boost_LIB_VERSION}
-       ${Boost_LIB_PREFIX}boost_${COMPONENT}${_boost_MULTITHREADED}-${Boost_LIB_VERSION}
-diff --git a/include/CGAL/Constrained_Delaunay_triangulation_2.h b/include/CGAL/Constrained_Delaunay_triangulation_2.h
-index c89e7f7..57a5d40 100644
---- a/include/CGAL/Constrained_Delaunay_triangulation_2.h
-+++ b/include/CGAL/Constrained_Delaunay_triangulation_2.h
-@@ -390,7 +390,7 @@ is_flipable(Face_handle f, int i, bool perturb) const
-   Face_handle ni = f->neighbor(i); 
-   if (is_infinite(f) || is_infinite(ni)) return false; 
-   if (f->is_constrained(i)) return false;
--  return (side_of_oriented_circle(ni, f->vertex(i)->point(), perturb) 
-+  return (this->side_of_oriented_circle(ni, f->vertex(i)->point(), perturb)
-                                         == ON_POSITIVE_SIDE);
- }
++# same as src/CGAL_Core/CMakeLists.txt
++if (NOT MSVC)
++  # See the release notes of CGAL-4.10: CGAL_Core now requires
++  # Boost.Thread, with all compilers but MSVC.
++  find_package( Boost 1.48 REQUIRED thread system )
++  cache_set(CGAL_3RD_PARTY_LIBRARIES    ${CGAL_3RD_PARTY_LIBRARIES} ${Boost_LIBRARIES} )
++endif(NOT MSVC)
++
+ include_directories (SYSTEM ${CGAL_3RD_PARTY_INCLUDE_DIRS})
  
-@@ -494,7 +494,7 @@ test_conflict(const Point& p, Face_handle fh) const
-   // return true  if P is inside the circumcircle of fh
-   // if fh is infinite, return true when p is in the positive
-   // halfspace or on the boundary and in the  finite edge of fh
--  Oriented_side os = side_of_oriented_circle(fh,p,true);
-+  Oriented_side os = this->side_of_oriented_circle(fh,p,true);
-   if (os == ON_POSITIVE_SIDE) return true;
-  
-   if (os == ON_ORIENTED_BOUNDARY && is_infinite(fh)) {
--- 
-1.7.10.4
-
-
-From a455aa3d21f432831ccafcffc90bc7baf766ce6b Mon Sep 17 00:00:00 2001
-From: Mark Brand <mabrand@mabrand.nl>
-Date: Fri, 18 Nov 2011 00:08:25 +0100
-Subject: [PATCH 2/4] prevent Qt's moc from choking on BOOST_JOIN
-
-Taken from:
-https://lists-sop.inria.fr/sympa/arc/cgal-discuss/2011-11/msg00087.html
-
-diff --git a/cmake/modules/CGAL_Macros.cmake b/cmake/modules/CGAL_Macros.cmake
-index 62d0485..852fcc9 100644
---- a/cmake/modules/CGAL_Macros.cmake
-+++ b/cmake/modules/CGAL_Macros.cmake
-@@ -174,9 +174,9 @@ if( NOT CGAL_MACROS_FILE_INCLUDED )
-         if ( ${LIB}_RUN_RES EQUAL "0" )
-         
-           string( REGEX MATCH "version=.*\$" ${LIB}_VERSION_LINE ${${LIB}_OUTPUT}  )
--          string( REPLACE "\n" "" ${LIB}_VERSION_LINE2 ${${LIB}_VERSION_LINE} )
--          string( REPLACE "\r" "" ${LIB}_VERSION_LINE3 ${${LIB}_VERSION_LINE2} )
--          string( REPLACE "version=" "" ${LIB}_VERSION ${${LIB}_VERSION_LINE3} )
-+          string( REPLACE "\n" "" "${LIB}_VERSION_LINE2" "${${LIB}_VERSION_LINE}" )
-+          string( REPLACE "\r" "" "${LIB}_VERSION_LINE3" "${${LIB}_VERSION_LINE2}" )
-+          string( REPLACE "version=" "" "${LIB}_VERSION" "${${LIB}_VERSION_LINE3}" )
-           
-         else()
-         
--- 
-1.7.10.4
-
-
-From 7225ba1e69c3e4501706e73e2f1e61e3d1313bfa Mon Sep 17 00:00:00 2001
-From: Mark Brand <mabrand@mabrand.nl>
-Date: Fri, 6 Jul 2012 09:27:49 +0200
-Subject: [PATCH 3/4] update "detected" Qt version
-
-
-diff --git a/TryRunResults.cgal.cmake b/TryRunResults.cgal.cmake
-index 299de90..f11ddc6 100644
---- a/TryRunResults.cgal.cmake
-+++ b/TryRunResults.cgal.cmake
-@@ -192,7 +192,7 @@ SET( ZLIB_RUN_RES__TRYRUN_OUTPUT
-      CACHE STRING "version=1.2.5" FORCE)
- SET( QT4_RUN_RES
-      0
--     CACHE STRING "version=4.8.0" FORCE)
-+     CACHE STRING "version=4.8.2" FORCE)
- SET( QT4_RUN_RES__TRYRUN_OUTPUT
-      0
--     CACHE STRING "version=4.8.0" FORCE)
-+     CACHE STRING "version=4.8.2" FORCE)
--- 
-1.7.10.4
-
-
-From c6a34b69b8c538456fa23d07f2914aef6395bcf7 Mon Sep 17 00:00:00 2001
-From: Mark Brand <mabrand@mabrand.nl>
-Date: Wed, 18 Jul 2012 00:43:17 +0200
-Subject: [PATCH 4/4] boost 1.50 compatibility
-
-
-diff --git a/cmake/modules/CGAL_SetupBoost.cmake b/cmake/modules/CGAL_SetupBoost.cmake
-index fc3dc11..d72074fd 100644
---- a/cmake/modules/CGAL_SetupBoost.cmake
-+++ b/cmake/modules/CGAL_SetupBoost.cmake
-@@ -3,7 +3,7 @@ if ( NOT CGAL_Boost_Setup )
-   include(CGAL_TweakFindBoost)
-   # In the documentation, we say we require Boost-1.39, but technically we
-   # require 1.33.1. Some packages may require more recent versions, though.
--  find_package( Boost 1.33.1 REQUIRED thread )
-+  find_package( Boost 1.33.1 REQUIRED thread system chrono )
-   
-   message( STATUS "Boost include:     ${Boost_INCLUDE_DIRS}" )
-   message( STATUS "Boost libraries:   ${Boost_LIBRARIES}" )
--- 
-1.7.10.4
-
+ add_definitions(${CGAL_3RD_PARTY_DEFINITIONS})
--- a/src/cgal.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/cgal.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,18 +3,17 @@
 
 PKG             := cgal
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 4.0.2
-$(PKG)_CHECKSUM := 20c58ebc021754e8be35237bcda43b0084f60617
+$(PKG)_VERSION  := 4.11
+$(PKG)_CHECKSUM := 9a7963bc59997459bb456a69b2f286eb1667f28c
 $(PKG)_SUBDIR   := CGAL-$($(PKG)_VERSION)
 $(PKG)_FILE     := CGAL-$($(PKG)_VERSION).tar.xz
-$(PKG)_URL      := https://gforge.inria.fr/frs/download.php/31176/$($(PKG)_FILE)
+$(PKG)_URL      := https://github.com/CGAL/cgal/releases/download/releases/$($(PKG)_SUBDIR)/$($(PKG)_FILE)
 $(PKG)_DEPS     := boost gmp mpfr qt
 
 define $(PKG)_UPDATE
-    $(WGET) -q -O- 'https://gforge.inria.fr/frs/?group_id=52' | \
-    grep 'CGAL-' | \
-    $(SED) -n 's,.*CGAL-\([0-9][^>a-z]*\)\.tar.*,\1,p' | \
-    head -1
+    $(WGET) -q -O- 'https://github.com/CGAL/cgal/tags' | \
+    $(SED) -n 's|.*releases/tag/v\([^"]*\).*|\1|p' | $(SORT) -V | \
+    tail -1
 endef
 
 define $(PKG)_BUILD
--- a/src/cmake.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/cmake.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := cmake
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 3.18.4
-$(PKG)_CHECKSUM := 73ab5348c881f1a53c250b66848b6ee101c9fe1f
+$(PKG)_VERSION  := 3.21.4
+$(PKG)_CHECKSUM := 7d5bde583207dc205cba158ce46f0c389884b211
 $(PKG)_SUBDIR   := cmake-$($(PKG)_VERSION)
 $(PKG)_FILE     := cmake-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://www.cmake.org/files/v$(call SHORT_PKG_VERSION,$(PKG))/$($(PKG)_FILE)
--- a/src/curl.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/curl.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := curl
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 7.73.0
-$(PKG)_CHECKSUM := 3afb9616ad14c0a84c016bbc1704dc6d883e7c17
+$(PKG)_VERSION  := 7.80.0
+$(PKG)_CHECKSUM := 5bc5332d0a7f68747d685b3c8681f69447c3498d
 $(PKG)_SUBDIR   := curl-$($(PKG)_VERSION)
 $(PKG)_FILE     := curl-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := http://curl.haxx.se/download/$($(PKG)_FILE)
@@ -12,7 +12,7 @@
 
 $(PKG)_CONFIGURE_OPTS :=
 ifeq ($(MXE_WINDOWS_BUILD),yes)
-    $(PKG)_CONFIGURE_OPTS := --with-winssl --with-default-ssl-backend=schannel
+    $(PKG)_CONFIGURE_OPTS := --with-schannel --with-default-ssl-backend=schannel
 endif
 
 define $(PKG)_UPDATE
--- a/src/dcmtk-4-c++11-related-fixes.patch	Wed Nov 24 18:31:48 2021 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,16 +0,0 @@
-From: Boris Pek
-Date: Thu, 05 May 2016 15:38:47 +0300
-Subject: [PATCH] fix build with GCC >= 6.x
-
-diff --git a/ofstd/libsrc/ofstd.cc b/ofstd/libsrc/ofstd.cc
---- a/ofstd/libsrc/ofstd.cc
-+++ b/ofstd/libsrc/ofstd.cc
-@@ -175,7 +175,7 @@
- 
- 
- // some systems don't properly define isnan()
--#ifdef HAVE_ISNAN
-+#if defined(HAVE_ISNAN) && (__cplusplus < 201103L)
- #ifndef HAVE_PROTOTYPE_ISNAN
- extern "C"
- {
--- a/src/dcmtk.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/dcmtk.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -23,14 +23,13 @@
     cd '$(1)' && ./configure \
         $(HOST_AND_BUILD_CONFIGURE_OPTIONS) \
         --prefix='$(HOST_PREFIX)' \
-        --with-openssl \
+        --without-openssl \
         --with-libtiff \
         --with-libpng \
         --with-libxml \
         --with-libxmlinc='$(HOST_PREFIX)' \
         --with-zlib \
         --without-libwrap \
-	--without-openssl \
         CXX='$(MXE_CXX)' \
         RANLIB='$(MXE_RANLIB)' \
         AR='$(MXE_AR)' \
--- a/src/default-octave.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/default-octave.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -117,6 +117,21 @@
   $(PKG)_ENABLE_FORTRAN_INT64_CONFIGURE_OPTIONS := ax_blas_f77_func_ok=yes ax_blas_integer_size=4 octave_cv_sizeof_fortran_integer=4
 endif
 
+ifeq ($(MXE_SYSTEM),mingw)
+  # This is very similar to CONFIGURE_CPPFLAGS and CONFIGURE_LDFLAGS but with
+  # double quoted paths.
+  $(PKG)_CONFIGURE_CPPFLAGS := CPPFLAGS='-I"$(HOST_PREFIX)/include"'
+  ifeq ($(MXE_USE_LIB64_DIRECTORY),yes)
+    $(PKG)_CONFIGURE_LDFLAGS := LDFLAGS='-L"$(HOST_PREFIX)/lib" -L"$(HOST_PREFIX)/lib64"'
+  else
+    $(PKG)_CONFIGURE_LDFLAGS := LDFLAGS='-L"$(HOST_PREFIX)/lib"'
+  endif
+else
+  $(PKG)_CONFIGURE_CPPFLAGS := $(CONFIGURE_CPPFLAGS)
+  $(PKG)_CONFIGURE_LDFLAGS := $(CONFIGURE_LDFLAGS)
+endif
+
+
 ifeq ($(MXE_SYSTEM),msvc)
   $(PKG)_PREFIX := '$(HOST_PREFIX)/local/$($(PKG)_SUBDIR)'
   # - Enable atomic refcount (required for QtHandles)
@@ -131,8 +146,13 @@
     CXXFLAGS='-O2 -wd4244 -wd4003 -wd4005 -wd4068'
 else
   $(PKG)_PREFIX := '$(HOST_PREFIX)'
-  $(PKG)_EXTRA_CONFIGURE_OPTIONS := \
-    LDFLAGS='-Wl,-rpath-link,$(HOST_LIBDIR) -L$(HOST_LIBDIR) -L$($(PKG)_QTDIR)/lib'
+  ifeq ($(MXE_SYSTEM),mingw)
+    $(PKG)_EXTRA_CONFIGURE_OPTIONS := \
+      LDFLAGS='-Wl,-rpath-link,"$(HOST_LIBDIR)" -L"$(HOST_LIBDIR)" -L"$($(PKG)_QTDIR)/lib"'
+  else
+    $(PKG)_EXTRA_CONFIGURE_OPTIONS := \
+      LDFLAGS='-Wl,-rpath-link,$(HOST_LIBDIR) -L$(HOST_LIBDIR) -L$($(PKG)_QTDIR)/lib'
+  endif
 endif
 
 ifeq ($(MXE_SYSTEM),mingw)
@@ -174,7 +194,8 @@
 
     mkdir '$(1)/.build'
     cd '$(1)/.build' && $($(PKG)_CONFIGURE_ENV) '$(1)/configure' \
-        $(CONFIGURE_CPPFLAGS) $(CONFIGURE_LDFLAGS) \
+        $($(PKG)_CONFIGURE_CPPFLAGS) \
+        $($(PKG)_CONFIGURE_LDFLAGS) \
         $(HOST_AND_BUILD_CONFIGURE_OPTIONS) \
         --prefix='$($(PKG)_PREFIX)' \
         --disable-silent-rules \
@@ -200,6 +221,7 @@
     if [ "x$(MXE_SYSTEM)" == "xmingw" ]; then \
       $(INSTALL) '$(3)/$(HOST_BINDIR)/libxerbla.dll' '$(3)$(HOST_BINDIR)/libxerbla-octave.dll'; \
       cp '$(1)/.build/src/.libs/octave-gui.exe' '$(3)$(HOST_BINDIR)'; \
+      cp '$(1)/.build/src/.libs/octave-svgconvert.exe' '$(3)$(HOST_BINDIR)'; \
       if [ "x$(ENABLE_BINARY_PACKAGES)" == "xyes" ]; then \
         mkdir -p '$(3)$(BUILD_TOOLS_PREFIX)/bin'; \
         $(INSTALL) '$(1)/.build/src/$(MXE_TOOL_PREFIX)mkoctfile' '$(3)$(BUILD_TOOLS_PREFIX)/bin'; \
--- a/src/eigen.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/eigen.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -12,8 +12,8 @@
 
 define $(PKG)_UPDATE
     $(WGET) -q -O- 'https://eigen.tuxfamily.org/index.php?title=Main_Page#Download' | \
-    $(GREP) 'eigen/get/' | \
-    $(SED) -n 's,.*eigen/get/\(3[^>]*\)\.tar.*,\1,p' | \
+    $(GREP) 'released!' | \
+    $(SED) -n 's,.*>Eigen \([0-9.]*\) released!.*,\1,p' | \
     head -1
 endef
 
--- a/src/expat.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/expat.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := expat
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 2.2.10
-$(PKG)_CHECKSUM := 0a9f06081d92ddea17b8b9f4086b3f68e337bf8f
+$(PKG)_VERSION  := 2.4.1
+$(PKG)_CHECKSUM := b677b9a1cf3a1424fda183223fae2c58f50151af
 $(PKG)_SUBDIR   := expat-$($(PKG)_VERSION)
 $(PKG)_FILE     := expat-$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/expat/expat/$($(PKG)_VERSION)/$($(PKG)_FILE)
--- a/src/fftw.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/fftw.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := fftw
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 3.3.8
-$(PKG)_CHECKSUM := 59831bd4b2705381ee395e54aa6e0069b10c3626
+$(PKG)_VERSION  := 3.3.10
+$(PKG)_CHECKSUM := 6abe7321c8c35ef52e56e299e66a9b967baf148a
 $(PKG)_SUBDIR   := fftw-$($(PKG)_VERSION)
 $(PKG)_FILE     := fftw-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://www.fftw.org/$($(PKG)_FILE)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/flac-1-ucrt.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,13 @@
+Don't force MSVCRT version on mingw.
+
+diff -aur a/configure.ac b/configure.ac
+--- a/configure.ac	2019-08-04 10:26:40.680643000 +0200
++++ b/configure.ac	2021-11-17 18:56:11.962266940 +0100
+@@ -208,7 +208,6 @@
+ os_is_windows=no
+ case "$host" in
+ 	*mingw*)
+-		CPPFLAGS="-D__MSVCRT_VERSION__=0x0601 $CPPFLAGS"
+ 		os_is_windows=yes
+ 		;;
+ esac
--- a/src/flac.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/flac.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -19,10 +19,10 @@
 endef
 
 define $(PKG)_BUILD
-    cd '$(1)' && ./configure \
+    cd '$(1)' && autoreconf -fi && ./configure \
         $(HOST_AND_BUILD_CONFIGURE_OPTIONS) \
         $(ENABLE_SHARED_OR_STATIC) \
-	$(CONFIGURE_LDFLAGS) $(CONFIGURE_CPPFLAGS) \
+        $(CONFIGURE_LDFLAGS) $(CONFIGURE_CPPFLAGS) \
         --prefix='$(HOST_PREFIX)' \
         --disable-doxygen-docs \
         --disable-xmms-plugin \
--- a/src/fltk.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/fltk.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := fltk
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 1.3.5
-$(PKG)_CHECKSUM := d0ea44a68a9424d9e7d1ff9985d9c510b9ee2b75
+$(PKG)_VERSION  := 1.3.8
+$(PKG)_CHECKSUM := 8753055c01f91e5295570324d8af2c5bdd7a2943
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $($(PKG)_SUBDIR)-source.tar.gz
 $(PKG)_URL      := http://fltk.org/pub/fltk/$($(PKG)_VERSION)/$($(PKG)_FILE)
--- a/src/freetds.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/freetds.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := freetds
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 1.2.5
-$(PKG)_CHECKSUM := 50b326d67ca88269d95c129bac5ea5c6f11fee91
+$(PKG)_VERSION  := 1.3.3
+$(PKG)_CHECKSUM := 369398abc6491b3c7af4cc91d2b918be854a237b
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := ftp://ftp.freetds.org/pub/$(PKG)/stable/$($(PKG)_FILE)
--- a/src/freetype.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/freetype.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := freetype
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 2.10.2
-$(PKG)_CHECKSUM := b074d5c34dc0e3cc150be6e7aa6b07c9ec4ed875
+$(PKG)_VERSION  := 2.11.0
+$(PKG)_CHECKSUM := f1635a1ed68ee467be33036d8881b7b89177663f
 $(PKG)_SUBDIR   := freetype-$($(PKG)_VERSION)
 $(PKG)_FILE     := freetype-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := https://$(SOURCEFORGE_MIRROR)/project/freetype/freetype2/$($(PKG)_VERSION)/$($(PKG)_FILE)
--- a/src/fribidi.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/fribidi.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := fribidi
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 1.0.10
-$(PKG)_CHECKSUM := e22d6cf070966d2735b8e1a6d961a87f1e828a99
+$(PKG)_VERSION  := 1.0.11
+$(PKG)_CHECKSUM := 326d3f89431b9553f1942ca6814433e4b34611a3
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := https://github.com/fribidi/fribidi/releases/download/v$($(PKG)_VERSION)/$($(PKG)_FILE)
--- a/src/gcc-gmp.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/gcc-gmp.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := gcc-gmp
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 6.2.0
-$(PKG)_CHECKSUM := 5e9341d3807bc7505376f9ed9f5c1c6c57050aa6
+$(PKG)_VERSION  := 6.2.1
+$(PKG)_CHECKSUM := 2dcf34d4a432dbe6cce1475a835d20fe44f75822
 $(PKG)_SUBDIR   := gmp-$($(PKG)_VERSION)
 $(PKG)_FILE     := gmp-$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := https://gmplib.org/download/gmp/$($(PKG)_FILE)
--- a/src/gcc-isl.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/gcc-isl.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,11 +4,11 @@
 PKG             := gcc-isl
 $(PKG)_IGNORE   :=
 $(PKG)_VERSION  := 0.22.1
-$(PKG)_CHECKSUM := 125303d52bd6226f80d23bf1f76b78c6f1115568
-$(PKG)_SUBDIR   := isl-$($(PKG)_VERSION)
-$(PKG)_FILE     := isl-$($(PKG)_VERSION).tar.xz
-$(PKG)_URL      := http://isl.gforge.inria.fr/$($(PKG)_FILE)
-$(PKG)_DEPS     := gcc-gmp
+$(PKG)_CHECKSUM := ce66c4415906bf2c16a8f09f31383f4fe0991531
+$(PKG)_SUBDIR   := isl-isl-$($(PKG)_VERSION)-788faca
+$(PKG)_FILE     := isl-$($(PKG)_VERSION).tar.gz
+$(PKG)_URL      := https://repo.or.cz/isl.git/snapshot/$($(PKG)_FILE)
+$(PKG)_DEPS     := build-libtool gcc-gmp
 
 define $(PKG)_UPDATE
     echo 'Warning: Updates are temporarily disabled for package $(PKG).' >&2;
@@ -16,6 +16,7 @@
 endef
 
 define $(PKG)_BUILD
+    cd '$(1)' && ./autogen.sh
     mkdir '$(1).build'
     cd    '$(1).build' && '$(1)/configure' \
         --prefix='$(BUILD_TOOLS_PREFIX)' \
--- a/src/gcc-mpfr.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/gcc-mpfr.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,12 +3,12 @@
 
 PKG             := gcc-mpfr
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 4.0.2
-$(PKG)_CHECKSUM := 52c1f2a4c9a202f46cf3275a8d46b562aa584208
+$(PKG)_VERSION  := 4.1.0
+$(PKG)_CHECKSUM := 159c3a58705662bfde4dc93f2617f3660855ead6
 $(PKG)_SUBDIR   := mpfr-$($(PKG)_VERSION)
 $(PKG)_FILE     := mpfr-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := ftp://ftp.gnu.org/gnu/mpfr/$($(PKG)_FILE)
-$(PKG)_URL_2    := http://www.mpfr.org/mpfr-$($(PKG)_VERSION)/$($(PKG)_FILE)
+$(PKG)_URL_2    := https://www.mpfr.org/mpfr-$($(PKG)_VERSION)/$($(PKG)_FILE)
 $(PKG)_DEPS     := gcc-gmp
 
 define $(PKG)_UPDATE
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/gdal-1-gcc11.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,10 @@
+--- ./ogr/ogrsf_frmts/cad/libopencad/dwg/r2000.cpp.orig	2020-01-28 11:13:43.000000000 +0100
++++ ./ogr/ogrsf_frmts/cad/libopencad/dwg/r2000.cpp	2021-08-09 21:20:52.610437353 +0200
+@@ -36,6 +36,7 @@
+ #include <cassert>
+ #include <cstring>
+ #include <iostream>
++#include <limits>
+ #include <memory>
+ #include <string>
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/gdal-2-ucrt.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,23 @@
+From bd4d925741b6c06ba38888a9bb959b490adf27af Mon Sep 17 00:00:00 2001
+From: Jeremy Drake <github@jdrake.com>
+Date: Mon, 18 Oct 2021 11:02:08 -0700
+Subject: [PATCH] gdal: don't define __MSVCRT_VERSION__
+
+--- gdal-3.3.2/port/cpl_port.h.orig	2021-10-18 10:57:01.393925700 -0700
++++ gdal-3.3.2/port/cpl_port.h	2021-10-18 10:57:27.784506600 -0700
+@@ -113,15 +113,6 @@
+ /*      MinGW stuff                                                     */
+ /* ==================================================================== */
+ 
+-/* We need __MSVCRT_VERSION__ >= 0x0700 to have "_aligned_malloc" */
+-/* Latest versions of mingw32 define it, but with older ones, */
+-/* we need to define it manually */
+-#if defined(__MINGW32__)
+-#ifndef __MSVCRT_VERSION__
+-#define __MSVCRT_VERSION__ 0x0700
+-#endif
+-#endif
+-
+ /* Needed for std=c11 on Solaris to have strcasecmp() */
+ #if defined(GDAL_COMPILATION) && defined(__sun__) && (__STDC_VERSION__ + 0) >= 201112L && (_XOPEN_SOURCE + 0) < 600
+ #ifdef _XOPEN_SOURCE
--- a/src/gdb.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/gdb.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -2,8 +2,8 @@
 # See index.html for further information.
 
 PKG             := gdb
-$(PKG)_VERSION  := 9.2
-$(PKG)_CHECKSUM := 356ee474a24bfb2f133894730916557dfea9da2e
+$(PKG)_VERSION  := 11.1
+$(PKG)_CHECKSUM := 6cb3361c7f2b22d6d2c25ab4992264aa41bc2471
 $(PKG)_SUBDIR   := gdb-$($(PKG)_VERSION)
 $(PKG)_FILE     := gdb-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := ftp://ftp.gnu.org/pub/gnu/$(PKG)/$($(PKG)_FILE)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/gdcm-2-getopt.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,16 @@
+--- gdcm-3.0.8/Utilities/getopt/getopt.h.orig	2020-10-13 09:40:48.964337600 +0300
++++ gdcm-3.0.8/Utilities/getopt/getopt.h	2020-10-13 09:40:38.576190500 +0300
+@@ -67,13 +67,7 @@
+   #define GETOPT_EXPORT
+ #endif /*defined(WIN32)*/
+ 
+-#if defined(_WIN32) && defined(GETOPT_DLL)
+-  #if defined(gdcmgetopt_EXPORTS)
+-    #define GETOPT_EXTERN __declspec( dllexport )
+-  #else
+-    #define GETOPT_EXTERN __declspec( dllimport )
+-  #endif
+-#else
++#if defined(_WIN32)
+   #define GETOPT_EXTERN extern
+ #endif /*defined(WIN32)*/
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/gdcm-3-gcc11.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,11 @@
+--- ./Source/MediaStorageAndFileFormat/gdcmImageChangePhotometricInterpretation.h.orig	2021-07-27 10:08:11.000000000 +0200
++++ ./Source/MediaStorageAndFileFormat/gdcmImageChangePhotometricInterpretation.h	2021-08-09 22:05:56.980228218 +0200
+@@ -14,6 +14,8 @@
+ #ifndef GDCMIMAGECHANGEPHOTOMETRICINTERPRETATION_H
+ #define GDCMIMAGECHANGEPHOTOMETRICINTERPRETATION_H
+ 
++#include <limits>
++
+ #include "gdcmImageToImageFilter.h"
+ #include "gdcmPhotometricInterpretation.h"
+ 
--- a/src/gdcm.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/gdcm.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,11 +3,11 @@
 
 PKG             := gdcm
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 3.0.8
-$(PKG)_CHECKSUM := 520d57530d20d5a0f5bb99a040cd261304902c89
+$(PKG)_VERSION  := 3.0.10
+$(PKG)_CHECKSUM := dd3543fde27351744cd31b2a80b6800d7810047d
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
-$(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/$(PKG)/$(PKG) 3.x/GDCM $($(PKG)_VERSION)/$($(PKG)_FILE)
+$(PKG)_URL      := https://$(SOURCEFORGE_MIRROR)/project/$(PKG)/$(PKG) 3.x/GDCM $($(PKG)_VERSION)/$($(PKG)_FILE)
 $(PKG)_DEPS     := expat zlib
 
 $(PKG)_CMAKE_OPTS :=
--- a/src/geos.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/geos.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := geos
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 3.8.1
-$(PKG)_CHECKSUM := dbd165752dd4c48d81a84aa51c99d04410d96c67
+$(PKG)_VERSION  := 3.10.1
+$(PKG)_CHECKSUM := 076fda159b29c2c3a04c1674f5cb458dae51eb32
 $(PKG)_SUBDIR   := geos-$($(PKG)_VERSION)
 $(PKG)_FILE     := geos-$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := http://download.osgeo.org/geos/$($(PKG)_FILE)
--- a/src/ghostscript-1-fixes.patch	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/ghostscript-1-fixes.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -1,40 +1,20 @@
-This file is part of MXE. See LICENSE.md for licensing information.
-
-Contains ad hoc patches for cross building.
-
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: darealshinji <djcj@gmx.de>
-Date: Mon, 3 Dec 2018 21:05:41 +0100
-Subject: [PATCH 1/1] cross-build fixes, hide libgs symbols
-
-
-diff --git a/Makefile.in b/Makefile.in
-index 1111111..2222222 100644
---- a/Makefile.in
-+++ b/Makefile.in
-@@ -173,6 +173,9 @@ CAPOPT= @HAVE_MKSTEMP@ @HAVE_FILE64@ @HAVE_FSEEKO@ @HAVE_MKSTEMP64@ @HAVE_FONTCO
+diff -ur ghostscript-9.50.orig/base/fapi_ft.c ghostscript-9.50/base/fapi_ft.c
+--- ghostscript-9.50.orig/base/fapi_ft.c	2020-12-27 14:29:32.714236780 -0500
++++ ghostscript-9.50/base/fapi_ft.c	2020-12-27 14:30:34.503600642 -0500
+@@ -125,6 +125,10 @@
+ delete_inc_int_info(gs_fapi_server * a_server,
+                     FT_IncrementalRec * a_inc_int_info);
  
- GS=@GS@
- GS_SO_BASE=@GS@
-+GS_SONAME=@GS_SONAME@
-+GS_SONAME_MAJOR=@GS_SONAME_MAJOR@
-+GS_SONAME_MAJOR_MINOR=@GS_SONAME_MAJOR_MINOR@
- 
- PCL=@PCL@
- PCL_SO_BASE=@PCL@
-@@ -184,7 +187,7 @@ GPDL=@GPDL@
- GPDL_SO_BASE=@GPDL@
- 
- XE=@EXEEXT@
--XEAUX=@EXEEXT@
-+XEAUX=@AUXEXEEXT@
- 
- PCL_TARGET=@PCL_TARGET@
- XPS_TARGET=@XPS_TARGET@
-diff --git a/base/gp_unix.c b/base/gp_unix.c
-index 1111111..2222222 100644
---- a/base/gp_unix.c
-+++ b/base/gp_unix.c
++#ifndef FT_CALLBACK_DEF
++  #define FT_CALLBACK_DEF(X) X
++#endif
++
+ FT_CALLBACK_DEF(void *)
+ FF_alloc(FT_Memory memory, long size)
+ {
+diff -ur ghostscript-9.50.orig/base/gp_unix.c ghostscript-9.50/base/gp_unix.c
+--- ghostscript-9.50.orig/base/gp_unix.c	2020-12-27 14:29:32.703236181 -0500
++++ ghostscript-9.50/base/gp_unix.c	2020-12-27 18:25:25.242079971 -0500
 @@ -16,6 +16,9 @@
  
  /* Unix-specific routines for Ghostscript */
@@ -45,7 +25,7 @@
  #include "pipe_.h"
  #include "string_.h"
  #include "time_.h"
-@@ -454,3 +457,54 @@ void gp_enumerate_fonts_free(void *enum_state)
+@@ -466,3 +469,54 @@
      }
  #endif
  }
@@ -100,11 +80,11 @@
 +    return unicode[0];
 +}
 +#endif /* __MINGW32__ */
-diff --git a/base/unix-aux.mak b/base/unix-aux.mak
-index 1111111..2222222 100644
---- a/base/unix-aux.mak
-+++ b/base/unix-aux.mak
-@@ -57,23 +57,29 @@ $(AUX)gp_stdia.$(OBJ): $(GLSRC)gp_stdia.c $(AK)\
+Only in ghostscript-9.50/base: gp_unix.c.orig
+diff -ur ghostscript-9.50.orig/base/unix-aux.mak ghostscript-9.50/base/unix-aux.mak
+--- ghostscript-9.50.orig/base/unix-aux.mak	2020-12-27 14:29:32.718236997 -0500
++++ ghostscript-9.50/base/unix-aux.mak	2020-12-27 18:25:25.242079971 -0500
+@@ -57,23 +57,29 @@
  # -------------------------- Auxiliary programs --------------------------- #
  
  $(ECHOGS_XE): $(GLSRC)echogs.c $(AK) $(stdpre_h) $(UNIX_AUX_MAK) $(MAKEDIRS)
@@ -134,7 +114,7 @@
  	$(CCAUX_) $(GENHT_CFLAGS) $(O_)$(GENHT_XE) $(GLSRC)genht.c $(AUXEXTRALIBS)
  
  # To get GS to use the system zlib, you remove/hide the gs/zlib directory
-@@ -84,6 +90,7 @@ MKROMFS_OBJS_0=$(MKROMFS_ZLIB_OBJS) $(AUX)gpmisc.$(OBJ) $(AUX)gp_getnv.$(OBJ) \
+@@ -84,6 +90,7 @@
   $(AUX)gp_stdia.$(OBJ) $(AUX)gsutil.$(OBJ) $(AUX)memento.$(OBJ)
  
  $(MKROMFS_XE)_0: $(GLSRC)mkromfs.c $(MKROMFS_COMMON_DEPS) $(MKROMFS_OBJS_0) $(UNIX_AUX_MAK) $(MAKEDIRS)
@@ -142,7 +122,7 @@
  	$(CCAUX_) $(GENOPTAUX) $(I_)$(GLSRCDIR)$(_I) $(I_)$(GLOBJ)$(_I) $(I_)$(ZSRCDIR)$(_I) $(GLSRC)mkromfs.c $(O_)$(MKROMFS_XE)_0 $(MKROMFS_OBJS_0) $(AUXEXTRALIBS)
  
  # .... and one using the zlib library linked via the command line
-@@ -93,9 +100,11 @@ MKROMFS_OBJS_1=$(AUX)gscdefs.$(OBJ) \
+@@ -93,9 +100,11 @@
   $(AUX)gp_stdia.$(OBJ) $(AUX)gsutil.$(OBJ)
  
  $(MKROMFS_XE)_1: $(GLSRC)mkromfs.c $(MKROMFS_COMMON_DEPS) $(MKROMFS_OBJS_1) $(UNIX_AUX_MAK) $(MAKEDIRS)
@@ -154,11 +134,10 @@
  	$(CP_) $(MKROMFS_XE)_$(SHARE_ZLIB) $(MKROMFS_XE)
  
  # Query the environment to construct gconfig_.h.
-diff --git a/base/unix-dll.mak b/base/unix-dll.mak
-index 1111111..2222222 100644
---- a/base/unix-dll.mak
-+++ b/base/unix-dll.mak
-@@ -66,9 +66,6 @@ GPDL_SONAME_BASE=lib$(GPDL_SO_BASE)
+diff -ur ghostscript-9.50.orig/base/unix-dll.mak ghostscript-9.50/base/unix-dll.mak
+--- ghostscript-9.50.orig/base/unix-dll.mak	2020-12-27 14:29:32.690235473 -0500
++++ ghostscript-9.50/base/unix-dll.mak	2020-12-27 18:25:25.242079971 -0500
+@@ -66,9 +66,6 @@
  GS_SOEXT=$(SO_LIB_EXT)
  GS_DLLEXT=$(DLL_EXT)
  
@@ -168,11 +147,10 @@
  
  PCL_SONAME=$(PCL_SONAME_BASE)$(GS_SOEXT)$(GS_DLLEXT)
  PCL_SONAME_MAJOR=$(PCL_SONAME_BASE)$(GS_SOEXT)$(SO_LIB_VERSION_SEPARATOR)$(GS_VERSION_MAJOR)$(GS_DLLEXT)
-diff --git a/configure.ac b/configure.ac
-index 1111111..2222222 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -23,6 +23,7 @@ AC_INIT
+diff -ur ghostscript-9.50.orig/configure.ac ghostscript-9.50/configure.ac
+--- ghostscript-9.50.orig/configure.ac	2020-12-27 14:29:32.689235419 -0500
++++ ghostscript-9.50/configure.ac	2020-12-27 18:25:25.243080026 -0500
+@@ -23,6 +23,7 @@
  AC_PREREQ(2.63)
  AC_LANG(C)
  AC_CONFIG_SRCDIR(psi/gs.c)
@@ -180,7 +158,7 @@
  
  dnl Inherit compiler flags from the environment...
  CFLAGS="${CFLAGS:=}"
-@@ -125,8 +126,11 @@ AUXEXTRALIBSTMP="\$(EXTRALIBS)"
+@@ -125,8 +126,11 @@
  
  # purposefully do not include "help" output for this
  AC_ARG_ENABLE([save_confaux])
@@ -193,7 +171,7 @@
    # rerun configure for the AUX tools, disabling a load of tests not relevant for CCAUX
    olddir=`pwd`
    if test x"$enable_save_confaux" = x"yes"; then
-@@ -146,9 +150,10 @@ if test x"$CCAUX" != x"" ; then
+@@ -146,9 +150,10 @@
    echo $AUXFLAGS_MAK_LINE06 >> $AUXFLAGS_MAK.in
    echo $AUXFLAGS_MAK_LINE07 >> $AUXFLAGS_MAK.in
  
@@ -206,7 +184,7 @@
    if test $status -eq 0 ; then
      CCAUX=$(grep CCAUX $AUXFLAGS_MAK | sed "s/CCAUX=//g")
      GCFLAGSAUXTMP=$(grep GCFLAGSAUX $AUXFLAGS_MAK | sed "s/GCFLAGSAUX=//g")
-@@ -204,7 +209,7 @@ AC_PATH_TOOL(PKGCONFIG, pkg-config)
+@@ -204,7 +209,7 @@
  # but if we are cross compiling, and there isn't a matching
  # pkconfig for the --host setting, then don't use the 'local'
  # pkconfig at all
@@ -215,7 +193,7 @@
    AC_PATH_PROG(BUILD_PKGCONFIG, pkg-config)
    if test x"$BUILD_PKGCONFIG" = x"$PKGCONFIG" ; then
      PKGCONFIG=
-@@ -217,7 +222,7 @@ AC_PATH_TOOL(STRIP_XE, strip)
+@@ -217,7 +222,7 @@
  # but if we are cross compiling, and there isn't a matching
  # pkconfig for the --host setting, then don't use the 'local'
  # pkconfig at all
@@ -224,7 +202,7 @@
    AC_PATH_PROG(BUILD_STRIP_XE, strip)
    if test x"$BUILD_STRIP_XE" = x"$STRIP_XE" ; then
      STRIP_XE=
-@@ -234,18 +239,14 @@ CONTRIBINCLUDE="include $srcdir/contrib/contrib.mak"
+@@ -234,18 +239,14 @@
  INSTALL_CONTRIB="install-contrib-extras"
  
  if test x"$enable_contrib" = x; then
@@ -245,7 +223,7 @@
  fi
  
  if test x"$enable_contrib" != x"no"; then
-@@ -274,26 +275,27 @@ dnl --------------------------------------------------
+@@ -274,26 +275,27 @@
  CC_OPT_FLAGS_TO_TRY="-O"
  SET_DT_SONAME="-soname="
  
@@ -283,7 +261,7 @@
          if test $ac_cv_prog_gcc = yes; then
              CC_OPT_FLAGS_TO_TRY="-O2"
              CC_DBG_FLAGS_TO_TRY="-gdwarf-2 -g3 -O0"
-@@ -321,7 +323,6 @@ else
+@@ -321,7 +323,6 @@
          fi
          ;;
    esac
@@ -291,7 +269,7 @@
  
  AC_SUBST(SET_DT_SONAME)
  
-@@ -368,18 +369,20 @@ AC_ARG_WITH([arch_h], AC_HELP_STRING([--with-arch_h=<arch.h to use>],
+@@ -368,18 +369,20 @@
  ARCH_CONF_HEADER=
  
  if test x"$with_arch_h" = x""; then
@@ -318,7 +296,7 @@
  else
    ARCH_CONF_HEADER=$with_arch_h
  fi
-@@ -658,15 +661,7 @@ dnl Set options that we want to pass into all other
+@@ -658,15 +661,7 @@
  dnl configure scripts we might call
  dnl --------------------------------------------------
  
@@ -335,7 +313,7 @@
  
  dnl --------------------------------------------------
  dnl Check for libraries
-@@ -996,7 +991,7 @@ if test x"$enable_fapi" != xno; then
+@@ -996,7 +991,7 @@
              if $PKGCONFIG --atleast-version=12.0.6 freetype2; then
                  AC_MSG_RESULT(yes)
                  FT_CFLAGS="$CFLAGS `$PKGCONFIG --cflags freetype2`"
@@ -344,7 +322,7 @@
                  FT_BRIDGE=1
                  SHARE_FT=1
              else
-@@ -1047,6 +1042,14 @@ AC_SUBST(FTSRCDIR)
+@@ -1047,6 +1042,14 @@
  AC_SUBST(FT_CFLAGS)
  AC_SUBST(FT_LIBS)
  
@@ -359,7 +337,7 @@
  AC_MSG_CHECKING([for local jpeg library source])
  dnl At present, we give the local source priority over the shared
  dnl build, so that the D_MAX_BLOCKS_IN_MCU patch will be applied.
-@@ -1088,6 +1091,13 @@ else
+@@ -1088,6 +1091,13 @@
      [define if the libjpeg memory system prototypes aren't available])
  fi
  
@@ -373,7 +351,7 @@
  AC_MSG_CHECKING([for local zlib source])
  dnl zlib is needed for language level 3, and libpng
  # we must define ZLIBDIR regardless because png.mak does a -I$(ZLIBDIR)
-@@ -1096,6 +1106,13 @@ ZLIBDIR=src
+@@ -1096,6 +1106,13 @@
  AUX_SHARED_ZLIB=
  ZLIBCFLAGS=""
  
@@ -387,7 +365,7 @@
  if test -d $srcdir/zlib; then
          AC_MSG_RESULT([yes])
          SHARE_ZLIB=0
-@@ -1110,6 +1127,9 @@ else
+@@ -1110,6 +1127,9 @@
            AC_CHECK_HEADERS(zlib.h, [SHARE_ZLIB=1; AUX_SHARED_ZLIB="-l\$(ZLIB_NAME)"])
          ])
  fi
@@ -397,7 +375,7 @@
  if test -z "$SHARE_ZLIB"; then
    AC_MSG_ERROR([I did not find a copy of zlib on your system.
    Please either install it, or unpack a copy of the source in a
-@@ -1136,6 +1156,11 @@ AC_SUBST(ZLIBDIR)
+@@ -1136,6 +1156,11 @@
  AC_SUBST(FT_SYS_ZLIB)
  
  dnl png for the png output device; it also requires zlib
@@ -409,7 +387,7 @@
  LIBPNGDIR=src
  PNGDEVS=''
  PNGDEVS_ALL='png48 png16m pnggray pngmono pngmonod png256 png16 pngalpha'
-@@ -1157,12 +1182,21 @@ fi
+@@ -1157,12 +1182,21 @@
  if test -z "$PNGDEVS"; then
    AC_MSG_NOTICE([disabling png output devices])
  fi
@@ -431,7 +409,7 @@
  AC_MSG_CHECKING([for local lcms2mt library source])
  LCMS2DIR=src
  LCMS2MTDIR=src
-@@ -1197,6 +1231,8 @@ else
+@@ -1197,6 +1231,8 @@
     fi
  fi
  
@@ -440,7 +418,7 @@
  AC_SUBST(SHARELCMS)
  AC_SUBST(WHICHLCMS)
  AC_SUBST(LCMS2DIR)
-@@ -1349,7 +1385,7 @@ EXPATDIR=src
+@@ -1349,7 +1385,7 @@
  EXPAT_CFLAGS=
  EXPAT_LIBS=
  
@@ -449,7 +427,7 @@
    if test -f $srcdir/xps/xps.mak; then
      AC_MSG_CHECKING([for local expat library source])
      if test -f $srcdir/expat/lib/expat.h ; then
-@@ -1528,16 +1564,14 @@ dnl look for IJS implementation
+@@ -1528,16 +1564,14 @@
  AC_ARG_WITH([ijs], AC_HELP_STRING([--without-ijs],
      [disable IJS driver support]))
  
@@ -468,7 +446,7 @@
  
  dnl set safe defaults
      IJSDIR=src
-@@ -1589,15 +1623,8 @@ if test x$with_luratech != xno; then
+@@ -1589,15 +1623,8 @@
      SHARE_JBIG2=0
      JBIG2DIR=$srcdir/luratech/ldf_jb2
  
@@ -486,7 +464,7 @@
            JBIG2_AUTOCONF_CFLAGS="-DUSE_LDF_JB2 -DMAC -DMAC_OS_X_BUILD -fsigned-char"
          ;;
          AIX)
-@@ -1611,7 +1638,6 @@ if test x$with_luratech != xno; then
+@@ -1611,7 +1638,6 @@
            JBIG2_AUTOCONF_CFLAGS="-DUSE_LDF_JB2 -fsigned-char -DLINUX=1 -DFORTE"
          ;;
        esac
@@ -494,7 +472,7 @@
  
      JBIG2FILEDEVS='$(DD)gdevjbig2.dev'
      JBIG2DEVS='$(PSD)jbig2.dev'
-@@ -1718,15 +1744,8 @@ if test x$with_luratech != xno; then
+@@ -1734,15 +1760,8 @@
      SHARE_JPX=0
      JPXDIR=$srcdir/luratech/lwf_jp2
  
@@ -512,7 +490,7 @@
            JPX_AUTOCONF_CFLAGS="-DUSE_LWF_JP2 -DMAC -DMAC_OS_X_BUILD"
          ;;
          AIX)
-@@ -1740,7 +1759,6 @@ if test x$with_luratech != xno; then
+@@ -1756,7 +1775,6 @@
            JPX_AUTOCONF_CFLAGS="-DUSE_LWF_JP2 -DLINUX=1 -DFORTE"
          ;;
        esac
@@ -520,7 +498,7 @@
      JPXDEVS='$(PSD)jpx.dev'
    else
      AC_MSG_RESULT([no])
-@@ -2357,22 +2375,15 @@ SO_LIB_EXT=".so"
+@@ -2506,22 +2524,15 @@
  DLL_EXT=""
  SO_LIB_VERSION_SEPARATOR="."
  
@@ -552,7 +530,7 @@
        DYNAMIC_CFLAGS="-fPIC"
        GS_DYNAMIC_LDFLAGS="-shared -Wl,\$(LD_SET_DT_SONAME)\$(LDFLAGS_SO_PREFIX)\$(GS_SONAME_MAJOR)"
        PCL_DYNAMIC_LDFLAGS="-shared -Wl,\$(LD_SET_DT_SONAME)\$(LDFLAGS_SO_PREFIX)\$(PCL_SONAME_MAJOR)"
-@@ -2386,17 +2397,21 @@ else
+@@ -2535,17 +2546,21 @@
        fi
        SO_LIB_EXT=".so"
      ;;
@@ -578,7 +556,7 @@
        DYNAMIC_CFLAGS="-fPIC"
        GS_DYNAMIC_LDFLAGS="-shared -Wl,\$(LD_SET_DT_SONAME)\$(LDFLAGS_SO_PREFIX)\$(GS_SONAME_MAJOR)"
        PCL_DYNAMIC_LDFLAGS="-shared -Wl,\$(LD_SET_DT_SONAME)\$(LDFLAGS_SO_PREFIX)\$(PCL_SONAME_MAJOR)"
-@@ -2404,7 +2419,7 @@ else
+@@ -2553,7 +2568,7 @@
        DYNAMIC_LIBS=""
        SO_LIB_EXT=".so"
      ;;
@@ -587,7 +565,7 @@
        GS_DYNAMIC_LDFLAGS="-dynamiclib -install_name \$(GS_SONAME_MAJOR_MINOR)"
        PCL_DYNAMIC_LDFLAGS="-dynamiclib -install_name \$(PCL_SONAME_MAJOR_MINOR)"
        XPS_DYNAMIC_LDFLAGS="-dynamiclib -install_name \$(XPS_SONAME_MAJOR_MINOR)"
-@@ -2442,15 +2457,18 @@ else
+@@ -2591,15 +2606,18 @@
        fi
        SO_LIB_EXT=".so"
        ;;
@@ -610,7 +588,7 @@
        INSTALL_SHARED="install-shared"
        if test "x$X_DEVS" != x; then
                DYNAMIC_DEVS="\$(GLOBJDIR)/X11.so"
-@@ -2462,14 +2480,14 @@ AC_ARG_ENABLE([dynamic], AC_HELP_STRING([--enable-dynamic],
+@@ -2611,14 +2629,14 @@
        OPT_CFLAGS="$DYNAMIC_CFLAGS $OPT_CFLAGS"
        DBG_CFLAGS="$DYNAMIC_CFLAGS $DBG_CFLAGS"
        ;;
@@ -627,7 +605,7 @@
        INSTALL_SHARED="install-shared"
        DYNAMIC_FLAGS="-DGS_DEVS_SHARED -DGS_DEVS_SHARED_DIR=\\\"\$(gssharedir)\\\""
        X11_DEVS=""
-@@ -2814,23 +2832,31 @@ AC_SUBST(AUXDIRPOSTFIX)
+@@ -2963,23 +2981,31 @@
  # usually empty on Unix-like systems
  # --------------------------------------------------
  EXEEXT=""
@@ -671,7 +649,7 @@
  
  # --------------------------------------------------
  # Check for disabling of versioned path option.
-@@ -2885,7 +2911,7 @@ fi
+@@ -3034,7 +3060,7 @@
  
  AC_SUBST(CLUSTER_CFLAGS)
  
@@ -680,7 +658,7 @@
  
    ilog2()
    {
-@@ -3025,7 +3051,7 @@ AC_SUBST(AUXEXTRALIBS)
+@@ -3174,7 +3200,7 @@
  
  CONFIG_FILES_LIST="$CONFIG_FILES_LIST $THEMAKEFILE"
  
@@ -689,19 +667,27 @@
    CONFIG_FILES_LIST="$CONFIG_FILES_LIST"
  fi
  
-diff --git a/psi/iapi.h b/psi/iapi.h
-index 1111111..2222222 100644
---- a/psi/iapi.h
-+++ b/psi/iapi.h
-@@ -68,6 +68,11 @@ extern "C" {
- #    define GSDLLEXPORT
- #  endif
- # endif
-+# ifdef __MINGW32__
-+/* export stdcall functions as "name" instead of "_name@ordinal" */
-+#  undef GSDLLAPI
-+#  define GSDLLAPI
-+# endif
- # ifndef GSDLLAPI
- #  define GSDLLAPI __stdcall
-# endif
+Only in ghostscript-9.50: configure.ac.orig
+diff -ur ghostscript-9.50.orig/Makefile.in ghostscript-9.50/Makefile.in
+--- ghostscript-9.50.orig/Makefile.in	2020-12-27 14:29:32.689235419 -0500
++++ ghostscript-9.50/Makefile.in	2020-12-27 18:25:25.241079917 -0500
+@@ -172,6 +172,9 @@
+ 
+ GS=@GS@
+ GS_SO_BASE=@GS@
++GS_SONAME=@GS_SONAME@
++GS_SONAME_MAJOR=@GS_SONAME_MAJOR@
++GS_SONAME_MAJOR_MINOR=@GS_SONAME_MAJOR_MINOR@
+ 
+ PCL=@PCL@
+ PCL_SO_BASE=@PCL@
+@@ -183,7 +186,7 @@
+ GPDL_SO_BASE=@GPDL@
+ 
+ XE=@EXEEXT@
+-XEAUX=@EXEEXT@
++XEAUX=@AUXEXEEXT@
+ 
+ PCL_TARGET=@PCL_TARGET@
+ XPS_TARGET=@XPS_TARGET@
+Only in ghostscript-9.50: Makefile.in.orig
--- a/src/ghostscript.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/ghostscript.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -39,10 +39,11 @@
     cd '$(1)/.build' && $(1)/configure \
         CPPFLAGS='$(CPPFLAGS) -DHAVE_SYS_TIMES_H=0' \
         $(HOST_AND_BUILD_CONFIGURE_OPTIONS) \
-	$($(PKG)_CONFIGURE_FLAGS) \
+        $($(PKG)_CONFIGURE_FLAGS) \
         --prefix='$(HOST_PREFIX)' \
         --without-local-zlib \
-        --with-system-libtiff
+        --with-system-libtiff \
+        --disable-openjpeg
 
     $(MAKE) -C '$(1)/.build' -j '$(JOBS)' $(if $(BUILD_STATIC),libgs,so)
     $(MAKE) -C '$(1)/.build' prefix='$(HOST_PREFIX)' install
--- a/src/glib-1-fixes.patch	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/glib-1-fixes.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -165,7 +165,7 @@
  Requires.private: gmodule-no-export-2.0
 -Libs: -L${libdir} -lgio-2.0
 +Libs: -L${libdir} -lgio-2.0 -ldnsapi -liphlpapi
- Libs.private: @ZLIB_LIBS@ @NETWORK_LIBS@ @SELINUX_LIBS@ @COCOA_LIBS@ @CARBON_LIBS@
+ Libs.private: @ZLIB_LIBS@ @NETWORK_LIBS@ @SELINUX_LIBS@ @COCOA_LIBS@ @CARBON_LIBS@ @LIBMOUNT_LIBS@
  Cflags:
 
 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
@@ -179,73 +179,65 @@
 index 1111111..2222222 100644
 --- a/glib/gmain.c
 +++ b/glib/gmain.c
-@@ -2657,12 +2657,15 @@ g_get_real_time (void)
- #if defined (G_OS_WIN32)
- static ULONGLONG (*g_GetTickCount64) (void) = NULL;
- static guint32 g_win32_tick_epoch = 0;
+@@ -2688,12 +2688,15 @@ g_get_real_time (void)
+  * So for now we calculate (usec_per_sec / ticks_per_sec) and use floating point
+  */
+ static gdouble g_monotonic_usec_per_tick = 0;
 +static gboolean g_win32_clock_is_initialized;
  
  void
  g_clock_win32_init (void)
  {
-   HMODULE kernel32;
+   LARGE_INTEGER freq;
  
 +  g_win32_clock_is_initialized = TRUE;
 +
-   g_GetTickCount64 = NULL;
-   kernel32 = GetModuleHandle ("KERNEL32.DLL");
-   if (kernel32 != NULL)
-@@ -2721,6 +2724,9 @@ g_get_monotonic_time (void)
-    *    timeBeginPeriod() to increase it as much as they want
-    */
- 
+   if (!QueryPerformanceFrequency (&freq) || freq.QuadPart == 0)
+     {
+       /* The documentation says that this should never happen */
+@@ -2707,6 +2709,9 @@ g_get_monotonic_time (void)
+ gint64
+ g_get_monotonic_time (void)
+ {
 +  if (!g_win32_clock_is_initialized)
 +    g_clock_win32_init ();
 +
-   if (g_GetTickCount64 != NULL)
+   if (G_LIKELY (g_monotonic_usec_per_tick != 0))
      {
-       guint32 ticks_as_32bit;
+       LARGE_INTEGER ticks;
 diff --git a/glib/gthread-win32.c b/glib/gthread-win32.c
 index 1111111..2222222 100644
 --- a/glib/gthread-win32.c
 +++ b/glib/gthread-win32.c
-@@ -116,18 +116,28 @@ typedef struct
-   void     (__stdcall * WakeConditionVariable)       (gpointer cond);
- } GThreadImplVtable;
- 
+@@ -60,6 +60,10 @@ g_thread_abort (gint         status,
+            strerror (status), function);
+   g_abort ();
+ }
 +/* Needed for static builds where DllMain initializer doesn't get called */
 +static gboolean g_threads_is_initialized;
 +G_GNUC_INTERNAL void g_thread_win32_init (void);
 +
- static GThreadImplVtable g_thread_impl_vtable;
  
- /* {{{1 GMutex */
+ /* Starting with Vista and Windows 2008, we have access to the
+  * CONDITION_VARIABLE and SRWLock primatives on Windows, which are
+@@ -79,6 +83,9 @@ g_thread_abort (gint         status,
  void
  g_mutex_init (GMutex *mutex)
  {
 +  if (!g_threads_is_initialized)
 +    g_thread_win32_init ();
 +
-   g_thread_impl_vtable.InitializeSRWLock (mutex);
+   InitializeSRWLock ((gpointer) mutex);
  }
  
- void
- g_mutex_clear (GMutex *mutex)
- {
-+  if (!g_threads_is_initialized)
-+    g_thread_win32_init ();
-+
-   if (g_thread_impl_vtable.DeleteSRWLock != NULL)
-     g_thread_impl_vtable.DeleteSRWLock (mutex);
- }
-@@ -135,18 +145,27 @@ g_mutex_clear (GMutex *mutex)
+@@ -90,18 +97,27 @@ g_mutex_clear (GMutex *mutex)
  void
  g_mutex_lock (GMutex *mutex)
  {
 +  if (!g_threads_is_initialized)
 +    g_thread_win32_init ();
 +
-   g_thread_impl_vtable.AcquireSRWLockExclusive (mutex);
+   AcquireSRWLockExclusive ((gpointer) mutex);
  }
  
  gboolean
@@ -254,7 +246,7 @@
 +  if (!g_threads_is_initialized)
 +    g_thread_win32_init ();
 +
-   return g_thread_impl_vtable.TryAcquireSRWLockExclusive (mutex);
+   return TryAcquireSRWLockExclusive ((gpointer) mutex);
  }
  
  void
@@ -263,10 +255,10 @@
 +  if (!g_threads_is_initialized)
 +    g_thread_win32_init ();
 +
-   g_thread_impl_vtable.ReleaseSRWLockExclusive (mutex);
+   ReleaseSRWLockExclusive ((gpointer) mutex);
  }
  
-@@ -157,6 +176,9 @@ g_rec_mutex_impl_new (void)
+@@ -112,6 +128,9 @@ g_rec_mutex_impl_new (void)
  {
    CRITICAL_SECTION *cs;
  
@@ -276,7 +268,7 @@
    cs = g_slice_new (CRITICAL_SECTION);
    InitializeCriticalSection (cs);
  
-@@ -167,6 +189,10 @@ static void
+@@ -122,6 +141,10 @@ static void
  g_rec_mutex_impl_free (CRITICAL_SECTION *cs)
  {
    DeleteCriticalSection (cs);
@@ -287,7 +279,7 @@
    g_slice_free (CRITICAL_SECTION, cs);
  }
  
-@@ -175,6 +201,9 @@ g_rec_mutex_get_impl (GRecMutex *mutex)
+@@ -130,6 +153,9 @@ g_rec_mutex_get_impl (GRecMutex *mutex)
  {
    CRITICAL_SECTION *impl = mutex->p;
  
@@ -297,7 +289,7 @@
    if G_UNLIKELY (mutex->p == NULL)
      {
        impl = g_rec_mutex_impl_new ();
-@@ -189,30 +218,45 @@ g_rec_mutex_get_impl (GRecMutex *mutex)
+@@ -144,30 +170,45 @@ g_rec_mutex_get_impl (GRecMutex *mutex)
  void
  g_rec_mutex_init (GRecMutex *mutex)
  {
@@ -343,33 +335,24 @@
    return TryEnterCriticalSection (g_rec_mutex_get_impl (mutex));
  }
  
-@@ -221,12 +265,18 @@ g_rec_mutex_trylock (GRecMutex *mutex)
+@@ -176,6 +217,9 @@ g_rec_mutex_trylock (GRecMutex *mutex)
  void
  g_rw_lock_init (GRWLock *lock)
  {
 +  if (!g_threads_is_initialized)
 +    g_thread_win32_init ();
 +
-   g_thread_impl_vtable.InitializeSRWLock (lock);
+   InitializeSRWLock ((gpointer) lock);
  }
  
- void
- g_rw_lock_clear (GRWLock *lock)
- {
-+  if (!g_threads_is_initialized)
-+    g_thread_win32_init ();
-+
-   if (g_thread_impl_vtable.DeleteSRWLock != NULL)
-     g_thread_impl_vtable.DeleteSRWLock (lock);
- }
-@@ -234,36 +284,54 @@ g_rw_lock_clear (GRWLock *lock)
+@@ -187,36 +231,54 @@ g_rw_lock_clear (GRWLock *lock)
  void
  g_rw_lock_writer_lock (GRWLock *lock)
  {
 +  if (!g_threads_is_initialized)
 +    g_thread_win32_init ();
 +
-   g_thread_impl_vtable.AcquireSRWLockExclusive (lock);
+   AcquireSRWLockExclusive ((gpointer) lock);
  }
  
  gboolean
@@ -378,7 +361,7 @@
 +  if (!g_threads_is_initialized)
 +    g_thread_win32_init ();
 +
-   return g_thread_impl_vtable.TryAcquireSRWLockExclusive (lock);
+   return TryAcquireSRWLockExclusive ((gpointer) lock);
  }
  
  void
@@ -387,7 +370,7 @@
 +  if (!g_threads_is_initialized)
 +    g_thread_win32_init ();
 +
-   g_thread_impl_vtable.ReleaseSRWLockExclusive (lock);
+   ReleaseSRWLockExclusive ((gpointer) lock);
  }
  
  void
@@ -396,7 +379,7 @@
 +  if (!g_threads_is_initialized)
 +    g_thread_win32_init ();
 +
-   g_thread_impl_vtable.AcquireSRWLockShared (lock);
+   AcquireSRWLockShared ((gpointer) lock);
  }
  
  gboolean
@@ -405,7 +388,7 @@
 +  if (!g_threads_is_initialized)
 +    g_thread_win32_init ();
 +
-   return g_thread_impl_vtable.TryAcquireSRWLockShared (lock);
+   return TryAcquireSRWLockShared ((gpointer) lock);
  }
  
  void
@@ -414,36 +397,27 @@
 +  if (!g_threads_is_initialized)
 +    g_thread_win32_init ();
 +
-   g_thread_impl_vtable.ReleaseSRWLockShared (lock);
+   ReleaseSRWLockShared ((gpointer) lock);
  }
  
-@@ -271,12 +339,18 @@ g_rw_lock_reader_unlock (GRWLock *lock)
+@@ -224,6 +286,9 @@ g_rw_lock_reader_unlock (GRWLock *lock)
  void
  g_cond_init (GCond *cond)
  {
 +  if (!g_threads_is_initialized)
 +    g_thread_win32_init ();
 +
-   g_thread_impl_vtable.InitializeConditionVariable (cond);
+   InitializeConditionVariable ((gpointer) cond);
  }
  
- void
- g_cond_clear (GCond *cond)
- {
-+  if (!g_threads_is_initialized)
-+    g_thread_win32_init ();
-+
-   if (g_thread_impl_vtable.DeleteConditionVariable)
-     g_thread_impl_vtable.DeleteConditionVariable (cond);
- }
-@@ -284,12 +358,18 @@ g_cond_clear (GCond *cond)
+@@ -235,12 +300,18 @@ g_cond_clear (GCond *cond)
  void
  g_cond_signal (GCond *cond)
  {
 +  if (!g_threads_is_initialized)
 +    g_thread_win32_init ();
 +
-   g_thread_impl_vtable.WakeConditionVariable (cond);
+   WakeConditionVariable ((gpointer) cond);
  }
  
  void
@@ -452,30 +426,30 @@
 +  if (!g_threads_is_initialized)
 +    g_thread_win32_init ();
 +
-   g_thread_impl_vtable.WakeAllConditionVariable (cond);
+   WakeAllConditionVariable ((gpointer) cond);
  }
  
-@@ -297,6 +377,9 @@ void
+@@ -248,6 +319,9 @@ void
  g_cond_wait (GCond  *cond,
               GMutex *entered_mutex)
  {
 +  if (!g_threads_is_initialized)
 +    g_thread_win32_init ();
 +
-   g_thread_impl_vtable.SleepConditionVariableSRW (cond, entered_mutex, INFINITE, 0);
+   SleepConditionVariableSRW ((gpointer) cond, (gpointer) entered_mutex, INFINITE, 0);
  }
  
-@@ -307,6 +390,9 @@ g_cond_wait_until (GCond  *cond,
- {
-   gint64 span;
+@@ -260,6 +334,9 @@ g_cond_wait_until (GCond  *cond,
+   DWORD span_millis;
+   gboolean signalled;
  
 +  if (!g_threads_is_initialized)
 +    g_thread_win32_init ();
 +
-   span = end_time - g_get_monotonic_time ();
- 
-   if G_UNLIKELY (span < 0)
-@@ -339,6 +425,9 @@ g_private_get_impl (GPrivate *key)
+   start_time = g_get_monotonic_time ();
+   do
+     {
+@@ -311,6 +388,9 @@ g_private_get_impl (GPrivate *key)
  
    if G_UNLIKELY (impl == 0)
      {
@@ -485,7 +459,7 @@
        EnterCriticalSection (&g_private_lock);
        impl = (DWORD) key->p;
        if (impl == 0)
-@@ -432,6 +521,9 @@ g_system_thread_free (GRealThread *thread)
+@@ -404,6 +484,9 @@ g_system_thread_free (GRealThread *thread)
  {
    GThreadWin32 *wt = (GThreadWin32 *) thread;
  
@@ -495,7 +469,7 @@
    win32_check_for_error (CloseHandle (wt->handle));
    g_slice_free (GThreadWin32, wt);
  }
-@@ -439,6 +531,9 @@ g_system_thread_free (GRealThread *thread)
+@@ -411,6 +494,9 @@ g_system_thread_free (GRealThread *thread)
  void
  g_system_thread_exit (void)
  {
@@ -505,7 +479,7 @@
    _endthreadex (0);
  }
  
-@@ -447,6 +542,9 @@ g_thread_win32_proxy (gpointer data)
+@@ -419,6 +505,9 @@ g_thread_win32_proxy (gpointer data)
  {
    GThreadWin32 *self = data;
  
@@ -515,7 +489,7 @@
    self->proxy (self);
  
    g_system_thread_exit ();
-@@ -464,6 +562,9 @@ g_system_thread_new (GThreadFunc   func,
+@@ -436,6 +525,9 @@ g_system_thread_new (GThreadFunc   func,
    GThreadWin32 *thread;
    guint ignore;
  
@@ -525,7 +499,7 @@
    thread = g_slice_new0 (GThreadWin32);
    thread->proxy = func;
  
-@@ -493,6 +594,9 @@ g_system_thread_wait (GRealThread *thread)
+@@ -465,6 +557,9 @@ g_system_thread_wait (GRealThread *thread)
  {
    GThreadWin32 *wt = (GThreadWin32 *) thread;
  
@@ -535,15 +509,16 @@
    win32_check_for_error (WAIT_FAILED != WaitForSingleObject (wt->handle, INFINITE));
  }
  
-@@ -1041,6 +1145,8 @@ g_thread_lookup_native_funcs (void)
+@@ -536,6 +631,8 @@ g_system_thread_set_name (const gchar *name)
  void
  g_thread_win32_init (void)
  {
 +  g_threads_is_initialized = TRUE;
 +
-   if (!g_thread_lookup_native_funcs ())
-     g_thread_xp_init ();
+   InitializeCriticalSection (&g_private_lock);
  
+ #ifndef _MSC_VER
+
 
 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: Gerardo Ballabio <gerardo.ballabio@gmail.com>
@@ -597,52 +572,6 @@
  dnl definitions in terms of our private definitions.
 
 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Tony Theodore <tonyt@logyst.com>
-Date: Mon, 26 Feb 2018 16:09:53 +1100
-Subject: [PATCH 9/9] darwin: disable g_cocoa_notification_backend
-
-
-diff --git a/gio/Makefile.am b/gio/Makefile.am
-index 1111111..2222222 100644
---- a/gio/Makefile.am
-+++ b/gio/Makefile.am
-@@ -279,10 +279,6 @@ unix_sources = \
- 
- appinfo_sources += $(unix_appinfo_sources)
- 
--if OS_COCOA
--unix_sources += gcocoanotificationbackend.c
--endif
--
- giounixincludedir=$(includedir)/gio-unix-2.0/gio
- giounixinclude_HEADERS = \
- 	gdesktopappinfo.h	\
-diff --git a/gio/giomodule.c b/gio/giomodule.c
-index 1111111..2222222 100644
---- a/gio/giomodule.c
-+++ b/gio/giomodule.c
-@@ -918,9 +918,6 @@ extern GType g_proxy_resolver_portal_get_type (void);
- extern GType g_network_monitor_portal_get_type (void);
- #endif
- 
--#ifdef HAVE_COCOA
--extern GType g_cocoa_notification_backend_get_type (void);
--#endif
- 
- #ifdef G_PLATFORM_WIN32
- 
-@@ -1117,9 +1114,6 @@ _g_io_modules_ensure_loaded (void)
-       g_type_ensure (g_network_monitor_portal_get_type ());
-       g_type_ensure (g_proxy_resolver_portal_get_type ());
- #endif
--#ifdef HAVE_COCOA
--      g_type_ensure (g_cocoa_notification_backend_get_type ());
--#endif
- #ifdef G_OS_WIN32
-       g_type_ensure (_g_winhttp_vfs_get_type ());
-#endif
-
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: Ernestas Kulik <ekulik@redhat.com>
 Date: Tue, 29 Jan 2019 09:50:46 +0100
 Subject: [PATCH 10/10] gdbus: Avoid printing null strings
@@ -692,7 +621,7 @@
            g_set_error (error,
 @@ -2703,10 +2702,10 @@ g_dbus_message_to_blob (GDBusMessage          *message,
                         G_IO_ERROR_INVALID_ARGUMENT,
-                        _("Message body has signature '%s' but there is no signature header"),
+                        _("Message body has signature “%s” but there is no signature header"),
                         signature_str);
 -          g_free (tupled_signature_str);
            goto out;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/glib-2-fixes.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,24 @@
+See: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1428
+
+--- a/glib/gtypes.h	2016-10-22 07:21:52.000000000 +0200
++++ b/glib/gtypes.h	2020-05-17 11:13:49.369639688 +0200
+@@ -522,7 +522,7 @@
+ #    else /* !GLIB_STATIC_COMPILATION */
+ #      ifdef GLIB_COMPILATION
+ #        ifdef DLL_EXPORT
+-#          define GLIB_VAR __declspec(dllexport)
++#          define GLIB_VAR extern __declspec(dllexport)
+ #        else /* !DLL_EXPORT */
+ #          define GLIB_VAR extern
+ #        endif /* !DLL_EXPORT */
+--- a/gobject/gparamspecs.h	2016-10-22 07:22:21.000000000 +0200
++++ b/gobject/gparamspecs.h	2020-05-17 11:16:37.803281391 +0200
+@@ -1144,7 +1144,7 @@
+ #    else /* !GOBJECT_STATIC_COMPILATION */
+ #      ifdef GOBJECT_COMPILATION
+ #        ifdef DLL_EXPORT
+-#          define GOBJECT_VAR __declspec(dllexport)
++#          define GOBJECT_VAR extern __declspec(dllexport)
+ #        else /* !DLL_EXPORT */
+ #          define GOBJECT_VAR extern
+ #        endif /* !DLL_EXPORT */
--- a/src/glib.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/glib.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := glib
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 2.50.2
-$(PKG)_CHECKSUM := 948a768931ca321a35e16556a1c8adcae04babf2
+$(PKG)_VERSION  := 2.58.0
+$(PKG)_CHECKSUM := c00e433c56e0ba3541abc5222aeca4136de10fb8
 $(PKG)_SUBDIR   := glib-$($(PKG)_VERSION)
 $(PKG)_FILE     := glib-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := http://ftp.gnome.org/pub/gnome/sources/glib/$(call SHORT_PKG_VERSION,$(PKG))/$($(PKG)_FILE)
@@ -41,7 +41,8 @@
         --disable-libmount \
         --with-libiconv=gnu \
         --with-pcre=internal \
-	&& $(CONFIGURE_POST_HOOK)
+        --disable-compile-warnings \
+        && $(CONFIGURE_POST_HOOK)
 
     $(SED) -i 's,#define G_ATOMIC.*,,' '$(1)/config.h'
     $(MAKE) -C '$(1)/glib'    -j '$(JOBS)'
@@ -68,6 +69,7 @@
         --with-pcre=system \
         --with-libiconv=gnu \
         --disable-inotify \
+        --disable-compile-warnings \
         PKG_CONFIG='$(MXE_PKG_CONFIG)' \
         PKG_CONFIG_PATH='$(PKG_CONFIG_PATH)' 
 
--- a/src/glpk.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/glpk.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := glpk
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 4.65
-$(PKG)_CHECKSUM := d9b607a9cf3a25b754a0cd9a842ea5043f8604db
+$(PKG)_VERSION  := 5.0
+$(PKG)_CHECKSUM := 3a85b1e4c806b91deebfcf9a845b9308cd785d64
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := glpk-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := ftp://ftp.gnu.org/gnu/glpk/$($(PKG)_FILE)
--- a/src/gmp.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/gmp.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := gmp
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 6.2.0
-$(PKG)_CHECKSUM := 5e9341d3807bc7505376f9ed9f5c1c6c57050aa6
+$(PKG)_VERSION  := 6.2.1
+$(PKG)_CHECKSUM := 2dcf34d4a432dbe6cce1475a835d20fe44f75822
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := https://gmplib.org/download/gmp/$($(PKG)_FILE)
--- a/src/gnuplot.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/gnuplot.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -76,6 +76,12 @@
     $(INSTALL) -d '$(3)$(HOST_PREFIX)/share/texmf/tex/generic/gnuplot/'
     $(INSTALL) -m644 "$(1)/share/LaTeX/gnuplot-lua-tikz-common.tex" '$(3)$(HOST_PREFIX)/share/texmf/tex/generic/gnuplot/';
 
+    # js files
+    $(INSTALL) -d '$(3)$(HOST_PREFIX)/share/js'
+    for f in $(1)/term/js/*.*; do \
+      $(INSTALL) -m644 "$$f" '$(3)$(HOST_PREFIX)/share/js/'; \
+    done
+
     ## MG: not sure what to do with these and how to integrate with DESTDIR
     $(INSTALL) -d '$(TOP_DIR)/gnuplot/bin'
     $(INSTALL) -m755 '$(1)/config/mingw/gnuplot.exe' '$(TOP_DIR)/gnuplot/bin/'
--- a/src/gnutls.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/gnutls.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -2,8 +2,8 @@
 # See index.html for further information.
 
 PKG             := gnutls
-$(PKG)_VERSION  := 3.6.15
-$(PKG)_CHECKSUM := 00ef7d93347df586c3d1a00f13c326706c0c59ba
+$(PKG)_VERSION  := 3.6.16
+$(PKG)_CHECKSUM := 6ba8fb898dcf4b4046b60662ba97df835593e687
 $(PKG)_SUBDIR   := gnutls-$($(PKG)_VERSION)
 $(PKG)_FILE     := gnutls-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := ftp://ftp.gnutls.org/gcrypt/gnutls/v3.6/$($(PKG)_FILE)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/graphicsmagick-3-user32.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,71 @@
+diff -ur GraphicsMagick-1.3.36.orig/configure.ac GraphicsMagick-1.3.36/configure.ac
+--- GraphicsMagick-1.3.36.orig/configure.ac	2021-01-01 09:35:17.966994198 -0500
++++ GraphicsMagick-1.3.36/configure.ac	2021-01-01 14:21:04.736125338 -0500
+@@ -2752,7 +2752,8 @@
+   found_libgdi32=0
+   AC_CHECK_HEADER([windows.h],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`])
+   AC_CHECK_HEADER([wingdi.h],[passed=`expr $passed + 1`],[failed=`expr $failed + 1`],[#include <windows.h>])
+-  AC_CHECK_LIB([gdi32],[OpenClipboard],[found_libgdi32=`expr $found_libgdi32 + 1`],,)
++  AC_CHECK_LIB([user32],[OpenClipboard],[found_libuser32=`expr $found_libuser32 + 1`],[],[])
++  AC_CHECK_LIB([gdi32],[CreateDIBSection],[found_libgdi32=`expr $found_libgdi32 + 1`],[],[])
+   if test $found_libgdi32 -gt 0
+   then
+     passed=`expr $passed + 1`
+@@ -2767,7 +2768,7 @@
+       AC_MSG_RESULT([no -- some components failed test])
+       have_gdi32='no (failed tests)'
+     else
+-      LIB_GDI32='-lgdi32'
++      LIB_GDI32='-lgdi32 -luser32'
+       LIBS="$LIB_GDI32 $LIBS"
+       AC_DEFINE([HasWINGDI32],[1],[Define to use the Windows GDI32 library])
+       AC_MSG_RESULT([yes])
+diff -ur GraphicsMagick-1.3.36.orig/magick/nt_feature.c GraphicsMagick-1.3.36/magick/nt_feature.c
+--- GraphicsMagick-1.3.36.orig/magick/nt_feature.c	2021-01-01 09:35:18.045998572 -0500
++++ GraphicsMagick-1.3.36/magick/nt_feature.c	2021-01-01 14:22:55.233205368 -0500
+@@ -78,6 +78,7 @@
+ %
+ %
+ */
++#if defined(HasWINGDI32)
+ MagickExport void *CropImageToHBITMAP(Image *image,
+   const RectangleInfo *geometry,ExceptionInfo *exception)
+ {
+@@ -217,6 +218,7 @@
+ 
+   return (void *)bitmapH;
+ }
++#endif
+ 
+ /*
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+@@ -612,6 +614,7 @@
+ %
+ %
+ */
++#if defined(HasWINGDI32)
+ MagickExport void *ImageToHBITMAP(Image* image)
+ {
+   unsigned long
+@@ -696,5 +699,6 @@
+ 
+   return (void *)bitmapH;
+ }
++#endif
+ 
+ #endif
+diff -ur GraphicsMagick-1.3.36.orig/magick/nt_feature.h GraphicsMagick-1.3.36/magick/nt_feature.h
+--- GraphicsMagick-1.3.36.orig/magick/nt_feature.h	2021-01-01 09:35:18.038998185 -0500
++++ GraphicsMagick-1.3.36/magick/nt_feature.h	2021-01-01 14:23:42.008779169 -0500
+@@ -23,9 +23,11 @@
+ extern MagickExport char
+   *NTRegistryKeyLookup(const char *key);
+ 
++#if defined(HasWINGDI32)
+ extern MagickExport void
+   *CropImageToHBITMAP(Image *,const RectangleInfo *,ExceptionInfo *),
+   *ImageToHBITMAP(Image* image);
++#endif
+ 
+ #if !defined(XS_VERSION)
+ 
--- a/src/graphicsmagick.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/graphicsmagick.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := graphicsmagick
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 1.3.35
-$(PKG)_CHECKSUM := b0460d7fb8b2d542a44446322ea62c053bc54b0c
+$(PKG)_VERSION  := 1.3.36
+$(PKG)_CHECKSUM := df45052bf485407ad4fb7d3b9b305d3e5ebb14e5
 $(PKG)_SUBDIR   := GraphicsMagick-$($(PKG)_VERSION)
 $(PKG)_FILE     := GraphicsMagick-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/$(PKG)/$(PKG)/$($(PKG)_VERSION)/$($(PKG)_FILE)
@@ -32,7 +32,7 @@
         $($(PKG)_CONFIGURE_OPTIONS) \
         $(HOST_AND_BUILD_CONFIGURE_OPTIONS) \
         $(ENABLE_SHARED_OR_STATIC) \
-         $(CONFIGURE_CPPFLAGS) $(CONFIGURE_LDFLAGS) \
+        $(CONFIGURE_CPPFLAGS) $(CONFIGURE_LDFLAGS) \
         --prefix='$(HOST_PREFIX)' \
         --disable-openmp \
         --with-modules \
@@ -55,14 +55,24 @@
         --with-xml \
         --with-zlib \
         --without-x \
-       --with-quantum-depth=16 \
+        --with-quantum-depth=16 \
         ac_cv_prog_xml2_config='$(HOST_BINDIR)/xml2-config' \
         ac_cv_path_xml2_config='$(HOST_BINDIR)/xml2-config' \
-	&& $(CONFIGURE_POST_HOOK)
+        && $(CONFIGURE_POST_HOOK)
     $(MAKE) -C '$(1)' -j '$(JOBS)' bin_PROGRAMS=
     $(MAKE) -C '$(1)' -j 1 install bin_PROGRAMS= DESTDIR='$(3)'
 
     if [ "$(ENABLE_DEP_DOCS)" == "no" ]; then \
       rm -rf "$(3)$(HOST_PREFIX)/share/doc/GraphicsMagick"; \
     fi
+
+    # Build (and install) fork of dcraw
+    if [ "x$(MXE_WINDOWS_BUILD)" == "xyes" ]; then \
+      cd '$(1)/dcraw' && $(MXE_CC) -O4 -o $(3)$(HOST_PREFIX)/bin/dcraw dcraw.c \
+        -Wall -Wno-unused-result -Wno-array-bounds -Wno-maybe-uninitialized \
+        -Wno-unused-but-set-variable \
+        -I$(HOST_PREFIX)/include -L$(HOST_PREFIX)/lib \
+        -lm -ljasper -ljpeg -llcms2 -lws2_32 -s; \
+    fi
+
 endef
--- a/src/gsl.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/gsl.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := gsl
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 2.6
-$(PKG)_CHECKSUM := 9273164b6bdf60d0577518a1c1310eff6659e3dd
+$(PKG)_VERSION  := 2.7
+$(PKG)_CHECKSUM := 29179db0d746f422bb0ceca2cbda4de107a2c651
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://ftp.gnu.org/gnu/$(PKG)/$($(PKG)_FILE)
--- a/src/gsoap.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/gsoap.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -7,11 +7,11 @@
 $(PKG)_CHECKSUM := b1c17d501361939c6d419eeb2aa26e7fd2b586fe
 $(PKG)_SUBDIR   := gsoap-$(call SHORT_PKG_VERSION,$(PKG))
 $(PKG)_FILE     := gsoap_$($(PKG)_VERSION).zip
-$(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/gsoap2/gSOAP/$($(PKG)_FILE)
+$(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/gsoap2/$($(PKG)_FILE)
 $(PKG)_DEPS     := gnutls libgcrypt libntlm
 
 define $(PKG)_UPDATE
-    $(WGET) -q -O- 'http://sourceforge.net/projects/gsoap2/files/gsoap-2.8/' | \
+    $(WGET) -q -O- 'http://sourceforge.net/projects/gsoap2/files' | \
     $(SED) -n 's,.*gsoap_\([0-9][^>]*\)\.zip.*,\1,p' | \
     head -1
 endef
--- a/src/hdf5.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/hdf5.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,12 +3,12 @@
 
 PKG             := hdf5
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 1.12.0
-$(PKG)_CHECKSUM := 6020131b6e18e6866816b1fe68980512c696c2bf
+$(PKG)_VERSION  := 1.12.1
+$(PKG)_CHECKSUM := 665eed49a004f96f852887bb2b232dd7d3d8d8a0
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := https://support.hdfgroup.org/ftp/HDF5/releases/$(PKG)-$(call SHORT_PKG_VERSION,$(PKG))/$(PKG)-$($(PKG)_VERSION)/src/$($(PKG)_FILE)
-$(PKG)_DEPS     := zlib
+$(PKG)_DEPS     := build-ninja zlib
 
 define $(PKG)_UPDATE
     echo 'Warning: Updates are temporarily disabled for package hdf5.' >&2;
@@ -32,7 +32,7 @@
             -DH5_DISABLE_SOME_LDOUBLE_CONV_RUN__TRYRUN_OUTPUT="" \
             -DH5_NO_ALIGNMENT_RESTRICTIONS_RUN=0 \
             -DH5_NO_ALIGNMENT_RESTRICTIONS_RUN__TRYRUN_OUTPUT="" \
-            -DH5_PRINTF_LL_TEST_RUN=1 \
+            -DH5_PRINTF_LL_TEST_RUN=0 \
             -DH5_PRINTF_LL_TEST_RUN__TRYRUN_OUTPUT="" \
             -DTEST_LFS_WORKS_RUN=0
     endif
@@ -41,26 +41,33 @@
 define $(PKG)_BUILD
     if test x$(MXE_SYSTEM) = xmingw; then \
         mkdir '$(1)/pregen'; \
+        mkdir '$(1)/pregen/shared'; \
         case '$(TARGET)' in \
             x86_64-w64-mingw32) \
                 cp '$(1)/src/H5Tinit.c.mingw64' '$(1)/pregen/H5Tinit.c' & \
-                cp '$(1)/src/H5lib_settings.c.mingw64' '$(1)/pregen/H5lib_settings.c' \
+                cp '$(1)/src/H5Tinit.c.mingw64' '$(1)/pregen/shared/H5Tinit.c' & \
+                cp '$(1)/src/H5lib_settings.c.mingw64' '$(1)/pregen/H5lib_settings.c' & \
+                cp '$(1)/src/H5lib_settings.c.mingw64' '$(1)/pregen/shared/H5lib_settings.c' \
             ;; \
             i686-w64-mingw32) \
                 cp '$(1)/src/H5Tinit.c.mingw32' '$(1)/pregen/H5Tinit.c' & \
-                cp '$(1)/src/H5lib_settings.c.mingw32' '$(1)/pregen/H5lib_settings.c' \
+                cp '$(1)/src/H5Tinit.c.mingw32' '$(1)/pregen/shared/H5Tinit.c' & \
+                cp '$(1)/src/H5lib_settings.c.mingw32' '$(1)/pregen/H5lib_settings.c' & \
+                cp '$(1)/src/H5lib_settings.c.mingw32' '$(1)/pregen/shared/H5lib_settings.c' \
             ;; \
             i686-pc-mingw32) \
                 cp '$(1)/src/H5Tinit.c.mingw32' '$(1)/pregen/H5Tinit.c' & \
-                cp '$(1)/src/H5lib_settings.c.mingw32' '$(1)/pregen/H5lib_settings.c' \
+                cp '$(1)/src/H5Tinit.c.mingw32' '$(1)/pregen/shared/H5Tinit.c' & \
+                cp '$(1)/src/H5lib_settings.c.mingw32' '$(1)/pregen/H5lib_settings.c' & \
+                cp '$(1)/src/H5lib_settings.c.mingw32' '$(1)/pregen/shared/H5lib_settings.c' \
             ;; \
         esac; \
     fi
 
     mkdir '$(1)/.build'
 
-    cd '$(1)/.build' && cmake .. -G "Unix Makefiles" \
-        -DCMAKE_INSTALL_PREFIX=${prefix} \
+    cd '$(1)/.build' && cmake .. -G Ninja \
+        -DCMAKE_INSTALL_PREFIX=$(HOST_PREFIX) \
         $($(PKG)_CMAKE_FLAGS) \
         $(CMAKE_CCACHE_FLAGS) \
         $(CMAKE_BUILD_SHARED_OR_STATIC) \
@@ -78,19 +85,17 @@
         $($(PKG)_CROSS_CONFIG_OPTIONS) \
         -DHDF5_USE_PREGEN_DIR='$(1)/pregen'
 
-    $(MAKE) -C '$(1)/.build' -j '$(JOBS)' 
-    $(MAKE) -C '$(1)/.build' -j 1 install DESTDIR='$(3)'
+    cmake --build '$(1)/.build' -j '$(JOBS)' 
+    DESTDIR='$(3)' cmake --install '$(1)/.build'
 
     # FIXME: Change the build rule to create the shared libs with the prefix
-    if test x$(MXE_SYSTEM) = xmingw; then \
+    if [ $(BUILD_STATIC) = yes ]; then \
+      if test x$(MXE_SYSTEM) = xmingw; then \
         mv '$(3)/$(HOST_LIBDIR)/hdf5.lib' '$(3)/$(HOST_LIBDIR)/libhdf5.lib'; \
         mv '$(3)/$(HOST_LIBDIR)/hdf5_tools.lib' '$(3)/$(HOST_LIBDIR)/libhdf5_tools.lib'; \
         mv '$(3)/$(HOST_LIBDIR)/hdf5_hl.lib' '$(3)/$(HOST_LIBDIR)/libhdf5_hl.lib'; \
+      fi; \
     fi
-    
-    # Remove version suffix from pkg-config files
-    mv '$(3)/$(HOST_LIBDIR)/pkgconfig/hdf5-$($(PKG)_VERSION).pc' '$(3)/$(HOST_LIBDIR)/pkgconfig/hdf5.pc'
-    mv '$(3)/$(HOST_LIBDIR)/pkgconfig/hdf5_hl-$($(PKG)_VERSION).pc' '$(3)/$(HOST_LIBDIR)/pkgconfig/hdf5_hl.pc'
 
     if [ "$(ENABLE_DEP_DOCS)" == "no" ]; then \
         rm -rf '$(3)$(HOST_PREFIX)/share/hdf5_examples'; \
--- a/src/icu4c.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/icu4c.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -1,7 +1,7 @@
 PKG             := icu4c
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 67.1
-$(PKG)_CHECKSUM := 6822a4a94324d1ba591b3e8ef084e4491af253c1
+$(PKG)_VERSION  := 70.1
+$(PKG)_CHECKSUM := f7c1363edee6be7de8b624ffbb801892b3417d4e
 $(PKG)_SUBDIR   := icu
 $(PKG)_FILE     := $(PKG)-$(subst .,_,$($(PKG)_VERSION))-src.tgz
 $(PKG)_URL      := https://github.com/unicode-org/icu/releases/download/release-$(subst .,-,$($(PKG)_VERSION))/$($(PKG)_FILE)
@@ -16,13 +16,14 @@
 endef
 
 ifeq ($(MXE_NATIVE_BUILD),no)
-define $(PKG)_BUILD
+  define $(PKG)_BUILD
     # build some native tools
     mkdir '$(1).native' && cd '$(1).native' && '$(1)/source/configure'
     $(MAKE) -C '$(1).native' -j '$(JOBS)'
 
     # build cross
-    mkdir '$(1).cross' && cd '$(1).cross' && '$(1)/source/configure' \
+    mkdir '$(1).cross' && cd '$(1).cross' && \
+      '$(1)/source/configure' \
         $(HOST_AND_BUILD_CONFIGURE_OPTIONS) \
         $(ENABLE_SHARED_OR_STATIC) \
         --prefix='$(HOST_PREFIX)' \
@@ -34,13 +35,15 @@
     $(MAKE) -C '$(1).cross' -j '$(JOBS)' $(MXE_DISABLE_DOCS) $(MXE_DISABLE_PROGS)
     $(MAKE) -C '$(1).cross' -j 1 install $(MXE_DISABLE_DOCS) $(MXE_DISABLE_PROGS) DESTDIR='$(3)'
     $(INSTALL) -d '$(3)$(HOST_BINDIR)'
-    #mv -fv $(3)$(HOST_LIBDIR)/icu*.dll '$(3)$(HOST_BINDIR)/'
+    # mv -fv $(3)$(HOST_LIBDIR)/icu*.dll '$(3)$(HOST_BINDIR)/'
     $(INSTALL) -d '$(3)$(BUILD_TOOLS_PREFIX)/bin/'
     $(LN_SF) '$(HOST_BINDIR)/icu-config' '$(3)$(BUILD_TOOLS_PREFIX)/bin/$(MXE_TOOL_PREFIX)icu-config'
-endef
+  endef
 else
-define $(PKG)_BUILD
-    mkdir '$(1).native' && cd '$(1).native' && '$(1)/source/configure' \
+  define $(PKG)_BUILD
+    mkdir '$(1).native' && cd '$(1).native' && \
+      '$(1)/source/configure' \
+        CC=$(MXE_CC) CXX=$(MXE_CXX) AR=$(MXE_AR) \
         $(HOST_AND_BUILD_CONFIGURE_OPTIONS) \
         $(ENABLE_SHARED_OR_STATIC) \
         PKG_CONFIG='$(MXE_PKG_CONFIG)' \
@@ -48,6 +51,6 @@
         --prefix='$(HOST_PREFIX)'
     $(MAKE) -C '$(1).native' -j '$(JOBS)' $(MXE_DISABLE_DOCS) $(MXE_DISABLE_PROGS)
     $(MAKE) -C '$(1).native' -j 1 install $(MXE_DISABLE_DOCS) $(MXE_DISABLE_PROGS)
-endef
+  endef
 endif
 
--- a/src/isl.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/isl.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,24 +4,24 @@
 PKG             := isl
 $(PKG)_IGNORE   :=
 $(PKG)_VERSION  := 0.22.1
-$(PKG)_CHECKSUM := 125303d52bd6226f80d23bf1f76b78c6f1115568
-$(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
-$(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.xz
-$(PKG)_URL      := http://isl.gforge.inria.fr/$($(PKG)_FILE)
+$(PKG)_CHECKSUM := ce66c4415906bf2c16a8f09f31383f4fe0991531
+$(PKG)_SUBDIR   := isl-$(PKG)-$($(PKG)_VERSION)-788faca
+$(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
+$(PKG)_URL      := https://repo.or.cz/isl.git/snapshot/$($(PKG)_FILE)
 $(PKG)_DEPS     := build-gcc gmp
 
 $(PKG)_EXTRA_MAKE_FLAGS := LDFLAGS='-no-undefined'
 
 # stick to tested versions from gcc
 define $(PKG)_UPDATE
-    $(WGET) -q -O- 'https://isl.gforge.inria.fr/' | \
-    $(SED) -n 's,.*isl-\([0-9][^>]*\)\.tar.*,\1,p' | \
+    $(WGET) -q -O- 'https://repo.or.cz/isl.git/refs' | \
+    $(SED) -n 's,.*>tags/isl-\([0-9][^<]*\).*,\1,p' | \
     $(SORT) -V |
     tail -1
 endef
 
 define $(PKG)_BUILD
-    cd '$(1)' && ./configure \
+    cd '$(1)' && ./autogen.sh && ./configure \
         $(HOST_AND_BUILD_CONFIGURE_OPTIONS) \
         $(ENABLE_SHARED_OR_STATIC) \
         --prefix='$(HOST_PREFIX)' \
--- a/src/lapack.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/lapack.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -2,8 +2,8 @@
 # See index.html for further information.
 
 PKG             := lapack
-$(PKG)_VERSION  := 3.9.0
-$(PKG)_CHECKSUM := 0451d180eed2b12b94aaae77e772d7573e87bec4
+$(PKG)_VERSION  := 3.10.0
+$(PKG)_CHECKSUM := 4a9384523bf236c83568884e8c62d9517e41ac42
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := https://github.com/Reference-LAPACK/$(PKG)/archive/v$($(PKG)_VERSION).tar.gz
--- a/src/lcms-1-fixes.patch	Wed Nov 24 18:31:48 2021 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,11 +0,0 @@
-diff -ur lcms2-2.9.orig/lcms2.pc.in lcms2-2.9/lcms2.pc.in
---- lcms2-2.9.orig/lcms2.pc.in	2017-12-04 16:39:09.491042791 -0500
-+++ lcms2-2.9/lcms2.pc.in	2017-12-04 16:40:58.941757920 -0500
-@@ -7,5 +7,6 @@
- Description: LCMS Color Management Library
- Version: @VERSION@
- Libs: -L${libdir} -llcms2
--Libs.private: @LIB_MATH@ @LIB_THREAD@
-+Libs.private: -ljpeg @LIB_MATH@ @LIB_THREAD@
- Cflags: -I${includedir}
-+Requires: libtiff-4
--- a/src/lcms.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/lcms.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := lcms
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 2.11
-$(PKG)_CHECKSUM := 7413047c74de29e20caa5c9afc1b12bf07bbf7a7
+$(PKG)_VERSION  := 2.12
+$(PKG)_CHECKSUM := 3d0c0276fcd3930b80c424512ec0b1ed54ec1497
 $(PKG)_SUBDIR   := $(PKG)$(word 1,$(subst ., ,$($(PKG)_VERSION)))-$(subst a,,$($(PKG)_VERSION))
 $(PKG)_FILE     := $(PKG)$(word 1,$(subst ., ,$($(PKG)_VERSION)))-$(subst a,,$($(PKG)_VERSION)).tar.gz
 $(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/$(PKG)/$(PKG)/$(subst a,,$($(PKG)_VERSION))/$($(PKG)_FILE)
--- a/src/libb64.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/libb64.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -18,7 +18,7 @@
 
 define $(PKG)_BUILD
 
-    CC=$(MXE_CC) CXX=$(MXE_CXX) PKG_CONFIG=$(MXE_PKG_CONFIG) AR=$(MXE_AR) $(MAKE) -C '$(1)/src'
+    CC=$(MXE_CC) CXX=$(MXE_CXX) PKG_CONFIG=$(MXE_PKG_CONFIG) AR=$(MXE_AR) CFLAGS='-fPIE' $(MAKE) -C '$(1)/src'
 
     $(INSTALL) -d '$(3)$(HOST_LIBDIR)'
     $(INSTALL) -d '$(3)$(HOST_INCDIR)/b64'
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/libbiosig-1-gcc11.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,72 @@
+Change Makefile so that the values of environment variables are respected.
+
+--- ./biosig4c++/Makefile.in.orig	2021-08-10 18:35:30.301801739 +0200
++++ ./biosig4c++/Makefile.in	2021-08-10 18:37:18.338795660 +0200
+@@ -101,6 +101,9 @@ includedir    = @includedir@
+ bindir        = @bindir@
+ mandir        = @mandir@
+ 
++CC ?= @CC@
++CXX ?= @CXX@
++
+ CFLAGS       += -I$(includedir)
+ CXXFLAGS     += $(CFLAGS)
+ 
+@@ -108,7 +111,8 @@ CXXFLAGS     += $(CFLAGS)
+ ifeq (,$(TARGET))
+ 	CC      ?= gcc
+ 	CXX     ?= g++
+-	AR      := ar rcs
++	ARFLAGS ?= rcs
++	AR      ?= ar
+ 	PKGCONF := pkg-config
+ 	SHAREDLIB = -shared
+ 	DLEXT    = so
+@@ -116,14 +120,16 @@ else ifeq (intel,$(TARGET))
+ 	CC      := icc
+ 	CXX     := icc
+ 	LD      := xild
+-	AR      := xiar crs
++	ARFLAGS ?= crs
++	AR      := xiar
+ else
+ 	PREFIX  := $(subst /bin/,/,$(dir $(shell which $(TARGET)-gcc)))
+-	CC      := $(TARGET)-gcc
+-	CXX     := $(TARGET)-g++
++	CC      ?= $(TARGET)-gcc
++	CXX     ?= $(TARGET)-g++
+ 	LD      := $(TARGET)-ld
+-	AR      := $(TARGET)-ar rcs
+-	PKGCONF := $(TARGET)-pkg-config
++	AR      ?= $(TARGET)-ar
++	ARFLAGS ?= rcs
++	PKGCONF ?= $(TARGET)-pkg-config
+ 	ifneq (,$(findstring mingw,$(TARGET)))
+ 		## add gnulib's getlogin
+ 		SOURCES += win32/getlogin.c win32/getline.c win32/getdelim.c
+@@ -136,6 +142,8 @@ else
+ 	endif
+ endif
+ 
++AR := $(AR) $(ARFLAGS)
++
+ SONAMEVERSION ?= 3
+ 
+ ### TODO: DLEXT does not work correctly on MXE/MINGW
+
+
+`typeof` is a GNU extension. Use `decltype` which is part of C++11.
+--- ./biosig4c++/t230/sopen_hl7aecg.cpp.orig	2021-08-02 18:59:57.000000000 +0200
++++ ./biosig4c++/t230/sopen_hl7aecg.cpp	2021-08-10 17:41:35.500597677 +0200
+@@ -791,8 +791,8 @@ EXTERN_C int sopen_HL7aECG_read(HDRTYPE*
+ 
+                                 if ((N+3) > N_Event) {
+                                 	N_Event = max(16,2*(N+2));
+-                                	hdr->EVENT.TYP = (typeof(hdr->EVENT.TYP)) realloc(hdr->EVENT.TYP,N_Event*sizeof(*hdr->EVENT.TYP));
+-                                	hdr->EVENT.POS = (typeof(hdr->EVENT.POS)) realloc(hdr->EVENT.POS,N_Event*sizeof(*hdr->EVENT.POS));
++                                	hdr->EVENT.TYP = (decltype(hdr->EVENT.TYP)) realloc(hdr->EVENT.TYP,N_Event*sizeof(*hdr->EVENT.TYP));
++                                	hdr->EVENT.POS = (decltype(hdr->EVENT.POS)) realloc(hdr->EVENT.POS,N_Event*sizeof(*hdr->EVENT.POS));
+                                 }
+ 
+         		        TiXmlHandle Boundary = Annotation.FirstChild("support").FirstChild("supportingROI").FirstChild("component").FirstChild("boundary").FirstChild("value");
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/libbiosig.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,63 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := libbiosig
+$(PKG)_WEBSITE  := http://biosig.sf.net/
+$(PKG)_IGNORE   :=
+$(PKG)_VERSION  := 2.3.2
+$(PKG)_CHECKSUM := 51b20ea75e927966cc14cf5d88e6cc9aa7ab06ea
+$(PKG)_SUBDIR   := biosig-$($(PKG)_VERSION)
+$(PKG)_FILE     := biosig-$($(PKG)_VERSION).src.tar.gz
+$(PKG)_URL      := https://sourceforge.net/projects/biosig/files/BioSig%20for%20C_C%2B%2B/src/$($(PKG)_FILE)
+$(PKG)_DEPS     := suitesparse zlib libb64 libiberty libiconv lapack tinyxml dcmtk
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- 'https://biosig.sourceforge.io/download.html' | \
+        $(SED) -n 's_.*>v\([0-9]\.[0-9]\.[0-9]\)<.*_\1_p' | \
+        head -1
+endef
+
+ifeq ($(MXE_WINDOWS_BUILD),yes)
+  $(PKG)_MAKE_FLAGS := TARGET=$(TARGET) CROSS=$(TARGET)
+  $(PKG)_AUTOCONF_CROSS_FLAGS := \
+    ac_cv_func_malloc_0_nonnull=yes \
+    ac_cv_func_realloc_0_nonnull=yes
+else
+  $(PKG)_MAKE_FLAGS := \
+  LDLIBS='-liconv -lm -ltinyxml'
+endif
+
+$(PKG)_MAKE_FLAGS += \
+  CC='$(MXE_CC)' \
+  CXX='$(MXE_CXX) -std=c++14' \
+  RANLIB='$(MXE_RANLIB)' \
+  AR='$(MXE_AR)' \
+  ARFLAGS=rcs \
+  LDFLAGS=$(MXE_LDFLAGS) \
+  CFLAGS=$(MXE_CFLAGS)
+
+
+define $(PKG)_BUILD
+  cd '$(1)' && ./configure \
+    $(HOST_AND_BUILD_CONFIGURE_OPTIONS) \
+    $($(PKG)_AUTOCONF_CROSS_FLAGS) \
+    --prefix=$(HOST_PREFIX) \
+    $($(PKG)_MAKE_FLAGS) \
+    LIBTOOL=$(LIBTOOL) \
+    PKG_CONFIG='$(MXE_PKG_CONFIG)' \
+    PKG_CONFIG_PATH='$(HOST_LIBDIR)/pkgconfig'
+
+  # make sure NDEBUG is defined
+  $(SED) -i '/NDEBUG/ s|#||g' '$(1)'/biosig4c++/Makefile
+
+  $($(PKG)_MAKE_FLAGS) $(MAKE) -C '$(1)/biosig4c++' lib tools
+  $($(PKG)_MAKE_FLAGS) $(MAKE) -C '$(1)/biosig4c++' install DESTDIR='$(3)'
+
+  # FIXME: These files should be installed by the Makefile rule.
+  if [ "x$(MXE_SYSTEM)" == "xmingw" ]; then \
+    $(INSTALL) '$(1)/biosig4c++/libbiosig.dll.a' '$(3)$(HOST_LIBDIR)'; \
+    $(INSTALL) '$(1)/biosig4c++/libphysicalunits.dll' '$(3)$(HOST_BINDIR)'; \
+    $(INSTALL) '$(1)/biosig4c++/libphysicalunits.dll.a' '$(3)$(HOST_LIBDIR)'; \
+  fi
+endef
+
--- a/src/libffi.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/libffi.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,31 +3,34 @@
 
 PKG             := libffi
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 3.3
-$(PKG)_CHECKSUM := 8df6cb570c8d6596a67d1c0773bf00650154f7aa
+$(PKG)_VERSION  := 3.4.2
+$(PKG)_CHECKSUM := f5fbf0e8b643c4029a069faca32dd0df2c7dd0a2
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
-$(PKG)_URL      := ftp://sourceware.org/pub/$(PKG)/$($(PKG)_FILE)
+$(PKG)_URL      := https://github.com/$(PKG)/$(PKG)/archive/refs/tags/v$($(PKG)_VERSION).tar.gz
 $(PKG)_DEPS     :=
 
 define $(PKG)_UPDATE
-    $(WGET) -q -O- 'https://github.com/atgreen/libffi/tags' | \
+    $(WGET) -q -O- 'https://github.com/libffi/libffi/tags' | \
     $(SED) -n 's,.*releases/tag/v\([0-9][^"]*\).*,\1,p' | \
     head -1
 endef
 
 define $(PKG)_BUILD
-    cd '$(1)' && ./configure \
-        $(HOST_AND_BUILD_CONFIGURE_OPTIONS) \
-        --prefix='$(HOST_PREFIX)' \
-        $(CONFIGURE_CPPFLAGS) $(CONFIGURE_LDFLAGS) \
-        $(ENABLE_SHARED_OR_STATIC) \
-	&& $(CONFIGURE_POST_HOOK)
-    $(MAKE) -C '$(1)/$(TARGET)' -j '$(JOBS)'
-    $(MAKE) -C '$(1)/$(TARGET)' -j 1 install DESTDIR='$(3)' 
+  cd '$(1)' && \
+    ./autogen.sh && \
+    ./configure \
+      $(HOST_AND_BUILD_CONFIGURE_OPTIONS) \
+      --prefix='$(HOST_PREFIX)' \
+      $(CONFIGURE_CPPFLAGS) $(CONFIGURE_LDFLAGS) \
+      $(ENABLE_SHARED_OR_STATIC) && \
+    $(CONFIGURE_POST_HOOK)
 
-    if [ "$(ENABLE_DEP_DOCS)" == "no" ]; then \
-      rm -rf "$(3)$(HOST_PREFIX)/share"; \
-    fi
+  $(MAKE) -C '$(1)/$(TARGET)' -j '$(JOBS)'
+  $(MAKE) -C '$(1)/$(TARGET)' -j 1 install DESTDIR='$(3)' 
+
+  if [ "$(ENABLE_DEP_DOCS)" == "no" ]; then \
+    rm -rf "$(3)$(HOST_PREFIX)/share"; \
+  fi
 
 endef
--- a/src/libgcrypt.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/libgcrypt.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := libgcrypt
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 1.8.6
-$(PKG)_CHECKSUM := 406b02873833427898d16bcc8483bc5c91c73d4a
+$(PKG)_VERSION  := 1.9.4
+$(PKG)_CHECKSUM := 1bccc8393482fa1953323ff429c6b5ba5676eb1a
 $(PKG)_SUBDIR   := libgcrypt-$($(PKG)_VERSION)
 $(PKG)_FILE     := libgcrypt-$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := ftp://ftp.gnupg.org/gcrypt/libgcrypt/$($(PKG)_FILE)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/libgomp-1-fixes.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,41 @@
+diff -ur gcc-10.2.0.orig/libgomp/libgomp.h gcc-10.2.0/libgomp/libgomp.h
+--- gcc-10.2.0.orig/libgomp/libgomp.h	2021-05-12 11:35:02.852122961 -0400
++++ gcc-10.2.0/libgomp/libgomp.h	2021-05-12 11:37:05.593912873 -0400
+@@ -69,6 +69,14 @@
+ # endif
+ #endif
+ 
++#include <stdio.h>
++#include <stdio.h>
++#ifdef __MINGW_PRINTF_FORMAT
++#define PRINTF_FORMAT __MINGW_PRINTF_FORMAT
++#else
++#define PRINTF_FORMAT printf
++#endif
++
+ #ifdef HAVE_ATTRIBUTE_VISIBILITY
+ # pragma GCC visibility push(hidden)
+ #endif
+@@ -173,7 +181,7 @@
+ 
+ extern void gomp_vdebug (int, const char *, va_list);
+ extern void gomp_debug (int, const char *, ...)
+-	__attribute__ ((format (printf, 2, 3)));
++	__attribute__ ((format (PRINTF_FORMAT, 2, 3)));
+ #define gomp_vdebug(KIND, FMT, VALIST) \
+   do { \
+     if (__builtin_expect (gomp_debug_var, 0)) \
+@@ -186,11 +194,11 @@
+   } while (0)
+ extern void gomp_verror (const char *, va_list);
+ extern void gomp_error (const char *, ...)
+-	__attribute__ ((format (printf, 1, 2)));
++	__attribute__ ((format (PRINTF_FORMAT, 1, 2)));
+ extern void gomp_vfatal (const char *, va_list)
+ 	__attribute__ ((noreturn));
+ extern void gomp_fatal (const char *, ...)
+-	__attribute__ ((noreturn, format (printf, 1, 2)));
++	__attribute__ ((noreturn, format (PRINTF_FORMAT, 1, 2)));
+ 
+ struct gomp_task;
+ struct gomp_taskgroup;
--- a/src/libgpg_error.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/libgpg_error.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := libgpg_error
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 1.39
-$(PKG)_CHECKSUM := 991a7a53e778a3de5ba8aad711e0bc9453101f4b
+$(PKG)_VERSION  := 1.43
+$(PKG)_CHECKSUM := e71b77e8e32023dfd9cb06504942aa8e028c8795
 $(PKG)_SUBDIR   := libgpg-error-$($(PKG)_VERSION)
 $(PKG)_FILE     := libgpg-error-$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := ftp://ftp.gnupg.org/gcrypt/libgpg-error/$($(PKG)_FILE)
--- a/src/libharu.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/libharu.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -12,7 +12,7 @@
 
 define $(PKG)_UPDATE
     $(WGET) -q -O- 'https://github.com/libharu/libharu/tags' | \
-    $(SED) -n 's,.*/archive/RELEASE_\([0-9][^"]*\)\.tar.*,\1,p' | \
+    $(SED) -n 's,.*/tags/RELEASE_\([0-9][^"]*\)\.tar.*,\1,p' | \
     $(SED) 's,_,.,g' | \
     grep -v 'RC' | \
     head -1
--- a/src/libidn2.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/libidn2.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := libidn2
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 2.3.0
-$(PKG)_CHECKSUM := 53f54fd3c305d871ed5716406c0695fad5c34c45
+$(PKG)_VERSION  := 2.3.2
+$(PKG)_CHECKSUM := 0a01fca61ab09f5ab3f2d7fa968d3276133f03d7
 $(PKG)_SUBDIR   := libidn2-$($(PKG)_VERSION)
 $(PKG)_FILE     := libidn2-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := ftp://ftp.gnu.org/gnu/libidn/$($(PKG)_FILE)
--- a/src/libproxy.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/libproxy.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,11 +3,11 @@
 
 PKG             := libproxy
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 0.4.15
-$(PKG)_CHECKSUM := 5261bf6875feef15a706b34e7c010619f484e92f
+$(PKG)_VERSION  := 0.4.17
+$(PKG)_CHECKSUM := cded2be341aa15bb1dc4ba574c0687e2ba8d59b2
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
-$(PKG)_FILE     := $($(PKG)_SUBDIR).tar.xz
-$(PKG)_URL      := https://github.com/libproxy/libproxy/releases/download/$($(PKG)_VERSION)/$($(PKG)_FILE)
+$(PKG)_FILE     := $($(PKG)_SUBDIR).tar.gz
+$(PKG)_URL      := https://github.com/libproxy/libproxy/archive/$($(PKG)_VERSION).tar.gz
 $(PKG)_DEPS     :=
 
 $(PKG)_CMAKE_FLAGS :=
--- a/src/libsndfile.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/libsndfile.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,38 +3,37 @@
 
 PKG             := libsndfile
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 1.0.28
-$(PKG)_CHECKSUM := 85aa967e19f6b9bf975601d79669025e5f8bc77d
+$(PKG)_VERSION  := 1.0.31
+$(PKG)_CHECKSUM := 4ada136ae38b08a7f17160f44ca9f0d85d53da50
 $(PKG)_SUBDIR   := libsndfile-$($(PKG)_VERSION)
 $(PKG)_FILE     := libsndfile-$($(PKG)_VERSION).tar.gz
-$(PKG)_URL      := http://www.mega-nerd.com/libsndfile/files/$($(PKG)_FILE)
-$(PKG)_DEPS     := sqlite flac ogg vorbis
+$(PKG)_URL      := https://github.com/$(PKG)/$(PKG)/archive/$($(PKG)_VERSION).tar.gz
+$(PKG)_DEPS     := sqlite flac ogg opus vorbis
 
 define $(PKG)_UPDATE
-    $(WGET) -q -O- 'http://www.mega-nerd.com/libsndfile/' | \
-    grep '<META NAME="Version"' | \
-    $(SED) -n 's,.*CONTENT="libsndfile-\([0-9][^"]*\)">.*,\1,p' | \
-    head -1
+    $(WGET) -q -O- 'https://github.com/libsndfile/libsndfile/tags' | \
+    $(SED) -n 's|.*releases/tag/[v]*\([^"]*\).*|\1|p' | $(SORT) -V | \
+    tail -1
 endef
 
-$(PKG)_EXTRA_CONFIGURE_OPTIONS :=
-ifneq ($(filter mingw msvc,$(MXE_SYSTEM)),)
-    $(PKG)_EXTRA_CONFIGURE_OPTIONS += --enable-stack-smash-protection
-endif
+define $(PKG)_BUILD
+    cd '$(1)' && cmake \
+        $($(PKG)_CMAKE_FLAGS) \
+        -DBUILD_TESTING=no \
+        -DBUILD_PROGRAMS=no \
+        -DBUILD_EXAMPLES=no \
+        -DINSTALL_MANPAGES=no \
+        -DENABLE_EXTERNAL_LIBS=yes \
+        $(CMAKE_CCACHE_FLAGS) \
+        $(CMAKE_BUILD_SHARED_OR_STATIC) \
+        -DCMAKE_TOOLCHAIN_FILE='$(CMAKE_TOOLCHAIN_FILE)' \
+        .
 
-define $(PKG)_BUILD
-    cd '$(1)' && autoreconf -fi -IM4
-    cd '$(1)' && ./configure \
-        $(HOST_AND_BUILD_CONFIGURE_OPTIONS) \
-        $(ENABLE_SHARED_OR_STATIC) \
-        --prefix='$(HOST_PREFIX)' \
-	$(CONFIGURE_CPPFLAGS) $(CONFIGURE_LDFLAGS) \
-        --enable-sqlite \
-        --enable-external-libs \
-        --disable-octave \
-        --disable-alsa \
-	--disable-full-suite \
-        $($(PKG)_EXTRA_CONFIGURE_OPTIONS)
-    $(MAKE) -C '$(1)' -j '$(JOBS)' $(MXE_DISABLE_PROGS)  $(MXE_DISABLE_DOCS)
-    $(MAKE) -C '$(1)' -j 1 install $(MXE_DISABLE_PROGS)  $(MXE_DISABLE_DOCS) DESTDIR='$(3)'
+    $(MAKE) -C '$(1)' -j '$(JOBS)' VERBOSE=1
+    $(MAKE) -C '$(1)' -j '1' VERBOSE=1 DESTDIR='$(3)' install
+
+    if [ "$(ENABLE_DEP_DOCS)" == "no" ]; then \
+        rm -rf '$(3)$(HOST_PREFIX)/share/doc/$(PKG)'; \
+    fi
+
 endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/libsodium.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,34 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := libsodium
+$(PKG)_IGNORE   :=
+$(PKG)_VERSION  := 1.0.18
+$(PKG)_CHECKSUM := cd8a76b79aeb077e8d3eea478ea6241972593dfd
+$(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
+$(PKG)_FILE     := $($(PKG)_SUBDIR).tar.gz
+$(PKG)_URL      := https://github.com/jedisct1/$(PKG)/archive/$($(PKG)_VERSION).tar.gz
+$(PKG)_DEPS     :=
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- 'https://github.com/jedisct1/libsodium/tags' | \
+    $(SED) -n 's|.*releases/tag/\([^"]*\).*|\1|p' | $(SORT) -V | \
+    tail -1
+endef
+
+$(PKG)_EXTRA_CONFIGURE_OPTIONS :=
+ifneq ($(filter mingw msvc,$(MXE_SYSTEM)),)
+    $(PKG)_EXTRA_CONFIGURE_OPTIONS += CFLAGS="-O2 -g -fstack-protector"
+endif
+
+define $(PKG)_BUILD
+    cd '$(1)' && ./autogen.sh \
+    cd '$(1)' && ./configure \
+        $(HOST_AND_BUILD_CONFIGURE_OPTIONS) \
+        --prefix='$(HOST_PREFIX)' \
+        $($(PKG)_EXTRA_CONFIGURE_OPTIONS) \
+        $(ENABLE_SHARED_OR_STATIC) 
+
+    $(MAKE) -C '$(1)' -j '$(JOBS)'
+    $(MAKE) -C '$(1)' -j 1 install DESTDIR='$(3)' $(MXE_DISABLE_PROGS) $(MXE_DISABLE_DOCS)
+endef
--- a/src/libssh2.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/libssh2.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,22 +3,21 @@
 
 PKG             := libssh2
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 1.9.0
-$(PKG)_CHECKSUM := 21e98282b103307a16792e5e2d4c99beaf0b3b9c
+$(PKG)_VERSION  := 1.10.0
+$(PKG)_CHECKSUM := 2ebb3bc5c944090ade840f3a0ada9874eced979b
 $(PKG)_SUBDIR   := libssh2-$($(PKG)_VERSION)
 $(PKG)_FILE     := libssh2-$($(PKG)_VERSION).tar.gz
-$(PKG)_URL      := http://www.libssh2.org/download/$($(PKG)_FILE)
+$(PKG)_URL      := https://www.libssh2.org/download/$($(PKG)_FILE)
 $(PKG)_DEPS     := libgcrypt zlib
 
 define $(PKG)_UPDATE
-    $(WGET) -q -O- 'http://www.libssh2.org/download/?C=M;O=D' | \
+    $(WGET) -q -O- 'https://www.libssh2.org/download/?C=M;O=D' | \
     grep 'libssh2-' | \
     $(SED) -n 's,.*libssh2-\([0-9][^>]*\)\.tar.*,\1,p' | \
     head -1
 endef
 
 define $(PKG)_BUILD
-    cd '$(1)' && ./buildconf
     cd '$(1)' && ./configure \
         $(CONFIGURE_CPPFLAGS) $(CONFIGURE_LDFLAGS) \
         $(HOST_AND_BUILD_CONFIGURE_OPTIONS) \
@@ -30,9 +29,4 @@
         PKG_CONFIG='$(MXE_PKG_CONFIG)' && $(CONFIGURE_POST_HOOK)
     $(MAKE) -C '$(1)' -j '$(JOBS)' install $(MXE_DISABLE_PROGS) $(MXE_DISABLE_DOCS) DESTDIR='$(3)'
 
-##    '$(MXE_CC)' \
-##        -W -Wall -Werror -ansi -pedantic \
-##        '$(2).c' -o '$(HOST_BINDIR)/test-libssh2.exe' \
-##        `'$(MXE_PKG_CONFIG)' --cflags --libs libssh2`
-
 endef
--- a/src/libtasn1.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/libtasn1.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -1,8 +1,8 @@
 # This file is part of MXE. See LICENSE.md for licensing information.
 
 PKG             := libtasn1
-$(PKG)_VERSION  := 4.16.0
-$(PKG)_CHECKSUM := f4f1fc301c0835389d9db7754815e48f4f57937a
+$(PKG)_VERSION  := 4.18.0
+$(PKG)_CHECKSUM := 1665249ce66e64958e8c61d5bdc6c1e9f3623888
 $(PKG)_SUBDIR   := libtasn1-$($(PKG)_VERSION)
 $(PKG)_FILE     := libtasn1-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := https://ftp.gnu.org/gnu/libtasn1/$($(PKG)_FILE)
--- a/src/libxml2.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/libxml2.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := libxml2
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 2.9.10
-$(PKG)_CHECKSUM := db6592ec9ca9708c4e71bf6bfd907bbb5cd40644
+$(PKG)_VERSION  := 2.9.12
+$(PKG)_CHECKSUM := 339fe5bb2a7d0c13f068c26d8f7cd194c13f9a2a
 $(PKG)_SUBDIR   := libxml2-$($(PKG)_VERSION)
 $(PKG)_FILE     := libxml2-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := ftp://xmlsoft.org/libxml2/$($(PKG)_FILE)
--- a/src/llvm-1-llvm-config.patch	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/llvm-1-llvm-config.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -17,11 +17,10 @@
  /* Major version of the LLVM API */
  #define LLVM_VERSION_MAJOR ${LLVM_VERSION_MAJOR}
  
-diff --git "a/tools/llvm-config/llvm-config.cpp" "b/tools/llvm-config/llvm-config.cpp"
-index bec89fe..a1be375 100644
---- "a/tools/llvm-config/llvm-config.cpp"	
-+++ "b/tools/llvm-config/llvm-config.cpp"
-@@ -37,7 +37,12 @@ using namespace llvm;
+diff -up "./tools/llvm-config/llvm-config.cpp.orig" "./tools/llvm-config/llvm-config.cpp"
+--- ./tools/llvm-config/llvm-config.cpp.orig	2021-06-28 18:23:38.000000000 +0200
++++ ./tools/llvm-config/llvm-config.cpp	2021-07-19 17:23:35.059439097 +0200
+@@ -36,7 +36,12 @@ using namespace llvm;
  
  // Include the build time variables we can report to the user. This is generated
  // at build time from the BuildVariables.inc.in file by the build system.
@@ -35,9 +34,9 @@
  
  // Include the component table. This creates an array of struct
  // AvailableComponent entries, which record the component name, library name,
-@@ -352,14 +352,16 @@ int main(int argc, char **argv) {
-   StringRef SharedExt, SharedVersionedExt, SharedDir, SharedPrefix, StaticExt,
-       StaticPrefix, StaticDir = "lib", DirSep = "/";
+@@ -377,15 +382,17 @@ int main(int argc, char **argv) {
+       StaticPrefix, StaticDir = "lib";
+   std::string DirSep = "/";
    const Triple HostTriple(Triple::normalize(LLVM_HOST_TRIPLE));
 -  if (HostTriple.isOSWindows()) {
 +  const Triple TargetTriple(Triple::normalize(LLVM_DEFAULT_TARGET_TRIPLE));
@@ -46,6 +45,7 @@
      SharedVersionedExt = LLVM_DYLIB_VERSION ".dll";
 -    if (HostTriple.isOSCygMing()) {
 +    if (TargetTriple.isOSCygMing()) {
+       SharedPrefix = "lib";
        StaticExt = "a";
        StaticPrefix = "lib";
      } else {
@@ -54,7 +54,7 @@
        DirSep = "\\";
        std::replace(ActiveObjRoot.begin(), ActiveObjRoot.end(), '/', '\\');
        std::replace(ActivePrefix.begin(), ActivePrefix.end(), '/', '\\');
-@@ -368,10 +370,11 @@ int main(int argc, char **argv) {
+@@ -394,10 +401,11 @@ int main(int argc, char **argv) {
        std::replace(ActiveCMakeDir.begin(), ActiveCMakeDir.end(), '/', '\\');
        std::replace(ActiveIncludeOption.begin(), ActiveIncludeOption.end(), '/',
                     '\\');
@@ -67,7 +67,7 @@
      SharedExt = "dylib";
      SharedVersionedExt = LLVM_DYLIB_VERSION ".dylib";
      StaticExt = "a";
-@@ -670,7 +673,7 @@ int main(int argc, char **argv) {
+@@ -694,7 +703,7 @@ int main(int argc, char **argv) {
          } else if (PrintLibs) {
            // On Windows, output full path to library without parameters.
            // Elsewhere, if this is a typical library name, include it using -l.
--- a/src/llvm.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/llvm.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,12 +3,12 @@
 
 PKG             := llvm
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 7.1.0
-$(PKG)_CHECKSUM := d43bfea58a35e058b93a6af36a728cfc64add33d
+$(PKG)_VERSION  := 12.0.1
+$(PKG)_CHECKSUM := 619fe668e0972d11d0fa2db670a57a42d02fb8ca
 $(PKG)_SUBDIR   := llvm-$($(PKG)_VERSION).src
 $(PKG)_FILE     := llvm-$($(PKG)_VERSION).src.tar.xz
 $(PKG)_URL      := https://github.com/llvm/llvm-project/releases/download/llvmorg-$($(PKG)_VERSION)/$($(PKG)_FILE)
-$(PKG)_DEPS     := build-python
+$(PKG)_DEPS     := build-cmake build-ninja build-python
 
 define $(PKG)_UPDATE
     wget -q -O- 'http://releases.llvm.org/download.html?' | \
@@ -21,6 +21,7 @@
     ifeq ($(MXE_SYSTEM),gnu-linux)
         define $(PKG)_BUILD
             mkdir '$(1)/.build' && cd '$(1)/.build' && cmake .. \
+                -GNinja \
                 $($(PKG)_CMAKE_FLAGS) \
                 $(CMAKE_CCACHE_FLAGS) \
                 -DCMAKE_TOOLCHAIN_FILE='$(CMAKE_TOOLCHAIN_FILE)' \
@@ -40,7 +41,7 @@
                 -DLLVM_ENABLE_DOXYGEN=OFF \
                 -DLLVM_ENABLE_BACKTRACES=OFF
 
-            $(MAKE) -C '$(1)/.build' -j '$(JOBS)' install DESTDIR='$(3)'
+            cd '$(1)/.build' && DESTDIR=$(3) ninja -j $(JOBS) install
         endef
     else
         define $(PKG)_BUILD
@@ -64,6 +65,7 @@
     define $(PKG)_BUILD
         mkdir '$(1)/.build'
         cd '$(1)/.build' && 'cmake' .. \
+            -GNinja \
             $($(PKG)_CMAKE_FLAGS) \
             $(CMAKE_CCACHE_FLAGS) \
             -DCMAKE_TOOLCHAIN_FILE='$(CMAKE_TOOLCHAIN_FILE)' \
@@ -93,14 +95,11 @@
             -DLLVM_INCLUDE_RUNTIMES=OFF \
             $($(PKG)_CCACHE_OPTIONS)
 
-        $(MAKE) -C '$(1)/.build' -j $(JOBS) LLVMSupport
-        $(MAKE) -C '$(1)/.build' -j $(JOBS) CONFIGURE_LLVM_NATIVE
-        $(MAKE) -C '$(1)/.build/NATIVE' -j $(JOBS) LLVMSupport
-        $(MAKE) -C '$(1)/.build' -j $(JOBS) llvm-config
-        $(MAKE) -C '$(1)/.build' -j $(JOBS) install DESTDIR='$(3)'
+        cd '$(1)/.build' && DESTDIR=$(3) ninja -j $(JOBS) llvm-config
+        cd '$(1)/.build' && DESTDIR=$(3) ninja -j $(JOBS) install
 
         # create symlink for shared library so that llvm-config can find it
-        cd '$(3)/$(HOST_BINDIR)' && ln -s LLVM.dll LLVM-$(word 1,$(subst ., ,$($(PKG)_VERSION))).$(word 2,$(subst ., ,$($(PKG)_VERSION))).dll
+        cd '$(3)/$(HOST_BINDIR)' && ln -s libLLVM.dll LLVM-$(word 1,$(subst ., ,$($(PKG)_VERSION))).dll
 
         # install native llvm-config in HOST_BINDIR because it won't find the libs otherwise
         $(INSTALL) -d '$(HOST_BINDIR)'
--- a/src/lua.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/lua.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := lua
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 5.3.5
-$(PKG)_CHECKSUM := 112eb10ff04d1b4c9898e121d6bdf54a81482447
+$(PKG)_VERSION  := 5.4.3
+$(PKG)_CHECKSUM := 1dda2ef23a9828492b4595c0197766de6e784bc7
 $(PKG)_SUBDIR   := lua-$($(PKG)_VERSION)
 $(PKG)_FILE     := lua-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://www.lua.org/ftp/$($(PKG)_FILE)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mesa-2-ucrt.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,62 @@
+From a3b60fc23f2968e2d22c8d46baf29d4cd90b0d5c Mon Sep 17 00:00:00 2001
+From: Jeremy Drake <github@jdrake.com>
+Date: Sat, 16 Oct 2021 16:50:46 -0700
+Subject: [PATCH] mesa: fixes for UCRT.
+
+--- mesa-21.2.4/meson.build.orig	2021-10-16 16:02:38.021997300 -0700
++++ mesa-21.2.4/meson.build	2021-10-16 16:03:24.287545400 -0700
+@@ -1046,8 +1046,6 @@
+       '-D_HAS_EXCEPTIONS=0', # Tell C++ STL to not use exceptions
+       '-DNOMINMAX',
+     ]
+-  else
+-    pre_args += ['-D__MSVCRT_VERSION__=0x0700']
+   endif
+ elif host_machine.system() == 'openbsd'
+   pre_args += '-D_ISOC11_SOURCE'
+--- mesa-21.2.4/src/compiler/spirv/vtn_private.h.orig	2021-10-16 15:28:02.537761600 -0700
++++ mesa-21.2.4/src/compiler/spirv/vtn_private.h	2021-10-16 15:28:05.959391400 -0700
+@@ -41,7 +41,7 @@
+ struct vtn_decoration;
+ 
+ /* setjmp/longjmp is broken on MinGW: https://sourceforge.net/p/mingw-w64/bugs/406/ */
+-#ifdef __MINGW32__
++#if defined(__MINGW32__) && !defined(_UCRT)
+   #define vtn_setjmp __builtin_setjmp
+   #define vtn_longjmp __builtin_longjmp
+ #else
+--- mesa-21.2.4/src/compiler/nir/nir.h.orig	2021-10-14 12:59:05.367845000 -0700
++++ mesa-21.2.4/src/compiler/nir/nir.h	2021-10-16 15:55:09.881268400 -0700
+@@ -54,7 +54,7 @@
+ 
+ #include "nir_opcodes.h"
+ 
+-#if defined(_WIN32) && !defined(snprintf)
++#if defined(_WIN32) && !defined(snprintf) && !defined(_UCRT)
+ #define snprintf _snprintf
+ #endif
+ 
+--- mesa-21.2.4/src/compiler/nir/nir_lower_atomics_to_ssbo.c.orig	2021-10-14 12:59:05.375845200 -0700
++++ mesa-21.2.4/src/compiler/nir/nir_lower_atomics_to_ssbo.c	2021-10-16 15:55:30.818804300 -0700
+@@ -27,10 +27,6 @@
+ #include "nir.h"
+ #include "nir_builder.h"
+ 
+-#if defined(_WIN32) && !defined(snprintf)
+-#define snprintf _snprintf
+-#endif
+-
+ /*
+  * Remap atomic counters to SSBOs, starting from the shader's next SSBO slot
+  * (info.num_ssbos).
+--- mesa-21.2.4/src/gallium/drivers/swr/swr_fence.cpp.orig	2021-10-16 16:29:10.287533700 -0700
++++ mesa-21.2.4/src/gallium/drivers/swr/swr_fence.cpp	2021-10-16 16:29:45.678206500 -0700
+@@ -29,7 +29,7 @@
+ #include "swr_screen.h"
+ #include "swr_fence.h"
+ 
+-#ifdef __APPLE__
++#if defined(__APPLE__) || defined(__MINGW32__)
+ #include <sched.h>
+ #endif
+ 
--- a/src/mesa.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/mesa.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -2,8 +2,8 @@
 # See index.html for further information.
 
 PKG             := mesa
-$(PKG)_VERSION  := 20.1.10
-$(PKG)_CHECKSUM := 151d5edff5caeead98f428698cf02ddb0cf66d4b
+$(PKG)_VERSION  := 21.1.8
+$(PKG)_CHECKSUM := bb184edbff2f7e9f1705532349a49bd1f53cb631
 $(PKG)_SUBDIR   := mesa-$($(PKG)_VERSION)
 $(PKG)_FILE     := mesa-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := ftp://ftp.freedesktop.org/pub/mesa/$($(PKG)_FILE)
@@ -26,6 +26,7 @@
 else
   ifeq ($(USE_SYSTEM_X11_LIBS),no)
     $(PKG)_DEPS += dri2proto glproto libdrm libxshmfence x11 xdamage xext xfixes
+    $(PKG)_BUILD_X11_LIBS_FLAGS = -Dxlib-lease=disabled
   else
     $(PKG)_PKG_CONFIG_PATH := $(PKG_CONFIG_PATH):$(BUILD_PKG_CONFIG_PATH)
   endif
@@ -36,7 +37,8 @@
 
   $(PKG)_X11_FLAGS := -Dplatforms='x11' \
       -Dglx=gallium-xlib \
-      -Ddri-drivers=''
+      -Ddri-drivers='' \
+      $($(PKG)_BUILD_X11_LIBS_FLAGS)
 endif
 
 define $(PKG)_BUILD
@@ -47,11 +49,17 @@
       $($(PKG)_X11_FLAGS) \
       -Dgallium-drivers=swrast \
       -Dvulkan-drivers='' \
-      -Degl=false \
-      -Dgbm=false \
-      -Dshared-llvm=true
+      -Degl=disabled \
+      -Dgbm=disabled \
+      -Dshared-llvm=enabled
 
   cd '$(1)/.build' && DESTDIR=$(3) ninja -j $(JOBS) install
+
+  #  install headers
+  for i in EGL GLES GLES2 GLES3 KHR; do \
+      $(INSTALL) -d "$(HOST_INCDIR)/$$i"; \
+      $(INSTALL) -m 644 "$(1)/include/$$i/"* "$(HOST_INCDIR)/$$i/"; \
+  done
   
   # opengl32.dll.a shadows libopengl32.a from mingw. They export slightly
   # different symbols which causes problems for some packages. So don't install
--- a/src/mingw-blas-1-xerbla.patch	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/mingw-blas-1-xerbla.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -1,47 +1,46 @@
 diff -uNr a/Makefile b/Makefile
---- a/Makefile	2017-11-15 00:39:21.000000000 -0500
-+++ b/Makefile	2018-06-20 09:55:02.049803368 -0400
-@@ -55,8 +55,8 @@
- #
- #######################################################################
+--- a/Makefile	2021-11-25 18:50:29.908859992 +0100
++++ b/Makefile	2021-11-25 18:54:00.741901186 +0100
+@@ -64,7 +64,7 @@
+ 	$(FC) $(FFLAGS) -c -o $@ $<
  
+ .PHONY: all
 -all: $(BLASLIB)
-- 
 +all: $(BLASLIB) $(XERBLALIB)
-+
- #---------------------------------------------------------
- #  Comment out the next 6 definitions if you already have
- #  the Level 1 BLAS.
-@@ -88,9 +88,11 @@
+ 
+ .PHONY: blas
+ blas: $(BLASLIB)
+@@ -104,9 +104,11 @@
  #  Level 2 and Level 3 BLAS.  Comment it out only if you already have
  #  both the Level 2 and 3 BLAS.
  #---------------------------------------------------------------------
--ALLBLAS  = lsame.o xerbla.o xerbla_array.o
-+ALLBLAS  = lsame.o xerbla_array.o
- $(ALLBLAS) : $(FRC)
+-ALLBLAS = lsame.o xerbla.o xerbla_array.o
++ALLBLAS = lsame.o xerbla_array.o
+ $(ALLBLAS): $(FRC)
  
 +XERBLA = xerbla.o
 +
  #---------------------------------------------------------
  #  Comment out the next 4 definitions if you already have
  #  the Level 2 BLAS.
-@@ -137,10 +139,16 @@
- 	$(CBLAS1) $(CBLAS2) $(CBLAS3) $(ZBLAS1) 	\
+@@ -153,10 +155,16 @@
+ 	$(CBLAS1) $(CBLAS2) $(CBLAS3) $(ZBLAS1) \
  	$(ZBLAS2) $(ZBLAS3) $(ALLBLAS)
  
 +XERBLAOBJ=$(XERBLA)
 +
  $(BLASLIB): $(ALLOBJ)
- 	$(ARCH) $(ARCHFLAGS) $@ $(ALLOBJ)
+ 	$(AR) $(ARFLAGS) $@ $^
  	$(RANLIB) $@
  
 +$(XERBLALIB): $(XERBLAOBJ)
-+	$(ARCH) $(ARCHFLAGS) $@ $(XERBLAOBJ)
++	$(AR) $(ARFLAGS) $@ $^
 +	$(RANLIB) $@
 +
+ .PHONY: single double complex complex16
  single: $(SBLAS1) $(ALLBLAS) $(SBLAS2) $(SBLAS3)
- 	$(ARCH) $(ARCHFLAGS) $(BLASLIB) $(SBLAS1) $(ALLBLAS) \
- 	$(SBLAS2) $(SBLAS3)
+ 	$(AR) $(ARFLAGS) $(BLASLIB) $^
+
 diff -uNr a/make.inc b/make.inc
 --- a/make.inc	2011-04-19 15:08:00.000000000 -0400
 +++ b/make.inc	2018-06-20 09:55:18.185059266 -0400
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mingw-graphicsmagick-1-dcraw.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,10336 @@
+Fork of dcraw from upstream graphicsmagick:
+http://hg.code.sf.net/p/graphicsmagick/code/file/tip/dcraw
+
+diff -ruN graphicsmagick_orig/dcraw/dcraw.c graphicsmagick/dcraw/dcraw.c
+--- graphicsmagick_orig/dcraw/dcraw.c	1970-01-01 01:00:00.000000000 +0100
++++ graphicsmagick/dcraw/dcraw.c	2021-06-04 12:17:20.422559688 +0200
+@@ -0,0 +1,10293 @@
++/*
++   dcraw.c -- Dave Coffin's raw photo decoder
++   Copyright 1997-2016 by Dave Coffin, dcoffin a cybercom o net
++
++   This is a command-line ANSI C program to convert raw photos from
++   any digital camera on any computer running any operating system.
++
++   No license is required to download and use dcraw.c.  However,
++   to lawfully redistribute dcraw, you must either (a) offer, at
++   no extra charge, full source code* for all executable files
++   containing RESTRICTED functions, (b) distribute this code under
++   the GPL Version 2 or later, (c) remove all RESTRICTED functions,
++   re-implement them, or copy them from an earlier, unrestricted
++   Revision of dcraw.c, or (d) purchase a license from the author.
++
++   The functions that process Foveon images have been RESTRICTED
++   since Revision 1.237.  All other code remains free for all uses.
++
++   *If you have not modified dcraw.c in any way, a link to my
++   homepage qualifies as "full source code".
++
++   $Revision: 1.477 $
++   $Date: 2016/05/10 21:30:43 $
++ */
++
++#define DCRAW_VERSION "9.27"
++
++#if defined(_VISUALC_)
++# pragma warning(disable : 4005)
++# pragma warning(disable : 4133)
++# pragma warning(disable : 4146)
++# pragma warning(disable : 4305)
++#if defined(WIN64)
++#  pragma warning(disable : 4267) /* conversion from 'size_t' to 'foo', possible loss of data */
++#endif
++#endif
++
++#ifndef _GNU_SOURCE
++#define _GNU_SOURCE
++#endif
++#define _USE_MATH_DEFINES
++#define WIN32_LEAN_AND_MEAN
++#define VC_EXTRALEAN
++#include <ctype.h>
++#include <errno.h>
++#include <fcntl.h>
++#include <float.h>
++#include <limits.h>
++#include <math.h>
++#include <setjmp.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <time.h>
++#include <sys/types.h>
++
++#if !defined(__WIN32__) && (defined(_WIN32) || defined(WIN32) || defined(_WIN64))
++#define __WIN32__
++#endif
++
++#if defined(DJGPP) || defined(__MINGW32__) || defined(__WIN32__)
++#define fseeko fseek
++#define ftello ftell
++#else
++#define fgetc getc_unlocked
++#endif
++#ifdef __CYGWIN__
++#include <io.h>
++#endif
++#ifdef __WIN32__
++#include <sys/utime.h>
++#include <winsock2.h>
++#pragma comment(lib, "ws2_32.lib")
++#define snprintf _snprintf
++#define strcasecmp stricmp
++#define strncasecmp strnicmp
++typedef __int64 INT64;
++typedef unsigned __int64 UINT64;
++#else
++#include <unistd.h>
++#include <utime.h>
++#include <netinet/in.h>
++typedef long long INT64;
++typedef unsigned long long UINT64;
++#endif
++
++#if !defined(M_PI)
++#  define M_PI 3.14159265358979323846
++#endif
++
++#ifdef NODEPS
++#define NO_JASPER
++#define NO_JPEG
++#define NO_LCMS
++#endif
++#ifndef NO_JASPER
++#include <jasper/jasper.h>	/* Decode Red camera movies */
++#endif
++#ifndef NO_JPEG
++#include <jpeglib.h>		/* Decode compressed Kodak DC120 photos */
++#endif				/* and Adobe Lossy DNGs */
++#ifndef NO_LCMS
++#include <lcms2.h>		/* Support color profiles */
++#endif
++#ifdef LOCALEDIR
++#include <libintl.h>
++#define _(String) gettext(String)
++#else
++#define _(String) (String)
++#endif
++
++#if !defined(uchar)
++#define uchar unsigned char
++#endif
++#if !defined(ushort)
++#define ushort unsigned short
++#endif
++
++#ifdef _MSC_VER
++ #if _MSC_VER <= 1310
++ #include "port/strnlen.c"
++ #endif
++#endif
++
++/*
++   All global variables are defined here, and all functions that
++   access them are prefixed with "CLASS".  Note that a thread-safe
++   C++ class cannot have non-const static local variables.
++ */
++FILE *ifp, *ofp;
++short order;
++const char *ifname;
++const char *outfile = NULL;
++char *meta_data, xtrans[6][6], xtrans_abs[6][6];
++char cdesc[5], desc[512], make[64], model[64], model2[64], artist[64];
++float flash_used, canon_ev, iso_speed, shutter, aperture, focal_len;
++time_t timestamp;
++off_t strip_offset, data_offset;
++off_t thumb_offset, meta_offset, profile_offset;
++unsigned shot_order, kodak_cbpp, exif_cfa, unique_id;
++unsigned thumb_length, meta_length, profile_length;
++unsigned thumb_misc, *oprof, fuji_layout, shot_select=0, multi_out=0;
++unsigned tiff_nifds, tiff_samples, tiff_bps, tiff_compress;
++unsigned black, maximum, mix_green, raw_color, zero_is_bad;
++unsigned zero_after_ff, is_raw, dng_version, is_foveon, data_error;
++unsigned tile_width, tile_length, gpsdata[32], load_flags;
++unsigned flip, tiff_flip, filters, colors;
++ushort raw_height, raw_width, height, width, top_margin, left_margin;
++ushort shrink, iheight, iwidth, fuji_width, thumb_width, thumb_height;
++ushort *raw_image, (*image)[4], cblack[4102];
++ushort white[8][8], curve[0x10000], cr2_slice[3], sraw_mul[4];
++double pixel_aspect, aber[4]={1,1,1,1}, gamm[6]={ 0.45,4.5,0,0,0,0 };
++float bright=1, user_mul[4]={0,0,0,0}, threshold=0;
++int mask[8][4];
++int half_size=0, four_color_rgb=0, document_mode=0, highlight=0;
++int verbose=0, use_auto_wb=0, use_camera_wb=0, use_camera_matrix=1;
++int output_color=1, output_bps=8, output_tiff=0, med_passes=0;
++int no_auto_bright=0;
++unsigned greybox[4] = { 0, 0, UINT_MAX, UINT_MAX };
++float cam_mul[4], pre_mul[4], cmatrix[3][4], rgb_cam[3][4];
++const double xyz_rgb[3][3] = {			/* XYZ from RGB */
++  { 0.412453, 0.357580, 0.180423 },
++  { 0.212671, 0.715160, 0.072169 },
++  { 0.019334, 0.119193, 0.950227 } };
++const float d65_white[3] = { 0.950456, 1, 1.088754 };
++int histogram[4][0x2000];
++void (*write_thumb)(), (*write_fun)();
++void (*load_raw)(), (*thumb_load_raw)();
++jmp_buf failure;
++
++struct decode {
++  struct decode *branch[2];
++  int leaf;
++} first_decode[2048], *second_decode, *free_decode;
++
++struct tiff_ifd {
++  int width, height, bps, comp, phint, offset, flip, samples, bytes;
++  int tile_width, tile_length;
++  float shutter;
++} tiff_ifd[10];
++
++struct ph1 {
++  int format, key_off, tag_21a;
++  int black, split_col, black_col, split_row, black_row;
++  float tag_210;
++} ph1;
++
++#define CLASS
++
++#define FORC(cnt) for (c=0; c < cnt; c++)
++#define FORC3 FORC(3)
++#define FORC4 FORC(4)
++#define FORCC FORC(colors)
++
++#define SQR(x) ((x)*(x))
++#define ABS(x) (((int)(x) ^ ((int)(x) >> 31)) - ((int)(x) >> 31))
++#define MIN(a,b) ((a) < (b) ? (a) : (b))
++#define MAX(a,b) ((a) > (b) ? (a) : (b))
++#define LIM(x,min,max) MAX(min,MIN(x,max))
++#define ULIM(x,y,z) ((y) < (z) ? LIM(x,y,z) : LIM(x,z,y))
++#define CLIP(x) LIM((int)(x),0,65535)
++#define SWAP(a,b) { a=a+b; b=a-b; a=a-b; }
++
++/*
++   In order to inline this calculation, I make the risky
++   assumption that all filter patterns can be described
++   by a repeating pattern of eight rows and two columns
++
++   Do not use the FC or BAYER macros with the Leaf CatchLight,
++   because its pattern is 16x16, not 2x8.
++
++   Return values are either 0/1/2/3 = G/M/C/Y or 0/1/2/3 = R/G1/B/G2
++
++	PowerShot 600	PowerShot A50	PowerShot Pro70	Pro90 & G1
++	0xe1e4e1e4:	0x1b4e4b1e:	0x1e4b4e1b:	0xb4b4b4b4:
++
++	  0 1 2 3 4 5	  0 1 2 3 4 5	  0 1 2 3 4 5	  0 1 2 3 4 5
++	0 G M G M G M	0 C Y C Y C Y	0 Y C Y C Y C	0 G M G M G M
++	1 C Y C Y C Y	1 M G M G M G	1 M G M G M G	1 Y C Y C Y C
++	2 M G M G M G	2 Y C Y C Y C	2 C Y C Y C Y
++	3 C Y C Y C Y	3 G M G M G M	3 G M G M G M
++			4 C Y C Y C Y	4 Y C Y C Y C
++	PowerShot A5	5 G M G M G M	5 G M G M G M
++	0x1e4e1e4e:	6 Y C Y C Y C	6 C Y C Y C Y
++			7 M G M G M G	7 M G M G M G
++	  0 1 2 3 4 5
++	0 C Y C Y C Y
++	1 G M G M G M
++	2 C Y C Y C Y
++	3 M G M G M G
++
++   All RGB cameras use one of these Bayer grids:
++
++	0x16161616:	0x61616161:	0x49494949:	0x94949494:
++
++	  0 1 2 3 4 5	  0 1 2 3 4 5	  0 1 2 3 4 5	  0 1 2 3 4 5
++	0 B G B G B G	0 G R G R G R	0 G B G B G B	0 R G R G R G
++	1 G R G R G R	1 B G B G B G	1 R G R G R G	1 G B G B G B
++	2 B G B G B G	2 G R G R G R	2 G B G B G B	2 R G R G R G
++	3 G R G R G R	3 B G B G B G	3 R G R G R G	3 G B G B G B
++ */
++
++#define RAW(row,col) \
++	raw_image[(row)*raw_width+(col)]
++
++#define FC(row,col) \
++	(filters >> ((((row) << 1 & 14) + ((col) & 1)) << 1) & 3)
++
++#define BAYER(row,col) \
++	image[((row) >> shrink)*iwidth + ((col) >> shrink)][FC(row,col)]
++
++#define BAYER2(row,col) \
++	image[((row) >> shrink)*iwidth + ((col) >> shrink)][fcol(row,col)]
++
++int CLASS fcol (int row, int col)
++{
++  static const char filter[16][16] =
++  { { 2,1,1,3,2,3,2,0,3,2,3,0,1,2,1,0 },
++    { 0,3,0,2,0,1,3,1,0,1,1,2,0,3,3,2 },
++    { 2,3,3,2,3,1,1,3,3,1,2,1,2,0,0,3 },
++    { 0,1,0,1,0,2,0,2,2,0,3,0,1,3,2,1 },
++    { 3,1,1,2,0,1,0,2,1,3,1,3,0,1,3,0 },
++    { 2,0,0,3,3,2,3,1,2,0,2,0,3,2,2,1 },
++    { 2,3,3,1,2,1,2,1,2,1,1,2,3,0,0,1 },
++    { 1,0,0,2,3,0,0,3,0,3,0,3,2,1,2,3 },
++    { 2,3,3,1,1,2,1,0,3,2,3,0,2,3,1,3 },
++    { 1,0,2,0,3,0,3,2,0,1,1,2,0,1,0,2 },
++    { 0,1,1,3,3,2,2,1,1,3,3,0,2,1,3,2 },
++    { 2,3,2,0,0,1,3,0,2,0,1,2,3,0,1,0 },
++    { 1,3,1,2,3,2,3,2,0,2,0,1,1,0,3,0 },
++    { 0,2,0,3,1,0,0,1,1,3,3,2,3,2,2,1 },
++    { 2,1,3,2,3,1,2,1,0,3,0,2,0,2,0,2 },
++    { 0,3,1,0,0,2,0,3,2,1,3,1,1,3,1,3 } };
++
++  if (filters == 1) return filter[(row+top_margin)&15][(col+left_margin)&15];
++  if (filters == 9) return xtrans[(row+6) % 6][(col+6) % 6];
++  return FC(row,col);
++}
++
++#ifndef __GLIBC__
++char *my_memmem (char *haystack, size_t haystacklen,
++	      char *needle, size_t needlelen)
++{
++  char *c;
++  for (c = haystack; c <= haystack + haystacklen - needlelen; c++)
++    if (!memcmp (c, needle, needlelen))
++      return c;
++  return 0;
++}
++#define memmem my_memmem
++char *my_strcasestr (char *haystack, const char *needle)
++{
++  char *c;
++  for (c = haystack; *c; c++)
++    if (!strncasecmp(c, needle, strlen(needle)))
++      return c;
++  return 0;
++}
++#define strcasestr my_strcasestr
++#endif
++
++void CLASS merror (void *ptr, const char *where)
++{
++  if (ptr) return;
++  fprintf (stderr,_("%s: Out of memory in %s\n"), ifname, where);
++  longjmp (failure, 1);
++}
++
++void CLASS derror()
++{
++  if (!data_error) {
++    fprintf (stderr, "%s: ", ifname);
++    if (feof(ifp))
++      fprintf (stderr,_("Unexpected end of file\n"));
++    else
++      fprintf (stderr,_("Corrupt data near 0x%llx\n"), (INT64) ftello(ifp));
++  }
++  data_error++;
++}
++
++ushort CLASS sget2 (uchar *s)
++{
++  if (order == 0x4949)		/* "II" means little-endian */
++    return s[0] | s[1] << 8;
++  else				/* "MM" means big-endian */
++    return s[0] << 8 | s[1];
++}
++
++ushort CLASS get2()
++{
++  uchar str[2] = { 0xff,0xff };
++  fread (str, 1, 2, ifp);
++  return sget2(str);
++}
++
++unsigned CLASS sget4 (uchar *s)
++{
++  if (order == 0x4949)
++    return s[0] | s[1] << 8 | s[2] << 16 | s[3] << 24;
++  else
++    return s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3];
++}
++#define sget4(s) sget4((uchar *)s)
++
++unsigned CLASS get4()
++{
++  uchar str[4] = { 0xff,0xff,0xff,0xff };
++  fread (str, 1, 4, ifp);
++  return sget4(str);
++}
++
++unsigned CLASS getint (int type)
++{
++  return type == 3 ? get2() : get4();
++}
++
++float CLASS int_to_float (int i)
++{
++  union { int i; float f; } u;
++  u.i = i;
++  return u.f;
++}
++
++double CLASS getreal (int type)
++{
++  union { char c[8]; double d; } u;
++  int i, rev;
++
++  switch (type) {
++    case 3: return (unsigned short) get2();
++    case 4: return (unsigned int) get4();
++    case 5:  u.d = (unsigned int) get4();
++      return u.d / (unsigned int) get4();
++    case 8: return (signed short) get2();
++    case 9: return (signed int) get4();
++    case 10: u.d = (signed int) get4();
++      return u.d / (signed int) get4();
++    case 11: return int_to_float (get4());
++    case 12:
++      rev = 7 * ((order == 0x4949) == (ntohs(0x1234) == 0x1234));
++      for (i=0; i < 8; i++)
++	u.c[i ^ rev] = fgetc(ifp);
++      return u.d;
++    default: return fgetc(ifp);
++  }
++}
++
++void CLASS read_shorts (ushort *pixel, int count)
++{
++  if (fread (pixel, 2, count, ifp) < count) derror();
++  if ((order == 0x4949) == (ntohs(0x1234) == 0x1234))
++    swab (pixel, pixel, count*2);
++}
++
++void CLASS cubic_spline (const int *x_, const int *y_, const int len)
++{
++  float **A, *b, *c, *d, *x, *y;
++  int i, j;
++
++  A = (float **) calloc (((2*len + 4)*sizeof **A + sizeof *A), 2*len);
++  if (!A) return;
++  A[0] = (float *) (A + 2*len);
++  for (i = 1; i < 2*len; i++)
++    A[i] = A[0] + 2*len*i;
++  y = len + (x = i + (d = i + (c = i + (b = A[0] + i*i))));
++  for (i = 0; i < len; i++) {
++    x[i] = x_[i] / 65535.0;
++    y[i] = y_[i] / 65535.0;
++  }
++  for (i = len-1; i > 0; i--) {
++    b[i] = (y[i] - y[i-1]) / (x[i] - x[i-1]);
++    d[i-1] = x[i] - x[i-1];
++  }
++  for (i = 1; i < len-1; i++) {
++    A[i][i] = 2 * (d[i-1] + d[i]);
++    if (i > 1) {
++      A[i][i-1] = d[i-1];
++      A[i-1][i] = d[i-1];
++    }
++    A[i][len-1] = 6 * (b[i+1] - b[i]);
++  }
++  for(i = 1; i < len-2; i++) {
++    float v = A[i+1][i] / A[i][i];
++    for(j = 1; j <= len-1; j++)
++      A[i+1][j] -= v * A[i][j];
++  }
++  for(i = len-2; i > 0; i--) {
++    float acc = 0;
++    for(j = i; j <= len-2; j++)
++      acc += A[i][j]*c[j];
++    c[i] = (A[i][len-1] - acc) / A[i][i];
++  }
++  for (i = 0; i < 0x10000; i++) {
++    float x_out = (float)(i / 65535.0);
++    float y_out = 0;
++    for (j = 0; j < len-1; j++) {
++      if (x[j] <= x_out && x_out <= x[j+1]) {
++	float v = x_out - x[j];
++	y_out = y[j] +
++	  ((y[j+1] - y[j]) / d[j] - (2 * d[j] * c[j] + c[j+1] * d[j])/6) * v
++	   + (c[j] * 0.5) * v*v + ((c[j+1] - c[j]) / (6 * d[j])) * v*v*v;
++      }
++    }
++    curve[i] = y_out < 0.0 ? 0 : (y_out >= 1.0 ? 65535 :
++		(ushort)(y_out * 65535.0 + 0.5));
++  }
++  free (A);
++}
++
++void CLASS canon_600_fixed_wb (int temp)
++{
++  static const short mul[4][5] = {
++    {  667, 358,397,565,452 },
++    {  731, 390,367,499,517 },
++    { 1119, 396,348,448,537 },
++    { 1399, 485,431,508,688 } };
++  int lo, hi, i;
++  float frac=0;
++
++  for (lo=4; --lo; )
++    if (*mul[lo] <= temp) break;
++  for (hi=0; hi < 3; hi++)
++    if (*mul[hi] >= temp) break;
++  if (lo != hi)
++    frac = (float) (temp - *mul[lo]) / (*mul[hi] - *mul[lo]);
++  for (i=1; i < 5; i++)
++    pre_mul[i-1] = 1 / (frac * mul[hi][i] + (1-frac) * mul[lo][i]);
++}
++
++/* Return values:  0 = white  1 = near white  2 = not white */
++int CLASS canon_600_color (int ratio[2], int mar)
++{
++  int clipped=0, target, miss;
++
++  if (flash_used) {
++    if (ratio[1] < -104)
++      { ratio[1] = -104; clipped = 1; }
++    if (ratio[1] >   12)
++      { ratio[1] =   12; clipped = 1; }
++  } else {
++    if (ratio[1] < -264 || ratio[1] > 461) return 2;
++    if (ratio[1] < -50)
++      { ratio[1] = -50; clipped = 1; }
++    if (ratio[1] > 307)
++      { ratio[1] = 307; clipped = 1; }
++  }
++  target = flash_used || ratio[1] < 197
++	? -38 - (398 * ratio[1] >> 10)
++	: -123 + (48 * ratio[1] >> 10);
++  if (target - mar <= ratio[0] &&
++      target + 20  >= ratio[0] && !clipped) return 0;
++  miss = target - ratio[0];
++  if (abs(miss) >= mar*4) return 2;
++  if (miss < -20) miss = -20;
++  if (miss > mar) miss = mar;
++  ratio[0] = target - miss;
++  return 1;
++}
++
++void CLASS canon_600_auto_wb()
++{
++  int mar, row, col, i, j, st, count[] = { 0,0 };
++  int test[8], total[2][8], ratio[2][2], stat[2];
++
++  memset (&total, 0, sizeof total);
++  i = canon_ev + 0.5;
++  if      (i < 10) mar = 150;
++  else if (i > 12) mar = 20;
++  else mar = 280 - 20 * i;
++  if (flash_used) mar = 80;
++  for (row=14; row < height-14; row+=4)
++    for (col=10; col < width; col+=2) {
++      for (i=0; i < 8; i++)
++	test[(i & 4) + FC(row+(i >> 1),col+(i & 1))] =
++		    BAYER(row+(i >> 1),col+(i & 1));
++      for (i=0; i < 8; i++)
++	if (test[i] < 150 || test[i] > 1500) goto next;
++      for (i=0; i < 4; i++)
++	if (abs(test[i] - test[i+4]) > 50) goto next;
++      for (i=0; i < 2; i++) {
++	for (j=0; j < 4; j+=2)
++	  ratio[i][j >> 1] = ((test[i*4+j+1]-test[i*4+j]) << 10) / test[i*4+j];
++	stat[i] = canon_600_color (ratio[i], mar);
++      }
++      if ((st = stat[0] | stat[1]) > 1) goto next;
++      for (i=0; i < 2; i++)
++	if (stat[i])
++	  for (j=0; j < 2; j++)
++	    test[i*4+j*2+1] = test[i*4+j*2] * (0x400 + ratio[i][j]) >> 10;
++      for (i=0; i < 8; i++)
++	total[st][i] += test[i];
++      count[st]++;
++next: ;
++    }
++  if (count[0] | count[1]) {
++    st = count[0]*200 < count[1];
++    for (i=0; i < 4; i++)
++      pre_mul[i] = 1.0 / (total[st][i] + total[st][i+4]);
++  }
++}
++
++void CLASS canon_600_coeff()
++{
++  static const short table[6][12] = {
++    { -190,702,-1878,2390,   1861,-1349,905,-393, -432,944,2617,-2105  },
++    { -1203,1715,-1136,1648, 1388,-876,267,245,  -1641,2153,3921,-3409 },
++    { -615,1127,-1563,2075,  1437,-925,509,3,     -756,1268,2519,-2007 },
++    { -190,702,-1886,2398,   2153,-1641,763,-251, -452,964,3040,-2528  },
++    { -190,702,-1878,2390,   1861,-1349,905,-393, -432,944,2617,-2105  },
++    { -807,1319,-1785,2297,  1388,-876,769,-257,  -230,742,2067,-1555  } };
++  int t=0, i, c;
++  float mc, yc;
++
++  mc = pre_mul[1] / pre_mul[2];
++  yc = pre_mul[3] / pre_mul[2];
++  if (mc > 1 && mc <= 1.28 && yc < 0.8789) t=1;
++  if (mc > 1.28 && mc <= 2) {
++    if  (yc < 0.8789) t=3;
++    else if (yc <= 2) t=4;
++  }
++  if (flash_used) t=5;
++  for (raw_color = i=0; i < 3; i++)
++    FORCC rgb_cam[i][c] = table[t][i*4 + c] / 1024.0;
++}
++
++void CLASS canon_600_load_raw()
++{
++  uchar  data[1120], *dp;
++  ushort *pix;
++  int irow, row;
++
++  for (irow=row=0; irow < height; irow++) {
++    if (fread (data, 1, 1120, ifp) < 1120) derror();
++    pix = raw_image + row*raw_width;
++    for (dp=data; dp < data+1120;  dp+=10, pix+=8) {
++      pix[0] = (dp[0] << 2) + (dp[1] >> 6    );
++      pix[1] = (dp[2] << 2) + (dp[1] >> 4 & 3);
++      pix[2] = (dp[3] << 2) + (dp[1] >> 2 & 3);
++      pix[3] = (dp[4] << 2) + (dp[1]      & 3);
++      pix[4] = (dp[5] << 2) + (dp[9]      & 3);
++      pix[5] = (dp[6] << 2) + (dp[9] >> 2 & 3);
++      pix[6] = (dp[7] << 2) + (dp[9] >> 4 & 3);
++      pix[7] = (dp[8] << 2) + (dp[9] >> 6    );
++    }
++    if ((row+=2) > height) row = 1;
++  }
++}
++
++void CLASS canon_600_correct()
++{
++  int row, col, val;
++  static const short mul[4][2] =
++  { { 1141,1145 }, { 1128,1109 }, { 1178,1149 }, { 1128,1109 } };
++
++  for (row=0; row < height; row++)
++    for (col=0; col < width; col++) {
++      if ((val = BAYER(row,col) - black) < 0) val = 0;
++      val = val * mul[row & 3][col & 1] >> 9;
++      BAYER(row,col) = val;
++    }
++  canon_600_fixed_wb(1311);
++  canon_600_auto_wb();
++  canon_600_coeff();
++  maximum = (0x3ff - black) * 1109 >> 9;
++  black = 0;
++}
++
++int CLASS canon_s2is()
++{
++  unsigned row;
++
++  for (row=0; row < 100; row++) {
++    fseek (ifp, row*3340 + 3284, SEEK_SET);
++    if (getc(ifp) > 15) return 1;
++  }
++  return 0;
++}
++
++unsigned CLASS getbithuff (int nbits, ushort *huff)
++{
++  static unsigned bitbuf=0;
++  static int vbits=0, reset=0;
++  unsigned c;
++
++  if (nbits > 25) return 0;
++  if (nbits < 0)
++    return bitbuf = vbits = reset = 0;
++  if (nbits == 0 || vbits < 0) return 0;
++  while (!reset && vbits < nbits && (c = fgetc(ifp)) != EOF &&
++    !(reset = zero_after_ff && c == 0xff && fgetc(ifp))) {
++    bitbuf = (bitbuf << 8) + (uchar) c;
++    vbits += 8;
++  }
++  c = bitbuf << (32-vbits) >> (32-nbits);
++  if (huff) {
++    vbits -= huff[c] >> 8;
++    c = (uchar) huff[c];
++  } else
++    vbits -= nbits;
++  if (vbits < 0) derror();
++  return c;
++}
++
++#define getbits(n) getbithuff(n,0)
++#define gethuff(h) getbithuff(*h,h+1)
++
++/*
++   Construct a decode tree according the specification in *source.
++   The first 16 bytes specify how many codes should be 1-bit, 2-bit
++   3-bit, etc.  Bytes after that are the leaf values.
++
++   For example, if the source is
++
++    { 0,1,4,2,3,1,2,0,0,0,0,0,0,0,0,0,
++      0x04,0x03,0x05,0x06,0x02,0x07,0x01,0x08,0x09,0x00,0x0a,0x0b,0xff  },
++
++   then the code is
++
++	00		0x04
++	010		0x03
++	011		0x05
++	100		0x06
++	101		0x02
++	1100		0x07
++	1101		0x01
++	11100		0x08
++	11101		0x09
++	11110		0x00
++	111110		0x0a
++	1111110		0x0b
++	1111111		0xff
++ */
++ushort * CLASS make_decoder_ref (const uchar **source)
++{
++  int max, len, h, i, j;
++  const uchar *count;
++  ushort *huff;
++
++  count = (*source += 16) - 17;
++  for (max=16; max && !count[max]; max--);
++  huff = (ushort *) calloc (1 + (1 << max), sizeof *huff);
++  merror (huff, "make_decoder()");
++  huff[0] = max;
++  for (h=len=1; len <= max; len++)
++    for (i=0; i < count[len]; i++, ++*source)
++      for (j=0; j < 1 << (max-len); j++)
++	if (h <= 1 << max)
++	  huff[h++] = len << 8 | **source;
++  return huff;
++}
++
++ushort * CLASS make_decoder (const uchar *source)
++{
++  return make_decoder_ref (&source);
++}
++
++void CLASS crw_init_tables (unsigned table, ushort *huff[2])
++{
++  static const uchar first_tree[3][29] = {
++    { 0,1,4,2,3,1,2,0,0,0,0,0,0,0,0,0,
++      0x04,0x03,0x05,0x06,0x02,0x07,0x01,0x08,0x09,0x00,0x0a,0x0b,0xff  },
++    { 0,2,2,3,1,1,1,1,2,0,0,0,0,0,0,0,
++      0x03,0x02,0x04,0x01,0x05,0x00,0x06,0x07,0x09,0x08,0x0a,0x0b,0xff  },
++    { 0,0,6,3,1,1,2,0,0,0,0,0,0,0,0,0,
++      0x06,0x05,0x07,0x04,0x08,0x03,0x09,0x02,0x00,0x0a,0x01,0x0b,0xff  },
++  };
++  static const uchar second_tree[3][180] = {
++    { 0,2,2,2,1,4,2,1,2,5,1,1,0,0,0,139,
++      0x03,0x04,0x02,0x05,0x01,0x06,0x07,0x08,
++      0x12,0x13,0x11,0x14,0x09,0x15,0x22,0x00,0x21,0x16,0x0a,0xf0,
++      0x23,0x17,0x24,0x31,0x32,0x18,0x19,0x33,0x25,0x41,0x34,0x42,
++      0x35,0x51,0x36,0x37,0x38,0x29,0x79,0x26,0x1a,0x39,0x56,0x57,
++      0x28,0x27,0x52,0x55,0x58,0x43,0x76,0x59,0x77,0x54,0x61,0xf9,
++      0x71,0x78,0x75,0x96,0x97,0x49,0xb7,0x53,0xd7,0x74,0xb6,0x98,
++      0x47,0x48,0x95,0x69,0x99,0x91,0xfa,0xb8,0x68,0xb5,0xb9,0xd6,
++      0xf7,0xd8,0x67,0x46,0x45,0x94,0x89,0xf8,0x81,0xd5,0xf6,0xb4,
++      0x88,0xb1,0x2a,0x44,0x72,0xd9,0x87,0x66,0xd4,0xf5,0x3a,0xa7,
++      0x73,0xa9,0xa8,0x86,0x62,0xc7,0x65,0xc8,0xc9,0xa1,0xf4,0xd1,
++      0xe9,0x5a,0x92,0x85,0xa6,0xe7,0x93,0xe8,0xc1,0xc6,0x7a,0x64,
++      0xe1,0x4a,0x6a,0xe6,0xb3,0xf1,0xd3,0xa5,0x8a,0xb2,0x9a,0xba,
++      0x84,0xa4,0x63,0xe5,0xc5,0xf3,0xd2,0xc4,0x82,0xaa,0xda,0xe4,
++      0xf2,0xca,0x83,0xa3,0xa2,0xc3,0xea,0xc2,0xe2,0xe3,0xff,0xff  },
++    { 0,2,2,1,4,1,4,1,3,3,1,0,0,0,0,140,
++      0x02,0x03,0x01,0x04,0x05,0x12,0x11,0x06,
++      0x13,0x07,0x08,0x14,0x22,0x09,0x21,0x00,0x23,0x15,0x31,0x32,
++      0x0a,0x16,0xf0,0x24,0x33,0x41,0x42,0x19,0x17,0x25,0x18,0x51,
++      0x34,0x43,0x52,0x29,0x35,0x61,0x39,0x71,0x62,0x36,0x53,0x26,
++      0x38,0x1a,0x37,0x81,0x27,0x91,0x79,0x55,0x45,0x28,0x72,0x59,
++      0xa1,0xb1,0x44,0x69,0x54,0x58,0xd1,0xfa,0x57,0xe1,0xf1,0xb9,
++      0x49,0x47,0x63,0x6a,0xf9,0x56,0x46,0xa8,0x2a,0x4a,0x78,0x99,
++      0x3a,0x75,0x74,0x86,0x65,0xc1,0x76,0xb6,0x96,0xd6,0x89,0x85,
++      0xc9,0xf5,0x95,0xb4,0xc7,0xf7,0x8a,0x97,0xb8,0x73,0xb7,0xd8,
++      0xd9,0x87,0xa7,0x7a,0x48,0x82,0x84,0xea,0xf4,0xa6,0xc5,0x5a,
++      0x94,0xa4,0xc6,0x92,0xc3,0x68,0xb5,0xc8,0xe4,0xe5,0xe6,0xe9,
++      0xa2,0xa3,0xe3,0xc2,0x66,0x67,0x93,0xaa,0xd4,0xd5,0xe7,0xf8,
++      0x88,0x9a,0xd7,0x77,0xc4,0x64,0xe2,0x98,0xa5,0xca,0xda,0xe8,
++      0xf3,0xf6,0xa9,0xb2,0xb3,0xf2,0xd2,0x83,0xba,0xd3,0xff,0xff  },
++    { 0,0,6,2,1,3,3,2,5,1,2,2,8,10,0,117,
++      0x04,0x05,0x03,0x06,0x02,0x07,0x01,0x08,
++      0x09,0x12,0x13,0x14,0x11,0x15,0x0a,0x16,0x17,0xf0,0x00,0x22,
++      0x21,0x18,0x23,0x19,0x24,0x32,0x31,0x25,0x33,0x38,0x37,0x34,
++      0x35,0x36,0x39,0x79,0x57,0x58,0x59,0x28,0x56,0x78,0x27,0x41,
++      0x29,0x77,0x26,0x42,0x76,0x99,0x1a,0x55,0x98,0x97,0xf9,0x48,
++      0x54,0x96,0x89,0x47,0xb7,0x49,0xfa,0x75,0x68,0xb6,0x67,0x69,
++      0xb9,0xb8,0xd8,0x52,0xd7,0x88,0xb5,0x74,0x51,0x46,0xd9,0xf8,
++      0x3a,0xd6,0x87,0x45,0x7a,0x95,0xd5,0xf6,0x86,0xb4,0xa9,0x94,
++      0x53,0x2a,0xa8,0x43,0xf5,0xf7,0xd4,0x66,0xa7,0x5a,0x44,0x8a,
++      0xc9,0xe8,0xc8,0xe7,0x9a,0x6a,0x73,0x4a,0x61,0xc7,0xf4,0xc6,
++      0x65,0xe9,0x72,0xe6,0x71,0x91,0x93,0xa6,0xda,0x92,0x85,0x62,
++      0xf3,0xc5,0xb2,0xa4,0x84,0xba,0x64,0xa5,0xb3,0xd2,0x81,0xe5,
++      0xd3,0xaa,0xc4,0xca,0xf2,0xb1,0xe4,0xd1,0x83,0x63,0xea,0xc3,
++      0xe2,0x82,0xf1,0xa3,0xc2,0xa1,0xc1,0xe3,0xa2,0xe1,0xff,0xff  }
++  };
++  if (table > 2) table = 2;
++  huff[0] = make_decoder ( first_tree[table]);
++  huff[1] = make_decoder (second_tree[table]);
++}
++
++/*
++   Return 0 if the image starts with compressed data,
++   1 if it starts with uncompressed low-order bits.
++
++   In Canon compressed data, 0xff is always followed by 0x00.
++ */
++int CLASS canon_has_lowbits()
++{
++  uchar test[0x4000];
++  int ret=1, i;
++
++  fseek (ifp, 0, SEEK_SET);
++  fread (test, 1, sizeof test, ifp);
++  for (i=540; i < sizeof test - 1; i++)
++    if (test[i] == 0xff) {
++      if (test[i+1]) return 1;
++      ret=0;
++    }
++  return ret;
++}
++
++void CLASS canon_load_raw()
++{
++  ushort *pixel, *prow, *huff[2];
++  int nblocks, lowbits, i, c, row, r, save, val;
++  int block, diffbuf[64], leaf, len, diff, carry=0, pnum=0, base[2];
++
++  crw_init_tables (tiff_compress, huff);
++  lowbits = canon_has_lowbits();
++  if (!lowbits) maximum = 0x3ff;
++  fseek (ifp, 540 + lowbits*raw_height*raw_width/4, SEEK_SET);
++  zero_after_ff = 1;
++  getbits(-1);
++  for (row=0; row < raw_height; row+=8) {
++    pixel = raw_image + row*raw_width;
++    nblocks = MIN (8, raw_height-row) * raw_width >> 6;
++    for (block=0; block < nblocks; block++) {
++      memset (diffbuf, 0, sizeof diffbuf);
++      for (i=0; i < 64; i++ ) {
++	leaf = gethuff(huff[i > 0]);
++	if (leaf == 0 && i) break;
++	if (leaf == 0xff) continue;
++	i  += leaf >> 4;
++	len = leaf & 15;
++	if (len == 0) continue;
++	diff = getbits(len);
++	if ((diff & (1 << (len-1))) == 0)
++	  diff -= (1 << len) - 1;
++	if (i < 64) diffbuf[i] = diff;
++      }
++      diffbuf[0] += carry;
++      carry = diffbuf[0];
++      for (i=0; i < 64; i++ ) {
++	if (pnum++ % raw_width == 0)
++	  base[0] = base[1] = 512;
++	if ((pixel[(block << 6) + i] = base[i & 1] += diffbuf[i]) >> 10)
++	  derror();
++      }
++    }
++    if (lowbits) {
++      save = ftell(ifp);
++      fseek (ifp, 26 + row*raw_width/4, SEEK_SET);
++      for (prow=pixel, i=0; i < raw_width*2; i++) {
++	c = fgetc(ifp);
++	for (r=0; r < 8; r+=2, prow++) {
++	  val = (*prow << 2) + ((c >> r) & 3);
++	  if (raw_width == 2672 && val < 512) val += 2;
++	  *prow = val;
++	}
++      }
++      fseek (ifp, save, SEEK_SET);
++    }
++  }
++  FORC(2) free (huff[c]);
++}
++
++struct jhead {
++  int algo, bits, high, wide, clrs, sraw, psv, restart, vpred[6];
++  ushort quant[64], idct[64], *huff[20], *free[20], *row;
++};
++
++int CLASS ljpeg_start (struct jhead *jh, int info_only)
++{
++  ushort c, tag, len;
++  uchar data[0x10000];
++  const uchar *dp;
++
++  memset (jh, 0, sizeof *jh);
++  jh->restart = INT_MAX;
++  if ((fgetc(ifp),fgetc(ifp)) != 0xd8) return 0;
++  do {
++    if (!fread (data, 2, 2, ifp)) return 0;
++    tag =  data[0] << 8 | data[1];
++    len = (data[2] << 8 | data[3]) - 2;
++    if (tag <= 0xff00) return 0;
++    fread (data, 1, len, ifp);
++    switch (tag) {
++      case 0xffc3:
++	jh->sraw = ((data[7] >> 4) * (data[7] & 15) - 1) & 3;
++      case 0xffc1:
++      case 0xffc0:
++	jh->algo = tag & 0xff;
++	jh->bits = data[0];
++	jh->high = data[1] << 8 | data[2];
++	jh->wide = data[3] << 8 | data[4];
++	jh->clrs = data[5] + jh->sraw;
++	if (len == 9 && !dng_version) getc(ifp);
++	break;
++      case 0xffc4:
++	if (info_only) break;
++	for (dp = data; dp < data+len && !((c = *dp++) & -20); )
++	  jh->free[c] = jh->huff[c] = make_decoder_ref (&dp);
++	break;
++      case 0xffda:
++	jh->psv = data[1+data[0]*2];
++	jh->bits -= data[3+data[0]*2] & 15;
++	break;
++      case 0xffdb:
++	FORC(64) jh->quant[c] = data[c*2+1] << 8 | data[c*2+2];
++	break;
++      case 0xffdd:
++	jh->restart = data[0] << 8 | data[1];
++    }
++  } while (tag != 0xffda);
++  if (jh->bits > 16 || jh->clrs > 6 ||
++     !jh->bits || !jh->high || !jh->wide || !jh->clrs) return 0;
++  if (info_only) return 1;
++  if (!jh->huff[0]) return 0;
++  FORC(19) if (!jh->huff[c+1]) jh->huff[c+1] = jh->huff[c];
++  if (jh->sraw) {
++    FORC(4)        jh->huff[2+c] = jh->huff[1];
++    FORC(jh->sraw) jh->huff[1+c] = jh->huff[0];
++  }
++  jh->row = (ushort *) calloc (jh->wide*jh->clrs, 4);
++  merror (jh->row, "ljpeg_start()");
++  return zero_after_ff = 1;
++}
++
++void CLASS ljpeg_end (struct jhead *jh)
++{
++  int c;
++  FORC4 if (jh->free[c]) free (jh->free[c]);
++  free (jh->row);
++}
++
++int CLASS ljpeg_diff (ushort *huff)
++{
++  int len, diff;
++
++  len = gethuff(huff);
++  if (len == 16 && (!dng_version || dng_version >= 0x1010000))
++    return -32768;
++  diff = getbits(len);
++  if ((diff & (1 << (len-1))) == 0)
++    diff -= (1 << len) - 1;
++  return diff;
++}
++
++ushort * CLASS ljpeg_row (int jrow, struct jhead *jh)
++{
++  int col, c, diff, pred, spred=0;
++  ushort mark=0, *row[3];
++
++  if (jrow * jh->wide % jh->restart == 0) {
++    FORC(6) jh->vpred[c] = 1 << (jh->bits-1);
++    if (jrow) {
++      fseek (ifp, -2, SEEK_CUR);
++      do mark = (mark << 8) + (c = fgetc(ifp));
++      while (c != EOF && mark >> 4 != 0xffd);
++    }
++    getbits(-1);
++  }
++  FORC3 row[c] = jh->row + jh->wide*jh->clrs*((jrow+c) & 1);
++  for (col=0; col < jh->wide; col++)
++    FORC(jh->clrs) {
++      diff = ljpeg_diff (jh->huff[c]);
++      if (jh->sraw && c <= jh->sraw && (col | c))
++		    pred = spred;
++      else if (col) pred = row[0][-jh->clrs];
++      else	    pred = (jh->vpred[c] += diff) - diff;
++      if (jrow && col) switch (jh->psv) {
++	case 1:	break;
++	case 2: pred = row[1][0];					break;
++	case 3: pred = row[1][-jh->clrs];				break;
++	case 4: pred = pred +   row[1][0] - row[1][-jh->clrs];		break;
++	case 5: pred = pred + ((row[1][0] - row[1][-jh->clrs]) >> 1);	break;
++	case 6: pred = row[1][0] + ((pred - row[1][-jh->clrs]) >> 1);	break;
++	case 7: pred = (pred + row[1][0]) >> 1;				break;
++	default: pred = 0;
++      }
++      if ((**row = pred + diff) >> jh->bits) derror();
++      if (c <= jh->sraw) spred = **row;
++      row[0]++; row[1]++;
++    }
++  return row[2];
++}
++
++void CLASS lossless_jpeg_load_raw()
++{
++  int jwide, jrow, jcol, val, jidx, i, j, row=0, col=0;
++  struct jhead jh;
++  ushort *rp;
++
++  if (!ljpeg_start (&jh, 0)) return;
++  jwide = jh.wide * jh.clrs;
++
++  for (jrow=0; jrow < jh.high; jrow++) {
++    rp = ljpeg_row (jrow, &jh);
++    if (load_flags & 1)
++      row = jrow & 1 ? height-1-jrow/2 : jrow/2;
++    for (jcol=0; jcol < jwide; jcol++) {
++      val = curve[*rp++];
++      if (cr2_slice[0]) {
++	jidx = jrow*jwide + jcol;
++	i = jidx / (cr2_slice[1]*raw_height);
++	if ((j = i >= cr2_slice[0]))
++		 i  = cr2_slice[0];
++	jidx -= i * (cr2_slice[1]*raw_height);
++	row = jidx / cr2_slice[1+j];
++	col = jidx % cr2_slice[1+j] + i*cr2_slice[1];
++      }
++      if (raw_width == 3984 && (col -= 2) < 0)
++	col += (row--,raw_width);
++      if ((unsigned) row < raw_height) RAW(row,col) = val;
++      if (++col >= raw_width)
++	col = (row++,0);
++    }
++  }
++  ljpeg_end (&jh);
++}
++
++void CLASS canon_sraw_load_raw()
++{
++  struct jhead jh;
++  short *rp=0, (*ip)[4];
++  int jwide, slice, scol, ecol, row, col, jrow=0, jcol=0, pix[3], c;
++  int v[3]={0,0,0}, ver, hue;
++  char *cp;
++
++  if (!ljpeg_start (&jh, 0) || jh.clrs < 4) return;
++  jwide = (jh.wide >>= 1) * jh.clrs;
++
++  for (ecol=slice=0; slice <= cr2_slice[0]; slice++) {
++    scol = ecol;
++    ecol += cr2_slice[1] * 2 / jh.clrs;
++    if (!cr2_slice[0] || ecol > raw_width-1) ecol = raw_width & -2;
++    for (row=0; row < height; row += (jh.clrs >> 1) - 1) {
++      ip = (short (*)[4]) image + row*width;
++      for (col=scol; col < ecol; col+=2, jcol+=jh.clrs) {
++	if ((jcol %= jwide) == 0)
++	  rp = (short *) ljpeg_row (jrow++, &jh);
++	if (col >= width) continue;
++	FORC (jh.clrs-2)
++	  ip[col + (c >> 1)*width + (c & 1)][0] = rp[jcol+c];
++	ip[col][1] = rp[jcol+jh.clrs-2] - 16384;
++	ip[col][2] = rp[jcol+jh.clrs-1] - 16384;
++      }
++    }
++  }
++  for (cp=model2; *cp && !isdigit(*cp); cp++);
++  sscanf (cp, "%d.%d.%d", v, v+1, v+2);
++  ver = (v[0]*1000 + v[1])*1000 + v[2];
++  hue = (jh.sraw+1) << 2;
++  if (unique_id >= 0x80000281 || (unique_id == 0x80000218 && ver > 1000006))
++    hue = jh.sraw << 1;
++  ip = (short (*)[4]) image;
++  rp = ip[0];
++  for (row=0; row < height; row++, ip+=width) {
++    if (row & (jh.sraw >> 1))
++      for (col=0; col < width; col+=2)
++	for (c=1; c < 3; c++)
++	  if (row == height-1)
++	       ip[col][c] =  ip[col-width][c];
++	  else ip[col][c] = (ip[col-width][c] + ip[col+width][c] + 1) >> 1;
++    for (col=1; col < width; col+=2)
++      for (c=1; c < 3; c++)
++	if (col == width-1)
++	     ip[col][c] =  ip[col-1][c];
++	else ip[col][c] = (ip[col-1][c] + ip[col+1][c] + 1) >> 1;
++  }
++  for ( ; rp < ip[0]; rp+=4) {
++    if (unique_id == 0x80000218 ||
++	unique_id == 0x80000250 ||
++	unique_id == 0x80000261 ||
++	unique_id == 0x80000281 ||
++	unique_id == 0x80000287) {
++      rp[1] = (rp[1] << 2) + hue;
++      rp[2] = (rp[2] << 2) + hue;
++      pix[0] = rp[0] + ((   50*rp[1] + 22929*rp[2]) >> 14);
++      pix[1] = rp[0] + ((-5640*rp[1] - 11751*rp[2]) >> 14);
++      pix[2] = rp[0] + ((29040*rp[1] -   101*rp[2]) >> 14);
++    } else {
++      if (unique_id < 0x80000218) rp[0] -= 512;
++      pix[0] = rp[0] + rp[2];
++      pix[2] = rp[0] + rp[1];
++      pix[1] = rp[0] + ((-778*rp[1] - (rp[2] << 11)) >> 12);
++    }
++    FORC3 rp[c] = CLIP(pix[c] * sraw_mul[c] >> 10);
++  }
++  ljpeg_end (&jh);
++  maximum = 0x3fff;
++}
++
++void CLASS adobe_copy_pixel (unsigned row, unsigned col, ushort **rp)
++{
++  int c;
++
++  if (tiff_samples == 2 && shot_select) (*rp)++;
++  if (raw_image) {
++    if (row < raw_height && col < raw_width)
++      RAW(row,col) = curve[**rp];
++    *rp += tiff_samples;
++  } else {
++    if (row < height && col < width)
++      FORC(tiff_samples)
++	image[row*width+col][c] = curve[(*rp)[c]];
++    *rp += tiff_samples;
++  }
++  if (tiff_samples == 2 && shot_select) (*rp)--;
++}
++
++void CLASS ljpeg_idct (struct jhead *jh)
++{
++  int c, i, j, len, skip, coef;
++  float work[3][8][8];
++  static float cs[106] = { 0 };
++  static const uchar zigzag[80] =
++  {  0, 1, 8,16, 9, 2, 3,10,17,24,32,25,18,11, 4, 5,12,19,26,33,
++    40,48,41,34,27,20,13, 6, 7,14,21,28,35,42,49,56,57,50,43,36,
++    29,22,15,23,30,37,44,51,58,59,52,45,38,31,39,46,53,60,61,54,
++    47,55,62,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63,63 };
++
++  if (!cs[0])
++    FORC(106) cs[c] = cos((c & 31)*M_PI/16)/2;
++  memset (work, 0, sizeof work);
++  work[0][0][0] = jh->vpred[0] += ljpeg_diff (jh->huff[0]) * jh->quant[0];
++  for (i=1; i < 64; i++ ) {
++    len = gethuff (jh->huff[16]);
++    i += skip = len >> 4;
++    if (!(len &= 15) && skip < 15) break;
++    coef = getbits(len);
++    if ((coef & (1 << (len-1))) == 0)
++      coef -= (1 << len) - 1;
++    ((float *)work)[zigzag[i]] = coef * jh->quant[i];
++  }
++  FORC(8) work[0][0][c] *= M_SQRT1_2;
++  FORC(8) work[0][c][0] *= M_SQRT1_2;
++  for (i=0; i < 8; i++)
++    for (j=0; j < 8; j++)
++      FORC(8) work[1][i][j] += work[0][i][c] * cs[(j*2+1)*c];
++  for (i=0; i < 8; i++)
++    for (j=0; j < 8; j++)
++      FORC(8) work[2][i][j] += work[1][c][j] * cs[(i*2+1)*c];
++
++  FORC(64) jh->idct[c] = CLIP(((float *)work[2])[c]+0.5);
++}
++
++void CLASS lossless_dng_load_raw()
++{
++  unsigned save, trow=0, tcol=0, jwide, jrow, jcol, row, col, i, j;
++  struct jhead jh;
++  ushort *rp;
++
++  while (trow < raw_height) {
++    save = ftell(ifp);
++    if (tile_length < INT_MAX)
++      fseek (ifp, get4(), SEEK_SET);
++    if (!ljpeg_start (&jh, 0)) break;
++    jwide = jh.wide;
++    if (filters) jwide *= jh.clrs;
++    jwide /= MIN (is_raw, tiff_samples);
++    switch (jh.algo) {
++      case 0xc1:
++	jh.vpred[0] = 16384;
++	getbits(-1);
++	for (jrow=0; jrow+7 < jh.high; jrow += 8) {
++	  for (jcol=0; jcol+7 < jh.wide; jcol += 8) {
++	    ljpeg_idct (&jh);
++	    rp = jh.idct;
++	    row = trow + jcol/tile_width + jrow*2;
++	    col = tcol + jcol%tile_width;
++	    for (i=0; i < 16; i+=2)
++	      for (j=0; j < 8; j++)
++		adobe_copy_pixel (row+i, col+j, &rp);
++	  }
++	}
++	break;
++      case 0xc3:
++	for (row=col=jrow=0; jrow < jh.high; jrow++) {
++	  rp = ljpeg_row (jrow, &jh);
++	  for (jcol=0; jcol < jwide; jcol++) {
++	    adobe_copy_pixel (trow+row, tcol+col, &rp);
++	    if (++col >= tile_width || col >= raw_width)
++	      row += 1 + (col = 0);
++	  }
++	}
++    }
++    fseek (ifp, save+4, SEEK_SET);
++    if ((tcol += tile_width) >= raw_width)
++      trow += tile_length + (tcol = 0);
++    ljpeg_end (&jh);
++  }
++}
++
++void CLASS packed_dng_load_raw()
++{
++  ushort *pixel, *rp;
++  int row, col;
++
++  pixel = (ushort *) calloc (raw_width, tiff_samples*sizeof *pixel);
++  merror (pixel, "packed_dng_load_raw()");
++  for (row=0; row < raw_height; row++) {
++    if (tiff_bps == 16)
++      read_shorts (pixel, raw_width * tiff_samples);
++    else {
++      getbits(-1);
++      for (col=0; col < raw_width * tiff_samples; col++)
++	pixel[col] = getbits(tiff_bps);
++    }
++    for (rp=pixel, col=0; col < raw_width; col++)
++      adobe_copy_pixel (row, col, &rp);
++  }
++  free (pixel);
++}
++
++void CLASS pentax_load_raw()
++{
++  ushort bit[2][15], huff[4097];
++  int dep, row, col, diff, c, i;
++  ushort vpred[2][2] = {{0,0},{0,0}}, hpred[2];
++
++  fseek (ifp, meta_offset, SEEK_SET);
++  dep = (get2() + 12) & 15;
++  fseek (ifp, 12, SEEK_CUR);
++  FORC(dep) bit[0][c] = get2();
++  FORC(dep) bit[1][c] = fgetc(ifp);
++  FORC(dep)
++    for (i=bit[0][c]; i <= ((bit[0][c]+(4096 >> bit[1][c])-1) & 4095); )
++      huff[++i] = bit[1][c] << 8 | c;
++  huff[0] = 12;
++  fseek (ifp, data_offset, SEEK_SET);
++  getbits(-1);
++  for (row=0; row < raw_height; row++)
++    for (col=0; col < raw_width; col++) {
++      diff = ljpeg_diff (huff);
++      if (col < 2) hpred[col] = vpred[row & 1][col] += diff;
++      else	   hpred[col & 1] += diff;
++      RAW(row,col) = hpred[col & 1];
++      if (hpred[col & 1] >> tiff_bps) derror();
++    }
++}
++
++void CLASS nikon_load_raw()
++{
++  static const uchar nikon_tree[][32] = {
++    { 0,1,5,1,1,1,1,1,1,2,0,0,0,0,0,0,	/* 12-bit lossy */
++      5,4,3,6,2,7,1,0,8,9,11,10,12 },
++    { 0,1,5,1,1,1,1,1,1,2,0,0,0,0,0,0,	/* 12-bit lossy after split */
++      0x39,0x5a,0x38,0x27,0x16,5,4,3,2,1,0,11,12,12 },
++    { 0,1,4,2,3,1,2,0,0,0,0,0,0,0,0,0,  /* 12-bit lossless */
++      5,4,6,3,7,2,8,1,9,0,10,11,12 },
++    { 0,1,4,3,1,1,1,1,1,2,0,0,0,0,0,0,	/* 14-bit lossy */
++      5,6,4,7,8,3,9,2,1,0,10,11,12,13,14 },
++    { 0,1,5,1,1,1,1,1,1,1,2,0,0,0,0,0,	/* 14-bit lossy after split */
++      8,0x5c,0x4b,0x3a,0x29,7,6,5,4,3,2,1,0,13,14 },
++    { 0,1,4,2,2,3,1,2,0,0,0,0,0,0,0,0,	/* 14-bit lossless */
++      7,6,8,5,9,4,10,3,11,12,2,0,1,13,14 } };
++  ushort *huff, ver0, ver1, vpred[2][2], hpred[2], csize;
++  int i, min, max, step=0, tree=0, split=0, row, col, len, shl, diff;
++
++  fseek (ifp, meta_offset, SEEK_SET);
++  ver0 = fgetc(ifp);
++  ver1 = fgetc(ifp);
++  if (ver0 == 0x49 || ver1 == 0x58)
++    fseek (ifp, 2110, SEEK_CUR);
++  if (ver0 == 0x46) tree = 2;
++  if (tiff_bps == 14) tree += 3;
++  read_shorts (vpred[0], 4);
++  max = 1 << tiff_bps & 0x7fff;
++  if ((csize = get2()) > 1)
++    step = max / (csize-1);
++  if (ver0 == 0x44 && ver1 == 0x20 && step > 0) {
++    for (i=0; i < csize; i++)
++      curve[i*step] = get2();
++    for (i=0; i < max; i++)
++      curve[i] = ( curve[i-i%step]*(step-i%step) +
++		   curve[i-i%step+step]*(i%step) ) / step;
++    fseek (ifp, meta_offset+562, SEEK_SET);
++    split = get2();
++  } else if (ver0 != 0x46 && csize <= 0x4001)
++    read_shorts (curve, max=csize);
++  while (curve[max-2] == curve[max-1]) max--;
++  huff = make_decoder (nikon_tree[tree]);
++  fseek (ifp, data_offset, SEEK_SET);
++  getbits(-1);
++  for (min=row=0; row < height; row++) {
++    if (split && row == split) {
++      free (huff);
++      huff = make_decoder (nikon_tree[tree+1]);
++      max += (min = 16) << 1;
++    }
++    for (col=0; col < raw_width; col++) {
++      i = gethuff(huff);
++      len = i & 15;
++      shl = i >> 4;
++      diff = ((getbits(len-shl) << 1) + 1) << shl >> 1;
++      if ((diff & (1 << (len-1))) == 0)
++	diff -= (1 << len) - !shl;
++      if (col < 2) hpred[col] = vpred[row & 1][col] += diff;
++      else	   hpred[col & 1] += diff;
++      if ((ushort)(hpred[col & 1] + min) >= max) derror();
++      RAW(row,col) = curve[LIM((short)hpred[col & 1],0,0x3fff)];
++    }
++  }
++  free (huff);
++}
++
++void CLASS nikon_yuv_load_raw()
++{
++  int row, col, yuv[4], rgb[3], b, c;
++  UINT64 bitbuf=0;
++
++  for (row=0; row < raw_height; row++)
++    for (col=0; col < raw_width; col++) {
++      if (!(b = col & 1)) {
++	bitbuf = 0;
++	FORC(6) bitbuf |= (UINT64) fgetc(ifp) << c*8;
++	FORC(4) yuv[c] = (bitbuf >> c*12 & 0xfff) - (c >> 1 << 11);
++      }
++      rgb[0] = yuv[b] + 1.370705*yuv[3];
++      rgb[1] = yuv[b] - 0.337633*yuv[2] - 0.698001*yuv[3];
++      rgb[2] = yuv[b] + 1.732446*yuv[2];
++      FORC3 image[row*width+col][c] = curve[LIM(rgb[c],0,0xfff)] / cam_mul[c];
++    }
++}
++
++/*
++   Returns 1 for a Coolpix 995, 0 for anything else.
++ */
++int CLASS nikon_e995()
++{
++  int i, histo[256];
++  const uchar often[] = { 0x00, 0x55, 0xaa, 0xff };
++
++  memset (histo, 0, sizeof histo);
++  fseek (ifp, -2000, SEEK_END);
++  for (i=0; i < 2000; i++)
++    histo[fgetc(ifp)]++;
++  for (i=0; i < 4; i++)
++    if (histo[often[i]] < 200)
++      return 0;
++  return 1;
++}
++
++/*
++   Returns 1 for a Coolpix 2100, 0 for anything else.
++ */
++int CLASS nikon_e2100()
++{
++  uchar t[12];
++  int i;
++
++  fseek (ifp, 0, SEEK_SET);
++  for (i=0; i < 1024; i++) {
++    fread (t, 1, 12, ifp);
++    if (((t[2] & t[4] & t[7] & t[9]) >> 4
++	& t[1] & t[6] & t[8] & t[11] & 3) != 3)
++      return 0;
++  }
++  return 1;
++}
++
++void CLASS nikon_3700()
++{
++  int bits, i;
++  uchar dp[24];
++  static const struct {
++    int bits;
++    char make[12], model[15];
++  } table[] = {
++    { 0x00, "Pentax",  "Optio 33WR" },
++    { 0x03, "Nikon",   "E3200" },
++    { 0x32, "Nikon",   "E3700" },
++    { 0x33, "Olympus", "C740UZ" } };
++
++  fseek (ifp, 3072, SEEK_SET);
++  fread (dp, 1, 24, ifp);
++  bits = (dp[8] & 3) << 4 | (dp[20] & 3);
++  for (i=0; i < sizeof table / sizeof *table; i++)
++    if (bits == table[i].bits) {
++      strcpy (make,  table[i].make );
++      strcpy (model, table[i].model);
++    }
++}
++
++/*
++   Separates a Minolta DiMAGE Z2 from a Nikon E4300.
++ */
++int CLASS minolta_z2()
++{
++  int i, nz;
++  char tail[424];
++
++  fseek (ifp, -sizeof tail, SEEK_END);
++  fread (tail, 1, sizeof tail, ifp);
++  for (nz=i=0; i < sizeof tail; i++)
++    if (tail[i]) nz++;
++  return nz > 20;
++}
++
++void CLASS jpeg_thumb();
++
++void CLASS ppm_thumb()
++{
++  char *thumb;
++  thumb_length = thumb_width*thumb_height*3;
++  thumb = (char *) malloc (thumb_length);
++  merror (thumb, "ppm_thumb()");
++  fprintf (ofp, "P6\n%d %d\n255\n", thumb_width, thumb_height);
++  fread  (thumb, 1, thumb_length, ifp);
++  fwrite (thumb, 1, thumb_length, ofp);
++  free (thumb);
++}
++
++void CLASS ppm16_thumb()
++{
++  int i;
++  char *thumb;
++  thumb_length = thumb_width*thumb_height*3;
++  thumb = (char *) calloc (thumb_length, 2);
++  merror (thumb, "ppm16_thumb()");
++  read_shorts ((ushort *) thumb, thumb_length);
++  for (i=0; i < thumb_length; i++)
++    thumb[i] = ((ushort *) thumb)[i] >> 8;
++  fprintf (ofp, "P6\n%d %d\n255\n", thumb_width, thumb_height);
++  fwrite (thumb, 1, thumb_length, ofp);
++  free (thumb);
++}
++
++void CLASS layer_thumb()
++{
++  int i, c;
++  char *thumb, map[][4] = { "012","102" };
++
++  colors = thumb_misc >> 5 & 7;
++  thumb_length = thumb_width*thumb_height;
++  thumb = (char *) calloc (colors, thumb_length);
++  merror (thumb, "layer_thumb()");
++  fprintf (ofp, "P%d\n%d %d\n255\n",
++	5 + (colors >> 1), thumb_width, thumb_height);
++  fread (thumb, thumb_length, colors, ifp);
++  for (i=0; i < thumb_length; i++)
++    FORCC putc (thumb[i+thumb_length*(map[thumb_misc >> 8][c]-'0')], ofp);
++  free (thumb);
++}
++
++void CLASS rollei_thumb()
++{
++  unsigned i;
++  ushort *thumb;
++
++  thumb_length = thumb_width * thumb_height;
++  thumb = (ushort *) calloc (thumb_length, 2);
++  merror (thumb, "rollei_thumb()");
++  fprintf (ofp, "P6\n%d %d\n255\n", thumb_width, thumb_height);
++  read_shorts (thumb, thumb_length);
++  for (i=0; i < thumb_length; i++) {
++    putc (thumb[i] << 3, ofp);
++    putc (thumb[i] >> 5  << 2, ofp);
++    putc (thumb[i] >> 11 << 3, ofp);
++  }
++  free (thumb);
++}
++
++void CLASS rollei_load_raw()
++{
++  uchar pixel[10];
++  unsigned iten=0, isix, i, buffer=0, todo[16];
++
++  isix = raw_width * raw_height * 5 / 8;
++  while (fread (pixel, 1, 10, ifp) == 10) {
++    for (i=0; i < 10; i+=2) {
++      todo[i]   = iten++;
++      todo[i+1] = pixel[i] << 8 | pixel[i+1];
++      buffer    = pixel[i] >> 2 | buffer << 6;
++    }
++    for (   ; i < 16; i+=2) {
++      todo[i]   = isix++;
++      todo[i+1] = buffer >> (14-i)*5;
++    }
++    for (i=0; i < 16; i+=2)
++      raw_image[todo[i]] = (todo[i+1] & 0x3ff);
++  }
++  maximum = 0x3ff;
++}
++
++int CLASS raw (unsigned row, unsigned col)
++{
++  return (row < raw_height && col < raw_width) ? RAW(row,col) : 0;
++}
++
++void CLASS phase_one_flat_field (int is_float, int nc)
++{
++  ushort head[8];
++  unsigned wide, high, y, x, c, rend, cend, row, col;
++  float *mrow, num, mult[4];
++
++  read_shorts (head, 8);
++  if (head[2] * head[3] * head[4] * head[5] == 0) return;
++  wide = head[2] / head[4] + (head[2] % head[4] != 0);
++  high = head[3] / head[5] + (head[3] % head[5] != 0);
++  mrow = (float *) calloc (nc*wide, sizeof *mrow);
++  merror (mrow, "phase_one_flat_field()");
++  for (y=0; y < high; y++) {
++    for (x=0; x < wide; x++)
++      for (c=0; c < nc; c+=2) {
++	num = is_float ? getreal(11) : get2()/32768.0;
++	if (y==0) mrow[c*wide+x] = num;
++	else mrow[(c+1)*wide+x] = (num - mrow[c*wide+x]) / head[5];
++      }
++    if (y==0) continue;
++    rend = head[1] + y*head[5];
++    for (row = rend-head[5];
++	 row < raw_height && row < rend &&
++	 row < head[1]+head[3]-head[5]; row++) {
++      for (x=1; x < wide; x++) {
++	for (c=0; c < nc; c+=2) {
++	  mult[c] = mrow[c*wide+x-1];
++	  mult[c+1] = (mrow[c*wide+x] - mult[c]) / head[4];
++	}
++	cend = head[0] + x*head[4];
++	for (col = cend-head[4];
++	     col < raw_width &&
++	     col < cend && col < head[0]+head[2]-head[4]; col++) {
++	  c = nc > 2 ? FC(row-top_margin,col-left_margin) : 0;
++	  if (!(c & 1)) {
++	    c = RAW(row,col) * mult[c];
++	    RAW(row,col) = LIM(c,0,65535);
++	  }
++	  for (c=0; c < nc; c+=2)
++	    mult[c] += mult[c+1];
++	}
++      }
++      for (x=0; x < wide; x++)
++	for (c=0; c < nc; c+=2)
++	  mrow[c*wide+x] += mrow[(c+1)*wide+x];
++    }
++  }
++  free (mrow);
++}
++
++void CLASS phase_one_correct()
++{
++  unsigned entries, tag, data, save, col, row, type;
++  int len, i, j, k, cip, val[4], dev[4], sum, max;
++  int head[9], diff, mindiff=INT_MAX, off_412=0;
++  static const signed char dir[12][2] =
++    { {-1,-1}, {-1,1}, {1,-1}, {1,1}, {-2,0}, {0,-2}, {0,2}, {2,0},
++      {-2,-2}, {-2,2}, {2,-2}, {2,2} };
++  float poly[8], num, cfrac, frac, mult[2], *yval[2];
++  ushort *xval[2];
++  int qmult_applied = 0, qlin_applied = 0;
++
++  if (half_size || !meta_length) return;
++  if (verbose) fprintf (stderr,_("Phase One correction...\n"));
++  fseek (ifp, meta_offset, SEEK_SET);
++  order = get2();
++  fseek (ifp, 6, SEEK_CUR);
++  fseek (ifp, meta_offset+get4(), SEEK_SET);
++  entries = get4();  get4();
++  while (entries--) {
++    tag  = get4();
++    len  = get4();
++    data = get4();
++    save = ftell(ifp);
++    fseek (ifp, meta_offset+data, SEEK_SET);
++    if (tag == 0x419) {				/* Polynomial curve */
++      for (get4(), i=0; i < 8; i++)
++	poly[i] = getreal(11);
++      poly[3] += (ph1.tag_210 - poly[7]) * poly[6] + 1;
++      for (i=0; i < 0x10000; i++) {
++	num = (poly[5]*i + poly[3])*i + poly[1];
++	curve[i] = LIM(num,0,65535);
++      } goto apply;				/* apply to right half */
++    } else if (tag == 0x41a) {			/* Polynomial curve */
++      for (i=0; i < 4; i++)
++	poly[i] = getreal(11);
++      for (i=0; i < 0x10000; i++) {
++	for (num=0, j=4; j--; )
++	  num = num * i + poly[j];
++	curve[i] = LIM(num+i,0,65535);
++      } apply:					/* apply to whole image */
++      for (row=0; row < raw_height; row++)
++	for (col = (tag & 1)*ph1.split_col; col < raw_width; col++)
++	  RAW(row,col) = curve[RAW(row,col)];
++    } else if (tag == 0x400) {			/* Sensor defects */
++      while ((len -= 8) >= 0) {
++	col  = get2();
++	row  = get2();
++	type = get2(); get2();
++	if (col >= raw_width) continue;
++	if (type == 131 || type == 137)		/* Bad column */
++	  for (row=0; row < raw_height; row++)
++	    if (FC(row-top_margin,col-left_margin) == 1) {
++	      for (sum=i=0; i < 4; i++)
++		sum += val[i] = raw (row+dir[i][0], col+dir[i][1]);
++	      for (max=i=0; i < 4; i++) {
++		dev[i] = abs((val[i] << 2) - sum);
++		if (dev[max] < dev[i]) max = i;
++	      }
++	      RAW(row,col) = (sum - val[max])/3.0 + 0.5;
++	    } else {
++	      for (sum=0, i=8; i < 12; i++)
++		sum += raw (row+dir[i][0], col+dir[i][1]);
++	      RAW(row,col) = 0.5 + sum * 0.0732233 +
++		(raw(row,col-2) + raw(row,col+2)) * 0.3535534;
++	    }
++	else if (type == 129) {			/* Bad pixel */
++	  if (row >= raw_height) continue;
++	  j = (FC(row-top_margin,col-left_margin) != 1) * 4;
++	  for (sum=0, i=j; i < j+8; i++)
++	    sum += raw (row+dir[i][0], col+dir[i][1]);
++	  RAW(row,col) = (sum + 4) >> 3;
++	}
++      }
++    } else if (tag == 0x401) {			/* All-color flat fields */
++      phase_one_flat_field (1, 2);
++    } else if (tag == 0x416 || tag == 0x410) {
++      phase_one_flat_field (0, 2);
++    } else if (tag == 0x40b) {			/* Red+blue flat field */
++      phase_one_flat_field (0, 4);
++    } else if (tag == 0x412) {
++      fseek (ifp, 36, SEEK_CUR);
++      diff = abs (get2() - ph1.tag_21a);
++      if (mindiff > diff) {
++	mindiff = diff;
++	off_412 = ftell(ifp) - 38;
++      }
++    } else if (tag == 0x41f && !qlin_applied) { /* Quadrant linearization */
++      ushort lc[2][2][16], ref[16];
++      int qr, qc;
++      for (qr = 0; qr < 2; qr++)
++	for (qc = 0; qc < 2; qc++)
++	  for (i = 0; i < 16; i++)
++	    lc[qr][qc][i] = get4();
++      for (i = 0; i < 16; i++) {
++	int v = 0;
++	for (qr = 0; qr < 2; qr++)
++	  for (qc = 0; qc < 2; qc++)
++	    v += lc[qr][qc][i];
++	ref[i] = (v + 2) >> 2;
++      }
++      for (qr = 0; qr < 2; qr++) {
++	for (qc = 0; qc < 2; qc++) {
++	  int cx[19], cf[19];
++	  for (i = 0; i < 16; i++) {
++	    cx[1+i] = lc[qr][qc][i];
++	    cf[1+i] = ref[i];
++	  }
++	  cx[0] = cf[0] = 0;
++	  cx[17] = cf[17] = ((unsigned) ref[15] * 65535) / lc[qr][qc][15];
++	  cx[18] = cf[18] = 65535;
++	  cubic_spline(cx, cf, 19);
++	  for (row = (qr ? ph1.split_row : 0);
++	       row < (qr ? raw_height : ph1.split_row); row++)
++	    for (col = (qc ? ph1.split_col : 0);
++		 col < (qc ? raw_width : ph1.split_col); col++)
++	      RAW(row,col) = curve[RAW(row,col)];
++	}
++      }
++      qlin_applied = 1;
++    } else if (tag == 0x41e && !qmult_applied) { /* Quadrant multipliers */
++      float qmult[2][2] = { { 1, 1 }, { 1, 1 } };
++      get4(); get4(); get4(); get4();
++      qmult[0][0] = 1.0 + getreal(11);
++      get4(); get4(); get4(); get4(); get4();
++      qmult[0][1] = 1.0 + getreal(11);
++      get4(); get4(); get4();
++      qmult[1][0] = 1.0 + getreal(11);
++      get4(); get4(); get4();
++      qmult[1][1] = 1.0 + getreal(11);
++      for (row=0; row < raw_height; row++)
++	for (col=0; col < raw_width; col++) {
++	  i = qmult[row >= ph1.split_row][col >= ph1.split_col] * RAW(row,col);
++	  RAW(row,col) = LIM(i,0,65535);
++	}
++      qmult_applied = 1;
++    } else if (tag == 0x431 && !qmult_applied) { /* Quadrant combined */
++      ushort lc[2][2][7], ref[7];
++      int qr, qc;
++      for (i = 0; i < 7; i++)
++	ref[i] = get4();
++      for (qr = 0; qr < 2; qr++)
++	for (qc = 0; qc < 2; qc++)
++	  for (i = 0; i < 7; i++)
++	    lc[qr][qc][i] = get4();
++      for (qr = 0; qr < 2; qr++) {
++	for (qc = 0; qc < 2; qc++) {
++	  int cx[9], cf[9];
++	  for (i = 0; i < 7; i++) {
++	    cx[1+i] = ref[i];
++	    cf[1+i] = ((unsigned) ref[i] * lc[qr][qc][i]) / 10000;
++	  }
++	  cx[0] = cf[0] = 0;
++	  cx[8] = cf[8] = 65535;
++	  cubic_spline(cx, cf, 9);
++	  for (row = (qr ? ph1.split_row : 0);
++	       row < (qr ? raw_height : ph1.split_row); row++)
++	    for (col = (qc ? ph1.split_col : 0);
++		 col < (qc ? raw_width : ph1.split_col); col++)
++	      RAW(row,col) = curve[RAW(row,col)];
++        }
++      }
++      qmult_applied = 1;
++      qlin_applied = 1;
++    }
++    fseek (ifp, save, SEEK_SET);
++  }
++  if (off_412) {
++    fseek (ifp, off_412, SEEK_SET);
++    for (i=0; i < 9; i++) head[i] = get4() & 0x7fff;
++    yval[0] = (float *) calloc (head[1]*head[3] + head[2]*head[4], 6);
++    merror (yval[0], "phase_one_correct()");
++    yval[1] = (float  *) (yval[0] + head[1]*head[3]);
++    xval[0] = (ushort *) (yval[1] + head[2]*head[4]);
++    xval[1] = (ushort *) (xval[0] + head[1]*head[3]);
++    get2();
++    for (i=0; i < 2; i++)
++      for (j=0; j < head[i+1]*head[i+3]; j++)
++	yval[i][j] = getreal(11);
++    for (i=0; i < 2; i++)
++      for (j=0; j < head[i+1]*head[i+3]; j++)
++	xval[i][j] = get2();
++    for (row=0; row < raw_height; row++)
++      for (col=0; col < raw_width; col++) {
++	cfrac = (float) col * head[3] / raw_width;
++	cfrac -= cip = cfrac;
++	num = RAW(row,col) * 0.5;
++	for (i=cip; i < cip+2; i++) {
++	  for (k=j=0; j < head[1]; j++)
++	    if (num < xval[0][k = head[1]*i+j]) break;
++	  frac = (j == 0 || j == head[1]) ? 0 :
++		(xval[0][k] - num) / (xval[0][k] - xval[0][k-1]);
++	  mult[i-cip] = yval[0][k-1] * frac + yval[0][k] * (1-frac);
++	}
++	i = ((mult[0] * (1-cfrac) + mult[1] * cfrac) * row + num) * 2;
++	RAW(row,col) = LIM(i,0,65535);
++      }
++    free (yval[0]);
++  }
++}
++
++void CLASS phase_one_load_raw()
++{
++  int a, b, i;
++  ushort akey, bkey, mask;
++
++  fseek (ifp, ph1.key_off, SEEK_SET);
++  akey = get2();
++  bkey = get2();
++  mask = ph1.format == 1 ? 0x5555:0x1354;
++  fseek (ifp, data_offset, SEEK_SET);
++  read_shorts (raw_image, raw_width*raw_height);
++  if (ph1.format)
++    for (i=0; i < raw_width*raw_height; i+=2) {
++      a = raw_image[i+0] ^ akey;
++      b = raw_image[i+1] ^ bkey;
++      raw_image[i+0] = (a & mask) | (b & ~mask);
++      raw_image[i+1] = (b & mask) | (a & ~mask);
++    }
++}
++
++unsigned CLASS ph1_bithuff (int nbits, ushort *huff)
++{
++  static UINT64 bitbuf=0;
++  static int vbits=0;
++  unsigned c;
++
++  if (nbits == -1)
++    return bitbuf = vbits = 0;
++  if (nbits == 0) return 0;
++  if (vbits < nbits) {
++    bitbuf = bitbuf << 32 | get4();
++    vbits += 32;
++  }
++  c = bitbuf << (64-vbits) >> (64-nbits);
++  if (huff) {
++    vbits -= huff[c] >> 8;
++    return (uchar) huff[c];
++  }
++  vbits -= nbits;
++  return c;
++}
++#define ph1_bits(n) ph1_bithuff(n,0)
++#define ph1_huff(h) ph1_bithuff(*h,h+1)
++
++void CLASS phase_one_load_raw_c()
++{
++  static const int length[] = { 8,7,6,9,11,10,5,12,14,13 };
++  int *offset, len[2], pred[2], row, col, i, j;
++  ushort *pixel;
++  short (*cblack)[2], (*rblack)[2];
++
++  pixel = (ushort *) calloc (raw_width*3 + raw_height*4, 2);
++  merror (pixel, "phase_one_load_raw_c()");
++  offset = (int *) (pixel + raw_width);
++  fseek (ifp, strip_offset, SEEK_SET);
++  for (row=0; row < raw_height; row++)
++    offset[row] = get4();
++  cblack = (short (*)[2]) (offset + raw_height);
++  fseek (ifp, ph1.black_col, SEEK_SET);
++  if (ph1.black_col)
++    read_shorts ((ushort *) cblack[0], raw_height*2);
++  rblack = cblack + raw_height;
++  fseek (ifp, ph1.black_row, SEEK_SET);
++  if (ph1.black_row)
++    read_shorts ((ushort *) rblack[0], raw_width*2);
++  for (i=0; i < 256; i++)
++    curve[i] = i*i / 3.969 + 0.5;
++  for (row=0; row < raw_height; row++) {
++    fseek (ifp, data_offset + offset[row], SEEK_SET);
++    ph1_bits(-1);
++    pred[0] = pred[1] = 0;
++    for (col=0; col < raw_width; col++) {
++      if (col >= (raw_width & -8))
++	len[0] = len[1] = 14;
++      else if ((col & 7) == 0)
++	for (i=0; i < 2; i++) {
++	  for (j=0; j < 5 && !ph1_bits(1); j++);
++	  if (j--) len[i] = length[j*2 + ph1_bits(1)];
++	}
++      if ((i = len[col & 1]) == 14)
++	pixel[col] = pred[col & 1] = ph1_bits(16);
++      else
++	pixel[col] = pred[col & 1] += ph1_bits(i) + 1 - (1 << (i - 1));
++      if (pred[col & 1] >> 16) derror();
++      if (ph1.format == 5 && pixel[col] < 256)
++	pixel[col] = curve[pixel[col]];
++    }
++    for (col=0; col < raw_width; col++) {
++      i = (pixel[col] << 2*(ph1.format != 8)) - ph1.black
++	+ cblack[row][col >= ph1.split_col]
++	+ rblack[col][row >= ph1.split_row];
++      if (i > 0) RAW(row,col) = i;
++    }
++  }
++  free (pixel);
++  maximum = 0xfffc - ph1.black;
++}
++
++void CLASS hasselblad_load_raw()
++{
++  struct jhead jh;
++  int shot, row, col, *back[5], len[2], diff[12], pred, sh, f, s, c;
++  unsigned upix, urow, ucol;
++  ushort *ip;
++
++  if (!ljpeg_start (&jh, 0)) return;
++  order = 0x4949;
++  ph1_bits(-1);
++  back[4] = (int *) calloc (raw_width, 3*sizeof **back);
++  merror (back[4], "hasselblad_load_raw()");
++  FORC3 back[c] = back[4] + c*raw_width;
++  cblack[6] >>= sh = tiff_samples > 1;
++  shot = LIM(shot_select, 1, tiff_samples) - 1;
++  for (row=0; row < raw_height; row++) {
++    FORC4 back[(c+3) & 3] = back[c];
++    for (col=0; col < raw_width; col+=2) {
++      for (s=0; s < tiff_samples*2; s+=2) {
++	FORC(2) len[c] = ph1_huff(jh.huff[0]);
++	FORC(2) {
++	  diff[s+c] = ph1_bits(len[c]);
++	  if ((diff[s+c] & (1 << (len[c]-1))) == 0)
++	    diff[s+c] -= (1 << len[c]) - 1;
++	  if (diff[s+c] == 65535) diff[s+c] = -32768;
++	}
++      }
++      for (s=col; s < col+2; s++) {
++	pred = 0x8000 + load_flags;
++	if (col) pred = back[2][s-2];
++	if (col && row > 1) switch (jh.psv) {
++	  case 11: pred += back[0][s]/2 - back[0][s-2]/2;  break;
++	}
++	f = (row & 1)*3 ^ ((col+s) & 1);
++	FORC (tiff_samples) {
++	  pred += diff[(s & 1)*tiff_samples+c];
++	  upix = pred >> sh & 0xffff;
++	  if (raw_image && c == shot)
++	    RAW(row,s) = upix;
++	  if (image) {
++	    urow = row-top_margin  + (c & 1);
++	    ucol = col-left_margin - ((c >> 1) & 1);
++	    ip = &image[urow*width+ucol][f];
++	    if (urow < height && ucol < width)
++	      *ip = c < 4 ? upix : (*ip + upix) >> 1;
++	  }
++	}
++	back[2][s] = pred;
++      }
++    }
++  }
++  free (back[4]);
++  ljpeg_end (&jh);
++  if (image) mix_green = 1;
++}
++
++void CLASS leaf_hdr_load_raw()
++{
++  ushort *pixel=0;
++  unsigned tile=0, r, c, row, col;
++
++  if (!filters) {
++    pixel = (ushort *) calloc (raw_width, sizeof *pixel);
++    merror (pixel, "leaf_hdr_load_raw()");
++  }
++  FORC(tiff_samples)
++    for (r=0; r < raw_height; r++) {
++      if (r % tile_length == 0) {
++	fseek (ifp, data_offset + 4*tile++, SEEK_SET);
++	fseek (ifp, get4(), SEEK_SET);
++      }
++      if (filters && c != shot_select) continue;
++      if (filters) pixel = raw_image + r*raw_width;
++      read_shorts (pixel, raw_width);
++      if (!filters && (row = r - top_margin) < height)
++	for (col=0; col < width; col++)
++	  image[row*width+col][c] = pixel[col+left_margin];
++    }
++  if (!filters) {
++    maximum = 0xffff;
++    raw_color = 1;
++    free (pixel);
++  }
++}
++
++void CLASS unpacked_load_raw()
++{
++  int row, col, bits=0;
++
++  while (1 << ++bits < maximum);
++  read_shorts (raw_image, raw_width*raw_height);
++  for (row=0; row < raw_height; row++)
++    for (col=0; col < raw_width; col++)
++      if ((RAW(row,col) >>= load_flags) >> bits
++	&& (unsigned) (row-top_margin) < height
++	&& (unsigned) (col-left_margin) < width) derror();
++}
++
++void CLASS sinar_4shot_load_raw()
++{
++  ushort *pixel;
++  unsigned shot, row, col, r, c;
++
++  if (raw_image) {
++    shot = LIM (shot_select, 1, 4) - 1;
++    fseek (ifp, data_offset + shot*4, SEEK_SET);
++    fseek (ifp, get4(), SEEK_SET);
++    unpacked_load_raw();
++    return;
++  }
++  pixel = (ushort *) calloc (raw_width, sizeof *pixel);
++  merror (pixel, "sinar_4shot_load_raw()");
++  for (shot=0; shot < 4; shot++) {
++    fseek (ifp, data_offset + shot*4, SEEK_SET);
++    fseek (ifp, get4(), SEEK_SET);
++    for (row=0; row < raw_height; row++) {
++      read_shorts (pixel, raw_width);
++      if ((r = row-top_margin - (shot >> 1 & 1)) >= height) continue;
++      for (col=0; col < raw_width; col++) {
++	if ((c = col-left_margin - (shot & 1)) >= width) continue;
++	image[r*width+c][(row & 1)*3 ^ (~col & 1)] = pixel[col];
++      }
++    }
++  }
++  free (pixel);
++  mix_green = 1;
++}
++
++void CLASS imacon_full_load_raw()
++{
++  int row, col;
++
++  if (!image) return;
++  for (row=0; row < height; row++)
++    for (col=0; col < width; col++)
++      read_shorts (image[row*width+col], 3);
++}
++
++void CLASS packed_load_raw()
++{
++  int vbits=0, bwide, rbits, bite, half, irow, row, col, val, i;
++  UINT64 bitbuf=0;
++
++  bwide = raw_width * tiff_bps / 8;
++  bwide += bwide & load_flags >> 7;
++  rbits = bwide * 8 - raw_width * tiff_bps;
++  if (load_flags & 1) bwide = bwide * 16 / 15;
++  bite = 8 + (load_flags & 24);
++  half = (raw_height+1) >> 1;
++  for (irow=0; irow < raw_height; irow++) {
++    row = irow;
++    if (load_flags & 2 &&
++	(row = irow % half * 2 + irow / half) == 1 &&
++	load_flags & 4) {
++      if (vbits=0, tiff_compress)
++	fseek (ifp, data_offset - (-half*bwide & -2048), SEEK_SET);
++      else {
++	fseek (ifp, 0, SEEK_END);
++	fseek (ifp, ftell(ifp) >> 3 << 2, SEEK_SET);
++      }
++    }
++    for (col=0; col < raw_width; col++) {
++      for (vbits -= tiff_bps; vbits < 0; vbits += bite) {
++	bitbuf <<= bite;
++	for (i=0; i < bite; i+=8)
++	  bitbuf |= (unsigned) (fgetc(ifp) << i);
++      }
++      val = bitbuf << (64-tiff_bps-vbits) >> (64-tiff_bps);
++      RAW(row,col ^ (load_flags >> 6 & 1)) = val;
++      if (load_flags & 1 && (col % 10) == 9 && fgetc(ifp) &&
++	row < height+top_margin && col < width+left_margin) derror();
++    }
++    vbits -= rbits;
++  }
++}
++
++void CLASS nokia_load_raw()
++{
++  uchar  *data,  *dp;
++  int rev, dwide, row, col, c;
++  double sum[]={0,0};
++
++  rev = 3 * (order == 0x4949);
++  dwide = (raw_width * 5 + 1) / 4;
++  data = (uchar *) malloc (dwide*2);
++  merror (data, "nokia_load_raw()");
++  for (row=0; row < raw_height; row++) {
++    if (fread (data+dwide, 1, dwide, ifp) < dwide) derror();
++    FORC(dwide) data[c] = data[dwide+(c ^ rev)];
++    for (dp=data, col=0; col < raw_width; dp+=5, col+=4)
++      FORC4 RAW(row,col+c) = (dp[c] << 2) | (dp[4] >> (c << 1) & 3);
++  }
++  free (data);
++  maximum = 0x3ff;
++  if (strcmp(make,"OmniVision")) return;
++  row = raw_height/2;
++  FORC(width-1) {
++    sum[ c & 1] += SQR(RAW(row,c)-RAW(row+1,c+1));
++    sum[~c & 1] += SQR(RAW(row+1,c)-RAW(row,c+1));
++  }
++  if (sum[1] > sum[0]) filters = 0x4b4b4b4b;
++}
++
++void CLASS canon_rmf_load_raw()
++{
++  int row, col, bits, orow, ocol, c;
++
++  for (row=0; row < raw_height; row++)
++    for (col=0; col < raw_width-2; col+=3) {
++      bits = get4();
++      FORC3 {
++	orow = row;
++	if ((ocol = col+c-4) < 0) {
++	  ocol += raw_width;
++	  if ((orow -= 2) < 0)
++	    orow += raw_height;
++	}
++	RAW(orow,ocol) = curve[bits >> (10*c+2) & 0x3ff];
++      }
++    }
++  maximum = curve[0x3ff];
++}
++
++unsigned CLASS pana_bits (int nbits)
++{
++  static uchar buf[0x4000];
++  static int vbits;
++  int byte;
++
++  if (!nbits) return vbits=0;
++  if (!vbits) {
++    fread (buf+load_flags, 1, 0x4000-load_flags, ifp);
++    fread (buf, 1, load_flags, ifp);
++  }
++  vbits = (vbits - nbits) & 0x1ffff;
++  byte = vbits >> 3 ^ 0x3ff0;
++  return (buf[byte] | buf[byte+1] << 8) >> (vbits & 7) & ~(-1 << nbits);
++}
++
++void CLASS panasonic_load_raw()
++{
++  int row, col, i, j, sh=0, pred[2], nonz[2];
++
++  pana_bits(0);
++  for (row=0; row < height; row++)
++    for (col=0; col < raw_width; col++) {
++      if ((i = col % 14) == 0)
++	pred[0] = pred[1] = nonz[0] = nonz[1] = 0;
++      if (i % 3 == 2) sh = 4 >> (3 - pana_bits(2));
++      if (nonz[i & 1]) {
++	if ((j = pana_bits(8))) {
++	  if ((pred[i & 1] -= 0x80 << sh) < 0 || sh == 4)
++	       pred[i & 1] &= ~(-1 << sh);
++	  pred[i & 1] += j << sh;
++	}
++      } else if ((nonz[i & 1] = pana_bits(8)) || i > 11)
++	pred[i & 1] = nonz[i & 1] << 4 | pana_bits(4);
++      if ((RAW(row,col) = pred[col & 1]) > 4098 && col < width) derror();
++    }
++}
++
++void CLASS olympus_load_raw()
++{
++  ushort huff[4096];
++  int row, col, nbits, sign, low, high, i, c, w, n, nw;
++  int acarry[2][3], *carry, pred, diff;
++
++  huff[n=0] = 0xc0c;
++  for (i=12; i--; )
++    FORC(2048 >> i) huff[++n] = (i+1) << 8 | i;
++  fseek (ifp, 7, SEEK_CUR);
++  getbits(-1);
++  for (row=0; row < height; row++) {
++    memset (acarry, 0, sizeof acarry);
++    for (col=0; col < raw_width; col++) {
++      carry = acarry[col & 1];
++      i = 2 * (carry[2] < 3);
++      for (nbits=2+i; (ushort) carry[0] >> (nbits+i); nbits++);
++      low = (sign = getbits(3)) & 3;
++      sign = sign << 29 >> 31;
++      if ((high = getbithuff(12,huff)) == 12)
++	high = getbits(16-nbits) >> 1;
++      carry[0] = (high << nbits) | getbits(nbits);
++      diff = (carry[0] ^ sign) + carry[1];
++      carry[1] = (diff*3 + carry[1]) >> 5;
++      carry[2] = carry[0] > 16 ? 0 : carry[2]+1;
++      if (col >= width) continue;
++      if (row < 2 && col < 2) pred = 0;
++      else if (row < 2) pred = RAW(row,col-2);
++      else if (col < 2) pred = RAW(row-2,col);
++      else {
++	w  = RAW(row,col-2);
++	n  = RAW(row-2,col);
++	nw = RAW(row-2,col-2);
++	if ((w < nw && nw < n) || (n < nw && nw < w)) {
++	  if (ABS(w-nw) > 32 || ABS(n-nw) > 32)
++	    pred = w + n - nw;
++	  else pred = (w + n) >> 1;
++	} else pred = ABS(w-nw) > ABS(n-nw) ? w : n;
++      }
++      if ((RAW(row,col) = pred + ((diff << 2) | low)) >> 12) derror();
++    }
++  }
++}
++
++void CLASS minolta_rd175_load_raw()
++{
++  uchar pixel[768];
++  unsigned irow, box, row, col;
++
++  for (irow=0; irow < 1481; irow++) {
++    if (fread (pixel, 1, 768, ifp) < 768) derror();
++    box = irow / 82;
++    row = irow % 82 * 12 + ((box < 12) ? box | 1 : (box-12)*2);
++    switch (irow) {
++      case 1477: case 1479: continue;
++      case 1476: row = 984; break;
++      case 1480: row = 985; break;
++      case 1478: row = 985; box = 1;
++    }
++    if ((box < 12) && (box & 1)) {
++      for (col=0; col < 1533; col++, row ^= 1)
++	if (col != 1) RAW(row,col) = (col+1) & 2 ?
++		   pixel[col/2-1] + pixel[col/2+1] : pixel[col/2] << 1;
++      RAW(row,1)    = pixel[1]   << 1;
++      RAW(row,1533) = pixel[765] << 1;
++    } else
++      for (col=row & 1; col < 1534; col+=2)
++	RAW(row,col) = pixel[col/2] << 1;
++  }
++  maximum = 0xff << 1;
++}
++
++void CLASS quicktake_100_load_raw()
++{
++  uchar pixel[484][644];
++  static const short gstep[16] =
++  { -89,-60,-44,-32,-22,-15,-8,-2,2,8,15,22,32,44,60,89 };
++  static const short rstep[6][4] =
++  { {  -3,-1,1,3  }, {  -5,-1,1,5  }, {  -8,-2,2,8  },
++    { -13,-3,3,13 }, { -19,-4,4,19 }, { -28,-6,6,28 } };
++  static const short curve[256] =
++  { 0,1,2,3,4,5,6,7,8,9,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,
++    28,29,30,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,53,
++    54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,74,75,76,77,78,
++    79,80,81,82,83,84,86,88,90,92,94,97,99,101,103,105,107,110,112,114,116,
++    118,120,123,125,127,129,131,134,136,138,140,142,144,147,149,151,153,155,
++    158,160,162,164,166,168,171,173,175,177,179,181,184,186,188,190,192,195,
++    197,199,201,203,205,208,210,212,214,216,218,221,223,226,230,235,239,244,
++    248,252,257,261,265,270,274,278,283,287,291,296,300,305,309,313,318,322,
++    326,331,335,339,344,348,352,357,361,365,370,374,379,383,387,392,396,400,
++    405,409,413,418,422,426,431,435,440,444,448,453,457,461,466,470,474,479,
++    483,487,492,496,500,508,519,531,542,553,564,575,587,598,609,620,631,643,
++    654,665,676,687,698,710,721,732,743,754,766,777,788,799,810,822,833,844,
++    855,866,878,889,900,911,922,933,945,956,967,978,989,1001,1012,1023 };
++  int rb, row, col, sharp, val=0;
++
++  getbits(-1);
++  memset (pixel, 0x80, sizeof pixel);
++  for (row=2; row < height+2; row++) {
++    for (col=2+(row & 1); col < width+2; col+=2) {
++      val = ((pixel[row-1][col-1] + 2*pixel[row-1][col+1] +
++		pixel[row][col-2]) >> 2) + gstep[getbits(4)];
++      pixel[row][col] = val = LIM(val,0,255);
++      if (col < 4)
++	pixel[row][col-2] = pixel[row+1][~row & 1] = val;
++      if (row == 2)
++	pixel[row-1][col+1] = pixel[row-1][col+3] = val;
++    }
++    pixel[row][col] = val;
++  }
++  for (rb=0; rb < 2; rb++)
++    for (row=2+rb; row < height+2; row+=2)
++      for (col=3-(row & 1); col < width+2; col+=2) {
++	if (row < 4 || col < 4) sharp = 2;
++	else {
++	  val = ABS(pixel[row-2][col] - pixel[row][col-2])
++	      + ABS(pixel[row-2][col] - pixel[row-2][col-2])
++	      + ABS(pixel[row][col-2] - pixel[row-2][col-2]);
++	  sharp = val <  4 ? 0 : val <  8 ? 1 : val < 16 ? 2 :
++		  val < 32 ? 3 : val < 48 ? 4 : 5;
++	}
++	val = ((pixel[row-2][col] + pixel[row][col-2]) >> 1)
++	      + rstep[sharp][getbits(2)];
++	pixel[row][col] = val = LIM(val,0,255);
++	if (row < 4) pixel[row-2][col+2] = val;
++	if (col < 4) pixel[row+2][col-2] = val;
++      }
++  for (row=2; row < height+2; row++)
++    for (col=3-(row & 1); col < width+2; col+=2) {
++      val = ((pixel[row][col-1] + (pixel[row][col] << 2) +
++	      pixel[row][col+1]) >> 1) - 0x100;
++      pixel[row][col] = LIM(val,0,255);
++    }
++  for (row=0; row < height; row++)
++    for (col=0; col < width; col++)
++      RAW(row,col) = curve[pixel[row+2][col+2]];
++  maximum = 0x3ff;
++}
++
++#define radc_token(tree) ((signed char) getbithuff(8,huff[tree]))
++
++#define FORYX for (y=1; y < 3; y++) for (x=col+1; x >= col; x--)
++
++#define PREDICTOR (c ? (buf[c][y-1][x] + buf[c][y][x+1]) / 2 \
++: (buf[c][y-1][x+1] + 2*buf[c][y-1][x] + buf[c][y][x+1]) / 4)
++
++void CLASS kodak_radc_load_raw()
++{
++  static const char src[] = {
++    1,1, 2,3, 3,4, 4,2, 5,7, 6,5, 7,6, 7,8,
++    1,0, 2,1, 3,3, 4,4, 5,2, 6,7, 7,6, 8,5, 8,8,
++    2,1, 2,3, 3,0, 3,2, 3,4, 4,6, 5,5, 6,7, 6,8,
++    2,0, 2,1, 2,3, 3,2, 4,4, 5,6, 6,7, 7,5, 7,8,
++    2,1, 2,4, 3,0, 3,2, 3,3, 4,7, 5,5, 6,6, 6,8,
++    2,3, 3,1, 3,2, 3,4, 3,5, 3,6, 4,7, 5,0, 5,8,
++    2,3, 2,6, 3,0, 3,1, 4,4, 4,5, 4,7, 5,2, 5,8,
++    2,4, 2,7, 3,3, 3,6, 4,1, 4,2, 4,5, 5,0, 5,8,
++    2,6, 3,1, 3,3, 3,5, 3,7, 3,8, 4,0, 5,2, 5,4,
++    2,0, 2,1, 3,2, 3,3, 4,4, 4,5, 5,6, 5,7, 4,8,
++    1,0, 2,2, 2,-2,
++    1,-3, 1,3,
++    2,-17, 2,-5, 2,5, 2,17,
++    2,-7, 2,2, 2,9, 2,18,
++    2,-18, 2,-9, 2,-2, 2,7,
++    2,-28, 2,28, 3,-49, 3,-9, 3,9, 4,49, 5,-79, 5,79,
++    2,-1, 2,13, 2,26, 3,39, 4,-16, 5,55, 6,-37, 6,76,
++    2,-26, 2,-13, 2,1, 3,-39, 4,16, 5,-55, 6,-76, 6,37
++  };
++  ushort huff[19][256];
++  int row, col, tree, nreps, rep, step, i, c, s, r, x, y, val;
++  short last[3] = { 16,16,16 }, mul[3], buf[3][3][386];
++  static const ushort pt[] =
++    { 0,0, 1280,1344, 2320,3616, 3328,8000, 4095,16383, 65535,16383 };
++
++  for (i=2; i < 12; i+=2)
++    for (c=pt[i-2]; c <= pt[i]; c++)
++      curve[c] = (float)
++	(c-pt[i-2]) / (pt[i]-pt[i-2]) * (pt[i+1]-pt[i-1]) + pt[i-1] + 0.5;
++  for (s=i=0; i < sizeof src; i+=2)
++    FORC(256 >> src[i])
++      ((ushort *)huff)[s++] = src[i] << 8 | (uchar) src[i+1];
++  s = kodak_cbpp == 243 ? 2 : 3;
++  FORC(256) huff[18][c] = (8-s) << 8 | c >> s << s | 1 << (s-1);
++  getbits(-1);
++  for (i=0; i < sizeof(buf)/sizeof(short); i++)
++    ((short *)buf)[i] = 2048;
++  for (row=0; row < height; row+=4) {
++    FORC3 mul[c] = getbits(6);
++    FORC3 {
++      val = ((0x1000000/last[c] + 0x7ff) >> 12) * mul[c];
++      s = val > 65564 ? 10:12;
++      x = ~(-1 << (s-1));
++      val <<= 12-s;
++      for (i=0; i < sizeof(buf[0])/sizeof(short); i++)
++	((short *)buf[c])[i] = (((short *)buf[c])[i] * val + x) >> s;
++      last[c] = mul[c];
++      for (r=0; r <= !c; r++) {
++	buf[c][1][width/2] = buf[c][2][width/2] = mul[c] << 7;
++	for (tree=1, col=width/2; col > 0; ) {
++	  if ((tree = radc_token(tree))) {
++	    col -= 2;
++	    if (tree == 8)
++	      FORYX buf[c][y][x] = (uchar) radc_token(18) * mul[c];
++	    else
++	      FORYX buf[c][y][x] = radc_token(tree+10) * 16 + PREDICTOR;
++	  } else
++	    do {
++	      nreps = (col > 2) ? radc_token(9) + 1 : 1;
++	      for (rep=0; rep < 8 && rep < nreps && col > 0; rep++) {
++		col -= 2;
++		FORYX buf[c][y][x] = PREDICTOR;
++		if (rep & 1) {
++		  step = radc_token(10) << 4;
++		  FORYX buf[c][y][x] += step;
++		}
++	      }
++	    } while (nreps == 9);
++	}
++	for (y=0; y < 2; y++)
++	  for (x=0; x < width/2; x++) {
++	    val = (buf[c][y+1][x] << 4) / mul[c];
++	    if (val < 0) val = 0;
++	    if (c) RAW(row+y*2+c-1,x*2+2-c) = val;
++	    else   RAW(row+r*2+y,x*2+y) = val;
++	  }
++	memcpy (buf[c][0]+!c, buf[c][2], sizeof buf[c][0]-2*!c);
++      }
++    }
++    for (y=row; y < row+4; y++)
++      for (x=0; x < width; x++)
++	if ((x+y) & 1) {
++	  r = x ? x-1 : x+1;
++	  s = x+1 < width ? x+1 : x-1;
++	  val = (RAW(y,x)-2048)*2 + (RAW(y,r)+RAW(y,s))/2;
++	  if (val < 0) val = 0;
++	  RAW(y,x) = val;
++	}
++  }
++  for (i=0; i < height*width; i++)
++    raw_image[i] = curve[raw_image[i]];
++  maximum = 0x3fff;
++}
++
++#undef FORYX
++#undef PREDICTOR
++
++#ifdef NO_JPEG
++void CLASS kodak_jpeg_load_raw() {}
++void CLASS lossy_dng_load_raw() {}
++#else
++
++METHODDEF(boolean)
++fill_input_buffer (j_decompress_ptr cinfo)
++{
++  static uchar jpeg_buffer[4096];
++  size_t nbytes;
++
++  nbytes = fread (jpeg_buffer, 1, 4096, ifp);
++  swab (jpeg_buffer, jpeg_buffer, nbytes);
++  cinfo->src->next_input_byte = jpeg_buffer;
++  cinfo->src->bytes_in_buffer = nbytes;
++  return TRUE;
++}
++
++void CLASS kodak_jpeg_load_raw()
++{
++  struct jpeg_decompress_struct cinfo;
++  struct jpeg_error_mgr jerr;
++  JSAMPARRAY buf;
++  JSAMPLE (*pixel)[3];
++  int row, col;
++
++  cinfo.err = jpeg_std_error (&jerr);
++  jpeg_create_decompress (&cinfo);
++  jpeg_stdio_src (&cinfo, ifp);
++  cinfo.src->fill_input_buffer = fill_input_buffer;
++  jpeg_read_header (&cinfo, TRUE);
++  jpeg_start_decompress (&cinfo);
++  if ((cinfo.output_width      != width  ) ||
++      (cinfo.output_height*2   != height ) ||
++      (cinfo.output_components != 3      )) {
++    fprintf (stderr,_("%s: incorrect JPEG dimensions\n"), ifname);
++    jpeg_destroy_decompress (&cinfo);
++    longjmp (failure, 3);
++  }
++  buf = (*cinfo.mem->alloc_sarray)
++		((j_common_ptr) &cinfo, JPOOL_IMAGE, width*3, 1);
++
++  while (cinfo.output_scanline < cinfo.output_height) {
++    row = cinfo.output_scanline * 2;
++    jpeg_read_scanlines (&cinfo, buf, 1);
++    pixel = (JSAMPLE (*)[3]) buf[0];
++    for (col=0; col < width; col+=2) {
++      RAW(row+0,col+0) = pixel[col+0][1] << 1;
++      RAW(row+1,col+1) = pixel[col+1][1] << 1;
++      RAW(row+0,col+1) = pixel[col][0] + pixel[col+1][0];
++      RAW(row+1,col+0) = pixel[col][2] + pixel[col+1][2];
++    }
++  }
++  jpeg_finish_decompress (&cinfo);
++  jpeg_destroy_decompress (&cinfo);
++  maximum = 0xff << 1;
++}
++
++void CLASS gamma_curve (double pwr, double ts, int mode, int imax);
++
++void CLASS lossy_dng_load_raw()
++{
++  struct jpeg_decompress_struct cinfo;
++  struct jpeg_error_mgr jerr;
++  JSAMPARRAY buf;
++  JSAMPLE (*pixel)[3];
++  unsigned sorder=order, ntags, opcode, deg, i, j, c;
++  unsigned save=data_offset-4, trow=0, tcol=0, row, col;
++  ushort cur[3][256];
++  double coeff[9], tot;
++
++  if (meta_offset) {
++    fseek (ifp, meta_offset, SEEK_SET);
++    order = 0x4d4d;
++    ntags = get4();
++    while (ntags--) {
++      opcode = get4(); get4(); get4();
++      if (opcode != 8)
++      { fseek (ifp, get4(), SEEK_CUR); continue; }
++      fseek (ifp, 20, SEEK_CUR);
++      if ((c = get4()) > 2) break;
++      fseek (ifp, 12, SEEK_CUR);
++      if ((deg = get4()) > 8) break;
++      for (i=0; i <= deg && i < 9; i++)
++	coeff[i] = getreal(12);
++      for (i=0; i < 256; i++) {
++	for (tot=j=0; j <= deg; j++)
++	  tot += coeff[j] * pow(i/255.0, j);
++	cur[c][i] = tot*0xffff;
++      }
++    }
++    order = sorder;
++  } else {
++    gamma_curve (1/2.4, 12.92, 1, 255);
++    FORC3 memcpy (cur[c], curve, sizeof cur[0]);
++  }
++  cinfo.err = jpeg_std_error (&jerr);
++  jpeg_create_decompress (&cinfo);
++  while (trow < raw_height) {
++    fseek (ifp, save+=4, SEEK_SET);
++    if (tile_length < INT_MAX)
++      fseek (ifp, get4(), SEEK_SET);
++    jpeg_stdio_src (&cinfo, ifp);
++    jpeg_read_header (&cinfo, TRUE);
++    jpeg_start_decompress (&cinfo);
++    buf = (*cinfo.mem->alloc_sarray)
++	((j_common_ptr) &cinfo, JPOOL_IMAGE, cinfo.output_width*3, 1);
++    while (cinfo.output_scanline < cinfo.output_height &&
++	(row = trow + cinfo.output_scanline) < height) {
++      jpeg_read_scanlines (&cinfo, buf, 1);
++      pixel = (JSAMPLE (*)[3]) buf[0];
++      for (col=0; col < cinfo.output_width && tcol+col < width; col++) {
++	FORC3 image[row*width+tcol+col][c] = cur[c][pixel[col][c]];
++      }
++    }
++    jpeg_abort_decompress (&cinfo);
++    if ((tcol += tile_width) >= raw_width)
++      trow += tile_length + (tcol = 0);
++  }
++  jpeg_destroy_decompress (&cinfo);
++  maximum = 0xffff;
++}
++#endif
++
++void CLASS kodak_dc120_load_raw()
++{
++  static const int mul[4] = { 162, 192, 187,  92 };
++  static const int add[4] = {   0, 636, 424, 212 };
++  uchar pixel[848];
++  int row, shift, col;
++
++  for (row=0; row < height; row++) {
++    if (fread (pixel, 1, 848, ifp) < 848) derror();
++    shift = row * mul[row & 3] + add[row & 3];
++    for (col=0; col < width; col++)
++      RAW(row,col) = (ushort) pixel[(col + shift) % 848];
++  }
++  maximum = 0xff;
++}
++
++void CLASS eight_bit_load_raw()
++{
++  uchar *pixel;
++  unsigned row, col;
++
++  pixel = (uchar *) calloc (raw_width, sizeof *pixel);
++  merror (pixel, "eight_bit_load_raw()");
++  for (row=0; row < raw_height; row++) {
++    if (fread (pixel, 1, raw_width, ifp) < raw_width) derror();
++    for (col=0; col < raw_width; col++)
++      RAW(row,col) = curve[pixel[col]];
++  }
++  free (pixel);
++  maximum = curve[0xff];
++}
++
++void CLASS kodak_c330_load_raw()
++{
++  uchar *pixel;
++  int row, col, y, cb, cr, rgb[3], c;
++
++  pixel = (uchar *) calloc (raw_width, 2*sizeof *pixel);
++  merror (pixel, "kodak_c330_load_raw()");
++  for (row=0; row < height; row++) {
++    if (fread (pixel, raw_width, 2, ifp) < 2) derror();
++    if (load_flags && (row & 31) == 31)
++      fseek (ifp, raw_width*32, SEEK_CUR);
++    for (col=0; col < width; col++) {
++      y  = pixel[col*2];
++      cb = pixel[(col*2 & -4) | 1] - 128;
++      cr = pixel[(col*2 & -4) | 3] - 128;
++      rgb[1] = y - ((cb + cr + 2) >> 2);
++      rgb[2] = rgb[1] + cb;
++      rgb[0] = rgb[1] + cr;
++      FORC3 image[row*width+col][c] = curve[LIM(rgb[c],0,255)];
++    }
++  }
++  free (pixel);
++  maximum = curve[0xff];
++}
++
++void CLASS kodak_c603_load_raw()
++{
++  uchar *pixel;
++  int row, col, y, cb, cr, rgb[3], c;
++
++  pixel = (uchar *) calloc (raw_width, 3*sizeof *pixel);
++  merror (pixel, "kodak_c603_load_raw()");
++  for (row=0; row < height; row++) {
++    if (~row & 1)
++      if (fread (pixel, raw_width, 3, ifp) < 3) derror();
++    for (col=0; col < width; col++) {
++      y  = pixel[width*2*(row & 1) + col];
++      cb = pixel[width + (col & -2)]   - 128;
++      cr = pixel[width + (col & -2)+1] - 128;
++      rgb[1] = y - ((cb + cr + 2) >> 2);
++      rgb[2] = rgb[1] + cb;
++      rgb[0] = rgb[1] + cr;
++      FORC3 image[row*width+col][c] = curve[LIM(rgb[c],0,255)];
++    }
++  }
++  free (pixel);
++  maximum = curve[0xff];
++}
++
++void CLASS kodak_262_load_raw()
++{
++  static const uchar kodak_tree[2][26] =
++  { { 0,1,5,1,1,2,0,0,0,0,0,0,0,0,0,0, 0,1,2,3,4,5,6,7,8,9 },
++    { 0,3,1,1,1,1,1,2,0,0,0,0,0,0,0,0, 0,1,2,3,4,5,6,7,8,9 } };
++  ushort *huff[2];
++  uchar *pixel;
++  int *strip, ns, c, row, col, chess, pi=0, pi1, pi2, pred, val;
++
++  FORC(2) huff[c] = make_decoder (kodak_tree[c]);
++  ns = (raw_height+63) >> 5;
++  pixel = (uchar *) malloc (raw_width*32 + ns*4);
++  merror (pixel, "kodak_262_load_raw()");
++  strip = (int *) (pixel + raw_width*32);
++  order = 0x4d4d;
++  FORC(ns) strip[c] = get4();
++  for (row=0; row < raw_height; row++) {
++    if ((row & 31) == 0) {
++      fseek (ifp, strip[row >> 5], SEEK_SET);
++      getbits(-1);
++      pi = 0;
++    }
++    for (col=0; col < raw_width; col++) {
++      chess = (row + col) & 1;
++      pi1 = chess ? pi-2           : pi-raw_width-1;
++      pi2 = chess ? pi-2*raw_width : pi-raw_width+1;
++      if (col <= chess) pi1 = -1;
++      if (pi1 < 0) pi1 = pi2;
++      if (pi2 < 0) pi2 = pi1;
++      if (pi1 < 0 && col > 1) pi1 = pi2 = pi-2;
++      pred = (pi1 < 0) ? 0 : (pixel[pi1] + pixel[pi2]) >> 1;
++      pixel[pi] = val = pred + ljpeg_diff (huff[chess]);
++      if (val >> 8) derror();
++      val = curve[pixel[pi++]];
++      RAW(row,col) = val;
++    }
++  }
++  free (pixel);
++  FORC(2) free (huff[c]);
++}
++
++int CLASS kodak_65000_decode (short *out, int bsize)
++{
++  uchar c, blen[768];
++  ushort raw[6];
++  INT64 bitbuf=0;
++  int save, bits=0, i, j, len, diff;
++
++  save = ftell(ifp);
++  bsize = (bsize + 3) & -4;
++  for (i=0; i < bsize; i+=2) {
++    c = fgetc(ifp);
++    if ((blen[i  ] = c & 15) > 12 ||
++	(blen[i+1] = c >> 4) > 12 ) {
++      fseek (ifp, save, SEEK_SET);
++      for (i=0; i < bsize; i+=8) {
++	read_shorts (raw, 6);
++	out[i  ] = raw[0] >> 12 << 8 | raw[2] >> 12 << 4 | raw[4] >> 12;
++	out[i+1] = raw[1] >> 12 << 8 | raw[3] >> 12 << 4 | raw[5] >> 12;
++	for (j=0; j < 6; j++)
++	  out[i+2+j] = raw[j] & 0xfff;
++      }
++      return 1;
++    }
++  }
++  if ((bsize & 7) == 4) {
++    bitbuf  = fgetc(ifp) << 8;
++    bitbuf += fgetc(ifp);
++    bits = 16;
++  }
++  for (i=0; i < bsize; i++) {
++    len = blen[i];
++    if (bits < len) {
++      for (j=0; j < 32; j+=8)
++	bitbuf += (INT64) fgetc(ifp) << (bits+(j^8));
++      bits += 32;
++    }
++    diff = bitbuf & (0xffff >> (16-len));
++    bitbuf >>= len;
++    bits -= len;
++    if ((diff & (1 << (len-1))) == 0)
++      diff -= (1 << len) - 1;
++    out[i] = diff;
++  }
++  return 0;
++}
++
++void CLASS kodak_65000_load_raw()
++{
++  short buf[256];
++  int row, col, len, pred[2], ret, i;
++
++  for (row=0; row < height; row++)
++    for (col=0; col < width; col+=256) {
++      pred[0] = pred[1] = 0;
++      len = MIN (256, width-col);
++      ret = kodak_65000_decode (buf, len);
++      for (i=0; i < len; i++)
++	if ((RAW(row,col+i) =	curve[ret ? buf[i] :
++		(pred[i & 1] += buf[i])]) >> 12) derror();
++    }
++}
++
++void CLASS kodak_ycbcr_load_raw()
++{
++  short buf[384], *bp;
++  int row, col, len, c, i, j, k, y[2][2], cb, cr, rgb[3];
++  ushort *ip;
++
++  if (!image) return;
++  for (row=0; row < height; row+=2)
++    for (col=0; col < width; col+=128) {
++      len = MIN (128, width-col);
++      kodak_65000_decode (buf, len*3);
++      y[0][1] = y[1][1] = cb = cr = 0;
++      for (bp=buf, i=0; i < len; i+=2, bp+=2) {
++	cb += bp[4];
++	cr += bp[5];
++	rgb[1] = -((cb + cr + 2) >> 2);
++	rgb[2] = rgb[1] + cb;
++	rgb[0] = rgb[1] + cr;
++	for (j=0; j < 2; j++)
++	  for (k=0; k < 2; k++) {
++	    if ((y[j][k] = y[j][k^1] + *bp++) >> 10) derror();
++	    ip = image[(row+j)*width + col+i+k];
++	    FORC3 ip[c] = curve[LIM(y[j][k]+rgb[c], 0, 0xfff)];
++	  }
++      }
++    }
++}
++
++void CLASS kodak_rgb_load_raw()
++{
++  short buf[768], *bp;
++  int row, col, len, c, i, rgb[3];
++  ushort *ip=image[0];
++
++  for (row=0; row < height; row++)
++    for (col=0; col < width; col+=256) {
++      len = MIN (256, width-col);
++      kodak_65000_decode (buf, len*3);
++      memset (rgb, 0, sizeof rgb);
++      for (bp=buf, i=0; i < len; i++, ip+=4)
++	FORC3 if ((ip[c] = rgb[c] += *bp++) >> 12) derror();
++    }
++}
++
++void CLASS kodak_thumb_load_raw()
++{
++  int row, col;
++  colors = thumb_misc >> 5;
++  for (row=0; row < height; row++)
++    for (col=0; col < width; col++)
++      read_shorts (image[row*width+col], colors);
++  maximum = (1 << (thumb_misc & 31)) - 1;
++}
++
++void CLASS sony_decrypt (unsigned *data, int len, int start, int key)
++{
++  static unsigned pad[128], p;
++
++  if (start) {
++    for (p=0; p < 4; p++)
++      pad[p] = key = key * 48828125 + 1;
++    pad[3] = pad[3] << 1 | (pad[0]^pad[2]) >> 31;
++    for (p=4; p < 127; p++)
++      pad[p] = (pad[p-4]^pad[p-2]) << 1 | (pad[p-3]^pad[p-1]) >> 31;
++    for (p=0; p < 127; p++)
++      pad[p] = htonl(pad[p]);
++  }
++  while (len-- && p++)
++    *data++ ^= pad[(p-1) & 127] = pad[p & 127] ^ pad[(p+64) & 127];
++}
++
++void CLASS sony_load_raw()
++{
++  uchar head[40];
++  ushort *pixel;
++  unsigned i, key, row, col;
++
++  fseek (ifp, 200896, SEEK_SET);
++  fseek (ifp, (unsigned) fgetc(ifp)*4 - 1, SEEK_CUR);
++  order = 0x4d4d;
++  key = get4();
++  fseek (ifp, 164600, SEEK_SET);
++  fread (head, 1, 40, ifp);
++  sony_decrypt ((unsigned *) head, 10, 1, key);
++  for (i=26; i-- > 22; )
++    key = key << 8 | head[i];
++  fseek (ifp, data_offset, SEEK_SET);
++  for (row=0; row < raw_height; row++) {
++    pixel = raw_image + row*raw_width;
++    if (fread (pixel, 2, raw_width, ifp) < raw_width) derror();
++    sony_decrypt ((unsigned *) pixel, raw_width/2, !row, key);
++    for (col=0; col < raw_width; col++)
++      if ((pixel[col] = ntohs(pixel[col])) >> 14) derror();
++  }
++  maximum = 0x3ff0;
++}
++
++void CLASS sony_arw_load_raw()
++{
++  ushort huff[32770];
++  static const ushort tab[18] =
++  { 0xf11,0xf10,0xe0f,0xd0e,0xc0d,0xb0c,0xa0b,0x90a,0x809,
++    0x708,0x607,0x506,0x405,0x304,0x303,0x300,0x202,0x201 };
++  int i, c, n, col, row, sum=0;
++
++  huff[0] = 15;
++  for (n=i=0; i < 18; i++)
++    FORC(32768 >> (tab[i] >> 8)) huff[++n] = tab[i];
++  getbits(-1);
++  for (col = raw_width; col--; )
++    for (row=0; row < raw_height+1; row+=2) {
++      if (row == raw_height) row = 1;
++      if ((sum += ljpeg_diff(huff)) >> 12) derror();
++      if (row < height) RAW(row,col) = sum;
++    }
++}
++
++void CLASS sony_arw2_load_raw()
++{
++  uchar *data, *dp;
++  ushort pix[16];
++  int row, col, val, max, min, imax, imin, sh, bit, i;
++
++  data = (uchar *) malloc (raw_width+1);
++  merror (data, "sony_arw2_load_raw()");
++  for (row=0; row < height; row++) {
++    fread (data, 1, raw_width, ifp);
++    for (dp=data, col=0; col < raw_width-30; dp+=16) {
++      max = 0x7ff & (val = sget4(dp));
++      min = 0x7ff & val >> 11;
++      imax = 0x0f & val >> 22;
++      imin = 0x0f & val >> 26;
++      for (sh=0; sh < 4 && 0x80 << sh <= max-min; sh++);
++      for (bit=30, i=0; i < 16; i++)
++	if      (i == imax) pix[i] = max;
++	else if (i == imin) pix[i] = min;
++	else {
++	  pix[i] = ((sget2(dp+(bit >> 3)) >> (bit & 7) & 0x7f) << sh) + min;
++	  if (pix[i] > 0x7ff) pix[i] = 0x7ff;
++	  bit += 7;
++	}
++      for (i=0; i < 16; i++, col+=2)
++	RAW(row,col) = curve[pix[i] << 1] >> 2;
++      col -= col & 1 ? 1:31;
++    }
++  }
++  free (data);
++}
++
++void CLASS samsung_load_raw()
++{
++  int row, col, c, i, dir, op[4], len[4];
++
++  order = 0x4949;
++  for (row=0; row < raw_height; row++) {
++    fseek (ifp, strip_offset+row*4, SEEK_SET);
++    fseek (ifp, data_offset+get4(), SEEK_SET);
++    ph1_bits(-1);
++    FORC4 len[c] = row < 2 ? 7:4;
++    for (col=0; col < raw_width; col+=16) {
++      dir = ph1_bits(1);
++      FORC4 op[c] = ph1_bits(2);
++      FORC4 switch (op[c]) {
++	case 3: len[c] = ph1_bits(4);	break;
++	case 2: len[c]--;		break;
++	case 1: len[c]++;
++      }
++      for (c=0; c < 16; c+=2) {
++	i = len[((c & 1) << 1) | (c >> 3)];
++        RAW(row,col+c) = ((signed) ph1_bits(i) << (32-i) >> (32-i)) +
++	  (dir ? RAW(row+(~c | -2),col+c) : col ? RAW(row,col+(c | -2)) : 128);
++	if (c == 14) c = -1;
++      }
++    }
++  }
++  for (row=0; row < raw_height-1; row+=2)
++    for (col=0; col < raw_width-1; col+=2)
++      SWAP (RAW(row,col+1), RAW(row+1,col));
++}
++
++void CLASS samsung2_load_raw()
++{
++  static const ushort tab[14] =
++  { 0x304,0x307,0x206,0x205,0x403,0x600,0x709,
++    0x80a,0x90b,0xa0c,0xa0d,0x501,0x408,0x402 };
++  ushort huff[1026], vpred[2][2] = {{0,0},{0,0}}, hpred[2];
++  int i, c, n, row, col, diff;
++
++  huff[0] = 10;
++  for (n=i=0; i < 14; i++)
++    FORC(1024 >> (tab[i] >> 8)) huff[++n] = tab[i];
++  getbits(-1);
++  for (row=0; row < raw_height; row++)
++    for (col=0; col < raw_width; col++) {
++      diff = ljpeg_diff (huff);
++      if (col < 2) hpred[col] = vpred[row & 1][col] += diff;
++      else	   hpred[col & 1] += diff;
++      RAW(row,col) = hpred[col & 1];
++      if (hpred[col & 1] >> tiff_bps) derror();
++    }
++}
++
++void CLASS samsung3_load_raw()
++{
++  int opt, init, mag, pmode, row, tab, col, pred, diff, i, c;
++  ushort lent[3][2], len[4], *prow[2];
++
++  order = 0x4949;
++  fseek (ifp, 9, SEEK_CUR);
++  opt = fgetc(ifp);
++  init = (get2(),get2());
++  for (row=0; row < raw_height; row++) {
++    fseek (ifp, (data_offset-ftell(ifp)) & 15, SEEK_CUR);
++    ph1_bits(-1);
++    mag = 0; pmode = 7;
++    FORC(6) ((ushort *)lent)[c] = row < 2 ? 7:4;
++    prow[ row & 1] = &RAW(row-1,1-((row & 1) << 1));	// green
++    prow[~row & 1] = &RAW(row-2,0);			// red and blue
++    for (tab=0; tab+15 < raw_width; tab+=16) {
++      if (~opt & 4 && !(tab & 63)) {
++	i = ph1_bits(2);
++	mag = i < 3 ? mag-'2'+"204"[i] : ph1_bits(12);
++      }
++      if (opt & 2)
++	pmode = 7 - 4*ph1_bits(1);
++      else if (!ph1_bits(1))
++	pmode = ph1_bits(3);
++      if (opt & 1 || !ph1_bits(1)) {
++	FORC4 len[c] = ph1_bits(2);
++	FORC4 {
++	  i = ((row & 1) << 1 | (c & 1)) % 3;
++	  len[c] = len[c] < 3 ? lent[i][0]-'1'+"120"[len[c]] : ph1_bits(4);
++	  lent[i][0] = lent[i][1];
++	  lent[i][1] = len[c];
++	}
++      }
++      FORC(16) {
++	col = tab + (((c & 7) << 1)^(c >> 3)^(row & 1));
++	pred = (pmode == 7 || row < 2)
++	     ? (tab ? RAW(row,tab-2+(col & 1)) : init)
++	     : (prow[col & 1][col-'4'+"0224468"[pmode]] +
++		prow[col & 1][col-'4'+"0244668"[pmode]] + 1) >> 1;
++	diff = ph1_bits (i = len[c >> 2]);
++	if (diff >> (i-1)) diff -= 1 << i;
++	diff = diff * (mag*2+1) + mag;
++	RAW(row,col) = pred + diff;
++      }
++    }
++  }
++}
++
++#define HOLE(row) ((holes >> (((row) - raw_height) & 7)) & 1)
++
++/* Kudos to Rich Taylor for figuring out SMaL's compression algorithm. */
++void CLASS smal_decode_segment (unsigned seg[2][2], int holes)
++{
++  uchar hist[3][13] = {
++    { 7, 7, 0, 0, 63, 55, 47, 39, 31, 23, 15, 7, 0 },
++    { 7, 7, 0, 0, 63, 55, 47, 39, 31, 23, 15, 7, 0 },
++    { 3, 3, 0, 0, 63,     47,     31,     15,    0 } };
++  int low, high=0xff, carry=0, nbits=8;
++  int pix, s, count, bin, next, i, sym[3];
++  uchar diff, pred[]={0,0};
++  ushort data=0, range=0;
++
++  fseek (ifp, seg[0][1]+1, SEEK_SET);
++  getbits(-1);
++  if (seg[1][0] > raw_width*raw_height)
++      seg[1][0] = raw_width*raw_height;
++  for (pix=seg[0][0]; pix < seg[1][0]; pix++) {
++    for (s=0; s < 3; s++) {
++      data = data << nbits | getbits(nbits);
++      if (carry < 0)
++	carry = (nbits += carry+1) < 1 ? nbits-1 : 0;
++      while (--nbits >= 0)
++	if ((data >> nbits & 0xff) == 0xff) break;
++      if (nbits > 0)
++	  data = ((data & ((1 << (nbits-1)) - 1)) << 1) |
++	((data + (((data & (1 << (nbits-1)))) << 1)) & (-1 << nbits));
++      if (nbits >= 0) {
++	data += getbits(1);
++	carry = nbits - 8;
++      }
++      count = ((((data-range+1) & 0xffff) << 2) - 1) / (high >> 4);
++      for (bin=0; hist[s][bin+5] > count; bin++);
++		low = hist[s][bin+5] * (high >> 4) >> 2;
++      if (bin) high = hist[s][bin+4] * (high >> 4) >> 2;
++      high -= low;
++      for (nbits=0; high << nbits < 128; nbits++);
++      range = (range+low) << nbits;
++      high <<= nbits;
++      next = hist[s][1];
++      if (++hist[s][2] > hist[s][3]) {
++	next = (next+1) & hist[s][0];
++	hist[s][3] = (hist[s][next+4] - hist[s][next+5]) >> 2;
++	hist[s][2] = 1;
++      }
++      if (hist[s][hist[s][1]+4] - hist[s][hist[s][1]+5] > 1) {
++	if (bin < hist[s][1])
++	  for (i=bin; i < hist[s][1]; i++) hist[s][i+5]--;
++	else if (next <= bin)
++	  for (i=hist[s][1]; i < bin; i++) hist[s][i+5]++;
++      }
++      hist[s][1] = next;
++      sym[s] = bin;
++    }
++    diff = sym[2] << 5 | sym[1] << 2 | (sym[0] & 3);
++    if (sym[0] & 4)
++      diff = diff ? -diff : 0x80;
++    if (ftell(ifp) + 12 >= seg[1][1])
++      diff = 0;
++    raw_image[pix] = pred[pix & 1] += diff;
++    if (!(pix & 1) && HOLE(pix / raw_width)) pix += 2;
++  }
++  maximum = 0xff;
++}
++
++void CLASS smal_v6_load_raw()
++{
++  unsigned seg[2][2];
++
++  fseek (ifp, 16, SEEK_SET);
++  seg[0][0] = 0;
++  seg[0][1] = get2();
++  seg[1][0] = raw_width * raw_height;
++  seg[1][1] = INT_MAX;
++  smal_decode_segment (seg, 0);
++}
++
++int CLASS median4 (int *p)
++{
++  int min, max, sum, i;
++
++  min = max = sum = p[0];
++  for (i=1; i < 4; i++) {
++    sum += p[i];
++    if (min > p[i]) min = p[i];
++    if (max < p[i]) max = p[i];
++  }
++  return (sum - min - max) >> 1;
++}
++
++void CLASS fill_holes (int holes)
++{
++  int row, col, val[4];
++
++  for (row=2; row < height-2; row++) {
++    if (!HOLE(row)) continue;
++    for (col=1; col < width-1; col+=4) {
++      val[0] = RAW(row-1,col-1);
++      val[1] = RAW(row-1,col+1);
++      val[2] = RAW(row+1,col-1);
++      val[3] = RAW(row+1,col+1);
++      RAW(row,col) = median4(val);
++    }
++    for (col=2; col < width-2; col+=4)
++      if (HOLE(row-2) || HOLE(row+2))
++	RAW(row,col) = (RAW(row,col-2) + RAW(row,col+2)) >> 1;
++      else {
++	val[0] = RAW(row,col-2);
++	val[1] = RAW(row,col+2);
++	val[2] = RAW(row-2,col);
++	val[3] = RAW(row+2,col);
++	RAW(row,col) = median4(val);
++      }
++  }
++}
++
++void CLASS smal_v9_load_raw()
++{
++  unsigned seg[256][2], offset, nseg, holes, i;
++
++  fseek (ifp, 67, SEEK_SET);
++  offset = get4();
++  nseg = (uchar) fgetc(ifp);
++  fseek (ifp, offset, SEEK_SET);
++  for (i=0; i < nseg*2; i++)
++    ((unsigned *)seg)[i] = get4() + data_offset*(i & 1);
++  fseek (ifp, 78, SEEK_SET);
++  holes = fgetc(ifp);
++  fseek (ifp, 88, SEEK_SET);
++  seg[nseg][0] = raw_height * raw_width;
++  seg[nseg][1] = get4() + data_offset;
++  for (i=0; i < nseg; i++)
++    smal_decode_segment (seg+i, holes);
++  if (holes) fill_holes (holes);
++}
++
++void CLASS redcine_load_raw()
++{
++#ifndef NO_JASPER
++  int c, row, col;
++  jas_stream_t *in;
++  jas_image_t *jimg;
++  jas_matrix_t *jmat;
++  jas_seqent_t *data;
++  ushort *img, *pix;
++
++  jas_init();
++  in = jas_stream_fopen (ifname, "rb");
++  jas_stream_seek (in, data_offset+20, SEEK_SET);
++  jimg = jas_image_decode (in, -1, 0);
++  if (!jimg) longjmp (failure, 3);
++  jmat = jas_matrix_create (height/2, width/2);
++  merror (jmat, "redcine_load_raw()");
++  img = (ushort *) calloc ((height+2), (width+2)*2);
++  merror (img, "redcine_load_raw()");
++  FORC4 {
++    jas_image_readcmpt (jimg, c, 0, 0, width/2, height/2, jmat);
++    data = jas_matrix_getref (jmat, 0, 0);
++    for (row = c >> 1; row < height; row+=2)
++      for (col = c & 1; col < width; col+=2)
++	img[(row+1)*(width+2)+col+1] = data[(row/2)*(width/2)+col/2];
++  }
++  for (col=1; col <= width; col++) {
++    img[col] = img[2*(width+2)+col];
++    img[(height+1)*(width+2)+col] = img[(height-1)*(width+2)+col];
++  }
++  for (row=0; row < height+2; row++) {
++    img[row*(width+2)] = img[row*(width+2)+2];
++    img[(row+1)*(width+2)-1] = img[(row+1)*(width+2)-3];
++  }
++  for (row=1; row <= height; row++) {
++    pix = img + row*(width+2) + (col = 1 + (FC(row,1) & 1));
++    for (   ; col <= width; col+=2, pix+=2) {
++      c = (((pix[0] - 0x800) << 3) +
++	pix[-(width+2)] + pix[width+2] + pix[-1] + pix[1]) >> 2;
++      pix[0] = LIM(c,0,4095);
++    }
++  }
++  for (row=0; row < height; row++)
++    for (col=0; col < width; col++)
++      RAW(row,col) = curve[img[(row+1)*(width+2)+col+1]];
++  free (img);
++  jas_matrix_destroy (jmat);
++  jas_image_destroy (jimg);
++  jas_stream_close (in);
++#endif
++}
++
++/* RESTRICTED code starts here */
++
++void CLASS foveon_decoder (unsigned size, unsigned code)
++{
++  static unsigned huff[1024];
++  struct decode *cur;
++  int i, len;
++
++  if (!code) {
++    for (i=0; i < size; i++)
++      huff[i] = get4();
++    memset (first_decode, 0, sizeof first_decode);
++    free_decode = first_decode;
++  }
++  cur = free_decode++;
++  if (free_decode > first_decode+2048) {
++    fprintf (stderr,_("%s: decoder table overflow\n"), ifname);
++    longjmp (failure, 2);
++  }
++  if (code)
++    for (i=0; i < size; i++)
++      if (huff[i] == code) {
++	cur->leaf = i;
++	return;
++      }
++  if ((len = code >> 27) > 26) return;
++  code = (len+1) << 27 | (code & 0x3ffffff) << 1;
++
++  cur->branch[0] = free_decode;
++  foveon_decoder (size, code);
++  cur->branch[1] = free_decode;
++  foveon_decoder (size, code+1);
++}
++
++void CLASS foveon_thumb()
++{
++  unsigned bwide, row, col, bitbuf=0, bit=1, c, i;
++  char *buf;
++  struct decode *dindex;
++  short pred[3];
++
++  bwide = get4();
++  fprintf (ofp, "P6\n%d %d\n255\n", thumb_width, thumb_height);
++  if (bwide > 0) {
++    if (bwide < thumb_width*3) return;
++    buf = (char *) malloc (bwide);
++    merror (buf, "foveon_thumb()");
++    for (row=0; row < thumb_height; row++) {
++      fread  (buf, 1, bwide, ifp);
++      fwrite (buf, 3, thumb_width, ofp);
++    }
++    free (buf);
++    return;
++  }
++  foveon_decoder (256, 0);
++
++  for (row=0; row < thumb_height; row++) {
++    memset (pred, 0, sizeof pred);
++    if (!bit) get4();
++    for (bit=col=0; col < thumb_width; col++)
++      FORC3 {
++	for (dindex=first_decode; dindex->branch[0]; ) {
++	  if ((bit = (bit-1) & 31) == 31)
++	    for (i=0; i < 4; i++)
++	      bitbuf = (bitbuf << 8) + fgetc(ifp);
++	  dindex = dindex->branch[bitbuf >> bit & 1];
++	}
++	pred[c] += dindex->leaf;
++	fputc (pred[c], ofp);
++      }
++  }
++}
++
++void CLASS foveon_sd_load_raw()
++{
++  struct decode *dindex;
++  short diff[1024];
++  unsigned bitbuf=0;
++  int pred[3], row, col, bit=-1, c, i;
++
++  read_shorts ((ushort *) diff, 1024);
++  if (!load_flags) foveon_decoder (1024, 0);
++
++  for (row=0; row < height; row++) {
++    memset (pred, 0, sizeof pred);
++    if (!bit && !load_flags && atoi(model+2) < 14) get4();
++    for (col=bit=0; col < width; col++) {
++      if (load_flags) {
++	bitbuf = get4();
++	FORC3 pred[2-c] += diff[bitbuf >> c*10 & 0x3ff];
++      }
++      else FORC3 {
++	for (dindex=first_decode; dindex->branch[0]; ) {
++	  if ((bit = (bit-1) & 31) == 31)
++	    for (i=0; i < 4; i++)
++	      bitbuf = (bitbuf << 8) + fgetc(ifp);
++	  dindex = dindex->branch[bitbuf >> bit & 1];
++	}
++	pred[c] += diff[dindex->leaf];
++	if (pred[c] >> 16 && ~pred[c] >> 16) derror();
++      }
++      FORC3 image[row*width+col][c] = pred[c];
++    }
++  }
++}
++
++void CLASS foveon_huff (ushort *huff)
++{
++  int i, j, clen, code;
++
++  huff[0] = 8;
++  for (i=0; i < 13; i++) {
++    clen = getc(ifp);
++    code = getc(ifp);
++    for (j=0; j < 256 >> clen; )
++      huff[code+ ++j] = clen << 8 | i;
++  }
++  get2();
++}
++
++void CLASS foveon_dp_load_raw()
++{
++  unsigned c, roff[4], row, col, diff;
++  ushort huff[512], vpred[2][2], hpred[2];
++
++  fseek (ifp, 8, SEEK_CUR);
++  foveon_huff (huff);
++  roff[0] = 48;
++  FORC3 roff[c+1] = -(-(roff[c] + get4()) & -16);
++  FORC3 {
++    fseek (ifp, data_offset+roff[c], SEEK_SET);
++    getbits(-1);
++    vpred[0][0] = vpred[0][1] = vpred[1][0] = vpred[1][1] = 512;
++    for (row=0; row < height; row++) {
++      for (col=0; col < width; col++) {
++	diff = ljpeg_diff(huff);
++	if (col < 2) hpred[col] = vpred[row & 1][col] += diff;
++	else hpred[col & 1] += diff;
++	image[row*width+col][c] = hpred[col & 1];
++      }
++    }
++  }
++}
++
++void CLASS foveon_load_camf()
++{
++  unsigned type, wide, high, i, j, row, col, diff;
++  ushort huff[258], vpred[2][2] = {{512,512},{512,512}}, hpred[2];
++
++  fseek (ifp, meta_offset, SEEK_SET);
++  type = get4();  get4();  get4();
++  wide = get4();
++  high = get4();
++  if (type == 2) {
++    fread (meta_data, 1, meta_length, ifp);
++    for (i=0; i < meta_length; i++) {
++      high = (high * 1597 + 51749) % 244944;
++      wide = high * (INT64) 301593171 >> 24;
++      meta_data[i] ^= ((((high << 8) - wide) >> 1) + wide) >> 17;
++    }
++  } else if (type == 4) {
++    free (meta_data);
++    meta_data = (char *) malloc (meta_length = wide*high*3/2);
++    merror (meta_data, "foveon_load_camf()");
++    foveon_huff (huff);
++    get4();
++    getbits(-1);
++    for (j=row=0; row < high; row++) {
++      for (col=0; col < wide; col++) {
++	diff = ljpeg_diff(huff);
++	if (col < 2) hpred[col] = vpred[row & 1][col] += diff;
++	else         hpred[col & 1] += diff;
++	if (col & 1) {
++	  meta_data[j++] = hpred[0] >> 4;
++	  meta_data[j++] = hpred[0] << 4 | hpred[1] >> 8;
++	  meta_data[j++] = hpred[1];
++	}
++      }
++    }
++  } else
++    fprintf (stderr,_("%s has unknown CAMF type %d.\n"), ifname, type);
++}
++
++const char * CLASS foveon_camf_param (const char *block, const char *param)
++{
++  unsigned idx, num;
++  char *pos, *cp, *dp;
++
++  for (idx=0; idx < meta_length; idx += sget4(pos+8)) {
++    pos = meta_data + idx;
++    if (strncmp (pos, "CMb", 3)) break;
++    if (pos[3] != 'P') continue;
++    if (strcmp (block, pos+sget4(pos+12))) continue;
++    cp = pos + sget4(pos+16);
++    num = sget4(cp);
++    dp = pos + sget4(cp+4);
++    while (num--) {
++      cp += 8;
++      if (!strcmp (param, dp+sget4(cp)))
++	return dp+sget4(cp+4);
++    }
++  }
++  return 0;
++}
++
++void * CLASS foveon_camf_matrix (unsigned dim[3], const char *name)
++{
++  unsigned i, idx, type, ndim, size, *mat;
++  char *pos, *cp, *dp;
++  double dsize;
++
++  for (idx=0; idx < meta_length; idx += sget4(pos+8)) {
++    pos = meta_data + idx;
++    if (strncmp (pos, "CMb", 3)) break;
++    if (pos[3] != 'M') continue;
++    if (strcmp (name, pos+sget4(pos+12))) continue;
++    dim[0] = dim[1] = dim[2] = 1;
++    cp = pos + sget4(pos+16);
++    type = sget4(cp);
++    if ((ndim = sget4(cp+4)) > 3) break;
++    dp = pos + sget4(cp+8);
++    for (i=ndim; i--; ) {
++      cp += 12;
++      dim[i] = sget4(cp);
++    }
++    if ((dsize = (double) dim[0]*dim[1]*dim[2]) > meta_length/4) break;
++    mat = (unsigned *) malloc ((size = dsize) * 4);
++    merror (mat, "foveon_camf_matrix()");
++    for (i=0; i < size; i++)
++      if (type && type != 6)
++	mat[i] = sget4(dp + i*4);
++      else
++	mat[i] = sget4(dp + i*2) & 0xffff;
++    return mat;
++  }
++  fprintf (stderr,_("%s: \"%s\" matrix not found!\n"), ifname, name);
++  return 0;
++}
++
++int CLASS foveon_fixed (void *ptr, int size, const char *name)
++{
++  void *dp;
++  unsigned dim[3];
++
++  if (!name) return 0;
++  dp = foveon_camf_matrix (dim, name);
++  if (!dp) return 0;
++  memcpy (ptr, dp, size*4);
++  free (dp);
++  return 1;
++}
++
++float CLASS foveon_avg (short *pix, int range[2], float cfilt)
++{
++  int i;
++  float val, min=FLT_MAX, max=-FLT_MAX, sum=0;
++
++  for (i=range[0]; i <= range[1]; i++) {
++    sum += val = pix[i*4] + (pix[i*4]-pix[(i-1)*4]) * cfilt;
++    if (min > val) min = val;
++    if (max < val) max = val;
++  }
++  if (range[1] - range[0] == 1) return sum/2;
++  return (sum - min - max) / (range[1] - range[0] - 1);
++}
++
++short * CLASS foveon_make_curve (double max, double mul, double filt)
++{
++  short *curve;
++  unsigned i, size;
++  double x;
++
++  if (!filt) filt = 0.8;
++  size = 4*M_PI*max / filt;
++  if (size == UINT_MAX) size--;
++  curve = (short *) calloc (size+1, sizeof *curve);
++  merror (curve, "foveon_make_curve()");
++  curve[0] = size;
++  for (i=0; i < size; i++) {
++    x = i*filt/max/4;
++    curve[i+1] = (cos(x)+1)/2 * tanh(i*filt/mul) * mul + 0.5;
++  }
++  return curve;
++}
++
++void CLASS foveon_make_curves
++	(short **curvep, float dq[3], float div[3], float filt)
++{
++  double mul[3], max=0;
++  int c;
++
++  FORC3 mul[c] = dq[c]/div[c];
++  FORC3 if (max < mul[c]) max = mul[c];
++  FORC3 curvep[c] = foveon_make_curve (max, mul[c], filt);
++}
++
++int CLASS foveon_apply_curve (short *curve, int i)
++{
++  if (abs(i) >= curve[0]) return 0;
++  return i < 0 ? -curve[1-i] : curve[1+i];
++}
++
++#define image ((short (*)[4]) image)
++
++void CLASS foveon_interpolate()
++{
++  static const short hood[] = { -1,-1, -1,0, -1,1, 0,-1, 0,1, 1,-1, 1,0, 1,1 };
++  short *pix, prev[3], *curve[8], (*shrink)[3];
++  float cfilt=0, ddft[3][3][2], ppm[3][3][3];
++  float cam_xyz[3][3], correct[3][3], last[3][3], trans[3][3];
++  float chroma_dq[3], color_dq[3], diag[3][3], div[3];
++  float (*black)[3], (*sgain)[3], (*sgrow)[3];
++  float fsum[3], val, frow, num;
++  int row, col, c, i, j, diff, sgx, irow, sum, min, max, limit;
++  int dscr[2][2], dstb[4], (*smrow[7])[3], total[4], ipix[3];
++  int work[3][3], smlast, smred, smred_p=0, dev[3];
++  int satlev[3], keep[4], active[4];
++  unsigned dim[3], *badpix;
++  double dsum=0, trsum[3];
++  char str[128];
++  const char* cp;
++
++  if (verbose)
++    fprintf (stderr,_("Foveon interpolation...\n"));
++
++  foveon_load_camf();
++  foveon_fixed (dscr, 4, "DarkShieldColRange");
++  foveon_fixed (ppm[0][0], 27, "PostPolyMatrix");
++  foveon_fixed (satlev, 3, "SaturationLevel");
++  foveon_fixed (keep, 4, "KeepImageArea");
++  foveon_fixed (active, 4, "ActiveImageArea");
++  foveon_fixed (chroma_dq, 3, "ChromaDQ");
++  foveon_fixed (color_dq, 3,
++	foveon_camf_param ("IncludeBlocks", "ColorDQ") ?
++		"ColorDQ" : "ColorDQCamRGB");
++  if (foveon_camf_param ("IncludeBlocks", "ColumnFilter"))
++		 foveon_fixed (&cfilt, 1, "ColumnFilter");
++
++  memset (ddft, 0, sizeof ddft);
++  if (!foveon_camf_param ("IncludeBlocks", "DarkDrift")
++	 || !foveon_fixed (ddft[1][0], 12, "DarkDrift"))
++    for (i=0; i < 2; i++) {
++      foveon_fixed (dstb, 4, i ? "DarkShieldBottom":"DarkShieldTop");
++      for (row = dstb[1]; row <= dstb[3]; row++)
++	for (col = dstb[0]; col <= dstb[2]; col++)
++	  FORC3 ddft[i+1][c][1] += (short) image[row*width+col][c];
++      FORC3 ddft[i+1][c][1] /= (dstb[3]-dstb[1]+1) * (dstb[2]-dstb[0]+1);
++    }
++
++  if (!(cp = foveon_camf_param ("WhiteBalanceIlluminants", model2)))
++  { fprintf (stderr,_("%s: Invalid white balance \"%s\"\n"), ifname, model2);
++    return; }
++  foveon_fixed (cam_xyz, 9, cp);
++  foveon_fixed (correct, 9,
++	foveon_camf_param ("WhiteBalanceCorrections", model2));
++  memset (last, 0, sizeof last);
++  for (i=0; i < 3; i++)
++    for (j=0; j < 3; j++)
++      FORC3 last[i][j] += correct[i][c] * cam_xyz[c][j];
++
++  #define LAST(x,y) last[(i+x)%3][(c+y)%3]
++  for (i=0; i < 3; i++)
++    FORC3 diag[c][i] = LAST(1,1)*LAST(2,2) - LAST(1,2)*LAST(2,1);
++  #undef LAST
++  FORC3 div[c] = diag[c][0]*0.3127 + diag[c][1]*0.329 + diag[c][2]*0.3583;
++  sprintf (str, "%sRGBNeutral", model2);
++  if (foveon_camf_param ("IncludeBlocks", str))
++    foveon_fixed (div, 3, str);
++  num = 0;
++  FORC3 if (num < div[c]) num = div[c];
++  FORC3 div[c] /= num;
++
++  memset (trans, 0, sizeof trans);
++  for (i=0; i < 3; i++)
++    for (j=0; j < 3; j++)
++      FORC3 trans[i][j] += rgb_cam[i][c] * last[c][j] * div[j];
++  FORC3 trsum[c] = trans[c][0] + trans[c][1] + trans[c][2];
++  dsum = (6*trsum[0] + 11*trsum[1] + 3*trsum[2]) / 20;
++  for (i=0; i < 3; i++)
++    FORC3 last[i][c] = trans[i][c] * dsum / trsum[i];
++  memset (trans, 0, sizeof trans);
++  for (i=0; i < 3; i++)
++    for (j=0; j < 3; j++)
++      FORC3 trans[i][j] += (i==c ? 32 : -1) * last[c][j] / 30;
++
++  foveon_make_curves (curve, color_dq, div, cfilt);
++  FORC3 chroma_dq[c] /= 3;
++  foveon_make_curves (curve+3, chroma_dq, div, cfilt);
++  FORC3 dsum += chroma_dq[c] / div[c];
++  curve[6] = foveon_make_curve (dsum, dsum, cfilt);
++  curve[7] = foveon_make_curve (dsum*2, dsum*2, cfilt);
++
++  sgain = (float (*)[3]) foveon_camf_matrix (dim, "SpatialGain");
++  if (!sgain) return;
++  sgrow = (float (*)[3]) calloc (dim[1], sizeof *sgrow);
++  sgx = (width + dim[1]-2) / (dim[1]-1);
++
++  black = (float (*)[3]) calloc (height, sizeof *black);
++  for (row=0; row < height; row++) {
++    for (i=0; i < 6; i++)
++      ((float *)ddft[0])[i] = ((float *)ddft[1])[i] +
++	row / (height-1.0) * (((float *)ddft[2])[i] - ((float *)ddft[1])[i]);
++    FORC3 black[row][c] =
++	( foveon_avg (image[row*width]+c, dscr[0], cfilt) +
++	  foveon_avg (image[row*width]+c, dscr[1], cfilt) * 3
++	  - ddft[0][c][0] ) / 4 - ddft[0][c][1];
++  }
++  memcpy (black, black+8, sizeof *black*8);
++  memcpy (black+height-11, black+height-22, 11*sizeof *black);
++  memcpy (last, black, sizeof last);
++
++  for (row=1; row < height-1; row++) {
++    FORC3 if (last[1][c] > last[0][c]) {
++	if (last[1][c] > last[2][c])
++	  black[row][c] = (last[0][c] > last[2][c]) ? last[0][c]:last[2][c];
++      } else
++	if (last[1][c] < last[2][c])
++	  black[row][c] = (last[0][c] < last[2][c]) ? last[0][c]:last[2][c];
++    memmove (last, last+1, 2*sizeof last[0]);
++    memcpy (last[2], black[row+1], sizeof last[2]);
++  }
++  FORC3 black[row][c] = (last[0][c] + last[1][c])/2;
++  FORC3 black[0][c] = (black[1][c] + black[3][c])/2;
++
++  val = 1 - exp(-1/24.0);
++  memcpy (fsum, black, sizeof fsum);
++  for (row=1; row < height; row++)
++    FORC3 fsum[c] += black[row][c] =
++	(black[row][c] - black[row-1][c])*val + black[row-1][c];
++  memcpy (last[0], black[height-1], sizeof last[0]);
++  FORC3 fsum[c] /= height;
++  for (row = height; row--; )
++    FORC3 last[0][c] = black[row][c] =
++	(black[row][c] - fsum[c] - last[0][c])*val + last[0][c];
++
++  memset (total, 0, sizeof total);
++  for (row=2; row < height; row+=4)
++    for (col=2; col < width; col+=4) {
++      FORC3 total[c] += (short) image[row*width+col][c];
++      total[3]++;
++    }
++  for (row=0; row < height; row++)
++    FORC3 black[row][c] += fsum[c]/2 + total[c]/(total[3]*100.0);
++
++  for (row=0; row < height; row++) {
++    for (i=0; i < 6; i++)
++      ((float *)ddft[0])[i] = ((float *)ddft[1])[i] +
++	row / (height-1.0) * (((float *)ddft[2])[i] - ((float *)ddft[1])[i]);
++    pix = image[row*width];
++    memcpy (prev, pix, sizeof prev);
++    frow = row / (height-1.0) * (dim[2]-1);
++    if ((irow = frow) == dim[2]-1) irow--;
++    frow -= irow;
++    for (i=0; i < dim[1]; i++)
++      FORC3 sgrow[i][c] = sgain[ irow   *dim[1]+i][c] * (1-frow) +
++			  sgain[(irow+1)*dim[1]+i][c] *    frow;
++    for (col=0; col < width; col++) {
++      FORC3 {
++	diff = pix[c] - prev[c];
++	prev[c] = pix[c];
++	ipix[c] = pix[c] + floor ((diff + (diff*diff >> 14)) * cfilt
++		- ddft[0][c][1] - ddft[0][c][0] * ((float) col/width - 0.5)
++		- black[row][c] );
++      }
++      FORC3 {
++	work[0][c] = ipix[c] * ipix[c] >> 14;
++	work[2][c] = ipix[c] * work[0][c] >> 14;
++	work[1][2-c] = ipix[(c+1) % 3] * ipix[(c+2) % 3] >> 14;
++      }
++      FORC3 {
++	for (val=i=0; i < 3; i++)
++	  for (  j=0; j < 3; j++)
++	    val += ppm[c][i][j] * work[i][j];
++	ipix[c] = floor ((ipix[c] + floor(val)) *
++		( sgrow[col/sgx  ][c] * (sgx - col%sgx) +
++		  sgrow[col/sgx+1][c] * (col%sgx) ) / sgx / div[c]);
++	if (ipix[c] > 32000) ipix[c] = 32000;
++	pix[c] = ipix[c];
++      }
++      pix += 4;
++    }
++  }
++  free (black);
++  free (sgrow);
++  free (sgain);
++
++  if ((badpix = (unsigned *) foveon_camf_matrix (dim, "BadPixels"))) {
++    for (i=0; i < dim[0]; i++) {
++      col = (badpix[i] >> 8 & 0xfff) - keep[0];
++      row = (badpix[i] >> 20       ) - keep[1];
++      if ((unsigned)(row-1) > height-3 || (unsigned)(col-1) > width-3)
++	continue;
++      memset (fsum, 0, sizeof fsum);
++      for (sum=j=0; j < 8; j++)
++	if (badpix[i] & (1 << j)) {
++	  FORC3 fsum[c] += (short)
++		image[(row+hood[j*2])*width+col+hood[j*2+1]][c];
++	  sum++;
++	}
++      if (sum) FORC3 image[row*width+col][c] = fsum[c]/sum;
++    }
++    free (badpix);
++  }
++
++  /* Array for 5x5 Gaussian averaging of red values */
++  smrow[6] = (int (*)[3]) calloc (width*5, sizeof **smrow);
++  merror (smrow[6], "foveon_interpolate()");
++  for (i=0; i < 5; i++)
++    smrow[i] = smrow[6] + i*width;
++
++  /* Sharpen the reds against these Gaussian averages */
++  for (smlast=-1, row=2; row < height-2; row++) {
++    while (smlast < row+2) {
++      for (i=0; i < 6; i++)
++	smrow[(i+5) % 6] = smrow[i];
++      pix = image[++smlast*width+2];
++      for (col=2; col < width-2; col++) {
++	smrow[4][col][0] =
++	  (pix[0]*6 + (pix[-4]+pix[4])*4 + pix[-8]+pix[8] + 8) >> 4;
++	pix += 4;
++      }
++    }
++    pix = image[row*width+2];
++    for (col=2; col < width-2; col++) {
++      smred = ( 6 *  smrow[2][col][0]
++	      + 4 * (smrow[1][col][0] + smrow[3][col][0])
++	      +      smrow[0][col][0] + smrow[4][col][0] + 8 ) >> 4;
++      if (col == 2)
++	smred_p = smred;
++      i = pix[0] + ((pix[0] - ((smred*7 + smred_p) >> 3)) >> 3);
++      if (i > 32000) i = 32000;
++      pix[0] = i;
++      smred_p = smred;
++      pix += 4;
++    }
++  }
++
++  /* Adjust the brighter pixels for better linearity */
++  min = 0xffff;
++  FORC3 {
++    i = satlev[c] / div[c];
++    if (min > i) min = i;
++  }
++  limit = min * 9 >> 4;
++  for (pix=image[0]; pix < image[height*width]; pix+=4) {
++    if (pix[0] <= limit || pix[1] <= limit || pix[2] <= limit)
++      continue;
++    min = max = pix[0];
++    for (c=1; c < 3; c++) {
++      if (min > pix[c]) min = pix[c];
++      if (max < pix[c]) max = pix[c];
++    }
++    if (min >= limit*2) {
++      pix[0] = pix[1] = pix[2] = max;
++    } else {
++      i = 0x4000 - ((min - limit) << 14) / limit;
++      i = 0x4000 - (i*i >> 14);
++      i = i*i >> 14;
++      FORC3 pix[c] += (max - pix[c]) * i >> 14;
++    }
++  }
++/*
++   Because photons that miss one detector often hit another,
++   the sum R+G+B is much less noisy than the individual colors.
++   So smooth the hues without smoothing the total.
++ */
++  for (smlast=-1, row=2; row < height-2; row++) {
++    while (smlast < row+2) {
++      for (i=0; i < 6; i++)
++	smrow[(i+5) % 6] = smrow[i];
++      pix = image[++smlast*width+2];
++      for (col=2; col < width-2; col++) {
++	FORC3 smrow[4][col][c] = (pix[c-4]+2*pix[c]+pix[c+4]+2) >> 2;
++	pix += 4;
++      }
++    }
++    pix = image[row*width+2];
++    for (col=2; col < width-2; col++) {
++      FORC3 dev[c] = -foveon_apply_curve (curve[7], pix[c] -
++	((smrow[1][col][c] + 2*smrow[2][col][c] + smrow[3][col][c]) >> 2));
++      sum = (dev[0] + dev[1] + dev[2]) >> 3;
++      FORC3 pix[c] += dev[c] - sum;
++      pix += 4;
++    }
++  }
++  for (smlast=-1, row=2; row < height-2; row++) {
++    while (smlast < row+2) {
++      for (i=0; i < 6; i++)
++	smrow[(i+5) % 6] = smrow[i];
++      pix = image[++smlast*width+2];
++      for (col=2; col < width-2; col++) {
++	FORC3 smrow[4][col][c] =
++		(pix[c-8]+pix[c-4]+pix[c]+pix[c+4]+pix[c+8]+2) >> 2;
++	pix += 4;
++      }
++    }
++    pix = image[row*width+2];
++    for (col=2; col < width-2; col++) {
++      for (total[3]=375, sum=60, c=0; c < 3; c++) {
++	for (total[c]=i=0; i < 5; i++)
++	  total[c] += smrow[i][col][c];
++	total[3] += total[c];
++	sum += pix[c];
++      }
++      if (sum < 0) sum = 0;
++      j = total[3] > 375 ? (sum << 16) / total[3] : sum * 174;
++      FORC3 pix[c] += foveon_apply_curve (curve[6],
++		((j*total[c] + 0x8000) >> 16) - pix[c]);
++      pix += 4;
++    }
++  }
++
++  /* Transform the image to a different colorspace */
++  for (pix=image[0]; pix < image[height*width]; pix+=4) {
++    FORC3 pix[c] -= foveon_apply_curve (curve[c], pix[c]);
++    sum = (pix[0]+pix[1]+pix[1]+pix[2]) >> 2;
++    FORC3 pix[c] -= foveon_apply_curve (curve[c], pix[c]-sum);
++    FORC3 {
++      for (dsum=i=0; i < 3; i++)
++	dsum += trans[c][i] * pix[i];
++      if (dsum < 0)  dsum = 0;
++      if (dsum > 24000) dsum = 24000;
++      ipix[c] = dsum + 0.5;
++    }
++    FORC3 pix[c] = ipix[c];
++  }
++
++  /* Smooth the image bottom-to-top and save at 1/4 scale */
++  shrink = (short (*)[3]) calloc ((height/4), (width/4)*sizeof *shrink);
++  merror (shrink, "foveon_interpolate()");
++  for (row = height/4; row--; )
++    for (col=0; col < width/4; col++) {
++      ipix[0] = ipix[1] = ipix[2] = 0;
++      for (i=0; i < 4; i++)
++	for (j=0; j < 4; j++)
++	  FORC3 ipix[c] += image[(row*4+i)*width+col*4+j][c];
++      FORC3
++	if (row+2 > height/4)
++	  shrink[row*(width/4)+col][c] = ipix[c] >> 4;
++	else
++	  shrink[row*(width/4)+col][c] =
++	    (shrink[(row+1)*(width/4)+col][c]*1840 + ipix[c]*141 + 2048) >> 12;
++    }
++  /* From the 1/4-scale image, smooth right-to-left */
++  for (row=0; row < (height & ~3); row++) {
++    ipix[0] = ipix[1] = ipix[2] = 0;
++    if ((row & 3) == 0)
++      for (col = width & ~3 ; col--; )
++	FORC3 smrow[0][col][c] = ipix[c] =
++	  (shrink[(row/4)*(width/4)+col/4][c]*1485 + ipix[c]*6707 + 4096) >> 13;
++
++  /* Then smooth left-to-right */
++    ipix[0] = ipix[1] = ipix[2] = 0;
++    for (col=0; col < (width & ~3); col++)
++      FORC3 smrow[1][col][c] = ipix[c] =
++	(smrow[0][col][c]*1485 + ipix[c]*6707 + 4096) >> 13;
++
++  /* Smooth top-to-bottom */
++    if (row == 0)
++      memcpy (smrow[2], smrow[1], sizeof **smrow * width);
++    else
++      for (col=0; col < (width & ~3); col++)
++	FORC3 smrow[2][col][c] =
++	  (smrow[2][col][c]*6707 + smrow[1][col][c]*1485 + 4096) >> 13;
++
++  /* Adjust the chroma toward the smooth values */
++    for (col=0; col < (width & ~3); col++) {
++      for (i=j=30, c=0; c < 3; c++) {
++	i += smrow[2][col][c];
++	j += image[row*width+col][c];
++      }
++      j = (j << 16) / i;
++      for (sum=c=0; c < 3; c++) {
++	ipix[c] = foveon_apply_curve (curve[c+3],
++	  ((smrow[2][col][c] * j + 0x8000) >> 16) - image[row*width+col][c]);
++	sum += ipix[c];
++      }
++      sum >>= 3;
++      FORC3 {
++	i = image[row*width+col][c] + ipix[c] - sum;
++	if (i < 0) i = 0;
++	image[row*width+col][c] = i;
++      }
++    }
++  }
++  free (shrink);
++  free (smrow[6]);
++  for (i=0; i < 8; i++)
++    free (curve[i]);
++
++  /* Trim off the black border */
++  active[1] -= keep[1];
++  active[3] -= 2;
++  i = active[2] - active[0];
++  for (row=0; row < active[3]-active[1]; row++)
++    memcpy (image[row*i], image[(row+active[1])*width+active[0]],
++	 i * sizeof *image);
++  width = i;
++  height = row;
++}
++#undef image
++
++/* RESTRICTED code ends here */
++
++void CLASS crop_masked_pixels()
++{
++  int row, col;
++  unsigned r, c, m, mblack[8], zero, val;
++
++  if (load_raw == &CLASS phase_one_load_raw ||
++      load_raw == &CLASS phase_one_load_raw_c)
++    phase_one_correct();
++  if (fuji_width) {
++    for (row=0; row < raw_height-top_margin*2; row++) {
++      for (col=0; col < fuji_width << !fuji_layout; col++) {
++	if (fuji_layout) {
++	  r = fuji_width - 1 - col + (row >> 1);
++	  c = col + ((row+1) >> 1);
++	} else {
++	  r = fuji_width - 1 + row - (col >> 1);
++	  c = row + ((col+1) >> 1);
++	}
++	if (r < height && c < width)
++	  BAYER(r,c) = RAW(row+top_margin,col+left_margin);
++      }
++    }
++  } else {
++    for (row=0; row < height; row++)
++      for (col=0; col < width; col++)
++	BAYER2(row,col) = RAW(row+top_margin,col+left_margin);
++  }
++  if (mask[0][3] > 0) goto mask_set;
++  if (load_raw == &CLASS canon_load_raw ||
++      load_raw == &CLASS lossless_jpeg_load_raw) {
++    mask[0][1] = mask[1][1] += 2;
++    mask[0][3] -= 2;
++    goto sides;
++  }
++  if (load_raw == &CLASS canon_600_load_raw ||
++      load_raw == &CLASS sony_load_raw ||
++     (load_raw == &CLASS eight_bit_load_raw && strncmp(model,"DC2",3)) ||
++      load_raw == &CLASS kodak_262_load_raw ||
++     (load_raw == &CLASS packed_load_raw && (load_flags & 32))) {
++sides:
++    mask[0][0] = mask[1][0] = top_margin;
++    mask[0][2] = mask[1][2] = top_margin+height;
++    mask[0][3] += left_margin;
++    mask[1][1] += left_margin+width;
++    mask[1][3] += raw_width;
++  }
++  if (load_raw == &CLASS nokia_load_raw) {
++    mask[0][2] = top_margin;
++    mask[0][3] = width;
++  }
++mask_set:
++  memset (mblack, 0, sizeof mblack);
++  for (zero=m=0; m < 8; m++)
++    for (row=MAX(mask[m][0],0); row < MIN(mask[m][2],raw_height); row++)
++      for (col=MAX(mask[m][1],0); col < MIN(mask[m][3],raw_width); col++) {
++	c = FC(row-top_margin,col-left_margin);
++	mblack[c] += val = RAW(row,col);
++	mblack[4+c]++;
++	zero += !val;
++      }
++  if (load_raw == &CLASS canon_600_load_raw && width < raw_width) {
++    black = (mblack[0]+mblack[1]+mblack[2]+mblack[3]) /
++	    (mblack[4]+mblack[5]+mblack[6]+mblack[7]) - 4;
++    canon_600_correct();
++  } else if (zero < mblack[4] && mblack[5] && mblack[6] && mblack[7]) {
++    FORC4 cblack[c] = mblack[c] / mblack[4+c];
++    cblack[4] = cblack[5] = cblack[6] = 0;
++  }
++}
++
++void CLASS remove_zeroes()
++{
++  unsigned row, col, tot, n, r, c;
++
++  for (row=0; row < height; row++)
++    for (col=0; col < width; col++)
++      if (BAYER(row,col) == 0) {
++	tot = n = 0;
++	for (r = row-2; r <= row+2; r++)
++	  for (c = col-2; c <= col+2; c++)
++	    if (r < height && c < width &&
++		FC(r,c) == FC(row,col) && BAYER(r,c))
++	      tot += (n++,BAYER(r,c));
++	if (n) BAYER(row,col) = tot/n;
++      }
++}
++
++/*
++   Seach from the current directory up to the root looking for
++   a ".badpixels" file, and fix those pixels now.
++ */
++void CLASS bad_pixels (const char *cfname)
++{
++  FILE *fp=0;
++  char *fname, *cp, line[128];
++  int len, time, row, col, r, c, rad, tot, n, fixed=0;
++
++  if (!filters) return;
++  if (cfname)
++    fp = fopen (cfname, "r");
++  else {
++    for (len=32 ; ; len *= 2) {
++      fname = (char *) malloc (len);
++      if (!fname) return;
++      if (getcwd (fname, len-16)) break;
++      free (fname);
++      if (errno != ERANGE) return;
++    }
++#if defined(WIN32) || defined(DJGPP)
++    if (fname[1] == ':')
++      memmove (fname, fname+2, len-2);
++    for (cp=fname; *cp; cp++)
++      if (*cp == '\\') *cp = '/';
++#endif
++    cp = fname + strlen(fname);
++    if (cp[-1] == '/') cp--;
++    while (*fname == '/') {
++      strcpy (cp, "/.badpixels");
++      if ((fp = fopen (fname, "r"))) break;
++      if (cp == fname) break;
++      while (*--cp != '/');
++    }
++    free (fname);
++  }
++  if (!fp) return;
++  while (fgets (line, 128, fp)) {
++    cp = strchr (line, '#');
++    if (cp) *cp = 0;
++    if (sscanf (line, "%d %d %d", &col, &row, &time) != 3) continue;
++    if ((unsigned) col >= width || (unsigned) row >= height) continue;
++    if (time > timestamp) continue;
++    for (tot=n=0, rad=1; rad < 3 && n==0; rad++)
++      for (r = row-rad; r <= row+rad; r++)
++	for (c = col-rad; c <= col+rad; c++)
++	  if ((unsigned) r < height && (unsigned) c < width &&
++		(r != row || c != col) && fcol(r,c) == fcol(row,col)) {
++	    tot += BAYER2(r,c);
++	    n++;
++	  }
++    BAYER2(row,col) = tot/n;
++    if (verbose) {
++      if (!fixed++)
++	fprintf (stderr,_("Fixed dead pixels at:"));
++      fprintf (stderr, " %d,%d", col, row);
++    }
++  }
++  if (fixed) fputc ('\n', stderr);
++  fclose (fp);
++}
++
++void CLASS subtract (const char *fname)
++{
++  FILE *fp;
++  int dim[3]={0,0,0}, comment=0, number=0, error=0, nd=0, c, row, col;
++  ushort *pixel;
++
++  if (!(fp = fopen (fname, "rb"))) {
++    perror (fname);  return;
++  }
++  if (fgetc(fp) != 'P' || fgetc(fp) != '5') error = 1;
++  while (!error && nd < 3 && (c = fgetc(fp)) != EOF) {
++    if (c == '#')  comment = 1;
++    if (c == '\n') comment = 0;
++    if (comment) continue;
++    if (isdigit(c)) number = 1;
++    if (number) {
++      if (isdigit(c)) dim[nd] = dim[nd]*10 + c -'0';
++      else if (isspace(c)) {
++	number = 0;  nd++;
++      } else error = 1;
++    }
++  }
++  if (error || nd < 3) {
++    fprintf (stderr,_("%s is not a valid PGM file!\n"), fname);
++    fclose (fp);  return;
++  } else if (dim[0] != width || dim[1] != height || dim[2] != 65535) {
++    fprintf (stderr,_("%s has the wrong dimensions!\n"), fname);
++    fclose (fp);  return;
++  }
++  pixel = (ushort *) calloc (width, sizeof *pixel);
++  merror (pixel, "subtract()");
++  for (row=0; row < height; row++) {
++    fread (pixel, 2, width, fp);
++    for (col=0; col < width; col++)
++      BAYER(row,col) = MAX (BAYER(row,col) - ntohs(pixel[col]), 0);
++  }
++  free (pixel);
++  fclose (fp);
++  memset (cblack, 0, sizeof cblack);
++  black = 0;
++}
++
++void CLASS gamma_curve (double pwr, double ts, int mode, int imax)
++{
++  int i;
++  double g[6], bnd[2]={0,0}, r;
++
++  g[0] = pwr;
++  g[1] = ts;
++  g[2] = g[3] = g[4] = 0;
++  bnd[g[1] >= 1] = 1;
++  if (g[1] && (g[1]-1)*(g[0]-1) <= 0) {
++    for (i=0; i < 48; i++) {
++      g[2] = (bnd[0] + bnd[1])/2;
++      if (g[0]) bnd[(pow(g[2]/g[1],-g[0]) - 1)/g[0] - 1/g[2] > -1] = g[2];
++      else	bnd[g[2]/exp(1-1/g[2]) < g[1]] = g[2];
++    }
++    g[3] = g[2] / g[1];
++    if (g[0]) g[4] = g[2] * (1/g[0] - 1);
++  }
++  if (g[0]) g[5] = 1 / (g[1]*SQR(g[3])/2 - g[4]*(1 - g[3]) +
++		(1 - pow(g[3],1+g[0]))*(1 + g[4])/(1 + g[0])) - 1;
++  else      g[5] = 1 / (g[1]*SQR(g[3])/2 + 1
++		- g[2] - g[3] -	g[2]*g[3]*(log(g[3]) - 1)) - 1;
++  if (!mode--) {
++    memcpy (gamm, g, sizeof gamm);
++    return;
++  }
++  for (i=0; i < 0x10000; i++) {
++    curve[i] = 0xffff;
++    if ((r = (double) i / imax) < 1)
++      curve[i] = 0x10000 * ( mode
++	? (r < g[3] ? r*g[1] : (g[0] ? pow( r,g[0])*(1+g[4])-g[4]    : log(r)*g[2]+1))
++	: (r < g[2] ? r/g[1] : (g[0] ? pow((r+g[4])/(1+g[4]),1/g[0]) : exp((r-1)/g[2]))));
++  }
++}
++
++void CLASS pseudoinverse (double (*in)[3], double (*out)[3], int size)
++{
++  double work[3][6], num;
++  int i, j, k;
++
++  for (i=0; i < 3; i++) {
++    for (j=0; j < 6; j++)
++      work[i][j] = j == i+3;
++    for (j=0; j < 3; j++)
++      for (k=0; k < size; k++)
++	work[i][j] += in[k][i] * in[k][j];
++  }
++  for (i=0; i < 3; i++) {
++    num = work[i][i];
++    for (j=0; j < 6; j++)
++      work[i][j] /= num;
++    for (k=0; k < 3; k++) {
++      if (k==i) continue;
++      num = work[k][i];
++      for (j=0; j < 6; j++)
++	work[k][j] -= work[i][j] * num;
++    }
++  }
++  for (i=0; i < size; i++)
++    for (j=0; j < 3; j++)
++      for (out[i][j]=k=0; k < 3; k++)
++	out[i][j] += work[j][k+3] * in[i][k];
++}
++
++void CLASS cam_xyz_coeff (float rgb_cam[3][4], double cam_xyz[4][3])
++{
++  double cam_rgb[4][3], inverse[4][3], num;
++  int i, j, k;
++
++  for (i=0; i < colors; i++)		/* Multiply out XYZ colorspace */
++    for (j=0; j < 3; j++)
++      for (cam_rgb[i][j] = k=0; k < 3; k++)
++	cam_rgb[i][j] += cam_xyz[i][k] * xyz_rgb[k][j];
++
++  for (i=0; i < colors; i++) {		/* Normalize cam_rgb so that */
++    for (num=j=0; j < 3; j++)		/* cam_rgb * (1,1,1) is (1,1,1,1) */
++      num += cam_rgb[i][j];
++    for (j=0; j < 3; j++)
++      cam_rgb[i][j] /= num;
++    pre_mul[i] = 1 / num;
++  }
++  pseudoinverse (cam_rgb, inverse, colors);
++  for (i=0; i < 3; i++)
++    for (j=0; j < colors; j++)
++      rgb_cam[i][j] = inverse[j][i];
++}
++
++#ifdef COLORCHECK
++void CLASS colorcheck()
++{
++#define NSQ 24
++// Coordinates of the GretagMacbeth ColorChecker squares
++// width, height, 1st_column, 1st_row
++  int cut[NSQ][4];			// you must set these
++// ColorChecker Chart under 6500-kelvin illumination
++  static const double gmb_xyY[NSQ][3] = {
++    { 0.400, 0.350, 10.1 },		// Dark Skin
++    { 0.377, 0.345, 35.8 },		// Light Skin
++    { 0.247, 0.251, 19.3 },		// Blue Sky
++    { 0.337, 0.422, 13.3 },		// Foliage
++    { 0.265, 0.240, 24.3 },		// Blue Flower
++    { 0.261, 0.343, 43.1 },		// Bluish Green
++    { 0.506, 0.407, 30.1 },		// Orange
++    { 0.211, 0.175, 12.0 },		// Purplish Blue
++    { 0.453, 0.306, 19.8 },		// Moderate Red
++    { 0.285, 0.202, 6.6 },		// Purple
++    { 0.380, 0.489, 44.3 },		// Yellow Green
++    { 0.473, 0.438, 43.1 },		// Orange Yellow
++    { 0.187, 0.129, 6.1 },		// Blue
++    { 0.305, 0.478, 23.4 },		// Green
++    { 0.539, 0.313, 12.0 },		// Red
++    { 0.448, 0.470, 59.1 },		// Yellow
++    { 0.364, 0.233, 19.8 },		// Magenta
++    { 0.196, 0.252, 19.8 },		// Cyan
++    { 0.310, 0.316, 90.0 },		// White
++    { 0.310, 0.316, 59.1 },		// Neutral 8
++    { 0.310, 0.316, 36.2 },		// Neutral 6.5
++    { 0.310, 0.316, 19.8 },		// Neutral 5
++    { 0.310, 0.316, 9.0 },		// Neutral 3.5
++    { 0.310, 0.316, 3.1 } };		// Black
++  double gmb_cam[NSQ][4], gmb_xyz[NSQ][3];
++  double inverse[NSQ][3], cam_xyz[4][3], balance[4], num;
++  int c, i, j, k, sq, row, col, pass, count[4];
++
++  memset (gmb_cam, 0, sizeof gmb_cam);
++  for (sq=0; sq < NSQ; sq++) {
++    FORCC count[c] = 0;
++    for   (row=cut[sq][3]; row < cut[sq][3]+cut[sq][1]; row++)
++      for (col=cut[sq][2]; col < cut[sq][2]+cut[sq][0]; col++) {
++	c = FC(row,col);
++	if (c >= colors) c -= 2;
++	gmb_cam[sq][c] += BAYER2(row,col);
++	BAYER2(row,col) = black + (BAYER2(row,col)-black)/2;
++	count[c]++;
++      }
++    FORCC gmb_cam[sq][c] = gmb_cam[sq][c]/count[c] - black;
++    gmb_xyz[sq][0] = gmb_xyY[sq][2] * gmb_xyY[sq][0] / gmb_xyY[sq][1];
++    gmb_xyz[sq][1] = gmb_xyY[sq][2];
++    gmb_xyz[sq][2] = gmb_xyY[sq][2] *
++		(1 - gmb_xyY[sq][0] - gmb_xyY[sq][1]) / gmb_xyY[sq][1];
++  }
++  pseudoinverse (gmb_xyz, inverse, NSQ);
++  for (pass=0; pass < 2; pass++) {
++    for (raw_color = i=0; i < colors; i++)
++      for (j=0; j < 3; j++)
++	for (cam_xyz[i][j] = k=0; k < NSQ; k++)
++	  cam_xyz[i][j] += gmb_cam[k][i] * inverse[k][j];
++    cam_xyz_coeff (rgb_cam, cam_xyz);
++    FORCC balance[c] = pre_mul[c] * gmb_cam[20][c];
++    for (sq=0; sq < NSQ; sq++)
++      FORCC gmb_cam[sq][c] *= balance[c];
++  }
++  if (verbose) {
++    printf ("    { \"%s %s\", %d,\n\t{", make, model, black);
++    num = 10000 / (cam_xyz[1][0] + cam_xyz[1][1] + cam_xyz[1][2]);
++    FORCC for (j=0; j < 3; j++)
++      printf ("%c%d", (c | j) ? ',':' ', (int) (cam_xyz[c][j] * num + 0.5));
++    puts (" } },");
++  }
++#undef NSQ
++}
++#endif
++
++void CLASS hat_transform (float *temp, float *base, int st, int size, int sc)
++{
++  int i;
++  for (i=0; i < sc; i++)
++    temp[i] = 2*base[st*i] + base[st*(sc-i)] + base[st*(i+sc)];
++  for (; i+sc < size; i++)
++    temp[i] = 2*base[st*i] + base[st*(i-sc)] + base[st*(i+sc)];
++  for (; i < size; i++)
++    temp[i] = 2*base[st*i] + base[st*(i-sc)] + base[st*(2*size-2-(i+sc))];
++}
++
++void CLASS wavelet_denoise()
++{
++  float *fimg=0, *temp, thold, mul[2], avg, diff;
++  int scale=1, size, lev, hpass, lpass, row, col, nc, c, i, wlast, blk[2];
++  ushort *window[4];
++  static const float noise[] =
++  { 0.8002,0.2735,0.1202,0.0585,0.0291,0.0152,0.0080,0.0044 };
++
++  if (verbose) fprintf (stderr,_("Wavelet denoising...\n"));
++
++  while (maximum << scale < 0x10000) scale++;
++  maximum <<= --scale;
++  black <<= scale;
++  FORC4 cblack[c] <<= scale;
++  if ((size = iheight*iwidth) < 0x15550000)
++    fimg = (float *) malloc ((size*3 + iheight + iwidth) * sizeof *fimg);
++  merror (fimg, "wavelet_denoise()");
++  temp = fimg + size*3;
++  if ((nc = colors) == 3 && filters) nc++;
++  FORC(nc) {			/* denoise R,G1,B,G3 individually */
++    for (i=0; i < size; i++)
++      fimg[i] = 256 * sqrt(image[i][c] << scale);
++    for (hpass=lev=0; lev < 5; lev++) {
++      lpass = size*((lev & 1)+1);
++      for (row=0; row < iheight; row++) {
++	hat_transform (temp, fimg+hpass+row*iwidth, 1, iwidth, 1 << lev);
++	for (col=0; col < iwidth; col++)
++	  fimg[lpass + row*iwidth + col] = temp[col] * 0.25;
++      }
++      for (col=0; col < iwidth; col++) {
++	hat_transform (temp, fimg+lpass+col, iwidth, iheight, 1 << lev);
++	for (row=0; row < iheight; row++)
++	  fimg[lpass + row*iwidth + col] = temp[row] * 0.25;
++      }
++      thold = threshold * noise[lev];
++      for (i=0; i < size; i++) {
++	fimg[hpass+i] -= fimg[lpass+i];
++	if	(fimg[hpass+i] < -thold) fimg[hpass+i] += thold;
++	else if (fimg[hpass+i] >  thold) fimg[hpass+i] -= thold;
++	else	 fimg[hpass+i] = 0;
++	if (hpass) fimg[i] += fimg[hpass+i];
++      }
++      hpass = lpass;
++    }
++    for (i=0; i < size; i++)
++      image[i][c] = CLIP(SQR(fimg[i]+fimg[lpass+i])/0x10000);
++  }
++  if (filters && colors == 3) {  /* pull G1 and G3 closer together */
++    for (row=0; row < 2; row++) {
++      mul[row] = 0.125 * pre_mul[FC(row+1,0) | 1] / pre_mul[FC(row,0) | 1];
++      blk[row] = cblack[FC(row,0) | 1];
++    }
++    for (i=0; i < 4; i++)
++      window[i] = (ushort *) fimg + width*i;
++    for (wlast=-1, row=1; row < height-1; row++) {
++      while (wlast < row+1) {
++	for (wlast++, i=0; i < 4; i++)
++	  window[(i+3) & 3] = window[i];
++	for (col = FC(wlast,1) & 1; col < width; col+=2)
++	  window[2][col] = BAYER(wlast,col);
++      }
++      thold = threshold/512;
++      for (col = (FC(row,0) & 1)+1; col < width-1; col+=2) {
++	avg = ( window[0][col-1] + window[0][col+1] +
++		window[2][col-1] + window[2][col+1] - blk[~row & 1]*4 )
++	      * mul[row & 1] + (window[1][col] + blk[row & 1]) * 0.5;
++	avg = avg < 0 ? 0 : sqrt(avg);
++	diff = sqrt(BAYER(row,col)) - avg;
++	if      (diff < -thold) diff += thold;
++	else if (diff >  thold) diff -= thold;
++	else diff = 0;
++	BAYER(row,col) = CLIP(SQR(avg+diff) + 0.5);
++      }
++    }
++  }
++  free (fimg);
++}
++
++void CLASS scale_colors()
++{
++  unsigned bottom, right, size, row, col, ur, uc, i, x, y, c, sum[8];
++  int val, dark, sat;
++  double dsum[8], dmin, dmax;
++  float scale_mul[4], fr, fc;
++  ushort *img=0, *pix;
++
++  if (user_mul[0])
++    memcpy (pre_mul, user_mul, sizeof pre_mul);
++  if (use_auto_wb || (use_camera_wb && cam_mul[0] == -1)) {
++    memset (dsum, 0, sizeof dsum);
++    bottom = MIN (greybox[1]+greybox[3], height);
++    right  = MIN (greybox[0]+greybox[2], width);
++    for (row=greybox[1]; row < bottom; row += 8)
++      for (col=greybox[0]; col < right; col += 8) {
++	memset (sum, 0, sizeof sum);
++	for (y=row; y < row+8 && y < bottom; y++)
++	  for (x=col; x < col+8 && x < right; x++)
++	    FORC4 {
++	      if (filters) {
++		c = fcol(y,x);
++		val = BAYER2(y,x);
++	      } else
++		val = image[y*width+x][c];
++	      if (val > maximum-25) goto skip_block;
++	      if ((val -= cblack[c]) < 0) val = 0;
++	      sum[c] += val;
++	      sum[c+4]++;
++	      if (filters) break;
++	    }
++	FORC(8) dsum[c] += sum[c];
++skip_block: ;
++      }
++    FORC4 if (dsum[c]) pre_mul[c] = dsum[c+4] / dsum[c];
++  }
++  if (use_camera_wb && cam_mul[0] != -1) {
++    memset (sum, 0, sizeof sum);
++    for (row=0; row < 8; row++)
++      for (col=0; col < 8; col++) {
++	c = FC(row,col);
++	if ((val = white[row][col] - cblack[c]) > 0)
++	  sum[c] += val;
++	sum[c+4]++;
++      }
++    if (sum[0] && sum[1] && sum[2] && sum[3])
++      FORC4 pre_mul[c] = (float) sum[c+4] / sum[c];
++    else if (cam_mul[0] && cam_mul[2])
++      memcpy (pre_mul, cam_mul, sizeof pre_mul);
++    else
++      fprintf (stderr,_("%s: Cannot use camera white balance.\n"), ifname);
++  }
++  if (pre_mul[1] == 0) pre_mul[1] = 1;
++  if (pre_mul[3] == 0) pre_mul[3] = colors < 4 ? pre_mul[1] : 1;
++  dark = black;
++  sat = maximum;
++  if (threshold) wavelet_denoise();
++  maximum -= black;
++  for (dmin=DBL_MAX, dmax=c=0; c < 4; c++) {
++    if (dmin > pre_mul[c])
++	dmin = pre_mul[c];
++    if (dmax < pre_mul[c])
++	dmax = pre_mul[c];
++  }
++  if (!highlight) dmax = dmin;
++  FORC4 scale_mul[c] = (pre_mul[c] /= dmax) * 65535.0 / maximum;
++  if (verbose) {
++    fprintf (stderr,
++      _("Scaling with darkness %d, saturation %d, and\nmultipliers"), dark, sat);
++    FORC4 fprintf (stderr, " %f", pre_mul[c]);
++    fputc ('\n', stderr);
++  }
++  if (filters > 1000 && (cblack[4]+1)/2 == 1 && (cblack[5]+1)/2 == 1) {
++    FORC4 cblack[FC(c/2,c%2)] +=
++	cblack[6 + c/2 % cblack[4] * cblack[5] + c%2 % cblack[5]];
++    cblack[4] = cblack[5] = 0;
++  }
++  size = iheight*iwidth;
++  for (i=0; i < size*4; i++) {
++    if (!(val = ((ushort *)image)[i])) continue;
++    if (cblack[4] && cblack[5])
++      val -= cblack[6 + i/4 / iwidth % cblack[4] * cblack[5] +
++			i/4 % iwidth % cblack[5]];
++    val -= cblack[i & 3];
++    val *= scale_mul[i & 3];
++    ((ushort *)image)[i] = CLIP(val);
++  }
++  if ((aber[0] != 1 || aber[2] != 1) && colors == 3) {
++    if (verbose)
++      fprintf (stderr,_("Correcting chromatic aberration...\n"));
++    for (c=0; c < 4; c+=2) {
++      if (aber[c] == 1) continue;
++      img = (ushort *) malloc (size * sizeof *img);
++      merror (img, "scale_colors()");
++      for (i=0; i < size; i++)
++	img[i] = image[i][c];
++      for (row=0; row < iheight; row++) {
++	ur = fr = (row - iheight*0.5) * aber[c] + iheight*0.5;
++	if (ur > iheight-2) continue;
++	fr -= ur;
++	for (col=0; col < iwidth; col++) {
++	  uc = fc = (col - iwidth*0.5) * aber[c] + iwidth*0.5;
++	  if (uc > iwidth-2) continue;
++	  fc -= uc;
++	  pix = img + ur*iwidth + uc;
++	  image[row*iwidth+col][c] =
++	    (pix[     0]*(1-fc) + pix[       1]*fc) * (1-fr) +
++	    (pix[iwidth]*(1-fc) + pix[iwidth+1]*fc) * fr;
++	}
++      }
++      free(img);
++    }
++  }
++}
++
++void CLASS pre_interpolate()
++{
++  ushort (*img)[4];
++  int row, col, c;
++
++  if (shrink) {
++    if (half_size) {
++      height = iheight;
++      width  = iwidth;
++      if (filters == 9) {
++	for (row=0; row < 3; row++)
++	  for (col=1; col < 4; col++)
++	    if (!(image[row*width+col][0] | image[row*width+col][2]))
++	      goto break2;  break2:
++	for ( ; row < height; row+=3)
++	  for (col=(col-1)%3+1; col < width-1; col+=3) {
++	    img = image + row*width+col;
++	    for (c=0; c < 3; c+=2)
++	      img[0][c] = (img[-1][c] + img[1][c]) >> 1;
++	  }
++      }
++    } else {
++      img = (ushort (*)[4]) calloc (height, width*sizeof *img);
++      merror (img, "pre_interpolate()");
++      for (row=0; row < height; row++)
++	for (col=0; col < width; col++) {
++	  c = fcol(row,col);
++	  img[row*width+col][c] = image[(row >> 1)*iwidth+(col >> 1)][c];
++	}
++      free (image);
++      image = img;
++      shrink = 0;
++    }
++  }
++  if (filters > 1000 && colors == 3) {
++    mix_green = four_color_rgb ^ half_size;
++    if (four_color_rgb | half_size) colors++;
++    else {
++      for (row = FC(1,0) >> 1; row < height; row+=2)
++	for (col = FC(row,1) & 1; col < width; col+=2)
++	  image[row*width+col][1] = image[row*width+col][3];
++      filters &= ~((filters & 0x55555555) << 1);
++    }
++  }
++  if (half_size) filters = 0;
++}
++
++void CLASS border_interpolate (int border)
++{
++  unsigned row, col, y, x, f, c, sum[8];
++
++  for (row=0; row < height; row++)
++    for (col=0; col < width; col++) {
++      if (col==border && row >= border && row < height-border)
++	col = width-border;
++      memset (sum, 0, sizeof sum);
++      for (y=row-1; y != row+2; y++)
++	for (x=col-1; x != col+2; x++)
++	  if (y < height && x < width) {
++	    f = fcol(y,x);
++	    sum[f] += image[y*width+x][f];
++	    sum[f+4]++;
++	  }
++      f = fcol(row,col);
++      FORCC if (c != f && sum[c+4])
++	image[row*width+col][c] = sum[c] / sum[c+4];
++    }
++}
++
++void CLASS lin_interpolate()
++{
++  int code[16][16][32], size=16, *ip, sum[4];
++  int f, c, i, x, y, row, col, shift, color;
++  ushort *pix;
++
++  if (verbose) fprintf (stderr,_("Bilinear interpolation...\n"));
++  if (filters == 9) size = 6;
++  border_interpolate(1);
++  for (row=0; row < size; row++)
++    for (col=0; col < size; col++) {
++      ip = code[row][col]+1;
++      f = fcol(row,col);
++      memset (sum, 0, sizeof sum);
++      for (y=-1; y <= 1; y++)
++	for (x=-1; x <= 1; x++) {
++	  shift = (y==0) + (x==0);
++	  color = fcol(row+y,col+x);
++	  if (color == f) continue;
++	  *ip++ = (width*y + x)*4 + color;
++	  *ip++ = shift;
++	  *ip++ = color;
++	  sum[color] += 1 << shift;
++	}
++      code[row][col][0] = (ip - code[row][col]) / 3;
++      FORCC
++	if (c != f) {
++	  *ip++ = c;
++	  *ip++ = 256 / sum[c];
++	}
++    }
++  for (row=1; row < height-1; row++)
++    for (col=1; col < width-1; col++) {
++      pix = image[row*width+col];
++      ip = code[row % size][col % size];
++      memset (sum, 0, sizeof sum);
++      for (i=*ip++; i--; ip+=3)
++	sum[ip[2]] += pix[ip[0]] << ip[1];
++      for (i=colors; --i; ip+=2)
++	pix[ip[0]] = sum[ip[0]] * ip[1] >> 8;
++    }
++}
++
++/*
++   This algorithm is officially called:
++
++   "Interpolation using a Threshold-based variable number of gradients"
++
++   described in http://scien.stanford.edu/pages/labsite/1999/psych221/projects/99/tingchen/algodep/vargra.html
++
++   I've extended the basic idea to work with non-Bayer filter arrays.
++   Gradients are numbered clockwise from NW=0 to W=7.
++ */
++void CLASS vng_interpolate()
++{
++  static const signed char *cp, terms[] = {
++    -2,-2,+0,-1,0,0x01, -2,-2,+0,+0,1,0x01, -2,-1,-1,+0,0,0x01,
++    -2,-1,+0,-1,0,0x02, -2,-1,+0,+0,0,0x03, -2,-1,+0,+1,1,0x01,
++    -2,+0,+0,-1,0,0x06, -2,+0,+0,+0,1,0x02, -2,+0,+0,+1,0,0x03,
++    -2,+1,-1,+0,0,0x04, -2,+1,+0,-1,1,0x04, -2,+1,+0,+0,0,0x06,
++    -2,+1,+0,+1,0,0x02, -2,+2,+0,+0,1,0x04, -2,+2,+0,+1,0,0x04,
++    -1,-2,-1,+0,0,0x80, -1,-2,+0,-1,0,0x01, -1,-2,+1,-1,0,0x01,
++    -1,-2,+1,+0,1,0x01, -1,-1,-1,+1,0,0x88, -1,-1,+1,-2,0,0x40,
++    -1,-1,+1,-1,0,0x22, -1,-1,+1,+0,0,0x33, -1,-1,+1,+1,1,0x11,
++    -1,+0,-1,+2,0,0x08, -1,+0,+0,-1,0,0x44, -1,+0,+0,+1,0,0x11,
++    -1,+0,+1,-2,1,0x40, -1,+0,+1,-1,0,0x66, -1,+0,+1,+0,1,0x22,
++    -1,+0,+1,+1,0,0x33, -1,+0,+1,+2,1,0x10, -1,+1,+1,-1,1,0x44,
++    -1,+1,+1,+0,0,0x66, -1,+1,+1,+1,0,0x22, -1,+1,+1,+2,0,0x10,
++    -1,+2,+0,+1,0,0x04, -1,+2,+1,+0,1,0x04, -1,+2,+1,+1,0,0x04,
++    +0,-2,+0,+0,1,0x80, +0,-1,+0,+1,1,0x88, +0,-1,+1,-2,0,0x40,
++    +0,-1,+1,+0,0,0x11, +0,-1,+2,-2,0,0x40, +0,-1,+2,-1,0,0x20,
++    +0,-1,+2,+0,0,0x30, +0,-1,+2,+1,1,0x10, +0,+0,+0,+2,1,0x08,
++    +0,+0,+2,-2,1,0x40, +0,+0,+2,-1,0,0x60, +0,+0,+2,+0,1,0x20,
++    +0,+0,+2,+1,0,0x30, +0,+0,+2,+2,1,0x10, +0,+1,+1,+0,0,0x44,
++    +0,+1,+1,+2,0,0x10, +0,+1,+2,-1,1,0x40, +0,+1,+2,+0,0,0x60,
++    +0,+1,+2,+1,0,0x20, +0,+1,+2,+2,0,0x10, +1,-2,+1,+0,0,0x80,
++    +1,-1,+1,+1,0,0x88, +1,+0,+1,+2,0,0x08, +1,+0,+2,-1,0,0x40,
++    +1,+0,+2,+1,0,0x10
++  }, chood[] = { -1,-1, -1,0, -1,+1, 0,+1, +1,+1, +1,0, +1,-1, 0,-1 };
++  ushort (*brow[5])[4], *pix;
++  int prow=8, pcol=2, *ip, *code[16][16], gval[8], gmin, gmax, sum[4];
++  int row, col, x, y, x1, x2, y1, y2, t, weight, grads, color, diag;
++  int g, diff, thold, num, c;
++
++  lin_interpolate();
++  if (verbose) fprintf (stderr,_("VNG interpolation...\n"));
++
++  if (filters == 1) prow = pcol = 16;
++  if (filters == 9) prow = pcol =  6;
++  ip = (int *) calloc (prow*pcol, 1280);
++  merror (ip, "vng_interpolate()");
++  for (row=0; row < prow; row++)		/* Precalculate for VNG */
++    for (col=0; col < pcol; col++) {
++      code[row][col] = ip;
++      for (cp=terms, t=0; t < 64; t++) {
++	y1 = *cp++;  x1 = *cp++;
++	y2 = *cp++;  x2 = *cp++;
++	weight = *cp++;
++	grads = *cp++;
++	color = fcol(row+y1,col+x1);
++	if (fcol(row+y2,col+x2) != color) continue;
++	diag = (fcol(row,col+1) == color && fcol(row+1,col) == color) ? 2:1;
++	if (abs(y1-y2) == diag && abs(x1-x2) == diag) continue;
++	*ip++ = (y1*width + x1)*4 + color;
++	*ip++ = (y2*width + x2)*4 + color;
++	*ip++ = weight;
++	for (g=0; g < 8; g++)
++	  if (grads & 1<<g) *ip++ = g;
++	*ip++ = -1;
++      }
++      *ip++ = INT_MAX;
++      for (cp=chood, g=0; g < 8; g++) {
++	y = *cp++;  x = *cp++;
++	*ip++ = (y*width + x) * 4;
++	color = fcol(row,col);
++	if (fcol(row+y,col+x) != color && fcol(row+y*2,col+x*2) == color)
++	  *ip++ = (y*width + x) * 8 + color;
++	else
++	  *ip++ = 0;
++      }
++    }
++  brow[4] = (ushort (*)[4]) calloc (width*3, sizeof **brow);
++  merror (brow[4], "vng_interpolate()");
++  for (row=0; row < 3; row++)
++    brow[row] = brow[4] + row*width;
++  for (row=2; row < height-2; row++) {		/* Do VNG interpolation */
++    for (col=2; col < width-2; col++) {
++      pix = image[row*width+col];
++      ip = code[row % prow][col % pcol];
++      memset (gval, 0, sizeof gval);
++      while ((g = ip[0]) != INT_MAX) {		/* Calculate gradients */
++	diff = ABS(pix[g] - pix[ip[1]]) << ip[2];
++	gval[ip[3]] += diff;
++	ip += 5;
++	if ((g = ip[-1]) == -1) continue;
++	gval[g] += diff;
++	while ((g = *ip++) != -1)
++	  gval[g] += diff;
++      }
++      ip++;
++      gmin = gmax = gval[0];			/* Choose a threshold */
++      for (g=1; g < 8; g++) {
++	if (gmin > gval[g]) gmin = gval[g];
++	if (gmax < gval[g]) gmax = gval[g];
++      }
++      if (gmax == 0) {
++	memcpy (brow[2][col], pix, sizeof *image);
++	continue;
++      }
++      thold = gmin + (gmax >> 1);
++      memset (sum, 0, sizeof sum);
++      color = fcol(row,col);
++      for (num=g=0; g < 8; g++,ip+=2) {		/* Average the neighbors */
++	if (gval[g] <= thold) {
++	  FORCC
++	    if (c == color && ip[1])
++	      sum[c] += (pix[c] + pix[ip[1]]) >> 1;
++	    else
++	      sum[c] += pix[ip[0] + c];
++	  num++;
++	}
++      }
++      FORCC {					/* Save to buffer */
++	t = pix[color];
++	if (c != color)
++	  t += (sum[c] - sum[color]) / num;
++	brow[2][col][c] = CLIP(t);
++      }
++    }
++    if (row > 3)				/* Write buffer to image */
++      memcpy (image[(row-2)*width+2], brow[0]+2, (width-4)*sizeof *image);
++    for (g=0; g < 4; g++)
++      brow[(g-1) & 3] = brow[g];
++  }
++  memcpy (image[(row-2)*width+2], brow[0]+2, (width-4)*sizeof *image);
++  memcpy (image[(row-1)*width+2], brow[1]+2, (width-4)*sizeof *image);
++  free (brow[4]);
++  free (code[0][0]);
++}
++
++/*
++   Patterned Pixel Grouping Interpolation by Alain Desbiolles
++*/
++void CLASS ppg_interpolate()
++{
++  int dir[5] = { 1, width, -1, -width, 1 };
++  int row, col, diff[2], guess[2], c, d, i;
++  ushort (*pix)[4];
++
++  border_interpolate(3);
++  if (verbose) fprintf (stderr,_("PPG interpolation...\n"));
++
++/*  Fill in the green layer with gradients and pattern recognition: */
++  for (row=3; row < height-3; row++)
++    for (col=3+(FC(row,3) & 1), c=FC(row,col); col < width-3; col+=2) {
++      pix = image + row*width+col;
++      for (i=0; (d=dir[i]) > 0; i++) {
++	guess[i] = (pix[-d][1] + pix[0][c] + pix[d][1]) * 2
++		      - pix[-2*d][c] - pix[2*d][c];
++	diff[i] = ( ABS(pix[-2*d][c] - pix[ 0][c]) +
++		    ABS(pix[ 2*d][c] - pix[ 0][c]) +
++		    ABS(pix[  -d][1] - pix[ d][1]) ) * 3 +
++		  ( ABS(pix[ 3*d][1] - pix[ d][1]) +
++		    ABS(pix[-3*d][1] - pix[-d][1]) ) * 2;
++      }
++      d = dir[i = diff[0] > diff[1]];
++      pix[0][1] = ULIM(guess[i] >> 2, pix[d][1], pix[-d][1]);
++    }
++/*  Calculate red and blue for each green pixel:		*/
++  for (row=1; row < height-1; row++)
++    for (col=1+(FC(row,2) & 1), c=FC(row,col+1); col < width-1; col+=2) {
++      pix = image + row*width+col;
++      for (i=0; (d=dir[i]) > 0; c=2-c, i++)
++	pix[0][c] = CLIP((pix[-d][c] + pix[d][c] + 2*pix[0][1]
++			- pix[-d][1] - pix[d][1]) >> 1);
++    }
++/*  Calculate blue for red pixels and vice versa:		*/
++  for (row=1; row < height-1; row++)
++    for (col=1+(FC(row,1) & 1), c=2-FC(row,col); col < width-1; col+=2) {
++      pix = image + row*width+col;
++      for (i=0; (d=dir[i]+dir[i+1]) > 0; i++) {
++	diff[i] = ABS(pix[-d][c] - pix[d][c]) +
++		  ABS(pix[-d][1] - pix[0][1]) +
++		  ABS(pix[ d][1] - pix[0][1]);
++	guess[i] = pix[-d][c] + pix[d][c] + 2*pix[0][1]
++		 - pix[-d][1] - pix[d][1];
++      }
++      if (diff[0] != diff[1])
++	pix[0][c] = CLIP(guess[diff[0] > diff[1]] >> 1);
++      else
++	pix[0][c] = CLIP((guess[0]+guess[1]) >> 2);
++    }
++}
++
++void CLASS cielab (ushort rgb[3], short lab[3])
++{
++  int c, i, j, k;
++  float r, xyz[3];
++  static float cbrt[0x10000], xyz_cam[3][4];
++
++  if (!rgb) {
++    for (i=0; i < 0x10000; i++) {
++      r = i / 65535.0;
++      cbrt[i] = r > 0.008856 ? pow(r,1/3.0) : 7.787*r + 16/116.0;
++    }
++    for (i=0; i < 3; i++)
++      for (j=0; j < colors; j++)
++	for (xyz_cam[i][j] = k=0; k < 3; k++)
++	  xyz_cam[i][j] += xyz_rgb[i][k] * rgb_cam[k][j] / d65_white[i];
++    return;
++  }
++  xyz[0] = xyz[1] = xyz[2] = 0.5;
++  FORCC {
++    xyz[0] += xyz_cam[0][c] * rgb[c];
++    xyz[1] += xyz_cam[1][c] * rgb[c];
++    xyz[2] += xyz_cam[2][c] * rgb[c];
++  }
++  xyz[0] = cbrt[CLIP((int) xyz[0])];
++  xyz[1] = cbrt[CLIP((int) xyz[1])];
++  xyz[2] = cbrt[CLIP((int) xyz[2])];
++  lab[0] = 64 * (116 * xyz[1] - 16);
++  lab[1] = 64 * 500 * (xyz[0] - xyz[1]);
++  lab[2] = 64 * 200 * (xyz[1] - xyz[2]);
++}
++
++#define TS 512		/* Tile Size */
++#define fcol(row,col) xtrans[(row+6) % 6][(col+6) % 6]
++
++/*
++   Frank Markesteijn's algorithm for Fuji X-Trans sensors
++ */
++void CLASS xtrans_interpolate (int passes)
++{
++  int c, d, f, g, h, i, v, ng, row, col, top, left, mrow, mcol;
++  int val, ndir, pass, hm[8], avg[4], color[3][8];
++  static const short orth[12] = { 1,0,0,1,-1,0,0,-1,1,0,0,1 },
++	patt[2][16] = { { 0,1,0,-1,2,0,-1,0,1,1,1,-1,0,0,0,0 },
++			{ 0,1,0,-2,1,0,-2,0,1,1,-2,-2,1,-1,-1,1 } },
++	dir[4] = { 1,TS,TS+1,TS-1 };
++  short allhex[3][3][2][8], *hex;
++  ushort min, max, sgrow, sgcol;
++  ushort (*rgb)[TS][TS][3], (*rix)[3], (*pix)[4];
++   short (*lab)    [TS][3], (*lix)[3];
++   float (*drv)[TS][TS], diff[6], tr;
++   char (*homo)[TS][TS], *buffer;
++
++  if (verbose)
++    fprintf (stderr,_("%d-pass X-Trans interpolation...\n"), passes);
++
++  cielab (0,0);
++  ndir = 4 << (passes > 1);
++  buffer = (char *) malloc (TS*TS*(ndir*11+6));
++  merror (buffer, "xtrans_interpolate()");
++  rgb  = (ushort(*)[TS][TS][3]) buffer;
++  lab  = (short (*)    [TS][3])(buffer + TS*TS*(ndir*6));
++  drv  = (float (*)[TS][TS])   (buffer + TS*TS*(ndir*6+6));
++  homo = (char  (*)[TS][TS])   (buffer + TS*TS*(ndir*10+6));
++
++/* Map a green hexagon around each non-green pixel and vice versa:	*/
++  for (row=0; row < 3; row++)
++    for (col=0; col < 3; col++)
++      for (ng=d=0; d < 10; d+=2) {
++	g = fcol(row,col) == 1;
++	if (fcol(row+orth[d],col+orth[d+2]) == 1) ng=0; else ng++;
++	if (ng == 4) { sgrow = row; sgcol = col; }
++	if (ng == g+1) FORC(8) {
++	  v = orth[d  ]*patt[g][c*2] + orth[d+1]*patt[g][c*2+1];
++	  h = orth[d+2]*patt[g][c*2] + orth[d+3]*patt[g][c*2+1];
++	  allhex[row][col][0][c^(g*2 & d)] = h + v*width;
++	  allhex[row][col][1][c^(g*2 & d)] = h + v*TS;
++	}
++      }
++
++/* Set green1 and green3 to the minimum and maximum allowed values:	*/
++  for (row=2; row < height-2; row++)
++    for (min=~(max=0), col=2; col < width-2; col++) {
++      if (fcol(row,col) == 1 && (min=~(max=0))) continue;
++      pix = image + row*width + col;
++      hex = allhex[row % 3][col % 3][0];
++      if (!max) FORC(6) {
++	val = pix[hex[c]][1];
++	if (min > val) min = val;
++	if (max < val) max = val;
++      }
++      pix[0][1] = min;
++      pix[0][3] = max;
++      switch ((row-sgrow) % 3) {
++	case 1: if (row < height-3) { row++; col--; } break;
++	case 2: if ((min=~(max=0)) && (col+=2) < width-3 && row > 2) row--;
++      }
++    }
++
++  for (top=3; top < height-19; top += TS-16)
++    for (left=3; left < width-19; left += TS-16) {
++      mrow = MIN (top+TS, height-3);
++      mcol = MIN (left+TS, width-3);
++      for (row=top; row < mrow; row++)
++	for (col=left; col < mcol; col++)
++	  memcpy (rgb[0][row-top][col-left], image[row*width+col], 6);
++      FORC3 memcpy (rgb[c+1], rgb[0], sizeof *rgb);
++
++/* Interpolate green horizontally, vertically, and along both diagonals: */
++      for (row=top; row < mrow; row++)
++	for (col=left; col < mcol; col++) {
++	  if ((f = fcol(row,col)) == 1) continue;
++	  pix = image + row*width + col;
++	  hex = allhex[row % 3][col % 3][0];
++	  color[1][0] = 174 * (pix[  hex[1]][1] + pix[  hex[0]][1]) -
++			 46 * (pix[2*hex[1]][1] + pix[2*hex[0]][1]);
++	  color[1][1] = 223 *  pix[  hex[3]][1] + pix[  hex[2]][1] * 33 +
++			 92 * (pix[      0 ][f] - pix[ -hex[2]][f]);
++	  FORC(2) color[1][2+c] =
++		164 * pix[hex[4+c]][1] + 92 * pix[-2*hex[4+c]][1] + 33 *
++		(2*pix[0][f] - pix[3*hex[4+c]][f] - pix[-3*hex[4+c]][f]);
++	  FORC4 rgb[c^!((row-sgrow) % 3)][row-top][col-left][1] =
++		LIM(color[1][c] >> 8,pix[0][1],pix[0][3]);
++	}
++
++      for (pass=0; pass < passes; pass++) {
++	if (pass == 1)
++	  memcpy (rgb+=4, buffer, 4*sizeof *rgb);
++
++/* Recalculate green from interpolated values of closer pixels:	*/
++	if (pass) {
++	  for (row=top+2; row < mrow-2; row++)
++	    for (col=left+2; col < mcol-2; col++) {
++	      if ((f = fcol(row,col)) == 1) continue;
++	      pix = image + row*width + col;
++	      hex = allhex[row % 3][col % 3][1];
++	      for (d=3; d < 6; d++) {
++		rix = &rgb[(d-2)^!((row-sgrow) % 3)][row-top][col-left];
++		val = rix[-2*hex[d]][1] + 2*rix[hex[d]][1]
++		    - rix[-2*hex[d]][f] - 2*rix[hex[d]][f] + 3*rix[0][f];
++		rix[0][1] = LIM(val/3,pix[0][1],pix[0][3]);
++	      }
++	    }
++	}
++
++/* Interpolate red and blue values for solitary green pixels:	*/
++	for (row=(top-sgrow+4)/3*3+sgrow; row < mrow-2; row+=3)
++	  for (col=(left-sgcol+4)/3*3+sgcol; col < mcol-2; col+=3) {
++	    rix = &rgb[0][row-top][col-left];
++	    h = fcol(row,col+1);
++	    memset (diff, 0, sizeof diff);
++	    for (i=1, d=0; d < 6; d++, i^=TS^1, h^=2) {
++	      for (c=0; c < 2; c++, h^=2) {
++		g = 2*rix[0][1] - rix[i<<c][1] - rix[-i<<c][1];
++		color[h][d] = g + rix[i<<c][h] + rix[-i<<c][h];
++		if (d > 1)
++		  diff[d] += SQR (rix[i<<c][1] - rix[-i<<c][1]
++				- rix[i<<c][h] + rix[-i<<c][h]) + SQR(g);
++	      }
++	      if (d > 1 && (d & 1))
++		if (diff[d-1] < diff[d])
++		  FORC(2) color[c*2][d] = color[c*2][d-1];
++	      if (d < 2 || (d & 1)) {
++		FORC(2) rix[0][c*2] = CLIP(color[c*2][d]/2);
++		rix += TS*TS;
++	      }
++	    }
++	  }
++
++/* Interpolate red for blue pixels and vice versa:		*/
++	for (row=top+3; row < mrow-3; row++)
++	  for (col=left+3; col < mcol-3; col++) {
++	    if ((f = 2-fcol(row,col)) == 1) continue;
++	    rix = &rgb[0][row-top][col-left];
++	    c = (row-sgrow) % 3 ? TS:1;
++	    h = 3 * (c ^ TS ^ 1);
++	    for (d=0; d < 4; d++, rix += TS*TS) {
++	      i = d > 1 || ((d ^ c) & 1) ||
++		 ((ABS(rix[0][1]-rix[c][1])+ABS(rix[0][1]-rix[-c][1])) <
++		2*(ABS(rix[0][1]-rix[h][1])+ABS(rix[0][1]-rix[-h][1]))) ? c:h;
++	      rix[0][f] = CLIP((rix[i][f] + rix[-i][f] +
++		  2*rix[0][1] - rix[i][1] - rix[-i][1])/2);
++	    }
++	  }
++
++/* Fill in red and blue for 2x2 blocks of green:		*/
++	for (row=top+2; row < mrow-2; row++) if ((row-sgrow) % 3)
++	  for (col=left+2; col < mcol-2; col++) if ((col-sgcol) % 3) {
++	    rix = &rgb[0][row-top][col-left];
++	    hex = allhex[row % 3][col % 3][1];
++	    for (d=0; d < ndir; d+=2, rix += TS*TS)
++	      if (hex[d] + hex[d+1]) {
++		g = 3*rix[0][1] - 2*rix[hex[d]][1] - rix[hex[d+1]][1];
++		for (c=0; c < 4; c+=2) rix[0][c] =
++			CLIP((g + 2*rix[hex[d]][c] + rix[hex[d+1]][c])/3);
++	      } else {
++		g = 2*rix[0][1] - rix[hex[d]][1] - rix[hex[d+1]][1];
++		for (c=0; c < 4; c+=2) rix[0][c] =
++			CLIP((g + rix[hex[d]][c] + rix[hex[d+1]][c])/2);
++	      }
++	  }
++      }
++      rgb = (ushort(*)[TS][TS][3]) buffer;
++      mrow -= top;
++      mcol -= left;
++
++/* Convert to CIELab and differentiate in all directions:	*/
++      for (d=0; d < ndir; d++) {
++	for (row=2; row < mrow-2; row++)
++	  for (col=2; col < mcol-2; col++)
++	    cielab (rgb[d][row][col], lab[row][col]);
++	for (f=dir[d & 3],row=3; row < mrow-3; row++)
++	  for (col=3; col < mcol-3; col++) {
++	    lix = &lab[row][col];
++	    g = 2*lix[0][0] - lix[f][0] - lix[-f][0];
++	    drv[d][row][col] = SQR(g)
++	      + SQR((2*lix[0][1] - lix[f][1] - lix[-f][1] + g*500/232))
++	      + SQR((2*lix[0][2] - lix[f][2] - lix[-f][2] - g*500/580));
++	  }
++      }
++
++/* Build homogeneity maps from the derivatives:			*/
++      memset(homo, 0, ndir*TS*TS);
++      for (row=4; row < mrow-4; row++)
++	for (col=4; col < mcol-4; col++) {
++	  for (tr=FLT_MAX, d=0; d < ndir; d++)
++	    if (tr > drv[d][row][col])
++		tr = drv[d][row][col];
++	  tr *= 8;
++	  for (d=0; d < ndir; d++)
++	    for (v=-1; v <= 1; v++)
++	      for (h=-1; h <= 1; h++)
++		if (drv[d][row+v][col+h] <= tr)
++		  homo[d][row][col]++;
++	}
++
++/* Average the most homogenous pixels for the final result:	*/
++      if (height-top < TS+4) mrow = height-top+2;
++      if (width-left < TS+4) mcol = width-left+2;
++      for (row = MIN(top,8); row < mrow-8; row++)
++	for (col = MIN(left,8); col < mcol-8; col++) {
++	  for (d=0; d < ndir; d++)
++	    for (hm[d]=0, v=-2; v <= 2; v++)
++	      for (h=-2; h <= 2; h++)
++		hm[d] += homo[d][row+v][col+h];
++	  for (d=0; d < ndir-4; d++)
++	    if (hm[d] < hm[d+4]) hm[d  ] = 0; else
++	    if (hm[d] > hm[d+4]) hm[d+4] = 0;
++	  for (max=hm[0],d=1; d < ndir; d++)
++	    if (max < hm[d]) max = hm[d];
++	  max -= max >> 3;
++	  memset (avg, 0, sizeof avg);
++	  for (d=0; d < ndir; d++)
++	    if (hm[d] >= max) {
++	      FORC3 avg[c] += rgb[d][row][col][c];
++	      avg[3]++;
++	    }
++	  FORC3 image[(row+top)*width+col+left][c] = avg[c]/avg[3];
++	}
++    }
++  free(buffer);
++  border_interpolate(8);
++}
++#undef fcol
++
++/*
++   Adaptive Homogeneity-Directed interpolation is based on
++   the work of Keigo Hirakawa, Thomas Parks, and Paul Lee.
++ */
++void CLASS ahd_interpolate()
++{
++  int i, j, top, left, row, col, tr, tc, c, d, val, hm[2];
++  static const int dir[4] = { -1, 1, -TS, TS };
++  unsigned ldiff[2][4], abdiff[2][4], leps, abeps;
++  ushort (*rgb)[TS][TS][3], (*rix)[3], (*pix)[4];
++   short (*lab)[TS][TS][3], (*lix)[3];
++   char (*homo)[TS][TS], *buffer;
++
++  if (verbose) fprintf (stderr,_("AHD interpolation...\n"));
++
++  cielab (0,0);
++  border_interpolate(5);
++  buffer = (char *) malloc (26*TS*TS);
++  merror (buffer, "ahd_interpolate()");
++  rgb  = (ushort(*)[TS][TS][3]) buffer;
++  lab  = (short (*)[TS][TS][3])(buffer + 12*TS*TS);
++  homo = (char  (*)[TS][TS])   (buffer + 24*TS*TS);
++
++  for (top=2; top < height-5; top += TS-6)
++    for (left=2; left < width-5; left += TS-6) {
++
++/*  Interpolate green horizontally and vertically:		*/
++      for (row=top; row < top+TS && row < height-2; row++) {
++	col = left + (FC(row,left) & 1);
++	for (c = FC(row,col); col < left+TS && col < width-2; col+=2) {
++	  pix = image + row*width+col;
++	  val = ((pix[-1][1] + pix[0][c] + pix[1][1]) * 2
++		- pix[-2][c] - pix[2][c]) >> 2;
++	  rgb[0][row-top][col-left][1] = ULIM(val,pix[-1][1],pix[1][1]);
++	  val = ((pix[-width][1] + pix[0][c] + pix[width][1]) * 2
++		- pix[-2*width][c] - pix[2*width][c]) >> 2;
++	  rgb[1][row-top][col-left][1] = ULIM(val,pix[-width][1],pix[width][1]);
++	}
++      }
++/*  Interpolate red and blue, and convert to CIELab:		*/
++      for (d=0; d < 2; d++)
++	for (row=top+1; row < top+TS-1 && row < height-3; row++)
++	  for (col=left+1; col < left+TS-1 && col < width-3; col++) {
++	    pix = image + row*width+col;
++	    rix = &rgb[d][row-top][col-left];
++	    lix = &lab[d][row-top][col-left];
++	    if ((c = 2 - FC(row,col)) == 1) {
++	      c = FC(row+1,col);
++	      val = pix[0][1] + (( pix[-1][2-c] + pix[1][2-c]
++				 - rix[-1][1] - rix[1][1] ) >> 1);
++	      rix[0][2-c] = CLIP(val);
++	      val = pix[0][1] + (( pix[-width][c] + pix[width][c]
++				 - rix[-TS][1] - rix[TS][1] ) >> 1);
++	    } else
++	      val = rix[0][1] + (( pix[-width-1][c] + pix[-width+1][c]
++				 + pix[+width-1][c] + pix[+width+1][c]
++				 - rix[-TS-1][1] - rix[-TS+1][1]
++				 - rix[+TS-1][1] - rix[+TS+1][1] + 1) >> 2);
++	    rix[0][c] = CLIP(val);
++	    c = FC(row,col);
++	    rix[0][c] = pix[0][c];
++	    cielab (rix[0],lix[0]);
++	  }
++/*  Build homogeneity maps from the CIELab images:		*/
++      memset (homo, 0, 2*TS*TS);
++      for (row=top+2; row < top+TS-2 && row < height-4; row++) {
++	tr = row-top;
++	for (col=left+2; col < left+TS-2 && col < width-4; col++) {
++	  tc = col-left;
++	  for (d=0; d < 2; d++) {
++	    lix = &lab[d][tr][tc];
++	    for (i=0; i < 4; i++) {
++	       ldiff[d][i] = ABS(lix[0][0]-lix[dir[i]][0]);
++	      abdiff[d][i] = SQR(lix[0][1]-lix[dir[i]][1])
++			   + SQR(lix[0][2]-lix[dir[i]][2]);
++	    }
++	  }
++	  leps = MIN(MAX(ldiff[0][0],ldiff[0][1]),
++		     MAX(ldiff[1][2],ldiff[1][3]));
++	  abeps = MIN(MAX(abdiff[0][0],abdiff[0][1]),
++		      MAX(abdiff[1][2],abdiff[1][3]));
++	  for (d=0; d < 2; d++)
++	    for (i=0; i < 4; i++)
++	      if (ldiff[d][i] <= leps && abdiff[d][i] <= abeps)
++		homo[d][tr][tc]++;
++	}
++      }
++/*  Combine the most homogenous pixels for the final result:	*/
++      for (row=top+3; row < top+TS-3 && row < height-5; row++) {
++	tr = row-top;
++	for (col=left+3; col < left+TS-3 && col < width-5; col++) {
++	  tc = col-left;
++	  for (d=0; d < 2; d++)
++	    for (hm[d]=0, i=tr-1; i <= tr+1; i++)
++	      for (j=tc-1; j <= tc+1; j++)
++		hm[d] += homo[d][i][j];
++	  if (hm[0] != hm[1])
++	    FORC3 image[row*width+col][c] = rgb[hm[1] > hm[0]][tr][tc][c];
++	  else
++	    FORC3 image[row*width+col][c] =
++		(rgb[0][tr][tc][c] + rgb[1][tr][tc][c]) >> 1;
++	}
++      }
++    }
++  free (buffer);
++}
++#undef TS
++
++void CLASS median_filter()
++{
++  ushort (*pix)[4];
++  int pass, c, i, j, k, med[9];
++  static const uchar opt[] =	/* Optimal 9-element median search */
++  { 1,2, 4,5, 7,8, 0,1, 3,4, 6,7, 1,2, 4,5, 7,8,
++    0,3, 5,8, 4,7, 3,6, 1,4, 2,5, 4,7, 4,2, 6,4, 4,2 };
++
++  for (pass=1; pass <= med_passes; pass++) {
++    if (verbose)
++      fprintf (stderr,_("Median filter pass %d...\n"), pass);
++    for (c=0; c < 3; c+=2) {
++      for (pix = image; pix < image+width*height; pix++)
++	pix[0][3] = pix[0][c];
++      for (pix = image+width; pix < image+width*(height-1); pix++) {
++	if ((pix-image+1) % width < 2) continue;
++	for (k=0, i = -width; i <= width; i += width)
++	  for (j = i-1; j <= i+1; j++)
++	    med[k++] = pix[j][3] - pix[j][1];
++	for (i=0; i < sizeof opt; i+=2)
++	  if     (med[opt[i]] > med[opt[i+1]])
++	    SWAP (med[opt[i]] , med[opt[i+1]]);
++	pix[0][c] = CLIP(med[4] + pix[0][1]);
++      }
++    }
++  }
++}
++
++void CLASS blend_highlights()
++{
++  int clip=INT_MAX, row, col, c, i, j;
++  static const float trans[2][4][4] =
++  { { { 1,1,1 }, { 1.7320508,-1.7320508,0 }, { -1,-1,2 } },
++    { { 1,1,1,1 }, { 1,-1,1,-1 }, { 1,1,-1,-1 }, { 1,-1,-1,1 } } };
++  static const float itrans[2][4][4] =
++  { { { 1,0.8660254,-0.5 }, { 1,-0.8660254,-0.5 }, { 1,0,1 } },
++    { { 1,1,1,1 }, { 1,-1,1,-1 }, { 1,1,-1,-1 }, { 1,-1,-1,1 } } };
++  float cam[2][4], lab[2][4], sum[2], chratio;
++
++  if ((unsigned) (colors-3) > 1) return;
++  if (verbose) fprintf (stderr,_("Blending highlights...\n"));
++  FORCC if (clip > (i = 65535*pre_mul[c])) clip = i;
++  for (row=0; row < height; row++)
++    for (col=0; col < width; col++) {
++      FORCC if (image[row*width+col][c] > clip) break;
++      if (c == colors) continue;
++      FORCC {
++	cam[0][c] = image[row*width+col][c];
++	cam[1][c] = MIN(cam[0][c],clip);
++      }
++      for (i=0; i < 2; i++) {
++	FORCC for (lab[i][c]=j=0; j < colors; j++)
++	  lab[i][c] += trans[colors-3][c][j] * cam[i][j];
++	for (sum[i]=0,c=1; c < colors; c++)
++	  sum[i] += SQR(lab[i][c]);
++      }
++      chratio = sqrt(sum[1]/sum[0]);
++      for (c=1; c < colors; c++)
++	lab[0][c] *= chratio;
++      FORCC for (cam[0][c]=j=0; j < colors; j++)
++	cam[0][c] += itrans[colors-3][c][j] * lab[0][j];
++      FORCC image[row*width+col][c] = cam[0][c] / colors;
++    }
++}
++
++#define SCALE (4 >> shrink)
++void CLASS recover_highlights()
++{
++  float *map, sum, wgt, grow;
++  int hsat[4], count, spread, change, val, i;
++  unsigned high, wide, mrow, mcol, row, col, kc, c, d, y, x;
++  ushort *pixel;
++  static const signed char dir[8][2] =
++    { {-1,-1}, {-1,0}, {-1,1}, {0,1}, {1,1}, {1,0}, {1,-1}, {0,-1} };
++
++  if (verbose) fprintf (stderr,_("Rebuilding highlights...\n"));
++
++  grow = pow (2, 4-highlight);
++  FORCC hsat[c] = 32000 * pre_mul[c];
++  for (kc=0, c=1; c < colors; c++)
++    if (pre_mul[kc] < pre_mul[c]) kc = c;
++  high = height / SCALE;
++  wide =  width / SCALE;
++  map = (float *) calloc (high, wide*sizeof *map);
++  merror (map, "recover_highlights()");
++  FORCC if (c != kc) {
++    memset (map, 0, high*wide*sizeof *map);
++    for (mrow=0; mrow < high; mrow++)
++      for (mcol=0; mcol < wide; mcol++) {
++	sum = wgt = count = 0;
++	for (row = mrow*SCALE; row < (mrow+1)*SCALE; row++)
++	  for (col = mcol*SCALE; col < (mcol+1)*SCALE; col++) {
++	    pixel = image[row*width+col];
++	    if (pixel[c] / hsat[c] == 1 && pixel[kc] > 24000) {
++	      sum += pixel[c];
++	      wgt += pixel[kc];
++	      count++;
++	    }
++	  }
++	if (count == SCALE*SCALE)
++	  map[mrow*wide+mcol] = sum / wgt;
++      }
++    for (spread = 32/grow; spread--; ) {
++      for (mrow=0; mrow < high; mrow++)
++	for (mcol=0; mcol < wide; mcol++) {
++	  if (map[mrow*wide+mcol]) continue;
++	  sum = count = 0;
++	  for (d=0; d < 8; d++) {
++	    y = mrow + dir[d][0];
++	    x = mcol + dir[d][1];
++	    if (y < high && x < wide && map[y*wide+x] > 0) {
++	      sum  += (1 + (d & 1)) * map[y*wide+x];
++	      count += 1 + (d & 1);
++	    }
++	  }
++	  if (count > 3)
++	    map[mrow*wide+mcol] = - (sum+grow) / (count+grow);
++	}
++      for (change=i=0; i < high*wide; i++)
++	if (map[i] < 0) {
++	  map[i] = -map[i];
++	  change = 1;
++	}
++      if (!change) break;
++    }
++    for (i=0; i < high*wide; i++)
++      if (map[i] == 0) map[i] = 1;
++    for (mrow=0; mrow < high; mrow++)
++      for (mcol=0; mcol < wide; mcol++) {
++	for (row = mrow*SCALE; row < (mrow+1)*SCALE; row++)
++	  for (col = mcol*SCALE; col < (mcol+1)*SCALE; col++) {
++	    pixel = image[row*width+col];
++	    if (pixel[c] / hsat[c] > 1) {
++	      val = pixel[kc] * map[mrow*wide+mcol];
++	      if (pixel[c] < val) pixel[c] = CLIP(val);
++	    }
++	  }
++      }
++  }
++  free (map);
++}
++#undef SCALE
++
++void CLASS tiff_get (unsigned base,
++	unsigned *tag, unsigned *type, unsigned *len, unsigned *save)
++{
++  *tag  = get2();
++  *type = get2();
++  *len  = get4();
++  *save = ftell(ifp) + 4;
++  if (*len * ("11124811248484"[*type < 14 ? *type:0]-'0') > 4)
++    fseek (ifp, get4()+base, SEEK_SET);
++}
++
++void CLASS parse_thumb_note (int base, unsigned toff, unsigned tlen)
++{
++  unsigned entries, tag, type, len, save;
++
++  entries = get2();
++  while (entries--) {
++    tiff_get (base, &tag, &type, &len, &save);
++    if (tag == toff) thumb_offset = get4()+base;
++    if (tag == tlen) thumb_length = get4();
++    fseek (ifp, save, SEEK_SET);
++  }
++}
++
++int CLASS parse_tiff_ifd (int base);
++
++void CLASS parse_makernote (int base, int uptag)
++{
++  static const uchar xlat[2][256] = {
++  { 0xc1,0xbf,0x6d,0x0d,0x59,0xc5,0x13,0x9d,0x83,0x61,0x6b,0x4f,0xc7,0x7f,0x3d,0x3d,
++    0x53,0x59,0xe3,0xc7,0xe9,0x2f,0x95,0xa7,0x95,0x1f,0xdf,0x7f,0x2b,0x29,0xc7,0x0d,
++    0xdf,0x07,0xef,0x71,0x89,0x3d,0x13,0x3d,0x3b,0x13,0xfb,0x0d,0x89,0xc1,0x65,0x1f,
++    0xb3,0x0d,0x6b,0x29,0xe3,0xfb,0xef,0xa3,0x6b,0x47,0x7f,0x95,0x35,0xa7,0x47,0x4f,
++    0xc7,0xf1,0x59,0x95,0x35,0x11,0x29,0x61,0xf1,0x3d,0xb3,0x2b,0x0d,0x43,0x89,0xc1,
++    0x9d,0x9d,0x89,0x65,0xf1,0xe9,0xdf,0xbf,0x3d,0x7f,0x53,0x97,0xe5,0xe9,0x95,0x17,
++    0x1d,0x3d,0x8b,0xfb,0xc7,0xe3,0x67,0xa7,0x07,0xf1,0x71,0xa7,0x53,0xb5,0x29,0x89,
++    0xe5,0x2b,0xa7,0x17,0x29,0xe9,0x4f,0xc5,0x65,0x6d,0x6b,0xef,0x0d,0x89,0x49,0x2f,
++    0xb3,0x43,0x53,0x65,0x1d,0x49,0xa3,0x13,0x89,0x59,0xef,0x6b,0xef,0x65,0x1d,0x0b,
++    0x59,0x13,0xe3,0x4f,0x9d,0xb3,0x29,0x43,0x2b,0x07,0x1d,0x95,0x59,0x59,0x47,0xfb,
++    0xe5,0xe9,0x61,0x47,0x2f,0x35,0x7f,0x17,0x7f,0xef,0x7f,0x95,0x95,0x71,0xd3,0xa3,
++    0x0b,0x71,0xa3,0xad,0x0b,0x3b,0xb5,0xfb,0xa3,0xbf,0x4f,0x83,0x1d,0xad,0xe9,0x2f,
++    0x71,0x65,0xa3,0xe5,0x07,0x35,0x3d,0x0d,0xb5,0xe9,0xe5,0x47,0x3b,0x9d,0xef,0x35,
++    0xa3,0xbf,0xb3,0xdf,0x53,0xd3,0x97,0x53,0x49,0x71,0x07,0x35,0x61,0x71,0x2f,0x43,
++    0x2f,0x11,0xdf,0x17,0x97,0xfb,0x95,0x3b,0x7f,0x6b,0xd3,0x25,0xbf,0xad,0xc7,0xc5,
++    0xc5,0xb5,0x8b,0xef,0x2f,0xd3,0x07,0x6b,0x25,0x49,0x95,0x25,0x49,0x6d,0x71,0xc7 },
++  { 0xa7,0xbc,0xc9,0xad,0x91,0xdf,0x85,0xe5,0xd4,0x78,0xd5,0x17,0x46,0x7c,0x29,0x4c,
++    0x4d,0x03,0xe9,0x25,0x68,0x11,0x86,0xb3,0xbd,0xf7,0x6f,0x61,0x22,0xa2,0x26,0x34,
++    0x2a,0xbe,0x1e,0x46,0x14,0x68,0x9d,0x44,0x18,0xc2,0x40,0xf4,0x7e,0x5f,0x1b,0xad,
++    0x0b,0x94,0xb6,0x67,0xb4,0x0b,0xe1,0xea,0x95,0x9c,0x66,0xdc,0xe7,0x5d,0x6c,0x05,
++    0xda,0xd5,0xdf,0x7a,0xef,0xf6,0xdb,0x1f,0x82,0x4c,0xc0,0x68,0x47,0xa1,0xbd,0xee,
++    0x39,0x50,0x56,0x4a,0xdd,0xdf,0xa5,0xf8,0xc6,0xda,0xca,0x90,0xca,0x01,0x42,0x9d,
++    0x8b,0x0c,0x73,0x43,0x75,0x05,0x94,0xde,0x24,0xb3,0x80,0x34,0xe5,0x2c,0xdc,0x9b,
++    0x3f,0xca,0x33,0x45,0xd0,0xdb,0x5f,0xf5,0x52,0xc3,0x21,0xda,0xe2,0x22,0x72,0x6b,
++    0x3e,0xd0,0x5b,0xa8,0x87,0x8c,0x06,0x5d,0x0f,0xdd,0x09,0x19,0x93,0xd0,0xb9,0xfc,
++    0x8b,0x0f,0x84,0x60,0x33,0x1c,0x9b,0x45,0xf1,0xf0,0xa3,0x94,0x3a,0x12,0x77,0x33,
++    0x4d,0x44,0x78,0x28,0x3c,0x9e,0xfd,0x65,0x57,0x16,0x94,0x6b,0xfb,0x59,0xd0,0xc8,
++    0x22,0x36,0xdb,0xd2,0x63,0x98,0x43,0xa1,0x04,0x87,0x86,0xf7,0xa6,0x26,0xbb,0xd6,
++    0x59,0x4d,0xbf,0x6a,0x2e,0xaa,0x2b,0xef,0xe6,0x78,0xb6,0x4e,0xe0,0x2f,0xdc,0x7c,
++    0xbe,0x57,0x19,0x32,0x7e,0x2a,0xd0,0xb8,0xba,0x29,0x00,0x3c,0x52,0x7d,0xa8,0x49,
++    0x3b,0x2d,0xeb,0x25,0x49,0xfa,0xa3,0xaa,0x39,0xa7,0xc5,0xa7,0x50,0x11,0x36,0xfb,
++    0xc6,0x67,0x4a,0xf5,0xa5,0x12,0x65,0x7e,0xb0,0xdf,0xaf,0x4e,0xb3,0x61,0x7f,0x2f } };
++  unsigned offset=0, entries, tag, type, len, save, c;
++  unsigned ver97=0, serial=0, i, wbi=0, wb[4]={0,0,0,0};
++  uchar buf97[324], ci, cj, ck;
++  short morder, sorder=order;
++  char buf[10];
++/*
++   The MakerNote might have its own TIFF header (possibly with
++   its own byte-order!), or it might just be a table.
++ */
++  if (!strcmp(make,"Nokia")) return;
++  fread (buf, 1, 10, ifp);
++  if (!strncmp (buf,"KDK" ,3) ||	/* these aren't TIFF tables */
++      !strncmp (buf,"VER" ,3) ||
++      !strncmp (buf,"IIII",4) ||
++      !strncmp (buf,"MMMM",4)) return;
++  if (!strncmp (buf,"KC"  ,2) ||	/* Konica KD-400Z, KD-510Z */
++      !strncmp (buf,"MLY" ,3)) {	/* Minolta DiMAGE G series */
++    order = 0x4d4d;
++    while ((i=ftell(ifp)) < data_offset && i < 16384) {
++      wb[0] = wb[2];  wb[2] = wb[1];  wb[1] = wb[3];
++      wb[3] = get2();
++      if (wb[1] == 256 && wb[3] == 256 &&
++	  wb[0] > 256 && wb[0] < 640 && wb[2] > 256 && wb[2] < 640)
++	FORC4 cam_mul[c] = wb[c];
++    }
++    goto quit;
++  }
++  if (!strcmp (buf,"Nikon")) {
++    base = ftell(ifp);
++    order = get2();
++    if (get2() != 42) goto quit;
++    offset = get4();
++    fseek (ifp, offset-8, SEEK_CUR);
++  } else if (!strcmp (buf,"OLYMPUS") ||
++             !strcmp (buf,"PENTAX ")) {
++    base = ftell(ifp)-10;
++    fseek (ifp, -2, SEEK_CUR);
++    order = get2();
++    if (buf[0] == 'O') get2();
++  } else if (!strncmp (buf,"SONY",4) ||
++	     !strcmp  (buf,"Panasonic")) {
++    goto nf;
++  } else if (!strncmp (buf,"FUJIFILM",8)) {
++    base = ftell(ifp)-10;
++nf: order = 0x4949;
++    fseek (ifp,  2, SEEK_CUR);
++  } else if (!strcmp (buf,"OLYMP") ||
++	     !strcmp (buf,"LEICA") ||
++	     !strcmp (buf,"Ricoh") ||
++	     !strcmp (buf,"EPSON"))
++    fseek (ifp, -2, SEEK_CUR);
++  else if (!strcmp (buf,"AOC") ||
++	   !strcmp (buf,"QVC"))
++    fseek (ifp, -4, SEEK_CUR);
++  else {
++    fseek (ifp, -10, SEEK_CUR);
++    if (!strncmp(make,"SAMSUNG",7))
++      base = ftell(ifp);
++  }
++  entries = get2();
++  if (entries > 1000) return;
++  morder = order;
++  while (entries--) {
++    order = morder;
++    tiff_get (base, &tag, &type, &len, &save);
++    tag |= uptag << 16;
++    if (tag == 2 && strstr(make,"NIKON") && !iso_speed)
++      iso_speed = (get2(),get2());
++    if (tag == 4 && len > 26 && len < 35) {
++      if ((i=(get4(),get2())) != 0x7fff && !iso_speed)
++	iso_speed = 50 * pow (2, i/32.0 - 4);
++      if ((i=(get2(),get2())) != 0x7fff && !aperture)
++	aperture = pow (2, i/64.0);
++      if ((i=get2()) != 0xffff && !shutter)
++	shutter = pow (2, (short) i/-32.0);
++      wbi = (get2(),get2());
++      shot_order = (get2(),get2());
++    }
++    if ((tag == 4 || tag == 0x114) && !strncmp(make,"KONICA",6)) {
++      fseek (ifp, tag == 4 ? 140:160, SEEK_CUR);
++      switch (get2()) {
++	case 72:  flip = 0;  break;
++	case 76:  flip = 6;  break;
++	case 82:  flip = 5;  break;
++      }
++    }
++    if (tag == 7 && type == 2 && len > 20)
++      fgets (model2, 64, ifp);
++    if (tag == 8 && type == 4)
++      shot_order = get4();
++    if (tag == 9 && !strcmp(make,"Canon"))
++      fread (artist, 64, 1, ifp);
++    if (tag == 0xc && len == 4)
++      FORC3 cam_mul[(c << 1 | c >> 1) & 3] = getreal(type);
++    if (tag == 0xd && type == 7 && get2() == 0xaaaa) {
++      for (c=i=2; (ushort) c != 0xbbbb && i < len; i++)
++	c = c << 8 | fgetc(ifp);
++      while ((i+=4) < len-5)
++	if (get4() == 257 && (i=len) && (c = (get4(),fgetc(ifp))) < 3)
++	  flip = "065"[c]-'0';
++    }
++    if (tag == 0x10 && type == 4)
++      unique_id = get4();
++    if (tag == 0x11 && is_raw && !strncmp(make,"NIKON",5)) {
++      fseek (ifp, get4()+base, SEEK_SET);
++      parse_tiff_ifd (base);
++    }
++    if (tag == 0x14 && type == 7) {
++      if (len == 2560) {
++	fseek (ifp, 1248, SEEK_CUR);
++	goto get2_256;
++      }
++      fread (buf, 1, 10, ifp);
++      if (!strncmp(buf,"NRW ",4)) {
++	fseek (ifp, strcmp(buf+4,"0100") ? 46:1546, SEEK_CUR);
++	cam_mul[0] = get4() << 2;
++	cam_mul[1] = get4() + get4();
++	cam_mul[2] = get4() << 2;
++      }
++    }
++    if (tag == 0x15 && type == 2 && is_raw)
++      fread (model, 64, 1, ifp);
++    if (strstr(make,"PENTAX")) {
++      if (tag == 0x1b) tag = 0x1018;
++      if (tag == 0x1c) tag = 0x1017;
++    }
++    if (tag == 0x1d)
++      while ((c = fgetc(ifp)) && c != EOF)
++	serial = serial*10 + (isdigit(c) ? c - '0' : c % 10);
++    if (tag == 0x29 && type == 1) {
++      c = wbi < 18 ? "012347800000005896"[wbi]-'0' : 0;
++      fseek (ifp, 8 + c*32, SEEK_CUR);
++      FORC4 cam_mul[c ^ (c >> 1) ^ 1] = get4();
++    }
++    if (tag == 0x3d && type == 3 && len == 4)
++      FORC4 cblack[c ^ c >> 1] = get2() >> (14-tiff_bps);
++    if (tag == 0x81 && type == 4) {
++      data_offset = get4();
++      fseek (ifp, data_offset + 41, SEEK_SET);
++      raw_height = get2() * 2;
++      raw_width  = get2();
++      filters = 0x61616161;
++    }
++    if ((tag == 0x81  && type == 7) ||
++	(tag == 0x100 && type == 7) ||
++	(tag == 0x280 && type == 1)) {
++      thumb_offset = ftell(ifp);
++      thumb_length = len;
++    }
++    if (tag == 0x88 && type == 4 && (thumb_offset = get4()))
++      thumb_offset += base;
++    if (tag == 0x89 && type == 4)
++      thumb_length = get4();
++    if (tag == 0x8c || tag == 0x96)
++      meta_offset = ftell(ifp);
++    if (tag == 0x97) {
++      for (i=0; i < 4; i++)
++	ver97 = ver97 * 10 + fgetc(ifp)-'0';
++      switch (ver97) {
++	case 100:
++	  fseek (ifp, 68, SEEK_CUR);
++	  FORC4 cam_mul[(c >> 1) | ((c & 1) << 1)] = get2();
++	  break;
++	case 102:
++	  fseek (ifp, 6, SEEK_CUR);
++	  FORC4 cam_mul[c ^ (c >> 1)] = get2();
++	  break;
++	case 103:
++	  fseek (ifp, 16, SEEK_CUR);
++	  FORC4 cam_mul[c] = get2();
++      }
++      if (ver97 >= 200) {
++	if (ver97 != 205) fseek (ifp, 280, SEEK_CUR);
++	fread (buf97, 324, 1, ifp);
++      }
++    }
++    if (tag == 0xa1 && type == 7) {
++      order = 0x4949;
++      fseek (ifp, 140, SEEK_CUR);
++      FORC3 cam_mul[c] = get4();
++    }
++    if (tag == 0xa4 && type == 3) {
++      fseek (ifp, wbi*48, SEEK_CUR);
++      FORC3 cam_mul[c] = get2();
++    }
++    if (tag == 0xa7 && (unsigned) (ver97-200) < 17) {
++      ci = xlat[0][serial & 0xff];
++      cj = xlat[1][fgetc(ifp)^fgetc(ifp)^fgetc(ifp)^fgetc(ifp)];
++      ck = 0x60;
++      for (i=0; i < 324; i++)
++	buf97[i] ^= (cj += ci * ck++);
++      i = "66666>666;6A;:;55"[ver97-200] - '0';
++      FORC4 cam_mul[c ^ (c >> 1) ^ (i & 1)] =
++	sget2 (buf97 + (i & -2) + c*2);
++    }
++    if (tag == 0x200 && len == 3)
++      shot_order = (get4(),get4());
++    if (tag == 0x200 && len == 4)
++      FORC4 cblack[c ^ c >> 1] = get2();
++    if (tag == 0x201 && len == 4)
++      FORC4 cam_mul[c ^ (c >> 1)] = get2();
++    if (tag == 0x220 && type == 7)
++      meta_offset = ftell(ifp);
++    if (tag == 0x401 && type == 4 && len == 4)
++      FORC4 cblack[c ^ c >> 1] = get4();
++    if (tag == 0xe01) {		/* Nikon Capture Note */
++      order = 0x4949;
++      fseek (ifp, 22, SEEK_CUR);
++      for (offset=22; offset+22 < len; offset += 22+i) {
++	tag = get4();
++	fseek (ifp, 14, SEEK_CUR);
++	i = get4()-4;
++	if (tag == 0x76a43207) flip = get2();
++	else fseek (ifp, i, SEEK_CUR);
++      }
++    }
++    if (tag == 0xe80 && len == 256 && type == 7) {
++      fseek (ifp, 48, SEEK_CUR);
++      cam_mul[0] = get2() * 508 * 1.078 / 0x10000;
++      cam_mul[2] = get2() * 382 * 1.173 / 0x10000;
++    }
++    if (tag == 0xf00 && type == 7) {
++      if (len == 614)
++	fseek (ifp, 176, SEEK_CUR);
++      else if (len == 734 || len == 1502)
++	fseek (ifp, 148, SEEK_CUR);
++      else goto next;
++      goto get2_256;
++    }
++    if ((tag == 0x1011 && len == 9) || tag == 0x20400200)
++      for (i=0; i < 3; i++)
++	FORC3 cmatrix[i][c] = ((short) get2()) / 256.0;
++    if ((tag == 0x1012 || tag == 0x20400600) && len == 4)
++      FORC4 cblack[c ^ c >> 1] = get2();
++    if (tag == 0x1017 || tag == 0x20400100)
++      cam_mul[0] = get2() / 256.0;
++    if (tag == 0x1018 || tag == 0x20400100)
++      cam_mul[2] = get2() / 256.0;
++    if (tag == 0x2011 && len == 2) {
++get2_256:
++      order = 0x4d4d;
++      cam_mul[0] = get2() / 256.0;
++      cam_mul[2] = get2() / 256.0;
++    }
++    if ((tag | 0x70) == 0x2070 && (type == 4 || type == 13))
++      fseek (ifp, get4()+base, SEEK_SET);
++    if (tag == 0x2020 && !strncmp(buf,"OLYMP",5))
++      parse_thumb_note (base, 257, 258);
++    if (tag == 0x2040)
++      parse_makernote (base, 0x2040);
++    if (tag == 0xb028) {
++      fseek (ifp, get4()+base, SEEK_SET);
++      parse_thumb_note (base, 136, 137);
++    }
++    if (tag == 0x4001 && len > 500) {
++      i = len == 582 ? 50 : len == 653 ? 68 : len == 5120 ? 142 : 126;
++      fseek (ifp, i, SEEK_CUR);
++      FORC4 cam_mul[c ^ (c >> 1)] = get2();
++      for (i+=18; i <= len; i+=10) {
++	get2();
++	FORC4 sraw_mul[c ^ (c >> 1)] = get2();
++	if (sraw_mul[1] == 1170) break;
++      }
++    }
++    if (tag == 0x4021 && get4() && get4())
++      FORC4 cam_mul[c] = 1024;
++    if (tag == 0xa021)
++      FORC4 cam_mul[c ^ (c >> 1)] = get4();
++    if (tag == 0xa028)
++      FORC4 cam_mul[c ^ (c >> 1)] -= get4();
++    if (tag == 0xb001)
++      unique_id = get2();
++next:
++    fseek (ifp, save, SEEK_SET);
++  }
++quit:
++  order = sorder;
++}
++
++/*
++   Since the TIFF DateTime string has no timezone information,
++   assume that the camera's clock was set to Universal Time.
++ */
++void CLASS get_timestamp (int reversed)
++{
++  struct tm t;
++  char str[20];
++  int i;
++
++  str[19] = 0;
++  if (reversed)
++    for (i=19; i--; ) str[i] = fgetc(ifp);
++  else
++    fread (str, 19, 1, ifp);
++  memset (&t, 0, sizeof t);
++  if (sscanf (str, "%d:%d:%d %d:%d:%d", &t.tm_year, &t.tm_mon,
++	&t.tm_mday, &t.tm_hour, &t.tm_min, &t.tm_sec) != 6)
++    return;
++  t.tm_year -= 1900;
++  t.tm_mon -= 1;
++  t.tm_isdst = -1;
++  if (mktime(&t) > 0)
++    timestamp = mktime(&t);
++}
++
++void CLASS parse_exif (int base)
++{
++  unsigned kodak, entries, tag, type, len, save, c;
++  double expo;
++
++  kodak = !strncmp(make,"EASTMAN",7) && tiff_nifds < 3;
++  entries = get2();
++  while (entries--) {
++    tiff_get (base, &tag, &type, &len, &save);
++    switch (tag) {
++      case 33434:  tiff_ifd[tiff_nifds-1].shutter =
++		   shutter = getreal(type);		break;
++      case 33437:  aperture = getreal(type);		break;
++      case 34855:  iso_speed = get2();			break;
++      case 36867:
++      case 36868:  get_timestamp(0);			break;
++      case 37377:  if ((expo = -getreal(type)) < 128)
++		     tiff_ifd[tiff_nifds-1].shutter =
++		     shutter = pow (2, expo);		break;
++      case 37378:  aperture = pow (2, getreal(type)/2);	break;
++      case 37386:  focal_len = getreal(type);		break;
++      case 37500:  parse_makernote (base, 0);		break;
++      case 40962:  if (kodak) raw_width  = get4();	break;
++      case 40963:  if (kodak) raw_height = get4();	break;
++      case 41730:
++	if (get4() == 0x20002)
++	  for (exif_cfa=c=0; c < 8; c+=2)
++	    exif_cfa |= fgetc(ifp) * 0x01010101 << c;
++    }
++    fseek (ifp, save, SEEK_SET);
++  }
++}
++
++void CLASS parse_gps (int base)
++{
++  unsigned entries, tag, type, len, save, c;
++
++  entries = get2();
++  while (entries--) {
++    tiff_get (base, &tag, &type, &len, &save);
++    switch (tag) {
++      case 1: case 3: case 5:
++	gpsdata[29+tag/2] = getc(ifp);			break;
++      case 2: case 4: case 7:
++	FORC(6) gpsdata[tag/3*6+c] = get4();		break;
++      case 6:
++	FORC(2) gpsdata[18+c] = get4();			break;
++      case 18: case 29:
++	fgets ((char *) (gpsdata+14+tag/3), MIN(len,12), ifp);
++    }
++    fseek (ifp, save, SEEK_SET);
++  }
++}
++
++void CLASS romm_coeff (float romm_cam[3][3])
++{
++  static const float rgb_romm[3][3] =	/* ROMM == Kodak ProPhoto */
++  { {  2.034193, -0.727420, -0.306766 },
++    { -0.228811,  1.231729, -0.002922 },
++    { -0.008565, -0.153273,  1.161839 } };
++  int i, j, k;
++
++  for (i=0; i < 3; i++)
++    for (j=0; j < 3; j++)
++      for (cmatrix[i][j] = k=0; k < 3; k++)
++	cmatrix[i][j] += rgb_romm[i][k] * romm_cam[k][j];
++}
++
++void CLASS parse_mos (int offset)
++{
++  char data[40];
++  int skip, from, i, c, neut[4], planes=0, frot=0;
++  static const char *mod[] =
++  { "","DCB2","Volare","Cantare","CMost","Valeo 6","Valeo 11","Valeo 22",
++    "Valeo 11p","Valeo 17","","Aptus 17","Aptus 22","Aptus 75","Aptus 65",
++    "Aptus 54S","Aptus 65S","Aptus 75S","AFi 5","AFi 6","AFi 7",
++    "AFi-II 7","Aptus-II 7","","Aptus-II 6","","","Aptus-II 10","Aptus-II 5",
++    "","","","","Aptus-II 10R","Aptus-II 8","","Aptus-II 12","","AFi-II 12" };
++  float romm_cam[3][3];
++
++  fseek (ifp, offset, SEEK_SET);
++  while (1) {
++    if (get4() != 0x504b5453) break;
++    get4();
++    fread (data, 1, 40, ifp);
++    skip = get4();
++    from = ftell(ifp);
++    if (!strcmp(data,"JPEG_preview_data")) {
++      thumb_offset = from;
++      thumb_length = skip;
++    }
++    if (!strcmp(data,"icc_camera_profile")) {
++      profile_offset = from;
++      profile_length = skip;
++    }
++    if (!strcmp(data,"ShootObj_back_type")) {
++      fscanf (ifp, "%d", &i);
++      if ((unsigned) i < sizeof mod / sizeof (*mod))
++	strcpy (model, mod[i]);
++    }
++    if (!strcmp(data,"icc_camera_to_tone_matrix")) {
++      for (i=0; i < 9; i++)
++	((float *)romm_cam)[i] = int_to_float(get4());
++      romm_coeff (romm_cam);
++    }
++    if (!strcmp(data,"CaptProf_color_matrix")) {
++      for (i=0; i < 9; i++)
++	fscanf (ifp, "%f", (float *)romm_cam + i);
++      romm_coeff (romm_cam);
++    }
++    if (!strcmp(data,"CaptProf_number_of_planes"))
++      fscanf (ifp, "%d", &planes);
++    if (!strcmp(data,"CaptProf_raw_data_rotation"))
++      fscanf (ifp, "%d", &flip);
++    if (!strcmp(data,"CaptProf_mosaic_pattern"))
++      FORC4 {
++	fscanf (ifp, "%d", &i);
++	if (i == 1) frot = c ^ (c >> 1);
++      }
++    if (!strcmp(data,"ImgProf_rotation_angle")) {
++      fscanf (ifp, "%d", &i);
++      flip = i - flip;
++    }
++    if (!strcmp(data,"NeutObj_neutrals") && !cam_mul[0]) {
++      FORC4 fscanf (ifp, "%d", neut+c);
++      FORC3 cam_mul[c] = (float) neut[0] / neut[c+1];
++    }
++    if (!strcmp(data,"Rows_data"))
++      load_flags = get4();
++    parse_mos (from);
++    fseek (ifp, skip+from, SEEK_SET);
++  }
++  if (planes)
++    filters = (planes == 1) * 0x01010101 *
++	(uchar) "\x94\x61\x16\x49"[(flip/90 + frot) & 3];
++}
++
++void CLASS linear_table (unsigned len)
++{
++  int i;
++  if (len > 0x1000) len = 0x1000;
++  read_shorts (curve, len);
++  for (i=len; i < 0x1000; i++)
++    curve[i] = curve[i-1];
++  maximum = curve[0xfff];
++}
++
++void CLASS parse_kodak_ifd (int base)
++{
++  unsigned entries, tag, type, len, save;
++  int i, c, wbi=-2, wbtemp=6500;
++  float mul[3]={1,1,1}, num;
++  static const int wbtag[] = { 64037,64040,64039,64041,-1,-1,64042 };
++
++  entries = get2();
++  if (entries > 1024) return;
++  while (entries--) {
++    tiff_get (base, &tag, &type, &len, &save);
++    if (tag == 1020) wbi = getint(type);
++    if (tag == 1021 && len == 72) {		/* WB set in software */
++      fseek (ifp, 40, SEEK_CUR);
++      FORC3 cam_mul[c] = 2048.0 / get2();
++      wbi = -2;
++    }
++    if (tag == 2118) wbtemp = getint(type);
++    if (tag == 2120 + wbi && wbi >= 0)
++      FORC3 cam_mul[c] = 2048.0 / getreal(type);
++    if (tag == 2130 + wbi)
++      FORC3 mul[c] = getreal(type);
++    if (tag == 2140 + wbi && wbi >= 0)
++      FORC3 {
++	for (num=i=0; i < 4; i++)
++	  num += getreal(type) * pow (wbtemp/100.0, i);
++	cam_mul[c] = 2048 / (num * mul[c]);
++      }
++    if (tag == 2317) linear_table (len);
++    if (tag == 6020) iso_speed = getint(type);
++    if (tag == 64013) wbi = fgetc(ifp);
++    if ((unsigned) wbi < 7 && tag == wbtag[wbi])
++      FORC3 cam_mul[c] = get4();
++    if (tag == 64019) width = getint(type);
++    if (tag == 64020) height = (getint(type)+1) & -2;
++    fseek (ifp, save, SEEK_SET);
++  }
++}
++
++void CLASS parse_minolta (int base);
++int CLASS parse_tiff (int base);
++
++int CLASS parse_tiff_ifd (int base)
++{
++  unsigned entries, tag, type, len, plen=16, save;
++  int ifd, use_cm=0, cfa, i, j, c, ima_len=0;
++  char software[64], *cbuf, *cp;
++  uchar cfa_pat[16], cfa_pc[] = { 0,1,2,3 }, tab[256];
++  double cc[4][4], cm[4][3], cam_xyz[4][3], num;
++  double ab[]={ 1,1,1,1 }, asn[] = { 0,0,0,0 }, xyz[] = { 1,1,1 };
++  unsigned sony_curve[] = { 0,0,0,0,0,4095 };
++  unsigned *buf, sony_offset=0, sony_length=0, sony_key=0;
++  struct jhead jh;
++  FILE *sfp;
++
++  if (tiff_nifds >= sizeof tiff_ifd / sizeof tiff_ifd[0])
++    return 1;
++  ifd = tiff_nifds++;
++  for (j=0; j < 4; j++)
++    for (i=0; i < 4; i++)
++      cc[j][i] = i == j;
++  entries = get2();
++  if (entries > 512) return 1;
++  while (entries--) {
++    tiff_get (base, &tag, &type, &len, &save);
++    switch (tag) {
++      case 5:   width  = get2();  break;
++      case 6:   height = get2();  break;
++      case 7:   width += get2();  break;
++      case 9:   if ((i = get2())) filters = i;  break;
++      case 17: case 18:
++	if (type == 3 && len == 1)
++	  cam_mul[(tag-17)*2] = get2() / 256.0;
++	break;
++      case 23:
++	if (type == 3) iso_speed = get2();
++	break;
++      case 28: case 29: case 30:
++	cblack[tag-28] = get2();
++	cblack[3] = cblack[1];
++	break;
++      case 36: case 37: case 38:
++	cam_mul[tag-36] = get2();
++	break;
++      case 39:
++	if (len < 50 || cam_mul[0]) break;
++	fseek (ifp, 12, SEEK_CUR);
++	FORC3 cam_mul[c] = get2();
++	break;
++      case 46:
++	if (type != 7 || fgetc(ifp) != 0xff || fgetc(ifp) != 0xd8) break;
++	thumb_offset = ftell(ifp) - 2;
++	thumb_length = len;
++	break;
++      case 61440:			/* Fuji HS10 table */
++	fseek (ifp, get4()+base, SEEK_SET);
++	parse_tiff_ifd (base);
++	break;
++      case 2: case 256: case 61441:	/* ImageWidth */
++	tiff_ifd[ifd].width = getint(type);
++	break;
++      case 3: case 257: case 61442:	/* ImageHeight */
++	tiff_ifd[ifd].height = getint(type);
++	break;
++      case 258:				/* BitsPerSample */
++      case 61443:
++	tiff_ifd[ifd].samples = len & 7;
++	tiff_ifd[ifd].bps = getint(type);
++	if (tiff_bps < tiff_ifd[ifd].bps)
++	    tiff_bps = tiff_ifd[ifd].bps;
++	break;
++      case 61446:
++	raw_height = 0;
++	if (tiff_ifd[ifd].bps > 12) break;
++	load_raw = &CLASS packed_load_raw;
++	load_flags = get4() ? 24:80;
++	break;
++      case 259:				/* Compression */
++	tiff_ifd[ifd].comp = getint(type);
++	break;
++      case 262:				/* PhotometricInterpretation */
++	tiff_ifd[ifd].phint = get2();
++	break;
++      case 270:				/* ImageDescription */
++	fread (desc, 512, 1, ifp);
++	break;
++      case 271:				/* Make */
++	fgets (make, 64, ifp);
++	break;
++      case 272:				/* Model */
++	fgets (model, 64, ifp);
++	break;
++      case 280:				/* Panasonic RW2 offset */
++	if (type != 4) break;
++	load_raw = &CLASS panasonic_load_raw;
++	load_flags = 0x2008;
++      case 273:				/* StripOffset */
++      case 513:				/* JpegIFOffset */
++      case 61447:
++	tiff_ifd[ifd].offset = get4()+base;
++	if (!tiff_ifd[ifd].bps && tiff_ifd[ifd].offset > 0) {
++	  fseek (ifp, tiff_ifd[ifd].offset, SEEK_SET);
++	  if (ljpeg_start (&jh, 1)) {
++	    tiff_ifd[ifd].comp    = 6;
++	    tiff_ifd[ifd].width   = jh.wide;
++	    tiff_ifd[ifd].height  = jh.high;
++	    tiff_ifd[ifd].bps     = jh.bits;
++	    tiff_ifd[ifd].samples = jh.clrs;
++	    if (!(jh.sraw || (jh.clrs & 1)))
++	      tiff_ifd[ifd].width *= jh.clrs;
++	    if ((tiff_ifd[ifd].width > 4*tiff_ifd[ifd].height) & ~jh.clrs) {
++	      tiff_ifd[ifd].width  /= 2;
++	      tiff_ifd[ifd].height *= 2;
++	    }
++	    i = order;
++	    parse_tiff (tiff_ifd[ifd].offset + 12);
++	    order = i;
++	  }
++	}
++	break;
++      case 274:				/* Orientation */
++	tiff_ifd[ifd].flip = "50132467"[get2() & 7]-'0';
++	break;
++      case 277:				/* SamplesPerPixel */
++	tiff_ifd[ifd].samples = getint(type) & 7;
++	break;
++      case 279:				/* StripByteCounts */
++      case 514:
++      case 61448:
++	tiff_ifd[ifd].bytes = get4();
++	break;
++      case 61454:
++	FORC3 cam_mul[(4-c) % 3] = getint(type);
++	break;
++      case 305:  case 11:		/* Software */
++	fgets (software, 64, ifp);
++	if (!strncmp(software,"Adobe",5) ||
++	    !strncmp(software,"dcraw",5) ||
++	    !strncmp(software,"UFRaw",5) ||
++	    !strncmp(software,"Bibble",6) ||
++	    !strncmp(software,"Nikon Scan",10) ||
++	    !strcmp (software,"Digital Photo Professional"))
++	  is_raw = 0;
++	break;
++      case 306:				/* DateTime */
++	get_timestamp(0);
++	break;
++      case 315:				/* Artist */
++	fread (artist, 64, 1, ifp);
++	break;
++      case 322:				/* TileWidth */
++	tiff_ifd[ifd].tile_width = getint(type);
++	break;
++      case 323:				/* TileLength */
++	tiff_ifd[ifd].tile_length = getint(type);
++	break;
++      case 324:				/* TileOffsets */
++	tiff_ifd[ifd].offset = len > 1 ? ftell(ifp) : get4();
++	if (len == 1)
++	  tiff_ifd[ifd].tile_width = tiff_ifd[ifd].tile_length = 0;
++	if (len == 4) {
++	  load_raw = &CLASS sinar_4shot_load_raw;
++	  is_raw = 5;
++	}
++	break;
++      case 330:				/* SubIFDs */
++	if (!strcmp(model,"DSLR-A100") && tiff_ifd[ifd].width == 3872) {
++	  load_raw = &CLASS sony_arw_load_raw;
++	  data_offset = get4()+base;
++	  ifd++;  break;
++	}
++	while (len--) {
++	  i = ftell(ifp);
++	  fseek (ifp, get4()+base, SEEK_SET);
++	  if (parse_tiff_ifd (base)) break;
++	  fseek (ifp, i+4, SEEK_SET);
++	}
++	break;
++      case 400:
++	strcpy (make, "Sarnoff");
++	maximum = 0xfff;
++	break;
++      case 28688:
++	FORC4 sony_curve[c+1] = get2() >> 2 & 0xfff;
++	for (i=0; i < 5; i++)
++	  for (j = sony_curve[i]+1; j <= sony_curve[i+1]; j++)
++	    curve[j] = curve[j-1] + (1 << i);
++	break;
++      case 29184: sony_offset = get4();  break;
++      case 29185: sony_length = get4();  break;
++      case 29217: sony_key    = get4();  break;
++      case 29264:
++	parse_minolta (ftell(ifp));
++	raw_width = 0;
++	break;
++      case 29443:
++	FORC4 cam_mul[c ^ (c < 2)] = get2();
++	break;
++      case 29459:
++	FORC4 cam_mul[c] = get2();
++	i = (cam_mul[1] == 1024 && cam_mul[2] == 1024) << 1;
++	SWAP (cam_mul[i],cam_mul[i+1])
++	break;
++      case 33405:			/* Model2 */
++	fgets (model2, 64, ifp);
++	break;
++      case 33421:			/* CFARepeatPatternDim */
++	if (get2() == 6 && get2() == 6)
++	  filters = 9;
++	break;
++      case 33422:			/* CFAPattern */
++	if (filters == 9) {
++	  FORC(36) ((char *)xtrans)[c] = fgetc(ifp) & 3;
++	  break;
++	}
++      case 64777:			/* Kodak P-series */
++	if ((plen=len) > 16) plen = 16;
++	fread (cfa_pat, 1, plen, ifp);
++	for (colors=cfa=i=0; i < plen && colors < 4; i++) {
++	  colors += !(cfa & (1 << cfa_pat[i]));
++	  cfa |= 1 << cfa_pat[i];
++	}
++	if (cfa == 070) memcpy (cfa_pc,"\003\004\005",3);	/* CMY */
++	if (cfa == 072) memcpy (cfa_pc,"\005\003\004\001",4);	/* GMCY */
++	goto guess_cfa_pc;
++      case 33424:
++      case 65024:
++	fseek (ifp, get4()+base, SEEK_SET);
++	parse_kodak_ifd (base);
++	break;
++      case 33434:			/* ExposureTime */
++	tiff_ifd[ifd].shutter = shutter = getreal(type);
++	break;
++      case 33437:			/* FNumber */
++	aperture = getreal(type);
++	break;
++      case 34306:			/* Leaf white balance */
++	FORC4 cam_mul[c ^ 1] = 4096.0 / get2();
++	break;
++      case 34307:			/* Leaf CatchLight color matrix */
++	fread (software, 1, 7, ifp);
++	if (strncmp(software,"MATRIX",6)) break;
++	colors = 4;
++	for (raw_color = i=0; i < 3; i++) {
++	  FORC4 fscanf (ifp, "%f", &rgb_cam[i][c^1]);
++	  if (!use_camera_wb) continue;
++	  num = 0;
++	  FORC4 num += rgb_cam[i][c];
++	  FORC4 rgb_cam[i][c] /= num;
++	}
++	break;
++      case 34310:			/* Leaf metadata */
++	parse_mos (ftell(ifp));
++      case 34303:
++	strcpy (make, "Leaf");
++	break;
++      case 34665:			/* EXIF tag */
++	fseek (ifp, get4()+base, SEEK_SET);
++	parse_exif (base);
++	break;
++      case 34853:			/* GPSInfo tag */
++	fseek (ifp, get4()+base, SEEK_SET);
++	parse_gps (base);
++	break;
++      case 34675:			/* InterColorProfile */
++      case 50831:			/* AsShotICCProfile */
++	profile_offset = ftell(ifp);
++	profile_length = len;
++	break;
++      case 37122:			/* CompressedBitsPerPixel */
++	kodak_cbpp = get4();
++	break;
++      case 37386:			/* FocalLength */
++	focal_len = getreal(type);
++	break;
++      case 37393:			/* ImageNumber */
++	shot_order = getint(type);
++	break;
++      case 37400:			/* old Kodak KDC tag */
++	for (raw_color = i=0; i < 3; i++) {
++	  getreal(type);
++	  FORC3 rgb_cam[i][c] = getreal(type);
++	}
++	break;
++      case 40976:
++	strip_offset = get4();
++	switch (tiff_ifd[ifd].comp) {
++	  case 32770: load_raw = &CLASS samsung_load_raw;   break;
++	  case 32772: load_raw = &CLASS samsung2_load_raw;  break;
++	  case 32773: load_raw = &CLASS samsung3_load_raw;  break;
++	}
++	break;
++      case 46275:			/* Imacon tags */
++	strcpy (make, "Imacon");
++	data_offset = ftell(ifp);
++	ima_len = len;
++	break;
++      case 46279:
++	if (!ima_len) break;
++	fseek (ifp, 38, SEEK_CUR);
++      case 46274:
++	fseek (ifp, 40, SEEK_CUR);
++	raw_width  = get4();
++	raw_height = get4();
++	left_margin = get4() & 7;
++	width = raw_width - left_margin - (get4() & 7);
++	top_margin = get4() & 7;
++	height = raw_height - top_margin - (get4() & 7);
++	if (raw_width == 7262) {
++	  height = 5444;
++	  width  = 7244;
++	  left_margin = 7;
++	}
++	fseek (ifp, 52, SEEK_CUR);
++	FORC3 cam_mul[c] = getreal(11);
++	fseek (ifp, 114, SEEK_CUR);
++	flip = (get2() >> 7) * 90;
++	if (width * height * 6 == ima_len) {
++	  if (flip % 180 == 90) SWAP(width,height);
++	  raw_width = width;
++	  raw_height = height;
++	  left_margin = top_margin = filters = flip = 0;
++	}
++	sprintf (model, "Ixpress %d-Mp", height*width/1000000);
++	load_raw = &CLASS imacon_full_load_raw;
++	if (filters) {
++	  if (left_margin & 1) filters = 0x61616161;
++	  load_raw = &CLASS unpacked_load_raw;
++	}
++	maximum = 0xffff;
++	break;
++      case 50454:			/* Sinar tag */
++      case 50455:
++	if (!(cbuf = (char *) malloc(len))) break;
++	fread (cbuf, 1, len, ifp);
++	for (cp = cbuf-1; cp && cp < cbuf+len; cp = strchr(cp,'\n'))
++	  if (!strncmp (++cp,"Neutral ",8))
++	    sscanf (cp+8, "%f %f %f", cam_mul, cam_mul+1, cam_mul+2);
++	free (cbuf);
++	break;
++      case 50458:
++	if (!make[0]) strcpy (make, "Hasselblad");
++	break;
++      case 50459:			/* Hasselblad tag */
++	i = order;
++	j = ftell(ifp);
++	c = tiff_nifds;
++	order = get2();
++	fseek (ifp, j+(get2(),get4()), SEEK_SET);
++	parse_tiff_ifd (j);
++	maximum = 0xffff;
++	tiff_nifds = c;
++	order = i;
++	break;
++      case 50706:			/* DNGVersion */
++	FORC4 dng_version = (dng_version << 8) + fgetc(ifp);
++	if (!make[0]) strcpy (make, "DNG");
++	is_raw = 1;
++	break;
++      case 50708:			/* UniqueCameraModel */
++	if (model[0]) break;
++	fgets (make, 64, ifp);
++        if ((cp = strchr(make,' '))) {
++	  strcpy(model,cp+1);
++	  *cp = 0;
++	}
++	break;
++      case 50710:			/* CFAPlaneColor */
++	if (filters == 9) break;
++	if (len > 4) len = 4;
++	colors = len;
++	fread (cfa_pc, 1, colors, ifp);
++guess_cfa_pc:
++	FORCC tab[cfa_pc[c]] = c;
++	cdesc[c] = 0;
++	for (i=16; i--; )
++	  filters = filters << 2 | tab[cfa_pat[i % plen]];
++	filters -= !filters;
++	break;
++      case 50711:			/* CFALayout */
++	if (get2() == 2) fuji_width = 1;
++	break;
++      case 291:
++      case 50712:			/* LinearizationTable */
++	linear_table (len);
++	break;
++      case 50713:			/* BlackLevelRepeatDim */
++	cblack[4] = get2();
++	cblack[5] = get2();
++	if (cblack[4] * cblack[5] > sizeof cblack / sizeof *cblack - 6)
++	    cblack[4] = cblack[5] = 1;
++	break;
++      case 61450:
++	cblack[4] = cblack[5] = MIN(sqrt(len),64);
++      case 50714:			/* BlackLevel */
++	if (!(cblack[4] * cblack[5]))
++	  cblack[4] = cblack[5] = 1;
++	FORC (cblack[4] * cblack[5])
++	  cblack[6+c] = getreal(type);
++	black = 0;
++	break;
++      case 50715:			/* BlackLevelDeltaH */
++      case 50716:			/* BlackLevelDeltaV */
++	for (num=i=0; i < (len & 0xffff); i++)
++	  num += getreal(type);
++	black += num/len + 0.5;
++	break;
++      case 50717:			/* WhiteLevel */
++	maximum = getint(type);
++	break;
++      case 50718:			/* DefaultScale */
++	pixel_aspect  = getreal(type);
++	pixel_aspect /= getreal(type);
++	break;
++      case 50721:			/* ColorMatrix1 */
++      case 50722:			/* ColorMatrix2 */
++	FORCC for (j=0; j < 3; j++)
++	  cm[c][j] = getreal(type);
++	use_cm = 1;
++	break;
++      case 50723:			/* CameraCalibration1 */
++      case 50724:			/* CameraCalibration2 */
++	for (i=0; i < colors; i++)
++	  FORCC cc[i][c] = getreal(type);
++	break;
++      case 50727:			/* AnalogBalance */
++	FORCC ab[c] = getreal(type);
++	break;
++      case 50728:			/* AsShotNeutral */
++	FORCC asn[c] = getreal(type);
++	break;
++      case 50729:			/* AsShotWhiteXY */
++	xyz[0] = getreal(type);
++	xyz[1] = getreal(type);
++	xyz[2] = 1 - xyz[0] - xyz[1];
++	FORC3 xyz[c] /= d65_white[c];
++	break;
++      case 50740:			/* DNGPrivateData */
++	if (dng_version) break;
++	parse_minolta (j = get4()+base);
++	fseek (ifp, j, SEEK_SET);
++	parse_tiff_ifd (base);
++	break;
++      case 50752:
++	read_shorts (cr2_slice, 3);
++	break;
++      case 50829:			/* ActiveArea */
++	top_margin = getint(type);
++	left_margin = getint(type);
++	height = getint(type) - top_margin;
++	width = getint(type) - left_margin;
++	break;
++      case 50830:			/* MaskedAreas */
++        for (i=0; i < len && i < 32; i++)
++	  ((int *)mask)[i] = getint(type);
++	black = 0;
++	break;
++      case 51009:			/* OpcodeList2 */
++	meta_offset = ftell(ifp);
++	break;
++      case 64772:			/* Kodak P-series */
++	if (len < 13) break;
++	fseek (ifp, 16, SEEK_CUR);
++	data_offset = get4();
++	fseek (ifp, 28, SEEK_CUR);
++	data_offset += get4();
++	load_raw = &CLASS packed_load_raw;
++	break;
++      case 65026:
++	if (type == 2) fgets (model2, 64, ifp);
++    }
++    fseek (ifp, save, SEEK_SET);
++  }
++  if (sony_length && (buf = (unsigned *) malloc(sony_length))) {
++    fseek (ifp, sony_offset, SEEK_SET);
++    fread (buf, sony_length, 1, ifp);
++    sony_decrypt (buf, sony_length/4, 1, sony_key);
++    sfp = ifp;
++    if ((ifp = tmpfile())) {
++      fwrite (buf, sony_length, 1, ifp);
++      fseek (ifp, 0, SEEK_SET);
++      parse_tiff_ifd (-sony_offset);
++      fclose (ifp);
++    }
++    ifp = sfp;
++    free (buf);
++  }
++  for (i=0; i < colors; i++)
++    FORCC cc[i][c] *= ab[i];
++  if (use_cm) {
++    FORCC for (i=0; i < 3; i++)
++      for (cam_xyz[c][i]=j=0; j < colors; j++)
++	cam_xyz[c][i] += cc[c][j] * cm[j][i] * xyz[i];
++    cam_xyz_coeff (cmatrix, cam_xyz);
++  }
++  if (asn[0]) {
++    cam_mul[3] = 0;
++    FORCC cam_mul[c] = 1 / asn[c];
++  }
++  if (!use_cm)
++    FORCC pre_mul[c] /= cc[c][c];
++  return 0;
++}
++
++int CLASS parse_tiff (int base)
++{
++  int doff;
++
++  fseek (ifp, base, SEEK_SET);
++  order = get2();
++  if (order != 0x4949 && order != 0x4d4d) return 0;
++  get2();
++  while ((doff = get4())) {
++    fseek (ifp, doff+base, SEEK_SET);
++    if (parse_tiff_ifd (base)) break;
++  }
++  return 1;
++}
++
++void CLASS apply_tiff()
++{
++  int max_samp=0, ties=0, os, ns, raw=-1, thm=-1, i;
++  struct jhead jh;
++
++  thumb_misc = 16;
++  if (thumb_offset) {
++    fseek (ifp, thumb_offset, SEEK_SET);
++    if (ljpeg_start (&jh, 1)) {
++      thumb_misc   = jh.bits;
++      thumb_width  = jh.wide;
++      thumb_height = jh.high;
++    }
++  }
++  for (i=tiff_nifds; i--; ) {
++    if (tiff_ifd[i].shutter)
++      shutter = tiff_ifd[i].shutter;
++    tiff_ifd[i].shutter = shutter;
++  }
++  for (i=0; i < tiff_nifds; i++) {
++    if (max_samp < tiff_ifd[i].samples)
++	max_samp = tiff_ifd[i].samples;
++    if (max_samp > 3) max_samp = 3;
++    os = raw_width*raw_height;
++    ns = tiff_ifd[i].width*tiff_ifd[i].height;
++    if (tiff_bps) {
++      os *= tiff_bps;
++      ns *= tiff_ifd[i].bps;
++    }
++    if ((tiff_ifd[i].comp != 6 || tiff_ifd[i].samples != 3) &&
++	(tiff_ifd[i].width | tiff_ifd[i].height) < 0x10000 &&
++	 ns && ((ns > os && (ties = 1)) ||
++		(ns == os && shot_select == ties++))) {
++      raw_width     = tiff_ifd[i].width;
++      raw_height    = tiff_ifd[i].height;
++      tiff_bps      = tiff_ifd[i].bps;
++      tiff_compress = tiff_ifd[i].comp;
++      data_offset   = tiff_ifd[i].offset;
++      tiff_flip     = tiff_ifd[i].flip;
++      tiff_samples  = tiff_ifd[i].samples;
++      tile_width    = tiff_ifd[i].tile_width;
++      tile_length   = tiff_ifd[i].tile_length;
++      shutter       = tiff_ifd[i].shutter;
++      raw = i;
++    }
++  }
++  if (is_raw == 1 && ties) is_raw = ties;
++  if (!tile_width ) tile_width  = INT_MAX;
++  if (!tile_length) tile_length = INT_MAX;
++  for (i=tiff_nifds; i--; )
++    if (tiff_ifd[i].flip) tiff_flip = tiff_ifd[i].flip;
++  if (raw >= 0 && !load_raw)
++    switch (tiff_compress) {
++      case 32767:
++	if (tiff_ifd[raw].bytes == raw_width*raw_height) {
++	  tiff_bps = 12;
++	  load_raw = &CLASS sony_arw2_load_raw;			break;
++	}
++	if (tiff_ifd[raw].bytes*8 != raw_width*raw_height*tiff_bps) {
++	  raw_height += 8;
++	  load_raw = &CLASS sony_arw_load_raw;			break;
++	}
++	load_flags = 79;
++      case 32769:
++	load_flags++;
++      case 32770:
++      case 32773: goto slr;
++      case 0:  case 1:
++	if (!strncmp(make,"OLYMPUS",7) &&
++		tiff_ifd[raw].bytes*2 == raw_width*raw_height*3)
++	  load_flags = 24;
++	if (tiff_ifd[raw].bytes*5 == raw_width*raw_height*8) {
++	  load_flags = 81;
++	  tiff_bps = 12;
++	} slr:
++	switch (tiff_bps) {
++	  case  8: load_raw = &CLASS eight_bit_load_raw;	break;
++	  case 12: if (tiff_ifd[raw].phint == 2)
++		     load_flags = 6;
++		   load_raw = &CLASS packed_load_raw;		break;
++	  case 14: load_flags = 0;
++	  case 16: load_raw = &CLASS unpacked_load_raw;
++		   if (!strncmp(make,"OLYMPUS",7) &&
++			tiff_ifd[raw].bytes*7 > raw_width*raw_height)
++		     load_raw = &CLASS olympus_load_raw;
++	}
++	break;
++      case 6:  case 7:  case 99:
++	load_raw = &CLASS lossless_jpeg_load_raw;		break;
++      case 262:
++	load_raw = &CLASS kodak_262_load_raw;			break;
++      case 34713:
++	if ((raw_width+9)/10*16*raw_height == tiff_ifd[raw].bytes) {
++	  load_raw = &CLASS packed_load_raw;
++	  load_flags = 1;
++	} else if (raw_width*raw_height*3 == tiff_ifd[raw].bytes*2) {
++	  load_raw = &CLASS packed_load_raw;
++	  if (model[0] == 'N') load_flags = 80;
++	} else if (raw_width*raw_height*3 == tiff_ifd[raw].bytes) {
++	  load_raw = &CLASS nikon_yuv_load_raw;
++	  gamma_curve (1/2.4, 12.92, 1, 4095);
++	  memset (cblack, 0, sizeof cblack);
++	  filters = 0;
++	} else if (raw_width*raw_height*2 == tiff_ifd[raw].bytes) {
++	  load_raw = &CLASS unpacked_load_raw;
++	  load_flags = 4;
++	  order = 0x4d4d;
++	} else
++	  load_raw = &CLASS nikon_load_raw;			break;
++      case 65535:
++	load_raw = &CLASS pentax_load_raw;			break;
++      case 65000:
++	switch (tiff_ifd[raw].phint) {
++	  case 2: load_raw = &CLASS kodak_rgb_load_raw;   filters = 0;  break;
++	  case 6: load_raw = &CLASS kodak_ycbcr_load_raw; filters = 0;  break;
++	  case 32803: load_raw = &CLASS kodak_65000_load_raw;
++	}
++      case 32867: case 34892: break;
++      default: is_raw = 0;
++    }
++  if (!dng_version)
++    if ( (tiff_samples == 3 && tiff_ifd[raw].bytes && tiff_bps != 14 &&
++	  (tiff_compress & -16) != 32768)
++      || (tiff_bps == 8 && strncmp(make,"Phase",5) &&
++	  !strcasestr(make,"Kodak") && !strstr(model2,"DEBUG RAW")))
++      is_raw = 0;
++  for (i=0; i < tiff_nifds; i++)
++    if (i != raw && tiff_ifd[i].samples == max_samp &&
++	tiff_ifd[i].width * tiff_ifd[i].height / (SQR(tiff_ifd[i].bps)+1) >
++	      thumb_width *       thumb_height / (SQR(thumb_misc)+1)
++	&& tiff_ifd[i].comp != 34892) {
++      thumb_width  = tiff_ifd[i].width;
++      thumb_height = tiff_ifd[i].height;
++      thumb_offset = tiff_ifd[i].offset;
++      thumb_length = tiff_ifd[i].bytes;
++      thumb_misc   = tiff_ifd[i].bps;
++      thm = i;
++    }
++  if (thm >= 0) {
++    thumb_misc |= tiff_ifd[thm].samples << 5;
++    switch (tiff_ifd[thm].comp) {
++      case 0:
++	write_thumb = &CLASS layer_thumb;
++	break;
++      case 1:
++	if (tiff_ifd[thm].bps <= 8)
++	  write_thumb = &CLASS ppm_thumb;
++	else if (!strcmp(make,"Imacon"))
++	  write_thumb = &CLASS ppm16_thumb;
++	else
++	  thumb_load_raw = &CLASS kodak_thumb_load_raw;
++	break;
++      case 65000:
++	thumb_load_raw = tiff_ifd[thm].phint == 6 ?
++		&CLASS kodak_ycbcr_load_raw : &CLASS kodak_rgb_load_raw;
++    }
++  }
++}
++
++void CLASS parse_minolta (int base)
++{
++  int save, tag, len, offset, high=0, wide=0, i, c;
++  short sorder=order;
++
++  fseek (ifp, base, SEEK_SET);
++  if (fgetc(ifp) || fgetc(ifp)-'M' || fgetc(ifp)-'R') return;
++  order = fgetc(ifp) * 0x101;
++  offset = base + get4() + 8;
++  while ((save=ftell(ifp)) < offset) {
++    for (tag=i=0; i < 4; i++)
++      tag = tag << 8 | fgetc(ifp);
++    len = get4();
++    switch (tag) {
++      case 0x505244:				/* PRD */
++	fseek (ifp, 8, SEEK_CUR);
++	high = get2();
++	wide = get2();
++	break;
++      case 0x574247:				/* WBG */
++	get4();
++	i = strcmp(model,"DiMAGE A200") ? 0:3;
++	FORC4 cam_mul[c ^ (c >> 1) ^ i] = get2();
++	break;
++      case 0x545457:				/* TTW */
++	parse_tiff (ftell(ifp));
++	data_offset = offset;
++    }
++    fseek (ifp, save+len+8, SEEK_SET);
++  }
++  raw_height = high;
++  raw_width  = wide;
++  order = sorder;
++}
++
++/*
++   Many cameras have a "debug mode" that writes JPEG and raw
++   at the same time.  The raw file has no header, so try to
++   to open the matching JPEG file and read its metadata.
++ */
++void CLASS parse_external_jpeg()
++{
++  const char *file, *ext;
++  char *jname, *jfile, *jext;
++  FILE *save=ifp;
++
++  ext  = strrchr (ifname, '.');
++  file = strrchr (ifname, '/');
++  if (!file) file = strrchr (ifname, '\\');
++  if (!file) file = ifname-1;
++  file++;
++  if (!ext || strlen(ext) != 4 || ext-file != 8) return;
++  jname = (char *) malloc (strlen(ifname) + 1);
++  merror (jname, "parse_external_jpeg()");
++  strcpy (jname, ifname);
++  jfile = file - ifname + jname;
++  jext  = ext  - ifname + jname;
++  if (strcasecmp (ext, ".jpg")) {
++    strcpy (jext, isupper(ext[1]) ? ".JPG":".jpg");
++    if (isdigit(*file)) {
++      memcpy (jfile, file+4, 4);
++      memcpy (jfile+4, file, 4);
++    }
++  } else
++    while (isdigit(*--jext)) {
++      if (*jext != '9') {
++	(*jext)++;
++	break;
++      }
++      *jext = '0';
++    }
++  if (strcmp (jname, ifname)) {
++    if ((ifp = fopen (jname, "rb"))) {
++      if (verbose)
++	fprintf (stderr,_("Reading metadata from %s ...\n"), jname);
++      parse_tiff (12);
++      thumb_offset = 0;
++      is_raw = 1;
++      fclose (ifp);
++    }
++  }
++  if (!timestamp)
++    fprintf (stderr,_("Failed to read metadata from %s\n"), jname);
++  free (jname);
++  ifp = save;
++}
++
++/*
++   CIFF block 0x1030 contains an 8x8 white sample.
++   Load this into white[][] for use in scale_colors().
++ */
++void CLASS ciff_block_1030()
++{
++  static const ushort key[] = { 0x410, 0x45f3 };
++  int i, bpp, row, col, vbits=0;
++  unsigned long bitbuf=0;
++
++  if ((get2(),get4()) != 0x80008 || !get4()) return;
++  bpp = get2();
++  if (bpp != 10 && bpp != 12) return;
++  for (i=row=0; row < 8; row++)
++    for (col=0; col < 8; col++) {
++      if (vbits < bpp) {
++	bitbuf = bitbuf << 16 | (get2() ^ key[i++ & 1]);
++	vbits += 16;
++      }
++      white[row][col] = bitbuf >> (vbits -= bpp) & ~(-1 << bpp);
++    }
++}
++
++/*
++   Parse a CIFF file, better known as Canon CRW format.
++ */
++void CLASS parse_ciff (int offset, int length, int depth)
++{
++  int tboff, nrecs, c, type, len, save, wbi=-1;
++  ushort key[] = { 0x410, 0x45f3 };
++
++  fseek (ifp, offset+length-4, SEEK_SET);
++  tboff = get4() + offset;
++  fseek (ifp, tboff, SEEK_SET);
++  nrecs = get2();
++  if ((nrecs | depth) > 127) return;
++  while (nrecs--) {
++    type = get2();
++    len  = get4();
++    save = ftell(ifp) + 4;
++    fseek (ifp, offset+get4(), SEEK_SET);
++    if ((((type >> 8) + 8) | 8) == 0x38)
++      parse_ciff (ftell(ifp), len, depth+1); /* Parse a sub-table */
++    if (type == 0x0810)
++      fread (artist, 64, 1, ifp);
++    if (type == 0x080a) {
++      fread (make, 64, 1, ifp);
++      fseek (ifp, strlen(make) - 63, SEEK_CUR);
++      fread (model, 64, 1, ifp);
++    }
++    if (type == 0x1810) {
++      width = get4();
++      height = get4();
++      pixel_aspect = int_to_float(get4());
++      flip = get4();
++    }
++    if (type == 0x1835)			/* Get the decoder table */
++      tiff_compress = get4();
++    if (type == 0x2007) {
++      thumb_offset = ftell(ifp);
++      thumb_length = len;
++    }
++    if (type == 0x1818) {
++      shutter = pow (2, -int_to_float((get4(),get4())));
++      aperture = pow (2, int_to_float(get4())/2);
++    }
++    if (type == 0x102a) {
++      iso_speed = pow (2, (get4(),get2())/32.0 - 4) * 50;
++      aperture  = pow (2, (get2(),(short)get2())/64.0);
++      shutter   = pow (2,-((short)get2())/32.0);
++      wbi = (get2(),get2());
++      if (wbi > 17) wbi = 0;
++      fseek (ifp, 32, SEEK_CUR);
++      if (shutter > 1e6) shutter = get2()/10.0;
++    }
++    if (type == 0x102c) {
++      if (get2() > 512) {		/* Pro90, G1 */
++	fseek (ifp, 118, SEEK_CUR);
++	FORC4 cam_mul[c ^ 2] = get2();
++      } else {				/* G2, S30, S40 */
++	fseek (ifp, 98, SEEK_CUR);
++	FORC4 cam_mul[c ^ (c >> 1) ^ 1] = get2();
++      }
++    }
++    if (type == 0x0032) {
++      if (len == 768) {			/* EOS D30 */
++	fseek (ifp, 72, SEEK_CUR);
++	FORC4 cam_mul[c ^ (c >> 1)] = 1024.0 / get2();
++	if (!wbi) cam_mul[0] = -1;	/* use my auto white balance */
++      } else if (!cam_mul[0]) {
++	if (get2() == key[0])		/* Pro1, G6, S60, S70 */
++	  c = (strstr(model,"Pro1") ?
++	      "012346000000000000":"01345:000000006008")[wbi]-'0'+ 2;
++	else {				/* G3, G5, S45, S50 */
++	  c = "023457000000006000"[wbi]-'0';
++	  key[0] = key[1] = 0;
++	}
++	fseek (ifp, 78 + c*8, SEEK_CUR);
++	FORC4 cam_mul[c ^ (c >> 1) ^ 1] = get2() ^ key[c & 1];
++	if (!wbi) cam_mul[0] = -1;
++      }
++    }
++    if (type == 0x10a9) {		/* D60, 10D, 300D, and clones */
++      if (len > 66) wbi = "0134567028"[wbi]-'0';
++      fseek (ifp, 2 + wbi*8, SEEK_CUR);
++      FORC4 cam_mul[c ^ (c >> 1)] = get2();
++    }
++    if (type == 0x1030 && (0x18040 >> wbi & 1))
++      ciff_block_1030();		/* all that don't have 0x10a9 */
++    if (type == 0x1031) {
++      raw_width = (get2(),get2());
++      raw_height = get2();
++    }
++    if (type == 0x5029) {
++      focal_len = len >> 16;
++      if ((len & 0xffff) == 2) focal_len /= 32;
++    }
++    if (type == 0x5813) flash_used = int_to_float(len);
++    if (type == 0x5814) canon_ev   = int_to_float(len);
++    if (type == 0x5817) shot_order = len;
++    if (type == 0x5834) unique_id  = len;
++    if (type == 0x580e) timestamp  = len;
++    if (type == 0x180e) timestamp  = get4();
++#ifdef LOCALTIME
++    if ((type | 0x4000) == 0x580e)
++      timestamp = mktime (gmtime (&timestamp));
++#endif
++    fseek (ifp, save, SEEK_SET);
++  }
++}
++
++void CLASS parse_rollei()
++{
++  char line[128], *val;
++  struct tm t;
++
++  fseek (ifp, 0, SEEK_SET);
++  memset (&t, 0, sizeof t);
++  do {
++    fgets (line, 128, ifp);
++    if ((val = strchr(line,'=')))
++      *val++ = 0;
++    else
++      val = line + strlen(line);
++    if (!strcmp(line,"DAT"))
++      sscanf (val, "%d.%d.%d", &t.tm_mday, &t.tm_mon, &t.tm_year);
++    if (!strcmp(line,"TIM"))
++      sscanf (val, "%d:%d:%d", &t.tm_hour, &t.tm_min, &t.tm_sec);
++    if (!strcmp(line,"HDR"))
++      thumb_offset = atoi(val);
++    if (!strcmp(line,"X  "))
++      raw_width = atoi(val);
++    if (!strcmp(line,"Y  "))
++      raw_height = atoi(val);
++    if (!strcmp(line,"TX "))
++      thumb_width = atoi(val);
++    if (!strcmp(line,"TY "))
++      thumb_height = atoi(val);
++  } while (strncmp(line,"EOHD",4));
++  data_offset = thumb_offset + thumb_width * thumb_height * 2;
++  t.tm_year -= 1900;
++  t.tm_mon -= 1;
++  if (mktime(&t) > 0)
++    timestamp = mktime(&t);
++  strcpy (make, "Rollei");
++  strcpy (model,"d530flex");
++  write_thumb = &CLASS rollei_thumb;
++}
++
++void CLASS parse_sinar_ia()
++{
++  int entries, off;
++  char str[8], *cp;
++
++  order = 0x4949;
++  fseek (ifp, 4, SEEK_SET);
++  entries = get4();
++  fseek (ifp, get4(), SEEK_SET);
++  while (entries--) {
++    off = get4(); get4();
++    fread (str, 8, 1, ifp);
++    if (!strcmp(str,"META"))   meta_offset = off;
++    if (!strcmp(str,"THUMB")) thumb_offset = off;
++    if (!strcmp(str,"RAW0"))   data_offset = off;
++  }
++  fseek (ifp, meta_offset+20, SEEK_SET);
++  fread (make, 64, 1, ifp);
++  make[63] = 0;
++  if ((cp = strchr(make,' '))) {
++    strcpy (model, cp+1);
++    *cp = 0;
++  }
++  raw_width  = get2();
++  raw_height = get2();
++  load_raw = &CLASS unpacked_load_raw;
++  thumb_width = (get4(),get2());
++  thumb_height = get2();
++  write_thumb = &CLASS ppm_thumb;
++  maximum = 0x3fff;
++}
++
++void CLASS parse_phase_one (int base)
++{
++  unsigned entries, tag, type, len, data, save, i, c;
++  float romm_cam[3][3];
++  char *cp;
++
++  memset (&ph1, 0, sizeof ph1);
++  fseek (ifp, base, SEEK_SET);
++  order = get4() & 0xffff;
++  if (get4() >> 8 != 0x526177) return;		/* "Raw" */
++  fseek (ifp, get4()+base, SEEK_SET);
++  entries = get4();
++  get4();
++  while (entries--) {
++    tag  = get4();
++    type = get4();
++    len  = get4();
++    data = get4();
++    save = ftell(ifp);
++    fseek (ifp, base+data, SEEK_SET);
++    switch (tag) {
++      case 0x100:  flip = "0653"[data & 3]-'0';  break;
++      case 0x106:
++	for (i=0; i < 9; i++)
++	  ((float *)romm_cam)[i] = getreal(11);
++	romm_coeff (romm_cam);
++	break;
++      case 0x107:
++	FORC3 cam_mul[c] = getreal(11);
++	break;
++      case 0x108:  raw_width     = data;	break;
++      case 0x109:  raw_height    = data;	break;
++      case 0x10a:  left_margin   = data;	break;
++      case 0x10b:  top_margin    = data;	break;
++      case 0x10c:  width         = data;	break;
++      case 0x10d:  height        = data;	break;
++      case 0x10e:  ph1.format    = data;	break;
++      case 0x10f:  data_offset   = data+base;	break;
++      case 0x110:  meta_offset   = data+base;
++		   meta_length   = len;			break;
++      case 0x112:  ph1.key_off   = save - 4;		break;
++      case 0x210:  ph1.tag_210   = int_to_float(data);	break;
++      case 0x21a:  ph1.tag_21a   = data;		break;
++      case 0x21c:  strip_offset  = data+base;		break;
++      case 0x21d:  ph1.black     = data;		break;
++      case 0x222:  ph1.split_col = data;		break;
++      case 0x223:  ph1.black_col = data+base;		break;
++      case 0x224:  ph1.split_row = data;		break;
++      case 0x225:  ph1.black_row = data+base;		break;
++      case 0x301:
++	model[63] = 0;
++	fread (model, 1, 63, ifp);
++	if ((cp = strstr(model," camera"))) *cp = 0;
++    }
++    fseek (ifp, save, SEEK_SET);
++  }
++  load_raw = ph1.format < 3 ?
++	&CLASS phase_one_load_raw : &CLASS phase_one_load_raw_c;
++  maximum = 0xffff;
++  strcpy (make, "Phase One");
++  if (model[0]) return;
++  switch (raw_height) {
++    case 2060: strcpy (model,"LightPhase");	break;
++    case 2682: strcpy (model,"H 10");		break;
++    case 4128: strcpy (model,"H 20");		break;
++    case 5488: strcpy (model,"H 25");		break;
++  }
++}
++
++void CLASS parse_fuji (int offset)
++{
++  unsigned entries, tag, len, save, c;
++
++  fseek (ifp, offset, SEEK_SET);
++  entries = get4();
++  if (entries > 255) return;
++  while (entries--) {
++    tag = get2();
++    len = get2();
++    save = ftell(ifp);
++    if (tag == 0x100) {
++      raw_height = get2();
++      raw_width  = get2();
++    } else if (tag == 0x121) {
++      height = get2();
++      if ((width = get2()) == 4284) width += 3;
++    } else if (tag == 0x130) {
++      fuji_layout = fgetc(ifp) >> 7;
++      fuji_width = !(fgetc(ifp) & 8);
++    } else if (tag == 0x131) {
++      filters = 9;
++      FORC(36) xtrans_abs[0][35-c] = fgetc(ifp) & 3;
++    } else if (tag == 0x2ff0) {
++      FORC4 cam_mul[c ^ 1] = get2();
++    } else if (tag == 0xc000) {
++      c = order;
++      order = 0x4949;
++      while ((tag = get4()) > raw_width);
++      width = tag;
++      height = get4();
++      order = c;
++    }
++    fseek (ifp, save+len, SEEK_SET);
++  }
++  height <<= fuji_layout;
++  width  >>= fuji_layout;
++}
++
++int CLASS parse_jpeg (int offset)
++{
++  int len, save, hlen, mark;
++
++  fseek (ifp, offset, SEEK_SET);
++  if (fgetc(ifp) != 0xff || fgetc(ifp) != 0xd8) return 0;
++
++  while (fgetc(ifp) == 0xff && (mark = fgetc(ifp)) != 0xda) {
++    order = 0x4d4d;
++    len   = get2() - 2;
++    save  = ftell(ifp);
++    if (mark == 0xc0 || mark == 0xc3 || mark == 0xc9) {
++      fgetc(ifp);
++      raw_height = get2();
++      raw_width  = get2();
++    }
++    order = get2();
++    hlen  = get4();
++    if (get4() == 0x48454150)		/* "HEAP" */
++      parse_ciff (save+hlen, len-hlen, 0);
++    if (parse_tiff (save+6)) apply_tiff();
++    fseek (ifp, save+len, SEEK_SET);
++  }
++  return 1;
++}
++
++void CLASS parse_riff()
++{
++  unsigned i, size, end;
++  char tag[4], date[64], month[64];
++  static const char mon[12][4] =
++  { "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" };
++  struct tm t;
++
++  order = 0x4949;
++  fread (tag, 4, 1, ifp);
++  size = get4();
++  end = ftell(ifp) + size;
++  if (!memcmp(tag,"RIFF",4) || !memcmp(tag,"LIST",4)) {
++    get4();
++    while (ftell(ifp)+7 < end && !feof(ifp))
++      parse_riff();
++  } else if (!memcmp(tag,"nctg",4)) {
++    while (ftell(ifp)+7 < end) {
++      i = get2();
++      size = get2();
++      if ((i+1) >> 1 == 10 && size == 20)
++	get_timestamp(0);
++      else fseek (ifp, size, SEEK_CUR);
++    }
++  } else if (!memcmp(tag,"IDIT",4) && size < 64) {
++    fread (date, 64, 1, ifp);
++    date[size] = 0;
++    memset (&t, 0, sizeof t);
++    if (sscanf (date, "%*s %s %d %d:%d:%d %d", month, &t.tm_mday,
++	&t.tm_hour, &t.tm_min, &t.tm_sec, &t.tm_year) == 6) {
++      for (i=0; i < 12 && strcasecmp(mon[i],month); i++);
++      t.tm_mon = i;
++      t.tm_year -= 1900;
++      if (mktime(&t) > 0)
++	timestamp = mktime(&t);
++    }
++  } else
++    fseek (ifp, size, SEEK_CUR);
++}
++
++void CLASS parse_qt (int end)
++{
++  unsigned save, size;
++  char tag[4];
++
++  order = 0x4d4d;
++  while (ftell(ifp)+7 < end) {
++    save = ftell(ifp);
++    if ((size = get4()) < 8) return;
++    fread (tag, 4, 1, ifp);
++    if (!memcmp(tag,"moov",4) ||
++	!memcmp(tag,"udta",4) ||
++	!memcmp(tag,"CNTH",4))
++      parse_qt (save+size);
++    if (!memcmp(tag,"CNDA",4))
++      parse_jpeg (ftell(ifp));
++    fseek (ifp, save+size, SEEK_SET);
++  }
++}
++
++void CLASS parse_smal (int offset, int fsize)
++{
++  int ver;
++
++  fseek (ifp, offset+2, SEEK_SET);
++  order = 0x4949;
++  ver = fgetc(ifp);
++  if (ver == 6)
++    fseek (ifp, 5, SEEK_CUR);
++  if (get4() != fsize) return;
++  if (ver > 6) data_offset = get4();
++  raw_height = height = get2();
++  raw_width  = width  = get2();
++  strcpy (make, "SMaL");
++  sprintf (model, "v%d %dx%d", ver, width, height);
++  if (ver == 6) load_raw = &CLASS smal_v6_load_raw;
++  if (ver == 9) load_raw = &CLASS smal_v9_load_raw;
++}
++
++void CLASS parse_cine()
++{
++  unsigned off_head, off_setup, off_image, i;
++
++  order = 0x4949;
++  fseek (ifp, 4, SEEK_SET);
++  is_raw = get2() == 2;
++  fseek (ifp, 14, SEEK_CUR);
++  is_raw *= get4();
++  off_head = get4();
++  off_setup = get4();
++  off_image = get4();
++  timestamp = get4();
++  if ((i = get4())) timestamp = i;
++  fseek (ifp, off_head+4, SEEK_SET);
++  raw_width = get4();
++  raw_height = get4();
++  switch (get2(),get2()) {
++    case  8:  load_raw = &CLASS eight_bit_load_raw;  break;
++    case 16:  load_raw = &CLASS  unpacked_load_raw;
++  }
++  fseek (ifp, off_setup+792, SEEK_SET);
++  strcpy (make, "CINE");
++  sprintf (model, "%d", get4());
++  fseek (ifp, 12, SEEK_CUR);
++  switch ((i=get4()) & 0xffffff) {
++    case  3:  filters = 0x94949494;  break;
++    case  4:  filters = 0x49494949;  break;
++    default:  is_raw = 0;
++  }
++  fseek (ifp, 72, SEEK_CUR);
++  switch ((get4()+3600) % 360) {
++    case 270:  flip = 4;  break;
++    case 180:  flip = 1;  break;
++    case  90:  flip = 7;  break;
++    case   0:  flip = 2;
++  }
++  cam_mul[0] = getreal(11);
++  cam_mul[2] = getreal(11);
++  maximum = ~(-1 << get4());
++  fseek (ifp, 668, SEEK_CUR);
++  shutter = get4()/1000000000.0;
++  fseek (ifp, off_image, SEEK_SET);
++  if (shot_select < is_raw)
++    fseek (ifp, shot_select*8, SEEK_CUR);
++  data_offset  = (INT64) get4() + 8;
++  data_offset += (INT64) get4() << 32;
++}
++
++void CLASS parse_redcine()
++{
++  unsigned i, len, rdvo;
++
++  order = 0x4d4d;
++  is_raw = 0;
++  fseek (ifp, 52, SEEK_SET);
++  width  = get4();
++  height = get4();
++  fseek (ifp, 0, SEEK_END);
++  fseek (ifp, -(i = ftello(ifp) & 511), SEEK_CUR);
++  if (get4() != i || get4() != 0x52454f42) {
++    fprintf (stderr,_("%s: Tail is missing, parsing from head...\n"), ifname);
++    fseek (ifp, 0, SEEK_SET);
++    while ((len = get4()) != EOF) {
++      if (get4() == 0x52454456)
++	if (is_raw++ == shot_select)
++	  data_offset = ftello(ifp) - 8;
++      fseek (ifp, len-8, SEEK_CUR);
++    }
++  } else {
++    rdvo = get4();
++    fseek (ifp, 12, SEEK_CUR);
++    is_raw = get4();
++    fseeko (ifp, rdvo+8 + shot_select*4, SEEK_SET);
++    data_offset = get4();
++  }
++}
++
++char * CLASS foveon_gets (int offset, char *str, int len)
++{
++  int i;
++  fseek (ifp, offset, SEEK_SET);
++  for (i=0; i < len-1; i++)
++    if ((str[i] = get2()) == 0) break;
++  str[i] = 0;
++  return str;
++}
++
++void CLASS parse_foveon()
++{
++  int entries, img=0, off, len, tag, save, i, wide, high, pent, poff[256][2];
++  char name[64], value[64];
++
++  order = 0x4949;			/* Little-endian */
++  fseek (ifp, 36, SEEK_SET);
++  flip = get4();
++  fseek (ifp, -4, SEEK_END);
++  fseek (ifp, get4(), SEEK_SET);
++  if (get4() != 0x64434553) return;	/* SECd */
++  entries = (get4(),get4());
++  while (entries--) {
++    off = get4();
++    len = get4();
++    tag = get4();
++    save = ftell(ifp);
++    fseek (ifp, off, SEEK_SET);
++    if (get4() != (0x20434553 | (tag << 24))) return;
++    switch (tag) {
++      case 0x47414d49:			/* IMAG */
++      case 0x32414d49:			/* IMA2 */
++	fseek (ifp, 8, SEEK_CUR);
++	pent = get4();
++	wide = get4();
++	high = get4();
++	if (wide > raw_width && high > raw_height) {
++	  switch (pent) {
++	    case  5:  load_flags = 1;
++	    case  6:  load_raw = &CLASS foveon_sd_load_raw;  break;
++	    case 30:  load_raw = &CLASS foveon_dp_load_raw;  break;
++	    default:  load_raw = 0;
++	  }
++	  raw_width  = wide;
++	  raw_height = high;
++	  data_offset = off+28;
++	  is_foveon = 1;
++	}
++	fseek (ifp, off+28, SEEK_SET);
++	if (fgetc(ifp) == 0xff && fgetc(ifp) == 0xd8
++		&& thumb_length < len-28) {
++	  thumb_offset = off+28;
++	  thumb_length = len-28;
++	  write_thumb = &CLASS jpeg_thumb;
++	}
++	if (++img == 2 && !thumb_length) {
++	  thumb_offset = off+24;
++	  thumb_width = wide;
++	  thumb_height = high;
++	  write_thumb = &CLASS foveon_thumb;
++	}
++	break;
++      case 0x464d4143:			/* CAMF */
++	meta_offset = off+8;
++	meta_length = len-28;
++	break;
++      case 0x504f5250:			/* PROP */
++	pent = (get4(),get4());
++	fseek (ifp, 12, SEEK_CUR);
++	off += pent*8 + 24;
++	if ((unsigned) pent > 256) pent=256;
++	for (i=0; i < pent*2; i++)
++	  ((int *)poff)[i] = off + get4()*2;
++	for (i=0; i < pent; i++) {
++	  foveon_gets (poff[i][0], name, 64);
++	  foveon_gets (poff[i][1], value, 64);
++	  if (!strcmp (name, "ISO"))
++	    iso_speed = atoi(value);
++	  if (!strcmp (name, "CAMMANUF"))
++	    strcpy (make, value);
++	  if (!strcmp (name, "CAMMODEL"))
++	    strcpy (model, value);
++	  if (!strcmp (name, "WB_DESC"))
++	    strcpy (model2, value);
++	  if (!strcmp (name, "TIME"))
++	    timestamp = atoi(value);
++	  if (!strcmp (name, "EXPTIME"))
++	    shutter = atoi(value) / 1000000.0;
++	  if (!strcmp (name, "APERTURE"))
++	    aperture = atof(value);
++	  if (!strcmp (name, "FLENGTH"))
++	    focal_len = atof(value);
++	}
++#ifdef LOCALTIME
++	timestamp = mktime (gmtime (&timestamp));
++#endif
++    }
++    fseek (ifp, save, SEEK_SET);
++  }
++}
++
++/*
++   All matrices are from Adobe DNG Converter unless otherwise noted.
++ */
++void CLASS adobe_coeff (const char *make, const char *model)
++{
++  static const struct {
++    const char *prefix;
++    short black, maximum, trans[12];
++  } table[] = {
++    { "AgfaPhoto DC-833m", 0, 0,	/* DJC */
++	{ 11438,-3762,-1115,-2409,9914,2497,-1227,2295,5300 } },
++    { "Apple QuickTake", 0, 0,		/* DJC */
++	{ 21392,-5653,-3353,2406,8010,-415,7166,1427,2078 } },
++    { "Canon EOS D2000", 0, 0,
++	{ 24542,-10860,-3401,-1490,11370,-297,2858,-605,3225 } },
++    { "Canon EOS D6000", 0, 0,
++	{ 20482,-7172,-3125,-1033,10410,-285,2542,226,3136 } },
++    { "Canon EOS D30", 0, 0,
++	{ 9805,-2689,-1312,-5803,13064,3068,-2438,3075,8775 } },
++    { "Canon EOS D60", 0, 0xfa0,
++	{ 6188,-1341,-890,-7168,14489,2937,-2640,3228,8483 } },
++    { "Canon EOS 5DS", 0, 0x3c96,
++	{ 6250,-711,-808,-5153,12794,2636,-1249,2198,5610 } },
++    { "Canon EOS 5D Mark III", 0, 0x3c80,
++	{ 6722,-635,-963,-4287,12460,2028,-908,2162,5668 } },
++    { "Canon EOS 5D Mark II", 0, 0x3cf0,
++	{ 4716,603,-830,-7798,15474,2480,-1496,1937,6651 } },
++    { "Canon EOS 5D", 0, 0xe6c,
++	{ 6347,-479,-972,-8297,15954,2480,-1968,2131,7649 } },
++    { "Canon EOS 6D", 0, 0x3c82,
++	{ 7034,-804,-1014,-4420,12564,2058,-851,1994,5758 } },
++    { "Canon EOS 7D Mark II", 0, 0x3510,
++	{ 7268,-1082,-969,-4186,11839,2663,-825,2029,5839 } },
++    { "Canon EOS 7D", 0, 0x3510,
++	{ 6844,-996,-856,-3876,11761,2396,-593,1772,6198 } },
++    { "Canon EOS 10D", 0, 0xfa0,
++	{ 8197,-2000,-1118,-6714,14335,2592,-2536,3178,8266 } },
++    { "Canon EOS 20Da", 0, 0,
++	{ 14155,-5065,-1382,-6550,14633,2039,-1623,1824,6561 } },
++    { "Canon EOS 20D", 0, 0xfff,
++	{ 6599,-537,-891,-8071,15783,2424,-1983,2234,7462 } },
++    { "Canon EOS 30D", 0, 0,
++	{ 6257,-303,-1000,-7880,15621,2396,-1714,1904,7046 } },
++    { "Canon EOS 40D", 0, 0x3f60,
++	{ 6071,-747,-856,-7653,15365,2441,-2025,2553,7315 } },
++    { "Canon EOS 50D", 0, 0x3d93,
++	{ 4920,616,-593,-6493,13964,2784,-1774,3178,7005 } },
++    { "Canon EOS 60D", 0, 0x2ff7,
++	{ 6719,-994,-925,-4408,12426,2211,-887,2129,6051 } },
++    { "Canon EOS 70D", 0, 0x3bc7,
++	{ 7034,-804,-1014,-4420,12564,2058,-851,1994,5758 } },
++    { "Canon EOS 80D", 0, 0,
++	{ 7457,-671,-937,-4849,12495,2643,-1213,2354,5492 } },
++    { "Canon EOS 100D", 0, 0x350f,
++	{ 6602,-841,-939,-4472,12458,2247,-975,2039,6148 } },
++    { "Canon EOS 300D", 0, 0xfa0,
++	{ 8197,-2000,-1118,-6714,14335,2592,-2536,3178,8266 } },
++    { "Canon EOS 350D", 0, 0xfff,
++	{ 6018,-617,-965,-8645,15881,2975,-1530,1719,7642 } },
++    { "Canon EOS 400D", 0, 0xe8e,
++	{ 7054,-1501,-990,-8156,15544,2812,-1278,1414,7796 } },
++    { "Canon EOS 450D", 0, 0x390d,
++	{ 5784,-262,-821,-7539,15064,2672,-1982,2681,7427 } },
++    { "Canon EOS 500D", 0, 0x3479,
++	{ 4763,712,-646,-6821,14399,2640,-1921,3276,6561 } },
++    { "Canon EOS 550D", 0, 0x3dd7,
++	{ 6941,-1164,-857,-3825,11597,2534,-416,1540,6039 } },
++    { "Canon EOS 600D", 0, 0x3510,
++	{ 6461,-907,-882,-4300,12184,2378,-819,1944,5931 } },
++    { "Canon EOS 650D", 0, 0x354d,
++	{ 6602,-841,-939,-4472,12458,2247,-975,2039,6148 } },
++    { "Canon EOS 700D", 0, 0x3c00,
++	{ 6602,-841,-939,-4472,12458,2247,-975,2039,6148 } },
++    { "Canon EOS 750D", 0, 0x368e,
++	{ 6362,-823,-847,-4426,12109,2616,-743,1857,5635 } },
++    { "Canon EOS 760D", 0, 0x350f,
++	{ 6362,-823,-847,-4426,12109,2616,-743,1857,5635 } },
++    { "Canon EOS 1000D", 0, 0xe43,
++	{ 6771,-1139,-977,-7818,15123,2928,-1244,1437,7533 } },
++    { "Canon EOS 1100D", 0, 0x3510,
++	{ 6444,-904,-893,-4563,12308,2535,-903,2016,6728 } },
++    { "Canon EOS 1200D", 0, 0x37c2,
++	{ 6461,-907,-882,-4300,12184,2378,-819,1944,5931 } },
++    { "Canon EOS 1300D", 0, 0x3510,
++	{ 6939,-1016,-866,-4428,12473,2177,-1175,2178,6162 } },
++    { "Canon EOS M3", 0, 0,
++	{ 6362,-823,-847,-4426,12109,2616,-743,1857,5635 } },
++    { "Canon EOS M10", 0, 0,
++	{ 6400,-480,-888,-5294,13416,2047,-1296,2203,6137 } },
++    { "Canon EOS M", 0, 0,
++	{ 6602,-841,-939,-4472,12458,2247,-975,2039,6148 } },
++    { "Canon EOS-1Ds Mark III", 0, 0x3bb0,
++	{ 5859,-211,-930,-8255,16017,2353,-1732,1887,7448 } },
++    { "Canon EOS-1Ds Mark II", 0, 0xe80,
++	{ 6517,-602,-867,-8180,15926,2378,-1618,1771,7633 } },
++    { "Canon EOS-1D Mark IV", 0, 0x3bb0,
++	{ 6014,-220,-795,-4109,12014,2361,-561,1824,5787 } },
++    { "Canon EOS-1D Mark III", 0, 0x3bb0,
++	{ 6291,-540,-976,-8350,16145,2311,-1714,1858,7326 } },
++    { "Canon EOS-1D Mark II N", 0, 0xe80,
++	{ 6240,-466,-822,-8180,15825,2500,-1801,1938,8042 } },
++    { "Canon EOS-1D Mark II", 0, 0xe80,
++	{ 6264,-582,-724,-8312,15948,2504,-1744,1919,8664 } },
++    { "Canon EOS-1DS", 0, 0xe20,
++	{ 4374,3631,-1743,-7520,15212,2472,-2892,3632,8161 } },
++    { "Canon EOS-1D C", 0, 0x3c4e,
++	{ 6847,-614,-1014,-4669,12737,2139,-1197,2488,6846 } },
++    { "Canon EOS-1D X Mark II", 0, 0,
++	{ 7596,-978,-967,-4808,12571,2503,-1398,2567,5752 } },
++    { "Canon EOS-1D X", 0, 0x3c4e,
++	{ 6847,-614,-1014,-4669,12737,2139,-1197,2488,6846 } },
++    { "Canon EOS-1D", 0, 0xe20,
++	{ 6806,-179,-1020,-8097,16415,1687,-3267,4236,7690 } },
++    { "Canon EOS C500", 853, 0,		/* DJC */
++	{ 17851,-10604,922,-7425,16662,763,-3660,3636,22278 } },
++    { "Canon PowerShot A530", 0, 0,
++	{ 0 } },	/* don't want the A5 matrix */
++    { "Canon PowerShot A50", 0, 0,
++	{ -5300,9846,1776,3436,684,3939,-5540,9879,6200,-1404,11175,217 } },
++    { "Canon PowerShot A5", 0, 0,
++	{ -4801,9475,1952,2926,1611,4094,-5259,10164,5947,-1554,10883,547 } },
++    { "Canon PowerShot G10", 0, 0,
++	{ 11093,-3906,-1028,-5047,12492,2879,-1003,1750,5561 } },
++    { "Canon PowerShot G11", 0, 0,
++	{ 12177,-4817,-1069,-1612,9864,2049,-98,850,4471 } },
++    { "Canon PowerShot G12", 0, 0,
++	{ 13244,-5501,-1248,-1508,9858,1935,-270,1083,4366 } },
++    { "Canon PowerShot G15", 0, 0,
++	{ 7474,-2301,-567,-4056,11456,2975,-222,716,4181 } },
++    { "Canon PowerShot G16", 0, 0,
++	{ 8020,-2687,-682,-3704,11879,2052,-965,1921,5556 } },
++    { "Canon PowerShot G1 X", 0, 0,
++	{ 7378,-1255,-1043,-4088,12251,2048,-876,1946,5805 } },
++    { "Canon PowerShot G1", 0, 0,
++	{ -4778,9467,2172,4743,-1141,4344,-5146,9908,6077,-1566,11051,557 } },
++    { "Canon PowerShot G2", 0, 0,
++	{ 9087,-2693,-1049,-6715,14382,2537,-2291,2819,7790 } },
++    { "Canon PowerShot G3 X", 0, 0,
++	{ 9701,-3857,-921,-3149,11537,1817,-786,1817,5147 } },
++    { "Canon PowerShot G3", 0, 0,
++	{ 9212,-2781,-1073,-6573,14189,2605,-2300,2844,7664 } },
++    { "Canon PowerShot G5 X", 0, 0,
++	{ 9602,-3823,-937,-2984,11495,1675,-407,1415,5049 } },
++    { "Canon PowerShot G5", 0, 0,
++	{ 9757,-2872,-933,-5972,13861,2301,-1622,2328,7212 } },
++    { "Canon PowerShot G6", 0, 0,
++	{ 9877,-3775,-871,-7613,14807,3072,-1448,1305,7485 } },
++    { "Canon PowerShot G7 X", 0, 0,
++	{ 9602,-3823,-937,-2984,11495,1675,-407,1415,5049 } },
++    { "Canon PowerShot G9 X", 0, 0,
++	{ 9602,-3823,-937,-2984,11495,1675,-407,1415,5049 } },
++    { "Canon PowerShot G9", 0, 0,
++	{ 7368,-2141,-598,-5621,13254,2625,-1418,1696,5743 } },
++    { "Canon PowerShot Pro1", 0, 0,
++	{ 10062,-3522,-999,-7643,15117,2730,-765,817,7323 } },
++    { "Canon PowerShot Pro70", 34, 0,
++	{ -4155,9818,1529,3939,-25,4522,-5521,9870,6610,-2238,10873,1342 } },
++    { "Canon PowerShot Pro90", 0, 0,
++	{ -4963,9896,2235,4642,-987,4294,-5162,10011,5859,-1770,11230,577 } },
++    { "Canon PowerShot S30", 0, 0,
++	{ 10566,-3652,-1129,-6552,14662,2006,-2197,2581,7670 } },
++    { "Canon PowerShot S40", 0, 0,
++	{ 8510,-2487,-940,-6869,14231,2900,-2318,2829,9013 } },
++    { "Canon PowerShot S45", 0, 0,
++	{ 8163,-2333,-955,-6682,14174,2751,-2077,2597,8041 } },
++    { "Canon PowerShot S50", 0, 0,
++	{ 8882,-2571,-863,-6348,14234,2288,-1516,2172,6569 } },
++    { "Canon PowerShot S60", 0, 0,
++	{ 8795,-2482,-797,-7804,15403,2573,-1422,1996,7082 } },
++    { "Canon PowerShot S70", 0, 0,
++	{ 9976,-3810,-832,-7115,14463,2906,-901,989,7889 } },
++    { "Canon PowerShot S90", 0, 0,
++	{ 12374,-5016,-1049,-1677,9902,2078,-83,852,4683 } },
++    { "Canon PowerShot S95", 0, 0,
++	{ 13440,-5896,-1279,-1236,9598,1931,-180,1001,4651 } },
++    { "Canon PowerShot S100", 0, 0,
++	{ 7968,-2565,-636,-2873,10697,2513,180,667,4211 } },
++    { "Canon PowerShot S110", 0, 0,
++	{ 8039,-2643,-654,-3783,11230,2930,-206,690,4194 } },
++    { "Canon PowerShot S120", 0, 0,
++	{ 6961,-1685,-695,-4625,12945,1836,-1114,2152,5518 } },
++    { "Canon PowerShot SX1 IS", 0, 0,
++	{ 6578,-259,-502,-5974,13030,3309,-308,1058,4970 } },
++    { "Canon PowerShot SX50 HS", 0, 0,
++	{ 12432,-4753,-1247,-2110,10691,1629,-412,1623,4926 } },
++    { "Canon PowerShot SX60 HS", 0, 0,
++	{ 13161,-5451,-1344,-1989,10654,1531,-47,1271,4955 } },
++    { "Canon PowerShot A3300", 0, 0,	/* DJC */
++	{ 10826,-3654,-1023,-3215,11310,1906,0,999,4960 } },
++    { "Canon PowerShot A470", 0, 0,	/* DJC */
++	{ 12513,-4407,-1242,-2680,10276,2405,-878,2215,4734 } },
++    { "Canon PowerShot A610", 0, 0,	/* DJC */
++	{ 15591,-6402,-1592,-5365,13198,2168,-1300,1824,5075 } },
++    { "Canon PowerShot A620", 0, 0,	/* DJC */
++	{ 15265,-6193,-1558,-4125,12116,2010,-888,1639,5220 } },
++    { "Canon PowerShot A630", 0, 0,	/* DJC */
++	{ 14201,-5308,-1757,-6087,14472,1617,-2191,3105,5348 } },
++    { "Canon PowerShot A640", 0, 0,	/* DJC */
++	{ 13124,-5329,-1390,-3602,11658,1944,-1612,2863,4885 } },
++    { "Canon PowerShot A650", 0, 0,	/* DJC */
++	{ 9427,-3036,-959,-2581,10671,1911,-1039,1982,4430 } },
++    { "Canon PowerShot A720", 0, 0,	/* DJC */
++	{ 14573,-5482,-1546,-1266,9799,1468,-1040,1912,3810 } },
++    { "Canon PowerShot S3 IS", 0, 0,	/* DJC */
++	{ 14062,-5199,-1446,-4712,12470,2243,-1286,2028,4836 } },
++    { "Canon PowerShot SX110 IS", 0, 0,	/* DJC */
++	{ 14134,-5576,-1527,-1991,10719,1273,-1158,1929,3581 } },
++    { "Canon PowerShot SX220", 0, 0,	/* DJC */
++	{ 13898,-5076,-1447,-1405,10109,1297,-244,1860,3687 } },
++    { "Canon IXUS 160", 0, 0,		/* DJC */
++	{ 11657,-3781,-1136,-3544,11262,2283,-160,1219,4700 } },
++    { "Casio EX-S20", 0, 0,		/* DJC */
++	{ 11634,-3924,-1128,-4968,12954,2015,-1588,2648,7206 } },
++    { "Casio EX-Z750", 0, 0,		/* DJC */
++	{ 10819,-3873,-1099,-4903,13730,1175,-1755,3751,4632 } },
++    { "Casio EX-Z10", 128, 0xfff,	/* DJC */
++	{ 9790,-3338,-603,-2321,10222,2099,-344,1273,4799 } },
++    { "CINE 650", 0, 0,
++	{ 3390,480,-500,-800,3610,340,-550,2336,1192 } },
++    { "CINE 660", 0, 0,
++	{ 3390,480,-500,-800,3610,340,-550,2336,1192 } },
++    { "CINE", 0, 0,
++	{ 20183,-4295,-423,-3940,15330,3985,-280,4870,9800 } },
++    { "Contax N Digital", 0, 0xf1e,
++	{ 7777,1285,-1053,-9280,16543,2916,-3677,5679,7060 } },
++    { "DXO ONE", 0, 0,
++	{ 6596,-2079,-562,-4782,13016,1933,-970,1581,5181 } },
++    { "Epson R-D1", 0, 0,
++	{ 6827,-1878,-732,-8429,16012,2564,-704,592,7145 } },
++    { "Fujifilm E550", 0, 0,
++	{ 11044,-3888,-1120,-7248,15168,2208,-1531,2277,8069 } },
++    { "Fujifilm E900", 0, 0,
++	{ 9183,-2526,-1078,-7461,15071,2574,-2022,2440,8639 } },
++    { "Fujifilm F5", 0, 0,
++	{ 13690,-5358,-1474,-3369,11600,1998,-132,1554,4395 } },
++    { "Fujifilm F6", 0, 0,
++	{ 13690,-5358,-1474,-3369,11600,1998,-132,1554,4395 } },
++    { "Fujifilm F77", 0, 0xfe9,
++	{ 13690,-5358,-1474,-3369,11600,1998,-132,1554,4395 } },
++    { "Fujifilm F7", 0, 0,
++	{ 10004,-3219,-1201,-7036,15047,2107,-1863,2565,7736 } },
++    { "Fujifilm F8", 0, 0,
++	{ 13690,-5358,-1474,-3369,11600,1998,-132,1554,4395 } },
++    { "Fujifilm S100FS", 514, 0,
++	{ 11521,-4355,-1065,-6524,13767,3058,-1466,1984,6045 } },
++    { "Fujifilm S1", 0, 0,
++	{ 12297,-4882,-1202,-2106,10691,1623,-88,1312,4790 } },
++    { "Fujifilm S20Pro", 0, 0,
++	{ 10004,-3219,-1201,-7036,15047,2107,-1863,2565,7736 } },
++    { "Fujifilm S20", 512, 0x3fff,
++	{ 11401,-4498,-1312,-5088,12751,2613,-838,1568,5941 } },
++    { "Fujifilm S2Pro", 128, 0,
++	{ 12492,-4690,-1402,-7033,15423,1647,-1507,2111,7697 } },
++    { "Fujifilm S3Pro", 0, 0,
++	{ 11807,-4612,-1294,-8927,16968,1988,-2120,2741,8006 } },
++    { "Fujifilm S5Pro", 0, 0,
++	{ 12300,-5110,-1304,-9117,17143,1998,-1947,2448,8100 } },
++    { "Fujifilm S5000", 0, 0,
++	{ 8754,-2732,-1019,-7204,15069,2276,-1702,2334,6982 } },
++    { "Fujifilm S5100", 0, 0,
++	{ 11940,-4431,-1255,-6766,14428,2542,-993,1165,7421 } },
++    { "Fujifilm S5500", 0, 0,
++	{ 11940,-4431,-1255,-6766,14428,2542,-993,1165,7421 } },
++    { "Fujifilm S5200", 0, 0,
++	{ 9636,-2804,-988,-7442,15040,2589,-1803,2311,8621 } },
++    { "Fujifilm S5600", 0, 0,
++	{ 9636,-2804,-988,-7442,15040,2589,-1803,2311,8621 } },
++    { "Fujifilm S6", 0, 0,
++	{ 12628,-4887,-1401,-6861,14996,1962,-2198,2782,7091 } },
++    { "Fujifilm S7000", 0, 0,
++	{ 10190,-3506,-1312,-7153,15051,2238,-2003,2399,7505 } },
++    { "Fujifilm S9000", 0, 0,
++	{ 10491,-3423,-1145,-7385,15027,2538,-1809,2275,8692 } },
++    { "Fujifilm S9500", 0, 0,
++	{ 10491,-3423,-1145,-7385,15027,2538,-1809,2275,8692 } },
++    { "Fujifilm S9100", 0, 0,
++	{ 12343,-4515,-1285,-7165,14899,2435,-1895,2496,8800 } },
++    { "Fujifilm S9600", 0, 0,
++	{ 12343,-4515,-1285,-7165,14899,2435,-1895,2496,8800 } },
++    { "Fujifilm SL1000", 0, 0,
++	{ 11705,-4262,-1107,-2282,10791,1709,-555,1713,4945 } },
++    { "Fujifilm IS-1", 0, 0,
++	{ 21461,-10807,-1441,-2332,10599,1999,289,875,7703 } },
++    { "Fujifilm IS Pro", 0, 0,
++	{ 12300,-5110,-1304,-9117,17143,1998,-1947,2448,8100 } },
++    { "Fujifilm HS10 HS11", 0, 0xf68,
++	{ 12440,-3954,-1183,-1123,9674,1708,-83,1614,4086 } },
++    { "Fujifilm HS2", 0, 0,
++	{ 13690,-5358,-1474,-3369,11600,1998,-132,1554,4395 } },
++    { "Fujifilm HS3", 0, 0,
++	{ 13690,-5358,-1474,-3369,11600,1998,-132,1554,4395 } },
++    { "Fujifilm HS50EXR", 0, 0,
++	{ 12085,-4727,-953,-3257,11489,2002,-511,2046,4592 } },
++    { "Fujifilm F900EXR", 0, 0,
++	{ 12085,-4727,-953,-3257,11489,2002,-511,2046,4592 } },
++    { "Fujifilm X100S", 0, 0,
++	{ 10592,-4262,-1008,-3514,11355,2465,-870,2025,6386 } },
++    { "Fujifilm X100T", 0, 0,
++	{ 10592,-4262,-1008,-3514,11355,2465,-870,2025,6386 } },
++    { "Fujifilm X100", 0, 0,
++	{ 12161,-4457,-1069,-5034,12874,2400,-795,1724,6904 } },
++    { "Fujifilm X10", 0, 0,
++	{ 13509,-6199,-1254,-4430,12733,1865,-331,1441,5022 } },
++    { "Fujifilm X20", 0, 0,
++	{ 11768,-4971,-1133,-4904,12927,2183,-480,1723,4605 } },
++    { "Fujifilm X30", 0, 0,
++	{ 12328,-5256,-1144,-4469,12927,1675,-87,1291,4351 } },
++    { "Fujifilm X70", 0, 0,
++	{ 10450,-4329,-878,-3217,11105,2421,-752,1758,6519 } },
++    { "Fujifilm X-Pro1", 0, 0,
++	{ 10413,-3996,-993,-3721,11640,2361,-733,1540,6011 } },
++    { "Fujifilm X-Pro2", 0, 0,
++	{ 11434,-4948,-1210,-3746,12042,1903,-666,1479,5235 } },
++    { "Fujifilm X-A1", 0, 0,
++	{ 11086,-4555,-839,-3512,11310,2517,-815,1341,5940 } },
++    { "Fujifilm X-A2", 0, 0,
++	{ 10763,-4560,-917,-3346,11311,2322,-475,1135,5843 } },
++    { "Fujifilm X-E1", 0, 0,
++	{ 10413,-3996,-993,-3721,11640,2361,-733,1540,6011 } },
++    { "Fujifilm X-E2S", 0, 0,
++	{ 11562,-5118,-961,-3022,11007,2311,-525,1569,6097 } },
++    { "Fujifilm X-E2", 0, 0,
++	{ 8458,-2451,-855,-4597,12447,2407,-1475,2482,6526 } },
++    { "Fujifilm X-M1", 0, 0,
++	{ 10413,-3996,-993,-3721,11640,2361,-733,1540,6011 } },
++    { "Fujifilm X-S1", 0, 0,
++	{ 13509,-6199,-1254,-4430,12733,1865,-331,1441,5022 } },
++    { "Fujifilm X-T1", 0, 0,	/* also X-T10 */
++	{ 8458,-2451,-855,-4597,12447,2407,-1475,2482,6526 } },
++    { "Fujifilm XF1", 0, 0,
++	{ 13509,-6199,-1254,-4430,12733,1865,-331,1441,5022 } },
++    { "Fujifilm XQ", 0, 0,	/* XQ1 and XQ2 */
++	{ 9252,-2704,-1064,-5893,14265,1717,-1101,2341,4349 } },
++    { "Imacon Ixpress", 0, 0,		/* DJC */
++	{ 7025,-1415,-704,-5188,13765,1424,-1248,2742,6038 } },
++    { "Kodak NC2000", 0, 0,
++	{ 13891,-6055,-803,-465,9919,642,2121,82,1291 } },
++    { "Kodak DCS315C", 8, 0,
++	{ 17523,-4827,-2510,756,8546,-137,6113,1649,2250 } },
++    { "Kodak DCS330C", 8, 0,
++	{ 20620,-7572,-2801,-103,10073,-396,3551,-233,2220 } },
++    { "Kodak DCS420", 0, 0,
++	{ 10868,-1852,-644,-1537,11083,484,2343,628,2216 } },
++    { "Kodak DCS460", 0, 0,
++	{ 10592,-2206,-967,-1944,11685,230,2206,670,1273 } },
++    { "Kodak EOSDCS1", 0, 0,
++	{ 10592,-2206,-967,-1944,11685,230,2206,670,1273 } },
++    { "Kodak EOSDCS3B", 0, 0,
++	{ 9898,-2700,-940,-2478,12219,206,1985,634,1031 } },
++    { "Kodak DCS520C", 178, 0,
++	{ 24542,-10860,-3401,-1490,11370,-297,2858,-605,3225 } },
++    { "Kodak DCS560C", 177, 0,
++	{ 20482,-7172,-3125,-1033,10410,-285,2542,226,3136 } },
++    { "Kodak DCS620C", 177, 0,
++	{ 23617,-10175,-3149,-2054,11749,-272,2586,-489,3453 } },
++    { "Kodak DCS620X", 176, 0,
++	{ 13095,-6231,154,12221,-21,-2137,895,4602,2258 } },
++    { "Kodak DCS660C", 173, 0,
++	{ 18244,-6351,-2739,-791,11193,-521,3711,-129,2802 } },
++    { "Kodak DCS720X", 0, 0,
++	{ 11775,-5884,950,9556,1846,-1286,-1019,6221,2728 } },
++    { "Kodak DCS760C", 0, 0,
++	{ 16623,-6309,-1411,-4344,13923,323,2285,274,2926 } },
++    { "Kodak DCS Pro SLR", 0, 0,
++	{ 5494,2393,-232,-6427,13850,2846,-1876,3997,5445 } },
++    { "Kodak DCS Pro 14nx", 0, 0,
++	{ 5494,2393,-232,-6427,13850,2846,-1876,3997,5445 } },
++    { "Kodak DCS Pro 14", 0, 0,
++	{ 7791,3128,-776,-8588,16458,2039,-2455,4006,6198 } },
++    { "Kodak ProBack645", 0, 0,
++	{ 16414,-6060,-1470,-3555,13037,473,2545,122,4948 } },
++    { "Kodak ProBack", 0, 0,
++	{ 21179,-8316,-2918,-915,11019,-165,3477,-180,4210 } },
++    { "Kodak P712", 0, 0,
++	{ 9658,-3314,-823,-5163,12695,2768,-1342,1843,6044 } },
++    { "Kodak P850", 0, 0xf7c,
++	{ 10511,-3836,-1102,-6946,14587,2558,-1481,1792,6246 } },
++    { "Kodak P880", 0, 0xfff,
++	{ 12805,-4662,-1376,-7480,15267,2360,-1626,2194,7904 } },
++    { "Kodak EasyShare Z980", 0, 0,
++	{ 11313,-3559,-1101,-3893,11891,2257,-1214,2398,4908 } },
++    { "Kodak EasyShare Z981", 0, 0,
++	{ 12729,-4717,-1188,-1367,9187,2582,274,860,4411 } },
++    { "Kodak EasyShare Z990", 0, 0xfed,
++	{ 11749,-4048,-1309,-1867,10572,1489,-138,1449,4522 } },
++    { "Kodak EASYSHARE Z1015", 0, 0xef1,
++	{ 11265,-4286,-992,-4694,12343,2647,-1090,1523,5447 } },
++    { "Leaf CMost", 0, 0,
++	{ 3952,2189,449,-6701,14585,2275,-4536,7349,6536 } },
++    { "Leaf Valeo 6", 0, 0,
++	{ 3952,2189,449,-6701,14585,2275,-4536,7349,6536 } },
++    { "Leaf Aptus 54S", 0, 0,
++	{ 8236,1746,-1314,-8251,15953,2428,-3673,5786,5771 } },
++    { "Leaf Aptus 65", 0, 0,
++	{ 7914,1414,-1190,-8777,16582,2280,-2811,4605,5562 } },
++    { "Leaf Aptus 75", 0, 0,
++	{ 7914,1414,-1190,-8777,16582,2280,-2811,4605,5562 } },
++    { "Leaf", 0, 0,
++	{ 8236,1746,-1314,-8251,15953,2428,-3673,5786,5771 } },
++    { "Mamiya ZD", 0, 0,
++	{ 7645,2579,-1363,-8689,16717,2015,-3712,5941,5961 } },
++    { "Micron 2010", 110, 0,		/* DJC */
++	{ 16695,-3761,-2151,155,9682,163,3433,951,4904 } },
++    { "Minolta DiMAGE 5", 0, 0xf7d,
++	{ 8983,-2942,-963,-6556,14476,2237,-2426,2887,8014 } },
++    { "Minolta DiMAGE 7Hi", 0, 0xf7d,
++	{ 11368,-3894,-1242,-6521,14358,2339,-2475,3056,7285 } },
++    { "Minolta DiMAGE 7", 0, 0xf7d,
++	{ 9144,-2777,-998,-6676,14556,2281,-2470,3019,7744 } },
++    { "Minolta DiMAGE A1", 0, 0xf8b,
++	{ 9274,-2547,-1167,-8220,16323,1943,-2273,2720,8340 } },
++    { "Minolta DiMAGE A200", 0, 0,
++	{ 8560,-2487,-986,-8112,15535,2771,-1209,1324,7743 } },
++    { "Minolta DiMAGE A2", 0, 0xf8f,
++	{ 9097,-2726,-1053,-8073,15506,2762,-966,981,7763 } },
++    { "Minolta DiMAGE Z2", 0, 0,	/* DJC */
++	{ 11280,-3564,-1370,-4655,12374,2282,-1423,2168,5396 } },
++    { "Minolta DYNAX 5", 0, 0xffb,
++	{ 10284,-3283,-1086,-7957,15762,2316,-829,882,6644 } },
++    { "Minolta DYNAX 7", 0, 0xffb,
++	{ 10239,-3104,-1099,-8037,15727,2451,-927,925,6871 } },
++    { "Motorola PIXL", 0, 0,		/* DJC */
++	{ 8898,-989,-1033,-3292,11619,1674,-661,3178,5216 } },
++    { "Nikon D100", 0, 0,
++	{ 5902,-933,-782,-8983,16719,2354,-1402,1455,6464 } },
++    { "Nikon D1H", 0, 0,
++	{ 7577,-2166,-926,-7454,15592,1934,-2377,2808,8606 } },
++    { "Nikon D1X", 0, 0,
++	{ 7702,-2245,-975,-9114,17242,1875,-2679,3055,8521 } },
++    { "Nikon D1", 0, 0, /* multiplied by 2.218750, 1.0, 1.148438 */
++	{ 16772,-4726,-2141,-7611,15713,1972,-2846,3494,9521 } },
++    { "Nikon D200", 0, 0xfbc,
++	{ 8367,-2248,-763,-8758,16447,2422,-1527,1550,8053 } },
++    { "Nikon D2H", 0, 0,
++	{ 5710,-901,-615,-8594,16617,2024,-2975,4120,6830 } },
++    { "Nikon D2X", 0, 0,
++	{ 10231,-2769,-1255,-8301,15900,2552,-797,680,7148 } },
++    { "Nikon D3000", 0, 0,
++	{ 8736,-2458,-935,-9075,16894,2251,-1354,1242,8263 } },
++    { "Nikon D3100", 0, 0,
++	{ 7911,-2167,-813,-5327,13150,2408,-1288,2483,7968 } },
++    { "Nikon D3200", 0, 0xfb9,
++	{ 7013,-1408,-635,-5268,12902,2640,-1470,2801,7379 } },
++    { "Nikon D3300", 0, 0,
++	{ 6988,-1384,-714,-5631,13410,2447,-1485,2204,7318 } },
++    { "Nikon D300", 0, 0,
++	{ 9030,-1992,-715,-8465,16302,2255,-2689,3217,8069 } },
++    { "Nikon D3X", 0, 0,
++	{ 7171,-1986,-648,-8085,15555,2718,-2170,2512,7457 } },
++    { "Nikon D3S", 0, 0,
++	{ 8828,-2406,-694,-4874,12603,2541,-660,1509,7587 } },
++    { "Nikon D3", 0, 0,
++	{ 8139,-2171,-663,-8747,16541,2295,-1925,2008,8093 } },
++    { "Nikon D40X", 0, 0,
++	{ 8819,-2543,-911,-9025,16928,2151,-1329,1213,8449 } },
++    { "Nikon D40", 0, 0,
++	{ 6992,-1668,-806,-8138,15748,2543,-874,850,7897 } },
++    { "Nikon D4S", 0, 0,
++	{ 8598,-2848,-857,-5618,13606,2195,-1002,1773,7137 } },
++    { "Nikon D4", 0, 0,
++	{ 8598,-2848,-857,-5618,13606,2195,-1002,1773,7137 } },
++    { "Nikon Df", 0, 0,
++	{ 8598,-2848,-857,-5618,13606,2195,-1002,1773,7137 } },
++    { "Nikon D5000", 0, 0xf00,
++	{ 7309,-1403,-519,-8474,16008,2622,-2433,2826,8064 } },
++    { "Nikon D5100", 0, 0x3de6,
++	{ 8198,-2239,-724,-4871,12389,2798,-1043,2050,7181 } },
++    { "Nikon D5200", 0, 0,
++	{ 8322,-3112,-1047,-6367,14342,2179,-988,1638,6394 } },
++    { "Nikon D5300", 0, 0,
++	{ 6988,-1384,-714,-5631,13410,2447,-1485,2204,7318 } },
++    { "Nikon D5500", 0, 0,
++	{ 8821,-2938,-785,-4178,12142,2287,-824,1651,6860 } },
++    { "Nikon D500", 0, 0,
++	{ 8813,-3210,-1036,-4703,12868,2021,-1054,1940,6129 } },
++    { "Nikon D50", 0, 0,
++	{ 7732,-2422,-789,-8238,15884,2498,-859,783,7330 } },
++    { "Nikon D5", 0, 0,
++	{ 9200,-3522,-992,-5755,13803,2117,-753,1486,6338 } },
++    { "Nikon D600", 0, 0x3e07,
++	{ 8178,-2245,-609,-4857,12394,2776,-1207,2086,7298 } },
++    { "Nikon D610", 0, 0,
++	{ 8178,-2245,-609,-4857,12394,2776,-1207,2086,7298 } },
++    { "Nikon D60", 0, 0,
++	{ 8736,-2458,-935,-9075,16894,2251,-1354,1242,8263 } },
++    { "Nikon D7000", 0, 0,
++	{ 8198,-2239,-724,-4871,12389,2798,-1043,2050,7181 } },
++    { "Nikon D7100", 0, 0,
++	{ 8322,-3112,-1047,-6367,14342,2179,-988,1638,6394 } },
++    { "Nikon D7200", 0, 0,
++	{ 8322,-3112,-1047,-6367,14342,2179,-988,1638,6394 } },
++    { "Nikon D750", 0, 0,
++	{ 9020,-2890,-715,-4535,12436,2348,-934,1919,7086 } },
++    { "Nikon D700", 0, 0,
++	{ 8139,-2171,-663,-8747,16541,2295,-1925,2008,8093 } },
++    { "Nikon D70", 0, 0,
++	{ 7732,-2422,-789,-8238,15884,2498,-859,783,7330 } },
++    { "Nikon D810", 0, 0,
++	{ 9369,-3195,-791,-4488,12430,2301,-893,1796,6872 } },
++    { "Nikon D800", 0, 0,
++	{ 7866,-2108,-555,-4869,12483,2681,-1176,2069,7501 } },
++    { "Nikon D80", 0, 0,
++	{ 8629,-2410,-883,-9055,16940,2171,-1490,1363,8520 } },
++    { "Nikon D90", 0, 0xf00,
++	{ 7309,-1403,-519,-8474,16008,2622,-2434,2826,8064 } },
++    { "Nikon E700", 0, 0x3dd,		/* DJC */
++	{ -3746,10611,1665,9621,-1734,2114,-2389,7082,3064,3406,6116,-244 } },
++    { "Nikon E800", 0, 0x3dd,		/* DJC */
++	{ -3746,10611,1665,9621,-1734,2114,-2389,7082,3064,3406,6116,-244 } },
++    { "Nikon E950", 0, 0x3dd,		/* DJC */
++	{ -3746,10611,1665,9621,-1734,2114,-2389,7082,3064,3406,6116,-244 } },
++    { "Nikon E995", 0, 0,	/* copied from E5000 */
++	{ -5547,11762,2189,5814,-558,3342,-4924,9840,5949,688,9083,96 } },
++    { "Nikon E2100", 0, 0,	/* copied from Z2, new white balance */
++	{ 13142,-4152,-1596,-4655,12374,2282,-1769,2696,6711} },
++    { "Nikon E2500", 0, 0,
++	{ -5547,11762,2189,5814,-558,3342,-4924,9840,5949,688,9083,96 } },
++    { "Nikon E3200", 0, 0,		/* DJC */
++	{ 9846,-2085,-1019,-3278,11109,2170,-774,2134,5745 } },
++    { "Nikon E4300", 0, 0,	/* copied from Minolta DiMAGE Z2 */
++	{ 11280,-3564,-1370,-4655,12374,2282,-1423,2168,5396 } },
++    { "Nikon E4500", 0, 0,
++	{ -5547,11762,2189,5814,-558,3342,-4924,9840,5949,688,9083,96 } },
++    { "Nikon E5000", 0, 0,
++	{ -5547,11762,2189,5814,-558,3342,-4924,9840,5949,688,9083,96 } },
++    { "Nikon E5400", 0, 0,
++	{ 9349,-2987,-1001,-7919,15766,2266,-2098,2680,6839 } },
++    { "Nikon E5700", 0, 0,
++	{ -5368,11478,2368,5537,-113,3148,-4969,10021,5782,778,9028,211 } },
++    { "Nikon E8400", 0, 0,
++	{ 7842,-2320,-992,-8154,15718,2599,-1098,1342,7560 } },
++    { "Nikon E8700", 0, 0,
++	{ 8489,-2583,-1036,-8051,15583,2643,-1307,1407,7354 } },
++    { "Nikon E8800", 0, 0,
++	{ 7971,-2314,-913,-8451,15762,2894,-1442,1520,7610 } },
++    { "Nikon COOLPIX A", 0, 0,
++	{ 8198,-2239,-724,-4871,12389,2798,-1043,2050,7181 } },
++    { "Nikon COOLPIX P330", 200, 0,
++	{ 10321,-3920,-931,-2750,11146,1824,-442,1545,5539 } },
++    { "Nikon COOLPIX P340", 200, 0,
++	{ 10321,-3920,-931,-2750,11146,1824,-442,1545,5539 } },
++    { "Nikon COOLPIX P6000", 0, 0,
++	{ 9698,-3367,-914,-4706,12584,2368,-837,968,5801 } },
++    { "Nikon COOLPIX P7000", 0, 0,
++	{ 11432,-3679,-1111,-3169,11239,2202,-791,1380,4455 } },
++    { "Nikon COOLPIX P7100", 0, 0,
++	{ 11053,-4269,-1024,-1976,10182,2088,-526,1263,4469 } },
++    { "Nikon COOLPIX P7700", 200, 0,
++	{ 10321,-3920,-931,-2750,11146,1824,-442,1545,5539 } },
++    { "Nikon COOLPIX P7800", 200, 0,
++	{ 10321,-3920,-931,-2750,11146,1824,-442,1545,5539 } },
++    { "Nikon 1 V3", 0, 0,
++	{ 5958,-1559,-571,-4021,11453,2939,-634,1548,5087 } },
++    { "Nikon 1 J4", 0, 0,
++	{ 5958,-1559,-571,-4021,11453,2939,-634,1548,5087 } },
++    { "Nikon 1 J5", 0, 0,
++	{ 7520,-2518,-645,-3844,12102,1945,-913,2249,6835 } },
++    { "Nikon 1 S2", 200, 0,
++	{ 6612,-1342,-618,-3338,11055,2623,-174,1792,5075 } },
++    { "Nikon 1 V2", 0, 0,
++	{ 6588,-1305,-693,-3277,10987,2634,-355,2016,5106 } },
++    { "Nikon 1 J3", 0, 0,
++	{ 6588,-1305,-693,-3277,10987,2634,-355,2016,5106 } },
++    { "Nikon 1 AW1", 0, 0,
++	{ 6588,-1305,-693,-3277,10987,2634,-355,2016,5106 } },
++    { "Nikon 1 ", 0, 0,		/* J1, J2, S1, V1 */
++	{ 8994,-2667,-865,-4594,12324,2552,-699,1786,6260 } },
++    { "Olympus AIR A01", 0, 0,
++	{ 8992,-3093,-639,-2563,10721,2122,-437,1270,5473 } },
++    { "Olympus C5050", 0, 0,
++	{ 10508,-3124,-1273,-6079,14294,1901,-1653,2306,6237 } },
++    { "Olympus C5060", 0, 0,
++	{ 10445,-3362,-1307,-7662,15690,2058,-1135,1176,7602 } },
++    { "Olympus C7070", 0, 0,
++	{ 10252,-3531,-1095,-7114,14850,2436,-1451,1723,6365 } },
++    { "Olympus C70", 0, 0,
++	{ 10793,-3791,-1146,-7498,15177,2488,-1390,1577,7321 } },
++    { "Olympus C80", 0, 0,
++	{ 8606,-2509,-1014,-8238,15714,2703,-942,979,7760 } },
++    { "Olympus E-10", 0, 0xffc,
++	{ 12745,-4500,-1416,-6062,14542,1580,-1934,2256,6603 } },
++    { "Olympus E-1", 0, 0,
++	{ 11846,-4767,-945,-7027,15878,1089,-2699,4122,8311 } },
++    { "Olympus E-20", 0, 0xffc,
++	{ 13173,-4732,-1499,-5807,14036,1895,-2045,2452,7142 } },
++    { "Olympus E-300", 0, 0,
++	{ 7828,-1761,-348,-5788,14071,1830,-2853,4518,6557 } },
++    { "Olympus E-330", 0, 0,
++	{ 8961,-2473,-1084,-7979,15990,2067,-2319,3035,8249 } },
++    { "Olympus E-30", 0, 0xfbc,
++	{ 8144,-1861,-1111,-7763,15894,1929,-1865,2542,7607 } },
++    { "Olympus E-3", 0, 0xf99,
++	{ 9487,-2875,-1115,-7533,15606,2010,-1618,2100,7389 } },
++    { "Olympus E-400", 0, 0,
++	{ 6169,-1483,-21,-7107,14761,2536,-2904,3580,8568 } },
++    { "Olympus E-410", 0, 0xf6a,
++	{ 8856,-2582,-1026,-7761,15766,2082,-2009,2575,7469 } },
++    { "Olympus E-420", 0, 0xfd7,
++	{ 8746,-2425,-1095,-7594,15612,2073,-1780,2309,7416 } },
++    { "Olympus E-450", 0, 0xfd2,
++	{ 8745,-2425,-1095,-7594,15613,2073,-1780,2309,7416 } },
++    { "Olympus E-500", 0, 0,
++	{ 8136,-1968,-299,-5481,13742,1871,-2556,4205,6630 } },
++    { "Olympus E-510", 0, 0xf6a,
++	{ 8785,-2529,-1033,-7639,15624,2112,-1783,2300,7817 } },
++    { "Olympus E-520", 0, 0xfd2,
++	{ 8344,-2322,-1020,-7596,15635,2048,-1748,2269,7287 } },
++    { "Olympus E-5", 0, 0xeec,
++	{ 11200,-3783,-1325,-4576,12593,2206,-695,1742,7504 } },
++    { "Olympus E-600", 0, 0xfaf,
++	{ 8453,-2198,-1092,-7609,15681,2008,-1725,2337,7824 } },
++    { "Olympus E-620", 0, 0xfaf,
++	{ 8453,-2198,-1092,-7609,15681,2008,-1725,2337,7824 } },
++    { "Olympus E-P1", 0, 0xffd,
++	{ 8343,-2050,-1021,-7715,15705,2103,-1831,2380,8235 } },
++    { "Olympus E-P2", 0, 0xffd,
++	{ 8343,-2050,-1021,-7715,15705,2103,-1831,2380,8235 } },
++    { "Olympus E-P3", 0, 0,
++	{ 7575,-2159,-571,-3722,11341,2725,-1434,2819,6271 } },
++    { "Olympus E-P5", 0, 0,
++	{ 8380,-2630,-639,-2887,10725,2496,-627,1427,5438 } },
++    { "Olympus E-PL1s", 0, 0,
++	{ 11409,-3872,-1393,-4572,12757,2003,-709,1810,7415 } },
++    { "Olympus E-PL1", 0, 0,
++	{ 11408,-4289,-1215,-4286,12385,2118,-387,1467,7787 } },
++    { "Olympus E-PL2", 0, 0xcf3,
++	{ 15030,-5552,-1806,-3987,12387,1767,-592,1670,7023 } },
++    { "Olympus E-PL3", 0, 0,
++	{ 7575,-2159,-571,-3722,11341,2725,-1434,2819,6271 } },
++    { "Olympus E-PL5", 0, 0xfcb,
++	{ 8380,-2630,-639,-2887,10725,2496,-627,1427,5438 } },
++    { "Olympus E-PL6", 0, 0,
++	{ 8380,-2630,-639,-2887,10725,2496,-627,1427,5438 } },
++    { "Olympus E-PL7", 0, 0,
++	{ 9197,-3190,-659,-2606,10830,2039,-458,1250,5458 } },
++    { "Olympus E-PM1", 0, 0,
++	{ 7575,-2159,-571,-3722,11341,2725,-1434,2819,6271 } },
++    { "Olympus E-PM2", 0, 0,
++	{ 8380,-2630,-639,-2887,10725,2496,-627,1427,5438 } },
++    { "Olympus E-M10", 0, 0,	/* also E-M10 Mark II */
++	{ 8380,-2630,-639,-2887,10725,2496,-627,1427,5438 } },
++    { "Olympus E-M1", 0, 0,
++	{ 7687,-1984,-606,-4327,11928,2721,-1381,2339,6452 } },
++    { "Olympus E-M5MarkII", 0, 0,
++	{ 9422,-3258,-711,-2655,10898,2015,-512,1354,5512 } },
++    { "Olympus E-M5", 0, 0xfe1,
++	{ 8380,-2630,-639,-2887,10725,2496,-627,1427,5438 } },
++    { "Olympus PEN-F", 0, 0,
++	{ 9476,-3182,-765,-2613,10958,1893,-449,1315,5268 } },
++    { "Olympus SH-2", 0, 0,
++	{ 10156,-3425,-1077,-2611,11177,1624,-385,1592,5080 } },
++    { "Olympus SP350", 0, 0,
++	{ 12078,-4836,-1069,-6671,14306,2578,-786,939,7418 } },
++    { "Olympus SP3", 0, 0,
++	{ 11766,-4445,-1067,-6901,14421,2707,-1029,1217,7572 } },
++    { "Olympus SP500UZ", 0, 0xfff,
++	{ 9493,-3415,-666,-5211,12334,3260,-1548,2262,6482 } },
++    { "Olympus SP510UZ", 0, 0xffe,
++	{ 10593,-3607,-1010,-5881,13127,3084,-1200,1805,6721 } },
++    { "Olympus SP550UZ", 0, 0xffe,
++	{ 11597,-4006,-1049,-5432,12799,2957,-1029,1750,6516 } },
++    { "Olympus SP560UZ", 0, 0xff9,
++	{ 10915,-3677,-982,-5587,12986,2911,-1168,1968,6223 } },
++    { "Olympus SP570UZ", 0, 0,
++	{ 11522,-4044,-1146,-4736,12172,2904,-988,1829,6039 } },
++    { "Olympus STYLUS1", 0, 0,
++	{ 8360,-2420,-880,-3928,12353,1739,-1381,2416,5173 } },
++    { "Olympus TG-4", 0, 0,
++	{ 11426,-4159,-1126,-2066,10678,1593,-120,1327,4998 } },
++    { "Olympus XZ-10", 0, 0,
++	{ 9777,-3483,-925,-2886,11297,1800,-602,1663,5134 } },
++    { "Olympus XZ-1", 0, 0,
++	{ 10901,-4095,-1074,-1141,9208,2293,-62,1417,5158 } },
++    { "Olympus XZ-2", 0, 0,
++	{ 9777,-3483,-925,-2886,11297,1800,-602,1663,5134 } },
++    { "OmniVision", 0, 0,		/* DJC */
++	{ 12782,-4059,-379,-478,9066,1413,1340,1513,5176 } },
++    { "Pentax *ist DL2", 0, 0,
++	{ 10504,-2438,-1189,-8603,16207,2531,-1022,863,12242 } },
++    { "Pentax *ist DL", 0, 0,
++	{ 10829,-2838,-1115,-8339,15817,2696,-837,680,11939 } },
++    { "Pentax *ist DS2", 0, 0,
++	{ 10504,-2438,-1189,-8603,16207,2531,-1022,863,12242 } },
++    { "Pentax *ist DS", 0, 0,
++	{ 10371,-2333,-1206,-8688,16231,2602,-1230,1116,11282 } },
++    { "Pentax *ist D", 0, 0,
++	{ 9651,-2059,-1189,-8881,16512,2487,-1460,1345,10687 } },
++    { "Pentax K10D", 0, 0,
++	{ 9566,-2863,-803,-7170,15172,2112,-818,803,9705 } },
++    { "Pentax K1", 0, 0,
++	{ 11095,-3157,-1324,-8377,15834,2720,-1108,947,11688 } },
++    { "Pentax K20D", 0, 0,
++	{ 9427,-2714,-868,-7493,16092,1373,-2199,3264,7180 } },
++    { "Pentax K200D", 0, 0,
++	{ 9186,-2678,-907,-8693,16517,2260,-1129,1094,8524 } },
++    { "Pentax K2000", 0, 0,
++	{ 11057,-3604,-1155,-5152,13046,2329,-282,375,8104 } },
++    { "Pentax K-m", 0, 0,
++	{ 11057,-3604,-1155,-5152,13046,2329,-282,375,8104 } },
++    { "Pentax K-x", 0, 0,
++	{ 8843,-2837,-625,-5025,12644,2668,-411,1234,7410 } },
++    { "Pentax K-r", 0, 0,
++	{ 9895,-3077,-850,-5304,13035,2521,-883,1768,6936 } },
++    { "Pentax K-1", 0, 0,
++	{ 8566,-2746,-1201,-3612,12204,1550,-893,1680,6264 } },
++    { "Pentax K-30", 0, 0,
++	{ 8710,-2632,-1167,-3995,12301,1881,-981,1719,6535 } },
++    { "Pentax K-3 II", 0, 0,
++	{ 8626,-2607,-1155,-3995,12301,1881,-1039,1822,6925 } },
++    { "Pentax K-3", 0, 0,
++	{ 7415,-2052,-721,-5186,12788,2682,-1446,2157,6773 } },
++    { "Pentax K-5 II", 0, 0,
++	{ 8170,-2725,-639,-4440,12017,2744,-771,1465,6599 } },
++    { "Pentax K-5", 0, 0,
++	{ 8713,-2833,-743,-4342,11900,2772,-722,1543,6247 } },
++    { "Pentax K-7", 0, 0,
++	{ 9142,-2947,-678,-8648,16967,1663,-2224,2898,8615 } },
++    { "Pentax K-S1", 0, 0,
++	{ 8512,-3211,-787,-4167,11966,2487,-638,1288,6054 } },
++    { "Pentax K-S2", 0, 0,
++	{ 8662,-3280,-798,-3928,11771,2444,-586,1232,6054 } },
++    { "Pentax Q-S1", 0, 0,
++	{ 12995,-5593,-1107,-1879,10139,2027,-64,1233,4919 } },
++    { "Pentax 645D", 0, 0x3e00,
++	{ 10646,-3593,-1158,-3329,11699,1831,-667,2874,6287 } },
++    { "Panasonic DMC-CM1", 15, 0,
++	{ 8770,-3194,-820,-2871,11281,1803,-513,1552,4434 } },
++    { "Panasonic DMC-FZ8", 0, 0xf7f,
++	{ 8986,-2755,-802,-6341,13575,3077,-1476,2144,6379 } },
++    { "Panasonic DMC-FZ18", 0, 0,
++	{ 9932,-3060,-935,-5809,13331,2753,-1267,2155,5575 } },
++    { "Panasonic DMC-FZ28", 15, 0xf96,
++	{ 10109,-3488,-993,-5412,12812,2916,-1305,2140,5543 } },
++    { "Panasonic DMC-FZ330", 15, 0,
++	{ 8378,-2798,-769,-3068,11410,1877,-538,1792,4623 } },
++    { "Panasonic DMC-FZ300", 15, 0,
++	{ 8378,-2798,-769,-3068,11410,1877,-538,1792,4623 } },
++    { "Panasonic DMC-FZ30", 0, 0xf94,
++	{ 10976,-4029,-1141,-7918,15491,2600,-1670,2071,8246 } },
++    { "Panasonic DMC-FZ3", 15, 0,
++	{ 9938,-2780,-890,-4604,12393,2480,-1117,2304,4620 } },
++    { "Panasonic DMC-FZ4", 15, 0,
++	{ 13639,-5535,-1371,-1698,9633,2430,316,1152,4108 } },
++    { "Panasonic DMC-FZ50", 0, 0,
++	{ 7906,-2709,-594,-6231,13351,3220,-1922,2631,6537 } },
++    { "Panasonic DMC-FZ7", 15, 0,
++	{ 11532,-4324,-1066,-2375,10847,1749,-564,1699,4351 } },
++    { "Leica V-LUX1", 0, 0,
++	{ 7906,-2709,-594,-6231,13351,3220,-1922,2631,6537 } },
++    { "Panasonic DMC-L10", 15, 0xf96,
++	{ 8025,-1942,-1050,-7920,15904,2100,-2456,3005,7039 } },
++    { "Panasonic DMC-L1", 0, 0xf7f,
++	{ 8054,-1885,-1025,-8349,16367,2040,-2805,3542,7629 } },
++    { "Leica DIGILUX 3", 0, 0xf7f,
++	{ 8054,-1885,-1025,-8349,16367,2040,-2805,3542,7629 } },
++    { "Panasonic DMC-LC1", 0, 0,
++	{ 11340,-4069,-1275,-7555,15266,2448,-2960,3426,7685 } },
++    { "Leica DIGILUX 2", 0, 0,
++	{ 11340,-4069,-1275,-7555,15266,2448,-2960,3426,7685 } },
++    { "Panasonic DMC-LX100", 15, 0,
++	{ 8844,-3538,-768,-3709,11762,2200,-698,1792,5220 } },
++    { "Leica D-LUX (Typ 109)", 15, 0,
++	{ 8844,-3538,-768,-3709,11762,2200,-698,1792,5220 } },
++    { "Panasonic DMC-LF1", 15, 0,
++	{ 9379,-3267,-816,-3227,11560,1881,-926,1928,5340 } },
++    { "Leica C (Typ 112)", 15, 0,
++	{ 9379,-3267,-816,-3227,11560,1881,-926,1928,5340 } },
++    { "Panasonic DMC-LX1", 0, 0xf7f,
++	{ 10704,-4187,-1230,-8314,15952,2501,-920,945,8927 } },
++    { "Leica D-LUX2", 0, 0xf7f,
++	{ 10704,-4187,-1230,-8314,15952,2501,-920,945,8927 } },
++    { "Panasonic DMC-LX2", 0, 0,
++	{ 8048,-2810,-623,-6450,13519,3272,-1700,2146,7049 } },
++    { "Leica D-LUX3", 0, 0,
++	{ 8048,-2810,-623,-6450,13519,3272,-1700,2146,7049 } },
++    { "Panasonic DMC-LX3", 15, 0,
++	{ 8128,-2668,-655,-6134,13307,3161,-1782,2568,6083 } },
++    { "Leica D-LUX 4", 15, 0,
++	{ 8128,-2668,-655,-6134,13307,3161,-1782,2568,6083 } },
++    { "Panasonic DMC-LX5", 15, 0,
++	{ 10909,-4295,-948,-1333,9306,2399,22,1738,4582 } },
++    { "Leica D-LUX 5", 15, 0,
++	{ 10909,-4295,-948,-1333,9306,2399,22,1738,4582 } },
++    { "Panasonic DMC-LX7", 15, 0,
++	{ 10148,-3743,-991,-2837,11366,1659,-701,1893,4899 } },
++    { "Leica D-LUX 6", 15, 0,
++	{ 10148,-3743,-991,-2837,11366,1659,-701,1893,4899 } },
++    { "Panasonic DMC-FZ1000", 15, 0,
++	{ 7830,-2696,-763,-3325,11667,1866,-641,1712,4824 } },
++    { "Leica V-LUX (Typ 114)", 15, 0,
++	{ 7830,-2696,-763,-3325,11667,1866,-641,1712,4824 } },
++    { "Panasonic DMC-FZ100", 15, 0xfff,
++	{ 16197,-6146,-1761,-2393,10765,1869,366,2238,5248 } },
++    { "Leica V-LUX 2", 15, 0xfff,
++	{ 16197,-6146,-1761,-2393,10765,1869,366,2238,5248 } },
++    { "Panasonic DMC-FZ150", 15, 0xfff,
++	{ 11904,-4541,-1189,-2355,10899,1662,-296,1586,4289 } },
++    { "Leica V-LUX 3", 15, 0xfff,
++	{ 11904,-4541,-1189,-2355,10899,1662,-296,1586,4289 } },
++    { "Panasonic DMC-FZ200", 15, 0xfff,
++	{ 8112,-2563,-740,-3730,11784,2197,-941,2075,4933 } },
++    { "Leica V-LUX 4", 15, 0xfff,
++	{ 8112,-2563,-740,-3730,11784,2197,-941,2075,4933 } },
++    { "Panasonic DMC-FX150", 15, 0xfff,
++	{ 9082,-2907,-925,-6119,13377,3058,-1797,2641,5609 } },
++    { "Panasonic DMC-G10", 0, 0,
++	{ 10113,-3400,-1114,-4765,12683,2317,-377,1437,6710 } },
++    { "Panasonic DMC-G1", 15, 0xf94,
++	{ 8199,-2065,-1056,-8124,16156,2033,-2458,3022,7220 } },
++    { "Panasonic DMC-G2", 15, 0xf3c,
++	{ 10113,-3400,-1114,-4765,12683,2317,-377,1437,6710 } },
++    { "Panasonic DMC-G3", 15, 0xfff,
++	{ 6763,-1919,-863,-3868,11515,2684,-1216,2387,5879 } },
++    { "Panasonic DMC-G5", 15, 0xfff,
++	{ 7798,-2562,-740,-3879,11584,2613,-1055,2248,5434 } },
++    { "Panasonic DMC-G6", 15, 0xfff,
++	{ 8294,-2891,-651,-3869,11590,2595,-1183,2267,5352 } },
++    { "Panasonic DMC-G7", 15, 0xfff,
++	{ 7610,-2780,-576,-4614,12195,2733,-1375,2393,6490 } },
++    { "Panasonic DMC-GF1", 15, 0xf92,
++	{ 7888,-1902,-1011,-8106,16085,2099,-2353,2866,7330 } },
++    { "Panasonic DMC-GF2", 15, 0xfff,
++	{ 7888,-1902,-1011,-8106,16085,2099,-2353,2866,7330 } },
++    { "Panasonic DMC-GF3", 15, 0xfff,
++	{ 9051,-2468,-1204,-5212,13276,2121,-1197,2510,6890 } },
++    { "Panasonic DMC-GF5", 15, 0xfff,
++	{ 8228,-2945,-660,-3938,11792,2430,-1094,2278,5793 } },
++    { "Panasonic DMC-GF6", 15, 0,
++	{ 8130,-2801,-946,-3520,11289,2552,-1314,2511,5791 } },
++    { "Panasonic DMC-GF7", 15, 0,
++	{ 7610,-2780,-576,-4614,12195,2733,-1375,2393,6490 } },
++    { "Panasonic DMC-GF8", 15, 0,
++	{ 7610,-2780,-576,-4614,12195,2733,-1375,2393,6490 } },
++    { "Panasonic DMC-GH1", 15, 0xf92,
++	{ 6299,-1466,-532,-6535,13852,2969,-2331,3112,5984 } },
++    { "Panasonic DMC-GH2", 15, 0xf95,
++	{ 7780,-2410,-806,-3913,11724,2484,-1018,2390,5298 } },
++    { "Panasonic DMC-GH3", 15, 0,
++	{ 6559,-1752,-491,-3672,11407,2586,-962,1875,5130 } },
++    { "Panasonic DMC-GH4", 15, 0,
++	{ 7122,-2108,-512,-3155,11201,2231,-541,1423,5045 } },
++    { "Panasonic DMC-GM1", 15, 0,
++	{ 6770,-1895,-744,-5232,13145,2303,-1664,2691,5703 } },
++    { "Panasonic DMC-GM5", 15, 0,
++	{ 8238,-3244,-679,-3921,11814,2384,-836,2022,5852 } },
++    { "Panasonic DMC-GX1", 15, 0,
++	{ 6763,-1919,-863,-3868,11515,2684,-1216,2387,5879 } },
++    { "Panasonic DMC-GX7", 15, 0,
++	{ 7610,-2780,-576,-4614,12195,2733,-1375,2393,6490 } },
++    { "Panasonic DMC-GX8", 15, 0,
++	{ 7564,-2263,-606,-3148,11239,2177,-540,1435,4853 } },
++    { "Panasonic DMC-TZ1", 15, 0,
++	{ 7790,-2736,-755,-3452,11870,1769,-628,1647,4898 } },
++    { "Panasonic DMC-ZS1", 15, 0,
++	{ 7790,-2736,-755,-3452,11870,1769,-628,1647,4898 } },
++    { "Panasonic DMC-TZ6", 15, 0,
++	{ 8607,-2822,-808,-3755,11930,2049,-820,2060,5224 } },
++    { "Panasonic DMC-ZS4", 15, 0,
++	{ 8607,-2822,-808,-3755,11930,2049,-820,2060,5224 } },
++    { "Panasonic DMC-TZ7", 15, 0,
++	{ 8802,-3135,-789,-3151,11468,1904,-550,1745,4810 } },
++    { "Panasonic DMC-ZS5", 15, 0,
++	{ 8802,-3135,-789,-3151,11468,1904,-550,1745,4810 } },
++    { "Panasonic DMC-TZ8", 15, 0,
++	{ 8550,-2908,-842,-3195,11529,1881,-338,1603,4631 } },
++    { "Panasonic DMC-ZS6", 15, 0,
++	{ 8550,-2908,-842,-3195,11529,1881,-338,1603,4631 } },
++    { "Leica S (Typ 007)", 0, 0,
++	{ 6063,-2234,-231,-5210,13787,1500,-1043,2866,6997 } },
++    { "Leica X", 0, 0,		/* X and X-U, both (Typ 113) */
++	{ 7712,-2059,-653,-3882,11494,2726,-710,1332,5958 } },
++    { "Leica Q (Typ 116)", 0, 0,
++	{ 11865,-4523,-1441,-5423,14458,935,-1587,2687,4830 } },
++    { "Leica M (Typ 262)", 0, 0,
++	{ 6653,-1486,-611,-4221,13303,929,-881,2416,7226 } },
++    { "Leica SL (Typ 601)", 0, 0,
++	{ 11865,-4523,-1441,-5423,14458,935,-1587,2687,4830} },
++    { "Phase One H 20", 0, 0,		/* DJC */
++	{ 1313,1855,-109,-6715,15908,808,-327,1840,6020 } },
++    { "Phase One H 25", 0, 0,
++	{ 2905,732,-237,-8134,16626,1476,-3038,4253,7517 } },
++    { "Phase One P 2", 0, 0,
++	{ 2905,732,-237,-8134,16626,1476,-3038,4253,7517 } },
++    { "Phase One P 30", 0, 0,
++	{ 4516,-245,-37,-7020,14976,2173,-3206,4671,7087 } },
++    { "Phase One P 45", 0, 0,
++	{ 5053,-24,-117,-5684,14076,1702,-2619,4492,5849 } },
++    { "Phase One P40", 0, 0,
++	{ 8035,435,-962,-6001,13872,2320,-1159,3065,5434 } },
++    { "Phase One P65", 0, 0,
++	{ 8035,435,-962,-6001,13872,2320,-1159,3065,5434 } },
++    { "Photron BC2-HD", 0, 0,		/* DJC */
++	{ 14603,-4122,-528,-1810,9794,2017,-297,2763,5936 } },
++    { "Red One", 704, 0xffff,		/* DJC */
++	{ 21014,-7891,-2613,-3056,12201,856,-2203,5125,8042 } },
++    { "Ricoh GR II", 0, 0,
++	{ 4630,-834,-423,-4977,12805,2417,-638,1467,6115 } },
++    { "Ricoh GR", 0, 0,
++	{ 3708,-543,-160,-5381,12254,3556,-1471,1929,8234 } },
++    { "Samsung EX1", 0, 0x3e00,
++	{ 8898,-2498,-994,-3144,11328,2066,-760,1381,4576 } },
++    { "Samsung EX2F", 0, 0x7ff,
++	{ 10648,-3897,-1055,-2022,10573,1668,-492,1611,4742 } },
++    { "Samsung EK-GN120", 0, 0,
++	{ 7557,-2522,-739,-4679,12949,1894,-840,1777,5311 } },
++    { "Samsung NX mini", 0, 0,
++	{ 5222,-1196,-550,-6540,14649,2009,-1666,2819,5657 } },
++    { "Samsung NX3300", 0, 0,
++	{ 8060,-2933,-761,-4504,12890,1762,-630,1489,5227 } },
++    { "Samsung NX3000", 0, 0,
++	{ 8060,-2933,-761,-4504,12890,1762,-630,1489,5227 } },
++    { "Samsung NX30", 0, 0,	/* NX30, NX300, NX300M */
++	{ 7557,-2522,-739,-4679,12949,1894,-840,1777,5311 } },
++    { "Samsung NX2000", 0, 0,
++	{ 7557,-2522,-739,-4679,12949,1894,-840,1777,5311 } },
++    { "Samsung NX2", 0, 0xfff,	/* NX20, NX200, NX210 */
++	{ 6933,-2268,-753,-4921,13387,1647,-803,1641,6096 } },
++    { "Samsung NX1000", 0, 0,
++	{ 6933,-2268,-753,-4921,13387,1647,-803,1641,6096 } },
++    { "Samsung NX1100", 0, 0,
++	{ 6933,-2268,-753,-4921,13387,1647,-803,1641,6096 } },
++    { "Samsung NX11", 0, 0,
++	{ 10332,-3234,-1168,-6111,14639,1520,-1352,2647,8331 } },
++    { "Samsung NX10", 0, 0,	/* also NX100 */
++	{ 10332,-3234,-1168,-6111,14639,1520,-1352,2647,8331 } },
++    { "Samsung NX500", 0, 0,
++	{ 10686,-4042,-1052,-3595,13238,276,-464,1259,5931 } },
++    { "Samsung NX5", 0, 0,
++	{ 10332,-3234,-1168,-6111,14639,1520,-1352,2647,8331 } },
++    { "Samsung NX1", 0, 0,
++	{ 10686,-4042,-1052,-3595,13238,276,-464,1259,5931 } },
++    { "Samsung WB2000", 0, 0xfff,
++	{ 12093,-3557,-1155,-1000,9534,1733,-22,1787,4576 } },
++    { "Samsung GX-1", 0, 0,
++	{ 10504,-2438,-1189,-8603,16207,2531,-1022,863,12242 } },
++    { "Samsung GX20", 0, 0,	/* copied from Pentax K20D */
++	{ 9427,-2714,-868,-7493,16092,1373,-2199,3264,7180 } },
++    { "Samsung S85", 0, 0,		/* DJC */
++	{ 11885,-3968,-1473,-4214,12299,1916,-835,1655,5549 } },
++    { "Sinar", 0, 0,			/* DJC */
++	{ 16442,-2956,-2422,-2877,12128,750,-1136,6066,4559 } },
++    { "Sony DSC-F828", 0, 0,
++	{ 7924,-1910,-777,-8226,15459,2998,-1517,2199,6818,-7242,11401,3481 } },
++    { "Sony DSC-R1", 0, 0,
++	{ 8512,-2641,-694,-8042,15670,2526,-1821,2117,7414 } },
++    { "Sony DSC-V3", 0, 0,
++	{ 7511,-2571,-692,-7894,15088,3060,-948,1111,8128 } },
++    { "Sony DSC-RX100M", 0, 0,		/* M2, M3, and M4 */
++	{ 6596,-2079,-562,-4782,13016,1933,-970,1581,5181 } },
++    { "Sony DSC-RX100", 0, 0,
++	{ 8651,-2754,-1057,-3464,12207,1373,-568,1398,4434 } },
++    { "Sony DSC-RX10", 0, 0,		/* also RX10M2 */
++	{ 6679,-1825,-745,-5047,13256,1953,-1580,2422,5183 } },
++    { "Sony DSC-RX1RM2", 0, 0,
++	{ 6629,-1900,-483,-4618,12349,2550,-622,1381,6514 } },
++    { "Sony DSC-RX1", 0, 0,
++	{ 6344,-1612,-462,-4863,12477,2681,-865,1786,6899 } },
++    { "Sony DSLR-A100", 0, 0xfeb,
++	{ 9437,-2811,-774,-8405,16215,2290,-710,596,7181 } },
++    { "Sony DSLR-A290", 0, 0,
++	{ 6038,-1484,-579,-9145,16746,2512,-875,746,7218 } },
++    { "Sony DSLR-A2", 0, 0,
++	{ 9847,-3091,-928,-8485,16345,2225,-715,595,7103 } },
++    { "Sony DSLR-A300", 0, 0,
++	{ 9847,-3091,-928,-8485,16345,2225,-715,595,7103 } },
++    { "Sony DSLR-A330", 0, 0,
++	{ 9847,-3091,-929,-8485,16346,2225,-714,595,7103 } },
++    { "Sony DSLR-A350", 0, 0xffc,
++	{ 6038,-1484,-578,-9146,16746,2513,-875,746,7217 } },
++    { "Sony DSLR-A380", 0, 0,
++	{ 6038,-1484,-579,-9145,16746,2512,-875,746,7218 } },
++    { "Sony DSLR-A390", 0, 0,
++	{ 6038,-1484,-579,-9145,16746,2512,-875,746,7218 } },
++    { "Sony DSLR-A450", 0, 0xfeb,
++	{ 4950,-580,-103,-5228,12542,3029,-709,1435,7371 } },
++    { "Sony DSLR-A580", 0, 0xfeb,
++	{ 5932,-1492,-411,-4813,12285,2856,-741,1524,6739 } },
++    { "Sony DSLR-A500", 0, 0xfeb,
++	{ 6046,-1127,-278,-5574,13076,2786,-691,1419,7625 } },
++    { "Sony DSLR-A5", 0, 0xfeb,
++	{ 4950,-580,-103,-5228,12542,3029,-709,1435,7371 } },
++    { "Sony DSLR-A700", 0, 0,
++	{ 5775,-805,-359,-8574,16295,2391,-1943,2341,7249 } },
++    { "Sony DSLR-A850", 0, 0,
++	{ 5413,-1162,-365,-5665,13098,2866,-608,1179,8440 } },
++    { "Sony DSLR-A900", 0, 0,
++	{ 5209,-1072,-397,-8845,16120,2919,-1618,1803,8654 } },
++    { "Sony ILCA-68", 0, 0,
++	{ 6435,-1903,-536,-4722,12449,2550,-663,1363,6517 } },
++    { "Sony ILCA-77M2", 0, 0,
++	{ 5991,-1732,-443,-4100,11989,2381,-704,1467,5992 } },
++    { "Sony ILCE-6300", 0, 0,
++	{ 5973,-1695,-419,-3826,11797,2293,-639,1398,5789 } },
++    { "Sony ILCE-7M2", 0, 0,
++	{ 5271,-712,-347,-6153,13653,2763,-1601,2366,7242 } },
++    { "Sony ILCE-7S", 0, 0,	/* also ILCE-7SM2 */
++	{ 5838,-1430,-246,-3497,11477,2297,-748,1885,5778 } },
++    { "Sony ILCE-7RM2", 0, 0,
++	{ 6629,-1900,-483,-4618,12349,2550,-622,1381,6514 } },
++    { "Sony ILCE-7R", 0, 0,
++	{ 4913,-541,-202,-6130,13513,2906,-1564,2151,7183 } },
++    { "Sony ILCE-7", 0, 0,
++	{ 5271,-712,-347,-6153,13653,2763,-1601,2366,7242 } },
++    { "Sony ILCE", 0, 0,	/* 3000, 5000, 5100, 6000, and QX1 */
++	{ 5991,-1456,-455,-4764,12135,2980,-707,1425,6701 } },
++    { "Sony NEX-5N", 0, 0,
++	{ 5991,-1456,-455,-4764,12135,2980,-707,1425,6701 } },
++    { "Sony NEX-5R", 0, 0,
++	{ 6129,-1545,-418,-4930,12490,2743,-977,1693,6615 } },
++    { "Sony NEX-5T", 0, 0,
++	{ 6129,-1545,-418,-4930,12490,2743,-977,1693,6615 } },
++    { "Sony NEX-3N", 0, 0,
++	{ 6129,-1545,-418,-4930,12490,2743,-977,1693,6615 } },
++    { "Sony NEX-3", 138, 0,		/* DJC */
++	{ 6907,-1256,-645,-4940,12621,2320,-1710,2581,6230 } },
++    { "Sony NEX-5", 116, 0,		/* DJC */
++	{ 6807,-1350,-342,-4216,11649,2567,-1089,2001,6420 } },
++    { "Sony NEX-3", 0, 0,		/* Adobe */
++	{ 6549,-1550,-436,-4880,12435,2753,-854,1868,6976 } },
++    { "Sony NEX-5", 0, 0,		/* Adobe */
++	{ 6549,-1550,-436,-4880,12435,2753,-854,1868,6976 } },
++    { "Sony NEX-6", 0, 0,
++	{ 6129,-1545,-418,-4930,12490,2743,-977,1693,6615 } },
++    { "Sony NEX-7", 0, 0,
++	{ 5491,-1192,-363,-4951,12342,2948,-911,1722,7192 } },
++    { "Sony NEX", 0, 0,	/* NEX-C3, NEX-F3 */
++	{ 5991,-1456,-455,-4764,12135,2980,-707,1425,6701 } },
++    { "Sony SLT-A33", 0, 0,
++	{ 6069,-1221,-366,-5221,12779,2734,-1024,2066,6834 } },
++    { "Sony SLT-A35", 0, 0,
++	{ 5986,-1618,-415,-4557,11820,3120,-681,1404,6971 } },
++    { "Sony SLT-A37", 0, 0,
++	{ 5991,-1456,-455,-4764,12135,2980,-707,1425,6701 } },
++    { "Sony SLT-A55", 0, 0,
++	{ 5932,-1492,-411,-4813,12285,2856,-741,1524,6739 } },
++    { "Sony SLT-A57", 0, 0,
++	{ 5991,-1456,-455,-4764,12135,2980,-707,1425,6701 } },
++    { "Sony SLT-A58", 0, 0,
++	{ 5991,-1456,-455,-4764,12135,2980,-707,1425,6701 } },
++    { "Sony SLT-A65", 0, 0,
++	{ 5491,-1192,-363,-4951,12342,2948,-911,1722,7192 } },
++    { "Sony SLT-A77", 0, 0,
++	{ 5491,-1192,-363,-4951,12342,2948,-911,1722,7192 } },
++    { "Sony SLT-A99", 0, 0,
++	{ 6344,-1612,-462,-4863,12477,2681,-865,1786,6899 } },
++  };
++  double cam_xyz[4][3];
++  char name[130];
++  int i, j;
++
++  sprintf (name, "%s %s", make, model);
++  for (i=0; i < sizeof table / sizeof *table; i++)
++    if (!strncmp (name, table[i].prefix, strlen(table[i].prefix))) {
++      if (table[i].black)   black   = (ushort) table[i].black;
++      if (table[i].maximum) maximum = (ushort) table[i].maximum;
++      if (table[i].trans[0]) {
++	for (raw_color = j=0; j < 12; j++)
++	  ((double *)cam_xyz)[j] = table[i].trans[j] / 10000.0;
++	cam_xyz_coeff (rgb_cam, cam_xyz);
++      }
++      break;
++    }
++}
++
++void CLASS simple_coeff (int index)
++{
++  static const float table[][12] = {
++  /* index 0 -- all Foveon cameras */
++  { 1.4032,-0.2231,-0.1016,-0.5263,1.4816,0.017,-0.0112,0.0183,0.9113 },
++  /* index 1 -- Kodak DC20 and DC25 */
++  { 2.25,0.75,-1.75,-0.25,-0.25,0.75,0.75,-0.25,-0.25,-1.75,0.75,2.25 },
++  /* index 2 -- Logitech Fotoman Pixtura */
++  { 1.893,-0.418,-0.476,-0.495,1.773,-0.278,-1.017,-0.655,2.672 },
++  /* index 3 -- Nikon E880, E900, and E990 */
++  { -1.936280,  1.800443, -1.448486,  2.584324,
++     1.405365, -0.524955, -0.289090,  0.408680,
++    -1.204965,  1.082304,  2.941367, -1.818705 }
++  };
++  int i, c;
++
++  for (raw_color = i=0; i < 3; i++)
++    FORCC rgb_cam[i][c] = table[index][i*colors+c];
++}
++
++short CLASS guess_byte_order (int words)
++{
++  uchar test[4][2];
++  int t=2, msb;
++  double diff, sum[2] = {0,0};
++
++  fread (test[0], 2, 2, ifp);
++  for (words-=2; words--; ) {
++    fread (test[t], 2, 1, ifp);
++    for (msb=0; msb < 2; msb++) {
++      diff = (test[t^2][msb] << 8 | test[t^2][!msb])
++	   - (test[t  ][msb] << 8 | test[t  ][!msb]);
++      sum[msb] += diff*diff;
++    }
++    t = (t+1) & 3;
++  }
++  return sum[0] < sum[1] ? 0x4d4d : 0x4949;
++}
++
++float CLASS find_green (int bps, int bite, int off0, int off1)
++{
++  UINT64 bitbuf=0;
++  int vbits, col, i, c;
++  ushort img[2][2064];
++  double sum[]={0,0};
++
++  FORC(2) {
++    fseek (ifp, c ? off1:off0, SEEK_SET);
++    for (vbits=col=0; col < width; col++) {
++      for (vbits -= bps; vbits < 0; vbits += bite) {
++	bitbuf <<= bite;
++	for (i=0; i < bite; i+=8)
++	  bitbuf |= (unsigned) (fgetc(ifp) << i);
++      }
++      img[c][col] = bitbuf << (64-bps-vbits) >> (64-bps);
++    }
++  }
++  FORC(width-1) {
++    sum[ c & 1] += ABS(img[0][c]-img[1][c+1]);
++    sum[~c & 1] += ABS(img[1][c]-img[0][c+1]);
++  }
++  return 100 * log(sum[0]/sum[1]);
++}
++
++/*
++   Identify which camera created this file, and set global variables
++   accordingly.
++ */
++void CLASS identify()
++{
++  static const short pana[][6] = {
++    { 3130, 1743,  4,  0, -6,  0 },
++    { 3130, 2055,  4,  0, -6,  0 },
++    { 3130, 2319,  4,  0, -6,  0 },
++    { 3170, 2103, 18,  0,-42, 20 },
++    { 3170, 2367, 18, 13,-42,-21 },
++    { 3177, 2367,  0,  0, -1,  0 },
++    { 3304, 2458,  0,  0, -1,  0 },
++    { 3330, 2463,  9,  0, -5,  0 },
++    { 3330, 2479,  9,  0,-17,  4 },
++    { 3370, 1899, 15,  0,-44, 20 },
++    { 3370, 2235, 15,  0,-44, 20 },
++    { 3370, 2511, 15, 10,-44,-21 },
++    { 3690, 2751,  3,  0, -8, -3 },
++    { 3710, 2751,  0,  0, -3,  0 },
++    { 3724, 2450,  0,  0,  0, -2 },
++    { 3770, 2487, 17,  0,-44, 19 },
++    { 3770, 2799, 17, 15,-44,-19 },
++    { 3880, 2170,  6,  0, -6,  0 },
++    { 4060, 3018,  0,  0,  0, -2 },
++    { 4290, 2391,  3,  0, -8, -1 },
++    { 4330, 2439, 17, 15,-44,-19 },
++    { 4508, 2962,  0,  0, -3, -4 },
++    { 4508, 3330,  0,  0, -3, -6 },
++  };
++  static const ushort canon[][11] = {
++    { 1944, 1416,   0,  0, 48,  0 },
++    { 2144, 1560,   4,  8, 52,  2, 0, 0, 0, 25 },
++    { 2224, 1456,  48,  6,  0,  2 },
++    { 2376, 1728,  12,  6, 52,  2 },
++    { 2672, 1968,  12,  6, 44,  2 },
++    { 3152, 2068,  64, 12,  0,  0, 16 },
++    { 3160, 2344,  44, 12,  4,  4 },
++    { 3344, 2484,   4,  6, 52,  6 },
++    { 3516, 2328,  42, 14,  0,  0 },
++    { 3596, 2360,  74, 12,  0,  0 },
++    { 3744, 2784,  52, 12,  8, 12 },
++    { 3944, 2622,  30, 18,  6,  2 },
++    { 3948, 2622,  42, 18,  0,  2 },
++    { 3984, 2622,  76, 20,  0,  2, 14 },
++    { 4104, 3048,  48, 12, 24, 12 },
++    { 4116, 2178,   4,  2,  0,  0 },
++    { 4152, 2772, 192, 12,  0,  0 },
++    { 4160, 3124, 104, 11,  8, 65 },
++    { 4176, 3062,  96, 17,  8,  0, 0, 16, 0, 7, 0x49 },
++    { 4192, 3062,  96, 17, 24,  0, 0, 16, 0, 0, 0x49 },
++    { 4312, 2876,  22, 18,  0,  2 },
++    { 4352, 2874,  62, 18,  0,  0 },
++    { 4476, 2954,  90, 34,  0,  0 },
++    { 4480, 3348,  12, 10, 36, 12, 0, 0, 0, 18, 0x49 },
++    { 4480, 3366,  80, 50,  0,  0 },
++    { 4496, 3366,  80, 50, 12,  0 },
++    { 4768, 3516,  96, 16,  0,  0, 0, 16 },
++    { 4832, 3204,  62, 26,  0,  0 },
++    { 4832, 3228,  62, 51,  0,  0 },
++    { 5108, 3349,  98, 13,  0,  0 },
++    { 5120, 3318, 142, 45, 62,  0 },
++    { 5280, 3528,  72, 52,  0,  0 },
++    { 5344, 3516, 142, 51,  0,  0 },
++    { 5344, 3584, 126,100,  0,  2 },
++    { 5360, 3516, 158, 51,  0,  0 },
++    { 5568, 3708,  72, 38,  0,  0 },
++    { 5632, 3710,  96, 17,  0,  0, 0, 16, 0, 0, 0x49 },
++    { 5712, 3774,  62, 20, 10,  2 },
++    { 5792, 3804, 158, 51,  0,  0 },
++    { 5920, 3950, 122, 80,  2,  0 },
++    { 6096, 4056,  72, 34,  0,  0 },
++    { 6288, 4056, 264, 34,  0,  0 },
++    { 8896, 5920, 160, 64,  0,  0 },
++  };
++  static const struct {
++    ushort id;
++    char model[20];
++  } unique[] = {
++    { 0x168, "EOS 10D" },    { 0x001, "EOS-1D" },
++    { 0x175, "EOS 20D" },    { 0x174, "EOS-1D Mark II" },
++    { 0x234, "EOS 30D" },    { 0x232, "EOS-1D Mark II N" },
++    { 0x190, "EOS 40D" },    { 0x169, "EOS-1D Mark III" },
++    { 0x261, "EOS 50D" },    { 0x281, "EOS-1D Mark IV" },
++    { 0x287, "EOS 60D" },    { 0x167, "EOS-1DS" },
++    { 0x325, "EOS 70D" },
++    { 0x350, "EOS 80D" },    { 0x328, "EOS-1D X Mark II" },
++    { 0x170, "EOS 300D" },   { 0x188, "EOS-1Ds Mark II" },
++    { 0x176, "EOS 450D" },   { 0x215, "EOS-1Ds Mark III" },
++    { 0x189, "EOS 350D" },   { 0x324, "EOS-1D C" },
++    { 0x236, "EOS 400D" },   { 0x269, "EOS-1D X" },
++    { 0x252, "EOS 500D" },   { 0x213, "EOS 5D" },
++    { 0x270, "EOS 550D" },   { 0x218, "EOS 5D Mark II" },
++    { 0x286, "EOS 600D" },   { 0x285, "EOS 5D Mark III" },
++    { 0x301, "EOS 650D" },   { 0x302, "EOS 6D" },
++    { 0x326, "EOS 700D" },   { 0x250, "EOS 7D" },
++    { 0x393, "EOS 750D" },   { 0x289, "EOS 7D Mark II" },
++    { 0x347, "EOS 760D" },
++    { 0x254, "EOS 1000D" },
++    { 0x288, "EOS 1100D" },
++    { 0x327, "EOS 1200D" },  { 0x382, "Canon EOS 5DS" },
++    { 0x404, "EOS 1300D" },  { 0x401, "Canon EOS 5DS R" },
++    { 0x346, "EOS 100D" },
++  }, sonique[] = {
++    { 0x002, "DSC-R1" },     { 0x100, "DSLR-A100" },
++    { 0x101, "DSLR-A900" },  { 0x102, "DSLR-A700" },
++    { 0x103, "DSLR-A200" },  { 0x104, "DSLR-A350" },
++    { 0x105, "DSLR-A300" },  { 0x108, "DSLR-A330" },
++    { 0x109, "DSLR-A230" },  { 0x10a, "DSLR-A290" },
++    { 0x10d, "DSLR-A850" },  { 0x111, "DSLR-A550" },
++    { 0x112, "DSLR-A500" },  { 0x113, "DSLR-A450" },
++    { 0x116, "NEX-5" },      { 0x117, "NEX-3" },
++    { 0x118, "SLT-A33" },    { 0x119, "SLT-A55V" },
++    { 0x11a, "DSLR-A560" },  { 0x11b, "DSLR-A580" },
++    { 0x11c, "NEX-C3" },     { 0x11d, "SLT-A35" },
++    { 0x11e, "SLT-A65V" },   { 0x11f, "SLT-A77V" },
++    { 0x120, "NEX-5N" },     { 0x121, "NEX-7" },
++    { 0x123, "SLT-A37" },    { 0x124, "SLT-A57" },
++    { 0x125, "NEX-F3" },     { 0x126, "SLT-A99V" },
++    { 0x127, "NEX-6" },      { 0x128, "NEX-5R" },
++    { 0x129, "DSC-RX100" },  { 0x12a, "DSC-RX1" },
++    { 0x12e, "ILCE-3000" },  { 0x12f, "SLT-A58" },
++    { 0x131, "NEX-3N" },     { 0x132, "ILCE-7" },
++    { 0x133, "NEX-5T" },     { 0x134, "DSC-RX100M2" },
++    { 0x135, "DSC-RX10" },   { 0x136, "DSC-RX1R" },
++    { 0x137, "ILCE-7R" },    { 0x138, "ILCE-6000" },
++    { 0x139, "ILCE-5000" },  { 0x13d, "DSC-RX100M3" },
++    { 0x13e, "ILCE-7S" },    { 0x13f, "ILCA-77M2" },
++    { 0x153, "ILCE-5100" },  { 0x154, "ILCE-7M2" },
++    { 0x155, "DSC-RX100M4" },{ 0x156, "DSC-RX10M2" },
++    { 0x158, "DSC-RX1RM2" }, { 0x15a, "ILCE-QX1" },
++    { 0x15b, "ILCE-7RM2" },  { 0x15e, "ILCE-7SM2" },
++    { 0x161, "ILCA-68" },    { 0x165, "ILCE-6300" },
++  };
++  static const struct {
++    unsigned fsize;
++    ushort rw, rh;
++    uchar lm, tm, rm, bm, lf, cf, max, flags;
++    char make[10], model[20];
++    ushort offset;
++  } table[] = {
++    {   786432,1024, 768, 0, 0, 0, 0, 0,0x94,0,0,"AVT","F-080C" },
++    {  1447680,1392,1040, 0, 0, 0, 0, 0,0x94,0,0,"AVT","F-145C" },
++    {  1920000,1600,1200, 0, 0, 0, 0, 0,0x94,0,0,"AVT","F-201C" },
++    {  5067304,2588,1958, 0, 0, 0, 0, 0,0x94,0,0,"AVT","F-510C" },
++    {  5067316,2588,1958, 0, 0, 0, 0, 0,0x94,0,0,"AVT","F-510C",12 },
++    { 10134608,2588,1958, 0, 0, 0, 0, 9,0x94,0,0,"AVT","F-510C" },
++    { 10134620,2588,1958, 0, 0, 0, 0, 9,0x94,0,0,"AVT","F-510C",12 },
++    { 16157136,3272,2469, 0, 0, 0, 0, 9,0x94,0,0,"AVT","F-810C" },
++    { 15980544,3264,2448, 0, 0, 0, 0, 8,0x61,0,1,"AgfaPhoto","DC-833m" },
++    {  9631728,2532,1902, 0, 0, 0, 0,96,0x61,0,0,"Alcatel","5035D" },
++    {  2868726,1384,1036, 0, 0, 0, 0,64,0x49,0,8,"Baumer","TXG14",1078 },
++    {  5298000,2400,1766,12,12,44, 2,40,0x94,0,2,"Canon","PowerShot SD300" },
++    {  6553440,2664,1968, 4, 4,44, 4,40,0x94,0,2,"Canon","PowerShot A460" },
++    {  6573120,2672,1968,12, 8,44, 0,40,0x94,0,2,"Canon","PowerShot A610" },
++    {  6653280,2672,1992,10, 6,42, 2,40,0x94,0,2,"Canon","PowerShot A530" },
++    {  7710960,2888,2136,44, 8, 4, 0,40,0x94,0,2,"Canon","PowerShot S3 IS" },
++    {  9219600,3152,2340,36,12, 4, 0,40,0x94,0,2,"Canon","PowerShot A620" },
++    {  9243240,3152,2346,12, 7,44,13,40,0x49,0,2,"Canon","PowerShot A470" },
++    { 10341600,3336,2480, 6, 5,32, 3,40,0x94,0,2,"Canon","PowerShot A720 IS" },
++    { 10383120,3344,2484,12, 6,44, 6,40,0x94,0,2,"Canon","PowerShot A630" },
++    { 12945240,3736,2772,12, 6,52, 6,40,0x94,0,2,"Canon","PowerShot A640" },
++    { 15636240,4104,3048,48,12,24,12,40,0x94,0,2,"Canon","PowerShot A650" },
++    { 15467760,3720,2772, 6,12,30, 0,40,0x94,0,2,"Canon","PowerShot SX110 IS" },
++    { 15534576,3728,2778,12, 9,44, 9,40,0x94,0,2,"Canon","PowerShot SX120 IS" },
++    { 18653760,4080,3048,24,12,24,12,40,0x94,0,2,"Canon","PowerShot SX20 IS" },
++    { 19131120,4168,3060,92,16, 4, 1,40,0x94,0,2,"Canon","PowerShot SX220 HS" },
++    { 21936096,4464,3276,25,10,73,12,40,0x16,0,2,"Canon","PowerShot SX30 IS" },
++    { 24724224,4704,3504, 8,16,56, 8,40,0x94,0,2,"Canon","PowerShot A3300 IS" },
++    { 30858240,5248,3920, 8,16,56,16,40,0x94,0,2,"Canon","IXUS 160" },
++    {  1976352,1632,1211, 0, 2, 0, 1, 0,0x94,0,1,"Casio","QV-2000UX" },
++    {  3217760,2080,1547, 0, 0,10, 1, 0,0x94,0,1,"Casio","QV-3*00EX" },
++    {  6218368,2585,1924, 0, 0, 9, 0, 0,0x94,0,1,"Casio","QV-5700" },
++    {  7816704,2867,2181, 0, 0,34,36, 0,0x16,0,1,"Casio","EX-Z60" },
++    {  2937856,1621,1208, 0, 0, 1, 0, 0,0x94,7,13,"Casio","EX-S20" },
++    {  4948608,2090,1578, 0, 0,32,34, 0,0x94,7,1,"Casio","EX-S100" },
++    {  6054400,2346,1720, 2, 0,32, 0, 0,0x94,7,1,"Casio","QV-R41" },
++    {  7426656,2568,1928, 0, 0, 0, 0, 0,0x94,0,1,"Casio","EX-P505" },
++    {  7530816,2602,1929, 0, 0,22, 0, 0,0x94,7,1,"Casio","QV-R51" },
++    {  7542528,2602,1932, 0, 0,32, 0, 0,0x94,7,1,"Casio","EX-Z50" },
++    {  7562048,2602,1937, 0, 0,25, 0, 0,0x16,7,1,"Casio","EX-Z500" },
++    {  7753344,2602,1986, 0, 0,32,26, 0,0x94,7,1,"Casio","EX-Z55" },
++    {  9313536,2858,2172, 0, 0,14,30, 0,0x94,7,1,"Casio","EX-P600" },
++    { 10834368,3114,2319, 0, 0,27, 0, 0,0x94,0,1,"Casio","EX-Z750" },
++    { 10843712,3114,2321, 0, 0,25, 0, 0,0x94,0,1,"Casio","EX-Z75" },
++    { 10979200,3114,2350, 0, 0,32,32, 0,0x94,7,1,"Casio","EX-P700" },
++    { 12310144,3285,2498, 0, 0, 6,30, 0,0x94,0,1,"Casio","EX-Z850" },
++    { 12489984,3328,2502, 0, 0,47,35, 0,0x94,0,1,"Casio","EX-Z8" },
++    { 15499264,3754,2752, 0, 0,82, 0, 0,0x94,0,1,"Casio","EX-Z1050" },
++    { 18702336,4096,3044, 0, 0,24, 0,80,0x94,7,1,"Casio","EX-ZR100" },
++    {  7684000,2260,1700, 0, 0, 0, 0,13,0x94,0,1,"Casio","QV-4000" },
++    {   787456,1024, 769, 0, 1, 0, 0, 0,0x49,0,0,"Creative","PC-CAM 600" },
++    { 28829184,4384,3288, 0, 0, 0, 0,36,0x61,0,0,"DJI" },
++    { 15151104,4608,3288, 0, 0, 0, 0, 0,0x94,0,0,"Matrix" },
++    {  3840000,1600,1200, 0, 0, 0, 0,65,0x49,0,0,"Foculus","531C" },
++    {   307200, 640, 480, 0, 0, 0, 0, 0,0x94,0,0,"Generic" },
++    {    62464, 256, 244, 1, 1, 6, 1, 0,0x8d,0,0,"Kodak","DC20" },
++    {   124928, 512, 244, 1, 1,10, 1, 0,0x8d,0,0,"Kodak","DC20" },
++    {  1652736,1536,1076, 0,52, 0, 0, 0,0x61,0,0,"Kodak","DCS200" },
++    {  4159302,2338,1779, 1,33, 1, 2, 0,0x94,0,0,"Kodak","C330" },
++    {  4162462,2338,1779, 1,33, 1, 2, 0,0x94,0,0,"Kodak","C330",3160 },
++    {  2247168,1232, 912, 0, 0,16, 0, 0,0x00,0,0,"Kodak","C330" },
++    {  3370752,1232, 912, 0, 0,16, 0, 0,0x00,0,0,"Kodak","C330" },
++    {  6163328,2864,2152, 0, 0, 0, 0, 0,0x94,0,0,"Kodak","C603" },
++    {  6166488,2864,2152, 0, 0, 0, 0, 0,0x94,0,0,"Kodak","C603",3160 },
++    {   460800, 640, 480, 0, 0, 0, 0, 0,0x00,0,0,"Kodak","C603" },
++    {  9116448,2848,2134, 0, 0, 0, 0, 0,0x00,0,0,"Kodak","C603" },
++    { 12241200,4040,3030, 2, 0, 0,13, 0,0x49,0,0,"Kodak","12MP" },
++    { 12272756,4040,3030, 2, 0, 0,13, 0,0x49,0,0,"Kodak","12MP",31556 },
++    { 18000000,4000,3000, 0, 0, 0, 0, 0,0x00,0,0,"Kodak","12MP" },
++    {   614400, 640, 480, 0, 3, 0, 0,64,0x94,0,0,"Kodak","KAI-0340" },
++    { 15360000,3200,2400, 0, 0, 0, 0,96,0x16,0,0,"Lenovo","A820" },
++    {  3884928,1608,1207, 0, 0, 0, 0,96,0x16,0,0,"Micron","2010",3212 },
++    {  1138688,1534, 986, 0, 0, 0, 0, 0,0x61,0,0,"Minolta","RD175",513 },
++    {  1581060,1305, 969, 0, 0,18, 6, 6,0x1e,4,1,"Nikon","E900" },
++    {  2465792,1638,1204, 0, 0,22, 1, 6,0x4b,5,1,"Nikon","E950" },
++    {  2940928,1616,1213, 0, 0, 0, 7,30,0x94,0,1,"Nikon","E2100" },
++    {  4771840,2064,1541, 0, 0, 0, 1, 6,0xe1,0,1,"Nikon","E990" },
++    {  4775936,2064,1542, 0, 0, 0, 0,30,0x94,0,1,"Nikon","E3700" },
++    {  5865472,2288,1709, 0, 0, 0, 1, 6,0xb4,0,1,"Nikon","E4500" },
++    {  5869568,2288,1710, 0, 0, 0, 0, 6,0x16,0,1,"Nikon","E4300" },
++    {  7438336,2576,1925, 0, 0, 0, 1, 6,0xb4,0,1,"Nikon","E5000" },
++    {  8998912,2832,2118, 0, 0, 0, 0,30,0x94,7,1,"Nikon","COOLPIX S6" },
++    {  5939200,2304,1718, 0, 0, 0, 0,30,0x16,0,0,"Olympus","C770UZ" },
++    {  3178560,2064,1540, 0, 0, 0, 0, 0,0x94,0,1,"Pentax","Optio S" },
++    {  4841984,2090,1544, 0, 0,22, 0, 0,0x94,7,1,"Pentax","Optio S" },
++    {  6114240,2346,1737, 0, 0,22, 0, 0,0x94,7,1,"Pentax","Optio S4" },
++    { 10702848,3072,2322, 0, 0, 0,21,30,0x94,0,1,"Pentax","Optio 750Z" },
++    {  4147200,1920,1080, 0, 0, 0, 0, 0,0x49,0,0,"Photron","BC2-HD" },
++    {  4151666,1920,1080, 0, 0, 0, 0, 0,0x49,0,0,"Photron","BC2-HD",8 },
++    { 13248000,2208,3000, 0, 0, 0, 0,13,0x61,0,0,"Pixelink","A782" },
++    {  6291456,2048,1536, 0, 0, 0, 0,96,0x61,0,0,"RoverShot","3320AF" },
++    {   311696, 644, 484, 0, 0, 0, 0, 0,0x16,0,8,"ST Micro","STV680 VGA" },
++    { 16098048,3288,2448, 0, 0,24, 0, 9,0x94,0,1,"Samsung","S85" },
++    { 16215552,3312,2448, 0, 0,48, 0, 9,0x94,0,1,"Samsung","S85" },
++    { 20487168,3648,2808, 0, 0, 0, 0,13,0x94,5,1,"Samsung","WB550" },
++    { 24000000,4000,3000, 0, 0, 0, 0,13,0x94,5,1,"Samsung","WB550" },
++    { 12582980,3072,2048, 0, 0, 0, 0,33,0x61,0,0,"Sinar","",68 },
++    { 33292868,4080,4080, 0, 0, 0, 0,33,0x61,0,0,"Sinar","",68 },
++    { 44390468,4080,5440, 0, 0, 0, 0,33,0x61,0,0,"Sinar","",68 },
++    {  1409024,1376,1024, 0, 0, 1, 0, 0,0x49,0,0,"Sony","XCD-SX910CR" },
++    {  2818048,1376,1024, 0, 0, 1, 0,97,0x49,0,0,"Sony","XCD-SX910CR" },
++  };
++  static const char *corp[] =
++    { "AgfaPhoto", "Canon", "Casio", "Epson", "Fujifilm",
++      "Mamiya", "Minolta", "Motorola", "Kodak", "Konica", "Leica",
++      "Nikon", "Nokia", "Olympus", "Ricoh", "Pentax", "Phase One",
++      "Samsung", "Sigma", "Sinar", "Sony" };
++  char head[32], *cp;
++  int hlen, flen, fsize, zero_fsize=1, i, c;
++  struct jhead jh;
++
++  tiff_flip = flip = filters = UINT_MAX;	/* unknown */
++  raw_height = raw_width = fuji_width = fuji_layout = cr2_slice[0] = 0;
++  maximum = height = width = top_margin = left_margin = 0;
++  cdesc[0] = desc[0] = artist[0] = make[0] = model[0] = model2[0] = 0;
++  iso_speed = shutter = aperture = focal_len = unique_id = 0;
++  tiff_nifds = 0;
++  memset (tiff_ifd, 0, sizeof tiff_ifd);
++  memset (gpsdata, 0, sizeof gpsdata);
++  memset (cblack, 0, sizeof cblack);
++  memset (white, 0, sizeof white);
++  memset (mask, 0, sizeof mask);
++  thumb_offset = thumb_length = thumb_width = thumb_height = 0;
++  load_raw = thumb_load_raw = 0;
++  write_thumb = &CLASS jpeg_thumb;
++  data_offset = meta_offset = meta_length = tiff_bps = tiff_compress = 0;
++  kodak_cbpp = zero_after_ff = dng_version = load_flags = 0;
++  timestamp = shot_order = tiff_samples = black = is_foveon = 0;
++  mix_green = profile_length = data_error = zero_is_bad = 0;
++  pixel_aspect = is_raw = raw_color = 1;
++  tile_width = tile_length = 0;
++  for (i=0; i < 4; i++) {
++    cam_mul[i] = i == 1;
++    pre_mul[i] = i < 3;
++    FORC3 cmatrix[c][i] = 0;
++    FORC3 rgb_cam[c][i] = c == i;
++  }
++  colors = 3;
++  for (i=0; i < 0x10000; i++) curve[i] = i;
++
++  order = get2();
++  hlen = get4();
++  fseek (ifp, 0, SEEK_SET);
++  fread (head, 1, 32, ifp);
++  fseek (ifp, 0, SEEK_END);
++  flen = fsize = ftell(ifp);
++  if ((cp = (char *) memmem (head, 32, "MMMM", 4)) ||
++      (cp = (char *) memmem (head, 32, "IIII", 4))) {
++    parse_phase_one (cp-head);
++    if (cp-head && parse_tiff(0)) apply_tiff();
++  } else if (order == 0x4949 || order == 0x4d4d) {
++    if (!memcmp (head+6,"HEAPCCDR",8)) {
++      data_offset = hlen;
++      parse_ciff (hlen, flen-hlen, 0);
++      load_raw = &CLASS canon_load_raw;
++    } else if (parse_tiff(0)) apply_tiff();
++  } else if (!memcmp (head,"\xff\xd8\xff\xe1",4) &&
++	     !memcmp (head+6,"Exif",4)) {
++    fseek (ifp, 4, SEEK_SET);
++    data_offset = 4 + get2();
++    fseek (ifp, data_offset, SEEK_SET);
++    if (fgetc(ifp) != 0xff)
++      parse_tiff(12);
++    thumb_offset = 0;
++  } else if (!memcmp (head+25,"ARECOYK",7)) {
++    strcpy (make, "Contax");
++    strcpy (model,"N Digital");
++    fseek (ifp, 33, SEEK_SET);
++    get_timestamp(1);
++    fseek (ifp, 60, SEEK_SET);
++    FORC4 cam_mul[c ^ (c >> 1)] = get4();
++  } else if (!strcmp (head, "PXN")) {
++    strcpy (make, "Logitech");
++    strcpy (model,"Fotoman Pixtura");
++  } else if (!strcmp (head, "qktk")) {
++    strcpy (make, "Apple");
++    strcpy (model,"QuickTake 100");
++    load_raw = &CLASS quicktake_100_load_raw;
++  } else if (!strcmp (head, "qktn")) {
++    strcpy (make, "Apple");
++    strcpy (model,"QuickTake 150");
++    load_raw = &CLASS kodak_radc_load_raw;
++  } else if (!memcmp (head,"FUJIFILM",8)) {
++    fseek (ifp, 84, SEEK_SET);
++    thumb_offset = get4();
++    thumb_length = get4();
++    fseek (ifp, 92, SEEK_SET);
++    parse_fuji (get4());
++    if (thumb_offset > 120) {
++      fseek (ifp, 120, SEEK_SET);
++      is_raw += (i = get4()) && 1;
++      if (is_raw == 2 && shot_select)
++	parse_fuji (i);
++    }
++    load_raw = &CLASS unpacked_load_raw;
++    fseek (ifp, 100+28*(shot_select > 0), SEEK_SET);
++    parse_tiff (data_offset = get4());
++    parse_tiff (thumb_offset+12);
++    apply_tiff();
++  } else if (!memcmp (head,"RIFF",4)) {
++    fseek (ifp, 0, SEEK_SET);
++    parse_riff();
++  } else if (!memcmp (head+4,"ftypqt   ",9)) {
++    fseek (ifp, 0, SEEK_SET);
++    parse_qt (fsize);
++    is_raw = 0;
++  } else if (!memcmp (head,"\0\001\0\001\0@",6)) {
++    fseek (ifp, 6, SEEK_SET);
++    fread (make, 1, 8, ifp);
++    fread (model, 1, 8, ifp);
++    fread (model2, 1, 16, ifp);
++    data_offset = get2();
++    get2();
++    raw_width = get2();
++    raw_height = get2();
++    load_raw = &CLASS nokia_load_raw;
++    filters = 0x61616161;
++  } else if (!memcmp (head,"NOKIARAW",8)) {
++    strcpy (make, "NOKIA");
++    order = 0x4949;
++    fseek (ifp, 300, SEEK_SET);
++    data_offset = get4();
++    i = get4();
++    width = get2();
++    height = get2();
++    switch (tiff_bps = i*8 / (width * height)) {
++      case  8: load_raw = &CLASS eight_bit_load_raw;  break;
++      case 10: load_raw = &CLASS nokia_load_raw;
++    }
++    raw_height = height + (top_margin = i / (width * tiff_bps/8) - height);
++    mask[0][3] = 1;
++    filters = 0x61616161;
++  } else if (!memcmp (head,"ARRI",4)) {
++    order = 0x4949;
++    fseek (ifp, 20, SEEK_SET);
++    width = get4();
++    height = get4();
++    strcpy (make, "ARRI");
++    fseek (ifp, 668, SEEK_SET);
++    fread (model, 1, 64, ifp);
++    data_offset = 4096;
++    load_raw = &CLASS packed_load_raw;
++    load_flags = 88;
++    filters = 0x61616161;
++  } else if (!memcmp (head,"XPDS",4)) {
++    order = 0x4949;
++    fseek (ifp, 0x800, SEEK_SET);
++    fread (make, 1, 41, ifp);
++    raw_height = get2();
++    raw_width  = get2();
++    fseek (ifp, 56, SEEK_CUR);
++    fread (model, 1, 30, ifp);
++    data_offset = 0x10000;
++    load_raw = &CLASS canon_rmf_load_raw;
++    gamma_curve (0, 12.25, 1, 1023);
++  } else if (!memcmp (head+4,"RED1",4)) {
++    strcpy (make, "Red");
++    strcpy (model,"One");
++    parse_redcine();
++    load_raw = &CLASS redcine_load_raw;
++    gamma_curve (1/2.4, 12.92, 1, 4095);
++    filters = 0x49494949;
++  } else if (!memcmp (head,"DSC-Image",9))
++    parse_rollei();
++  else if (!memcmp (head,"PWAD",4))
++    parse_sinar_ia();
++  else if (!memcmp (head,"\0MRM",4))
++    parse_minolta(0);
++  else if (!memcmp (head,"FOVb",4))
++    parse_foveon();
++  else if (!memcmp (head,"CI",2))
++    parse_cine();
++  if (make[0] == 0)
++    for (zero_fsize=i=0; i < sizeof table / sizeof *table; i++)
++      if (fsize == table[i].fsize) {
++	strcpy (make,  table[i].make );
++	strcpy (model, table[i].model);
++	flip = table[i].flags >> 2;
++	zero_is_bad = table[i].flags & 2;
++	if (table[i].flags & 1)
++	  parse_external_jpeg();
++	data_offset = table[i].offset;
++	raw_width   = table[i].rw;
++	raw_height  = table[i].rh;
++	left_margin = table[i].lm;
++	 top_margin = table[i].tm;
++	width  = raw_width - left_margin - table[i].rm;
++	height = raw_height - top_margin - table[i].bm;
++	filters = 0x1010101 * table[i].cf;
++	colors = 4 - !((filters & filters >> 1) & 0x5555);
++	load_flags = table[i].lf;
++	switch (tiff_bps = (fsize-data_offset)*8 / (raw_width*raw_height)) {
++	  case 6:
++	    load_raw = &CLASS minolta_rd175_load_raw;  break;
++	  case 8:
++	    load_raw = &CLASS eight_bit_load_raw;  break;
++	  case 10: case 12:
++	    load_flags |= 128;
++	    load_raw = &CLASS packed_load_raw;     break;
++	  case 16:
++	    order = 0x4949 | 0x404 * (load_flags & 1);
++	    tiff_bps -= load_flags >> 4;
++	    tiff_bps -= load_flags = load_flags >> 1 & 7;
++	    load_raw = &CLASS unpacked_load_raw;
++	}
++	maximum = (1 << tiff_bps) - (1 << table[i].max);
++      }
++  if (zero_fsize) fsize = 0;
++  if (make[0] == 0) parse_smal (0, flen);
++  if (make[0] == 0) {
++    parse_jpeg(0);
++    if (!(strncmp(model,"ov",2) && strncmp(model,"RP_OV",5)) &&
++	!fseek (ifp, -6404096, SEEK_END) &&
++	fread (head, 1, 32, ifp) && !strcmp(head,"BRCMn")) {
++      strcpy (make, "OmniVision");
++      data_offset = ftell(ifp) + 0x8000-32;
++      width = raw_width;
++      raw_width = 2611;
++      load_raw = &CLASS nokia_load_raw;
++      filters = 0x16161616;
++    } else is_raw = 0;
++  }
++
++  for (i=0; i < sizeof corp / sizeof *corp; i++)
++    if (strcasestr (make, corp[i]))	/* Simplify company names */
++	    strcpy (make, corp[i]);
++  if ((!strcmp(make,"Kodak") || !strcmp(make,"Leica")) &&
++	((cp = strcasestr(model," DIGITAL CAMERA")) ||
++	 (cp = strstr(model,"FILE VERSION"))))
++     *cp = 0;
++  if (!strncasecmp(model,"PENTAX",6))
++    strcpy (make, "Pentax");
++  cp = make + strlen(make);		/* Remove trailing spaces */
++  while (*--cp == ' ') *cp = 0;
++  cp = model + strlen(model);
++  while (*--cp == ' ') *cp = 0;
++  i = strlen(make);			/* Remove make from model */
++  if (!strncasecmp (model, make, i) && model[i++] == ' ')
++    memmove (model, model+i, 64-i);
++  if (!strncmp (model,"FinePix ",8))
++    strcpy (model, model+8);
++  if (!strncmp (model,"Digital Camera ",15))
++    strcpy (model, model+15);
++  desc[511] = artist[63] = make[63] = model[63] = model2[63] = 0;
++  if (!is_raw) goto notraw;
++
++  if (!height) height = raw_height;
++  if (!width)  width  = raw_width;
++  if (height == 2624 && width == 3936)	/* Pentax K10D and Samsung GX10 */
++    { height  = 2616;   width  = 3896; }
++  if (height == 3136 && width == 4864)  /* Pentax K20D and Samsung GX20 */
++    { height  = 3124;   width  = 4688; filters = 0x16161616; }
++  if (width == 4352 && (!strcmp(model,"K-r") || !strcmp(model,"K-x")))
++    {			width  = 4309; filters = 0x16161616; }
++  if (width >= 4960 && !strncmp(model,"K-5",3))
++    { left_margin = 10; width  = 4950; filters = 0x16161616; }
++  if (width == 4736 && !strcmp(model,"K-7"))
++    { height  = 3122;   width  = 4684; filters = 0x16161616; top_margin = 2; }
++  if (width == 6080 && !strcmp(model,"K-3"))
++    { left_margin = 4;  width  = 6040; }
++  if (width == 7424 && !strcmp(model,"645D"))
++    { height  = 5502;   width  = 7328; filters = 0x61616161; top_margin = 29;
++      left_margin = 48; }
++  if (height == 3014 && width == 4096)	/* Ricoh GX200 */
++			width  = 4014;
++  if (dng_version) {
++    if (filters == UINT_MAX) filters = 0;
++    if (filters) is_raw *= tiff_samples;
++    else	 colors  = tiff_samples;
++    switch (tiff_compress) {
++      case 0:
++      case 1:     load_raw = &CLASS   packed_dng_load_raw;  break;
++      case 7:     load_raw = &CLASS lossless_dng_load_raw;  break;
++      case 34892: load_raw = &CLASS    lossy_dng_load_raw;  break;
++      default:    load_raw = 0;
++    }
++    goto dng_skip;
++  }
++  if (!strcmp(make,"Canon") && !fsize && tiff_bps != 15) {
++    if (!load_raw)
++      load_raw = &CLASS lossless_jpeg_load_raw;
++    for (i=0; i < sizeof canon / sizeof *canon; i++)
++      if (raw_width == canon[i][0] && raw_height == canon[i][1]) {
++	width  = raw_width - (left_margin = canon[i][2]);
++	height = raw_height - (top_margin = canon[i][3]);
++	width  -= canon[i][4];
++	height -= canon[i][5];
++	mask[0][1] =  canon[i][6];
++	mask[0][3] = -canon[i][7];
++	mask[1][1] =  canon[i][8];
++	mask[1][3] = -canon[i][9];
++	if (canon[i][10]) filters = canon[i][10] * 0x01010101;
++      }
++    if ((unique_id | 0x20000) == 0x2720000) {
++      left_margin = 8;
++      top_margin = 16;
++    }
++  }
++  for (i=0; i < sizeof unique / sizeof *unique; i++)
++    if (unique_id == 0x80000000 + unique[i].id) {
++      adobe_coeff ("Canon", unique[i].model);
++      if (model[4] == 'K' && strlen(model) == 8)
++	strcpy (model, unique[i].model);
++    }
++  for (i=0; i < sizeof sonique / sizeof *sonique; i++)
++    if (unique_id == sonique[i].id)
++      strcpy (model, sonique[i].model);
++  if (!strcmp(make,"Nikon")) {
++    if (!load_raw)
++      load_raw = &CLASS packed_load_raw;
++    if (model[0] == 'E')
++      load_flags |= !data_offset << 2 | 2;
++  }
++
++/* Set parameters based on camera name (for non-DNG files). */
++
++  if (!strcmp(model,"KAI-0340")
++	&& find_green (16, 16, 3840, 5120) < 25) {
++    height = 480;
++    top_margin = filters = 0;
++    strcpy (model,"C603");
++  }
++  if (!strcmp(make,"Sony") && raw_width > 3888)
++    black = 128 << (tiff_bps - 12);
++  if (is_foveon) {
++    if (height*2 < width) pixel_aspect = 0.5;
++    if (height   > width) pixel_aspect = 2;
++    filters = 0;
++    simple_coeff(0);
++  } else if (!strcmp(make,"Canon") && tiff_bps == 15) {
++    switch (width) {
++      case 3344: width -= 66;
++      case 3872: width -= 6;
++    }
++    if (height > width) {
++      SWAP(height,width);
++      SWAP(raw_height,raw_width);
++    }
++    if (width == 7200 && height == 3888) {
++      raw_width  = width  = 6480;
++      raw_height = height = 4320;
++    }
++    filters = 0;
++    tiff_samples = colors = 3;
++    load_raw = &CLASS canon_sraw_load_raw;
++  } else if (!strcmp(model,"PowerShot 600")) {
++    height = 613;
++    width  = 854;
++    raw_width = 896;
++    colors = 4;
++    filters = 0xe1e4e1e4;
++    load_raw = &CLASS canon_600_load_raw;
++  } else if (!strcmp(model,"PowerShot A5") ||
++	     !strcmp(model,"PowerShot A5 Zoom")) {
++    height = 773;
++    width  = 960;
++    raw_width = 992;
++    pixel_aspect = 256/235.0;
++    filters = 0x1e4e1e4e;
++    goto canon_a5;
++  } else if (!strcmp(model,"PowerShot A50")) {
++    height =  968;
++    width  = 1290;
++    raw_width = 1320;
++    filters = 0x1b4e4b1e;
++    goto canon_a5;
++  } else if (!strcmp(model,"PowerShot Pro70")) {
++    height = 1024;
++    width  = 1552;
++    filters = 0x1e4b4e1b;
++canon_a5:
++    colors = 4;
++    tiff_bps = 10;
++    load_raw = &CLASS packed_load_raw;
++    load_flags = 40;
++  } else if (!strcmp(model,"PowerShot Pro90 IS") ||
++	     !strcmp(model,"PowerShot G1")) {
++    colors = 4;
++    filters = 0xb4b4b4b4;
++  } else if (!strcmp(model,"PowerShot A610")) {
++    if (canon_s2is()) strcpy (model+10, "S2 IS");
++  } else if (!strcmp(model,"PowerShot SX220 HS")) {
++    mask[1][3] = -4;
++  } else if (!strcmp(model,"EOS D2000C")) {
++    filters = 0x61616161;
++    black = curve[200];
++  } else if (!strcmp(model,"D1")) {
++    cam_mul[0] *= 256/527.0;
++    cam_mul[2] *= 256/317.0;
++  } else if (!strcmp(model,"D1X")) {
++    width -= 4;
++    pixel_aspect = 0.5;
++  } else if (!strcmp(model,"D40X") ||
++	     !strcmp(model,"D60")  ||
++	     !strcmp(model,"D80")  ||
++	     !strcmp(model,"D3000")) {
++    height -= 3;
++    width  -= 4;
++  } else if (!strcmp(model,"D3")   ||
++	     !strcmp(model,"D3S")  ||
++	     !strcmp(model,"D700")) {
++    width -= 4;
++    left_margin = 2;
++  } else if (!strcmp(model,"D3100")) {
++    width -= 28;
++    left_margin = 6;
++  } else if (!strcmp(model,"D5000") ||
++	     !strcmp(model,"D90")) {
++    width -= 42;
++  } else if (!strcmp(model,"D5100") ||
++	     !strcmp(model,"D7000") ||
++	     !strcmp(model,"COOLPIX A")) {
++    width -= 44;
++  } else if (!strcmp(model,"D3200") ||
++	    !strncmp(model,"D6",2)  ||
++	    !strncmp(model,"D800",4)) {
++    width -= 46;
++  } else if (!strcmp(model,"D4") ||
++	     !strcmp(model,"Df")) {
++    width -= 52;
++    left_margin = 2;
++  } else if (!strncmp(model,"D40",3) ||
++	     !strncmp(model,"D50",3) ||
++	     !strncmp(model,"D70",3)) {
++    width--;
++  } else if (!strcmp(model,"D100")) {
++    if (load_flags)
++      raw_width = (width += 3) + 3;
++  } else if (!strcmp(model,"D200")) {
++    left_margin = 1;
++    width -= 4;
++    filters = 0x94949494;
++  } else if (!strncmp(model,"D2H",3)) {
++    left_margin = 6;
++    width -= 14;
++  } else if (!strncmp(model,"D2X",3)) {
++    if (width == 3264) width -= 32;
++    else width -= 8;
++  } else if (!strncmp(model,"D300",4)) {
++    width -= 32;
++  } else if (!strncmp(model,"COOLPIX P",9) && raw_width != 4032) {
++    load_flags = 24;
++    filters = 0x94949494;
++    if (model[9] == '7' && iso_speed >= 400)
++      black = 255;
++  } else if (!strncmp(model,"1 ",2)) {
++    height -= 2;
++  } else if (fsize == 1581060) {
++    simple_coeff(3);
++    pre_mul[0] = 1.2085;
++    pre_mul[1] = 1.0943;
++    pre_mul[3] = 1.1103;
++  } else if (fsize == 3178560) {
++    cam_mul[0] *= 4;
++    cam_mul[2] *= 4;
++  } else if (fsize == 4771840) {
++    if (!timestamp && nikon_e995())
++      strcpy (model, "E995");
++    if (strcmp(model,"E995")) {
++      filters = 0xb4b4b4b4;
++      simple_coeff(3);
++      pre_mul[0] = 1.196;
++      pre_mul[1] = 1.246;
++      pre_mul[2] = 1.018;
++    }
++  } else if (fsize == 2940928) {
++    if (!timestamp && !nikon_e2100())
++      strcpy (model,"E2500");
++    if (!strcmp(model,"E2500")) {
++      height -= 2;
++      load_flags = 6;
++      colors = 4;
++      filters = 0x4b4b4b4b;
++    }
++  } else if (fsize == 4775936) {
++    if (!timestamp) nikon_3700();
++    if (model[0] == 'E' && atoi(model+1) < 3700)
++      filters = 0x49494949;
++    if (!strcmp(model,"Optio 33WR")) {
++      flip = 1;
++      filters = 0x16161616;
++    }
++    if (make[0] == 'O') {
++      i = find_green (12, 32, 1188864, 3576832);
++      c = find_green (12, 32, 2383920, 2387016);
++      if (abs(i) < abs(c)) {
++	SWAP(i,c);
++	load_flags = 24;
++      }
++      if (i < 0) filters = 0x61616161;
++    }
++  } else if (fsize == 5869568) {
++    if (!timestamp && minolta_z2()) {
++      strcpy (make, "Minolta");
++      strcpy (model,"DiMAGE Z2");
++    }
++    load_flags = 6 + 24*(make[0] == 'M');
++  } else if (fsize == 6291456) {
++    fseek (ifp, 0x300000, SEEK_SET);
++    if ((order = guess_byte_order(0x10000)) == 0x4d4d) {
++      height -= (top_margin = 16);
++      width -= (left_margin = 28);
++      maximum = 0xf5c0;
++      strcpy (make, "ISG");
++      model[0] = 0;
++    }
++  } else if (!strcmp(make,"Fujifilm")) {
++    if (!strcmp(model+7,"S2Pro")) {
++      strcpy (model,"S2Pro");
++      height = 2144;
++      width  = 2880;
++      flip = 6;
++    } else if (load_raw != &CLASS packed_load_raw)
++      maximum = (is_raw == 2 && shot_select) ? 0x2f00 : 0x3e00;
++    top_margin = (raw_height - height) >> 2 << 1;
++    left_margin = (raw_width - width ) >> 2 << 1;
++    if (width == 2848 || width == 3664) filters = 0x16161616;
++    if (width == 4032 || width == 4952 || width == 6032) left_margin = 0;
++    if (width == 3328 && (width -= 66)) left_margin = 34;
++    if (width == 4936) left_margin = 4;
++    if (!strcmp(model,"HS50EXR") ||
++	!strcmp(model,"F900EXR")) {
++      width += 2;
++      left_margin = 0;
++      filters = 0x16161616;
++    }
++    if (fuji_layout) raw_width *= is_raw;
++    if (filters == 9)
++      FORC(36) ((char *)xtrans)[c] =
++	xtrans_abs[(c/6+top_margin) % 6][(c+left_margin) % 6];
++  } else if (!strcmp(model,"KD-400Z")) {
++    height = 1712;
++    width  = 2312;
++    raw_width = 2336;
++    goto konica_400z;
++  } else if (!strcmp(model,"KD-510Z")) {
++    goto konica_510z;
++  } else if (!strcasecmp(make,"Minolta")) {
++    if (!load_raw && (maximum = 0xfff))
++      load_raw = &CLASS unpacked_load_raw;
++    if (!strncmp(model,"DiMAGE A",8)) {
++      if (!strcmp(model,"DiMAGE A200"))
++	filters = 0x49494949;
++      tiff_bps = 12;
++      load_raw = &CLASS packed_load_raw;
++    } else if (!strncmp(model,"ALPHA",5) ||
++	       !strncmp(model,"DYNAX",5) ||
++	       !strncmp(model,"MAXXUM",6)) {
++      sprintf (model+20, "DYNAX %-10s", model+6+(model[0]=='M'));
++      adobe_coeff (make, model+20);
++      load_raw = &CLASS packed_load_raw;
++    } else if (!strncmp(model,"DiMAGE G",8)) {
++      if (model[8] == '4') {
++	height = 1716;
++	width  = 2304;
++      } else if (model[8] == '5') {
++konica_510z:
++	height = 1956;
++	width  = 2607;
++	raw_width = 2624;
++      } else if (model[8] == '6') {
++	height = 2136;
++	width  = 2848;
++      }
++      data_offset += 14;
++      filters = 0x61616161;
++konica_400z:
++      load_raw = &CLASS unpacked_load_raw;
++      maximum = 0x3df;
++      order = 0x4d4d;
++    }
++  } else if (!strcmp(model,"*ist D")) {
++    load_raw = &CLASS unpacked_load_raw;
++    data_error = -1;
++  } else if (!strcmp(model,"*ist DS")) {
++    height -= 2;
++  } else if (!strcmp(make,"Samsung") && raw_width == 4704) {
++    height -= top_margin = 8;
++    width -= 2 * (left_margin = 8);
++    load_flags = 32;
++  } else if (!strcmp(make,"Samsung") && raw_height == 3714) {
++    height -= top_margin = 18;
++    left_margin = raw_width - (width = 5536);
++    if (raw_width != 5600)
++      left_margin = top_margin = 0;
++    filters = 0x61616161;
++    colors = 3;
++  } else if (!strcmp(make,"Samsung") && raw_width == 5632) {
++    order = 0x4949;
++    height = 3694;
++    top_margin = 2;
++    width  = 5574 - (left_margin = 32 + tiff_bps);
++    if (tiff_bps == 12) load_flags = 80;
++  } else if (!strcmp(make,"Samsung") && raw_width == 5664) {
++    height -= top_margin = 17;
++    left_margin = 96;
++    width = 5544;
++    filters = 0x49494949;
++  } else if (!strcmp(make,"Samsung") && raw_width == 6496) {
++    filters = 0x61616161;
++    black = 1 << (tiff_bps - 7);
++  } else if (!strcmp(model,"EX1")) {
++    order = 0x4949;
++    height -= 20;
++    top_margin = 2;
++    if ((width -= 6) > 3682) {
++      height -= 10;
++      width  -= 46;
++      top_margin = 8;
++    }
++  } else if (!strcmp(model,"WB2000")) {
++    order = 0x4949;
++    height -= 3;
++    top_margin = 2;
++    if ((width -= 10) > 3718) {
++      height -= 28;
++      width  -= 56;
++      top_margin = 8;
++    }
++  } else if (strstr(model,"WB550")) {
++    strcpy (model, "WB550");
++  } else if (!strcmp(model,"EX2F")) {
++    height = 3045;
++    width  = 4070;
++    top_margin = 3;
++    order = 0x4949;
++    filters = 0x49494949;
++    load_raw = &CLASS unpacked_load_raw;
++  } else if (!strcmp(model,"STV680 VGA")) {
++    black = 16;
++  } else if (!strcmp(model,"N95")) {
++    height = raw_height - (top_margin = 2);
++  } else if (!strcmp(model,"640x480")) {
++    gamma_curve (0.45, 4.5, 1, 255);
++  } else if (!strcmp(make,"Hasselblad")) {
++    if (load_raw == &CLASS lossless_jpeg_load_raw)
++      load_raw = &CLASS hasselblad_load_raw;
++    if (raw_width == 7262) {
++      height = 5444;
++      width  = 7248;
++      top_margin  = 4;
++      left_margin = 7;
++      filters = 0x61616161;
++    } else if (raw_width == 7410 || raw_width == 8282) {
++      height -= 84;
++      width  -= 82;
++      top_margin  = 4;
++      left_margin = 41;
++      filters = 0x61616161;
++    } else if (raw_width == 9044) {
++      height = 6716;
++      width  = 8964;
++      top_margin  = 8;
++      left_margin = 40;
++      black += load_flags = 256;
++      maximum = 0x8101;
++    } else if (raw_width == 4090) {
++      strcpy (model, "V96C");
++      height -= (top_margin = 6);
++      width -= (left_margin = 3) + 7;
++      filters = 0x61616161;
++    }
++    if (tiff_samples > 1) {
++      is_raw = tiff_samples+1;
++      if (!shot_select && !half_size) filters = 0;
++    }
++  } else if (!strcmp(make,"Sinar")) {
++    if (!load_raw) load_raw = &CLASS unpacked_load_raw;
++    if (is_raw > 1 && !shot_select && !half_size) filters = 0;
++    maximum = 0x3fff;
++  } else if (!strcmp(make,"Leaf")) {
++    maximum = 0x3fff;
++    fseek (ifp, data_offset, SEEK_SET);
++    if (ljpeg_start (&jh, 1) && jh.bits == 15)
++      maximum = 0x1fff;
++    if (tiff_samples > 1) filters = 0;
++    if (tiff_samples > 1 || tile_length < raw_height) {
++      load_raw = &CLASS leaf_hdr_load_raw;
++      raw_width = tile_width;
++    }
++    if ((width | height) == 2048) {
++      if (tiff_samples == 1) {
++	filters = 1;
++	strcpy (cdesc, "RBTG");
++	strcpy (model, "CatchLight");
++	top_margin =  8; left_margin = 18; height = 2032; width = 2016;
++      } else {
++	strcpy (model, "DCB2");
++	top_margin = 10; left_margin = 16; height = 2028; width = 2022;
++      }
++    } else if (width+height == 3144+2060) {
++      if (!model[0]) strcpy (model, "Cantare");
++      if (width > height) {
++	 top_margin = 6; left_margin = 32; height = 2048;  width = 3072;
++	filters = 0x61616161;
++      } else {
++	left_margin = 6;  top_margin = 32;  width = 2048; height = 3072;
++	filters = 0x16161616;
++      }
++      if (!cam_mul[0] || model[0] == 'V') filters = 0;
++      else is_raw = tiff_samples;
++    } else if (width == 2116) {
++      strcpy (model, "Valeo 6");
++      height -= 2 * (top_margin = 30);
++      width -= 2 * (left_margin = 55);
++      filters = 0x49494949;
++    } else if (width == 3171) {
++      strcpy (model, "Valeo 6");
++      height -= 2 * (top_margin = 24);
++      width -= 2 * (left_margin = 24);
++      filters = 0x16161616;
++    }
++  } else if (!strcmp(make,"Leica") || !strcmp(make,"Panasonic")) {
++    if ((flen - data_offset) / (raw_width*8/7) == raw_height)
++      load_raw = &CLASS panasonic_load_raw;
++    if (!load_raw) {
++      load_raw = &CLASS unpacked_load_raw;
++      load_flags = 4;
++    }
++    zero_is_bad = 1;
++    if ((height += 12) > raw_height) height = raw_height;
++    for (i=0; i < sizeof pana / sizeof *pana; i++)
++      if (raw_width == pana[i][0] && raw_height == pana[i][1]) {
++	left_margin = pana[i][2];
++	 top_margin = pana[i][3];
++	     width += pana[i][4];
++	    height += pana[i][5];
++      }
++    filters = 0x01010101 * (uchar) "\x94\x61\x49\x16"
++	[((filters-1) ^ (left_margin & 1) ^ (top_margin << 1)) & 3];
++  } else if (!strcmp(model,"C770UZ")) {
++    height = 1718;
++    width  = 2304;
++    filters = 0x16161616;
++    load_raw = &CLASS packed_load_raw;
++    load_flags = 30;
++  } else if (!strcmp(make,"Olympus")) {
++    height += height & 1;
++    if (exif_cfa) filters = exif_cfa;
++    if (width == 4100) width -= 4;
++    if (width == 4080) width -= 24;
++    if (width == 9280) { width -= 6; height -= 6; }
++    if (load_raw == &CLASS unpacked_load_raw)
++      load_flags = 4;
++    tiff_bps = 12;
++    if (!strcmp(model,"E-300") ||
++	!strcmp(model,"E-500")) {
++      width -= 20;
++      if (load_raw == &CLASS unpacked_load_raw) {
++	maximum = 0xfc3;
++	memset (cblack, 0, sizeof cblack);
++      }
++    } else if (!strcmp(model,"E-330")) {
++      width -= 30;
++      if (load_raw == &CLASS unpacked_load_raw)
++	maximum = 0xf79;
++    } else if (!strcmp(model,"SP550UZ")) {
++      thumb_length = flen - (thumb_offset = 0xa39800);
++      thumb_height = 480;
++      thumb_width  = 640;
++    } else if (!strcmp(model,"TG-4")) {
++      width -= 16;
++    }
++  } else if (!strcmp(model,"N Digital")) {
++    height = 2047;
++    width  = 3072;
++    filters = 0x61616161;
++    data_offset = 0x1a00;
++    load_raw = &CLASS packed_load_raw;
++  } else if (!strcmp(model,"DSC-F828")) {
++    width = 3288;
++    left_margin = 5;
++    mask[1][3] = -17;
++    data_offset = 862144;
++    load_raw = &CLASS sony_load_raw;
++    filters = 0x9c9c9c9c;
++    colors = 4;
++    strcpy (cdesc, "RGBE");
++  } else if (!strcmp(model,"DSC-V3")) {
++    width = 3109;
++    left_margin = 59;
++    mask[0][1] = 9;
++    data_offset = 787392;
++    load_raw = &CLASS sony_load_raw;
++  } else if (!strcmp(make,"Sony") && raw_width == 3984) {
++    width = 3925;
++    order = 0x4d4d;
++  } else if (!strcmp(make,"Sony") && raw_width == 4288) {
++    width -= 32;
++  } else if (!strcmp(make,"Sony") && raw_width == 4600) {
++    if (!strcmp(model,"DSLR-A350"))
++      height -= 4;
++    black = 0;
++  } else if (!strcmp(make,"Sony") && raw_width == 4928) {
++    if (height < 3280) width -= 8;
++  } else if (!strcmp(make,"Sony") && raw_width == 5504) {
++    width -= height > 3664 ? 8 : 32;
++    if (!strncmp(model,"DSC",3))
++      black = 200 << (tiff_bps - 12);
++  } else if (!strcmp(make,"Sony") && raw_width == 6048) {
++    width -= 24;
++    if (strstr(model,"RX1") || strstr(model,"A99"))
++      width -= 6;
++  } else if (!strcmp(make,"Sony") && raw_width == 7392) {
++    width -= 30;
++  } else if (!strcmp(make,"Sony") && raw_width == 8000) {
++    width -= 32;
++    if (!strncmp(model,"DSC",3)) {
++      tiff_bps = 14;
++      load_raw = &CLASS unpacked_load_raw;
++      black = 512;
++    }
++  } else if (!strcmp(model,"DSLR-A100")) {
++    if (width == 3880) {
++      height--;
++      width = ++raw_width;
++    } else {
++      height -= 4;
++      width  -= 4;
++      order = 0x4d4d;
++      load_flags = 2;
++    }
++    filters = 0x61616161;
++  } else if (!strcmp(model,"PIXL")) {
++    height -= top_margin = 4;
++    width -= left_margin = 32;
++    gamma_curve (0, 7, 1, 255);
++  } else if (!strcmp(model,"C603") || !strcmp(model,"C330")
++	|| !strcmp(model,"12MP")) {
++    order = 0x4949;
++    if (filters && data_offset) {
++      fseek (ifp, data_offset < 4096 ? 168 : 5252, SEEK_SET);
++      read_shorts (curve, 256);
++    } else gamma_curve (0, 3.875, 1, 255);
++    load_raw  =  filters   ? &CLASS eight_bit_load_raw :
++      strcmp(model,"C330") ? &CLASS kodak_c603_load_raw :
++			     &CLASS kodak_c330_load_raw;
++    load_flags = tiff_bps > 16;
++    tiff_bps = 8;
++  } else if (!strncasecmp(model,"EasyShare",9)) {
++    data_offset = data_offset < 0x15000 ? 0x15000 : 0x17000;
++    load_raw = &CLASS packed_load_raw;
++  } else if (!strcasecmp(make,"Kodak")) {
++    if (filters == UINT_MAX) filters = 0x61616161;
++    if (!strncmp(model,"NC2000",6) ||
++	!strncmp(model,"EOSDCS",6) ||
++	!strncmp(model,"DCS4",4)) {
++      width -= 4;
++      left_margin = 2;
++      if (model[6] == ' ') model[6] = 0;
++      if (!strcmp(model,"DCS460A")) goto bw;
++    } else if (!strcmp(model,"DCS660M")) {
++      black = 214;
++      goto bw;
++    } else if (!strcmp(model,"DCS760M")) {
++bw:   colors = 1;
++      filters = 0;
++    }
++    if (!strcmp(model+4,"20X"))
++      strcpy (cdesc, "MYCY");
++    if (strstr(model,"DC25")) {
++      strcpy (model, "DC25");
++      data_offset = 15424;
++    }
++    if (!strncmp(model,"DC2",3)) {
++      raw_height = 2 + (height = 242);
++      if (flen < 100000) {
++	raw_width = 256; width = 249;
++	pixel_aspect = (4.0*height) / (3.0*width);
++      } else {
++	raw_width = 512; width = 501;
++	pixel_aspect = (493.0*height) / (373.0*width);
++      }
++      top_margin = left_margin = 1;
++      colors = 4;
++      filters = 0x8d8d8d8d;
++      simple_coeff(1);
++      pre_mul[1] = 1.179;
++      pre_mul[2] = 1.209;
++      pre_mul[3] = 1.036;
++      load_raw = &CLASS eight_bit_load_raw;
++    } else if (!strcmp(model,"40")) {
++      strcpy (model, "DC40");
++      height = 512;
++      width  = 768;
++      data_offset = 1152;
++      load_raw = &CLASS kodak_radc_load_raw;
++      tiff_bps = 12;
++    } else if (strstr(model,"DC50")) {
++      strcpy (model, "DC50");
++      height = 512;
++      width  = 768;
++      data_offset = 19712;
++      load_raw = &CLASS kodak_radc_load_raw;
++    } else if (strstr(model,"DC120")) {
++      strcpy (model, "DC120");
++      height = 976;
++      width  = 848;
++      pixel_aspect = height/0.75/width;
++      load_raw = tiff_compress == 7 ?
++	&CLASS kodak_jpeg_load_raw : &CLASS kodak_dc120_load_raw;
++    } else if (!strcmp(model,"DCS200")) {
++      thumb_height = 128;
++      thumb_width  = 192;
++      thumb_offset = 6144;
++      thumb_misc   = 360;
++      write_thumb = &CLASS layer_thumb;
++      black = 17;
++    }
++  } else if (!strcmp(model,"Fotoman Pixtura")) {
++    height = 512;
++    width  = 768;
++    data_offset = 3632;
++    load_raw = &CLASS kodak_radc_load_raw;
++    filters = 0x61616161;
++    simple_coeff(2);
++  } else if (!strncmp(model,"QuickTake",9)) {
++    if (head[5]) strcpy (model+10, "200");
++    fseek (ifp, 544, SEEK_SET);
++    height = get2();
++    width  = get2();
++    data_offset = (get4(),get2()) == 30 ? 738:736;
++    if (height > width) {
++      SWAP(height,width);
++      fseek (ifp, data_offset-6, SEEK_SET);
++      flip = ~get2() & 3 ? 5:6;
++    }
++    filters = 0x61616161;
++  } else if (!strcmp(make,"Rollei") && !load_raw) {
++    switch (raw_width) {
++      case 1316:
++	height = 1030;
++	width  = 1300;
++	top_margin  = 1;
++	left_margin = 6;
++	break;
++      case 2568:
++	height = 1960;
++	width  = 2560;
++	top_margin  = 2;
++	left_margin = 8;
++    }
++    filters = 0x16161616;
++    load_raw = &CLASS rollei_load_raw;
++  }
++  if (!model[0])
++    sprintf (model, "%dx%d", width, height);
++  if (filters == UINT_MAX) filters = 0x94949494;
++  if (thumb_offset && !thumb_height) {
++    fseek (ifp, thumb_offset, SEEK_SET);
++    if (ljpeg_start (&jh, 1)) {
++      thumb_width  = jh.wide;
++      thumb_height = jh.high;
++    }
++  }
++dng_skip:
++  if ((use_camera_matrix & (use_camera_wb || dng_version))
++	&& cmatrix[0][0] > 0.125) {
++    memcpy (rgb_cam, cmatrix, sizeof cmatrix);
++    raw_color = 0;
++  }
++  if (raw_color) adobe_coeff (make, model);
++  if (load_raw == &CLASS kodak_radc_load_raw)
++    if (raw_color) adobe_coeff ("Apple","Quicktake");
++  if (fuji_width) {
++    fuji_width = width >> !fuji_layout;
++    filters = fuji_width & 1 ? 0x94949494 : 0x49494949;
++    width = (height >> fuji_layout) + fuji_width;
++    height = width - 1;
++    pixel_aspect = 1;
++  } else {
++    if (raw_height < height) raw_height = height;
++    if (raw_width  < width ) raw_width  = width;
++  }
++  if (!tiff_bps) tiff_bps = 12;
++  if (!maximum) maximum = (1 << tiff_bps) - 1;
++  if (!load_raw || height < 22 || width < 22 ||
++	tiff_bps > 16 || tiff_samples > 6 || colors > 4)
++    is_raw = 0;
++#ifdef NO_JASPER
++  if (load_raw == &CLASS redcine_load_raw) {
++    fprintf (stderr,_("%s: You must link dcraw with %s!!\n"),
++	ifname, "libjasper");
++    is_raw = 0;
++  }
++#endif
++#ifdef NO_JPEG
++  if (load_raw == &CLASS kodak_jpeg_load_raw ||
++      load_raw == &CLASS lossy_dng_load_raw) {
++    fprintf (stderr,_("%s: You must link dcraw with %s!!\n"),
++	ifname, "libjpeg");
++    is_raw = 0;
++  }
++#endif
++  if (!cdesc[0])
++    strcpy (cdesc, colors == 3 ? "RGBG":"GMCY");
++  if (!raw_height) raw_height = height;
++  if (!raw_width ) raw_width  = width;
++  if (filters > 999 && colors == 3)
++    filters |= ((filters >> 2 & 0x22222222) |
++		(filters << 2 & 0x88888888)) & filters << 1;
++notraw:
++  if (flip == UINT_MAX) flip = tiff_flip;
++  if (flip == UINT_MAX) flip = 0;
++}
++
++#ifndef NO_LCMS
++void CLASS apply_profile (const char *input, const char *output)
++{
++  char *prof;
++  cmsHPROFILE hInProfile=0, hOutProfile=0;
++  cmsHTRANSFORM hTransform;
++  FILE *fp;
++  unsigned size;
++
++  if (strcmp (input, "embed"))
++    hInProfile = cmsOpenProfileFromFile (input, "r");
++  else if (profile_length) {
++    prof = (char *) malloc (profile_length);
++    merror (prof, "apply_profile()");
++    fseek (ifp, profile_offset, SEEK_SET);
++    fread (prof, 1, profile_length, ifp);
++    hInProfile = cmsOpenProfileFromMem (prof, profile_length);
++    free (prof);
++  } else
++    fprintf (stderr,_("%s has no embedded profile.\n"), ifname);
++  if (!hInProfile) return;
++  if (!output)
++    hOutProfile = cmsCreate_sRGBProfile();
++  else if ((fp = fopen (output, "rb"))) {
++    fread (&size, 4, 1, fp);
++    fseek (fp, 0, SEEK_SET);
++    oprof = (unsigned *) malloc (size = ntohl(size));
++    merror (oprof, "apply_profile()");
++    fread (oprof, 1, size, fp);
++    fclose (fp);
++    if (!(hOutProfile = cmsOpenProfileFromMem (oprof, size))) {
++      free (oprof);
++      oprof = 0;
++    }
++  } else
++    fprintf (stderr,_("Cannot open file %s!\n"), output);
++  if (!hOutProfile) goto quit;
++  if (verbose)
++    fprintf (stderr,_("Applying color profile...\n"));
++  hTransform = cmsCreateTransform (hInProfile, TYPE_RGBA_16,
++	hOutProfile, TYPE_RGBA_16, INTENT_PERCEPTUAL, 0);
++  cmsDoTransform (hTransform, image, image, width*height);
++  raw_color = 1;		/* Don't use rgb_cam with a profile */
++  cmsDeleteTransform (hTransform);
++  cmsCloseProfile (hOutProfile);
++quit:
++  cmsCloseProfile (hInProfile);
++}
++#endif
++
++void CLASS convert_to_rgb()
++{
++  int row, col, c, i, j, k;
++  ushort *img;
++  float out[3], out_cam[3][4];
++  double num, inverse[3][3];
++  static const double xyzd50_srgb[3][3] =
++  { { 0.436083, 0.385083, 0.143055 },
++    { 0.222507, 0.716888, 0.060608 },
++    { 0.013930, 0.097097, 0.714022 } };
++  static const double rgb_rgb[3][3] =
++  { { 1,0,0 }, { 0,1,0 }, { 0,0,1 } };
++  static const double adobe_rgb[3][3] =
++  { { 0.715146, 0.284856, 0.000000 },
++    { 0.000000, 1.000000, 0.000000 },
++    { 0.000000, 0.041166, 0.958839 } };
++  static const double wide_rgb[3][3] =
++  { { 0.593087, 0.404710, 0.002206 },
++    { 0.095413, 0.843149, 0.061439 },
++    { 0.011621, 0.069091, 0.919288 } };
++  static const double prophoto_rgb[3][3] =
++  { { 0.529317, 0.330092, 0.140588 },
++    { 0.098368, 0.873465, 0.028169 },
++    { 0.016879, 0.117663, 0.865457 } };
++  static const double aces_rgb[3][3] =
++  { { 0.432996, 0.375380, 0.189317 },
++    { 0.089427, 0.816523, 0.102989 },
++    { 0.019165, 0.118150, 0.941914 } };
++  static const double (*out_rgb[])[3] =
++  { rgb_rgb, adobe_rgb, wide_rgb, prophoto_rgb, xyz_rgb, aces_rgb };
++  static const char *name[] =
++  { "sRGB", "Adobe RGB (1998)", "WideGamut D65", "ProPhoto D65", "XYZ", "ACES" };
++  static const unsigned phead[] =
++  { 1024, 0, 0x2100000, 0x6d6e7472, 0x52474220, 0x58595a20, 0, 0, 0,
++    0x61637370, 0, 0, 0x6e6f6e65, 0, 0, 0, 0, 0xf6d6, 0x10000, 0xd32d };
++  unsigned pbody[] =
++  { 10, 0x63707274, 0, 36,	/* cprt */
++	0x64657363, 0, 40,	/* desc */
++	0x77747074, 0, 20,	/* wtpt */
++	0x626b7074, 0, 20,	/* bkpt */
++	0x72545243, 0, 14,	/* rTRC */
++	0x67545243, 0, 14,	/* gTRC */
++	0x62545243, 0, 14,	/* bTRC */
++	0x7258595a, 0, 20,	/* rXYZ */
++	0x6758595a, 0, 20,	/* gXYZ */
++	0x6258595a, 0, 20 };	/* bXYZ */
++  static const unsigned pwhite[] = { 0xf351, 0x10000, 0x116cc };
++  unsigned pcurve[] = { 0x63757276, 0, 1, 0x1000000 };
++
++  gamma_curve (gamm[0], gamm[1], 0, 0);
++  memcpy (out_cam, rgb_cam, sizeof out_cam);
++  raw_color |= colors == 1 || document_mode ||
++		output_color < 1 || output_color > 6;
++  if (!raw_color) {
++    oprof = (unsigned *) calloc (phead[0], 1);
++    merror (oprof, "convert_to_rgb()");
++    memcpy (oprof, phead, sizeof phead);
++    if (output_color == 5) oprof[4] = oprof[5];
++    oprof[0] = 132 + 12*pbody[0];
++    for (i=0; i < pbody[0]; i++) {
++      oprof[oprof[0]/4] = i ? (i > 1 ? 0x58595a20 : 0x64657363) : 0x74657874;
++      pbody[i*3+2] = oprof[0];
++      oprof[0] += (pbody[i*3+3] + 3) & -4;
++    }
++    memcpy (oprof+32, pbody, sizeof pbody);
++    oprof[pbody[5]/4+2] = strlen(name[output_color-1]) + 1;
++    memcpy ((char *)oprof+pbody[8]+8, pwhite, sizeof pwhite);
++    pcurve[3] = (short)(256/gamm[5]+0.5) << 16;
++    for (i=4; i < 7; i++)
++      memcpy ((char *)oprof+pbody[i*3+2], pcurve, sizeof pcurve);
++    pseudoinverse ((double (*)[3]) out_rgb[output_color-1], inverse, 3);
++    for (i=0; i < 3; i++)
++      for (j=0; j < 3; j++) {
++	for (num = k=0; k < 3; k++)
++	  num += xyzd50_srgb[i][k] * inverse[j][k];
++	oprof[pbody[j*3+23]/4+i+2] = num * 0x10000 + 0.5;
++      }
++    for (i=0; i < phead[0]/4; i++)
++      oprof[i] = htonl(oprof[i]);
++    strcpy ((char *)oprof+pbody[2]+8, "auto-generated by dcraw");
++    strcpy ((char *)oprof+pbody[5]+12, name[output_color-1]);
++    for (i=0; i < 3; i++)
++      for (j=0; j < colors; j++)
++	for (out_cam[i][j] = k=0; k < 3; k++)
++	  out_cam[i][j] += out_rgb[output_color-1][i][k] * rgb_cam[k][j];
++  }
++  if (verbose)
++    fprintf (stderr, raw_color ? _("Building histograms...\n") :
++	_("Converting to %s colorspace...\n"), name[output_color-1]);
++
++  memset (histogram, 0, sizeof histogram);
++  for (img=image[0], row=0; row < height; row++)
++    for (col=0; col < width; col++, img+=4) {
++      if (!raw_color) {
++	out[0] = out[1] = out[2] = 0;
++	FORCC {
++	  out[0] += out_cam[0][c] * img[c];
++	  out[1] += out_cam[1][c] * img[c];
++	  out[2] += out_cam[2][c] * img[c];
++	}
++	FORC3 img[c] = CLIP((int) out[c]);
++      }
++      else if (document_mode)
++	img[0] = img[fcol(row,col)];
++      FORCC histogram[c][img[c] >> 3]++;
++    }
++  if (colors == 4 && output_color) colors = 3;
++  if (document_mode && filters) colors = 1;
++}
++
++void CLASS fuji_rotate()
++{
++  int i, row, col;
++  double step;
++  float r, c, fr, fc;
++  unsigned ur, uc;
++  ushort wide, high, (*img)[4], (*pix)[4];
++
++  if (!fuji_width) return;
++  if (verbose)
++    fprintf (stderr,_("Rotating image 45 degrees...\n"));
++  fuji_width = (fuji_width - 1 + shrink) >> shrink;
++  step = sqrt(0.5);
++  wide = fuji_width / step;
++  high = (height - fuji_width) / step;
++  img = (ushort (*)[4]) calloc (high, wide*sizeof *img);
++  merror (img, "fuji_rotate()");
++
++  for (row=0; row < high; row++)
++    for (col=0; col < wide; col++) {
++      ur = r = fuji_width + (row-col)*step;
++      uc = c = (row+col)*step;
++      if (ur > height-2 || uc > width-2) continue;
++      fr = r - ur;
++      fc = c - uc;
++      pix = image + ur*width + uc;
++      for (i=0; i < colors; i++)
++	img[row*wide+col][i] =
++	  (pix[    0][i]*(1-fc) + pix[      1][i]*fc) * (1-fr) +
++	  (pix[width][i]*(1-fc) + pix[width+1][i]*fc) * fr;
++    }
++  free (image);
++  width  = wide;
++  height = high;
++  image  = img;
++  fuji_width = 0;
++}
++
++void CLASS stretch()
++{
++  ushort newdim, (*img)[4], *pix0, *pix1;
++  int row, col, c;
++  double rc, frac;
++
++  if (pixel_aspect == 1) return;
++  if (verbose) fprintf (stderr,_("Stretching the image...\n"));
++  if (pixel_aspect < 1) {
++    newdim = height / pixel_aspect + 0.5;
++    img = (ushort (*)[4]) calloc (width, newdim*sizeof *img);
++    merror (img, "stretch()");
++    for (rc=row=0; row < newdim; row++, rc+=pixel_aspect) {
++      frac = rc - (c = rc);
++      pix0 = pix1 = image[c*width];
++      if (c+1 < height) pix1 += width*4;
++      for (col=0; col < width; col++, pix0+=4, pix1+=4)
++	FORCC img[row*width+col][c] = pix0[c]*(1-frac) + pix1[c]*frac + 0.5;
++    }
++    height = newdim;
++  } else {
++    newdim = width * pixel_aspect + 0.5;
++    img = (ushort (*)[4]) calloc (height, newdim*sizeof *img);
++    merror (img, "stretch()");
++    for (rc=col=0; col < newdim; col++, rc+=1/pixel_aspect) {
++      frac = rc - (c = rc);
++      pix0 = pix1 = image[c];
++      if (c+1 < width) pix1 += 4;
++      for (row=0; row < height; row++, pix0+=width*4, pix1+=width*4)
++	FORCC img[row*newdim+col][c] = pix0[c]*(1-frac) + pix1[c]*frac + 0.5;
++    }
++    width = newdim;
++  }
++  free (image);
++  image = img;
++}
++
++int CLASS flip_index (int row, int col)
++{
++  if (flip & 4) SWAP(row,col);
++  if (flip & 2) row = iheight - 1 - row;
++  if (flip & 1) col = iwidth  - 1 - col;
++  return row * iwidth + col;
++}
++
++struct tiff_tag {
++  ushort tag, type;
++  int count;
++  union { char c[4]; short s[2]; int i; } val;
++};
++
++struct tiff_hdr {
++  ushort order, magic;
++  int ifd;
++  ushort pad, ntag;
++  struct tiff_tag tag[23];
++  int nextifd;
++  ushort pad2, nexif;
++  struct tiff_tag exif[4];
++  ushort pad3, ngps;
++  struct tiff_tag gpst[10];
++  short bps[4];
++  int rat[10];
++  unsigned gps[26];
++  char desc[512], make[64], model[64], soft[32], date[20], artist[64];
++};
++
++void CLASS tiff_set (struct tiff_hdr *th, ushort *ntag,
++	ushort tag, ushort type, int count, int val)
++{
++  struct tiff_tag *tt;
++  int c;
++
++  tt = (struct tiff_tag *)(ntag+1) + (*ntag)++;
++  tt->val.i = val;
++  if (type == 1 && count <= 4)
++    FORC(4) tt->val.c[c] = val >> (c << 3);
++  else if (type == 2) {
++    count = strnlen((char *)th + val, count-1) + 1;
++    if (count <= 4)
++      FORC(4) tt->val.c[c] = ((char *)th)[val+c];
++  } else if (type == 3 && count <= 2)
++    FORC(2) tt->val.s[c] = val >> (c << 4);
++  tt->count = count;
++  tt->type = type;
++  tt->tag = tag;
++}
++
++#define TOFF(ptr) ((char *)(&(ptr)) - (char *)th)
++
++void CLASS tiff_head (struct tiff_hdr *th, int full)
++{
++  int c, psize=0;
++  struct tm *t;
++
++  memset (th, 0, sizeof *th);
++  th->order = htonl(0x4d4d4949) >> 16;
++  th->magic = 42;
++  th->ifd = 10;
++  th->rat[0] = th->rat[2] = 300;
++  th->rat[1] = th->rat[3] = 1;
++  FORC(6) th->rat[4+c] = 1000000;
++  th->rat[4] *= shutter;
++  th->rat[6] *= aperture;
++  th->rat[8] *= focal_len;
++  strncpy (th->desc, desc, 512);
++  strncpy (th->make, make, 64);
++  strncpy (th->model, model, 64);
++  strcpy (th->soft, "dcraw v"DCRAW_VERSION);
++  t = localtime (&timestamp);
++  sprintf (th->date, "%04d:%02d:%02d %02d:%02d:%02d",
++      t->tm_year+1900,t->tm_mon+1,t->tm_mday,t->tm_hour,t->tm_min,t->tm_sec);
++  strncpy (th->artist, artist, 64);
++  if (full) {
++    tiff_set (th, &th->ntag, 254, 4, 1, 0);
++    tiff_set (th, &th->ntag, 256, 4, 1, width);
++    tiff_set (th, &th->ntag, 257, 4, 1, height);
++    tiff_set (th, &th->ntag, 258, 3, colors, output_bps);
++    if (colors > 2)
++      th->tag[th->ntag-1].val.i = TOFF(th->bps);
++    FORC4 th->bps[c] = output_bps;
++    tiff_set (th, &th->ntag, 259, 3, 1, 1);
++    tiff_set (th, &th->ntag, 262, 3, 1, 1 + (colors > 1));
++  }
++  tiff_set (th, &th->ntag, 270, 2, 512, TOFF(th->desc));
++  tiff_set (th, &th->ntag, 271, 2, 64, TOFF(th->make));
++  tiff_set (th, &th->ntag, 272, 2, 64, TOFF(th->model));
++  if (full) {
++    if (oprof) psize = ntohl(oprof[0]);
++    tiff_set (th, &th->ntag, 273, 4, 1, sizeof *th + psize);
++    tiff_set (th, &th->ntag, 277, 3, 1, colors);
++    tiff_set (th, &th->ntag, 278, 4, 1, height);
++    tiff_set (th, &th->ntag, 279, 4, 1, height*width*colors*output_bps/8);
++  } else
++    tiff_set (th, &th->ntag, 274, 3, 1, "12435867"[flip]-'0');
++  tiff_set (th, &th->ntag, 282, 5, 1, TOFF(th->rat[0]));
++  tiff_set (th, &th->ntag, 283, 5, 1, TOFF(th->rat[2]));
++  tiff_set (th, &th->ntag, 284, 3, 1, 1);
++  tiff_set (th, &th->ntag, 296, 3, 1, 2);
++  tiff_set (th, &th->ntag, 305, 2, 32, TOFF(th->soft));
++  tiff_set (th, &th->ntag, 306, 2, 20, TOFF(th->date));
++  tiff_set (th, &th->ntag, 315, 2, 64, TOFF(th->artist));
++  tiff_set (th, &th->ntag, 34665, 4, 1, TOFF(th->nexif));
++  if (psize) tiff_set (th, &th->ntag, 34675, 7, psize, sizeof *th);
++  tiff_set (th, &th->nexif, 33434, 5, 1, TOFF(th->rat[4]));
++  tiff_set (th, &th->nexif, 33437, 5, 1, TOFF(th->rat[6]));
++  tiff_set (th, &th->nexif, 34855, 3, 1, iso_speed);
++  tiff_set (th, &th->nexif, 37386, 5, 1, TOFF(th->rat[8]));
++  if (gpsdata[1]) {
++    tiff_set (th, &th->ntag, 34853, 4, 1, TOFF(th->ngps));
++    tiff_set (th, &th->ngps,  0, 1,  4, 0x202);
++    tiff_set (th, &th->ngps,  1, 2,  2, gpsdata[29]);
++    tiff_set (th, &th->ngps,  2, 5,  3, TOFF(th->gps[0]));
++    tiff_set (th, &th->ngps,  3, 2,  2, gpsdata[30]);
++    tiff_set (th, &th->ngps,  4, 5,  3, TOFF(th->gps[6]));
++    tiff_set (th, &th->ngps,  5, 1,  1, gpsdata[31]);
++    tiff_set (th, &th->ngps,  6, 5,  1, TOFF(th->gps[18]));
++    tiff_set (th, &th->ngps,  7, 5,  3, TOFF(th->gps[12]));
++    tiff_set (th, &th->ngps, 18, 2, 12, TOFF(th->gps[20]));
++    tiff_set (th, &th->ngps, 29, 2, 12, TOFF(th->gps[23]));
++    memcpy (th->gps, gpsdata, sizeof th->gps);
++  }
++}
++
++void CLASS jpeg_thumb()
++{
++  char *thumb;
++  ushort exif[5];
++  struct tiff_hdr th;
++
++  thumb = (char *) malloc (thumb_length);
++  merror (thumb, "jpeg_thumb()");
++  fread (thumb, 1, thumb_length, ifp);
++  fputc (0xff, ofp);
++  fputc (0xd8, ofp);
++  if (strcmp (thumb+6, "Exif")) {
++    memcpy (exif, "\xff\xe1  Exif\0\0", 10);
++    exif[1] = htons (8 + sizeof th);
++    fwrite (exif, 1, sizeof exif, ofp);
++    tiff_head (&th, 0);
++    fwrite (&th, 1, sizeof th, ofp);
++  }
++  fwrite (thumb+2, 1, thumb_length-2, ofp);
++  free (thumb);
++}
++
++void CLASS write_ppm_tiff()
++{
++  struct tiff_hdr th;
++  uchar *ppm;
++  ushort *ppm2;
++  int c, row, col, soff, rstep, cstep;
++  int perc, val, total, white=0x2000;
++
++  perc = width * height * 0.01;		/* 99th percentile white level */
++  if (fuji_width) perc /= 2;
++  if (!((highlight & ~2) || no_auto_bright))
++    for (white=c=0; c < colors; c++) {
++      for (val=0x2000, total=0; --val > 32; )
++	if ((total += histogram[c][val]) > perc) break;
++      if (white < val) white = val;
++    }
++  gamma_curve (gamm[0], gamm[1], 2, (white << 3)/bright);
++  iheight = height;
++  iwidth  = width;
++  if (flip & 4) SWAP(height,width);
++  ppm = (uchar *) calloc (width, colors*output_bps/8);
++  ppm2 = (ushort *) ppm;
++  merror (ppm, "write_ppm_tiff()");
++  if (output_tiff) {
++    tiff_head (&th, 1);
++    fwrite (&th, sizeof th, 1, ofp);
++    if (oprof)
++      fwrite (oprof, ntohl(oprof[0]), 1, ofp);
++  } else if (colors > 3)
++    fprintf (ofp,
++      "P7\nWIDTH %d\nHEIGHT %d\nDEPTH %d\nMAXVAL %d\nTUPLTYPE %s\nENDHDR\n",
++	width, height, colors, (1 << output_bps)-1, cdesc);
++  else
++    fprintf (ofp, "P%d\n%d %d\n%d\n",
++	colors/2+5, width, height, (1 << output_bps)-1);
++  soff  = flip_index (0, 0);
++  cstep = flip_index (0, 1) - soff;
++  rstep = flip_index (1, 0) - flip_index (0, width);
++  for (row=0; row < height; row++, soff += rstep) {
++    for (col=0; col < width; col++, soff += cstep)
++      if (output_bps == 8)
++	   FORCC ppm [col*colors+c] = curve[image[soff][c]] >> 8;
++      else FORCC ppm2[col*colors+c] = curve[image[soff][c]];
++    if (output_bps == 16 && !output_tiff && htons(0x55aa) != 0x55aa)
++      swab (ppm2, ppm2, width*colors*2);
++    fwrite (ppm, colors*output_bps/8, width, ofp);
++  }
++  free (ppm);
++}
++
++int CLASS main (int argc, const char **argv)
++{
++  int arg, status=0, quality, i, c;
++  int timestamp_only=0, thumbnail_only=0, identify_only=0;
++  int user_qual=-1, user_black=-1, user_sat=-1, user_flip=-1;
++  int use_fuji_rotate=1, write_to_stdout=0, read_from_stdin=0;
++  const char *sp, *bpfile=0, *dark_frame=0, *write_ext;
++  char opm, opt, *ofname, *cp;
++  struct utimbuf ut;
++#ifndef NO_LCMS
++  const char *cam_profile=0, *out_profile=0;
++#endif
++
++#ifndef LOCALTIME
++  putenv ((char *) "TZ=UTC");
++#endif
++#ifdef LOCALEDIR
++  setlocale (LC_CTYPE, "");
++  setlocale (LC_MESSAGES, "");
++  bindtextdomain ("dcraw", LOCALEDIR);
++  textdomain ("dcraw");
++#endif
++
++  if (argc == 1) {
++    printf(_("\nRaw photo decoder \"dcraw\" v%s"), DCRAW_VERSION);
++    printf(_("\nby Dave Coffin, dcoffin a cybercom o net\n"));
++    printf(_("\nUsage:  %s [OPTION]... [FILE]...\n\n"), argv[0]);
++    puts(_("-v        Print verbose messages"));
++    puts(_("-c        Write image data to standard output"));
++    puts(_("-e        Extract embedded thumbnail image"));
++    puts(_("-i        Identify files without decoding them"));
++    puts(_("-i -v     Identify files and show metadata"));
++    puts(_("-z        Change file dates to camera timestamp"));
++    puts(_("-w        Use camera white balance, if possible"));
++    puts(_("-a        Average the whole image for white balance"));
++    puts(_("-A <x y w h> Average a grey box for white balance"));
++    puts(_("-r <r g b g> Set custom white balance"));
++    puts(_("+M/-M     Use/don't use an embedded color matrix"));
++    puts(_("-C <r b>  Correct chromatic aberration"));
++    puts(_("-O <file> Write output to this file"));
++    puts(_("-P <file> Fix the dead pixels listed in this file"));
++    puts(_("-K <file> Subtract dark frame (16-bit raw PGM)"));
++    puts(_("-k <num>  Set the darkness level"));
++    puts(_("-S <num>  Set the saturation level"));
++    puts(_("-n <num>  Set threshold for wavelet denoising"));
++    puts(_("-H [0-9]  Highlight mode (0=clip, 1=unclip, 2=blend, 3+=rebuild)"));
++    puts(_("-t [0-7]  Flip image (0=none, 3=180, 5=90CCW, 6=90CW)"));
++    puts(_("-o [0-6]  Output colorspace (raw,sRGB,Adobe,Wide,ProPhoto,XYZ,ACES)"));
++#ifndef NO_LCMS
++    puts(_("-o <file> Apply output ICC profile from file"));
++    puts(_("-p <file> Apply camera ICC profile from file or \"embed\""));
++#endif
++    puts(_("-d        Document mode (no color, no interpolation)"));
++    puts(_("-D        Document mode without scaling (totally raw)"));
++    puts(_("-j        Don't stretch or rotate raw pixels"));
++    puts(_("-W        Don't automatically brighten the image"));
++    puts(_("-b <num>  Adjust brightness (default = 1.0)"));
++    puts(_("-g <p ts> Set custom gamma curve (default = 2.222 4.5)"));
++    puts(_("-q [0-3]  Set the interpolation quality"));
++    puts(_("-h        Half-size color image (twice as fast as \"-q 0\")"));
++    puts(_("-f        Interpolate RGGB as four colors"));
++    puts(_("-m <num>  Apply a 3x3 median filter to R-G and B-G"));
++    puts(_("-s [0..N-1] Select one raw image or \"all\" from each file"));
++    puts(_("-6        Write 16-bit instead of 8-bit"));
++    puts(_("-4        Linear 16-bit, same as \"-6 -W -g 1 1\""));
++    puts(_("-T        Write TIFF instead of PPM"));
++    puts("");
++    return 1;
++  }
++  argv[argc] = "";
++  for (arg=1; (((opm = argv[arg][0]) - 2) | 2) == '+'; ) {
++    opt = argv[arg++][1];
++    if ((cp = (char *) strchr (sp="nbrkStqmHACg", opt)))
++      for (i=0; i < "114111111422"[cp-sp]-'0'; i++)
++	if (!isdigit(argv[arg+i][0])) {
++	  fprintf (stderr,_("Non-numeric argument to \"-%c\"\n"), opt);
++	  return 1;
++	}
++    switch (opt) {
++      case 'n':  threshold   = atof(argv[arg++]);  break;
++      case 'b':  bright      = atof(argv[arg++]);  break;
++      case 'r':
++	   FORC4 user_mul[c] = atof(argv[arg++]);  break;
++      case 'C':  aber[0] = 1 / atof(argv[arg++]);
++		 aber[2] = 1 / atof(argv[arg++]);  break;
++      case 'g':  gamm[0] =     atof(argv[arg++]);
++		 gamm[1] =     atof(argv[arg++]);
++		 if (gamm[0]) gamm[0] = 1/gamm[0]; break;
++      case 'k':  user_black  = atoi(argv[arg++]);  break;
++      case 'S':  user_sat    = atoi(argv[arg++]);  break;
++      case 't':  user_flip   = atoi(argv[arg++]);  break;
++      case 'q':  user_qual   = atoi(argv[arg++]);  break;
++      case 'm':  med_passes  = atoi(argv[arg++]);  break;
++      case 'H':  highlight   = atoi(argv[arg++]);  break;
++      case 's':
++	shot_select = abs(atoi(argv[arg]));
++	multi_out = !strcmp(argv[arg++],"all");
++	break;
++      case 'o':
++	if (isdigit(argv[arg][0]) && !argv[arg][1])
++	  output_color = atoi(argv[arg++]);
++#ifndef NO_LCMS
++	else     out_profile = argv[arg++];
++	break;
++      case 'p':  cam_profile = argv[arg++];
++#endif
++	break;
++      case 'P':  bpfile     = argv[arg++];  break;
++      case 'O':  outfile    = argv[arg++];  break;
++      case 'K':  dark_frame = argv[arg++];  break;
++      case 'z':  timestamp_only    = 1;  break;
++      case 'e':  thumbnail_only    = 1;  break;
++      case 'i':  identify_only     = 1;  break;
++      case 'c':  write_to_stdout   = 1;  break;
++      case 'v':  verbose           = 1;  break;
++      case 'h':  half_size         = 1;  break;
++      case 'f':  four_color_rgb    = 1;  break;
++      case 'A':  FORC4 greybox[c]  = atoi(argv[arg++]);
++      case 'a':  use_auto_wb       = 1;  break;
++      case 'w':  use_camera_wb     = 1;  break;
++      case 'M':  use_camera_matrix = 3 * (opm == '+');  break;
++      case 'I':  read_from_stdin   = 1;  break;
++      case 'E':  document_mode++;
++      case 'D':  document_mode++;
++      case 'd':  document_mode++;
++      case 'j':  use_fuji_rotate   = 0;  break;
++      case 'W':  no_auto_bright    = 1;  break;
++      case 'T':  output_tiff       = 1;  break;
++      case '4':  gamm[0] = gamm[1] =
++		 no_auto_bright    = 1;
++      case '6':  output_bps       = 16;  break;
++      default:
++	fprintf (stderr,_("Unknown option \"-%c\".\n"), opt);
++	return 1;
++    }
++  }
++  if (arg == argc) {
++    fprintf (stderr,_("No files to process.\n"));
++    return 1;
++  }
++  if (write_to_stdout) {
++    if (isatty(1)) {
++      fprintf (stderr,_("Will not write an image to the terminal!\n"));
++      return 1;
++    }
++#if defined(WIN32) || defined(DJGPP) || defined(__CYGWIN__)
++    if (setmode(1,O_BINARY) < 0) {
++      perror ("setmode()");
++      return 1;
++    }
++#endif
++  }
++  for ( ; arg < argc; arg++) {
++    status = 1;
++    raw_image = 0;
++    image = 0;
++    oprof = 0;
++    meta_data = ofname = 0;
++    ofp = stdout;
++    if (setjmp (failure)) {
++      if (fileno(ifp) > 2) fclose(ifp);
++      if (fileno(ofp) > 2) fclose(ofp);
++      status = 1;
++      goto cleanup;
++    }
++    ifname = argv[arg];
++    if (!(ifp = fopen (ifname, "rb"))) {
++      perror (ifname);
++      continue;
++    }
++    status = (identify(),!is_raw);
++    if (user_flip >= 0)
++      flip = user_flip;
++    switch ((flip+3600) % 360) {
++      case 270:  flip = 5;  break;
++      case 180:  flip = 3;  break;
++      case  90:  flip = 6;
++    }
++    if (timestamp_only) {
++      if ((status = !timestamp))
++	fprintf (stderr,_("%s has no timestamp.\n"), ifname);
++      else if (identify_only)
++	printf ("%10ld%10d %s\n", (long) timestamp, shot_order, ifname);
++      else {
++	if (verbose)
++	  fprintf (stderr,_("%s time set to %d.\n"), ifname, (int) timestamp);
++	ut.actime = ut.modtime = timestamp;
++	utime (ifname, &ut);
++      }
++      goto next;
++    }
++    write_fun = &CLASS write_ppm_tiff;
++    if (thumbnail_only) {
++      if ((status = !thumb_offset)) {
++	fprintf (stderr,_("%s has no thumbnail.\n"), ifname);
++	goto next;
++      } else if (thumb_load_raw) {
++	load_raw = thumb_load_raw;
++	data_offset = thumb_offset;
++	height = thumb_height;
++	width  = thumb_width;
++	filters = 0;
++	colors = 3;
++      } else {
++	fseek (ifp, thumb_offset, SEEK_SET);
++	write_fun = write_thumb;
++	goto thumbnail;
++      }
++    }
++    if (load_raw == &CLASS kodak_ycbcr_load_raw) {
++      height += height & 1;
++      width  += width  & 1;
++    }
++    if (identify_only && verbose && make[0]) {
++      printf (_("\nFilename: %s\n"), ifname);
++      printf (_("Timestamp: %s"), ctime(&timestamp));
++      printf (_("Camera: %s %s\n"), make, model);
++      if (artist[0])
++	printf (_("Owner: %s\n"), artist);
++      if (dng_version) {
++	printf (_("DNG Version: "));
++	for (i=24; i >= 0; i -= 8)
++	  printf ("%d%c", dng_version >> i & 255, i ? '.':'\n');
++      }
++      printf (_("ISO speed: %d\n"), (int) iso_speed);
++      printf (_("Shutter: "));
++      if (shutter > 0 && shutter < 1)
++	shutter = (printf ("1/"), 1 / shutter);
++      printf (_("%0.1f sec\n"), shutter);
++      printf (_("Aperture: f/%0.1f\n"), aperture);
++      printf (_("Focal length: %0.1f mm\n"), focal_len);
++      printf (_("Embedded ICC profile: %s\n"), profile_length ? _("yes"):_("no"));
++      printf (_("Number of raw images: %d\n"), is_raw);
++      if (pixel_aspect != 1)
++	printf (_("Pixel Aspect Ratio: %0.6f\n"), pixel_aspect);
++      if (thumb_offset)
++	printf (_("Thumb size:  %4d x %d\n"), thumb_width, thumb_height);
++      printf (_("Full size:   %4d x %d\n"), raw_width, raw_height);
++    } else if (!is_raw)
++      fprintf (stderr,_("Cannot decode file %s\n"), ifname);
++    if (!is_raw) goto next;
++    shrink = filters && (half_size || (!identify_only &&
++	(threshold || aber[0] != 1 || aber[2] != 1)));
++    iheight = (height + shrink) >> shrink;
++    iwidth  = (width  + shrink) >> shrink;
++    if (identify_only) {
++      if (verbose) {
++	if (document_mode == 3) {
++	  top_margin = left_margin = fuji_width = 0;
++	  height = raw_height;
++	  width  = raw_width;
++	}
++	iheight = (height + shrink) >> shrink;
++	iwidth  = (width  + shrink) >> shrink;
++	if (use_fuji_rotate) {
++	  if (fuji_width) {
++	    fuji_width = (fuji_width - 1 + shrink) >> shrink;
++	    iwidth = fuji_width / sqrt(0.5);
++	    iheight = (iheight - fuji_width) / sqrt(0.5);
++	  } else {
++	    if (pixel_aspect < 1) iheight = iheight / pixel_aspect + 0.5;
++	    if (pixel_aspect > 1) iwidth  = iwidth  * pixel_aspect + 0.5;
++	  }
++	}
++	if (flip & 4)
++	  SWAP(iheight,iwidth);
++	printf (_("Image size:  %4d x %d\n"), width, height);
++	printf (_("Output size: %4d x %d\n"), iwidth, iheight);
++	printf (_("Raw colors: %d"), colors);
++	if (filters) {
++	  int fhigh = 2, fwide = 2;
++	  if ((filters ^ (filters >>  8)) & 0xff)   fhigh = 4;
++	  if ((filters ^ (filters >> 16)) & 0xffff) fhigh = 8;
++	  if (filters == 1) fhigh = fwide = 16;
++	  if (filters == 9) fhigh = fwide = 6;
++	  printf (_("\nFilter pattern: "));
++	  for (i=0; i < fhigh; i++)
++	    for (c = i && putchar('/') && 0; c < fwide; c++)
++	      putchar (cdesc[fcol(i,c)]);
++	}
++	printf (_("\nDaylight multipliers:"));
++	FORCC printf (" %f", pre_mul[c]);
++	if (cam_mul[0] > 0) {
++	  printf (_("\nCamera multipliers:"));
++	  FORC4 printf (" %f", cam_mul[c]);
++	}
++	putchar ('\n');
++      } else
++	printf (_("%s is a %s %s image.\n"), ifname, make, model);
++next:
++      fclose(ifp);
++      continue;
++    }
++    if (meta_length) {
++      meta_data = (char *) malloc (meta_length);
++      merror (meta_data, "main()");
++    }
++    if (filters || colors == 1) {
++      raw_image = (ushort *) calloc ((raw_height+7), raw_width*2);
++      merror (raw_image, "main()");
++    } else {
++      image = (ushort (*)[4]) calloc (iheight, iwidth*sizeof *image);
++      merror (image, "main()");
++    }
++    if (verbose)
++      fprintf (stderr,_("Loading %s %s image from %s ...\n"),
++	make, model, ifname);
++    if (shot_select >= is_raw)
++      fprintf (stderr,_("%s: \"-s %d\" requests a nonexistent image!\n"),
++	ifname, shot_select);
++    fseeko (ifp, data_offset, SEEK_SET);
++    if (raw_image && read_from_stdin)
++      fread (raw_image, 2, raw_height*raw_width, stdin);
++    else (*load_raw)();
++    if (document_mode == 3) {
++      top_margin = left_margin = fuji_width = 0;
++      height = raw_height;
++      width  = raw_width;
++    }
++    iheight = (height + shrink) >> shrink;
++    iwidth  = (width  + shrink) >> shrink;
++    if (raw_image) {
++      image = (ushort (*)[4]) calloc (iheight, iwidth*sizeof *image);
++      merror (image, "main()");
++      crop_masked_pixels();
++      free (raw_image);
++    }
++    if (zero_is_bad) remove_zeroes();
++    bad_pixels (bpfile);
++    if (dark_frame) subtract (dark_frame);
++    quality = 2 + !fuji_width;
++    if (user_qual >= 0) quality = user_qual;
++    i = cblack[3];
++    FORC3 if (i > cblack[c]) i = cblack[c];
++    FORC4 cblack[c] -= i;
++    black += i;
++    i = cblack[6];
++    FORC (cblack[4] * cblack[5])
++      if (i > cblack[6+c]) i = cblack[6+c];
++    FORC (cblack[4] * cblack[5])
++      cblack[6+c] -= i;
++    black += i;
++    if (user_black >= 0) black = user_black;
++    FORC4 cblack[c] += black;
++    if (user_sat > 0) maximum = user_sat;
++#ifdef COLORCHECK
++    colorcheck();
++#endif
++    if (is_foveon) {
++      if (document_mode || load_raw == &CLASS foveon_dp_load_raw) {
++	for (i=0; i < height*width*4; i++)
++	  if ((short) image[0][i] < 0) image[0][i] = 0;
++      } else foveon_interpolate();
++    } else if (document_mode < 2)
++      scale_colors();
++    pre_interpolate();
++    if (filters && !document_mode) {
++      if (quality == 0)
++	lin_interpolate();
++      else if (quality == 1 || colors > 3)
++	vng_interpolate();
++      else if (quality == 2 && filters > 1000)
++	ppg_interpolate();
++      else if (filters == 9)
++	xtrans_interpolate (quality*2-3);
++      else
++	ahd_interpolate();
++    }
++    if (mix_green)
++      for (colors=3, i=0; i < height*width; i++)
++	image[i][1] = (image[i][1] + image[i][3]) >> 1;
++    if (!is_foveon && colors == 3) median_filter();
++    if (!is_foveon && highlight == 2) blend_highlights();
++    if (!is_foveon && highlight > 2) recover_highlights();
++    if (use_fuji_rotate) fuji_rotate();
++#ifndef NO_LCMS
++    if (cam_profile) apply_profile (cam_profile, out_profile);
++#endif
++    convert_to_rgb();
++    if (use_fuji_rotate) stretch();
++thumbnail:
++    if (write_fun == &CLASS jpeg_thumb)
++      write_ext = ".jpg";
++    else if (output_tiff && write_fun == &CLASS write_ppm_tiff)
++      write_ext = ".tiff";
++    else
++      write_ext = ".pgm\0.ppm\0.ppm\0.pam" + colors*5-5;
++    ofname = (char *) malloc (strlen(ifname) + 64);
++    merror (ofname, "main()");
++    if (write_to_stdout)
++      strcpy (ofname,_("standard output"));
++    else {
++      if (outfile)
++        strcpy (ofname,outfile);
++      else {
++        strcpy (ofname, ifname);
++      if ((cp = strrchr (ofname, '.'))) *cp = 0;
++      if (multi_out)
++	sprintf (ofname+strlen(ofname), "_%0*d",
++		snprintf(0,0,"%d",is_raw-1), shot_select);
++      if (thumbnail_only)
++	strcat (ofname, ".thumb");
++      strcat (ofname, write_ext);
++      }
++      ofp = fopen (ofname, "wb");
++      if (!ofp) {
++	status = 1;
++	perror (ofname);
++	goto cleanup;
++      }
++    }
++    if (verbose)
++      fprintf (stderr,_("Writing data to %s ...\n"), ofname);
++    (*write_fun)();
++    fclose(ifp);
++    if (ofp != stdout) fclose(ofp);
++cleanup:
++    if (meta_data) free (meta_data);
++    if (ofname) free (ofname);
++    if (oprof) free (oprof);
++    if (image) free (image);
++    if (multi_out) {
++      if (++shot_select < is_raw) arg--;
++      else shot_select = 0;
++    }
++  }
++  return status;
++}
+
+diff -ruN graphicsmagick_orig/dcraw/port/strnlen.c graphicsmagick/dcraw/port/strnlen.c
+--- graphicsmagick_orig/dcraw/port/strnlen.c	1970-01-01 01:00:00.000000000 +0100
++++ graphicsmagick/dcraw/port/strnlen.c	2021-06-04 12:17:20.710715767 +0200
+@@ -0,0 +1,18 @@
++
++#include <stdio.h>
++
++
++/** Implementation of posix' strnlen for systems where it's not available.
++ *
++ * Returns the number of characters before a null-byte in the string pointed
++ * to by str, unless there's no null-byte before maxlen. In the latter case
++ * maxlen is returned. */
++unsigned strnlen(const char *s, unsigned maxlen)
++{
++  register const char *e;
++  unsigned n;
++
++  for(e=s, n=0; *e && n<maxlen; e++, n++)
++    ;
++  return n;
++}
+
+--- graphicsmagick.orig/config/delegates.mgk.in	2021-06-04 12:17:20.662689000 +0200
++++ graphicsmagick/config/delegates.mgk.in	2021-06-04 12:34:16.975259869 +0200
+@@ -72,7 +72,7 @@
+ <delegatemap>
+   <delegate decode="browse" stealth="True" command='"@BrowseDelegate@" "http://www.GraphicsMagick.org/" &'  />
+   <delegate decode="cgm" command='"@CGMDecodeDelegate@" -d ps < "%i" > "%o" 2>/dev/null' />
+-  <delegate decode="dcraw" command='"@DCRAWDecodeDelegate@" -c -w @DcrawExtraOptions@ "%i" > "%o"' />
++  <delegate decode="dcraw" command='"@DCRAWDecodeDelegate@" -w @DcrawExtraOptions@ -O "%o" "%i"' />
+   <delegate decode="dot" command='"@DOTDecodeDelegate@" -Tps "%i" -o "%o"' />
+   <delegate decode="dvi" command='"@DVIDecodeDelegate@" -q -o "%o" "%i"' />
+   <delegate decode="edit" stealth="True" command='"@EditorDelegate@" -title "Edit Image Comment" -e vi "%o"' />
+   
--- a/src/mingw-hdf5-1.patch	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/mingw-hdf5-1.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -2268,108 +2268,182 @@
 +;
 +
 
-diff --git "a/src/H5win32defs.h" "b/src/H5win32defs.h"
-index 0a0bd37..405e9e8 100644
---- "a/src/H5win32defs.h"	
-+++ "b/src/H5win32defs.h"
-@@ -42,7 +42,7 @@ typedef __int64             h5_stat_size_t;
- #define HDisatty(F)         _isatty(F)
- 
- /* The isnan function needs underscore in VS2012 and earlier */
--#if (_MSC_VER <= 1700)
-+#if defined(_MSC_VER) && (_MSC_VER <= 1700)
-   #define HDisnan(X)      _isnan(X)
- #endif /* MSC_VER < 1700 */
- 
-diff --git "a/src/CMakeLists.txt" "b/src/CMakeLists.txt"
---- "a/src/CMakeLists.txt"	
-+++ "b/src/CMakeLists.txt"
-@@ -1087,7 +1087,8 @@ else ()
-   endif ()
+
+Generating the files above requires executing programs natively. That doesn't
+work when cross-compiling. Instead modify build rules to take the pre-generated
+files from above.
+
+diff -rNu a/src/CMakeLists.txt b/src/CMakeLists.txt
+--- a/src/CMakeLists.txt	2021-07-01 23:26:40.000000000 +0200
++++ b/src/CMakeLists.txt	2021-10-19 16:38:19.588486107 +0200
+@@ -1069,6 +1069,19 @@
+         COMMAND ${CMAKE_COMMAND} -P ${HDF5_SOURCE_DIR}/config/cmake/wait_H5Tinit.cmake
+     )
+     set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c PROPERTIES GENERATED TRUE)
++    if (BUILD_SHARED_LIBS)
++      add_custom_command (TARGET H5detect POST_BUILD
++          COMMAND    ${CMAKE_COMMAND}
++          ARGS       -E copy_if_different H5Tinit.c shared/H5Tinit.c
++          BYPRODUCTS shared/H5Tinit.c shared/shared_gen_SRCS.stamp1
++          COMMAND    ${CMAKE_COMMAND}
++          ARGS       -E touch shared/shared_gen_SRCS.stamp1
++          DEPENDS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit_created
++          WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR}
++          COMMENT    "Copy H5Tinit.c to shared folder"
++      )
++      set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c PROPERTIES GENERATED TRUE)
++    endif ()
+   else ()
+     add_custom_command (TARGET H5detect POST_BUILD
+         COMMAND    ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:H5detect>
+@@ -1100,20 +1113,20 @@
+       OUTPUT     gen_SRCS.stamp1
+       COMMAND    ${CMAKE_COMMAND}
+       ARGS       -E touch gen_SRCS.stamp1
+-      DEPENDS H5Tinit.c
++      DEPENDS    ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c
+       WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR}
+       COMMENT    "Touch existing H5Tinit.c"
+   )
+   set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c PROPERTIES GENERATED TRUE)
+   if (BUILD_SHARED_LIBS)
+     add_custom_command (
+-        OUTPUT     shared/shared_gen_SRCS.stamp1
++        OUTPUT     ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp1
+         COMMAND    ${CMAKE_COMMAND}
+-        ARGS       -E copy_if_different H5Tinit.c shared/H5Tinit.c
++        ARGS       -E copy_if_different "${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c" "${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c"
+         BYPRODUCTS shared/H5Tinit.c shared/shared_gen_SRCS.stamp1
+         COMMAND    ${CMAKE_COMMAND}
+         ARGS       -E touch shared/shared_gen_SRCS.stamp1
+-        DEPENDS H5Tinit.c
++        DEPENDS    ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c
+         WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR}
+         COMMENT    "Copy existing H5Tinit.c to shared folder"
+     )
+@@ -1128,6 +1141,7 @@
+   clang_format (HDF5_SRC_DETECT_FORMAT ${HDF5_SRC_DIR}/H5detect.c)
  endif ()
  
 +if (NOT EXISTS "${HDF5_GENERATED_SOURCE_DIR}/H5lib_settings.c")
  add_executable (H5make_libsettings ${HDF5_SRC_DIR}/H5make_libsettings.c)
- target_include_directories (H5make_libsettings PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
+ target_include_directories (H5make_libsettings PRIVATE "${HDF5_SRC_DIR};${HDF5_SRC_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>")
  target_compile_definitions(H5make_libsettings PUBLIC ${HDF_EXTRA_C_FLAGS} ${HDF_EXTRA_FLAGS})
- TARGET_C_PROPERTIES (H5make_libsettings STATIC)
-@@ -1097,28 +1098,49 @@ target_link_libraries (H5make_libsettings
+@@ -1157,7 +1171,7 @@
+     WORKING_DIRECTORY ${HDF5_SRC_BINARY_DIR}
+     COMMENT    "Create H5lib_settings.c"
  )
- 
- add_custom_command (
--    OUTPUT ${HDF5_BINARY_DIR}/H5lib_settings.c
--           ${HDF5_BINARY_DIR}/gen_SRCS.stamp2
-+    OUTPUT ${HDF5_GENERATED_SOURCE_DIR}/H5lib_settings.c
-+           ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp2
-     COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:H5make_libsettings>
--    ARGS ${HDF5_BINARY_DIR}/H5lib_settings.c
-+    ARGS ${HDF5_GENERATED_SOURCE_DIR}/H5lib_settings.c
-     COMMAND    ${CMAKE_COMMAND}
-     ARGS       -E touch ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp2
-     DEPENDS H5make_libsettings
--    WORKING_DIRECTORY ${HDF5_BINARY_DIR}
-+    WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR}
- )
--set_source_files_properties (${HDF5_BINARY_DIR}/H5lib_settings.c PROPERTIES GENERATED TRUE)
+-set_source_files_properties (${HDF5_SRC_BINARY_DIR}/H5lib_settings.c PROPERTIES GENERATED TRUE)
 +set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/H5lib_settings.c PROPERTIES GENERATED TRUE)
  if (BUILD_SHARED_LIBS)
-   add_custom_command (
--      OUTPUT ${HDF5_BINARY_DIR}/shared/H5lib_settings.c
--             ${HDF5_BINARY_DIR}/shared/shared_gen_SRCS.stamp2
-+      OUTPUT ${HDF5_GENERATED_SOURCE_DIR}/shared/H5lib_settings.c
-+             ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp2
+   add_custom_command (TARGET H5make_libsettings POST_BUILD
+       COMMAND    ${CMAKE_COMMAND}
+@@ -1166,11 +1180,32 @@
        COMMAND    ${CMAKE_COMMAND}
--      ARGS       -E copy_if_different "${HDF5_BINARY_DIR}/H5lib_settings.c" "${HDF5_BINARY_DIR}/shared/H5lib_settings.c"
-+      ARGS       -E copy_if_different "${HDF5_GENERATED_SOURCE_DIR}/H5lib_settings.c" "${HDF5_GENERATED_SOURCE_DIR}/shared/H5lib_settings.c"
-       COMMAND    ${CMAKE_COMMAND}
-       ARGS       -E touch ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp2
--      DEPENDS    ${HDF5_BINARY_DIR}/H5lib_settings.c
--      WORKING_DIRECTORY ${HDF5_BINARY_DIR}
+       ARGS       -E touch shared/shared_gen_SRCS.stamp2
+       DEPENDS H5make_libsettings H5lib_settings.c
+-      WORKING_DIRECTORY ${HDF5_SRC_BINARY_DIR}
++      WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR}
+       COMMENT    "Copy H5lib_settings.c to shared folder"
+   )
+-  set_source_files_properties (${HDF5_SRC_BINARY_DIR}/shared/H5lib_settings.c PROPERTIES GENERATED TRUE)
++  set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/shared/H5lib_settings.c PROPERTIES GENERATED TRUE)
+ endif ()
++else ()
++  add_custom_command (
++      OUTPUT gen_SRCS.stamp2
++      COMMAND    ${CMAKE_COMMAND}
++      ARGS       -E touch gen_SRCS.stamp2
 +      DEPENDS    ${HDF5_GENERATED_SOURCE_DIR}/H5lib_settings.c
 +      WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR}
-+  )
-+  set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/shared/H5lib_settings.c PROPERTIES GENERATED TRUE)
-+endif ()
-+else ()
-+  add_custom_command (
-+      OUTPUT ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp2
-+      COMMAND    ${CMAKE_COMMAND}
-+      ARGS       -E touch ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp2
-+      DEPENDS    ${HDF5_GENERATED_SOURCE_DIR}/H5lib_settings.c
-+      WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR}
-   )
--  set_source_files_properties (${HDF5_BINARY_DIR}/shared/H5lib_settings.c PROPERTIES GENERATED TRUE)
++   )
 +  if (BUILD_SHARED_LIBS)
 +    add_custom_command (
 +        OUTPUT     ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp2
 +        COMMAND    ${CMAKE_COMMAND}
 +        ARGS       -E copy_if_different "${HDF5_GENERATED_SOURCE_DIR}/H5lib_settings.c" "${HDF5_GENERATED_SOURCE_DIR}/shared/H5lib_settings.c"
 +        COMMAND    ${CMAKE_COMMAND}
-+        ARGS       -E touch ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp2
++        ARGS       -E touch shared/shared_gen_SRCS.stamp2
 +        DEPENDS    ${HDF5_GENERATED_SOURCE_DIR}/H5lib_settings.c
 +        WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR}
 +    )
 +    set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/shared/H5lib_settings.c PROPERTIES GENERATED TRUE)
 +  endif ()
- endif ()
++ endif ()
  
  ## all_packages="AC,B,B2,D,F,FA,FL,FS,HL,I,O,S,ST,T,Z"
-@@ -1129,7 +1151,7 @@ option (HDF5_ENABLE_DEBUG_APIS "Turn on extra debug output in all packages" OFF)
+ #all_packages="AC,B2,CX,D,F,HL,I,O,S,ST,T,Z"
+@@ -1180,7 +1215,7 @@
  # Add H5Tinit source to build - generated by H5detect/CMake at configure time
  #-----------------------------------------------------------------------------
  if (NOT ONLY_SHARED_LIBS)
--  set (gen_SRCS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c ${HDF5_BINARY_DIR}/H5lib_settings.c)
-+  set (gen_SRCS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c ${HDF5_GENERATED_SOURCE_DIR}/H5lib_settings.c)
-   add_custom_target (gen_${HDF5_LIB_TARGET} ALL DEPENDS ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp1 ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp2)
- 
-   add_library (${HDF5_LIB_TARGET} STATIC ${common_SRCS} ${gen_SRCS} ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS} ${H5_GENERATED_HEADERS})
-@@ -1164,7 +1186,7 @@ if (NOT ONLY_SHARED_LIBS)
+-  set (gen_SRCS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c ${HDF5_SRC_BINARY_DIR}/H5lib_settings.c)
++  set (gen_SRCS H5Tinit.c ${HDF5_GENERATED_SOURCE_DIR}/H5lib_settings.c)
+   add_custom_target (gen_${HDF5_LIB_TARGET} ALL
+     DEPENDS ${lib_prog_deps} ${gen_SRCS} ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp1 ${HDF5_SRC_BINARY_DIR}/gen_SRCS.stamp2
+     COMMENT "Generation target files"
+@@ -1219,9 +1254,9 @@
  endif ()
  
  if (BUILD_SHARED_LIBS)
--  set (shared_gen_SRCS ${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c ${HDF5_BINARY_DIR}/shared/H5lib_settings.c)
+-  set (shared_gen_SRCS ${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c ${HDF5_SRC_BINARY_DIR}/shared/H5lib_settings.c)
 +  set (shared_gen_SRCS ${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c ${HDF5_GENERATED_SOURCE_DIR}/shared/H5lib_settings.c)
-   add_custom_target (gen_${HDF5_LIBSH_TARGET} ALL DEPENDS ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp1 ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp2)
+   add_custom_target (gen_${HDF5_LIBSH_TARGET} ALL
+-    DEPENDS ${lib_prog_deps} ${shared_gen_SRCS} ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp1 ${HDF5_SRC_BINARY_DIR}/shared/shared_gen_SRCS.stamp2
++    DEPENDS ${lib_prog_deps} ${shared_gen_SRCS} ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp1 ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp2
+     COMMENT "Shared generation target files"
+   )
+ 
+@@ -1404,7 +1439,7 @@
+   configure_file (${HDF5_DOXYGEN_DIR}/Doxyfile.in ${HDF5_BINARY_DIR}/Doxyfile @ONLY)
+   add_custom_target (hdf5lib_doc ALL
+         COMMAND ${DOXYGEN_EXECUTABLE} ${HDF5_BINARY_DIR}/Doxyfile
+-        DEPENDS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c ${HDF5_SRC_BINARY_DIR}/H5lib_settings.c
++        DEPENDS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c ${HDF5_GENERATED_SOURCE_DIR}/H5lib_settings.c
+         WORKING_DIRECTORY ${HDF5_SRC_DIR}
+         COMMENT "Generating HDF5 library Source API documentation with Doxygen"
+         VERBATIM )
+
+
+Remove hard-coded test program that should write to a text file.
+Provide the result of that program (executed on Windows 10 64bit mingw32) as a
+string instead.
+
+diff -rNu a/config/cmake/ConfigureChecks.cmake b/config/cmake/ConfigureChecks.cmake
+--- a/config/cmake/ConfigureChecks.cmake	2021-07-01 23:26:38.000000000 +0200
++++ b/config/cmake/ConfigureChecks.cmake	2021-10-19 16:21:55.391645870 +0200
+@@ -305,33 +305,7 @@
+     endif ()
+ endmacro ()
  
-   add_library (${HDF5_LIBSH_TARGET} SHARED ${common_SRCS} ${shared_gen_SRCS} ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS} ${H5_GENERATED_HEADERS})
-
+-set (PROG_SRC
+-    "
+-#include <float.h>\n\
+-#include <stdio.h>\n\
+-#define CHECK_FLOAT128 _SIZEOF___FLOAT128\n\
+-#if CHECK_FLOAT128!=0\n\
+-#if _HAVE_QUADMATH_H!=0\n\
+-#include <quadmath.h>\n\
+-#endif\n\
+-#ifdef FLT128_DIG\n\
+-#define C_FLT128_DIG FLT128_DIG\n\
+-#else\n\
+-#define C_FLT128_DIG 0\n\
+-#endif\n\
+-#else\n\
+-#define C_FLT128_DIG 0\n\
+-#endif\n\
+-#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L\n\
+-#define C_LDBL_DIG DECIMAL_DIG\n\
+-#else\n\
+-#define C_LDBL_DIG LDBL_DIG\n\
+-#endif\n\nint main() {\nFILE *pFile = fopen(\"pac_Cconftest.out\",\"w\")\\\;\nfprintf(pFile, \"\\%d\\\;\\%d\\\;\", C_LDBL_DIG, C_FLT128_DIG)\\\;\n\nreturn 0\\\;\n}\n
+-     "
+-)
+-
+-C_RUN ("maximum decimal precision for C" ${PROG_SRC} PROG_RES)
+-file (READ "${RUN_OUTPUT_PATH_DEFAULT}/pac_Cconftest.out" PROG_OUTPUT4)
++set (PROG_OUTPUT4 "21;33;")
+ message (STATUS "Testing maximum decimal precision for C - ${PROG_OUTPUT4}")
+ 
+ # dnl The output from the above program will be:
--- a/src/mingw-lapack-1-xerbla.patch	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/mingw-lapack-1-xerbla.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -4,7 +4,7 @@
 @@ -37,7 +37,7 @@
  
  set(ALLAUX ilaenv.f ilaenv2stage.f ieeeck.f lsamen.f iparmq.f iparam2stage.F
-    ilaprec.f ilatrans.f ilauplo.f iladiag.f chla_transtype.f
+    ilaprec.f ilatrans.f ilauplo.f iladiag.f chla_transtype.f la_xisnan.F90
 -   ../INSTALL/ilaver.f ../INSTALL/lsame.f xerbla.f xerbla_array.f
 +   ../INSTALL/ilaver.f ../INSTALL/lsame.f xerbla_array.f
     ../INSTALL/slamch.f)
@@ -13,12 +13,12 @@
 diff -ur lapack-3.8.0.orig/SRC/Makefile lapack-3.8.0/SRC/Makefile
 --- lapack-3.8.0.orig/SRC/Makefile	2018-11-07 11:53:43.337468050 -0500
 +++ lapack-3.8.0/SRC/Makefile	2018-11-07 11:56:19.701220847 -0500
-@@ -56,7 +56,7 @@
- #
- #######################################################################
+@@ -69,7 +69,7 @@
+ .o.mod:
+ 	@true
  
 -ALLAUX = ilaenv.o ilaenv2stage.o ieeeck.o lsamen.o xerbla.o xerbla_array.o \
 +ALLAUX = ilaenv.o ilaenv2stage.o ieeeck.o lsamen.o xerbla_array.o \
-    iparmq.o iparam2stage.o \
+    iparmq.o iparam2stage.o la_xisnan.o \
     ilaprec.o ilatrans.o ilauplo.o iladiag.o chla_transtype.o \
     ../INSTALL/ilaver.o ../INSTALL/lsame.o ../INSTALL/slamch.o
--- a/src/mingw-libgcrypt-1-fixes.patch	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/mingw-libgcrypt-1-fixes.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -58,33 +58,6 @@
  
 
 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Saikrishna Arcot <saiarcot895@gmail.com>
-Date: Fri, 12 Jun 2015 14:53:55 -0700
-Subject: [PATCH 2/3] Don't call git to determine the revision.
-
-
-diff --git a/configure.ac b/configure.ac
-index 1111111..2222222 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -38,13 +38,10 @@ m4_define(mym4_version_micro, [1])
- # processing is done by autoconf and not during the configure run.
- m4_define(mym4_version,
-           [mym4_version_major.mym4_version_minor.mym4_version_micro])
--m4_define([mym4_revision],
--          m4_esyscmd([git rev-parse --short HEAD | tr -d '\n\r']))
-+m4_define([mym4_revision], [4091])
- m4_define([mym4_revision_dec],
-           m4_esyscmd_s([echo $((0x$(echo ]mym4_revision[|head -c 4)))]))
--m4_define([mym4_betastring],
--          m4_esyscmd_s([git describe --match 'libgcrypt-[0-9].*[0-9]' --long|\
--                        awk -F- '$3!=0{print"-beta"$3}']))
-+m4_define([mym4_betastring], [])
- m4_define([mym4_isgit],m4_if(mym4_betastring,[],[no],[yes]))
- m4_define([mym4_full_version],[mym4_version[]mym4_betastring])
- 
-
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: "Richard W.M. Jones" <rjones@redhat.com>
 Date: Sun, 28 Jun 2015 17:17:25 +0200
 Subject: [PATCH 3/3] configure.ac: no serial-tests if automake < 1.12
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mingw-pkg-config-1-gnu-printf.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,86 @@
+diff -Naur a/glib/configure.ac b/glib/configure.ac
+--- a/glib/configure.ac	2015-09-21 15:38:33.000000000 +0300
++++ b/glib/configure.ac	2015-09-22 09:09:02.118820700 +0300
+@@ -567,7 +567,7 @@
+ ])
+ fi
+ 
+-AS_IF([test x$glib_native_win32 != xyes && test x$ac_cv_sizeof_long_long = x8], [
++AS_IF([test x$ac_cv_sizeof_long_long = x8], [
+ 	# long long is a 64 bit integer.
+ 	AC_MSG_CHECKING(for format to printf and scanf a guint64)
+ 	AC_CACHE_VAL(glib_cv_long_long_format,[
+@@ -589,8 +589,8 @@
+ 	AS_IF([ test -n "$glib_cv_long_long_format"], [
+ 	  AC_MSG_RESULT(%${glib_cv_long_long_format}u)
+ 	  AC_DEFINE(HAVE_LONG_LONG_FORMAT,1,[define if system printf can print long long])
+-	  if test x"$glib_cv_long_long_format" = xI64; then
+-	    AC_DEFINE(HAVE_INT64_AND_I64,1,[define to support printing 64-bit integers with format I64])
++	  if test x"$glib_cv_long_long_format" = xll; then
++	    AC_DEFINE(HAVE_INT64_AND_I64,1,[define to support printing 64-bit integers with format ll])
+           fi
+ 	], [AC_MSG_RESULT(none)])
+ ],[ test x$ac_cv_sizeof___int64 = x8], [
+@@ -3177,8 +3177,8 @@
+   glib_msize_type='LONG'
+   ;;
+ "long long"|__int64)
+-  gsize_modifier='"I64"'
+-  gsize_format='"I64u"'
++  gsize_modifier='"z"'
++  gsize_format='"zu"'
+   glib_msize_type='INT64'
+   ;;
+ esac
+@@ -3200,8 +3200,8 @@
+   glib_mssize_type='LONG'
+   ;;
+ "long long"|__int64)
+-  gssize_modifier='"I64"'
+-  gssize_format='"I64i"'
++  gssize_modifier='"z"'
++  gssize_format='"zi"'
+   glib_mssize_type='INT64'
+   ;;
+ esac
+@@ -3230,9 +3230,9 @@
+   ;;
+ $ac_cv_sizeof_long_long)
+   glib_intptr_type_define='long long'
+-  gintptr_modifier='"I64"'
+-  gintptr_format='"I64i"'
+-  guintptr_format='"I64u"'
++  gintptr_modifier='"ll"'
++  gintptr_format='"lli"'
++  guintptr_format='"llu"'
+   glib_gpi_cast='(gint64)'
+   glib_gpui_cast='(guint64)'
+   ;;
+diff -Naur a/glib/glib/gmacros.h b/glib/glib/gmacros.h
+--- a/glib/glib/gmacros.h	2015-08-19 06:35:30.000000000 +0300
++++ b/glib/glib/gmacros.h	2015-09-22 09:09:02.118820700 +0300
+@@ -79,9 +79,9 @@
+ 
+ #if     __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
+ #define G_GNUC_PRINTF( format_idx, arg_idx )    \
+-  __attribute__((__format__ (__printf__, format_idx, arg_idx)))
++  __attribute__((__format__ (gnu_printf, format_idx, arg_idx)))
+ #define G_GNUC_SCANF( format_idx, arg_idx )     \
+-  __attribute__((__format__ (__scanf__, format_idx, arg_idx)))
++  __attribute__((__format__ (gnu_scanf, format_idx, arg_idx)))
+ #define G_GNUC_FORMAT( arg_idx )                \
+   __attribute__((__format_arg__ (arg_idx)))
+ #define G_GNUC_NORETURN                         \
+diff -Naur a/glib/glib/gpoll.h b/glib/glib/gpoll.h
+--- a/glib/glib/gpoll.h	2014-12-20 00:49:48.000000000 +0300
++++ b/glib/glib/gpoll.h	2015-09-22 09:09:02.118820700 +0300
+@@ -108,7 +108,7 @@
+  */
+ #ifdef G_OS_WIN32
+ #if GLIB_SIZEOF_VOID_P == 8
+-#define G_POLLFD_FORMAT "%#I64x"
++#define G_POLLFD_FORMAT "%#llx"
+ #else
+ #define G_POLLFD_FORMAT "%#x"
+ #endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mingw-texinfo-2-makeinfo-non-ASCII-perl.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,16 @@
+"perl" cannot run scripts in paths with non-ASCII characters on Windows.
+To work around that, change to the directory containing the script first,
+then call it without path.
+FIXME: Could changing the directory have negative side effects for the
+"makeinfo" script?
+
+diff --git "a/util/makeinfo.bat" "b/util/makeinfo.bat"
+index 5ae4286..6a51502 100644
+--- "a/util/makeinfo.bat"	
++++ "b/util/makeinfo.bat"	
+@@ -1,2 +1,4 @@
+ @echo off
+-perl "%~dpn0" %*
++%~d0
++cd "%~dp0"
++perl "%~n0" %*
--- a/src/mingw-w64-1-float-h.patch	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/mingw-w64-1-float-h.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -1,9 +1,11 @@
 This file is part of MXE. See LICENSE.md for licensing information.
 
+Contains ad hoc patches for cross building.
+
 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: Mark Brand <mabrand@mabrand.nl>
 Date: Sun, 29 Mar 2015 14:36:38 +0200
-Subject: [PATCH 1/2] workaround for -isystem flag messing up include order
+Subject: [PATCH 1/1] workaround for -isystem flag messing up include order
 
 https://bugzilla.redhat.com/show_bug.cgi?id=843436
 
@@ -27,35 +29,3 @@
  	/* Addition rounds to 0: zero, 1: nearest, 2: +inf, 3: -inf, -1: unknown.  */
  	/* ??? This is supposed to change with calls to fesetround in <fenv.h>.  */
  	#undef FLT_ROUNDS
-
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Jonathan Yong <10walls@gmail.com>
-Date: Fri, 22 Dec 2017 13:01:03 +0000
-Subject: [PATCH 2/2] dwmapi.def: Regenegerate from Windows 10
-
-Remove ordinals from x86 library too.
-
-Signed-off-by: Jonathan Yong <10walls@gmail.com>
-
-Taken from: https://sourceforge.net/p/mingw-w64/mailman/message/36166386/
-
-diff --git a/mingw-w64-headers/crt/float.h b/mingw-w64-headers/crt/float.h
-index 1111111..2222222 100644
---- a/mingw-w64-headers/crt/float.h
-+++ b/mingw-w64-headers/crt/float.h
-@@ -114,6 +114,15 @@
- 	#define DBL_MAX_10_EXP	__DBL_MAX_10_EXP__
- 	#define LDBL_MAX_10_EXP	__LDBL_MAX_10_EXP__
- 
-+    /* The difference between 1 and the least value greater than 1 that is
-+    representable in the given floating point type, b**1-p.  */
-+    #undef FLT_EPSILON
-+    #undef DBL_EPSILON
-+    #undef LDBL_EPSILON
-+    #define FLT_EPSILON __FLT_EPSILON__
-+    #define DBL_EPSILON __DBL_EPSILON__
-+    #define LDBL_EPSILON    __LDBL_EPSILON__
-+
-     /* The difference between 1 and the least value greater than 1 that is
-     representable in the given floating point type, b**1-p.  */
-     #undef FLT_EPSILON
--- a/src/mingw-w64.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/mingw-w64.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,28 +3,41 @@
 
 PKG             := mingw-w64
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 7.0.0
-$(PKG)_CHECKSUM := 25940043c4541e3e59608dead9b6f75b5596d606
+$(PKG)_VERSION  := 9.0.0
+$(PKG)_CHECKSUM := 9c496ed063e085888d250cc461ec4d31d97b72f1
 $(PKG)_SUBDIR   := $(PKG)-v$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-v$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/$(PKG)/$(PKG)/$(PKG)-release/$($(PKG)_FILE)
 $(PKG)_DEPS     :=
 
 define $(PKG)_UPDATE
-    $(WGET) -q -O- 'http://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-release/' | \
-    $(SED) -n 's,.*mingw-w64-v\([0-9.]*\)\.tar.*,\1,p' | \
-    $(SORT) -V | \
-    tail -1
+  $(WGET) -q -O- 'http://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-release/' | \
+  $(SED) -n 's,.*mingw-w64-v\([0-9.]*\)\.tar.*,\1,p' | \
+  $(SORT) -V | \
+  tail -1
 endef
 
+ifneq ($(OCTAVE_TARGET),release-octave)
+  # FIXME: Set unconditionally for the first release candidate of Octave 7.
+  $(PKG)_WINAPI_VERSION_FLAGS := --with-default-win32-winnt=0x0601
+endif
+
+ifneq ($(HOST_MSVCRT),ucrt)
+  $(PKG)_DEFAULT_MSVCRT := --with-default-msvcrt=msvcrt
+else
+  $(PKG)_DEFAULT_MSVCRT := --with-default-msvcrt=ucrt
+endif
+
 define $(PKG)_BUILD
-    mkdir '$(1).headers-build'
-    cd '$(1).headers-build' && '$(1)/mingw-w64-headers/configure' \
-        --host='$(TARGET)' \
-        --prefix='$(HOST_PREFIX)' \
-        --enable-sdk=all \
-        --enable-idl \
-        --enable-secure-api
+  mkdir '$(1).headers-build'
+  cd '$(1).headers-build' && '$(1)/mingw-w64-headers/configure' \
+    --host='$(TARGET)' \
+    --prefix='$(HOST_PREFIX)' \
+    --enable-sdk=all \
+    --enable-idl \
+    --enable-secure-api \
+    $($(PKG)_WINAPI_VERSION_FLAGS) \
+    $($(PKG)_DEFAULT_MSVCRT)
 
-    $(MAKE) -C '$(1).headers-build' install
+  $(MAKE) -C '$(1).headers-build' install
 endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mingw-zeromq-1-fixes.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,64 @@
+--- a/tests/testutil.cpp
++++ b/tests/testutil.cpp
+@@ -382,7 +382,7 @@ fd_t connect_socket (const char *endpoint_, const int af_, const int protocol_)
+                                protocol_ == IPPROTO_UDP
+                                  ? IPPROTO_UDP
+                                  : protocol_ == IPPROTO_TCP ? IPPROTO_TCP : 0);
+-    TEST_ASSERT_NOT_EQUAL (-1, s_pre);
++    TEST_ASSERT_NOT_EQUAL (retired_fd, s_pre);
+
+     if (af_ == AF_INET || af_ == AF_INET6) {
+         const char *port = strrchr (endpoint_, ':') + 1;
+@@ -439,7 +439,7 @@ fd_t bind_socket_resolve_port (const char *address_,
+                                protocol_ == IPPROTO_UDP
+                                  ? IPPROTO_UDP
+                                  : protocol_ == IPPROTO_TCP ? IPPROTO_TCP : 0);
+-    TEST_ASSERT_NOT_EQUAL (-1, s_pre);
++    TEST_ASSERT_NOT_EQUAL (retired_fd, s_pre);
+
+     if (af_ == AF_INET || af_ == AF_INET6) {
+ #ifdef ZMQ_HAVE_WINDOWS
+
+--- a/tests/testutil.hpp
++++ b/tests/testutil.hpp
+@@ -102,7 +102,6 @@ const uint8_t zmtp_ready_sub[27] = {
+ #include <winsock2.h>
+ #include <ws2tcpip.h>
+ #include <stdexcept>
+-#define close closesocket
+ typedef int socket_size_t;
+ inline const char *as_setsockopt_opt_t (const void *opt)
+ {
+
+--- a/tests/testutil.cpp
++++ b/tests/testutil.cpp
+@@ -296,7 +296,7 @@ int is_ipv6_available ()
+                 ipv6 = 0;
+         }
+ #endif
+-        close (fd);
++        closesocket (fd);
+     }
+
+     return ipv6;
+@@ -484,7 +484,7 @@ fd_t bind_socket_resolve_port (const char *address_,
+ #else
+         int fd = mkstemp (buffer);
+         TEST_ASSERT_TRUE (fd != -1);
+-        close (fd);
++        closesocket (fd);
+ #endif
+ #endif
+         strcpy ((*(struct sockaddr_un *) &addr).sun_path, buffer);
+diff -ur zeromq-4.3.3.orig/Makefile.in zeromq-4.3.3/Makefile.in
+--- zeromq-4.3.3.orig/Makefile.in	2021-01-16 16:58:57.118548621 -0500
++++ zeromq-4.3.3/Makefile.in	2021-01-16 17:07:39.885588121 -0500
+@@ -2881,7 +2881,7 @@
+ 	$(am__append_29) $(am__append_30) $(am__append_31) \
+ 	$(am__append_32) $(am__append_33) $(am__append_36) \
+ 	$(am__append_37) $(am__append_38) $(am__append_39)
+-UNITY_CPPFLAGS = -I$(top_srcdir)/external/unity -DUNITY_USE_COMMAND_LINE_ARGS -DUNITY_EXCLUDE_FLOAT
++UNITY_CPPFLAGS = -I$(top_srcdir)/external/unity -DUNITY_USE_COMMAND_LINE_ARGS -DUNITY_EXCLUDE_FLOAT -D__USE_MINGW_ANSI_STDIO=1
+ UNITY_LIBS = $(top_builddir)/external/unity/libunity.a
+ external_unity_libunity_a_SOURCES = external/unity/unity.c \
+ 	external/unity/unity.h \
--- a/src/mpfr.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/mpfr.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,16 +3,16 @@
 
 PKG             := mpfr
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 4.0.2
-$(PKG)_CHECKSUM := 52c1f2a4c9a202f46cf3275a8d46b562aa584208
+$(PKG)_VERSION  := 4.1.0
+$(PKG)_CHECKSUM := 159c3a58705662bfde4dc93f2617f3660855ead6
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := ftp://ftp.gnu.org/gnu/mpfr/$($(PKG)_FILE)
-$(PKG)_URL_2    := http://www.mpfr.org/mpfr-$($(PKG)_VERSION)/$($(PKG)_FILE)
+$(PKG)_URL_2    := https://www.mpfr.org/mpfr-$($(PKG)_VERSION)/$($(PKG)_FILE)
 $(PKG)_DEPS     := build-gcc gmp
 
 define $(PKG)_UPDATE
-    $(WGET) -q -O- 'https://gforge.inria.fr/scm/viewvc.php/mpfr/tags/' | \
+    $(WGET) -q -O- 'https://www.mpfr.org/mpfr-current/' | \
     $(SED) -n 's,.*tags/\([0-9][^/]*\).*,\1,p' |
     $(SORT) -V | \
     tail -1
--- a/src/msys2-bash.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-bash.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-bash
 $(PKG)_NAME     := bash
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 4.4.023-2
-$(PKG)_x86_64_CS := 848e82bda353cfa817aab58068f26de1dc8ebb55
-$(PKG)_i686_CS  := bceb04296febb3632f20f4ada02ce6f1bbd6c21d
+$(PKG)_VERSION  := 5.1.008-1
+$(PKG)_x86_64_CS := c596a9b3a0e9831df75048f46dbcd955be5965eb
+$(PKG)_i686_CS  := 7bb03bfb3f5a432e1aaad2971b0896bee90b2ef9
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/msys2-ca-certificates.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,33 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := msys2-ca-certificates
+$(PKG)_NAME     := ca-certificates
+$(PKG)_IGNORE   :=
+$(PKG)_VERSION  := 20210119-1
+$(PKG)_x86_64_CS := 5c1c4a20b87ed27ba87b8a099b246a2eee5be7e8
+$(PKG)_i686_CS  := c2b2fe6e9a80c60f564fb50e9db40e88fba80e1c
+$(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
+$(PKG)_CHECKSUM := $($(PKG)_CS)
+$(PKG)_SUBDIR   := 
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
+$(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_NAME)-$($(PKG)_VERSION)-any.pkg.tar.zst
+
+$(PKG)_DEPS     := msys2-openssl
+
+define $(PKG)_UPDATE
+    $(MSYS2_PKG_UPDATE)
+endef
+
+define $(PKG)_BUILD
+    # we need do create a post install for the certs
+    mkdir -p "$(1)/etc/post-install"
+    cat "$(1)/.INSTALL" > "$(1)/etc/post-install/07-ca-certificates.post"
+    echo "" >> "$(1)/etc/post-install/07-ca-certificates.post"
+    echo "if [ ! -d /etc/pacman.d/gnupg ]" >> "$(1)/etc/post-install/07-ca-certificates.post"
+    echo "then" >> "$(1)/etc/post-install/07-ca-certificates.post"
+    echo "  (cd / && post_install)" >> "$(1)/etc/post-install/07-ca-certificates.post"
+    echo "fi" >> "$(1)/etc/post-install/07-ca-certificates.post"
+
+    $(MSYS2_PKG_BUILD)
+endef
--- a/src/msys2-dos2unix.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-dos2unix.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-dos2unix
 $(PKG)_NAME     := dos2unix
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 7.4.1-1
-$(PKG)_x86_64_CS := 08aec6e840765af492691b6aab0b6ddf4cd54eff
-$(PKG)_i686_CS  := 541f5b8addcd6950008917c7242e4169e8d2e726
+$(PKG)_VERSION  := 7.4.2-1
+$(PKG)_x86_64_CS := 5fe9bc87b5a547b615a15622a7b95309094c1dda
+$(PKG)_i686_CS  := 92260b4794003deeb6c6ad37f33a42bb13cd329b
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- a/src/msys2-filesystem.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-filesystem.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-filesystem
 $(PKG)_NAME     := filesystem
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 2020.02-2
-$(PKG)_x86_64_CS := 57a49aac59dffaa450062ab0b35804b2e2bd438f
-$(PKG)_i686_CS  := 1327b7ed5b9b543ba78826374d8f66b4b24ac518
+$(PKG)_VERSION  := 2021.06-1
+$(PKG)_x86_64_CS := 119b065c17f0243e91786c5ae4c33f94f70bafed
+$(PKG)_i686_CS  := c2139a15abb3c9153201f0f79e6638298f2d65ee
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- a/src/msys2-findutils.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-findutils.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-findutils
 $(PKG)_NAME     := findutils
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 4.7.0-1
-$(PKG)_x86_64_CS := dacf83fddf197b74be16d55cbab41866cd1dd66f
-$(PKG)_i686_CS  := 0e995f9cdd4c563695ab028cb25bbccbbda19596
+$(PKG)_VERSION  := 4.8.0-1
+$(PKG)_x86_64_CS := 4808ef0e69657f1ad08724b16d424b26d0a92f8f
+$(PKG)_i686_CS  := 08773c5243becd6f4b852fb56e807d7ab6cfff27
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- a/src/msys2-gcc-libs.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-gcc-libs.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-gcc-libs
 $(PKG)_NAME     := gcc-libs
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 9.3.0-1
-$(PKG)_x86_64_CS := 6c9519fed737408a63015e6e37228bfa0511391a
-$(PKG)_i686_CS  := afeb3a10d56ed9bc1c6fb1235dd392ce2afc243d
+$(PKG)_VERSION  := 10.2.0-1
+$(PKG)_x86_64_CS := 33a43d91c18ab91a0ea61049005309d6351ebe3a
+$(PKG)_i686_CS  := e4286aa812cf926c72df061cb5100e9424c81857
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/msys2-glib2.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,24 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := msys2-glib2
+$(PKG)_NAME     := glib2
+$(PKG)_IGNORE   :=
+$(PKG)_VERSION  := 2.68.1-1
+$(PKG)_x86_64_CS := c19bd031bc78eb488f6efefb3abd2caa3c54d34e
+$(PKG)_i686_CS  := 489f6d1a9a32e2afb63e5a6a8f1d2a139d3f17d9
+$(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
+$(PKG)_CHECKSUM := $($(PKG)_CS)
+$(PKG)_SUBDIR   := 
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
+$(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
+
+$(PKG)_DEPS     := 
+
+define $(PKG)_UPDATE
+    $(MSYS2_PKG_UPDATE)
+endef
+
+define $(PKG)_BUILD
+    $(MSYS2_PKG_BUILD)
+endef
--- a/src/msys2-gmp.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-gmp.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,16 +4,16 @@
 PKG             := msys2-gmp
 $(PKG)_NAME     := gmp
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 6.2.0-1
-$(PKG)_x86_64_CS := aaa5e44a168ea7afe922f59cef94274b491a0e2d
-$(PKG)_i686_CS  := 6aef4305181c56241feb5a767c19f34dbefdc7b3
+$(PKG)_VERSION  := 6.2.1-1
+$(PKG)_x86_64_CS := ae059cef3d83843567401014daaa97ba8be64b79
+$(PKG)_i686_CS  := 74eb22780e0df1c4156d23a4988a23aa5087cdc4
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
-$(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_SUBDIR   :=
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
-$(PKG)_DEPS     := 
+$(PKG)_DEPS     :=
 
 define $(PKG)_UPDATE
     $(MSYS2_PKG_UPDATE)
--- a/src/msys2-gnupg.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-gnupg.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,16 +4,16 @@
 PKG             := msys2-gnupg
 $(PKG)_NAME     := gnupg
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 2.2.20-1
-$(PKG)_x86_64_CS := 979c73be90b3c54047a15d9717fb2bdafc04351b
-$(PKG)_i686_CS  := 4f390fda3bb09989651d644a8d097a5218cb263f
+$(PKG)_VERSION  := 2.2.28-3
+$(PKG)_x86_64_CS := 52cd46ea2d755812b202027f2536b8f4c5ad991e
+$(PKG)_i686_CS  := 7152f79b2ffc37c5ceecaf97458e43699f1cb88b
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
-$(PKG)_DEPS     := 
+$(PKG)_DEPS     := msys2-libassuan msys2-libgcrypt
 
 define $(PKG)_UPDATE
     $(MSYS2_PKG_UPDATE)
--- a/src/msys2-icu.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-icu.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-icu
 $(PKG)_NAME     := icu
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 65.1-1
-$(PKG)_x86_64_CS := 9f18870beb7da0f261c44cdfc248126fed27ec1d
-$(PKG)_i686_CS  := e57c5d590b2a052e9ba7549783574e9f78dafd85
+$(PKG)_VERSION  := 68.2-1
+$(PKG)_x86_64_CS := 280b019c2f812158c312341daff046f95903393d
+$(PKG)_i686_CS  := 9ef9a030f9b5c34733b96a7be116bf6fa63fd724
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- a/src/msys2-info.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-info.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-info
 $(PKG)_NAME     := info
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 6.7-1
-$(PKG)_x86_64_CS := a8362f25defeae5777d3e31db6df288610c1387a
-$(PKG)_i686_CS  := 0d39065dec721d1fcc73c2cb37e42a306e91b62a
+$(PKG)_VERSION  := 6.7-3
+$(PKG)_x86_64_CS := 17fb9d8fa2a81de24460d183435c6019fe87a764
+$(PKG)_i686_CS  := ec3607dbe39b31d65cdd150ff1b14fdeba60cc92
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- a/src/msys2-less.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-less.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-less
 $(PKG)_NAME     := less
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 551-1
-$(PKG)_x86_64_CS := 9247cc2e0387cfbdaff1ccb28a045be7444c9454
-$(PKG)_i686_CS  := 0eb69e481b6bf89a1a01b0bff2e9289ebaecf26d
+$(PKG)_VERSION  := 581-1
+$(PKG)_x86_64_CS := 7fe25f3161bf82c8cb0c931cbe4e32ccbcbb3aee
+$(PKG)_i686_CS  := 638279b04dfd72be40e3ba80b6340d5a3f3189cb
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- a/src/msys2-libassuan.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-libassuan.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-libassuan
 $(PKG)_NAME     := libassuan
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 2.5.3-1
-$(PKG)_x86_64_CS := 7b53d8b1071d01b23c2757ed7c213538b5713baa
-$(PKG)_i686_CS  := 05cad0d103ac09d4562813b82db75c2aa876948b
+$(PKG)_VERSION  := 2.5.5-1
+$(PKG)_x86_64_CS := 3b2e23b33eaeee3f06c046db1f0c5a7b22e0700e
+$(PKG)_i686_CS  := 942d543c45502515bbb407667daf7ad9f2b8699e
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- a/src/msys2-libcrypt.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-libcrypt.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-libcrypt
 $(PKG)_NAME     := libcrypt
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 2.1-2
-$(PKG)_x86_64_CS := 4e8b7747e8443209507811492bc560a2752064f3
-$(PKG)_i686_CS  := 80868955c97e2a8d0a33f491af0f66803ecafa89
+$(PKG)_VERSION  := 2.1-3
+$(PKG)_x86_64_CS := e2da3af731c026a737c39ed042f3e51e9416bab4
+$(PKG)_i686_CS  := 6fe9df8e5bfd1636c4ff84809e03047897ff6ab0
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- a/src/msys2-libexpat.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-libexpat.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-libexpat
 $(PKG)_NAME     := libexpat
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 2.2.9-1
-$(PKG)_x86_64_CS := 9f03f4f283f25a16c00781fbc4cad602d41f9c47
-$(PKG)_i686_CS  := d445da2f656c497e090bb2ea79be2d883a73a740
+$(PKG)_VERSION  := 2.3.0-1
+$(PKG)_x86_64_CS := cfa568fa6957e14103919acd1dbfd6ec1a8b7302
+$(PKG)_i686_CS  := a3d2338e6dca58cb881eaa63dea131a04874dd2b
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- a/src/msys2-libgcrypt.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-libgcrypt.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-libgcrypt
 $(PKG)_NAME     := libgcrypt
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 1.8.5-1
-$(PKG)_x86_64_CS := 235feccfc059c53370bce609542f79b65aad9fd1
-$(PKG)_i686_CS  := 3be5d1ee6ff6e8893e750ea0470699161f1a04c8
+$(PKG)_VERSION  := 1.9.2-1
+$(PKG)_x86_64_CS := 3c8e63d2ca5a63f074422ae7a4c75539e83a4c97
+$(PKG)_i686_CS  := 25728e633b68ec3c7d3e296fcf25d59ea7531097
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- a/src/msys2-libgnutls.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-libgnutls.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-libgnutls
 $(PKG)_NAME     := libgnutls
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 3.6.13-1
-$(PKG)_x86_64_CS := bbfff49c947b1ee7b52d5b53f1421647e6280b7e
-$(PKG)_i686_CS  := c30b75a31d19f1fe4e06d9b8f235c9be82e19d01
+$(PKG)_VERSION  := 3.7.2-1
+$(PKG)_x86_64_CS := d8c8f7d972b5c7e41d9a8b7261ce75dc1bfb1aab
+$(PKG)_i686_CS  := 9622f79fe3b66da138e3aef4528ec118820148dd
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- a/src/msys2-libgpg-error.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-libgpg-error.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-libgpg-error
 $(PKG)_NAME     := libgpg-error
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 1.37-1
-$(PKG)_x86_64_CS := 2c93e18b4411b4bec8efedc952190e3ce4d3fbbd
-$(PKG)_i686_CS  := 748f1463be555ce8f298767d1113ff20dc82eb22
+$(PKG)_VERSION  := 1.42-1
+$(PKG)_x86_64_CS := 0558048a188d8b9669f53881508195767962cfa2
+$(PKG)_i686_CS  := c835b44bb7864b4df8b33021e80d0f4b19b33219
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- a/src/msys2-libgpgme.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-libgpgme.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-libgpgme
 $(PKG)_NAME     := libgpgme
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 1.13.1-3
-$(PKG)_x86_64_CS := c7b4f7cf67031d7a70141f03ef03a23a946e1fed
-$(PKG)_i686_CS  := e8c0530ca026afe6ee7c913184481e17d75104f8
+$(PKG)_VERSION  := 1.16.0-1
+$(PKG)_x86_64_CS := 40dc3d159f9519a18b46b8eb27707754a2f334b2
+$(PKG)_i686_CS  := 8a895f275001cc6296dd3119c627f7d32033e965
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- a/src/msys2-libhogweed.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-libhogweed.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-libhogweed
 $(PKG)_NAME     := libhogweed
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 3.5.1-1
-$(PKG)_x86_64_CS := a3d2009be308b3f9b36d1afdc7fa2dff2855c8e1
-$(PKG)_i686_CS  := d84d9c6a3af7aa1100a97bb34205deb38a3c797a
+$(PKG)_VERSION  := 3.7.3-1
+$(PKG)_x86_64_CS := d4be4d53c78218a5e7410cdf6776f1928d32cf68
+$(PKG)_i686_CS  := e3685738ff2c129f16c18422b7b657c21808745f
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- a/src/msys2-libiconv.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-libiconv.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-libiconv
 $(PKG)_NAME     := libiconv
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 1.16-1
-$(PKG)_x86_64_CS := a08074a71d5d987f77f45e88776dca03d5a180a7
-$(PKG)_i686_CS  := dda8526c9a1600ecd1860614aa2e3b201ea39d26
+$(PKG)_VERSION  := 1.16-2
+$(PKG)_x86_64_CS := d4fdeb0648bcae7006185af4dca59dbdb1c003eb
+$(PKG)_i686_CS  := 90db540078910c062abc39007206416619e001d4
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- a/src/msys2-libidn2.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-libidn2.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-libidn2
 $(PKG)_NAME     := libidn2
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 2.3.0-1
-$(PKG)_x86_64_CS := 5a18ac2fdd5800bd02ae2e727b0f628fe7483a6f
-$(PKG)_i686_CS  := d33015d4d55c205b505d1b44cf941b1a708f6776
+$(PKG)_VERSION  := 2.3.1-2
+$(PKG)_x86_64_CS := c728726c489fc72b5e3fa8204d48040f8259c77e
+$(PKG)_i686_CS  := dc4e202e40feff4c9bea3095b30e43e679a8fcfb
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 #https://sourceforge.net/projects/msys2/files/REPOS/MSYS2/x86_64/bash-4.4.019-3-x86_64.pkg.tar.xz
--- a/src/msys2-libksba.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-libksba.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-libksba
 $(PKG)_NAME     := libksba
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 1.3.5-1
-$(PKG)_x86_64_CS := d4af71da2553d81b172a7c59ce0dec07edd8189e
-$(PKG)_i686_CS  := 36fd428bd5e74d634114ae606dfa33949c1f5a9e
+$(PKG)_VERSION  := 1.6.0-1
+$(PKG)_x86_64_CS := 210125b66d60d448a6077ebc8d1f0cbcee722f69
+$(PKG)_i686_CS  := 90f3c06bc936d204f36ce093b61845ceaf6dd27e
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- a/src/msys2-libnettle.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-libnettle.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-libnettle
 $(PKG)_NAME     := libnettle
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 3.5.1-1
-$(PKG)_x86_64_CS := 18b98825f5a3ff66187549d72dc0db72c11eb861
-$(PKG)_i686_CS  := db9029d1fed37eaa91f5d455e6410f65e53b255e
+$(PKG)_VERSION  := 3.7.3-1
+$(PKG)_x86_64_CS := bd57cd803522a7c74e26f2af6d445f8d1f5557ad
+$(PKG)_i686_CS  := cb5639908c639b22bee80f0cc140c3be8f8d93b8
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- a/src/msys2-libopenssl.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-libopenssl.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-libopenssl
 $(PKG)_NAME     := libopenssl
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 1.1.1.g-1
-$(PKG)_x86_64_CS := 12c21b7ad554c2a0cae971e0537eb2af6edf22c5
-$(PKG)_i686_CS  := 5ed48e1039adaf7561f1f30a03ca08d0b1e6a239
+$(PKG)_VERSION  := 1.1.1.k-1
+$(PKG)_x86_64_CS := 1e8c4a206dab9b30d56e89e3d24bce503a3f0823
+$(PKG)_i686_CS  := 40ae24afa20efb578a3f3519a6b4844d9e74d85e
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- a/src/msys2-libp11-kit.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-libp11-kit.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-libp11-kit
 $(PKG)_NAME     := libp11-kit
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 0.23.20-2
-$(PKG)_x86_64_CS := 18e030cfa65b99d71bb5fd525679f6057eee1c35
-$(PKG)_i686_CS  := 9701df51b3cba239826ee1fee8fba80bd03fcc12
+$(PKG)_VERSION  := 0.23.22-2
+$(PKG)_x86_64_CS := 2b7022bbfc30801b7fef674d1d49698fc8003180
+$(PKG)_i686_CS  := a00467c7b70e199c5f4fa834a1757be0bb5814a9
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- a/src/msys2-libpcre.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-libpcre.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-libpcre
 $(PKG)_NAME     := libpcre
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 8.44-1
-$(PKG)_x86_64_CS := 90c9d7d604b20151dc07623b1efffe6ed1b9928f
-$(PKG)_i686_CS  := f607f93aee4866f2c2c29a8f58cc8b9fa7f6b233
+$(PKG)_VERSION  := 8.45-1
+$(PKG)_x86_64_CS := 5480625cfe7b8631b729013483652d47ef90ae0a
+$(PKG)_i686_CS  := 32c476fd099fb5c0ec79ae5fc3494c9e2cb5b9f7
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- a/src/msys2-libpcre2.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-libpcre2.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-libpcre2
 $(PKG)_NAME     := libpcre2_8
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 10.34-1
-$(PKG)_x86_64_CS := 4ac35dd23d6eed722c36d19cbf6cdee339ba2a38
-$(PKG)_i686_CS  := 7bed54e4762f6c7fcfda6c5709cb59d294fb6672
+$(PKG)_VERSION  := 10.37-1
+$(PKG)_x86_64_CS := caaa50dda77e1ce8ae4b861a2cebeb4b88f66ee8
+$(PKG)_i686_CS  := 46e1cf88bfefa689ed3ccda587a9ecfeeb3ed977
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- a/src/msys2-libpsl.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-libpsl.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-libpsl
 $(PKG)_NAME     := libpsl
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 0.21.0-1
-$(PKG)_x86_64_CS := 54c0714d9ea362822ad1fa3663d6feb7a704bc43
-$(PKG)_i686_CS  := 60f5a4b5209d3e370e5e93ab4b69071eb16f12b3
+$(PKG)_VERSION  := 0.21.1-2
+$(PKG)_x86_64_CS := 790e9da9b3a7d5b62563946f3da0602bdbac8a75
+$(PKG)_i686_CS  := 65e5a1d26d62a4c79e8f67fa8156e646dae379d5
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- a/src/msys2-libreadline.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-libreadline.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-libreadline
 $(PKG)_NAME     := libreadline
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 8.0.004-1
-$(PKG)_x86_64_CS := 510fe1a5412f913c5283bf48696a80e23396ab16
-$(PKG)_i686_CS  := 3831f3f711ea07bc41a0b3606acdc18052310dc1
+$(PKG)_VERSION  := 8.1.0-1
+$(PKG)_x86_64_CS := 58b7a142055b941bc2dd49e073ac2f1d690e681f
+$(PKG)_i686_CS  := 6b455f4357b09b2dcf74b1a0ce1211570a9891ab
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- a/src/msys2-libsqlite.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-libsqlite.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-libsqlite
 $(PKG)_NAME     := libsqlite
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 3.30.0-1
-$(PKG)_x86_64_CS := 9af9e322fa96172c9c9f04c0913ea6bacf88dd48
-$(PKG)_i686_CS  := 50979a209e065353a523233a108788eb77ed1e1c
+$(PKG)_VERSION  := 3.36.0-1
+$(PKG)_x86_64_CS := 3433a6a55df9faf128f644c7ff61cc8f14237936
+$(PKG)_i686_CS  := b928e6560c8b833d448dd3b814ffd14f66b80702
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- a/src/msys2-libtasn1.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-libtasn1.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-libtasn1
 $(PKG)_NAME     := libtasn1
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 4.16.0-1
-$(PKG)_x86_64_CS := bda097c0a09e9629ddf67a994f87ef58e4b44ec0
-$(PKG)_i686_CS  := f6c5a551fc9999b5a70b16092aebcd3fca386cae
+$(PKG)_VERSION  := 4.17.0-2
+$(PKG)_x86_64_CS := 48261db49ef18271118904fff12501689f252ead
+$(PKG)_i686_CS  := 1e7c9d2bc1fc0a283890efdaab2cefd14d2043e7
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- a/src/msys2-libutil-linux.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-libutil-linux.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-libutil-linux
 $(PKG)_NAME     := libutil-linux
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 2.35.1-1
-$(PKG)_x86_64_CS := 292e299fff3f0ee848a7683c3b2820ad7ec47431
-$(PKG)_i686_CS  := 7f6c875eabad30530de3378522f277f4e8358d59
+$(PKG)_VERSION  := 2.35.2-1
+$(PKG)_x86_64_CS := a954a605386c24309f251c64a8d4e5d490355350
+$(PKG)_i686_CS  := 199ffb8d40f76f89e33bb0f04d4323f6db982b5f
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- a/src/msys2-libxml2.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-libxml2.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-libxml2
 $(PKG)_NAME     := libxml2
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 2.9.10-4
-$(PKG)_x86_64_CS := 2bbee395235ed343984d2436de5258d83a148078
-$(PKG)_i686_CS  := 29073c3181245e089c04bb6807167ffaf499e6b2
+$(PKG)_VERSION  := 2.9.10-9
+$(PKG)_x86_64_CS := c1124aa1f6fc77d09900f11fb951dd29e53c1f34
+$(PKG)_i686_CS  := f97d29e0e2d046fb108691d8579680a2f160d9cd
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/msys2-libxslt.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,24 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := msys2-libxslt
+$(PKG)_NAME     := libxslt
+$(PKG)_IGNORE   :=
+$(PKG)_VERSION  := 1.1.34-4
+$(PKG)_x86_64_CS := f3aa2f91122503d31be5ed64a7c3ed34eda349bf
+$(PKG)_i686_CS  := 536dcc352aa259df8191262cdbc75de4a24069fc
+$(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
+$(PKG)_CHECKSUM := $($(PKG)_CS)
+$(PKG)_SUBDIR   := 
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
+$(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
+
+$(PKG)_DEPS     := 
+
+define $(PKG)_UPDATE
+    $(MSYS2_PKG_UPDATE)
+endef
+
+define $(PKG)_BUILD
+    $(MSYS2_PKG_BUILD)
+endef
--- a/src/msys2-mintty.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-mintty.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,14 +4,14 @@
 PKG             := msys2-mintty
 $(PKG)_NAME     := mintty
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 1~3.1.4-1
+$(PKG)_VERSION  := 1~3.5.0-1
 $(PKG)_FILTER   := mintty-1~
-$(PKG)_x86_64_CS := 0de49be7036be097be0abea36ae81e86ca9d2551
-$(PKG)_i686_CS  := 7c99fbb40c4124473b86b9df40b2b661928f515a
+$(PKG)_x86_64_CS := 5bed728c6e0cd51d35aaaf3fa83a4b2b6aa89cdb
+$(PKG)_i686_CS  := 680923ca77fe8896625c1cec8c9062a8ba78ba82
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- a/src/msys2-mpdecimal.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-mpdecimal.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-mpdecimal
 $(PKG)_NAME     := mpdecimal
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 2.4.2-2
-$(PKG)_x86_64_CS := d9458d2f42ac8141cae4396cdf4d5c012d335d48
-$(PKG)_i686_CS  := e50bc964c77e2c1e8e38da7bacd1e56c1bfa6278
+$(PKG)_VERSION  := 2.5.0-1
+$(PKG)_x86_64_CS := e49198d21fcd50b5b42baf2185e0046adffbd14d
+$(PKG)_i686_CS  := b613d59ad12bd9de6741f61eda10719cd2a11fa8
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- a/src/msys2-mpfr.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-mpfr.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,16 +4,16 @@
 PKG             := msys2-mpfr
 $(PKG)_NAME     := mpfr
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 4.0.2-1
-$(PKG)_x86_64_CS := 7d5b3fa6860878ce6f7289aeabd8fb4a9b47d639
-$(PKG)_i686_CS  := 2ed5eed28cd54e7b7b318383915178438123c7a4
+$(PKG)_VERSION  := 4.1.0-1
+$(PKG)_x86_64_CS := 8657316342a11ec7027df6fa1f1c86eadb0037a8
+$(PKG)_i686_CS  := 976e7007dd3c5013334ec44fc754c389ab4efbd2
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
-$(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_SUBDIR   :=
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
-$(PKG)_DEPS     := 
+$(PKG)_DEPS     :=
 
 define $(PKG)_UPDATE
     $(MSYS2_PKG_UPDATE)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/msys2-openssl.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,24 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := msys2-openssl
+$(PKG)_NAME     := openssl
+$(PKG)_IGNORE   :=
+$(PKG)_VERSION  := 1.1.1.k-1
+$(PKG)_x86_64_CS := 8e70b9d37a74435302a26bf651908fbfc2235f4b
+$(PKG)_i686_CS  := dd95fd3040af7586e345ed49a813af76f099eed3
+$(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
+$(PKG)_CHECKSUM := $($(PKG)_CS)
+$(PKG)_SUBDIR   := 
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
+$(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
+
+$(PKG)_DEPS     := 
+
+define $(PKG)_UPDATE
+    $(MSYS2_PKG_UPDATE)
+endef
+
+define $(PKG)_BUILD
+    $(MSYS2_PKG_BUILD)
+endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/msys2-p11-kit.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,24 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := msys2-p11-kit
+$(PKG)_NAME     := p11-kit
+$(PKG)_IGNORE   :=
+$(PKG)_VERSION  := 0.23.22-2
+$(PKG)_x86_64_CS := 4f931487b174b7ae2541a095d2b6579eb9c3da86
+$(PKG)_i686_CS  := 6d2843f2f3cc3b0077d3bc21eaab982fb9841045
+$(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
+$(PKG)_CHECKSUM := $($(PKG)_CS)
+$(PKG)_SUBDIR   := 
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
+$(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
+
+$(PKG)_DEPS     := msys2-libp11-kit
+
+define $(PKG)_UPDATE
+    $(MSYS2_PKG_UPDATE)
+endef
+
+define $(PKG)_BUILD
+    $(MSYS2_PKG_BUILD)
+endef
--- a/src/msys2-pacman-mirrors.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-pacman-mirrors.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,15 +4,15 @@
 PKG             := msys2-pacman-mirrors
 $(PKG)_NAME     := pacman-mirrors
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 20200329-1
-# the mirror package is NOT the same for both systems
-$(PKG)_i686_CS  := 21417ae4d160dadf091625b210e459afc6505b95
-$(PKG)_x86_64_CS := 5eb8f63b7036a0553162e10060f0695e593648e7
+$(PKG)_VERSION  := 20210703-1
+# the mirror package is NOT the same for both systems, but same name
+$(PKG)_i686_CS  := b625b8c4439b2f5037a05c5e4aff3704c2283408
+$(PKG)_x86_64_CS := 3abd8f937b706ec5f3e17a2a52bb04f8605b6b70
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-any.pkg.tar.xz
-$(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
+$(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_NAME)-$($(PKG)_VERSION)-any.pkg.tar.zst
 
 $(PKG)_DEPS     := 
 
--- a/src/msys2-pacman.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-pacman.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,17 +4,16 @@
 PKG             := msys2-pacman
 $(PKG)_NAME     := pacman
 $(PKG)_IGNORE   :=
-# NOTE: currently 5.X versions not compatible with our format
-$(PKG)_VERSION  := 5.2.1-6
-$(PKG)_x86_64_CS := f8525811c2feddcb49801e4652487531dcace21a
-$(PKG)_i686_CS  := 9d0a4a2a1dade9968fbb660d003a8fca63411f0d
+$(PKG)_VERSION  := 6.0.0-4
+$(PKG)_x86_64_CS := d337c026c6b772a6a9783193d9cda7972017cc29
+$(PKG)_i686_CS  := 5473f451adbd52818ce4a551c92e3e6475388bc1
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
-$(PKG)_DEPS     := 
+$(PKG)_DEPS     := msys2-pacman-mirrors msys2-keyring msys2-gnupg
 
 define $(PKG)_UPDATE
     $(MSYS2_PKG_UPDATE)
--- a/src/msys2-perl.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-perl.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-perl
 $(PKG)_NAME     := perl
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 5.30.2-1
-$(PKG)_x86_64_CS := e3cdfcbcf9e61a96783385e6d94c3df9367a5ba7
-$(PKG)_i686_CS  := 5a645efeed96ef749f88450d260bb95692ded6f2
+$(PKG)_VERSION  := 5.32.1-1
+$(PKG)_x86_64_CS := 43140fa9d016b85f0a31dad3b26260310678a336
+$(PKG)_i686_CS  := cadc64bd12a67e596686ba954d90a7291fe8fecc
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- a/src/msys2-python.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-python.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-python
 $(PKG)_NAME     := python
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 3.8.2-1
-$(PKG)_x86_64_CS := 338c9877b879a00b39d661a7513f62897413791d
-$(PKG)_i686_CS  := 551ce598052dc6bd1f8116f667c4856426545268
+$(PKG)_VERSION  := 3.9.5-1
+$(PKG)_x86_64_CS := a3a386850b5620c13db9e3744e427e46282cfe4b
+$(PKG)_i686_CS  := e845f05fd6e6ac793e284a03061db5a74b76b773
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- a/src/msys2-runtime.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-runtime.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-runtime
 $(PKG)_NAME     := msys2-runtime
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 3.0.7-6
-$(PKG)_x86_64_CS := 4336017742d38bf8b16714b5ff61a3b8f03e045f
-$(PKG)_i686_CS  := 40c4e20fad4f25219cafe6ecac1fdbf711fedb52
+$(PKG)_VERSION  := 3.2.0-14
+$(PKG)_x86_64_CS := e27265d09710681f836b94455f1e57ddf1e7445c
+$(PKG)_i686_CS  := 6d87f417963ef2dd2ee1f85a6616acdb73693f7f
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- a/src/msys2-tar.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-tar.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-tar
 $(PKG)_NAME     := tar
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 1.32-1
-$(PKG)_x86_64_CS := a3936e67ca6c4ce7b5472bc51b250fcb6de0588a
-$(PKG)_i686_CS  := 9578891365be560dccfb22ef718443ae6648c566
+$(PKG)_VERSION  := 1.34-1
+$(PKG)_x86_64_CS := b5adc14cc4e5ebcdc3f5c4ae0b3df3e2de844487
+$(PKG)_i686_CS  := d3281a465b593e55eb6cc8f58517d3098c024318
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- a/src/msys2-wget.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/msys2-wget.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := msys2-wget
 $(PKG)_NAME     := wget
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 1.20.3-1
-$(PKG)_x86_64_CS := 1ab446bb4804de21f82781325c402a8751d0554e
-$(PKG)_i686_CS  := 7acffc43c7ebec2741173d229361bc39b24efb05
+$(PKG)_VERSION  := 1.21.1-2
+$(PKG)_x86_64_CS := b1cf111e44f2a5bc5f9ffebb65154b951fbbb7e4
+$(PKG)_i686_CS  := f33a22e9e2c106b15597e58cc15e5268ed660872
 $(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
 $(PKG)_CHECKSUM := $($(PKG)_CS)
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.zst
 $(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
 
 $(PKG)_DEPS     := 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/msys2-which.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,24 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := msys2-which
+$(PKG)_NAME     := which
+$(PKG)_IGNORE   :=
+$(PKG)_VERSION  := 2.21-2
+$(PKG)_x86_64_CS := c6183ec9734892a55b94978d8b173bbe414e3e37
+$(PKG)_i686_CS  := d8fba94924bf7a7015860029e6c48d64ec041c45
+$(PKG)_CS       := $($(PKG)_$(MSYS2_ARCH)_CS)
+$(PKG)_CHECKSUM := $($(PKG)_CS)
+$(PKG)_SUBDIR   := 
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION)-$(MSYS2_ARCH).pkg.tar.xz
+$(PKG)_URL      := $(MSYS2_URL)/$($(PKG)_FILE)
+
+$(PKG)_DEPS     := 
+
+define $(PKG)_UPDATE
+    $(MSYS2_PKG_UPDATE)
+endef
+
+define $(PKG)_BUILD
+    $(MSYS2_PKG_BUILD)
+endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/native-gcc-1-canadian-cross.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,42 @@
+See: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100017#c12
+
+diff --git a/libstdc++-v3/include/c_compatibility/fenv.h b/libstdc++-v3/include/c_compatibility/fenv.h
+index 0413e3b7c25..56cabaa3635 100644
+--- a/libstdc++-v3/include/c_compatibility/fenv.h
++++ b/libstdc++-v3/include/c_compatibility/fenv.h
+@@ -26,6 +26,10 @@
+  *  This is a Standard C++ Library header.
+  */
+ 
++#if !defined __cplusplus || defined _GLIBCXX_INCLUDE_NEXT_C_HEADERS
++# include_next <fenv.h>
++#else
++
+ #ifndef _GLIBCXX_FENV_H
+ #define _GLIBCXX_FENV_H 1
+ 
+@@ -83,3 +83,5 @@ namespace std
+ #endif // C++11
+ 
+ #endif // _GLIBCXX_FENV_H
++
++#endif // include_next
+
+diff --git a/libstdc++-v3/include/c_global/cfenv b/libstdc++-v3/include/c_global/cfenv
+index 0b0ec35a837..d24cb1a3c81 100644
+--- a/libstdc++-v3/include/c_global/cfenv
++++ b/libstdc++-v3/include/c_global/cfenv
+@@ -37,9 +37,11 @@
+ 
+ #include <bits/c++config.h>
+ 
+-#if _GLIBCXX_HAVE_FENV_H
+-# include <fenv.h>
+-#endif
++// Need to ensure this finds the C library's <fenv.h> not a libstdc++
++// wrapper that might already be installed later in the include search path.
++#define _GLIBCXX_INCLUDE_NEXT_C_HEADERS
++#include_next <fenv.h>
++#undef _GLIBCXX_INCLUDE_NEXT_C_HEADERS
+ 
+ #ifdef _GLIBCXX_USE_C99_FENV_TR1
--- a/src/native-gcc.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/native-gcc.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := native-gcc
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 9.3.0
-$(PKG)_CHECKSUM := b746688bf045a316fc92c3528138ad10d0822b6b
+$(PKG)_VERSION  := 11.2.0
+$(PKG)_CHECKSUM := f902ccacecf8949978d6261e9f1d034cff73ffdb
 $(PKG)_SUBDIR   := gcc-$($(PKG)_VERSION)
 $(PKG)_FILE     := gcc-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := ftp://ftp.gnu.org/pub/gnu/gcc/gcc-$($(PKG)_VERSION)/$($(PKG)_FILE)
--- a/src/netcdf-1-fixes.patch	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/netcdf-1-fixes.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -1,14 +1,22 @@
-diff --git "a/netcdf/ncdump/ncvalidator.c" "b/netcdf/ncdump/ncvalidator.c"
-index a0e4acb..2a7c5af 100644
---- "a/ncdump/ncvalidator.c"	
-+++ "b/ncdump/ncvalidator.c"
-@@ -76,7 +76,9 @@ THIS SOFTWARE.
- #ifdef _WIN32
- #include <io.h>
- #define snprintf _snprintf
-+#ifndef HAVE_UNISTD_H
- #include "XGetopt.h"
-+#endif
- int opterr;
- int optind;
- #endif
+From 9a8a2eb2694581f6caf103aee593ca9607be17bd Mon Sep 17 00:00:00 2001
+From: Milton Woods <miltonjwoods@gmail.com>
+Date: Mon, 23 Aug 2021 14:22:57 +1000
+Subject: [PATCH] Fix path conversions for mingw-w64
+
+---
+ libdispatch/dpathmgr.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/libdispatch/dpathmgr.c b/libdispatch/dpathmgr.c
+index eb450534e..6a5890423 100644
+--- a/libdispatch/dpathmgr.c
++++ b/libdispatch/dpathmgr.c
+@@ -861,7 +861,7 @@ getlocalpathkind(void)
+ 	kind = NCPD_CYGWIN;
+ #elif __MSYS__
+ 	kind = NCPD_MSYS;
+-#elif _MSC_VER /* not _WIN32 */
++#elif defined(_MSC_VER) || defined(__MINGW32__) /* not _WIN32 */
+ 	kind = NCPD_WIN;
+ #else
+ 	kind = NCPD_NIX;
--- a/src/netcdf.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/netcdf.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,22 +3,23 @@
 
 PKG             := netcdf
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 4.7.4
-$(PKG)_CHECKSUM := dce4851dd65bf8ec985f11711bb5a8aa299515b9
+$(PKG)_VERSION  := 4.8.1
+$(PKG)_CHECKSUM := ae9e8741aebdb3ba4494a78a7f5a32e92516edc1
 $(PKG)_SUBDIR   := netcdf-c-$($(PKG)_VERSION)
 $(PKG)_FILE     := netcdf-c-$($(PKG)_VERSION).tar.gz
-$(PKG)_URL      := ftp://ftp.unidata.ucar.edu/pub/netcdf/$($(PKG)_FILE)
+$(PKG)_URL      := https://github.com/Unidata/netcdf-c/archive/v$($(PKG)_VERSION).tar.gz
 $(PKG)_DEPS     := curl hdf5
 
 define $(PKG)_UPDATE
-    $(WGET) -q -O- 'ftp://ftp.unidata.ucar.edu/pub/netcdf/' | \
-    $(SED) -n 's,.*netcdf-c-\([0-9]\.[^>]*\)\.tar.*,\1,p' | \
-    $(SORT) -V | \
-    tail -1
+    $(WGET) -q -O- 'https://github.com/Unidata/netcdf-c/tags' | \
+    $(SED) -n 's|.*releases/tag/v\([^"]*\).*|\1|p' | \
+    head -1
 endef
 
 ifeq ($(MXE_WINDOWS_BUILD),yes)
-  $(PKG)_CONFIGURE_OPTIONS := --enable-dll
+  $(PKG)_CONFIGURE_OPTIONS := CPPFLAGS='-DH5_USE_110_API -DDLL_NETCDF -I$(HOST_PREFIX)/include'
+else
+  $(PKG)_CONFIGURE_OPTIONS := CPPFLAGS='-DH5_USE_110_API -I$(HOST_PREFIX)/include'
 endif
 
 $(PKG)_CONFIGURE_POST_HOOK := $(CONFIGURE_POST_HOOK)
@@ -32,12 +33,13 @@
     fi
     cd '$(1)' && ./configure \
         $(HOST_AND_BUILD_CONFIGURE_OPTIONS) \
+	--enable-hdf5 --disable-testsets --disable-utilities \
         $(CONFIGURE_CPPFLAGS) $(CONFIGURE_LDFLAGS) \
         $(ENABLE_SHARED_OR_STATIC) \
         --prefix='$(HOST_PREFIX)' \
         $($(PKG)_CONFIGURE_OPTIONS) \
 	&& $($(PKG)_CONFIGURE_POST_HOOK)
-    $(MAKE) -C '$(1)' -j '$(JOBS)' LDFLAGS='-no-undefined -L$(HOST_LIBDIR)'
+    $(MAKE) -C '$(1)' -j '$(JOBS)' LDFLAGS='-no-undefined -L$(HOST_LIBDIR)' $(MXE_DISABLE_PROGS) $(MXE_DISABLE_DOCS) V=1
     $(MAKE) -C '$(1)' -j 1 install LDFLAGS='-no-undefined -L$(HOST_LIBDIR)' $(MXE_DISABLE_PROGS) $(MXE_DISABLE_DOCS) DESTDIR='$(3)'
   
     if [ ! "x$(MXE_NATIVE_BUILD)" = "xyes" ]; then \
--- a/src/nettle.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/nettle.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := nettle
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 3.6
-$(PKG)_CHECKSUM := 22e48a4d232ccd26ba8303709f2222b422a8827d
+$(PKG)_VERSION  := 3.7.3
+$(PKG)_CHECKSUM := 9adfadd4ae4104c8aceb38bf16064d65d7edbcce
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://www.lysator.liu.se/~nisse/archive/$($(PKG)_FILE)
--- a/src/npp.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/npp.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,10 +3,10 @@
 
 PKG             := npp
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 7.8.9
-$(PKG)_CHECKSUM := 26297d8c55833a6c43d16f3b0fa842ecd5153e20
+$(PKG)_VERSION  := 8.1.9
+$(PKG)_CHECKSUM := 491bbf27d72c39ae0f7b6460e22a9bb004711c3f
 $(PKG)_SUBDIR   := 
-$(PKG)_FILE     := $(PKG).$($(PKG)_VERSION).bin.zip
+$(PKG)_FILE     := $(PKG).$($(PKG)_VERSION).portable.zip
 $(PKG)_URL      := https://github.com/notepad-plus-plus/notepad-plus-plus/releases/download/v$($(PKG)_VERSION)/$($(PKG)_FILE)
 $(PKG)_DEPS     :=
 
--- a/src/nsis.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/nsis.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,12 +3,12 @@
 
 PKG             := nsis
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 3.06.1
-$(PKG)_CHECKSUM := 525d763d08a8c69d5541d5b025adc56907b4c5de
+$(PKG)_VERSION  := 3.08
+$(PKG)_CHECKSUM := 784061fd42bf5e838e40e9f4504fd3e696d5d9a1
 $(PKG)_SUBDIR   := nsis-$($(PKG)_VERSION)-src
 $(PKG)_FILE     := nsis-$($(PKG)_VERSION)-src.tar.bz2
 $(PKG)_URL      := https://$(SOURCEFORGE_MIRROR)/project/nsis/NSIS 3/$($(PKG)_VERSION)/$($(PKG)_FILE)
-$(PKG)_DEPS     := build-python build-scons build-setuptools
+$(PKG)_DEPS     := build-scons build-setuptools
 
 define $(PKG)_UPDATE
     $(WGET) -q -O- 'https://nsis.sourceforge.io/Download' | \
@@ -19,14 +19,14 @@
 ifeq ($(ENABLE_WINDOWS_64),yes)
     $(PKG)_PREBUILD = \
         $(SED) -i 's/pei-i386/pei-x86-64/' '$(1)/SCons/Config/linker_script' && \
-        $(SED) -i 's/m_target_type=TARGET_X86ANSI/m_target_type=TARGET_AMD64/' '$(1)/Source/build.cpp' 
+        $(SED) -i 's/m_target_type=TARGET_X86UNICODE/m_target_type=TARGET_AMD64/' '$(1)/Source/build.cpp' 
 
     $(PKG)_TARGET_SCON_OPTIONS := TARGET_ARCH=amd64
 endif
 
 define $(PKG)_BUILD
     $($(PKG)_PREBUILD)
-    cd '$(1)' && python2 $(shell which scons) VERBOSE=1 \
+    cd '$(1)' && scons VERBOSE=1 \
         PATH='$(PATH)' \
         XGCC_W32_PREFIX='$(MXE_TOOL_PREFIX)' \
         PREFIX='$(BUILD_TOOLS_PREFIX)' \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/of-communications-2-error_state.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,321 @@
+# HG changeset patch
+# User Markus Mützel <markus.muetzel@gmx.de>
+# Date 1637943467 -3600
+#      Fri Nov 26 17:17:47 2021 +0100
+# Node ID ace112d772c3be2ee53792fa9b687fe22f105fa3
+# Parent  a132b9df4944dadf0144c1eb61bffe71a706e166
+Fix compilation with Octave 8 (bug #61566).
+
+* src/genqamdemod.cc (Fgenqamdemod), src/gf.cc (make_gdiag, DATA_REDUCTION,
+Fglu, Fginv), src/ov-galois.cc (octave_galois::subsref, octave_galois::assign,
+octave_galois::load_binary): Remove usage of `error_state`. It was
+unconditionally set to 0 since about 6 years ago and will finally be removed in
+Octave 8.
+
+diff -r a132b9df4944 -r ace112d772c3 src/genqamdemod.cc
+--- a/src/genqamdemod.cc	Tue Jul 27 11:56:45 2021 -0400
++++ b/src/genqamdemod.cc	Fri Nov 26 17:17:47 2021 +0100
+@@ -79,28 +79,23 @@
+     { // Complex-valued input & constellation
+       ComplexMatrix x (args(0).complex_matrix_value ());
+       ComplexColumnVector constellation (args(1).complex_vector_value ());
+-      if (!error_state)
++      for (i = 0;i < nr1;i++)
+         {
+-          for (i = 0;i < nr1;i++)
++          for (j = 0;j < nc1;j++)
+             {
+-              for (j = 0;j < nc1;j++)
++              tmp1 = abs (x(i,j)-constellation(0));
++              y(i,j) = 0;
++              for (m = 1;m < M;m++)
+                 {
+-                  tmp1 = abs (x(i,j)-constellation(0));
+-                  y(i,j) = 0;
+-                  for (m = 1;m < M;m++)
++                  tmp2 = abs (x(i,j)-constellation(m));
++                  if (tmp2 < tmp1)
+                     {
+-                      tmp2 = abs (x(i,j)-constellation(m));
+-                      if (tmp2 < tmp1)
+-                        {
+-                          y(i,j) = m;
+-                          tmp1 = tmp2;
+-                        }
++                      y(i,j) = m;
++                      tmp1 = tmp2;
+                     }
+                 }
+             }
+         }
+-      else
+-        print_usage ();
+     }
+   else
+     {
+diff -r a132b9df4944 -r ace112d772c3 src/gf.cc
+--- a/src/gf.cc	Tue Jul 27 11:56:45 2021 -0400
++++ b/src/gf.cc	Fri Nov 26 17:17:47 2021 +0100
+@@ -180,55 +180,50 @@
+       galois m = ((const octave_galois&) a.get_rep ()).galois_value ();
+       int k = b.nint_value ();
+ 
+-      if (! error_state)
++      int nr = m.rows ();
++      int nc = m.columns ();
++
++      if (nr == 0 || nc == 0)
++        retval = new octave_galois (m);
++      else if (nr == 1 || nc == 1)
+         {
+-          int nr = m.rows ();
+-          int nc = m.columns ();
+-
+-          if (nr == 0 || nc == 0)
+-            retval = new octave_galois (m);
+-          else if (nr == 1 || nc == 1)
++          int roff = 0;
++          int coff = 0;
++          if (k > 0)
+             {
+-              int roff = 0;
+-              int coff = 0;
+-              if (k > 0)
+-                {
+-                  roff = 0;
+-                  coff = k;
+-                }
+-              else if (k < 0)
+-                {
+-                  k = -k;
+-                  roff = k;
+-                  coff = 0;
+-                }
++              roff = 0;
++              coff = k;
++            }
++          else if (k < 0)
++            {
++              k = -k;
++              roff = k;
++              coff = 0;
++            }
+ 
+-              if (nr == 1)
+-                {
+-                  int n = nc + k;
+-                  galois r (n, n, 0, m.m (), m.primpoly ());
+-                  for (int i = 0; i < nc; i++)
+-                    r (i+roff, i+coff) = m (0, i);
+-                  retval = new octave_galois (r);
+-                }
+-              else
+-                {
+-                  int n = nr + k;
+-                  galois r (n, n, 0, m.m (), m.primpoly ());
+-                  for (int i = 0; i < nr; i++)
+-                    r (i+roff, i+coff) = m (i, 0);
+-                  retval = new octave_galois (r);
+-                }
++          if (nr == 1)
++            {
++              int n = nc + k;
++              galois r (n, n, 0, m.m (), m.primpoly ());
++              for (int i = 0; i < nc; i++)
++                r (i+roff, i+coff) = m (0, i);
++              retval = new octave_galois (r);
+             }
+           else
+             {
+-              galois r = m.diag (k);
+-              if (r.numel () > 0)
+-                retval = new octave_galois (r);
++              int n = nr + k;
++              galois r (n, n, 0, m.m (), m.primpoly ());
++              for (int i = 0; i < nr; i++)
++                r (i+roff, i+coff) = m (i, 0);
++              retval = new octave_galois (r);
+             }
+         }
+       else
+-        OCTAVE__ERR_WRONG_TYPE_ARG ("gdiag", a);
++        {
++          galois r = m.diag (k);
++          if (r.numel () > 0)
++            retval = new octave_galois (r);
++        }
+     }
+   return retval;
+ }
+@@ -390,27 +385,23 @@
+  \
+       int dim = (nargin == 1 ? -1 : args(1).int_value (true) - 1); \
+  \
+-      if (! error_state) \
++      if (dim <= 1 && dim >= -1) \
+         { \
+-          if (dim <= 1 && dim >= -1) \
++          if (galois_type_loaded && (arg.type_id () == \
++                                     octave_galois::static_type_id ())) \
+             { \
+-              if (galois_type_loaded && (arg.type_id () == \
+-                                         octave_galois::static_type_id ())) \
+-                { \
+-                  galois tmp = ((const octave_galois&)arg.get_rep ()).galois_value (); \
++              galois tmp = ((const octave_galois&)arg.get_rep ()).galois_value (); \
+  \
+-                  if (! error_state) \
+-                    retval(0) = new octave_galois (tmp.FCN (dim)); \
+-                } \
+-              else \
+-                { \
+-                  OCTAVE__ERR_WRONG_TYPE_ARG (#FCN, arg); \
+-                  return retval; \
+-                } \
++              retval(0) = new octave_galois (tmp.FCN (dim)); \
+             } \
+           else \
+-            error (#FCN ": invalid dimension argument = %d", dim + 1); \
++            { \
++              OCTAVE__ERR_WRONG_TYPE_ARG (#FCN, arg); \
++              return retval; \
++            } \
+         } \
++      else \
++        error (#FCN ": invalid dimension argument = %d", dim + 1); \
+     } \
+   else \
+     print_usage (); \
+@@ -1017,32 +1008,29 @@
+       return retval;
+     }
+ 
+-  if (! error_state)
+-    {
+-      galoisLU fact (m);
++  galoisLU fact (m);
+ 
+-      switch (nargout)
+-        {
+-        case 0:
+-        case 1:
+-        case 2:
+-          {
+-            // While we don't have sparse galois matrices converting the
+-            // permutation matrix to a full matrix is the best we can do.
+-            Matrix P = Matrix (fact.P ());
+-            galois L = P.transpose () * fact.L ();
+-            retval(1) = new octave_galois (fact.U ());
+-            retval(0) = new octave_galois (L);
+-          }
+-          break;
++  switch (nargout)
++    {
++    case 0:
++    case 1:
++    case 2:
++      {
++        // While we don't have sparse galois matrices converting the
++        // permutation matrix to a full matrix is the best we can do.
++        Matrix P = Matrix (fact.P ());
++        galois L = P.transpose () * fact.L ();
++        retval(1) = new octave_galois (fact.U ());
++        retval(0) = new octave_galois (L);
++      }
++      break;
+ 
+-        case 3:
+-        default:
+-          retval(2) = fact.P ();
+-          retval(1) = new octave_galois (fact.U ());
+-          retval(0) = new octave_galois (fact.L ());
+-          break;
+-        }
++    case 3:
++    default:
++      retval(2) = fact.P ();
++      retval(1) = new octave_galois (fact.U ());
++      retval(0) = new octave_galois (fact.L ());
++      break;
+     }
+ 
+   return retval;
+@@ -1104,21 +1092,18 @@
+       return retval;
+     }
+ 
+-  if (! error_state)
+-    {
+-      int info;
+-      double rcond = 0.0;
++  int info;
++  double rcond = 0.0;
+ 
+-      galois result = m.inverse (info, 1);
++  galois result = m.inverse (info, 1);
+ 
+-      if (nargout > 1)
+-        retval(1) = rcond;
++  if (nargout > 1)
++    retval(1) = rcond;
+ 
+-      retval(0) = new octave_galois (result);
++  retval(0) = new octave_galois (result);
+ 
+-      if (nargout < 2 && info == -1)
+-        warning ("inverse: matrix singular to machine precision, rcond = %g", rcond);
+-    }
++  if (nargout < 2 && info == -1)
++    warning ("inverse: matrix singular to machine precision, rcond = %g", rcond);
+ 
+   return retval;
+ }
+diff -r a132b9df4944 -r ace112d772c3 src/ov-galois.cc
+--- a/src/ov-galois.cc	Tue Jul 27 11:56:45 2021 -0400
++++ b/src/ov-galois.cc	Fri Nov 26 17:17:47 2021 +0100
+@@ -208,8 +208,7 @@
+       panic_impossible ();
+     }
+ 
+-  if (! error_state)
+-    retval = retval.next_subsref (type, idx, skip);
++  retval = retval.next_subsref (type, idx, skip);
+ 
+   return retval;
+ }
+@@ -427,14 +426,9 @@
+     case 2:
+       {
+         idx_vector i = idx (0).index_vector ();
++        idx_vector j = idx (1).index_vector ();
+ 
+-        if (! error_state)
+-          {
+-            idx_vector j = idx (1).index_vector ();
+-
+-            if (! error_state)
+-              gval.assign (i, j, rhs);
+-          }
++        gval.assign (i, j, rhs);
+       }
+       break;
+ 
+@@ -442,8 +436,7 @@
+       {
+         idx_vector i = idx (0).index_vector ();
+ 
+-        if (! error_state)
+-          gval.assign (i, rhs);
++        gval.assign (i, rhs);
+       }
+       break;
+ 
+@@ -597,7 +590,7 @@
+       Matrix m (dv(0), dv(1));
+       double *re = m.fortran_vec ();
+       read_doubles (is, re, X_CAST (save_type, tmp), dv.numel (), swap, fmt);
+-      if (error_state || ! is)
++      if (! is)
+         return false;
+ 
+       gval = galois (m, mord, prim);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/of-control-1-deprecated-warnings.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,12 @@
+diff -uNr a/src/Makefile b/src/Makefile
+--- a/src/Makefile	2021-07-05 01:05:54.000000000 -0400
++++ b/src/Makefile	2021-08-20 00:58:10.329056319 -0400
+@@ -15,7 +15,7 @@
+ 
+ AR := $(shell $(MKOCTFILE) -p AR)
+ 
+-PKG_CXXFLAGS := -Wall -Wno-deprecated-declarations $(PKG_CXXFLAGS_APPEND)
++PKG_CXXFLAGS := -Wall $(PKG_CXXFLAGS_APPEND)
+ 
+ all: __control_slicot_functions__.oct \
+      __control_helper_functions__.oct
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/of-database-1-verror.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,22 @@
+# HG changeset patch
+# User Markus Mützel <markus.muetzel@gmx.de>
+# Date 1637944272 -3600
+#      Fri Nov 26 17:31:12 2021 +0100
+# Node ID 3d24e71eb8b1eb3325b6c3d5ed56c74cb58646cb
+# Parent  8ce48d0bb822adcbf40aa5ff6b759c3a898a7934
+Fix compilation with Octave 8 (bug #61567).
+
+* src/error-helpers.h: Use wrapper function.
+
+diff -r 8ce48d0bb822 -r 3d24e71eb8b1 src/error-helpers.h
+--- a/src/error-helpers.h	Thu Mar 25 10:59:09 2021 +0100
++++ b/src/error-helpers.h	Fri Nov 26 17:31:12 2021 +0100
+@@ -64,7 +64,7 @@
+       } \
+     catch (OCTAVE__EXECUTION_EXCEPTION& e) \
+       { \
+-        verror (e, __VA_ARGS__); \
++        c_verror (e, __VA_ARGS__); \
+       }
+ #endif
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/of-geometry-1-cxx17.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,78 @@
+Make operator() const (no mutable state allowed).
+This was always implied but is required for std::set in C++17.
+
+$ diff -Naup ./src/martinez.cpp.orig ./src/martinez.cpp
+--- ./src/martinez.cpp.orig	2020-02-03 04:35:21.000000000 +0100
++++ ./src/martinez.cpp	2021-08-12 13:22:32.462499966 +0200
+@@ -26,7 +26,7 @@ void Martinez::print (SweepEvent& e)
+ 
+ // Compare two sweep events
+ // Return true means that e1 is placed at the event queue after e2, i.e,, e1 is processed by the algorithm after e2
+-bool Martinez::SweepEventComp::operator() (SweepEvent* e1, SweepEvent* e2) {
++bool Martinez::SweepEventComp::operator() (const SweepEvent* e1, const SweepEvent* e2) const {
+ 	if (e1->p.x > e2->p.x) // Different x-coordinate
+ 		return true;
+ 	if (e2->p.x > e1->p.x) // Different x-coordinate
+@@ -40,7 +40,7 @@ bool Martinez::SweepEventComp::operator(
+ }
+ 
+ // e1 and a2 are the left events of line segments (e1->p, e1->other->p) and (e2->p, e2->other->p)
+-bool Martinez::SegmentComp::operator() (SweepEvent* e1, SweepEvent* e2) {
++bool Martinez::SegmentComp::operator() (const SweepEvent* e1, const SweepEvent* e2) const {
+ 	if (e1 == e2)
+ 		return false;
+ 	if (signedArea (e1->p, e1->other->p, e2->p) != 0 || signedArea (e1->p, e1->other->p, e2->other->p) != 0) {
+
+$ diff -Naup ./src/martinez.h.orig ./src/martinez.h
+--- ./src/martinez.h.orig	2020-02-03 04:35:21.000000000 +0100
++++ ./src/martinez.h	2021-08-12 13:21:16.650607542 +0200
+@@ -38,7 +38,7 @@ private:
+ 
+ 	struct SweepEvent;
+ 	struct SegmentComp : public binary_function<SweepEvent*, SweepEvent*, bool> { // for sorting edges in the sweep line
+-		bool operator() (SweepEvent* e1, SweepEvent* e2);
++		bool operator() (const SweepEvent* e1, const SweepEvent* e2) const;
+ 	};
+ 	
+ 	struct SweepEvent {
+@@ -65,7 +65,7 @@ private:
+ 	static void print (SweepEvent& e); // This function is intended for debugging purposes
+ 
+ 	struct SweepEventComp : public binary_function<SweepEvent*, SweepEvent*, bool> { // for sortening events
+-		bool operator() (SweepEvent* e1, SweepEvent* e2);
++		bool operator() (const SweepEvent* e1, const SweepEvent* e2) const;
+ 	};
+ 
+ 	/** @brief Event Queue */
+
+$ diff -Naup ./src/polygon.cpp.orig ./src/polygon.cpp
+--- ./src/polygon.cpp.orig	2020-02-03 04:35:21.000000000 +0100
++++ ./src/polygon.cpp	2021-08-12 13:30:01.848702003 +0200
+@@ -94,7 +94,7 @@ void Polygon::move (double x, double y)
+ namespace { // start of anonymous namespace
+ 	struct SweepEvent;
+ 	struct SegmentComp : public binary_function<SweepEvent*, SweepEvent*, bool> {
+-		bool operator() (SweepEvent* e1, SweepEvent* e2);
++		bool operator() (const SweepEvent* e1, const SweepEvent* e2) const;
+ 	};
+ 
+ 	struct SweepEvent {
+@@ -117,7 +117,7 @@ namespace { // start of anonymous namesp
+ 	};
+ 
+ 	struct SweepEventComp : public binary_function<SweepEvent*, SweepEvent*, bool> {
+-		bool operator() (SweepEvent* e1, SweepEvent* e2) {
++		bool operator() (const SweepEvent* e1, const SweepEvent* e2) const {
+ 			if (e1->p.x < e2->p.x) // Different x coordinate
+ 				return true;
+ 			if (e2->p.x < e1->p.x) // Different x coordinate
+@@ -133,7 +133,7 @@ namespace { // start of anonymous namesp
+ 
+ } // end of anonymous namespace
+ 
+-bool SegmentComp::operator() (SweepEvent* e1, SweepEvent* e2) {
++bool SegmentComp::operator() (const SweepEvent* e1, const SweepEvent* e2) const {
+ 	if (e1 == e2)
+ 		return false;
+ 	if (signedArea (e1->p, e1->other->p, e2->p) != 0 || signedArea (e1->p, e1->other->p, e2->other->p) != 0) {
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/of-image-1-namespace.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,357 @@
+diff -uNr a/src/bwconncomp.cc b/src/bwconncomp.cc
+--- a/src/bwconncomp.cc	2020-02-02 08:20:08.000000000 -0500
++++ b/src/bwconncomp.cc	2021-08-20 03:40:55.040903123 -0400
+@@ -30,7 +30,7 @@
+ #include <octave/oct-map.h>
+ 
+ #include "connectivity.h"
+-using namespace octave::image;
++using namespace octave_image;
+ 
+ static std::vector<std::vector<octave_idx_type>>
+ connected_components (const boolNDArray& BW, const connectivity& conn)
+diff -uNr a/src/bwlabeln.cc b/src/bwlabeln.cc
+--- a/src/bwlabeln.cc	2020-02-02 08:20:08.000000000 -0500
++++ b/src/bwlabeln.cc	2021-08-20 03:41:02.785032122 -0400
+@@ -32,7 +32,7 @@
+ #define WANTS_OCTAVE_IMAGE_VALUE 1
+ #include "octave-wrappers.h"
+ 
+-using namespace octave::image;
++using namespace octave_image;
+ 
+ static union_find
+ pre_label (NDArray& L, const connectivity& conn)
+diff -uNr a/src/conndef.cc b/src/conndef.cc
+--- a/src/conndef.cc	2020-02-02 08:20:08.000000000 -0500
++++ b/src/conndef.cc	2021-08-20 03:41:12.149188253 -0400
+@@ -19,7 +19,7 @@
+ #include "config.h"
+ 
+ #include "connectivity.h"
+-using namespace octave::image;
++using namespace octave_image;
+ 
+ // The conndef() function is really really simple and could have easily
+ // been a m file (actually it once was, check the hg log if it ever needs
+diff -uNr a/src/connectivity.cc b/src/connectivity.cc
+--- a/src/connectivity.cc	2020-02-02 08:20:08.000000000 -0500
++++ b/src/connectivity.cc	2021-08-20 03:41:18.001285906 -0400
+@@ -25,7 +25,7 @@
+ #define WANTS_OCTAVE_IMAGE_VALUE 1
+ #include "octave-wrappers.h"
+ 
+-using namespace octave::image;
++using namespace octave_image;
+ 
+ 
+ connectivity::connectivity (const boolNDArray& mask_arg)
+@@ -296,7 +296,7 @@
+ 
+ 
+ connectivity
+-octave::image::conndef (const octave_value& _val)
++octave_image::conndef (const octave_value& _val)
+ {
+   octave_image::value val (_val);
+ 
+diff -uNr a/src/connectivity.h b/src/connectivity.h
+--- a/src/connectivity.h	2020-02-02 08:20:08.000000000 -0500
++++ b/src/connectivity.h	2021-08-20 03:41:28.897467898 -0400
+@@ -29,10 +29,8 @@
+ 
+ #include <octave/ov.h>
+ 
+-namespace octave
++namespace octave_image
+ {
+-  namespace image
+-  {
+     class connectivity
+     {
+       public:
+@@ -89,14 +87,13 @@
+     };
+ 
+     connectivity conndef (const octave_value& val);
+-  }
+ }
+ 
+ // Templated methods
+ 
+ template<class T, class P>
+ T
+-octave::image::connectivity::create_padded (const T& image, const P& val) const
++octave_image::connectivity::create_padded (const T& image, const P& val) const
+ {
+   const octave_idx_type pad_ndims = std::min (mask.ndims (), image.ndims ());
+ 
+@@ -117,7 +114,7 @@
+ 
+ template<class T>
+ void
+-octave::image::connectivity::unpad (T& image) const
++octave_image::connectivity::unpad (T& image) const
+ {
+   const octave_idx_type pad_ndims = std::min (mask.ndims (), image.ndims ());
+   const dim_vector padded_size = image.dims ();
+@@ -134,7 +131,7 @@
+ 
+ template<class P>
+ P
+-octave::image::connectivity::min_value (void)
++octave_image::connectivity::min_value (void)
+ {
+   if (typeid (P) == typeid (bool))
+     return false;
+@@ -144,7 +141,7 @@
+ 
+ template<class T, class P>
+ void
+-octave::image::connectivity::set_padding (const dim_vector& size,
++octave_image::connectivity::set_padding (const dim_vector& size,
+                                           const dim_vector& padded_size,
+                                           T& im, const P& val)
+ {
+diff -uNr a/src/imerode.cc b/src/imerode.cc
+--- a/src/imerode.cc	2020-02-02 08:20:08.000000000 -0500
++++ b/src/imerode.cc	2021-08-20 03:42:06.186092277 -0400
+@@ -32,7 +32,7 @@
+ #define WANTS_OCTAVE_IMAGE_VALUE 1
+ #include "octave-wrappers.h"
+ 
+-using namespace octave::image;
++using namespace octave_image;
+ 
+ // How this works:
+ //
+diff -uNr a/src/imreconstruct.cc b/src/imreconstruct.cc
+--- a/src/imreconstruct.cc	2020-02-02 08:20:08.000000000 -0500
++++ b/src/imreconstruct.cc	2021-08-20 03:42:11.690184639 -0400
+@@ -36,7 +36,7 @@
+ 
+ #include "connectivity.h"
+ 
+-using namespace octave::image;
++using namespace octave_image;
+ 
+ #define WANTS_OCTAVE_IMAGE_VALUE 1
+ #include "octave-wrappers.h"
+diff -uNr a/src/strel.cc b/src/strel.cc
+--- a/src/strel.cc	2020-02-02 08:20:08.000000000 -0500
++++ b/src/strel.cc	2021-08-20 03:39:35.059577831 -0400
+@@ -35,7 +35,7 @@
+ 
+ // Expects a @strel object, or a boolean matrix (or something
+ // that can be converted into one with bool_matrix_value()
+-octave::image::strel::strel (const octave_value& arg)
++octave_image::strel::strel (const octave_value& arg)
+ {
+   octave_value se = arg;
+   // We are only creating a strel object here so that we can use
+@@ -105,7 +105,7 @@
+   return;
+ }
+ 
+-octave::image::strel::strel (const boolNDArray& nhood, const NDArray& height)
++octave_image::strel::strel (const boolNDArray& nhood, const NDArray& height)
+   : nhood (nhood), height (height)
+ {
+   ini_ctor ();
+@@ -114,7 +114,7 @@
+   return;
+ }
+ 
+-octave::image::strel::strel (const boolNDArray& nhood, const NDArray& height,
++octave_image::strel::strel (const boolNDArray& nhood, const NDArray& height,
+                              const Array<octave_idx_type>& origin)
+   : nhood (nhood), height (height), origin (origin)
+ {
+@@ -125,25 +125,25 @@
+ }
+ 
+ boolNDArray
+-octave::image::strel::get_nhood (void) const
++octave_image::strel::get_nhood (void) const
+ {
+   return nhood;
+ }
+ 
+ octave_idx_type
+-octave::image::strel::get_nnz (void) const
++octave_image::strel::get_nnz (void) const
+ {
+   return nnz;
+ }
+ 
+ Array<octave_idx_type>
+-octave::image::strel::get_origin (void) const
++octave_image::strel::get_origin (void) const
+ {
+   return origin;
+ }
+ 
+-octave::image::strel
+-octave::image::strel::operator () (const octave_idx_type& i) const
++octave_image::strel
++octave_image::strel::operator () (const octave_idx_type& i) const
+ {
+   assert (i >= 0 && i < octave_idx_type (decomposition.size ()));
+   return decomposition[i];
+@@ -151,7 +151,7 @@
+ 
+ // Number of strel elements after decomposition
+ octave_idx_type
+-octave::image::strel::numel (void) const
++octave_image::strel::numel (void) const
+ {
+   return octave_idx_type (decomposition.size ());
+ }
+@@ -163,8 +163,8 @@
+ // center of the matrix, there will be no change.
+ // The reason for this is so that we can keep the origin in matrices with
+ // sides with an even length.
+-octave::image::strel
+-octave::image::strel::reflect (void) const
++octave_image::strel
++octave_image::strel::reflect (void) const
+ {
+   boolNDArray ref_nhood   (size);
+   NDArray     ref_height  (size);
+@@ -178,11 +178,11 @@
+   for (octave_idx_type dim = 0; dim < ndims; dim++)
+     ref_origin(dim) = size(dim) - origin(dim) -1;
+ 
+-  return octave::image::strel (ref_nhood, ref_height, ref_origin);
++  return octave_image::strel (ref_nhood, ref_height, ref_origin);
+ }
+ 
+ void
+-octave::image::strel::set_origin (const Array<octave_idx_type>& sub)
++octave_image::strel::set_origin (const Array<octave_idx_type>& sub)
+ {
+   origin = sub;
+   validate_origin ();
+@@ -190,7 +190,7 @@
+ }
+ 
+ bool
+-octave::image::strel::flat (void) const
++octave_image::strel::flat (void) const
+ {
+   bool flat = true;
+   if (! height.all_elements_are_zero ())
+@@ -220,7 +220,7 @@
+ // linear shift is [0 1 11 21 22]
+ // The second element is the matching height for each.
+ Array<octave_idx_type>
+-octave::image::strel::offsets (const dim_vector& cum_size) const
++octave_image::strel::offsets (const dim_vector& cum_size) const
+ {
+   Array<octave_idx_type> sub (dim_vector (ndims, 1), 0);
+   Array<octave_idx_type> offsets (dim_vector (nnz, 1));
+@@ -244,7 +244,7 @@
+ // at coordinates (0,0) of the input matrix and we need enough padding for
+ // it. If the shape is "full", then we add the double.
+ Array<octave_idx_type>
+-octave::image::strel::pre_pad (const octave_idx_type& mt_ndims,
++octave_image::strel::pre_pad (const octave_idx_type& mt_ndims,
+                                const std::string& shape) const
+ {
+   Array<octave_idx_type> pad (dim_vector (mt_ndims, 1), 0);
+@@ -274,7 +274,7 @@
+ }
+ 
+ Array<octave_idx_type>
+-octave::image::strel::post_pad (const octave_idx_type& mt_ndims,
++octave_image::strel::post_pad (const octave_idx_type& mt_ndims,
+                                 const std::string& shape) const
+ {
+   Array<octave_idx_type> pad (dim_vector (mt_ndims, 1), 0);
+@@ -304,7 +304,7 @@
+ }
+ 
+ void
+-octave::image::strel::ini_ctor ()
++octave_image::strel::ini_ctor ()
+ {
+   size    = nhood.dims ();
+   ndims   = nhood.ndims ();
+@@ -313,7 +313,7 @@
+ }
+ 
+ Array<octave_idx_type>
+-octave::image::strel::default_origin ()
++octave_image::strel::default_origin ()
+ {
+   Array<octave_idx_type> origin (dim_vector (ndims, 1));
+   for (octave_idx_type dim = 0; dim < ndims; dim++)
+@@ -323,14 +323,14 @@
+ }
+ 
+ void
+-octave::image::strel::end_ctor (void)
++octave_image::strel::end_ctor (void)
+ {
+   if (decomposition.empty ())
+     decomposition.push_back (*this);
+ }
+ 
+ void
+-octave::image::strel::validate_origin (void)
++octave_image::strel::validate_origin (void)
+ {
+   assert (ndims == origin.numel ());
+   for (octave_idx_type dim = 0; dim < ndims; dim++)
+diff -uNr a/src/strel.h b/src/strel.h
+--- a/src/strel.h	2020-02-02 08:20:08.000000000 -0500
++++ b/src/strel.h	2021-08-20 03:40:39.204639691 -0400
+@@ -45,10 +45,8 @@
+ 
+ #include <octave/ov.h>
+ 
+-namespace octave
++namespace octave_image
+ {
+-  namespace image
+-  {
+     class strel
+     {
+       public:
+@@ -109,14 +107,13 @@
+         void validate_origin (void);
+ 
+     };
+-  }
+ }
+ 
+ // Define it on header or we we need to instantiate it for all
+ // possible classes in strel.cc
+ template<class P>
+ Array<P>
+-octave::image::strel::true_heights (void) const
++octave_image::strel::true_heights (void) const
+ {
+   Array<P> true_heights (dim_vector (nnz, 1));
+   for (octave_idx_type ind = 0, found = 0; found < nnz; ind++)
+diff -uNr a/src/watershed.cc b/src/watershed.cc
+--- a/src/watershed.cc	2020-02-02 08:20:08.000000000 -0500
++++ b/src/watershed.cc	2021-08-20 03:40:18.700299337 -0400
+@@ -26,7 +26,7 @@
+ #include "octave-wrappers.h"
+ 
+ #include "connectivity.h"
+-using namespace octave::image;
++using namespace octave_image;
+ 
+ template<class T>
+ static boolNDArray
+@@ -297,7 +297,7 @@
+ 
+   connectivity conn;
+   if (nargin > 1)
+-    conn = octave::image::conndef (args(1));
++    conn = octave_image::conndef (args(1));
+   else
+     {
+       try
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/of-image-1-no-jit.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,134 @@
+Don't use function dim_vector::to_jit. It was thought to be used exclusively by
+the JIT compiler and it is removed now.
+
+--- ./src/connectivity.h.orig	2020-02-02 14:20:08.000000000 +0100
++++ ./src/connectivity.h	2021-08-11 14:26:19.706581028 +0200
+@@ -153,8 +153,7 @@ octave::image::connectivity::set_padding
+   const Array<octave_idx_type> lengths = padding_lengths (size, padded_size);
+   const octave_idx_type* lengths_v = lengths.fortran_vec ();
+ 
+-  const octave_idx_type* strides_v = size.to_jit ();
+-  const octave_idx_type row_stride = strides_v[0];
++  const octave_idx_type row_stride = size.xelem (0);
+ 
+   std::function<void(const octave_idx_type)> fill;
+   fill = [&] (const octave_idx_type dim) -> void
+@@ -165,7 +164,7 @@ octave::image::connectivity::set_padding
+     if (dim == 0)
+       im_v += row_stride;
+     else
+-      for (octave_idx_type i = 0; i < strides_v[dim]; i++)
++      for (octave_idx_type i = 0; i < size.xelem (dim); i++)
+         fill (dim -1);
+ 
+     for (octave_idx_type i = 0; i < lengths_v[dim]; i++, im_v++)
+
+--- ./src/imreconstruct.cc.orig	2020-02-02 14:20:08.000000000 +0100
++++ ./src/imreconstruct.cc	2021-08-11 14:31:36.450682736 +0200
+@@ -110,10 +110,6 @@ scan_raster_order (T& padded_marker, con
+ 
+   const octave_idx_type n_neighbours = raster_neighbours.numel ();
+ 
+-  // We probably should not be using this but converting to Array
+-  // just to have fortran_vec seems a bit too much.
+-  const octave_idx_type* s = original_size.to_jit ();
+-
+   std::function<void(const octave_idx_type)> scan;
+   scan = [&] (const octave_idx_type dim) -> void
+   {
+@@ -122,7 +118,7 @@ scan_raster_order (T& padded_marker, con
+ 
+     if (dim == 0)
+       {
+-        for (octave_idx_type k = 0; k < s[0]; k++, J++, I++)
++        for (octave_idx_type k = 0; k < original_size.xelem (0); k++, J++, I++)
+           {
+             for (octave_idx_type i = 0; i < n_neighbours; i++)
+               if (*J < J[neighbours[i]])
+@@ -133,7 +129,7 @@ scan_raster_order (T& padded_marker, con
+           }
+       }
+     else
+-      for (octave_idx_type i = 0; i < s[dim]; i++)
++      for (octave_idx_type i = 0; i < original_size.xelem (dim); i++)
+         scan (dim-1);
+ 
+     J += pads[dim];
+@@ -161,10 +157,6 @@ scan_antiraster_order (T& padded_marker,
+ 
+   const octave_idx_type n_neighbours = antiraster_neighbours.numel ();
+ 
+-  // We probably should not be using this but converting to Array
+-  // just to have fortran_vec seems a bit too much.
+-  const octave_idx_type* s = original_size.to_jit ();
+-
+   J += padded_marker.numel () -1;
+   I += padded_marker.numel () -1;
+ 
+@@ -178,7 +170,7 @@ scan_antiraster_order (T& padded_marker,
+ 
+     if (dim == 0)
+       {
+-        for (octave_idx_type k = 0; k < s[0]; k++, J--, I--, ind--)
++        for (octave_idx_type k = 0; k < original_size.xelem (0); k++, J--, I--, ind--)
+           {
+             for (octave_idx_type i = 0; i < n_neighbours; i++)
+               if (*J < J[neighbours[i]])
+@@ -193,7 +185,7 @@ scan_antiraster_order (T& padded_marker,
+           }
+       }
+     else
+-      for (octave_idx_type i = 0; i < s[dim]; i++)
++      for (octave_idx_type i = 0; i < original_size.xelem (dim); i++)
+         scan (dim-1);
+ 
+     J   -= pads[dim];
+
+--- ./src/bwconncomp.cc.orig	2020-02-02 14:20:08.000000000 +0100
++++ ./src/bwconncomp.cc	2021-08-11 14:41:35.249619414 +0200
+@@ -81,13 +81,11 @@ connected_components (const boolNDArray&
+ 
+   const dim_vector original_size = BW.dims ();
+   const dim_vector padded_size = BW_pad.dims ();
+-  const octave_idx_type* o = original_size.to_jit ();
+-  const octave_idx_type* p = padded_size.to_jit ();
+   const octave_idx_type ndims_m1 = BW_pad.ndims () -1;
+ 
+   std::vector<bool> dim_padded (BW_pad.ndims (), true);
+   for (octave_idx_type i = 0; i < BW_pad.ndims (); i++)
+-    if (p[i] == o[i])
++    if (padded_size.xelem (i) == original_size.xelem (i))
+       dim_padded[i] = false;
+ 
+   for (std::vector<octave_idx_type>& conn_comp : all_components)
+@@ -100,21 +98,21 @@ connected_components (const boolNDArray&
+             {
+               if (dim_padded[d])
+                 {
+-                  ind  += mult * (offset % p[d] - 1);
+-                  mult *= p[d] - 2;
+-                  offset /= p[d];
++                  ind  += mult * (offset % padded_size.xelem (d) - 1);
++                  mult *= padded_size.xelem (d) - 2;
++                  offset /= padded_size.xelem (d);
+                 }
+               else
+                 {
+-                  ind  += mult * (offset % p[d]);
+-                  mult *= p[d];
+-                  offset /= p[d];
++                  ind  += mult * (offset % padded_size.xelem (d));
++                  mult *= padded_size.xelem (d);
++                  offset /= padded_size.xelem (d);
+                 }
+             }
+           if (dim_padded[ndims_m1])
+-            ind  += mult * (offset % p[ndims_m1] - 1);
++            ind  += mult * (offset % padded_size.xelem (ndims_m1) - 1);
+           else
+-            ind  += mult * (offset % p[ndims_m1]);
++            ind  += mult * (offset % padded_size.xelem (ndims_m1));
+ 
+           offset = ind;
+         }
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/of-interval-3-error_state.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,151 @@
+# HG changeset patch
+# User Markus Mützel <markus.muetzel@gmx.de>
+# Date 1637946154 -3600
+#      Fri Nov 26 18:02:34 2021 +0100
+# Node ID afe5ca3dbea5893fcc0b166a4c9e4bbaf24f18c5
+# Parent  9014fec674bdbac46727ca3e3f25d57bf06a2115
+Fix compilation with Octave 8 (bug #61568).
+
+* src/crlibm_function.cc (Fcrlibm_function), src/mpfr_function_d.cc
+(Fmpfr_function_d), src/mpfr_linspace_d.cc (Fmpfr_linspace_d),
+src/mpfr_matrix_mul_d.cc (Fmpfr_matrix_mul_d), src/mpfr_matrix_sqr_d.cc
+(Fmpfr_matrix_sqr_d), src/mpfr_to_string_d.cc (Fmpfr_to_string_d),
+src/mpfr_vector_dot_d.cc (Fmpfr_vector_dot_d), src/mpfr_vector_sum_d.cc
+(Fmpfr_vector_sum_d), src/__setround__.cc (F__setround__): Remove usage of
+`error_state`. It was unconditionally set to 0 since about 6 years ago and will
+finally be removed in Octave 8.
+
+diff -r 9014fec674bd -r afe5ca3dbea5 src/__setround__.cc
+--- a/src/__setround__.cc	Mon Dec 21 08:57:25 2020 +0100
++++ b/src/__setround__.cc	Fri Nov 26 18:02:34 2021 +0100
+@@ -62,9 +62,6 @@
+     error ("__setround__: Unsupported rounding mode, please use -inf, +inf "
+            "or 0.5");
+ 
+-  if (error_state)
+-    return octave_value_list ();
+-
+   if (fesetround (mode) != 0)
+     error ("__setround__: Unable to change rounding mode");
+ 
+diff -r 9014fec674bd -r afe5ca3dbea5 src/crlibm_function.cc
+--- a/src/crlibm_function.cc	Mon Dec 21 08:57:25 2020 +0100
++++ b/src/crlibm_function.cc	Fri Nov 26 18:02:34 2021 +0100
+@@ -84,9 +84,6 @@
+   const double      rnd      = args(1).scalar_value ();
+   NDArray           arg1     = args(2).array_value ();
+ 
+-  if (error_state)
+-    return octave_value_list ();
+-
+   if (rnd == INFINITY)
+     {
+       // Round upwards
+diff -r 9014fec674bd -r afe5ca3dbea5 src/mpfr_function_d.cc
+--- a/src/mpfr_function_d.cc	Mon Dec 21 08:57:25 2020 +0100
++++ b/src/mpfr_function_d.cc	Fri Nov 26 18:02:34 2021 +0100
+@@ -391,8 +391,6 @@
+       if (arg1.dims () != arg2.dims () || arg2.dims () != arg3.dims ())
+         error ("mpfr_function_d: Array dimensions must agree!");
+     }
+-  if (error_state)
+-    return octave_value_list ();
+ 
+   // Choose the function to evaluate
+   switch (nargin - 2)
+@@ -491,8 +489,6 @@
+         else if (function == "nthroot")
+           {
+             uint64NDArray n = args (3).uint64_array_value ();
+-            if (error_state)
+-              return octave_value_list ();
+             nthroot (arg1, n, rnd);
+           }
+         else if (function == "plus")
+diff -r 9014fec674bd -r afe5ca3dbea5 src/mpfr_linspace_d.cc
+--- a/src/mpfr_linspace_d.cc	Mon Dec 21 08:57:25 2020 +0100
++++ b/src/mpfr_linspace_d.cc	Fri Nov 26 18:02:34 2021 +0100
+@@ -65,8 +65,6 @@
+     error ("mpfr_linspace_d: vectors must be of equal length");
+   if (rnd != MPFR_RNDD && rnd != MPFR_RNDU)
+     error ("mpfr_linspace_d: only directed rounding supported");
+-  if (error_state)
+-    return octave_value_list ();
+ 
+   // Result size
+   n = std::max (n, 1);
+diff -r 9014fec674bd -r afe5ca3dbea5 src/mpfr_matrix_mul_d.cc
+--- a/src/mpfr_matrix_mul_d.cc	Mon Dec 21 08:57:25 2020 +0100
++++ b/src/mpfr_matrix_mul_d.cc	Fri Nov 26 18:02:34 2021 +0100
+@@ -137,9 +137,7 @@
+   Matrix matrix_yl = args (1).matrix_value ();
+   Matrix matrix_xu = args (2).matrix_value ();
+   Matrix matrix_yu = args (3).matrix_value ();
+-  if (error_state)
+-    return octave_value_list ();
+-  
++
+   std::pair <Matrix, Matrix> result_d = 
+     interval_matrix_mul (matrix_xl, matrix_yl, matrix_xu, matrix_yu);
+   octave_value_list result;
+diff -r 9014fec674bd -r afe5ca3dbea5 src/mpfr_matrix_sqr_d.cc
+--- a/src/mpfr_matrix_sqr_d.cc	Mon Dec 21 08:57:25 2020 +0100
++++ b/src/mpfr_matrix_sqr_d.cc	Fri Nov 26 18:02:34 2021 +0100
+@@ -331,9 +331,7 @@
+ 
+   Matrix matrix_xl = args (0).matrix_value ();
+   Matrix matrix_xu = args (1).matrix_value ();
+-  if (error_state)
+-    return octave_value_list ();
+-  
++
+   std::pair <Matrix, Matrix> result_d = 
+     interval_matrix_sqr (matrix_xl, matrix_xu);
+   octave_value_list result;
+diff -r 9014fec674bd -r afe5ca3dbea5 src/mpfr_to_string_d.cc
+--- a/src/mpfr_to_string_d.cc	Mon Dec 21 08:57:25 2020 +0100
++++ b/src/mpfr_to_string_d.cc	Fri Nov 26 18:02:34 2021 +0100
+@@ -128,9 +128,7 @@
+     }
+   
+   const Matrix x = args (2).matrix_value ();
+-  if (error_state)
+-    return octave_value_list ();
+-  
++
+   char buf [768];
+   mpfr_t mp;
+   mpfr_t zero;
+diff -r 9014fec674bd -r afe5ca3dbea5 src/mpfr_vector_dot_d.cc
+--- a/src/mpfr_vector_dot_d.cc	Mon Dec 21 08:57:25 2020 +0100
++++ b/src/mpfr_vector_dot_d.cc	Fri Nov 26 18:02:34 2021 +0100
+@@ -460,8 +460,6 @@
+           NDArray array_xu = args (2).array_value ();
+           NDArray array_yu = args (3).array_value ();
+           octave_idx_type dim = args (4).scalar_value ();
+-          if (error_state)
+-            return octave_value_list ();
+ 
+           std::pair <NDArray, NDArray> result_d =
+               interval_vector_dot (array_xl, array_yl, array_xu, array_yu, dim);
+@@ -475,8 +473,6 @@
+           const NDArray array_x = args (1).array_value ();
+           const NDArray array_y = args (2).array_value ();
+           const octave_idx_type dim = args (3).scalar_value ();
+-          if (error_state)
+-            return octave_value_list ();
+ 
+           std::pair <NDArray, NDArray> result_and_error
+               = vector_dot (rnd, array_x, array_y, dim, nargout >= 2);
+diff -r 9014fec674bd -r afe5ca3dbea5 src/mpfr_vector_sum_d.cc
+--- a/src/mpfr_vector_sum_d.cc	Mon Dec 21 08:57:25 2020 +0100
++++ b/src/mpfr_vector_sum_d.cc	Fri Nov 26 18:02:34 2021 +0100
+@@ -69,8 +69,6 @@
+   const mpfr_rnd_t rnd      = parse_rounding_mode (args (0).scalar_value ());
+   const NDArray    array    = args (1).array_value ();
+   const octave_idx_type dim = args (2).scalar_value ();
+-  if (error_state)
+-    return octave_value_list ();
+ 
+   if (dim > array.ndims ())
+     {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/of-ltfat-2-LDFLAGS.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,33 @@
+From a4a28fae940e37db61b598ed0ed887f358fbfe1f Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Markus=20M=C3=BCtzel?= <markus.muetzel@gmx.de>
+Date: Sun, 28 Nov 2021 20:04:06 +0100
+Subject: [PATCH] Use LDFLAGS instead of LFLAGS (bug #61576).
+
+* oct/Makefile_unix: Use LDFLAGS instead of LFLAGS. The latter was misnamed and
+removed in Octave 8.  Keep setting LFLAGS for older versions of Octave (prior
+to version 7).
+---
+ oct/Makefile_unix | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/oct/Makefile_unix b/oct/Makefile_unix
+index 8f497297..20edbbc3 100644
+--- a/oct/Makefile_unix
++++ b/oct/Makefile_unix
+@@ -34,9 +34,11 @@ FFTW_LIBS := $(shell $(MKOCTFILE) -p FFTW_LIBS)
+ endif
+ 
+ export CXXFLAGS := $(shell $(MKOCTFILE) -p CXXFLAGS) -std=gnu++11 -Wall -DLTFAT_LARGEARRAYS $(OPTCXXFLAGS)
+-# export is necessary, otherwise LFLAGS won't have any effect
++# export is necessary, otherwise LDFLAGS won't have any effect
+ # at least on Windows and on Mac
+-export LFLAGS := $(shell $(MKOCTFILE) -p LFLAGS) $(FLIBS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FFTW_LIBS) 
++export LDFLAGS := $(shell $(MKOCTFILE) -p LDFLAGS) $(FLIBS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FFTW_LIBS)
++# also export as LFLAGS for Octave prior to version 7
++export LFLAGS := $(shell $(MKOCTFILE) -p LFLAGS) $(FLIBS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FFTW_LIBS)
+ 
+ MKOCTFILEFLAGS = -I../libltfat/modules/libltfat/include -DNDEBUG -L../lib -lltfat
+ 
+-- 
+2.34.1.windows.1
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/of-ocs-6-error_state.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,40 @@
+From b33b618b03579438efceeda51c2d1c6eab0ddea9 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Markus=20M=C3=BCtzel?= <markus.muetzel@gmx.de>
+Date: Sun, 28 Nov 2021 21:29:13 +0100
+Subject: [PATCH] Fix compilation with Octave 8 (bug #61577).
+
+* src/Mshichmanhodgesmosfet.cc (FMshichmanhodgesmosfet): Remove usage of
+`error_state`. It was unconditionally set to 0 since about 6 years ago and
+will finally be removed in Octave 8.
+---
+ src/Mshichmanhodgesmosfet.cc | 8 ++------
+ 1 file changed, 2 insertions(+), 6 deletions(-)
+
+diff --git a/src/Mshichmanhodgesmosfet.cc b/src/Mshichmanhodgesmosfet.cc
+index 4b3e51a..1c0d7c6 100644
+--- a/src/Mshichmanhodgesmosfet.cc
++++ b/src/Mshichmanhodgesmosfet.cc
+@@ -342,10 +342,8 @@ the output structures.\n\
+     error("Mshichmanhodgesmosfet: double type value expected as time instant.\n");
+   }
+ 
+-  if (!error_state)
+-    {
+-      //FIXME: create enum of cases and use switch?
+-      if (eltype == "NMOS")
++  //FIXME: create enum of cases and use switch?
++  if (eltype == "NMOS")
+ 	{
+ 	  //FIXME: change parameters to a single map or Octave_map
+ 	  /* Default n-MOS parameters*/
+@@ -543,7 +541,5 @@ the output structures.\n\
+       else
+ 	error("Mshichmanhodgesmosfet: unknown element type.\n");
+ 
+-    }
+-
+   return (retval);
+ }
+-- 
+2.34.1.windows.1
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/of-optim-1-verror.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,22 @@
+# HG changeset patch
+# User Markus Mützel <markus.muetzel@gmx.de>
+# Date 1637940821 -3600
+#      Fri Nov 26 16:33:41 2021 +0100
+# Node ID c63a32659f1f68b7ec0e3d7431746fded68594ca
+# Parent  4c32793ffd1a83e3d4d918074bdaf659508d416a
+Fix compilation with Octave 8 (bug #61562).
+
+* src/error-helpers.h: Use wrapper function.
+
+diff -r 4c32793ffd1a -r c63a32659f1f src/error-helpers.h
+--- a/src/error-helpers.h	Wed Mar 31 19:56:59 2021 +0200
++++ b/src/error-helpers.h	Fri Nov 26 16:33:41 2021 +0100
+@@ -64,7 +64,7 @@
+       } \
+     catch (OCTAVE__EXECUTION_EXCEPTION& e) \
+       { \
+-        verror (e, __VA_ARGS__); \
++        c_verror (e, __VA_ARGS__); \
+       }
+ #endif
+ 
--- a/src/of-optiminterp.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/of-optiminterp.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := of-optiminterp
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 0.3.6
-$(PKG)_CHECKSUM := 8d6309f389ccfadaadd0dd52e84db21aa75b82f3
+$(PKG)_VERSION  := 0.3.7
+$(PKG)_CHECKSUM := b67f1938c817ba22b49e7da1405fa93d8d9fd196
 $(PKG)_REMOTE_SUBDIR :=
 $(PKG)_SUBDIR   := optiminterp-$($(PKG)_VERSION)
 $(PKG)_FILE     := optiminterp-$($(PKG)_VERSION).tar.gz
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/of-signal-1-deprecated-warnings.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,12 @@
+diff -uNr a/src/Makefile b/src/Makefile
+--- a/src/Makefile	2019-02-08 17:00:37.000000000 -0500
++++ b/src/Makefile	2021-08-20 01:01:13.437770211 -0400
+@@ -19,7 +19,7 @@
+ MKOCTFILE ?= mkoctfile
+ SED       ?= sed
+ 
+-PKG_CXXFLAGS := -Wall -Wno-deprecated-declarations $(PKG_CXXFLAGS_APPEND)
++PKG_CXXFLAGS := -Wall $(PKG_CXXFLAGS_APPEND)
+ 
+ OCT_FILES = \
+   __fwht__.oct \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/of-signal-2-error_state.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,141 @@
+# HG changeset patch
+# User Markus Mützel <markus.muetzel@gmx.de>
+# Date 1637941971 -3600
+#      Fri Nov 26 16:52:51 2021 +0100
+# Node ID 8d0372aeaf46d24f1d1b22ffc1bbfa32e7623250
+# Parent  7f535130c1912a5cc5021b5a761be02509219738
+Fix compilation with Octave 8 (bug #61564).
+
+* src/cl2bp.cc (Fcl2bp), src/sosfilt.cc (Fsosfilt), src/upfirdn.cc (Fupfirdn):
+Remove usage of `error_state`. It was unconditionally set to 0 since about 6
+years ago and will finally be removed in Octave 8.
+
+diff -r 7f535130c191 -r 8d0372aeaf46 src/cl2bp.cc
+--- a/src/cl2bp.cc	Thu Jun 17 00:46:56 2021 +0200
++++ b/src/cl2bp.cc	Fri Nov 26 16:52:51 2021 +0100
+@@ -89,30 +89,10 @@
+   }
+ 
+   const int m = args(0).int_value(true);
+-  if (error_state) {
+-    err_wrong_type_arg ("cl2bp", args(0));
+-    return retval;
+-  }
+   const double w1 = args(1).double_value();
+-  if (error_state) {
+-    err_wrong_type_arg ("cl2bp", args(1));
+-    return retval;
+-  }
+   const double w2 = args(2).double_value();
+-  if (error_state) {
+-    err_wrong_type_arg ("cl2bp", args(2));
+-    return retval;
+-  }
+   const ColumnVector up_vector(args(3).vector_value());
+-  if (error_state) {
+-    err_wrong_type_arg ("cl2bp", args(3));
+-    return retval;
+-  }
+   const ColumnVector lo_vector(args(4).vector_value());
+-  if (error_state) {
+-    err_wrong_type_arg ("cl2bp", args(4));
+-    return retval;
+-  }
+   if (up_vector.numel() != 3 || lo_vector.numel() != 3) {
+     error("cl2bp: The up and lo vectors must contain 3 values");
+     return retval;
+@@ -126,10 +106,6 @@
+   }
+ 
+   const int L = args(5).int_value(true);
+-  if (error_state) {
+-    err_wrong_type_arg ("cl2bp", args(5));
+-    return retval;
+-  }
+   if (L > 1000000) {
+     error("cl2bp: The \"gridsize\" parameter cannot exceed 1000000");
+     return retval;
+diff -r 7f535130c191 -r 8d0372aeaf46 src/sosfilt.cc
+--- a/src/sosfilt.cc	Thu Jun 17 00:46:56 2021 +0200
++++ b/src/sosfilt.cc	Fri Nov 26 16:52:51 2021 +0100
+@@ -55,12 +55,6 @@
+ 
+   Matrix sos( args(0).matrix_value() );
+ 
+-  if (error_state)
+-    {
+-      err_wrong_type_arg ("sosfilt", args(0));
+-      return retval;
+-    }
+-
+   if (sos.columns() != 6)
+     {
+       error("Second-order section matrix must be a non-empty Lx6 matrix");
+@@ -69,12 +63,6 @@
+ 
+   Matrix x( args(1).matrix_value() );
+ 
+-  if (error_state)
+-    {
+-      err_wrong_type_arg ("sosfilt", args(1));
+-      return retval;
+-    }
+-
+   int n=x.rows();
+   int m=x.columns();
+ 
+diff -r 7f535130c191 -r 8d0372aeaf46 src/upfirdn.cc
+--- a/src/upfirdn.cc	Thu Jun 17 00:46:56 2021 +0200
++++ b/src/upfirdn.cc	Fri Nov 26 16:52:51 2021 +0100
+@@ -107,51 +107,19 @@
+     }
+ 
+   ColumnVector h (args (1).vector_value ());
+-
+-  if (error_state)
+-    {
+-      err_wrong_type_arg ("upfirdn", args(1));
+-      return retval;
+-    }
+-
+   octave_idx_type p = args (2).idx_type_value ();
+-
+-  if (error_state)
+-    {
+-      err_wrong_type_arg ("upfirdn", args(2));
+-      return retval;
+-    }
+-
+   octave_idx_type q = args (3).idx_type_value ();
+ 
+-  if (error_state)
+-    {
+-      err_wrong_type_arg ("upfirdn", args(3));
+-      return retval;
+-    }
+-
+   // Do the dispatching
+   if (octave::signal::isreal (args (0)))
+     {
+       Matrix x = args (0).matrix_value ();
+-      if (error_state)
+-        {
+-          err_wrong_type_arg ("upfirdn", args(0));
+-          return retval;
+-        }
+-
+       Matrix y = upfirdn (x, h, p, q);
+       retval (0) = y;
+     }
+   else if (octave::signal::iscomplex (args (0)))
+     {
+       ComplexMatrix x = args (0).complex_matrix_value ();
+-      if (error_state)
+-        {
+-          err_wrong_type_arg ("upfirdn", args(0));
+-          return retval;
+-        }
+-
+       ComplexMatrix y = upfirdn (x, h, p, q);
+       retval (0) = y;
+     }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/of-sparsersb-1-no-internal-mex-fcns.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,25 @@
+# HG changeset patch
+# User Markus Mützel <markus.muetzel@gmx.de>
+# Date 1633779189 -7200
+#      Sat Oct 09 13:33:09 2021 +0200
+# Node ID 11cafc15faeec2ea20216f8b6e22906df5932e53
+# Parent  67a14d968d2db3ffe34474e6be1c7a2d164ad416
+Don't use internal functions (bug #61320).
+
+* src/sparsersb.cc (subsasgn): Use "ridx" and "cidx" instead of internal
+  functions.
+
+diff -r 67a14d968d2d -r 11cafc15faee src/sparsersb.cc
+--- a/src/sparsersb.cc	Tue Sep 21 11:09:59 2021 +0200
++++ b/src/sparsersb.cc	Sat Oct 09 13:33:09 2021 +0200
+@@ -1242,8 +1242,8 @@
+ 						if(ovl(0).issparse() && ovl(0).isreal() && rhs.isreal())
+ 						{
+   							const SparseBoolMatrix sm = SparseBoolMatrix (ovl(0).sparse_matrix_value());
+-							const octave_idx_type * ir = sm.mex_get_ir ();
+-							const octave_idx_type * jc = sm.mex_get_jc ();
++							const octave_idx_type * ir = sm.ridx ();
++							const octave_idx_type * jc = sm.cidx ();
+         						const octave_idx_type nc = sm.cols ();
+ 							RSBOI_DEBUG_NOTICE(RSBOI_D_EMPTY_MSG);
+ 							const RSBOI_T rv = rhs.double_value();
--- a/src/of-strings-1-fixes.patch	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/of-strings-1-fixes.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -14,23 +14,3 @@
  
  pcregexp.oct: %.oct: %.cc
  	$(MKOCTFILE) $(PCRE_SWITCHES) -o $@ $<
-diff -uNr a/src/pcregexp.cc b/src/pcregexp.cc
---- a/src/pcregexp.cc	2015-06-06 17:40:45.000000000 -0400
-+++ b/src/pcregexp.cc	2018-04-09 15:01:27.359869527 -0400
-@@ -22,6 +22,7 @@
- // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- 
- #include <octave/oct.h>
-+#include <octave/errwarn.h>
- #include <pcre.h>
- #include <iostream>
- #include <vector>
-@@ -49,7 +50,7 @@
-     std::string pattern = args(0).string_value();
-     std::string input = args(1).string_value();
-     if (error_state) {
--        gripe_wrong_type_arg("pcregexp", args(0));
-+        err_wrong_type_arg("pcregexp", args(0));
-         return retval;
-     }
- 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/of-strings-2-error_state.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,26 @@
+# HG changeset patch
+# User Markus Mützel <markus.muetzel@gmx.de>
+# Date 1638133340 -3600
+#      Sun Nov 28 22:02:20 2021 +0100
+# Node ID 2f2695e1f4b779632465782368c89ef1c7df0d91
+# Parent  c3d5e17f6023c14b85d405aba8b1c76a8f54d02a
+Fix compilation with Octave 8 (bug #61578).
+
+* src/pcregexp.cc (Fpcregexp): Remove usage of `error_state`. It was
+unconditionally set to 0 since about 6 years ago and will finally be removed in
+Octave 8.
+
+diff -r c3d5e17f6023 -r 2f2695e1f4b7 src/pcregexp.cc
+--- a/src/pcregexp.cc	Thu Jan 09 16:50:10 2020 -0500
++++ b/src/pcregexp.cc	Sun Nov 28 22:02:20 2021 +0100
+@@ -48,10 +48,6 @@
+ 
+     std::string pattern = args(0).string_value();
+     std::string input = args(1).string_value();
+-    if (error_state) {
+-        gripe_wrong_type_arg("pcregexp", args(0));
+-        return retval;
+-    }
+ 
+     // Compile expression
+     pcre *re;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/of-struct-1-verror.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,22 @@
+# HG changeset patch
+# User Markus Mützel <markus.muetzel@gmx.de>
+# Date 1638187375 -3600
+#      Mon Nov 29 13:02:55 2021 +0100
+# Node ID 3d28b7df6df9c5c161f9e4518a03c34d6300f2b4
+# Parent  b38448d3d291256bedb125b2c52c40820acdc235
+Fix compilation with Octave 8 (bug #61582).
+
+* src/error-helpers.h: Use wrapper function.
+
+diff -r b38448d3d291 -r 3d28b7df6df9 src/error-helpers.h
+--- a/src/error-helpers.h	Wed Feb 17 13:25:40 2021 +0100
++++ b/src/error-helpers.h	Mon Nov 29 13:02:55 2021 +0100
+@@ -64,7 +64,7 @@
+       } \
+     catch (OCTAVE__EXECUTION_EXCEPTION& e) \
+       { \
+-        verror (e, __VA_ARGS__); \
++        c_verror (e, __VA_ARGS__); \
+       }
+ #endif
+ 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/of-tisean-2-error_state.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,637 @@
+# HG changeset patch
+# User Markus Mützel <markus.muetzel@gmx.de>
+# Date 1638190865 -3600
+#      Mon Nov 29 14:01:05 2021 +0100
+# Node ID fdca531d6a1268500b3ebefbacb97a4a44141c43
+# Parent  7d4b181cd726d9ad0d6ee5a37d128d90fc925858
+Remove usage of `error_state` (bug #61583).
+
+* src/pcregexp.cc (many files): Remove usage of `error_state`. It was
+unconditionally set to 0 since about 6 years ago and will finally be removed in
+Octave 8.
+
+diff -r 7d4b181cd726 -r fdca531d6a12 src/__boxcount__.cc
+--- a/src/__boxcount__.cc	Mon Nov 29 13:49:05 2021 +0100
++++ b/src/__boxcount__.cc	Mon Nov 29 14:01:05 2021 +0100
+@@ -194,8 +194,6 @@
+ 
+       octave_idx_type length=LENGTH-(maxembed-1)*DELAY;
+ 
+-      if ( ! error_state)
+-        {
+           // Calculate output
+           double heps              = EPSMAX*EPSFAKTOR;
+           octave_idx_type epsi_old = 0;
+@@ -276,7 +274,6 @@
+ 
+ 
+           retval(0) = output;
+-        }
+     }
+   return retval;
+ }
+diff -r 7d4b181cd726 -r fdca531d6a12 src/__c1__.cc
+--- a/src/__c1__.cc	Mon Nov 29 13:49:05 2021 +0100
++++ b/src/__c1__.cc	Mon Nov 29 14:01:05 2021 +0100
+@@ -77,10 +77,6 @@
+       bool verbose           = args(9).bool_value ();
+       octave_idx_type iverb  = verbose;
+ 
+-
+-      if (! error_state)
+-        {
+-
+           octave_idx_type lines_read   = input.rows (); //nmax in d1()
+           octave_idx_type columns_read = input.columns ();
+ 
+@@ -136,7 +132,6 @@
+             }
+ 
+           retval(0) = output;
+-        }
+     }
+   return retval;
+ }
+diff -r 7d4b181cd726 -r fdca531d6a12 src/__d2__.cc
+--- a/src/__d2__.cc	Mon Nov 29 13:49:05 2021 +0100
++++ b/src/__d2__.cc	Mon Nov 29 14:01:05 2021 +0100
+@@ -365,9 +365,6 @@
+       time_t lasttime;
+       time(&lasttime);
+ 
+-      if (! error_state)
+-        {
+-
+           bool imin_too_large = false;
+           bool pause_calc     = false;
+           // Calculate the outputs
+@@ -608,7 +605,6 @@
+           // Assign outputs
+           retval(0) = values;
+           retval(1) = vars;
+-        }
+ 
+     }
+   return retval;
+diff -r 7d4b181cd726 -r fdca531d6a12 src/__delay__.cc
+--- a/src/__delay__.cc	Mon Nov 29 13:49:05 2021 +0100
++++ b/src/__delay__.cc	Mon Nov 29 14:01:05 2021 +0100
+@@ -60,8 +60,6 @@
+ 
+       OCTAVE_LOCAL_BUFFER (octave_idx_type, inddelay, alldim);
+ 
+-      if (! error_state)
+-        {
+           octave_idx_type rundel=0;
+           octave_idx_type runmdel=0;
+ 
+@@ -108,7 +106,6 @@
+               // previously fprintf(stdout,"\n");
+             }
+           retval(0) = series;
+-        }
+ 
+     }
+   return retval;
+diff -r 7d4b181cd726 -r fdca531d6a12 src/__false_nearest__.cc
+--- a/src/__false_nearest__.cc	Mon Nov 29 13:49:05 2021 +0100
++++ b/src/__false_nearest__.cc	Mon Nov 29 14:01:05 2021 +0100
+@@ -179,8 +179,6 @@
+       check_alloc(vcomp=(unsigned int*)malloc(sizeof(int)*(maxdim)));
+       check_alloc(vemb=(unsigned int*)malloc(sizeof(int)*(maxdim)));
+ 
+-      if ( ! error_state)
+-        {
+           for (i=0;i<maxdim;i++) {
+             if (comp == 1) {
+               vcomp[i]=0;
+@@ -250,7 +248,6 @@
+ 
+           for (i = 0; i < 4; i++)
+             retval(i) = output.column(i);
+-        }
+     }
+   return retval;
+ }
+diff -r 7d4b181cd726 -r fdca531d6a12 src/__ghkss__.cc
+--- a/src/__ghkss__.cc	Mon Nov 29 13:49:05 2021 +0100
++++ b/src/__ghkss__.cc	Mon Nov 29 14:01:05 2021 +0100
+@@ -203,8 +203,6 @@
+ 
+   OCTAVE_LOCAL_BUFFER (double, hav, comp);
+   OCTAVE_LOCAL_BUFFER (double, hsigma, comp);
+-  if ( ! error_state)
+-    {
+       for (j=0;j<comp;j++)
+         hav[j]=hsigma[j]=0.0;
+ 
+@@ -238,7 +236,6 @@
+       }
+ 
+       resize_eps=0;
+-    }
+ }
+ 
+ DEFUN_DLD (__ghkss__, args, , HELPTEXT)
+@@ -338,9 +335,6 @@
+         mat[i]=(double*)(matarray+dim*i);
+       check_alloc(hser=(double**)malloc(sizeof(double*)*comp));
+ 
+-      if ( ! error_state)
+-        {
+-          // Create output matrix
+           Matrix output (length, comp);
+ 
+           for (i=0;i<dim;i++) {
+@@ -423,7 +417,7 @@
+                   }
+             }
+           retval(0) = output;
+-        }
++
+     // Deallocate of all the memory
+       delete[] d_min;
+       delete[] d_max;
+diff -r 7d4b181cd726 -r fdca531d6a12 src/__lfo_ar__.cc
+--- a/src/__lfo_ar__.cc	Mon Nov 29 13:49:05 2021 +0100
++++ b/src/__lfo_ar__.cc	Mon Nov 29 14:01:05 2021 +0100
+@@ -168,12 +168,6 @@
+     Matrix solved_vec = mat.solve(vec);
+     double *solved_vec_arr = solved_vec.fortran_vec ();
+ 
+-    // If errors were raised, there is no sense in countinueing
+-    if (error_state)
+-      {
+-        return ;
+-      }
+-
+     double cast=foreav[i];
+     for (octave_idx_type j=0;j<dim;j++) {
+ 
+@@ -262,9 +256,6 @@
+ 
+       octave_idx_type clength=(CLENGTH <= LENGTH) ? CLENGTH-STEP : LENGTH-STEP;
+ 
+-      if ( ! error_state)
+-        {
+-
+           // Promote warnings connected with singular matrixes to errors
+           set_warning_state ("Octave:nearly-singular-matrix","error");
+           set_warning_state ("Octave:singular-matrix","error");
+@@ -313,11 +304,6 @@
+                       make_fit (series, found, error_array,
+                                 i,dim, embed, delay, STEP, actfound);
+                       // Checking if the fit was correct
+-                      // If any errors were raised: end function
+-                      if (error_state)
+-                        {
+-                          return retval;
+-                        }
+                       pfound++;
+                       avfound += (double)(actfound-1);
+                       for (octave_idx_type j=0;j<dim;j++) 
+@@ -365,7 +351,6 @@
+           output.resize (count, dim + 4);
+ 
+           retval(0) = output;
+-        }
+     }
+   return retval;
+ }
+diff -r 7d4b181cd726 -r fdca531d6a12 src/__lfo_run__.cc
+--- a/src/__lfo_run__.cc	Mon Nov 29 13:49:05 2021 +0100
++++ b/src/__lfo_run__.cc	Mon Nov 29 14:01:05 2021 +0100
+@@ -226,13 +226,6 @@
+       Matrix solved_vec      = mat.solve (vec);
+       double *solved_vec_arr = solved_vec.fortran_vec ();
+ 
+-    // If errors were raised (a singular matrix was encountered), 
+-    // there is no sense in countinuing
+-    if (error_state)
+-      {
+-        return ;
+-      }
+-
+       newcast[i]=foreav[i];
+       for (octave_idx_type j=0;j<dim;j++) {
+         for (octave_idx_type j1=0;j1<embed;j1++) {
+@@ -330,9 +323,6 @@
+         for (octave_idx_type i=0;i<hdim;i++)
+           cast[i][j]=series[j][LENGTH-hdim+i];
+ 
+-      if ( ! error_state)
+-        {
+-
+           // Promote warnings connected with singular matrixes to errors
+           set_warning_state ("Octave:nearly-singular-matrix","error");
+           set_warning_state ("Octave:singular-matrix","error");
+@@ -377,12 +367,6 @@
+                         make_zeroth(series, found, dim, actfound,newcast);
+ 
+                       // Checking if the fit was correct
+-                      // If any errors were raised: end function
+-                      if (error_state)
+-                        {
+-                          return retval;
+-                        }
+-
+                       for (octave_idx_type j=0;j<dim;j++)
+                         {
+                       // old printf("%e ",newcast[j]*interval[j]+min_array[j]);
+@@ -410,7 +394,6 @@
+                 }
+             }
+           retval(0) = output;
+-        }
+     }
+   return retval;
+ }
+diff -r 7d4b181cd726 -r fdca531d6a12 src/__lfo_test__.cc
+--- a/src/__lfo_test__.cc	Mon Nov 29 13:49:05 2021 +0100
++++ b/src/__lfo_test__.cc	Mon Nov 29 14:01:05 2021 +0100
+@@ -212,13 +212,6 @@
+       Matrix solved_vec      = mat.solve (vec);
+       double *solved_vec_arr = solved_vec.fortran_vec ();
+ 
+-    // If errors were raised (a singular matrix was encountered), 
+-    // there is no sense in countinueing
+-    if (error_state)
+-      {
+-        return ;
+-      }
+-
+       newcast[i]=foreav[i];
+       for (octave_idx_type j=0;j<DIM;j++) {
+         octave_idx_type hcj=indexes[0][j];
+@@ -332,9 +325,6 @@
+       for (octave_idx_type i=0;i<COMP;i++)
+         error_array[i]=0.0;
+ 
+-      if ( ! error_state)
+-        {
+-
+           // Promote warnings connected with singular matrixes to errors
+           set_warning_state ("Octave:nearly-singular-matrix","error");
+           set_warning_state ("Octave:singular-matrix","error");
+@@ -375,11 +365,6 @@
+                       make_fit(series, indexes, found, STEP, DIM, COMP,
+                                actfound,i,newcast);
+                       // Checking if the fit was correct
+-                      // If any errors were raised: end function
+-                      if (error_state)
+-                        {
+-                          return retval;
+-                        }
+                       for (octave_idx_type j=0;j<COMP;j++)
+                         error_array[j] += sqr(newcast[j]-series[j][i+STEP]);
+ 
+@@ -415,7 +400,6 @@
+ 
+           retval(0) = rel;
+           retval(1) = ind;
+-        }
+     }
+   return retval;
+ }
+diff -r 7d4b181cd726 -r fdca531d6a12 src/__lyap_k__.cc
+--- a/src/__lyap_k__.cc	Mon Nov 29 13:49:05 2021 +0100
++++ b/src/__lyap_k__.cc	Mon Nov 29 14:01:05 2021 +0100
+@@ -211,8 +211,6 @@
+         eps_fak=pow(epsmax/epsmin,1.0/(double)(epscount-1));
+ 
+ 
+-      if (! error_state)
+-        {
+           // Calculate exponents
+           dim_vector dv (epscount ,((int)maxdim-(int)mindim + 1));
+           string_vector keys;
+@@ -274,7 +272,6 @@
+             }
+           // Assign output
+           retval(0) = output;
+-        }
+     }
+   return retval;
+ }
+diff -r 7d4b181cd726 -r fdca531d6a12 src/__lyap_r__.cc
+--- a/src/__lyap_r__.cc	Mon Nov 29 13:49:05 2021 +0100
++++ b/src/__lyap_r__.cc	Mon Nov 29 14:01:05 2021 +0100
+@@ -167,9 +167,6 @@
+       octave_idx_type maxlength=length-delay*(dim-1)-steps-1-mindist;
+       bool alldone=0;
+ 
+-      if (! error_state)
+-        {
+-
+           // Calculate the maximum epsilon that makes sense
+           // On the basis of 'i' and 'j' from put_in_boxes ()
+           NDArray input_max = input.max ();
+@@ -224,7 +221,6 @@
+ 
+           // Assign output
+           retval(0) = output;
+-        }
+     }
+   return retval;
+ }
+diff -r 7d4b181cd726 -r fdca531d6a12 src/__lyap_spec__.cc
+--- a/src/__lyap_spec__.cc	Mon Nov 29 13:49:05 2021 +0100
++++ b/src/__lyap_spec__.cc	Mon Nov 29 14:01:05 2021 +0100
+@@ -220,13 +220,6 @@
+       Matrix solved      = mat.solve (vec);
+       double *solved_arr = solved.fortran_vec ();
+ 
+-    // If errors were raised (a singular matrix was encountered), 
+-    // there is no sense in countinuing
+-    if (error_state)
+-      {
+-        return ;
+-      }
+-
+       double new_vec = solved_arr[0];
+       for (octave_idx_type i=1;i<=alldim;i++)
+         dynamics[d][i-1] = solved_arr[i];
+@@ -419,9 +412,6 @@
+         }
+      // end old indexes = make_multi_index();
+ 
+-      if (!error_state)
+-        {
+-
+           // Promote warnings connected with singular matrixes to errors
+           set_warning_state ("Octave:nearly-singular-matrix","error");
+           set_warning_state ("Octave:singular-matrix","error");
+@@ -463,13 +453,7 @@
+               make_dynamics(series, box, indexes, epsmin, epsset, EPSSTEP,
+                             EMBED, MINNEIGHBORS, LENGTH, DIMENSION, count,
+                             avneig, aveps, dynamics, averr, i);
+-              // If there was an error
+-              // (matrix singularity or not enough neighbors)
+-              // No sense continuing
+-              if (error_state)
+-                {
+-                  return retval;
+-                }
++
+               make_iteration(DIMENSION, alldim, dynamics, delta);
+               gram_schmidt(alldim, delta,lfactor);
+               for (octave_idx_type j=0;j<alldim;j++) {
+@@ -562,7 +546,6 @@
+               retval(0) = lyap_exp;
+               retval(1) = pars;
+             }
+-        }
+     }
+   return retval;
+ }
+diff -r 7d4b181cd726 -r fdca531d6a12 src/__lzo_gm__.cc
+--- a/src/__lzo_gm__.cc	Mon Nov 29 13:49:05 2021 +0100
++++ b/src/__lzo_gm__.cc	Mon Nov 29 14:01:05 2021 +0100
+@@ -110,8 +110,6 @@
+ 
+       MArray<octave_idx_type> box (dim_vector(NMAX,NMAX));
+ 
+-      if ( ! error_state)
+-        {
+           // Estimate maximum possible output size
+           octave_idx_type output_rows = (octave_idx_type)
+                                         ((log(EPS1) - log(EPS0)) / log (EPSF));
+@@ -194,8 +192,6 @@
+           output.resize (count, dim + 4);
+ 
+           retval(0) = output;
+-
+-        }
+     }
+   return retval;
+ }
+diff -r 7d4b181cd726 -r fdca531d6a12 src/__lzo_run__.cc
+--- a/src/__lzo_run__.cc	Mon Nov 29 13:49:05 2021 +0100
++++ b/src/__lzo_run__.cc	Mon Nov 29 14:01:05 2021 +0100
+@@ -209,8 +209,6 @@
+ 
+       MArray<octave_idx_type> box (dim_vector(NMAX,NMAX));
+ 
+-      if ( ! error_state)
+-        {
+           for (octave_idx_type j=0;j<dim;j++)
+             for (octave_idx_type i=0;i<hdim;i++)
+               cast[i][j]=input(LENGTH-hdim+i,j);
+@@ -292,7 +290,6 @@
+             }
+           else 
+             retval(0) = Matrix (0,0);
+-        }
+     }
+   return retval;
+ }
+diff -r 7d4b181cd726 -r fdca531d6a12 src/__lzo_test__.cc
+--- a/src/__lzo_test__.cc	Mon Nov 29 13:49:05 2021 +0100
++++ b/src/__lzo_test__.cc	Mon Nov 29 14:01:05 2021 +0100
+@@ -150,8 +150,6 @@
+       MArray<octave_idx_type> box (dim_vector(NMAX, NMAX));
+ 
+       // Compute forecast error
+-      if ( ! error_state)
+-        {
+           for (octave_idx_type i=0;i<LENGTH;i++)
+             done[i]=0;
+ 
+@@ -236,7 +234,6 @@
+ 
+           retval(0) = rel_forecast_err;
+           retval(1) = ind_forecast_err;
+-        }
+     }
+   return retval;
+ }
+diff -r 7d4b181cd726 -r fdca531d6a12 src/__poincare__.cc
+--- a/src/__poincare__.cc	Mon Nov 29 13:49:05 2021 +0100
++++ b/src/__poincare__.cc	Mon Nov 29 14:01:05 2021 +0100
+@@ -129,8 +129,6 @@
+ 
+ 
+ 
+-        if ( ! error_state)
+-          {
+             Matrix output (out_size, embdim);
+ 
+             octave_idx_type count = poincare (input.fortran_vec(), 
+@@ -141,7 +139,6 @@
+             output.resize (count, embdim);
+ 
+             retval(0) = output;
+-          }
+     }
+   return retval;
+ }
+diff -r 7d4b181cd726 -r fdca531d6a12 src/__polynom__.cc
+--- a/src/__polynom__.cc	Mon Nov 29 13:49:05 2021 +0100
++++ b/src/__polynom__.cc	Mon Nov 29 14:01:05 2021 +0100
+@@ -222,8 +222,6 @@
+       make_coding(coding_vec,N,N,DIM-1,1,0);
+       octave_idx_type *coding = coding_vec.data();
+ 
+-      if (! error_state)
+-        {
+           // Promote warnings connected with singular matrixes to errors
+           set_warning_state ("Octave:nearly-singular-matrix","error");
+           set_warning_state ("Octave:singular-matrix","error");
+@@ -232,12 +230,6 @@
+           make_fit (series, coding, results, INSAMPLE, N, DIM, DELAY,
+                     maxencode, pars);
+ 
+-          // If error encountered during the fit there is no sense to continue
+-          if (error_state)
+-            {
+-              return retval;
+-            }
+-
+           // Create outputs
+ 
+           // Create output that contains the number of free parameters
+@@ -303,7 +295,6 @@
+           retval(2) = coeffs;
+           retval(3) = sample_err;
+           retval(4) = forecast;
+-        }
+     }
+   return retval;
+ }
+diff -r 7d4b181cd726 -r fdca531d6a12 src/__rbf__.cc
+--- a/src/__rbf__.cc	Mon Nov 29 13:49:05 2021 +0100
++++ b/src/__rbf__.cc	Mon Nov 29 14:01:05 2021 +0100
+@@ -152,9 +152,6 @@
+         for (octave_idx_type j=0;j<DIM;j++)
+           center[i][j]=series[(DIM-1)*DELAY-j*DELAY+(i*cstep)/(CENTER-1)];
+ 
+-      if (! error_state)
+-        {
+-
+           // Promote warnings connected with singular matrixes to errors
+           set_warning_state ("Octave:nearly-singular-matrix","error");
+           set_warning_state ("Octave:singular-matrix","error");
+@@ -207,10 +204,6 @@
+           coefs = mat.solve(coefs);
+           coefs_arr = coefs.fortran_vec ();// coefs takes up new memory space
+ 
+-          // If solving the matrix generated errors do not continue
+-          if (error_state)
+-            return retval;
+-
+           // end make_fit()
+ 
+ 
+@@ -314,7 +307,6 @@
+           retval(2) = coeff; 
+           retval(3) = sample_error; // sample error [in sample; out of sample];
+           retval(4) = forecast; // forecast values;
+-        }
+     }
+   return retval;
+ }
+diff -r 7d4b181cd726 -r fdca531d6a12 src/__surrogates__.cc
+--- a/src/__surrogates__.cc	Mon Nov 29 13:49:05 2021 +0100
++++ b/src/__surrogates__.cc	Mon Nov 29 14:01:05 2021 +0100
+@@ -63,9 +63,6 @@
+       octave_idx_type ispec = args(3).idx_type_value ();
+       double seed           = args(4).double_value ();
+ 
+-      if (! error_state)
+-        {
+-
+           octave_idx_type nmaxp = input.rows ();
+           octave_idx_type mcmax = input.columns ();
+ 
+@@ -90,8 +87,6 @@
+ 
+           retval(0) = surro_data;
+           retval(1) = pars;
+-        }
+-
+     }
+   return retval;
+ }
+diff -r 7d4b181cd726 -r fdca531d6a12 src/__upo__.cc
+--- a/src/__upo__.cc	Mon Nov 29 13:49:05 2021 +0100
++++ b/src/__upo__.cc	Mon Nov 29 14:01:05 2021 +0100
+@@ -74,10 +74,6 @@
+       int icen        = args(9).int_value();
+ 
+ 
+-
+-      if (! error_state)
+-        {
+-
+           int lines_read = in_out1.numel();
+           // Generating output vectors with estimated lengths
+           // The extra length (+1) is to store the actual lengths
+@@ -98,7 +94,6 @@
+           retval(1) = orbit_data;
+           retval(2) = acc;
+           retval(3) = stability;
+-        }
+     }
+   return retval;
+ }
+diff -r 7d4b181cd726 -r fdca531d6a12 src/__xzero__.cc
+--- a/src/__xzero__.cc	Mon Nov 29 13:49:05 2021 +0100
++++ b/src/__xzero__.cc	Mon Nov 29 14:01:05 2021 +0100
+@@ -111,8 +111,6 @@
+       double epsilon=EPS0/EPSF;
+       octave_idx_type clength=(CLENGTH <= LENGTH) ? CLENGTH-STEP : LENGTH-STEP;
+ 
+-      if (! error_state)
+-        {
+           // Calculate fit
+           while (!alldone) {
+             alldone=1;
+@@ -142,8 +140,6 @@
+               output(i,0) = sqrt(error_array[i]/(clength-(DIM-1)*DELAY))/rms2;
+             }
+           retval(0) = output;
+-        }
+-
+     }
+   return retval;
+ }
+diff -r 7d4b181cd726 -r fdca531d6a12 src/lazy.cc
+--- a/src/lazy.cc	Mon Nov 29 13:49:05 2021 +0100
++++ b/src/lazy.cc	Mon Nov 29 14:01:05 2021 +0100
+@@ -133,8 +133,6 @@
+                        "Number of iterations (IMAX) must be a positive "
+                        "integer");
+ 
+-      if (! error_state)
+-        {
+         // If vector is in 1 row: transpose (we will transpose the output to fit)
+             transposed = 0;
+ 
+@@ -160,7 +158,6 @@
+ 
+           retval(0) = in_out1;
+           retval(1) = in_out2;
+-        }
+     }
+   return retval;
+ }
+diff -r 7d4b181cd726 -r fdca531d6a12 src/mutual.cc
+--- a/src/mutual.cc	Mon Nov 29 13:49:05 2021 +0100
++++ b/src/mutual.cc	Mon Nov 29 14:01:05 2021 +0100
+@@ -193,8 +193,6 @@
+       int32NDArray h2 (dim_vector(partitions, partitions));
+       OCTAVE_LOCAL_BUFFER (long, array, length);
+ 
+-      if (! error_state)
+-        {
+           // Load array
+ 
+           // Rescale data and load array
+@@ -246,7 +244,6 @@
+             }
+           retval(0) = delay;
+           retval(1) = mutual_inf;
+-        }
+     }
+   return retval;
+ }
--- a/src/of-video-1-fixes.patch	Wed Nov 24 18:31:48 2021 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-Only in video-2.0.0/src: aclocal.m4
-diff -ur video-2.0.0.orig/src/configure video-2.0.0/src/configure
---- video-2.0.0.orig/src/configure	2020-03-04 11:23:26.508419633 -0500
-+++ video-2.0.0/src/configure	2020-03-04 12:19:15.552103743 -0500
-@@ -588,7 +588,7 @@
- PKG_CONFIG_LIBDIR
- PKG_CONFIG_PATH
- PKG_CONFIG
--HAVE_MKOCTFILE
-+MKOCTFILE
- OBJEXT
- EXEEXT
- ac_ct_CXX
-@@ -2280,11 +2280,11 @@
- set dummy mkoctfile; ac_word=$2
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
- $as_echo_n "checking for $ac_word... " >&6; }
--if ${ac_cv_prog_HAVE_MKOCTFILE+:} false; then :
-+if ${ac_cv_prog_MKOCTFILE+:} false; then :
-   $as_echo_n "(cached) " >&6
- else
--  if test -n "$HAVE_MKOCTFILE"; then
--  ac_cv_prog_HAVE_MKOCTFILE="$HAVE_MKOCTFILE" # Let the user override the test.
-+  if test -n "$MKOCTFILE"; then
-+  ac_cv_prog_MKOCTFILE="$MKOCTFILE" # Let the user override the test.
- else
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
- for as_dir in $PATH
-@@ -2293,7 +2293,7 @@
-   test -z "$as_dir" && as_dir=.
-     for ac_exec_ext in '' $ac_executable_extensions; do
-   if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
--    ac_cv_prog_HAVE_MKOCTFILE="yes"
-+    ac_cv_prog_MKOCTFILE="yes"
-     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-     break 2
-   fi
-@@ -2301,20 +2301,20 @@
-   done
- IFS=$as_save_IFS
- 
--  test -z "$ac_cv_prog_HAVE_MKOCTFILE" && ac_cv_prog_HAVE_MKOCTFILE="no"
-+  test -z "$ac_cv_prog_MKOCTFILE" && ac_cv_prog_MKOCTFILE="no"
- fi
- fi
--HAVE_MKOCTFILE=$ac_cv_prog_HAVE_MKOCTFILE
--if test -n "$HAVE_MKOCTFILE"; then
--  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $HAVE_MKOCTFILE" >&5
--$as_echo "$HAVE_MKOCTFILE" >&6; }
-+MKOCTFILE=$ac_cv_prog_MKOCTFILE
-+if test -n "$MKOCTFILE"; then
-+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKOCTFILE" >&5
-+$as_echo "$MKOCTFILE" >&6; }
- else
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
- $as_echo "no" >&6; }
- fi
- 
- 
--if test $HAVE_MKOCTFILE = "no"; then
-+if test "$MKOCTFILE" = "no"; then
-   as_fn_error $? "mkoctfile required to install $PACKAGE_NAME" "$LINENO" 5
- fi
- 
-diff -ur video-2.0.0.orig/src/configure.ac video-2.0.0/src/configure.ac
---- video-2.0.0.orig/src/configure.ac	2020-03-04 11:23:26.508419633 -0500
-+++ video-2.0.0/src/configure.ac	2020-03-04 12:18:54.007562316 -0500
-@@ -12,8 +12,8 @@
- # Define macros needed for libav
- #AC_DEFINE(__STDC_CONSTANT_MACROS, [], [workaround for C++ programs to use C99 macros])
- 
--AC_CHECK_PROG([HAVE_MKOCTFILE], [mkoctfile], [yes], [no])
--if [test $HAVE_MKOCTFILE = "no"]; then
-+AC_CHECK_PROG([MKOCTFILE], [mkoctfile], [yes], [no])
-+if [test "$MKOCTFILE" = "no"]; then
-   AC_MSG_ERROR([mkoctfile required to install $PACKAGE_NAME])
- fi
- 
--- a/src/of-video.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/of-video.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := of-video
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 2.0.0
-$(PKG)_CHECKSUM := f3d2ec3dafd3ab0d0b1215ca7fb391ebd8ebd544
+$(PKG)_VERSION  := 2.0.2
+$(PKG)_CHECKSUM := dc76e6ad2bb354d1d716804907a29ea1322d70e7
 $(PKG)_REMOTE_SUBDIR := 
 $(PKG)_SUBDIR   := video-$($(PKG)_VERSION)
 $(PKG)_FILE     := $($(PKG)_SUBDIR).tar.gz
--- a/src/ogg.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/ogg.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := ogg
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 1.3.4
-$(PKG)_CHECKSUM := 851cef020b346d44893e5d1c3dab83c675d479d9
+$(PKG)_VERSION  := 1.3.5
+$(PKG)_CHECKSUM := 56f24c585af430e6714f96d096c60ddf9539ebfd
 $(PKG)_SUBDIR   := libogg-$($(PKG)_VERSION)
 $(PKG)_FILE     := libogg-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://downloads.xiph.org/releases/ogg/$($(PKG)_FILE)
--- a/src/openblas.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/openblas.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := openblas
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 0.3.13
-$(PKG)_CHECKSUM := 685537a821819ef4dae5901998a57f0eec5bddad
+$(PKG)_VERSION  := 0.3.18
+$(PKG)_CHECKSUM := a9d5ce86908657f002c6566cd8f35fe882709be4
 $(PKG)_SUBDIR   := OpenBLAS-$($(PKG)_VERSION)
 $(PKG)_FILE     := $($(PKG)_SUBDIR).tar.gz
 $(PKG)_URL      := https://github.com/xianyi/OpenBLAS/archive/v$($(PKG)_VERSION).tar.gz
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/openjpeg.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,33 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := openjpeg
+$(PKG)_IGNORE   :=
+$(PKG)_VERSION  := 2.4.0
+$(PKG)_CHECKSUM := bbbf4dc4d9ce95286843cd39ac2febd3fd516c9d
+$(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
+$(PKG)_FILE     := $($(PKG)_SUBDIR).tar.gz
+$(PKG)_URL      := https://github.com/uclouvain/$(PKG)/archive/v$($(PKG)_VERSION).tar.gz
+$(PKG)_DEPS     := lcms libpng tiff zlib
+
+$(PKG)_CMAKE_FLAGS :=
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- 'https://github.com/uclouvain/openjpeg/tags' | \
+    $(SED) -n 's|.*releases/tag/v\([0-9][^"]*\).*|\1|p' | $(SORT) -V | \
+    tail -1
+endef
+
+define $(PKG)_BUILD
+    cd '$(1)' && cmake \
+        $($(PKG)_CMAKE_FLAGS) \
+        -DBUILD_PKGCONFIG_FILES=ON \
+        -DBUILD_TESTING=OFF \
+        $(CMAKE_CCACHE_FLAGS) \
+        $(CMAKE_BUILD_SHARED_OR_STATIC) \
+        -DCMAKE_TOOLCHAIN_FILE='$(CMAKE_TOOLCHAIN_FILE)' \
+        .
+
+    $(MAKE) -C '$(1)' -j '$(JOBS)' VERBOSE=1
+    $(MAKE) -C '$(1)' -j '1' VERBOSE=1 DESTDIR='$(3)' install
+endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/opkg-biosig.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,24 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := opkg-biosig
+$(PKG)_IGNORE   :=
+$(PKG)_VERSION  := 2.3.2
+$(PKG)_CHECKSUM := 184c28c0625caafc3c8fb1e820ed7336bb218473
+$(PKG)_SUBDIR   := biosig4octave-$($(PKG)_VERSION)
+$(PKG)_FILE     := $($(PKG)_SUBDIR).src.tar.gz
+$(PKG)_URL      := https://pub.ist.ac.at/~schloegl/biosig/prereleases/$($(PKG)_FILE)
+$(PKG)_DEPS     := libbiosig
+
+ifeq ($(ENABLE_BINARY_PACKAGES),yes)
+  $(PKG)_DEPS += $(OCTAVE_TARGET)
+endif
+
+define $(PKG)_UPDATE
+  echo 'Warning: Updates are temporarily disabled for package $(PKG).' >&2;
+  echo $($(PKG)_VERSION)
+endef
+
+define $(PKG)_BUILD
+  $(OCTAVE_FORGE_PKG_BUILD)
+endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/opus.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,40 @@
+# This file is part of MXE. See LICENSE.md for licensing information.
+
+PKG             := opus
+$(PKG)_IGNORE   :=
+$(PKG)_VERSION  := 1.3.1
+$(PKG)_CHECKSUM := ed226536537861c9f0f1ef7ca79dffc225bc181b
+$(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
+$(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
+$(PKG)_URL      := https://archive.mozilla.org/pub/$(PKG)/$($(PKG)_FILE)
+$(PKG)_DEPS     := 
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- 'https://archive.mozilla.org/pub/opus/?C=M;O=D' | \
+    $(SED) -n 's,.*opus-\([0-9][^>]*\)\.tar.*,\1,p' | \
+    grep -v 'alpha' | \
+    grep -v 'beta' | \
+    grep -v 'rc' | \
+    $(SORT) -Vr | \
+    head -1
+endef
+
+$(PKG)_EXTRA_CONFIGURE_OPTIONS :=
+ifneq ($(filter mingw msvc,$(MXE_SYSTEM)),)
+    $(PKG)_EXTRA_CONFIGURE_OPTIONS += CFLAGS="-O2 -g -fstack-protector"
+endif
+
+define $(PKG)_BUILD
+    cd '$(1)' && ./configure \
+        $(CONFIGURE_CPPFLAGS) $(CONFIGURE_LDFLAGS) \
+        $($(PKG)_EXTRA_CONFIGURE_OPTIONS) \
+        $(HOST_AND_BUILD_CONFIGURE_OPTIONS) \
+        $(ENABLE_SHARED_OR_STATIC) \
+	--prefix='$(HOST_PREFIX)' \
+	&& $(CONFIGURE_POST_HOOK)
+    $(MAKE) -C '$(1)' -j '$(JOBS)' $(MXE_DISABLE_PROGS)
+    $(MAKE) -C '$(1)' -j 1 install $(MXE_DISABLE_PROGS) $(MXE_DISABLE_DOCS) DESTDIR='$(3)'
+    #rm -f '$(PREFIX)/$(TARGET)'/share/man/man3/opus_*.3
+    #rm -f '$(PREFIX)/$(TARGET)'/share/man/man3/opus.h.3
+    #rm -rf '$(PREFIX)/$(TARGET)'/share/doc/opus/html
+endef
--- a/src/pcre.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/pcre.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,18 +3,17 @@
 
 PKG             := pcre
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 8.44
-$(PKG)_CHECKSUM := 8179b083053fce9b4a766513fa1f14807aabee42
+$(PKG)_VERSION  := 8.45
+$(PKG)_CHECKSUM := 8463cc88b737e2c3ce7f041922a6ff0c5abbed34
 $(PKG)_SUBDIR   := pcre-$($(PKG)_VERSION)
 $(PKG)_FILE     := pcre-$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/pcre/pcre/$($(PKG)_VERSION)/$($(PKG)_FILE)
-$(PKG)_URL_2    := ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/$($(PKG)_FILE)
 $(PKG)_DEPS     :=
 
 define $(PKG)_UPDATE
-    $(WGET) -q -O- 'https://ftp.pcre.org/pub/pcre/' | \
-    $(SED) -n 's,.*pcre-\([0-9]\+\)\(\.[0-9]\+\)*\.zip.*,\1\2,p' | \
-    tail -1
+    $(WGET) -q -O- https://sourceforge.net/projects/pcre/files/pcre/ | \
+    $(SED) -n 's,.*tr title="\([0-9][^"]*\)".*,\1,p' | \
+    head -1
 endef
 
 define $(PKG)_BUILD
--- a/src/pcre2.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/pcre2.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,17 +3,17 @@
 
 PKG             := pcre2
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 10.35
-$(PKG)_CHECKSUM := 2e5ee2dd397fa8c3ce9aed1a986e51d66a88bdb0
+$(PKG)_VERSION  := 10.39
+$(PKG)_CHECKSUM := 9cf3ec88cd68dc76354eb0568738c47b57377042
 $(PKG)_SUBDIR   := pcre2-$($(PKG)_VERSION)
 $(PKG)_FILE     := pcre2-$($(PKG)_VERSION).tar.bz2
-$(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/pcre/pcre2/$($(PKG)_VERSION)/$($(PKG)_FILE)
+$(PKG)_URL      := https://github.com/PhilipHazel/$(PKG)/releases/download/$(PKG)-$($(PKG)_VERSION)/$($(PKG)_FILE)
 $(PKG)_DEPS     := zlib
 
 define $(PKG)_UPDATE
-    $(WGET) -q -O- 'http://sourceforge.net/projects/pcre/files/pcre2/' | \
-    $(SED) -n 's,.*tr title="\([0-9][^"]*\)".*,\1,p' | \
-    head -1
+    $(WGET) -q -O- 'https://github.com/PhilipHazel/pcre2/tags' | \
+    $(SED) -n 's|.*releases/tag/pcre2-\([^"]*\).*|\1|p' | $(SORT) -V | \
+    tail -1
 endef
 
 define $(PKG)_BUILD
--- a/src/portaudio-1-win32.patch	Wed Nov 24 18:31:48 2021 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-diff -ur portaudio.orig/src/hostapi/dsound/pa_win_ds.c portaudio/src/hostapi/dsound/pa_win_ds.c
---- portaudio.orig/src/hostapi/dsound/pa_win_ds.c	2016-12-30 08:41:50.075512531 -0500
-+++ portaudio/src/hostapi/dsound/pa_win_ds.c	2016-12-30 08:46:26.248068904 -0500
-@@ -904,6 +904,9 @@
-                             case DSSPEAKER_STEREO:           count = 2; break;
-                             case DSSPEAKER_SURROUND:         count = 4; break;
-                             case DSSPEAKER_5POINT1:          count = 6; break;
-+#ifndef DSSPEAKER_7POINT1
-+#define DSSPEAKER_7POINT1 0x00000007
-+#endif
-                             case DSSPEAKER_7POINT1:          count = 8; break;
- #ifndef DSSPEAKER_7POINT1_SURROUND
- #define DSSPEAKER_7POINT1_SURROUND 0x00000008
-@@ -2136,7 +2139,8 @@
-         }
-         else
-         {
--            CalculateBufferSettings( &stream->hostBufferSizeFrames, &pollingPeriodFrames,
-+            CalculateBufferSettings( (unsigned long *)&stream->hostBufferSizeFrames, 
-+	            &pollingPeriodFrames,
-                     /* isFullDuplex = */ (inputParameters && outputParameters),
-                     suggestedInputLatencyFrames,
-                     suggestedOutputLatencyFrames, 
--- a/src/portaudio.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/portaudio.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,11 +3,11 @@
 
 PKG             := portaudio
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 190600_20161030
-$(PKG)_CHECKSUM := 56c596bba820d90df7d057d8f6a0ec6bf9ab82e8
-$(PKG)_SUBDIR   := portaudio
-$(PKG)_FILE     := pa_stable_v$($(PKG)_VERSION).tgz
-$(PKG)_URL      := http://www.portaudio.com/archives/$($(PKG)_FILE)
+$(PKG)_VERSION  := 19.7.0
+$(PKG)_CHECKSUM := 90676f9b7856bf100b396d8f14cc95bbfb91fa40
+$(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
+$(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
+$(PKG)_URL      := https://github.com/PortAudio/$(PKG)/archive/v$($(PKG)_VERSION).tar.gz
 $(PKG)_DEPS     := 
 
 $(PKG)_SYSDEP_OPTIONS :=
@@ -19,8 +19,8 @@
 endif
 
 define $(PKG)_UPDATE
-    $(WGET) -q -O- 'http://www.portaudio.com/download.html' | \
-    $(SED) -n 's,.*pa_stable_v\([0-9][^>]*\)\.tgz.*,\1,p' | \
+    $(WGET) -q -O- 'https://github.com/PortAudio/portaudio/tags' | \
+    $(SED) -n 's|.*releases/tag/v\([^"]*\).*|\1|p' | \
     head -1
 endef
 
--- a/src/proj.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/proj.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := proj
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 7.1.1
-$(PKG)_CHECKSUM := 3e713e3f7bbd0e0211dda500bfc5b05364c45485
+$(PKG)_VERSION  := 8.1.1
+$(PKG)_CHECKSUM := 69f11aad0b434cf7171a96889ad699817a5b8407
 $(PKG)_SUBDIR   := proj-$($(PKG)_VERSION)
 $(PKG)_FILE     := proj-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://download.osgeo.org/proj/$($(PKG)_FILE)
--- a/src/pstoedit-1-fixes.patch	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/pstoedit-1-fixes.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -1,6 +1,6 @@
-diff -ur pstoedit-3.75.orig/othersrc/gsdllinc/wgsver.c pstoedit-3.75/othersrc/gsdllinc/wgsver.c
---- pstoedit-3.75.orig/othersrc/gsdllinc/wgsver.c	2020-01-06 12:45:59.927286515 -0500
-+++ pstoedit-3.75/othersrc/gsdllinc/wgsver.c	2020-01-06 12:46:54.580699984 -0500
+diff -ur pstoedit-3.77.orig/othersrc/gsdllinc/wgsver.c pstoedit-3.77/othersrc/gsdllinc/wgsver.c
+--- pstoedit-3.77.orig/othersrc/gsdllinc/wgsver.c	2021-09-08 15:38:09.812856463 -0400
++++ pstoedit-3.77/othersrc/gsdllinc/wgsver.c	2021-09-08 15:39:08.695322622 -0400
 @@ -40,6 +40,9 @@
  #include "wgsver.h"
  #include "cppcomp.h"
@@ -11,9 +11,9 @@
  /* Ghostscript may be known in the Windows Registry by
   * the following names.
   */
-diff -ur pstoedit-3.75.orig/src/cbstream.cpp pstoedit-3.75/src/cbstream.cpp
---- pstoedit-3.75.orig/src/cbstream.cpp	2020-01-06 12:45:59.927286515 -0500
-+++ pstoedit-3.75/src/cbstream.cpp	2020-01-06 12:49:33.424788938 -0500
+diff -ur pstoedit-3.77.orig/src/cbstream.cpp pstoedit-3.77/src/cbstream.cpp
+--- pstoedit-3.77.orig/src/cbstream.cpp	2021-09-08 15:38:09.813856522 -0400
++++ pstoedit-3.77/src/cbstream.cpp	2021-09-08 15:39:08.696322681 -0400
 @@ -33,6 +33,8 @@
  // this code is only needed under WIN32
  // ...and under OS/2
@@ -23,10 +23,22 @@
  #include "cppcomp.h"
  
  #include "cbstream.h"
-diff -ur pstoedit-3.75.orig/src/Makefile.am pstoedit-3.75/src/Makefile.am
---- pstoedit-3.75.orig/src/Makefile.am	2020-01-06 12:45:59.931286619 -0500
-+++ pstoedit-3.75/src/Makefile.am	2020-01-06 12:52:56.149975594 -0500
-@@ -143,7 +143,8 @@
+diff -ur pstoedit-3.77.orig/src/dynload.cpp pstoedit-3.77/src/dynload.cpp
+--- pstoedit-3.77.orig/src/dynload.cpp	2021-09-08 15:38:09.817856757 -0400
++++ pstoedit-3.77/src/dynload.cpp	2021-09-08 15:42:20.225597212 -0400
+@@ -241,7 +241,7 @@
+ #ifdef _WIN64
+ 	DynLoader::fptr rfptr = /* ptr_to_fptr */(GetProcAddress((HINSTANCE) handle, name));	//lint !e611 //: Suspicious cast
+ #else
+-	DynLoader::fptr rfptr = ptr_to_fptr(GetProcAddress((HINSTANCE)handle, name));
++	DynLoader::fptr rfptr = ptr_to_fptr((void*)GetProcAddress((HINSTANCE)handle, name));
+ #endif
+ 
+ #else
+diff -ur pstoedit-3.77.orig/src/Makefile.am pstoedit-3.77/src/Makefile.am
+--- pstoedit-3.77.orig/src/Makefile.am	2021-09-08 15:38:09.817856757 -0400
++++ pstoedit-3.77/src/Makefile.am	2021-09-08 15:39:08.696322681 -0400
+@@ -144,7 +144,8 @@
  	psfront.h				\
  	genericints.h
  
@@ -36,18 +48,12 @@
  libpstoedit_la_LDFLAGS = -no-undefined
  
  pstoedit_SOURCES = cmdmain.cpp
-diff -ur pstoedit-3.75.orig/src/dynload.cpp pstoedit-3.75/src/dynload.cpp
---- pstoedit-3.75.orig/src/dynload.cpp	2020-01-09 13:50:03.610222335 -0500
-+++ pstoedit-3.75/src/dynload.cpp	2020-01-09 13:51:10.084019302 -0500
-@@ -239,8 +239,10 @@
- 	DynLoader::fptr rfptr = ptr_to_fptr(dlsym(handle, name));	//lint !e611 //: Suspicious cast
- #elif defined(OS_WIN32_WCE)
- 	DynLoader::fptr rfptr = ptr_to_fptr(GetProcAddress((HINSTANCE) handle, LPSTRtoLPWSTR(name).c_str()));	//lint !e611 //: Suspicious cast
--#elif defined(_WIN32)
-+#elif defined(_WIN64)
- 	DynLoader::fptr rfptr = /* ptr_to_fptr */(GetProcAddress((HINSTANCE) handle, name));	//lint !e611 //: Suspicious cast
-+#elif defined(_WIN32)
-+	DynLoader::fptr rfptr = ptr_to_fptr((void*)GetProcAddress((HINSTANCE) handle, name));	//lint !e611 //: Suspicious cast
- #else
- #error "system unsupported so far"
- #endif
+@@ -171,7 +172,7 @@
+ pstoedit.cpp : pstoedit.ph
+ 
+ pstoedit.ph : pstoedit.pro
+-	awk -f ps_pro_to_ph.awk < pstoedit.pro > pstoedit.ph
++	awk -f $(srcdir)/ps_pro_to_ph.awk < $(srcdir)/pstoedit.pro > pstoedit.ph
+ 
+ cppcheck:
+ 	cppcheck --inconclusive --enable=all `sh ./get_D_and_I_options.sh ${AM_CPPFLAGS}` ${SOURCES}
--- a/src/pstoedit-5-use_gs_env.patch	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/pstoedit-5-use_gs_env.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -1,12 +1,11 @@
-diff -ur pstoedit-3.70.orig/src/callgs.cpp pstoedit-3.70/src/callgs.cpp
---- pstoedit-3.70.orig/src/callgs.cpp	2016-07-27 13:04:53.173499210 -0400
-+++ pstoedit-3.70/src/callgs.cpp	2016-07-27 13:56:54.686649091 -0400
-@@ -364,7 +364,15 @@
+diff -ur pstoedit-3.77.orig/src/callgs.cpp pstoedit-3.77/src/callgs.cpp
+--- pstoedit-3.77.orig/src/callgs.cpp	2021-09-06 16:18:29.786833687 -0400
++++ pstoedit-3.77/src/callgs.cpp	2021-09-06 16:23:10.927193819 -0400
+@@ -368,7 +368,14 @@
  		} else {
  		    if (verbose) errstream<< "nothing found in gsview32.ini file - using find_gs to lookup latest version of Ghostscript in registry " << endl;
  			static char buf[1000];
--			if (find_gs(buf, sizeof(buf), 550 /* min ver*/ , getPstoeditsetDLLUsage() , gsregbase)) { 
-+
+-			if (find_gs(buf, sizeof(buf), 550 /* min ver*/ , getPstoeditsetDLLUsage() , gsregbase, verbose)) { 
 +
 +	                gstocall = getenv("GS");
 +
@@ -14,7 +13,7 @@
 +		                if (verbose)
 +			                errstream << "GS is set to:" << gstocall << endl;
 +
-+                        } else if (find_gs(buf, sizeof(buf), 550 /* min ver*/ , getPstoeditsetDLLUsage() , gsregbase)) { 
++                        } else if (find_gs(buf, sizeof(buf), 550 /* min ver*/ , getPstoeditsetDLLUsage() , gsregbase, verbose)) { 
  				if (verbose) {
- 					(void)dumpgsvers(gsregbase);
+ 					(void)dumpgsvers(gsregbase, verbose);
  					if (getPstoeditsetDLLUsage()) errstream << "Latest GS DLL is " << buf << endl;
--- a/src/pstoedit.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/pstoedit.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := pstoedit
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 3.75
-$(PKG)_CHECKSUM := b0fa3356efdca67bbc0c7c9145827c31384a6cc6
+$(PKG)_VERSION  := 3.77
+$(PKG)_CHECKSUM := 480a6004a47d06f8a506ccc542b2954329e2be97
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := https://sourceforge.net/projects/pstoedit/files/$(PKG)/$($(PKG)_VERSION)/$($(PKG)_FILE)/download
--- a/src/python-mpmath.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/python-mpmath.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -2,11 +2,11 @@
 # See index.html for further information.
 
 PKG             := python-mpmath
-$(PKG)_VERSION  := 1.1.0
-$(PKG)_CHECKSUM := 3f479408ea65b08bc23eeebe5dac2f2293dfec9d
+$(PKG)_VERSION  := 1.2.1
+$(PKG)_CHECKSUM := ce8bd24606eeb02218b26304e6d99228919021f8
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := mpmath-$($(PKG)_VERSION).tar.gz
-$(PKG)_URL      := https://files.pythonhosted.org/packages/ca/63/3384ebb3b51af9610086b23ea976e6d27d6d97bf140a76a365bd77a3eb32/$($(PKG)_FILE)
+$(PKG)_URL      := https://files.pythonhosted.org/packages/95/ba/7384cb4db4ed474d4582944053549e02ec25da630810e4a23454bc9fa617/$($(PKG)_FILE)
 $(PKG)_DEPS     :=
 
 ifeq ($(MXE_WINDOWS_BUILD),yes)
--- a/src/python-sympy.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/python-sympy.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -2,9 +2,9 @@
 # See index.html for further information.
 
 PKG             := python-sympy
-$(PKG)_VERSION  := 1.4
-$(PKG)_CHECKSUM := 9485daf9e29f4ffa20e04111bea940a917eb3a69
-$(PKG)_SUBDIR   := 
+$(PKG)_VERSION  := 1.5
+$(PKG)_CHECKSUM := be2e740860f7900f0ee2a8102d2943fded44125c
+$(PKG)_SUBDIR   :=
 $(PKG)_FILE     := sympy-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := https://github.com/sympy/sympy/releases/download/sympy-$($(PKG)_VERSION)/$($(PKG)_FILE)
 
--- a/src/qhull.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/qhull.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := qhull
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 2020.1
-$(PKG)_CHECKSUM := a938aa73a8964f81786a05fc4c98044878e09f07
+$(PKG)_VERSION  := 2020.2
+$(PKG)_CHECKSUM := 739346b5d6b3fe3675243b156c7ffe55f60cc3c9
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := qhull-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := https://github.com/qhull/$(PKG)/archive/$($(PKG)_VERSION).tar.gz
@@ -23,6 +23,9 @@
     tail -1
 endef
 
+# FIXME: Building and installing the deprecated target "libqhull" can be
+#        removed when Octave switches to using "libqhull_r" (see bug #60016).
+
 define $(PKG)_BUILD
     mkdir '$(1)/../.build'
     cd '$(1)/../.build' && cmake \
@@ -33,5 +36,12 @@
         -DDOC_INSTALL_DIR='$(1)' \
         ../$($(PKG)_SUBDIR)
     make -C $(1)/../.build -j $(JOBS) 
+    make -C $(1)/../.build libqhull -j $(JOBS) 
     make -C $(1)/../.build -j 1 install DESTDIR=$(3)
+    if [ x$(MXE_WINDOWS_BUILD) == xyes ]; then \
+      $(INSTALL) '$(1)/../.build/libqhull.dll.a' '$(3)$(HOST_LIBDIR)/'; \
+      $(INSTALL) '$(1)/../.build/libqhull.dll' '$(3)$(HOST_BINDIR)/'; \
+    else \
+      $(INSTALL) $(1)/../.build/libqhull.so* '$(3)$(HOST_LIBDIR)/'; \
+    fi
 endef
--- a/src/qscintilla-1-fixes.patch	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/qscintilla-1-fixes.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -1,8 +1,8 @@
-diff -ur QScintilla_gpl-2.11.1.orig/Qt4Qt5/qscintilla.pro QScintilla_gpl-2.11.1/Qt4Qt5/qscintilla.pro
---- QScintilla_gpl-2.11.1.orig/Qt4Qt5/qscintilla.pro	2019-02-26 13:51:51.426342211 -0500
-+++ QScintilla_gpl-2.11.1/Qt4Qt5/qscintilla.pro	2019-02-26 13:52:39.639554334 -0500
-@@ -23,7 +23,7 @@
- !win32:VERSION = 15.0.0
+diff -ur QScintilla_src-2.13.0.orig/src/qscintilla.pro QScintilla_src-2.13.0/src/qscintilla.pro
+--- QScintilla_src-2.13.0.orig/src/qscintilla.pro	2021-10-16 14:29:45.588604124 -0400
++++ QScintilla_src-2.13.0/src/qscintilla.pro	2021-10-16 14:30:15.765967678 -0400
+@@ -21,7 +21,7 @@
+ !win32:VERSION = 15.1.0
  
  TEMPLATE = lib
 -CONFIG += qt warn_off thread exceptions hide_symbols
@@ -10,4 +10,3 @@
  
  CONFIG(debug, debug|release) {
      mac: {
-Only in QScintilla_gpl-2.11.1/Qt4Qt5: qscintilla.pro.orig
--- a/src/qscintilla.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/qscintilla.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,10 +3,10 @@
 
 PKG             := qscintilla
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 2.11.5
-$(PKG)_CHECKSUM := 1719d557f21375e04c11bd4ecf09a4d2ef87d2d0
-$(PKG)_SUBDIR   := QScintilla-$($(PKG)_VERSION)
-$(PKG)_FILE     := QScintilla-$($(PKG)_VERSION).tar.gz
+$(PKG)_VERSION  := 2.13.1
+$(PKG)_CHECKSUM := 082cbaa8419ff1911cd9d7fec79ce21ca621eeb6
+$(PKG)_SUBDIR   := QScintilla_src-$($(PKG)_VERSION)
+$(PKG)_FILE     := QScintilla_src-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := https://www.riverbankcomputing.com/static/Downloads/QScintilla/$($(PKG)_VERSION)/$($(PKG)_FILE)
 
 
@@ -24,7 +24,7 @@
 
 define $(PKG)_UPDATE
     $(WGET) -q -O- 'http://www.riverbankcomputing.com/software/qscintilla/download' | \
-        $(SED) -n 's,.*QScintilla-\([0-9][^>]*\)\.zip.*,\1,p' | \
+        $(SED) -n 's,.*QScintilla_src-\([0-9][^>]*\)\.zip.*,\1,p' | \
         head -n 1 
 endef
 
@@ -43,7 +43,7 @@
 endif
 
 define $(PKG)_BUILD
-    cd '$(1)/Qt4Qt5' && \
+    cd '$(1)/src' && \
       '$(MXE_QMAKE)' -makefile \
         $($(PKG)_QMAKE_SPEC_OPTION) \
         QMAKE_UIC='$(MXE_UIC)' \
@@ -53,13 +53,13 @@
 
     if [ $(MXE_SYSTEM) = msvc ]; then \
         mkdir -p '$(3)' && \
-        cd '$(1)/Qt4Qt5' && \
+        cd '$(1)/src' && \
         env -u MAKE -u MAKEFLAGS nmake && \
         env -u MAKE -u MAKEFLAGS nmake \
             INSTALL_ROOT=`cd $(3) && pwd -W | sed -e 's,^[a-zA-Z]:,,' -e 's,/,\\\\,g'` install; \
     else \
-        $(MAKE) -C '$(1)/Qt4Qt5' -j '$(JOBS)' && \
-        $(MAKE) -C '$(1)/Qt4Qt5' -j 1 install INSTALL_ROOT='$($(PKG)_INSTALL_ROOT)'; \
+        $(MAKE) -C '$(1)/src' -j '$(JOBS)' && \
+        $(MAKE) -C '$(1)/src' -j 1 install INSTALL_ROOT='$($(PKG)_INSTALL_ROOT)'; \
     fi
 
     if [ $(MXE_SYSTEM) = mingw ]; then \
--- a/src/qtbase.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/qtbase.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -56,8 +56,9 @@
   ## there are a number of other places that will need to be adjusted.
   ## --jwe
   $(PKG)_CONFIGURE_PREFIX_OPTION := -prefix '$(HOST_PREFIX)/qt5'
-  $(PKG)_CONFIGURE_OPTS += -no-xcb
+  $(PKG)_CONFIGURE_OPTS += -no-xcb -opengl dynamic
 else
+  $(PKG)_CONFIGURE_OPTS += -opengl desktop
   $(PKG)_CONFIGURE_PREFIX_OPTION := -prefix '$(HOST_PREFIX)'
   $(PKG)_CONFIGURE_INCLUDE_OPTION += -I '$(HOST_INCDIR)/freetype2'
 ifeq ($(USE_SYSTEM_OPENGL),no)
@@ -124,7 +125,6 @@
             -shared \
             $($(PKG)_CONFIGURE_PREFIX_OPTION) \
             -hostprefix '$(BUILD_TOOLS_PREFIX)' \
-            -opengl desktop \
             -no-glib \
             -accessibility \
             -nomake examples \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/readline-0-001-upstream.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,66 @@
+			   READLINE PATCH REPORT
+			   =====================
+
+Readline-Release: 8.1
+Patch-ID: readline81-001
+
+Bug-Reported-by:	Tom Tromey <tom@tromey.com>
+Bug-Reference-ID:	<875z3u9fd0.fsf@tromey.com>
+Bug-Reference-URL:	https://lists.gnu.org/archive/html/bug-readline/2021-01/msg00009.html
+
+Bug-Description:
+
+The code to check readline versions in an inputrc file had the sense of the
+comparisons reversed.
+
+diff -ur a/input.c b/input.c
+--- a/bind.c	2020-10-26 10:03:14.000000000 -0400
++++ b/bind.c	2021-01-18 16:38:48.000000000 -0500
+@@ -1235,5 +1235,5 @@
+   else if (_rl_strnicmp (args, "version", 7) == 0)
+     {
+-      int rlversion, versionarg, op, previ, major, minor;
++      int rlversion, versionarg, op, previ, major, minor, opresult;
+ 
+       _rl_parsing_conditionalized_out = 1;
+@@ -1295,22 +1295,23 @@
+ 	{
+ 	case OP_EQ:
+-	  _rl_parsing_conditionalized_out = rlversion == versionarg;
++	  opresult = rlversion == versionarg;
+ 	  break;
+ 	case OP_NE:
+-	  _rl_parsing_conditionalized_out = rlversion != versionarg;
++	  opresult = rlversion != versionarg;
+ 	  break;
+ 	case OP_GT:
+-	  _rl_parsing_conditionalized_out = rlversion > versionarg;
++	  opresult = rlversion > versionarg;
+ 	  break;
+ 	case OP_GE:
+-	  _rl_parsing_conditionalized_out = rlversion >= versionarg;
++	  opresult = rlversion >= versionarg;
+ 	  break;
+ 	case OP_LT:
+-	  _rl_parsing_conditionalized_out = rlversion < versionarg;
++	  opresult = rlversion < versionarg;
+ 	  break;
+ 	case OP_LE:
+-	  _rl_parsing_conditionalized_out = rlversion <= versionarg;
++	  opresult = rlversion <= versionarg;
+ 	  break;
+ 	}
++       _rl_parsing_conditionalized_out = 1 - opresult;
+     }
+   /* Check to see if the first word in ARGS is the same as the
+
+diff -ur a/patchlevel b/patchlevel
+--- a/patchlevel	2013-11-15 08:11:11.000000000 -0500
++++ b/patchlevel	2014-03-21 08:28:40.000000000 -0400
+***************
+@@ -1,3 +1,3 @@
+ # Do not edit -- exists only for use by patch
+ 
+-0
++1
+
--- a/src/readline-0-001.patch	Wed Nov 24 18:31:48 2021 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-			   READLINE PATCH REPORT
-			   =====================
-
-Readline-Release: 8.0
-Patch-ID: readline80-001
-
-Bug-Reported-by:	chet.ramey@case.edu
-Bug-Reference-ID:
-Bug-Reference-URL:
-
-Bug-Description:
-
-The history file reading code doesn't close the file descriptor open to
-the history file when it encounters a zero-length file.
-
-diff --git "a/histfile.c" "b/histfile.c"
---- a/histfile.c	2018-06-11 09:14:52.000000000 -0400
-+++ b/histfile.c	2019-05-16 15:55:57.000000000 -0400
-@@ -306,4 +306,5 @@
-     {
-       free (input);
-+      close (file);
-       return 0;	/* don't waste time if we don't have to */
-     }
-diff --git "a/patchlevel" "b/patchlevel"
---- a/patchlevel	2013-11-15 08:11:11.000000000 -0500
-+++ b/patchlevel	2014-03-21 08:28:40.000000000 -0400
-@@ -1,3 +1,3 @@
- # Do not edit -- exists only for use by patch
- 
--0
-+1
--- a/src/readline-0-002.patch	Wed Nov 24 18:31:48 2021 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-			   READLINE PATCH REPORT
-			   =====================
-
-Readline-Release: 8.0
-Patch-ID: readline80-002
-
-Bug-Reported-by:	lessbug@qq.com
-Bug-Reference-ID:	<tencent_6AA531D9A5CC4121D86BD5CDA2E0DA98C605@qq.com>
-Bug-Reference-URL:
-
-Bug-Description:
-
-When using previous-history to go back beyond the beginning of the history list,
-it's possible to move to an incorrect partial line.
-
-diff --git "a/misc.c" "b/misc.c"
---- a/misc.c	2017-07-07 17:30:12.000000000 -0400
-+++ b/misc.c	2019-05-16 11:43:46.000000000 -0400
-@@ -577,4 +577,5 @@
- {
-   HIST_ENTRY *old_temp, *temp;
-+  int had_saved_line;
- 
-   if (count < 0)
-@@ -589,4 +590,5 @@
- 
-   /* If we don't have a line saved, then save this one. */
-+  had_saved_line = _rl_saved_line_for_history != 0;
-   rl_maybe_save_line ();
- 
-@@ -612,5 +614,6 @@
-   if (temp == 0)
-     {
--      rl_maybe_unsave_line ();
-+      if (had_saved_line == 0)
-+        _rl_free_saved_history_line ();
-       rl_ding ();
-     }
-diff --git "a/patchlevel" "b/patchlevel"
---- a/patchlevel	2013-11-15 08:11:11.000000000 -0500
-+++ b/patchlevel	2014-03-21 08:28:40.000000000 -0400
-@@ -1,3 +1,3 @@
- # Do not edit -- exists only for use by patch
- 
--1
-+2
--- a/src/readline-0-003.patch	Wed Nov 24 18:31:48 2021 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-			   READLINE PATCH REPORT
-			   =====================
-
-Readline-Release: 8.0
-Patch-ID: readline80-003
-
-Bug-Reported-by:	HIROSE Masaaki <hirose31@gmail.com>
-Bug-Reference-ID:	<CAGSOfA-RqiTe=+GsXsDKyZrrMWH4bDbXgMVVegMa6OjqC5xbnQ@mail.gmail.com>
-Bug-Reference-URL:	https://lists.gnu.org/archive/html/bug-bash/2019-05/msg00038.html
-
-Bug-Description:
-
-Reading history entries with timestamps can result in history entries joined
-by linefeeds.
-
-diff --git "a/histfile.c" "b/histfile.c"
---- a/histfile.c	2018-06-11 09:14:52.000000000 -0400
-+++ b/histfile.c	2019-05-16 15:55:57.000000000 -0400
-@@ -370,7 +370,9 @@
- 
-   has_timestamps = HIST_TIMESTAMP_START (buffer);
--  history_multiline_entries += has_timestamps && history_write_timestamps;  
-+  history_multiline_entries += has_timestamps && history_write_timestamps;
- 
-   /* Skip lines until we are at FROM. */
-+  if (has_timestamps)
-+    last_ts = buffer;
-   for (line_start = line_end = buffer; line_end < bufend && current_line < from; line_end++)
-     if (*line_end == '\n')
-@@ -381,5 +383,16 @@
- 	if (HIST_TIMESTAMP_START(p) == 0)
- 	  current_line++;
-+	else
-+	  last_ts = p;
- 	line_start = p;
-+	/* If we are at the last line (current_line == from) but we have
-+	   timestamps (has_timestamps), then line_start points to the
-+	   text of the last command, and we need to skip to its end. */
-+	if (current_line >= from && has_timestamps)
-+	  {
-+	    for (line_end = p; line_end < bufend && *line_end != '\n'; line_end++)
-+	      ;
-+	    line_start = (*line_end == '\n') ? line_end + 1 : line_end;
-+	  }
-       }
- 
-diff --git "a/patchlevel" "b/patchlevel"
---- a/patchlevel	2013-11-15 08:11:11.000000000 -0500
-+++ b/patchlevel	2014-03-21 08:28:40.000000000 -0400
-@@ -1,3 +1,3 @@
- # Do not edit -- exists only for use by patch
- 
--2
-+3
--- a/src/readline-0-004.patch	Wed Nov 24 18:31:48 2021 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,39 +0,0 @@
-			   READLINE PATCH REPORT
-			   =====================
-
-Readline-Release: 8.0
-Patch-ID: readline80-004
-
-Bug-Reported-by:	auroralanes@protonmail.ch
-Bug-Reference-ID:	<WikEDKluAyoha9IDLp83rbN7_Uinr2rrpvSV_z4wmt9qur9piN-FNOn17P0cAizEVah1Fvc9d641vIIWX_7SC6EUTz0CatnOH-C-UK3rPYc=@protonmail.ch>
-Bug-Reference-URL:	https://lists.gnu.org/archive/html/bug-readline/2020-01/msg00008.html
-
-Bug-Description:
-
-If writing the history file fails, and renaming the backup history file fails,
-it's possible for readline's history code to return the wrong error to its
-caller.
-
-diff --git "a/histfile.c" "b/histfile.c"
---- a/histfile.c	2019-11-19 10:31:58.000000000 -0500
-+++ b/histfile.c	2020-02-01 16:28:29.000000000 -0500
-@@ -621,4 +621,5 @@
-   if (rv != 0)
-     {
-+      rv = errno;
-       if (tempname)
- 	unlink (tempname);
-@@ -768,4 +769,5 @@
-   if (rv != 0)
-     {
-+      rv = errno;
-       if (tempname)
- 	unlink (tempname);
-diff --git "a/patchlevel" "b/patchlevel"
---- a/patchlevel	2013-11-15 08:11:11.000000000 -0500
-+++ b/patchlevel	2014-03-21 08:28:40.000000000 -0400
-@@ -1,3 +1,3 @@
- # Do not edit -- exists only for use by patch
- 
--3
-+4
--- a/src/readline-1-display.patch	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/readline-1-display.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -1,6 +1,6 @@
-diff -ur readline-8.0.orig/display.c readline-8.0.disp/display.c
---- readline-8.0.orig/display.c	2019-03-20 07:41:37.573786782 -0400
-+++ readline-8.0.disp/display.c	2019-03-20 17:00:29.866659451 -0400
+diff -ur readline-8.1.orig/display.c readline-8.1/display.c
+--- readline-8.1.orig/display.c	2020-12-19 07:41:44.122860975 -0500
++++ readline-8.1/display.c	2020-12-19 07:52:09.009050414 -0500
 @@ -59,6 +59,11 @@
  #include "rlprivate.h"
  #include "xmalloc.h"
@@ -13,7 +13,7 @@
  #if !defined (strchr) && !defined (__STDC__)
  extern char *strchr (), *strrchr ();
  #endif /* !strchr && !__STDC__ */
-@@ -2367,6 +2372,20 @@
+@@ -2686,6 +2691,20 @@
    int in_invisline;
    int mb_cur_max = MB_CUR_MAX;
  
@@ -34,7 +34,7 @@
    woff = WRAP_OFFSET (_rl_last_v_pos, wrap_offset);
    cpos = _rl_last_c_pos;
  
-@@ -2519,6 +2538,20 @@
+@@ -2832,6 +2851,20 @@
  {
    register int delta, i;
  
@@ -55,7 +55,7 @@
    if (_rl_last_v_pos == to || to > _rl_screenheight)
      return;
  
-@@ -2848,6 +2881,17 @@
+@@ -3157,6 +3190,17 @@
  void
  _rl_clear_to_eol (int count)
  {
@@ -73,9 +73,9 @@
  #ifndef __MSDOS__
    if (_rl_term_clreol)
      tputs (_rl_term_clreol, 1, _rl_output_character_function);
-@@ -2873,6 +2917,33 @@
+@@ -3182,6 +3226,33 @@
  void
- _rl_clear_screen (void)
+ _rl_clear_screen (int clrscr)
  {
 +#if defined (_WIN32)
 +  COORD coordScreen = { 0, 0 };
--- a/src/readline-1-fixes.patch	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/readline-1-fixes.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -1,16 +1,7 @@
-This file is part of MXE. See LICENSE.md for licensing information.
-
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Timothy Gu <timothygu99@gmail.com>
-Date: Tue, 30 Sep 2014 17:16:32 -0700
-Subject: [PATCH 1/1] Handle missing S_IS* macros more gracefully
-
-
-diff --git a/colors.c b/colors.c
-index 1111111..2222222 100644
---- a/colors.c
-+++ b/colors.c
-@@ -200,8 +200,10 @@ _rl_print_color_indicator (const char *f)
+diff -ur readline-8.1/colors.c readline-8.1.1/colors.c
+--- readline-8.1/colors.c	2019-11-19 10:30:54.000000000 -0500
++++ readline-8.1.1/colors.c	2020-12-19 07:54:28.888704198 -0500
+@@ -207,8 +207,10 @@
  #endif
            if (is_colored (C_CAP) && 0) //f->has_capability)
              colored_filetype = C_CAP;
@@ -21,7 +12,7 @@
            else if ((1 < astat.st_nlink) && is_colored (C_MULTIHARDLINK))
              colored_filetype = C_MULTIHARDLINK;
          }
-@@ -215,8 +217,10 @@ _rl_print_color_indicator (const char *f)
+@@ -222,8 +224,10 @@
              colored_filetype = C_STICKY_OTHER_WRITABLE;
            else
  #endif
@@ -32,11 +23,11 @@
  #if defined (S_ISVTX)
            else if ((mode & S_ISVTX) != 0 && is_colored (C_STICKY))
              colored_filetype = C_STICKY;
-diff --git a/colors.h b/colors.h
-index 1111111..2222222 100644
---- a/colors.h
-+++ b/colors.h
-@@ -96,7 +96,7 @@ enum indicator_no
+Only in readline-8.1.1: colors.c.orig
+diff -ur readline-8.1/colors.h readline-8.1.1/colors.h
+--- readline-8.1/colors.h	2016-01-25 10:38:11.000000000 -0500
++++ readline-8.1.1/colors.h	2020-12-19 07:54:28.888704198 -0500
+@@ -96,7 +96,7 @@
    };
  
  
@@ -45,10 +36,9 @@
  # define S_IXUGO (S_IXUSR | S_IXGRP | S_IXOTH)
  #endif
  
-diff --git a/posixstat.h b/posixstat.h
-index 1111111..2222222 100644
---- a/posixstat.h
-+++ b/posixstat.h
+diff -ur readline-8.1/posixstat.h readline-8.1.1/posixstat.h
+--- readline-8.1/posixstat.h	2019-12-19 11:24:37.000000000 -0500
++++ readline-8.1.1/posixstat.h	2020-12-19 07:54:28.888704198 -0500
 @@ -78,30 +78,44 @@
  
  #if defined (S_IFBLK) && !defined (S_ISBLK)
@@ -94,7 +84,7 @@
  #endif
  
  /*
-@@ -137,6 +151,8 @@
+@@ -157,6 +171,8 @@
  /* These are non-standard, but are used in builtins.c$symbolic_umask() */
  #define S_IRUGO		(S_IRUSR | S_IRGRP | S_IROTH)
  #define S_IWUGO		(S_IWUSR | S_IWGRP | S_IWOTH)
@@ -103,4 +93,3 @@
 +#endif
  
  #endif /* _POSIXSTAT_H_ */
-
--- a/src/readline-1-input.patch	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/readline-1-input.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -1,7 +1,7 @@
-diff -ur readline-8.0.disp/input.c readline-8.0/input.c
---- readline-8.0.disp/input.c	2019-03-20 07:56:04.897036396 -0400
-+++ readline-8.0/input.c	2019-03-20 08:00:45.403401856 -0400
-@@ -519,7 +519,12 @@
+diff -ur readline-8.1.1/input.c readline-8.1.2/input.c
+--- readline-8.1.1/input.c	2020-12-19 07:54:06.883500144 -0500
++++ readline-8.1.2/input.c	2020-12-19 07:55:29.042995655 -0500
+@@ -538,7 +538,12 @@
  
  #if defined (__MINGW32__)
        if (isatty (fileno (stream)))
--- a/src/readline-1-sigwinch.patch	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/readline-1-sigwinch.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -1,9 +1,7 @@
-Common subdirectories: readline-8.0.input/doc and readline-8.0/doc
-Common subdirectories: readline-8.0.input/examples and readline-8.0/examples
-diff -u readline-8.0.input/readline.c readline-8.0/readline.c
---- readline-8.0.input/readline.c	2019-03-20 08:02:03.533512025 -0400
-+++ readline-8.0/readline.c	2019-03-20 08:06:59.117185446 -0400
-@@ -1103,8 +1103,12 @@
+diff -ur readline-8.1.2/readline.c readline-8.1.3/readline.c
+--- readline-8.1.2/readline.c	2020-12-19 07:55:06.477760951 -0500
++++ readline-8.1.3/readline.c	2020-12-19 07:56:17.722659252 -0500
+@@ -1154,8 +1154,12 @@
        RL_SETSTATE(RL_STATE_INITIALIZED);
      }
    else
@@ -18,10 +16,10 @@
    /* Initialize the current line information. */
    _rl_init_line_state ();
  
-Common subdirectories: readline-8.0.input/shlib and readline-8.0/shlib
-diff -u readline-8.0.input/signals.c readline-8.0/signals.c
---- readline-8.0.input/signals.c	2019-03-20 08:02:03.529511918 -0400
-+++ readline-8.0/signals.c	2019-03-20 08:13:44.347195350 -0400
+Only in readline-8.1.3: readline.c.orig
+diff -ur readline-8.1.2/signals.c readline-8.1.3/signals.c
+--- readline-8.1.2/signals.c	2020-12-19 07:55:06.471760622 -0500
++++ readline-8.1.3/signals.c	2020-12-19 08:19:50.548964783 -0500
 @@ -46,6 +46,11 @@
  
  #include "rlprivate.h"
@@ -43,7 +41,18 @@
  int rl_catch_sigwinch = 1;
  #else
  int rl_catch_sigwinch = 0;	/* for the readline state struct in readline.c */
-@@ -495,6 +500,21 @@
+@@ -266,8 +271,10 @@
+     case SIGQUIT:
+ #endif
+ 
++#if defined (HAVE_POSIX_SIGNALS)
+       if (block_sig)
+ 	sigprocmask (SIG_BLOCK, &set, &oset);
++#endif
+ 
+       rl_echo_signal_char (sig);
+       rl_cleanup_after_signal ();
+@@ -532,6 +539,21 @@
      }
  #endif /* SIGWINCH */
  
@@ -65,7 +74,7 @@
    return 0;
  }
  
-@@ -545,6 +565,20 @@
+@@ -582,6 +604,20 @@
        sigwinch_set_flag = 0;
      }
  #endif
@@ -86,4 +95,3 @@
  
    return 0;
  }
-Common subdirectories: readline-8.0.input/support and readline-8.0/support
--- a/src/readline-2-event-hook.patch	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/readline-2-event-hook.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -1,7 +1,7 @@
-diff -ur readline-8.0.sigwinch/input.c readline-8.0/input.c
---- readline-8.0.sigwinch/input.c	2019-03-20 08:15:55.450361377 -0400
-+++ readline-8.0/input.c	2019-03-20 08:30:58.059756179 -0400
-@@ -140,6 +140,11 @@
+diff -ur readline-8.1.3/input.c readline-8.1.4/input.c
+--- readline-8.1.3/input.c	2020-12-19 07:56:01.572775578 -0500
++++ readline-8.1.4/input.c	2020-12-19 07:57:24.608319024 -0500
+@@ -142,6 +142,11 @@
  static unsigned char ibuffer[512];
  static int ibuffer_len = sizeof (ibuffer) - 1;
  
@@ -13,7 +13,7 @@
  #define any_typein (push_index != pop_index)
  
  int
-@@ -266,7 +271,7 @@
+@@ -268,7 +273,7 @@
  #if defined (__MINGW32__)
    /* Use getch/_kbhit to check for available console input, in the same way
       that we read it normally. */
@@ -22,7 +22,7 @@
     result = 0;
  #endif
  
-@@ -501,6 +506,120 @@
+@@ -520,6 +525,120 @@
    return (c);
  }
  
@@ -143,7 +143,7 @@
  int
  rl_getc (FILE *stream)
  {
-@@ -520,9 +639,9 @@
+@@ -539,9 +658,9 @@
  #if defined (__MINGW32__)
        if (isatty (fileno (stream)))
          {
--- a/src/readline-2-history.patch	Wed Nov 24 18:31:48 2021 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-diff -ur readline-8.0.eventhook/histfile.c readline-8.0/histfile.c
---- readline-8.0.eventhook/histfile.c	2019-04-03 10:21:42.916563353 -0400
-+++ readline-8.0/histfile.c	2019-04-03 16:16:04.605404093 -0400
-@@ -107,6 +107,11 @@
- #  define PATH_MAX	1024	/* default */
- #endif
- 
-+#if defined(_WIN32)
-+ #define WIN32_LEAN_AND_MEAN
-+ #include <windows.h>
-+#endif
-+
- extern void _hs_append_history_line PARAMS((int, const char *));
- 
- /* history file version; currently unused */
-@@ -139,6 +144,19 @@
- static int histfile_backup PARAMS((const char *, const char *));
- static int histfile_restore PARAMS((const char *, const char *));
- 
-+static int
-+history_rename(const char *from, const char *to)
-+{
-+#if defined(_WIN32)
-+  if (!MoveFileEx(from, to, MOVEFILE_REPLACE_EXISTING)) {
-+    return -1;
-+  }
-+  return 0;
-+#else
-+  return rename(from, to);
-+#endif
-+}
-+
- /* Return the string that should be used in the place of this
-    filename.  This only matters when you don't specify the
-    filename to read_history (), or write_history (). */
-@@ -448,10 +466,10 @@
-   if ((n = readlink (filename, linkbuf, sizeof (linkbuf) - 1)) > 0)
-     {
-       linkbuf[n] = '\0';
--      return (rename (linkbuf, back));
-+      return (history_rename (linkbuf, back));
-     }
- #endif
--  return (rename (filename, back));
-+  return (history_rename (filename, back));
- }
- 
- /* Restore ORIG from BACKUP handling case where ORIG is a symlink
-@@ -467,10 +485,10 @@
-   if ((n = readlink (orig, linkbuf, sizeof (linkbuf) - 1)) > 0)
-     {
-       linkbuf[n] = '\0';
--      return (rename (backup, linkbuf));
-+      return (history_rename (backup, linkbuf));
-     }
- #endif
--  return (rename (backup, orig));
-+  return (history_rename (backup, orig));
- }
- 
- /* Truncate the history file FNAME, leaving only LINES trailing lines.
--- a/src/readline.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/readline.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := readline
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 8.0
-$(PKG)_CHECKSUM := d58041c2143595dc001d2777ae9a200be30198b0
+$(PKG)_VERSION  := 8.1
+$(PKG)_CHECKSUM := 48c5e0c3a212449e206e21ba82856accac842c6f
 $(PKG)_SUBDIR   := readline-$($(PKG)_VERSION)
 $(PKG)_FILE     := readline-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://ftp.gnu.org/gnu/readline/$($(PKG)_FILE)
--- a/src/release-octave.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/release-octave.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -221,6 +221,7 @@
     if [ "x$(MXE_SYSTEM)" == "xmingw" ]; then \
       $(INSTALL) '$(3)/$(HOST_BINDIR)/libxerbla.dll' '$(3)$(HOST_BINDIR)/libxerbla-octave.dll'; \
       cp '$(1)/.build/src/.libs/octave-gui.exe' '$(3)$(HOST_BINDIR)'; \
+      cp '$(1)/.build/src/.libs/octave-svgconvert.exe' '$(3)$(HOST_BINDIR)'; \
       if [ "x$(ENABLE_BINARY_PACKAGES)" == "xyes" ]; then \
         mkdir -p '$(3)$(BUILD_TOOLS_PREFIX)/bin'; \
         $(INSTALL) '$(1)/.build/src/$(MXE_TOOL_PREFIX)mkoctfile' '$(3)$(BUILD_TOOLS_PREFIX)/bin'; \
--- a/src/rtmidi.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/rtmidi.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := rtmidi
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 4.0.0
-$(PKG)_CHECKSUM := 227513d9087d95e171ccf42c7b7e2fe9c5040e27
+$(PKG)_VERSION  := 5.0.0
+$(PKG)_CHECKSUM := e208da4f468b44ab64d0e842e703f5a2e312d03e
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $($(PKG)_SUBDIR).tar.gz
 $(PKG)_URL      := https://github.com/thestk/$(PKG)/archive/$($(PKG)_VERSION).tar.gz
--- a/src/sdl.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/sdl.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -10,11 +10,11 @@
 $(PKG)_URL      := http://www.libsdl.org/release/$($(PKG)_FILE)
 $(PKG)_DEPS     := libiconv
 
+# SDL1 is no longer updated, so wont see any new versions
+# TODO: create a SDL2 target if we want to use that
 define $(PKG)_UPDATE
-    $(WGET) -q -O- 'http://hg.libsdl.org/SDL/tags' | \
-    $(SED) -n 's,.*release-\([0-9][^<]*\).*,\1,p' | \
-    $(GREP) "^1" | \
-    head -1
+    echo 'Warning: Updates are temporarily disabled for package $(PKG).' >&2;
+    echo $($(PKG)_VERSION)
 endef
 
 ifeq ($(MXE_NATIVE_BUILD),no)
--- a/src/sdl_image.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/sdl_image.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -12,7 +12,7 @@
 
 define $(PKG)_UPDATE
     $(WGET) -q -O- 'http://hg.libsdl.org/SDL_image/tags' | \
-    $(SED) -n 's,.*release-\([0-9][^<]*\).*,\1,p' | \
+    $(SED) -n 's,.*release-\([0-9][^<"]*\).*,\1,p' | \
     $(GREP) "^1" | \
     head -1
 endef
--- a/src/sdl_mixer.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/sdl_mixer.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -12,7 +12,7 @@
 
 define $(PKG)_UPDATE
     $(WGET) -q -O- 'http://hg.libsdl.org/SDL_mixer/tags' | \
-    $(SED) -n 's,.*release-\([0-9][^<]*\).*,\1,p' | \
+    $(SED) -n 's,.*release-\([0-9][^<"]*\).*,\1,p' | \
     $(GREP) "^1" | \
     head -1
 endef
--- a/src/sdl_net.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/sdl_net.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -12,7 +12,7 @@
 
 define $(PKG)_UPDATE
     $(WGET) -q -O- 'http://hg.libsdl.org/SDL_net/tags' | \
-    $(SED) -n 's,.*release-\([0-9][^<]*\).*,\1,p' | \
+    $(SED) -n 's,.*release-\([0-9][^<"]*\).*,\1,p' | \
     $(GREP) "^1" | \
     head -1
 endef
--- a/src/sdl_sound.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/sdl_sound.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -12,7 +12,7 @@
 
 define $(PKG)_UPDATE
     $(WGET) -q -O- 'http://hg.icculus.org/icculus/SDL_sound/tags' | \
-    $(SED) -n 's,.*release-\([0-9][^<]*\).*,\1,p' | \
+    $(SED) -n 's,.*tag/release-\([0-9][^"]*\).*,\1,p' | \
     head -1
 endef
 
--- a/src/sdl_ttf.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/sdl_ttf.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -12,7 +12,7 @@
 
 define $(PKG)_UPDATE
     $(WGET) -q -O- 'http://hg.libsdl.org/SDL_ttf/tags' | \
-    $(SED) -n 's,.*release-\([0-9][^<]*\).*,\1,p' | \
+    $(SED) -n 's,.*release-\([0-9][^<"]*\).*,\1,p' | \
     head -1
 endef
 
--- a/src/sqlite.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/sqlite.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,11 +3,11 @@
 
 PKG             := sqlite
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 3330000
-$(PKG)_CHECKSUM := d63f3ce52cb295d62d09fc2ad8f2d29c35e1645f
+$(PKG)_VERSION  := 3360000
+$(PKG)_CHECKSUM := a4bcf9e951bfb9745214241ba08476299fc2dc1e
 $(PKG)_SUBDIR   := $(PKG)-autoconf-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-autoconf-$($(PKG)_VERSION).tar.gz
-$(PKG)_URL      := http://www.sqlite.org/2020/$($(PKG)_FILE)
+$(PKG)_URL      := http://www.sqlite.org/2021/$($(PKG)_FILE)
 $(PKG)_DEPS     := readline zlib
 
 ifeq ($(MXE_SYSTEM),mingw)
--- a/src/src-msys2-bash.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-bash.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-bash
 $(PKG)_NAME     := bash
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 4.4.023-2
-$(PKG)_CHECKSUM := 828f34e19213e85da923af12a3d5b98ad3a3dcff
+$(PKG)_VERSION  := 5.1.008-1
+$(PKG)_CHECKSUM := e3b145bb312d8415d7a18b6f3a59eb6a474d6923
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/src-msys2-ca-certificates.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,22 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := src-msys2-ca-certificates
+$(PKG)_NAME     := ca-certificates
+$(PKG)_IGNORE   :=
+$(PKG)_VERSION  := 20210119-1
+$(PKG)_CHECKSUM := cad949a1f34c4a2c71021b331b88bde82ead1482
+$(PKG)_SUBDIR   := 
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
+$(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
+
+$(PKG)_DEPS     := 
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- '$(MSYS2_BASE_URL)/' | \
+    $(SED) -n 's,.*title="$($(PKG)_NAME)-\([0-9][^"]*\)".*,\1,p' | \
+    head -1
+endef
+
+define $(PKG)_BUILD
+endef
--- a/src/src-msys2-dos2unix.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-dos2unix.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-dos2unix
 $(PKG)_NAME     := dos2unix
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 7.4.1-1
-$(PKG)_CHECKSUM := d0b853bfc7670317eaf6782cbe21eb2fba19b303
+$(PKG)_VERSION  := 7.4.2-1
+$(PKG)_CHECKSUM := ed5f40a1c113fc85632a093059e0b669345a394a
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-filesystem.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-filesystem.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-filesystem
 $(PKG)_NAME     := filesystem
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 2020.02-2
-$(PKG)_CHECKSUM := 055d9bdc1b18f1f2028c24500ce526883ed66192
+$(PKG)_VERSION  := 2021.06-1
+$(PKG)_CHECKSUM := f07cc0b21b8ed1e4ab65464ec3c0aa6acffd47ea
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-findutils.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-findutils.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-findutils
 $(PKG)_NAME     := findutils
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 4.7.0-1
-$(PKG)_CHECKSUM := fdf6a21d7d4a160eb8824fa76e110f542a7f76c7
+$(PKG)_VERSION  := 4.8.0-1
+$(PKG)_CHECKSUM := 953779d5d626590686afa71de4bdf74839951b59
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-gcc-libs.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-gcc-libs.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-gcc-libs
 $(PKG)_NAME     := gcc
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 9.3.0-1
-$(PKG)_CHECKSUM := f0090333d3529304e10160f6c06286b3d7f04b8f
+$(PKG)_VERSION  := 10.2.0-1
+$(PKG)_CHECKSUM := a14669fdb1998c5b08ff78a3d447fa3bf3a492fc
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/src-msys2-glib2.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,22 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := src-msys2-glib2
+$(PKG)_NAME     := glib2
+$(PKG)_IGNORE   :=
+$(PKG)_VERSION  := 2.68.1-1
+$(PKG)_CHECKSUM := f3043a67fac49cd12a56b49fb87f760095efa86f
+$(PKG)_SUBDIR   := 
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
+$(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
+
+$(PKG)_DEPS     := 
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- '$(MSYS2_BASE_URL)/' | \
+    $(SED) -n 's,.*title="$($(PKG)_NAME)-\([0-9][^"]*\)".*,\1,p' | \
+    head -1
+endef
+
+define $(PKG)_BUILD
+endef
--- a/src/src-msys2-gmp.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-gmp.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := src-msys2-gmp
 $(PKG)_NAME     := gmp
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 6.2.0-1
-$(PKG)_CHECKSUM := 20de4de5d414ac1636f84ea274c286d352a4276d
-$(PKG)_SUBDIR   := 
+$(PKG)_VERSION  := 6.2.1-1
+$(PKG)_CHECKSUM := 5befe32118a009a7d49c1ed9e2d56e21d60f6e2f
+$(PKG)_SUBDIR   :=
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
 
-$(PKG)_DEPS     := 
+$(PKG)_DEPS     :=
 
 define $(PKG)_UPDATE
     $(WGET) -q -O- '$(MSYS2_BASE_URL)/' | \
--- a/src/src-msys2-gnupg.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-gnupg.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-gnupg
 $(PKG)_NAME     := gnupg
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 2.2.20-1
-$(PKG)_CHECKSUM := 5ac0bfb40c98f45ff14bbff7a9f9d9d68b402f7c
+$(PKG)_VERSION  := 2.2.28-3
+$(PKG)_CHECKSUM := 3dc6c57d1d01bcb2e8e048db6b327bb8dd9dba4c
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-icu.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-icu.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-icu
 $(PKG)_NAME     := icu
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 65.1-1
-$(PKG)_CHECKSUM := b3f8ed15b175f003267f906ddc4a0bad303ff2bb
+$(PKG)_VERSION  := 68.2-1
+$(PKG)_CHECKSUM := f6db549ca8e4b74350321379cd01a1fb8c410053
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-info.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-info.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-info
 $(PKG)_NAME     := texinfo
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 6.7-1
-$(PKG)_CHECKSUM := 88be67273cd44cc49490d85e1847ec4cccddc26e
+$(PKG)_VERSION  := 6.7-3
+$(PKG)_CHECKSUM := f20e8d34521526b58cfda23da6038513c68e0258
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-less.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-less.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-less
 $(PKG)_NAME     := less
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 551-1
-$(PKG)_CHECKSUM := 999d5d0f27e5b68115cc4346f8e57fb1d3572484
+$(PKG)_VERSION  := 581-1
+$(PKG)_CHECKSUM := 3265c0e4f42d9bcc8495a6e678857d9dfc03308b
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-libassuan.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-libassuan.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-libassuan
 $(PKG)_NAME     := libassuan
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 2.5.3-1
-$(PKG)_CHECKSUM := 30580eb283c48ab1452d3775361848a6c21ff2a4
+$(PKG)_VERSION  := 2.5.5-1
+$(PKG)_CHECKSUM := def7ff35430354e22bcdd3a0cd08cdb98b342186
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-libcrypt.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-libcrypt.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-libcrypt
 $(PKG)_NAME     := libcrypt
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 2.1-2
-$(PKG)_CHECKSUM := d8ad56e97e77e1c0e35e5fe7a6650b69861bcc25
+$(PKG)_VERSION  := 2.1-3
+$(PKG)_CHECKSUM := cd9b8cb9a3a6f97b5acd84efd85c1b65ef8f40f7
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-libexpat.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-libexpat.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-libexpat
 $(PKG)_NAME     := expat
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 2.2.9-1
-$(PKG)_CHECKSUM := 42604d838eb06ac6be2f3e53e50d8c59d9b0ad29
+$(PKG)_VERSION  := 2.3.0-1
+$(PKG)_CHECKSUM := e3e72749215f2db69b4558fdb7284da08720965c
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-libgcrypt.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-libgcrypt.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-libgcrypt
 $(PKG)_NAME     := libgcrypt
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 1.8.5-1
-$(PKG)_CHECKSUM := ce681470f42231bf8f621658206ff7720289690d
+$(PKG)_VERSION  := 1.9.2-1
+$(PKG)_CHECKSUM := bd4a4ba87efd902adbc766272c09ba97d50579c7
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-libgnutls.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-libgnutls.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-libgnutls
 $(PKG)_NAME     := gnutls
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 3.6.13-1
-$(PKG)_CHECKSUM := d697ee3fe43df6d3a32213405d4313ad66747fb3
+$(PKG)_VERSION  := 3.7.2-1
+$(PKG)_CHECKSUM := 76cc5c3ac8e8f9e1636b1b6ac8579c64bc0aa0bf
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-libgpg-error.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-libgpg-error.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-libgpg-error
 $(PKG)_NAME     := libgpg-error
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 1.37-1
-$(PKG)_CHECKSUM := b7f4dc174a139f2c1ebcb8b2de9e2c6f7d1678f2
+$(PKG)_VERSION  := 1.42-1
+$(PKG)_CHECKSUM := 581584628071c586109d4c9cf59e23a4cc99e1fe
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-libgpgme.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-libgpgme.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-libgpgme
 $(PKG)_NAME     := gpgme
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 1.13.1-3
-$(PKG)_CHECKSUM := 31ff6481ffa5c1d23c4dc76529cf1ca4e8027a54
+$(PKG)_VERSION  := 1.16.0-1
+$(PKG)_CHECKSUM := 0752ca3bd16567beb6894c24a1876e84c82e14a6
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-libhogweed.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-libhogweed.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-libhogweed
 $(PKG)_NAME     := nettle
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 3.5.1-1
-$(PKG)_CHECKSUM := 1c910c231882e4b1d17da5ff27c27ab7b2d86cf0
+$(PKG)_VERSION  := 3.7.3-1
+$(PKG)_CHECKSUM := 87913feed891b81342e6c4c001e064f314e35261
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-libiconv.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-libiconv.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-libiconv
 $(PKG)_NAME     := libiconv
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 1.16-1
-$(PKG)_CHECKSUM := 7cec3650b665c102df9178f656b1f889ff4e7241
+$(PKG)_VERSION  := 1.16-2
+$(PKG)_CHECKSUM := ca06d6e8e87c726448fa76829415e0f5f6dc4c64
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-libidn2.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-libidn2.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-libidn2
 $(PKG)_NAME     := libidn2
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 2.3.0-1
-$(PKG)_CHECKSUM := e9e242218ff9c0afcbb127b66e052e52e9f0b4dd
+$(PKG)_VERSION  := 2.3.1-2
+$(PKG)_CHECKSUM := 5ed012b731189c6272b3207bacddd0b3198b2332
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-libksba.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-libksba.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-libksba
 $(PKG)_NAME     := libksba
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 1.3.5-1
-$(PKG)_CHECKSUM := e508a3b3f7f084c2b37d8d91bb712239fffd8bc2
+$(PKG)_VERSION  := 1.6.0-1
+$(PKG)_CHECKSUM := 35aff45eed190e57956e7abf47194a69c3c83540
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-libnettle.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-libnettle.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-libnettle
 $(PKG)_NAME     := nettle
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 3.5.1-1
-$(PKG)_CHECKSUM := 1c910c231882e4b1d17da5ff27c27ab7b2d86cf0
+$(PKG)_VERSION  := 3.7.3-1
+$(PKG)_CHECKSUM := 87913feed891b81342e6c4c001e064f314e35261
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-libopenssl.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-libopenssl.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-libopenssl
 $(PKG)_NAME     := openssl
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 1.1.1.g-1
-$(PKG)_CHECKSUM := ecfa421d0c2a9afc6a9e659aad9a2004fc97d7fe
+$(PKG)_VERSION  := 1.1.1.k-1
+$(PKG)_CHECKSUM := 5471494f73c19025778809963cd508c3f6af38d7
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-libp11-kit.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-libp11-kit.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-libp11-kit
 $(PKG)_NAME     := p11-kit
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 0.23.20-2
-$(PKG)_CHECKSUM := 0852244b980cc3f0a6d09af72263a76fe4c243e2
+$(PKG)_VERSION  := 0.23.22-2
+$(PKG)_CHECKSUM := 156ab765aa07164231629a8d1d161d6dbf9e5e00
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-libpcre.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-libpcre.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-libpcre
 $(PKG)_NAME     := pcre
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 8.44-1
-$(PKG)_CHECKSUM := d33654d0c64a567e62b00160f493b3898444baeb
+$(PKG)_VERSION  := 8.45-1
+$(PKG)_CHECKSUM := 7ecb3c6b4b2e57a5d112d4ed5955c4059f45b328
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-libpcre2.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-libpcre2.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-libpcre2
 $(PKG)_NAME     := pcre2
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 10.34-1
-$(PKG)_CHECKSUM := 4983764393b7e56ba3d934050e111823f866063e
+$(PKG)_VERSION  := 10.37-1
+$(PKG)_CHECKSUM := b3c9231489becbcf47ba02ab7c1108e0b636e1e7
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-libpsl.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-libpsl.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-libpsl
 $(PKG)_NAME     := libpsl
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 0.21.0-1
-$(PKG)_CHECKSUM := 96d498e03fa9635ba548ff53474d93e683715164
+$(PKG)_VERSION  := 0.21.1-2
+$(PKG)_CHECKSUM := a7a1626ecf9171b3d90a39140e8405a7813f59c2
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-libreadline.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-libreadline.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-libreadline
 $(PKG)_NAME     := readline
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 8.0.004-1
-$(PKG)_CHECKSUM := cc5bce2c911d1c6d16330694eb3a9c72a7af7c44
+$(PKG)_VERSION  := 8.1.0-1
+$(PKG)_CHECKSUM := 13144f681ae400bb9b06294558a9ca05c8fbf043
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-libsqlite.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-libsqlite.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-libsqlite
 $(PKG)_NAME     := sqlite
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 3.30.0-1
-$(PKG)_CHECKSUM := fb98954867b2a7786aa8d84c41509b7ac080127e
+$(PKG)_VERSION  := 3.36.0-1
+$(PKG)_CHECKSUM := 68940fa61e04f3cac5b616282eb4cfb05e6bd408
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-libtasn1.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-libtasn1.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-libtasn1
 $(PKG)_NAME     := libtasn1
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 4.16.0-1
-$(PKG)_CHECKSUM := 1698268df00ffca54f9c72f6c04d2cbf2e934588
+$(PKG)_VERSION  := 4.17.0-2
+$(PKG)_CHECKSUM := 9a617aeea9dc603d96270220ea179c8ad58ca37a
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-libutil-linux.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-libutil-linux.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-libutil-linux
 $(PKG)_NAME     := util-linux
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 2.35.1-1
-$(PKG)_CHECKSUM := f06d7e490e71339ebf9ebb578d6d36418fe532fa
+$(PKG)_VERSION  := 2.35.2-1
+$(PKG)_CHECKSUM := f5dfbbc2adefea121983fb0a955395ea86b9c4d1
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-libxml2.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-libxml2.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-libxml2
 $(PKG)_NAME     := libxml2
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 2.9.10-4
-$(PKG)_CHECKSUM := 217439c1526077d2b9660b9eecfb7e01266b5fc3
+$(PKG)_VERSION  := 2.9.10-9
+$(PKG)_CHECKSUM := 41e864c7f32763dee80891ece64c670d37e039ff
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/src-msys2-libxslt.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,22 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := src-msys2-libxslt
+$(PKG)_NAME     := libxslt
+$(PKG)_IGNORE   :=
+$(PKG)_VERSION  := 1.1.34-4
+$(PKG)_CHECKSUM := d46c35bede215c76ff0f704790933aef039b6891
+$(PKG)_SUBDIR   := 
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
+$(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
+
+$(PKG)_DEPS     := 
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- '$(MSYS2_BASE_URL)/' | \
+    $(SED) -n 's,.*title="$($(PKG)_NAME)-\([0-9][^"]*\)".*,\1,p' | \
+    head -1
+endef
+
+define $(PKG)_BUILD
+endef
--- a/src/src-msys2-mintty.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-mintty.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,9 +4,9 @@
 PKG             := src-msys2-mintty
 $(PKG)_NAME     := mintty
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 1~3.1.4-1
+$(PKG)_VERSION  := 1~3.5.0-1
 $(PKG)_FILTER   := mintty-1~
-$(PKG)_CHECKSUM := cc1becd7433520479d9c9307aba854316ef3e6cf
+$(PKG)_CHECKSUM := b99e1ece695a09c5c7096f9bc1e053df4b0eb875
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-mpdecimal.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-mpdecimal.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-mpdecimal
 $(PKG)_NAME     := mpdecimal
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 2.4.2-2
-$(PKG)_CHECKSUM := baf2f04d1502ce51bff4d88a6756bf5bc942f5db
+$(PKG)_VERSION  := 2.5.0-1
+$(PKG)_CHECKSUM := 5469641967af008773a08d3532ae3303cc7162ec
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-mpfr.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-mpfr.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,13 +4,13 @@
 PKG             := src-msys2-mpfr
 $(PKG)_NAME     := mpfr
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 4.0.2-1
-$(PKG)_CHECKSUM := 637b68bbddb0c6b004b1cc580ea0dc18322b1a50
-$(PKG)_SUBDIR   := 
+$(PKG)_VERSION  := 4.1.0-1
+$(PKG)_CHECKSUM := 40957fdcc2c1da6c09947e2597af236f0bf7a36f
+$(PKG)_SUBDIR   :=
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
 
-$(PKG)_DEPS     := 
+$(PKG)_DEPS     :=
 
 define $(PKG)_UPDATE
     $(WGET) -q -O- '$(MSYS2_BASE_URL)/' | \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/src-msys2-openssl.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,22 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := src-msys2-openssl
+$(PKG)_NAME     := openssl
+$(PKG)_IGNORE   :=
+$(PKG)_VERSION  := 1.1.1.k-1
+$(PKG)_CHECKSUM := 5471494f73c19025778809963cd508c3f6af38d7
+$(PKG)_SUBDIR   := 
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
+$(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
+
+$(PKG)_DEPS     := 
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- '$(MSYS2_BASE_URL)/' | \
+    $(SED) -n 's,.*title="$($(PKG)_NAME)-\([0-9][^"]*\)".*,\1,p' | \
+    head -1
+endef
+
+define $(PKG)_BUILD
+endef
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/src-msys2-p11-kit.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,22 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := src-msys2-p11-kit
+$(PKG)_NAME     := p11-kit
+$(PKG)_IGNORE   :=
+$(PKG)_VERSION  := 0.23.22-2
+$(PKG)_CHECKSUM := 156ab765aa07164231629a8d1d161d6dbf9e5e00
+$(PKG)_SUBDIR   := 
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
+$(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
+
+$(PKG)_DEPS     := 
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- '$(MSYS2_BASE_URL)/' | \
+    $(SED) -n 's,.*title="$($(PKG)_NAME)-\([0-9][^"]*\)".*,\1,p' | \
+    head -1
+endef
+
+define $(PKG)_BUILD
+endef
--- a/src/src-msys2-pacman-mirrors.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-pacman-mirrors.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-pacman-mirrors
 $(PKG)_NAME     := pacman-mirrors
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 20200329-1
-$(PKG)_CHECKSUM := a8355dfd152888e8d8efe9dfc886d4ef9ebb6cad
+$(PKG)_VERSION  := 20210703-1
+$(PKG)_CHECKSUM := 9a40f5bf7b2ebbc6ac5b6ff53aba3adfa01dd234
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-pacman.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-pacman.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-pacman
 $(PKG)_NAME     := pacman
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 5.2.1-6
-$(PKG)_CHECKSUM := 45db0e8e4345872b188644719a56fb8c550763c8
+$(PKG)_VERSION  := 6.0.0-4
+$(PKG)_CHECKSUM := 4d31244edc695a6c91514a4e30c5120be3560486
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-perl.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-perl.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-perl
 $(PKG)_NAME     := perl
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 5.30.2-1
-$(PKG)_CHECKSUM := 6144c54c7c89cbf71c889f8c78fae536105f5c77
+$(PKG)_VERSION  := 5.32.1-1
+$(PKG)_CHECKSUM := da18194800b255080fe85723a1f31a1d32a05faf
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-python.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-python.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-python
 $(PKG)_NAME     := python
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 3.8.4-1
-$(PKG)_CHECKSUM := 2318102220163c823e9f7f2e8d4a5ee75f094b9b
+$(PKG)_VERSION  := 3.9.5-1
+$(PKG)_CHECKSUM := 1491bb730710db207210148fdb744ddb3ce7719c
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-runtime.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-runtime.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-runtime
 $(PKG)_NAME     := msys2-runtime
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 3.0.7-6
-$(PKG)_CHECKSUM := e30bfc716abc701fe3b5af24b6caaa2e9ba4958e
+$(PKG)_VERSION  := 3.2.0-14
+$(PKG)_CHECKSUM := 7cec9abb7889a332730d363611bafc1a6b20dbf3
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-tar.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-tar.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-tar
 $(PKG)_NAME     := tar
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 1.32-1
-$(PKG)_CHECKSUM := e95131e3bbca2ee42f73a28653ff9dd0c6177397
+$(PKG)_VERSION  := 1.34-1
+$(PKG)_CHECKSUM := 7b38d42e46e61731db29cef0cb6b4688960017b0
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- a/src/src-msys2-wget.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/src-msys2-wget.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -4,8 +4,8 @@
 PKG             := src-msys2-wget
 $(PKG)_NAME     := wget
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 1.20.3-1
-$(PKG)_CHECKSUM := d2cf2253936beaf8b0f378c736141ab4561f119d
+$(PKG)_VERSION  := 1.21.1-2
+$(PKG)_CHECKSUM := 9de5090aa3dbdb426723062c9c6164b5f38c971f
 $(PKG)_SUBDIR   := 
 $(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
 $(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/src-msys2-which.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,22 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+PKG             := src-msys2-which
+$(PKG)_NAME     := which
+$(PKG)_IGNORE   :=
+$(PKG)_VERSION  := 2.21-2
+$(PKG)_CHECKSUM := f18972325d78ab3ca79e3f426ec450de6636c263
+$(PKG)_SUBDIR   := 
+$(PKG)_FILE     := $($(PKG)_NAME)-$($(PKG)_VERSION).src.tar.gz
+$(PKG)_URL      := $(MSYS2_SRC_URL)/$($(PKG)_FILE)
+
+$(PKG)_DEPS     := 
+
+define $(PKG)_UPDATE
+    $(WGET) -q -O- '$(MSYS2_BASE_URL)/' | \
+    $(SED) -n 's,.*title="$($(PKG)_NAME)-\([0-9][^"]*\)".*,\1,p' | \
+    head -1
+endef
+
+define $(PKG)_BUILD
+endef
--- a/src/stable-octave.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/stable-octave.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -117,6 +117,21 @@
   $(PKG)_ENABLE_FORTRAN_INT64_CONFIGURE_OPTIONS := ax_blas_f77_func_ok=yes ax_blas_integer_size=4 octave_cv_sizeof_fortran_integer=4
 endif
 
+ifeq ($(MXE_SYSTEM),mingw)
+  # This is very similar to CONFIGURE_CPPFLAGS and CONFIGURE_LDFLAGS but with
+  # double quoted paths.
+  $(PKG)_CONFIGURE_CPPFLAGS := CPPFLAGS='-I"$(HOST_PREFIX)/include"'
+  ifeq ($(MXE_USE_LIB64_DIRECTORY),yes)
+    $(PKG)_CONFIGURE_LDFLAGS := LDFLAGS='-L"$(HOST_PREFIX)/lib" -L"$(HOST_PREFIX)/lib64"'
+  else
+    $(PKG)_CONFIGURE_LDFLAGS := LDFLAGS='-L"$(HOST_PREFIX)/lib"'
+  endif
+else
+  $(PKG)_CONFIGURE_CPPFLAGS := $(CONFIGURE_CPPFLAGS)
+  $(PKG)_CONFIGURE_LDFLAGS := $(CONFIGURE_LDFLAGS)
+endif
+
+
 ifeq ($(MXE_SYSTEM),msvc)
   $(PKG)_PREFIX := '$(HOST_PREFIX)/local/$($(PKG)_SUBDIR)'
   # - Enable atomic refcount (required for QtHandles)
@@ -131,8 +146,13 @@
     CXXFLAGS='-O2 -wd4244 -wd4003 -wd4005 -wd4068'
 else
   $(PKG)_PREFIX := '$(HOST_PREFIX)'
-  $(PKG)_EXTRA_CONFIGURE_OPTIONS := \
-    LDFLAGS='-Wl,-rpath-link,$(HOST_LIBDIR) -L$(HOST_LIBDIR) -L$($(PKG)_QTDIR)/lib'
+  ifeq ($(MXE_SYSTEM),mingw)
+    $(PKG)_EXTRA_CONFIGURE_OPTIONS := \
+      LDFLAGS='-Wl,-rpath-link,"$(HOST_LIBDIR)" -L"$(HOST_LIBDIR)" -L"$($(PKG)_QTDIR)/lib"'
+  else
+    $(PKG)_EXTRA_CONFIGURE_OPTIONS := \
+      LDFLAGS='-Wl,-rpath-link,$(HOST_LIBDIR) -L$(HOST_LIBDIR) -L$($(PKG)_QTDIR)/lib'
+  endif
 endif
 
 ifeq ($(MXE_SYSTEM),mingw)
@@ -174,7 +194,8 @@
 
     mkdir '$(1)/.build'
     cd '$(1)/.build' && $($(PKG)_CONFIGURE_ENV) '$(1)/configure' \
-        $(CONFIGURE_CPPFLAGS) $(CONFIGURE_LDFLAGS) \
+        $($(PKG)_CONFIGURE_CPPFLAGS) \
+        $($(PKG)_CONFIGURE_LDFLAGS) \
         $(HOST_AND_BUILD_CONFIGURE_OPTIONS) \
         --prefix='$($(PKG)_PREFIX)' \
         --disable-silent-rules \
@@ -200,6 +221,7 @@
     if [ "x$(MXE_SYSTEM)" == "xmingw" ]; then \
       $(INSTALL) '$(3)/$(HOST_BINDIR)/libxerbla.dll' '$(3)$(HOST_BINDIR)/libxerbla-octave.dll'; \
       cp '$(1)/.build/src/.libs/octave-gui.exe' '$(3)$(HOST_BINDIR)'; \
+      cp '$(1)/.build/src/.libs/octave-svgconvert.exe' '$(3)$(HOST_BINDIR)'; \
       if [ "x$(ENABLE_BINARY_PACKAGES)" == "xyes" ]; then \
         mkdir -p '$(3)$(BUILD_TOOLS_PREFIX)/bin'; \
         $(INSTALL) '$(1)/.build/src/$(MXE_TOOL_PREFIX)mkoctfile' '$(3)$(BUILD_TOOLS_PREFIX)/bin'; \
--- a/src/sundials-ida.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/sundials-ida.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,11 +3,11 @@
 
 PKG             := sundials-ida
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 5.3.0
-$(PKG)_CHECKSUM := a33d5a9f19fad4e4a257a8c9ae1c321550885996
+$(PKG)_VERSION  := 5.7.0
+$(PKG)_CHECKSUM := c04ecc9102851955b62e626a43ad5f604e890ab0
 $(PKG)_SUBDIR   := sundials-$($(PKG)_VERSION)
 $(PKG)_FILE     := sundials-$($(PKG)_VERSION).tar.gz
-$(PKG)_URL      := https://computation.llnl.gov/projects/sundials/download/$($(PKG)_FILE)
+$(PKG)_URL      := https://github.com/LLNL/sundials/releases/download/v$($(PKG)_VERSION)/$($(PKG)_FILE)
 $(PKG)_DEPS     := lapack suitesparse
 ifeq ($(USE_SYSTEM_GCC),no)
   $(PKG)_DEPS += libgomp
--- a/src/tiff.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/tiff.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := tiff
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 4.1.0
-$(PKG)_CHECKSUM := 7a882f8d55fd0620cbf89c47994d2d1d3b975452
+$(PKG)_VERSION  := 4.3.0
+$(PKG)_CHECKSUM := c03f6cb05b64ff496b3a5c733a0af6296aead051
 $(PKG)_SUBDIR   := tiff-$($(PKG)_VERSION)
 $(PKG)_FILE     := tiff-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://download.osgeo.org/libtiff/$($(PKG)_FILE)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/tinyxml-1-cmakelists.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,22 @@
+diff -burN tinyxml.orig/CMakeLists.txt tinyxml/CMakeLists.txt
+--- tinyxml.orig/CMakeLists.txt	1970-01-01 01:00:00.000000000 +0100
++++ tinyxml/CMakeLists.txt	2015-06-21 19:03:09.878168410 +0200
+@@ -0,0 +1,18 @@
++cmake_minimum_required(VERSION 2.8)
++
++file(GLOB SRCS "${CMAKE_SOURCE_DIR}/tiny*.cpp" )
++
++include_directories(${CMAKE_SOURCE_DIR})
++add_definitions(-DTIXML_USE_STL)
++
++add_library(tinyxml ${SRCS})
++
++install(TARGETS tinyxml
++  RUNTIME DESTINATION bin
++  LIBRARY DESTINATION lib
++  ARCHIVE DESTINATION lib)
++
++file(GLOB HEADERS "${CMAKE_SOURCE_DIR}/*.h")
++install(FILES ${HEADERS}
++  DESTINATION include)
++
--- a/src/tinyxml.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/tinyxml.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -17,13 +17,23 @@
 endef
 
 define $(PKG)_BUILD
-    cd '$(1)' && $(MXE_CXX) -c -O3 -Wall -Wno-unknown-pragmas -Wno-format -D TIXML_USE_STL '$(1)'/*.cpp
-    cd '$(1)' && $(MXE_AR) cr libtinyxml.a *.o
-    $(MXE_RANLIB) '$(1)/libtinyxml.a'
-    $(INSTALL) -d               '$(HOST_LIBDIR)'
-    $(INSTALL) -m644 '$(1)'/*.a '$(HOST_LIBDIR)'
-    $(INSTALL) -d               '$(HOST_INCDIR)'
-    $(INSTALL) -m644 '$(1)'/*.h '$(HOST_INCDIR)'
+    mkdir '$(1)/.build'
+    cd '$(1)/.build' && cmake '$(1)' \
+      -DCMAKE_INSTALL_PREFIX=$(HOST_PREFIX) \
+      $($(PKG)_CMAKE_FLAGS) \
+      $(CMAKE_CCACHE_FLAGS) \
+      $(CMAKE_BUILD_SHARED_OR_STATIC) \
+      -DCMAKE_TOOLCHAIN_FILE='$(CMAKE_TOOLCHAIN_FILE)'
+
+    $(MAKE) -C '$(1)/.build' install
+
+#    cd '$(1)' && $(MXE_CXX) -c -O3 -Wall -Wno-unknown-pragmas -Wno-format -D TIXML_USE_STL '$(1)'/*.cpp
+#    cd '$(1)' && $(MXE_AR) cr libtinyxml.a *.o
+#    $(MXE_RANLIB) '$(1)/libtinyxml.a'
+#    $(INSTALL) -d               '$(HOST_LIBDIR)'
+#    $(INSTALL) -m644 '$(1)'/*.a '$(HOST_LIBDIR)'
+#    $(INSTALL) -d               '$(HOST_INCDIR)'
+#    $(INSTALL) -m644 '$(1)'/*.h '$(HOST_INCDIR)'
 
     #'$(MXE_CXX)' \
     #    -W -Wall -D TIXML_USE_STL -Werror -ansi -pedantic \
--- a/src/transfig-1-fixes.patch	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/transfig-1-fixes.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -1,47 +1,97 @@
-diff -ur fig2dev-3.2.7a.orig/fig2dev/dev/genbitmaps.c fig2dev-3.2.7a/fig2dev/dev/genbitmaps.c
---- fig2dev-3.2.7a.orig/fig2dev/dev/genbitmaps.c	2018-10-19 15:28:40.513608360 -0400
-+++ fig2dev-3.2.7a/fig2dev/dev/genbitmaps.c	2018-10-19 15:30:51.900907004 -0400
-@@ -232,8 +232,9 @@
- 		if (to)
- 			sprintf(com + n, " >'%s'", to);
+diff -ur fig2dev-3.2.8b.orig/fig2dev/dev/genbitmaps.c fig2dev-3.2.8b/fig2dev/dev/genbitmaps.c
+--- fig2dev-3.2.8b.orig/fig2dev/dev/genbitmaps.c	2021-09-06 12:57:54.175751149 -0400
++++ fig2dev-3.2.8b/fig2dev/dev/genbitmaps.c	2021-09-06 13:10:27.022794005 -0400
+@@ -95,6 +95,13 @@
+ static int	border_margin = 0;
+ static int	smooth = 0;
+ 
++#if defined (__WIN32__) || !defined (__CYGWIN__)
++  #define WEXITSTATUS(w)  (w)
++  #define WIFEXITED(w)	  (true)
++  #define WIFSIGNALED(w)  (false)
++  #define WTERMSIG(w)     (0)
++#endif
++
+ void
+ genbitmaps_option(char opt, char *optarg)
+ {
+@@ -498,7 +505,9 @@
+ 		BITMAP_EXIT_FAILURE;
  	}
--
+ 
 +#if !defined (__WIN32__) || defined (__CYGWIN__)
  	(void) signal(SIGPIPE, bitmaps_broken_pipe);
 +#endif
- 	if ((tfp = popen(com, "w")) == 0) {
- 		fprintf(stderr, "fig2dev: Can't open pipe to ghostscript\n");
+ 	if ((tfp = popen(com, "w")) == NULL) {
+ 		fprintf(stderr, "fig2dev: Cannot open pipe to ghostscript\n");
  		fprintf(stderr, "command was: %s\n", com);
-@@ -275,7 +276,9 @@
- 
- 	status = pclose(tfp);
- 	tfp = 0;	/* Otherwise main() tries to close tfp again */
-+#if ! defined (__WIN32__) || defined (__CYGWIN__)
+@@ -542,8 +551,9 @@
+ 	else
+ 		status = -1;
+ 	tfp = NULL;	/* Otherwise main() tries to close tfp again */
++#if !defined (__WIN32__) || defined (__CYGWIN__)
  	(void) signal(SIGPIPE, SIG_DFL);
+-
 +#endif
+ 	if (status != 0) {
+ 		FILE	*f;
  
- 	if (status != 0) {
- 		fputs("Error in ghostcript or netpbm command\n", stderr);
-diff -ur fig2dev-3.2.7a.orig/fig2dev/dev/genpdf.c fig2dev-3.2.7a/fig2dev/dev/genpdf.c
---- fig2dev-3.2.7a.orig/fig2dev/dev/genpdf.c	2018-10-19 15:28:40.509608259 -0400
-+++ fig2dev-3.2.7a/fig2dev/dev/genpdf.c	2018-10-19 15:31:31.761906076 -0400
-@@ -95,7 +95,9 @@
- 		"-dAutoFilterColorImages=false -dColorImageFilter=/DCTEncode "
- 		"-sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -o '%s' -",
- 		GSEXE, ofile);
+diff -ur fig2dev-3.2.8b.orig/fig2dev/dev/genpdf.c fig2dev-3.2.8b/fig2dev/dev/genpdf.c
+--- fig2dev-3.2.8b.orig/fig2dev/dev/genpdf.c	2021-09-06 12:57:54.174751090 -0400
++++ fig2dev-3.2.8b/fig2dev/dev/genpdf.c	2021-09-06 13:00:15.862053203 -0400
+@@ -111,7 +111,9 @@
+ 		exit(EXIT_FAILURE);
+ 	}
+ 
 +#if !defined (__WIN32__) || defined (__CYGWIN__)
  	(void) signal(SIGPIPE, pdf_broken_pipe);
 +#endif
  	if ((tfp = popen(com, "w")) == 0) {
- 		fprintf(stderr, "fig2dev: Cannot open pipe to ghostscript\n");
- 		fprintf(stderr, "command was: %s\n", com);
-@@ -125,7 +127,9 @@
- 		free(com);
- 		return -1;
+ 		err_msg("fig2dev: Cannot open pipe to ghostscript");
+ 		put_msg("Command was: %s", com);
+@@ -145,7 +147,9 @@
+ 		err_msg("Error in ghostcript command,\n  %s", com);
+ 		status = -1;
+ 	} else {
++#if !defined (__WIN32__) || defined (__CYGWIN__)
+ 		(void)signal(SIGPIPE, SIG_DFL);
++#endif
  	}
-+#if !defined (__WIN32__) || defined (__CYGWIN__)
- 	(void) signal(SIGPIPE, SIG_DFL);
+ 
+ 	if (com != com_buf)
+diff -ur fig2dev-3.2.8b.orig/fig2dev/dev/readeps.c fig2dev-3.2.8b/fig2dev/dev/readeps.c
+--- fig2dev-3.2.8b.orig/fig2dev/dev/readeps.c	2021-09-06 12:57:54.173751032 -0400
++++ fig2dev-3.2.8b/fig2dev/dev/readeps.c	2021-09-06 13:13:39.700059768 -0400
+@@ -35,6 +35,13 @@
+ #include "messages.h"
+ #include "readpics.h"
+ 
++#if defined (__WIN32__) || !defined (__CYGWIN__)
++  #define WEXITSTATUS(w)  (w)
++  #define WIFEXITED(w)	  (true)
++  #define WIFSIGNALED(w)  (false)
++  #define WTERMSIG(w)     (0)
 +#endif
- 	free(com);
++
+ int	read_eps(F_pic *pic, struct xfig_stream *restrict pic_stream,
+ 		int *llx, int *lly);
+ 
+diff -ur fig2dev-3.2.8b.orig/fig2dev/dev/readpics.c fig2dev-3.2.8b/fig2dev/dev/readpics.c
+--- fig2dev-3.2.8b.orig/fig2dev/dev/readpics.c	2021-09-06 12:57:54.173751032 -0400
++++ fig2dev-3.2.8b/fig2dev/dev/readpics.c	2021-09-06 13:11:49.848636802 -0400
+@@ -36,6 +36,15 @@
+ #include "xtmpfile.h"
+ 
  
- 	return 0;
++#if defined (__WIN32__) || !defined (__CYGWIN__)
++  #define WEXITSTATUS(w)  (w)
++  #define WIFEXITED(w)	  (true)
++  #define WIFSIGNALED(w)  (false)
++  #define WTERMSIG(w)     (0)
++#endif
++
++
++
+ void
+ init_stream(struct xfig_stream *restrict xf_stream)
+ {
--- a/src/transfig.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/transfig.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := transfig
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 3.2.7b
-$(PKG)_CHECKSUM := 8097c178b7fff1023112250938cc87837c0f564e
+$(PKG)_VERSION  := 3.2.8b
+$(PKG)_CHECKSUM := 9a85b37a0770d73915584f1e75e58375b093d9bd
 $(PKG)_SUBDIR   := fig2dev-$($(PKG)_VERSION)
 $(PKG)_FILE     := fig2dev-$($(PKG)_VERSION).tar.xz
 $(PKG)_URL      := http://$(SOURCEFORGE_MIRROR)/project/mcj/$($(PKG)_FILE)
--- a/src/units.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/units.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,8 +3,8 @@
 
 PKG             := units
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 2.19
-$(PKG)_CHECKSUM := 8c241b04046cafa4a4503dc3567d8d869b46329c
+$(PKG)_VERSION  := 2.21
+$(PKG)_CHECKSUM := a897e639111c9400737b68ec22e5f70eaf5d7253
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://ftp.gnu.org/gnu/$(PKG)/$($(PKG)_FILE)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/wxwidgets-1-fixes.patch	Tue Nov 30 19:01:07 2021 +0100
@@ -0,0 +1,192 @@
+This file is part of MXE. See LICENSE.md for licensing information.
+
+Contains ad hoc patches for cross building.
+
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: darealshinji <djcj@gmx.de>
+Date: Fri, 26 May 2017 09:33:22 +0200
+Subject: [PATCH 1/2] make it possible to install DLLs into $(libdir)/../bin
+
+
+diff --git a/Makefile.in b/Makefile.in
+index 1111111..2222222 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -15523,7 +15523,7 @@ distclean: clean
+ @COND_MONOLITHIC_1_SHARED_1@install_monodll: $(__monodll___depname)
+ @COND_MONOLITHIC_1_SHARED_1@	$(INSTALL_DIR) $(DESTDIR)$(libdir)
+ @COND_MONOLITHIC_1_SHARED_1@	$(INSTALL_DATA) $(LIBDIRNAME)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) $(DESTDIR)$(libdir)
+-@COND_MONOLITHIC_1_SHARED_1@	$(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf3) $(DESTDIR)$(libdir)
++@COND_MONOLITHIC_1_SHARED_1@	$(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf3) $(DESTDIR)$(libdir)$(DLLDEST)
+ @COND_MONOLITHIC_1_SHARED_1@	(cd $(DESTDIR)$(libdir) ; $(__monodll___so_symlinks_inst_cmd))
+ 
+ @COND_MONOLITHIC_1_SHARED_1@uninstall_monodll: 
+@@ -15558,7 +15558,7 @@ distclean: clean
+ @COND_MONOLITHIC_0_SHARED_1@install_basedll: $(__basedll___depname)
+ @COND_MONOLITHIC_0_SHARED_1@	$(INSTALL_DIR) $(DESTDIR)$(libdir)
+ @COND_MONOLITHIC_0_SHARED_1@	$(INSTALL_DATA) $(LIBDIRNAME)/$(LIBPREFIX)wx_base$(WXBASEPORT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) $(DESTDIR)$(libdir)
+-@COND_MONOLITHIC_0_SHARED_1@	$(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIX)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf3) $(DESTDIR)$(libdir)
++@COND_MONOLITHIC_0_SHARED_1@	$(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIX)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf3) $(DESTDIR)$(libdir)$(DLLDEST)
+ @COND_MONOLITHIC_0_SHARED_1@	(cd $(DESTDIR)$(libdir) ; $(__basedll___so_symlinks_inst_cmd))
+ 
+ @COND_MONOLITHIC_0_SHARED_1@uninstall_basedll: 
+@@ -15595,7 +15595,7 @@ distclean: clean
+ @COND_MONOLITHIC_0_SHARED_1@install_netdll: $(__netdll___depname)
+ @COND_MONOLITHIC_0_SHARED_1@	$(INSTALL_DIR) $(DESTDIR)$(libdir)
+ @COND_MONOLITHIC_0_SHARED_1@	$(INSTALL_DATA) $(LIBDIRNAME)/$(LIBPREFIX)wx_base$(WXBASEPORT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_net-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) $(DESTDIR)$(libdir)
+-@COND_MONOLITHIC_0_SHARED_1@	$(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIX)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_net$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf3) $(DESTDIR)$(libdir)
++@COND_MONOLITHIC_0_SHARED_1@	$(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIX)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_net$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf3) $(DESTDIR)$(libdir)$(DLLDEST)
+ @COND_MONOLITHIC_0_SHARED_1@	(cd $(DESTDIR)$(libdir) ; $(__netdll___so_symlinks_inst_cmd))
+ 
+ @COND_MONOLITHIC_0_SHARED_1@uninstall_netdll: 
+@@ -15632,7 +15632,7 @@ distclean: clean
+ @COND_MONOLITHIC_0_SHARED_1_USE_GUI_1@install_coredll: $(__coredll___depname)
+ @COND_MONOLITHIC_0_SHARED_1_USE_GUI_1@	$(INSTALL_DIR) $(DESTDIR)$(libdir)
+ @COND_MONOLITHIC_0_SHARED_1_USE_GUI_1@	$(INSTALL_DATA) $(LIBDIRNAME)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_core-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) $(DESTDIR)$(libdir)
+-@COND_MONOLITHIC_0_SHARED_1_USE_GUI_1@	$(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_core$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf3) $(DESTDIR)$(libdir)
++@COND_MONOLITHIC_0_SHARED_1_USE_GUI_1@	$(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_core$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf3) $(DESTDIR)$(libdir)$(DLLDEST)
+ @COND_MONOLITHIC_0_SHARED_1_USE_GUI_1@	(cd $(DESTDIR)$(libdir) ; $(__coredll___so_symlinks_inst_cmd))
+ 
+ @COND_MONOLITHIC_0_SHARED_1_USE_GUI_1@uninstall_coredll: 
+@@ -15669,7 +15669,7 @@ distclean: clean
+ @COND_MONOLITHIC_0_SHARED_1_USE_GUI_1@install_advdll: $(__advdll___depname)
+ @COND_MONOLITHIC_0_SHARED_1_USE_GUI_1@	$(INSTALL_DIR) $(DESTDIR)$(libdir)
+ @COND_MONOLITHIC_0_SHARED_1_USE_GUI_1@	$(INSTALL_DATA) $(LIBDIRNAME)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_adv-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) $(DESTDIR)$(libdir)
+-@COND_MONOLITHIC_0_SHARED_1_USE_GUI_1@	$(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_adv$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf3) $(DESTDIR)$(libdir)
++@COND_MONOLITHIC_0_SHARED_1_USE_GUI_1@	$(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_adv$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf3) $(DESTDIR)$(libdir)$(DLLDEST)
+ @COND_MONOLITHIC_0_SHARED_1_USE_GUI_1@	(cd $(DESTDIR)$(libdir) ; $(__advdll___so_symlinks_inst_cmd))
+ 
+ @COND_MONOLITHIC_0_SHARED_1_USE_GUI_1@uninstall_advdll: 
+@@ -15706,7 +15706,7 @@ distclean: clean
+ @COND_MONOLITHIC_0_SHARED_1_USE_GUI_1_USE_MEDIA_1@install_mediadll: $(__mediadll___depname)
+ @COND_MONOLITHIC_0_SHARED_1_USE_GUI_1_USE_MEDIA_1@	$(INSTALL_DIR) $(DESTDIR)$(libdir)
+ @COND_MONOLITHIC_0_SHARED_1_USE_GUI_1_USE_MEDIA_1@	$(INSTALL_DATA) $(LIBDIRNAME)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_media-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) $(DESTDIR)$(libdir)
+-@COND_MONOLITHIC_0_SHARED_1_USE_GUI_1_USE_MEDIA_1@	$(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_media$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf3) $(DESTDIR)$(libdir)
++@COND_MONOLITHIC_0_SHARED_1_USE_GUI_1_USE_MEDIA_1@	$(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_media$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf3) $(DESTDIR)$(libdir)$(DLLDEST)
+ @COND_MONOLITHIC_0_SHARED_1_USE_GUI_1_USE_MEDIA_1@	(cd $(DESTDIR)$(libdir) ; $(__mediadll___so_symlinks_inst_cmd))
+ 
+ @COND_MONOLITHIC_0_SHARED_1_USE_GUI_1_USE_MEDIA_1@uninstall_mediadll: 
+@@ -15743,7 +15743,7 @@ distclean: clean
+ @COND_MONOLITHIC_0_SHARED_1_USE_GUI_1_USE_HTML_1@install_htmldll: $(__htmldll___depname)
+ @COND_MONOLITHIC_0_SHARED_1_USE_GUI_1_USE_HTML_1@	$(INSTALL_DIR) $(DESTDIR)$(libdir)
+ @COND_MONOLITHIC_0_SHARED_1_USE_GUI_1_USE_HTML_1@	$(INSTALL_DATA) $(LIBDIRNAME)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_html-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) $(DESTDIR)$(libdir)
+-@COND_MONOLITHIC_0_SHARED_1_USE_GUI_1_USE_HTML_1@	$(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_html$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf3) $(DESTDIR)$(libdir)
++@COND_MONOLITHIC_0_SHARED_1_USE_GUI_1_USE_HTML_1@	$(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_html$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf3) $(DESTDIR)$(libdir)$(DLLDEST)
+ @COND_MONOLITHIC_0_SHARED_1_USE_GUI_1_USE_HTML_1@	(cd $(DESTDIR)$(libdir) ; $(__htmldll___so_symlinks_inst_cmd))
+ 
+ @COND_MONOLITHIC_0_SHARED_1_USE_GUI_1_USE_HTML_1@uninstall_htmldll: 
+@@ -15780,7 +15780,7 @@ distclean: clean
+ @COND_MONOLITHIC_0_SHARED_1_USE_GUI_1_USE_WEBVIEW_1@install_webviewdll: $(__webviewdll___depname)
+ @COND_MONOLITHIC_0_SHARED_1_USE_GUI_1_USE_WEBVIEW_1@	$(INSTALL_DIR) $(DESTDIR)$(libdir)
+ @COND_MONOLITHIC_0_SHARED_1_USE_GUI_1_USE_WEBVIEW_1@	$(INSTALL_DATA) $(LIBDIRNAME)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_webview-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) $(DESTDIR)$(libdir)
+-@COND_MONOLITHIC_0_SHARED_1_USE_GUI_1_USE_WEBVIEW_1@	$(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_webview$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf3) $(DESTDIR)$(libdir)
++@COND_MONOLITHIC_0_SHARED_1_USE_GUI_1_USE_WEBVIEW_1@	$(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_webview$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf3) $(DESTDIR)$(libdir)$(DLLDEST)
+ @COND_MONOLITHIC_0_SHARED_1_USE_GUI_1_USE_WEBVIEW_1@	(cd $(DESTDIR)$(libdir) ; $(__webviewdll___so_symlinks_inst_cmd))
+ 
+ @COND_MONOLITHIC_0_SHARED_1_USE_GUI_1_USE_WEBVIEW_1@uninstall_webviewdll: 
+@@ -15817,7 +15817,7 @@ distclean: clean
+ @COND_MONOLITHIC_0_SHARED_1_USE_GUI_1_USE_QA_1@install_qadll: $(__qadll___depname)
+ @COND_MONOLITHIC_0_SHARED_1_USE_GUI_1_USE_QA_1@	$(INSTALL_DIR) $(DESTDIR)$(libdir)
+ @COND_MONOLITHIC_0_SHARED_1_USE_GUI_1_USE_QA_1@	$(INSTALL_DATA) $(LIBDIRNAME)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_qa-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) $(DESTDIR)$(libdir)
+-@COND_MONOLITHIC_0_SHARED_1_USE_GUI_1_USE_QA_1@	$(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_qa$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf3) $(DESTDIR)$(libdir)
++@COND_MONOLITHIC_0_SHARED_1_USE_GUI_1_USE_QA_1@	$(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_qa$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf3) $(DESTDIR)$(libdir)$(DLLDEST)
+ @COND_MONOLITHIC_0_SHARED_1_USE_GUI_1_USE_QA_1@	(cd $(DESTDIR)$(libdir) ; $(__qadll___so_symlinks_inst_cmd))
+ 
+ @COND_MONOLITHIC_0_SHARED_1_USE_GUI_1_USE_QA_1@uninstall_qadll: 
+@@ -15854,7 +15854,7 @@ distclean: clean
+ @COND_MONOLITHIC_0_SHARED_1@install_xmldll: $(__xmldll___depname)
+ @COND_MONOLITHIC_0_SHARED_1@	$(INSTALL_DIR) $(DESTDIR)$(libdir)
+ @COND_MONOLITHIC_0_SHARED_1@	$(INSTALL_DATA) $(LIBDIRNAME)/$(LIBPREFIX)wx_base$(WXBASEPORT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_xml-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) $(DESTDIR)$(libdir)
+-@COND_MONOLITHIC_0_SHARED_1@	$(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIX)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_xml$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf3) $(DESTDIR)$(libdir)
++@COND_MONOLITHIC_0_SHARED_1@	$(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIX)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_xml$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf3) $(DESTDIR)$(libdir)$(DLLDEST)
+ @COND_MONOLITHIC_0_SHARED_1@	(cd $(DESTDIR)$(libdir) ; $(__xmldll___so_symlinks_inst_cmd))
+ 
+ @COND_MONOLITHIC_0_SHARED_1@uninstall_xmldll: 
+@@ -15891,7 +15891,7 @@ distclean: clean
+ @COND_MONOLITHIC_0_SHARED_1_USE_XRC_1@install_xrcdll: $(__xrcdll___depname)
+ @COND_MONOLITHIC_0_SHARED_1_USE_XRC_1@	$(INSTALL_DIR) $(DESTDIR)$(libdir)
+ @COND_MONOLITHIC_0_SHARED_1_USE_XRC_1@	$(INSTALL_DATA) $(LIBDIRNAME)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_xrc-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) $(DESTDIR)$(libdir)
+-@COND_MONOLITHIC_0_SHARED_1_USE_XRC_1@	$(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_xrc$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf3) $(DESTDIR)$(libdir)
++@COND_MONOLITHIC_0_SHARED_1_USE_XRC_1@	$(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_xrc$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf3) $(DESTDIR)$(libdir)$(DLLDEST)
+ @COND_MONOLITHIC_0_SHARED_1_USE_XRC_1@	(cd $(DESTDIR)$(libdir) ; $(__xrcdll___so_symlinks_inst_cmd))
+ 
+ @COND_MONOLITHIC_0_SHARED_1_USE_XRC_1@uninstall_xrcdll: 
+@@ -15928,7 +15928,7 @@ distclean: clean
+ @COND_MONOLITHIC_0_SHARED_1_USE_AUI_1@install_auidll: $(__auidll___depname)
+ @COND_MONOLITHIC_0_SHARED_1_USE_AUI_1@	$(INSTALL_DIR) $(DESTDIR)$(libdir)
+ @COND_MONOLITHIC_0_SHARED_1_USE_AUI_1@	$(INSTALL_DATA) $(LIBDIRNAME)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_aui-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) $(DESTDIR)$(libdir)
+-@COND_MONOLITHIC_0_SHARED_1_USE_AUI_1@	$(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_aui$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf3) $(DESTDIR)$(libdir)
++@COND_MONOLITHIC_0_SHARED_1_USE_AUI_1@	$(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_aui$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf3) $(DESTDIR)$(libdir)$(DLLDEST)
+ @COND_MONOLITHIC_0_SHARED_1_USE_AUI_1@	(cd $(DESTDIR)$(libdir) ; $(__auidll___so_symlinks_inst_cmd))
+ 
+ @COND_MONOLITHIC_0_SHARED_1_USE_AUI_1@uninstall_auidll: 
+@@ -15965,7 +15965,7 @@ distclean: clean
+ @COND_MONOLITHIC_0_SHARED_1_USE_RIBBON_1@install_ribbondll: $(__ribbondll___depname)
+ @COND_MONOLITHIC_0_SHARED_1_USE_RIBBON_1@	$(INSTALL_DIR) $(DESTDIR)$(libdir)
+ @COND_MONOLITHIC_0_SHARED_1_USE_RIBBON_1@	$(INSTALL_DATA) $(LIBDIRNAME)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_ribbon-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) $(DESTDIR)$(libdir)
+-@COND_MONOLITHIC_0_SHARED_1_USE_RIBBON_1@	$(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_ribbon$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf3) $(DESTDIR)$(libdir)
++@COND_MONOLITHIC_0_SHARED_1_USE_RIBBON_1@	$(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_ribbon$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf3) $(DESTDIR)$(libdir)$(DLLDEST)
+ @COND_MONOLITHIC_0_SHARED_1_USE_RIBBON_1@	(cd $(DESTDIR)$(libdir) ; $(__ribbondll___so_symlinks_inst_cmd))
+ 
+ @COND_MONOLITHIC_0_SHARED_1_USE_RIBBON_1@uninstall_ribbondll: 
+@@ -16002,7 +16002,7 @@ distclean: clean
+ @COND_MONOLITHIC_0_SHARED_1_USE_PROPGRID_1@install_propgriddll: $(__propgriddll___depname)
+ @COND_MONOLITHIC_0_SHARED_1_USE_PROPGRID_1@	$(INSTALL_DIR) $(DESTDIR)$(libdir)
+ @COND_MONOLITHIC_0_SHARED_1_USE_PROPGRID_1@	$(INSTALL_DATA) $(LIBDIRNAME)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_propgrid-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) $(DESTDIR)$(libdir)
+-@COND_MONOLITHIC_0_SHARED_1_USE_PROPGRID_1@	$(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_propgrid$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf3) $(DESTDIR)$(libdir)
++@COND_MONOLITHIC_0_SHARED_1_USE_PROPGRID_1@	$(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_propgrid$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf3) $(DESTDIR)$(libdir)$(DLLDEST)
+ @COND_MONOLITHIC_0_SHARED_1_USE_PROPGRID_1@	(cd $(DESTDIR)$(libdir) ; $(__propgriddll___so_symlinks_inst_cmd))
+ 
+ @COND_MONOLITHIC_0_SHARED_1_USE_PROPGRID_1@uninstall_propgriddll: 
+@@ -16039,7 +16039,7 @@ distclean: clean
+ @COND_MONOLITHIC_0_SHARED_1_USE_RICHTEXT_1@install_richtextdll: $(__richtextdll___depname)
+ @COND_MONOLITHIC_0_SHARED_1_USE_RICHTEXT_1@	$(INSTALL_DIR) $(DESTDIR)$(libdir)
+ @COND_MONOLITHIC_0_SHARED_1_USE_RICHTEXT_1@	$(INSTALL_DATA) $(LIBDIRNAME)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_richtext-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) $(DESTDIR)$(libdir)
+-@COND_MONOLITHIC_0_SHARED_1_USE_RICHTEXT_1@	$(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_richtext$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf3) $(DESTDIR)$(libdir)
++@COND_MONOLITHIC_0_SHARED_1_USE_RICHTEXT_1@	$(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_richtext$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf3) $(DESTDIR)$(libdir)$(DLLDEST)
+ @COND_MONOLITHIC_0_SHARED_1_USE_RICHTEXT_1@	(cd $(DESTDIR)$(libdir) ; $(__richtextdll___so_symlinks_inst_cmd))
+ 
+ @COND_MONOLITHIC_0_SHARED_1_USE_RICHTEXT_1@uninstall_richtextdll: 
+@@ -16076,7 +16076,7 @@ distclean: clean
+ @COND_MONOLITHIC_0_SHARED_1_USE_STC_1@install_stcdll: $(__stcdll___depname)
+ @COND_MONOLITHIC_0_SHARED_1_USE_STC_1@	$(INSTALL_DIR) $(DESTDIR)$(libdir)
+ @COND_MONOLITHIC_0_SHARED_1_USE_STC_1@	$(INSTALL_DATA) $(LIBDIRNAME)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_stc-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) $(DESTDIR)$(libdir)
+-@COND_MONOLITHIC_0_SHARED_1_USE_STC_1@	$(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_stc$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf3) $(DESTDIR)$(libdir)
++@COND_MONOLITHIC_0_SHARED_1_USE_STC_1@	$(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_stc$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf3) $(DESTDIR)$(libdir)$(DLLDEST)
+ @COND_MONOLITHIC_0_SHARED_1_USE_STC_1@	(cd $(DESTDIR)$(libdir) ; $(__stcdll___so_symlinks_inst_cmd))
+ 
+ @COND_MONOLITHIC_0_SHARED_1_USE_STC_1@uninstall_stcdll: 
+@@ -16113,7 +16113,7 @@ distclean: clean
+ @COND_SHARED_1_USE_GUI_1_USE_OPENGL_1@install_gldll: $(__gldll___depname)
+ @COND_SHARED_1_USE_GUI_1_USE_OPENGL_1@	$(INSTALL_DIR) $(DESTDIR)$(libdir)
+ @COND_SHARED_1_USE_GUI_1_USE_OPENGL_1@	$(INSTALL_DATA) $(LIBDIRNAME)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gl-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) $(DESTDIR)$(libdir)
+-@COND_SHARED_1_USE_GUI_1_USE_OPENGL_1@	$(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gl$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf3) $(DESTDIR)$(libdir)
++@COND_SHARED_1_USE_GUI_1_USE_OPENGL_1@	$(INSTALL_PROGRAM) $(LIBDIRNAME)/$(DLLPREFIX)$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gl$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG)$(dll___targetsuf3) $(DESTDIR)$(libdir)$(DLLDEST)
+ @COND_SHARED_1_USE_GUI_1_USE_OPENGL_1@	(cd $(DESTDIR)$(libdir) ; $(__gldll___so_symlinks_inst_cmd))
+ 
+ @COND_SHARED_1_USE_GUI_1_USE_OPENGL_1@uninstall_gldll: 
+
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Maarten Bent <MaartenBent@users.noreply.github.com>
+Date: Thu, 16 Aug 2018 20:08:56 +0200
+Subject: [PATCH 2/2] Fix c++11-narrowing error when using clang on Windows
+
+Case value 0xfffffd9f results in the following error:
+error: case value evaluates to 4294966687, which cannot be narrowed to type
+'DISPID' (aka 'long') [-Wc++11-narrowing]
+
+diff --git a/src/msw/mediactrl_am.cpp b/src/msw/mediactrl_am.cpp
+index 1111111..2222222 100644
+--- a/src/msw/mediactrl_am.cpp
++++ b/src/msw/mediactrl_am.cpp
+@@ -2179,7 +2179,9 @@ void wxAMMediaBackend::Move(int WXUNUSED(x), int WXUNUSED(y),
+ //---------------------------------------------------------------------------
+ void wxAMMediaEvtHandler::OnActiveX(wxActiveXEvent& event)
+ {
+-    switch(event.GetDispatchId())
++    // cast to unsigned long to fix narrowing error with case 0xfffffd9f
++    // when using clang
++    switch (static_cast<unsigned long>(event.GetDispatchId()))
+     {
+ #ifndef __WXWINCE__
+     case 0x00000001: // statechange in IActiveMovie
--- a/src/xcb-proto.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/xcb-proto.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -8,7 +8,7 @@
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := http://www.x.org/archive/individual/xcb/$($(PKG)_FILE)
-$(PKG)_DEPS     := 
+$(PKG)_DEPS     := build-python
 
 
 define $(PKG)_UPDATE
@@ -24,7 +24,7 @@
 else
   define $(PKG)_BUILD
     mkdir '$(1)/.build'
-    cd '$(1)/.build' && $($(PKG)_CONFIGURE_ENV) '$(1)/configure' \
+    cd '$(1)/.build' && $($(PKG)_CONFIGURE_ENV) PYTHON=$(MXE_PYTHON) '$(1)/configure' \
         $(CONFIGURE_CPPFLAGS) $(CONFIGURE_LDFLAGS) \
         $(HOST_AND_BUILD_CONFIGURE_OPTIONS) \
         --prefix='$(HOST_PREFIX)' \
--- a/src/xcb.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/xcb.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -8,7 +8,7 @@
 $(PKG)_SUBDIR   := libxcb-$($(PKG)_VERSION)
 $(PKG)_FILE     := libxcb-$($(PKG)_VERSION).tar.bz2
 $(PKG)_URL      := http://www.x.org/archive/individual/xcb/$($(PKG)_FILE)
-$(PKG)_DEPS     := pthread-stubs util-macros xau xcb-proto
+$(PKG)_DEPS     := build-python pthread-stubs util-macros xau xcb-proto
 
 define $(PKG)_UPDATE
     $(WGET) -q -O- 'https://www.x.org/archive/individual/xcb/' | \
@@ -23,7 +23,7 @@
 else
   define $(PKG)_BUILD
     mkdir '$(1)/.build'
-    cd '$(1)/.build' && $($(PKG)_CONFIGURE_ENV) '$(1)/configure' \
+    cd '$(1)/.build' && $($(PKG)_CONFIGURE_ENV) PYTHON=$(MXE_PYTHON) '$(1)/configure' \
         $(CONFIGURE_CPPFLAGS) $(CONFIGURE_LDFLAGS) \
         $(HOST_AND_BUILD_CONFIGURE_OPTIONS) \
         --prefix='$(HOST_PREFIX)' \
--- a/src/zeromq.mk	Wed Nov 24 18:31:48 2021 +0100
+++ b/src/zeromq.mk	Tue Nov 30 19:01:07 2021 +0100
@@ -3,12 +3,12 @@
 
 PKG             := zeromq
 $(PKG)_IGNORE   :=
-$(PKG)_VERSION  := 4.3.1
-$(PKG)_CHECKSUM := 6cce22d830eaf95feff7cab00744df13ad7ab7f3
+$(PKG)_VERSION  := 4.3.4
+$(PKG)_CHECKSUM := 47277a64749049123d1401600e8cfbab10a3ae28
 $(PKG)_SUBDIR   := $(PKG)-$($(PKG)_VERSION)
 $(PKG)_FILE     := $(PKG)-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := http://github.com/$(PKG)/libzmq/releases/download/v$($(PKG)_VERSION)/$($(PKG)_FILE)
-$(PKG)_DEPS     := pthreads
+$(PKG)_DEPS     := pthreads libsodium
 
 define $(PKG)_UPDATE
     $(WGET) -q -O- 'https://github.com/zeromq/libzmq/tags' | \
@@ -20,8 +20,11 @@
     cd '$(1)' && ./configure \
         $(HOST_AND_BUILD_CONFIGURE_OPTIONS) \
         --prefix='$(HOST_PREFIX)' \
-        --without-libsodium \
-        $(ENABLE_SHARED_OR_STATIC) 
+        --disable-perf \
+        --with-libsodium \
+        $(ENABLE_SHARED_OR_STATIC) \
+        CXXFLAGS="-std=c++14"
+
     $(MAKE) -C '$(1)' -j '$(JOBS)'
-    $(MAKE) -C '$(1)' -j 1 install
+    $(MAKE) -C '$(1)' -j 1 install $(MXE_DISABLE_PROGS) $(MXE_DISABLE_DOCS) DESTDIR='$(3)'
 endef
--- a/tools/makeinst-script.sh.in	Wed Nov 24 18:31:48 2021 +0100
+++ b/tools/makeinst-script.sh.in	Tue Nov 30 19:01:07 2021 +0100
@@ -73,7 +73,7 @@
 !define DESCRIPTION "GNU Octave Installer"
 !define INSTALLER_FILES "$TOPDIR/installer-files"
 !define INSTALLER_NAME "$INSTALLER_NAME"
-!define MAIN_APP_EXE "octave-firsttime.vbs"
+!define MAIN_APP_EXE "octave-launch-firsttime.exe"
 !define PRODUCT_ROOT_KEY "SHCTX"
 !define PRODUCT_KEY "Software\\Octave-$VERSION"
 !define PRODUCT_UNINST_KEY "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Octave-$VERSION"
@@ -437,10 +437,12 @@
   SetOutPath "\$INSTDIR" 
   File "$OCTAVE_SOURCE/README.html"
 
-  ; include octave.vbs and other scripts
+  ; include octave-launch, octave.vbs and other scripts
   SetOutPath "\$INSTDIR" 
   File "$OCTAVE_SOURCE/octave.vbs"
   File "$OCTAVE_SOURCE/octave-firsttime.vbs"
+  File "$OCTAVE_SOURCE/octave-launch.exe"
+  File "$OCTAVE_SOURCE/octave-launch-firsttime.exe"
   File "$OCTAVE_SOURCE/fc_update.bat"
   File "$OCTAVE_SOURCE/post-install.bat"
 
@@ -507,8 +509,8 @@
  CreateDirectory "\$SMPROGRAMS\\GNU Octave $VERSION\$MultiUser.Local"
  CreateShortCut "\$SMPROGRAMS\\GNU Octave $VERSION\$MultiUser.Local\\Uninstall.lnk" "\$INSTDIR\\uninstall.exe" "" "\$INSTDIR\\uninstall.exe" 0
  SetOutPath "%USERPROFILE%"
- CreateShortCut "\$SMPROGRAMS\\GNU Octave $VERSION\$MultiUser.Local\\Octave-$VERSION\$MultiUser.Local (CLI).lnk" "%SYSTEMROOT%\\system32\\wscript.exe" "\$\\"\$INSTDIR\\octave.vbs\$\\" --no-gui" "\$INSTDIR\\$ICON" 0 SW_SHOWMINIMIZED
- CreateShortCut "\$SMPROGRAMS\\GNU Octave $VERSION\$MultiUser.Local\\Octave-$VERSION\$MultiUser.Local (GUI).lnk" "%SYSTEMROOT%\\system32\\wscript.exe" "\$\\"\$INSTDIR\\octave.vbs\$\\" --gui" "\$INSTDIR\\$ICON" 0 SW_SHOWMINIMIZED
+ CreateShortCut "\$SMPROGRAMS\\GNU Octave $VERSION\$MultiUser.Local\\Octave-$VERSION\$MultiUser.Local (CLI).lnk" "\$INSTDIR\\octave-launch.exe" "--no-gui" "\$INSTDIR\\$ICON" 0 SW_SHOWMINIMIZED
+ CreateShortCut "\$SMPROGRAMS\\GNU Octave $VERSION\$MultiUser.Local\\Octave-$VERSION\$MultiUser.Local (GUI).lnk" "\$INSTDIR\\octave-launch.exe" "--gui" "\$INSTDIR\\$ICON" 0 SW_SHOWMINIMIZED
  SetOutPath "\$INSTDIR"
 
  ; fix the shortcuts for appid
@@ -580,8 +582,8 @@
 
 have_ver_str:
     SetOutPath "%USERPROFILE%"
-    CreateShortCut "\$desktop\\GNU Octave\$MultiUser.Local (CLI).lnk" "%SYSTEMROOT%\\system32\\wscript.exe" "\$\\"\$R0\\octave.vbs\$\\" --no-gui" "\$R2" 0 SW_SHOWMINIMIZED
-    CreateShortCut "\$desktop\\GNU Octave\$MultiUser.Local (GUI).lnk" "%SYSTEMROOT%\\system32\\wscript.exe" "\$\\"\$R0\\octave.vbs\$\\" --gui" "\$R2" 0 SW_SHOWMINIMIZED
+    CreateShortCut "\$desktop\\GNU Octave\$MultiUser.Local (CLI).lnk" "\$R0\\octave-launch.exe" "--no-gui" "\$R2" 0 SW_SHOWMINIMIZED
+    CreateShortCut "\$desktop\\GNU Octave\$MultiUser.Local (GUI).lnk" "\$R0\\octave-launch.exe" "--gui" "\$R2" 0 SW_SHOWMINIMIZED
 
     nsExec::Exec /TIMEOUT=30000 '"\$INSTDIR\\$OCTAVE_SUBDIR\\bin\\win7appid.exe" "\$desktop\\GNU Octave\$MultiUser.Local (GUI).lnk" "gnu.octave.\$R1"'
     Pop \$0
@@ -606,7 +608,7 @@
 
   WriteRegStr SHCTX "Software\\Classes\\Octave.Document.$VERSION" "FriendlyAppName" "GNU Octave $VERSION"
   WriteRegStr SHCTX "Software\\Classes\\Octave.Document.$VERSION\\DefaultIcon" "" "\$INSTDIR\\$ICON"
-  WriteRegStr SHCTX "Software\\Classes\\Octave.Document.$VERSION\\shell\\open\\command" "" "wscript \$\\"\$INSTDIR\\octave.vbs\$\\" --gui --persist --eval \$\\"edit '%1'\$\\""
+  WriteRegStr SHCTX "Software\\Classes\\Octave.Document.$VERSION\\shell\\open\\command" "" "\$\\"\$INSTDIR\\octave-launch.exe\$\\" --gui --persist --eval \$\\"edit '%1'\$\\""
 
   \${If} \$RegisterOctaveFileType == \${BST_CHECKED}
 
@@ -688,12 +690,12 @@
 
  IfFileExists "\$desktop\\GNU Octave\$MultiUser.Local (CLI).lnk" 0 check_gui_shortcut 
  SetOutPath "%USERPROFILE%"
- CreateShortCut "\$desktop\\GNU Octave\$MultiUser.Local (CLI).lnk" "%SYSTEMROOT%\system32\wscript.exe" "\$\\"\$R0\\octave.vbs\$\\" --no-gui" "\$R2" 0 SW_SHOWMINIMIZED
+ CreateShortCut "\$desktop\\GNU Octave\$MultiUser.Local (CLI).lnk" "\$R0\\octave-launch.exe" "--no-gui" "\$R2" 0 SW_SHOWMINIMIZED
 
 check_gui_shortcut:
  IfFileExists "\$desktop\\GNU Octave\$MultiUser.Local (GUI).lnk" 0 done_remove_desktop_shortcuts
  SetOutPath "%USERPROFILE%"
- CreateShortCut "\$desktop\\GNU Octave\$MultiUser.Local (GUI).lnk" "%SYSTEMROOT%\system32\wscript.exe" "\$\\"\$R0\\octave.vbs\$\\" --gui" "\$R2" 0 SW_SHOWMINIMIZED
+ CreateShortCut "\$desktop\\GNU Octave\$MultiUser.Local (GUI).lnk" "\$R0\\octave-launch.exe" "--gui" "\$R2" 0 SW_SHOWMINIMIZED
  nsExec::Exec /TIMEOUT=30000 '"\$INSTDIR\\$OCTAVE_SUBDIR\\bin\\win7appid.exe" "\$desktop\\GNU Octave\$MultiUser.Local (GUI).lnk" "gnu.octave.\$R1"'
  Pop \$0
 
--- a/tools/msys2-install.py	Wed Nov 24 18:31:48 2021 +0100
+++ b/tools/msys2-install.py	Tue Nov 30 19:01:07 2021 +0100
@@ -222,6 +222,8 @@
     save_list_file (pkg_info_dir + "/files", filelist, "%FILES%")
     save_desc_file (pkg_info_dir + "/desc", pkginfo)
     shutil.copy2(tmpdir + "/.MTREE", pkg_info_dir + "/mtree")
+    if os.path.exists(tmpdir + "/.INSTALL") == True:
+      shutil.copy2(tmpdir + "/.INSTALL", pkg_info_dir + "/install")
 
   finally:
     if env.verbose: