aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2006-09-04 15:41:29 +0000
committerlloyd <[email protected]>2006-09-04 15:41:29 +0000
commitd6375884e024c8cc16f4754a65bac2ecd81b0266 (patch)
tree94863ced603e6639254da732b7d379b54d93f8a6
parenta16da7366d606cda9e7881c2de951adf4495f2eb (diff)
Move some subroutines that were only used in one place inside the
function in question. Rename some variables Add a helper function in get_module_info
-rwxr-xr-xconfigure.pl180
1 files changed, 92 insertions, 88 deletions
diff --git a/configure.pl b/configure.pl
index 250b4003b..09fc5137d 100755
--- a/configure.pl
+++ b/configure.pl
@@ -1643,25 +1643,6 @@ sub list_push {
return sub { push @$listref, $_[0]; }
}
-sub set_undef {
- my ($hashref,$key) = @_;
-
- return sub {
- my ($arg) = @_;
- if(!defined($$hashref{$key})) { $$hashref{$key} = {}; }
- $$hashref{$key}{$arg} = undef;
- }
-}
-
-sub quoted_mapping {
- my $hashref = $_[0];
- return sub {
- my $line = $_[0];
- $line =~ m/^(\S*) -> \"(.*)\"$/;
- $$hashref{$1} = $2;
- }
-}
-
sub set_if {
my ($line, $what, $var) = @_;
$$var = $1 if($line =~ /^$what (.*)/);
@@ -1680,11 +1661,11 @@ sub set_if_any {
}
sub get_module_info {
- my ($MODULE, $MOD_DIR) = @_;
+ my ($name, $dir) = @_;
my %info;
- my $desc_file = File::Spec->catfile($MOD_DIR, $MODULE, 'modinfo.txt');
- die "(error): Module $MODULE does not seem to have a description file\n"
+ my $desc_file = File::Spec->catfile($dir, $name, 'modinfo.txt');
+ die "(error): Module $name does not seem to have a description file\n"
unless(-e $desc_file);
my $reader = make_reader($desc_file);
@@ -1719,22 +1700,36 @@ sub get_module_info {
100*$MAJOR_VERSION + 10*$MINOR_VERSION + $PATCH_VERSION;
if($needed_version > $have_version) {
- warn "Module $MODULE requires Botan version $version\n";
+ warn "Module $name requires Botan version $version\n";
return ();
}
}
else {
- warn "In module $MODULE, bad version code in require_version\n";
+ warn "In module $name, bad version code in require_version\n";
}
}
- read_hash($_, $reader, 'arch', set_undef(\%info, 'arch'));
- read_hash($_, $reader, 'os', set_undef(\%info, 'os'));
- read_hash($_, $reader, 'cc', set_undef(\%info, 'cc'));
+ sub set_undef {
+ my ($hashref,$key) = @_;
- read_hash($_, $reader, 'add', set_undef(\%info, 'add'));
- read_hash($_, $reader, 'ignore', set_undef(\%info, 'ignore'));
- read_hash($_, $reader, 'replace', set_undef(\%info, 'replace'));
+ return sub {
+ my ($arg) = @_;
+ if(!defined($$hashref{$key})) { $$hashref{$key} = {}; }
+ $$hashref{$key}{$arg} = undef;
+ }
+ }
+
+ sub read_and_set_undef {
+ my ($line,$reader,$hash,$key) = @_;
+ read_hash($line, $reader, $key, set_undef($hash, $key));
+ }
+
+ read_and_set_undef($_, $reader, \%info, 'arch');
+ read_and_set_undef($_, $reader, \%info, 'cc');
+ read_and_set_undef($_, $reader, \%info, 'os');
+ read_and_set_undef($_, $reader, \%info, 'add');
+ read_and_set_undef($_, $reader, \%info, 'replace');
+ read_and_set_undef($_, $reader, \%info, 'ignore');
read_hash($_, $reader, 'libs',
sub {
@@ -1771,33 +1766,6 @@ sub get_arch_info {
return %info;
}
-sub set_arch_defines {
- my $dir = $_[0];
-
- foreach my $arch (dir_list($dir)) {
- my %info = get_arch_info($arch, File::Spec->catfile($dir, $arch));
-
- $ARCH{$arch} = $info{'name'};
- $REALNAME{$arch} = $info{'realname'};
- $DEFAULT_SUBMODEL{$arch} = $info{'default_submodel'};
-
- foreach my $alias (@{$info{'aliases'}}) {
- $ARCH_ALIAS{$alias} = $arch;
- }
-
- foreach my $submodel (@{$info{'submodels'}}) {
- $ARCH{$submodel} = $arch;
- }
-
- if(defined($info{'submodel_aliases'})) {
- my %submodel_aliases = %{$info{'submodel_aliases'}};
- foreach my $sm_alias (keys %submodel_aliases) {
- $SUBMODEL_ALIAS{$sm_alias} = $submodel_aliases{$sm_alias};
- }
- }
- }
-}
-
sub get_os_info {
my ($name,$file) = @_;
my $reader = make_reader($file);
@@ -1826,37 +1794,6 @@ sub get_os_info {
return %info;
}
-sub set_os_defines {
- my $dir = $_[0];
-
- foreach my $os (dir_list($dir)) {
- my %info = get_os_info($os, File::Spec->catfile($dir, $os));
-
- $REALNAME{$os} = $info{'realname'};
- $OS_TYPE{$os} = $info{'os_type'};
- $OS_AR_COMMAND{$os} = $info{'ar_command'};
- $OS_OBJ_SUFFIX{$os} = $info{'obj_suffix'};
- $OS_SHARED_SUFFIX{$os} = $info{'so_suffix'};
- $OS_STATIC_SUFFIX{$os} = $info{'static_suffix'};
- $OS_AR_NEEDS_RANLIB{$os} = $info{'needs_ranlib'};
-
- $INSTALL_INFO{$os}{'root'} = $info{'install_root'};
- $INSTALL_INFO{$os}{'headers'} = $info{'header_dir'};
- $INSTALL_INFO{$os}{'libs'} = $info{'lib_dir'};
- $INSTALL_INFO{$os}{'docs'} = $info{'doc_dir'};
- $INSTALL_INFO{$os}{'user'} = $info{'install_user'};
- $INSTALL_INFO{$os}{'group'} = $info{'install_group'};
- $INSTALL_INFO{$os}{'command'} = $info{'install_cmd'};
-
- foreach my $alias (@{$info{'aliases'}}) {
- $OS_ALIAS{$alias} = $os;
- }
-
- @{$OS_SUPPORTS_SHARED{$os}} = @{$info{'supports_shared'}};
- @{$OS_SUPPORTS_ARCH{$os}} = @{$info{'arch'}};
- }
-}
-
sub get_cc_info {
my ($name,$file) = @_;
my $reader = make_reader($file);
@@ -1875,6 +1812,15 @@ sub get_cc_info {
read_hash($_, $reader, 'os', list_push(\@{$info{'os'}}));
read_hash($_, $reader, 'arch', list_push(\@{$info{'arch'}}));
+ sub quoted_mapping {
+ my $hashref = $_[0];
+ return sub {
+ my $line = $_[0];
+ $line =~ m/^(\S*) -> \"(.*)\"$/;
+ $$hashref{$1} = $2;
+ }
+ }
+
read_hash($_, $reader, 'mach_abi_linking',
quoted_mapping(\%{$info{'mach_abi_linking'}}));
read_hash($_, $reader, 'so_link_flags',
@@ -1892,6 +1838,64 @@ sub get_cc_info {
return %info;
}
+sub set_arch_defines {
+ my $dir = $_[0];
+
+ foreach my $arch (dir_list($dir)) {
+ my %info = get_arch_info($arch, File::Spec->catfile($dir, $arch));
+
+ $ARCH{$arch} = $info{'name'};
+ $REALNAME{$arch} = $info{'realname'};
+ $DEFAULT_SUBMODEL{$arch} = $info{'default_submodel'};
+
+ foreach my $alias (@{$info{'aliases'}}) {
+ $ARCH_ALIAS{$alias} = $arch;
+ }
+
+ foreach my $submodel (@{$info{'submodels'}}) {
+ $ARCH{$submodel} = $arch;
+ }
+
+ if(defined($info{'submodel_aliases'})) {
+ my %submodel_aliases = %{$info{'submodel_aliases'}};
+ foreach my $sm_alias (keys %submodel_aliases) {
+ $SUBMODEL_ALIAS{$sm_alias} = $submodel_aliases{$sm_alias};
+ }
+ }
+ }
+}
+
+sub set_os_defines {
+ my $dir = $_[0];
+
+ foreach my $os (dir_list($dir)) {
+ my %info = get_os_info($os, File::Spec->catfile($dir, $os));
+
+ $REALNAME{$os} = $info{'realname'};
+ $OS_TYPE{$os} = $info{'os_type'};
+ $OS_AR_COMMAND{$os} = $info{'ar_command'};
+ $OS_OBJ_SUFFIX{$os} = $info{'obj_suffix'};
+ $OS_SHARED_SUFFIX{$os} = $info{'so_suffix'};
+ $OS_STATIC_SUFFIX{$os} = $info{'static_suffix'};
+ $OS_AR_NEEDS_RANLIB{$os} = $info{'needs_ranlib'};
+
+ $INSTALL_INFO{$os}{'root'} = $info{'install_root'};
+ $INSTALL_INFO{$os}{'headers'} = $info{'header_dir'};
+ $INSTALL_INFO{$os}{'libs'} = $info{'lib_dir'};
+ $INSTALL_INFO{$os}{'docs'} = $info{'doc_dir'};
+ $INSTALL_INFO{$os}{'user'} = $info{'install_user'};
+ $INSTALL_INFO{$os}{'group'} = $info{'install_group'};
+ $INSTALL_INFO{$os}{'command'} = $info{'install_cmd'};
+
+ foreach my $alias (@{$info{'aliases'}}) {
+ $OS_ALIAS{$alias} = $os;
+ }
+
+ @{$OS_SUPPORTS_SHARED{$os}} = @{$info{'supports_shared'}};
+ @{$OS_SUPPORTS_ARCH{$os}} = @{$info{'arch'}};
+ }
+}
+
sub set_cc_defines {
my $dir = $_[0];