? inc32
? out32_ARMV4I
? out32_X86
? out32dll_ARMV4I
? out32dll_X86
? tmp32_ARMV4I
? tmp32_X86
? tmp32dll_ARMV4I
? tmp32dll_X86
? wince_trunk_090115.patch
? ms/version32.rc
Index: INSTALL.WCE
===================================================================
RCS file: /v/openssl/cvs/openssl/INSTALL.WCE,v
retrieving revision 1.7
diff -d -u -r1.7 INSTALL.WCE
--- INSTALL.WCE	6 Nov 2005 20:52:25 -0000	1.7
+++ INSTALL.WCE	13 Jan 2009 08:54:37 -0000
@@ -4,15 +4,15 @@
 
  Building OpenSSL for Windows CE requires the following external tools:
 
-  * Microsoft eMbedded Visual C++ 3.0 or later
+  * Microsoft eMbedded Visual C++ 3.0 or Visual Studio 2005 and later
   * Appropriate SDK might be required
   * Perl for Win32 [commonly recommended ActiveState Perl is available
     from http://www.activestate.com/Products/ActivePerl/]
 
   * wcecompat compatibility library available at
-    http://www.essemer.com.au/windowsce/
-  * Optionally ceutils for running automated tests (same location)
-
+    * www.essemer.com.au for Windows CE 4.2 and earlier
+    * github.com/mauricek/wcecompat all Windows CE versions
+  * Optionally ceutils for running automated tests (www.essemer.com.au)
   _or_
 
   * PocketConsole driver and PortSDK available at
@@ -20,11 +20,7 @@
   * CMD command interpreter (same location)
 
  As Windows CE support in OpenSSL relies on 3rd party compatibility
- library, it's appropriate to check corresponding URL for updates. For
- example if you choose wcecompat, note that as for the moment of this
- writing version 1.2 is available and actually required for WCE 4.2
- and newer platforms. All wcecompat issues should be directed to
- www.essemer.com.au.
+ library, it's appropriate to check corresponding URL for updates.
 
  Why compatibility library at all? The C Runtime Library implementation
  for Windows CE that is included with Microsoft eMbedded Visual C++ is
@@ -35,6 +31,10 @@
  redirects IO to active sync link, while PortSDK - to NT-like console
  driver on the handheld itself.
 
+ With Windows CE 5 and following a lot of standard functionality has been
+ added to the core system, making some parts of the wcecompat lib deprecated.
+ More information is available at github.com/mauricek/wcecompat
+
  Building
  --------
 
@@ -51,6 +51,10 @@
     > set WCECOMPAT=C:\wcecompat
     > set PORTSDK_LIBPATH=
 
+ OpenSSL for Windows CE uses the same environment variables for compilation
+ as wcecompat does. Thus, there might be more settings needed. For more
+ information follow the wcecompat documentation
+
  2. To choose PortSDK set up PORTSDK_LIBPATH to point at hardware-
     specific location where your portlib.lib is installed:
 
@@ -75,10 +79,9 @@
 
    > nmake -f ms\cedll.mak
 
- [note that static builds are not supported under CE]
-
- If all is well it should compile and you will have some DLLs and executables
- in out32dll*. 
+ If all is well it should compile and you will have some static libraries and
+ executables in out32_xyz, or some DLLs and executables in out32dll_xyz where
+ xyz refers to the target processor architecture of the Windows CE SDK.
 
  <<< everyting below needs revision in respect to wcecompat vs. PortSDK >>>
 
Index: e_os.h
===================================================================
RCS file: /v/openssl/cvs/openssl/e_os.h,v
retrieving revision 1.98
diff -d -u -r1.98 e_os.h
--- e_os.h	22 Dec 2008 13:54:09 -0000	1.98
+++ e_os.h	15 Jan 2009 13:03:59 -0000
@@ -126,6 +126,9 @@
 #if defined(OPENSSL_SYS_WINDOWS) && !defined(WINDOWS)
 #  define WINDOWS
 #endif
+#if defined(OPENSSL_SYS_WINCE) && !defined(WINCE)
+#  define WINCE
+#endif
 #if defined(OPENSSL_SYS_MSDOS) && !defined(MSDOS)
 #  define MSDOS
 #endif
@@ -134,7 +137,7 @@
 #  define GETPID_IS_MEANINGLESS
 #endif
 
-#ifdef WIN32
+#if defined(WIN32) || defined(WINCE)
 #define get_last_sys_error()	GetLastError()
 #define clear_sys_error()	SetLastError(0)
 #if !defined(WINNT)
@@ -272,7 +275,7 @@
 	*/
 #      define _WIN32_WINNT 0x0400
 #    endif
-#    if !defined(OPENSSL_NO_SOCK) && defined(_WIN32_WINNT)
+#    if !defined(OPENSSL_NO_SOCK) && (defined(_WIN32_WINNT) || defined(_WIN32_WCE))
        /*
         * Just like defining _WIN32_WINNT including winsock2.h implies
         * certain "discipline" for maintaing [broad] binary compatibility.
@@ -308,7 +311,7 @@
 #      undef isupper
 #      undef isxdigit
 #    endif
-#    if defined(_MSC_VER) && !defined(_DLL) && defined(stdin)
+#    if defined(_MSC_VER) && !defined(_DLL) && defined(stdin) && !defined(_WIN32_WCE)
 #      if _MSC_VER>=1300
 #        undef stdin
 #        undef stdout
@@ -337,10 +340,6 @@
 #  include <io.h>
 #  include <fcntl.h>
 
-#  ifdef OPENSSL_SYS_WINCE
-#    define OPENSSL_NO_POSIX_IO
-#  endif
-
 #  define ssize_t long
 
 #  if defined (__BORLANDC__)
@@ -485,7 +484,7 @@
 /*************/
 
 #ifdef USE_SOCKETS
-#  if defined(WINDOWS) || defined(MSDOS)
+#  if defined(WINDOWS) || defined(MSDOS) || defined(WINCE)
       /* windows world */
 
 #    ifdef OPENSSL_NO_SOCK
@@ -494,7 +493,7 @@
 #      define SHUTDOWN(fd)		close(fd)
 #      define SHUTDOWN2(fd)		close(fd)
 #    elif !defined(__DJGPP__)
-#      if defined(_WIN32_WCE) && _WIN32_WCE<410
+#      if defined(_WIN32_WCE)
 #        define getservbyname _masked_declaration_getservbyname
 #      endif
 #      if !defined(IPPROTO_IP)
@@ -666,7 +665,7 @@
 #define IRIX_CC_BUG	/* CDS++ up to V2.0Bsomething suffered from the same bug.*/
 #endif
 
-#if defined(OPENSSL_SYS_WINDOWS)
+#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WINCE)
 #  define strcasecmp _stricmp
 #  define strncasecmp _strnicmp
 #elif defined(OPENSSL_SYS_VMS)
Index: apps/apps.c
===================================================================
RCS file: /v/openssl/cvs/openssl/apps/apps.c,v
retrieving revision 1.132
diff -d -u -r1.132 apps.c
--- apps/apps.c	24 Nov 2008 17:27:04 -0000	1.132
+++ apps/apps.c	12 Jan 2009 11:10:51 -0000
@@ -116,7 +116,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#ifndef OPENSSL_SYSNAME_WIN32
+#if !defined(OPENSSL_SYSNAME_WIN32) && !defined(OPENSSL_SYSNAME_WINCE)
 #include <strings.h>
 #endif
 #include <sys/types.h>
Index: crypto/o_str.c
===================================================================
RCS file: /v/openssl/cvs/openssl/crypto/o_str.c,v
retrieving revision 1.12
diff -d -u -r1.12 o_str.c
--- crypto/o_str.c	14 Jan 2008 18:10:55 -0000	1.12
+++ crypto/o_str.c	12 Jan 2009 11:07:11 -0000
@@ -60,7 +60,7 @@
 #include <e_os.h>
 #include "o_str.h"
 
-#if !defined(OPENSSL_IMPLEMENTS_strncasecmp) && !defined(OPENSSL_SYSNAME_WIN32)
+#if !defined(OPENSSL_IMPLEMENTS_strncasecmp) && !defined(OPENSSL_SYSNAME_WIN32) && !defined(OPENSSL_SYS_WINCE)
 # include <strings.h>
 #endif
 
Index: crypto/bio/b_sock.c
===================================================================
RCS file: /v/openssl/cvs/openssl/crypto/bio/b_sock.c,v
retrieving revision 1.49
diff -d -u -r1.49 b_sock.c
--- crypto/bio/b_sock.c	3 Jan 2008 22:43:01 -0000	1.49
+++ crypto/bio/b_sock.c	12 Jan 2009 11:11:58 -0000
@@ -88,7 +88,7 @@
 static int wsa_init_done=0;
 #endif
 
-#if defined(OPENSSL_SYS_BEOS_BONE)		
+#if defined(OPENSSL_SYS_BEOS_BONE) || defined(OPENSSL_SYS_WINCE)
 /* BONE's IP6 support is incomplete */
 #undef AF_INET6
 #endif
Index: crypto/dso/dso_win32.c
===================================================================
RCS file: /v/openssl/cvs/openssl/crypto/dso/dso_win32.c,v
retrieving revision 1.37
diff -d -u -r1.37 dso_win32.c
--- crypto/dso/dso_win32.c	29 Dec 2008 12:35:47 -0000	1.37
+++ crypto/dso/dso_win32.c	15 Jan 2009 13:29:50 -0000
@@ -686,7 +686,9 @@
 	CREATETOOLHELP32SNAPSHOT create_snap;
 	CLOSETOOLHELP32SNAPSHOT  close_snap;
 	MODULE32 module_first, module_next;
+#if !defined(_WIN32_WCE) || _WIN32_WCE < 100
 	int len;
+#endif
  
 	if (addr == NULL)
 		{
Index: crypto/rand/randfile.c
===================================================================
RCS file: /v/openssl/cvs/openssl/crypto/rand/randfile.c,v
retrieving revision 1.56
diff -d -u -r1.56 randfile.c
--- crypto/rand/randfile.c	22 Dec 2008 13:54:10 -0000	1.56
+++ crypto/rand/randfile.c	12 Jan 2009 11:54:59 -0000
@@ -79,7 +79,7 @@
 # include <sys/stat.h>
 #endif
 
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(_WIN32_WCE)
 #define stat	_stat
 #define chmod	_chmod
 #define open	_open
Index: crypto/rsa/rsa_pss.c
===================================================================
RCS file: /v/openssl/cvs/openssl/crypto/rsa/rsa_pss.c,v
retrieving revision 1.9
diff -d -u -r1.9 rsa_pss.c
--- crypto/rsa/rsa_pss.c	29 Dec 2008 16:11:56 -0000	1.9
+++ crypto/rsa/rsa_pss.c	12 Jan 2009 11:07:31 -0000
@@ -66,7 +66,7 @@
 
 static const unsigned char zeroes[] = {0,0,0,0,0,0,0,0};
 
-#if defined(_MSC_VER) && defined(_ARM_)
+#if defined(_MSC_VER) && defined(_ARM_) && (!defined(_WIN32_WCE) || (_WIN32_WCE < 500))
 #pragma optimize("g", off)
 #endif
 
Index: crypto/x509/by_dir.c
===================================================================
RCS file: /v/openssl/cvs/openssl/crypto/x509/by_dir.c,v
retrieving revision 1.31
diff -d -u -r1.31 by_dir.c
--- crypto/x509/by_dir.c	22 Dec 2008 13:54:11 -0000	1.31
+++ crypto/x509/by_dir.c	12 Jan 2009 11:56:09 -0000
@@ -392,7 +392,7 @@
 					postfix,k);
 				}
 #ifndef OPENSSL_NO_POSIX_IO
-#ifdef _WIN32
+#if defined(_WIN32) && !defined(_WIN32_WCE)
 #define stat _stat
 #endif
 			{
Index: util/pl/VC-32.pl
===================================================================
RCS file: /v/openssl/cvs/openssl/util/pl/VC-32.pl,v
retrieving revision 1.60
diff -d -u -r1.60 VC-32.pl
--- util/pl/VC-32.pl	5 Jun 2008 23:42:04 -0000	1.60
+++ util/pl/VC-32.pl	15 Jan 2009 14:19:14 -0000
@@ -55,7 +55,6 @@
     {
     # sanity check
     die '%OSVERSION% is not defined'	if (!defined($ENV{'OSVERSION'}));
-    die '%PLATFORM% is not defined'	if (!defined($ENV{'PLATFORM'}));
     die '%TARGETCPU% is not defined'	if (!defined($ENV{'TARGETCPU'}));
 
     #
@@ -64,11 +63,15 @@
     $wcevers = $ENV{'OSVERSION'};			# WCENNN
     die '%OSVERSION% value is insane'	if ($wcevers !~ /^WCE([1-9])([0-9]{2})$/);
     $wcecdefs = "-D_WIN32_WCE=$1$2 -DUNDER_CE=$1$2";	# -D_WIN32_WCE=NNN
+    $wcevers = substr($wcevers,3);
     $wcelflag = "/subsystem:windowsce,$1.$2";		# ...,N.NN
 
-    $wceplatf =  $ENV{'PLATFORM'};
-    $wceplatf =~ tr/a-z0-9 /A-Z0-9_/d;
-    $wcecdefs .= " -DWCE_PLATFORM_$wceplatf";
+    if ($wcevers < 500 || defined($ENV{'PLATFORM'})) {
+        die '%PLATFORM% is not defined' if (!defined($ENV{'PLATFORM'}));
+        $wceplatf =  $ENV{'PLATFORM'};
+        $wceplatf =~ tr/a-z0-9 /A-Z0-9_/d;
+        $wcecdefs .= " -DWCE_PLATFORM_$wceplatf";
+    }
 
     $wcetgt = $ENV{'TARGETCPU'};	# just shorter name...
     SWITCH: for($wcetgt) {
@@ -99,13 +102,22 @@
     }
 
     $cc='$(CC)';
-    $base_cflags=' /W3 /WX /GF /Gy /nologo -DUNICODE -D_UNICODE -DOPENSSL_SYSNAME_WINCE -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32 -DNO_CHMOD -DOPENSSL_SMALL_FOOTPRINT';
+    $base_cflags=' /W3 /GF /Gy /nologo -DUNICODE -D_UNICODE -DOPENSSL_SYSNAME_WINCE -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32 -DNO_CHMOD -DOPENSSL_SMALL_FOOTPRINT';
     $base_cflags.=" $wcecdefs";
     $base_cflags.=' -I$(WCECOMPAT)/include'		if (defined($ENV{'WCECOMPAT'}));
     $base_cflags.=' -I$(PORTSDK_LIBPATH)/../../include'	if (defined($ENV{'PORTSDK_LIBPATH'}));
-    $opt_cflags=' /MC /O1i';	# optimize for space, but with intrinsics...
-    $dbg_clfags=' /MC /Od -DDEBUG -D_DEBUG';
+    $opt_cflags=' /O1i';	# optimize for space, but with intrinsics...
+    $dbg_cflags=' /Od -DDEBUG -D_DEBUG';
     $lflags="/nologo /opt:ref $wcelflag";
+    if ($wcevers >= 500) {
+        $lflags .=" /NODEFAULTLIB:oldnames.lib /NODEFAULTLIB:libc.lib ws2.lib";
+        if (!($wcetgt eq "X86") || $shlib) {
+            $lflags .=" coredll.lib corelibc.lib";
+        }
+    } else {
+        $opt_cflags .= ' /MC';
+        $dbg_cflags .= ' /MC';
+    }
     }
 else	# Win32
     {
@@ -151,6 +163,7 @@
 	$ex_libs.=' $(WCECOMPAT)/lib/wcecompatex.lib'	if (defined($ENV{'WCECOMPAT'}));
 	$ex_libs.=' $(PORTSDK_LIBPATH)/portlib.lib'	if (defined($ENV{'PORTSDK_LIBPATH'}));
 	$ex_libs.=' /nodefaultlib:oldnames.lib coredll.lib corelibc.lib' if ($ENV{'TARGETCPU'} eq "X86");
+	$ex_libs.=' crypt32.lib';
 	}
 else
 	{
@@ -257,6 +270,7 @@
 elsif ($shlib && $FLAVOR =~ /CE/)
 	{
 	$mlflags.=" $lflags /dll";
+	$mlflags.=' $(WCECOMPAT)/lib/wcecompatex.lib'   if (defined($ENV{'WCECOMPAT'}));
 	$lflags.=' /entry:mainCRTstartup' if(defined($ENV{'PORTSDK_LIBPATH'}));
 	$lib_cflag=" -D_WINDLL -D_DLL";
 	$out_def='out32dll_$(TARGETCPU)';
@@ -293,7 +307,14 @@
 			$ex.=' bufferoverflowu.lib' if ($FLAVOR =~ /WIN64/);
 			if ($target =~ /capi/)
 				{
-				$ex.=' crypt32.lib advapi32.lib';
+				if ($FLAVOR !~ /CE/)
+					{
+					$ex.=' crypt32.lib advapi32.lib';
+					}
+				else
+					{
+					$ex.=' crypt32.lib';
+					}
 				}
 			}
 		elsif ($FLAVOR =~ /CE/)
