util/pl/VC-32.pl: refresh, switch to ws2, add crypt32, fix typo (based on
[openssl.git] / util / pl / VC-32.pl
index 693adae6e4778b5b2148e1a0e233ab9d243bef83..69197b0144e3dba0a4539281641f1ee9f96a1c6a 100644 (file)
@@ -49,8 +49,7 @@ if ($FLAVOR =~ /WIN64/)
     # considered safe to ignore.
     # 
     $base_cflags= " $mf_cflag";
-    my $f = $shlib?' /MD':' /MT';
-    $lib_cflag='/Zl' if (!$shlib);     # remove /DEFAULTLIBs from static lib
+    my $f = ($shlib and !$fipscanisterbuild)?' /MD':' /MT';
     $opt_cflags=$f.' /Ox';
     $dbg_cflags=$f.'d /Od -DDEBUG -D_DEBUG';
     $lflags="/nologo /subsystem:console /opt:ref";
@@ -64,6 +63,10 @@ if ($FLAVOR =~ /WIN64/)
 \$(TMP_D)$o$bname.asm: $source
        set ASM=\$(ASM)
        \$(PERL) $source \$\@
+___
+       $ret .= "\t\$(PERL) util\\fipsas.pl . \$@ norunasm \$(CFLAG)\n" if $fipscanisterbuild;
+
+       $ret.=<<___;
 
 $target: \$(TMP_D)$o$bname.asm
        \$(ASM) $afile\$\@ \$(TMP_D)$o$bname.asm
@@ -93,7 +96,7 @@ elsif ($FLAVOR =~ /CE/)
     $wcetgt = $ENV{'TARGETCPU'};       # just shorter name...
     SWITCH: for($wcetgt) {
        /^X86/          && do { $wcecdefs.=" -Dx86 -D_X86_ -D_i386_ -Di_386_";
-                               $wcelflag.=" /machine:IX86";    last; };
+                               $wcelflag.=" /machine:X86";     last; };
        /^ARMV4[IT]/    && do { $wcecdefs.=" -DARM -D_ARM_ -D$wcetgt";
                                $wcecdefs.=" -DTHUMB -D_THUMB_" if($wcetgt=~/T$/);
                                $wcecdefs.=" -QRarch4T -QRinterwork-return";
@@ -118,24 +121,29 @@ elsif ($FLAVOR =~ /CE/)
          $wcelflag.=" /machine:$wcetgt";                       last; };
     }
 
-    $cc='$(CC)';
+    $cc=($ENV{CC} or "cl");
     $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';
     $base_cflags.=" $wcecdefs";
     $base_cflags.=' -I$(WCECOMPAT)/include'            if (defined($ENV{'WCECOMPAT'}));
     $base_cflags.=' -I$(PORTSDK_LIBPATH)/../../include'        if (defined($ENV{'PORTSDK_LIBPATH'}));
-    $opt_cflags=' /MC /O1i';   # optimize for space, but with intrinsics...
-    $dbg_clfags=' /MC /Od -DDEBUG -D_DEBUG';
+    if ($cc =~ /\bcl(\.exe)*$/) {
+       $base_cflags.=($shlib and !$fipscanisterbuild)?' /MD':' /MT';
+    } else {
+       $base_cflags.=' /MC';
+    }
+    $opt_cflags=' /O1i';       # optimize for space, but with intrinsics...
+    $dbg_cflags=' /Od -DDEBUG -D_DEBUG';
     $lflags="/nologo /opt:ref $wcelflag";
     }
 else   # Win32
     {
     $base_cflags= " $mf_cflag";
-    my $f = $shlib?' /MD':' /MT';
-    $lib_cflag='/Zl' if (!$shlib);     # remove /DEFAULTLIBs from static lib
+    my $f = ($shlib and !$fipscanisterbuild)?' /MD':' /MT';
     $opt_cflags=$f.' /Ox /O2 /Ob2';
     $dbg_cflags=$f.'d /Od -DDEBUG -D_DEBUG';
     $lflags="/nologo /subsystem:console /opt:ref";
     }
+$lib_cflag='/Zl' if (!$shlib or $fipscanisterbuild);   # remove /DEFAULTLIBs
 $mlflags='';
 
 $out_def ="out32";     $out_def.="dll"                 if ($shlib);
@@ -158,6 +166,8 @@ $app_cflag.=" /Zi /Fd\$(TMP_D)/app";
 $lib_cflag.=" /Zi /Fd\$(TMP_D)/lib";
 $lflags.=" /debug";
 
+$lflags.=" /fixed" if ($fips && $FLAVOR !~ /WIN64/);
+
 $obj='.obj';
 $asm_suffix='.asm';
 $ofile="/Fo";
@@ -168,14 +178,26 @@ $rsc="rc";
 $efile="/out:";
 $exep='.exe';
 if ($no_sock)          { $ex_libs=''; }
-elsif ($FLAVOR =~ /CE/)        { $ex_libs='winsock.lib'; }
+elsif ($FLAVOR =~ /CE/)        { $ex_libs='ws2.lib'; }
 else                   { $ex_libs='ws2_32.lib'; }
 
 if ($FLAVOR =~ /CE/)
        {
-       $ex_libs.=' $(WCECOMPAT)/lib/wcecompatex.lib'   if (defined($ENV{'WCECOMPAT'}));
+       $ex_libs.=' crypt32.lib';       # for e_capi.c
+       if (defined($ENV{WCECOMPAT}))
+               {
+               $ex_libs.= ' $(WCECOMPAT)/lib';
+               if (-f "$ENV{WCECOMPAT}/lib/$ENV{TARGETCPU}/wcecompatex.lib")
+                       {
+                       $ex_libs.='/$(TARGETCPU)/whecompatex.lib';
+                       }
+               else
+                       {
+                       $ex_libs.='/wcecompatex.lib';
+                       }
+               }
        $ex_libs.=' $(PORTSDK_LIBPATH)/portlib.lib'     if (defined($ENV{'PORTSDK_LIBPATH'}));
-       $ex_libs.=' /nodefaultlib:oldnames.lib coredll.lib corelibc.lib' if ($ENV{'TARGETCPU'} eq "X86");
+       $ex_libs.=' /nodefaultlib coredll.lib corelibc.lib' if ($ENV{'TARGETCPU'} eq "X86");
        }
 else
        {
@@ -278,7 +300,8 @@ elsif ($shlib && $FLAVOR =~ /CE/)
        {
        $mlflags.=" $lflags /dll";
        $lflags.=' /entry:mainCRTstartup' if(defined($ENV{'PORTSDK_LIBPATH'}));
-       $lib_cflag.=" -D_WINDLL -D_DLL";
+       $lib_cflag.=" -D_WINDLL";
+       $lib_cflag.=" -D_DLL" if (!$fipscanisterbuild);
        }
 
 sub do_lib_rule