]> 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 26d39d6bc9e695be897dc0dd9c6033be30a8d3dd..1c17677ed269ccb56fc9c43016c117395da61bde 100755 (executable)
--- a/configure
+++ b/configure
 #
 ########################################
 
-
-$this = resolve_directory($ENV{PWD});                                          # PWD, Regardless.
+chomp($topdir = `pwd`);
+$this = resolve_directory($topdir);                                            # PWD, Regardless.
 @modlist = ();                                                                 # Declare for Module List..
 %config = ();                                                                  # Initiate Configuration Hash..
-$config{ME}                 = resolve_directory($ENV{PWD});                    # Present Working Directory
-$config{CONFIG_DIR}         = resolve_directory($ENV{PWD}."/conf");            # Configuration Directory
-$config{MODULE_DIR}         = resolve_directory($ENV{PWD}."/modules");         # Modules Directory
-$config{BINARY_DIR}         = resolve_directory($ENV{PWD}."/bin");             # Binary Directory
-$config{LIBRARY_DIR}        = resolve_directory($ENV{PWD}."/lib");             # Library Directory
+$config{ME}                 = resolve_directory($topdir);                      # Present Working Directory
+$config{CONFIG_DIR}         = resolve_directory($config{ME}."/conf");          # Configuration Directory
+$config{MODULE_DIR}         = resolve_directory($config{ME}."/modules");       # Modules Directory
+$config{BINARY_DIR}         = resolve_directory($config{ME}."/bin");           # Binary Directory
+$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
@@ -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}) { 
@@ -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,15 +382,34 @@ 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} =~ /SunOS/) {
+    # solaris/sunos needs these
+    # 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";
+  }
 }
 
 sub is_dir {
@@ -415,7 +442,7 @@ sub writefiles {
   # First File.. inspircd_config.h
   chomp(my $incos = `uname -n -s -r`);
   chomp(my $version = `sh ./src/version.sh`);
-  open(FILEHANDLE, "> include/inspircd_config.h");
+  open(FILEHANDLE, ">include/inspircd_config.h");
   print FILEHANDLE <<EOF;
 /* Auto generated by configure, do not modify! */
 #define SYSLOG_FACILITY LOG_DAEMON
@@ -433,6 +460,9 @@ sub writefiles {
 #define MAXBUF 514
 EOF
 
+  if ($config{OSNAME} =~ /SunOS/) {
+    print FILEHANDLE "#define IS_SOLARIS\n";
+  }
   if ($config{GCCVER} > 3) {
     print FILEHANDLE "#define GCC3\n";
     print FILEHANDLE "#define GCC34\n";
@@ -490,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}/;