Browse code

core, lib, modules: restructured source code tree

- new folder src/ to hold the source code for main project applications
- main.c is in src/
- all core files are subfolder are in src/core/
- modules are in src/modules/
- libs are in src/lib/
- application Makefiles are in src/
- application binary is built in src/ (src/kamailio)

Daniel-Constantin Mierla authored on 07/12/2016 11:03:51
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,2083 +0,0 @@
1
-# Kamailio build system
2
-
3
-#
4
-# makefile defs (CC, LD,a.s.o)
5
-#
6
-# Environment variables:
7
-#   PREFIX, LOCALBASE, BASEDIR
8
-#   INSTALL, TAR , CC, LEX, YACC,
9
-#   CPUTYPE, CC_EXTRA_OPTS, LD_EXTRA_OPTS
10
-#   exclude_modules, skip_modules, include_modules
11
-#   extra_defs
12
-#
13
-
14
-# default silent, unless Q= 0|no|off|verbose|noisy
15
-quiet?=$(if $(filter 0 no off verbose noisy,$(Q)),verbose,silent)
16
-
17
-# check if already included/exported
18
-
19
-# used for sanity checks for Makefile.defs inclusion (!= makefile_defs which
20
-# specifies if we have a set of valid defs)
21
-override makefile_defs_included:=1
22
-ifeq ($(makefile_defs),1)
23
-ifeq ($(quiet),verbose)
24
-$(info Makefile.defs defs skipped)
25
-endif # verbose
26
-
27
-else
28
-
29
-ifeq (,$(main_makefile))
30
-# hack to automatically use config.mak in all the modules, without
31
-# changing the current module makefiles (which all include Makefile.defs):
32
-# if not called from the main makefile (module, lib or ut):
33
-# include config.mak, but if not present or incomplete (makefile_defs!=1)
34
-# don't export the vars)
35
-COREPATH?= ../..
36
-include $(COREPATH)/config.mak
37
-ifeq ($(quiet),verbose)
38
-$(info config.mak included)
39
-endif # verbose
40
-# config.mak should set makefile_defs if complete
41
-export makefile_defs
42
-
43
-else
44
-override makefile_defs=1
45
-export makefile_defs
46
-
47
-
48
-ifeq ($(quiet),verbose)
49
-$(info normal Makefile.defs exec)
50
-endif # verbose
51
-
52
--include Makefile.vars
53
-
54
-# usage: $(call set_if_empty,VAR,value)
55
-set_if_empty=$(if $($(1)),,$(eval override $(1)=$(2)))
56
-
57
-# flavour: sip-router, ser or kamailio
58
-$(call	set_if_empty,FLAVOUR,kamailio)
59
-
60
-#prefix for various configs and scripts
61
-#config name/name-prefix for distributed configs
62
-CFG_NAME?=sip-router
63
-#config name/name-prefix for distributed scripts
64
-SCR_NAME=sip-router
65
-#name in source tree
66
-SRC_NAME=sip-router
67
-
68
-ifeq ($(FLAVOUR),sip-router)
69
-# main binary name
70
-MAIN_NAME=ser
71
-else ifeq ($(FLAVOUR),ser)
72
-# main binary name
73
-MAIN_NAME=ser
74
-else ifeq ($(FLAVOUR),kamailio)
75
-# main binary name
76
-MAIN_NAME=kamailio
77
-# use kamailio config
78
-CFG_NAME=kamailio
79
-# kamailio statistics on
80
-KMSTATS ?= 1
81
-# fast malloc statistics on
82
-FMSTATS ?= 1
83
-else # unknown:
84
-# main binary name
85
-MAIN_NAME=kamailio
86
-endif
87
-
88
-# application server support on
89
-WITHAS ?= 1
90
-# enable core hooks for SCTP
91
-SCTP ?= 1
92
-# enable raw sockets
93
-RAW_SOCKS ?= yes
94
-ifeq ($(RAW_SOCKS),1)
95
-	RAW_SOCKS = yes
96
-endif
97
-
98
-# what to install
99
-INSTALL_FLAVOUR=$(FLAVOUR)
100
-
101
-# version number
102
-VERSION = 5
103
-PATCHLEVEL = 0
104
-SUBLEVEL =  0
105
-EXTRAVERSION = -dev7
106
-
107
-# memory manager switcher
108
-# 0 - f_malloc (fast malloc)
109
-# 1 - q_malloc (quick malloc)
110
-# 2 - tlsf_malloc (O(1) malloc and free)
111
-MEMMNG ?= 0
112
-# memory debugger switcher
113
-# 0 - off (no-debug mode)
114
-# 1 - on (debug mode)
115
-MEMDBG ?= 1
116
-
117
-SER_VER = $(shell expr $(VERSION) \* 1000000 + $(PATCHLEVEL) \* 1000 + \
118
-			$(SUBLEVEL) )
119
-RELEASE:=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
120
-OS := $(shell uname -s | sed -e s/SunOS/solaris/ -e s/CYGWIN.*/cygwin/ \
121
-		 | tr "[A-Z]" "[a-z]" | tr "/" "_")
122
-
123
-ifeq ($(OS),solaris)
124
-	GETARCH=isainfo -n
125
-ifeq ($(GETARCH),)
126
-	GETARCH=uname -p
127
-endif
128
-else
129
-	GETARCH=uname -m
130
-endif
131
-
132
-HOST_ARCH := $(shell $(GETARCH) |sed -e s/i.86/i386/ -e s/sun4[uv]/sparc64/  \
133
-			-e s/armv[3-5].*/arm/  -e s/armv6.*/arm6/ \
134
-			-e "s/Power Macintosh/ppc/" \
135
-			-e "s/cobalt/mips2/" \
136
-			-e s/amd64/x86_64/ -e s/sparcv9/sparc64/ )
137
-# fix sparc -> sparc64
138
-ifeq ($(HOST_ARCH),sparc)
139
-	ifeq ($(shell uname -m),sun4u)
140
-		HOST_ARCH := sparc64
141
-	endif
142
-	ifeq ($(shell uname -m),sun4v)
143
-		HOST_ARCH := sparc64
144
-	endif
145
-endif
146
-
147
-OSREL := $(shell uname -r)
148
-# numerical version (good for comparisons: A.B.C => A*1000000+B*1000+C)
149
-OSREL_N:= $(shell echo $(OSREL) | sed -e 's/^[^0-9]*//' \
150
-		-e 's/^\([0-9][0-9]*\(\.[0-9][0-9]*\)*\).*$$/\1/g' | \
151
-		(IFS=. read A B C D; R=0; \
152
-		[ -n "$$A" ] && R=`expr $$R \* 1000 + $$A` && \
153
-		[ -n "$$B" ] && R=`expr $$R \* 1000 + $$B` && \
154
-		[ -n "$$C" ] && R=`expr $$R \* 1000 + $$C`; echo $$R ) )
155
-
156
-
157
-# TLS support
158
-CORE_TLS ?=
159
-# by default compile with tls hooks support (so that no ser recompile is
160
-#  needed before the tls module can be used)
161
-TLS_HOOKS=1
162
-ifeq ($(CORE_TLS), 1)
163
-	RELEASE:=$(RELEASE)-tls
164
-	TLS_HOOKS:=0
165
-endif
166
-ifeq ($(TLS_HOOKS), 1)
167
-#	RELEASE:=$(RELEASE)-tls
168
-endif
169
-
170
-# extra CC command line options (e.g  -march=athlon-mp)
171
-CC_EXTRA_OPTS ?=
172
-
173
-# extra LD command line options
174
-LD_EXTRA_OPTS ?=
175
-
176
-ifeq ($(OS), solaris)
177
-#use GNU versions
178
-INSTALL ?= ginstall
179
-TAR ?= gtar
180
-else
181
-INSTALL ?= install
182
-TAR ?= tar
183
-endif
184
-
185
-INSTALL_TOUCH = touch          # used to create the file first (good to
186
-                               #  make solaris install work)
187
-INSTALL_CFG = $(INSTALL) -m 644
188
-INSTALL_BIN = $(INSTALL) -m 755
189
-INSTALL_SCRIPT = $(INSTALL) -m 755
190
-INSTALL_MODULES = $(INSTALL) -m 755
191
-INSTALL_LIB = $(INSTALL) -m 755
192
-INSTALL_DOC = $(INSTALL) -m 644
193
-INSTALL_MAN = $(INSTALL) -m 644
194
-INSTALL_SHARE = $(INSTALL) -m 644
195
-
196
-#set some vars from the environment (and not make builtins)
197
-CC   := $(shell echo "$${CC}")
198
-LEX  := $(shell echo "$${LEX}")
199
-YACC := $(shell echo "$${YACC}")
200
-
201
-
202
-
203
-
204
-# find compiler name & version
205
-ifeq ($(CC),)
206
-	CC=gcc
207
-endif
208
-LD= $(CC)
209
-CC_LONGVER:=$(shell if  $(CC) -v 2>/dev/null; then \
210
-						$(CC) -v 2>&1 ;\
211
-					else \
212
-						$(CC) -V 2>&1 ; \
213
-					fi )
214
-CC_OPT ?= -O9
215
-MKTAGS=ctags
216
-
217
-#find-out the compiler's name
218
-
219
-ifneq (,$(findstring gcc, $(CC_LONGVER)))
220
-	CC_NAME=gcc
221
-	RPAREN=)
222
-	CC_VER:=$(word 1,$(CC)) $(shell $(CC) - --version|head -n 1|\
223
-				sed  -e 's/([^$(RPAREN)]*)//g' \
224
-					 -e 's/^.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/'\
225
-					 -e 's/^[^0-9].*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/')
226
-#	CC_VER:=$(word 1,$(CC)) $(shell $(CC) - --version|head -n 1|cut -d" " -f 3\
227
-#				|sed -e 's/^.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/'\
228
-#				 	 -e 's/^[^0-9].*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/')
229
-	# sed with POSIX.1 regex doesn't support |, + or ?
230
-	# (darwin, solaris ...) => this complicated expression
231
-	MKDEP=$(CC) -MM -MG
232
-	#transform gcc version into 2.9x or 3.0
233
-	CC_SHORTVER:=$(shell echo "$(CC_VER)" | cut -d" " -f 2| \
234
-				 sed -e 's/[^0-9]*-\(.*\)/\1/'| \
235
-				 sed -e 's/2\.9.*/2.9x/' \
236
-					-e 's/3\.[0-3]\..*/3.0/' \
237
-					-e 's/3\.[0-3]/3.0/' \
238
-					-e 's/3\.[4-9]\..*/3.4/' \
239
-					-e 's/3\.[4-9]/3.4/' \
240
-					-e 's/4\.[0-1]\..*/4.x/' \
241
-					-e 's/4\.[0-1]/4.x/' \
242
-					-e 's/4\.[2-4]\..*/4.2+/' \
243
-					-e 's/4\.[2-4]$$/4.2+/' \
244
-					-e 's/4\.[5-9]\..*/4.5+/' \
245
-					-e 's/4\.[5-9]$$/4.5+/' \
246
-					-e 's/5\.[0-9]\..*/5.0+/' \
247
-					-e 's/5\.[0-9]$$/5.0+/' \
248
-					-e 's/6\.[0-9]\..*/6.0+/' \
249
-					-e 's/6\.[0-9]$$/6.0+/')
250
-ifeq (,$(strip $(filter-out 3.0 3.4 4.x 4.2+ 4.5+ 5.0+ 6.0+,$(CC_SHORTVER))))
251
-	# dependencies can be generated on-the-fly while compiling *.c
252
-	CC_MKDEP_OPTS=-MMD -MP
253
-endif # 3.0 <= $(CC_SHORTVER) <= 4.x
254
-endif # gcc
255
-
256
-ifneq (, $(findstring Sun, $(CC_LONGVER)))
257
-	CC_NAME=suncc
258
-	CC_SHORTVER:=$(shell echo "$(CC_LONGVER)"|head -n 1| \
259
-					sed -e 's/.*\([0-9]\.[0-9]\).*/\1/g' )
260
-	CC_VER=$(CC) $(CC_SHORTVER)
261
-	MKDEP=$(CC) -xM1
262
-	CC_MKDEP_OPTS=-xMMD
263
-endif
264
-
265
-ifneq (, $(findstring Intel(R) C++ Compiler, $(CC_LONGVER)))
266
-	# very nice: gcc compatible
267
-	CC_NAME=icc
268
-	CC_FULLVER:=$(shell echo "$(CC_LONGVER)"|head -n 1| \
269
-					sed -e 's/.*Version \([0-9]\.[0-9]\.[0-9]*\).*/\1/g' )
270
-	CC_SHORTVER:=$(shell echo "$(CC_FULLVER)" | cut -d. -f1,2 )
271
-	CC_VER=$(CC) $(CC_FULLVER)
272
-	MKDEP=$(CC) -MM
273
-endif
274
-
275
-ifneq (, $(findstring clang, $(CC_LONGVER)))
276
-	#clang should be gcc compatible
277
-	CC_NAME=clang
278
-	CC_FULLVER:=$(shell echo "$(CC_LONGVER)" | head -n 1 |  sed -e 's/.*version \([0-9]\.[0-9]\).*/\1/g' )
279
-	CC_SHORTVER:=$(shell echo "$(CC_FULLVER)" | cut -d. -f1,2 )
280
-	CC_VER=$(CC) $(CC_FULLVER)
281
-	CC_OPT=-O3
282
-	MKDEP=$(CC) -MM
283
-endif
284
-
285
-ifeq (,$(CC_NAME))
286
-#not found
287
-	CC_NAME=$(CC)
288
-	CC_SHORTVER=unknown
289
-	CC_VER=unknown
290
-	MKDEP=gcc -MM
291
-$(warning	Unknown compiler $(CC)\; supported compilers: \
292
-			gcc, sun cc, intel icc )
293
-endif
294
-
295
-# ARCH detection
296
-# predefined compiler macros for different architectures
297
-# (see http://predef.sourceforge.net/prearch.html for a more complete list)
298
-i386_macros= i386 __i386__ __i486__ __i586__ __i686__ \
299
-			__i386 _M_IX86 __X86__ _X86_
300
-x86_64_macros= __amd64__ __amd64 __x86_64__ __x86_64 _M_X64
301
-
302
-sparc_macros= __sparc__ __sparc __sparcv8
303
-sparc64_macros= __sparcv9 __sparc_v9__
304
-
305
-arm_macros= __arm__ __thumb__
306
-arm6_macros= __ARM_ARCH_6__
307
-
308
-ppc_macros= __powerpc __powerpc__ __POWERPC__ __ppc__ _ARCH_PPC
309
-ppc64_macros= __ppc64__ _ARCH_PPC64
310
-
311
-mips_macros= __mips__ __mips _MIPS_ARCH_MIPS1
312
-mips2_macros= _MIPS_ISA_MIPS2 _MIPS_ISA_MIPS3 _MIPS_ISA_MIPS4 \
313
-			_MIPS_ARCH_MIPS2 _MIPS_ARCH_MIPS3 _MIPS_ARCH_MIPS4
314
-mips64_macros= _MIPS_ISA_MIPS64 _MIPS_ARCH_MIPS64
315
-
316
-alpha_macros= __alpha__ __alpha _M_ALPHA_
317
-
318
-ifeq ($(CC_NAME),gcc)
319
-#if gcc use gcc arch
320
-predef_macros:=$(shell $(CC) -dM -E -x c $(CC_EXTRA_OPTS) $(extra_defs) \
321
-					$(CFLAGS) /dev/null)
322
-
323
-ifneq ($(strip $(filter $(i386_macros), $(predef_macros))),)
324
-CC_ARCH=i386
325
-else ifneq ($(strip $(filter $(x86_64_macros), $(predef_macros))),)
326
-CC_ARCH=x86_64
327
-else ifneq ($(strip $(filter $(sparc_macros), $(predef_macros))),)
328
-
329
-ifneq ($(strip $(filter $(sparc64_macros), $(predef_macros))),)
330
-CC_ARCH=sparc64
331
-else # sparc64_macros
332
-CC_ARCH=sparc
333
-endif # sparc64_macros
334
-
335
-else ifneq ($(strip $(filter $(arm_macros), $(predef_macros))),)
336
-
337
-ifneq ($(strip $(filter $(arm6_macros), $(predef_macros))),)
338
-CC_ARCH=arm6
339
-else # arm6_macros
340
-CC_ARCH=arm
341
-endif # arm6_macros
342
-
343
-else ifneq ($(strip $(filter $(ppc64_macros), $(predef_macros))),)
344
-CC_ARCH=ppc64
345
-else ifneq ($(strip $(filter $(ppc_macros), $(predef_macros))),)
346
-CC_ARCH=ppc
347
-else ifneq ($(strip $(filter $(mips_macros), $(predef_macros))),)
348
-
349
-ifneq ($(strip $(filter $(mips64_macros), $(predef_macros))),)
350
-CC_ARCH=mips64
351
-else ifneq ($(strip $(filter $(mips2_macros), $(predef_macros))),)
352
-CC_ARCH=mips2
353
-else # mips2_macros
354
-CC_ARCH=mips
355
-endif # mips64_macros
356
-
357
-else ifneq ($(strip $(filter $(alpha_macros), $(predef_macros))),)
358
-CC_ARCH=alpha
359
-else
360
-
361
-$(warn "Unknown target compiler architecture")
362
-
363
-endif # predefined macros tests (x86_macros, ...)
364
-
365
-endif # gcc
366
-
367
-ifdef CC_ARCH
368
-ARCH:=$(CC_ARCH)
369
-else
370
-ARCH:=$(HOST_ARCH)
371
-endif
372
-$(info target architecture <$(ARCH)>, host architecture <$(HOST_ARCH)>)
373
-
374
-LIBDIR ?=
375
-ifeq ($(LIBDIR),)
376
-ARCHBSZ= $(shell echo $(ARCH) | sed -e 's/.*64.*/64b/')
377
-ifeq ($(ARCHBSZ),64b)
378
-	LIBDIR = lib64
379
-else
380
-	LIBDIR = lib
381
-endif
382
-endif
383
-
384
-# dirs
385
-cfg_dir = etc/$(MAIN_NAME)/
386
-bin_dir = sbin/
387
-share_dir = share/$(MAIN_NAME)/
388
-# lib/$(MAIN_NAME)/modules , lib/$(MAIN_NAME)/modules-s, lib/$(MAIN_NAME)/modules-k
389
-modules_dir = $(LIBDIR)/$(MAIN_NAME)/
390
-lib_dir = $(LIBDIR)/$(MAIN_NAME)/
391
-run_dir = var/run/$(MAIN_NAME)/
392
-doc_dir = doc/$(MAIN_NAME)/
393
-man_dir = man/
394
-data_dir = $(MAIN_NAME)/
395
-
396
-ifeq ($(OS), linux)
397
-	doc_dir = share/doc/$(MAIN_NAME)/
398
-	man_dir = share/man/
399
-	data_dir = share/$(MAIN_NAME)/
400
-	LOCALBASE ?= /usr/local
401
-endif
402
-
403
-ifeq ($(OS), gnu_kfreebsd)
404
-	doc_dir = share/doc/$(MAIN_NAME)/
405
-	man_dir = share/man/
406
-	data_dir = share/$(MAIN_NAME)/
407
-	LOCALBASE ?= /usr/local
408
-endif
409
-
410
-ifeq ($(OS), freebsd)
411
-	doc_dir = share/doc/$(MAIN_NAME)/
412
-	man_dir = man/
413
-	data_dir = share/$(MAIN_NAME)/
414
-	LOCALBASE ?= /usr/local
415
-endif
416
-
417
-ifeq ($(OS), openbsd)
418
-	doc_dir = share/doc/$(MAIN_NAME)/
419
-	man_dir = man/
420
-	data_dir = share/$(MAIN_NAME)/
421
-	LOCALBASE ?= /usr/local
422
-endif
423
-
424
-ifeq ($(OS), netbsd)
425
-	doc_dir = share/doc/$(MAIN_NAME)/
426
-	man_dir = man/
427
-	data_dir = share/$(MAIN_NAME)/
428
-	LOCALBASE ?= /usr/pkg
429
-endif
430
-
431
-ifeq ($(OS), dragonfly)
432
-	doc_dir = share/doc/$(MAIN_NAME)/
433
-	man_dir = man/
434
-	data_dir = share/$(MAIN_NAME)/
435
-	LOCALBASE ?= /usr/pkg
436
-endif
437
-
438
-ifeq ($(OS), darwin)
439
-	doc_dir = share/doc/$(MAIN_NAME)/
440
-	man_dir = man/
441
-	data_dir = share/$(MAIN_NAME)/
442
-	LOCALBASE ?= /usr/local
443
-endif
444
-
445
-LOCALBASE ?= /usr/local
446
-
447
-# Doxygen directory
448
-doxygen_dir=doc/doxygen
449
-
450
-BASEDIR ?= $(DESTDIR)
451
-basedir = $(BASEDIR)
452
-RUNBASEDIR ?= $(DESTDIR)
453
-runbasedir = $(RUNBASEDIR)
454
-
455
-# install location
456
-PREFIX ?= $(LOCALBASE)
457
-prefix = $(PREFIX)
458
-# install path is $(basedir) $(prefix)
459
-# example:
460
-#  creating a bin. archive in /tmp, which unpacks in /usr/local
461
-#  basedir=/tmp
462
-#  prefix=/usr/local
463
-
464
-# install prefixes for various stuff
465
-cfg_prefix = $(basedir)$(prefix)
466
-bin_prefix = $(basedir)$(prefix)
467
-modules_prefix = $(basedir)$(prefix)
468
-lib_prefix = $(basedir)$(prefix)
469
-run_prefix = $(runbasedir)
470
-doc_prefix = $(basedir)$(prefix)
471
-man_prefix = $(basedir)$(prefix)
472
-ut_prefix = $(basedir)$(prefix)
473
-share_prefix = $(basedir)$(prefix)
474
-data_prefix = $(basedir)$(prefix)
475
-
476
-
477
-# target dirs for various stuff
478
-cfg_target = $(prefix)/$(cfg_dir)
479
-bin_target = $(prefix)/$(bin_dir)
480
-#modules_target = $(prefix)/$(modules_dir)
481
-lib_target = $(prefix)/$(lib_dir)
482
-run_target = $(run_prefix)/$(run_dir)
483
-doc_target = $(prefix)/$(doc_dir)
484
-data_target = $(prefix)/$(data_dir)
485
-
486
-
487
-# compile-time options
488
-#
489
-# -DSTATS
490
-#		allows to print out number of packets processed on CTRL-C;
491
-# 		implementation still nasty and reports per-process
492
-# -DNO_DEBUG
493
-#		turns off some of the debug messages (DBG(...)).
494
-# -DNO_LOG
495
-#		completely turns of all the logging (and DBG(...))
496
-# -DEXTRA_DEBUG
497
-#		compiles in some extra debugging code
498
-# -DDNS_IP_HACK
499
-#		faster ip address resolver for ip strings (e.g "127.0.0.1")
500
-# -DSHM_MEM
501
-#		compiles in shared mem. support, needed by some modules and
502
-#		by USE_SHM_MEM
503
-# -DSHM_MMAP
504
-#		use mmap instead of SYSV shared memory
505
-# -DPKG_MALLOC
506
-#		uses a faster malloc (exclusive w/ USE_SHM_MEM)
507
-# -DUSE_SHM_MEM
508
-#		all pkg_malloc => shm_malloc (most mallocs use a common sh.
509
-#		mem. segment); don't define PKG_MALLOC if you want this!
510
-# -DDBG_QM_MALLOC
511
-#		qm_malloc debug code, will cause pkg_malloc and shm_malloc
512
-#		to keep and display lot of debuging information: file name,
513
-#		function, line number of malloc/free call for each block,
514
-#		extra error checking (trying to free the same pointer
515
-#		twice, trying to free a pointer alloc'ed with a different
516
-#		malloc etc.)
517
-# -DVQ_MALLOC
518
-#		additional option to PKG_MALLOC which utilizes a fater then
519
-#		qm version
520
-#		(not true anymore, q_malloc performs approx. the same)
521
-# -DQ_MALLOC
522
-#		custom quick malloc, recommended for debugging
523
-# -DF_MALLOC
524
-#		an even faster malloc, not recommended for debugging
525
-# -DTLSF_MALLOC
526
-#       an implemetation of the "two levels segregated fit" malloc algorithm
527
-# -DDL_MALLOC
528
-#		a malloc implementation based on Doug Lea's dl_malloc
529
-# -DSF_MALLOC
530
-#		an experimental multi-CPU, pool based, multi-process safe version of
531
-#		F_MALLOC. Should give better performance on machines with lots of CPUs
532
-#		after some tunning.
533
-# -DLL_MALLOC
534
-#		an experimental multi-CPU, pool based, multi-process safe, mostly
535
-#		lockless version of SF_MALLOC/F_MALLOC. Not for production use for
536
-#		now.
537
-# -DDBG_MALLOC
538
-#		issues additional debugging information if lock/unlock is called
539
-# -DMEM_JOIN_FREE
540
-#		enable the join of free memory chunks (see also mem_join cfg param)
541
-# -DFAST_LOCK
542
-#		uses fast arhitecture specific locking (see the arh. specific section)
543
-# -DUSE_SYSV_SEM
544
-#		uses sys v sems for locking (slower & limited number)
545
-# -DUSE_PTHREAD_MUTEX
546
-#		uses pthread mutexes, faster than sys v or posix sems, but do not
547
-#		work on all systems inter-processes (e.g. linux)
548
-# -DUSE_POSIX_SEM
549
-#		uses posix semaphores for locking (faster than sys v)
550
-# -DUSE_FUTEX
551
-#		uses futexes for locking (linux 2.6+)
552
-# -DBUSY_WAIT
553
-#		uses busy waiting on the lock (FAST_LOCK)
554
-# -DADAPTIVE_WAIT
555
-#		try busy waiting for a while and if the lock is still held go to
556
-#		force reschedule (FAST_LOCK)
557
-# -DADAPTIVE_WAIT_LOOPS=number
558
-#		number of loops we busy wait, after "number" loops have elapsed we
559
-#		force a reschedule (FAST_LOCK)
560
-# -DNOSMP
561
-#		don't use smp compliant locking (faster but won't work on SMP machines)
562
-#		(not yet enabled) (FAST_LOCK)
563
-# -DNO_PINGTEL_TAG_HACK
564
-#		if enabled, To-header-field will be less liberal and will not accept
565
-#		'tag=' (tag parameter with equal sign and without value); it is called
566
-#		this way because such message was sighted from a Pingtel phone
567
-# -DUSE_TCP
568
-#		compiles in tcp support
569
-# -DDISABLE_NAGLE
570
-#		disable the tcp Nagle algorithm (lower delay)
571
-# -DUSE_TLS
572
-#		compiles in tls support, requires -DUSE_TCP. Note: this is only
573
-#		generic support (parsing a.s.o.), it does not include the actual
574
-#		"tls engine". If you really want tls you need also either
575
-#		-DCORE_TLS and a tls/ subdir with the tls code or -DTLS_HOOKS and
576
-#		the tls module loaded.
577
-# -DCORE_TLS
578
-#		compiles tls in-core support. Requires -DUSE_TLS, conflicts
579
-#		-DTLS_HOOKS. Please use make CORE_TLS=1 instead  (it will set all the
580
-#		needed defines automatically and extra libraries needed for linking).
581
-# -DTLS_HOOKS
582
-#		compile tls module support (support for having the "tls engine" in a
583
-#		module). Requires -DUSE_TLS, conflicts -DCORE_TLS.
584
-#		Please use make TLS_HOOKS=1 (or TLS_HOOKS=0 to for disabling) instead
585
-#		of setting -DTLS_HOOKS (it will set all the needed defines
586
-#		automatically)
587
-# -DHAVE_RESOLV_RES
588
-#		support for changing some of the resolver parameters present
589
-#		 (_res structure in <resolv.h>)
590
-# -DUSE_COMP
591
-#		compiles in comp=[sergz|sigcomp] support (parsing uri & via,
592
-#		adding it to via, lumps a.s.o). WARNING: right now this option
593
-#		is useless since the compression code doesn't exist yet.
594
-# -DHONOR_MADDR
595
-#		compiles in checks and use for maddr parameter in uri.
596
-#		Required to support Windows Messenger 5.x over TCP connection
597
-#		which (mis)uses this parameter.
598
-# -DUSE_DNS_CACHE
599
-#		use an internal dns cache instead of making dns requests each time
600
-# -DUSE_DNS_CACHE_STATS
601
-#		turns on DNS cache measurements
602
-# -DUSE_DNS_FAILOVER
603
-#		if the destination resolves to multiple ips, on send error fall back
604
-#		to the others
605
-# -DUSE_DST_BLACKLIST
606
-#		blacklist bad destination (timeout, failed to connect, error sending
607
-#        a.s.o)
608
-# -DUSE_DST_BLACKLIST_STATS
609
-#		turns on blacklist bad destination measurements
610
-# -DPROFILING
611
-#		if enabled profiling will be enabled for child processes
612
-#		Don't forget to set PROFILE (see below)
613
-# -DNO_SIG_DEBUG
614
-#        turns off debugging messages in signal handlers (which might be
615
-#         unsafe)
616
-# -DUSE_NAPTR
617
-#		 turns on naptr support (but must be also enabled from the config)
618
-# -DDNS_WATCHDOG_SUPPORT
619
-#		turns on DNS watchdog support which can be used to inform the
620
-#		core that the DNS servers are down. No DNS query is performed
621
-#		when the servers are unreachable, and even expired resource
622
-#		records are used from the cache. (requires external watchdog)
623
-# -DWITH_AS_SUPPORT
624
-#		adds support for Application Server interface
625
-# Sometimes is needes correct non-quoted $OS. HACK: gcc translates known OS to number ('linux'), so there is added underscore
626
-
627
-ifeq ($(OS), dragonfly)
628
-	# Tell it that dragonflybsd is equivalent to compiling for freebsd, but
629
-	# define also __OS_dragonfly (for fine-tunning like kqueue support).
630
-	os_defs := -D__OS_freebsd -D__OS_dragonfly
631
-	EQUIV_OS = freebsd
632
-else
633
-	os_defs := -D__OS_$(OS)
634
-	EQUIV_OS = $(OS)
635
-endif
636
-
637
-C_DEFS= $(extra_defs) \
638
-	 -DNAME='"$(MAIN_NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
639
-	 -DOS='$(OS)_' -DOS_QUOTED='"$(OS)"' -DCOMPILER='"$(CC_VER)"'\
640
-	 -D__CPU_$(ARCH) $(os_defs) \
641
-	 -DSER_VER=$(SER_VER) \
642
-	 -DCFG_DIR='"$(cfg_target)"'\
643
-	 -DRUN_DIR='"$(run_target)"'\
644
-	 -DPKG_MALLOC \
645
-	 -DSHM_MEM  -DSHM_MMAP \
646
-	 -DDNS_IP_HACK \
647
-	 -DUSE_MCAST \
648
-	 -DUSE_TCP \
649
-	 -DDISABLE_NAGLE \
650
-	 -DHAVE_RESOLV_RES \
651
-	 -DUSE_DNS_CACHE \
652
-	 -DUSE_DNS_FAILOVER \
653
-	 -DUSE_DST_BLACKLIST \
654
-	 -DUSE_NAPTR \
655
-	 -DWITH_XAVP \
656
-	 #-DUSE_DNS_CACHE_STATS \
657
-	 #-DUSE_DST_BLACKLIST_STATS \
658
-	 #-DDNS_WATCHDOG_SUPPORT \
659
-	 #-DLL_MALLOC \
660
-	 #-DSF_MALLOC \
661
-	 #-DDL_MALLOC \
662
-	 #-DDBG_F_MALLOC \
663
-	 #-DNO_DEBUG \
664
-	 #-DEXTRA_DEBUG \
665
-	 #-DVQ_MALLOC  \
666
-	 #-DDBG_LOCK \
667
-	 #-DNOSMP \
668
-	 #-DUSE_SHM_MEM \
669
-	 #-DSTATS \
670
-	 #-DNO_LOG \
671
-	 #-DPROFILING \
672
-	 #-DNO_SIG_DEBUG
673
-
674
-#PROFILE=  -pg	# set this if you want profiling
675
-				# you may also want to set -DPROFILING
676
-
677
-# WARNING: do not add mode=debug or mode=release anymore in the Makefile,
678
-# use make mode=debug all instead. Anyway no by default ser is  compiled w/
679
-# debugging symbols in all cases (-g). --andrei
680
-
681
-# memory managers and related debug mode
682
-C_DEFS+= -DMEM_JOIN_FREE
683
-# enable f_malloc
684
-C_DEFS+= -DF_MALLOC
685
-# enable q_malloc
686
-C_DEFS+= -DQ_MALLOC
687
-# enable TLSF malloc
688
-C_DEFS+= -DTLSF_MALLOC
689
-ifeq 	($(MEMDBG), 1)
690
-	C_DEFS+= -DDBG_SR_MEMORY
691
-endif
692
-
693
-ifneq ($(PKG_MEM_SIZE),)
694
-	C_DEFS+= -DPKG_MEM_SIZE=$(PKG_MEM_SIZE)
695
-endif
696
-ifeq ($(CORE_TLS), 1)
697
-	C_DEFS+= -DUSE_TLS -DCORE_TLS
698
-endif
699
-ifeq ($(TLS_HOOKS), 1)
700
-	C_DEFS+= -DUSE_TLS -DTLS_HOOKS
701
-endif
702
-ifeq ($(KMSTATS), 1)
703
-	C_DEFS+= -DUSE_CORE_STATS -DSTATISTICS
704
-endif
705
-ifeq ($(FMSTATS), 1)
706
-	C_DEFS+= -DMALLOC_STATS
707
-endif
708
-ifeq ($(WITHAS), 1)
709
-	C_DEFS+= -DWITH_AS_SUPPORT
710
-endif
711
-
712
-ifeq ($(SCTP), 1)
713
-	C_DEFS+= -DUSE_SCTP
714
-endif
715
-
716
-ifeq ($(mode),)
717
-	mode = release
718
-endif
719
-
720
-ifeq ($(mode),debug)
721
-	C_DEFS+= -DEXTRA_DEBUG
722
-endif
723
-
724
-# platform dependent settings
725
-
726
-# find ld & as name (gnu or solaris)
727
-ifeq ($(OS), solaris)
728
-ifeq ($(CC_NAME), gcc)
729
-		LDGCC:=$(shell $(CC) -v 2>&1 | grep with-ld| \
730
-				   sed -e 's/.*--with-ld=\([^ ][^ ]*\).*/\1/' )
731
-		ASGCC:=$(shell $(CC) -v 2>&1 | grep with-as| \
732
-				   sed -e 's/.*--with-as=\([^ ][^ ]*\).*/\1/' )
733
-		LDPATH:=$(shell  if [ -z "$(LDGCC)" ] ; then echo "ld" ;\
734
-						else \
735
-						if $(LDGCC) -V 2>/dev/null 1>/dev/null; then \
736
-							echo $(LDGCC); \
737
-						else echo "ld" ; \
738
-						fi\
739
-						fi)
740
-		ASPATH:=$(shell  if [ -z "$(ASGCC)" ] ; then echo "as" ;\
741
-						else \
742
-						if $(ASGCC) -V 2>/dev/null 1>/dev/null </dev/null; \
743
-						then \
744
-							echo $(ASGCC); \
745
-						else echo "as" ; \
746
-						fi\
747
-						fi)
748
-
749
-		LDTYPE:=$(shell if $(LDPATH) -V 1>/dev/null  2>/dev/null; then \
750
-							if $(LDPATH) -V 2>&1|grep GNU >/dev/null; \
751
-							then echo gnu; \
752
-							else \
753
-							if $(LDPATH) -V 2>&1|grep Solaris >/dev/null;\
754
-							then echo solaris; \
755
-							else \
756
-								echo unknown ; \
757
-							fi \
758
-							fi \
759
-						fi)
760
-		ASTYPE:=$(shell if $(ASPATH) -V 1>/dev/null  2>/dev/null </dev/null; \
761
-						then \
762
-							if $(ASPATH) -V 2>&1 </dev/null | \
763
-								grep GNU >/dev/null; then echo gnu; \
764
-							else \
765
-							if $(ASPATH) -V 2>&1 </dev/null | \
766
-								grep Sun >/dev/null; then echo solaris; \
767
-							else \
768
-								echo unknown ; \
769
-							fi \
770
-							fi \
771
-						fi)
772
-#$(warning "using ld=$(LDPATH)/$(LDTYPE), as=$(ASPATH)/$(ASTYPE)")
773
-
774
-endif
775
-endif
776
-
777
-# arch. specific definitions
778
-ifeq ($(ARCH), i386)
779
-	use_fast_lock=yes
780
-endif
781
-
782
-ifeq ($(ARCH), x86_64)
783
-	use_fast_lock=yes
784
-endif
785
-
786
-ifeq ($(ARCH), sparc64)
787
-ifeq 	($(CC_NAME), gcc)
788
-	use_fast_lock=yes
789
-endif
790
-endif
791
-
792
-ifeq ($(ARCH), sparc)
793
-	use_fast_lock=yes
794
-endif
795
-
796
-ifeq ($(ARCH), arm)
797
-	use_fast_lock=yes
798
-	C_DEFS+=-DNOSMP # very unlikely to have an smp arm
799
-endif
800
-
801
-ifeq ($(ARCH), arm6)
802
-	use_fast_lock=yes
803
-	C_DEFS+=-DNOSMP # very unlikely to have an smp arm
804
-endif
805
-
806
-ifeq ($(ARCH), ppc)
807
-	use_fast_lock=yes
808
-endif
809
-
810
-ifeq ($(ARCH), ppc64)
811
-	use_fast_lock=yes
812
-endif
813
-
814
-ifeq ($(ARCH), mips)
815
-# mips1 arch. (e.g. R3000) - no hardware locking support
816
-	use_fast_lock=no
817
-	C_DEFS+=-DMIPS_HAS_LLSC # likely
818
-	C_DEFS+=-DNOSMP # very likely
819
-endif
820
-
821
-ifeq ($(ARCH), mips2)
822
-# mips2 arch and newer (mips3=R4000, mips4=R5000 a.s.o)
823
-	use_fast_lock=yes
824
-endif
825
-
826
-ifeq ($(ARCH), mips64)
827
-# mips2 arch and newer (mips3=R4000, mips4=R5000 a.s.o)
828
-	use_fast_lock=yes
829
-endif
830
-
831
-ifeq ($(ARCH), alpha)
832
-	use_fast_lock=yes
833
-	C_DEFS+=-DNOSMP # very likely
834
-endif
835
-
836
-ifeq ($(use_fast_lock), yes)
837
-	C_DEFS+= -DFAST_LOCK -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024
838
-	found_lock_method=yes
839
-endif
840
-
841
-CFLAGS=
842
-LDFLAGS=
843
-C_INCLUDES=
844
-# setting CFLAGS
845
-ifeq ($(mode), release)
846
-	#if i386
847
-ifeq	($(ARCH), i386)
848
-		# if gcc
849
-ifeq		($(CC_NAME), gcc)
850
-				C_DEFS+=-DCC_GCC_LIKE_ASM
851
-				#common stuff
852
-				CFLAGS=-g $(CC_OPT) -funroll-loops  -Wcast-align $(PROFILE)
853
-			#if gcc 6.0+, 5.0+, 4.5+ or 4.2+
854
-ifeq (,$(strip $(filter-out 4.2+ 4.5+ 5.0+ 6.0+,$(CC_SHORTVER))))
855
-$(call				set_if_empty,CPUTYPE,athlon64)
856
-					CFLAGS+=-m32 -minline-all-stringops \
857
-							-falign-loops \
858
-							-ftree-vectorize \
859
-							-fno-strict-overflow \
860
-							-mtune=$(CPUTYPE)
861
-					LDFLAGS+=-m32
862
-else
863
-			#if gcc 4.0+
864
-ifeq			($(CC_SHORTVER), 4.x)
865
-$(call				set_if_empty,CPUTYPE,athlon64)
866
-					CFLAGS+=-m32 -minline-all-stringops \
867
-							-falign-loops \
868
-							-ftree-vectorize \
869
-							-mtune=$(CPUTYPE)
870
-					LDFLAGS+=-m32
871
-else
872
-			#if gcc 3.4+
873
-ifeq			($(CC_SHORTVER), 3.4)
874
-$(call				set_if_empty,CPUTYPE,athlon)
875
-					CFLAGS+=-m32 -minline-all-stringops \
876
-							-falign-loops \
877
-							-mtune=$(CPUTYPE)
878
-					LDFLAGS+=-m32
879
-else
880
-			#if gcc 3.0+
881
-ifeq			($(CC_SHORTVER), 3.0)
882
-$(call				set_if_empty,CPUTYPE,athlon)
883
-					CFLAGS+=-minline-all-stringops \
884
-							-falign-loops \
885
-							-mcpu=$(CPUTYPE)
886
-					# -m32 supported since gcc 3.2
887
-else
888
-ifeq			($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
889
-$(warning 			Old gcc detected ($(CC_SHORTVER)), use  gcc >= 3.1 \
890
-					for better results)
891
-
892
-					CFLAGS+=-m486 \
893
-							-malign-loops=4
894
-else
895
-				#really old version
896
-$(warning			You are using an old and unsupported gcc \
897
-					 version  ($(CC_SHORTVER)), compile at your own risk!)
898
-
899
-endif			# CC_SHORTVER, 2.9x
900
-endif			# CC_SHORTVER, 3.0
901
-endif			# CC_SHORTVER, 3.4
902
-endif			# CC_SHORTVER, 4.x
903
-endif			# CC_SHORTVER, 6.0+, 5.0+, 4.5+ or 4.2+
904
-