]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - configure
Fix bug experienced by satmd, remove space indents + tidy a little
[user/henk/code/inspircd.git] / configure
index 86dbc444e0660240d734ef5c8104b09e3990ef18..8af40ef104704863db4e33310c68cd194811761b 100755 (executable)
--- a/configure
+++ b/configure
@@ -2,7 +2,7 @@
 
 # InspIRCd Configuration Script
 #
-# Copyright 2003 The ChatSpike Development Team
+# Copyright 2002-2006 The ChatSpike Development Team
 # <brain@chatspike.net>
 # <Craig@chatspike.net>
 #
 #
 ########################################
 
+require 5.6.0;
 use Cwd;
 use Getopt::Long;
 
 GetOptions (
        'enable-gnutls' => \$opt_use_gnutls,
        'enable-openssl' => \$opt_use_openssl,
+       'disable-interactive' => \$opt_nointeractive,
        'with-nick-length=i' => \$opt_nick_length,
        'with-channel-length=i' => \$opt_chan_length,
        'with-max-channels=i' => \$opt_maxchans,
@@ -45,6 +47,10 @@ GetOptions (
        'binary-dir=s' => \$opt_binary_dir,
        'library-dir=s' => \$opt_library_dir,
        'help'  => sub { showhelp(); },
+       'modupdate' => sub { modupdate(); },
+       'update' => sub { update(); },
+       'svnupdate' => sub { svnupdate(); },
+       'clean' => sub { clean(); },
 );
 
 my $non_interactive = (
@@ -54,6 +60,7 @@ my $non_interactive = (
        (defined $opt_module_dir) ||
        (defined $opt_base_dir) ||
        (defined $opt_binary_dir) ||
+       (defined $opt_nointeractive) ||
        (defined $opt_away) ||
        (defined $opt_gecos) ||
        (defined $opt_kick) ||
@@ -240,7 +247,7 @@ if (defined $opt_away)
 
 $no_svn = 0;
 
-$config{HAS_OPENSSL} =~ /OpenSSL ([-[:digit:].]+)([a-z])? (\w{3}|[0-9]+) (\w{3}|[0-9]+) [0-9]{4}/;
+$config{HAS_OPENSSL} =~ /OpenSSL ([-[:digit:].]+)([a-z])?(\-[a-z][0-9])? (\w{3}|[0-9]+) (\w{3}|[0-9]+) [0-9]{4}/;
 $config{HAS_OPENSSL} = $1;
 
 if ($config{GCCVER} eq "") {
@@ -278,12 +285,18 @@ if (!$config{MAX_CLIENT_T}) {
 # Get and Set some important vars..
 getmodules();
 
-my $arg = $ARGV[0];                                            # Do Some Argument Checks..
-if ($arg eq "-clean") {
-       system("rm -rf .config.cache");
-}               # Remove the config.cache file.
+sub clean
+{
+       if ($arg eq "-clean") {
+               system("rm -rf .config.cache");
+       }
+}
 
-if ($arg eq "-update") {
+sub update
+{
+       chomp($topdir = getcwd());
+       $this = resolve_directory($topdir);                                             # PWD, Regardless.
+       getmodules();
        # Does the cache file exist?
        if (!getcache()) {
                # No, No it doesn't.. *BASH*
@@ -301,7 +314,11 @@ if ($arg eq "-update") {
        }
 }
 
-if ($arg eq "-modupdate") {
+sub modupdate
+{
+       chomp($topdir = getcwd());
+       $this = resolve_directory($topdir);                                             # PWD, Regardless.
+       getmodules();
         # Does the cache file exist?
         if (!getcache()) {
                 # No, No it doesn't.. *BASH*
@@ -321,7 +338,8 @@ if ($arg eq "-modupdate") {
 
 
 
-if ($arg eq "-svnupdate") {
+sub svnupdate
+{
        my $fail = 0;
        open(FH,"<.svn/entries") or $fail = 1;
        if ($fail) {
@@ -337,11 +355,10 @@ if ($arg eq "-svnupdate") {
 }
 
 print "Running non-interactive configure...\n" unless $interactive;
-
-print "Checking for cache from previous configure...\n";
-getcache();
-print "Checking operating system version...\n";
-getosflags();
+print "Checking for cache from previous configure... ";
+print ((getcache() eq "true") ? "found\n" : "not found\n");
+print "Checking operating system version... ";
+print getosflags() . "\n";
 
 if (defined $opt_maxclients)
 {
@@ -453,26 +470,24 @@ if (($config{HAS_OPENSSL}) && (($config{HAS_OPENSSL} >= 0.8) || ($config{HAS_OPE
 if ($interactive)
 {
        system("clear");
-       # Display Splash Logo..
-       show_splash();
-       chomp($wholeos = `uname -mnr`);
+       chomp($wholeos = `uname -sr`);
 
        my $rev = getrevision();
        # Display Introduction Message..
        print "
-Welcome to the InspIRCd Configuration program!
+Welcome to the \033[1mInspIRCd\033[0m Configuration program! (\033[1minteractive mode\033[0m)
+\033[1mPackage maintainers: Type ./configure --help for non-interactive help\033[0m
 
 *** If you are unsure of any of these values, leave it blank for    ***
 *** standard settings that will work, and your server will run      ***
-*** using them. If you are running this server as part of a         ***
-*** larger network, you must consult with your network admins       ***
-*** for the proper values to use, or server links will be unstable! ***
+*** using them. Please consult your IRC network admin if in doubt.  ***
 
 Press \033[1m<RETURN>\033[0m to accept the default for any option, or enter
 a new value. Please note: You will \033[1mHAVE\033[0m to read the docs
 dir, otherwise you won't have a config file!
 
-Your operating system is: \033[1;32m$config{OSNAME}\033[0m ($wholeos), fdmax: $config{MAX_CLIENT_T}
+Your operating system is: \033[1;32m$config{OSNAME}\033[0m ($wholeos)
+Maximum file descriptors: \033[1;32m$config{MAX_CLIENT_T}\033[0m
 Your InspIRCd revision ID is \033[1;32mr$rev\033[0m";
        if ($rev eq "r0") {
                print " (Non-SVN build)";
@@ -863,6 +878,17 @@ print "\033[0mIPv6 to IPv4 Links:\033[1;32m\t\t$config{SUPPORT_IP6LINKS}\033[0m\
 print "\033[0mGnuTLS Support:\033[1;32m\t\t\t$config{USE_GNUTLS}\033[0m\n";
 print "\033[0mOpenSSL Support:\033[1;32m\t\t$config{USE_OPENSSL}\033[0m\n\n";
 
+if (($config{USE_GNUTLS} eq "y") && ($config{HAS_GNUTLS} ne "y"))
+{
+       print "Sorry, but i couldn't detect gnutls. Make sure gnutls-config is in your path.\n";
+       exit(0);
+}
+if (($config{USE_OPENSSL} eq "y") && ($config{HAS_OPENSSL} ne "y"))
+{
+       print "Sorry, but i couldn't detect openssl. Make sure openssl is in your path.\n";
+       exit(0);
+}
+
 if ($config{USE_GNUTLS} eq "y") {
        $failed = 0;
        open(TMP, "<src/modules/m_ssl_gnutls.cpp") or $failed = 1;
@@ -875,13 +901,15 @@ if ($config{USE_GNUTLS} eq "y") {
                chdir("../..");
        }
        getmodules();
-       $failed = 0;
-       open(TMP, "<$config{CONFIG_DIR}/key.pem") or $failed = 1;
-       close(TMP);
-       open(TMP, "<$config{CONFIG_DIR}/cert.pem") or $failed = 1;
-       close(TMP);
-       if ($failed) {
-               print "SSL Certificates Not found, Generating.. \n\n
+       if ($interactive)
+       {
+               $failed = 0;
+               open(TMP, "<$config{CONFIG_DIR}/key.pem") or $failed = 1;
+               close(TMP);
+               open(TMP, "<$config{CONFIG_DIR}/cert.pem") or $failed = 1;
+               close(TMP);
+               if ($failed) {
+                       print "SSL Certificates Not found, Generating.. \n\n
 *************************************************************
 * Generating the Private Key may take some time, go grab a  *
 * Coffee. Even better, to generate some more entropy if it  *
@@ -889,15 +917,20 @@ if ($config{USE_GNUTLS} eq "y") {
 * few times and get that HD going :) Then answer the        *
 * Questions which follow. If you are unsure, just hit enter *
 *************************************************************\n\n";
-               system("certtool --generate-privkey --outfile key.pem");
-               system("certtool --generate-self-signed --load-privkey key.pem --outfile cert.pem");
-               print "\nCertificate generation complete, copying to config directory... ";
-               system("mv key.pem $config{CONFIG_DIR}/key.pem");
-               system("mv cert.pem $config{CONFIG_DIR}/cert.pem");
-               print "Done.\n\n";
-       } else {
-               print "SSL Certificates found, skipping.\n\n"
-       }       
+                       system("certtool --generate-privkey --outfile key.pem");
+                       system("certtool --generate-self-signed --load-privkey key.pem --outfile cert.pem");
+                       print "\nCertificate generation complete, copying to config directory... ";
+                       system("mv key.pem $config{CONFIG_DIR}/key.pem");
+                       system("mv cert.pem $config{CONFIG_DIR}/cert.pem");
+                       print "Done.\n\n";
+               } else {
+                       print "SSL Certificates found, skipping.\n\n"
+               }
+       }
+       else
+       {
+               print "Skipping SSL certificate generation\nin non-interactive mode.\n\n";
+       }
 } elsif ($config{USE_OPENSSL} eq "y") {
        $failed = 0;
        open(TMP, "<src/modules/m_ssl_openssl.cpp") or $failed = 1;
@@ -911,25 +944,32 @@ if ($config{USE_GNUTLS} eq "y") {
        }
        getmodules();
        $failed = 0;
-       open(TMP, "<$config{CONFIG_DIR}/key.pem") or $failed = 1;
-       close(TMP);
-       open(TMP, "<$config{CONFIG_DIR}/cert.pem") or $failed = 1;
-       close(TMP);
-       if ($failed) {
-               print "SSL Certificates Not found, Generating.. \n\n
+       if ($interactive)
+       {
+               open(TMP, "<$config{CONFIG_DIR}/key.pem") or $failed = 1;
+               close(TMP);
+               open(TMP, "<$config{CONFIG_DIR}/cert.pem") or $failed = 1;
+               close(TMP);
+               if ($failed) {
+                       print "SSL Certificates Not found, Generating.. \n\n
 *************************************************************
 * Generating the certificates may take some time, go grab a *
 * coffee, or something.                                     *
 *************************************************************\n\n";
-               system("openssl req -x509 -nodes -newkey rsa:1024 -keyout key.pem -out cert.pem");
-               system("openssl dhparam -out dhparams.pem 1024");
-               print "\nCertificate generation complete, copying to config directory... ";
-               system("mv key.pem $config{CONFIG_DIR}/key.pem");
-               system("mv cert.pem $config{CONFIG_DIR}/cert.pem");
-               system("mv dhparams.pem $config{CONFIG_DIR}/dhparams.pem");
-               print "Done.\n\n";
-       } else {
-               print "SSL Certificates found, skipping.\n\n"
+                       system("openssl req -x509 -nodes -newkey rsa:1024 -keyout key.pem -out cert.pem");
+                       system("openssl dhparam -out dhparams.pem 1024");
+                       print "\nCertificate generation complete, copying to config directory... ";
+                       system("mv key.pem $config{CONFIG_DIR}/key.pem");
+                       system("mv cert.pem $config{CONFIG_DIR}/cert.pem");
+                       system("mv dhparams.pem $config{CONFIG_DIR}/dhparams.pem");
+                       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_GNUTLS} eq "n") && ($config{USE_OPENSSL} eq "n")) {
@@ -1060,7 +1100,9 @@ sub getosflags {
                                $config{CC} = "eg++";
                                chomp($config{GCCVER}       = `eg++ -dumpversion | cut -c 1`); # we must redo these if we change the compiler path
                        }
+                       return "OpenBSD";
                }
+               return $config{OSNAME};
        } else {
                $config{LDLIBS} = "-ldl -lstdc++";
                $config{FLAGS}  = "-fPIC -Wall -Woverloaded-virtual $config{OPTIMISATI}";
@@ -1070,6 +1112,7 @@ sub getosflags {
                        $config{LDLIBS} = "";
                        $config{MAKEPROG} = "/usr/bin/make";
                        $config{MAKEORDER} = "ircd mods";
+                       return "Cygwin";
                } elsif ($config{OSNAME} eq "CYG-STATIC") {
                        $config{FLAGS} = "-Wall -Woverloaded-virtual $config{OPTIMISATI}";
                        $config{LDLIBS} = "";
@@ -1077,7 +1120,9 @@ sub getosflags {
                        $config{MAKEORDER} = "mods ircd";
                        $config{STATICLIBS} = "modules/mods.a";
                        $config{STATIC_LINK} = "yes";
+                       return "Cygwin-Static";
                }
+               return "Linux";
        }
        
        if ($config{OSNAME} =~ /SunOS/)
@@ -1088,12 +1133,14 @@ sub getosflags {
                # rt = POSIX realtime extensions
                # resolv = inet_aton only (why isnt this in nsl?!)
                $config{LDLIBS} = $config{LDLIBS} . " -lsocket -lnsl -lrt -lresolv";
+               return "Solaris";
        }
        
        if($config{OSNAME} eq "MINGW32")
        {
                # All code is position-independent on windows
                $config{FLAGS} =~ s/-fPIC //;
+               return "MinGW";
        }
 }
 
@@ -1356,15 +1403,17 @@ sub getlinkerflags {
        return undef;
 }
 
-sub show_splash {
-  print "'\033[1;33m####\033[0m:'\033[1;33m##\033[0m::: \033[1;33m##\033[0m::'\033[1;33m######\033[0m::'\033[1;33m########\033[0m::'\033[1;33m####\033[0m:'\033[1;33m########\033[0m:::'\033[1;33m######\033[0m::'\033[1;33m########\033[0m::\n";
-  print ". \033[1;33m##\033[0m:: \033[1;33m###\033[0m:: \033[1;33m##\033[0m:'\033[1;33m##\033[0m... \033[1;33m##\033[0m: \033[1;33m##\033[0m.... \033[1;33m##\033[0m:. \033[1;33m##\033[0m:: \033[1;33m##\033[0m.... \033[1;33m##\033[0m:'\033[1;33m##\033[0m... \033[1;33m##\033[0m: \033[1;33m##\033[0m.... \033[1;33m##\033[0m:\n";
-  print ": \033[1;33m##\033[0m:: \033[1;33m####\033[0m: \033[1;33m##\033[0m: \033[1;33m##\033[0m:::..:: \033[1;33m##\033[0m:::: \033[1;33m##\033[0m:: \033[1;33m##\033[0m:: \033[1;33m##\033[0m:::: \033[1;33m##\033[0m: \033[1;33m##\033[0m:::..:: \033[1;33m##\033[0m:::: \033[1;33m##\033[0m:\n";
-  print ": \033[1;33m##\033[0m:: \033[1;33m##\033[0m \033[1;33m##\033[0m \033[1;33m##\033[0m:. \033[1;33m######\033[0m:: \033[1;33m########\033[0m::: \033[1;33m##\033[0m:: \033[1;33m########\033[0m:: \033[1;33m##\033[0m::::::: \033[1;33m##\033[0m:::: \033[1;33m##\033[0m:\n";
-  print ": \033[1;33m##\033[0m:: \033[1;33m##\033[0m. \033[1;33m####\033[0m::..... \033[1;33m##\033[0m: \033[1;33m##\033[0m.....:::: \033[1;33m##\033[0m:: \033[1;33m##\033[0m.. \033[1;33m##\033[0m::: \033[1;33m##\033[0m::::::: \033[1;33m##\033[0m:::: \033[1;33m##\033[0m:\n";
-  print ": \033[1;33m##\033[0m:: \033[1;33m##\033[0m:. \033[1;33m###\033[0m:'\033[1;33m##\033[0m::: \033[1;33m##\033[0m: \033[1;33m##\033[0m::::::::: \033[1;33m##\033[0m:: \033[1;33m##\033[0m::. \033[1;33m##\033[0m:: \033[1;33m##\033[0m::: \033[1;33m##\033[0m: \033[1;33m##\033[0m:::: \033[1;33m##\033[0m:\n";
-  print "'\033[1;33m####\033[0m: \033[1;33m##\033[0m::. \033[1;33m##\033[0m:. \033[1;33m######\033[0m:: \033[1;33m##\033[0m::::::::'\033[1;33m####\033[0m: \033[1;33m##\033[0m:::. \033[1;33m##\033[0m:. \033[1;33m######\033[0m:: \033[1;33m########\033[0m::\n";
-  print "\033[0m\033[0m....::..::::..:::......:::..:::::::::....::..:::::..:::......:::........:::\n\n";
+sub getdependencies {
+       my ($file) = @_;
+       open(FLAGS, $file);
+       while (<FLAGS>) {
+               if ($_ =~ /^\/\* \$ModDep: (.+) \*\/$/) {
+                       close(FLAGS);
+                       return $1;
+               }
+       }
+       close(FLAGS);
+       return undef;
 }
 
 sub resolve_directory {
@@ -1447,12 +1496,13 @@ HEADER
                if ($i !~ /_static$/) {
                        $cmflags = getcompilerflags("src/modules/m_".$i.".cpp");
                        $liflags = getlinkerflags("src/modules/m_".$i.".cpp");
+                       $deps = getdependencies("src/modules/m_".$i.".cpp");
 
                        ###
                        # Write Entry to the Makefile
                        ###
                        print FILEHANDLE <<EOCHEESE;
-m_$i.o: .m_$i\_static.cpp ../../include/modules.h ../../include/users.h ../../include/channels.h ../../include/base.h
+m_$i.o: .m_$i\_static.cpp ../../include/modules.h ../../include/users.h ../../include/channels.h ../../include/base.h $deps
        \$(CC) -pipe -I../../include \$(FLAGS) $flags -export-dynamic -c .m_$i\_static.cpp
        mv .m_$i\_static.o ../m_$i.o
 
@@ -1520,8 +1570,9 @@ EOF
        ###
        $cmflags = getcompilerflags("src/modules/m_".$i.".cpp");
        $liflags = getlinkerflags("src/modules/m_".$i.".cpp");
+       $deps = getdependencies("src/modules/m_".$i.".cpp");
        print FILEHANDLE <<EOCHEESE;
-m_$i.so: m_$i.cpp ../../include/modules.h ../../include/users.h ../../include/channels.h ../../include/base.h ../../include/inspircd_config.h ../../include/inspircd.h ../../include/configreader.h
+m_$i.so: m_$i.cpp ../../include/modules.h ../../include/users.h ../../include/channels.h ../../include/base.h ../../include/inspircd_config.h ../../include/inspircd.h ../../include/configreader.h $deps
        \$(CC) -pipe -I../../include \$(FLAGS) $cmflags -export-dynamic -c m_$i.cpp
        \$(CC) \$(FLAGS) -shared $liflags -o m_$i.so m_$i.o $extra
 
@@ -1840,6 +1891,7 @@ ITEM
 
 sub showhelp
 {
+       chomp($PWD = `pwd`);
        print "Usage: configure [options]
 Options: [defaults in brackets after descriptions]
 
@@ -1849,21 +1901,20 @@ any required values manually. If one or more
 options are specified, non-interactive configuration
 is started, and any omitted values are defaulted.
 
-Interactive configuration and reconfiguration:
-
-  -update                      Update makefiles
-  -modupdate                   Detect new modules
-  -svnupdate {rebuild}         Update working copy
-                               {and optionally rebuild}
-  -clean                       Remove .config.cache
-
-Non-interactive and initial configuration:
+Arguments with a single \"-\" symbol, as in
+InspIRCd 1.0.x, are also allowed.
 
+  --disable-interactive        Sets no options intself, but
+                               will disable any interactive prompting.
+  --update                     Update makefiles and dependencies
+  --modupdate                  Detect new modules and write makefiles
+  --svnupdate {rebuild}        Update working copy via subversion
+                               {and optionally rebuild it}
+  --clean                      Remove .config.cache file and go interactive
   --enable-gnutls              Enable GnuTLS module [no]
   --enable-openssl             Enable OpenSSL module [no]
   --with-nick-length=[n]       Specify max. nick length [32]
-  --with-channel-length=[n]    Specify max. channel length
-                               [64]
+  --with-channel-length=[n]    Specify max. channel length [64]
   --with-max-channels=[n]      Specify max. number of channels
                                a normal user may join [20]
   --with-max-oper-channels=[n] Specify max. number of channels
@@ -1871,10 +1922,8 @@ Non-interactive and initial configuration:
   --with-max-clients=[n]       Specify maximum number of users
                                which may connect locally
   --enable-optimization=[n]    Optimize using -O[n] gcc flag
-  --enable-epoll               Enable epoll() where supported
-                               [set]
-  --enable-kqueue              Enable kqueue() where supported
-                               [set]
+  --enable-epoll               Enable epoll() where supported [set]
+  --enable-kqueue              Enable kqueue() where supported [set]
   --disable-epoll              Do not enable epoll(), fall back
                                to select() [not set]
   --disable-kqueue             Do not enable kqueue(), fall back
@@ -1882,8 +1931,7 @@ Non-interactive and initial configuration:
   --enable-ipv6                Build ipv6 native InspIRCd [no]
   --enable-remote-ipv6         Build with ipv6 support for remote
                                servers on the network [yes]
-  --disable-remote-ipv6        No not allow remote ipv6 servers
-                               [not set]
+  --disable-remote-ipv6        Do not allow remote ipv6 servers [not set]
   --with-cc=[filename]         Use an alternative g++ binary to
                                build InspIRCd [g++]
   --with-ident-length=[n]      Specify max length of ident [12]
@@ -1894,13 +1942,20 @@ Non-interactive and initial configuration:
   --with-away-length=[n]       Specify max length of away [150]
   --with-max-modes=[n]         Specify max modes per line which
                                have parameters [20]
-  --prefix=[directory]         Base directory to install into
-                               [current directory]
-  --config-dir=[directory]     Config file directory [prefix/conf]
-  --module-dir=[directory]     Modules directory [prefix/modules]
-  --binary-dir=[directory]     Binaries directory [prefix/bin]
-  --library-dir=[directory]    Library directory [prefix/lib]
-  --help                       Show this help text
+  --prefix=[directory]         Base directory to install into (if defined,
+                               can automatically define config, module, bin
+                              and library dirs as subdirectories of prefix)
+                               [$PWD]
+  --config-dir=[directory]     Config file directory for config and SSL certs
+                               [$PWD/conf]
+  --module-dir=[directory]     Modules directory for loadable modules
+                               [$PWD/modules]
+  --binary-dir=[directory]     Binaries directory for core binary
+                               [$PWD/bin]
+  --library-dir=[directory]    Library directory for core libraries
+                               [$PWD/lib]
+  --help                       Show this help text and exit
+
 ";
        exit(0);
 }