]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - make/common.pm
Merge pull request #1319 from SaberUK/master+compiler-detection
[user/henk/code/inspircd.git] / make / common.pm
index d5a2f06c73c0cb8537fb03a910875d840efe0f7c..6ca280bece1f8307df33491fffca887385772e82 100644 (file)
@@ -31,11 +31,13 @@ use Exporter              qw(import);
 use File::Path            qw(mkpath);
 use File::Spec::Functions qw(rel2abs);
 
+use make::console;
+
 our @EXPORT = qw(create_directory
                  get_cpu_count
                  get_version
                  read_config_file
-                 module_installed);
+                 write_config_file);
 
 sub create_directory($$) {
        my ($location, $permissions) = @_;
@@ -87,12 +89,6 @@ sub get_version {
        return %version;
 }
 
-sub module_installed($) {
-       my $module = shift;
-       eval("use $module;");
-       return !$@;
-}
-
 sub get_cpu_count {
        my $count = 1;
        if ($^O =~ /bsd/) {
@@ -121,4 +117,15 @@ sub read_config_file($) {
        return %config;
 }
 
+sub write_config_file($%) {
+       my $path = shift;
+       my %config = @_;
+       open(my $fh, '>', $path) or print_error "unable to write to $path: $!";
+       while (my ($key, $value) = each %config) {
+               $value //= '';
+               say $fh "$key $value";
+       }
+       close $fh;
+}
+
 1;