summaryrefslogtreecommitdiff
path: root/make/configure.pm
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2016-03-22 22:40:59 +0000
committerPeter Powell <petpow@saberuk.com>2016-03-22 23:38:44 +0000
commitf79a55616b5ff05d4f2e6b031a17be5668d1d3ea (patch)
treedd1863593cd08e196a33e431ee81f1b37e725ee1 /make/configure.pm
parentfb58d69bf5373d8aa3033d4440d2d5f05ed7e39f (diff)
Write generated templates to the .configure directory.
Diffstat (limited to 'make/configure.pm')
-rw-r--r--make/configure.pm18
1 files changed, 14 insertions, 4 deletions
diff --git a/make/configure.pm b/make/configure.pm
index 06dd4de19..7614ca884 100644
--- a/make/configure.pm
+++ b/make/configure.pm
@@ -31,14 +31,16 @@ use feature ':5.10';
use strict;
use warnings FATAL => qw(all);
-use Cwd qw(getcwd);
-use Exporter qw(import);
-use File::Basename qw(basename);
+use Cwd qw(getcwd);
+use Exporter qw(import);
+use File::Basename qw(basename dirname);
+use File::Spec::Functions qw(catfile);
use make::common;
use make::console;
use make::utilities;
+use constant CONFIGURE_DIRECTORY => '.configure';
use constant CONFIGURE_CACHE_FILE => '.configure.cache';
use constant CONFIGURE_CACHE_VERSION => '1';
@@ -87,6 +89,7 @@ sub __get_template_settings($$$) {
}
# Miscellaneous information
+ $settings{CONFIGURE_DIRECTORY} = CONFIGURE_DIRECTORY;
$settings{CONFIGURE_CACHE_FILE} = CONFIGURE_CACHE_FILE;
$settings{SYSTEM_NAME} = lc $^O;
chomp($settings{SYSTEM_NAME_VERSION} = `uname -sr 2>/dev/null`);
@@ -337,7 +340,7 @@ sub parse_templates($$$) {
# Add a default target if the template has not defined one.
unless (scalar keys %targets) {
- $targets{DEFAULT} = basename $_;
+ $targets{DEFAULT} = catfile(CONFIGURE_DIRECTORY, basename $_);
}
# Second pass: parse makefile junk and write files.
@@ -417,6 +420,13 @@ sub parse_templates($$$) {
push @final_lines, $line;
}
+ # Create the directory if it doesn't already exist.
+ my $directory = dirname $target;
+ unless (-e $directory) {
+ print_format "Creating <|GREEN $directory|> ...\n";
+ create_directory $directory, 0750 or print_error "unable to create $directory: $!";
+ };
+
# Write the template file.
print_format "Writing <|GREEN $target|> ...\n";
open(TARGET, '>', $target) or print_error "unable to write $target: $!";