summaryrefslogtreecommitdiff
path: root/make/template/main.mk
diff options
context:
space:
mode:
Diffstat (limited to 'make/template/main.mk')
-rw-r--r--make/template/main.mk250
1 files changed, 120 insertions, 130 deletions
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