--- libxml2/catalog.c.orig	2017-10-18 20:32:07.805900500 -0400
+++ libxml2/catalog.c	2017-10-18 20:54:23.935581600 -0400
@@ -2396,6 +2396,7 @@ xmlParseSGMLCatalog(xmlCatalogPtr catal,
 		case SGML_CATA_ENTITY:
 		    if (*cur == '%')
 			type = SGML_CATA_PENTITY;
+                     /* Falls through. */
 		case SGML_CATA_PENTITY:
 		case SGML_CATA_DOCTYPE:
 		case SGML_CATA_LINKTYPE:

--- libxml2/dict.c.orig	2017-10-18 16:14:35.754607500 -0400
+++ libxml2/dict.c	2017-10-18 16:23:42.179523300 -0400
@@ -453,14 +453,23 @@ xmlDictComputeFastKey(const xmlChar *nam
     }
     switch (namelen) {
         case 10: value += name[9];
+        /* Falls through. */
         case 9: value += name[8];
+        /* Falls through. */
         case 8: value += name[7];
+        /* Falls through. */ 
         case 7: value += name[6];
+        /* Falls through. */
         case 6: value += name[5];
+        /* Falls through. */
         case 5: value += name[4];
+        /* Falls through. */
         case 4: value += name[3];
+        /* Falls through. */
         case 3: value += name[2];
+        /* Falls through. */
         case 2: value += name[1];
+        /* Falls through. */
         default: break;
     }
     return(value);
@@ -496,15 +505,25 @@ xmlDictComputeFastQKey(const xmlChar *pr
     }
     switch (plen) {
         case 10: value += prefix[9];
+        /* Falls through. */
         case 9: value += prefix[8];
+        /* Falls through. */
         case 8: value += prefix[7];
+        /* Falls through. */
         case 7: value += prefix[6];
+        /* Falls through. */
         case 6: value += prefix[5];
+        /* Falls through. */
         case 5: value += prefix[4];
+        /* Falls through. */
         case 4: value += prefix[3];
+        /* Falls through. */
         case 3: value += prefix[2];
+        /* Falls through. */
         case 2: value += prefix[1];
+        /* Falls through. */
         case 1: value += prefix[0];
+        /* Falls through. */
         default: break;
     }
     len -= plen;
@@ -513,16 +532,26 @@ xmlDictComputeFastQKey(const xmlChar *pr
 	len--;
     }
     switch (len) {
-        case 10: value += name[9];
+        case 10: value += name[9]; 
+        /* Falls through. */
         case 9: value += name[8];
+        /* Falls through. */
         case 8: value += name[7];
+        /* Falls through. */
         case 7: value += name[6];
+        /* Falls through. */
         case 6: value += name[5];
+        /* Falls through. */
         case 5: value += name[4];
+        /* Falls through. */
         case 4: value += name[3];
+        /* Falls through. */
         case 3: value += name[2];
+        /* Falls through. */
         case 2: value += name[1];
+        /* Falls through. */
         case 1: value += name[0];
+        /* Falls through. */
         default: break;
     }
     return(value);

--- libxml2/libxml.h.orig	2017-10-12 17:45:23.138297500 -0400
+++ libxml2/libxml.h	2017-10-12 17:45:59.105744500 -0400
@@ -109,7 +109,7 @@ int xmlNop(void);
 #endif
 #endif
 #endif
-#if !defined(PIC) && !defined(NOLIBTOOL)
+#if !defined(PIC) && !defined(NOLIBTOOL) && !defined(LIBXML_STATIC)
 #  define LIBXML_STATIC
 #endif
 #endif /* ! __XML_LIBXML_H__ */
--- libxml2/nanoftp.c.orig	2017-10-18 20:56:42.393584400 -0400
+++ libxml2/nanoftp.c	2017-10-18 21:08:14.565975100 -0400
@@ -14,6 +14,10 @@
 #define HAVE_SYS_TIME_H
 #endif /* TESTING */
 
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#include <wsockcompat.h>
+#endif
+
 #define IN_LIBXML
 #include "libxml.h"
 
@@ -75,10 +79,6 @@
 #endif
 
 
-#if defined(_WIN32) && !defined(__CYGWIN__)
-#include <wsockcompat.h>
-#endif
-
 /**
  * A couple portability macros
  */
@@ -901,7 +901,7 @@ xmlNanoFTPConnect(void *ctx) {
 	    __xmlIOErr(XML_FROM_FTP, 0, "getaddrinfo failed");
 	    return (-1);
 	}
-	if (tmp->ai_addrlen > sizeof(ctxt->ftpAddr)) {
+	if ((size_t)tmp->ai_addrlen > (size_t)sizeof(ctxt->ftpAddr)) {
 	    if (result)
 		freeaddrinfo (result);
 	    __xmlIOErr(XML_FROM_FTP, 0, "gethostbyname address mismatch");
@@ -1036,6 +1036,7 @@ xmlNanoFTPConnect(void *ctx) {
 		case 2:
 		    if (proxyPasswd == NULL)
 			break;
+                    /* Falls through. */
 		case 3:
 		    if (proxyPasswd != NULL)
 			snprintf(buf, sizeof(buf), "PASS %s\r\n", proxyPasswd);
@@ -1105,6 +1106,7 @@ xmlNanoFTPConnect(void *ctx) {
 		    ctxt->controlFd = INVALID_SOCKET;
 		    return(-1);
 		}
+                /* Falls through. */
 	    case 2:
 		/* USER user@host command */
 		if (ctxt->user == NULL)
@@ -1158,6 +1160,7 @@ xmlNanoFTPConnect(void *ctx) {
 		    ctxt->controlFd = INVALID_SOCKET;
 		    return(-1);
 		}
+                /* Falls through. */
 	    case 3:
 		/*
 		 * If you need support for other Proxy authentication scheme
@@ -1206,6 +1209,7 @@ xmlNanoFTPConnect(void *ctx) {
 	case 3:
 	    __xmlIOErr(XML_FROM_FTP, XML_FTP_ACCNT,
 		       "FTP server asking for ACCNT on anonymous\n");
+           /* Falls through. */
 	case 1:
 	case 4:
 	case 5:
--- libxml2/nanohttp.c.orig	2017-10-15 05:38:02.063055700 -0400
+++ libxml2/nanohttp.c	2017-10-15 05:47:39.373225800 -0400
@@ -1088,7 +1088,7 @@ xmlNanoHTTPConnectHost(const char *host,
 
 	for (res = result; res; res = res->ai_next) {
 	    if (res->ai_family == AF_INET) {
-		if (res->ai_addrlen > sizeof(sockin)) {
+		if (res->ai_addrlen > (socklen_t)sizeof(sockin)) {
 		    __xmlIOErr(XML_FROM_HTTP, 0, "address size mismatch\n");
 		    freeaddrinfo (result);
 		    return INVALID_SOCKET;
@@ -1098,7 +1098,7 @@ xmlNanoHTTPConnectHost(const char *host,
 		addr = (struct sockaddr *)&sockin;
 #ifdef SUPPORT_IP6
 	    } else if (have_ipv6 () && (res->ai_family == AF_INET6)) {
-		if (res->ai_addrlen > sizeof(sockin6)) {
+		if ((size_t)res->ai_addrlen > (size_t)sizeof(sockin6)) {
 		    __xmlIOErr(XML_FROM_HTTP, 0, "address size mismatch\n");
 		    freeaddrinfo (result);
 		    return INVALID_SOCKET;

--- libxml2/relaxng.c.orig	2017-10-18 18:05:32.748287100 -0400
+++ libxml2/relaxng.c	2017-10-18 18:28:39.636345500 -0400
@@ -8891,6 +8891,7 @@ xmlRelaxNGValidateValue(xmlRelaxNGValidC
             if (ret != 0) {
                 break;
             }
+            /* Falls through. */
             /* no break on purpose */
         case XML_RELAXNG_ZEROORMORE:{
                 xmlChar *cur, *temp;
@@ -10168,6 +10169,7 @@ xmlRelaxNGValidateState(xmlRelaxNGValidC
             }
             if (ctxt->errNr > errNr)
                 xmlRelaxNGPopErrors(ctxt, errNr);
+            /* Falls through. */
             /* no break on purpose */
         case XML_RELAXNG_ZEROORMORE:{
                 int progress;

--- libxml2/runtest.c.orig	2017-10-14 15:11:41.995529500 -0400
+++ libxml2/runtest.c	2017-10-14 15:20:57.076248100 -0400
@@ -3962,8 +3962,12 @@ static const char *testfiles[] = {
     "test/threads/invalid.xml",
 };
 
+#if defined(_WIN32) && !defined(__CYGWIN__)
+#define OKAY 1
+#else
 static const char *Okay = "OK";
 static const char *Failed = "Failed";
+#endif
 
 #ifndef xmlDoValidityCheckingDefaultValue
 #error xmlDoValidityCheckingDefaultValue is not a macro
@@ -3972,12 +3976,21 @@ static const char *Failed = "Failed";
 #error xmlGenericErrorContext is not a macro
 #endif
 
+#if defined(_WIN32) && !defined(__CYGWIN__)
+static DWORD
+thread_specific_data(void *private_data)
+#else
 static void *
 thread_specific_data(void *private_data)
+#endif
 {
     xmlDocPtr myDoc;
     const char *filename = (const char *) private_data;
+#if defined(_WIN32) && !defined(__CYGWIN__)
+    DWORD okay = OKAY;
+#else
     int okay = 1;
+#endif
 
     if (!strcmp(filename, "test/threads/invalid.xml")) {
         xmlDoValidityCheckingDefaultValue = 0;
@@ -4016,9 +4029,13 @@ thread_specific_data(void *private_data)
             okay = 0;
         }
     }
+#if defined(_WIN32) && !defined(__CYGWIN__)
+    return (okay);
+#else
     if (okay == 0)
         return ((void *) Failed);
     return ((void *) Okay);
+#endif
 }
 
 #if defined(_WIN32) && !defined(__CYGWIN__)
@@ -4032,7 +4049,7 @@ static HANDLE tid[MAX_ARGC];
 static DWORD WINAPI
 win32_thread_specific_data(void *private_data)
 {
-    return((DWORD) thread_specific_data(private_data));
+    return(thread_specific_data(private_data));
 }
 
 static int
@@ -4084,7 +4101,7 @@ testThread(void)
 
         xmlCatalogCleanup();
         for (i = 0; i < num_threads; i++) {
-            if (results[i] != (DWORD) Okay) {
+            if (results[i] != OKAY) {
                 fprintf(stderr, "Thread %d handling %s failed\n",
 		        i, testfiles[i]);
 	        res = 1;

--- libxml2/testrecurse.c.orig	2017-10-19 09:27:34.279279900 -0400
+++ libxml2/testrecurse.c	2017-10-19 09:38:16.540294600 -0400
@@ -69,9 +69,15 @@ typedef struct
 } glob_t;
 
 #define GLOB_DOOFFS 0
+#if defined __MINGW32__
+static int glob(const char *pattern, ATTRIBUTE_UNUSED int flags,
+                ATTRIBUTE_UNUSED int errfunc(const char *epath, int eerrno),
+                glob_t *pglob) {
+#else
 static int glob(const char *pattern, int flags,
                 int errfunc(const char *epath, int eerrno),
                 glob_t *pglob) {
+#endif
     glob_t *ret;
     WIN32_FIND_DATA FindFileData;
     HANDLE hFind;
--- libxml2/threads.c.orig	2017-10-19 12:06:34.686297000 -0400
+++ libxml2/threads.c	2017-10-19 12:43:22.692896600 -0400
@@ -981,10 +981,19 @@ xmlOnceInit(void)
 #ifdef HAVE_PTHREAD_H
 #elif defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
 #if defined(LIBXML_STATIC_FOR_DLL)
-BOOL XMLCALL
-xmlDllMain(ATTRIBUTE_UNUSED HINSTANCE hinstDLL, DWORD fdwReason,
-           ATTRIBUTE_UNUSED LPVOID lpvReserved)
+xmlDllMain(ATTRIBUTE_UNUSED void *hinstDLL, unsigned long fdwReason,
+           ATTRIBUTE_UNUSED void *lpvReserved)
 #else
+/* declare to avoid "no previous prototype for 'DllMain'" warning */
+/* Note that we do NOT want to include this function declaration in
+   a public header because it's meant to be called by Windows itself,
+   not a program that uses this library.  This also has to be exported. */
+
+XMLPUBFUN BOOL WINAPI
+DllMain (HINSTANCE hinstDLL,
+         DWORD     fdwReason,
+         LPVOID    lpvReserved);
+
 BOOL WINAPI
 DllMain(ATTRIBUTE_UNUSED HINSTANCE hinstDLL, DWORD fdwReason,
         ATTRIBUTE_UNUSED LPVOID lpvReserved)
--- libxml2/tree.c.orig	2017-10-18 13:35:34.433831000 -0400
+++ libxml2/tree.c	2017-10-18 15:57:34.317080700 -0400
@@ -8259,6 +8259,7 @@ xmlDOMWrapRemoveNode(xmlDOMWrapCtxtPtr c
 			ns = ns->next;
 		    } while (ns != NULL);
 		}
+                /* Falls through. */
 		/* No break on purpose. */
 	    case XML_ATTRIBUTE_NODE:
 		if (node->ns != NULL) {
@@ -8850,6 +8851,7 @@ next_ns_decl:
 		}
 		if (! adoptns)
 		    goto ns_end;
+                /* Falls through. */
 		/* No break on purpose. */
 	    case XML_ATTRIBUTE_NODE:
 		/* No ns, no fun. */
@@ -9131,6 +9133,7 @@ xmlDOMWrapAdoptBranch(xmlDOMWrapCtxtPtr
 			    goto internal_error;
 		    }
 		}
+                /* Falls through. */
 		/* No break on purpose. */
 	    case XML_ATTRIBUTE_NODE:
 		/* No namespace, no fun. */

--- libxml2/valid.c.orig	2017-10-18 13:25:03.759092500 -0400
+++ libxml2/valid.c	2017-10-18 13:25:21.909382700 -0400
@@ -5190,6 +5190,7 @@ xmlSnprintfElements(char *buf, int size,
             case XML_TEXT_NODE:
 		if (xmlIsBlankNode(cur))
 		    break;
+                /* Falls through. */
             case XML_CDATA_SECTION_NODE:
             case XML_ENTITY_REF_NODE:
 	        strcat(buf, "CDATA");
--- libxml2/xmlregexp.c.orig	2017-10-18 13:07:47.358432300 -0400
+++ libxml2/xmlregexp.c	2017-10-18 13:26:58.437608300 -0400
@@ -2810,18 +2810,21 @@ xmlRegCheckCharacterRange(xmlRegAtomType
 	    break;
         case XML_REGEXP_NOTSPACE:
 	    neg = !neg;
+            /* Falls through. */
         case XML_REGEXP_ANYSPACE:
 	    ret = ((codepoint == '\n') || (codepoint == '\r') ||
 		   (codepoint == '\t') || (codepoint == ' '));
 	    break;
         case XML_REGEXP_NOTINITNAME:
 	    neg = !neg;
+            /* Falls through. */
         case XML_REGEXP_INITNAME:
 	    ret = (IS_LETTER(codepoint) ||
 		   (codepoint == '_') || (codepoint == ':'));
 	    break;
         case XML_REGEXP_NOTNAMECHAR:
 	    neg = !neg;
+            /* Falls through. */
         case XML_REGEXP_NAMECHAR:
 	    ret = (IS_LETTER(codepoint) || IS_DIGIT(codepoint) ||
 		   (codepoint == '.') || (codepoint == '-') ||
@@ -2830,11 +2833,13 @@ xmlRegCheckCharacterRange(xmlRegAtomType
 	    break;
         case XML_REGEXP_NOTDECIMAL:
 	    neg = !neg;
+            /* Falls through. */
         case XML_REGEXP_DECIMAL:
 	    ret = xmlUCSIsCatNd(codepoint);
 	    break;
         case XML_REGEXP_REALCHAR:
 	    neg = !neg;
+            /* Falls through. */
         case XML_REGEXP_NOTREALCHAR:
 	    ret = xmlUCSIsCatP(codepoint);
 	    if (ret == 0)
--- libxml2/xmlschemastypes.c.orig	2017-10-18 16:33:51.303165500 -0400
+++ libxml2/xmlschemastypes.c	2017-10-18 17:01:47.269086000 -0400
@@ -5403,6 +5403,7 @@ xmlSchemaValidateFacetInternal(xmlSchema
 	    if ((valType == XML_SCHEMAS_QNAME) ||
 		(valType == XML_SCHEMAS_NOTATION))
 		return (0);
+            /* Falls through. */
 	    /* No break on purpose. */
 	case XML_SCHEMA_FACET_MAXLENGTH:
 	case XML_SCHEMA_FACET_MINLENGTH: {
--- libxml2/xmlschemas.c.orig	2017-10-18 20:00:46.213182800 -0400
+++ libxml2/xmlschemas.c	2017-10-18 20:03:58.611542600 -0400
@@ -1742,6 +1742,7 @@ xmlSchemaFormatItemForReport(xmlChar **b
 		*buf = xmlStrcat(*buf, BAD_CAST "'");
 		FREE_AND_NULL(str);
 	    }
+        /* Falls through. */
 	default:
 	    named = 0;
 	}
--- libxml2/xmlwriter.c.orig	2017-10-18 20:28:45.652695000 -0400
+++ libxml2/xmlwriter.c	2017-10-18 20:31:14.694429600 -0400
@@ -3754,6 +3754,7 @@ xmlTextWriterEndDTDEntity(xmlTextWriterP
             if (count < 0)
                 return -1;
             sum += count;
+        /* Falls through. */
         case XML_TEXTWRITER_DTD_ENTY:
         case XML_TEXTWRITER_DTD_PENT:
             count = xmlOutputBufferWriteString(writer->out, ">");
--- libxml2/xpath.c.orig	2017-10-18 19:50:56.607929600 -0400
+++ libxml2/xpath.c	2017-10-18 19:52:20.027137900 -0400
@@ -7042,6 +7042,7 @@ xmlXPathEqualValuesCommon(xmlXPathParser
 		    valuePush(ctxt, arg2);
 		    xmlXPathNumberFunction(ctxt, 1);
 		    arg2 = valuePop(ctxt);
+                    /* Falls through. */
 		    /* no break on purpose */
 		case XPATH_NUMBER:
 		    /* Hand check NaN and Infinity equalities */
--- libxml2/include/libxml/threads.h.orig	2017-10-19 11:18:26.336090600 -0400
+++ libxml2/include/libxml/threads.h	2017-10-19 11:21:18.229263700 -0400
@@ -72,8 +72,13 @@ XMLPUBFUN void XMLCALL
 XMLPUBFUN xmlGlobalStatePtr XMLCALL
 			xmlGetGlobalState(void);
 
-#if defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && defined(LIBXML_STATIC_FOR_DLL)
-int XMLCALL xmlDllMain(void *hinstDLL, unsigned long fdwReason, void *lpvReserved);
+#ifdef HAVE_PTHREAD_H
+#elif defined(HAVE_WIN32_THREADS) && !defined(HAVE_COMPILER_TLS) && (!defined(LIBXML_STATIC) || defined(LIBXML_STATIC_FOR_DLL))
+#if defined(LIBXML_STATIC_FOR_DLL)
+int XMLCALL
+xmlDllMain(void *hinstDLL, unsigned long fdwReason,
+           void *lpvReserved);
+#endif
 #endif
 
 #ifdef __cplusplus
