]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - make/template/main.mk
748eae0362d6ee2e62b101850a424c48853b6f5c
[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 ?= $(dir $(realpath $(firstword $(MAKEFILE_LIST))))/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
42 BASE    = "$(DESTDIR)@BASE_DIR@"
43 BINPATH = "$(DESTDIR)@BINARY_DIR@"
44 CONPATH = "$(DESTDIR)@CONFIG_DIR@"
45 DATPATH = "$(DESTDIR)@DATA_DIR@"
46 EXAPATH = "$(DESTDIR)@EXAMPLE_DIR@"
47 LOGPATH = "$(DESTDIR)@LOG_DIR@"
48 MANPATH = "$(DESTDIR)@MANUAL_DIR@"
49 MODPATH = "$(DESTDIR)@MODULE_DIR@"
50 SCRPATH = "$(DESTDIR)@SCRIPT_DIR@"
51
52 INSTALL ?= install
53 INSTMODE_DIR ?= 0755
54 INSTMODE_BIN ?= 0755
55 INSTMODE_TXT ?= 0644
56 INSTMODE_PRV ?= 0640
57
58 ifneq ($(COMPILER), ICC)
59   CORECXXFLAGS += -Woverloaded-virtual -Wshadow
60 ifneq ($(SYSTEM), openbsd)
61     CORECXXFLAGS += -pedantic -Wformat=2 -Wmissing-format-attribute -Wno-format-nonliteral
62 endif
63 endif
64
65 ifneq ($(SYSTEM), darwin)
66   LDLIBS += -pthread
67 endif
68
69 ifeq ($(SYSTEM), linux)
70   LDLIBS += -ldl -lrt
71 endif
72 ifeq ($(SYSTEM), gnukfreebsd)
73   LDLIBS += -ldl -lrt
74 endif
75 ifeq ($(SYSTEM), gnu)
76   LDLIBS += -ldl -lrt
77 endif
78 ifeq ($(SYSTEM), solaris)
79   LDLIBS += -lsocket -lnsl -lrt -lresolv
80 endif
81 ifeq ($(SYSTEM), darwin)
82   LDLIBS += -ldl
83   CORELDFLAGS = -dynamic -bind_at_load -L.
84   PICLDFLAGS = -fPIC -shared -twolevel_namespace -undefined dynamic_lookup
85 endif
86 ifeq ($(SYSTEM), haiku)
87   LDLIBS = -lnetwork -lstdc++
88   CORELDFLAGS = -L.
89   PICLDFLAGS = -fPIC -shared
90 endif
91
92 ifndef INSPIRCD_DEBUG
93   INSPIRCD_DEBUG=0
94 endif
95
96 DBGOK=0
97 ifeq ($(INSPIRCD_DEBUG), 0)
98   CORECXXFLAGS += -fno-rtti -O2
99 ifeq ($(COMPILER), GCC)
100     CORECXXFLAGS += -g1
101 endif
102   HEADER = std-header
103   DBGOK=1
104 endif
105 ifeq ($(INSPIRCD_DEBUG), 1)
106   CORECXXFLAGS += -O0 -g3 -Werror -DINSPIRCD_ENABLE_RTTI
107   HEADER = debug-header
108   DBGOK=1
109 endif
110 ifeq ($(INSPIRCD_DEBUG), 2)
111   CORECXXFLAGS += -fno-rtti -O2 -g3
112   HEADER = debug-header
113   DBGOK=1
114 endif
115 ifeq ($(INSPIRCD_DEBUG), 3)
116   CORECXXFLAGS += -fno-rtti -O0 -g0 -Werror
117   HEADER = std-header
118   DBGOK=1
119 endif
120 FOOTER = finishmessage
121
122 MAKEFLAGS += --no-print-directory
123
124 SOURCEPATH = $(shell pwd)
125
126 ifndef INSPIRCD_VERBOSE
127   MAKEFLAGS += --silent
128 endif
129
130 # Append any flags set in the environment after the base flags so
131 # that they can be overridden if necessary.
132 CORECXXFLAGS += $(CPPFLAGS) $(CXXFLAGS)
133 CORELDFLAGS += $(LDFLAGS)
134 PICLDFLAGS += $(LDFLAGS)
135
136 export BUILDPATH
137 export CORECXXFLAGS
138 export CORELDFLAGS
139 export CXX
140 export INSPIRCD_VERBOSE
141 export LDLIBS
142 export PICLDFLAGS
143 export SOCKETENGINE
144 export SOURCEPATH
145
146 # Default target
147 TARGET = all
148
149 ifdef INSPIRCD_TARGET
150     HEADER = mod-header
151     FOOTER = mod-footer
152     TARGET = $(INSPIRCD_TARGET)
153 endif
154
155 ifeq ($(DBGOK), 0)
156   HEADER = unknown-debug-level
157 endif
158
159 all: $(FOOTER)
160
161 target: $(HEADER)
162         $(MAKEENV) perl make/calcdep.pl
163         cd "$(BUILDPATH)"; $(MAKEENV) $(MAKE) -f real.mk $(TARGET)
164
165 debug:
166         @${MAKE} INSPIRCD_DEBUG=1 all
167
168 debug-header:
169         @echo "*************************************"
170         @echo "*    BUILDING WITH DEBUG SYMBOLS    *"
171         @echo "*                                   *"
172         @echo "*   This will take a *long* time.   *"
173         @echo "*  Please be aware that this build  *"
174         @echo "*  will consume a very large amount *"
175         @echo "*  of disk space (~350MB), and may  *"
176         @echo "*  run slower. Use the debug build  *"
177         @echo "*  for module development or if you *"
178         @echo "*    are experiencing problems.     *"
179         @echo "*                                   *"
180         @echo "*************************************"
181
182 mod-header:
183         @echo 'Building specific targets:'
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 docs at      *"
195         @echo "*     https://docs.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         @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(BASE)
210         @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(BINPATH)
211         @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(CONPATH)
212         @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(DATPATH)
213         @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(EXAPATH)/services
214         @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(EXAPATH)/sql
215         @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(LOGPATH)
216         @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(MANPATH)
217         @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(MODPATH)
218         @-$(INSTALL) -d -g @GID@ -o @UID@ -m $(INSTMODE_DIR) $(SCRPATH)
219         -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_BIN) "$(BUILDPATH)/bin/inspircd" $(BINPATH)
220         -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_BIN) "$(BUILDPATH)/modules/"*.so $(MODPATH)
221         -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_BIN) @CONFIGURE_DIRECTORY@/inspircd $(SCRPATH) 2>/dev/null
222 ifeq ($(SYSTEM), darwin)
223         -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_BIN) @CONFIGURE_DIRECTORY@/org.inspircd.plist $(SCRPATH) 2>/dev/null
224 endif
225 ifeq ($(SYSTEM), linux)
226         -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/inspircd.service $(SCRPATH) 2>/dev/null
227 endif
228         -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/inspircd.1 $(MANPATH) 2>/dev/null
229         -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) @CONFIGURE_DIRECTORY@/inspircd-genssl.1 $(MANPATH) 2>/dev/null
230         -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_BIN) tools/genssl $(BINPATH)/inspircd-genssl 2>/dev/null
231         -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) docs/conf/*.example $(EXAPATH)
232         -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) docs/conf/services/*.example $(EXAPATH)/services
233         -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_TXT) docs/sql/*.sql $(EXAPATH)/sql
234         -$(INSTALL) -g @GID@ -o @UID@ -m $(INSTMODE_PRV) *.pem $(CONPATH) 2>/dev/null
235         @echo ""
236         @echo "*************************************"
237         @echo "*        INSTALL COMPLETE!          *"
238         @echo "*************************************"
239         @echo 'Paths:'
240         @echo '  Base install:' $(BASE)
241         @echo '  Configuration:' $(CONPATH)
242         @echo '  Binaries:' $(BINPATH)
243         @echo '  Modules:' $(MODPATH)
244         @echo '  Data:' $(DATPATH)
245         @echo 'To start the ircd, run:' $(SCRPATH)/inspircd start
246         @echo 'Remember to create your config file:' $(CONPATH)/inspircd.conf
247         @echo 'Examples are available at:' $(EXAPATH)
248
249 GNUmakefile: make/template/main.mk src/version.sh configure @CONFIGURE_CACHE_FILE@
250         ./configure --update
251
252 clean:
253         @echo Cleaning...
254         -rm -f "$(BUILDPATH)/bin/inspircd" "$(BUILDPATH)/include" "$(BUILDPATH)/real.mk"
255         -rm -rf "$(BUILDPATH)/obj" "$(BUILDPATH)/modules"
256         @-rmdir "$(BUILDPATH)/bin" 2>/dev/null
257         @-rmdir "$(BUILDPATH)" 2>/dev/null
258         @echo Completed.
259
260 deinstall:
261         -rm -f $(BINPATH)/inspircd
262         -rm -rf $(CONPATH)/examples
263         -rm -f $(MANPATH)/inspircd.1
264         -rm -f $(MANPATH)/inspircd-genssl.1
265         -rm -f $(MODPATH)/m_*.so
266         -rm -f $(MODPATH)/core_*.so
267         -rm -f $(SCRPATH)/inspircd.service
268         -rm -f $(SCRPATH)/org.inspircd.plist
269
270 configureclean:
271         -rm -f Makefile
272         rm -f GNUmakefile
273         rm -f include/config.h
274         rm -rf @CONFIGURE_DIRECTORY@
275
276 distclean: clean configureclean
277         -rm -rf "$(SOURCEPATH)/run"
278         find "$(SOURCEPATH)/src/modules" -type l | xargs rm -f
279
280 help:
281         @echo 'InspIRCd Makefile'
282         @echo ''
283         @echo 'Use: ${MAKE} [flags] [targets]'
284         @echo ''
285         @echo 'Flags:'
286         @echo ' INSPIRCD_VERBOSE=1  Show the full command being executed instead of "BUILD: dns.cpp"'
287         @echo ' INSPIRCD_DEBUG=1    Enable debug build, for module development or crash tracing'
288         @echo ' INSPIRCD_DEBUG=2    Enable debug build with optimizations, for detailed backtraces'
289         @echo ' INSPIRCD_DEBUG=3    Enable fast build with no optimisations or symbols, for Travis CI'
290         @echo ' DESTDIR=            Specify a destination root directory (for tarball creation)'
291         @echo ' -j <N>              Run a parallel build using N jobs'
292         @echo ''
293         @echo 'Targets:'
294         @echo ' all       Complete build of InspIRCd, without installing (default)'
295         @echo ' install   Build and install InspIRCd to the directory chosen in ./configure'
296         @echo '           Currently installs to ${BASE}'
297         @echo ' debug     Compile a debug build. Equivalent to "make D=1 all"'
298         @echo ''
299         @echo ' INSPIRCD_TARGET=target  Builds a user-specified target, such as "inspircd" or "core_dns"'
300         @echo '                         Multiple targets may be separated by a space'
301         @echo ''
302         @echo ' clean     Cleans object files produced by the compile'
303         @echo ' distclean Cleans all generated files (build, configure, run, etc)'
304         @echo ' deinstall Removes the files created by "make install"'
305         @echo
306
307 .NOTPARALLEL:
308
309 .PHONY: all target debug debug-header mod-header mod-footer std-header finishmessage install clean deinstall configureclean help