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