Ignore machine-check MSRs
[freebsd-src/fkvm-freebsd.git] / crypto / openssl / util / pl / VC-32.pl
blob81e92f0ad4266b137b77c819e38408bf07b8ebf3
1 #!/usr/local/bin/perl
2 # VC-32.pl - unified script for Microsoft Visual C++, covering Win32,
3 # Win64 and WinCE [follow $FLAVOR variable to trace the differences].
6 $ssl= "ssleay32";
7 $crypto="libeay32";
9 $o='\\';
10 $cp='$(PERL) util/copy.pl';
11 $mkdir='$(PERL) util/mkdir-p.pl';
12 $rm='del';
14 $zlib_lib="zlib1.lib";
16 # C compiler stuff
17 $cc='cl';
18 if ($FLAVOR =~ /WIN64/)
20 # Note that we currently don't have /WX on Win64! There is a lot of
21 # warnings, but only of two types:
23 # C4344: conversion from '__int64' to 'int/long', possible loss of data
24 # C4267: conversion from 'size_t' to 'int/long', possible loss of data
26 # Amount of latter type is minimized by aliasing strlen to function of
27 # own desing and limiting its return value to 2GB-1 (see e_os.h). As
28 # per 0.9.8 release remaining warnings were explicitly examined and
29 # considered safe to ignore.
31 $base_cflags=' /W3 /Gs0 /GF /Gy /nologo -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32 -DOPENSSL_SYSNAME_WIN32 -DOPENSSL_SYSNAME_WINNT -DUNICODE -D_UNICODE';
32 $base_cflags.=' -D_CRT_SECURE_NO_DEPRECATE'; # shut up VC8
33 $base_cflags.=' -D_CRT_NONSTDC_NO_DEPRECATE'; # shut up VC8
34 $opt_cflags=' /MD /Ox';
35 $dbg_cflags=' /MDd /Od -DDEBUG -D_DEBUG';
36 $lflags="/nologo /subsystem:console /opt:ref";
38 elsif ($FLAVOR =~ /CE/)
40 # sanity check
41 die '%OSVERSION% is not defined' if (!defined($ENV{'OSVERSION'}));
42 die '%PLATFORM% is not defined' if (!defined($ENV{'PLATFORM'}));
43 die '%TARGETCPU% is not defined' if (!defined($ENV{'TARGETCPU'}));
46 # Idea behind this is to mimic flags set by eVC++ IDE...
48 $wcevers = $ENV{'OSVERSION'}; # WCENNN
49 die '%OSVERSION% value is insane' if ($wcevers !~ /^WCE([1-9])([0-9]{2})$/);
50 $wcecdefs = "-D_WIN32_WCE=$1$2 -DUNDER_CE=$1$2"; # -D_WIN32_WCE=NNN
51 $wcelflag = "/subsystem:windowsce,$1.$2"; # ...,N.NN
53 $wceplatf = $ENV{'PLATFORM'};
54 $wceplatf =~ tr/a-z0-9 /A-Z0-9_/d;
55 $wcecdefs .= " -DWCE_PLATFORM_$wceplatf";
57 $wcetgt = $ENV{'TARGETCPU'}; # just shorter name...
58 SWITCH: for($wcetgt) {
59 /^X86/ && do { $wcecdefs.=" -Dx86 -D_X86_ -D_i386_ -Di_386_";
60 $wcelflag.=" /machine:IX86"; last; };
61 /^ARMV4[IT]/ && do { $wcecdefs.=" -DARM -D_ARM_ -D$wcetgt";
62 $wcecdefs.=" -DTHUMB -D_THUMB_" if($wcetgt=~/T$/);
63 $wcecdefs.=" -QRarch4T -QRinterwork-return";
64 $wcelflag.=" /machine:THUMB"; last; };
65 /^ARM/ && do { $wcecdefs.=" -DARM -D_ARM_ -D$wcetgt";
66 $wcelflag.=" /machine:ARM"; last; };
67 /^MIPSIV/ && do { $wcecdefs.=" -DMIPS -D_MIPS_ -DR4000 -D$wcetgt";
68 $wcecdefs.=" -D_MIPS64 -QMmips4 -QMn32";
69 $wcelflag.=" /machine:MIPSFPU"; last; };
70 /^MIPS16/ && do { $wcecdefs.=" -DMIPS -D_MIPS_ -DR4000 -D$wcetgt";
71 $wcecdefs.=" -DMIPSII -QMmips16";
72 $wcelflag.=" /machine:MIPS16"; last; };
73 /^MIPSII/ && do { $wcecdefs.=" -DMIPS -D_MIPS_ -DR4000 -D$wcetgt";
74 $wcecdefs.=" -QMmips2";
75 $wcelflag.=" /machine:MIPS"; last; };
76 /^R4[0-9]{3}/ && do { $wcecdefs.=" -DMIPS -D_MIPS_ -DR4000";
77 $wcelflag.=" /machine:MIPS"; last; };
78 /^SH[0-9]/ && do { $wcecdefs.=" -D$wcetgt -D_$wcetgt_ -DSHx";
79 $wcecdefs.=" -Qsh4" if ($wcetgt =~ /^SH4/);
80 $wcelflag.=" /machine:$wcetgt"; last; };
81 { $wcecdefs.=" -D$wcetgt -D_$wcetgt_";
82 $wcelflag.=" /machine:$wcetgt"; last; };
85 $cc='$(CC)';
86 $base_cflags=' /W3 /WX /GF /Gy /nologo -DUNICODE -D_UNICODE -DOPENSSL_SYSNAME_WINCE -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32 -DNO_CHMOD -I$(WCECOMPAT)/include -DOPENSSL_SMALL_FOOTPRINT';
87 $base_cflags.=" $wcecdefs";
88 $opt_cflags=' /MC /O1i'; # optimize for space, but with intrinsics...
89 $dbg_clfags=' /MC /Od -DDEBUG -D_DEBUG';
90 $lflags="/nologo /opt:ref $wcelflag";
92 else # Win32
94 $base_cflags=' /W3 /WX /Gs0 /GF /Gy /nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32';
95 $base_cflags.=' -D_CRT_SECURE_NO_DEPRECATE'; # shut up VC8
96 $base_cflags.=' -D_CRT_NONSTDC_NO_DEPRECATE'; # shut up VC8
97 $opt_cflags=' /MD /Ox /O2 /Ob2';
98 $dbg_cflags=' /MDd /Od -DDEBUG -D_DEBUG';
99 $lflags="/nologo /subsystem:console /opt:ref";
101 $mlflags='';
103 $out_def="out32"; $out_def.='_$(TARGETCPU)' if ($FLAVOR =~ /CE/);
104 $tmp_def="tmp32"; $tmp_def.='_$(TARGETCPU)' if ($FLAVOR =~ /CE/);
105 $inc_def="inc32";
107 if ($debug)
109 $cflags=$dbg_cflags.$base_cflags;
110 $lflags.=" /debug";
111 $mlflags.=' /debug';
113 else
115 $cflags=$opt_cflags.$base_cflags;
118 $obj='.obj';
119 $ofile="/Fo";
121 # EXE linking stuff
122 $link="link";
123 $rsc="rc";
124 $efile="/out:";
125 $exep='.exe';
126 if ($no_sock) { $ex_libs=''; }
127 elsif ($FLAVOR =~ /CE/) { $ex_libs='winsock.lib'; }
128 else { $ex_libs='wsock32.lib'; }
130 if ($FLAVOR =~ /CE/)
132 $ex_libs.=' $(WCECOMPAT)/lib/wcecompatex.lib';
133 $ex_libs.=' /nodefaultlib:oldnames.lib coredll.lib corelibc.lib' if ($ENV{'TARGETCPU'} eq "X86");
135 else
137 $ex_libs.=' gdi32.lib advapi32.lib user32.lib';
138 $ex_libs.=' bufferoverflowu.lib' if ($FLAVOR =~ /WIN64/);
141 # As native NT API is pure UNICODE, our WIN-NT build defaults to UNICODE,
142 # but gets linked with unicows.lib to ensure backward compatibility.
143 if ($FLAVOR =~ /NT/)
145 $cflags.=" -DOPENSSL_SYSNAME_WINNT -DUNICODE -D_UNICODE";
146 $ex_libs="unicows.lib $ex_libs";
148 # static library stuff
149 $mklib='lib';
150 $ranlib='';
151 $plib="";
152 $libp=".lib";
153 $shlibp=($shlib)?".dll":".lib";
154 $lfile='/out:';
156 $shlib_ex_obj="";
157 $app_ex_obj="setargv.obj" if ($FLAVOR !~ /CE/);
158 if ($nasm) {
159 $asm='nasmw -f win32';
160 $afile='-o ';
161 } else {
162 $asm='ml /Cp /coff /c /Cx';
163 $asm.=" /Zi" if $debug;
164 $afile='/Fo';
167 $bn_asm_obj='';
168 $bn_asm_src='';
169 $des_enc_obj='';
170 $des_enc_src='';
171 $bf_enc_obj='';
172 $bf_enc_src='';
174 if (!$no_asm)
176 $bn_asm_obj='crypto\bn\asm\bn_win32.obj';
177 $bn_asm_src='crypto\bn\asm\bn_win32.asm';
178 $des_enc_obj='crypto\des\asm\d_win32.obj crypto\des\asm\y_win32.obj';
179 $des_enc_src='crypto\des\asm\d_win32.asm crypto\des\asm\y_win32.asm';
180 $bf_enc_obj='crypto\bf\asm\b_win32.obj';
181 $bf_enc_src='crypto\bf\asm\b_win32.asm';
182 $cast_enc_obj='crypto\cast\asm\c_win32.obj';
183 $cast_enc_src='crypto\cast\asm\c_win32.asm';
184 $rc4_enc_obj='crypto\rc4\asm\r4_win32.obj';
185 $rc4_enc_src='crypto\rc4\asm\r4_win32.asm';
186 $rc5_enc_obj='crypto\rc5\asm\r5_win32.obj';
187 $rc5_enc_src='crypto\rc5\asm\r5_win32.asm';
188 $md5_asm_obj='crypto\md5\asm\m5_win32.obj';
189 $md5_asm_src='crypto\md5\asm\m5_win32.asm';
190 $sha1_asm_obj='crypto\sha\asm\s1_win32.obj';
191 $sha1_asm_src='crypto\sha\asm\s1_win32.asm';
192 $rmd160_asm_obj='crypto\ripemd\asm\rm_win32.obj';
193 $rmd160_asm_src='crypto\ripemd\asm\rm_win32.asm';
194 $cflags.=" -DBN_ASM -DMD5_ASM -DSHA1_ASM -DRMD160_ASM";
197 if ($shlib && $FLAVOR !~ /CE/)
199 $mlflags.=" $lflags /dll";
200 # $cflags =~ s| /MD| /MT|;
201 $lib_cflag=" -D_WINDLL";
202 $out_def="out32dll";
203 $tmp_def="tmp32dll";
205 # Engage Applink...
207 $app_ex_obj.=" \$(OBJ_D)\\applink.obj /implib:\$(TMP_D)\\junk.lib";
208 $cflags.=" -DOPENSSL_USE_APPLINK -I.";
209 # I'm open for better suggestions than overriding $banner...
210 $banner=<<'___';
211 @echo Building OpenSSL
213 $(OBJ_D)\applink.obj: ms\applink.c
214 $(CC) /Fo$(OBJ_D)\applink.obj $(APP_CFLAGS) -c ms\applink.c
215 $(OBJ_D)\uplink.obj: ms\uplink.c ms\applink.c
216 $(CC) /Fo$(OBJ_D)\uplink.obj $(SHLIB_CFLAGS) -c ms\uplink.c
217 $(INCO_D)\applink.c: ms\applink.c
218 $(CP) ms\applink.c $(INCO_D)\applink.c
220 EXHEADER= $(EXHEADER) $(INCO_D)\applink.c
222 LIBS_DEP=$(LIBS_DEP) $(OBJ_D)\applink.obj
223 CRYPTOOBJ=$(OBJ_D)\uplink.obj $(CRYPTOOBJ)
225 $banner.=<<'___' if ($FLAVOR =~ /WIN64/);
226 CRYPTOOBJ=ms\uptable.obj $(CRYPTOOBJ)
229 elsif ($shlib && $FLAVOR =~ /CE/)
231 $mlflags.=" $lflags /dll";
232 $lib_cflag=" -D_WINDLL -D_DLL";
233 $out_def='out32dll_$(TARGETCPU)';
234 $tmp_def='tmp32dll_$(TARGETCPU)';
237 $cflags.=" /Fd$out_def";
239 sub do_lib_rule
241 local($objs,$target,$name,$shlib)=@_;
242 local($ret);
244 $taget =~ s/\//$o/g if $o ne '/';
245 if ($name ne "")
247 $name =~ tr/a-z/A-Z/;
248 $name = "/def:ms/${name}.def";
251 # $target="\$(LIB_D)$o$target";
252 $ret.="$target: $objs\n";
253 if (!$shlib)
255 # $ret.="\t\$(RM) \$(O_$Name)\n";
256 $ex =' ';
257 $ret.="\t\$(MKLIB) $lfile$target @<<\n $objs $ex\n<<\n";
259 else
261 local($ex)=($target =~ /O_CRYPTO/)?'':' $(L_CRYPTO)';
262 if ($name eq "")
264 $ex.=' bufferoverflowu.lib' if ($FLAVOR =~ /WIN64/);
266 elsif ($FLAVOR =~ /CE/)
268 $ex.=' winsock.lib $(WCECOMPAT)/lib/wcecompatex.lib';
270 else
272 $ex.=' unicows.lib' if ($FLAVOR =~ /NT/);
273 $ex.=' wsock32.lib gdi32.lib advapi32.lib user32.lib';
274 $ex.=' bufferoverflowu.lib' if ($FLAVOR =~ /WIN64/);
276 $ex.=" $zlib_lib" if $zlib_opt == 1 && $target =~ /O_CRYPTO/;
277 $ret.="\t\$(LINK) \$(MLFLAGS) $efile$target $name @<<\n \$(SHLIB_EX_OBJ) $objs $ex\n<<\n";
278 $ret.="\tIF EXIST \$@.manifest mt -manifest \$@.manifest -outputresource:\$@;2\n\n";
280 $ret.="\n";
281 return($ret);
284 sub do_link_rule
286 local($target,$files,$dep_libs,$libs)=@_;
287 local($ret,$_);
289 $file =~ s/\//$o/g if $o ne '/';
290 $n=&bname($targer);
291 $ret.="$target: $files $dep_libs\n";
292 $ret.="\t\$(LINK) \$(LFLAGS) $efile$target @<<\n";
293 $ret.=" \$(APP_EX_OBJ) $files $libs\n<<\n";
294 $ret.="\tIF EXIST \$@.manifest mt -manifest \$@.manifest -outputresource:\$@;1\n\n";
295 return($ret);