]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Fix compiler version parsing on GCC 7.
authorPeter Powell <petpow@saberuk.com>
Tue, 21 Mar 2017 22:52:12 +0000 (22:52 +0000)
committerPeter Powell <petpow@saberuk.com>
Fri, 14 Apr 2017 13:24:43 +0000 (14:24 +0100)
GCC 7 may optionally omit the MINOR version number in dumpversion
depending on the compiler flags it was built with.

configure

index 0cf165a0a4db485aac0f1625e7a91a8b586fd6d9..b380b5700046cad908714e057d3370ae2cc080e4 100755 (executable)
--- a/configure
+++ b/configure
@@ -269,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])?/) {
@@ -348,10 +347,9 @@ 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} = test_compile('stdint');
@@ -489,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";