summaryrefslogtreecommitdiff
path: root/configure
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2017-03-21 22:52:12 +0000
committerPeter Powell <petpow@saberuk.com>2017-04-14 14:24:43 +0100
commitf15e2ca435b0a85d32041fbbdba9f09c099c3a41 (patch)
tree2ee8365037248dd9893773fe7760c33559d086ae /configure
parent41ef94bebb0fcb358150ff0179c6c55104827683 (diff)
Fix compiler version parsing on GCC 7.
GCC 7 may optionally omit the MINOR version number in dumpversion depending on the compiler flags it was built with.
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure19
1 files changed, 9 insertions, 10 deletions
diff --git a/configure b/configure
index 0cf165a0a..b380b5700 100755
--- 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";