diff options
Diffstat (limited to 'make/template')
-rw-r--r-- | make/template/bsd.mk | 33 | ||||
-rw-r--r-- | make/template/config.h | 34 | ||||
-rw-r--r-- | make/template/gdbargs | 4 | ||||
-rw-r--r-- | make/template/inspircd | 71 | ||||
-rw-r--r-- | make/template/inspircd-genssl.1 | 46 | ||||
-rw-r--r-- | make/template/inspircd.1 | 104 | ||||
-rw-r--r-- | make/template/inspircd.service | 35 | ||||
-rw-r--r-- | make/template/main.mk | 250 | ||||
-rw-r--r-- | make/template/org.inspircd.plist | 5 |
9 files changed, 425 insertions, 157 deletions
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/config.h b/make/template/config.h new file mode 100644 index 000000000..c1e8bd0fc --- /dev/null +++ b/make/template/config.h @@ -0,0 +1,34 @@ +/* + * InspIRCd -- Internet Relay Chat Daemon + * + * Copyright (C) 2014 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/>. + */ + + +#pragma once + +#define INSPIRCD_BRANCH "InspIRCd-@VERSION_MAJOR@.@VERSION_MINOR@" +#define INSPIRCD_VERSION "InspIRCd-@VERSION_FULL@" + +#define INSPIRCD_CONFIG_PATH "@CONFIG_DIR@" +#define INSPIRCD_DATA_PATH "@DATA_DIR@" +#define INSPIRCD_LOG_PATH "@LOG_DIR@" +#define INSPIRCD_MODULE_PATH "@MODULE_DIR@" + +#ifndef _WIN32 + %target include/config.h + %define HAS_CLOCK_GETTIME + %define HAS_EVENTFD +#endif diff --git a/make/template/gdbargs b/make/template/gdbargs new file mode 100644 index 000000000..de76c7270 --- /dev/null +++ b/make/template/gdbargs @@ -0,0 +1,4 @@ +%target .gdbargs +handle SIGPIPE pass nostop noprint +handle SIGHUP pass nostop noprint +run diff --git a/make/template/inspircd b/make/template/inspircd index b43ad60c9..f34345cea 100644 --- a/make/template/inspircd +++ b/make/template/inspircd @@ -1,3 +1,4 @@ +%mode 0750 #!/usr/bin/env perl # @@ -29,17 +30,36 @@ use strict; use POSIX; use Fcntl; +# From http://refspecs.linuxbase.org/LSB_4.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html +use constant { + STATUS_EXIT_SUCCESS => 0, + STATUS_EXIT_DEAD_WITH_PIDFILE => 1, + STATUS_EXIT_DEAD_WITH_LOCKFILE => 2, + STATUS_EXIT_NOT_RUNNING => 3, + STATUS_EXIT_UNKNOWN => 4, + + GENERIC_EXIT_SUCCESS => 0, + GENERIC_EXIT_UNSPECIFIED => 1, + GENERIC_EXIT_INVALID_ARGUMENTS => 2, + GENERIC_EXIT_UNIMPLEMENTED => 3, + GENERIC_EXIT_INSUFFICIENT_PRIVILEGE => 4, + GENERIC_EXIT_NOT_INSTALLED => 5, + GENERIC_EXIT_NOT_CONFIGURED => 6, + GENERIC_EXIT_NOT_RUNNING => 7 +}; + +my $scriptpath = "@SCRIPT_DIR@"; my $basepath = "@BASE_DIR@"; my $confpath = "@CONFIG_DIR@/"; my $binpath = "@BINARY_DIR@"; my $runpath = "@BASE_DIR@"; my $datadir = "@DATA_DIR@"; my $valgrindlogpath = "$basepath/valgrindlogs"; -my $executable = "@EXECUTABLE@"; -my $version = "@VERSION@"; +my $executable = "inspircd"; +my $version = "@VERSION_FULL@"; my $uid = "@UID@"; -if ($< == 0 || $> == 0) { +if (!("--runasroot" ~~ @ARGV) && ($< == 0 || $> == 0)) { if ($uid !~ /^\d+$/) { # Named UID, look it up $uid = getpwnam $uid; @@ -87,12 +107,11 @@ if (!defined($sub)) { print STDERR "Invalid command or none given.\n"; cmd_help(); - exit 1; + exit GENERIC_EXIT_UNIMPLEMENTED; } else { - $sub->(@ARGV); - exit 0; + exit $sub->(@ARGV); # Error code passed through return value } sub cmd_help() @@ -105,7 +124,7 @@ sub cmd_help() $_ =~ s/_/-/g foreach (@cmds, @devs); print STDERR "Usage: ./inspircd (" . join("|", @cmds) . ")\n"; print STDERR "Developer arguments: (" . join("|", @devs) . ")\n"; - exit 0; + exit GENERIC_EXIT_SUCCESS; } sub cmd_status() @@ -113,10 +132,10 @@ sub cmd_status() if (getstatus() == 1) { my $pid = getprocessid(); print "InspIRCd is running (PID: $pid)\n"; - exit(); + exit STATUS_EXIT_SUCCESS; } else { print "InspIRCd is not running. (Or PID File not found)\n"; - exit(); + exit STATUS_EXIT_NOT_RUNNING; } } @@ -126,23 +145,23 @@ sub cmd_rehash() my $pid = getprocessid(); system("kill -HUP $pid >/dev/null 2>&1"); print "InspIRCd rehashed (pid: $pid).\n"; - exit(); + exit GENERIC_EXIT_SUCCESS; } else { print "InspIRCd is not running. (Or PID File not found)\n"; - exit(); + exit GENERIC_EXIT_NOT_RUNNING; } } sub cmd_cron() { if (getstatus() == 0) { goto &cmd_start(@_); } - exit(); + exit GENERIC_EXIT_UNSPECIFIED; } sub cmd_version() { print "InspIRCd version: $version\n"; - exit(); + exit GENERIC_EXIT_SUCCESS; } sub cmd_restart(@) @@ -156,13 +175,13 @@ sub hid_cheese_sandwich() { print "Creating Cheese Sandwich..\n"; print "Done.\n"; - exit(); + exit GENERIC_EXIT_SUCCESS; } sub cmd_start(@) { # Check to see its not 'running' already. - if (getstatus() == 1) { print "InspIRCd is already running.\n"; return 0; } + if (getstatus() == 1) { print "InspIRCd is already running.\n"; exit GENERIC_EXIT_SUCCESS; } # If we are still alive here.. Try starting the IRCd.. chdir $runpath; print "$binpath/$executable doesn't exist\n" and return 0 unless(-e "$binpath/$executable"); @@ -185,7 +204,7 @@ sub dev_debug(@) checkgdb(); # If we are still alive here.. Try starting the IRCd.. - exec 'gdb', "--command=$basepath/.gdbargs", '--args', "$binpath/$executable", qw(--nofork --debug), @_; + exec 'gdb', "--command=$scriptpath/.gdbargs", '--args', "$binpath/$executable", qw(--nofork --debug), @_; die "Failed to start GDB: $!\n"; } @@ -204,7 +223,7 @@ sub dev_screendebug(@) # If we are still alive here.. Try starting the IRCd.. print "Starting InspIRCd in `screen`, type `screen -r` when the ircd crashes to view the gdb output and get a backtrace.\n"; print "Once you're inside the screen session press ^C + d to re-detach from the session\n"; - exec qw(screen -m -d gdb), "--command=$basepath/.gdbargs", '-args', "$binpath/$executable", qw(--nofork --debug --nolog), @_; + exec qw(screen -m -d gdb), "--command=$scriptpath/.gdbargs", '-args', "$binpath/$executable", qw(--nofork --debug --nolog), @_; die "Failed to start screen: $!\n"; } @@ -224,7 +243,7 @@ sub dev_valdebug(@) # If we are still alive here.. Try starting the IRCd.. # May want to do something with these args at some point: --suppressions=.inspircd.sup --gen-suppressions=yes # Could be useful when we want to stop it complaining about things we're sure aren't issues. - exec qw(valgrind -v --tool=memcheck --leak-check=yes --db-attach=yes --num-callers=10), "$binpath/$executable", qw(--nofork --debug --nolog), @_; + exec qw(valgrind -v --tool=memcheck --leak-check=yes --db-attach=yes --num-callers=30), "$binpath/$executable", qw(--nofork --debug --nolog), @_; die "Failed to start valgrind: $!\n"; } @@ -258,7 +277,7 @@ sub dev_valdebug_unattended(@) sysopen STDERR, "$valgrindlogpath/valdebug.$suffix", O_WRONLY | O_CREAT | O_NOCTTY | O_APPEND, 0666 or die "Can't open $valgrindlogpath/valdebug.$suffix: $!\n"; # May want to do something with these args at some point: --suppressions=.inspircd.sup --gen-suppressions=yes # Could be useful when we want to stop it complaining about things we're sure aren't issues. - exec qw(valgrind -v --tool=memcheck --leak-check=full --show-reachable=yes --num-callers=15 --track-fds=yes), + exec qw(valgrind -v --tool=memcheck --leak-check=full --show-reachable=yes --num-callers=30 --track-fds=yes), "--suppressions=$binpath/valgrind.sup", qw(--gen-suppressions=all), qw(--leak-resolution=med --time-stamp=yes --log-fd=2 --), "$binpath/$executable", qw(--nofork --debug --nolog), @_; @@ -283,13 +302,13 @@ sub dev_screenvaldebug(@) # If we are still alive here.. Try starting the IRCd.. print "Starting InspIRCd in `screen`, type `screen -r` when the ircd crashes to view the valgrind and gdb output and get a backtrace.\n"; print "Once you're inside the screen session press ^C + d to re-detach from the session\n"; - exec qw(screen -m -d valgrind -v --tool=memcheck --leak-check=yes --db-attach=yes --num-callers=10), "$binpath/$executable", qw(--nofork --debug --nolog), @_; + exec qw(screen -m -d valgrind -v --tool=memcheck --leak-check=yes --db-attach=yes --num-callers=30), "$binpath/$executable", qw(--nofork --debug --nolog), @_; die "Failed to start screen: $!\n"; } sub cmd_stop() { - if (getstatus() == 0) { print "InspIRCd is not running. (Or PID File not found)\n"; return 0; } + if (getstatus() == 0) { print "InspIRCd is not running. (Or PID File not found)\n"; return GENERIC_EXIT_SUCCESS; } # Get to here, we have something to kill. my $pid = getprocessid(); print "Stopping InspIRCd (pid: $pid)...\n"; @@ -299,12 +318,12 @@ sub cmd_stop() sleep 1; if (getstatus() == 0) { print "InspIRCd Stopped.\n"; - return; + return GENERIC_EXIT_SUCCESS; } } print "InspIRCd not dying quietly -- forcing kill\n"; kill KILL => $pid; - return 0; + return GENERIC_EXIT_SUCCESS; } ### @@ -415,7 +434,7 @@ sub checkvalgrind unless(`valgrind --version`) { print "Couldn't start valgrind: $!\n"; - exit; + exit GENERIC_EXIT_UNSPECIFIED; } } @@ -424,7 +443,7 @@ sub checkgdb unless(`gdb --version`) { print "Couldn't start gdb: $!\n"; - exit; + exit GENERIC_EXIT_UNSPECIFIED; } } @@ -433,6 +452,6 @@ sub checkscreen unless(`screen --version`) { print "Couldn't start screen: $!\n"; - exit; + exit GENERIC_EXIT_UNSPECIFIED; } } diff --git a/make/template/inspircd-genssl.1 b/make/template/inspircd-genssl.1 new file mode 100644 index 000000000..d43a3b4e8 --- /dev/null +++ b/make/template/inspircd-genssl.1 @@ -0,0 +1,46 @@ +.\" +.\" InspIRCd -- Internet Relay Chat Daemon +.\" +.\" Copyright (C) 2014 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/>. +.\" + + +.TH "InspIRCd" "1" "June 2014" "InspIRCd @VERSION_FULL@" "InspIRCd Manual" + +.SH "NAME" +\t\fBInspIRCd\fR - \fIthe\fR stable, high-performance and modular Internet Relay Chat Daemon +.BR + +.SH "SYNOPSIS" +\t\fBinspircd-genssl\fR [ auto | gnutls | openssl ] + +.SH "OPTIONS" +.TP +.B "auto" +.br +Looks for both GnuTLS and OpenSSL and uses the first one which is available for certificate generation. +.TP +.B "gnutls" +.br +Generates certificates using GnuTLS. +.TP +.br +.B "openssl" +Generates certificates using OpenSSL. + +.SH "SUPPORT" +IRC support for InspIRCd can be found at irc://irc.inspircd.org/inspircd. + +Bug reports and feature requests can be filed at https://github.com/inspircd/inspircd/issues. diff --git a/make/template/inspircd.1 b/make/template/inspircd.1 new file mode 100644 index 000000000..eb1453d2f --- /dev/null +++ b/make/template/inspircd.1 @@ -0,0 +1,104 @@ +.\" +.\" InspIRCd -- Internet Relay Chat Daemon +.\" +.\" Copyright (C) 2014 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/>. +.\" + + +.TH "InspIRCd" "1" "June 2014" "InspIRCd @VERSION_FULL@" "InspIRCd Manual" + +.SH "NAME" +\t\fBInspIRCd\fR - \fIthe\fR stable, high-performance and modular Internet Relay Chat Daemon +.BR + +.SH "SYNOPSIS" +\t\fBinspircd\fR [--config <file>] [--debug] [--nofork] [--nolog] [--runasroot] [--version] + +.SH "OPTIONS" +.TP +.B "--config <file>" +.br +Sets the path to the main configuration file. Defaults to \fI@CONFIG_DIR@/inspircd.conf\fR. +.TP +.B "--debug" +.br +Log verbosely to the standard output stream. +.TP +.B "--nofork" +.br +Don't fork into the background after starting up. +.TP +.B "--nolog" +.br +Don't write to log files. +.TP +.B "--runasroot" +.br +Allow the server to start as root (not recommended). +.TP +.B "--version" +.br +Displays the InspIRCd version and exits. + +.SH "EXIT STATUS" +.TP +.B "0 (EXIT_STATUS_NOERROR)" +.br +The server exited cleanly. +.TP +.B "1 (EXIT_STATUS_DIE)" +.br +The server exited because the DIE command was executed. +.TP +.B "2 (EXIT_STATUS_CONFIG)" +.br +The server exited because of a configuration file error. +.TP +.B "3 (EXIT_STATUS_LOG)" +.br +The server exited because of a log file error. +.TP +.B "4 (EXIT_STATUS_FORK)" +.br +The server exited because it was unable to fork into the background. +.TP +.B "5 (EXIT_STATUS_ARGV)" +.br +The server exited because an invalid argument was passed to it on the command line. +.TP +.B "6 (EXIT_STATUS_PID)" +.br +The server exited because it was unable to write to the PID file. +.TP +.B "7 (EXIT_STATUS_SOCKETENGINE)" +.br +The server exited because it was unable to initialize the @SOCKETENGINE@ socket engine. +.TP +.B "8 (EXIT_STATUS_ROOT)" +.br +The server exited because the user tried to start as root without \fI--runasroot\fR. +.TP +.B "9 (EXIT_STATUS_MODULE)" +.br +The server exited because it was unable to load a module on first run. +.TP +.B "10 (EXIT_STATUS_SIGTERM)" +.br +The server exited because it received SIGTERM. + +.SH "SUPPORT" +IRC support for InspIRCd can be found at irc://irc.inspircd.org/inspircd. + +Bug reports and feature requests can be filed at https://github.com/inspircd/inspircd/issues. diff --git a/make/template/inspircd.service b/make/template/inspircd.service new file mode 100644 index 000000000..c05e61822 --- /dev/null +++ b/make/template/inspircd.service @@ -0,0 +1,35 @@ +%platform linux +# +# InspIRCd -- Internet Relay Chat Daemon +# +# Copyright (C) 2014 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/>. +# + + +[Unit] +After=network.target +Description=InspIRCd - Internet Relay Chat Daemon +Requires=network.target + +[Service] +ExecReload=@SCRIPT_DIR@/inspircd rehash +ExecStart=@SCRIPT_DIR@/inspircd start +ExecStop=@SCRIPT_DIR@/inspircd stop +PIDFile=@DATA_DIR@/inspircd.pid +Restart=on-failure +Type=forking + +[Install] +WantedBy=multi-user.target diff --git a/make/template/main.mk b/make/template/main.mk index 23daa7efc..077084280 100644 --- a/make/template/main.mk +++ b/make/template/main.mk @@ -1,3 +1,4 @@ +%target GNUmakefile # # InspIRCd -- Internet Relay Chat Daemon # @@ -24,142 +25,127 @@ # 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. # -CC = @CC@ -SYSTEM = @SYSTEM@ -BUILDPATH = @BUILD_DIR@ +CXX = @CXX@ +COMPILER = @COMPILER_NAME@ +SYSTEM = @SYSTEM_NAME@ +BUILDPATH ?= $(PWD)/build SOCKETENGINE = @SOCKETENGINE@ -CXXFLAGS = -pipe -fPIC -DPIC -LDLIBS = -pthread -lstdc++ -LDFLAGS = +CORECXXFLAGS = -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -pipe -Iinclude -Wall -Wextra -Wfatal-errors -Wno-unused-parameter -Wshadow +LDLIBS = -lstdc++ CORELDFLAGS = -rdynamic -L. $(LDFLAGS) PICLDFLAGS = -fPIC -shared -rdynamic $(LDFLAGS) BASE = "$(DESTDIR)@BASE_DIR@" CONPATH = "$(DESTDIR)@CONFIG_DIR@" +MANPATH = "$(DESTDIR)@MANUAL_DIR@" MODPATH = "$(DESTDIR)@MODULE_DIR@" LOGPATH = "$(DESTDIR)@LOG_DIR@" DATPATH = "$(DESTDIR)@DATA_DIR@" BINPATH = "$(DESTDIR)@BINARY_DIR@" +SCRPATH = "$(DESTDIR)@SCRIPT_DIR@" INSTALL = install INSTUID = @UID@ -INSTMODE_DIR = 0755 -INSTMODE_BIN = 0755 -INSTMODE_LIB = 0644 - -@IFEQ $(CC) icpc - CXXFLAGS += -Wshadow -@ELSE - CXXFLAGS += -pedantic -Woverloaded-virtual -Wshadow -Wformat=2 -Wmissing-format-attribute -Wall -@ENDIF - - -@IFEQ $(SYSTEM) linux +INSTMODE_DIR = 0750 +INSTMODE_BIN = 0750 +INSTMODE_LIB = 0640 + +ifneq ($(COMPILER), ICC) + CORECXXFLAGS += -Woverloaded-virtual -Wshadow +ifneq ($(SYSTEM), openbsd) + CORECXXFLAGS += -pedantic -Wformat=2 -Wmissing-format-attribute +endif +endif + +ifneq ($(SYSTEM), darwin) + LDLIBS += -pthread +endif + +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) sunos - LDLIBS += -lsocket -lnsl -lrt -lresolv - INSTALL = ginstall -@ENDIF -@IFEQ $(SYSTEM) darwin - CXXFLAGS += -DDARWIN -frtti +endif +ifeq ($(SYSTEM), darwin) LDLIBS += -ldl CORELDFLAGS = -dynamic -bind_at_load -L. $(LDFLAGS) PICLDFLAGS = -fPIC -shared -twolevel_namespace -undefined dynamic_lookup $(LDFLAGS) -@ENDIF -@IFEQ $(SYSTEM) interix - CXXFLAGS += -D_ALL_SOURCE -I/usr/local/include -@ENDIF +endif -@IFNDEF D - D=0 -@ENDIF - -GCC6=@GCC6@ -@IFEQ $(GCC6) true - CXXFLAGS += -fno-delete-null-pointer-checks -@ENDIF +ifndef INSPIRCD_DEBUG + INSPIRCD_DEBUG=0 +endif DBGOK=0 -@IFEQ $(D) 0 - CXXFLAGS += -O2 -@IFEQ $(CC) g++ - CXXFLAGS += -g1 -@ENDIF +ifeq ($(INSPIRCD_DEBUG), 0) + CORECXXFLAGS += -fno-rtti -O2 +ifeq ($(COMPILER), GCC) + CORECXXFLAGS += -g1 +endif HEADER = std-header DBGOK=1 -@ENDIF -@IFEQ $(D) 1 - CXXFLAGS += -O0 -g3 -Werror +endif +ifeq ($(INSPIRCD_DEBUG), 1) + CORECXXFLAGS += -O0 -g3 -Werror -DINSPIRCD_ENABLE_RTTI HEADER = debug-header DBGOK=1 -@ENDIF -@IFEQ $(D) 2 - CXXFLAGS += -O2 -g3 +endif +ifeq ($(INSPIRCD_DEBUG), 2) + CORECXXFLAGS += -fno-rtti -O2 -g3 HEADER = debug-header DBGOK=1 -@ENDIF +endif FOOTER = finishmessage -CXXFLAGS += -Iinclude +MAKEFLAGS += --no-print-directory -@GNU_ONLY MAKEFLAGS += --no-print-directory +SOURCEPATH = $(shell /bin/pwd) -@GNU_ONLY SOURCEPATH = $(shell /bin/pwd) -@BSD_ONLY SOURCEPATH != /bin/pwd +ifndef INSPIRCD_VERBOSE + MAKEFLAGS += --silent +endif -@IFDEF V - RUNCC = $(CC) - RUNLD = $(CC) - VERBOSE = -v -@ELSE - @GNU_ONLY MAKEFLAGS += --silent - @BSD_ONLY MAKE += -s - RUNCC = perl "$(SOURCEPATH)/make/run-cc.pl" $(CC) - RUNLD = perl "$(SOURCEPATH)/make/run-cc.pl" $(CC) - VERBOSE = -@ENDIF +ifdef INSPIRCD_STATIC + CORECXXFLAGS += -DINSPIRCD_STATIC +endif -@IFDEF PURE_STATIC - CXXFLAGS += -DPURE_STATIC -@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 RUNCC RUNLD CXXFLAGS LDLIBS PICLDFLAGS VERBOSE SOCKETENGINE CORELDFLAGS -@DO_EXPORT SOURCEPATH BUILDPATH PURE_STATIC SPLIT_CC +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 M +ifdef INSPIRCD_TARGET HEADER = mod-header FOOTER = mod-footer - @BSD_ONLY TARGET = modules/${M:S/.so$//}.so - @GNU_ONLY TARGET = modules/$(M:.so=).so -@ENDIF - -@IFDEF T - HEADER = - FOOTER = target - TARGET = $(T) -@ENDIF + TARGET = $(INSPIRCD_TARGET) +endif -@IFEQ $(DBGOK) 0 +ifeq ($(DBGOK), 0) HEADER = unknown-debug-level -@ENDIF +endif all: $(FOOTER) @@ -168,7 +154,7 @@ target: $(HEADER) cd "$(BUILDPATH)"; $(MAKEENV) $(MAKE) -f real.mk $(TARGET) debug: - @${MAKE} D=1 all + @${MAKE} INSPIRCD_DEBUG=1 all debug-header: @echo "*************************************" @@ -185,11 +171,11 @@ debug-header: @echo "*************************************" mod-header: -@IFDEF PURE_STATIC - @echo 'Cannot build single modules in pure-static build' +ifdef INSPIRCD_STATIC + @echo 'Cannot build specific targets in pure-static build' @exit 1 -@ENDIF - @echo 'Building single module:' +endif + @echo 'Building specific targets:' mod-footer: target @echo 'To install, copy $(BUILDPATH)/$(TARGET) to $(MODPATH)' @@ -229,18 +215,28 @@ install: target @-$(INSTALL) -d -o $(INSTUID) -m $(INSTMODE_DIR) $(DATPATH) @-$(INSTALL) -d -o $(INSTUID) -m $(INSTMODE_DIR) $(LOGPATH) @-$(INSTALL) -d -m $(INSTMODE_DIR) $(BINPATH) - @-$(INSTALL) -d -m $(INSTMODE_DIR) $(CONPATH)/examples/aliases - @-$(INSTALL) -d -m $(INSTMODE_DIR) $(CONPATH)/examples/modules + @-$(INSTALL) -d -m $(INSTMODE_DIR) $(CONPATH)/examples/services + @-$(INSTALL) -d -m $(INSTMODE_DIR) $(MANPATH) @-$(INSTALL) -d -m $(INSTMODE_DIR) $(MODPATH) + @-$(INSTALL) -d -m $(INSTMODE_DIR) $(SCRPATH) [ "$(BUILDPATH)/bin/" -ef $(BINPATH) ] || $(INSTALL) -m $(INSTMODE_BIN) "$(BUILDPATH)/bin/inspircd" $(BINPATH) -@IFNDEF PURE_STATIC +ifndef INSPIRCD_STATIC [ "$(BUILDPATH)/modules/" -ef $(MODPATH) ] || $(INSTALL) -m $(INSTMODE_LIB) "$(BUILDPATH)/modules/"*.so $(MODPATH) -@ENDIF - -$(INSTALL) -m $(INSTMODE_BIN) @STARTSCRIPT@ $(BASE) 2>/dev/null - -$(INSTALL) -m $(INSTMODE_LIB) tools/gdbargs $(BASE)/.gdbargs 2>/dev/null +endif + -$(INSTALL) -m $(INSTMODE_BIN) @CONFIGURE_DIRECTORY@/inspircd $(SCRPATH) 2>/dev/null + -$(INSTALL) -m $(INSTMODE_LIB) .gdbargs $(SCRPATH)/.gdbargs 2>/dev/null +ifeq ($(SYSTEM), darwin) + -$(INSTALL) -m $(INSTMODE_BIN) @CONFIGURE_DIRECTORY@/org.inspircd.plist $(SCRPATH) 2>/dev/null +endif +ifeq ($(SYSTEM), linux) + -$(INSTALL) -m $(INSTMODE_LIB) @CONFIGURE_DIRECTORY@/inspircd.service $(SCRPATH) 2>/dev/null +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 -$(INSTALL) -m $(INSTMODE_LIB) docs/conf/*.example $(CONPATH)/examples - -$(INSTALL) -m $(INSTMODE_LIB) docs/conf/aliases/*.example $(CONPATH)/examples/aliases - -$(INSTALL) -m $(INSTMODE_LIB) docs/conf/modules/*.example $(CONPATH)/examples/modules + -$(INSTALL) -m $(INSTMODE_LIB) docs/conf/services/*.example $(CONPATH)/examples/services + -$(INSTALL) -m $(INSTMODE_LIB) *.pem $(CONPATH) 2>/dev/null @echo "" @echo "*************************************" @echo "* INSTALL COMPLETE! *" @@ -251,15 +247,12 @@ install: target @echo ' Binaries:' $(BINPATH) @echo ' Modules:' $(MODPATH) @echo ' Data:' $(DATPATH) - @echo 'To start the ircd, run:' $(BASE)/inspircd start + @echo 'To start the ircd, run:' $(SCRPATH)/inspircd start @echo 'Remember to create your config file:' $(CONPATH)/inspircd.conf @echo 'Examples are available at:' $(CONPATH)/examples/ -@GNU_ONLY RCS_FILES = $(wildcard .git/index src/version.sh) -@BSD_ONLY RCS_FILES = src/version.sh -GNUmakefile BSDmakefile: make/template/main.mk configure $(RCS_FILES) - ./configure -update -@BSD_ONLY .MAKEFILEDEPS: BSDmakefile +GNUmakefile: make/template/main.mk src/version.sh configure @CONFIGURE_CACHE_FILE@ + ./configure --update clean: @echo Cleaning... @@ -272,21 +265,20 @@ clean: deinstall: -rm -f $(BINPATH)/inspircd -rm -rf $(CONPATH)/examples - -rm -f $(MODPATH)/cmd_*.so + -rm -f $(MANPATH)/inspircd.1 + -rm -f $(MANPATH)/inspircd-genssl.1 -rm -f $(MODPATH)/m_*.so - -rm -f $(BASE)/.gdbargs - -rm -f $(BASE)/org.inspircd.plist - -squeakyclean: distclean + -rm -f $(MODPATH)/core_*.so + -rm -f $(SCRPATH)/.gdbargs + -rm -f $(SCRPATH)/inspircd.service + -rm -f $(SCRPATH)/org.inspircd.plist configureclean: - rm -f .config.cache - rm -f BSDmakefile + rm -f .gdbargs + -rm -f Makefile rm -f GNUmakefile - rm -f include/inspircd_config.h - rm -f include/inspircd_version.h - rm -f inspircd - -rm -f org.inspircd.plist + rm -f include/config.h + rm -rf @CONFIGURE_DIRECTORY@ distclean: clean configureclean -rm -rf "$(SOURCEPATH)/run" @@ -298,11 +290,11 @@ help: @echo 'Use: ${MAKE} [flags] [targets]' @echo '' @echo 'Flags:' - @echo ' V=1 Show the full command being executed instead of "BUILD: dns.cpp"' - @echo ' D=1 Enable debug build, for module development or crash tracing' - @echo ' D=2 Enable debug build with optimizations, for detailed backtraces' - @echo ' DESTDIR= Specify a destination root directory (for tarball creation)' - @echo ' -j <N> Run a parallel build using N jobs' + @echo ' INSPIRCD_VERBOSE=1 Show the full command being executed instead of "BUILD: dns.cpp"' + @echo ' INSPIRCD_DEBUG=1 Enable debug build, for module development or crash tracing' + @echo ' INSPIRCD_DEBUG=2 Enable debug build with optimizations, for detailed backtraces' + @echo ' DESTDIR= Specify a destination root directory (for tarball creation)' + @echo ' -j <N> Run a parallel build using N jobs' @echo '' @echo 'Targets:' @echo ' all Complete build of InspIRCd, without installing (default)' @@ -310,10 +302,8 @@ help: @echo ' Currently installs to ${BASE}' @echo ' debug Compile a debug build. Equivalent to "make D=1 all"' @echo '' - @echo ' M=m_foo Builds a single module (cmd_foo also works here)' - @echo ' T=target Builds a user-specified target, such as "inspircd" or "modules"' - @echo ' Other targets are specified by their path in the build directory' - @echo ' Multiple targets may be separated by a space' + @echo ' INSPIRCD_TARGET=target Builds a user-specified target, such as "inspircd" or "core_dns"' + @echo ' Multiple targets may be separated by a space' @echo '' @echo ' clean Cleans object files produced by the compile' @echo ' distclean Cleans all generated files (build, configure, run, etc)' @@ -322,4 +312,4 @@ help: .NOTPARALLEL: -.PHONY: all target debug debug-header mod-header mod-footer std-header finishmessage install clean deinstall squeakyclean configureclean help +.PHONY: all target debug debug-header mod-header mod-footer std-header finishmessage install clean deinstall configureclean help diff --git a/make/template/org.inspircd.plist b/make/template/org.inspircd.plist index 4dac209f6..ae4e90916 100644 --- a/make/template/org.inspircd.plist +++ b/make/template/org.inspircd.plist @@ -1,3 +1,4 @@ +%platform darwin <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> @@ -26,6 +27,8 @@ <key>StandardErrorPath</key> <string>@LOG_DIR@/launchd-stderr.log</string> <key>UserName</key> - <string>ircdaemon</string> + <string>@USER@</string> + <key>GroupName</key> + <string>@GROUP@</string> </dict> </plist> |