Make -DOPENSSL_FIPSSYMS work under WIN32: run perl script when
[openssl.git] / util / mk1mf.pl
index 068b70491637cea31e6b1b8a89496c671c83ec15..cb104f8097f34207ea531f995ed5ce44ad962cc5 100755 (executable)
@@ -25,11 +25,16 @@ my $fips_sha1_exe_path = "";
 
 local $fipscanisterbuild = 0;
 
+my $fipscanisteronly = 0;
+
 my $fipslibdir = "";
 my $baseaddr = "";
 
 my $ex_l_libs = "";
 
+my $build_targets = "lib exe";
+my $libs_dep = "\$(O_CRYPTO) \$(O_SSL)";
+
 # Options to import from top level Makefile
 
 my %mf_import = (
@@ -371,7 +376,7 @@ for (;;)
        if ($key eq "LIBKRB5")
                { $ex_libs .= " $val" if $val ne "";}
 
-       if ($key eq "TEST")
+       if ($key eq "TEST" && (!$fipscanisteronly || $dir =~ /^fips/ ))
                { $test.=&var_add($dir,$val, 0); }
 
        if (($key eq "PROGS") || ($key eq "E_OBJ"))
@@ -448,7 +453,7 @@ if ($fips)
                                $lib_obj{"FIPS"} .= "$_ ";
                                }
                        }
-               else
+               elsif (!$fipscanisteronly)
                        {
                        $lib_obj{"CRYPTO"} .= "$_ ";
                        }
@@ -498,7 +503,7 @@ if ($fips)
        {
        if (!$shlib)
                {
-               $ex_build_targets .= " \$(LIB_D)$o$crypto_compat \$(PREMAIN_DSO_EXE)";
+               $build_targets .= " \$(LIB_D)$o$crypto_compat \$(PREMAIN_DSO_EXE)";
                $ex_l_libs .= " \$(O_FIPSCANISTER)";
                $ex_libs_dep .= " \$(O_FIPSCANISTER)" if $fipscanisterbuild;
                }
@@ -521,6 +526,13 @@ if ($fips)
                }
        }
 
+if ($fipscanisteronly)
+       {
+       $build_targets = "\$(O_FIPSCANISTER) \$(T_EXE)";
+       $libs_dep = "";
+       }
+       
+
 if ($shlib)
        {
        $extra_install= <<"EOF";
@@ -659,13 +671,13 @@ INC=-I\$(INC_D) -I\$(INCL_D)
 APP_CFLAGS=\$(INC) \$(CFLAG) \$(APP_CFLAG)
 LIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG)
 SHLIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) \$(SHLIB_CFLAG)
-LIBS_DEP=\$(O_CRYPTO) \$(O_SSL) $ex_libs_dep
+LIBS_DEP=$libs_dep
 
 #############################################
 EOF
 
 $rules=<<"EOF";
-all: banner \$(TMP_D) \$(BIN_D) \$(TEST_D) \$(LIB_D) \$(INCO_D) headers \$(FIPS_SHA1_EXE) lib exe $ex_build_targets
+all: banner \$(TMP_D) \$(BIN_D) \$(TEST_D) \$(LIB_D) \$(INCO_D) headers \$(FIPS_SHA1_EXE) $build_targets
 
 banner:
 $banner
@@ -1151,10 +1163,14 @@ sub perlasm_compile_target
        {
        my($target,$source,$bname)=@_;
        my($ret);
-
        $bname =~ s/(.*)\.[^\.]$/$1/;
        $ret ="\$(TMP_D)$o$bname.asm: $source\n";
-       $ret.="\t\$(PERL) $source $asmtype \$(CFLAG) >\$\@\n\n";
+       $ret.="\t\$(PERL) $source $asmtype \$(CFLAG) >\$\@\n";
+       if ($cflags =~ /-DOPENSSL_FIPSSYMS/)
+               {
+               $ret .= "\t\$(PERL) util\\fipsas.pl . \$@ norunasm \$(CFLAG)\n";
+               }
+       $ret .= "\n";
        $ret.="$target: \$(TMP_D)$o$bname.asm\n";
        $ret.="\t\$(ASM) $afile\$\@ \$(TMP_D)$o$bname.asm\n\n";
        return($ret);
@@ -1325,6 +1341,7 @@ sub read_options
                "no-zlib-dynamic" => 0,
                "fips" => \$fips,
                "fipscanisterbuild" => [\$fips, \$fipscanisterbuild],
+               "fipscanisteronly" => [\$fips, \$fipscanisterbuild, \$fipscanisteronly],
                );
 
        if (exists $valid_options{$_})