]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - make/template/main.mk
Add a logrotate config.
[user/henk/code/inspircd.git] / make / template / main.mk
1 %target GNUmakefile
2 #
3 # InspIRCd -- Internet Relay Chat Daemon
4 #
5 #   Copyright (C) 2018 Puck Meerburg <puck@puckipedia.com>
6 #   Copyright (C) 2012-2020 Sadie Powell <sadie@witchery.services>
7 #   Copyright (C) 2012, 2015-2016 Attila Molnar <attilamolnar@hush.com>
8 #   Copyright (C) 2012 Robby <robby@chatbelgie.be>
9 #   Copyright (C) 2012 Christoph Egger <christoph@debian.org>
10 #   Copyright (C) 2012 ChrisTX <xpipe@hotmail.de>
11 #   Copyright (C) 2010 Dennis Friis <peavey@inspircd.org>
12 #   Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
13 #   Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
14 #   Copyright (C) 2005-2007 Craig Edwards <brain@inspircd.org>
15 #   Copyright (C) 2005 Craig McLure <craig@frostycoolslug.com>
16 #
17 # This file is part of InspIRCd.  InspIRCd is free software: you can
18 # redistribute it and/or modify it under the terms of the GNU General Public
19 # License as published by the Free Software Foundation, version 2.
20 #
21 # This program is distributed in the hope that it will be useful, but WITHOUT
22 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
23 # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
24 # details.
25 #
26 # You should have received a copy of the GNU General Public License
27 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
28 #
29
30
31 #
32 #               InspIRCd Main Makefile
33 #
34 # This file is automagically generated by configure, from
35 # make/template/main.mk. Any changes made to the generated
36 #     files will go away whenever it is regenerated!
37 #
38 # Please do not edit unless you know what you're doing.
39 #
40
41
42 CXX = @CXX@
43 COMPILER = @COMPILER_NAME@
44 SYSTEM = @SYSTEM_NAME@
45 BUILDPATH ?= $(dir $(realpath $(firstword $(MAKEFILE_LIST))))/build/@COMPILER_NAME@-@COMPILER_VERSION@
46 SOCKETENGINE = @SOCKETENGINE@
47 CORECXXFLAGS = -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -pipe -Iinclude -Wall -Wextra -Wfatal-errors -Wno-unused-parameter -Wshadow
48 LDLIBS = -lstdc++
49 CORELDFLAGS = -rdynamic -L.
50 PICLDFLAGS = -fPIC -shared -rdynamic
51
52 DESTDIR := $(if $(DESTDIR),$(DESTDIR),"@DESTDIR|@")
53 BASE    = "$(DESTDIR)@BASE_DIR@"
54 BINPATH = "$(DESTDIR)@BINARY_DIR@"
55 CONPATH = "$(DESTDIR)@CONFIG_DIR@"
56 DATPATH = "$(DESTDIR)@DATA_DIR@"
57 EXAPATH = "$(DESTDIR)@EXAMPLE_DIR@"
58 LOGPATH = "$(DESTDIR)@LOG_DIR@"
59 MANPATH = "$(DESTDIR)@MANUAL_DIR@"
60 MODPATH = "$(DESTDIR)@MODULE_DIR@"
61 SCRPATH = "$(DESTDIR)@SCRIPT_DIR@"
62
63 INSTALL ?= install
64 INSTMODE_DIR ?= 0755
65 INSTMODE_BIN ?= 0755
66 INSTMODE_TXT ?= 0644
67 INSTMODE_PRV ?= 0640
68
69 ifneq ($(COMPILER), ICC)
70   CORECXXFLAGS += -Woverloaded-virtual -Wshadow
71 ifneq ($(SYSTEM), openbsd)
72     CORECXXFLAGS += -pedantic -Wformat=2 -Wmissing-format-attribute -Wno-format-nonliteral
73 endif
74 endif
75
76 ifneq ($(SYSTEM), darwin)
77   LDLIBS += -pthread
78 endif
79
80 ifeq ($(SYSTEM), linux)
81   LDLIBS += -ldl -lrt
82 endif
83 ifeq ($(SYSTEM), gnukfreebsd)
84   LDLIBS += -ldl -lrt
85 endif
86 ifeq ($(SYSTEM), gnu)
87   LDLIBS += -ldl -lrt
88 endif
89 ifeq ($(SYSTEM), solaris)
90   LDLIBS += -lsocket -lnsl -lrt -lresolv
91 endif
92 ifeq ($(SYSTEM), darwin)
93   LDLIBS += -ldl
94   CORELDFLAGS = -dynamic -bind_at_load -L.
95   PICLDFLAGS = -fPIC -shared -twolevel_namespace -undefined dynamic_lookup
96 endif
97 ifeq ($(SYSTEM), haiku)
98   LDLIBS = -lnetwork -lstdc++
99   CORELDFLAGS = -L.
100   PICLDFLAGS = -fPIC -shared
101 endif
102
103 ifndef INSPIRCD_DEBUG
104   INSPIRCD_DEBUG=0
105 endif
106
107 DBGOK=0
108 ifeq ($(INSPIRCD_DEBUG), 0)
109   CORECXXFLAGS += -fno-rtti -O2
110 ifeq ($(COMPILER), GCC)
111     CORECXXFLAGS += -g1
112 endif
113   HEADER = std-header
114   DBGOK=1
115 endif
116 ifeq ($(INSPIRCD_DEBUG), 1)
117   CORECXXFLAGS += -O0 -g3 -Werror -DINSPIRCD_ENABLE_RTTI
118   HEADER = debug-header
119   DBGOK=1
120 endif
121 ifeq ($(INSPIRCD_DEBUG), 2)
122   CORECXXFLAGS += -fno-rtti -O2 -g3
123   HEADER = debug-header
124   DBGOK=1
125 endif
126 ifeq ($(INSPIRCD_DEBUG), 3)
127   CORECXXFLAGS += -fno-rtti -O0 -g0 -Werror
128   HEADER = std-header
129   DBGOK=1
130 endif
131 FOOTER = finishmessage
132
133 MAKEFLAGS += --no-print-directory
134
135 SOURCEPATH = $(shell pwd)
136
137 ifndef INSPIRCD_VERBOSE
138   MAKEFLAGS += --silent
139 endif
140
141 # Append any flags set in the environment after the base flags so
142 # that they can be overridden if necessary.
143 CORECXXFLAGS += $(CPPFLAGS) $(CXXFLAGS)
144 CORELDFLAGS += $(LDFLAGS)
145 PICLDFLAGS += $(LDFLAGS)
146
147 export BUILDPATH
148 export CORECXXFLAGS
149 export CORELDFLAGS
150 export CXX
151 export INSPIRCD_VERBOSE
152 export LDLIBS
153 export PICLDFLAGS
154 export SOCKETENGINE
155 export SOURCEPATH
156
157 # Default target
158 TARGET = all
159
160 ifdef INSPIRCD_TARGET
161     HEADER = mod-header
162     FOOTER = mod-footer
163     TARGET = $(INSPIRCD_TARGET)
164 endif
165
166 ifeq ($(DBGOK), 0)
167   HEADER = unknown-debug-level
168 endif
169
170 all: $(FOOTER)
171
172 target: $(HEADER)
173         $(MAKEENV) perl make/calcdep.pl
174         cd "$(BUILDPATH)"; $(MAKEENV) $(MAKE) -f real.mk $(TARGET)
175
176 debug:
177         @${MAKE} INSPIRCD_DEBUG=1 all
178
179 debug-header:
180         @echo "*************************************"
181         @echo "*    BUILDING WITH DEBUG SYMBOLS    *"
182         @echo "*                                   *"
183         @echo "*   This will take a *long* time.   *"
184         @echo "*  Please be aware that this build  *"
185         @echo "*  will consume a very large amount *"
186         @echo "*  of disk space (~350MB), and may  *"
187         @echo "*  run slower. Use the debug build  *"
188         @echo "*  for module development or if you *"
189         @echo "*    are experiencing problems.     *"
190         @echo "*                                   *"
191         @echo "*************************************"
192
193 mod-header:
194         @echo 'Building specific targets:'
195
196 mod-footer: target
197         @echo 'To install, copy $(BUILDPATH)/$(TARGET) to $(MODPATH)'
198         @echo 'Or, run "make install"'
199
200 std-header:
201         @echo "*************************************"
202         @echo "*       BUILDING INSPIRCD           *"
203         @echo "*                                   *"
204         @echo "*   This will take a *long* time.   *"
205         @echo "*     Why not read our docs at      *"
206         @echo "*     https://docs.inspircd.org     *"
207         @echo "*  while you wait for Make to run?  *"
208         @echo "*************************************"
209
210 finishmessage: target
211         @echo ""
212         @echo "*************************************"
213         @echo "*        BUILD COMPLETE!            *"
214         @echo "*                                   *"
215         @echo "*   To install InspIRCd, type:      *"
216         @echo "*        'make install'             *"
217         @echo "*************************************"
218
219 install: target
220         @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(BASE)
221         @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(BINPATH)
222         @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(CONPATH)
223         @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(DATPATH)
224         @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(EXAPATH)/codepages
225         @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(EXAPATH)/providers
226         @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(EXAPATH)/services
227         @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(EXAPATH)/sql
228         @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(LOGPATH)
229         @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(MANPATH)
230         @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(MODPATH)
231         @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(SCRPATH)
232         -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_BIN) "$(BUILDPATH)/bin/inspircd" $(BINPATH)
233         -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_BIN) "$(BUILDPATH)/modules/"*.so $(MODPATH)
234         -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_BIN) @CONFIGURE_DIRECTORY@/inspircd $(SCRPATH) 2>/dev/null
235         -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/logrotate $(SCRPATH) 2>/dev/null
236 ifeq ($(SYSTEM), darwin)
237         -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_BIN) @CONFIGURE_DIRECTORY@/org.inspircd.plist $(SCRPATH) 2>/dev/null
238 endif
239 ifeq ($(SYSTEM), linux)
240         -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/inspircd.service $(SCRPATH) 2>/dev/null
241 endif
242         -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/inspircd.1 $(MANPATH) 2>/dev/null
243         -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/inspircd-genssl.1 $(MANPATH) 2>/dev/null
244         -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/inspircd-testssl.1 $(MANPATH) 2>/dev/null
245         -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_BIN) tools/genssl $(BINPATH)/inspircd-genssl 2>/dev/null
246         -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_BIN) tools/testssl $(BINPATH)/inspircd-testssl 2>/dev/null
247         -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) docs/conf/*.example $(EXAPATH)
248         -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) docs/conf/codepages/*.example $(EXAPATH)/codepages
249         -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) docs/conf/providers/*.example $(EXAPATH)/providers
250         -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) docs/conf/services/*.example $(EXAPATH)/services
251         -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) docs/sql/*.sql $(EXAPATH)/sql
252         -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/help.txt $(CONPATH)
253         -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_PRV) *.pem $(CONPATH) 2>/dev/null
254         @echo ""
255         @echo "*************************************"
256         @echo "*        INSTALL COMPLETE!          *"
257         @echo "*************************************"
258         @echo 'Paths:'
259         @echo '  Base install:' $(BASE)
260         @echo '  Configuration:' $(CONPATH)
261         @echo '  Binaries:' $(BINPATH)
262         @echo '  Modules:' $(MODPATH)
263         @echo '  Data:' $(DATPATH)
264         @echo 'To start the ircd, run:' $(SCRPATH)/inspircd start
265         @echo 'Remember to create your config file:' $(CONPATH)/inspircd.conf
266         @echo 'Examples are available at:' $(EXAPATH)
267
268 GNUmakefile: make/template/main.mk src/version.sh configure @CONFIGURE_CACHE_FILE@
269         ./configure --update
270
271 clean:
272         @echo Cleaning...
273         -rm -f "$(BUILDPATH)/bin/inspircd" "$(BUILDPATH)/include" "$(BUILDPATH)/real.mk"
274         -rm -rf "$(BUILDPATH)/obj" "$(BUILDPATH)/modules"
275         @-rmdir "$(BUILDPATH)/bin" 2>/dev/null
276         @-rmdir "$(BUILDPATH)" 2>/dev/null
277         @echo Completed.
278
279 deinstall:
280         -rm -f $(BINPATH)/inspircd
281         -rm -rf $(EXAPATH)
282         -rm -f $(MANPATH)/inspircd.1
283         -rm -f $(MANPATH)/inspircd-genssl.1
284         -rm -f $(MODPATH)/m_*.so
285         -rm -f $(MODPATH)/core_*.so
286         -rm -f $(SCRPATH)/inspircd.service
287         -rm -f $(SCRPATH)/org.inspircd.plist
288
289 configureclean:
290         -rm -f Makefile
291         rm -f GNUmakefile
292         rm -f include/config.h
293         rm -rf @CONFIGURE_DIRECTORY@
294
295 distclean: clean configureclean
296         -rm -rf "$(SOURCEPATH)/run"
297         find "$(SOURCEPATH)/src/modules" -type l | xargs rm -f
298
299 help:
300         @echo 'InspIRCd Makefile'
301         @echo ''
302         @echo 'Use: ${MAKE} [flags] [targets]'
303         @echo ''
304         @echo 'Flags:'
305         @echo ' INSPIRCD_VERBOSE=1  Show the full command being executed instead of "BUILD: dns.cpp"'
306         @echo ' INSPIRCD_DEBUG=1    Enable debug build, for module development or crash tracing'
307         @echo ' INSPIRCD_DEBUG=2    Enable debug build with optimizations, for detailed backtraces'
308         @echo ' INSPIRCD_DEBUG=3    Enable fast build with no optimisations or symbols (only for CI)'
309         @echo ' DESTDIR=            Specify a destination root directory (for tarball creation)'
310         @echo ' -j <N>              Run a parallel build using N jobs'
311         @echo ''
312         @echo 'Targets:'
313         @echo ' all       Complete build of InspIRCd, without installing (default)'
314         @echo ' install   Build and install InspIRCd to the directory chosen in ./configure'
315         @echo '           Currently installs to ${BASE}'
316         @echo ' debug     Compile a debug build. Equivalent to "make D=1 all"'
317         @echo ''
318         @echo ' INSPIRCD_TARGET=target  Builds a user-specified target, such as "inspircd" or "core_dns"'
319         @echo '                         Multiple targets may be separated by a space'
320         @echo ''
321         @echo ' clean     Cleans object files produced by the compile'
322         @echo ' distclean Cleans all generated files (build, configure, run, etc)'
323         @echo ' deinstall Removes the files created by "make install"'
324         @echo
325
326 .NOTPARALLEL:
327
328 .PHONY: all target debug debug-header mod-header mod-footer std-header finishmessage install clean deinstall configureclean help