summaryrefslogtreecommitdiff
path: root/make
diff options
context:
space:
mode:
Diffstat (limited to 'make')
-rw-r--r--make/configure.pm38
-rw-r--r--make/directive.pm6
-rw-r--r--make/test/clock_gettime.cpp1
-rw-r--r--make/test/compiler.cpp2
-rw-r--r--make/test/compiler_info.cpp41
5 files changed, 64 insertions, 24 deletions
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 (<make/template/*>) {
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 = <TEMPLATE>) {
+ while (my $line = <$fh>) {
chomp $line;
# Does this line match a variable?
@@ -305,7 +301,7 @@ sub parse_templates($$$) {
}
push @lines, $line;
}
- close(TEMPLATE);
+ close $fh;
# Only proceed if this file should be templated on this platform.
if ($#platforms < 0 || grep { $_ eq $^O } @platforms) {
@@ -401,11 +397,11 @@ sub parse_templates($$$) {
# Write the template file.
print_format "Writing <|GREEN $target|> ...\n";
- open(TARGET, '>', $target) or print_error "unable to write $target: $!";
+ open(my $fh, '>', $target) or print_error "unable to write $target: $!";
foreach (@final_lines) {
- say TARGET $_;
+ say $fh $_;
}
- close(TARGET);
+ close $fh;
# Set file permissions.
if (defined $mode) {
diff --git a/make/directive.pm b/make/directive.pm
index 4501fc5ec..2e9e7ed61 100644
--- a/make/directive.pm
+++ b/make/directive.pm
@@ -41,16 +41,16 @@ our @EXPORT = qw(get_directive
sub get_directive($$;$)
{
my ($file, $property, $default) = @_;
- open(MODULE, $file) or return $default;
+ open(my $fh, $file) or return $default;
my $value = '';
- while (<MODULE>) {
+ while (<$fh>) {
if ($_ =~ /^\/\* \$(\S+): (.+) \*\/$/ || $_ =~ /^\/\/\/ \$(\S+): (.+)/) {
next unless $1 eq $property;
$value .= ' ' . execute_functions($file, $1, $2);
}
}
- close(MODULE);
+ close $fh;
# Strip all extraneous whitespace.
$value =~ s/^\s+|\s+$//g;
diff --git a/make/test/clock_gettime.cpp b/make/test/clock_gettime.cpp
index 91d8cd412..d111d591f 100644
--- a/make/test/clock_gettime.cpp
+++ b/make/test/clock_gettime.cpp
@@ -1,6 +1,7 @@
/*
* InspIRCd -- Internet Relay Chat Daemon
*
+ * Copyright (C) 2013 Peter Powell <petpow@saberuk.com>
*
* This file is part of InspIRCd. InspIRCd is free software: you can
* redistribute it and/or modify it under the terms of the GNU General Public
diff --git a/make/test/compiler.cpp b/make/test/compiler.cpp
index e2cbd9f64..f01423325 100644
--- a/make/test/compiler.cpp
+++ b/make/test/compiler.cpp
@@ -1,6 +1,8 @@
/*
* InspIRCd -- Internet Relay Chat Daemon
*
+ * Copyright (C) 2016 Attila Molnar <attilamolnar@hush.com>
+ * Copyright (C) 2014-2015 Peter Powell <petpow@saberuk.com>
*
* This file is part of InspIRCd. InspIRCd is free software: you can
* redistribute it and/or modify it under the terms of the GNU General Public
diff --git a/make/test/compiler_info.cpp b/make/test/compiler_info.cpp
new file mode 100644
index 000000000..10b156fc8
--- /dev/null
+++ b/make/test/compiler_info.cpp
@@ -0,0 +1,41 @@
+/*
+ * InspIRCd -- Internet Relay Chat Daemon
+ *
+ * Copyright (C) 2017 Peter Powell <petpow@saberuk.com>
+ *
+ * This file is part of InspIRCd. InspIRCd is free software: you can
+ * redistribute it and/or modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation, version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+#include <iostream>
+
+#if defined __INTEL_COMPILER // Also defines __clang__ and __GNUC__
+# define INSPIRCD_COMPILER_NAME "Intel"
+# define INSPIRCD_COMPILER_VERSION (__INTEL_COMPILER / 100) << '.' << (__INTEL_COMPILER % 100)
+#elif defined __clang__ // Also defines __GNUC__
+# if defined __apple_build_version__
+# define INSPIRCD_COMPILER_NAME "AppleClang"
+# else
+# define INSPIRCD_COMPILER_NAME "Clang"
+# endif
+# define INSPIRCD_COMPILER_VERSION __clang_major__ << '.' << __clang_minor__
+#elif defined __GNUC__
+# define INSPIRCD_COMPILER_NAME "GCC"
+# define INSPIRCD_COMPILER_VERSION __GNUC__ << '.' << __GNUC_MINOR__
+#endif
+
+int main() {
+ std::cout << "NAME " << INSPIRCD_COMPILER_NAME << std::endl
+ << "VERSION " << INSPIRCD_COMPILER_VERSION << std::endl;
+ return 0;
+}