summaryrefslogtreecommitdiff
path: root/make
diff options
context:
space:
mode:
Diffstat (limited to 'make')
-rwxr-xr-xmake/calcdep.pl2
-rw-r--r--make/configure.pm130
-rw-r--r--make/directive.pm6
-rw-r--r--make/template/bsd.mk33
-rw-r--r--make/template/main.mk123
-rw-r--r--make/test/clock_gettime.cpp1
-rw-r--r--make/test/compiler.cpp2
-rw-r--r--make/test/compiler_info.cpp41
8 files changed, 167 insertions, 171 deletions
diff --git a/make/calcdep.pl b/make/calcdep.pl
index 882e75f22..99355efa4 100755
--- a/make/calcdep.pl
+++ b/make/calcdep.pl
@@ -166,7 +166,7 @@ END
obj/ld-extra.cmd: $core_src
\@\$(SOURCEPATH)/make/unit-cc.pl gen-ld \$\@ \$^ \$>
-bin/inspircd: obj/ld-extra.cmd $core_mk
+bin/inspircd: $core_mk obj/ld-extra.cmd
\@\$(SOURCEPATH)/make/unit-cc.pl static-ld \$\@ \$^ \$>
inspircd: bin/inspircd
diff --git a/make/configure.pm b/make/configure.pm
index a10493318..dfdbf5f75 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 $_: $!";
- my (@lines, $mode, @platforms, %targets);
+ 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?
@@ -292,11 +288,7 @@ sub parse_templates($$$) {
} elsif ($1 eq 'platform') {
push @platforms, $2;
} elsif ($1 eq 'target') {
- if ($2 =~ /(\w+)\s(.+)/) {
- $targets{$1} = $2;
- } else {
- $targets{DEFAULT} = $2;
- }
+ push @targets, $2
} else {
print_warning "unknown template command '$1' in $_!";
push @lines, $line;
@@ -305,92 +297,18 @@ 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) {
# Add a default target if the template has not defined one.
- unless (scalar keys %targets) {
- $targets{DEFAULT} = catfile(CONFIGURE_DIRECTORY, basename $_);
+ unless (@targets) {
+ push @targets, catfile(CONFIGURE_DIRECTORY, basename $_);
}
- # Second pass: parse makefile junk and write files.
- while (my ($name, $target) = each %targets) {
-
- # TODO: when buildtool is done this mess can be removed completely.
- my @final_lines;
- foreach my $line (@lines) {
-
- # Are we parsing a makefile and does this line match a statement?
- if ($name =~ /(?:BSD|GNU)_MAKE/ && $line =~ /^\s*\@(\w+)(?:\s+(.+))?$/) {
- my @tokens = split /\s/, $2 if defined $2;
- if ($1 eq 'DO_EXPORT' && defined $2) {
- if ($name eq 'BSD_MAKE') {
- foreach my $variable (@tokens) {
- push @final_lines, "MAKEENV += $variable='\${$variable}'";
- }
- } elsif ($name eq 'GNU_MAKE') {
- push @final_lines, "export $2";
- }
- } elsif ($1 eq 'ELSE') {
- if ($name eq 'BSD_MAKE') {
- push @final_lines, ".else";
- } elsif ($name eq 'GNU_MAKE') {
- push @final_lines, "else";
- }
- } elsif ($1 eq 'ENDIF') {
- if ($name eq 'BSD_MAKE') {
- push @final_lines, ".endif";
- } elsif ($name eq 'GNU_MAKE') {
- push @final_lines, "endif";
- }
- } elsif ($1 eq 'ELSIFEQ' && defined $2) {
- if ($name eq 'BSD_MAKE') {
- push @final_lines, ".elif $tokens[0] == $tokens[1]";
- } elsif ($name eq 'GNU_MAKE') {
- push @final_lines, "else ifeq ($tokens[0], $tokens[1])";
- }
- } elsif ($1 eq 'IFDEF' && defined $2) {
- if ($name eq 'BSD_MAKE') {
- push @final_lines, ".if defined($2)";
- } elsif ($name eq 'GNU_MAKE') {
- push @final_lines, "ifdef $2";
- }
- } elsif ($1 eq 'IFEQ' && defined $2) {
- if ($name eq 'BSD_MAKE') {
- push @final_lines, ".if $tokens[0] == $tokens[1]";
- } elsif ($name eq 'GNU_MAKE') {
- push @final_lines, "ifeq ($tokens[0],$tokens[1])";
- }
- } elsif ($1 eq 'IFNEQ' && defined $2) {
- if ($name eq 'BSD_MAKE') {
- push @final_lines, ".if $tokens[0] != $tokens[1]";
- } elsif ($name eq 'GNU_MAKE') {
- push @final_lines, "ifneq ($tokens[0],$tokens[1])";
- }
- } elsif ($1 eq 'IFNDEF' && defined $2) {
- if ($name eq 'BSD_MAKE') {
- push @final_lines, ".if !defined($2)";
- } elsif ($name eq 'GNU_MAKE') {
- push @final_lines, "ifndef $2";
- }
- } elsif ($1 eq 'TARGET' && defined $2) {
- if ($tokens[0] eq $name) {
- push @final_lines, substr($2, length($tokens[0]) + 1);
- }
- } elsif ($1 !~ /[A-Z]/) {
- # HACK: silently ignore if lower case as these are probably make commands.
- push @final_lines, $line;
- } else {
- print_warning "unknown template command '$1' in $_!";
- push @final_lines, $line;
- }
- next;
- }
-
- push @final_lines, $line;
- }
+ # Write the templated files to disk.
+ for my $target (@targets) {
# Create the directory if it doesn't already exist.
my $directory = dirname $target;
@@ -401,11 +319,11 @@ sub parse_templates($$$) {
# Write the template file.
print_format "Writing <|GREEN $target|> ...\n";
- open(TARGET, '>', $target) or print_error "unable to write $target: $!";
- foreach (@final_lines) {
- say TARGET $_;
+ open(my $fh, '>', $target) or print_error "unable to write $target: $!";
+ foreach (@lines) {
+ 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/template/bsd.mk b/make/template/bsd.mk
new file mode 100644
index 000000000..05d413d0a
--- /dev/null
+++ b/make/template/bsd.mk
@@ -0,0 +1,33 @@
+%platform darwin
+%platform freebsd
+%platform netbsd
+%platform openbsd
+%target Makefile
+#
+# 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/>.
+#
+
+# This file will be installed as `Makefile` on BSD derivatives. When a user runs
+# BSD Make it will be picked up as the default makefile even on systems like
+# OpenBSD which have removed BSDMakefile support. If they run GNU Make then it
+# will ignore this file and run GNUmakefile instead.
+
+all clean configureclean debug deinstall distclean help install:
+ @echo "InspIRCd no longer supports BSD Make. You should install GNU Make instead."
+ @echo "If this is problematic for you then please contact us via our IRC channel"
+ @echo "at irc.inspircd.org #InspIRCd."
+ @exit 1
diff --git a/make/template/main.mk b/make/template/main.mk
index 50feb8f8d..49c77da05 100644
--- a/make/template/main.mk
+++ b/make/template/main.mk
@@ -1,5 +1,4 @@
-%target BSD_MAKE BSDmakefile
-%target GNU_MAKE GNUmakefile
+%target GNUmakefile
#
# InspIRCd -- Internet Relay Chat Daemon
#
@@ -26,9 +25,7 @@
# make/template/main.mk. Any changes made to the generated
# files will go away whenever it is regenerated!
#
-# Please do not edit unless you know what you're doing. This
-# needs to work in both GNU and BSD make; it is mangled for
-# them by configure.
+# Please do not edit unless you know what you're doing.
#
@@ -54,101 +51,106 @@ INSTMODE_DIR = 0750
INSTMODE_BIN = 0750
INSTMODE_LIB = 0640
-@IFNEQ $(COMPILER) ICC
+ifneq ($(COMPILER), ICC)
CORECXXFLAGS += -Woverloaded-virtual -Wshadow
-@IFNEQ $(SYSTEM) openbsd
+ifneq ($(SYSTEM), openbsd)
CORECXXFLAGS += -pedantic -Wformat=2 -Wmissing-format-attribute
-@ENDIF
-@ENDIF
+endif
+endif
-@IFNEQ $(SYSTEM) darwin
+ifneq ($(SYSTEM), darwin)
LDLIBS += -pthread
-@ENDIF
+endif
-@IFEQ $(SYSTEM) linux
+ifeq ($(SYSTEM), linux)
LDLIBS += -ldl -lrt
-@ENDIF
-@IFEQ $(SYSTEM) gnukfreebsd
+endif
+ifeq ($(SYSTEM), gnukfreebsd)
LDLIBS += -ldl -lrt
-@ENDIF
-@IFEQ $(SYSTEM) gnu
+endif
+ifeq ($(SYSTEM), gnu)
LDLIBS += -ldl -lrt
-@ENDIF
-@IFEQ $(SYSTEM) solaris
+endif
+ifeq ($(SYSTEM), solaris)
LDLIBS += -lsocket -lnsl -lrt -lresolv
INSTALL = ginstall
-@ENDIF
-@IFEQ $(SYSTEM) darwin
+endif
+ifeq ($(SYSTEM), darwin)
LDLIBS += -ldl
CORELDFLAGS = -dynamic -bind_at_load -L. $(LDFLAGS)
PICLDFLAGS = -fPIC -shared -twolevel_namespace -undefined dynamic_lookup $(LDFLAGS)
-@ENDIF
+endif
-@IFNDEF INSPIRCD_DEBUG
+ifndef INSPIRCD_DEBUG
INSPIRCD_DEBUG=0
-@ENDIF
+endif
DBGOK=0
-@IFEQ $(INSPIRCD_DEBUG) 0
+ifeq ($(INSPIRCD_DEBUG), 0)
CORECXXFLAGS += -fno-rtti -O2
-@IFEQ $(COMPILER) GCC
+ifeq ($(COMPILER), GCC)
CORECXXFLAGS += -g1
-@ENDIF
+endif
HEADER = std-header
DBGOK=1
-@ENDIF
-@IFEQ $(INSPIRCD_DEBUG) 1
+endif
+ifeq ($(INSPIRCD_DEBUG), 1)
CORECXXFLAGS += -O0 -g3 -Werror -DINSPIRCD_ENABLE_RTTI
HEADER = debug-header
DBGOK=1
-@ENDIF
-@IFEQ $(INSPIRCD_DEBUG) 2
+endif
+ifeq ($(INSPIRCD_DEBUG), 2)
CORECXXFLAGS += -fno-rtti -O2 -g3
HEADER = debug-header
DBGOK=1
-@ENDIF
+endif
FOOTER = finishmessage
-@TARGET GNU_MAKE MAKEFLAGS += --no-print-directory
+MAKEFLAGS += --no-print-directory
-@TARGET GNU_MAKE SOURCEPATH = $(shell /bin/pwd)
-@TARGET BSD_MAKE SOURCEPATH != /bin/pwd
+SOURCEPATH = $(shell /bin/pwd)
-@IFNDEF INSPIRCD_VERBOSE
- @TARGET GNU_MAKE MAKEFLAGS += --silent
- @TARGET BSD_MAKE MAKE += -s
-@ENDIF
+ifndef INSPIRCD_VERBOSE
+ MAKEFLAGS += --silent
+endif
-@IFDEF INSPIRCD_STATIC
+ifdef INSPIRCD_STATIC
CORECXXFLAGS += -DINSPIRCD_STATIC
-@ENDIF
+endif
# Add the users CPPFLAGS/CXXFLAGS to the base ones to allow them to
# override things like -Wfatal-errors if they wish to.
CORECXXFLAGS += $(CPPFLAGS) $(CXXFLAGS)
-@DO_EXPORT CXX CORECXXFLAGS LDLIBS PICLDFLAGS INSPIRCD_VERBOSE SOCKETENGINE CORELDFLAGS
-@DO_EXPORT SOURCEPATH BUILDPATH INSPIRCD_STATIC
+export BUILDPATH
+export CORECXXFLAGS
+export CORELDFLAGS
+export CXX
+export INSPIRCD_STATIC
+export INSPIRCD_VERBOSE
+export LDLIBS
+export PICLDFLAGS
+export SOCKETENGINE
+export SOURCEPATH
# Default target
TARGET = all
-@IFDEF INSPIRCD_MODULE
+ifdef INSPIRCD_MODULE
HEADER = mod-header
FOOTER = mod-footer
- @TARGET BSD_MAKE TARGET = modules/${INSPIRCD_MODULE:S/.so$//}.so
- @TARGET GNU_MAKE TARGET = modules/$(INSPIRCD_MODULE:.so=).so
-@ENDIF
+ TARGET = modules/$(INSPIRCD_MODULE:.so=).so
+endif
-@IFDEF INSPIRCD_TARGET
+ifdef INSPIRCD_TARGET
HEADER =
FOOTER = target
TARGET = $(INSPIRCD_TARGET)
-@ENDIF
+endif
-@IFEQ $(DBGOK) 0
+ifeq ($(DBGOK), 0)
HEADER = unknown-debug-level
-@ENDIF
+endif
all: $(FOOTER)
@@ -174,10 +176,10 @@ debug-header:
@echo "*************************************"
mod-header:
-@IFDEF INSPIRCD_STATIC
+ifdef INSPIRCD_STATIC
@echo 'Cannot build single modules in pure-static build'
@exit 1
-@ENDIF
+endif
@echo 'Building single module:'
mod-footer: target
@@ -223,17 +225,17 @@ install: target
@-$(INSTALL) -d -m $(INSTMODE_DIR) $(MANPATH)
@-$(INSTALL) -d -m $(INSTMODE_DIR) $(MODPATH)
[ "$(BUILDPATH)/bin/" -ef $(BINPATH) ] || $(INSTALL) -m $(INSTMODE_BIN) "$(BUILDPATH)/bin/inspircd" $(BINPATH)
-@IFNDEF INSPIRCD_STATIC
+ifndef INSPIRCD_STATIC
[ "$(BUILDPATH)/modules/" -ef $(MODPATH) ] || $(INSTALL) -m $(INSTMODE_LIB) "$(BUILDPATH)/modules/"*.so $(MODPATH)
-@ENDIF
+endif
-$(INSTALL) -m $(INSTMODE_BIN) @CONFIGURE_DIRECTORY@/inspircd $(BASE) 2>/dev/null
-$(INSTALL) -m $(INSTMODE_LIB) .gdbargs $(BASE)/.gdbargs 2>/dev/null
-@IFEQ $(SYSTEM) darwin
+ifeq ($(SYSTEM), darwin)
-$(INSTALL) -m $(INSTMODE_BIN) @CONFIGURE_DIRECTORY@/org.inspircd.plist $(BASE) 2>/dev/null
-@ENDIF
-@IFEQ $(SYSTEM) linux
+endif
+ifeq ($(SYSTEM), linux)
-$(INSTALL) -m $(INSTMODE_LIB) @CONFIGURE_DIRECTORY@/inspircd.service $(BASE) 2>/dev/null
-@ENDIF
+endif
-$(INSTALL) -m $(INSTMODE_LIB) @CONFIGURE_DIRECTORY@/inspircd.1 $(MANPATH) 2>/dev/null
-$(INSTALL) -m $(INSTMODE_LIB) @CONFIGURE_DIRECTORY@/inspircd-genssl.1 $(MANPATH) 2>/dev/null
-$(INSTALL) -m $(INSTMODE_BIN) tools/genssl $(BINPATH)/inspircd-genssl 2>/dev/null
@@ -255,9 +257,8 @@ install: target
@echo 'Remember to create your config file:' $(CONPATH)/inspircd.conf
@echo 'Examples are available at:' $(CONPATH)/examples/
-GNUmakefile BSDmakefile: make/template/main.mk src/version.sh configure @CONFIGURE_CACHE_FILE@
+GNUmakefile: make/template/main.mk src/version.sh configure @CONFIGURE_CACHE_FILE@
./configure --update
-@TARGET BSD_MAKE .MAKEFILEDEPS: BSDmakefile
clean:
@echo Cleaning...
@@ -280,7 +281,7 @@ deinstall:
configureclean:
rm -f .gdbargs
- rm -f BSDmakefile
+ -rm -f Makefile
rm -f GNUmakefile
rm -f include/config.h
rm -rf @CONFIGURE_DIRECTORY@
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;
+}