]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - configure
Warning message for openbsd users that try and use gcc
[user/henk/code/inspircd.git] / configure
index 5152dc94d90b38e0ee3b699162504ef5c1970d96..ac0be8fe094a77784af069d63b840d1296e509c3 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}       = `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}) { 
@@ -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,18 +382,33 @@ 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}";
     $config{MAKEPROG} = "make";
   }
-  if ($config{OSNAME} eq "SunOS") {
+  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";
   }
 }
 
@@ -437,8 +460,8 @@ sub writefiles {
 #define MAXBUF 514
 EOF
 
-  if ($config{OSNAME} eq "SunOS") {
-    print FILENAME "#define IS_SOLARIS";
+  if ($config{OSNAME} =~ /SunOS/) {
+    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}/;