]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - configure
Merge pull request #1330 from SaberUK/insp20+mm-inc
[user/henk/code/inspircd.git] / configure
index 68d03a29c646913bfc9bf2dd0f1105bd603dc1ca..b380b5700046cad908714e057d3370ae2cc080e4 100755 (executable)
--- a/configure
+++ b/configure
@@ -28,6 +28,7 @@
 
 BEGIN {
        require 5.8.0;
+       push @INC, '.';
 }
 
 use strict;
@@ -257,7 +258,8 @@ if ($config{OSNAME} =~ /darwin/i)
 elsif ($config{OSNAME} =~ /freebsd/i)
 {
        chomp(my $fbsd_version = `uname -r`);
-       $config{CC} = $fbsd_version ge '10.0' ? 'clang++' : 'g++';
+       $fbsd_version =~ s/^(\d+\.\d+).*/$1/g;
+       $config{CC} = $fbsd_version >= 10.0 ? 'clang++' : 'g++';
 }
 else
 {
@@ -267,10 +269,9 @@ if (defined $opt_cc)
 {
        $config{CC} = $opt_cc;
 }
-our $exec = $config{CC} . " -dumpversion | cut -c 1";
-chomp($config{GCCVER}          = `$exec`);                             # Major GCC Version
-$exec = $config{CC} . " -dumpversion | cut -c 3";
-chomp($config{GCCMINOR}                = `$exec`);
+`$config{CC} -dumpversion` =~ /^(\d+)(?:\.(\d+))?/;
+$config{GCCVER} = defined $1 ? $1 : '';
+$config{GCCMINOR} = defined $2 ? $2 : '0';
 $config{MAXBUF}                        = "512";                                # Max buffer size
 
 if ($config{HAS_OPENSSL} =~ /^([-[:digit:].]+)(?:[a-z])?(?:\-[a-z][0-9])?/) {
@@ -346,57 +347,21 @@ print ($cache_loaded ? "found\n" : "not found\n");
 $config{SYSTEM} = lc $^O;
 print "Checking operating system version... $config{SYSTEM}\n";
 
-$exec = $config{CC} . " -dumpversion | cut -c 1";
-chomp($config{GCCVER}          = `$exec`);                             # Major GCC Version
-$exec = $config{CC} . " -dumpversion | cut -c 3";
-chomp($config{GCCMINOR}                = `$exec`);
+`$config{CC} -dumpversion` =~ /^(\d+)(?:\.(\d+))?/;
+$config{GCCVER} = defined $1 ? $1 : '';
+$config{GCCMINOR} = defined $2 ? $2 : '0';
 
 printf "Checking if stdint.h exists... ";
-$config{HAS_STDINT} = "true";
-our $fail = 0;
-open(STDINT, "</usr/include/stdint.h") or $config{HAS_STDINT} = "false";
-if ($config{HAS_STDINT} eq "true") {
-       close(STDINT);
-}
-print "yes\n" if $config{HAS_STDINT} eq "true";
-print "no\n" if $config{HAS_STDINT} eq "false";
+$config{HAS_STDINT} = test_compile('stdint');
+print $config{HAS_STDINT} ? "yes\n" : "no\n";
 
 printf "Checking if strlcpy exists... ";
-# Perform the strlcpy() test..
-$config{HAS_STRLCPY} = "false";
-$fail = 0;
-open(STRLCPY, "</usr/include/string.h") or $fail = 1;
-if (!$fail) {
-       while (defined(my $line = <STRLCPY>)) {
-               chomp($line);
-               # try and find the delcaration of:
-               # size_t strlcpy(...)
-               if ($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";
+$config{HAS_STRLCPY} = test_compile('strlcpy');
+print $config{HAS_STRLCPY} ? "yes\n" : "no\n";
 
 printf "Checking if kqueue exists... ";
-$has_kqueue = 0;
-$fail = 0;
-open(KQUEUE, "</usr/include/sys/event.h") or $fail = 1;
-if (!$fail) {
-       while (defined(my $line = <KQUEUE>)) {
-               chomp($line);
-               # try and find the delcaration of:
-               # int kqueue(void);
-               if ($line =~ /int(\0x9|\s)+kqueue/) {
-                       $has_kqueue = 1;
-               }
-       }
-       close(KQUEUE);
-}
-print "yes\n" if $has_kqueue == 1;
-print "no\n" if $has_kqueue == 0;
+$has_kqueue = test_compile('kqueue');
+print $has_kqueue ? "yes\n" : "no\n";
 
 printf "Checking for epoll support... ";
 $has_epoll = test_compile('epoll');
@@ -522,8 +487,9 @@ should NOT be used. You should probably specify a newer compiler.\n\n";
                        }
                        chomp(my $foo = `$config{CC} -dumpversion | cut -c 1`);
                        if ($foo ne "") {
-                               chomp($config{GCCVER}       = `$config{CC} -dumpversion | cut -c 1`); # we must redo these if we change compilers
-                               chomp($config{GCCMINOR}     = `$config{CC} -dumpversion | cut -c 3`);
+                               `$config{CC} -dumpversion` =~ /^(\d+)(?:\.(\d+))?/;
+                               $config{GCCVER} = defined $1 ? $1 : '';
+                               $config{GCCMINOR} = defined $2 ? $2 : '0';
                                print "Queried compiler: \e[1;32m$config{CC}\e[0m (version \e[1;32m$config{GCCVER}.$config{GCCMINOR}\e[0m)\n";
                                if ($config{GCCVER} < 3) {
                                        print "\e[1;32mGCC 2.x WILL NOT WORK!\e[0m. Let's try that again, shall we?\n";
@@ -873,8 +839,8 @@ sub writefiles {
                open(FILEHANDLE, ">include/inspircd_config.h.tmp");
                print FILEHANDLE <<EOF;
 /* Auto generated by configure, do not modify! */
-#ifndef __CONFIGURATION_AUTO__
-#define __CONFIGURATION_AUTO__
+#ifndef INSPIRCD_CONFIG_H
+#define INSPIRCD_CONFIG_H
 
 /* this is for windows support. */
 #define CoreExport /**/
@@ -910,6 +876,10 @@ print FILEHANDLE "#define MAXBUF " . ($config{MAXBUF}+2) . "\n";
                }
                if ($config{OSNAME} !~ /DARWIN/i) {
                        print FILEHANDLE "#define HAS_CLOCK_GETTIME\n";
+               } else {
+                       print FILEHANDLE "#ifdef MAC_OS_X_VERSION_10_12\n";
+                       print FILEHANDLE "# define HAS_CLOCK_GETTIME\n";
+                       print FILEHANDLE "#endif\n";
                }
                my $use_hiperf = 0;
                if (($has_kqueue) && ($config{USE_KQUEUE} eq "y")) {
@@ -999,6 +969,9 @@ EOF
        my @dotfiles = qw(main.mk inspircd);
        push @dotfiles, 'org.inspircd.plist' if $config{OSNAME} eq 'darwin';
 
+       # HACK: we need to know if we are on GCC6 to disable the omission of `this` null pointer checks.
+       $config{GCC6} = `$config{CC} --version 2>/dev/null` =~ /gcc/i && $config{GCCVER} ge "6" ? "true" : "false";
+
        foreach my $file (@dotfiles) {
                open(FILEHANDLE, "make/template/$file") or die "Can't open make/template/$file: $!";
                $_ = join '', <FILEHANDLE>;
@@ -1008,7 +981,7 @@ EOF
 
                for my $var (qw(
                        CC SYSTEM BASE_DIR CONFIG_DIR MODULE_DIR BINARY_DIR BUILD_DIR DATA_DIR UID
-                       STARTSCRIPT DESTINATION SOCKETENGINE LOG_DIR
+                       STARTSCRIPT DESTINATION SOCKETENGINE LOG_DIR GCC6
                )) {
                        s/\@$var\@/$config{$var}/g;
                }