summaryrefslogtreecommitdiff
path: root/make/template/main.mk
blob: f3f2c3cc5105ab6c1ef0dbf67092473b3048ddcf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
%target GNUmakefile
#
# InspIRCd -- Internet Relay Chat Daemon
#
#   Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
#
# This file is part of InspIRCd.  InspIRCd is free software: you can
# redistribute it and/or modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation, version 2.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#


#
#               InspIRCd Main Makefile
#
# This file is automagically generated by configure, from
# make/template/main.mk. Any changes made to the generated
#     files will go away whenever it is regenerated!
#
# Please do not edit unless you know what you're doing.
#


CXX = @CXX@
COMPILER = @COMPILER_NAME@
SYSTEM = @SYSTEM_NAME@
BUILDPATH ?= $(PWD)/build
SOCKETENGINE = @SOCKETENGINE@
CORECXXFLAGS = -fPIC -fvisibility=hidden -fvisibility-inlines-hidden -pipe -Iinclude -Wall -Wextra -Wfatal-errors -Wno-unused-parameter -Wshadow
LDLIBS = -lstdc++
CORELDFLAGS = -rdynamic -L.
PICLDFLAGS = -fPIC -shared -rdynamic
BASE = "$(DESTDIR)@BASE_DIR@"
CONPATH = "$(DESTDIR)@CONFIG_DIR@"
MANPATH = "$(DESTDIR)@MANUAL_DIR@"
MODPATH = "$(DESTDIR)@MODULE_DIR@"
LOGPATH = "$(DESTDIR)@LOG_DIR@"
DATPATH = "$(DESTDIR)@DATA_DIR@"
BINPATH = "$(DESTDIR)@BINARY_DIR@"
SCRPATH = "$(DESTDIR)@SCRIPT_DIR@"
INSTALL = install
INSTUID = @UID@
INSTMODE_DIR = 0750
INSTMODE_BIN = 0750
INSTMODE_LIB = 0640

ifneq ($(COMPILER), ICC)
  CORECXXFLAGS += -Woverloaded-virtual -Wshadow
ifneq ($(SYSTEM), openbsd)
    CORECXXFLAGS += -pedantic -Wformat=2 -Wmissing-format-attribute
endif
endif

ifneq ($(SYSTEM), darwin)
  LDLIBS += -pthread
endif

ifeq ($(SYSTEM), linux)
  LDLIBS += -ldl -lrt
endif
ifeq ($(SYSTEM), gnukfreebsd)
  LDLIBS += -ldl -lrt
endif
ifeq ($(SYSTEM), gnu)
  LDLIBS += -ldl -lrt
endif
ifeq ($(SYSTEM), solaris)
  LDLIBS += -lsocket -lnsl -lrt -lresolv
  INSTALL = ginstall
endif
ifeq ($(SYSTEM), darwin)
  LDLIBS += -ldl
  CORELDFLAGS = -dynamic -bind_at_load -L.
  PICLDFLAGS = -fPIC -shared -twolevel_namespace -undefined dynamic_lookup
endif
ifeq ($(SYSTEM), haiku)
  LDLIBS = -lnetwork -lstdc++
  CORELDFLAGS = -L.
  PICLDFLAGS = -fPIC -shared
endif

ifndef INSPIRCD_DEBUG
  INSPIRCD_DEBUG=0
endif

DBGOK=0
ifeq ($(INSPIRCD_DEBUG), 0)
  CORECXXFLAGS += -fno-rtti -O2
ifeq ($(COMPILER), GCC)
    CORECXXFLAGS += -g1
endif
  HEADER = std-header
  DBGOK=1
endif
ifeq ($(INSPIRCD_DEBUG), 1)
  CORECXXFLAGS += -O0 -g3 -Werror -DINSPIRCD_ENABLE_RTTI
  HEADER = debug-header
  DBGOK=1
endif
ifeq ($(INSPIRCD_DEBUG), 2)
  CORECXXFLAGS += -fno-rtti -O2 -g3
  HEADER = debug-header
  DBGOK=1
endif
FOOTER = finishmessage

MAKEFLAGS += --no-print-directory

SOURCEPATH = $(shell /bin/pwd)

ifndef INSPIRCD_VERBOSE
  MAKEFLAGS += --silent
endif

ifdef INSPIRCD_STATIC
  CORECXXFLAGS += -DINSPIRCD_STATIC
endif

# Append any flags set in the environment after the base flags so
# that they can be overridden if necessary.
CORECXXFLAGS += $(CPPFLAGS) $(CXXFLAGS)
CORELDFLAGS += $(LDFLAGS)
PICLDFLAGS += $(LDFLAGS)

export BUILDPATH
export CORECXXFLAGS
export CORELDFLAGS
export CXX
export INSPIRCD_STATIC
export INSPIRCD_VERBOSE
export LDLIBS
export PICLDFLAGS
export SOCKETENGINE
export SOURCEPATH

# Default target
TARGET = all

ifdef INSPIRCD_TARGET
    HEADER = mod-header
    FOOTER = mod-footer
    TARGET = $(INSPIRCD_TARGET)
endif

ifeq ($(DBGOK), 0)
  HEADER = unknown-debug-level
endif

all: $(FOOTER)

target: $(HEADER)
	$(MAKEENV) perl make/calcdep.pl
	cd "$(BUILDPATH)"; $(MAKEENV) $(MAKE) -f real.mk $(TARGET)

debug:
	@${MAKE} INSPIRCD_DEBUG=1 all

debug-header:
	@echo "*************************************"
	@echo "*    BUILDING WITH DEBUG SYMBOLS    *"
	@echo "*                                   *"
	@echo "*   This will take a *long* time.   *"
	@echo "*  Please be aware that this build  *"
	@echo "*  will consume a very large amount *"
	@echo "*  of disk space (~350MB), and may  *"
	@echo "*  run slower. Use the debug build  *"
	@echo "*  for module development or if you *"
	@echo "*    are experiencing problems.     *"
	@echo "*                                   *"
	@echo "*************************************"

mod-header:
ifdef INSPIRCD_STATIC
	@echo 'Cannot build specific targets in pure-static build'
	@exit 1
endif
	@echo 'Building specific targets:'

mod-footer: target
	@echo 'To install, copy $(BUILDPATH)/$(TARGET) to $(MODPATH)'
	@echo 'Or, run "make install"'

std-header:
	@echo "*************************************"
	@echo "*       BUILDING INSPIRCD           *"
	@echo "*                                   *"
	@echo "*   This will take a *long* time.   *"
	@echo "*     Why not read our wiki at      *"
	@echo "*     http://wiki.inspircd.org      *"
	@echo "*  while you wait for make to run?  *"
	@echo "*************************************"

finishmessage: target
	@echo ""
	@echo "*************************************"
	@echo "*        BUILD COMPLETE!            *"
	@echo "*                                   *"
	@echo "*   To install InspIRCd, type:      *"
	@echo "*         make install              *"
	@echo "*************************************"

install: target
	@if [ "$(INSTUID)" = 0 -o "$(INSTUID)" = root ]; then \
		echo ""; \
		echo "Error: You must specify a non-root UID for the server"; \
		echo ""; \
		echo "If you are making a package, please specify using ./configure --uid"; \
		echo "Otherwise, rerun using 'make INSTUID=irc install', where 'irc' is the user"; \
		echo "who will be running the ircd. You will also need to modify the start script."; \
		echo ""; \
		exit 1; \
	fi
	@-$(INSTALL) -d -o $(INSTUID) -m $(INSTMODE_DIR) $(BASE)
	@-$(INSTALL) -d -o $(INSTUID) -m $(INSTMODE_DIR) $(DATPATH)
	@-$(INSTALL) -d -o $(INSTUID) -m $(INSTMODE_DIR) $(LOGPATH)
	@-$(INSTALL) -d -m $(INSTMODE_DIR) $(BINPATH)
	@-$(INSTALL) -d -m $(INSTMODE_DIR) $(CONPATH)/examples/services
	@-$(INSTALL) -d -m $(INSTMODE_DIR) $(MANPATH)
	@-$(INSTALL) -d -m $(INSTMODE_DIR) $(MODPATH)
	@-$(INSTALL) -d -m $(INSTMODE_DIR) $(SCRPATH)
	[ "$(BUILDPATH)/bin/" -ef $(BINPATH) ] || $(INSTALL) -m $(INSTMODE_BIN) "$(BUILDPATH)/bin/inspircd" $(BINPATH)
ifndef INSPIRCD_STATIC
	[ "$(BUILDPATH)/modules/" -ef $(MODPATH) ] || $(INSTALL) -m $(INSTMODE_LIB) "$(BUILDPATH)/modules/"*.so $(MODPATH)
endif
	-$(INSTALL) -m $(INSTMODE_BIN) @CONFIGURE_DIRECTORY@/inspircd $(SCRPATH) 2>/dev/null
	-$(INSTALL) -m $(INSTMODE_LIB) .gdbargs $(SCRPATH)/.gdbargs 2>/dev/null
ifeq ($(SYSTEM), darwin)
	-$(INSTALL) -m $(INSTMODE_BIN) @CONFIGURE_DIRECTORY@/org.inspircd.plist $(SCRPATH) 2>/dev/null
endif
ifeq ($(SYSTEM), linux)
	-$(INSTALL) -m $(INSTMODE_LIB) @CONFIGURE_DIRECTORY@/inspircd.service $(SCRPATH) 2>/dev/null
endif
	-$(INSTALL) -m $(INSTMODE_LIB) @CONFIGURE_DIRECTORY@/inspircd.1 $(MANPATH) 2>/dev/null
	-$(INSTALL) -m $(INSTMODE_LIB) @CONFIGURE_DIRECTORY@/inspircd-genssl.1 $(MANPATH) 2>/dev/null
	-$(INSTALL) -m $(INSTMODE_BIN) tools/genssl $(BINPATH)/inspircd-genssl 2>/dev/null
	-$(INSTALL) -m $(INSTMODE_LIB) docs/conf/*.example $(CONPATH)/examples
	-$(INSTALL) -m $(INSTMODE_LIB) docs/conf/services/*.example $(CONPATH)/examples/services
	-$(INSTALL) -m $(INSTMODE_LIB) *.pem $(CONPATH) 2>/dev/null
	@echo ""
	@echo "*************************************"
	@echo "*        INSTALL COMPLETE!          *"
	@echo "*************************************"
	@echo 'Paths:'
	@echo '  Base install:' $(BASE)
	@echo '  Configuration:' $(CONPATH)
	@echo '  Binaries:' $(BINPATH)
	@echo '  Modules:' $(MODPATH)
	@echo '  Data:' $(DATPATH)
	@echo 'To start the ircd, run:' $(SCRPATH)/inspircd start
	@echo 'Remember to create your config file:' $(CONPATH)/inspircd.conf
	@echo 'Examples are available at:' $(CONPATH)/examples/

GNUmakefile: make/template/main.mk src/version.sh configure @CONFIGURE_CACHE_FILE@
	./configure --update

clean:
	@echo Cleaning...
	-rm -f "$(BUILDPATH)/bin/inspircd" "$(BUILDPATH)/include" "$(BUILDPATH)/real.mk"
	-rm -rf "$(BUILDPATH)/obj" "$(BUILDPATH)/modules"
	@-rmdir "$(BUILDPATH)/bin" 2>/dev/null
	@-rmdir "$(BUILDPATH)" 2>/dev/null
	@echo Completed.

deinstall:
	-rm -f $(BINPATH)/inspircd
	-rm -rf $(CONPATH)/examples
	-rm -f $(MANPATH)/inspircd.1
	-rm -f $(MANPATH)/inspircd-genssl.1
	-rm -f $(MODPATH)/m_*.so
	-rm -f $(MODPATH)/core_*.so
	-rm -f $(SCRPATH)/.gdbargs
	-rm -f $(SCRPATH)/inspircd.service
	-rm -f $(SCRPATH)/org.inspircd.plist

configureclean:
	rm -f .gdbargs
	-rm -f Makefile
	rm -f GNUmakefile
	rm -f include/config.h
	rm -rf @CONFIGURE_DIRECTORY@

distclean: clean configureclean
	-rm -rf "$(SOURCEPATH)/run"
	find "$(SOURCEPATH)/src/modules" -type l | xargs rm -f

help:
	@echo 'InspIRCd Makefile'
	@echo ''
	@echo 'Use: ${MAKE} [flags] [targets]'
	@echo ''
	@echo 'Flags:'
	@echo ' INSPIRCD_VERBOSE=1  Show the full command being executed instead of "BUILD: dns.cpp"'
	@echo ' INSPIRCD_DEBUG=1    Enable debug build, for module development or crash tracing'
	@echo ' INSPIRCD_DEBUG=2    Enable debug build with optimizations, for detailed backtraces'
	@echo ' DESTDIR=            Specify a destination root directory (for tarball creation)'
	@echo ' -j <N>              Run a parallel build using N jobs'
	@echo ''
	@echo 'Targets:'
	@echo ' all       Complete build of InspIRCd, without installing (default)'
	@echo ' install   Build and install InspIRCd to the directory chosen in ./configure'
	@echo '           Currently installs to ${BASE}'
	@echo ' debug     Compile a debug build. Equivalent to "make D=1 all"'
	@echo ''
	@echo ' INSPIRCD_TARGET=target  Builds a user-specified target, such as "inspircd" or "core_dns"'
	@echo '                         Multiple targets may be separated by a space'
	@echo ''
	@echo ' clean     Cleans object files produced by the compile'
	@echo ' distclean Cleans all generated files (build, configure, run, etc)'
	@echo ' deinstall Removes the files created by "make install"'
	@echo

.NOTPARALLEL:

.PHONY: all target debug debug-header mod-header mod-footer std-header finishmessage install clean deinstall configureclean help