summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xconfigure263
-rw-r--r--make/configure.pm331
-rw-r--r--make/template/main.mk6
-rw-r--r--make/utilities.pm55
-rwxr-xr-xmodulemanager13
5 files changed, 270 insertions, 398 deletions
diff --git a/configure b/configure
index ded314ea4..6fba700ce 100755
--- a/configure
+++ b/configure
@@ -67,9 +67,9 @@ GetOptions (
'binary-dir=s' => \$opt_binary_dir,
'data-dir=s' => \$opt_data_dir,
'log-dir=s' => \$opt_log_dir,
- 'help' => sub { showhelp(); },
- 'update' => sub { update(); },
- 'clean' => sub { clean(); },
+ 'help' => \&cmd_help,
+ 'update' => \&cmd_update,
+ 'clean' => \&cmd_clean,
'list-extras' => sub { list_extras; exit 0; }, # This, --enable-extras, and --disable-extras are for non-interactive managing.
'enable-extras=s@' => \@opt_enableextras, # ^
'disable-extras=s@' => \@opt_disableextras, # ^
@@ -102,9 +102,10 @@ our $interactive = !(
);
our $topdir = getcwd();
-our @modlist = ();
-our %config = ();
-our $cache_loaded = getcache();
+our %config = read_configure_cache();
+
+print "Checking for cache from previous configure... ";
+print %config ? "found\n" : "not found\n";
$config{BASE_DIR} = $topdir."/run";
@@ -129,7 +130,7 @@ if (defined $opt_system) {
$config{BINARY_DIR} = rel2abs($config{BASE_DIR}."/bin");
$config{BUILD_DIR} = rel2abs($topdir."/build");
$config{DATA_DIR} = rel2abs($config{BASE_DIR}."/data");
- $config{LOG_DIR} = rel2abs($config{BASE_DIR}."/logs");
+ $config{LOG_DIR} = rel2abs($config{BASE_DIR}."/logs");
}
if (defined $opt_config_dir) {
@@ -185,45 +186,6 @@ if ($config{HAS_OPENSSL} =~ /^([-[:digit:].]+)(?:[a-z])?(?:\-[a-z][0-9])?/) {
$config{HAS_OPENSSL} = "";
}
-# Get and Set some important vars..
-getmodules();
-
-sub clean
-{
- unlink(".config.cache");
-}
-
-sub update
-{
- eval {
- # Does the cache file exist?
- if (!getcache()) {
- # No, No it doesn't.. *BASH*
- print "You have not run ./configure before. Please do this before trying to run the update script.\n";
- exit 1;
- } else {
- # We've Loaded the cache file and all our variables..
- $topdir = getcwd();
- getmodules();
- print "Updating files...\n";
- %cxx = get_compiler_info($config{CXX});
- writefiles();
- makecache();
- print "Complete.\n";
- exit;
- }
- };
- if ($@)
- {
- print "Configure update failed: $@\n";
- }
- exit;
-}
-
-print "Running non-interactive configure...\n" unless $interactive;
-print "Checking for cache from previous configure... ";
-print ($cache_loaded ? "found\n" : "not found\n");
-
$config{HAS_CLOCK_GETTIME} = run_test 'clock_gettime()', test_file($config{CXX}, 'clock_gettime.cpp', '-lrt');
$config{HAS_EVENTFD} = run_test 'eventfd()', test_file($config{CXX}, 'eventfd.cpp');
@@ -296,7 +258,7 @@ if ($interactive)
# Clear the screen.
system 'tput', 'clear';
- my $revision = getrevision();
+ my $revision = get_revision();
chomp(my $version = `sh src/version.sh`);
# Display Introduction Message..
@@ -321,7 +283,7 @@ STOP
# Directory Settings..
my $tmpbase = $config{BASE_DIR};
- dir_check("do you wish to install the InspIRCd base", "BASE_DIR");
+ $config{BASE_DIR} = prompt_dir(1, 'What directory do you wish to install the InspIRCd base?', $config{BASE_DIR});
if ($tmpbase ne $config{BASE_DIR}) {
$config{CONFIG_DIR} = rel2abs($config{BASE_DIR}."/conf");
$config{MODULE_DIR} = rel2abs($config{BASE_DIR}."/modules");
@@ -330,81 +292,75 @@ STOP
$config{BINARY_DIR} = rel2abs($config{BASE_DIR}."/bin");
}
- dir_check("are the configuration files", "CONFIG_DIR");
- dir_check("are the modules to be compiled to", "MODULE_DIR");
- dir_check("is the IRCd binary to be placed", "BINARY_DIR");
- dir_check("are variable data files to be located in", "DATA_DIR");
- dir_check("are the logs to be stored in", "LOG_DIR");
- dir_check("do you want the build to take place", "BUILD_DIR");
-
+ $config{BINARY_DIR} = prompt_dir(1, 'In what directory should the InspIRCd binary be placed?', $config{BINARY_DIR});
+ $config{CONFIG_DIR} = prompt_dir(1, 'In what directory are the configuration files to be stored?', $config{CONFIG_DIR});
+ $config{DATA_DIR} = prompt_dir(1, 'In what directory are variable data files to be stored?', $config{DATA_DIR});
+ $config{LOG_DIR} = prompt_dir(1, 'In what directory are log files to be stored?', $config{LOG_DIR});
+ $config{MODULE_DIR} = prompt_dir(1, 'In what directory are the modules to be placed?', $config{MODULE_DIR});
+ $config{BUILD_DIR} = prompt_dir(1, 'In what directory do you want the build to take place?', $config{BUILD_DIR});
+
my $chose_hiperf = 0;
if ($config{HAS_KQUEUE}) {
- $config{USE_KQUEUE} = "y";
- yesno('USE_KQUEUE',"You are running a BSD operating system, and kqueue\nwas detected. Would you like to enable kqueue support?\nThis is likely to increase performance.\nIf you are unsure, answer yes.\n\nEnable kqueue?");
- print "\n";
- if ($config{USE_KQUEUE} eq "y") {
+ $config{USE_KQUEUE} = prompt_bool(1, 'Your operating system has support for the high performance kqueue socket engine. Would you like to enable it?', 1);
+ if ($config{USE_KQUEUE}) {
$config{SOCKETENGINE} = "kqueue";
$chose_hiperf = 1;
}
}
if ($config{HAS_EPOLL}) {
- $config{USE_EPOLL} = "y";
- yesno('USE_EPOLL',"You are running a Linux 2.6+ operating system, and epoll\nwas detected. Would you like to enable epoll support?\nThis is likely to increase performance.\nIf you are unsure, answer yes.\n\nEnable epoll?");
- print "\n";
- if ($config{USE_EPOLL} eq "y") {
+ $config{USE_EPOLL} = prompt_bool(1, 'Your operating system has support for the high performance epoll socket engine. Would you like to enable it?', 1);
+ if ($config{USE_EPOLL}) {
$config{SOCKETENGINE} = "epoll";
$chose_hiperf = 1;
}
}
if ($config{HAS_PORTS}) {
- $config{USE_PORTS} = "y";
- yesno('USE_PORTS',"You are running Solaris 10.\nWould you like to enable I/O completion ports support?\nThis is likely to increase performance.\nIf you are unsure, answer yes.\n\nEnable support for I/O completion ports?");
- print "\n";
- if ($config{USE_PORTS} eq "y") {
+ $config{USE_PORTS} = prompt_bool(1, 'Your operating system has support for the high performance IOCP socket engine. Would you like to enable it?', 1);
+ if ($config{USE_PORTS}) {
$config{SOCKETENGINE} = "ports";
$chose_hiperf = 1;
}
}
if (!$chose_hiperf && $config{HAS_POLL}) {
- $config{USE_POLL} = "y";
- yesno('USE_POLL', "Would you like to use poll?\nThis is likely to increase performance.\nIf you are unsure, answer yes.\n\nEnable poll?");
- if ($config{USE_POLL} eq "y") {
+ $config{USE_POLL} = prompt_bool(1, 'Your operating system has support for the mid performance poll socket engine. Would you like to enable it?', 1);
+ if ($config{USE_POLL}) {
$config{SOCKETENGINE} = "poll";
}
}
- if (!$chose_hiperf && $config{USE_POLL} ne "y")
+ unless ($chose_hiperf || $config{USE_POLL})
{
- print "No high-performance socket engines are available, or you chose\n";
- print "not to enable one. Defaulting to select() engine.\n\n";
+ print "No high-performance socket engines are available, or you chose not to enable one. Defaulting to select() engine.\n\n";
$config{SOCKETENGINE} = "select";
}
- $config{USE_SSL} = "n";
-
if ($config{HAS_GNUTLS} eq "y" || $config{HAS_OPENSSL} eq "y")
{
print "Detected GnuTLS version: \e[1;32m" . $gnutls_ver . "\e[0m\n";
print "Detected OpenSSL version: \e[1;32m" . $openssl_ver . "\e[0m\n\n";
- yesno('USE_SSL', "One or more SSL libraries detected. Would you like to enable SSL support?");
- if ($config{USE_SSL} eq "y")
+ $config{USE_SSL} = prompt_bool(1, 'One or more SSL libraries detected. Would you like to enable SSL support?', 1);
+ if ($config{USE_SSL})
{
if ($config{HAS_GNUTLS} eq "y")
{
- yesno('USE_GNUTLS',"Would you like to enable SSL with m_ssl_gnutls? (recommended)");
- if ($config{USE_GNUTLS} eq "y")
+ $config{USE_GNUTLS} = prompt_bool(1, 'Would you like to enable SSL with m_ssl_gnutls (recommended)?', 1);
+ if ($config{USE_GNUTLS})
{
- print "\nUsing GnuTLS SSL module.\n";
+ print "Using GnuTLS SSL module.\n\n";
+ unlink 'src/modules/m_ssl_gnutls.cpp' if -f 'src/modules/m_ssl_gnutls.cpp';
+ symlink "extra/m_ssl_gnutls.cpp", "src/modules/m_ssl_gnutls.cpp" or print STDERR "Symlink failed: $!\n";
}
}
if ($config{HAS_OPENSSL} eq "y")
{
- yesno('USE_OPENSSL', "Would you like to enable SSL with m_ssl_openssl?");
- if ($config{USE_OPENSSL} eq "y")
+ $config{USE_OPENSSL} = prompt_bool(1, 'Would you like to enable SSL with m_ssl_openssl (recommended)?', 1);
+ if ($config{USE_OPENSSL})
{
- print "\nUsing OpenSSL SSL module.\n";
+ print "Using OpenSSL SSL module.\n\n";
+ unlink 'src/modules/m_ssl_openssl.cpp' if -f 'src/modules/m_ssl_openssl.cpp';
+ symlink "extra/m_ssl_openssl.cpp", "src/modules/m_ssl_openssl.cpp" or print STDERR "Symlink failed: $!\n";
}
}
}
@@ -419,55 +375,21 @@ STOP
# We are on a POSIX system, we can enable POSIX extras without asking
symlink "extra/m_regex_posix.cpp", "src/modules/m_regex_posix.cpp";
-if (($config{USE_GNUTLS} eq "y") && ($config{HAS_GNUTLS} ne "y"))
+if (($config{USE_GNUTLS}) && ($config{HAS_GNUTLS} ne "y"))
{
print "Sorry, but i couldn't detect gnutls. Make sure pkg-config is in your path.\n";
exit 1;
}
-if (($config{USE_OPENSSL} eq "y") && ($config{HAS_OPENSSL} ne "y"))
+if (($config{USE_OPENSSL}) && ($config{HAS_OPENSSL} ne "y"))
{
print "Sorry, but i couldn't detect openssl. Make sure pkg-config is in your path.\n";
exit 1;
}
-$config{CERTGEN} ||= 'y';
-yesno('CERTGEN',"Would you like generate SSL certificates now?") if ($interactive && ($config{USE_GNUTLS} eq "y" || $config{USE_OPENSSL} eq "y"));
-
-if ($config{USE_GNUTLS} eq "y") {
- unless (-r "src/modules/m_ssl_gnutls.cpp") {
- print "Symlinking src/modules/m_ssl_gnutls.cpp from extra/\n";
- symlink "extra/m_ssl_gnutls.cpp", "src/modules/m_ssl_gnutls.cpp" or print STDERR "Symlink failed: $!";
- }
- if ($interactive && $config{CERTGEN} eq 'y')
- {
+if ($config{USE_GNUTLS} || $config{USE_OPENSSL}) {
+ if (my $val = prompt_bool($interactive, 'Would you like to generate SSL certificates now?', $interactive)) {
unless (-r "$config{CONFIG_DIR}/key.pem" && -r "$config{CONFIG_DIR}/cert.pem" && -r "$config{CONFIG_DIR}/dhparams.pem") {
- unless (system './tools/genssl gnutls') {
- print "\nCertificate generation complete, copying to config directory... ";
- File::Copy::move("key.pem", "$config{CONFIG_DIR}/key.pem") or print STDERR "Could not copy key.pem!\n";
- File::Copy::move("cert.pem", "$config{CONFIG_DIR}/cert.pem") or print STDERR "Could not copy cert.pem!\n";
- File::Copy::move("dhparams.pem", "$config{CONFIG_DIR}/dhparams.pem") or print STDERR "Could not copy dhparams.pem!\n";
- print "Done.\n\n";
- }
- }
- else {
- print "SSL Certificates found, skipping.\n\n";
- }
- }
- else
- {
- print "Skipping SSL certificate generation\nin non-interactive mode.\n\n";
- }
-}
-
-if ($config{USE_OPENSSL} eq "y") {
- unless (-r "src/modules/m_ssl_openssl.cpp") {
- print "Symlinking src/modules/m_ssl_openssl.cpp from extra/\n";
- symlink "extra/m_ssl_openssl.cpp", "src/modules/m_ssl_openssl.cpp" or print STDERR "Symlink failed: $!";
- }
- if ($interactive && $config{CERTGEN} eq 'y')
- {
- unless (-r "$config{CONFIG_DIR}/key.pem" && -r "$config{CONFIG_DIR}/cert.pem" && -r "$config{CONFIG_DIR}/dhparams.pem") {
- unless (system './tools/genssl openssl') {
+ unless (system './tools/genssl auto') {
print "\nCertificate generation complete, copying to config directory... ";
File::Copy::move("key.pem", "$config{CONFIG_DIR}/key.pem") or print STDERR "Could not copy key.pem!\n";
File::Copy::move("cert.pem", "$config{CONFIG_DIR}/cert.pem") or print STDERR "Could not copy cert.pem!\n";
@@ -477,24 +399,21 @@ if ($config{USE_OPENSSL} eq "y") {
} else {
print "SSL Certificates found, skipping.\n\n"
}
+ } else {
+ print "Skipping SSL certificate generation in non-interactive mode.\n\n";
}
- else
- {
- print "Skipping SSL certificate generation\nin non-interactive mode.\n\n";
- }
-}
-if (($config{USE_GNUTLS} eq "n") && ($config{USE_OPENSSL} eq "n")) {
+} else {
print "Skipping SSL Certificate generation, SSL support is not available.\n\n";
}
-getmodules();
+print "Writing \e[1;32m.config.cache\e[0m ...\n";
+write_configure_cache(%config);
writefiles();
-makecache();
-dumphash();
+dump_hash();
print "\n";
print "To build your server with these settings, please run '\e[1;32mmake\e[0m' now.\n";
-if (($config{USE_GNUTLS} eq "y") || ($config{USE_OPENSSL} eq "y")) {
+if ($config{USE_GNUTLS} || $config{USE_OPENSSL}) {
print "Please note: for \e[1;32mSSL support\e[0m you will need to load required\n";
print "modules in your config. This configure script has added those modules to the\n";
print "build process. For more info please refer to:\n";
@@ -502,86 +421,10 @@ if (($config{USE_GNUTLS} eq "y") || ($config{USE_OPENSSL} eq "y")) {
}
print "*** \e[1;32mRemember to edit your configuration files!!!\e[0m ***\n\n";
-sub getcache {
- # Retrieves the .config.cache file, and loads values into the main config hash.
- open(CACHE, ".config.cache") or return 0;
- while (<CACHE>) {
- chomp;
- # Ignore Blank lines, and comments..
- next if /^\s*$/;
- next if /^\s*#/;
- my ($key, $value) = split("=", $_, 2);
- $value =~ /^\"(.*)\"$/;
- # Do something with data here!
- $config{$key} = $1;
- }
- close(CACHE);
- return 1;
-}
-
-sub makecache {
- # Dump the contents of %config
- print "Writing \e[1;32mcache file\e[0m for future ./configures ...\n";
- open(FILEHANDLE, ">.config.cache");
- foreach my $key (keys %config) {
- print FILEHANDLE "$key=\"$config{$key}\"\n";
- }
- close(FILEHANDLE);
-}
-
-sub dir_check {
- my ($desc, $hash_key) = @_;
- my $complete = 0;
- while (!$complete) {
- print "In what directory $desc?\n";
- print "[\e[1;32m$config{$hash_key}\e[0m] -> ";
- chomp(my $var = <STDIN>);
- if ($var eq "") {
- $var = $config{$hash_key};
- }
- if ($var =~ /^\~\/(.+)$/) {
- # Convert it to a full path..
- $var = rel2abs($ENV{HOME} . "/" . $1);
- }
- $var = rel2abs($var);
- if (! -e $var) {
- print "$var does not exist. Create it?\n[\e[1;32my\e[0m] ";
- chomp(my $tmp = <STDIN>);
- if (($tmp eq "") || ($tmp =~ /^y/i)) {
- # Attempt to Create the Dir..
- my $chk = eval {
- use File::Path ();
- File::Path::mkpath($var, 0, 0777);
- 1;
- };
- unless (defined($chk) && -d $var) {
- print "Unable to create directory. ($var)\n\n";
- # Restart Loop..
- next;
- }
- } else {
- # They said they don't want to create, and we can't install there.
- print "\n\n";
- next;
- }
- } else {
- if (! -d $var) {
- # Target exists, but is not a directory.
- print "File $var exists, but is not a directory.\n\n";
- next;
- }
- }
- # Either Dir Exists, or was created fine.
- $config{$hash_key} = $var;
- $complete = 1;
- print "\n";
- }
-}
-
sub writefiles {
chomp(my $incos = `uname -n -s -r`);
chomp(my $version = `sh src/version.sh`);
- my $revision = getrevision();
+ my $revision = get_revision();
my $branch = "InspIRCd-0.0";
if ($version =~ /^(InspIRCd-[0-9]+\.[0-9]+)\.[0-9]+/)
{
@@ -685,7 +528,7 @@ EOF
}
}
- chmod 0755, 'inspircd';
+ chmod 0750, 'inspircd';
}
# Routine to list out the extra/ modules that have been enabled.
diff --git a/make/configure.pm b/make/configure.pm
index ba67545ac..286424080 100644
--- a/make/configure.pm
+++ b/make/configure.pm
@@ -21,42 +21,175 @@
#
-package make::configure;
+BEGIN {
+ require 5.8.0;
+}
-require 5.8.0;
+package make::configure;
use strict;
use warnings FATAL => qw(all);
+use Cwd;
use Exporter 'import';
-use POSIX;
+
use make::utilities;
-our @EXPORT = qw(get_compiler_info find_compiler run_test test_file test_header promptnumeric dumphash getmodules getrevision get_property yesno showhelp promptstring_s module_installed);
+
+our @EXPORT = qw(cmd_clean cmd_help cmd_update
+ read_configure_cache write_configure_cache
+ get_compiler_info find_compiler
+ run_test test_file test_header
+ get_property get_revision
+ dump_hash);
my $revision;
+sub __get_socketengines() {
+ my @socketengines;
+ foreach (<src/socketengines/socketengine_*.cpp>) {
+ s/src\/socketengines\/socketengine_(\w+)\.cpp/$1/;
+ push @socketengines, $1;
+ }
+ return @socketengines;
+}
+
+sub cmd_clean {
+ unlink '.config.cache';
+}
+
+sub cmd_help {
+ my $PWD = getcwd();
+ my $SELIST = join ', ', __get_socketengines();
+ print <<EOH;
+Usage: $0 [options]
+
+When no options are specified, configure runs in interactive mode and you must
+specify any required values manually. If one or more options are specified,
+non-interactive configuration is started and any omitted values are defaulted.
+
+PATH OPTIONS
+
+ --system Automatically set up the installation paths
+ for system-wide installation.
+ --prefix=[dir] The root install directory. If this is set then
+ all subdirectories will be adjusted accordingly.
+ [$PWD/run]
+ --binary-dir=[dir] The location where the main server binary is
+ stored.
+ [$PWD/run/bin]
+ --config-dir=[dir] The location where the configuration files and
+ SSL certificates are stored.
+ [$PWD/run/conf]
+ --data-dir=[dir] The location where the data files, such as the
+ pid file, are stored.
+ [$PWD/run/data]
+ --log-dir=[dir] The location where the log files are stored.
+ [$PWD/run/logs]
+ --module-dir=[dir] The location where the loadable modules are
+ stored.
+ [$PWD/run/modules]
+ --build-dir=[dir] The location to store files in while building.
+
+
+EXTRA MODULE OPTIONS
+
+ --enable-extras=[extras] Enables a comma separated list of extra modules.
+ --disable-extras=[extras] Disables a comma separated list of extra modules.
+ --list-extras Shows the availability status of all extra
+ modules.
+
+MISC OPTIONS
+
+ --clean Remove the configuration cache file and start
+ the interactive configuration wizard.
+ --disable-interactive Disables the interactive configuration wizard.
+ --help Show this message and exit.
+ --uid=[name] Sets the user to run InspIRCd as.
+ --socketengine=[name] Sets the socket engine to be used. Possible
+ values are $SELIST.
+ --update Updates the build environment.
+
+
+FLAGS
+
+ CXX=[name] Sets the C++ compiler to use when building the
+ server. If not specified then the build system
+ will search for c++, g++, clang++ or icpc.
+
+If you have any problems with configuring InspIRCd then visit our IRC channel
+at irc.ChatSpike.net #InspIRCd.
+
+EOH
+ exit 0;
+}
+
+sub cmd_update {
+ unless (-f '.config.cache') {
+ print "You have not run $0 before. Please do this before trying to update the build files.\n";
+ exit 1;
+ }
+ print "Updating...\n";
+ %main::config = read_configure_cache();
+ %main::cxx = get_compiler_info($main::config{CXX});
+ $main::topdir = getcwd();
+ main::writefiles();
+ print "Update complete!\n";
+ exit 0;
+}
+
+sub read_configure_cache {
+ my %cfg = ();
+ open(CACHE, '.config.cache') or return %cfg;
+ while (my $line = <CACHE>) {
+ next if $line =~ /^\s*($|\#)/;
+ my ($key, $value) = ($line =~ /^(\S+)="(.*)"$/);
+ $cfg{$key} = $value;
+ }
+ close(CACHE);
+ return %cfg;
+}
+
+sub write_configure_cache(%) {
+ my %cfg = @_;
+ open(CACHE, ">.config.cache") or return 0;
+ while (my ($key, $value) = each %cfg) {
+ $value = "" unless defined $value;
+ print CACHE "$key=\"$value\"\n";
+ }
+ close(CACHE);
+ return 1;
+}
+
sub get_compiler_info($) {
- my %info = (NAME => shift, VERSION => '0.0');
- my $version = `$info{NAME} -v 2>&1`;
- return (ERROR => 1) if $?;
- if ($version =~ /(?:clang|llvm)\sversion\s(\d+\.\d+)/i) {
- $info{NAME} = 'Clang';
- $info{VERSION} = $1;
- $info{UNSUPPORTED} = $1 lt '3.0';
- $info{REASON} = 'Clang 2.9 and older do not have adequate C++ support.';
- } elsif ($version =~ /gcc\sversion\s(\d+\.\d+)/i) {
- $info{NAME} = 'GCC';
- $info{VERSION} = $1;
- $info{UNSUPPORTED} = $1 lt '4.1';
- $info{REASON} = 'GCC 4.0 and older do not have adequate C++ support.';
- } elsif ($version =~ /(?:icc|icpc)\sversion\s(\d+\.\d+).\d+\s\(gcc\sversion\s(\d+\.\d+).\d+/i) {
- $info{NAME} = 'ICC';
- $info{VERSION} = $1;
- $info{UNSUPPORTED} = $2 lt '4.1';
- $info{REASON} = "ICC $1 (GCC $2 compatibility mode) does not have adequate C++ support."
- }
- return %info;
-}
+ my $binary = shift;
+ my $version = `$binary -v 2>&1`;
+ if ($version =~ /(?:clang|llvm)\sversion\s(\d+\.\d+)/i) {
+ return (
+ NAME => 'Clang',
+ VERSION => $1,
+ UNSUPPORTED => $1 lt '3.0',
+ REASON => 'Clang 2.9 and older do not have adequate C++ support.'
+ );
+ } elsif ($version =~ /gcc\sversion\s(\d+\.\d+)/i) {
+ return (
+ NAME => 'GCC',
+ VERSION => $1,
+ UNSUPPORTED => $1 lt '4.1',
+ REASON => 'GCC 4.0 and older do not have adequate C++ support.'
+ );
+ } elsif ($version =~ /(?:icc|icpc)\sversion\s(\d+\.\d+).\d+\s\(gcc\sversion\s(\d+\.\d+).\d+/i) {
+ return (
+ NAME => 'ICC',
+ VERSION => $1,
+ UNSUPPORTED => $2 lt '4.1',
+ REASON => "ICC $1 (GCC $2 compatibility mode) does not have adequate C++ support."
+ );
+ }
+ return (
+ NAME => $binary,
+ VERSION => '0.0'
+ );
+}
sub find_compiler {
foreach my $compiler ('c++', 'g++', 'clang++', 'icpc') {
@@ -94,22 +227,6 @@ sub test_header($$;$) {
return !$?;
}
-sub yesno {
- my ($flag,$prompt) = @_;
- print "$prompt [\e[1;32m$main::config{$flag}\e[0m] -> ";
- chomp(my $tmp = <STDIN>);
- if ($tmp eq "") { $tmp = $main::config{$flag} }
- if (($tmp eq "") || ($tmp =~ /^y/i))
- {
- $main::config{$flag} = "y";
- }
- else
- {
- $main::config{$flag} = "n";
- }
- return;
-}
-
sub get_property($$;$)
{
my ($file, $property, $default) = @_;
@@ -125,89 +242,14 @@ sub get_property($$;$)
return defined $default ? $default : '';
}
-sub getrevision {
+sub get_revision {
return $revision if defined $revision;
chomp(my $tags = `git describe --tags 2>/dev/null`);
$revision = $tags || 'release';
return $revision;
}
-sub getmodules
-{
- my ($silent) = @_;
-
- my $i = 0;
-
- if (!$silent)
- {
- print "Detecting modules ";
- }
-
- opendir(DIRHANDLE, "src/modules") or die("WTF, missing src/modules!");
- foreach my $name (sort readdir(DIRHANDLE))
- {
- if ($name =~ /^m_(.+)\.cpp$/)
- {
- my $mod = $1;
- $main::modlist[$i++] = $mod;
- if (!$silent)
- {
- print ".";
- }
- }
- }
- closedir(DIRHANDLE);
-
- if (!$silent)
- {
- print "\nOk, $i modules.\n";
- }
-}
-
-sub promptnumeric($$)
-{
- my $continue = 0;
- my ($prompt, $configitem) = @_;
- while (!$continue)
- {
- print "Please enter the maximum $prompt?\n";
- print "[\e[1;32m$main::config{$configitem}\e[0m] -> ";
- chomp(my $var = <STDIN>);
- if ($var eq "")
- {
- $var = $main::config{$configitem};
- }
- if ($var =~ /^\d+$/) {
- # We don't care what the number is, set it and be on our way.
- $main::config{$configitem} = $var;
- $continue = 1;
- print "\n";
- } else {
- print "You must enter a number in this field. Please try again.\n\n";
- }
- }
-}
-
-sub module_installed($)
-{
- my $module = shift;
- eval("use $module;");
- return !$@;
-}
-
-sub promptstring_s($$)
-{
- my ($prompt,$default) = @_;
- my $var;
- print "$prompt\n";
- print "[\e[1;32m$default\e[0m] -> ";
- chomp($var = <STDIN>);
- $var = $default if $var eq "";
- print "\n";
- return $var;
-}
-
-sub dumphash()
+sub dump_hash()
{
print "\n\e[1;32mPre-build configuration is complete!\e[0m\n\n";
print "\e[0mBase install path:\e[1;32m\t\t$main::config{BASE_DIR}\e[0m\n";
@@ -221,57 +263,4 @@ sub dumphash()
print "\e[0mOpenSSL support:\e[1;32m\t\t$main::config{USE_OPENSSL}\e[0m\n";
}
-sub showhelp
-{
- chomp(my $PWD = `pwd`);
- my (@socketengines, $SELIST);
- foreach (<src/socketengines/socketengine_*.cpp>) {
- s/src\/socketengines\/socketengine_(\w+)\.cpp/$1/;
- push(@socketengines, $1);
- }
- $SELIST = join(", ", @socketengines);
- print <<EOH;
-Usage: configure [options]
-
-When no options are specified, interactive
-configuration is started and you must specify
-any required values manually. If one or more
-options are specified, non-interactive configuration
-is started, and any omitted values are defaulted.
-
-Arguments with a single \"-\" symbol are also allowed.
-
- --disable-interactive Sets no options itself, but
- will disable any interactive prompting.
- --update Update makefiles and dependencies
- --clean Remove .config.cache file and go interactive
- --enable-gnutls Enable GnuTLS module [no]
- --enable-openssl Enable OpenSSL module [no]
- --socketengine=[name] Sets the socket engine to be used. Possible values are
- $SELIST.
- --prefix=[directory] Base directory to install into (if defined,
- can automatically define config, data, module,
- log and binary dirs as subdirectories of prefix)
- [$PWD]
- --config-dir=[directory] Config file directory for config and SSL certs
- [$PWD/conf]
- --log-dir=[directory] Log file directory for logs
- [$PWD/logs]
- --data-dir=[directory] Data directory for variable data, such as the permchannel
- configuration and the XLine database
- [$PWD/data]
- --module-dir=[directory] Modules directory for loadable modules
- [$PWD/modules]
- --binary-dir=[directory] Binaries directory for core binary
- [$PWD/bin]
- --list-extras Show current status of extra modules
- --enable-extras=[extras] Enable the specified list of extras
- --disable-extras=[extras] Disable the specified list of extras
- --help Show this help text and exit
-
-EOH
- exit(0);
-}
-
1;
-
diff --git a/make/template/main.mk b/make/template/main.mk
index b93c15094..bdb4d9762 100644
--- a/make/template/main.mk
+++ b/make/template/main.mk
@@ -46,9 +46,9 @@ DATPATH = "$(DESTDIR)@DATA_DIR@"
BINPATH = "$(DESTDIR)@BINARY_DIR@"
INSTALL = install
INSTUID = @UID@
-INSTMODE_DIR = 0755
-INSTMODE_BIN = 0755
-INSTMODE_LIB = 0644
+INSTMODE_DIR = 0750
+INSTMODE_BIN = 0750
+INSTMODE_LIB = 0640
@IFNEQ $(COMPILER) icc
CORECXXFLAGS += -pedantic -Woverloaded-virtual -Wshadow -Wformat=2 -Wmissing-format-attribute
diff --git a/make/utilities.pm b/make/utilities.pm
index 9bafe372e..87aa46d6e 100644
--- a/make/utilities.pm
+++ b/make/utilities.pm
@@ -20,18 +20,22 @@
#
-package make::utilities;
+BEGIN {
+ require 5.8.0;
+}
-require 5.8.0;
+package make::utilities;
use strict;
use warnings FATAL => qw(all);
use Exporter 'import';
-use POSIX;
-use Getopt::Long;
use Fcntl;
-our @EXPORT = qw(make_rpath pkgconfig_get_include_dirs pkgconfig_get_lib_dirs pkgconfig_check_version translate_functions promptstring);
+use File::Path;
+use File::Spec::Functions qw(rel2abs);
+use Getopt::Long;
+
+our @EXPORT = qw(module_installed prompt_bool prompt_dir prompt_string make_rpath pkgconfig_get_include_dirs pkgconfig_get_lib_dirs pkgconfig_check_version translate_functions promptstring);
# Parse the output of a *_config program,
# such as pcre_config, take out the -L
@@ -42,6 +46,47 @@ our @EXPORT = qw(make_rpath pkgconfig_get_include_dirs pkgconfig_get_lib_dirs pk
my %already_added = ();
my $if_skip_lines = 0;
+sub module_installed($)
+{
+ my $module = shift;
+ eval("use $module;");
+ return !$@;
+}
+
+sub prompt_bool($$$) {
+ my ($interactive, $question, $default) = @_;
+ my $answer = prompt_string($interactive, $question, $default ? 'y' : 'n');
+ return $answer =~ /y/i;
+}
+
+sub prompt_dir($$$) {
+ my ($interactive, $question, $default) = @_;
+ my ($answer, $create) = (undef, 'y');
+ do {
+ $answer = rel2abs(prompt_string($interactive, $question, $default));
+ $create = prompt_bool($interactive && !-d $answer, "$answer does not exist. Create it?", 'y');
+ my $mkpath = eval {
+ mkpath($answer, 0, 0750);
+ return 1;
+ };
+ unless (defined $mkpath) {
+ print "Error: unable to create $answer!\n\n";
+ $create = 0;
+ }
+ } while (!$create);
+ return $answer;
+}
+
+sub prompt_string($$$) {
+ my ($interactive, $question, $default) = @_;
+ return $default unless $interactive;
+ print $question, "\n";
+ print "[\e[1;32m$default\e[0m] => ";
+ chomp(my $answer = <STDIN>);
+ print "\n";
+ return $answer ? $answer : $default;
+}
+
sub promptstring($$$$$)
{
my ($prompt, $configitem, $default, $package, $commandlineswitch) = @_;
diff --git a/modulemanager b/modulemanager
index 7884654af..9e4670de8 100755
--- a/modulemanager
+++ b/modulemanager
@@ -22,8 +22,7 @@
use strict;
use warnings FATAL => qw(all);
-use make::configure;
-
+use make::utilities;
if (!module_installed("LWP::Simple"))
{
@@ -35,10 +34,9 @@ if (!module_installed("Crypt::SSLeay") && !module_installed("IO::Socket::SSL"))
die "Your system is missing the Crypt::SSLeay or IO::Socket::SSL Perl modules!";
}
+use File::Basename;
use LWP::Simple;
-our @modlist;
-
my %installed;
# $installed{name} = $version
@@ -128,8 +126,6 @@ while (<SRC>) {
}
close SRC;
-getmodules(1);
-
# determine core version
`./src/version.sh` =~ /InspIRCd-([0-9.]+)/ or die "Cannot determine inspircd version";
$installed{core} = $1;
@@ -153,9 +149,8 @@ $modules{core}{$1} = {
};
# set up core module list
-for my $modname (@modlist) {
- my $mod = "m_$modname";
- my $modfile = "src/modules/$mod.cpp";
+for my $modname (<src/modules/m_*.cpp>) {
+ my $mod = basename($modname, '.cpp');
my $ver = getmodversion($mod) || '0.0';
$ver =~ s/\$Rev: (.*) \$/$1/; # for storing revision in SVN
$installed{$mod} = $ver;