From 656829b78f999df6c3420c2b4e5bc296e056a4e0 Mon Sep 17 00:00:00 2001 From: Ben Laurie Date: Mon, 4 Mar 2013 14:11:18 +0000 Subject: [PATCH] Handle assembler files. --- util/mk1mf.pl | 32 ++++++++++++++++++++ util/pl/unix.pl | 80 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 112 insertions(+) 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)=@_; -- 2.25.1