]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - make/template/main.mk
Move the SQL tables to docs/sql and install them on `make install`.
[user/henk/code/inspircd.git] / make / template / main.mk
index c78d9047d0916ddc0ca56f3ba24a55e5c9f13444..a67c14f732c7dc25334cfb7eeccd9cf6f780d7ce 100644 (file)
@@ -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,133 +34,129 @@ 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)
+CORELDFLAGS = -rdynamic -L.
+PICLDFLAGS = -fPIC -shared -rdynamic
 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
-  CORECXXFLAGS += -pedantic -Woverloaded-virtual -Wshadow -Wformat=2 -Wmissing-format-attribute
-@ENDIF
+ifneq ($(COMPILER), ICC)
+  CORECXXFLAGS += -Woverloaded-virtual -Wshadow
+ifneq ($(SYSTEM), openbsd)
+    CORECXXFLAGS += -pedantic -Wformat=2 -Wmissing-format-attribute
+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
-
-@IFNDEF D
-  D=0
-@ENDIF
+  CORELDFLAGS = -dynamic -bind_at_load -L.
+  PICLDFLAGS = -fPIC -shared -twolevel_namespace -undefined dynamic_lookup
+endif
+ifeq ($(SYSTEM), haiku)
+  LDLIBS = -lnetwork -lstdc++
+  CORELDFLAGS = -L.
+  PICLDFLAGS = -fPIC -shared
+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
-
-@TARGET GNU_MAKE SOURCEPATH = $(shell /bin/pwd)
-@TARGET BSD_MAKE SOURCEPATH != /bin/pwd
+MAKEFLAGS += --no-print-directory
 
-@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
+SOURCEPATH = $(shell pwd)
 
-@IFDEF PURE_STATIC
-  CORECXXFLAGS += -DPURE_STATIC
-@ENDIF
+ifndef INSPIRCD_VERBOSE
+  MAKEFLAGS += --silent
+endif
 
-# Add the users CXXFLAGS to the base ones to allow them to override
-# things like -Wfatal-errors if they wish to.
-CORECXXFLAGS += $(CXXFLAGS)
+# Append any flags set in the environment after the base flags so
+# that they can be overridden if necessary.
+CORECXXFLAGS += $(CPPFLAGS) $(CXXFLAGS)
+CORELDFLAGS += $(LDFLAGS)
+PICLDFLAGS += $(LDFLAGS)
 
-@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_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
+    TARGET = $(INSPIRCD_TARGET)
+endif
 
-@IFDEF T
-    HEADER =
-    FOOTER = target
-    TARGET = $(T)
-@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 "*************************************"
@@ -180,11 +173,7 @@ debug-header:
        @echo "*************************************"
 
 mod-header:
-@IFDEF PURE_STATIC
-       @echo 'Cannot build single modules in pure-static build'
-       @exit 1
-@ENDIF
-       @echo 'Building single module:'
+       @echo 'Building specific targets:'
 
 mod-footer: target
        @echo 'To install, copy $(BUILDPATH)/$(TARGET) to $(MODPATH)'
@@ -197,7 +186,7 @@ std-header:
        @echo "*   This will take a *long* time.   *"
        @echo "*     Why not read our wiki at      *"
        @echo "*     http://wiki.inspircd.org      *"
-       @echo "*  while you wait for make to run?  *"
+       @echo "*  while you wait for Make to run?  *"
        @echo "*************************************"
 
 finishmessage: target
@@ -206,7 +195,7 @@ finishmessage: target
        @echo "*        BUILD COMPLETE!            *"
        @echo "*                                   *"
        @echo "*   To install InspIRCd, type:      *"
-       @echo "*         make install              *"
+       @echo "*        'make install'             *"
        @echo "*************************************"
 
 install: target
@@ -221,32 +210,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) $(CONPATH)/examples/sql
        @-$(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)
+       [ "$(BUILDPATH)/modules/" -ef $(MODPATH) ] || $(INSTALL) -m $(INSTMODE_LIB) "$(BUILDPATH)/modules/"*.so $(MODPATH)
+       -$(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) *.pem $(CONPATH)
-       -$(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) docs/sql/*.sql $(CONPATH)/examples/sql
+       -$(INSTALL) -m $(INSTMODE_LIB) *.pem $(CONPATH) 2>/dev/null
        @echo ""
        @echo "*************************************"
        @echo "*        INSTALL COMPLETE!          *"
@@ -257,20 +245,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 .config.cache
-       ./configure -update
-@TARGET BSD_MAKE .MAKEFILEDEPS: BSDmakefile
+GNUmakefile: make/template/main.mk src/version.sh configure @CONFIGURE_CACHE_FILE@
+       ./configure --update
 
 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:
@@ -278,25 +265,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 .config.cache
-       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 -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'
@@ -304,11 +288,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)'
@@ -316,14 +300,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