diff --git a/3rdp/build/Common.gmake b/3rdp/build/Common.gmake
index eec37ad2e91be2d55a22d7d36dfd7ecd49dfff8b..c74fd266892d39817fadbee58bbc88a21382b338 100644
--- a/3rdp/build/Common.gmake
+++ b/3rdp/build/Common.gmake
@@ -126,7 +126,7 @@ else
  CRYPTLIBDIR := $(CRYPT_IDIR)
  CRYPT_DEPS := cl
  CRYPT_LIBS += $(CRYPT_IDIR)/libcl.a
- CRYPT_CFLAGS += -DSTATIC_CRYPTLIB
+ CRYPT_CFLAGS += -DSTATIC_CRYPTLIB -DSTATIC_LIB
 endif
 
 # Put it all together...
diff --git a/3rdp/build/GNUmakefile b/3rdp/build/GNUmakefile
index 03a27f7c6a59563e4fb164db05f999fc37182198..aae8edb9599a8368997b402d90cb2ac65ac26173 100644
--- a/3rdp/build/GNUmakefile
+++ b/3rdp/build/GNUmakefile
@@ -65,7 +65,7 @@ $(CRYPT_SRC): | $(3RDPSRCDIR)
 $(CRYPT_IDIR): | $(3RDPODIR)
 	$(QUIET)$(IFNOTEXIST) mkdir $(CRYPT_IDIR)
 
-$(CRYPTLIB_BUILD): $(3RDP_ROOT)$(DIRSEP)dist/cryptlib.zip $(3RDP_ROOT)$(DIRSEP)build/SSL-fix.patch $(3RDP_ROOT)$(DIRSEP)build/random_exit.patch $(3RDP_ROOT)$(DIRSEP)build/Dynamic-linked-static-lib.patch $(3RDP_ROOT)$(DIRSEP)build/terminal-params.patch | $(CRYPT_SRC) $(CRYPT_IDIR)
+$(CRYPTLIB_BUILD): $(3RDP_ROOT)$(DIRSEP)dist/cryptlib.zip $(3RDP_ROOT)$(DIRSEP)build/SSL-fix.patch $(3RDP_ROOT)$(DIRSEP)build/random_exit.patch $(3RDP_ROOT)$(DIRSEP)build/Dynamic-linked-static-lib.patch $(3RDP_ROOT)$(DIRSEP)build/terminal-params.patch $(3RDP_ROOT)$(DIRSEP)build/cl-mingw32.patch | $(CRYPT_SRC) $(CRYPT_IDIR)
 	@echo Creating $@ ...
 	$(QUIET)-rm -rf $(CRYPT_SRC)/*
 	$(QUIET)unzip -oa $(3RDPDISTDIR)$(DIRSEP)cryptlib.zip -d $(CRYPT_SRC)
@@ -73,6 +73,7 @@ $(CRYPTLIB_BUILD): $(3RDP_ROOT)$(DIRSEP)dist/cryptlib.zip $(3RDP_ROOT)$(DIRSEP)b
 	$(QUIET)patch -p0 -d $(CRYPT_SRC) < SSL-fix.patch
 	$(QUIET)patch -p0 -d $(CRYPT_SRC) < Dynamic-linked-static-lib.patch
 	$(QUIET)patch -p0 -d $(CRYPT_SRC) < terminal-params.patch
-	$(QUIET)cd $(CRYPT_SRC) && env - PATH=$(PATH) make
+	$(QUIET)patch -p0 -d $(CRYPT_SRC) < cl-mingw32.patch
+	$(QUIET)cd $(CRYPT_SRC) && env - PATH=$(PATH) CC=$(CC) AR=$(AR) RANLIB=$(RANLIB) make
 	$(QUIET)cp $(CRYPT_SRC)$(DIRSEP)libcl.a $(CRYPT_IDIR)
 	$(QUIET)cp $(CRYPT_SRC)$(DIRSEP)cryptlib.h $(CRYPT_IDIR)
diff --git a/3rdp/build/cl-mingw32.patch b/3rdp/build/cl-mingw32.patch
new file mode 100644
index 0000000000000000000000000000000000000000..a0e81d95e62baa7b66afb6319fbc8a833b9fa0ed
--- /dev/null
+++ b/3rdp/build/cl-mingw32.patch
@@ -0,0 +1,128 @@
+diff -ur ../cl.patched/io/tcp.h ./io/tcp.h
+--- ../cl.patched/io/tcp.h	2014-06-23 03:18:20.000000000 -0700
++++ ./io/tcp.h	2014-06-23 03:49:37.000000000 -0700
+@@ -199,7 +199,7 @@
+ 	  defined( __ECOS__ ) || defined( __MVS__ ) || \
+ 	  defined( __PALMOS__ ) || defined( __RTEMS__ ) || \
+ 	  defined ( __SYMBIAN32__ ) || defined( __TANDEM_NSK__ ) || \
+-	  defined( __TANDEM_OSS__ ) || defined( __UNIX__ )
++	  defined( __TANDEM_OSS__ ) || ( defined( __UNIX__ ) && !defined(__MSVCRT__))
+ 
+ /* C_IN is a cryptlib.h value which is also defined in some versions of
+    netdb.h, so we have to undefine it before we include any network header
+Only in ./io: tcp.h.orig
+diff -ur ../cl.patched/makefile ./makefile
+--- ../cl.patched/makefile	2014-06-23 03:18:24.000000000 -0700
++++ ./makefile	2014-06-23 03:49:39.000000000 -0700
+@@ -2299,9 +2299,8 @@
+ 
+ target-mingw:
+ 	@make OSNAME=win32 target-init
+-	@make asm_elf OBJPATH=$(OBJPATH)
+ 	make $(XDEFINES) OSNAME=MinGW CFLAGS="$(XCFLAGS) \
+-		-DCONFIG_DATA_LITTLEENDIAN -DWIN32 -DUSE_ASM -fomit-frame-pointer -O3"
++		-DCONFIG_DATA_LITTLEENDIAN -DWIN32 -DNO_ASM -DSTATIC_LIB -fomit-frame-pointer -O3"
+ 
+ # MIPS running Linux: Little-endian, 2.x kernel.  Note that we use $(CFLAGS)
+ # rather than $(XCFLAGS) since this is a Unix system, just not the same as
+Only in .: makefile.orig
+diff -ur ../cl.patched/misc/config.h ./misc/config.h
+--- ../cl.patched/misc/config.h	2014-06-23 03:18:16.000000000 -0700
++++ ./misc/config.h	2014-06-23 03:49:40.000000000 -0700
+@@ -268,7 +268,7 @@
+ 
+ #if defined( __WIN32__ )
+   #ifndef __BORLANDC__
+-	#define USE_PKCS11
++//	#define USE_PKCS11
+   #endif /* Borland C can't handle PKCS #11 headers */
+   #if !defined( NDEBUG )
+ 	#define USE_HARDWARE
+Only in ./misc: config.h.orig
+diff -ur ../cl.patched/misc/os_spec.c ./misc/os_spec.c
+--- ../cl.patched/misc/os_spec.c	2014-06-23 03:18:16.000000000 -0700
++++ ./misc/os_spec.c	2014-06-23 03:49:42.000000000 -0700
+@@ -1077,6 +1077,7 @@
+   #pragma comment( linker, "/export:DllRegisterServer=_DllRegisterServer@0,PRIVATE" )
+ #endif /* Win64 */
+ 
++#if 0
+ STDAPI DllRegisterServer( void )
+ 	{
+ 	MessageBoxA( NULL, "Why are you trying to register the cryptlib DLL?\n"
+@@ -1085,6 +1086,7 @@
+ 				 MB_ICONQUESTION | MB_OK );
+ 	return( E_NOINTERFACE );
+ 	}
++#endif
+ #endif /* !( NT_DRIVER || STATIC_LIB ) */
+ 
+ /* Borland's archaic compilers don't recognise DllMain() but still use the
+Only in ./misc: os_spec.c.orig
+diff -ur ../cl.patched/misc/os_spec.h ./misc/os_spec.h
+--- ../cl.patched/misc/os_spec.h	2014-06-23 03:18:16.000000000 -0700
++++ ./misc/os_spec.h	2014-06-23 03:49:43.000000000 -0700
+@@ -664,14 +664,14 @@
+    fairly easy but under Unix it's supported somewhat selectively and may be
+    buggy or platform-specific */
+ 
+-#if defined( __WINDOWS__ ) || \
++#if defined( __WINDOWS__ ) || defined( __MSVCRT__) || \
+ 	( defined( __UNIX__ ) && \
+ 	  ( ( defined( sun ) && OSVERSION > 4 ) || defined( __linux__ ) || \
+ 		defined( _AIX ) || ( defined( __APPLE__ ) && !defined( __MAC__ ) ) ) )
+   #define DYNAMIC_LOAD
+ 
+   /* Macros to map OS-specific dynamic-load values to generic ones */
+-  #if defined( __WINDOWS__ )
++  #if defined( __WINDOWS__ ) || defined( __MSVCRT__ )
+ 	HMODULE WINAPI SafeLoadLibrary( LPCTSTR lpFileName );
+ 
+ 	#define INSTANCE_HANDLE		HINSTANCE
+@@ -944,7 +944,8 @@
+   #define EOL "\n"
+   #define EOL_LEN 1
+ #else
+-  #error "You need to add the OS-specific define to enable end-of-line handling"
++  #define EOL		"\n"
++  #define EOL_LEN	1
+ #endif /* OS-specific EOL markers */
+ 
+ /* If we're compiling on IBM mainframes, enable EBCDIC <-> ASCII string
+Only in ./misc: os_spec.h.orig
+diff -ur ../cl.patched/random/win32.c ./random/win32.c
+--- ../cl.patched/random/win32.c	2014-06-23 03:18:14.000000000 -0700
++++ ./random/win32.c	2014-06-23 03:49:45.000000000 -0700
+@@ -1216,7 +1216,7 @@
+ /* If we're running under Win64 there's no need to include Win95/98 
+    backwards-compatibility features */
+ 
+-#ifndef __WIN64__
++#if 0
+ 
+ /* Type definitions for function pointers to call Toolhelp32 functions */
+ 
+@@ -2118,7 +2118,7 @@
+ 		krnlExitMutex( MUTEX_RANDOM );
+ 		return;
+ 		}
+-#ifndef __WIN64__
++#if 0
+ 	if( getSysVar( SYSVAR_ISWIN95 ) == TRUE )
+ 		{
+ 		hThread = ( HANDLE ) _beginthreadex( NULL, 0, threadSafeSlowPollWin95,
+Only in ./random: win32.c.orig
+diff -ur ../cl.patched/tools/buildlib.sh ./tools/buildlib.sh
+--- ../cl.patched/tools/buildlib.sh	2014-06-23 03:18:20.000000000 -0700
++++ ./tools/buildlib.sh	2014-06-23 03:49:46.000000000 -0700
+@@ -69,7 +69,7 @@
+ 		echo "Need to set up ucLinux link command" ;;
+ 
+ 	*)
+-		ar rcs $LIBNAME $* || \
+-		( ar rc $LIBNAME $* && ranlib $LIBNAME )
++		$AR rcs $LIBNAME $* || \
++		( $AR rc $LIBNAME $* && $RANLIB $LIBNAME )
+ 
+ esac
+Only in ./tools: buildlib.sh.orig