]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - make/template/main.mk
Rename D to INSPIRCD_DEBUG.
[user/henk/code/inspircd.git] / make / template / main.mk
1 %target BSD_MAKE BSDmakefile
2 %target GNU_MAKE GNUmakefile
3 #
4 # InspIRCd -- Internet Relay Chat Daemon
5 #
6 #   Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
7 #
8 # This file is part of InspIRCd.  InspIRCd is free software: you can
9 # redistribute it and/or modify it under the terms of the GNU General Public
10 # License as published by the Free Software Foundation, version 2.
11 #
12 # This program is distributed in the hope that it will be useful, but WITHOUT
13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
15 # details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
19 #
20
21
22 #
23 #               InspIRCd Main Makefile
24 #
25 # This file is automagically generated by configure, from
26 # make/template/main.mk. Any changes made to the generated
27 #     files will go away whenever it is regenerated!
28 #
29 # Please do not edit unless you know what you're doing. This
30 # needs to work in both GNU and BSD make; it is mangled for
31 # them by configure.
32 #
33
34
35 CXX = @CXX@
36 COMPILER = @COMPILER_NAME@
37 SYSTEM = @SYSTEM_NAME@
38 BUILDPATH ?= $(PWD)/build
39 SOCKETENGINE = @SOCKETENGINE@
40 CORECXXFLAGS = -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -pipe -Iinclude -Wall -Wextra -Wfatal-errors -Wno-unused-parameter -Wshadow
41 LDLIBS = -lstdc++
42 CORELDFLAGS = -rdynamic -L. $(LDFLAGS)
43 PICLDFLAGS = -fPIC -shared -rdynamic $(LDFLAGS)
44 BASE = "$(DESTDIR)@BASE_DIR@"
45 CONPATH = "$(DESTDIR)@CONFIG_DIR@"
46 MANPATH = "$(DESTDIR)@MANUAL_DIR@"
47 MODPATH = "$(DESTDIR)@MODULE_DIR@"
48 LOGPATH = "$(DESTDIR)@LOG_DIR@"
49 DATPATH = "$(DESTDIR)@DATA_DIR@"
50 BINPATH = "$(DESTDIR)@BINARY_DIR@"
51 INSTALL = install
52 INSTUID = @UID@
53 INSTMODE_DIR = 0750
54 INSTMODE_BIN = 0750
55 INSTMODE_LIB = 0640
56
57 @IFNEQ $(COMPILER) ICC
58   CORECXXFLAGS += -Woverloaded-virtual -Wshadow
59 @IFNEQ $(SYSTEM) openbsd
60     CORECXXFLAGS += -pedantic -Wformat=2 -Wmissing-format-attribute
61 @ENDIF
62 @ENDIF
63
64 @IFNEQ $(SYSTEM) darwin
65   LDLIBS += -pthread
66 @ENDIF
67
68 @IFEQ $(SYSTEM) linux
69   LDLIBS += -ldl -lrt
70 @ENDIF
71 @IFEQ $(SYSTEM) gnukfreebsd
72   LDLIBS += -ldl -lrt
73 @ENDIF
74 @IFEQ $(SYSTEM) gnu
75   LDLIBS += -ldl -lrt
76 @ENDIF
77 @IFEQ $(SYSTEM) solaris
78   LDLIBS += -lsocket -lnsl -lrt -lresolv
79   INSTALL = ginstall
80 @ENDIF
81 @IFEQ $(SYSTEM) darwin
82   LDLIBS += -ldl
83   CORELDFLAGS = -dynamic -bind_at_load -L. $(LDFLAGS)
84   PICLDFLAGS = -fPIC -shared -twolevel_namespace -undefined dynamic_lookup $(LDFLAGS)
85 @ENDIF
86
87 @IFNDEF INSPIRCD_DEBUG
88   INSPIRCD_DEBUG=0
89 @ENDIF
90
91 DBGOK=0
92 @IFEQ $(INSPIRCD_DEBUG) 0
93   CORECXXFLAGS += -fno-rtti -O2
94 @IFEQ $(COMPILER) GCC
95     CORECXXFLAGS += -g1
96 @ENDIF
97   HEADER = std-header
98   DBGOK=1
99 @ENDIF
100 @IFEQ $(INSPIRCD_DEBUG) 1
101   CORECXXFLAGS += -O0 -g3 -Werror -DINSPIRCD_ENABLE_RTTI
102   HEADER = debug-header
103   DBGOK=1
104 @ENDIF
105 @IFEQ $(INSPIRCD_DEBUG) 2
106   CORECXXFLAGS += -fno-rtti -O2 -g3
107   HEADER = debug-header
108   DBGOK=1
109 @ENDIF
110 FOOTER = finishmessage
111
112 @TARGET GNU_MAKE MAKEFLAGS += --no-print-directory
113
114 @TARGET GNU_MAKE SOURCEPATH = $(shell /bin/pwd)
115 @TARGET BSD_MAKE SOURCEPATH != /bin/pwd
116
117 @IFDEF INSPIRCD_VERBOSE
118   VERBOSE = -v
119 @ELSE
120   @TARGET GNU_MAKE MAKEFLAGS += --silent
121   @TARGET BSD_MAKE MAKE += -s
122   VERBOSE =
123 @ENDIF
124
125 @IFDEF INSPIRCD_STATIC
126   CORECXXFLAGS += -DINSPIRCD_STATIC
127 @ENDIF
128
129 # Add the users CXXFLAGS to the base ones to allow them to override
130 # things like -Wfatal-errors if they wish to.
131 CORECXXFLAGS += $(CXXFLAGS)
132
133 @DO_EXPORT CXX CORECXXFLAGS LDLIBS PICLDFLAGS VERBOSE SOCKETENGINE CORELDFLAGS
134 @DO_EXPORT SOURCEPATH BUILDPATH INSPIRCD_STATIC
135
136 # Default target
137 TARGET = all
138
139 @IFDEF M
140     HEADER = mod-header
141     FOOTER = mod-footer
142     @TARGET BSD_MAKE TARGET = modules/${M:S/.so$//}.so
143     @TARGET GNU_MAKE TARGET = modules/$(M:.so=).so
144 @ENDIF
145
146 @IFDEF T
147     HEADER =
148     FOOTER = target
149     TARGET = $(T)
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 @IFDEF INSPIRCD_STATIC
181         @echo 'Cannot build single modules in pure-static build'
182         @exit 1
183 @ENDIF
184         @echo 'Building single module:'
185
186 mod-footer: target
187         @echo 'To install, copy $(BUILDPATH)/$(TARGET) to $(MODPATH)'
188         @echo 'Or, run "make install"'
189
190 std-header:
191         @echo "*************************************"
192         @echo "*       BUILDING INSPIRCD           *"
193         @echo "*                                   *"
194         @echo "*   This will take a *long* time.   *"
195         @echo "*     Why not read our wiki at      *"
196         @echo "*     http://wiki.inspircd.org      *"
197         @echo "*  while you wait for make to run?  *"
198         @echo "*************************************"
199
200 finishmessage: target
201         @echo ""
202         @echo "*************************************"
203         @echo "*        BUILD COMPLETE!            *"
204         @echo "*                                   *"
205         @echo "*   To install InspIRCd, type:      *"
206         @echo "*         make install              *"
207         @echo "*************************************"
208
209 install: target
210         @if [ "$(INSTUID)" = 0 -o "$(INSTUID)" = root ]; then \
211                 echo ""; \
212                 echo "Error: You must specify a non-root UID for the server"; \
213                 echo ""; \
214                 echo "If you are making a package, please specify using ./configure --uid"; \
215                 echo "Otherwise, rerun using 'make INSTUID=irc install', where 'irc' is the user"; \
216                 echo "who will be running the ircd. You will also need to modify the start script."; \
217                 echo ""; \
218                 exit 1; \
219         fi
220         @-$(INSTALL) -d -o $(INSTUID) -m $(INSTMODE_DIR) $(BASE)
221         @-$(INSTALL) -d -o $(INSTUID) -m $(INSTMODE_DIR) $(DATPATH)
222         @-$(INSTALL) -d -o $(INSTUID) -m $(INSTMODE_DIR) $(LOGPATH)
223         @-$(INSTALL) -d -m $(INSTMODE_DIR) $(BINPATH)
224         @-$(INSTALL) -d -m $(INSTMODE_DIR) $(CONPATH)/examples/aliases
225         @-$(INSTALL) -d -m $(INSTMODE_DIR) $(CONPATH)/examples/modules
226         @-$(INSTALL) -d -m $(INSTMODE_DIR) $(MANPATH)
227         @-$(INSTALL) -d -m $(INSTMODE_DIR) $(MODPATH)
228         [ $(BUILDPATH)/bin/ -ef $(BINPATH) ] || $(INSTALL) -m $(INSTMODE_BIN) $(BUILDPATH)/bin/inspircd $(BINPATH)
229 @IFNDEF INSPIRCD_STATIC
230         [ $(BUILDPATH)/modules/ -ef $(MODPATH) ] || $(INSTALL) -m $(INSTMODE_LIB) $(BUILDPATH)/modules/*.so $(MODPATH)
231 @ENDIF
232         -$(INSTALL) -m $(INSTMODE_BIN) @CONFIGURE_DIRECTORY@/inspircd $(BASE) 2>/dev/null
233         -$(INSTALL) -m $(INSTMODE_LIB) .gdbargs $(BASE)/.gdbargs 2>/dev/null
234 @IFEQ $(SYSTEM) darwin
235         -$(INSTALL) -m $(INSTMODE_BIN) @CONFIGURE_DIRECTORY@/org.inspircd.plist $(BASE) 2>/dev/null
236 @ENDIF
237 @IFEQ $(SYSTEM) linux
238         -$(INSTALL) -m $(INSTMODE_LIB) @CONFIGURE_DIRECTORY@/inspircd.service $(BASE) 2>/dev/null
239 @ENDIF
240         -$(INSTALL) -m $(INSTMODE_LIB) @CONFIGURE_DIRECTORY@/inspircd.1 $(MANPATH) 2>/dev/null
241         -$(INSTALL) -m $(INSTMODE_LIB) @CONFIGURE_DIRECTORY@/inspircd-genssl.1 $(MANPATH) 2>/dev/null
242         -$(INSTALL) -m $(INSTMODE_BIN) tools/genssl $(BINPATH)/inspircd-genssl 2>/dev/null
243         -$(INSTALL) -m $(INSTMODE_LIB) docs/conf/*.example $(CONPATH)/examples
244         -$(INSTALL) -m $(INSTMODE_LIB) *.pem $(CONPATH) 2>/dev/null
245         -$(INSTALL) -m $(INSTMODE_LIB) docs/conf/aliases/*.example $(CONPATH)/examples/aliases
246         -$(INSTALL) -m $(INSTMODE_LIB) docs/conf/modules/*.example $(CONPATH)/examples/modules
247         @echo ""
248         @echo "*************************************"
249         @echo "*        INSTALL COMPLETE!          *"
250         @echo "*************************************"
251         @echo 'Paths:'
252         @echo '  Base install:' $(BASE)
253         @echo '  Configuration:' $(CONPATH)
254         @echo '  Binaries:' $(BINPATH)
255         @echo '  Modules:' $(MODPATH)
256         @echo '  Data:' $(DATPATH)
257         @echo 'To start the ircd, run:' $(BASE)/inspircd start
258         @echo 'Remember to create your config file:' $(CONPATH)/inspircd.conf
259         @echo 'Examples are available at:' $(CONPATH)/examples/
260
261 GNUmakefile BSDmakefile: make/template/main.mk src/version.sh configure @CONFIGURE_CACHE_FILE@
262         ./configure --update
263 @TARGET BSD_MAKE .MAKEFILEDEPS: BSDmakefile
264
265 clean:
266         @echo Cleaning...
267         -rm -f $(BUILDPATH)/bin/inspircd $(BUILDPATH)/include $(BUILDPATH)/real.mk
268         -rm -rf $(BUILDPATH)/obj $(BUILDPATH)/modules
269         @-rmdir $(BUILDPATH)/bin 2>/dev/null
270         @-rmdir $(BUILDPATH) 2>/dev/null
271         @echo Completed.
272
273 deinstall:
274         -rm -f $(BINPATH)/inspircd
275         -rm -rf $(CONPATH)/examples
276         -rm -f $(MANPATH)/inspircd.1
277         -rm -f $(MANPATH)/inspircd-genssl.1
278         -rm -f $(MODPATH)/*.so
279         -rm -f $(BASE)/.gdbargs
280         -rm -f $(BASE)/inspircd.service
281         -rm -f $(BASE)/org.inspircd.plist
282
283 configureclean:
284         rm -f BSDmakefile
285         rm -f GNUmakefile
286         rm -f include/config.h
287         rm -f inspircd
288         rm -f inspircd.1
289         rm -f inspircd-genssl.1
290         -rm -f inspircd.service
291         -rm -f org.inspircd.plist
292         -rm -f @CONFIGURE_CACHE_FILE@
293
294 distclean: clean configureclean
295         -rm -rf $(SOURCEPATH)/run
296         find $(SOURCEPATH)/src/modules -type l | xargs rm -f
297
298 help:
299         @echo 'InspIRCd Makefile'
300         @echo ''
301         @echo 'Use: ${MAKE} [flags] [targets]'
302         @echo ''
303         @echo 'Flags:'
304         @echo ' INSPIRCD_VERBOSE=1  Show the full command being executed instead of "BUILD: dns.cpp"'
305         @echo ' INSPIRCD_DEBUG=1    Enable debug build, for module development or crash tracing'
306         @echo ' INSPIRCD_DEBUG=2    Enable debug build with optimizations, for detailed backtraces'
307         @echo ' DESTDIR=            Specify a destination root directory (for tarball creation)'
308         @echo ' -j <N>              Run a parallel build using N jobs'
309         @echo ''
310         @echo 'Targets:'
311         @echo ' all       Complete build of InspIRCd, without installing (default)'
312         @echo ' install   Build and install InspIRCd to the directory chosen in ./configure'
313         @echo '           Currently installs to ${BASE}'
314         @echo ' debug     Compile a debug build. Equivalent to "make D=1 all"'
315         @echo ''
316         @echo ' M=m_foo   Builds a single module (cmd_foo also works here)'
317         @echo ' T=target  Builds a user-specified target, such as "inspircd" or "modules"'
318         @echo '           Other targets are specified by their path in the build directory'
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