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