diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2008-01-06 00:36:22 +0000 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2008-01-06 00:36:22 +0000 |
commit | 7398053149ca6f86584baec02fd71e2e99a737f2 (patch) | |
tree | 04ae35d7d71272a75baf92925df8a2aab44cb3dc | |
parent | 4d1f3f7a6c4dd0162c903c8fb96265db1ba0b91c (diff) |
Experimental support for import of more options from Configure
(via top level Makefile) into mk1mf builds. This avoids the need
to duplicate the CFLAG handling and can auto build assembly language
source files from perl scripts.
Extend VC-WIN32 Configure entry to include new options.
-rw-r--r-- | CHANGES | 6 | ||||
-rwxr-xr-x | Configure | 6 | ||||
-rwxr-xr-x | ms/do_nasm.bat | 78 | ||||
-rwxr-xr-x | util/mk1mf.pl | 61 | ||||
-rw-r--r-- | util/pl/VC-32.pl | 77 |
5 files changed, 108 insertions, 120 deletions
@@ -4,6 +4,12 @@ Changes between 0.9.8g and 0.9.9 [xx XXX xxxx] + *) Extend mk1mf to support importing of options and assembly language + files from Configure script, currently only included in VC-WIN32. + The assembly language rules can now optionally generate the source + files from the associated perl scripts. + [Steve Henson] + *) Implement remaining functionality needed to support GOST ciphersuites. Interop testing has been performed using CryptoPro implementations. [Victor B. Wagner <vitus@cryptocom.ru>] @@ -121,6 +121,8 @@ my $x86_coff_asm="x86cpuid-cof.o:bn86-cof.o co86-cof.o mo86-cof.o:dx86-cof.o yx8 my $x86_out_asm="x86cpuid-out.o:bn86-out.o co86-out.o mo86-out.o:dx86-out.o yx86-out.o:ax86-out.o:bx86-out.o:mx86-out.o:sx86-out.o sha256x86-out.o sha512x86-out.o:cx86-out.o:rx86-out.o:rm86-out.o:r586-out.o:wp_block.o w86mmx-out.o:"; my $x86_macosx_asm="x86cpuid-macosx.o:bn86-macosx.o co86-macosx.o mo86-macosx.o:dx86-macosx.o yx86-macosx.o:ax86-macosx.o:bx86-macosx.o:mx86-macosx.o:sx86-macosx.o sha256x86-macosx.o sha512x86-macosx.o:cx86-macosx.o:rx86-macosx.o:rm86-macosx.o:r586-macosx.o:wp_block.o w86mmx-macosx.o:"; +my $x86_win32_asm="x86cpuid.o:bn-586.o co-586.o x86-mont.o:des-586.o crypt586.o:aes-586.o:bf-586.o:md5-586.o:sha1-586.o sha256-586.o sha512-586.o:cast-586.o:rc4-586.o:rmd-586.o:rc5-586.o:wp-mmx.o:"; + my $x86_64_asm="x86_64cpuid.o:x86_64-gcc.o x86_64-mont.o::aes-x86_64.o::md5-x86_64.o:sha1-x86_64.o sha256-x86_64.o sha512-x86_64.o::rc4-x86_64.o:::wp-x86_64.o:"; my $ia64_asm="ia64cpuid.o:bn-ia64.o::aes_core.o aes_cbc.o aes-ia64.o::md5-ia64.o:sha1-ia64.o sha256-ia64.o sha512-ia64.o::rc4-ia64.o rc4_skey.o::::"; my $sparcv9_asm="sparcv9cap.o sparccpuid.o:bn-sparcv9.o sparcv9-mont.o sparcv9a-mont.o:des_enc-sparc.o fcrypt_b.o:aes_core.o aes_cbc.o aes-sparcv9.o:::sha1-sparcv9.o sha256-sparcv9.o sha512-sparcv9.o::::::"; @@ -480,7 +482,7 @@ my %table=( # Visual C targets "VC-NT","cl::::WINNT::BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN ${x86_gcc_opts}:${no_asm}:win32", "VC-CE","cl::::WINCE::BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN ${x86_gcc_opts}:${no_asm}:win32", -"VC-WIN32","cl::::WIN32::BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN ${x86_gcc_opts}:${no_asm}:win32", +"VC-WIN32","cl:-W3 -WX -Gs0 -GF -Gy -nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE:::WIN32::BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN ${x86_gcc_opts}:${x86_win32_asm}:win32", # Borland C++ 4.5 "BC-32","bcc32::::WIN32::BN_LLONG DES_PTR RC4_INDEX EXPORT_VAR_AS_FN:${no_asm}:win32", @@ -1256,7 +1258,7 @@ $cpuid_obj="" if ($processor eq "386"); $bn_obj = $bn_asm unless $bn_obj ne ""; # bn86* is the only one implementing bn_*_part_words -$cflags.=" -DOPENSSL_BN_ASM_PART_WORDS" if ($bn_obj =~ /bn86/); +$cflags.=" -DOPENSSL_BN_ASM_PART_WORDS" if ($bn_obj =~ /bn(86|-586)/); $cflags.=" -DOPENSSL_IA32_SSE2" if (!$no_sse2 && $bn_obj =~ /bn86/); $cflags.=" -DOPENSSL_BN_ASM_MONT" if ($bn_obj =~ /\-mont|mo86\-/); diff --git a/ms/do_nasm.bat b/ms/do_nasm.bat index 7cceea023a..7b3f3edbf0 100755 --- a/ms/do_nasm.bat +++ b/ms/do_nasm.bat @@ -1,82 +1,4 @@ -@echo off - -SET ASMOPTS=-DOPENSSL_IA32_SSE2 -echo Generating x86 for NASM assember - -echo Bignum -cd crypto\bn\asm -perl bn-586.pl win32n %ASMOPTS% > bn_win32.asm -perl co-586.pl win32n %ASMOPTS% > co_win32.asm -perl x86-mont.pl win32n %ASMOPTS% > mo_win32.asm -cd ..\..\.. - -echo AES -cd crypto\aes\asm -perl aes-586.pl win32n %ASMOPTS% > a_win32.asm -cd ..\..\.. - -echo DES -cd crypto\des\asm -perl des-586.pl win32n %ASMOPTS% > d_win32.asm -cd ..\..\.. - -echo "crypt(3)" - -cd crypto\des\asm -perl crypt586.pl win32n %ASMOPTS% > y_win32.asm -cd ..\..\.. - -echo Blowfish - -cd crypto\bf\asm -perl bf-586.pl win32n %ASMOPTS% > b_win32.asm -cd ..\..\.. - -echo CAST5 -cd crypto\cast\asm -perl cast-586.pl win32n %ASMOPTS% > c_win32.asm -cd ..\..\.. - -echo RC4 -cd crypto\rc4\asm -perl rc4-586.pl win32n %ASMOPTS% > r4_win32.asm -cd ..\..\.. - -echo MD5 -cd crypto\md5\asm -perl md5-586.pl win32n %ASMOPTS% > m5_win32.asm -cd ..\..\.. - -echo SHA1 -cd crypto\sha\asm -perl sha1-586.pl win32n %ASMOPTS% > s1_win32.asm -perl sha256-586.pl win32n %ASMOPTS% > sha256_win32.asm -perl sha512-586.pl win32n %ASMOPTS% > sha512_win32.asm -cd ..\..\.. - -echo RIPEMD160 -cd crypto\ripemd\asm -perl rmd-586.pl win32n %ASMOPTS% > rm_win32.asm -cd ..\..\.. - -echo RC5\32 -cd crypto\rc5\asm -perl rc5-586.pl win32n %ASMOPTS% > r5_win32.asm -cd ..\..\.. - -echo Whirlpool -cd crypto\whrlpool\asm -perl wp-mmx.pl win32n %ASMOPTS% > wp_win32.asm -cd ..\..\.. - -echo CPU-ID -cd crypto -perl x86cpuid.pl win32n %ASMOPTS% > cpu_win32.asm -cd .. - -echo on - perl util\mkfiles.pl >MINFO perl util\mk1mf.pl nasm VC-WIN32 >ms\nt.mak perl util\mk1mf.pl dll nasm VC-WIN32 >ms\ntdll.mak diff --git a/util/mk1mf.pl b/util/mk1mf.pl index a76199cf58..0bcda863c2 100755 --- a/util/mk1mf.pl +++ b/util/mk1mf.pl @@ -15,14 +15,42 @@ my $no_static_engine = 1; my $engines = ""; local $zlib_opt = 0; # 0 = no zlib, 1 = static, 2 = dynamic local $zlib_lib = ""; +local $perl_asm = 0; # 1 to autobuild asm files from perl scripts + +# Options to import from top level Makefile + +my %mf_import = ( + VERSION => \$ssl_version, + OPTIONS => \$OPTIONS, + INSTALLTOP => \$INSTALLTOP, + OPENSSLDIR => \$OPENSSLDIR, + PLATFORM => \$mf_platform, + CFLAG => \$mf_cflag, + DEPFLAG => \$mf_depflag, + CPUID_OBJ => \$mf_cpuid_asm, + BN_ASM => \$mf_bn_asm, + DES_ENC => \$mf_des_asm, + AES_ENC => \$mf_aes_asm, + BF_ENC => \$mf_bf_asm, + CAST_ENC => \$mf_cast_asm, + RC4_ENC => \$mf_rc4_asm, + RC5_ENC => \$mf_rc5_asm, + MD5_ASM_OBJ => \$mf_md5_asm, + SHA1_ASM_OBJ => \$mf_sha_asm, + RMD160_ASM_OBJ => \$mf_rmd_asm, + WP_ASM_OBJ => \$mf_wp_asm, + CMLL_ENC => \$mf_cm_asm +); open(IN,"<Makefile") || die "unable to open Makefile!\n"; while(<IN>) { - $ssl_version=$1 if (/^VERSION=(.*)$/); - $OPTIONS=$1 if (/^OPTIONS=(.*)$/); - $INSTALLTOP=$1 if (/^INSTALLTOP=(.*$)/); - $OPENSSLDIR=$1 if (/^OPENSSLDIR=(.*$)/); + my ($mf_opt, $mf_ref); + while (($mf_opt, $mf_ref) = each %mf_import) { + if (/^$mf_opt\s*=\s*(.*)$/) { + $$mf_ref = $1; + } + } } close(IN); @@ -48,6 +76,7 @@ $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" ); $platform=""; @@ -134,6 +163,12 @@ $bin_dir=(defined($VARS{'BIN'}))?$VARS{'BIN'}:''; $NT=0; push(@INC,"util/pl","pl"); + +if ($platform eq "auto") { + $platform = $mf_platform; + print STDERR "Imported platform $mf_platform\n"; +} + if (($platform =~ /VC-(.+)/)) { $FLAVOR=$1; @@ -947,13 +982,25 @@ sub do_asm_rule $target =~ s/\//$o/g if $o ne "/"; $src =~ s/\//$o/g if $o ne "/"; - @s=split(/\s+/,$src); @t=split(/\s+/,$target); + @s=split(/\s+/,$src); + for ($i=0; $i<=$#s; $i++) { - $ret.="$t[$i]: $s[$i]\n"; - $ret.="\t\$(ASM) $afile$t[$i] \$(SRC_D)$o$s[$i]\n\n"; + my $objfile = $t[$i]; + my $srcfile = $s[$i]; + + if ($perl_asm == 1) + { + my $plasm = $objfile; + $plasm =~ s/${obj}/.pl/; + $ret.="$srcfile: $plasm\n"; + $ret.="\t\$(PERL) $plasm $asmtype \$(CFLAG) >$srcfile\n\n"; + } + + $ret.="$objfile: $srcfile\n"; + $ret.="\t\$(ASM) $afile$objfile \$(SRC_D)$o$srcfile\n\n"; } return($ret); } diff --git a/util/pl/VC-32.pl b/util/pl/VC-32.pl index 5cdf62264f..f9ab6ab9f6 100644 --- a/util/pl/VC-32.pl +++ b/util/pl/VC-32.pl @@ -95,9 +95,7 @@ elsif ($FLAVOR =~ /CE/) } else # Win32 { - $base_cflags=' /W3 /WX /Gs0 /GF /Gy /nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32'; - $base_cflags.=' -D_CRT_SECURE_NO_DEPRECATE'; # shut up VC8 - $base_cflags.=' -D_CRT_NONSTDC_NO_DEPRECATE'; # shut up VC8 + $base_cflags= " $mf_cflag"; my $f = $shlib?' /MD':' /MT'; $lib_cflag='/Zl' if (!$shlib); # remove /DEFAULTLIBs from static lib $opt_cflags=$f.' /Ox /O2 /Ob2'; @@ -122,6 +120,7 @@ else } $obj='.obj'; +$asm_suffix='.asm'; $ofile="/Fo"; # EXE linking stuff @@ -167,11 +166,13 @@ if ($nasm) { my $vew=`nasmw -v 2>NUL`; # pick newest version $asm=($ver gt $vew?"nasm":"nasmw")." -f win32"; + $asmtype="win32n"; $afile='-o '; } else { $asm='ml /Cp /coff /c /Cx'; $asm.=" /Zi" if $debug; $afile='/Fo'; + $asmtype="win32"; } $bn_asm_obj=''; @@ -183,36 +184,19 @@ $bf_enc_src=''; if (!$no_asm) { - $aes_asm_obj='crypto\aes\asm\a_win32.obj'; - $aes_asm_src='crypto\aes\asm\a_win32.asm'; - $bn_asm_obj='crypto\bn\asm\bn_win32.obj crypto\bn\asm\mo_win32.obj'; - $bn_asm_src='crypto\bn\asm\bn_win32.asm crypto\bn\asm\mo_win32.asm'; - $bnco_asm_obj='crypto\bn\asm\co_win32.obj'; - $bnco_asm_src='crypto\bn\asm\co_win32.asm'; - $des_enc_obj='crypto\des\asm\d_win32.obj crypto\des\asm\y_win32.obj'; - $des_enc_src='crypto\des\asm\d_win32.asm crypto\des\asm\y_win32.asm'; - $bf_enc_obj='crypto\bf\asm\b_win32.obj'; - $bf_enc_src='crypto\bf\asm\b_win32.asm'; - $cast_enc_obj='crypto\cast\asm\c_win32.obj'; - $cast_enc_src='crypto\cast\asm\c_win32.asm'; - $rc4_enc_obj='crypto\rc4\asm\r4_win32.obj'; - $rc4_enc_src='crypto\rc4\asm\r4_win32.asm'; - $rc5_enc_obj='crypto\rc5\asm\r5_win32.obj'; - $rc5_enc_src='crypto\rc5\asm\r5_win32.asm'; - $md5_asm_obj='crypto\md5\asm\m5_win32.obj'; - $md5_asm_src='crypto\md5\asm\m5_win32.asm'; - $sha1_asm_obj='crypto\sha\asm\s1_win32.obj crypto\sha\asm\sha256_win32.obj crypto\sha\asm\sha512_win32.obj'; - $sha1_asm_src='crypto\sha\asm\s1_win32.asm crypto\sha\asm\sha256_win32.asm crypto\sha\asm\sha512_win32.asm'; - $rmd160_asm_obj='crypto\ripemd\asm\rm_win32.obj'; - $rmd160_asm_src='crypto\ripemd\asm\rm_win32.asm'; - $whirlpool_asm_obj='crypto\whrlpool\asm\wp_win32.obj'; - $whirlpool_asm_src='crypto\whrlpool\asm\wp_win32.asm'; - $cpuid_asm_obj='crypto\cpu_win32.obj'; - $cpuid_asm_src='crypto\cpu_win32.asm'; - $cflags.=" -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2"; - $cflags.=" -DOPENSSL_BN_ASM_PART_WORDS -DBN_ASM -DOPENSSL_BN_ASM_MONT"; - $cflags.=" -DAES_ASM -DMD5_ASM -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM"; - $cflags.=" -DRMD160_ASM -DWHIRLPOOL_ASM"; + win32_import_asm($mf_bn_asm, "bn", \$bn_asm_obj, \$bn_asm_src); + win32_import_asm($mf_aes_asm, "aes", \$aes_asm_obj, \$aes_asm_src); + win32_import_asm($mf_des_asm, "des", \$des_enc_obj, \$des_enc_src); + win32_import_asm($mf_bf_asm, "bf", \$bf_enc_obj, \$bf_enc_src); + win32_import_asm($mf_cast_asm, "cast", \$cast_enc_obj, \$cast_enc_src); + win32_import_asm($mf_rc4_asm, "rc4", \$rc4_enc_obj, \$rc4_enc_src); + win32_import_asm($mf_rc5_asm, "rc5", \$rc5_enc_obj, \$rc5_enc_src); + win32_import_asm($mf_md5_asm, "md5", \$md5_asm_obj, \$md5_asm_src); + win32_import_asm($mf_sha_asm, "sha", \$sha1_asm_obj, \$sha1_asm_src); + win32_import_asm($mf_rmd_asm, "ripemd", \$rmd160_asm_obj, \$rmd160_asm_src); + win32_import_asm($mf_wp_asm, "whrlpool", \$whirlpool_asm_obj, \$whirlpool_asm_src); + win32_import_asm($mf_cpuid_asm, "", \$cpuid_asm_obj, \$cpuid_asm_src); + $perl_asm = 1; } if ($shlib && $FLAVOR !~ /CE/) @@ -318,4 +302,31 @@ sub do_link_rule return($ret); } +sub win32_import_asm + { + my ($mf_var, $asm_name, $oref, $sref) = @_; + my $asm_dir; + if ($asm_name eq "") + { + $asm_dir = "crypto\\"; + } + else + { + $asm_dir = "crypto\\$asm_name\\asm\\"; + } + + $$oref = ""; + $mf_var =~ s/\.o/.obj/g; + + foreach (split(/ /, $mf_var)) + { + $$oref .= $asm_dir . $_ . " "; + } + $$oref =~ s/ $//; + $$sref = $$oref; + $$sref =~ s/\.obj/.asm/g; + + } + + 1; |