Hi,

Here are some patches to OpenSSL 1.0.0 to improve support for win64 and to fix 
the build for WinCE when using the 
wcecompat compatibility library together with msvc2008.
Here's a brief summary of the contents of the files:

- mingw64-support.patch : as the name indicates, adds support for the mingw64 
toolchain, as well as minor tweaks to 
mingw32

- use-winsock2-header.patch : replaces a few forgotten <winsock.h> with 
<winsock2.h> now that openssl uses winsock2

- fix-wince-build-with-wcecompat.patch :
  * fixes redefinition issues with symbols already #define'd by wcecompat
  * try to use Posix IO on Wince if the compat library has sufficient support 
(which is the case for wcecompat)
  * switch to winsock2 for wince too
  * update msvc compiler flags: disable some harmless warnings which make the 
build fail and remove deprecated /MC 
option with msvc2008
  * use an explicit entry point for the examples, as wcecompat may be built 
without entry point support

- remove-unneeded-includes-in-public-headers.patch : remove unneeded #include's 
for errno.h and sys/types.h in public 
headers. In addition those headers aren't standard on wince so they force users 
of openssl to also bring in the 
compatibility library when using openssl, which may conflict with their own 
compatibility layer.

I've tested these patches with msvc2008 both on win32 and on Windows CE 5 
(windows mobile 6.5). Obviously the mingw 
related patch has been tested with mingw, but not by me.
Note that this series of patches come from the KDE on Windows project, and the 
original patch file can be found at :

svn.kde.org/home/kde/trunk/kdesupport/emerge/portage/win32libs-sources/openssl-src/openssl-1.0.0.diff


Best regards,
Romain

-- 
Romain Pokrzywka | [email protected] | Certified Qt Software Engineer & Trainer
Klarälvdalens Datakonsult AB, a KDAB Group company
Tel. Sweden (HQ) +46-563-540090, USA +1-866-777-KDAB(5322)
KDAB - Qt Experts - Platform-independent software solutions

--- openssl-1.0.0.orig/e_os.h	Mon Jan 19 23:26:36 1970
+++ openssl-1.0.0/e_os.h	Mon Jan 19 23:26:36 1970
@@ -308,7 +308,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,7 +337,7 @@
 #  include <io.h>
 #  include <fcntl.h>
 
-#  ifdef OPENSSL_SYS_WINCE
+#  if defined(OPENSSL_SYS_WINCE) && !defined(open)
 #    define OPENSSL_NO_POSIX_IO
 #  endif
 
@@ -499,7 +499,8 @@
 #      endif
 #      if !defined(IPPROTO_IP)
          /* winsock[2].h was included already? */
-#        include <winsock.h>
+#        include <winsock2.h>
+#        include <ws2tcpip.h>
 #      endif
 #      ifdef getservbyname
 #        undef getservbyname
--- openssl-1.0.0.orig/apps/apps.c	Mon Jan 19 23:26:36 1970
+++ openssl-1.0.0/apps/apps.c	Mon Jan 19 23:26:36 1970
@@ -147,7 +147,7 @@
 #include "apps.h"
 #undef NON_MAIN
 
-#ifdef _WIN32
+#if defined(OPENSSL_SYS_WIN32) && !defined(rename)
 static int WIN32_rename(const char *from, const char *to);
 #define rename(from,to) WIN32_rename((from),(to))
 #endif
--- openssl-1.0.0.orig/crypto/rand/randfile.c	Mon Jan 19 23:26:36 1970
+++ openssl-1.0.0/crypto/rand/randfile.c	Mon Jan 19 23:26:36 1970
@@ -79,11 +79,19 @@
 # include <sys/stat.h>
 #endif
 
-#ifdef _WIN32
+#ifdef OPENSSL_SYS_WIN32
+#ifndef stat
 #define stat	_stat
+#endif
+#ifndef chmod
 #define chmod	_chmod
+#endif
+#ifndef open
 #define open	_open
+#endif
+#ifndef fdopen
 #define fdopen	_fdopen
+#endif
 #endif
 
 #undef BUFSIZE
--- openssl-1.0.0.orig/util/pl/VC-32.pl	Mon Jan 19 23:26:36 1970
+++ openssl-1.0.0/util/pl/VC-32.pl	Mon Jan 19 23:26:36 1970
@@ -103,12 +103,12 @@
     }
 
     $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 /WX /wd4748 /wd4101 /GF /Gy /nologo -DUNICODE -D_UNICODE -DOPENSSL_SYSNAME_WINCE -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32 -DNO_CHMOD -DOPENSSL_SMALL_FOOTPRINT -DOPENSSL_NO_CAPIENG';
     $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_clfags=' /Od -DDEBUG -D_DEBUG';
     $lflags="/nologo /opt:ref $wcelflag";
     }
 else	# Win32
@@ -147,14 +147,14 @@
 $efile="/out:";
 $exep='.exe';
 if ($no_sock)		{ $ex_libs=''; }
-elsif ($FLAVOR =~ /CE/)	{ $ex_libs='winsock.lib'; }
+elsif ($FLAVOR =~ /CE/)	{ $ex_libs='ws2.lib'; }
 else			{ $ex_libs='ws2_32.lib'; }
 
 if ($FLAVOR =~ /CE/)
 	{
-	$ex_libs.=' $(WCECOMPAT)/lib/wcecompatex.lib'	if (defined($ENV{'WCECOMPAT'}));
+	$ex_libs.=' $(WCECOMPAT)/lib/wcecompat.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.=' /nodefaultlib:oldnames.lib coredll.lib corelibc.lib';
 	}
 else
 	{
@@ -261,10 +261,15 @@
 elsif ($shlib && $FLAVOR =~ /CE/)
 	{
 	$mlflags.=" $lflags /dll";
-	$lflags.=' /entry:mainCRTstartup' if(defined($ENV{'PORTSDK_LIBPATH'}));
 	$lib_cflag=" -D_WINDLL -D_DLL";
 	$out_def='out32dll_$(TARGETCPU)';
 	$tmp_def='tmp32dll_$(TARGETCPU)';
+	}
+
+if ($FLAVOR =~ /CE/)
+	{
+	$lflags.=' /entry:mainCRTstartup' if(defined($ENV{'PORTSDK_LIBPATH'}));
+	$lflags.=' /entry:mainACRTStartup' if(defined($ENV{'WCECOMPAT'}));
 	}
 
 $cflags.=" /Fd$out_def";
diff -Nru openssl-1.0.0.orig/Configure openssl-1.0.0/Configure
--- openssl-1.0.0.orig/Configure	2010-01-19 22:40:54.000000000 +0100
+++ openssl-1.0.0/Configure	2010-04-25 16:23:07.241942800 +0200
@@ -503,7 +503,7 @@
 "BC-32","bcc32::::WIN32::BN_LLONG DES_PTR RC4_INDEX EXPORT_VAR_AS_FN:${no_asm}:win32",
 
 # MinGW
-"mingw", "gcc:-mno-cygwin -DL_ENDIAN -DWIN32_LEAN_AND_MEAN -fomit-frame-pointer -O3 -march=i486 -Wall:::MINGW32:-lws2_32 -lgdi32 -lcrypt32:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts} EXPORT_VAR_AS_FN:${x86_asm}:coff:win32:cygwin-shared:-D_WINDLL -DOPENSSL_USE_APPLINK:-mno-cygwin:.dll.a",
+"mingw", "gcc:-mno-cygwin -DL_ENDIAN -DOPENSSL_NO_CAPIENG -DWIN32_LEAN_AND_MEAN -fomit-frame-pointer -O3 -march=i486 -Wall:::MINGW32:-lws2_32 -lgdi32 -lcrypt32:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts} EXPORT_VAR_AS_FN:${x86_asm}:coff:win32:cygwin-shared:-D_WINDLL -DOPENSSL_USE_APPLINK:-mno-cygwin:.dll.a",
 # As for OPENSSL_USE_APPLINK. Applink makes it possible to use .dll
 # compiled with one compiler with application compiled with another
 # compiler. It's possible to engage Applink support in mingw64 build,
@@ -584,7 +584,7 @@
 
 my @MK1MF_Builds=qw(VC-WIN64I VC-WIN64A
 		    VC-NT VC-CE VC-WIN32 debug-VC-WIN32
-		    BC-32 
+		    BC-32 mingw mingw64
 		    netware-clib netware-clib-bsdsock
 		    netware-libc netware-libc-bsdsock);
 
diff -Nru openssl-1.0.0.orig/ms/mingw64.bat openssl-1.0.0/ms/mingw64.bat
--- openssl-1.0.0.orig/ms/mingw64.bat	1970-01-01 01:00:00.000000000 +0100
+++ openssl-1.0.0/ms/mingw64.bat	2010-04-25 16:23:07.295945900 +0200
@@ -0,0 +1,90 @@
+...@rem OpenSSL with Mingw32+GNU as
+...@rem ---------------------------
+
+perl Configure mingw64 %1 %2 %3 %4 %5 %6 %7 %8
+
+...@echo off
+
+perl -e "exit 1 if '%1' eq 'no-asm'"
+if errorlevel 1 goto noasm
+
+echo Generating x86_64 for GNU assember
+
+echo Bignum
+cd crypto\bn\asm
+perl bn-586.pl gaswin > bn-win32.s
+perl co-586.pl gaswin > co-win32.s
+cd ..\..\..
+
+echo DES
+cd crypto\des\asm
+perl des-586.pl gaswin > d-win32.s
+cd ..\..\..
+
+echo crypt
+cd crypto\des\asm
+perl crypt586.pl gaswin > y-win32.s
+cd ..\..\..
+
+echo Blowfish
+cd crypto\bf\asm
+perl bf-586.pl gaswin > b-win32.s
+cd ..\..\..
+
+echo CAST5
+cd crypto\cast\asm
+perl cast-586.pl gaswin > c-win32.s
+cd ..\..\..
+
+echo RC4
+cd crypto\rc4\asm
+perl rc4-586.pl gaswin > r4-win32.s
+cd ..\..\..
+
+echo MD5
+cd crypto\md5\asm
+perl md5-586.pl gaswin > m5-win32.s
+cd ..\..\..
+
+echo SHA1
+cd crypto\sha\asm
+perl sha1-586.pl gaswin > s1-win32.s
+cd ..\..\..
+
+echo RIPEMD160
+cd crypto\ripemd\asm
+perl rmd-586.pl gaswin > rm-win32.s
+cd ..\..\..
+
+echo RC5\32
+cd crypto\rc5\asm
+perl rc5-586.pl gaswin > r5-win32.s
+cd ..\..\..
+
+:noasm
+
+echo Generating makefile
+perl util\mkfiles.pl >MINFO
+perl util\mk1mf.pl gaswin Mingw32 >ms\mingw32a.mak
+echo Generating DLL definition files
+perl util\mkdef.pl 32 libeay >ms\libeay32.def
+if errorlevel 1 goto end
+perl util\mkdef.pl 32 ssleay >ms\ssleay32.def
+if errorlevel 1 goto end
+
+rem copy ms\tlhelp32.h outinc
+
+echo Building the libraries
+mingw32-make -f ms/mingw32a.mak
+if errorlevel 1 goto end
+
+echo Generating the DLLs and input libraries
+dllwrap --dllname libeay32.dll --output-lib out/libeay32.a --def ms/libeay32.def out/libcrypto.a -lws2_32 -lgdi32
+if errorlevel 1 goto end
+dllwrap --dllname libssl32.dll --output-lib out/libssl32.a --def ms/ssleay32.def out/libssl.a out/libeay32.a
+if errorlevel 1 goto end
+
+echo Done compiling OpenSSL
+
+:end
+
diff -Nru openssl-1.0.0.orig/util/pl/Mingw32.pl openssl-1.0.0/util/pl/Mingw32.pl
--- openssl-1.0.0.orig/util/pl/Mingw32.pl	2008-04-17 12:19:16.000000000 +0200
+++ openssl-1.0.0/util/pl/Mingw32.pl	2010-04-25 16:23:07.307946600 +0200
@@ -19,7 +19,7 @@
 if ($debug)
 	{ $cflags="-DL_ENDIAN -DDSO_WIN32 -g2 -ggdb"; }
 else
-	{ $cflags="-DL_ENDIAN -DDSO_WIN32 -fomit-frame-pointer -O3 -mcpu=i486 -Wall"; }
+	{ $cflags="-DL_ENDIAN -DDSO_WIN32 -fomit-frame-pointer -O3 -march=i486 -Wall"; }
 
 if ($gaswin and !$no_asm)
 	{
--- openssl-1.0.0.orig/crypto/buffer/buffer.h	Mon Jan 19 23:26:36 1970
+++ openssl-1.0.0/crypto/buffer/buffer.h	Mon Jan 19 23:26:36 1970
@@ -67,10 +67,6 @@
 
 #include <stddef.h>
 
-#if !defined(NO_SYS_TYPES_H)
-#include <sys/types.h>
-#endif
-
 /* Already declared in ossl_typ.h */
 /* typedef struct buf_mem_st BUF_MEM; */
 
--- openssl-1.0.0.orig/crypto/err/err.h	Mon Jan 19 23:26:36 1970
+++ openssl-1.0.0/crypto/err/err.h	Mon Jan 19 23:26:36 1970
@@ -137,8 +137,6 @@
 #define ERR_PUT_error(a,b,c,d,e)	ERR_put_error(a,b,c,NULL,0)
 #endif
 
-#include <errno.h>
-
 #define ERR_TXT_MALLOCED	0x01
 #define ERR_TXT_STRING		0x02
 
--- openssl-1.0.0.orig/include/openssl/buffer.h	Mon Jan 19 23:26:36 1970
+++ openssl-1.0.0/include/openssl/buffer.h	Mon Jan 19 23:26:36 1970
@@ -67,10 +67,6 @@
 
 #include <stddef.h>
 
-#if !defined(NO_SYS_TYPES_H)
-#include <sys/types.h>
-#endif
-
 /* Already declared in ossl_typ.h */
 /* typedef struct buf_mem_st BUF_MEM; */
 
--- openssl-1.0.0.orig/include/openssl/err.h	Mon Jan 19 23:26:36 1970
+++ openssl-1.0.0/include/openssl/err.h	Mon Jan 19 23:26:36 1970
@@ -137,8 +137,6 @@
 #define ERR_PUT_error(a,b,c,d,e)	ERR_put_error(a,b,c,NULL,0)
 #endif
 
-#include <errno.h>
-
 #define ERR_TXT_MALLOCED	0x01
 #define ERR_TXT_STRING		0x02
 
--- openssl-1.0.0.orig/engines/ccgost/gost_lcl.h	Mon Jan 19 23:26:36 1970
+++ openssl-1.0.0/engines/ccgost/gost_lcl.h	Mon Jan 19 23:26:36 1970
@@ -18,6 +18,11 @@
 #include <openssl/ec.h>
 #include "gost89.h"
 #include "gosthash.h"
+
+#if !defined(NO_SYS_TYPES_H)
+#include <sys/types.h>
+#endif
+
 /* Control commands */
 #define GOST_PARAM_CRYPT_PARAMS 0
 #define GOST_PARAM_MAX 0
diff -Nru openssl-1.0.0.orig/include/openssl/dtls1.h openssl-1.0.0/include/openssl/dtls1.h
--- openssl-1.0.0.orig/include/openssl/dtls1.h	2009-09-09 19:05:42.000000000 +0200
+++ openssl-1.0.0/include/openssl/dtls1.h	2010-04-25 16:27:01.187323700 +0200
@@ -68,7 +68,7 @@
 #endif
 #ifdef OPENSSL_SYS_WIN32
 /* Needed for struct timeval */
-#include <winsock.h>
+#include <winsock2.h>
 #elif defined(OPENSSL_SYS_NETWARE) && !defined(_WINSOCK2API_)
 #include <sys/timeval.h>
 #else
diff -Nru openssl-1.0.0.orig/ssl/dtls1.h openssl-1.0.0/ssl/dtls1.h
--- openssl-1.0.0.orig/ssl/dtls1.h	2009-09-09 19:05:42.000000000 +0200
+++ openssl-1.0.0/ssl/dtls1.h	2010-04-25 16:26:18.163862900 +0200
@@ -68,7 +68,7 @@
 #endif
 #ifdef OPENSSL_SYS_WIN32
 /* Needed for struct timeval */
-#include <winsock.h>
+#include <winsock2.h>
 #elif defined(OPENSSL_SYS_NETWARE) && !defined(_WINSOCK2API_)
 #include <sys/timeval.h>
 #else
diff -Nru openssl-1.0.0.orig/ssl/ssltest.c openssl-1.0.0/ssl/ssltest.c
--- openssl-1.0.0.orig/ssl/ssltest.c	2010-01-24 17:57:38.000000000 +0100
+++ openssl-1.0.0/ssl/ssltest.c	2010-04-25 16:26:51.252755500 +0200
@@ -190,7 +190,7 @@
 				  */
 
 #ifdef OPENSSL_SYS_WINDOWS
-#include <winsock.h>
+#include <winsock2.h>
 #else
 #include OPENSSL_UNISTD
 #endif

Attachment: signature.asc
Description: PGP signature

Reply via email to