Remove building with NOCRYPTO option
[minix.git] / crypto / external / bsd / openssl / dist / util / pl / VC-32.pl
blobb5979985152726aa6ca584764262756054bf007d
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 if ($fips && !$shlib)
11 $crypto="libeayfips32";
12 $crypto_compat = "libeaycompat32.lib";
14 else
16 $crypto="libeay32";
19 $o='\\';
20 $cp='$(PERL) util/copy.pl';
21 $mkdir='$(PERL) util/mkdir-p.pl';
22 $rm='del /Q';
24 $zlib_lib="zlib1.lib";
26 # Santize -L options for ms link
27 $l_flags =~ s/-L("\[^"]+")/\/libpath:$1/g;
28 $l_flags =~ s/-L(\S+)/\/libpath:$1/g;
30 my $ff = "";
32 # C compiler stuff
33 $cc='cl';
34 if ($FLAVOR =~ /WIN64/)
36 # Note that we currently don't have /WX on Win64! There is a lot of
37 # warnings, but only of two types:
39 # C4344: conversion from '__int64' to 'int/long', possible loss of data
40 # C4267: conversion from 'size_t' to 'int/long', possible loss of data
42 # Amount of latter type is minimized by aliasing strlen to function of
43 # own desing and limiting its return value to 2GB-1 (see e_os.h). As
44 # per 0.9.8 release remaining warnings were explicitly examined and
45 # considered safe to ignore.
47 $base_cflags= " $mf_cflag";
48 my $f = $shlib || $fips ?' /MD':' /MT';
49 $lib_cflag='/Zl' if (!$shlib); # remove /DEFAULTLIBs from static lib
50 $opt_cflags=$f.' /Ox';
51 $dbg_cflags=$f.'d /Od -DDEBUG -D_DEBUG';
52 $lflags="/nologo /subsystem:console /opt:ref";
54 *::perlasm_compile_target = sub {
55 my ($target,$source,$bname)=@_;
56 my $ret;
58 $bname =~ s/(.*)\.[^\.]$/$1/;
59 $ret=<<___;
60 \$(TMP_D)$o$bname.asm: $source
61 set ASM=\$(ASM)
62 \$(PERL) $source \$\@
64 $target: \$(TMP_D)$o$bname.asm
65 \$(ASM) $afile\$\@ \$(TMP_D)$o$bname.asm
67 ___
70 elsif ($FLAVOR =~ /CE/)
72 # sanity check
73 die '%OSVERSION% is not defined' if (!defined($ENV{'OSVERSION'}));
74 die '%PLATFORM% is not defined' if (!defined($ENV{'PLATFORM'}));
75 die '%TARGETCPU% is not defined' if (!defined($ENV{'TARGETCPU'}));
78 # Idea behind this is to mimic flags set by eVC++ IDE...
80 $wcevers = $ENV{'OSVERSION'}; # WCENNN
81 die '%OSVERSION% value is insane' if ($wcevers !~ /^WCE([1-9])([0-9]{2})$/);
82 $wcecdefs = "-D_WIN32_WCE=$1$2 -DUNDER_CE=$1$2"; # -D_WIN32_WCE=NNN
83 $wcelflag = "/subsystem:windowsce,$1.$2"; # ...,N.NN
85 $wceplatf = $ENV{'PLATFORM'};
86 $wceplatf =~ tr/a-z0-9 /A-Z0-9_/d;
87 $wcecdefs .= " -DWCE_PLATFORM_$wceplatf";
89 $wcetgt = $ENV{'TARGETCPU'}; # just shorter name...
90 SWITCH: for($wcetgt) {
91 /^X86/ && do { $wcecdefs.=" -Dx86 -D_X86_ -D_i386_ -Di_386_";
92 $wcelflag.=" /machine:IX86"; last; };
93 /^ARMV4[IT]/ && do { $wcecdefs.=" -DARM -D_ARM_ -D$wcetgt";
94 $wcecdefs.=" -DTHUMB -D_THUMB_" if($wcetgt=~/T$/);
95 $wcecdefs.=" -QRarch4T -QRinterwork-return";
96 $wcelflag.=" /machine:THUMB"; last; };
97 /^ARM/ && do { $wcecdefs.=" -DARM -D_ARM_ -D$wcetgt";
98 $wcelflag.=" /machine:ARM"; last; };
99 /^MIPSIV/ && do { $wcecdefs.=" -DMIPS -D_MIPS_ -DR4000 -D$wcetgt";
100 $wcecdefs.=" -D_MIPS64 -QMmips4 -QMn32";
101 $wcelflag.=" /machine:MIPSFPU"; last; };
102 /^MIPS16/ && do { $wcecdefs.=" -DMIPS -D_MIPS_ -DR4000 -D$wcetgt";
103 $wcecdefs.=" -DMIPSII -QMmips16";
104 $wcelflag.=" /machine:MIPS16"; last; };
105 /^MIPSII/ && do { $wcecdefs.=" -DMIPS -D_MIPS_ -DR4000 -D$wcetgt";
106 $wcecdefs.=" -QMmips2";
107 $wcelflag.=" /machine:MIPS"; last; };
108 /^R4[0-9]{3}/ && do { $wcecdefs.=" -DMIPS -D_MIPS_ -DR4000";
109 $wcelflag.=" /machine:MIPS"; last; };
110 /^SH[0-9]/ && do { $wcecdefs.=" -D$wcetgt -D_$wcetgt_ -DSHx";
111 $wcecdefs.=" -Qsh4" if ($wcetgt =~ /^SH4/);
112 $wcelflag.=" /machine:$wcetgt"; last; };
113 { $wcecdefs.=" -D$wcetgt -D_$wcetgt_";
114 $wcelflag.=" /machine:$wcetgt"; last; };
117 $cc='$(CC)';
118 $base_cflags=' /W3 /WX /GF /Gy /nologo -DUNICODE -D_UNICODE -DOPENSSL_SYSNAME_WINCE -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32 -DNO_CHMOD -DOPENSSL_SMALL_FOOTPRINT';
119 $base_cflags.=" $wcecdefs";
120 $base_cflags.=' -I$(WCECOMPAT)/include' if (defined($ENV{'WCECOMPAT'}));
121 $base_cflags.=' -I$(PORTSDK_LIBPATH)/../../include' if (defined($ENV{'PORTSDK_LIBPATH'}));
122 $opt_cflags=' /MC /O1i'; # optimize for space, but with intrinsics...
123 $dbg_cflags=' /MC /Od -DDEBUG -D_DEBUG';
124 $lflags="/nologo /opt:ref $wcelflag";
126 else # Win32
128 $base_cflags= " $mf_cflag";
129 my $f = $shlib || $fips ?' /MD':' /MT';
130 $lib_cflag='/Zl' if (!$shlib); # remove /DEFAULTLIBs from static lib
131 $ff = "/fixed";
132 $opt_cflags=$f.' /Ox /O2 /Ob2';
133 $dbg_cflags=$f.'d /Od -DDEBUG -D_DEBUG';
134 $lflags="/nologo /subsystem:console /opt:ref";
136 $mlflags='';
138 $out_def ="out32"; $out_def.="dll" if ($shlib);
139 $out_def.='_$(TARGETCPU)' if ($FLAVOR =~ /CE/);
140 $tmp_def ="tmp32"; $tmp_def.="dll" if ($shlib);
141 $tmp_def.='_$(TARGETCPU)' if ($FLAVOR =~ /CE/);
142 $inc_def="inc32";
144 if ($debug)
146 $cflags=$dbg_cflags.$base_cflags;
148 else
150 $cflags=$opt_cflags.$base_cflags;
153 # generate symbols.pdb unconditionally
154 $app_cflag.=" /Zi /Fd\$(TMP_D)/app";
155 $lib_cflag.=" /Zi /Fd\$(TMP_D)/lib";
156 $lflags.=" /debug";
158 $obj='.obj';
159 $asm_suffix='.asm';
160 $ofile="/Fo";
162 # EXE linking stuff
163 $link="link";
164 $rsc="rc";
165 $efile="/out:";
166 $exep='.exe';
167 if ($no_sock) { $ex_libs=''; }
168 elsif ($FLAVOR =~ /CE/) { $ex_libs='winsock.lib'; }
169 else { $ex_libs='ws2_32.lib'; }
171 if ($FLAVOR =~ /CE/)
173 $ex_libs.=' $(WCECOMPAT)/lib/wcecompatex.lib' if (defined($ENV{'WCECOMPAT'}));
174 $ex_libs.=' $(PORTSDK_LIBPATH)/portlib.lib' if (defined($ENV{'PORTSDK_LIBPATH'}));
175 $ex_libs.=' /nodefaultlib:oldnames.lib coredll.lib corelibc.lib' if ($ENV{'TARGETCPU'} eq "X86");
177 else
179 $ex_libs.=' gdi32.lib advapi32.lib crypt32.lib user32.lib';
180 $ex_libs.=' bufferoverflowu.lib' if ($FLAVOR =~ /WIN64/ and `cl 2>&1` =~ /14\.00\.4[0-9]{4}\./);
181 # WIN32 UNICODE build gets linked with unicows.lib for
182 # backward compatibility with Win9x.
183 $ex_libs="unicows.lib $ex_libs" if ($FLAVOR =~ /WIN32/ and $cflags =~ /\-DUNICODE/);
186 # static library stuff
187 $mklib='lib /nologo';
188 $ranlib='';
189 $plib="";
190 $libp=".lib";
191 $shlibp=($shlib)?".dll":".lib";
192 $lfile='/out:';
194 $shlib_ex_obj="";
195 $app_ex_obj="setargv.obj" if ($FLAVOR !~ /CE/);
196 if ($FLAVOR =~ /WIN64A/) {
197 if (`nasm -v 2>NUL` =~ /NASM version ([0-9]+\.[0-9]+)/ && $1 >= 2.0) {
198 $asm='nasm -f win64 -DNEAR -Ox -g';
199 $afile='-o ';
200 } else {
201 $asm='ml64 /c /Cp /Cx /Zi';
202 $afile='/Fo';
204 } elsif ($FLAVOR =~ /WIN64I/) {
205 $asm='ias -d debug';
206 $afile="-o ";
207 } elsif ($nasm) {
208 my $ver=`nasm -v 2>NUL`;
209 my $vew=`nasmw -v 2>NUL`;
210 # pick newest version
211 $asm=($ver ge $vew?"nasm":"nasmw")." -f win32";
212 $asmtype="win32n";
213 $afile='-o ';
214 } else {
215 $asm='ml /nologo /Cp /coff /c /Cx /Zi';
216 $afile='/Fo';
217 $asmtype="win32";
220 $bn_asm_obj='';
221 $bn_asm_src='';
222 $des_enc_obj='';
223 $des_enc_src='';
224 $bf_enc_obj='';
225 $bf_enc_src='';
227 if (!$no_asm)
229 win32_import_asm($mf_bn_asm, "bn", \$bn_asm_obj, \$bn_asm_src);
230 win32_import_asm($mf_aes_asm, "aes", \$aes_asm_obj, \$aes_asm_src);
231 win32_import_asm($mf_des_asm, "des", \$des_enc_obj, \$des_enc_src);
232 win32_import_asm($mf_bf_asm, "bf", \$bf_enc_obj, \$bf_enc_src);
233 win32_import_asm($mf_cast_asm, "cast", \$cast_enc_obj, \$cast_enc_src);
234 win32_import_asm($mf_rc4_asm, "rc4", \$rc4_enc_obj, \$rc4_enc_src);
235 win32_import_asm($mf_rc5_asm, "rc5", \$rc5_enc_obj, \$rc5_enc_src);
236 win32_import_asm($mf_md5_asm, "md5", \$md5_asm_obj, \$md5_asm_src);
237 win32_import_asm($mf_sha_asm, "sha", \$sha1_asm_obj, \$sha1_asm_src);
238 win32_import_asm($mf_rmd_asm, "ripemd", \$rmd160_asm_obj, \$rmd160_asm_src);
239 win32_import_asm($mf_wp_asm, "whrlpool", \$whirlpool_asm_obj, \$whirlpool_asm_src);
240 win32_import_asm($mf_cpuid_asm, "", \$cpuid_asm_obj, \$cpuid_asm_src);
241 $perl_asm = 1;
244 if ($shlib && $FLAVOR !~ /CE/)
246 $mlflags.=" $lflags /dll";
247 $lib_cflag.=" -D_WINDLL";
249 # Engage Applink...
251 $app_ex_obj.=" \$(OBJ_D)\\applink.obj /implib:\$(TMP_D)\\junk.lib";
252 $cflags.=" -DOPENSSL_USE_APPLINK -I.";
253 # I'm open for better suggestions than overriding $banner...
254 $banner=<<'___';
255 @echo Building OpenSSL
257 $(OBJ_D)\applink.obj: ms\applink.c
258 $(CC) /Fo$(OBJ_D)\applink.obj $(APP_CFLAGS) -c ms\applink.c
259 $(OBJ_D)\uplink.obj: ms\uplink.c ms\applink.c
260 $(CC) /Fo$(OBJ_D)\uplink.obj $(SHLIB_CFLAGS) -c ms\uplink.c
261 $(INCO_D)\applink.c: ms\applink.c
262 $(CP) ms\applink.c $(INCO_D)\applink.c
264 EXHEADER= $(EXHEADER) $(INCO_D)\applink.c
266 LIBS_DEP=$(LIBS_DEP) $(OBJ_D)\applink.obj
267 CRYPTOOBJ=$(OBJ_D)\uplink.obj $(CRYPTOOBJ)
269 $banner.=<<'___' if ($FLAVOR =~ /WIN64/);
270 CRYPTOOBJ=ms\uptable.obj $(CRYPTOOBJ)
273 elsif ($shlib && $FLAVOR =~ /CE/)
275 $mlflags.=" $lflags /dll";
276 $lflags.=' /entry:mainCRTstartup' if(defined($ENV{'PORTSDK_LIBPATH'}));
277 $lib_cflag.=" -D_WINDLL -D_DLL";
280 sub do_lib_rule
282 my($objs,$target,$name,$shlib,$ign,$base_addr) = @_;
283 local($ret);
285 $taget =~ s/\//$o/g if $o ne '/';
286 my $base_arg;
287 if ($base_addr ne "")
289 $base_arg= " /base:$base_addr";
291 else
293 $base_arg = "";
295 if ($name ne "")
297 $name =~ tr/a-z/A-Z/;
298 $name = "/def:ms/${name}.def";
301 # $target="\$(LIB_D)$o$target";
302 # $ret.="$target: $objs\n";
303 if (!$shlib)
305 # $ret.="\t\$(RM) \$(O_$Name)\n";
306 $ret.="$target: $objs\n";
307 $ret.="\t\$(MKLIB) $lfile$target @<<\n $objs\n<<\n";
309 else
311 local($ex)=($target =~ /O_CRYPTO/)?'':' $(L_CRYPTO)';
312 $ex.=" $zlib_lib" if $zlib_opt == 1 && $target =~ /O_CRYPTO/;
314 if ($fips && $target =~ /O_CRYPTO/)
316 $ret.="$target: $objs \$(PREMAIN_DSO_EXE)";
317 $ret.="\n\tSET FIPS_LINK=\$(LINK)\n";
318 $ret.="\tSET FIPS_CC=\$(CC)\n";
319 $ret.="\tSET FIPS_CC_ARGS=/Fo\$(OBJ_D)${o}fips_premain.obj \$(SHLIB_CFLAGS) -c\n";
320 $ret.="\tSET PREMAIN_DSO_EXE=\$(PREMAIN_DSO_EXE)\n";
321 $ret.="\tSET FIPS_SHA1_EXE=\$(FIPS_SHA1_EXE)\n";
322 $ret.="\tSET FIPS_TARGET=$target\n";
323 $ret.="\tSET FIPSLIB_D=\$(FIPSLIB_D)\n";
324 $ret.="\t\$(FIPSLINK) \$(MLFLAGS) $ff /map $base_arg $efile$target ";
325 $ret.="$name @<<\n \$(SHLIB_EX_OBJ) $objs \$(EX_LIBS) ";
326 $ret.="\$(OBJ_D)${o}fips_premain.obj $ex\n<<\n";
328 else
330 $ret.="$target: $objs";
331 $ret.="\n\t\$(LINK) \$(MLFLAGS) $efile$target $name @<<\n \$(SHLIB_EX_OBJ) $objs $ex \$(EX_LIBS)\n<<\n";
333 $ret.="\tIF EXIST \$@.manifest mt -nologo -manifest \$@.manifest -outputresource:\$@;2\n\n";
335 $ret.="\n";
336 return($ret);
339 sub do_link_rule
341 my($target,$files,$dep_libs,$libs,$standalone)=@_;
342 local($ret,$_);
343 $file =~ s/\//$o/g if $o ne '/';
344 $n=&bname($target);
345 $ret.="$target: $files $dep_libs\n";
346 if ($standalone == 1)
348 $ret.=" \$(LINK) \$(LFLAGS) $efile$target @<<\n\t";
349 $ret.= "\$(EX_LIBS) " if ($files =~ /O_FIPSCANISTER/ && !$fipscanisterbuild);
350 $ret.="$files $libs\n<<\n";
352 elsif ($standalone == 2)
354 $ret.="\tSET FIPS_LINK=\$(LINK)\n";
355 $ret.="\tSET FIPS_CC=\$(CC)\n";
356 $ret.="\tSET FIPS_CC_ARGS=/Fo\$(OBJ_D)${o}fips_premain.obj \$(SHLIB_CFLAGS) -c\n";
357 $ret.="\tSET PREMAIN_DSO_EXE=\n";
358 $ret.="\tSET FIPS_TARGET=$target\n";
359 $ret.="\tSET FIPS_SHA1_EXE=\$(FIPS_SHA1_EXE)\n";
360 $ret.="\tSET FIPSLIB_D=\$(FIPSLIB_D)\n";
361 $ret.="\t\$(FIPSLINK) \$(LFLAGS) $ff /map $efile$target @<<\n";
362 $ret.="\t\$(APP_EX_OBJ) $files \$(OBJ_D)${o}fips_premain.obj $libs\n<<\n";
364 else
366 $ret.="\t\$(LINK) \$(LFLAGS) $efile$target @<<\n";
367 $ret.="\t\$(APP_EX_OBJ) $files $libs\n<<\n";
369 $ret.="\tIF EXIST \$@.manifest mt -nologo -manifest \$@.manifest -outputresource:\$@;1\n\n";
370 return($ret);
373 sub win32_import_asm
375 my ($mf_var, $asm_name, $oref, $sref) = @_;
376 my $asm_dir;
377 if ($asm_name eq "")
379 $asm_dir = "crypto\\";
381 else
383 $asm_dir = "crypto\\$asm_name\\asm\\";
386 $$oref = "";
387 $mf_var =~ s/\.o$/.obj/g;
389 foreach (split(/ /, $mf_var))
391 $$oref .= $asm_dir . $_ . " ";
393 $$oref =~ s/ $//;
394 $$sref = $$oref;
395 $$sref =~ s/\.obj/.asm/g;