diff options
28 files changed, 173 insertions, 161 deletions
diff --git a/configure.pl b/configure.pl index fe8f7719a..5bcda4973 100755 --- a/configure.pl +++ b/configure.pl @@ -24,14 +24,6 @@ my @DOCS = ( 'credits.txt', 'info.txt', 'license.txt', 'log.txt', 'thanks.txt', 'todo.txt', 'pgpkeys.asc'); -my %MODULE_SETS = - ( - 'unix' => [ 'alloc_mmap', 'es_egd', 'es_ftw', 'es_unix', 'fd_unix', - 'tm_unix' ], - 'beos' => [ 'es_beos', 'es_unix', 'fd_unix', 'tm_unix' ], - 'win32' => ['es_capi', 'es_win32', 'mux_win32', 'tm_win32' ], - ); - my $TRACING = 0; ################################################## @@ -68,7 +60,7 @@ sub main { 'version' => $VERSION_STRING, }); - my $module_list = get_options($config); + get_options($config); my $default_value_is = sub { my ($var, $val) = @_; @@ -107,7 +99,7 @@ sub main { &$default_value_is('docdir', os_info_for($os, 'doc_dir')); &$default_value_is('make_style', $COMPILER{$cc}{'makefile_style'}); - my @modules = choose_modules($config, $module_list); + autoload_modules($config) if($$config{'autoconfig'}); add_to($config, { 'includedir' => os_info_for($os, 'header_dir'), @@ -119,9 +111,8 @@ sub main { 'build_include_botan' => File::Spec->catdir($$config{'build-dir'}, 'include', 'botan'), - 'modules' => [ @modules ], - 'mp_bits' => find_mp_bits(@modules), - 'mod_libs' => [ using_libs($os, @modules) ], + 'mp_bits' => find_mp_bits(sort keys %{$$config{'modules'}}), + 'mod_libs' => [ using_libs($os, sort keys %{$$config{'modules'}}) ], 'sources' => { map_to($$config{'src-dir'}, dir_list($$config{'src-dir'})) @@ -212,44 +203,60 @@ sub trace { # Display Help and Quit # ################################################## sub display_help { - my $sets = join('|', sort keys %MODULE_SETS); + sub module_sets { + my %modsets; + for my $name (sort keys %MODULES) { + my %info = %{$MODULES{$name}}; + next unless (defined($info{'modset'})); + + for my $s (split(/,/, $info{'modset'})) { + $modsets{$s} = undef; + } + } + return sort keys %modsets; + } - my $listing = sub { - my (@list) = @_; + my $sets = join(' ', module_sets()); - return '' if (@list == 0); + my $listing = sub { + my (@list) = @_; - my ($output, $len) = ('', 0); + return '' if (@list == 0); - my $append = sub { - my ($to_append) = @_; - $output .= $to_append; - $len += length $to_append; - }; + my ($output, $len) = ('', 0); - foreach my $name (sort @list) { - next if $name eq 'defaults'; - if($len > 71) { - $output .= "\n "; - $len = 3; - } - &$append($name . ' '); - } - chop $output; - return $output; - }; + my $append = sub { + my ($to_append) = @_; + $output .= $to_append; + $len += length $to_append; + }; - my $modules = &$listing(keys %MODULES); - my $compilers = &$listing(keys %COMPILER); - my $oses = &$listing(keys %OPERATING_SYSTEM); - my $cpus = &$listing(keys %CPU); + foreach my $name (sort @list) { + next if $name eq 'defaults'; + if($len > 71) { + $output .= "\n "; + $len = 3; + } + &$append($name . ' '); + } + chop $output; + return $output; + }; - my $helptxt = <<ENDOFHELP; + my $modules = &$listing(keys %MODULES); + my $compilers = &$listing(keys %COMPILER); + my $oses = &$listing(keys %OPERATING_SYSTEM); + my $cpus = &$listing(keys %CPU); + + my $helptxt = <<ENDOFHELP; Usage for $0 (Botan $VERSION_STRING): + --help display this help + --version display the version of Botan --quiet display only warnings and errors + --trace enable tracing To change where the library is installed: @@ -261,6 +268,7 @@ Usage for $0 (Botan $VERSION_STRING): --build-dir=DIR: setup the build in DIR --local-config=FILE: include the contents of FILE into build.h + --debug: set compiler flags for debugging --no-shared: don't build shared libararies --make-style=STYLE: override the guess as to what type of makefile to use @@ -383,33 +391,59 @@ sub choose_target { }); } -sub choose_modules { - my ($config, $mod_str) = @_; +# Add modules that we think would work (unless autoconfig is off) +# to $$config{'modules'} +sub autoload_modules { + my ($config) = @_; - $mod_str = '' unless defined $mod_str; + my $cc = $$config{'compiler'}; + my $os = $$config{'os'}; + my $arch = $$config{'arch'}; + my $submodel = $$config{'submodel'}; - my @modules = grep { $_ ne '' } split(/,/, $mod_str); + my $asm_ok = $$config{'asm_ok'}; - if($$config{'autoconfig'}) - { - foreach my $mod (guess_mods($config, @modules)) { + foreach my $mod (sort keys %MODULES) { + my %modinfo = %{ $MODULES{$mod} }; - autoconfig("Enabling module $mod") - unless in_array($mod, \@modules); + if(defined($$config{'modules'}{$mod})) { + autoconfig("Module $mod - loading by user request"); + next; + } - push @modules, $mod; + if($modinfo{'load_on'} eq 'request') { + autoconfig("Module $mod - won't use, loaded by request only"); + next; + } + if(!$asm_ok and $modinfo{'load_on'} eq 'asm_ok') { + autoconfig("Module $mod - won't use; avoiding due to use of --no-asm"); + next; + } + + my @cc_list = @{ $modinfo{'cc'} }; + if(scalar @cc_list > 0 && !in_array($cc, \@cc_list)) { + autoconfig("Module $mod - won't use, not compatbile with CC $cc"); + next; } - } - # Uniqify @modules - my %uniqed_mods = map_to(undef, @modules); - @modules = sort keys %uniqed_mods; + my @os_list = @{ $modinfo{'os'} }; + if(scalar @os_list > 0 && !in_array($os, \@os_list)) { + autoconfig("Module $mod - won't use, not compatible with OS $os"); + next; + } + + my @arch_list = @{ $modinfo{'arch'} }; + if(scalar @arch_list > 0 && + !in_array($arch, \@arch_list) && + !in_array($submodel, \@arch_list)) { + autoconfig("Module $mod - won't use, " . + "doesn't run on CPU $arch/$submodel"); + next; + } - foreach (@modules) { - croak("Module '$_' isn't known (try --help)") - unless defined $MODULES{$_}; + autoconfig("Module $mod - autoloading"); + $$config{'modules'}{$mod} = 1; } - return @modules; } sub get_options { @@ -422,6 +456,8 @@ sub get_options { }; $$config{'verbose'} = 1; + $$config{'asm_ok'} = 1; + $$config{'modules'} = {}; sub arch_info { my $arg = $_[0]; @@ -460,8 +496,32 @@ sub get_options { return $out; } - my $module_set = ''; - my @modules; + sub add_modules { + my ($config,$mods) = @_; + + foreach my $mod (split(/,/, $mods)) { + $$config{'modules'}{$mod} = 1; + } + } + + sub add_module_sets { + my ($config,$sets) = @_; + + foreach my $set (split(/,/, $sets)) { + for my $name (sort keys %MODULES) { + my %info = %{$MODULES{$name}}; + + next unless (defined($info{'modset'})); + + for my $s (split(/,/, $info{'modset'})) { + if($s eq $set) { + $$config{'modules'}{$name} = 1; + } + } + } + } + } + exit 1 unless GetOptions( 'help' => sub { display_help(); }, 'module-info' => sub { emit_help(module_info()); }, @@ -486,30 +546,22 @@ sub get_options { 'make-style=s' => sub { &$save_option(@_); }, - 'modules=s' => \@modules, - 'module-set=s' => \$module_set, + 'module=s' => sub { add_modules($config, $_[1]); }, + 'modules=s' => sub { add_modules($config, $_[1]); }, + 'module-set=s' => sub { add_module_sets($config, $_[1]); }, + 'module-sets=s' => sub { add_module_sets($config, $_[1]); }, 'trace' => sub { $TRACING = 1; }, 'debug' => sub { &$save_option($_[0], 1); }, 'no-shared' => sub { $$config{'shared'} = 'no'; }, + 'no-asm' => sub { $$config{'asm_ok'} = 0; }, 'noauto' => sub { $$config{'autoconfig'} = 0; }, 'dumb-gcc|gcc295x' => sub { $$config{'gcc_bug'} = 1; } ); - croak("Module set $module_set isn't known (try --help)") - if($module_set && !defined($MODULE_SETS{$module_set})); - - if($module_set) { - foreach (@{ $MODULE_SETS{$module_set} }) { push @modules,$_; } - } - - my $mod_str = join(',', @modules); - - return $mod_str if($#ARGV == -1); - - warning("Unknown options $ARGV[0]"); - display_help(); + # All arguments should now be consumed + croak("Unknown option $ARGV[0] (try --help)") unless($#ARGV == -1); } ################################################## @@ -603,6 +655,8 @@ sub os_alias { sub os_info_for { my ($os,$what) = @_; + die unless defined($os); + croak('os_info_for called with an os of defaults (internal problem)') if($os eq 'defaults'); @@ -883,9 +937,7 @@ sub realname { sub load_modules { my ($config) = @_; - my @modules = @{$$config{'modules'}}; - - foreach my $mod (@modules) { + foreach my $mod (sort keys %{$$config{'modules'}}) { load_module($config, $mod); } @@ -949,7 +1001,7 @@ sub load_modules { } my @defarray; - foreach my $mod (@modules) { + foreach my $mod (sort keys %{$$config{'modules'}}) { my $defs = $MODULES{$mod}{'define'}; next unless $defs; @@ -1227,20 +1279,19 @@ sub read_module_files { ################################################## # # ################################################## + sub get_module_info { my ($name, $file) = @_; my $reader = make_reader($file); my %info; $info{'name'} = $name; - $info{'load_on'} = 'requeste'; # default unless specified + $info{'load_on'} = 'request'; # default unless specified $info{'libs'} = {}; while($_ = &$reader()) { match_any_of($_, \%info, 'quoted', 'realname:note'); - match_any_of($_, \%info, 'unquoted', 'define:mp_bits'); - - $info{'load_on'} = $1 if(/^load_on: (.*)$/); + match_any_of($_, \%info, 'unquoted', 'define:mp_bits:modset:load_on'); read_list($_, $reader, 'arch', list_push(\@{$info{'arch'}})); read_list($_, $reader, 'cc', list_push(\@{$info{'cc'}})); @@ -1380,57 +1431,6 @@ sub get_cc_info { return %info; } -sub guess_mods { - my ($config, @modules) = @_; - - my $cc = $$config{'compiler'}; - my $os = $$config{'os'}; - my $arch = $$config{'arch'}; - my $submodel = $$config{'submodel'}; - - my $asm_ok = ($$config{'debug'} == 0); - - my @usable_modules; - - foreach my $mod (sort keys %MODULES) { - my %modinfo = %{ $MODULES{$mod} }; - - if($modinfo{'load_on'} eq 'request') { - autoconfig("Won't use module $mod - by request only") - unless in_array($mod, \@modules); - next; - } - if(!$asm_ok and $modinfo{'load_on'} eq 'asm_ok') { - autoconfig("Won't use module $mod - uses assembly, using --debug"); - next; - } - - my @cc_list = @{ $modinfo{'cc'} }; - if(scalar @cc_list > 0 && !in_array($cc, \@cc_list)) { - autoconfig("Won't use module $mod - not compatbile with $cc"); - next; - } - - my @os_list = @{ $modinfo{'os'} }; - if(scalar @os_list > 0 && !in_array($os, \@os_list)) { - autoconfig("Won't use module $mod - not compatible with $os"); - next; - } - - my @arch_list = @{ $modinfo{'arch'} }; - if(scalar @arch_list > 0 && - !in_array($arch, \@arch_list) && - !in_array($submodel, \@arch_list)) { - autoconfig("Won't use module $mod - " . - "doesn't run on $arch/$submodel"); - next; - } - - push @usable_modules, $mod; - } - return @usable_modules; -} - ################################################## # # ################################################## diff --git a/modules/alg_amd64/modinfo.txt b/modules/alg_amd64/modinfo.txt index f9023b273..313d9ea03 100644 --- a/modules/alg_amd64/modinfo.txt +++ b/modules/alg_amd64/modinfo.txt @@ -2,7 +2,7 @@ realname "Algorithm x86-64 Assembler" mp_bits 64 -load_on: asm_ok +load_on asm_ok <replace> sha160.cpp diff --git a/modules/alg_ia32/modinfo.txt b/modules/alg_ia32/modinfo.txt index fdd955d11..33d30e8bf 100644 --- a/modules/alg_ia32/modinfo.txt +++ b/modules/alg_ia32/modinfo.txt @@ -2,7 +2,7 @@ realname "Algorithm x86 Assembler" mp_bits 32 -load_on: asm_ok +load_on asm_ok <replace> md4.cpp diff --git a/modules/alloc_mmap/modinfo.txt b/modules/alloc_mmap/modinfo.txt index 6426bdf24..8cc2b206e 100644 --- a/modules/alloc_mmap/modinfo.txt +++ b/modules/alloc_mmap/modinfo.txt @@ -1,8 +1,9 @@ realname "Disk Based Allocation System" define ALLOC_MMAP +modset unix -load_on: auto +load_on auto <add> mmap_mem.cpp diff --git a/modules/comp_bzip2/modinfo.txt b/modules/comp_bzip2/modinfo.txt index 92ffb2085..efedc097f 100644 --- a/modules/comp_bzip2/modinfo.txt +++ b/modules/comp_bzip2/modinfo.txt @@ -3,8 +3,9 @@ realname "Bzip2 Compressor" define COMPRESSOR_BZIP2 +modset compression -load_on: request +load_on request <add> bzip2.h diff --git a/modules/comp_zlib/modinfo.txt b/modules/comp_zlib/modinfo.txt index 1687ad312..c1f1f998c 100644 --- a/modules/comp_zlib/modinfo.txt +++ b/modules/comp_zlib/modinfo.txt @@ -4,7 +4,8 @@ realname "Zlib Compressor" define COMPRESSOR_ZLIB #define COMPRESSOR_ZLIB,COMPRESSOR_GZIP -load_on: request +load_on request +modset compression <add> zlib.h diff --git a/modules/eng_aep/modinfo.txt b/modules/eng_aep/modinfo.txt index 1ffdb81d5..497a0c89f 100644 --- a/modules/eng_aep/modinfo.txt +++ b/modules/eng_aep/modinfo.txt @@ -2,7 +2,7 @@ realname "AEP Engine" define ENGINE_AEP,ENTROPY_SRC_AEP -load_on: request +load_on request <add> eng_aep.cpp diff --git a/modules/eng_gmp/modinfo.txt b/modules/eng_gmp/modinfo.txt index bc44986de..e65e411fd 100644 --- a/modules/eng_gmp/modinfo.txt +++ b/modules/eng_gmp/modinfo.txt @@ -2,7 +2,7 @@ realname "GMP Engine" define ENGINE_GNU_MP -load_on: request +load_on request <add> eng_gmp.cpp diff --git a/modules/eng_ossl/modinfo.txt b/modules/eng_ossl/modinfo.txt index 3378a9158..7892e8e90 100644 --- a/modules/eng_ossl/modinfo.txt +++ b/modules/eng_ossl/modinfo.txt @@ -2,7 +2,7 @@ realname "OpenSSL Engine" define ENGINE_OPENSSL -load_on: request +load_on request <add> eng_ossl.cpp diff --git a/modules/es_beos/modinfo.txt b/modules/es_beos/modinfo.txt index 292f7832d..a7e62cfb3 100644 --- a/modules/es_beos/modinfo.txt +++ b/modules/es_beos/modinfo.txt @@ -1,8 +1,9 @@ realname "BeOS Entropy Source" define ENTROPY_SRC_BEOS +modset beos -load_on: auto +load_on auto <add> es_beos.h diff --git a/modules/es_capi/modinfo.txt b/modules/es_capi/modinfo.txt index 8a0f3041c..40104664b 100644 --- a/modules/es_capi/modinfo.txt +++ b/modules/es_capi/modinfo.txt @@ -1,8 +1,8 @@ realname "Win32 CryptoAPI Entropy Source" define ENTROPY_SRC_CAPI - -load_on: auto +load_on auto +modset win32 <add> es_capi.h diff --git a/modules/es_egd/modinfo.txt b/modules/es_egd/modinfo.txt index 06261862c..6b34f395c 100644 --- a/modules/es_egd/modinfo.txt +++ b/modules/es_egd/modinfo.txt @@ -2,7 +2,8 @@ realname "EGD Entropy Source" define ENTROPY_SRC_EGD -load_on: auto +load_on auto +modset unix <add> es_egd.h diff --git a/modules/es_ftw/modinfo.txt b/modules/es_ftw/modinfo.txt index d3e93db69..d932523fd 100644 --- a/modules/es_ftw/modinfo.txt +++ b/modules/es_ftw/modinfo.txt @@ -2,7 +2,8 @@ realname "File Tree Walking Entropy Source" define ENTROPY_SRC_FTW -load_on: auto +load_on auto +modset unix <add> es_ftw.h diff --git a/modules/es_unix/modinfo.txt b/modules/es_unix/modinfo.txt index ccb499b82..f16e21289 100644 --- a/modules/es_unix/modinfo.txt +++ b/modules/es_unix/modinfo.txt @@ -1,8 +1,9 @@ realname "Generic Unix Entropy Source" define ENTROPY_SRC_UNIX +modset unix,beos -load_on: auto +load_on auto <add> es_unix.cpp diff --git a/modules/es_win32/modinfo.txt b/modules/es_win32/modinfo.txt index cc8a525bc..931760979 100644 --- a/modules/es_win32/modinfo.txt +++ b/modules/es_win32/modinfo.txt @@ -4,8 +4,9 @@ realname "Win32 Entropy Source" #note "This module will not run under NT4" define ENTROPY_SRC_WIN32 +modset win32 -load_on: auto +load_on auto <add> es_win32.h diff --git a/modules/fd_unix/modinfo.txt b/modules/fd_unix/modinfo.txt index c659f5377..e1f30ea28 100644 --- a/modules/fd_unix/modinfo.txt +++ b/modules/fd_unix/modinfo.txt @@ -1,8 +1,9 @@ realname "Unix I/O support for Pipe" define PIPE_UNIXFD_IO +modset unix,beos -load_on: auto +load_on auto <add> fd_unix.h diff --git a/modules/ml_unix/modinfo.txt b/modules/ml_unix/modinfo.txt index b25468586..201a30ead 100644 --- a/modules/ml_unix/modinfo.txt +++ b/modules/ml_unix/modinfo.txt @@ -1,6 +1,6 @@ realname "Memory Locking for Unix" -load_on: auto +load_on auto <replace> mlock.cpp diff --git a/modules/ml_win32/modinfo.txt b/modules/ml_win32/modinfo.txt index e886c758f..92936e1de 100644 --- a/modules/ml_win32/modinfo.txt +++ b/modules/ml_win32/modinfo.txt @@ -1,6 +1,6 @@ realname "Memory Locking for Win32" -load_on: auto +load_on auto <replace> mlock.cpp diff --git a/modules/mp_amd64/modinfo.txt b/modules/mp_amd64/modinfo.txt index 0e24da0d9..527d9a2c6 100644 --- a/modules/mp_amd64/modinfo.txt +++ b/modules/mp_amd64/modinfo.txt @@ -2,7 +2,7 @@ realname "MPI Assembler Backend for x86-64/AMD64 Systems" mp_bits 64 -load_on: asm_ok +load_on asm_ok <replace> mp_asm.h diff --git a/modules/mp_asm64/modinfo.txt b/modules/mp_asm64/modinfo.txt index 256a439d3..6c51ed5b8 100644 --- a/modules/mp_asm64/modinfo.txt +++ b/modules/mp_asm64/modinfo.txt @@ -2,7 +2,7 @@ realname "MPI Assembler Backend for 64 bit Systems" mp_bits 64 -load_on: asm_ok +load_on asm_ok <replace> mp_asm.h diff --git a/modules/mp_ia32/modinfo.txt b/modules/mp_ia32/modinfo.txt index 805fb656f..2fa8db56e 100644 --- a/modules/mp_ia32/modinfo.txt +++ b/modules/mp_ia32/modinfo.txt @@ -2,7 +2,7 @@ realname "MPI Assembler Backend for x86 Systems" mp_bits 32 -load_on: asm_ok +load_on asm_ok <replace> mp_asm.h diff --git a/modules/mux_pthr/modinfo.txt b/modules/mux_pthr/modinfo.txt index f14137dd5..88de70de0 100644 --- a/modules/mux_pthr/modinfo.txt +++ b/modules/mux_pthr/modinfo.txt @@ -2,7 +2,7 @@ realname "Pthread Mutex" define MUTEX_PTHREAD -load_on: auto +load_on auto <add> mux_pthr.cpp diff --git a/modules/mux_qt/modinfo.txt b/modules/mux_qt/modinfo.txt index 32094eaf4..a21108c79 100644 --- a/modules/mux_qt/modinfo.txt +++ b/modules/mux_qt/modinfo.txt @@ -4,7 +4,7 @@ define MUTEX_QT note "You'll probably have to add -I/-L flags to the Makefile to find Qt" -load_on: request +load_on request <add> mux_qt.cpp diff --git a/modules/mux_win32/modinfo.txt b/modules/mux_win32/modinfo.txt index 320d21b5b..d235ff73c 100644 --- a/modules/mux_win32/modinfo.txt +++ b/modules/mux_win32/modinfo.txt @@ -1,8 +1,9 @@ realname "Win32 Mutex" define MUTEX_WIN32 +modset win32 -load_on: auto +load_on auto <add> mux_win32.cpp diff --git a/modules/tm_hard/modinfo.txt b/modules/tm_hard/modinfo.txt index 35f13dd91..5c928cf83 100644 --- a/modules/tm_hard/modinfo.txt +++ b/modules/tm_hard/modinfo.txt @@ -2,7 +2,7 @@ realname "Hardware Timer" define TIMER_HARDWARE -load_on: asm_ok +load_on asm_ok <add> tm_hard.cpp diff --git a/modules/tm_posix/modinfo.txt b/modules/tm_posix/modinfo.txt index b6c1d6916..e9298a81c 100644 --- a/modules/tm_posix/modinfo.txt +++ b/modules/tm_posix/modinfo.txt @@ -2,7 +2,7 @@ realname "POSIX Timer" define TIMER_POSIX -load_on: auto +load_on auto <add> tm_posix.cpp diff --git a/modules/tm_unix/modinfo.txt b/modules/tm_unix/modinfo.txt index 405e341c4..495914589 100644 --- a/modules/tm_unix/modinfo.txt +++ b/modules/tm_unix/modinfo.txt @@ -2,7 +2,8 @@ realname "Unix Timer" define TIMER_UNIX -load_on: auto +load_on auto +modset unix,beos <add> tm_unix.cpp diff --git a/modules/tm_win32/modinfo.txt b/modules/tm_win32/modinfo.txt index cc5f06197..74c4a59ea 100644 --- a/modules/tm_win32/modinfo.txt +++ b/modules/tm_win32/modinfo.txt @@ -1,8 +1,9 @@ realname "Win32 Timer" define TIMER_WIN32 +modset win32 -load_on: auto +load_on auto <add> tm_win32.cpp |