Add FIPS support to the WIN32 build system.
[openssl.git] / util / pl / VC-32.pl
index 5f25fc4..ce8cd73 100644 (file)
@@ -6,6 +6,21 @@
 $ssl=  "ssleay32";
 $crypto="libeay32";
 
+if ($fips && !$shlib)
+       {
+       $crypto="libeayfips32";
+       $crypto_compat = "libeaycompat32.lib";
+       }
+else
+       {
+       $crypto="libeay32";
+       }
+
+if ($fipscanisterbuild)
+       {
+       $fips_canister_path = "\$(LIB_D)\\fipscanister.lib";
+       }
+
 $o='\\';
 $cp='$(PERL) util/copy.pl';
 $mkdir='$(PERL) util/mkdir-p.pl';
@@ -266,10 +281,19 @@ elsif ($shlib && $FLAVOR =~ /CE/)
 
 sub do_lib_rule
        {
-       local($objs,$target,$name,$shlib)=@_;
+       my($objs,$target,$name,$shlib,$ign,$base_addr) = @_;
        local($ret);
 
        $taget =~ s/\//$o/g if $o ne '/';
+       my $base_arg;
+       if ($base_addr ne "")
+               {
+               $base_arg= " /base:$base_addr";
+               }
+       else
+               {
+               $base_arg = "";
+               }
        if ($name ne "")
                {
                $name =~ tr/a-z/A-Z/;
@@ -277,7 +301,7 @@ sub do_lib_rule
                }
 
 #      $target="\$(LIB_D)$o$target";
-       $ret.="$target: $objs\n";
+#      $ret.="$target: $objs\n";
        if (!$shlib)
                {
 #              $ret.="\t\$(RM) \$(O_$Name)\n";
@@ -287,7 +311,27 @@ sub do_lib_rule
                {
                local($ex)=($target =~ /O_CRYPTO/)?'':' $(L_CRYPTO)';
                $ex.=" $zlib_lib" if $zlib_opt == 1 && $target =~ /O_CRYPTO/;
-               $ret.="\t\$(LINK) \$(MLFLAGS) $efile$target $name @<<\n  \$(SHLIB_EX_OBJ) $objs $ex \$(EX_LIBS)\n<<\n";
+
+               if ($fips && $target =~ /O_CRYPTO/)
+                       {
+                       $ret.="$target: $objs \$(PREMAIN_DSO_EXE)";
+                       $ret.="\n\tSET FIPS_LINK=\$(LINK)\n";
+                       $ret.="\tSET FIPS_CC=\$(CC)\n";
+                       $ret.="\tSET FIPS_CC_ARGS=/Fo\$(OBJ_D)${o}fips_premain.obj \$(SHLIB_CFLAGS) -c\n";
+                       $ret.="\tSET PREMAIN_DSO_EXE=\$(PREMAIN_DSO_EXE)\n";
+                       $ret.="\tSET FIPS_SHA1_EXE=\$(FIPS_SHA1_EXE)\n";
+                       $ret.="\tSET FIPS_TARGET=$target\n";
+                       $ret.="\tSET FIPSLIB_D=\$(FIPSLIB_D)\n";
+                       $ret.="\t\$(FIPSLINK) \$(MLFLAGS) /map $base_arg $efile$target ";
+                       $ret.="$name @<<\n  \$(SHLIB_EX_OBJ) $objs \$(EX_LIBS) ";
+                       $ret.="\$(OBJ_D)${o}fips_premain.obj $ex\n<<\n";
+                       }
+               else
+                       {
+                       $ret.="$target: $objs";
+                       $ret.="\n\t\$(LINK) \$(MLFLAGS) $efile$target $name @<<\n  \$(SHLIB_EX_OBJ) $objs $ex \$(EX_LIBS)\n<<\n";
+                       }
+
                $ret.="\tIF EXIST \$@.manifest mt -nologo -manifest \$@.manifest -outputresource:\$@;2\n\n";
                }
        $ret.="\n";
@@ -296,15 +340,55 @@ sub do_lib_rule
 
 sub do_link_rule
        {
-       local($target,$files,$dep_libs,$libs)=@_;
+       my($target,$files,$dep_libs,$libs,$standalone)=@_;
        local($ret,$_);
-       
        $file =~ s/\//$o/g if $o ne '/';
        $n=&bname($targer);
        $ret.="$target: $files $dep_libs\n";
-       $ret.="\t\$(LINK) \$(LFLAGS) $efile$target @<<\n";
-       $ret.="  \$(APP_EX_OBJ) $files $libs\n<<\n";
-       $ret.="\tIF EXIST \$@.manifest mt -nologo -manifest \$@.manifest -outputresource:\$@;1\n\n";
+       if ($standalone == 1)
+               {
+               $ret.="  \$(LINK) \$(LFLAGS) $efile$target @<<\n\t";
+               $ret.= "\$(EX_LIBS) " if ($files =~ /O_FIPSCANISTER/ && !$fipscanisterbuild);
+               $ret.="$files $libs\n<<\n";
+               }
+       elsif ($standalone == 2)
+               {
+               $ret.="\tSET FIPS_LINK=\$(LINK)\n";
+               $ret.="\tSET FIPS_CC=\$(CC)\n";
+               $ret.="\tSET FIPS_CC_ARGS=/Fo\$(OBJ_D)${o}fips_premain.obj \$(SHLIB_CFLAGS) -c\n";
+               $ret.="\tSET PREMAIN_DSO_EXE=\n";
+               $ret.="\tSET FIPS_TARGET=$target\n";
+               $ret.="\tSET FIPS_SHA1_EXE=\$(FIPS_SHA1_EXE)\n";
+               $ret.="\tSET FIPSLIB_D=\$(FIPSLIB_D)\n";
+               $ret.="\t\$(FIPSLINK) \$(LFLAGS) /map $efile$target @<<\n";
+               $ret.="\t\$(APP_EX_OBJ) $files \$(OBJ_D)${o}fips_premain.obj $libs\n<<\n";
+               }
+       else
+               {
+               $ret.="\t\$(LINK) \$(LFLAGS) $efile$target @<<\n";
+               $ret.="\t\$(APP_EX_OBJ) $files $libs\n<<\n";
+               }
+       $ret.="\tIF EXIST \$@.manifest mt -nologo -manifest \$@.manifest -outputresource:\$@;1\n\n";
+       return($ret);
+       }
+
+sub do_rlink_rule
+       {
+       local($target,$rl_start, $rl_mid, $rl_end,$dep_libs,$libs)=@_;
+       local($ret,$_);
+       my $files = "$rl_start $rl_mid $rl_end";
+
+       $file =~ s/\//$o/g if $o ne '/';
+       $n=&bname($targer);
+       $ret.="$target: $files $dep_libs \$(FIPS_SHA1_EXE)\n";
+       $ret.="\t\$(PERL) ms\\segrenam.pl \$\$a $rl_start\n";
+       $ret.="\t\$(PERL) ms\\segrenam.pl \$\$b $rl_mid\n";
+       $ret.="\t\$(PERL) ms\\segrenam.pl \$\$c $rl_end\n";
+       $ret.="\t\$(MKLIB) $lfile$target @<<\n\t$files\n<<\n";
+       $ret.="\t\$(FIPS_SHA1_EXE) $target > ${target}.sha1\n";
+       $ret.="\t\$(PERL) util${o}copy.pl -stripcr fips${o}fips_premain.c \$(LIB_D)${o}fips_premain.c\n";
+       $ret.="\t\$(CP) fips${o}fips_premain.c.sha1 \$(LIB_D)${o}fips_premain.c.sha1\n";
+       $ret.="\n";
        return($ret);
        }
 
@@ -322,15 +406,19 @@ sub win32_import_asm
                }
 
        $$oref = "";
-       $mf_var =~ s/\.o$/.obj/g;
+       $$sref = "";
+       $mf_var =~ s/\.o//g;
 
        foreach (split(/ /, $mf_var))
                {
-               $$oref .= $asm_dir . $_ . " ";
+               $$sref .= $asm_dir . $_ . ".asm ";
+               }
+       foreach (split(/ /, $mf_var))
+               {
+               $$oref .= "\$(TMP_D)\\" . $_ . ".obj ";
                }
        $$oref =~ s/ $//;
-       $$sref = $$oref;
-       $$sref =~ s/\.obj/.asm/g;
+       $$sref =~ s/ $//;
 
        }