X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=make%2Ftemplate%2Fmain.mk;h=07708428024d508552c86b7dc405ce4f94386e7d;hb=96cc8bf4813877724d011531da1923aa457d8542;hp=521888beadedae4bbaad4dbeadceaeefcb52a016;hpb=8f13eddcd3f23a2c47e88e176f2e5032f8227450;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/make/template/main.mk b/make/template/main.mk index 521888bea..077084280 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. # @@ -37,7 +34,7 @@ COMPILER = @COMPILER_NAME@ SYSTEM = @SYSTEM_NAME@ BUILDPATH ?= $(PWD)/build SOCKETENGINE = @SOCKETENGINE@ -CORECXXFLAGS = -fPIC -fvisibility-inlines-hidden -pipe -Iinclude -Wall -Wextra -Wfatal-errors -Wno-unused-parameter -Wshadow +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) @@ -45,128 +42,119 @@ 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 = 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)-$(COMPILER) darwin-GCC - CORECXXFLAGS += -fvisibility=hidden -@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 D - D=0 -@ENDIF +ifndef INSPIRCD_DEBUG + INSPIRCD_DEBUG=0 +endif DBGOK=0 -@IFEQ $(D) 0 - CORECXXFLAGS += -O2 -@IFEQ $(COMPILER) GCC +ifeq ($(INSPIRCD_DEBUG), 0) + CORECXXFLAGS += -fno-rtti -O2 +ifeq ($(COMPILER), GCC) CORECXXFLAGS += -g1 -@ENDIF +endif HEADER = std-header DBGOK=1 -@ENDIF -@IFEQ $(D) 1 - CORECXXFLAGS += -O0 -g3 -Werror +endif +ifeq ($(INSPIRCD_DEBUG), 1) + CORECXXFLAGS += -O0 -g3 -Werror -DINSPIRCD_ENABLE_RTTI HEADER = debug-header DBGOK=1 -@ENDIF -@IFEQ $(D) 2 - CORECXXFLAGS += -O2 -g3 +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) -@IFDEF V - RUNCC = $(CXX) - RUNLD = $(CXX) - VERBOSE = -v -@ELSE - @TARGET GNU_MAKE MAKEFLAGS += --silent - @TARGET BSD_MAKE MAKE += -s - RUNCC = perl $(SOURCEPATH)/make/run-cc.pl $(CXX) - RUNLD = perl $(SOURCEPATH)/make/run-cc.pl $(CXX) -@ENDIF +ifndef INSPIRCD_VERBOSE + MAKEFLAGS += --silent +endif -@IFDEF PURE_STATIC - CORECXXFLAGS += -DPURE_STATIC -@ENDIF +ifdef INSPIRCD_STATIC + CORECXXFLAGS += -DINSPIRCD_STATIC +endif -# Add the users CXXFLAGS to the base ones to allow them to override -# things like -Wfatal-errors if they wish to. -CORECXXFLAGS += $(CXXFLAGS) +# 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 CORECXXFLAGS LDLIBS PICLDFLAGS VERBOSE SOCKETENGINE CORELDFLAGS -@DO_EXPORT SOURCEPATH BUILDPATH PURE_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 M +ifdef INSPIRCD_TARGET HEADER = mod-header FOOTER = mod-footer - @TARGET BSD_MAKE TARGET = modules/${M:S/.so$//}.so - @TARGET GNU_MAKE 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) target: $(HEADER) $(MAKEENV) perl make/calcdep.pl - cd $(BUILDPATH); $(MAKEENV) $(MAKE) -f real.mk $(TARGET) + cd "$(BUILDPATH)"; $(MAKEENV) $(MAKE) -f real.mk $(TARGET) debug: - @${MAKE} D=1 all + @${MAKE} INSPIRCD_DEBUG=1 all debug-header: @echo "*************************************" @@ -183,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)' @@ -224,32 +212,31 @@ install: target exit 1; \ fi @-$(INSTALL) -d -o $(INSTUID) -m $(INSTMODE_DIR) $(BASE) - @-$(INSTALL) -d -o $(INSTUID) -m $(INSTMODE_DIR) $(BASE)/data - @-$(INSTALL) -d -o $(INSTUID) -m $(INSTMODE_DIR) $(BASE)/logs + @-$(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) - [ $(BUILDPATH)/bin/ -ef $(BINPATH) ] || $(INSTALL) -m $(INSTMODE_BIN) $(BUILDPATH)/bin/inspircd $(BINPATH) -@IFNDEF PURE_STATIC - [ $(BUILDPATH)/modules/ -ef $(MODPATH) ] || $(INSTALL) -m $(INSTMODE_LIB) $(BUILDPATH)/modules/*.so $(MODPATH) -@ENDIF - -$(INSTALL) -m $(INSTMODE_BIN) inspircd $(BASE) 2>/dev/null - -$(INSTALL) -m $(INSTMODE_LIB) .gdbargs $(BASE)/.gdbargs 2>/dev/null -@IFEQ $(SYSTEM) darwin - -$(INSTALL) -m $(INSTMODE_BIN) org.inspircd.plist $(BASE) 2>/dev/null -@ENDIF -@IFEQ $(SYSTEM) linux - -$(INSTALL) -m $(INSTMODE_LIB) inspircd.service $(BASE) 2>/dev/null -@ENDIF - -$(INSTALL) -m $(INSTMODE_LIB) inspircd.1 $(MANPATH) 2>/dev/null - -$(INSTALL) -m $(INSTMODE_LIB) inspircd-genssl.1 $(MANPATH) 2>/dev/null + @-$(INSTALL) -d -m $(INSTMODE_DIR) $(SCRPATH) + [ "$(BUILDPATH)/bin/" -ef $(BINPATH) ] || $(INSTALL) -m $(INSTMODE_BIN) "$(BUILDPATH)/bin/inspircd" $(BINPATH) +ifndef INSPIRCD_STATIC + [ "$(BUILDPATH)/modules/" -ef $(MODPATH) ] || $(INSTALL) -m $(INSTMODE_LIB) "$(BUILDPATH)/modules/"*.so $(MODPATH) +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/services/*.example $(CONPATH)/examples/services -$(INSTALL) -m $(INSTMODE_LIB) *.pem $(CONPATH) 2>/dev/null - -$(INSTALL) -m $(INSTMODE_LIB) docs/conf/aliases/*.example $(CONPATH)/examples/aliases - -$(INSTALL) -m $(INSTMODE_LIB) docs/conf/modules/*.example $(CONPATH)/examples/modules @echo "" @echo "*************************************" @echo "* INSTALL COMPLETE! *" @@ -260,20 +247,19 @@ 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/ -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... - -rm -f $(BUILDPATH)/bin/inspircd $(BUILDPATH)/include $(BUILDPATH)/real.mk - -rm -rf $(BUILDPATH)/obj $(BUILDPATH)/modules - @-rmdir $(BUILDPATH)/bin 2>/dev/null - @-rmdir $(BUILDPATH) 2>/dev/null + -rm -f "$(BUILDPATH)/bin/inspircd" "$(BUILDPATH)/include" "$(BUILDPATH)/real.mk" + -rm -rf "$(BUILDPATH)/obj" "$(BUILDPATH)/modules" + @-rmdir "$(BUILDPATH)/bin" 2>/dev/null + @-rmdir "$(BUILDPATH)" 2>/dev/null @echo Completed. deinstall: @@ -281,25 +267,22 @@ deinstall: -rm -rf $(CONPATH)/examples -rm -f $(MANPATH)/inspircd.1 -rm -f $(MANPATH)/inspircd-genssl.1 - -rm -f $(MODPATH)/*.so - -rm -f $(BASE)/.gdbargs - -rm -f $(BASE)/inspircd.service - -rm -f $(BASE)/org.inspircd.plist + -rm -f $(MODPATH)/m_*.so + -rm -f $(MODPATH)/core_*.so + -rm -f $(SCRPATH)/.gdbargs + -rm -f $(SCRPATH)/inspircd.service + -rm -f $(SCRPATH)/org.inspircd.plist configureclean: - rm -f BSDmakefile + rm -f .gdbargs + -rm -f Makefile rm -f GNUmakefile rm -f include/config.h - rm -f inspircd - rm -f inspircd.1 - rm -f inspircd-genssl.1 - -rm -f inspircd.service - -rm -f org.inspircd.plist - -rm -f @CONFIGURE_CACHE_FILE@ + rm -rf @CONFIGURE_DIRECTORY@ distclean: clean configureclean - -rm -rf $(SOURCEPATH)/run - find $(SOURCEPATH)/src/modules -type l | xargs rm -f + -rm -rf "$(SOURCEPATH)/run" + find "$(SOURCEPATH)/src/modules" -type l | xargs rm -f help: @echo 'InspIRCd Makefile' @@ -307,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 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 Run a parallel build using N jobs' @echo '' @echo 'Targets:' @echo ' all Complete build of InspIRCd, without installing (default)' @@ -319,14 +302,14 @@ 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)' @echo ' deinstall Removes the files created by "make install"' @echo +.NOTPARALLEL: + .PHONY: all target debug debug-header mod-header mod-footer std-header finishmessage install clean deinstall configureclean help