--- misc/build/openssl-3.0.20/crypto/bio/bio_sock2.c
+++ misc/build/openssl-3.0.20/crypto/bio/bio_sock2.c
@@ -268,6 +268,10 @@
          * Therefore we always have to use setsockopt here.
          */
         on = options & BIO_SOCK_V6_ONLY ? 1 : 0;
+/* Windows < XP needs this: */
+#  if !defined(IPPROTO_IPV6)
+#    define IPPROTO_IPV6 41
+#  endif
         if (setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,
                 (const void *)&on, sizeof(on))
             != 0) {
--- misc/build/openssl-3.0.20/crypto/init.c
+++ misc/build/openssl-3.0.20/crypto/init.c
@@ -133,7 +133,7 @@

 #if !defined(OPENSSL_USE_NODELETE) \
     && !defined(OPENSSL_NO_PINSHARED)
-#if defined(DSO_WIN32) && !defined(_WIN32_WCE)
+#if defined(DSO_WIN32) && !defined(_WIN32_WCE) && _WIN32_WINNT >= 0x0500
     {
         HMODULE handle = NULL;
         BOOL ret;
@@ -656,7 +656,7 @@
 #if !defined(OPENSSL_USE_NODELETE) \
     && !defined(OPENSSL_NO_PINSHARED)
     {
-#if defined(DSO_WIN32) && !defined(_WIN32_WCE)
+#if defined(DSO_WIN32) && !defined(_WIN32_WCE) && _WIN32_WINNT >= 0x0500
         HMODULE handle = NULL;
         BOOL ret;
         union {
--- misc/build/openssl-3.0.20/crypto/threads_win.c
+++ misc/build/openssl-3.0.20/crypto/threads_win.c
@@ -54,7 +54,7 @@
         return NULL;
     }

-#if !defined(_WIN32_WCE)
+#if !defined(_WIN32_WCE) && _WIN32_WINNT >= 0x0403
     /* 0x400 is the spin count value suggested in the documentation */
     if (!InitializeCriticalSectionAndSpinCount(lock, 0x400)) {
         OPENSSL_free(lock);
