Add version info to Win32 DLLs.
[openssl.git] / util / pl / VC-32.pl
1 #!/usr/local/bin/perl
2 # VCw32lib.pl - the file for Visual C++ 4.[01] for windows NT, static libraries
3 #
4
5 $ssl=   "ssleay32";
6 $crypto="libeay32";
7
8 $o='\\';
9 $cp='copy nul+';        # Timestamps get stuffed otherwise
10 $rm='del';
11
12 # C compiler stuff
13 $cc='cl';
14 $cflags=' /MD /W3 /WX /G5 /Ox /O2 /Ob2 /Gs0 /GF /Gy /nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32';
15 $lflags="/nologo /subsystem:console /machine:I386 /opt:ref";
16 $mlflags='';
17
18 $out_def="out32";
19 $tmp_def="tmp32";
20 $inc_def="inc32";
21
22 if ($debug)
23         {
24         $cflags=" /MDd /W3 /WX /Zi /Yd /Od /nologo -DOPENSSL_SYSNAME_WIN32 -D_DEBUG -DL_ENDIAN -DWIN32_LEAN_AND_MEAN -DDEBUG -DDSO_WIN32";
25         $lflags.=" /debug";
26         $mlflags.=' /debug';
27         }
28 $cflags .= " -DOPENSSL_SYSNAME_WINNT" if $NT == 1;
29
30 $obj='.obj';
31 $ofile="/Fo";
32
33 # EXE linking stuff
34 $link="link";
35 $rsc="rc";
36 $efile="/out:";
37 $exep='.exe';
38 if ($no_sock)
39         { $ex_libs=""; }
40 else    { $ex_libs="wsock32.lib user32.lib gdi32.lib"; }
41
42 # static library stuff
43 $mklib='lib';
44 $ranlib='';
45 $plib="";
46 $libp=".lib";
47 $shlibp=($shlib)?".dll":".lib";
48 $lfile='/out:';
49
50 $shlib_ex_obj="";
51 $app_ex_obj="setargv.obj";
52 if ($nasm) {
53         $asm='nasmw -f win32';
54         $afile='-o ';
55 } else {
56         $asm='ml /Cp /coff /c /Cx';
57         $asm.=" /Zi" if $debug;
58         $afile='/Fo';
59 }
60
61 $bn_asm_obj='';
62 $bn_asm_src='';
63 $des_enc_obj='';
64 $des_enc_src='';
65 $bf_enc_obj='';
66 $bf_enc_src='';
67
68 if (!$no_asm)
69         {
70         $bn_asm_obj='crypto\bn\asm\bn_win32.obj';
71         $bn_asm_src='crypto\bn\asm\bn_win32.asm';
72         $des_enc_obj='crypto\des\asm\d_win32.obj crypto\des\asm\y_win32.obj';
73         $des_enc_src='crypto\des\asm\d_win32.asm crypto\des\asm\y_win32.asm';
74         $bf_enc_obj='crypto\bf\asm\b_win32.obj';
75         $bf_enc_src='crypto\bf\asm\b_win32.asm';
76         $cast_enc_obj='crypto\cast\asm\c_win32.obj';
77         $cast_enc_src='crypto\cast\asm\c_win32.asm';
78         $rc4_enc_obj='crypto\rc4\asm\r4_win32.obj';
79         $rc4_enc_src='crypto\rc4\asm\r4_win32.asm';
80         $rc5_enc_obj='crypto\rc5\asm\r5_win32.obj';
81         $rc5_enc_src='crypto\rc5\asm\r5_win32.asm';
82         $md5_asm_obj='crypto\md5\asm\m5_win32.obj';
83         $md5_asm_src='crypto\md5\asm\m5_win32.asm';
84         $sha1_asm_obj='crypto\sha\asm\s1_win32.obj';
85         $sha1_asm_src='crypto\sha\asm\s1_win32.asm';
86         $rmd160_asm_obj='crypto\ripemd\asm\rm_win32.obj';
87         $rmd160_asm_src='crypto\ripemd\asm\rm_win32.asm';
88         $cflags.=" -DBN_ASM -DMD5_ASM -DSHA1_ASM -DRMD160_ASM";
89         }
90
91 if ($shlib)
92         {
93         $mlflags.=" $lflags /dll";
94 #       $cflags =~ s| /MD| /MT|;
95         $lib_cflag=" -D_WINDLL -D_DLL";
96         $out_def="out32dll";
97         $tmp_def="tmp32dll";
98         }
99
100 $cflags.=" /Fd$out_def";
101
102 sub do_lib_rule
103         {
104         local($objs,$target,$name,$shlib)=@_;
105         local($ret,$Name);
106
107         $taget =~ s/\//$o/g if $o ne '/';
108         ($Name=$name) =~ tr/a-z/A-Z/;
109
110 #       $target="\$(LIB_D)$o$target";
111         $ret.="$target: $objs\n";
112         if (!$shlib)
113                 {
114 #               $ret.="\t\$(RM) \$(O_$Name)\n";
115                 $ex =' advapi32.lib';
116                 $ret.="\t\$(MKLIB) $lfile$target @<<\n  $objs $ex\n<<\n";
117                 }
118         else
119                 {
120                 local($ex)=($target =~ /O_SSL/)?' $(L_CRYPTO)':'';
121                 $ex.=' wsock32.lib gdi32.lib advapi32.lib';
122                 $ret.="\t\$(LINK) \$(MLFLAGS) $efile$target /def:ms/${Name}.def @<<\n  \$(SHLIB_EX_OBJ) $objs $ex\n<<\n";
123                 }
124         $ret.="\n";
125         return($ret);
126         }
127
128 sub do_link_rule
129         {
130         local($target,$files,$dep_libs,$libs)=@_;
131         local($ret,$_);
132         
133         $file =~ s/\//$o/g if $o ne '/';
134         $n=&bname($targer);
135         $ret.="$target: $files $dep_libs\n";
136         $ret.="  \$(LINK) \$(LFLAGS) $efile$target @<<\n";
137         $ret.="  \$(APP_EX_OBJ) $files $libs\n<<\n\n";
138         return($ret);
139         }
140
141 1;