diff -ur openssl-1.0.1g.orig/util/mk1mf.pl openssl-1.0.1g.patched/util/mk1mf.pl
--- openssl-1.0.1g.orig/util/mk1mf.pl	2014-03-17 18:14:20.000000000 +0200
+++ openssl-1.0.1g.patched/util/mk1mf.pl	2014-04-16 12:09:10.642127200 +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-gmp" => 0,
 		"no-rfc3779" => 0,
diff -ur openssl-1.0.1g.orig/util/mkdef.pl openssl-1.0.1g.patched/util/mkdef.pl
--- openssl-1.0.1g.orig/util/mkdef.pl	2014-03-17 18:14:20.000000000 +0200
+++ openssl-1.0.1g.patched/util/mkdef.pl	2014-04-16 12:09:10.645127200 +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";
@@ -146,6 +148,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") {
@@ -178,6 +182,7 @@
 		$do_crypto=1;
 		$libname=$_;
 	}
+
 	$no_static_engine=1 if $_ eq "no-static-engine";
 	$no_static_engine=0 if $_ eq "enable-static-engine";
 	$do_update=1 if $_ eq "update";
@@ -247,6 +252,7 @@
 	}
 }
 
+	
 # If no platform is given, assume WIN32
 if ($W32 + $W16 + $VMS + $OS2 == 0) {
 	$W32 = 1;
@@ -1300,6 +1306,19 @@
 		  # Vendor field can't contain colon, drat; so we omit http://
 		  $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";
 ;
diff -ur openssl-1.0.1g.orig/util/pl/VC-32.pl openssl-1.0.1g.patched/util/pl/VC-32.pl
--- openssl-1.0.1g.orig/util/pl/VC-32.pl	2014-03-17 18:14:20.000000000 +0200
+++ openssl-1.0.1g.patched/util/pl/VC-32.pl	2014-04-16 12:09:10.648127200 +0300
@@ -15,6 +15,21 @@
 	{
 	$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 +166,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 +356,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)
 		{
Only in openssl-1.0.1g.patched/util/pl: VC-32.pl.orig
