X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=make%2Fconfigure.pm;h=dbbbf650978ec6af386201428b34594c221adafd;hb=1f3b7f2455b0d73d8874daff0459f4bde46b9524;hp=a104933188f4afcf27a7c0807b0923a7df154457;hpb=127683c29e6eb33c21f85cf1ccba6fb85fc0cdec;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/make/configure.pm b/make/configure.pm index a10493318..dbbbf6509 100644 --- a/make/configure.pm +++ b/make/configure.pm @@ -208,9 +208,9 @@ sub test_file($$;$) { sub test_header($$;$) { my ($compiler, $header, $args) = @_; $args //= ''; - open(COMPILER, "| $compiler -E - $args ${\CONFIGURE_ERROR_PIPE}") or return 0; - print COMPILER "#include <$header>"; - close(COMPILER); + open(my $fh, "| $compiler -E - $args ${\CONFIGURE_ERROR_PIPE}") or return 0; + print $fh "#include <$header>"; + close $fh; return !$?; } @@ -227,19 +227,15 @@ sub write_configure_cache(%) { sub get_compiler_info($) { my $binary = shift; - my $version = `$binary -v 2>&1`; - if ($version =~ /Apple\sLLVM\sversion\s(\d+\.\d+)/i) { - # Apple version their LLVM releases slightly differently to the mainline LLVM. - # See https://trac.macports.org/wiki/XcodeVersionInfo for more information. - return (NAME => 'AppleClang', VERSION => $1); - } elsif ($version =~ /clang\sversion\s(\d+\.\d+)/i) { - return (NAME => 'Clang', VERSION => $1); - } elsif ($version =~ /gcc\sversion\s(\d+\.\d+)/i) { - return (NAME => 'GCC', VERSION => $1); - } elsif ($version =~ /(?:icc|icpc)\sversion\s(\d+\.\d+).\d+\s\(gcc\sversion\s(\d+\.\d+).\d+/i) { - return (NAME => 'ICC', VERSION => $1); + my %info = (NAME => 'Unknown', VERSION => '0.0'); + return %info if system "$binary -o __compiler_info make/test/compiler_info.cpp ${\CONFIGURE_ERROR_PIPE}"; + open(my $fh, '-|', './__compiler_info 2>/dev/null'); + while (my $line = <$fh>) { + $info{$1} = $2 if $line =~ /^([A-Z]+)\s(.+)$/; } - return (NAME => $binary, VERSION => '0.0'); + close $fh; + unlink './__compiler_info'; + return %info; } sub find_compiler { @@ -261,11 +257,11 @@ sub parse_templates($$$) { # Iterate through files in make/template. foreach () { print_format "Parsing <|GREEN $_|> ...\n"; - open(TEMPLATE, $_) or print_error "unable to read $_: $!"; + open(my $fh, $_) or print_error "unable to read $_: $!"; my (@lines, $mode, @platforms, %targets); # First pass: parse template variables and directives. - while (my $line =