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