]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - configure
Fixed to never append double sums
[user/henk/code/inspircd.git] / configure
index 560959de9ecc20e478fe0c56a0732f05116bf9cb..01683da91c927a1eef0e18410e69c01dbab0f3d0 100755 (executable)
--- a/configure
+++ b/configure
@@ -22,18 +22,21 @@ $config{BINARY_DIR}         = resolve_directory($config{ME}."/bin");                # Binary D
 $config{LIBRARY_DIR}        = resolve_directory($config{ME}."/lib");           # Library Directory
 $config{OPTIMITEMP}         = "0";                                             # Default Optimisation Value
 $config{OPTIMISATI}         = "-g";                                            # Optimisation Flag
-$config{NICK_LENGT}         = "32";                                            # Default Nick Length
+$config{NICK_LENGT}         = "31";                                            # Default Nick Length
 $config{CHAN_LENGT}         = "64";                                            # Default Channel Name Length
 $config{MAX_CHANNE}         = "20";                                            # Default Max. Channels per user..
 $config{MAXI_MODES}         = "20";                                            # Default Max. Number of Modes set at once.
 $config{HAS_STRLCPY}        = "false";                                         # strlcpy Check.
 $config{USE_KQUEUE}         = "y";                                             # kqueue enabled
 $config{USE_EPOLL}          = "y";                                             # epoll enabled
+$config{STATIC_LINK}       = "no";                                             # are doing static modules?
 chomp($config{MAX_CLIENT_T} = `sh -c \"ulimit -n\"`);                          # FD Limit
 chomp($config{GCCVER}       = `gcc -dumpversion | cut -c 1`);                  # Major GCC Version
 chomp($config{GCC34}        = `gcc -dumpversion | cut -c 3`);                  # Minor GCC Version
 chomp($config{OSNAME}       = `/bin/uname`);                                   # Operating System Name
 $config{CC}                = "g++";                                            # C++ compiler
+$config{MAKEORDER}         = "ircd mods config bininst";                       # build order
+$config{STATICLIBS}         = "";                                              # library archive path
 
 if ((!$config{OSNAME}) || ($config{OSNAME} eq "")) {
   chomp($config{OSNAME} = `/usr/bin/uname`);
@@ -238,6 +241,9 @@ while (!$continue) {
   }
 }
 
+# Because of the terminating null char we must increment this by one
+$config{NICK_LENGT}++;
+
 my $continue = 0;
 while (!$continue) {
   print "What is the Maximum number of mode changes in one line?\n";
@@ -292,7 +298,8 @@ print "\033[0mMax channel length:\033[1;32m\t\t$config{CHAN_LENGT}\n";
 print "\033[0mMax mode length:\033[1;32m\t\t$config{MAXI_MODES}\n";
 print "\033[0mGCC Version Found:\033[1;32m\t\t$config{GCCVER}.$config{GCC34}\n";
 print "\033[0mOptimatizaton Flag:\033[1;32m\t\t$config{OPTIMISATI}\033[0m\n";
-print "\033[0mCompiler program:\033[1;32m\t\t$config{CC}\033[0m\n\n";
+print "\033[0mCompiler program:\033[1;32m\t\t$config{CC}\033[0m\n";
+print "\033[0mStatic modules:\033[1;32m\t\t\t$config{STATIC_LINK}\033[0m\n\n";
 
 makecache();
 writefiles();
@@ -304,7 +311,13 @@ if (($config{OSNAME} eq "OpenBSD") && ($config{CC} ne "eg++")) {
        print "\033[1;32mWARNING!\033[0m You are running OpenBSD but you are using the base gcc package\nrather than eg++. This compile will most likely fail, but i'm letting you\ngo ahead with it anyway, just in case i'm wrong :-)\n";
 }
 if ($config{OSNAME} =~ /CYGWIN/) {
-       print "\033[1;32mWARNING!\033[0m CYGWIN does not properly support shared modules,\nso modules are unavailable on this platform.\nThe modules will build as .o files but will not be available for use.\nYou will be able to run the core ircd file (inspircd.exe) as normal.\n";
+       print <<FOO;
+\033[1;32mWARNING!\033[0m CYGWIN does not properly support shared modules,
+so modules will be compiled statically into the core of the ircd. The modules
+will act like they are being loaded from disk and being unloaded from RAM,
+however they are in fact being enabled and disabled similar to features in
+other ircds.
+FOO
 }
 
 ################################################################################
@@ -412,6 +425,9 @@ sub getosflags {
        $config{FLAGS}  = "-frtti $OPTIMISATI -Woverloaded-virtual $config{OPTIMISATI}";
        $config{LDLIBS} = "";
        $config{MAKEPROG} = "/usr/bin/make";
+       $config{MAKEORDER} = "mods ircd config bininst";
+       $config{STATICLIBS} = "modules/mods.a";
+       $config{STATIC_LINK} = "yes";
     }
   }
   if ($config{OSNAME} =~ /SunOS/) {
@@ -442,7 +458,10 @@ sub getmodules {
   foreach $name (sort readdir(DIRHANDLE)) {
     if ($name =~ /^m_(.+)\.cpp$/)
     {
-      $modlist[$i++] = $1;
+      $mod = $1;
+      if ($mod !~ /_static$/) {
+             $modlist[$i++] = $mod;
+      }
     }
   }
   closedir(DIRHANDLE);
@@ -475,6 +494,12 @@ EOF
   if ($config{OSNAME} =~ /SunOS/) {
     print FILEHANDLE "#define IS_SOLARIS\n";
   }
+  if ($config{OSNAME} =~ /CYGWIN/) {
+    print FILEHANDLE "#define IS_CYGWIN\n";
+  }
+  if ($config{STATIC_LINK} eq "yes") {
+    print FILEHANDLE "#define STATIC_LINK\n";
+  }
   if ($config{GCCVER} > 3) {
     print FILEHANDLE "#define GCC3\n";
     print FILEHANDLE "#define GCC34\n";
@@ -553,6 +578,8 @@ EOF
       $tmp =~ s/\@LIBRARY_DIR\@/$config{LIBRARY_DIR}/;
       $tmp =~ s/\@MODULES\@/$modules/;
       $tmp =~ s/\@EXECUTABLE\@/$exe/;
+      $tmp =~ s/\@MAKEORDER\@/$config{MAKEORDER}/;
+      $tmp =~ s/\@STATICLIBS\@/$config{STATICLIBS}/;
 
       print "Writing \033[1;32m$file\033[0m\n";
       open(FILEHANDLE, ">$file");
@@ -573,6 +600,7 @@ EOF
        write_dynamic_makefile();
   }
 
+
   # Modules Makefile..
   print "Writing \033[1;32msrc/modules/Makefile\033[0m\n";
   open(FILEHANDLE, ">src/modules/Makefile");
@@ -592,26 +620,64 @@ EOF
   # Create a Modules List..
   my $modules = "";
   my $flags = "";
+  if ($config{OSNAME} =~ /CYGWIN/) {
+     open(MODLIST,">include/modlist.h");
+     print MODLIST <<HEADER;
+// Generated automatically by configure. DO NOT EDIT!
+
+#ifndef __SYMBOLS__H_CONFIGURED__
+#define __SYMBOLS__H_CONFIGURED__
+
+HEADER
+     foreach $i (@modlist) {
+       if ($i !~ /_static$/) {
+               print MODLIST "extern \"C\" void * $i\_init (void);\n";
+       }
+     }
+     print MODLIST "\nstruct {const char *name; initfunc *value; } modsyms[] = {\n";
+  }
   foreach $i (@modlist)
   {
-    $flags = getcompilerflags("src/modules/m_".$i.".cpp");
-    if ($config{OSNAME} =~ /CYGWIN/) {
-       print FILEHANDLE <<EOCHEESE;
-m_$i.o: m_$i.cpp ../../include/modules.h ../../include/users.h ../../include/channels.h ../../include/servers.h ../../include/base.h
-       \$(CC) -pipe -I../../include \$(FLAGS) $flags -export-dynamic -c m_$i.cpp
+    if ($i !~ /_static$/) {
+     $flags = getcompilerflags("src/modules/m_".$i.".cpp");
+     if ($config{OSNAME} =~ /CYGWIN/) {
+        print FILEHANDLE <<EOCHEESE;
+m_$i.o: m_$i\_static.cpp ../../include/modules.h ../../include/users.h ../../include/channels.h ../../include/servers.h ../../include/base.h
+       \$(CC) -pipe -I../../include \$(FLAGS) $flags -export-dynamic -c m_$i\_static.cpp
+       mv m_$i\_static.o ../m_$i.o
 
 EOCHEESE
-    }
-    else {
-        print FILEHANDLE <<EOCHEESE;
+        print "Configuring module [\033[1;32mm_$i.so\033[0m] for static linking... ";
+        open(MODULE,"<src/modules/m_".$i.".cpp") or die("Could not open m_".$i.".cpp");
+        open(MUNGED,">src/modules/m_".$i."_static.cpp") or die("Could not create m_".$i."_static.cpp");
+        while (chomp($a = <MODULE>)) { 
+               $a =~ s/init_module/$i\_init/g;
+               $a =~ s/Srv/$i\Srv/g;
+               print MUNGED "$a\n";
+        }
+        close(MODULE);
+        close(MUNGED);
+        print MODLIST <<EOENT;
+{"m_$i.so",\&$i\_init},
+EOENT
+        print "done\n";
+     }
+     else {
+         print FILEHANDLE <<EOCHEESE;
 m_$i.so: m_$i.cpp ../../include/modules.h ../../include/users.h ../../include/channels.h ../../include/servers.h ../../include/base.h
        \$(CC) -pipe -I../../include \$(FLAGS) $flags -export-dynamic -c m_$i.cpp
        \$(CC) \$(FLAGS) -shared $flags -o m_$i.so m_$i.o
+       @-rm -f \$(MODPATH)/m_$i.so
        cp m_$i.so \$(MODPATH)/
        chmod 0700 \$(MODPATH)/m_$i.so
 
 EOCHEESE
-     }
+      }
+   }
+  }
+  if ($config{OSNAME} =~ /CYGWIN/) {
+     print MODLIST "{0}};\n\n#endif\n";
+     close(MODLIST);
   }
 }
 
@@ -671,12 +737,12 @@ sub write_static_makefile {
 
 CC = im a cheezeball
 
-CXXFLAGS = -I$../include \${FLAGS}
+CXXFLAGS = -I../include \${FLAGS}
 
-all: hashcomp.o channels.o mode.o xline.o inspstring.o dns.o base.o inspircd_util.o inspircd_io.o connection.o message.o commands.o dnsqueue.o dynamic.o users.o modules.o wildcard.o servers.o helperfuncs.o inspircd.exe
+all: hashcomp.o channels.o mode.o xline.o inspstring.o dns.o base.o inspircd_util.o inspircd_io.o connection.o message.o commands.o dnsqueue.o dynamic.o users.o modules.o wildcard.o servers.o helperfuncs.o \$(MODULES) inspircd.exe
 
 inspircd.exe: inspircd.cpp ../include/base.h ../include/channels.h ../include/inspircd.h ../include/channels.h ../include/globals.h ../include/inspircd_config.h
-       \$(CC) -I../include \$(FLAGS) inspircd.cpp -o inspircd.exe \$(LDLIBS) channels.o mode.o xline.o inspstring.o dns.o base.o inspircd_util.o inspircd_io.o connection.o message.o commands.o dnsqueue.o dynamic.o users.o modules.o wildcard.o servers.o helperfuncs.o hashcomp.o
+       \$(CC) -I../include \$(FLAGS) inspircd.cpp -o inspircd.exe \$(LDLIBS) channels.o mode.o xline.o inspstring.o dns.o base.o inspircd_util.o inspircd_io.o connection.o message.o commands.o dnsqueue.o dynamic.o users.o modules.o wildcard.o servers.o helperfuncs.o hashcomp.o \$(MODULES)
 
 hashcomp.o: hashcomp.cpp ../include/base.h ../include/hashcomp.h ../include/inspircd.h ../include/users.h ../include/globals.h ../include/inspircd_config.h
        \$(CC) -pipe -I../include \$(FLAGS) -export-dynamic -c hashcomp.cpp
@@ -752,7 +818,7 @@ sub write_dynamic_makefile {
 
 CC = im a cheezeball
 
-CXXFLAGS = -I$../include ${FLAGS}
+CXXFLAGS = -I../include \${FLAGS}
 
 all: libIRCDhash.so libIRCDchannels.so libIRCDmode.so libIRCDxline.so libIRCDstring.so libIRCDasyncdns.so libIRCDbase.so libIRCDutil.so libIRCDio.so libIRCDconnection.so libIRCDmessage.so libIRCDcommands.so libIRCDdnsqueue.so libIRCDdynamic.so libIRCDusers.so libIRCDmodules.so libIRCDwildcard.so libIRCDservers.so libIRCDhelper.so inspircd