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