diff -Nru postgresql-16.9-orig/configure.ac postgresql-16.9-patched/configure.ac
--- postgresql-16.9-orig/configure.ac	2025-05-05 16:30:08.000000000 -0400
+++ postgresql-16.9-patched/configure.ac	2025-05-19 07:39:11.168855453 -0400
@@ -19,10 +19,16 @@
 
 AC_INIT([PostgreSQL], [16.9], [pgsql-bugs@lists.postgresql.org], [], [https://www.postgresql.org/])
 
-m4_if(m4_defn([m4_PACKAGE_VERSION]), [2.69], [], [m4_fatal([Autoconf version 2.69 is required.
-Untested combinations of 'autoconf' and PostgreSQL versions are not
-recommended.  You can remove the check from 'configure.ac' but it is then
-your responsibility whether the result works or not.])])
+dnl Buffer for MXE patch application
+dnl   Required to ensure patch context
+dnl   excludes version numbers / dates
+dnl End buffer for MXE patch application
+AC_PREREQ(2.69)
+dnl Buffer for MXE patch application
+dnl   Required to ensure patch context
+dnl   excludes version numbers / dates
+dnl End buffer for MXE patch application
+
 AC_COPYRIGHT([Copyright (c) 1996-2023, PostgreSQL Global Development Group])
 AC_CONFIG_SRCDIR([src/backend/access/common/heaptuple.c])
 AC_CONFIG_AUX_DIR(config)
@@ -1377,13 +1383,8 @@
   # Minimum required OpenSSL version is 1.0.1
   AC_DEFINE(OPENSSL_API_COMPAT, [0x10001000L],
             [Define to the OpenSSL API version in use. This avoids deprecation warnings from newer OpenSSL versions.])
-  if test "$PORTNAME" != "win32"; then
-     AC_CHECK_LIB(crypto, CRYPTO_new_ex_data, [], [AC_MSG_ERROR([library 'crypto' is required for OpenSSL])])
-     AC_CHECK_LIB(ssl,    SSL_new, [], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])])
-  else
-     AC_SEARCH_LIBS(CRYPTO_new_ex_data, [eay32 crypto], [], [AC_MSG_ERROR([library 'eay32' or 'crypto' is required for OpenSSL])])
-     AC_SEARCH_LIBS(SSL_new, [ssleay32 ssl], [], [AC_MSG_ERROR([library 'ssleay32' or 'ssl' is required for OpenSSL])])
-  fi
+  AC_CHECK_LIB(crypto, CRYPTO_new_ex_data, [], [AC_MSG_ERROR([library 'crypto' is required for OpenSSL])])
+  AC_CHECK_LIB(ssl,    SSL_new, [], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])])
   # Functions introduced in OpenSSL 1.0.2. LibreSSL does not have
   # SSL_CTX_set_cert_cb().
   AC_CHECK_FUNCS([X509_get_signature_nid SSL_CTX_set_cert_cb])
diff -Nru postgresql-16.9-orig/src/Makefile.shlib postgresql-16.9-patched/src/Makefile.shlib
--- postgresql-16.9-orig/src/Makefile.shlib	2025-05-05 16:30:08.000000000 -0400
+++ postgresql-16.9-patched/src/Makefile.shlib	2025-05-19 07:35:50.326998870 -0400
@@ -213,10 +213,15 @@
 endif
 
 ifeq ($(PORTNAME), win32)
-  ifdef SO_MAJOR_VERSION
-    shlib		= lib$(NAME)$(DLSUFFIX)
+  ifeq ($(MXE_BUILD_SHARED), TRUE)
+    ifdef SO_MAJOR_VERSION
+      shlib		= lib$(NAME)$(DLSUFFIX)
+      stlib		= lib$(NAME)$(DLSUFFIX).a
+    endif
+    haslibarule		= yes
+  else
+    shlib		=
   endif
-  haslibarule   = yes
 endif
 
 
@@ -322,10 +327,6 @@
 
 # Win32 case
 
-# See notes in src/backend/parser/Makefile about the following two rules
-$(stlib): $(shlib)
-	touch $@
-
 # XXX A backend that loads a module linked with libgcc_s_dw2-1.dll will exit
 # uncleanly, hence -static-libgcc.  (Last verified with MinGW-w64 compilers
 # from i686-4.9.1-release-win32-dwarf-rt_v3-rev1.)  Shared libgcc has better
@@ -334,6 +335,13 @@
 #
 # If SHLIB_EXPORTS is set, the rules below will build a .def file from that.
 # Else we just use --export-all-symbols.
+
+ifeq ($(MXE_BUILD_SHARED), TRUE)
+## See notes in src/backend/parser/Makefile about the following two rules
+## MXE: for static builds we do not override the stdlib rule.
+$(stlib): $(shlib)
+	touch $@
+
 ifeq (,$(SHLIB_EXPORTS))
 $(shlib): $(OBJS) | $(SHLIB_PREREQS)
 	$(CC) $(CFLAGS)  -shared -static-libgcc -o $@  $(OBJS) $(LDFLAGS) $(LDFLAGS_SL) $(SHLIB_LINK) $(LIBS) -Wl,--export-all-symbols -Wl,--out-implib=$(stlib)
@@ -350,6 +358,7 @@
 	echo 'EXPORTS' >>$@
 	sed -e '/^#/d' -e 's/^\(.*[ 	]\)\([0-9][0-9]*\)/    \1@ \2/' $< >>$@
 endif
+endif # MXE_BUILD_SHARED
 
 endif # PORTNAME == cygwin
 endif # PORTNAME == cygwin || PORTNAME == win32
@@ -394,14 +403,17 @@
 install-lib-static: $(stlib) installdirs-lib
 	$(INSTALL_STLIB) $< '$(DESTDIR)$(libdir)/$(stlib)'
 
-install-lib-shared: $(shlib) installdirs-lib
+ifeq ($(MXE_BUILD_SHARED), TRUE)
+install-lib-shared: $(shlib)
+ifeq (, $(filter $(PORTNAME), win32 cygwin))
+install-lib-shared: installdirs-lib
+endif # not win32 or cygwin
 ifdef soname
 # we don't install $(shlib) on AIX
 # (see http://archives.postgresql.org/message-id/52EF20B2E3209443BC37736D00C3C1380A6E79FE@EXADV1.host.magwien.gv.at)
 ifneq ($(PORTNAME), aix)
+ifeq (, $(filter $(PORTNAME), win32 cygwin))
 	$(INSTALL_SHLIB) $< '$(DESTDIR)$(libdir)/$(shlib)'
-ifneq ($(PORTNAME), cygwin)
-ifneq ($(PORTNAME), win32)
 ifneq ($(shlib), $(shlib_major))
 	cd '$(DESTDIR)$(libdir)' && \
 	rm -f $(shlib_major) && \
@@ -412,8 +424,9 @@
 	rm -f $(shlib_bare) && \
 	$(LN_S) $(shlib) $(shlib_bare)
 endif
-endif # not win32
-endif # not cygwin
+else  # win32 or cygwin
+	$(INSTALL_SHLIB) $< '$(DESTDIR)$(bindir)/$(shlib)'
+endif # not win32 or cygwin
 endif # not aix
 ifneq (,$(findstring $(PORTNAME),win32 cygwin))
 	$(INSTALL_SHLIB) $< '$(DESTDIR)$(bindir)/$(shlib)'
@@ -421,6 +434,7 @@
 else # no soname
 	$(INSTALL_SHLIB) $< '$(DESTDIR)$(pkglibdir)/$(shlib)'
 endif
+endif # not MXE_BUILD_SHARED
 
 
 installdirs-lib:
