]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - configure
Edited to properly detect strlcpy on netbsd (different declaration in string.h didn...
[user/henk/code/inspircd.git] / configure
index 0503f6008183c6d278135a1b5196a900ecad4b4f..1c17677ed269ccb56fc9c43016c117395da61bde 100755 (executable)
--- a/configure
+++ b/configure
@@ -32,10 +32,14 @@ $config{USE_EPOLL}          = "y";                                          # epoll 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
-chomp($config{OSNAME}       = `/bin/uname -s`);                                # Operating System Name
+chomp($config{OSNAME}       = `/bin/uname`);                                   # Operating System Name
+$config{CC}                = "g++";                                            # C++ compiler
 
-if (!$config{OSNAME}) {
-  $config{OSNAME} = "Unknown";                                  # For use when uname fails.
+if ((!$config{OSNAME}) || ($config{OSNAME} eq "")) {
+  chomp($config{OSNAME} = `/usr/bin/uname`);
+  if ((!$config{OSNAME}) || ($config{OSNAME} eq "")){
+       $config{OSNAME} = "Unknown";
+  }
 }
 
 if (!$config{MAX_CLIENT_T}) { 
@@ -88,7 +92,7 @@ if (!$fail)
        {
                # try and find the delcaration of:
                # size_t strlcpy(...)
-               if (($line =~ /size_t(\0x9|\s)+strlcpy(\0x9|\s)+\(/) || ($line =~ /size_t(\0x9|\s)+strlcpy\(/))
+               if ($line =~ /size_t(\0x9|\s)+strlcpy/)
                {
                        $config{HAS_STRLCPY} = "true";
                }
@@ -283,7 +287,8 @@ print "\033[0mMax nickname length:\033[1;32m\t\t$config{NICK_LENGT}\n";
 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\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";
 
 makecache();
 writefiles();
@@ -291,6 +296,9 @@ writefiles();
 print "\n\n";
 print "To build your server with these settings, please type '\033[1;32m$config{MAKEPROG}\033[0m' now.\n";
 print "*** \033[1;32mRemember to edit your configuration files!!!\033[0m ***\n\n\n";
+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";
+}
 
 ################################################################################
 #                              HELPER FUNCTIONS                                #
@@ -374,10 +382,21 @@ sub dir_check {
 }
 
 sub getosflags {
-  if ($config{OSNAME} eq "FreeBSD") {
+  if ($config{OSNAME} =~ /BSD$/) {
     $config{LDLIBS} = "-Ldl";
     $config{FLAGS}  = "-fPIC -frtti $OPTIMISATI -Woverloaded-virtual $config{OPTIMISATI}";
     $config{MAKEPROG} = "gmake";
+    if ($config{OSNAME} eq "OpenBSD") {
+       chomp($foo = `eg++ -dumpversion | cut -c 1`);
+       # theyre running the package version of gcc (eg++)... detect it and set up its version numbers.
+       # if theyre not running this, configure lets the build continue but they probably wont manage to
+       # compile as this standard version is 2.95.3!
+       if ($foo ne "") {
+               $config{CC} = "eg++";
+               chomp($config{GCCVER}       = `eg++ -dumpversion | cut -c 1`); # we must redo these if we change
+               chomp($config{GCC34}        = `eg++ -dumpversion | cut -c 3`); # the compiler path
+       }
+    }
   } else {
     $config{LDLIBS} = "-ldl";
     $config{FLAGS}  = "-fPIC -frtti $OPTIMISATI -Woverloaded-virtual $config{OPTIMISATI}";
@@ -385,7 +404,11 @@ sub getosflags {
   }
   if ($config{OSNAME} =~ /SunOS/) {
     # solaris/sunos needs these
-    $config{LDLIBS} = $config{LDLIBS} . " -lsocket -lnsl";
+    # socket = bsd sockets api
+    # nsl = dns stuff
+    # rt = POSIX realtime extensions
+    # resolv = inet_aton only (why isnt this in nsl?!)
+    $config{LDLIBS} = $config{LDLIBS} . " -lsocket -lnsl -lrt -lresolv";
   }
 }
 
@@ -438,7 +461,7 @@ sub writefiles {
 EOF
 
   if ($config{OSNAME} =~ /SunOS/) {
-    print FILEHANDLE "#define IS_SOLARIS";
+    print FILEHANDLE "#define IS_SOLARIS\n";
   }
   if ($config{GCCVER} > 3) {
     print FILEHANDLE "#define GCC3\n";
@@ -497,6 +520,7 @@ EOF
       }
       close(FILEHANDLE);
 
+      $tmp =~ s/\@CC\@/$config{CC}/;
       $tmp =~ s/\@MAKEPROG\@/$config{MAKEPROG}/;
       $tmp =~ s/\@FLAGS\@/$config{FLAGS}/;
       $tmp =~ s/\@LDLIBS\@/$config{LDLIBS}/;