Hi all OpenSSL users on Windows

With the VC6 compiler you have the option of linking the ssl libs against the 
static C runtime libraries (instead of the MSVCRT.dll). 

If you link your application (or dll) against such statically linked ssl libs, 
your application (or dll) contains all that it needs and you don't have to 
distribute any dll's at all with your application.

The downside, of course: your application could get bigger... (My dll grows 
from 588kb to 768kb)


The appended patch introduces the option "staticrt" to util/mk1mf.pl, expands 
the output path (eg out32_static.dbg) if necessary and sets the correct 
compiler switches (/MT[d] or /MD[d]) in util/pl/VC-32.pl.
It also uses the new switch in ms/do_masm.bat to generate the appropriate 
makefiles.

It works for me. That is about all the guarantee I can give because I do not 
understand the openssl configuration well enough to spot all blunders I might 
have made. There is for example a line in util/mk1mf.pl which reads: "Don't 
touch anything below this point". I violated this because I couldn't see 
another way to introduce the "staticrt" parameter to the read_options sub! 
Enlightment, anyone?

If there's enough demand for this, some core developer might even put this into 
the next relase!

Here comes the patch for all those of you who want to try my version anyway: 
(also as attachment)


diff -urN openssl-0.9.5/ms/do_masm.bat openssl-0.9.5.work/ms/do_masm.bat
--- openssl-0.9.5/ms/do_masm.bat        Tue Jul 13 02:35:10 1999
+++ openssl-0.9.5.work/ms/do_masm.bat   Fri Mar 10 11:40:29 2000
@@ -61,6 +61,12 @@
 perl util\mk1mf.pl dll VC-W31-32 >ms\w31dll.mak
 perl util\mk1mf.pl VC-WIN32 >ms\nt.mak
 perl util\mk1mf.pl dll VC-WIN32 >ms\ntdll.mak
+perl util\mk1mf.pl debug VC-WIN32 >ms\ntD.mak
+perl util\mk1mf.pl debug dll VC-WIN32 >ms\ntdllD.mak
+perl util\mk1mf.pl staticrt VC-WIN32 >ms\ntS.mak
+perl util\mk1mf.pl staticrt debug VC-WIN32 >ms\ntSD.mak
+rem perl util\mk1mf.pl staticrt dll VC-WIN32 >ms\ntdllS.mak
+rem perl util\mk1mf.pl staticrt debug dll VC-WIN32 >ms\ntdllSD.mak
 
 perl util\mkdef.pl 16 libeay > ms\libeay16.def
 perl util\mkdef.pl 32 libeay > ms\libeay32.def
diff -urN openssl-0.9.5/util/mk1mf.pl openssl-0.9.5.work/util/mk1mf.pl
--- openssl-0.9.5/util/mk1mf.pl Thu Aug 05 03:11:06 1999
+++ openssl-0.9.5.work/util/mk1mf.pl    Fri Mar 10 11:34:14 2000
@@ -187,8 +187,8 @@
        $cflags.=' -DTERMIO';
        }
 
-$out_dir=(defined($VARS{'OUT'}))?$VARS{'OUT'}:$out_def.($debug?".dbg":"");
-$tmp_dir=(defined($VARS{'TMP'}))?$VARS{'TMP'}:$tmp_def.($debug?".dbg":"");
+$out_dir=(defined($VARS{'OUT'}))?$VARS{'OUT'}:$out_def.($staticrt?"_static":"")
.($debug?".dbg":"");
+$tmp_dir=(defined($VARS{'TMP'}))?$VARS{'TMP'}:$tmp_def.($staticrt?"_static":"")
.($debug?".dbg":"");
 $inc_dir=(defined($VARS{'INC'}))?$VARS{'INC'}:$inc_def;
 
 $bin_dir=$bin_dir.$o unless ((substr($bin_dir,-1,1) eq $o) || ($bin_dir eq 
''));
@@ -862,6 +862,7 @@
        elsif (/^rsaref$/)      { $rsaref=1; }
        elsif (/^gcc$/)         { $gcc=1; }
        elsif (/^debug$/)       { $debug=1; }
+       elsif (/^staticrt$/){ $staticrt=1; }
        elsif (/^shlib$/)       { $shlib=1; }
        elsif (/^dll$/)         { $shlib=1; }
        elsif (/^([^=]*)=(.*)$/){ $VARS{$1}=$2; }
diff -urN openssl-0.9.5/util/pl/VC-32.pl openssl-0.9.5.work/util/pl/VC-32.pl
--- openssl-0.9.5/util/pl/VC-32.pl      Thu Aug 12 13:03:06 1999
+++ openssl-0.9.5.work/util/pl/VC-32.pl Fri Mar 10 11:34:12 2000
@@ -12,7 +12,8 @@
 
 # C compiler stuff
 $cc='cl';
-$cflags=' /MD /W3 /WX /G5 /Ox /O2 /Ob2 /Gs0 /GF /Gy /nologo -DWIN32 
-DWIN32_LEAN_AND_MEAN -DL_ENDIAN';
+$cflags=' /W3 /WX /G5 /Ox /O2 /Ob2 /Gs0 /GF /Gy /nologo -DWIN32 
-DWIN32_LEAN_AND_MEAN -DL_ENDIAN';
+$cflags.= $staticrt ? " /MT" : " /MD";
 $lflags="/nologo /subsystem:console /machine:I386 /opt:ref";
 $mlflags='';
 
@@ -22,7 +23,8 @@
 
 if ($debug)
        {
-       $cflags=" /MDd /W3 /WX /Zi /Yd /Od /nologo -DWIN32 -D_DEBUG -DL_ENDIAN 
-DWIN32_LEAN_AND_MEAN -DDEBUG";
+       $cflags=" /W3 /WX /Zi /Yd /Od /nologo -DWIN32 -D_DEBUG -DL_ENDIAN 
-DWIN32_LEAN_AND_MEAN -DDEBUG";
+       $cflags.= $staticrt ? " /MTd" : " /MDd";
        $lflags.=" /debug";
        $mlflags.=' /debug';
        }

STATICRT_DIFFS.PATCH

Reply via email to