Sometimes, we have partial comments on the same line as other stuff we
[openssl.git] / util / pl / VC-16.pl
1 #!/usr/local/bin/perl
2 # VCw16lib.pl - the file for Visual C++ 1.52b for windows, static libraries
3 #
4
5 $ssl=   "ssleay16";
6 $crypto="libeay16";
7
8 $o='\\';
9 $cp='copy';
10 $rm='del';
11
12 # C compiler stuff
13 $cc='cl';
14
15 $out_def="out16";
16 $tmp_def="tmp16";
17 $inc_def="inc16";
18
19 if ($debug)
20         {
21         $op="/Od /Zi /Zd";
22         $base_lflags="/CO";
23         }
24 else    {
25         $op="/G2 /f- /Ocgnotb2";
26         }
27 $base_lflags.=" /FARCALL /NOLOGO /NOD /SEG:1024 /ONERROR:NOEXE /NOE /PACKC:60000";
28 if ($win16) { $base_lflags.=" /PACKD:60000"; }
29
30 $cflags="/ALw /Gx- /Gt256 /Gf $op /W3 /WX -DL_ENDIAN /nologo";
31 # I add the stack opt
32 $lflags="$base_lflags /STACK:20000";
33
34 if ($win16)
35         {
36         $cflags.=" -DOPENSSL_SYSNAME_WIN16";
37         $app_cflag="/Gw /FPi87";
38         $lib_cflag="/Gw";
39         $lib_cflag.=" -D_WINDLL -D_DLL" if $shlib;
40         $lib_cflag.=" -DWIN16TTY" if !$shlib;
41         $lflags.=" /ALIGN:256";
42         $ex_libs.="oldnames llibcewq libw";
43         }
44 else
45         {
46         $no_sock=1;
47         $cflags.=" -DOPENSSL_SYSNAME_MSDOS";
48         $lflags.=" /EXEPACK";
49         $ex_libs.="oldnames.lib llibce.lib";
50         }
51
52 if ($shlib)
53         {
54         $mlflags="$base_lflags";
55         $libs="oldnames ldllcew libw";
56         $shlib_ex_obj="";
57 #       $no_asm=1;
58         $out_def="out16dll";
59         $tmp_def="tmp16dll";
60         }
61 else
62         { $mlflags=''; }
63
64 $app_ex_obj="setargv.obj";
65
66 $obj='.obj';
67 $ofile="/Fo";
68
69 # EXE linking stuff
70 $link="link";
71 $efile="";
72 $exep='.exe';
73 $ex_libs.=$no_sock?"":" winsock";
74
75 # static library stuff
76 $mklib='lib /PAGESIZE:1024';
77 $ranlib='';
78 $plib="";
79 $libp=".lib";
80 $shlibp=($shlib)?".dll":".lib";
81 $lfile='';
82
83 $asm='ml /Cp /c /Cx';
84 $afile='/Fo';
85
86 $bn_asm_obj='';
87 $bn_asm_src='';
88 $des_enc_obj='';
89 $des_enc_src='';
90 $bf_enc_obj='';
91 $bf_enc_src='';
92
93 if (!$no_asm)
94         {
95         if ($asmbits == 32)
96                 {
97                 $bn_asm_obj='crypto\bn\asm\x86w32.obj';
98                 $bn_asm_src='crypto\bn\asm\x86w32.asm';
99                 }
100         else
101                 {
102                 $bn_asm_obj='crypto\bn\asm\x86w16.obj';
103                 $bn_asm_src='crypto\bn\asm\x86w16.asm';
104                 }
105         }
106
107 sub do_lib_rule
108         {
109         local($objs,$target,$name,$shlib)=@_;
110         local($ret,$Name);
111
112         $taget =~ s/\//$o/g if $o ne '/';
113         ($Name=$name) =~ tr/a-z/A-Z/;
114
115 #       $target="\$(LIB_D)$o$target";
116         $ret.="$target: $objs\n";
117 #       $ret.="\t\$(RM) \$(O_$Name)\n";
118
119         # Due to a pathetic line length limit, I unwrap the args.
120         local($lib_names)="";
121         local($dll_names)="  \$(SHLIB_EX_OBJ) +\n";
122         ($obj)= ($objs =~ /\((.*)\)/);
123         foreach $_ (sort split(/\s+/,$Vars{$obj}))
124                 {
125                 $lib_names.="+$_ &\n";
126                 $dll_names.="  $_ +\n";
127                 }
128
129         if (!$shlib)
130                 {
131                 $ret.="\tdel $target\n";
132                 $ret.="\t\$(MKLIB) @<<\n$target\ny\n$lib_names\n\n<<\n";
133                 }
134         else
135                 {
136                 local($ex)=($target =~ /O_SSL/)?'$(L_CRYPTO)':"";
137                 $ex.=' winsock';
138                 $ret.="\t\$(LINK) \$(MLFLAGS) @<<\n";
139                 $ret.=$dll_names;
140                 $ret.="\n  $target\n\n  $ex $libs\nms$o${name}.def;\n<<\n";
141                 ($out_lib=$target) =~ s/O_/L_/;
142                 $ret.="\timplib /noignorecase /nowep $out_lib $target\n";
143                 }
144         $ret.="\n";
145         return($ret);
146         }
147
148 sub do_link_rule
149         {
150         local($target,$files,$dep_libs,$libs)=@_;
151         local($ret,$f,$_,@f);
152         
153         $file =~ s/\//$o/g if $o ne '/';
154         $n=&bname($targer);
155         $ret.="$target: $files $dep_libs\n";
156         $ret.="  \$(LINK) \$(LFLAGS) @<<\n";
157         
158         # Due to a pathetic line length limit, I have to unwrap the args.
159         if ($files =~ /\(([^)]*)\)$/)
160                 {
161                 @a=('$(APP_EX_OBJ)');
162                 push(@a,sort split(/\s+/,$Vars{$1}));
163                 for $_ (@a)
164                         { $ret.="  $_ +\n"; }
165                 }
166         else
167                 { $ret.="  \$(APP_EX_OBJ) $files"; }
168         $ret.="\n  $target\n\n  $libs\n\n<<\n\n";
169         return($ret);
170         }
171
172 1;