summaryrefslogtreecommitdiff
path: root/lib/make
diff options
context:
space:
mode:
authorallen <allen@17b73243-c579-4c4c-a9d2-2d5706c11dac>2001-09-22 09:09:15 +0000
committerallen <allen@17b73243-c579-4c4c-a9d2-2d5706c11dac>2001-09-22 09:09:15 +0000
commit8bb637279a2fc0777e6da60bae8dad858549647a (patch)
treeeb564432806aad5290df9dec0071c4fe41cd163c /lib/make
parentd1bce8af6b0df847251c75ebc25e2f4e424f3743 (diff)
Use configuration options in CACTUSRC directory if it exists
git-svn-id: http://svn.cactuscode.org/flesh/trunk@2377 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'lib/make')
-rwxr-xr-xlib/make/setup_configuration.pl66
1 files changed, 65 insertions, 1 deletions
diff --git a/lib/make/setup_configuration.pl b/lib/make/setup_configuration.pl
index 53df3eaf..13dafabe 100755
--- a/lib/make/setup_configuration.pl
+++ b/lib/make/setup_configuration.pl
@@ -32,6 +32,23 @@ else
$config = $uname;
}
+# Work out if there is a user default file
+
+if($ENV{"CACTUSRC_DIR"})
+{
+ if (-e $ENV{"CACTUSRC_DIR"}."/.cactus/config")
+ {
+ $default_file = $ENV{"CACTUSRC_DIR"}."/.cactus/config";
+ }
+}
+elsif (-e $ENV{"HOME"}."/.cactus/config")
+{
+ if (-e $ENV{"HOME"}."/.cactus/config")
+ {
+ $default_file = $ENV{"HOME"}."/.cactus/config";
+ }
+}
+
# Work out where the config directory is
if($ENV{"CONFIGS_DIR"})
@@ -124,10 +141,55 @@ exit $retcode;
#@@*/
sub SetConfigureEnv
{
- local($line_number) = 0;
+ local($line_number);
# Set a default name for the configuration
$ENV{"EXE"} = "cactus_$config";
+ # Set variables from user default file first
+ if ($default_file)
+ {
+ print "Using configuration options from user defaults...\n";
+
+ open(INFILE, "<$default_file") || die "Cannot open configuration file $config_file";
+
+ $line_number;
+
+ while(<INFILE>)
+ {
+ $line_number++;
+
+ #Ignore comments.
+ s/\#(.*)$//g;
+
+ #Remove spaces at end of lines
+ s/\s*$//;
+
+ s/\n//g; # Different from chop...
+
+ #Ignore blank lines
+ next if (m:^\s*$:);
+
+ # Match lines of the form
+ # keyword value
+ # or keyword = value
+ m/\s*([^\s=]*)([\s]*=?\s*)(.*)\s*/;
+
+ if($1 && $2)
+ {
+ print "Setting $1 to '$3'\n";
+ $ENV{"$1"} = $3;
+ }
+ else
+ {
+ print "Could not parse configuration line $line_number...\n'$_'\n";
+ }
+ }
+ print "End of options from user defaults.\n";
+
+ close(INFILE);
+ }
+
+
if($config_file)
{
# The user has specified a configuration file
@@ -139,6 +201,8 @@ sub SetConfigureEnv
}
open(INFILE, "<$config_file") || die "Cannot open configuration file $config_file";
+ $line_number = 0;
+
while(<INFILE>)
{
$line_number++;