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