summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorBen Laurie <ben@links.org>2013-03-04 14:11:18 +0000
committerBen Laurie <ben@links.org>2013-03-04 14:31:19 +0000
commit656829b78f999df6c3420c2b4e5bc296e056a4e0 (patch)
tree8f1b2d2773c7ca21d61b37dc18e8c733e263e35e /util
parent95dd3018613f600308f199bdad3feb7d24f86642 (diff)
Handle assembler files.
Diffstat (limited to 'util')
-rwxr-xr-xutil/mk1mf.pl32
-rw-r--r--util/pl/unix.pl80
2 files changed, 112 insertions, 0 deletions
diff --git a/util/mk1mf.pl b/util/mk1mf.pl
index e19816f4f7..2b1e915265 100755
--- a/util/mk1mf.pl
+++ b/util/mk1mf.pl
@@ -61,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
);
@@ -862,6 +863,28 @@ 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');
+$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{$_};
@@ -1206,6 +1229,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);
@@ -1216,6 +1244,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";
diff --git a/util/pl/unix.pl b/util/pl/unix.pl
index 146611ad99..071e97a3af 100644
--- a/util/pl/unix.pl
+++ b/util/pl/unix.pl
@@ -53,6 +53,86 @@ $des_enc_src="";
$bf_enc_obj="";
$bf_enc_src="";
+%perl1 = (
+ 'md5-x86_64' => 'crypto/md5',
+ 'x86_64-mont' => 'crypto/bn',
+ 'x86_64-mont5' => 'crypto/bn',
+ 'x86_64-gf2m' => 'crypto/bn',
+ 'modexp512-x86_64' => 'crypto/bn',
+ 'aes-x86_64' => 'crypto/aes',
+ 'vpaes-x86_64' => 'crypto/aes',
+ 'bsaes-x86_64' => 'crypto/aes',
+ 'aesni-x86_64' => 'crypto/aes',
+ 'aesni-sha1-x86_64' => 'crypto/aes',
+ 'sha1-x86_64' => 'crypto/sha',
+ 'e_padlock-x86_64' => 'engines',
+ 'rc4-x86_64' => 'crypto/rc4',
+ 'rc4-md5-x86_64' => 'crypto/rc4',
+ 'ghash-x86_64' => 'crypto/modes',
+ );
+
+# If I were feeling more clever, these could probably be extracted
+# from makefiles.
+sub platform_perlasm_compile_target
+ {
+ local($target, $source, $bname) = @_;
+
+ for $p (keys %perl1)
+ {
+ if ($target eq "\$(OBJ_D)/$p.o")
+ {
+ return << "EOF";
+\$(TMP_D)/$p.s: $perl1{$p}/asm/$p.pl
+ \$(PERL) $perl1{$p}/asm/$p.pl \$(PERLASM_SCHEME) > \$@
+EOF
+ }
+ }
+ if ($target eq '$(OBJ_D)/x86_64cpuid.o')
+ {
+ return << 'EOF';
+$(TMP_D)/x86_64cpuid.s: crypto/x86_64cpuid.pl
+ $(PERL) crypto/x86_64cpuid.pl $(PERLASM_SCHEME) > $@
+EOF
+ }
+ elsif ($target eq '$(OBJ_D)/sha256-x86_64.o')
+ {
+ return << 'EOF';
+$(TMP_D)/sha256-x86_64.s: crypto/sha/asm/sha512-x86_64.pl
+ $(PERL) crypto/sha/asm/sha512-x86_64.pl $(PERLASM_SCHEME) $@
+EOF
+ }
+ elsif ($target eq '$(OBJ_D)/sha512-x86_64.o')
+ {
+ return << 'EOF';
+$(TMP_D)/sha512-x86_64.s: crypto/sha/asm/sha512-x86_64.pl
+ $(PERL) crypto/sha/asm/sha512-x86_64.pl $(PERLASM_SCHEME) $@
+EOF
+ }
+ elsif ($target eq '$(OBJ_D)/sha512-x86_64.o')
+ {
+ return << 'EOF';
+$(TMP_D)/sha512-x86_64.s: crypto/sha/asm/sha512-x86_64.pl
+ $(PERL) crypto/sha/asm/sha512-x86_64.pl $(PERLASM_SCHEME) $@
+EOF
+ }
+
+ die $target;
+ }
+
+sub special_compile_target
+ {
+ local($target) = @_;
+
+ if ($target eq 'crypto/bn/x86_64-gcc')
+ {
+ return << "EOF";
+\$(TMP_D)/x86_64-gcc.o: crypto/bn/asm/x86_64-gcc.c
+ \$(CC) \$(CFLAGS) -c -o \$@ crypto/bn/asm/x86_64-gcc.c
+EOF
+ }
+ return undef;
+ }
+
sub do_lib_rule
{
local($obj,$target,$name,$shlib)=@_;