Add conditional unit testing interface.
[openssl.git] / util / mk1mf.pl
index ab806d1d23b6f870125b6a0c8808817f08c89b03..66ff994852f2a06fe9125ddc6e38c92c40271d30 100755 (executable)
@@ -1,4 +1,4 @@
-#!/usr/local/bin/perl
+#!/usr/bin/env perl
 # A bit of an evil hack but it post processes the file ../MINFO which
 # is generated by `make files` in the top directory.
 # This script outputs one mega makefile that has no shell stuff or any
@@ -192,7 +192,7 @@ $mkdir="-mkdir" unless defined $mkdir;
 $ranlib="echo ranlib";
 
 $cc=(defined($VARS{'CC'}))?$VARS{'CC'}:'cc';
-$src_dir=(defined($VARS{'SRC'}))?$VARS{'SRC'}:getcwd();
+$src_dir=(defined($VARS{'SRC'}))?$VARS{'SRC'}: $platform eq 'copy' ? getcwd() : '.';
 $bin_dir=(defined($VARS{'BIN'}))?$VARS{'BIN'}:'';
 
 # $bin_dir.=$o causes a core dump on my sparc :-(
@@ -455,6 +455,14 @@ for (;;)
        }
 close(IN);
 
+if ($orig_platform eq 'copy')
+       {
+       # Remove opensslconf.h so it doesn't get updated if we configure a
+       # different branch.
+       $exheader =~ s/[^ ]+\/opensslconf.h//;
+       $header =~ s/[^ ]+\/opensslconf.h//;
+       }
+
 if ($fips)
        {
 
@@ -609,6 +617,8 @@ EOF
        $ex_libs .= " $zlib_lib" if $zlib_opt == 1;
        }
 
+my $asm_def = $orig_platform eq 'copy' ? "" : "ASM=$bin_dir$asm";
+
 $defs= <<"EOF";
 # N.B. You MUST use -j on FreeBSD.
 # This makefile has been automatically generated from the OpenSSL distribution.
@@ -669,7 +679,7 @@ RANLIB=$ranlib
 MKDIR=$mkdir
 MKLIB=$bin_dir$mklib
 MLFLAGS=$mlflags
-ASM=$bin_dir$asm
+$asm_def
 
 # FIPS validated module and support file locations
 
@@ -756,6 +766,7 @@ $banner
 # This needs to be invoked once, when the makefile is first constructed, or
 # after cleaning.
 init: \$(TMP_D) \$(LIB_D) \$(INC_D) \$(INCO_D) \$(BIN_D) \$(TEST_D) headers
+       \$(PERL) \$(SRC_D)/util/copy-if-different.pl "\$(SRC_D)/crypto/opensslconf.h" "\$(INCO_D)/opensslconf.h"
 
 headers: \$(HEADER) \$(EXHEADER)
 
@@ -1269,15 +1280,15 @@ sub perlasm_compile_target
 
        my($ret);
        $bname =~ s/(.*)\.[^\.]$/$1/;
-       $ret ="\$(TMP_D)$o$bname.asm: $source\n";
+       $ret ="\$(TMP_D)$o$bname$asm_suffix: $source\n";
        $ret.="\t\$(PERL) $source $asmtype \$(CFLAG) >\$\@\n";
        if ($fipscanisteronly)
                {
-               $ret .= "\t\$(PERL) util\\fipsas.pl . \$@ norunasm \$(CFLAG)\n";
+               $ret .= "\t\$(PERL) util$o.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";
+       $ret.="$target: \$(TMP_D)$o$bname$asm_suffix\n";
+       $ret.="\t\$(ASM) $afile\$\@ \$(TMP_D)$o$bname$asm_suffix\n\n";
        return($ret);
        }
 
@@ -1454,6 +1465,7 @@ sub read_options
                "no-zlib" => 0,
                "no-zlib-dynamic" => 0,
                "no-ssl-trace" => 0,
+               "no-unit-test" => 0,
                "fips" => \$fips,
                "fipscanisterbuild" => [\$fips, \$fipscanisterbuild],
                "fipscanisteronly" => [\$fips, \$fipscanisterbuild, \$fipscanisteronly],