diff -Naur openssl-1.0.1j.orig/util/mk1mf.pl openssl-1.0.1j.patched/util/mk1mf.pl
--- openssl-1.0.1j.orig/util/mk1mf.pl	2014-10-15 15:54:01.000000000 +0300
+++ openssl-1.0.1j.patched/util/mk1mf.pl	2014-10-24 20:14:28.713867100 +0300
@@ -496,7 +496,7 @@
 # You should not need to touch anything below this point
 ######################################################
 
-E_EXE=openssl
+E_EXE=openssl$libsuffix
 SSL=$ssl
 CRYPTO=$crypto
 
@@ -1144,6 +1144,8 @@
 		"shlib" => \$shlib,
 		"dll" => \$shlib,
 		"shared" => 0,
+		"debug_lib" => \$debug_lib,
+		"static_lib" => \$static_lib,
 		"no-sctp" => 0,
 		"no-srtp" => 0,
 		"no-gmp" => 0,
diff -Naur openssl-1.0.1j.orig/util/mkdef.pl openssl-1.0.1j.patched/util/mkdef.pl
--- openssl-1.0.1j.orig/util/mkdef.pl	2014-10-15 15:54:01.000000000 +0300
+++ openssl-1.0.1j.patched/util/mkdef.pl	2014-10-24 20:16:47.001953100 +0300
@@ -55,6 +55,8 @@
 #
 
 my $debug=0;
+my $debug_lib=0;
+my $static_lib=0;
 
 my $crypto_num= "util/libeay.num";
 my $ssl_num=    "util/ssleay.num";
@@ -151,6 +153,8 @@
 foreach (@ARGV, split(/ /, $options))
 	{
 	$debug=1 if $_ eq "debug";
+	$debug_lib=1 if $_ eq "debug_lib";
+	$static_lib=1 if $_ eq "static_lib";
 	$W32=1 if $_ eq "32";
 	$W16=1 if $_ eq "16";
 	if($_ eq "NT") {
@@ -1310,6 +1314,19 @@
 		  $description = "\@#$http_vendor:$version#\@$what; DLL for library $name.  Build for EMX -Zmtd";
 		}
 
+	$libsuffix="";
+	if ($static_lib) {
+		$libsuffix="MT";
+	} else {
+		$libsuffix="MD";
+	}
+	
+	if ($debug_lib) {
+		$libsuffix=$libsuffix."d";
+	}
+		
+	$libname=$libname.$libsuffix;
+
 	print OUT <<"EOF";
 ;
 ; Definition file for the DLL version of the $name library from OpenSSL
diff -Naur openssl-1.0.1j.orig/util/pl/VC-32.pl openssl-1.0.1j.patched/util/pl/VC-32.pl
--- openssl-1.0.1j.orig/util/pl/VC-32.pl	2014-10-15 15:53:39.000000000 +0300
+++ openssl-1.0.1j.patched/util/pl/VC-32.pl	2014-10-24 20:18:46.994140600 +0300
@@ -15,6 +15,20 @@
 	{
 	$crypto="libeay32";
 	}
+	
+$libsuffix="";
+if ($static_lib) {
+	$libsuffix="MT";
+} else {
+	$libsuffix="MD";
+}
+
+if ($debug_lib) {
+	$libsuffix=$libsuffix."d";
+}
+	
+$ssl=$ssl.$libsuffix;
+$crypto=$crypto.$libsuffix;
 
 $o='\\';
 $cp='$(PERL) util/copy.pl';
@@ -151,8 +165,8 @@
 	}
 
 # generate symbols.pdb unconditionally
-$app_cflag.=" /Zi /Fd\$(TMP_D)/app";
-$lib_cflag.=" /Zi /Fd\$(TMP_D)/lib";
+$app_cflag.=" /Zi /Fd\$(TMP_D)/app".$libsuffix;
+$lib_cflag.=" /Zi /Fd\$(TMP_D)/lib".$libsuffix;
 $lflags.=" /debug";
 
 $obj='.obj';
@@ -341,7 +355,7 @@
 	my($target,$files,$dep_libs,$libs,$standalone)=@_;
 	local($ret,$_);
 	$file =~ s/\//$o/g if $o ne '/';
-	$n=&bname($targer);
+	$n=&bname($target);
 	$ret.="$target: $files $dep_libs\n";
 	if ($standalone == 1)
 		{
