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