diff options
author | lloyd <[email protected]> | 2008-09-30 02:36:25 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-09-30 02:36:25 +0000 |
commit | 8b063a0b60946578ba16e8e7d8ee4223fadb5eb9 (patch) | |
tree | caa6c4c55c90a8c5e5837abb615ed9e14c5b5345 | |
parent | c4f3550ce65b998bd75ddb9e9aff9f7729dc3573 (diff) |
Rewrite part of the module loading code in configure.pl, now dependencies
seem to be handled correctly (er, at least mostly), and more importantly
the asm MPI modules are detected and used correctly (at least on x86-64
and x86).
-rwxr-xr-x | configure.pl | 256 | ||||
-rw-r--r-- | src/asn1/info.txt | 2 | ||||
-rw-r--r-- | src/bigint/info.txt | 4 | ||||
-rw-r--r-- | src/bigint/monty_generic/info.txt | 2 | ||||
-rw-r--r-- | src/bigint/mp_amd64/info.txt | 2 | ||||
-rw-r--r-- | src/bigint/mp_generic/info.txt | 2 | ||||
-rw-r--r-- | src/bigint/mulop_amd64/info.txt | 2 | ||||
-rw-r--r-- | src/bigint/mulop_generic/info.txt | 2 | ||||
-rw-r--r-- | src/bigint/mulop_ia32/info.txt | 4 | ||||
-rw-r--r-- | src/hash/mdx_hash/info.txt | 2 | ||||
-rw-r--r-- | src/kdf/mgf1/info.txt | 2 | ||||
-rw-r--r-- | src/pk/pubkey/info.txt | 2 |
12 files changed, 133 insertions, 149 deletions
diff --git a/configure.pl b/configure.pl index 0477d807c..be797dfd6 100755 --- a/configure.pl +++ b/configure.pl @@ -108,7 +108,9 @@ sub main { &$default_value_is('docdir', os_info_for($os, 'doc_dir')); &$default_value_is('make_style', $COMPILER{$cc}{'makefile_style'}); - autoload_modules($config) if($$config{'autoconfig'}); + scan_modules($config); + + print_enabled_modules($config); add_to($config, { 'includedir' => os_info_for($os, 'header_dir'), @@ -403,7 +405,12 @@ sub choose_target { } sub module_runs_on { - my ($noisy, $modinfo, $mod, $arch, $submodel, $os, $cc) = @_; + my ($config, $modinfo, $mod, $noisy) = @_; + + my $cc = $$config{'compiler'}; + my $os = $$config{'os'}; + my $submodel = $$config{'submodel'}; + my $arch = $$config{'arch'}; my %modinfo = %{$modinfo}; @@ -438,112 +445,86 @@ sub module_runs_on { return 1; } +sub can_enable_module { + my ($config, $mod, $for_dep) = @_; -# Add modules that we think would work (unless autoconfig is off) -# to $$config{'modules'} -sub autoload_modules { - my ($config) = @_; + my %modinfo = %{ $MODULES{$mod} }; - my $cc = $$config{'compiler'}; - my $os = $$config{'os'}; - my $arch = $$config{'arch'}; - my $submodel = $$config{'submodel'}; + my $is_enabled = 0; - my $asm_ok = $$config{'asm_ok'}; + if(defined($$config{'modules'}{$mod})) { + return '' if($$config{'modules'}{$mod} < 0); + $is_enabled = 1; + } - my %loaded; # type -> { mod1 => 1, mod2 => 1 } + unless($is_enabled) { + return '' if $modinfo{'load_on'} eq 'dep' and $for_dep == 0; + return '' if $modinfo{'load_on'} eq 'request'; + } - MOD: foreach my $mod (sort keys %MODULES) { - my %modinfo = %{ $MODULES{$mod} }; + return '' unless module_runs_on($config, \%modinfo, $mod, 0); - my $realname = $modinfo{'realname'}; + my @deps; + push @deps, $mod; - my $type = $modinfo{'type'}; + LINE: foreach (@{$modinfo{'requires'}}) { - autoconfig("$mod '$realname' is $type"); + for my $req_mod (split(/\|/, $_)) { - if(defined($$config{'modules'}{$mod})) { - my $n = $$config{'modules'}{$mod}; + next unless defined $MODULES{$req_mod}; - if($n < 0) { - autoconfig("$mod ($realname): disabled by user request"); - next; - } - else { - #$loaded{$type}{$mod} = 1; - #autoconfig("$mod ($realname): loading by user request"); - next; + if(can_enable_module($config, $req_mod, 1)) { + #autoconfig("Use $req_mod to satisfy dep request $_ for mod $mod"); + push @deps, $req_mod; + next LINE; } } - my @to_enable; - - foreach my $req_mod_l (@{$modinfo{'requires'}}) { - my @any_of = split(/\|/, $req_mod_l); - - autoconfig("Finding a dep $req_mod_l of $realname"); - - my $mod_to_use = undef; - for my $req_mod (@any_of) { - - # one already enabled or disabled - if(defined($$config{'modules'}{$req_mod})) { - my $n = $$config{'modules'}{$req_mod}; + autoconfig("Could not get a dep match for $_ for mod $mod"); + # Could not find a match + return ''; + } - next if($n < 0); + return join(' ', @deps); +} - if($n > 0) { - $mod_to_use = $mod; - $loaded{$type}{$mod} = 1; - $$config{'modules'}{$req_mod} = 1; - last; - } - } - elsif(module_runs_on(0, \%modinfo, $realname, $arch, $submodel, $os, $cc)) { - autoconfig("XXX Enabling $req_mod for $mod"); - $mod_to_use = $mod; - $loaded{$type}{$mod} = 1; - $$config{'modules'}{$req_mod} = 1; - } - } +sub scan_modules { + my ($config) = @_; - unless(defined $mod_to_use) { - autoconfig("Disabling module $mod due to missing dep $req_mod_l"); - $$config{'modules'}{$mod} = -1; - } - } + MOD: foreach my $mod (sort keys %MODULES) { + my %modinfo = %{ $MODULES{$mod} }; - next unless module_runs_on(1, \%modinfo, $realname, $arch, $submodel, $os, $cc); + my @mods = split(/ /, can_enable_module($config, $mod, 0)); - if(!$asm_ok and $modinfo{'load_on'} eq 'asm_ok') { - autoconfig("$mod ($realname): " . - "skipping due to --no-asm"); + if($#mods < 0) { + autoconfig("Will not enable $mod"); next; } - if($modinfo{'load_on'} eq 'request') { - autoconfig("$mod ($realname): skipping, loaded by request only"); - next; + foreach my $req_mod (@mods) { + #autoconfig("Enabling module $req_mod"); + $$config{'modules'}{$req_mod} = 1; } + } +} - foreach my $req_mod (@to_enable) { - autoconfig("Enabling module $req_mod; " . - "required by $mod '$realname'"); +sub print_enabled_modules { + my ($config) = @_; - my $req_type = $MODULES{$req_mod}{'type'}; + my %by_type; - $loaded{$req_type}{$req_mod} = 1; - $$config{'modules'}{$req_mod} = 1; - load_module($config, $req_mod); - } + foreach my $mod (sort keys %{$$config{'modules'}}) { + + my $n = $$config{'modules'}{$mod}; - trace("Enabling $mod ($realname): loading"); - $loaded{$type}{$mod} = 1; - $$config{'modules'}{$mod} = 1; + if($n > 0) { + my $type = $MODULES{$mod}{'type'}; + $by_type{$type}{$mod} = $n; + } } - for my $type (sort keys %loaded) { - my %mods = %{$loaded{$type}}; + for my $type (sort keys %by_type) { + my %mods = %{$by_type{$type}}; print with_diagnostic('loading', $type . ': ' . join(' ', sort keys %mods)); } @@ -1062,6 +1043,63 @@ sub realname { ################################################## # # ################################################## + +sub load_module { + my ($config, $modname) = @_; + + trace("load_module($modname)"); + + croak("Unknown module $modname") unless defined($MODULES{$modname}); + + my %module = %{$MODULES{$modname}}; + + my $works_on = sub { + my ($what, $lst_ref) = @_; + my @lst = @{$lst_ref}; + return 1 if not @lst; # empty list -> no restrictions + return 1 if $what eq 'generic'; # trust the user + return in_array($what, \@lst); + }; + + # Check to see if everything is OK WRT system requirements + my $os = $$config{'os'}; + + croak("Module '$modname' does not run on $os") + unless(&$works_on($os, $module{'os'})); + + my $arch = $$config{'arch'}; + my $sub = $$config{'submodel'}; + + croak("Module '$modname' does not run on $arch/$sub") + unless(&$works_on($arch, $module{'arch'}) or + &$works_on($sub, $module{'arch'})); + + my $cc = $$config{'compiler'}; + + croak("Module '$modname' does not work with $cc") + unless(&$works_on($cc, $module{'cc'})); + + trace($modname); + trace($module{'moddirs'}); + + my $handle_files = sub { + my($lst, $func) = @_; + return unless defined($lst); + + foreach (sort @$lst) { + &$func($module{'moddirs'}, $config, $_); + } + }; + + &$handle_files($module{'ignore'}, \&ignore_file); + &$handle_files($module{'add'}, \&add_file); + &$handle_files($module{'replace'}, + sub { ignore_file(@_); add_file(@_); }); + + warning($modname, ': ', $module{'note'}) + if(defined($module{'note'})); +} + sub load_modules { my ($config) = @_; @@ -1073,7 +1111,6 @@ sub load_modules { load_module($config, $mod); push @mod_names, $mod; - } $$config{'mod-list'} = join("\n", @mod_names); @@ -1174,62 +1211,6 @@ sub load_modules { $$config{'defines'} = &$gen_defines(); } -sub load_module { - my ($config, $modname) = @_; - - trace("load_module($modname)"); - - croak("Unknown module $modname") unless defined($MODULES{$modname}); - - my %module = %{$MODULES{$modname}}; - - my $works_on = sub { - my ($what, $lst_ref) = @_; - my @lst = @{$lst_ref}; - return 1 if not @lst; # empty list -> no restrictions - return 1 if $what eq 'generic'; # trust the user - return in_array($what, \@lst); - }; - - # Check to see if everything is OK WRT system requirements - my $os = $$config{'os'}; - - croak("Module '$modname' does not run on $os") - unless(&$works_on($os, $module{'os'})); - - my $arch = $$config{'arch'}; - my $sub = $$config{'submodel'}; - - croak("Module '$modname' does not run on $arch/$sub") - unless(&$works_on($arch, $module{'arch'}) or - &$works_on($sub, $module{'arch'})); - - my $cc = $$config{'compiler'}; - - croak("Module '$modname' does not work with $cc") - unless(&$works_on($cc, $module{'cc'})); - - trace($modname); - trace($module{'moddirs'}); - - my $handle_files = sub { - my($lst, $func) = @_; - return unless defined($lst); - - foreach (sort @$lst) { - &$func($module{'moddirs'}, $config, $_); - } - }; - - &$handle_files($module{'ignore'}, \&ignore_file); - &$handle_files($module{'add'}, \&add_file); - &$handle_files($module{'replace'}, - sub { ignore_file(@_); add_file(@_); }); - - warning($modname, ': ', $module{'note'}) - if(defined($module{'note'})); -} - ################################################## # # ################################################## @@ -1481,6 +1462,7 @@ sub get_module_info { $info{'moddirs'} = $dirs; $info{'load_on'} = 'request'; # default unless specified $info{'libs'} = {}; + $info{'use'} = 'no'; my @dir_arr = File::Spec->splitdir($dirs); $info{'type'} = $dir_arr[$#dir_arr-2]; # cipher, hash, ... diff --git a/src/asn1/info.txt b/src/asn1/info.txt index 4e561afc5..e923bd1d8 100644 --- a/src/asn1/info.txt +++ b/src/asn1/info.txt @@ -2,7 +2,7 @@ realname "ASN.1/BER/DER module" define ASN1 -load_on request +load_on auto <requires> bigint diff --git a/src/bigint/info.txt b/src/bigint/info.txt index 3e1531754..d6c5df763 100644 --- a/src/bigint/info.txt +++ b/src/bigint/info.txt @@ -6,8 +6,8 @@ define BIGINT <requires> hex -mp_amd64 -monty_amd64|monty_generic +mp_amd64|mp_asm64|mp_ia32|mp_ia32_msvc|mp_generic +monty_generic mulop_generic </requires> diff --git a/src/bigint/monty_generic/info.txt b/src/bigint/monty_generic/info.txt index 9187e9d22..6f5f0e722 100644 --- a/src/bigint/monty_generic/info.txt +++ b/src/bigint/monty_generic/info.txt @@ -1,6 +1,6 @@ realname "Montgomery Reduction" -load_on request +load_on dep <add> mp_monty.cpp diff --git a/src/bigint/mp_amd64/info.txt b/src/bigint/mp_amd64/info.txt index c177c2a27..84a5bcf53 100644 --- a/src/bigint/mp_amd64/info.txt +++ b/src/bigint/mp_amd64/info.txt @@ -2,7 +2,7 @@ realname "MPI Core (x86-64)" mp_bits 64 -load_on request +load_on dep <add> mp_asm.h diff --git a/src/bigint/mp_generic/info.txt b/src/bigint/mp_generic/info.txt index 8b319c58d..8bf75fec3 100644 --- a/src/bigint/mp_generic/info.txt +++ b/src/bigint/mp_generic/info.txt @@ -1,6 +1,6 @@ realname "MPI Core (C++)" -load_on request +load_on dep <add> mp_asm.h diff --git a/src/bigint/mulop_amd64/info.txt b/src/bigint/mulop_amd64/info.txt index 0960ac4d6..670780d9c 100644 --- a/src/bigint/mulop_amd64/info.txt +++ b/src/bigint/mulop_amd64/info.txt @@ -2,7 +2,7 @@ realname "BigInt Multiply-Add (x86-64)" mp_bits 64 -load_on request +load_on dep <add> mp_mulop_amd64.S diff --git a/src/bigint/mulop_generic/info.txt b/src/bigint/mulop_generic/info.txt index 1fe3c2868..28ebe41eb 100644 --- a/src/bigint/mulop_generic/info.txt +++ b/src/bigint/mulop_generic/info.txt @@ -1,6 +1,6 @@ realname "BigInt Multiply-Add" -load_on request +load_on dep <add> mp_mulop.cpp diff --git a/src/bigint/mulop_ia32/info.txt b/src/bigint/mulop_ia32/info.txt index 0814bc08a..1c89e95c1 100644 --- a/src/bigint/mulop_ia32/info.txt +++ b/src/bigint/mulop_ia32/info.txt @@ -2,6 +2,8 @@ realname "BigInt Multiply-Add (IA-32)" mp_bits 32 +# Out of date, still implements bigint_mul_add_words + load_on request <add> @@ -9,7 +11,7 @@ mp_mulop.S </add> <requires> -asm_amd64 +asm_ia32 </requires> <arch> diff --git a/src/hash/mdx_hash/info.txt b/src/hash/mdx_hash/info.txt index 22791f836..412c93350 100644 --- a/src/hash/mdx_hash/info.txt +++ b/src/hash/mdx_hash/info.txt @@ -2,7 +2,7 @@ realname "MDx Hash Base" define MDX_HASH_FUNCTION -load_on request +load_on dep <add> mdx_hash.cpp diff --git a/src/kdf/mgf1/info.txt b/src/kdf/mgf1/info.txt index a42273eb6..2f704173d 100644 --- a/src/kdf/mgf1/info.txt +++ b/src/kdf/mgf1/info.txt @@ -2,7 +2,7 @@ realname "MGF1" define MGF1 -load_on request +load_on dep <add> mgf1.h diff --git a/src/pk/pubkey/info.txt b/src/pk/pubkey/info.txt index ebcb4eb0e..480274670 100644 --- a/src/pk/pubkey/info.txt +++ b/src/pk/pubkey/info.txt @@ -2,7 +2,7 @@ realname "Public Key Base" define PUBKEY_BASE -load_on request +load_on dep <requires> bigint |