]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - make/template/main.mk
Rename the spanningtree module header to server.
[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. $(LDFLAGS)
40 PICLDFLAGS = -fPIC -shared -rdynamic $(LDFLAGS)
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 INSTUID = @UID@
51 INSTMODE_DIR = 0750
52 INSTMODE_BIN = 0750
53 INSTMODE_LIB = 0640
54
55 ifneq ($(COMPILER), ICC)
56   CORECXXFLAGS += -Woverloaded-virtual -Wshadow
57 ifneq ($(SYSTEM), openbsd)
58     CORECXXFLAGS += -pedantic -Wformat=2 -Wmissing-format-attribute
59 endif
60 endif
61
62 ifneq ($(SYSTEM), darwin)
63   LDLIBS += -pthread
64 endif
65
66 ifeq ($(SYSTEM), linux)
67   LDLIBS += -ldl -lrt
68 endif
69 ifeq ($(SYSTEM), gnukfreebsd)
70   LDLIBS += -ldl -lrt
71 endif
72 ifeq ($(SYSTEM), gnu)
73   LDLIBS += -ldl -lrt
74 endif
75 ifeq ($(SYSTEM), solaris)
76   LDLIBS += -lsocket -lnsl -lrt -lresolv
77   INSTALL = ginstall
78 endif
79 ifeq ($(SYSTEM), darwin)
80   LDLIBS += -ldl
81   CORELDFLAGS = -dynamic -bind_at_load -L. $(LDFLAGS)
82   PICLDFLAGS = -fPIC -shared -twolevel_namespace -undefined dynamic_lookup $(LDFLAGS)
83 endif
84
85 ifndef INSPIRCD_DEBUG
86   INSPIRCD_DEBUG=0
87 endif
88
89 DBGOK=0
90 ifeq ($(INSPIRCD_DEBUG), 0)
91   CORECXXFLAGS += -fno-rtti -O2
92 ifeq ($(COMPILER), GCC)
93     CORECXXFLAGS += -g1
94 endif
95   HEADER = std-header
96   DBGOK=1
97 endif
98 ifeq ($(INSPIRCD_DEBUG), 1)
99   CORECXXFLAGS += -O0 -g3 -Werror -DINSPIRCD_ENABLE_RTTI
100   HEADER = debug-header
101   DBGOK=1
102 endif
103 ifeq ($(INSPIRCD_DEBUG), 2)
104   CORECXXFLAGS += -fno-rtti -O2 -g3
105   HEADER = debug-header
106   DBGOK=1
107 endif
108 FOOTER = finishmessage
109
110 MAKEFLAGS += --no-print-directory
111
112 SOURCEPATH = $(shell /bin/pwd)
113
114 ifndef INSPIRCD_VERBOSE
115   MAKEFLAGS += --silent
116 endif
117
118 ifdef INSPIRCD_STATIC
119   CORECXXFLAGS += -DINSPIRCD_STATIC
120 endif
121
122 # Add the users CPPFLAGS/CXXFLAGS to the base ones to allow them to
123 # override things like -Wfatal-errors if they wish to.
124 CORECXXFLAGS += $(CPPFLAGS) $(CXXFLAGS)
125
126 export BUILDPATH
127 export CORECXXFLAGS
128 export CORELDFLAGS
129 export CXX
130 export INSPIRCD_STATIC
131 export INSPIRCD_VERBOSE
132 export LDLIBS
133 export PICLDFLAGS
134 export SOCKETENGINE
135 export SOURCEPATH
136
137 # Default target
138 TARGET = all
139
140 ifdef INSPIRCD_TARGET
141     HEADER = mod-header
142     FOOTER = mod-footer
143     TARGET = $(INSPIRCD_TARGET)
144 endif
145
146 ifeq ($(DBGOK), 0)
147   HEADER = unknown-debug-level
148 endif
149
150 all: $(FOOTER)
151
152 target: $(HEADER)
153         $(MAKEENV) perl make/calcdep.pl
154         cd "$(BUILDPATH)"; $(MAKEENV) $(MAKE) -f real.mk $(TARGET)
155
156 debug:
157         @${MAKE} INSPIRCD_DEBUG=1 all
158
159 debug-header:
160         @echo "*************************************"
161         @echo "*    BUILDING WITH DEBUG SYMBOLS    *"
162         @echo "*                                   *"
163         @echo "*   This will take a *long* time.   *"
164         @echo "*  Please be aware that this build  *"
165         @echo "*  will consume a very large amount *"
166         @echo "*  of disk space (~350MB), and may  *"
167         @echo "*  run slower. Use the debug build  *"
168         @echo "*  for module development or if you *"
169         @echo "*    are experiencing problems.     *"
170         @echo "*                                   *"
171         @echo "*************************************"
172
173 mod-header:
174 ifdef INSPIRCD_STATIC
175         @echo 'Cannot build specific targets in pure-static build'
176         @exit 1
177 endif
178         @echo 'Building specific targets:'
179
180 mod-footer: target
181         @echo 'To install, copy $(BUILDPATH)/$(TARGET) to $(MODPATH)'
182         @echo 'Or, run "make install"'
183
184 std-header:
185         @echo "*************************************"
186         @echo "*       BUILDING INSPIRCD           *"
187         @echo "*                                   *"
188         @echo "*   This will take a *long* time.   *"
189         @echo "*     Why not read our wiki at      *"
190         @echo "*     http://wiki.inspircd.org      *"
191         @echo "*  while you wait for make to run?  *"
192         @echo "*************************************"
193
194 finishmessage: target
195         @echo ""
196         @echo "*************************************"
197         @echo "*        BUILD COMPLETE!            *"
198         @echo "*                                   *"
199         @echo "*   To install InspIRCd, type:      *"
200         @echo "*         make install              *"
201         @echo "*************************************"
202
203 install: target
204         @if [ "$(INSTUID)" = 0 -o "$(INSTUID)" = root ]; then \
205                 echo ""; \
206                 echo "Error: You must specify a non-root UID for the server"; \
207                 echo ""; \
208                 echo "If you are making a package, please specify using ./configure --uid"; \
209                 echo "Otherwise, rerun using 'make INSTUID=irc install', where 'irc' is the user"; \
210                 echo "who will be running the ircd. You will also need to modify the start script."; \
211                 echo ""; \
212                 exit 1; \
213         fi
214         @-$(INSTALL) -d -o $(INSTUID) -m $(INSTMODE_DIR) $(BASE)
215         @-$(INSTALL) -d -o $(INSTUID) -m $(INSTMODE_DIR) $(DATPATH)
216         @-$(INSTALL) -d -o $(INSTUID) -m $(INSTMODE_DIR) $(LOGPATH)
217         @-$(INSTALL) -d -m $(INSTMODE_DIR) $(BINPATH)
218         @-$(INSTALL) -d -m $(INSTMODE_DIR) $(CONPATH)/examples/services
219         @-$(INSTALL) -d -m $(INSTMODE_DIR) $(MANPATH)
220         @-$(INSTALL) -d -m $(INSTMODE_DIR) $(MODPATH)
221         @-$(INSTALL) -d -m $(INSTMODE_DIR) $(SCRPATH)
222         [ "$(BUILDPATH)/bin/" -ef $(BINPATH) ] || $(INSTALL) -m $(INSTMODE_BIN) "$(BUILDPATH)/bin/inspircd" $(BINPATH)
223 ifndef INSPIRCD_STATIC
224         [ "$(BUILDPATH)/modules/" -ef $(MODPATH) ] || $(INSTALL) -m $(INSTMODE_LIB) "$(BUILDPATH)/modules/"*.so $(MODPATH)
225 endif
226         -$(INSTALL) -m $(INSTMODE_BIN) @CONFIGURE_DIRECTORY@/inspircd $(SCRPATH) 2>/dev/null
227         -$(INSTALL) -m $(INSTMODE_LIB) .gdbargs $(SCRPATH)/.gdbargs 2>/dev/null
228 ifeq ($(SYSTEM), darwin)
229         -$(INSTALL) -m $(INSTMODE_BIN) @CONFIGURE_DIRECTORY@/org.inspircd.plist $(SCRPATH) 2>/dev/null
230 endif
231 ifeq ($(SYSTEM), linux)
232         -$(INSTALL) -m $(INSTMODE_LIB) @CONFIGURE_DIRECTORY@/inspircd.service $(SCRPATH) 2>/dev/null
233 endif
234         -$(INSTALL) -m $(INSTMODE_LIB) @CONFIGURE_DIRECTORY@/inspircd.1 $(MANPATH) 2>/dev/null
235         -$(INSTALL) -m $(INSTMODE_LIB) @CONFIGURE_DIRECTORY@/inspircd-genssl.1 $(MANPATH) 2>/dev/null
236         -$(INSTALL) -m $(INSTMODE_BIN) tools/genssl $(BINPATH)/inspircd-genssl 2>/dev/null
237         -$(INSTALL) -m $(INSTMODE_LIB) docs/conf/*.example $(CONPATH)/examples
238         -$(INSTALL) -m $(INSTMODE_LIB) docs/conf/services/*.example $(CONPATH)/examples/services
239         -$(INSTALL) -m $(INSTMODE_LIB) *.pem $(CONPATH) 2>/dev/null
240         @echo ""
241         @echo "*************************************"
242         @echo "*        INSTALL COMPLETE!          *"
243         @echo "*************************************"
244         @echo 'Paths:'
245         @echo '  Base install:' $(BASE)
246         @echo '  Configuration:' $(CONPATH)
247         @echo '  Binaries:' $(BINPATH)
248         @echo '  Modules:' $(MODPATH)
249         @echo '  Data:' $(DATPATH)
250         @echo 'To start the ircd, run:' $(SCRPATH)/inspircd start
251         @echo 'Remember to create your config file:' $(CONPATH)/inspircd.conf
252         @echo 'Examples are available at:' $(CONPATH)/examples/
253
254 GNUmakefile: make/template/main.mk src/version.sh configure @CONFIGURE_CACHE_FILE@
255         ./configure --update
256
257 clean:
258         @echo Cleaning...
259         -rm -f "$(BUILDPATH)/bin/inspircd" "$(BUILDPATH)/include" "$(BUILDPATH)/real.mk"
260         -rm -rf "$(BUILDPATH)/obj" "$(BUILDPATH)/modules"
261         @-rmdir "$(BUILDPATH)/bin" 2>/dev/null
262         @-rmdir "$(BUILDPATH)" 2>/dev/null
263         @echo Completed.
264
265 deinstall:
266         -rm -f $(BINPATH)/inspircd
267         -rm -rf $(CONPATH)/examples
268         -rm -f $(MANPATH)/inspircd.1
269         -rm -f $(MANPATH)/inspircd-genssl.1
270         -rm -f $(MODPATH)/m_*.so
271         -rm -f $(MODPATH)/core_*.so
272         -rm -f $(SCRPATH)/.gdbargs
273         -rm -f $(SCRPATH)/inspircd.service
274         -rm -f $(SCRPATH)/org.inspircd.plist
275
276 configureclean:
277         rm -f .gdbargs
278         -rm -f Makefile
279         rm -f GNUmakefile
280         rm -f include/config.h
281         rm -rf @CONFIGURE_DIRECTORY@
282
283 distclean: clean configureclean
284         -rm -rf "$(SOURCEPATH)/run"
285         find "$(SOURCEPATH)/src/modules" -type l | xargs rm -f
286
287 help:
288         @echo 'InspIRCd Makefile'
289         @echo ''
290         @echo 'Use: ${MAKE} [flags] [targets]'
291         @echo ''
292         @echo 'Flags:'
293         @echo ' INSPIRCD_VERBOSE=1  Show the full command being executed instead of "BUILD: dns.cpp"'
294         @echo ' INSPIRCD_DEBUG=1    Enable debug build, for module development or crash tracing'
295         @echo ' INSPIRCD_DEBUG=2    Enable debug build with optimizations, for detailed backtraces'
296         @echo ' DESTDIR=            Specify a destination root directory (for tarball creation)'
297         @echo ' -j <N>              Run a parallel build using N jobs'
298         @echo ''
299         @echo 'Targets:'
300         @echo ' all       Complete build of InspIRCd, without installing (default)'
301         @echo ' install   Build and install InspIRCd to the directory chosen in ./configure'
302         @echo '           Currently installs to ${BASE}'
303         @echo ' debug     Compile a debug build. Equivalent to "make D=1 all"'
304         @echo ''
305         @echo ' INSPIRCD_TARGET=target  Builds a user-specified target, such as "inspircd" or "core_dns"'
306         @echo '                         Multiple targets may be separated by a space'
307         @echo ''
308         @echo ' clean     Cleans object files produced by the compile'
309         @echo ' distclean Cleans all generated files (build, configure, run, etc)'
310         @echo ' deinstall Removes the files created by "make install"'
311         @echo
312
313 .NOTPARALLEL:
314
315 .PHONY: all target debug debug-header mod-header mod-footer std-header finishmessage install clean deinstall configureclean help