Only copy headers if they've changed.
[openssl.git] / util / mk1mf.pl
index 1771e5a4cea9ed142af085114358b241cf93f1d9..e0e8d572436d4e5e3fb1c48d0aaa16a0430b9ce5 100755 (executable)
@@ -44,6 +44,7 @@ my %mf_import = (
        INSTALLTOP     => \$INSTALLTOP,
        OPENSSLDIR     => \$OPENSSLDIR,
        PLATFORM       => \$mf_platform,
+       CC             => \$mf_cc,
        CFLAG          => \$mf_cflag,
        DEPFLAG        => \$mf_depflag,
        CPUID_OBJ      => \$mf_cpuid_asm,
@@ -60,6 +61,7 @@ my %mf_import = (
        WP_ASM_OBJ     => \$mf_wp_asm,
        CMLL_ENC       => \$mf_cm_asm,
        MODES_ASM_OBJ  => \$mf_modes_asm,
+        ENGINES_ASM_OBJ=> \$mf_engines_asm,
        FIPSCANISTERONLY  => \$mf_fipscanisteronly,
        FIPSCANISTERINTERNAL  => \$mf_fipscanisterinternal
 );
@@ -68,7 +70,7 @@ open(IN,"<Makefile") || die "unable to open Makefile!\n";
 while(<IN>) {
     my ($mf_opt, $mf_ref);
     while (($mf_opt, $mf_ref) = each %mf_import) {
-       if (/^$mf_opt\s*=\s*(.*)$/) {
+       if (/^$mf_opt\s*=\s*(.*)$/ && !defined($$mfref)) {
           $$mf_ref = $1;
        }
     }
@@ -106,7 +108,8 @@ $infile="MINFO";
        "netware-libc", "CodeWarrior for NetWare - LibC - with WinSock Sockets",
        "netware-libc-bsdsock", "CodeWarrior for NetWare - LibC - with BSD Sockets",
        "default","cc under unix",
-       "auto", "auto detect from top level Makefile"
+       "auto", "auto detect from top level Makefile",
+        "copy", "copy from top level Makefile"
        );
 
 $platform="";
@@ -195,7 +198,7 @@ $NT=0;
 
 push(@INC,"util/pl","pl");
 
-if ($platform eq "auto") {
+if ($platform eq "auto" || $platform eq 'copy') {
        $orig_platform = $platform;
        $platform = $mf_platform;
        print STDERR "Imported platform $mf_platform\n";
@@ -322,8 +325,10 @@ else
 ##else
        { $cflags="$c_flags$cflags" if ($c_flags ne ""); }
 
-print STDERR "platform = $orig_platform\n";
-$cflags = $mf_cflag if $orig_platform eq 'auto';
+if ($orig_platform eq 'copy') {
+    $cflags = $mf_cflag;
+    $cc = $mf_cc;
+}
 
 $ex_libs="$l_flags$ex_libs" if ($l_flags ne "");
 
@@ -858,6 +863,29 @@ if ($fips)
                "-DFINGERPRINT_PREMAIN_DSO_LOAD \$(APP_CFLAGS)");
        }
 
+sub fix_asm
+       {
+       my($asm, $dir) = @_;
+
+       $asm = " $asm";
+       $asm =~ s/\s+/ $dir\//g;
+       $asm =~ s/\.o//g;
+       $asm =~ s/^ //;
+
+       return $asm . ' ';
+       }
+
+$lib_obj{CRYPTO} .= fix_asm($mf_md5_asm, 'crypto/md5');
+$lib_obj{CRYPTO} .= fix_asm($mf_bn_asm, 'crypto/bn');
+# cpuid is included by the crypto dir
+#$lib_obj{CRYPTO} .= fix_asm($mf_cpuid_asm, 'crypto');
+# AES asm files end up included by the aes dir itself
+#$lib_obj{CRYPTO} .= fix_asm($mf_aes_asm, 'crypto/aes');
+$lib_obj{CRYPTO} .= fix_asm($mf_sha_asm, 'crypto/sha');
+$lib_obj{CRYPTO} .= fix_asm($mf_engines_asm, 'engines');
+$lib_obj{CRYPTO} .= fix_asm($mf_rc4_asm, 'crypto/rc4');
+$lib_obj{CRYPTO} .= fix_asm($mf_modes_asm, 'crypto/modes');
+
 foreach (values %lib_nam)
        {
        $lib_obj=$lib_obj{$_};
@@ -1202,6 +1230,11 @@ sub do_compile_rule
                        {
                        $ret.=&Sasm_compile_target("$to${o}$n$obj",$s,$n);
                        }
+               elsif (defined &special_compile_target and
+                      ($s=special_compile_target($_)))
+                       {
+                       $ret.=$s;
+                       }
                else    { die "no rule for $_"; }
                }
        return($ret);
@@ -1212,6 +1245,10 @@ sub do_compile_rule
 sub perlasm_compile_target
        {
        my($target,$source,$bname)=@_;
+
+       return platform_perlasm_compile_target($target, $source, $bname)
+           if defined &platform_perlasm_compile_target;
+
        my($ret);
        $bname =~ s/(.*)\.[^\.]$/$1/;
        $ret ="\$(TMP_D)$o$bname.asm: $source\n";
@@ -1316,7 +1353,7 @@ sub do_copy_rule
                if ($n =~ /bss_file/)
                        { $pp=".c"; }
                else    { $pp=$p; }
-               $ret.="$to${o}$n$pp: \$(SRC_D)$o$_$pp $to\n\t\$(CP) \"\$(SRC_D)$o$_$pp\" \"$to${o}$n$pp\"\n\n";
+               $ret.="$to${o}$n$pp: \$(SRC_D)$o$_$pp $to\n\t\$(SRC_D)${o}util${o}copy-if-different.pl \"\$(SRC_D)$o$_$pp\" \"$to${o}$n$pp\"\n\n";
                }
        return($ret);
        }