]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - configure
Fixes by misspell-fixer
[user/henk/code/inspircd.git] / configure
index 9d064c693d97455c1fed77378dccd5e45e7997e1..896ded1c40fd79dee2575fc1c468cbfd32d4a051 100755 (executable)
--- a/configure
+++ b/configure
@@ -36,9 +36,10 @@ use feature ':5.10';
 use strict;
 use warnings FATAL => qw(all);
 
+use Cwd                   qw(getcwd);
 use File::Basename        qw(basename);
 use File::Copy            ();
-use File::Spec::Functions qw(catfile catdir rel2abs);
+use File::Spec::Functions qw(abs2rel catfile catdir rel2abs);
 use FindBin               qw($RealDir);
 use Getopt::Long          qw(GetOptions);
 use POSIX                 qw(getgid getuid);
@@ -146,7 +147,7 @@ print_format "<|BOLD Configuring InspIRCd $version{FULL} on $^O.|>\n";
 my %config;
 if ($interactive) {
        %config = read_config_file(CONFIGURE_CACHE_FILE);
-       run_test CONFIGURE_CACHE_FILE, %config;
+       run_test abs2rel(CONFIGURE_CACHE_FILE, $RealDir), %config;
        if (!defined $config{VERSION}) {
                $config{VERSION} = CONFIGURE_CACHE_VERSION;
        } elsif ($config{VERSION} != CONFIGURE_CACHE_VERSION) {
@@ -351,10 +352,10 @@ Currently, InspIRCd is configured to automatically enable all available extra mo
 Would you like to enable extra modules manually?
 EOQ
 if (prompt_bool $interactive, $question, 0) {
-       foreach my $extra (<src/modules/extra/m_*.cpp>) {
+       foreach my $extra (<$RealDir/src/modules/extra/m_*.cpp>) {
                my $module_name = basename $extra, '.cpp';
                if (prompt_bool $interactive, "Would you like to enable $module_name?", 0) {
-                       enable_extras "$module_name.cpp";
+                       enable_extras $module_name;
                }
        }
 } elsif (!defined $opt_disable_auto_extras) {
@@ -362,6 +363,7 @@ if (prompt_bool $interactive, $question, 0) {
        # system './modulemanager', 'enable', '--auto';
        my %modules = (
                # Missing: m_ldap, m_regex_stdlib, m_ssl_mbedtls
+               'm_argon2.cpp'          => 'pkg-config --exists libargon2',
                'm_geo_maxmind.cpp'     => 'pkg-config --exists libmaxminddb',
                'm_mysql.cpp'           => 'mysql_config --version',
                'm_pgsql.cpp'           => 'pg_config --version',
@@ -390,11 +392,23 @@ Note: you can get a <|BOLD free|> CA-signed certificate from Let's Encrypt. See
 https://letsencrypt.org/getting-started/ for more details.
 EOQ
 
-if (<src/modules/m_ssl_*.cpp>) {
+if (<$RealDir/src/modules/m_ssl_*.cpp>) {
        if (prompt_bool $interactive, $question, $interactive) {
-               system './tools/genssl', 'auto';
+               create_directory CONFIGURE_DIRECTORY, 0750 or print_error "unable to create ${\CONFIGURE_DIRECTORY}: $!";
+               system './tools/genssl', 'auto', CONFIGURE_DIRECTORY;
+       } else {
+               my @pems = <${\CONFIGURE_DIRECTORY}/{cert,csr,dhparams,key}.pem>;
+               $question = <<EOQ;
+The following self-signed files were previously generated and will be installed
+when you run Make. Do you want to delete them?
+
+  * ${\join "\n  * ", @pems}
+EOQ
+               if (@pems && prompt_bool $interactive, $question, 0) {
+                       unlink @pems;
+               }
        }
-} else {
+} elsif (!defined $opt_disable_auto_extras) {
        print_warning <<"EOM";
 You are building without enabling any SSL modules. This is not
 recommended as SSL greatly enhances the security and privacy of your IRC server
@@ -426,11 +440,15 @@ Configuration is complete! You have chosen to build with the following settings:
 <|GREEN Extra Modules:|>
 EOM
 
-for my $file (<src/modules/m_*>) {
+for my $file (<$RealDir/src/modules/m_*>) {
        my $module = basename $file, '.cpp';
        say "  * $module" if -l $file;
 }
 
+my @makeargs;
+push @makeargs, "-C${\abs2rel $RealDir}" unless getcwd eq $RealDir;
+push @makeargs, "-j${\(get_cpu_count() + 1)}";
+
 print_format <<"EOM";
 
 <|GREEN Paths:|>
@@ -448,7 +466,7 @@ print_format <<"EOM";
 <|GREEN Execution User:|>  $config{USER} ($config{UID})
 <|GREEN Socket Engine:|>   $config{SOCKETENGINE}
 
-To build with these settings run '<|GREEN make -j${\(get_cpu_count() + 1)} install|>' now.
+To build with these settings run '<|GREEN make ${\join ' ', @makeargs} install|>' now.
 
 EOM
 
@@ -548,72 +566,56 @@ EXTRA:    for my $extra (@extras) {
        return keys(%extras) if wantarray; # Can be used by manage_extras.
 }
 
-sub enable_extras (@) {
-       my (@extras) = @_;
-       for my $extra (@extras) {
-               $extra = "m_$extra" unless $extra =~ /^m_/;
-               $extra = "$extra.cpp" unless $extra =~ /\.cpp$/;
-               my $extrapath = "src/modules/extra/$extra";
-               if (!-e $extrapath) {
-                       print STDERR "Cannot enable \e[32;1m$extra\e[0m : No such file or directory in src/modules/extra\n";
-                       next;
-               }
-               my $source = "src/modules/$extra";
-               if (-e $source) {
-                       print STDERR "Cannot enable \e[32;1m$extra\e[0m : destination in src/modules exists (might already be enabled?)\n";
-                       next;
+sub enable_extras(@) {
+       my $moduledir = catdir $RealDir, 'src', 'modules';
+       my $extradir = catdir $moduledir, 'extra';
+
+       for my $extra (@_) {
+               my $shortname = $extra =~ s/(?:^m_|\.cpp$)//gr;
+               my $extrafile = "m_$shortname.cpp";
+
+               my $extrapath = catfile $extradir, $extrafile;
+               if (!-f $extrapath) {
+                       print_error "<|GREEN $extra|> is not an extra module!";
                }
-               # Get dependencies, and add them to be processed.
-               my @deps = split /\s+/, get_directive($extrapath, 'ModDep', '');
-               for my $dep (@deps) {
-                       next if scalar(grep { $_ eq $dep } (@extras)) > 0; # Skip if we're going to be enabling it anyway.
-                       if (!-e "src/modules/$dep" && !-e "include/$dep") {
-                               if (-e "src/modules/extra/$dep") {
-                                       print STDERR "Will also enable extra \e[32;1m$dep\e[0m (needed by \e[32;1m$extra\e[0m)\n";
-                                       push @extras, $dep;
-                               } else {
-                                       print STDERR "\e[33;1mWARNING:\e[0m module \e[32;1m$extra\e[0m might be missing dependency \e[32;1m$dep\e[0m - YOU are responsible for satisfying it!\n";
-                               }
+
+               my $modulepath = catfile $moduledir, $extrafile;
+               if (-l $modulepath) {
+                       if (readlink($modulepath) ne $extrapath) {
+                               unlink $modulepath; # Remove the dead symlink.
+                       } else {
+                               next; # Module is already enabled.
                        }
                }
-               print "Enabling $extra ... \n";
-               symlink "extra/$extra", $source or print STDERR "$source: Cannot link to 'extra/$extra': $!\n";
+
+               if (-e $modulepath) {
+                       print_error "unable to symlink <|GREEN ${\abs2rel $modulepath}|> to <|GREEN ${\abs2rel $extrapath}|>: the target exists and is not a symlink.";
+               } else {
+                       print_format "Enabling the <|GREEN $shortname|> module ...\n";
+                       symlink $extrapath, $modulepath or print_error "unable to symlink <|GREEN ${\abs2rel $modulepath}|> to <|GREEN ${\abs2rel $extrapath}|>: $!";
+               }
        }
 }
 
-sub disable_extras (@)
-{
-       opendir my $dd, "src/modules/extra/";
-       my @files = readdir($dd);
-       closedir $dd;
-       my (@extras) = @_;
-EXTRA: for my $extra (@extras) {
-               $extra = "m_$extra" unless $extra =~ /^m_/;
-               $extra = "$extra.cpp" unless $extra =~ /\.cpp$/;
-               my $extrapath = "src/modules/extra/$extra";
-               my $source = "src/modules/$extra";
-               if (!-e $extrapath) {
-                       print STDERR "Cannot disable \e[32;1m$extra\e[0m : Is not an extra\n";
-                       next;
-               }
-               if ((! -l $source) || readlink($source) ne "extra/$extra") {
-                       print STDERR "Cannot disable \e[32;1m$extra\e[0m : Source is not a link or doesn't refer to the right file. Remove manually if this is in error.\n";
-                       next;
-               }
-               # Check if anything needs this.
-               for my $file (@files) {
-                       my @deps = split /\s+/, get_directive("src/modules/extra/$file", 'ModDep', '');
-                       # File depends on this extra...
-                       if (scalar(grep { $_ eq $extra } @deps) > 0) {
-                               # And is both enabled and not about to be disabled.
-                               if (-e "src/modules/$file" && scalar(grep { $_ eq $file } @extras) < 1) {
-                                       print STDERR "Cannot disable \e[32;1m$extra\e[0m : is needed by \e[32;1m$file\e[0m\n";
-                                       next EXTRA;
-                               }
-                       }
+sub disable_extras(@) {
+       my $moduledir = catdir $RealDir, 'src', 'modules';
+       my $extradir = catdir $moduledir, 'extra';
+
+       for my $extra (@_) {
+               my $shortname = $extra =~ s/(?:^m_|\.cpp$)//gr;
+               my $extrafile = "m_$shortname.cpp";
+
+               my $modulepath = catfile $moduledir, $extrafile;
+               my $extrapath = catfile $extradir, $extrafile;
+               if (!-e $modulepath && !-e $extrapath) {
+                       print_error "the <|GREEN $shortname|> module does not exist!";
+               } elsif (!-e $modulepath && -e $extrapath) {
+                       print_error "the <|GREEN $shortname|> module is not currently enabled!";
+               } elsif ((-e $modulepath && !-e $extrapath) || !-l $modulepath) {
+                       print_error "the <|GREEN $shortname|> module is not an extra module!";
+               } else {
+                       print_format "Disabling the <|GREEN $shortname|> module ...\n";
+                       unlink $modulepath or print_error "unable to unlink <|GREEN $extrapath|>: $!";
                }
-               # Now remove.
-               print "Disabling $extra ... \n";
-               unlink "src/modules/$extra" or print STDERR "Cannot disable \e[32;1m$extra\e[0m : $!\n";
        }
 }