forked from sems-server/sems
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile.defs
375 lines (304 loc) · 9.09 KB
/
Makefile.defs
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
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
ifeq ($(makefile_defs),"1")
else
makefile_defs="1"
export makefile_defs
GIT := $(shell which git)
ifneq ($(GIT),)
SCM_REV := $(shell if git --help describe |grep dirty 2>&1 >/dev/null ; \
then git describe --always --dirty 2>/dev/null; \
else git describe --always 2>/dev/null; fi)
endif
#version number
VERSION = 1
PATCHLEVEL = 7
SUBLEVEL = 0
ifneq ($(SCM_REV),)
RELEASE := $(SCM_REV)
else
REL_VERSION := $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)
RELEASE := $(REL_VERSION)$(EXTRAVERSION)
endif
APP_NAME ?= sems
SYSTEM_SAMPLECLOCK_RATE ?= 32000LL
CPPFLAGS += -D_DEBUG \
-D_THREAD_SAFE -D_REENTRANT \
-DSEMS_VERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"'\
-DOS='"$(OS)"' \
-DSYSTEM_SAMPLECLOCK_RATE=$(SYSTEM_SAMPLECLOCK_RATE) \
-DSEMS_APP_NAME='"$(APP_NAME)"'
# -DSUPPORT_IPV6 \
# -DNO_THREADID_LOG \
# -DLOG_PRETTY_FUNCTION \
# -DLOG_LOC_DATA_ATEND
# compile with session thread pool support?
# use this for very high concurrent call count
# applications (e.g. for signaling only)
# if compiled with thread pool, there will be a
# thread pool of configurable size processing the
# signaling and application logic of the calls.
# if compiled without thread pool support, every
# session will have its own thread.
#
#USE_THREADPOOL = yes
# compile with spandsp DTMF detection? see soft-switch.org
# this needs a fairly new version of spandsp - tested with 0.0.4pre11
# will not work with spandsp 0.0.2 .
# (which means that current debian and gentoo packages don't work)
#
#USE_SPANDSP = yes
# statically link spandsp library?
# (might need adjusting spandsp lib path LIBSPANDSP_LDIR - may be /usr/lib)
#LIBSPANDSP_STATIC = yes
#LIBSPANDSP_LDIR = /usr/local/lib/
# compile with sample rate conversion from secret rabbit code?
# (see http://www.mega-nerd.com/SRC/)
#
#USE_LIBSAMPLERATE = yes
# compile with internal resampler?
#
#
USE_INTERNAL_RESAMPLER = yes
#
# ZRTP support? (see zfoneproject.com)
#WITH_ZRTP = yes
#
# Disable the ability to run sems as daemon
#DISABLE_DAEMON_MODE = yes
#
# exclude some modules from compilation?
# e.g. python modules:
exclude_core_modules = g729 silk
#exclude_apps_modules = py_sems ivr mailbox pin_collect conf_auth mp3 examples
# build in support for monitoring?
#
#
USE_MONITORING=yes
# Support for long debug messages? (useful for debugging SIP messages' contents)
#
# disable for slight performance gain
LONG_DEBUG_MESSAGE=yes
# Is this a debug build or not?
debug=no
# Propagate all unparsed SIP headers into AmSipReply. Disabled by default
# because only special applications might need this and it brings higher memory
# demands and affects performance.
#PROPAGATE_UNPARSED_REPLY_HEADERS=no
################### end of configuration section #######################
LDFLAGS += -lm
GETOS=$(COREPATH)/compat/getos
GETARCH=$(COREPATH)/compat/getarch
OS := $(shell if [ -f $(GETOS) ] ; then $(GETOS); else $(CC) $(EXTRA_CFLAGS) -o $(GETOS) $(GETOS).c && $(GETOS); fi)
ARCH := $(shell if [ -f $(GETARCH) ] ; then $(GETARCH); else $(CC) $(EXTRA_CFLAGS) -o $(GETARCH) $(GETARCH).c && $(GETARCH); fi)
ifdef USE_THREADPOOL
CPPFLAGS += -DSESSION_THREADPOOL
endif
ifndef USE_SPANDSP
exclude_core_modules += g722
endif
ifdef USE_MONITORING
CPPFLAGS += -DUSE_MONITORING
endif
ifndef LONG_DEBUG_MESSAGE
CPPFLAGS += -DLOG_BUFFER_LEN=2048
endif
ifeq ($(PROPAGATE_UNPARSED_REPLY_HEADERS),yes)
CPPFLAGS += -DPROPAGATE_UNPARSED_REPLY_HEADERS
endif
ifeq ($(DISABLE_DAEMON_MODE),yes)
CPPFLAGS += -DDISABLE_DAEMON_MODE
endif
# Additions for Solaris support.
ifeq ($(OS),solaris)
CPPFLAGS += -DHAVE_SYS_SOCKIO_H -DBSD_COMP -fPIC -include compat/solaris.h
CFLAGS += -DHAVE_SYS_SOCKIO_H -DBSD_COMP -fPIC -include compat/solaris.h
# For nanosleep.
LDFLAGS += -lrt
# For inet_aton.
LDFLAGS += -lresolv
# I don't have libspeex installed.
# binrpcctrl does some really weird header stuff that doesn't work.
exclude_core_modules += binrpcctrl ilbc speex
endif
# fix sparc -> sparc64
ifeq ($(ARCH),sparc)
ifeq ($(shell uname -m),sun4u)
ARCH := sparc64
endif
endif
# need OS specific for this ?
CXX = g++
CC = gcc
LD = $(CC)
CXXFLAGS += -Wall -Wno-reorder -Wno-unused -fPIC -std=c++11 -g $(EXTRA_CXXFLAGS)
CFLAGS += -Wall -fPIC -g $(EXTRA_CFLAGS)
# only optimize if releasing, as it slows down the build process
ifneq ($(debug),yes)
CXXFLAGS += -O2
CFLAGS += -O2
endif
ifeq ($(DEBUG_PLAYOUT), yes)
CPPFLAGS += -DDEBUG_PLAYOUTBUF
endif
ifdef WITH_ZRTP
CPPFLAGS += -DWITH_ZRTP \
-DBUILD_ZRTP_MUTEXES \
-DBUILD_DEFAULT_CACHE -DBUILD_DEFAULT_TIMER -DUNIX -DBUILD_ZRTP_MUTEXES \
-I/usr/local/include/zrtp
endif
TARGET=
LIB_LDFLAGS = -shared
ifeq ($(LD), clang)
LDFLAG_DYN=
LDFLAG_PTHREAD=
else
LDFLAG_DYN = -rdynamic
LDFLAG_PTHREAD = -lpthread
endif
ifeq ($(OS), linux)
LDFLAGS += -ldl $(LDFLAG_DYN) $(LDFLAG_PTHREAD)
CPPFLAGS += -DPROPAGATE_COREDUMP_SETTINGS
else
ifeq ($(OS), freebsd)
LDFLAGS += $(LDFLAG_DYN) $(LDFLAG_PTHREAD)
else
ifeq ($(OS), openbsd)
LDFLAGS += $(LDFLAG_DYN) $(LDFLAG_PTHREAD)
else
ifeq ($(OS), netbsd)
LDFLAGS += $(LDFLAG_DYN) $(LDFLAG_PTHREAD)
else
ifeq ($(OS), macosx)
LDFLAGS += $(LDFLAG_DYN) $(LDFLAG_PTHREAD)
LIB_LDFLAGS = -flat_namespace -undefined suppress -bundle
CXXFLAGS += -fno-common
CFLAGS += -fno-common
#necessary for sa_len|ss_len|sin_len
# may be needed on other *BSD
CPPFLAGS += -DBSD44SOCKETS
# add the DarwinPorts directory
ifneq ($(ARCH), iphone)
CPPFLAGS += -D__DARWIN_UNIX03
CPPFLAGS += -I /opt/local/include
LDFLAGS += -L/opt/local/lib
endif
else
ifeq ($(OS), solaris)
LDFLAGS+= -fPIC -ldl -lsocket -lnsl $(LDFLAG_PTHREAD)
TARGET=solaris
# These don't build on Solaris because of missing Python, invalid make args, or other.
exclude_app_modules += py_sems py_comp pin_collect mailbox ivr diameter_client conf_auth mp3 cc_acc_xmlrpc xmlrpc2di
endif
endif
endif
endif
endif
endif
LDFLAGS += -lstdc++
ifeq ($(ARCH),iphone)
LDFLAGS += -lgcc_eh
endif
ifdef WITH_ZRTP
LDFLAGS +=-lzrtp -lbn
endif
LIB_LDFLAGS += $(LDFLAGS)
# install path is $(basedir) $(prefix)
# example:
# creating a bin. archive in /tmp, which unpacks in /usr/local
# basedir=/tmp
# prefix=/usr/local
DESTDIR ?=
PREFIX ?= /usr/local
prefix ?= $(PREFIX)
BASEDIR ?=
basedir = $(BASEDIR)
# install prefixes for various stuff
cfg_prefix = $(basedir)$(prefix)
bin_prefix = $(basedir)$(prefix)
modules_prefix = $(basedir)$(prefix)
doc_prefix = $(basedir)$(prefix)
audio_prefix = $(basedir)$(prefix)
lib_prefix = $(basedir)$(prefix)
# dirs
cfg_dir = etc/$(APP_NAME)/
bin_dir = sbin/
modules_dir = lib/$(APP_NAME)/plug-in/
audio_dir = lib/$(APP_NAME)/audio/
lib_dir = lib/$(APP_NAME)/
ifeq ($(OS), linux)
doc_dir = share/doc/$(APP_NAME)/
man_dir = share/man/
else
ifeq ($(OS), freebsd)
doc_dir = share/doc/$(APP_NAME)/
man_dir = man/
else
ifeq ($(OS), openbsd)
doc_dir = share/doc/$(APP_NAME)/
man_dir = man/
else
ifeq ($(OS), netbsd)
doc_dir = share/doc/$(APP_NAME)
man_dir = man/
else
doc_dir = doc/$(APP_NAME)/
man_dir = man/
endif
endif
endif
endif
# target dirs for various stuff
bin_target = $(prefix)/$(bin_dir)
cfg_target ?= $(prefix)/$(cfg_dir)
app_cfg_target = $(cfg_target)etc/
modules_target = $(prefix)/$(modules_dir)
audio_target = $(prefix)/$(audio_dir)
lib_target = $(prefix)/$(lib_dir)
ifeq ($(OS), solaris)
#use GNU versions
INSTALL ?= ginstall
TAR ?= gtar
else
INSTALL ?= install
TAR ?= tar
endif
INSTALL_TOUCH = touch # used to create the file first (good to
# make solaris install work)
INSTALL_CFG = $(INSTALL) -m 644
INSTALL_BIN = $(INSTALL) -m 755
INSTALL_MODULES = $(INSTALL) -m 755
INSTALL_DOC = $(INSTALL) -m 644
INSTALL_AUDIO = $(INSTALL) -m 644
#export stuff to sub-makes
export REL_VERSION RELEASE OS ARCH
export CPPFLAGS CXXFLAGS LDFLAGS CFLAGS LIB_LDFLAGS
export CXX CC LD
export DESTDIR PREFIX prefix basedir
export cfg_prefix bin_prefix modules_prefix doc_prefix audio_prefix lib_prefix
export cfg_dir bin_dir modules_dir audio_dir lib_dir doc_dir man_dir
export bin_target cfg_target app_cfg_target modules_target audio_target lib_target
export INSTALL TAR INSTALL_TOUCH INSTALL_CFG INSTALL_BIN INSTALL_MODULES INSTALL_DOC INSTALL_AUDIO
export APP_NAME
export USE_SPANDSP LIBSPANDSP_STATIC LIBSPANDSP_LDIR
export USE_LIBSAMPLERATE USE_INTERNAL_RESAMPLER
export WITH_ZRTP
export USE_MONITORING
export exclude_core_modules exclude_app_modules
endif # ifeq ($(makefile_defs, 1)
mk-install-dirs: $(DESTDIR)$(cfg_target) \
$(DESTDIR)$(app_cfg_target) \
$(DESTDIR)$(bin_prefix)/$(bin_dir) \
$(DESTDIR)$(modules_prefix)/$(modules_dir) \
$(DESTDIR)$(audio_prefix)/$(audio_dir) \
$(DESTDIR)$(doc_prefix)/$(doc_dir)
$(DESTDIR)$(cfg_target):
mkdir -p $(DESTDIR)$(cfg_target)
$(DESTDIR)$(app_cfg_target):
mkdir -p $(DESTDIR)$(app_cfg_target)
$(DESTDIR)$(bin_prefix)/$(bin_dir):
mkdir -p $(DESTDIR)$(bin_prefix)/$(bin_dir)
$(DESTDIR)$(modules_prefix)/$(modules_dir):
mkdir -p $(DESTDIR)$(modules_prefix)/$(modules_dir)
$(DESTDIR)$(audio_prefix)/$(audio_dir):
mkdir -p $(DESTDIR)$(audio_prefix)/$(audio_dir)
$(DESTDIR)$(doc_prefix)/$(doc_dir):
mkdir -p $(DESTDIR)$(doc_prefix)/$(doc_dir)