--- openssl-1.0.0.orig/ms/mingw32-cross.sh	1970-01-01 01:00:00.000000000 +0100
+++ openssl-1.0.0/ms/mingw32-cross.sh	2010-04-10 10:22:33.000000000 +0200
@@ -0,0 +1,37 @@
+#!/bin/sh
+# Mingw32 on Linux + GNU as
+# ---------------------------
+
+set -e
+
+CROSS=i586-mingw32msvc-
+
+sh ./Configure mingw $@
+
+echo Generating makefile
+perl util/mkfiles.pl >MINFO
+perl util/mk1mf.pl gaswin $@ Mingw32-cross >ms/mingw32-cross.mak
+
+echo Generating DLL definition files
+perl util/mkdef.pl 32 libeay >ms/libeay32.def
+perl util/mkdef.pl 32 ssleay >ms/ssleay32.def
+
+echo Building the libraries
+make -f ms/mingw32-cross.mak CROSS=${CROSS}
+
+echo Generating the DLLs and input libraries
+${CROSS}dllwrap --dllname libeay32.dll --output-lib out/libeay32.a --def ms/libeay32.def out/libcrypto.a -lwsock32 -lgdi32
+
+${CROSS}dllwrap --dllname libssl32.dll --output-lib out/libssl32.a --def ms/ssleay32.def out/libssl.a out/libeay32.a
+
+echo "Done compiling OpenSSL"
+
+if test -n "${INSTALL_DIR}"; then
+  echo "Installing OpenSSL to '${INSTALL_DIR}'"
+  mkdir -p ${INSTALL_DIR}/bin ${INSTALL_DIR}/lib ${INSTALL_DIR}/include
+  cp -r outinc/openssl ${INSTALL_DIR}/include
+  cp *.dll ${INSTALL_DIR}/bin
+  cp out/*.a ${INSTALL_DIR}/lib
+fi
+
+
--- openssl-1.0.0.orig/util/mk1mf.pl	2009-09-20 14:47:04.000000000 +0200
+++ openssl-1.0.0/util/mk1mf.pl	2010-04-10 09:28:56.000000000 +0200
@@ -67,6 +67,7 @@
 	"VC-CE",   "Microsoft eMbedded Visual C++ 3.0 - Windows CE ONLY",
 	"VC-NT",   "Microsoft Visual C++ [4-6] - Windows NT ONLY",
 	"Mingw32", "GNU C++ - Windows NT or 9x",
+	"Mingw32-cross", "GNU C++ Linux cross compiling",
 	"Mingw32-files", "Create files with DOS copy ...",
 	"BC-NT",   "Borland C++ 4.5 - Windows NT",
 	"linux-elf","Linux elf",
@@ -181,6 +182,10 @@
 	{
 	require 'Mingw32.pl';
 	}
+elsif ($platform eq "Mingw32-cross")
+	{
+	require 'Mingw32-cross.pl';
+	}
 elsif ($platform eq "Mingw32-files")
 	{
 	require 'Mingw32f.pl';
--- openssl-1.0.0.orig/util/pl/Mingw32-cross.pl	1970-01-01 01:00:00.000000000 +0100
+++ openssl-1.0.0/util/pl/Mingw32-cross.pl	2010-04-10 10:24:35.000000000 +0200
@@ -0,0 +1,74 @@
+#!/usr/local/bin/perl
+#
+# Mingw32.pl -- Mingw
+#
+
+$o='/';
+$cp='cp';
+$rm='rm -f';
+$mkdir='mkdir -p';
+
+# C compiler stuff
+
+$asmtype="gaswin";
+
+$cc='$(CROSS)gcc';
+if ($debug)
+	{ $cflags="-DL_ENDIAN -DDSO_WIN32 -g2 -ggdb"; }
+else
+	{ $cflags="-DL_ENDIAN -DDSO_WIN32 -fomit-frame-pointer -O3 -march=i686 -Wall"; }
+
+if ($gaswin and !$no_asm)
+	{ $cflags.=" -DBN_ASM -DMD5_ASM -DSHA1_ASM -DOPENSSL_BN_ASM_PART_WORDS"; }
+
+
+$obj='.o';
+$ofile='-o ';
+
+# EXE linking stuff
+$link='${CC}';
+$lflags='${CFLAGS}';
+$efile='-o ';
+$exep='.exe';
+$ex_libs="-lwsock32 -lgdi32";
+
+# static library stuff
+$mklib='$(CROSS)ar r';
+$mlflags='';
+$ranlib='$(CROSS)ranlib';
+$plib='lib';
+$libp=".a";
+$shlibp=".a";
+$lfile='';
+
+$asm='$(CROSS)as';
+$afile='-o ';
+
+
+sub do_lib_rule
+	{
+	local($obj,$target,$name,$shlib)=@_;
+	local($ret,$_,$Name);
+
+	$target =~ s/\//$o/g if $o ne '/';
+	$target="$target";
+	($Name=$name) =~ tr/a-z/A-Z/;
+
+	$ret.="$target: \$(${Name}OBJ)\n";
+	$ret.="\trm -f $target\n";
+	$ret.="\t\$(MKLIB) $target \$(${Name}OBJ)\n";
+	$ret.="\t\$(RANLIB) $target\n\n";
+	}
+
+sub do_link_rule
+	{
+	local($target,$files,$dep_libs,$libs)=@_;
+	local($ret,$_);
+
+	$file =~ s/\//$o/g if $o ne '/';
+	$n=&bname($target);
+	$ret.="$target: $files $dep_libs\n";
+	$ret.="\t\$(LINK) ${efile}$target \$(LFLAGS) $files $libs\n\n";
+	return($ret);
+	}
+1;
