1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
#/*@@
# @file ProcessConfiguration.pl
# @date Mon May 8 15:52:08 2000
# @author Tom Goodale
# @desc
#
# @enddesc
#@@*/
#/*@@
# @routine SplitThorns
# @date Mon May 8 16:04:59 2000
# @author Tom Goodale
# @desc
# Splits the thorns hash into those with source and those without source
# @enddesc
# @calls
# @calledby
# @history
#
# @endhistory
#
#@@*/
sub SplitThorns
{
my ($configuration_database, $thorns, $source_thorns, $nosource_thorns) = @_;
foreach $thorn (sort keys %$thorns)
{
if($configuration_database->{"\U$thorn OPTIONS\E"} =~ m/NO_SOURCE/i)
{
$nosource_thorns->{"$thorn"} = $thorns->{"$thorn"};
}
else
{
$source_thorns->{"$thorn"} = $thorns->{"$thorn"};
}
}
}
#/*@@
# @routine ProcessConfiguration
# @date Thu Aug 26 22:09:26 2004
# @author Tom Goodale
# @desc
# Runs all the configuration scripts belonging to thorns.
# Has to setup the environment correctly, and as a result
# modifies the config-info file for future reference.
# @enddesc
# @calls
# @calledby
# @history
#
# @endhistory
#
#@@*/
sub ProcessConfiguration
{
my($config_dir,$config_database, $thorns, $config_file) = @_;
my $thorn;
my $provides;
my @allowed_opts;
# Find the master list of allowed options
foreach $thorn (sort keys %thorns)
{
# print "DEBUG: Thorn $thorn\n";
foreach $provides (split(' ',$config_database->{"\U$thorn\E PROVIDES"}))
{
# print "DEBUG: Provides $provides\n";
if(@{$config_database->{"\U$thorn\E PROVIDES \U$provides\E OPTIONS"}} != 0)
{
# print "DEBUG: $thorn provides $provides with options\n";
push(@allowed_opts, @{$config_database->{"\U$thorn\E PROVIDES \U$provides\E OPTIONS"}});
}
}
}
# print "DEBUG: allowed options are @allowed_opts\n";
# Now get all the configuration options.
my $env;
my $optfile;
my $configinfo;
my $headers;
($configinfo,$headers) = ParseConfigInfo($config_file);
if($ENV{"options"})
{
$optfile = ParseOptionsFile($ENV{"options"})
}
else
{
$optfile = {};
}
$env = GetOptionsFromEnv(\%ENV, \@allowed_opts);
my $modified = AmalgamateOptions($env,$optfile,$configinfo,\@allowed_opts);
# Write a new config-info file if anything has changed
if($modified)
{
WriteNewConfigInfo($config_file,$headers,$configinfo);
}
# Now setup the environment
# FIXME: Would like to restrict this to just the @allowed_opts, but then
# flesh configuration options like MPI or arch specific ones like
# IRIX_BITS would not be propogated 8-(
foreach $option (keys %$configinfo)
{
$ENV{$option} = $configinfo->{$option};
}
# Ok, can now run the configuration scripts.
foreach $thorn (sort keys %thorns)
{
foreach $provides (split(' ',$config_database->{"\U$thorn\E PROVIDES"}))
{
my $script = $config_database->{"\U$thorn\E PROVIDES \U$provides\E SCRIPT"};
my $lang = $config_database->{"\U$thorn\E PROVIDES \U$provides\E LANG"};
if ($script)
{
print "Running configuration script '$script'\n";
&ParseConfigScript($config_dir, $provides, $lang, $script,
$thorn, $config_database);
print "\n";
}
}
}
}
1;
|