diff -ur openssl-0.9.7-stable-SNAP-20021201/INSTALL.WCE openssl-0.9.7-stable-SNAP-20021201.wce/INSTALL.WCE
--- openssl-0.9.7-stable-SNAP-20021201/INSTALL.WCE	2002-11-18 07:06:36.000000000 +1100
+++ openssl-0.9.7-stable-SNAP-20021201.wce/INSTALL.WCE	2002-12-03 02:32:51.000000000 +1100
@@ -11,6 +11,9 @@
  You also need Perl for Win32.  You will need ActiveState Perl, available
  from http://www.activestate.com/ActivePerl.
 
+ Windows CE support in OpenSSL relies on wcecompat.  All Windows CE specific
+ issues should be directed to www.essemer.com.au.
+
  The C Runtime Library implementation for Windows CE that is included with
  Microsoft eMbedded Visual C++ 3.0 is incomplete and in some places
  incorrect.  wcecompat plugs the holes and tries to bring the Windows CE
diff -ur openssl-0.9.7-stable-SNAP-20021201/crypto/crypto.h openssl-0.9.7-stable-SNAP-20021201.wce/crypto/crypto.h
--- openssl-0.9.7-stable-SNAP-20021201/crypto/crypto.h	2002-11-28 00:03:14.000000000 +1100
+++ openssl-0.9.7-stable-SNAP-20021201.wce/crypto/crypto.h	2002-12-03 00:07:13.000000000 +1100
@@ -63,9 +63,6 @@
 
 #ifndef OPENSSL_NO_FP_API
 #include <stdio.h>
-#ifdef OPENSSL_SYS_WINCE
-#include <stdio_extras.h>
-#endif
 #endif
 
 #include <openssl/stack.h>
diff -ur openssl-0.9.7-stable-SNAP-20021201/crypto/des/read2pwd.c openssl-0.9.7-stable-SNAP-20021201.wce/crypto/des/read2pwd.c
--- openssl-0.9.7-stable-SNAP-20021201/crypto/des/read2pwd.c	2002-11-28 20:03:03.000000000 +1100
+++ openssl-0.9.7-stable-SNAP-20021201.wce/crypto/des/read2pwd.c	2002-12-03 00:07:32.000000000 +1100
@@ -112,9 +112,6 @@
 #include <string.h>
 #include <openssl/des.h>
 #include <openssl/ui.h>
-#ifdef OPENSSL_SYS_WINCE
-#include <stdio_extras.h>	/* BUFSIZ */
-#endif
 
 int DES_read_password(DES_cblock *key, const char *prompt, int verify)
 	{
diff -ur openssl-0.9.7-stable-SNAP-20021201/crypto/engine/enginetest.c openssl-0.9.7-stable-SNAP-20021201.wce/crypto/engine/enginetest.c
--- openssl-0.9.7-stable-SNAP-20021201/crypto/engine/enginetest.c	2002-11-16 10:08:27.000000000 +1100
+++ openssl-0.9.7-stable-SNAP-20021201.wce/crypto/engine/enginetest.c	2002-12-03 00:07:59.000000000 +1100
@@ -58,9 +58,6 @@
 
 #include <openssl/e_os2.h>
 #include <stdio.h>
-#ifdef OPENSSL_SYS_WINCE
-#include <stdlib_extras.h>
-#endif
 #include <string.h>
 #include <openssl/buffer.h>
 #include <openssl/crypto.h>
diff -ur openssl-0.9.7-stable-SNAP-20021201/crypto/md2/md2_dgst.c openssl-0.9.7-stable-SNAP-20021201.wce/crypto/md2/md2_dgst.c
--- openssl-0.9.7-stable-SNAP-20021201/crypto/md2/md2_dgst.c	2002-11-29 23:02:53.000000000 +1100
+++ openssl-0.9.7-stable-SNAP-20021201.wce/crypto/md2/md2_dgst.c	2002-12-03 01:38:20.000000000 +1100
@@ -61,6 +61,7 @@
 #include <string.h>
 #include <openssl/md2.h>
 #include <openssl/opensslv.h>
+#include "cryptlib.h"
 
 const char *MD2_version="MD2" OPENSSL_VERSION_PTEXT;
 
diff -ur openssl-0.9.7-stable-SNAP-20021201/crypto/md4/md4_one.c openssl-0.9.7-stable-SNAP-20021201.wce/crypto/md4/md4_one.c
--- openssl-0.9.7-stable-SNAP-20021201/crypto/md4/md4_one.c	2002-11-29 23:02:54.000000000 +1100
+++ openssl-0.9.7-stable-SNAP-20021201.wce/crypto/md4/md4_one.c	2002-12-03 01:38:42.000000000 +1100
@@ -59,6 +59,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <openssl/md4.h>
+#include "cryptlib.h"
 
 #ifdef CHARSET_EBCDIC
 #include <openssl/ebcdic.h>
diff -ur openssl-0.9.7-stable-SNAP-20021201/crypto/md5/md5_one.c openssl-0.9.7-stable-SNAP-20021201.wce/crypto/md5/md5_one.c
--- openssl-0.9.7-stable-SNAP-20021201/crypto/md5/md5_one.c	2002-11-29 23:02:54.000000000 +1100
+++ openssl-0.9.7-stable-SNAP-20021201.wce/crypto/md5/md5_one.c	2002-12-03 01:39:00.000000000 +1100
@@ -59,6 +59,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <openssl/md5.h>
+#include "cryptlib.h"
 
 #ifdef CHARSET_EBCDIC
 #include <openssl/ebcdic.h>
diff -ur openssl-0.9.7-stable-SNAP-20021201/crypto/rand/rand_win.c openssl-0.9.7-stable-SNAP-20021201.wce/crypto/rand/rand_win.c
--- openssl-0.9.7-stable-SNAP-20021201/crypto/rand/rand_win.c	2002-11-16 10:08:50.000000000 +1100
+++ openssl-0.9.7-stable-SNAP-20021201.wce/crypto/rand/rand_win.c	2002-12-03 00:11:44.000000000 +1100
@@ -211,7 +211,7 @@
         osverinfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO) ;
         GetVersionEx( &osverinfo ) ;
 
-#ifdef OPENSSL_SYS_WINCE
+#if defined(OPENSSL_SYS_WINCE) && WCEPLATFORM!=MS_HPC_PRO
 	/* poll the CryptoAPI PRNG */
 	/* The CryptoAPI returns sizeof(buf) bytes of randomness */
 	if (CryptAcquireContext(&hProvider, 0, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT))
diff -ur openssl-0.9.7-stable-SNAP-20021201/crypto/ripemd/rmd_one.c openssl-0.9.7-stable-SNAP-20021201.wce/crypto/ripemd/rmd_one.c
--- openssl-0.9.7-stable-SNAP-20021201/crypto/ripemd/rmd_one.c	2002-11-28 20:03:21.000000000 +1100
+++ openssl-0.9.7-stable-SNAP-20021201.wce/crypto/ripemd/rmd_one.c	2002-12-03 01:40:29.000000000 +1100
@@ -59,6 +59,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <openssl/ripemd.h>
+#include "cryptlib.h"
 
 unsigned char *RIPEMD160(const unsigned char *d, unsigned long n,
 	     unsigned char *md)
diff -ur openssl-0.9.7-stable-SNAP-20021201/crypto/sha/sha1_one.c openssl-0.9.7-stable-SNAP-20021201.wce/crypto/sha/sha1_one.c
--- openssl-0.9.7-stable-SNAP-20021201/crypto/sha/sha1_one.c	2002-11-28 20:03:22.000000000 +1100
+++ openssl-0.9.7-stable-SNAP-20021201.wce/crypto/sha/sha1_one.c	2002-12-03 01:39:59.000000000 +1100
@@ -59,6 +59,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <openssl/sha.h>
+#include "cryptlib.h"
 
 #ifndef OPENSSL_NO_SHA1
 unsigned char *SHA1(const unsigned char *d, unsigned long n, unsigned char *md)
diff -ur openssl-0.9.7-stable-SNAP-20021201/crypto/sha/sha_one.c openssl-0.9.7-stable-SNAP-20021201.wce/crypto/sha/sha_one.c
--- openssl-0.9.7-stable-SNAP-20021201/crypto/sha/sha_one.c	2002-11-28 20:03:22.000000000 +1100
+++ openssl-0.9.7-stable-SNAP-20021201.wce/crypto/sha/sha_one.c	2002-12-03 01:39:41.000000000 +1100
@@ -59,6 +59,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <openssl/sha.h>
+#include "cryptlib.h"
 
 #ifndef OPENSSL_NO_SHA0
 unsigned char *SHA(const unsigned char *d, unsigned long n, unsigned char *md)
diff -ur openssl-0.9.7-stable-SNAP-20021201/crypto/ui/ui_util.c openssl-0.9.7-stable-SNAP-20021201.wce/crypto/ui/ui_util.c
--- openssl-0.9.7-stable-SNAP-20021201/crypto/ui/ui_util.c	2002-11-28 20:03:23.000000000 +1100
+++ openssl-0.9.7-stable-SNAP-20021201.wce/crypto/ui/ui_util.c	2002-12-03 00:08:44.000000000 +1100
@@ -55,9 +55,6 @@
 
 #include <string.h>
 #include <openssl/ui.h>
-#ifdef OPENSSL_SYS_WINCE
-#include <stdio_extras.h>	/* BUFSIZ */
-#endif
 
 int UI_UTIL_read_pw_string(char *buf,int length,const char *prompt,int verify)
 	{
diff -ur openssl-0.9.7-stable-SNAP-20021201/e_os.h openssl-0.9.7-stable-SNAP-20021201.wce/e_os.h
--- openssl-0.9.7-stable-SNAP-20021201/e_os.h	2002-11-29 06:03:19.000000000 +1100
+++ openssl-0.9.7-stable-SNAP-20021201.wce/e_os.h	2002-12-03 00:06:38.000000000 +1100
@@ -230,9 +230,6 @@
 #  include <fcntl.h>
 
 #  ifdef OPENSSL_SYS_WINCE
-#    include <stdio_extras.h>
-#    include <stdlib_extras.h>
-#    include <string_extras.h>
 #    include <winsock_extras.h>
 #  endif
 
diff -ur openssl-0.9.7-stable-SNAP-20021201/util/mk1mf.pl openssl-0.9.7-stable-SNAP-20021201.wce/util/mk1mf.pl
--- openssl-0.9.7-stable-SNAP-20021201/util/mk1mf.pl	2002-11-16 10:10:09.000000000 +1100
+++ openssl-0.9.7-stable-SNAP-20021201.wce/util/mk1mf.pl	2002-12-03 00:36:55.000000000 +1100
@@ -271,6 +271,17 @@
 # The one monster makefile better suits building in non-unix
 # environments.
 
+EOF
+
+if ($platform eq "VC-CE")
+	{
+	$defs.= <<"EOF";
+!INCLUDE <\$(WCECOMPAT)/wcedefs.mak>
+
+EOF
+	}
+
+$defs.= <<"EOF";
 INSTALLTOP=$INSTALLTOP
 
 # Set your compiler options
diff -ur openssl-0.9.7-stable-SNAP-20021201/util/pl/VC-CE.pl openssl-0.9.7-stable-SNAP-20021201.wce/util/pl/VC-CE.pl
--- openssl-0.9.7-stable-SNAP-20021201/util/pl/VC-CE.pl	2002-11-18 07:08:42.000000000 +1100
+++ openssl-0.9.7-stable-SNAP-20021201.wce/util/pl/VC-CE.pl	2002-12-03 01:52:32.000000000 +1100
@@ -12,8 +12,8 @@
 
 # C compiler stuff
 $cc='$(CC)';
-$cflags=' /W3 /WX /Ox /O2 /Ob2 /Gs0 /GF /Gy /nologo -D$(TARGETCPU) -D_$(TARGETCPU)_ -DUNDER_CE=300 -D_WIN32_CE=300 -DWIN32_PLATFORM_PSPC -DUNICODE -D_UNICODE -DWIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32 -DNO_CHMOD -I$(WCECOMPAT)/include';
-$lflags='/nologo /subsystem:windowsce,3.00 /machine:$(TARGETCPU) /opt:ref';
+$cflags=' /W3 /WX /Ox /O2 /Ob2 /Gs0 /GF /Gy /nologo $(WCETARGETDEFS) -DUNICODE -D_UNICODE -DWIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32 -DNO_CHMOD -I$(WCECOMPAT)/include';
+$lflags='/nologo /subsystem:windowsce,$(WCELDVERSION) /machine:$(WCELDMACHINE) /opt:ref';
 $mlflags='';
 
 $out_def='out32_$(TARGETCPU)';
@@ -36,8 +36,7 @@
 $exep='.exe';
 if ($no_sock)
 	{ $ex_libs=""; }
-else	{ $ex_libs='winsock.lib $(WCECOMPAT)/lib/wcecompatex.lib'; }
-#else	{ $ex_libs='winsock.lib coredll.lib $(WCECOMPAT)/lib/wcecompatex.lib'; }
+else	{ $ex_libs='winsock.lib $(WCECOMPAT)/lib/wcecompatex.lib $(WCELDFLAGS)'; }
 
 # static library stuff
 $mklib='lib';
