]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - configure
A few simple output lines (similar to gnu autoconf so people know what's happening)
[user/henk/code/inspircd.git] / configure
index f0881ee4cb20528f19a36ce108ce8ed035943661..428328e424858ea9c55b730725ab5f3fc765d9ff 100755 (executable)
--- a/configure
+++ b/configure
@@ -27,6 +27,7 @@ $config{CHAN_LENGT}         = "64";                                           # Default Chan
 $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}         = "n";                                             # kqueue enabled
 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
@@ -63,8 +64,9 @@ if ($arg eq "-update") {
   }
 }
 
-
+print "Checking for cache from previous configure...\n";
 getcache();
+print "Checking operating system version...\n";
 getosflags();
 
 if (!$config{MAX_CLIENT}) { 
@@ -74,21 +76,46 @@ if (!$config{MAX_CLIENT}) {
   $config{MAX_CLIENT} = $config{MAX_CLIENT_T};
 }
 
+printf "Checking if strlcpy exists... ";
 # Perform the strlcpy() test..
-open(STRLCPY, ">.test.cpp");
-print STRLCPY "#include <string.h>
-#include <stdio.h>
-int main() { char a[10]; char b[10]; strlcpy(a,b,10); printf(\"%d\\n\",9); }\n";
-close(STRLCPY);
-
-# Build the Binary..
-system("g++ -o .test .test.cpp 2>&1");
-
-# Was the build succesful?
-if (-e ".test") {
-  $config{HAS_STRLCPY} = "true";
-  system("rm -f .test .test.cpp");
+$config{HAS_STRLCPY} = "false";
+my $fail = 0;
+open(STRLCPY, "</usr/include/string.h") or $fail = 1;
+if (!$fail)
+{
+       while (chomp($line = <STRLCPY>))
+       {
+               # try and find the delcaration of:
+               # size_t strlcpy(...)
+               if (($line =~ /size_t(\0x9|\s)+strlcpy(\0x9|\s)+\(/) || ($line =~ /size_t(\0x9|\s)+strlcpy\(/))
+               {
+                       $config{HAS_STRLCPY} = "true";
+               }
+       }
+       close(STRLCPY);
+}
+print "yes\n" if $config{HAS_STRLCPY} eq "true";
+print "no\n" if $config{HAS_STRLCPY} eq "false";
+
+printf "Checking if kqueue exists... ";
+$has_kqueue = 0;
+$fail = 0;
+open(KQUEUE, "</usr/include/sys/event.h") or $fail = 1;
+if (!$fail)
+{
+        while (chomp($line = <KQUEUE>))
+        {
+                # try and find the delcaration of:
+               # int kqueue(void);
+               if (($line =~ /int(\0x9|\s)+kqueue(\0x9|\s)+\(/) || ($line =~ /int(\0x9|\s)+kqueue\(/))
+               {
+                       $has_kqueue = 1;
+               }
+       }
+       close(KQUEUE);
 }
+print "yes\n" if $has_kqueue == 1;
+print "no\n" if $has_kqueue == 0;
 
 ################################################################################
 #                          BEGIN INTERACTIVE PART                              #
@@ -122,6 +149,10 @@ 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 the IRCd libraries to be placed", "LIBRARY_DIR");
 
+if ($has_kqueue) {
+       yesno(USE_KQUEUE,"You are running a BSD operating system, and kqueue\nwas detected. Would you like to enable kqueue support?\nIf you are unsure, answer no.\n\nEnable kqueue?");
+}
+
 # File Descriptor Settings..
 my $continue = 0;
 while (!$continue) {
@@ -193,15 +224,19 @@ Please read the documentation for more information.
 
 The Higher the number, the more optimised your binary will be. This value will default to 0
 If you either a) Dont enter a number, or b) Enter a value outside the range.\n";
-print "[\033[1;32m0\033[0m] -> ";
+print "[\033[1;32m$config{OPTIMITEMP}\033[0m] -> ";
 chomp($var = <STDIN>);
-if ($var == 1) {
+if ($var eq "") {
+  $var = $config{OPTIMITEMP};
+}
+
+if ($var eq "1") {
   $config{OPTIMITEMP} = 1;
   $config{OPTIMISATI} = "-O";
-} elsif ($var == 2) {
+} elsif ($var eq "2") {
   $config{OPTIMITEMP} = 2;
   $config{OPTIMISATI} = "-O2";
-} elsif ($var == 3) {
+} elsif ($var eq "3") {
   $config{OPTIMITEMP} = 3;
   $config{OPTIMISATI} = "-O3";
 } else {
@@ -311,11 +346,11 @@ sub dir_check {
 sub getosflags {
   if ($config{OSNAME} eq "FreeBSD") {
     $config{LDLIBS} = "-Ldl";
-    $config{FLAGS}  = "-fPIC -frtti $OPTIMISATI -Woverloaded-virtual -g";
+    $config{FLAGS}  = "-fPIC -frtti $OPTIMISATI -Woverloaded-virtual $config{OPTIMISATI}";
     $config{MAKEPROG} = "gmake";
   } else {
     $config{LDLIBS} = "-ldl";
-    $config{FLAGS}  = "-fPIC -frtti $OPTIMISATI -Woverloaded-virtual -g";
+    $config{FLAGS}  = "-fPIC -frtti $OPTIMISATI -Woverloaded-virtual $config{OPTIMISATI}";
     $config{MAKEPROG} = "make";
   }
 }
@@ -384,6 +419,9 @@ EOF
   if ($config{HAS_STRLCPY} eq "true") {
     print FILEHANDLE "#define HAS_STRLCPY\n";
   }
+  if ($config{USE_KQUEUE} eq "y") {
+    print FILEHANDLE "#define USE_KQUEUE\n";
+  }
   close(FILEHANDLE);
 
   # Create a Modules List..
@@ -454,9 +492,10 @@ EOF
     $flags = getcompilerflags("src/modules/m_".$i.".cpp");
     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) -I../../include \$(FLAGS) -shared $flags -o m_$i.so m_$i.cpp
-       \@cp m_$i.so \$(MODPATH)/
-       \@chmod 0700 \$(MODPATH)/m_$i.so
+       \$(CC) -pipe -I../../include \$(FLAGS) $flags -export-dynamic -c m_$i.cpp
+       \$(CC) \$(FLAGS) -shared $flags -o m_$i.so m_$i.o
+       cp m_$i.so \$(MODPATH)/
+       chmod 0700 \$(MODPATH)/m_$i.so
 
 EOCHEESE
   }
@@ -489,13 +528,18 @@ sub show_splash {
 sub resolve_directory {
        use File::Spec;
        return File::Spec->rel2abs($_[0]);
+}
 
-       #my $dir = $_[0];
-       #my $old_dir = "";
-       #my $real_dir = "";
-       #getpwd($old_dir);
-       #chdir($dir);
-       #getpwd($real_dir);
-       #chdir($old_dir);
-       #return $real_dir;
+sub yesno {
+       my ($flag,$prompt) = @_;
+       print "$prompt [\033[1;32m$config{$flag}\033[0m] -> ";
+       chomp($tmp = <STDIN>);
+       if ($tmp eq "") { $tmp = $config{$flag} }
+
+       if (($tmp eq "") || ($tmp =~ /^y/i)) {
+               $config{$flag} = "y";
+       } else {
+               $config{$flag} = "n";
+        }
+       return;
 }