Makefile: make TAGS skips the obsolete folder
[sip-router] / Makefile.defs
1
2 #
3 # makefile defs (CC, LD,a.s.o)
4 #
5 # Environment variables:
6 #   PREFIX, LOCALBASE, BASEDIR
7 #   INSTALL, TAR , CC, LEX, YACC,
8 #   CPU, CC_EXTRA_OPTS, LD_EXTRA_OPTS
9 #   exclude_modules, skip_modules, include_modules
10 #   extra_defs
11 #
12 # History:
13 # --------
14 #              created by andrei
15 #  2003-02-24  added LOCALBASE, fixed doc_dir for freebsd - patch provided
16 #               by Maxim Sobolev <sobomax@FreeBSD.org>
17 #  2003-02-25  added -DDISABLE_NAGLE (andrei)
18 #  2003-03-02  added -DDIGEST_DOMAIN (janakj)
19 #  2003-03-10  added -xcode=pic32 for module compilation w/ sun cc
20 #               (too many symbols for pic13)  (andrei)
21 #  2003-04-16  added CC_EXTRA_OPTS, s/march/mcpu, added CPU (cpu to optimize 
22 #               for, used only with gcc-3.x) (andrei)
23 #  2003-05-23  check if this makefile was already included (andrei)
24 #              removed -DDIGEST_DOMAIN (andrei)
25 #  2003-05-30  added extra_defs (andrei)
26 #  2003-06-06  moved compiler detection before DEFS (andrei)
27 #  2003-06-10  removed -m32 for gcc 3.x/sparc64  -- it will use 
28 #              arch. default: -m32 on solaris, -m64 on *bsd (andrei)
29 #  2003-09-25  added -pthread into LIBS when compiling on FreeBSD/alpha
30 #              and other FreeBSD arches for which no fast locking assembly
31 #              code exists (sobomax)
32 #  2003-11-08  mips1 support introduced (andrei)
33 #  2003-11-24  openbsd 3.4 (elf) fixes (andrei)
34 #  2004-07-27  darwin (mac os x) port  (andrei)
35 #  2004-09-12  mips2 & cobalt support introduced (andrei)
36 #  2004-09-28  x86_64 support introduced (andrei)
37 #  2004-12-14  gcc-3.4 special case added (andrei)
38 #  2004-12-15  HAVE_ALLOCA_H added (andrei)
39 #  2004-12-19  amd64 transformed in x86_64 (andrei)
40 #  2005-04-27  alpha support added (andrei)
41 #  2005-06-01  use $(LOCALBASE) instead of /usr/{local,pkg} (andrei)
42 #  2005-06-26  numeric OSREL & HAVE_KQUEUE added to the *BSD (andrei)
43 #  2005-07-04  HAVE_DEVPOLL added to solaris (andrei)
44 #  2005-07-06  gcc 4.0 optimizations support (andrei)
45 #  2005-07-25  better solaris arch detection (andrei)
46 #  2005-09-12  -mallign-double removed (too many problems) (andrei)
47 #  2005-10-02  distcc get gcc version hack (andrei)
48 #  2006-03-30  64 bit mode compile by default on sparc64 (-m64), added
49 #              CC_GCC_LIKE_ASM and SPARC64_MODE (andrei)
50 #              sparc <= v8 support (andrei)
51 #  2006-03-31  armv6 & mips64 support added
52 #              mips and arm set to NOSMP by default (andrei)
53 #  2006-07-10  added -DPROFILING (hscholz)
54 #  2007-02-09  added TLS_HOOKS and CORE_TLS support, obsoleted TLS=1
55 #              added TLS_EXTRA_LIBS (andrei)
56 #  2007-03-16  added LIB building options: LIB_LDFLAGS, LIB_SONAME, LIB_RPATH,
57 #                INSTALL_LIB, libraries install paths (andrei)
58 #  2007-05-14  futex support if linux 2.5.70+ and 
59 #               use_futex=yes (default) (andrei)
60 #  2007-05-26  changed darwin module link flags (instead of -bundle_loader ser
61 #               -flat_namespace -undefined suppress) (andrei)
62 #  2007-07-07  use isainfo -n to detect cpu type on solaris (andrei)
63 #  2007-07-07  added HAVE_SCHED_SETSCHEDULER for linux (andrei)
64 #  2007-07-18  added DNS_WATCHDOG_SUPPORT (Miklos)
65 #  2007-07-30  added USE_DNS_CACHE_STATS and USE_DST_BLACKLIST_STATS (Gergo)
66 #  2008-06-26  support for make cfg / config.mak and hack to load 
67 #               automatically config.mak when included from a module, lib 
68 #               a.s.o (not from the main Makefile)  (andrei)
69 #  2009-03-10  replaced DEFS with C_DEFS and INCLUDES with C_INCLUDES (DEFS
70 #              and INCLUDES are now used only for "temporary" defines/includes
71 #              inside modules or libs) (andrei)
72 #  2009-09-29  for gcc 4.2+ use -fno-strict-overflow (andrei)
73 #  2009-09-30  find the target architecture from the compiler and not
74 #              from the host (andrei)
75 #  2009-10-01  use -fsigned-char for gcc on ppc, ppc64, arm and arm6
76 #              (on those archs char is unsigned by default) (andrei)
77 #  2010-03-10  added CC_MKDEP_OPTS, which contains to the list of options
78 #               needed to generate dependencies on-the-fly while compiling
79 #               or is empty if the compiler doesn't support it (andrei)
80
81
82 # default silent, unless Q= 0|no|off|verbose|noisy
83 quiet?=$(if $(filter 0 no off verbose noisy,$(Q)),verbose,silent)
84
85 # check if already included/exported
86
87 # used for sanity checks for Makefile.defs inclusion (!= makefile_defs which
88 # specifies if we have a set of valid defs)
89 override makefile_defs_included:=1
90 ifeq ($(makefile_defs),1)
91 ifeq ($(quiet),verbose)
92 $(info Makefile.defs defs skipped)
93 endif # verbose
94
95 else
96
97 ifeq (,$(main_makefile))
98 # hack to automatically use config.mak in all the modules, without 
99 # changing the current module makefiles (which all include Makefile.defs):
100 # if not called from the main makefile (module, lib or ut):
101 # include config.mak, but if not present or incomplete (makefile_defs!=1)
102 # don't export the vars)
103 COREPATH?= ../..
104 include $(COREPATH)/config.mak
105 ifeq ($(quiet),verbose)
106 $(info config.mak included)
107 endif # verbose
108 # config.mak should set makefile_defs if complete
109 export makefile_defs
110
111 else
112 override makefile_defs=1
113 export makefile_defs
114
115
116 ifeq ($(quiet),verbose)
117 $(info normal Makefile.defs exec)
118 endif # verbose
119
120 -include Makefile.vars
121
122 # usage: $(call set_if_empty,VAR,value)
123 set_if_empty=$(if $($(1)),,$(eval override $(1)=$(2)))
124
125 # flavour: sip-router, ser or kamailio
126 $(call  set_if_empty,FLAVOUR,kamailio)
127
128 #prefix for various configs and scripts
129 #config name/name-prefix for distributed configs
130 CFG_NAME?=sip-router
131 #config name/name-prefix for distributed scripts
132 SCR_NAME=sip-router
133 #name in source tree
134 SRC_NAME=sip-router
135
136 ifeq ($(FLAVOUR),sip-router)
137 # main binary name
138 MAIN_NAME=ser
139 else ifeq ($(FLAVOUR),ser)
140 # main binary name
141 MAIN_NAME=ser
142 else ifeq ($(FLAVOUR),kamailio)
143 # main binary name
144 MAIN_NAME=kamailio
145 # use kamailio config
146 CFG_NAME=kamailio
147 # kamailio statistics on
148 KMSTATS ?= 1
149 # fast malloc statistics on
150 FMSTATS ?= 1
151 # application server support on
152 WITHAS ?= 1
153 else # unknown:
154 # main binary name
155 MAIN_NAME=kamailio
156 endif
157
158 # what to install
159 INSTALL_FLAVOUR=$(FLAVOUR)
160
161 #version number
162 VERSION = 3
163 PATCHLEVEL = 4
164 SUBLEVEL =  0
165 EXTRAVERSION = -dev7
166
167 # memory manager switcher
168 # 0 - f_malloc (fast malloc)
169 # 1 - q_malloc (quick malloc)
170 MEMMNG ?= 1
171 # memory debugger switcher
172 # 0 - off (no-debug mode)
173 # 1 - on (debug mode)
174 MEMDBG ?= 0
175
176 SER_VER = $(shell expr $(VERSION) \* 1000000 + $(PATCHLEVEL) \* 1000 + \
177                         $(SUBLEVEL) )
178 RELEASE:=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
179 OS := $(shell uname -s | sed -e s/SunOS/solaris/ -e s/CYGWIN.*/cygwin/ \
180                  | tr "[A-Z]" "[a-z]")
181
182 ifeq ($(OS),solaris)
183         GETARCH=isainfo -n
184 ifeq ($(GETARCH),)
185         GETARCH=uname -p
186 endif
187 else
188         GETARCH=uname -m
189 endif
190
191 HOST_ARCH := $(shell $(GETARCH) |sed -e s/i.86/i386/ -e s/sun4[uv]/sparc64/  \
192                         -e s/armv[3-5].*/arm/  -e s/armv6.*/arm6/ \
193                         -e "s/Power Macintosh/ppc/" \
194                         -e "s/cobalt/mips2/" \
195                         -e s/amd64/x86_64/ -e s/sparcv9/sparc64/ )
196 # fix sparc -> sparc64
197 ifeq ($(HOST_ARCH),sparc)
198         ifeq ($(shell uname -m),sun4u)
199                 HOST_ARCH := sparc64
200         endif
201         ifeq ($(shell uname -m),sun4v)
202                 HOST_ARCH := sparc64
203         endif
204 endif
205
206 OSREL := $(shell uname -r)
207 # numerical version (good for comparisons: A.B.C => A*1000000+B*1000+C)
208 OSREL_N:= $(shell echo $(OSREL) | sed -e 's/^[^0-9]*//' \
209                 -e 's/^\([0-9][0-9]*\(\.[0-9][0-9]*\)*\).*$$/\1/g' | \
210                 (IFS=. read A B C D; R=0; \
211                 [ -n "$$A" ] && R=`expr $$R \* 1000 + $$A` && \
212                 [ -n "$$B" ] && R=`expr $$R \* 1000 + $$B` && \
213                 [ -n "$$C" ] && R=`expr $$R \* 1000 + $$C`; echo $$R ) )
214
215
216 # TLS support
217 CORE_TLS ?= 
218 # by default compile with tls hooks support (so that no ser recompile is
219 #  needed before the tls module can be used)
220 TLS_HOOKS=1
221 ifeq ($(CORE_TLS), 1)
222         RELEASE:=$(RELEASE)-tls
223         TLS_HOOKS:=0
224 endif
225 ifeq ($(TLS_HOOKS), 1)
226 #       RELEASE:=$(RELEASE)-tls
227 endif
228
229 # extra CC command line options (e.g  -march=athlon-mp)
230 CC_EXTRA_OPTS ?=
231
232 # extra LD command line options
233 LD_EXTRA_OPTS ?=
234
235 ifeq ($(OS), solaris)
236 #use GNU versions
237 INSTALL ?= ginstall
238 TAR ?= gtar
239 else
240 INSTALL ?= install
241 TAR ?= tar
242 endif
243
244 INSTALL_TOUCH = touch          # used to create the file first (good to 
245                                #  make solaris install work)
246 INSTALL_CFG = $(INSTALL) -m 644
247 INSTALL_BIN = $(INSTALL) -m 755
248 INSTALL_SCRIPT = $(INSTALL) -m 755
249 INSTALL_MODULES = $(INSTALL) -m 755
250 INSTALL_LIB = $(INSTALL) -m 755
251 INSTALL_DOC = $(INSTALL) -m 644
252 INSTALL_MAN = $(INSTALL) -m 644
253 INSTALL_SHARE = $(INSTALL) -m 644
254
255 #set some vars from the environment (and not make builtins)
256 CC   := $(shell echo "$${CC}")
257 LEX  := $(shell echo "$${LEX}")
258 YACC := $(shell echo "$${YACC}")
259
260
261
262
263 # find compiler name & version
264 ifeq ($(CC),)
265         CC=gcc
266 endif
267 LD= $(CC)
268 CC_LONGVER:=$(shell if  $(CC) -v 2>/dev/null; then \
269                                                 $(CC) -v 2>&1 ;\
270                                         else \
271                                                 $(CC) -V 2>&1 ; \
272                                         fi )
273 MKTAGS=ctags
274
275 #find-out the compiler's name
276
277 ifneq (,$(findstring gcc, $(CC_LONGVER)))
278         CC_NAME=gcc
279         RPAREN=)
280         CC_VER:=$(word 1,$(CC)) $(shell $(CC) - --version|head -n 1|\
281                                 sed  -e 's/([^$(RPAREN)]*)//g' \
282                                          -e 's/^.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/'\
283                                          -e 's/^[^0-9].*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/')
284 #       CC_VER:=$(word 1,$(CC)) $(shell $(CC) - --version|head -n 1|cut -d" " -f 3\
285 #                               |sed -e 's/^.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/'\
286 #                                        -e 's/^[^0-9].*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/')
287         # sed with POSIX.1 regex doesn't support |, + or ? 
288         # (darwin, solaris ...) => this complicated expression
289         MKDEP=$(CC) -MM -MG
290         #transform gcc version into 2.9x or 3.0
291         CC_SHORTVER:=$(shell echo "$(CC_VER)" | cut -d" " -f 2| \
292                                  sed -e 's/[^0-9]*-\(.*\)/\1/'| \
293                                  sed -e 's/2\.9.*/2.9x/' \
294                                         -e 's/3\.[0-3]\..*/3.0/' \
295                                         -e 's/3\.[0-3]/3.0/' \
296                                         -e 's/3\.[4-9]\..*/3.4/' \
297                                         -e 's/3\.[4-9]/3.4/' \
298                                         -e 's/4\.[0-1]\..*/4.x/' \
299                                         -e 's/4\.[0-1]/4.x/' \
300                                         -e 's/4\.[2-4]\..*/4.2+/' \
301                                         -e 's/4\.[2-4]$$/4.2+/' \
302                                         -e 's/4\.[5-9]\..*/4.5+/' \
303                                         -e 's/4\.[5-9]$$/4.5+/')
304 ifeq (,$(strip $(filter-out 3.0 3.4 4.x 4.2+ 4.5+,$(CC_SHORTVER))))
305         # dependencies can be generated on-the-fly while compiling *.c
306         CC_MKDEP_OPTS=-MMD -MP
307 endif # 3.0 <= $(CC_SHORTVER) <= 4.x
308 endif # gcc
309
310 ifneq (, $(findstring Sun, $(CC_LONGVER)))
311         CC_NAME=suncc
312         CC_SHORTVER:=$(shell echo "$(CC_LONGVER)"|head -n 1| \
313                                         sed -e 's/.*\([0-9]\.[0-9]\).*/\1/g' )
314         CC_VER=$(CC) $(CC_SHORTVER)
315         MKDEP=$(CC) -xM1 
316 endif
317
318 ifneq (, $(findstring Intel(R) C++ Compiler, $(CC_LONGVER)))
319         # very nice: gcc compatible
320         CC_NAME=icc
321         CC_FULLVER:=$(shell echo "$(CC_LONGVER)"|head -n 1| \
322                                         sed -e 's/.*Version \([0-9]\.[0-9]\.[0-9]*\).*/\1/g' )
323         CC_SHORTVER:=$(shell echo "$(CC_FULLVER)" | cut -d. -f1,2 )
324         CC_VER=$(CC) $(CC_FULLVER)
325         MKDEP=$(CC) -MM 
326 endif
327
328 ifneq (, $(findstring clang, $(CC_LONGVER)))
329         #clang should be gcc compatible
330         CC_NAME=clang
331         CC_FULLVER:=$(shell echo "$(CC_LONGVER)" | head -n 1 |  sed -e 's/.*version \([0-9]\.[0-9]\).*/\1/g' )
332         CC_SHORTVER:=$(shell echo "$(CC_FULLVER)" | cut -d. -f1,2 )
333         CC_VER=$(CC) $(CC_FULLVER)
334         MKDEP=$(CC) -MM 
335 endif
336
337 ifeq (,$(CC_NAME))
338 #not found
339         CC_NAME=$(CC)
340         CC_SHORTVER=unknown
341         CC_VER=unknown
342         MKDEP=gcc -MM 
343 $(warning       Unknown compiler $(CC)\; supported compilers: \
344                         gcc, sun cc, intel icc )
345 endif
346
347 # ARCH detection
348 # predefined compiler macros for different architectures
349 # (see http://predef.sourceforge.net/prearch.html for a more complete list)
350 i386_macros= i386 __i386__ __i486__ __i586__ __i686__ \
351                         __i386 _M_IX86 __X86__ _X86_
352 x86_64_macros= __amd64__ __amd64 __x86_64__ __x86_64 _M_X64
353
354 sparc_macros= __sparc__ __sparc __sparcv8
355 sparc64_macros= __sparcv9 __sparc_v9__
356
357 arm_macros= __arm__ __thumb__
358 arm6_macros= __ARM_ARCH_6__
359
360 ppc_macros= __powerpc __powerpc__ __POWERPC__ __ppc__ _ARCH_PPC
361 ppc64_macros= __ppc64__ _ARCH_PPC64
362
363 mips_macros= __mips__ __mips _MIPS_ARCH_MIPS1
364 mips2_macros= _MIPS_ISA_MIPS2 _MIPS_ISA_MIPS3 _MIPS_ISA_MIPS4 \
365                         _MIPS_ARCH_MIPS2 _MIPS_ARCH_MIPS3 _MIPS_ARCH_MIPS4
366 mips64_macros= _MIPS_ISA_MIPS64 _MIPS_ARCH_MIPS64
367
368 alpha_macros= __alpha__ __alpha _M_ALPHA_
369
370 ifeq ($(CC_NAME),gcc)
371 #if gcc use gcc arch
372 predef_macros:=$(shell $(CC) -dM -E -x c $(CC_EXTRA_OPTS) $(extra_defs) \
373                                         $(CFLAGS) /dev/null)
374
375 ifneq ($(strip $(filter $(i386_macros), $(predef_macros))),)
376 CC_ARCH=i386
377 else ifneq ($(strip $(filter $(x86_64_macros), $(predef_macros))),)
378 CC_ARCH=x86_64
379 else ifneq ($(strip $(filter $(sparc_macros), $(predef_macros))),)
380
381 ifneq ($(strip $(filter $(sparc64_macros), $(predef_macros))),)
382 CC_ARCH=sparc64
383 else # sparc64_macros
384 CC_ARCH=sparc
385 endif # sparc64_macros
386
387 else ifneq ($(strip $(filter $(arm_macros), $(predef_macros))),)
388
389 ifneq ($(strip $(filter $(arm6_macros), $(predef_macros))),)
390 CC_ARCH=arm6
391 else # arm6_macros
392 CC_ARCH=arm
393 endif # arm6_macros
394
395 else ifneq ($(strip $(filter $(ppc64_macros), $(predef_macros))),)
396 CC_ARCH=ppc64
397 else ifneq ($(strip $(filter $(ppc_macros), $(predef_macros))),)
398 CC_ARCH=ppc
399 else ifneq ($(strip $(filter $(mips_macros), $(predef_macros))),)
400
401 ifneq ($(strip $(filter $(mips64_macros), $(predef_macros))),)
402 CC_ARCH=mips64
403 else ifneq ($(strip $(filter $(mips2_macros), $(predef_macros))),)
404 CC_ARCH=mips2
405 else # mips2_macros
406 CC_ARCH=mips
407 endif # mips64_macros
408
409 else ifneq ($(strip $(filter $(alpha_macros), $(predef_macros))),)
410 CC_ARCH=alpha
411 else
412
413 $(warn "Unknown target compiler architecture")
414
415 endif # predefined macros tests (x86_macros, ...)
416
417 endif # gcc
418
419 ifdef CC_ARCH
420 ARCH:=$(CC_ARCH)
421 else
422 ARCH:=$(HOST_ARCH)
423 endif
424 $(info target architecture <$(ARCH)>, host architecture <$(HOST_ARCH)>)
425
426 LIBDIR ?=
427 ifeq ($(LIBDIR),)
428 ARCHBSZ= $(shell echo $(ARCH) | sed -e 's/.*64.*/64b/')
429 ifeq ($(ARCHBSZ),64b)
430         LIBDIR = lib64
431 else
432         LIBDIR = lib
433 endif
434 endif
435
436 # dirs
437 cfg_dir = etc/$(MAIN_NAME)/
438 bin_dir = sbin/
439 share_dir = share/$(MAIN_NAME)/
440 # lib/$(MAIN_NAME)/modules , lib/$(MAIN_NAME)/modules-s, lib/$(MAIN_NAME)/modules-k
441 modules_dir = $(LIBDIR)/$(MAIN_NAME)/
442 lib_dir = $(LIBDIR)/$(MAIN_NAME)/
443
444 doc_dir = doc/$(MAIN_NAME)/
445 man_dir = man/
446 data_dir = $(MAIN_NAME)/
447
448 ifeq ($(OS), linux)
449         doc_dir = share/doc/$(MAIN_NAME)/
450         man_dir = share/man/
451         data_dir = share/$(MAIN_NAME)/
452         LOCALBASE ?= /usr/local
453 endif
454
455 ifeq ($(OS), freebsd)
456         doc_dir = share/doc/$(MAIN_NAME)/
457         man_dir = man/
458         data_dir = share/$(MAIN_NAME)/
459         LOCALBASE ?= /usr/local
460 endif
461
462 ifeq ($(OS), openbsd)
463         doc_dir = share/doc/$(MAIN_NAME)/
464         man_dir = man/
465         data_dir = share/$(MAIN_NAME)/
466         LOCALBASE ?= /usr/local
467 endif
468
469 ifeq ($(OS), netbsd)
470         doc_dir = share/doc/$(MAIN_NAME)/
471         man_dir = man/
472         data_dir = share/$(MAIN_NAME)/
473         LOCALBASE ?= /usr/pkg
474 endif
475
476 ifeq ($(OS), dragonfly)
477         doc_dir = share/doc/$(MAIN_NAME)/
478         man_dir = man/
479         data_dir = share/$(MAIN_NAME)/
480         LOCALBASE ?= /usr/pkg
481 endif
482
483 ifeq ($(OS), darwin)
484         doc_dir = share/doc/$(MAIN_NAME)/
485         man_dir = man/
486         data_dir = share/$(MAIN_NAME)/
487         LOCALBASE ?= /usr/local
488 endif
489
490 LOCALBASE ?= /usr/local
491
492 # Doxygen directory
493 doxygen_dir=doc/doxygen
494
495 # install location
496 PREFIX ?= $(LOCALBASE)
497 prefix = $(PREFIX)
498 # install path is $(basedir) $(prefix)
499 # example:
500 #  creating a bin. archive in /tmp, which unpacks in /usr/local
501 #  basedir=/tmp
502 #  prefix=/usr/local
503
504 BASEDIR ?= $(DESTDIR)
505 basedir = $(BASEDIR)
506 # install prefixes for various stuff
507 cfg_prefix = $(basedir)$(prefix)
508 bin_prefix = $(basedir)$(prefix)
509 modules_prefix = $(basedir)$(prefix)
510 lib_prefix = $(basedir)$(prefix)
511 doc_prefix = $(basedir)$(prefix)
512 man_prefix = $(basedir)$(prefix)
513 ut_prefix = $(basedir)$(prefix)
514 share_prefix = $(basedir)$(prefix)
515 data_prefix = $(basedir)$(prefix)
516
517
518 # target dirs for various stuff
519 cfg_target = $(prefix)/$(cfg_dir)
520 bin_target = $(prefix)/$(bin_dir)
521 #modules_target = $(prefix)/$(modules_dir)
522 lib_target = $(prefix)/$(lib_dir)
523 doc_target = $(prefix)/$(doc_dir)
524 data_target = $(prefix)/$(data_dir)
525
526
527 # compile-time options
528 #
529 # -DSTATS
530 #               allows to print out number of packets processed on CTRL-C;
531 #               implementation still nasty and reports per-process
532 # -DNO_DEBUG
533 #               turns off some of the debug messages (DBG(...)).
534 # -DNO_LOG
535 #               completely turns of all the logging (and DBG(...))
536 # -DEXTRA_DEBUG
537 #               compiles in some extra debugging code
538 # -DDNS_IP_HACK
539 #               faster ip address resolver for ip strings (e.g "127.0.0.1")
540 # -DSHM_MEM
541 #               compiles in shared mem. support, needed by some modules and
542 #               by USE_SHM_MEM
543 # -DSHM_MMAP
544 #               use mmap instead of SYSV shared memory
545 # -DPKG_MALLOC
546 #               uses a faster malloc (exclusive w/ USE_SHM_MEM)
547 # -DUSE_SHM_MEM
548 #               all pkg_malloc => shm_malloc (most mallocs use a common sh.
549 #               mem. segment); don't define PKG_MALLOC if you want this!
550 # -DDBG_QM_MALLOC
551 #               qm_malloc debug code, will cause pkg_malloc and shm_malloc
552 #               to keep and display lot of debuging information: file name,
553 #               function, line number of malloc/free call for each block,
554 #               extra error checking (trying to free the same pointer
555 #               twice, trying to free a pointer alloc'ed with a different
556 #               malloc etc.)
557 # -DVQ_MALLOC
558 #               additional option to PKG_MALLOC which utilizes a fater then
559 #               qm version
560 #               (not true anymore, q_malloc performs approx. the same)
561 # -DF_MALLOC
562 #               an even faster malloc, not recommended for debugging
563 # -DDL_MALLOC
564 #               a malloc implementation based on Doug Lea's dl_malloc
565 # -DSF_MALLOC 
566 #               an experimental multi-CPU, pool based, multi-process safe version of 
567 #               F_MALLOC. Should give better performance on machines with lots of CPUs
568 #               after some tunning.
569 # -DLL_MALLOC
570 #               an experimental multi-CPU, pool based, multi-process safe, mostly
571 #               lockless version of SF_MALLOC/F_MALLOC. Not for production use for
572 #               now.
573 # -DDBG_MALLOC
574 #               issues additional debugging information if lock/unlock is called
575 # -DMEM_JOIN_FREE
576 #               enable the join of free memory chunks (see also mem_join cfg param)
577 # -DFAST_LOCK
578 #               uses fast arhitecture specific locking (see the arh. specific section)
579 # -DUSE_SYSV_SEM
580 #               uses sys v sems for locking (slower & limited number)
581 # -DUSE_PTHREAD_MUTEX
582 #               uses pthread mutexes, faster than sys v or posix sems, but do not 
583 #               work on all systems inter-processes (e.g. linux)
584 # -DUSE_POSIX_SEM
585 #               uses posix semaphores for locking (faster than sys v)
586 # -DUSE_FUTEX
587 #               uses futexes for locking (linux 2.6+)
588 # -DBUSY_WAIT
589 #               uses busy waiting on the lock (FAST_LOCK)
590 # -DADAPTIVE_WAIT
591 #               try busy waiting for a while and if the lock is still held go to
592 #               force reschedule (FAST_LOCK)
593 # -DADAPTIVE_WAIT_LOOPS=number
594 #               number of loops we busy wait, after "number" loops have elapsed we 
595 #               force a reschedule (FAST_LOCK)
596 # -DNOSMP
597 #               don't use smp compliant locking (faster but won't work on SMP machines)
598 #               (not yet enabled) (FAST_LOCK)
599 # -DNO_PINGTEL_TAG_HACK
600 #               if enabled, To-header-field will be less liberal and will not accept
601 #               'tag=' (tag parameter with equal sign and without value); it is called
602 #               this way because such message was sighted from a Pingtel phone
603 # -DUSE_TCP
604 #               compiles in tcp support
605 # -DDISABLE_NAGLE
606 #               disable the tcp Nagle algorithm (lower delay)
607 # -DUSE_TLS
608 #               compiles in tls support, requires -DUSE_TCP. Note: this is only 
609 #               generic support (parsing a.s.o.), it does not include the actual
610 #               "tls engine". If you really want tls you need also either
611 #               -DCORE_TLS and a tls/ subdir with the tls code or -DTLS_HOOKS and
612 #               the tls module loaded.
613 # -DCORE_TLS
614 #               compiles tls in-core support. Requires -DUSE_TLS, conflicts 
615 #               -DTLS_HOOKS. Please use make CORE_TLS=1 instead  (it will set all the
616 #               needed defines automatically and extra libraries needed for linking).
617 # -DTLS_HOOKS
618 #               compile tls module support (support for having the "tls engine" in a
619 #               module). Requires -DUSE_TLS, conflicts -DCORE_TLS.
620 #               Please use make TLS_HOOKS=1 (or TLS_HOOKS=0 to for disabling) instead
621 #               of setting -DTLS_HOOKS (it will set all the needed defines 
622 #               automatically)
623 # -DHAVE_RESOLV_RES
624 #               support for changing some of the resolver parameters present
625 #                (_res structure in <resolv.h>)
626 # -DUSE_COMP
627 #               compiles in comp=[sergz|sigcomp] support (parsing uri & via, 
628 #               adding it to via, lumps a.s.o). WARNING: right now this option
629 #               is useless since the compression code doesn't exist yet.
630 # -DHONOR_MADDR
631 #               compiles in checks and use for maddr parameter in uri.
632 #               Required to support Windows Messenger 5.x over TCP connection
633 #               which (mis)uses this parameter.
634 # -DUSE_DNS_CACHE
635 #               use an internal dns cache instead of making dns requests each time
636 # -DUSE_DNS_CACHE_STATS
637 #               turns on DNS cache measurements
638 # -DUSE_DNS_FAILOVER
639 #               if the destination resolves to multiple ips, on send error fall back
640 #               to the others
641 # -DUSE_DST_BLACKLIST
642 #               blacklist bad destination (timeout, failed to connect, error sending
643 #        a.s.o)
644 # -DUSE_DST_BLACKLIST_STATS
645 #               turns on blacklist bad destination measurements
646 # -DPROFILING
647 #               if enabled profiling will be enabled for child processes
648 #               Don't forget to set PROFILE (see below)
649 # -DUSE_STUN
650 #               compiles in stun support
651 # -DNO_SIG_DEBUG
652 #        turns off debugging messages in signal handlers (which might be 
653 #         unsafe)
654 # -DUSE_NAPTR
655 #                turns on naptr support (but must be also enabled from the config)
656 # -DDNS_WATCHDOG_SUPPORT
657 #               turns on DNS watchdog support which can be used to inform the
658 #               core that the DNS servers are down. No DNS query is performed
659 #               when the servers are unreachable, and even expired resource
660 #               records are used from the cache. (requires external watchdog)
661 # -DWITH_AS_SUPPORT
662 #               adds support for Application Server interface
663 # Sometimes is needes correct non-quoted $OS. HACK: gcc translates known OS to number ('linux'), so there is added underscore
664
665 ifeq ($(OS), dragonfly)
666         # Tell it that dragonflybsd is equivalent to compiling for freebsd, but
667         # define also __OS_dragonfly (for fine-tunning like kqueue support).
668         os_defs := -D__OS_freebsd -D__OS_dragonfly
669         EQUIV_OS = freebsd
670 else
671         os_defs := -D__OS_$(OS)
672         EQUIV_OS = $(OS)
673 endif
674
675 C_DEFS= $(extra_defs) \
676          -DNAME='"$(MAIN_NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
677          -DOS='$(OS)_' -DOS_QUOTED='"$(OS)"' -DCOMPILER='"$(CC_VER)"'\
678          -D__CPU_$(ARCH) $(os_defs) \
679          -DSER_VER=$(SER_VER) \
680          -DCFG_DIR='"$(cfg_target)"'\
681          -DPKG_MALLOC \
682          -DSHM_MEM  -DSHM_MMAP \
683          -DDNS_IP_HACK \
684          -DUSE_IPV6 \
685          -DUSE_MCAST \
686          -DUSE_TCP \
687          -DDISABLE_NAGLE \
688          -DHAVE_RESOLV_RES \
689          -DUSE_DNS_CACHE \
690          -DUSE_DNS_FAILOVER \
691          -DUSE_DST_BLACKLIST \
692          -DUSE_NAPTR \
693          -DWITH_XAVP \
694          #-DUSE_DNS_CACHE_STATS \
695          #-DUSE_DST_BLACKLIST_STATS \
696          #-DDNS_WATCHDOG_SUPPORT \
697          #-DLL_MALLOC \
698          #-DSF_MALLOC \
699          #-DDL_MALLOC \
700          #-DDBG_F_MALLOC \
701          #-DNO_DEBUG \
702          #-DEXTRA_DEBUG \
703          #-DVQ_MALLOC  \
704          #-DDBG_LOCK \
705          #-DNOSMP \
706          #-DUSE_SHM_MEM \
707          #-DSTATS \
708          #-DNO_LOG \
709          #-DPROFILING \
710          #-DNO_SIG_DEBUG
711
712 #PROFILE=  -pg  # set this if you want profiling
713                                 # you may also want to set -DPROFILING
714
715 # WARNING: do not add mode=debug or mode=release anymore in the Makefile,
716 # use make mode=debug all instead. Anyway no by default ser is  compiled w/ 
717 # debugging symbols in all cases (-g). --andrei
718
719 # set memory manager and its debug mode
720 ifeq ($(MEMMNG), 1)
721 #       use q_malloc
722 ifeq    ($(MEMDBG), 1)
723                 C_DEFS+= -DDBG_QM_MALLOC
724 endif
725         C_DEFS+= -DMEM_JOIN_FREE
726 else
727 #       use f_malloc
728         C_DEFS+= -DF_MALLOC
729 ifeq    ($(MEMDBG), 1)
730                 C_DEFS+= -DDBG_F_MALLOC
731 endif
732         C_DEFS+= -DMEM_JOIN_FREE
733 endif
734
735 ifneq ($(PKG_MEM_SIZE),)
736         C_DEFS+= -DPKG_MEM_SIZE=$(PKG_MEM_SIZE)
737 endif
738 ifeq ($(CORE_TLS), 1)
739         C_DEFS+= -DUSE_TLS -DCORE_TLS
740 endif
741 ifeq ($(TLS_HOOKS), 1)
742         C_DEFS+= -DUSE_TLS -DTLS_HOOKS
743 endif
744 ifeq ($(KMSTATS), 1)
745         C_DEFS+= -DUSE_CORE_STATS -DSTATISTICS
746 endif
747 ifeq ($(FMSTATS), 1)
748         C_DEFS+= -DMALLOC_STATS
749 endif
750 ifeq ($(WITHAS), 1)
751         C_DEFS+= -DWITH_AS_SUPPORT
752 endif
753
754 ifneq ($(STUN),)
755         C_DEFS+= -DUSE_STUN
756 endif
757
758 ifeq ($(mode),)
759         mode = release
760 endif
761
762 ifeq ($(mode),debug)
763         C_DEFS+= -DEXTRA_DEBUG
764 endif
765
766 # platform dependent settings
767
768 # find ld & as name (gnu or solaris)
769 ifeq ($(OS), solaris)
770 ifeq ($(CC_NAME), gcc)
771                 LDGCC:=$(shell $(CC) -v 2>&1 | grep with-ld| \
772                                    sed -e 's/.*--with-ld=\([^ ][^ ]*\).*/\1/' )
773                 ASGCC:=$(shell $(CC) -v 2>&1 | grep with-as| \
774                                    sed -e 's/.*--with-as=\([^ ][^ ]*\).*/\1/' )
775                 LDPATH:=$(shell  if [ -z "$(LDGCC)" ] ; then echo "ld" ;\
776                                                 else \
777                                                 if $(LDGCC) -V 2>/dev/null 1>/dev/null; then \
778                                                         echo $(LDGCC); \
779                                                 else echo "ld" ; \
780                                                 fi\
781                                                 fi)
782                 ASPATH:=$(shell  if [ -z "$(ASGCC)" ] ; then echo "as" ;\
783                                                 else \
784                                                 if $(ASGCC) -V 2>/dev/null 1>/dev/null </dev/null; \
785                                                 then \
786                                                         echo $(ASGCC); \
787                                                 else echo "as" ; \
788                                                 fi\
789                                                 fi)
790                                                         
791                 LDTYPE:=$(shell if $(LDPATH) -V 1>/dev/null  2>/dev/null; then \
792                                                         if $(LDPATH) -V 2>&1|grep GNU >/dev/null; \
793                                                         then echo gnu; \
794                                                         else \
795                                                         if $(LDPATH) -V 2>&1|grep Solaris >/dev/null;\
796                                                         then echo solaris; \
797                                                         else \
798                                                                 echo unknown ; \
799                                                         fi \
800                                                         fi \
801                                                 fi)
802                 ASTYPE:=$(shell if $(ASPATH) -V 1>/dev/null  2>/dev/null </dev/null; \
803                                                 then \
804                                                         if $(ASPATH) -V 2>&1 </dev/null | \
805                                                                 grep GNU >/dev/null; then echo gnu; \
806                                                         else \
807                                                         if $(ASPATH) -V 2>&1 </dev/null | \
808                                                                 grep Sun >/dev/null; then echo solaris; \
809                                                         else \
810                                                                 echo unknown ; \
811                                                         fi \
812                                                         fi \
813                                                 fi)
814 #$(warning "using ld=$(LDPATH)/$(LDTYPE), as=$(ASPATH)/$(ASTYPE)")
815
816 endif
817 endif
818
819 # arch. specific definitions
820 ifeq ($(ARCH), i386)
821         use_fast_lock=yes
822 endif
823
824 ifeq ($(ARCH), x86_64)
825         use_fast_lock=yes
826 endif
827
828 ifeq ($(ARCH), sparc64)
829 ifeq    ($(CC_NAME), gcc)
830         use_fast_lock=yes
831 endif
832 endif
833
834 ifeq ($(ARCH), sparc)
835         use_fast_lock=yes
836 endif
837
838 ifeq ($(ARCH), arm)
839         use_fast_lock=yes
840         C_DEFS+=-DNOSMP # very unlikely to have an smp arm
841 endif
842
843 ifeq ($(ARCH), arm6)
844         use_fast_lock=yes
845 endif
846
847 ifeq ($(ARCH), ppc)
848         use_fast_lock=yes
849 endif
850
851 ifeq ($(ARCH), ppc64)
852         use_fast_lock=yes
853 endif
854
855 ifeq ($(ARCH), mips)
856 # mips1 arch. (e.g. R3000) - no hardware locking support
857         use_fast_lock=no
858         C_DEFS+=-DMIPS_HAS_LLSC # likely
859         C_DEFS+=-DNOSMP # very likely
860 endif
861
862 ifeq ($(ARCH), mips2)
863 # mips2 arch and newer (mips3=R4000, mips4=R5000 a.s.o)
864         use_fast_lock=yes
865 endif
866
867 ifeq ($(ARCH), mips64)
868 # mips2 arch and newer (mips3=R4000, mips4=R5000 a.s.o)
869         use_fast_lock=yes
870 endif
871
872 ifeq ($(ARCH), alpha)
873         use_fast_lock=yes
874         C_DEFS+=-DNOSMP # very likely
875 endif
876
877 ifeq ($(use_fast_lock), yes)
878         C_DEFS+= -DFAST_LOCK -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 
879         found_lock_method=yes
880 endif
881
882 CFLAGS=
883 LDFLAGS=
884 C_INCLUDES=
885 # setting CFLAGS
886 ifeq ($(mode), release)
887         #if i386
888 ifeq    ($(ARCH), i386)
889                 # if gcc 
890 ifeq            ($(CC_NAME), gcc) 
891                                 C_DEFS+=-DCC_GCC_LIKE_ASM
892                                 #common stuff
893                                 CFLAGS=-g -O9 -funroll-loops  -Wcast-align $(PROFILE)
894                         #if gcc 4.5+ or 4.2+
895 ifeq (,$(strip $(filter-out 4.2+ 4.5+,$(CC_SHORTVER))))
896 $(call                          set_if_empty,CPU,athlon64)
897                                         CFLAGS+=-m32 -minline-all-stringops \
898                                                         -falign-loops \
899                                                         -ftree-vectorize \
900                                                         -fno-strict-overflow \
901                                                         -mtune=$(CPU)
902                                         LDFLAGS+=-m32
903 else
904                         #if gcc 4.0+
905 ifeq                    ($(CC_SHORTVER), 4.x)
906 $(call                          set_if_empty,CPU,athlon64)
907                                         CFLAGS+=-m32 -minline-all-stringops \
908                                                         -falign-loops \
909                                                         -ftree-vectorize \
910                                                         -mtune=$(CPU) 
911                                         LDFLAGS+=-m32
912 else
913                         #if gcc 3.4+
914 ifeq                    ($(CC_SHORTVER), 3.4)
915 $(call                          set_if_empty,CPU,athlon)
916                                         CFLAGS+=-m32 -minline-all-stringops \
917                                                         -falign-loops \
918                                                         -mtune=$(CPU) 
919                                         LDFLAGS+=-m32
920 else
921                         #if gcc 3.0+
922 ifeq                    ($(CC_SHORTVER), 3.0)
923 $(call                          set_if_empty,CPU,athlon)
924                                         CFLAGS+=-minline-all-stringops \
925                                                         -falign-loops \
926                                                         -mcpu=$(CPU)
927                                         # -m32 supported since gcc 3.2
928 else
929 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
930 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc >= 3.1 \
931                                         for better results)
932                                         
933                                         CFLAGS+=-m486 \
934                                                         -malign-loops=4
935 else
936                                 #really old version
937 $(warning                       You are using an old and unsupported gcc \
938                                          version  ($(CC_SHORTVER)), compile at your own risk!)
939
940 endif                   # CC_SHORTVER, 2.9x
941 endif                   # CC_SHORTVER, 3.0
942 endif                   # CC_SHORTVER, 3.4
943 endif                   # CC_SHORTVER, 4.x
944 endif                   # CC_SHORTVER, 4.5+ or 4.2+
945
946 else            # CC_NAME, gcc
947 ifeq            ($(CC_NAME), clang)
948 $(call                          set_if_empty,CPU,athlon64)
949                                         C_DEFS+=-DCC_GCC_LIKE_ASM
950                                         CFLAGS+=-m32
951                                                 -O9      \
952                                                          \
953                                                 -mtune=$(CPU)
954                                         LDFLAGS+=-m32
955 else                    # CC_NAME, clang
956 ifeq            ($(CC_NAME), icc)
957                         C_DEFS+=-DCC_GCC_LIKE_ASM
958                         CFLAGS=-g -O3  -ipo -ipo_obj -unroll  $(PROFILE) \
959                                          -tpp6 -xK  #-openmp  #optimize for PIII 
960                                 # -prefetch doesn't seem to work
961                                 #( ty to inline acroos files, unroll loops,prefetch,
962                                 # optimize for PIII, use PIII instructions & vect.,
963                                 # mutlithread loops)
964 else
965                                 #other compilers
966 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
967 endif           #CC_NAME, icc
968 endif           #CC_NAME, clang
969 endif           #CC_NAME, gcc
970 endif   #ARCH, i386
971
972 #x86_64
973 ifeq    ($(ARCH), x86_64)
974                 # if gcc 
975 ifeq            ($(CC_NAME), gcc)
976                                 C_DEFS+=-DCC_GCC_LIKE_ASM
977                                 #common stuff
978                                 CFLAGS=-g -O9 -funroll-loops  -Wcast-align $(PROFILE)
979                         #if gcc 4.5+
980                         # don't add '-mtune=$(CPU)' - gcc failure
981 ifeq                    ($(CC_SHORTVER), 4.5+)
982 $(call                          set_if_empty,CPU,opteron)
983                                         CFLAGS+=-m64 -minline-all-stringops \
984                                                         -falign-loops \
985                                                         -ftree-vectorize \
986                                                         -fno-strict-overflow
987                                         LDFLAGS+=-m64
988 else
989                         #if gcc 4.2+
990 ifeq                    ($(CC_SHORTVER), 4.2+)
991 $(call                          set_if_empty,CPU,opteron)
992                                         CFLAGS+=-m64 -minline-all-stringops \
993                                                         -falign-loops \
994                                                         -ftree-vectorize \
995                                                         -fno-strict-overflow \
996                                                         -mtune=$(CPU)
997                                         LDFLAGS+=-m64
998 else
999                         #if gcc 4.0+
1000 ifeq                    ($(CC_SHORTVER), 4.x)
1001 $(call                          set_if_empty,CPU,opteron)
1002                                         CFLAGS+=-m64 -minline-all-stringops \
1003                                                         -falign-loops \
1004                                                         -ftree-vectorize \
1005                                                         -mtune=$(CPU) 
1006                                         LDFLAGS+=-m64
1007 else
1008                         #if gcc 3.4
1009 ifeq                    ($(CC_SHORTVER), 3.4)
1010 $(call                          set_if_empty,CPU,athlon64)
1011                                         CFLAGS+=-m64 -minline-all-stringops \
1012                                                         -falign-loops 
1013                                         LDFLAGS+=-m64
1014 else
1015                         #if gcc 3.0
1016 ifeq                    ($(CC_SHORTVER), 3.0)
1017 $(call                          set_if_empty,CPU,athlon64)
1018                                         CFLAGS+=-minline-all-stringops \
1019                                                         -falign-loops 
1020                                                         #-mcpu=$(CPU) \ # not working on all x86_64 gccs
1021                                                         #-mcpu=athlon
1022                                         #-m64 on x86_64/x86 works starting with gcc 3.2
1023 else
1024 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1025 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc >= 3.1 \
1026                                         for better results)
1027                                         
1028                                         CFLAGS+=-m486 \
1029                                                         -malign-loops=4
1030 else
1031                                 #really old version
1032 $(warning                       You are using an old and unsupported gcc \
1033                                          version  ($(CC_SHORTVER)), compile at your own risk!)
1034
1035 endif                   # CC_SHORTVER, 2.9x
1036 endif                   # CC_SHORTVER, 3.0
1037 endif                   # CC_SHORTVER, 3.4
1038 endif                   # CC_SHORTVER, 4.x
1039 endif                   # CC_SHORTVER, 4.2+
1040 endif                   # CC_SHORTVER, 4.5+
1041
1042 else            # CC_NAME, gcc
1043 ifeq            ($(CC_NAME), clang)
1044 $(call                          set_if_empty,CPU,opteron)
1045                                         C_DEFS+=-DCC_GCC_LIKE_ASM
1046                                         CFLAGS+=-m64 \
1047                                                 -O9        
1048                                         LDFLAGS+=-m64
1049 else            # CC_NAME, clang
1050 ifeq            ($(CC_NAME), icc)
1051                         C_DEFS+=-DCC_GCC_LIKE_ASM
1052                         CFLAGS=-g -O3  -ipo -ipo_obj -unroll  $(PROFILE) \
1053                                          -tpp6 -xK  #-openmp  #optimize for PIII 
1054                                 # -prefetch doesn't seem to work
1055                                 #( ty to inline acroos files, unroll loops,prefetch,
1056                                 # optimize for PIII, use PIII instructions & vect.,
1057                                 # mutlithread loops)
1058 else
1059                                 #other compilers
1060 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1061 endif           #CC_NAME, icc
1062 endif           #CC_NAME, clang
1063 endif           #CC_NAME, gcc
1064 endif   #ARCH, x86_64
1065
1066         #if sparc64
1067 ifeq    ($(ARCH), sparc64)
1068                         #if gcc
1069 ifeq            ($(CC_NAME), gcc)
1070                                 C_DEFS+=-DCC_GCC_LIKE_ASM -DSPARC64_MODE
1071                                 #common stuff
1072                                 CFLAGS=-g -O9 -funroll-loops  $(PROFILE) \
1073                                         #-Wcast-align \
1074                                         #-Wmissing-prototypes 
1075                                 #if gcc 4.5+ or 4.2+
1076 ifeq (,$(strip $(filter-out 4.2+ 4.5+,$(CC_SHORTVER))))
1077 $(call                          set_if_empty,CPU,ultrasparc)
1078                                         #use 32bit for now
1079                                         CFLAGS+=-m64 -mcpu=ultrasparc  \
1080                                                         -mtune=$(CPU) \
1081                                                         -fno-strict-overflow \
1082                                                         -ftree-vectorize
1083                                         # use -m64 to force 64 bit (but add it also to LDFLAGS and
1084                                         #  don't forget to define SPARC64_MODE)
1085                                         # -m32 for 32 bit (default on solaris),
1086                                         # nothing for arch. default
1087                                         LDFLAGS+=-m64
1088 else
1089                                 #if gcc 4.x
1090 ifeq                    ($(CC_SHORTVER), 4.x)
1091 $(call                          set_if_empty,CPU,ultrasparc)
1092                                         #use 32bit for now
1093                                         CFLAGS+=-m64 -mcpu=ultrasparc  \
1094                                                         -mtune=$(CPU) \
1095                                                         -ftree-vectorize
1096                                         LDFLAGS+=-m64
1097 else
1098                                 #if gcc 3.4
1099 ifeq                    ($(CC_SHORTVER), 3.4)
1100 $(call                          set_if_empty,CPU,ultrasparc)
1101                                         #use 32bit for now
1102                                         CFLAGS+=-m64 -mcpu=ultrasparc -mtune=$(CPU)
1103                                         LDFLAGS+=-m64
1104 else
1105                                 #if gcc 3.0
1106 ifeq                    ($(CC_SHORTVER), 3.0)
1107 $(call                          set_if_empty,CPU,ultrasparc)
1108                                         #use 32bit for now
1109                                         CFLAGS+=-m64 -mcpu=ultrasparc -mtune=$(CPU)   \
1110                                         # -mcpu=v9 or ultrasparc? # -mtune implied by -mcpu
1111                                         #-mno-epilogue #try to inline function exit code
1112                                         #-mflat # omit save/restore
1113                                         #-,faster-structs #faster non Sparc ABI structure copy ops
1114                                         LDFLAGS+=-m64
1115 else                    # CC_SHORTVER, 3.0
1116 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1117 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc >= 3.1 \
1118                                         for better results)
1119 ifneq                           ($(OS), netbsd)
1120                                                 # on netbsd/sparc64,  gcc 2.95.3 does not compile
1121                                                 # ser with -mv8
1122                                                 CFLAGS+= -mv9 
1123                                                 # -m64/-m32 on sparc works starting with gcc 3.0
1124 endif
1125 ifeq                                    ($(ASTYPE), solaris)
1126                                                         CFLAGS+= -Wa,-xarch=v8plus
1127 endif                                   
1128 else                    #CC_SHORTVER, 2.9x
1129                                 #really old version
1130 $(warning                       You are using an old and unsupported gcc \
1131                                          version ($(CC_SHORTVER)), compile at your own risk!)
1132                                         
1133                                         CFLAGS+= -mv9 
1134 ifeq                                    ($(ASTYPE), solaris)
1135                                                         CFLAGS+= -Wa,-xarch=v8plus
1136 endif                                   
1137         
1138 endif                   #CC_SHORTVER, 2.9x
1139 endif                   #CC_SHORTVER, 3.0
1140 endif                   #CC_SHORTVER, 3.4
1141 endif                   #CC_SHORTVER, 4.x
1142 endif                   #CC_SHORTVER, 4.5+ or 4.2+
1143         
1144 else            #CC_NAME, gcc
1145 ifeq            ($(CC_NAME), suncc)
1146                         C_DEFS+=-DSPARC64_MODE
1147                         CFLAGS+= -m64 -g -xO5 -fast -native -xarch=v9 -xCC \
1148                                         -xc99 # C99 support
1149                         # -Dinline="" # add this if cc < 5.3 (define inline as null)
1150 else
1151                                 #other compilers
1152 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1153 endif           #CC_NAME, suncc
1154 endif           #CC_NAME, gcc
1155 endif   #ARCH, sparc64
1156
1157         #if sparc
1158 ifeq    ($(ARCH), sparc)
1159                         #if gcc
1160 ifeq            ($(CC_NAME), gcc)
1161                                 C_DEFS+=-DCC_GCC_LIKE_ASM
1162                                 #common stuff
1163                                 CFLAGS=-g -O9 -funroll-loops  $(PROFILE) \
1164                                         #-Wcast-align \
1165                                         #-Wmissing-prototypes 
1166                                 #if gcc 4.5+ or 4.2+
1167 ifeq (,$(strip $(filter-out 4.2+ 4.5+,$(CC_SHORTVER))))
1168 $(call                          set_if_empty,CPU,v8)
1169                                         #use 32bit for now
1170                                         CFLAGS+= -mtune=$(CPU) \
1171                                                         -fno-strict-overflow \
1172                                                         -ftree-vectorize
1173 else
1174                                 #if gcc 4.x
1175 ifeq                    ($(CC_SHORTVER), 4.x)
1176 $(call                          set_if_empty,CPU,v8)
1177                                         #use 32bit for now
1178                                         CFLAGS+= -mtune=$(CPU) \
1179                                                         -ftree-vectorize
1180 else
1181                                 #if gcc 3.4
1182 ifeq                    ($(CC_SHORTVER), 3.4)
1183 $(call                          set_if_empty,CPU,v8)
1184                                         #use 32bit for now
1185                                         CFLAGS+= -mtune=$(CPU)
1186 else
1187                                 #if gcc 3.0
1188 ifeq                    ($(CC_SHORTVER), 3.0)
1189 $(call                          set_if_empty,CPU,v8)
1190                                         #use 32bit for now
1191                                         CFLAGS+= -mtune=$(CPU)   \
1192                                         #-mno-epilogue #try to inline function exit code
1193                                         #-mflat # omit save/restore
1194                                         #-,faster-structs #faster non Sparc ABI structure copy ops
1195 else                    # CC_SHORTVER, 3.0
1196 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1197 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc >= 3.1 \
1198                                         for better results)
1199 else                    #CC_SHORTVER, 2.9x
1200                                 #really old version
1201 $(warning                       You are using an old and unsupported gcc \
1202                                          version ($(CC_SHORTVER)), compile at your own risk!)
1203                                         
1204 endif                   #CC_SHORTVER, 2.9x
1205 endif                   #CC_SHORTVER, 3.0
1206 endif                   #CC_SHORTVER, 3.4
1207 endif                   #CC_SHORTVER, 4.x
1208 endif                   #CC_SHORTVER, 4.5+ or 4.2+
1209         
1210 else            #CC_NAME, gcc
1211 ifeq            ($(CC_NAME), suncc)
1212                         CFLAGS+= -g -xO5 -fast -native -xCC \
1213                                         -xc99 # C99 support
1214                         # -Dinline="" # add this if cc < 5.3 (define inline as null)
1215 else
1216                                 #other compilers
1217 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1218 endif           #CC_NAME, suncc
1219 endif           #CC_NAME, gcc
1220 endif   #ARCH, sparc
1221
1222         #if ipaq/netwinder
1223 ifeq    ($(ARCH), arm)
1224                 # if gcc 
1225 ifeq            ($(CC_NAME), gcc)
1226                                 C_DEFS+=-DCC_GCC_LIKE_ASM
1227                                 #common stuff
1228                                 CFLAGS=-marm -march=armv5t -O9 -funroll-loops -fsigned-char $(PROFILE)
1229                         #if gcc 4.5+ or 4.2+
1230 ifeq (,$(strip $(filter-out 4.2+ 4.5+,$(CC_SHORTVER))))
1231                                         CFLAGS+= -ftree-vectorize -fno-strict-overflow
1232                                         # not supported on arm: -minline-all-stringops 
1233 else
1234                         #if gcc 4.x+
1235 ifeq                    ($(CC_SHORTVER), 4.x)
1236                                         CFLAGS+= -ftree-vectorize
1237                                         # not supported on arm: -minline-all-stringops 
1238 else
1239                         #if gcc 3.4+
1240 ifeq                    ($(CC_SHORTVER), 3.4)
1241                                         CFLAGS+=
1242 else
1243                         #if gcc 3.0
1244 ifeq                    ($(CC_SHORTVER), 3.0)
1245                                         CFLAGS+= 
1246                                                         #-mcpu=athlon
1247 else
1248 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1249 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
1250                                         for better results)
1251                                         
1252                                         CFLAGS+=
1253 else
1254                                 #really old version
1255 $(warning                       You are using an old and unsupported gcc \
1256                                          version ($(CC_SHORTVER)), compile at your own risk!)
1257         
1258 endif                   # CC_SHORTVER, 2.9x
1259 endif                   # CC_SHORTVER, 3.0
1260 endif                   # CC_SHORTVER, 3.4
1261 endif                   # CC_SHORTVER, 4.x
1262 endif                   # CC_SHORTVER, 4.5+ or 4.2+
1263         
1264 else            # CC_NAME, gcc
1265                                 #other compilers
1266 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1267 endif           #CC_NAME, gcc
1268 endif   #ARCH, arm 
1269
1270         #if armv6 cpu 
1271 ifeq    ($(ARCH), arm6)
1272                 # if gcc 
1273 ifeq            ($(CC_NAME), gcc)
1274                                 C_DEFS+=-DCC_GCC_LIKE_ASM
1275                                 #common stuff
1276                                 CFLAGS=-march=armv6 -O9 -funroll-loops -fsigned-char \
1277                                                 $(PROFILE)
1278                         #if gcc 4.5+ or 4.2+
1279 ifeq (,$(strip $(filter-out 4.2+ 4.5+,$(CC_SHORTVER))))
1280                                         CFLAGS+= -ftree-vectorize -fno-strict-overflow
1281 else
1282                         #if gcc 4.x+
1283 ifeq                    ($(CC_SHORTVER), 4.x)
1284                                         CFLAGS+= -ftree-vectorize
1285 else
1286                         #if gcc 3.4+
1287 ifeq                    ($(CC_SHORTVER), 3.4)
1288                                         CFLAGS+=
1289 else
1290                         #if gcc 3.0
1291 ifeq                    ($(CC_SHORTVER), 3.0)
1292                                         CFLAGS+= 
1293                                                         #-mcpu=athlon
1294 else
1295 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1296 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
1297                                         for better results)
1298                                         
1299                                         CFLAGS+=
1300 else
1301                                 #really old version
1302 $(warning                       You are using an old and unsupported gcc \
1303                                          version ($(CC_SHORTVER)), compile at your own risk!)
1304         
1305 endif                   # CC_SHORTVER, 2.9x
1306 endif                   # CC_SHORTVER, 3.0
1307 endif                   # CC_SHORTVER, 3.4
1308 endif                   # CC_SHORTVER, 4.x
1309 endif                   # CC_SHORTVER, 4.5+ or 4.2+
1310         
1311 else            # CC_NAME, gcc
1312                                 #other compilers
1313 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1314 endif           #CC_NAME, gcc
1315 endif   #ARCH, arm6
1316
1317         #if  mips (R3000)
1318 ifeq    ($(ARCH), mips)
1319                 # if gcc 
1320 ifeq            ($(CC_NAME), gcc)
1321                                 C_DEFS+=-DCC_GCC_LIKE_ASM
1322                                 #common stuff
1323                                 CFLAGS=-O9 -funroll-loops  $(PROFILE)
1324                         #if gcc 4.5+ or 4.2+
1325 ifeq (,$(strip $(filter-out 4.2+ 4.5+,$(CC_SHORTVER))))
1326                                         CFLAGS+=-march=r3000 -minline-all-stringops \
1327                                                         -ftree-vectorize -fno-strict-overflow
1328 else
1329                         #if gcc 4.0+
1330 ifeq                    ($(CC_SHORTVER), 4.x)
1331                                         CFLAGS+=-march=r3000 -minline-all-stringops \
1332                                                         -ftree-vectorize
1333 else
1334                         #if gcc 3.4+
1335 ifeq                    ($(CC_SHORTVER), 3.4)
1336                                         CFLAGS+= -march=r3000
1337 else
1338                         #if gcc 3.0
1339 ifeq                    ($(CC_SHORTVER), 3.0)
1340                                         CFLAGS+= -march=r3000
1341 else
1342 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1343 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
1344                                         for better results)
1345                                         
1346                                         CFLAGS+=-march=r3000
1347 else
1348                                 #really old version
1349 $(warning                       You are using an old and unsupported gcc \
1350                                          version ($(CC_SHORTVER)), compile at your own risk!)
1351         
1352 endif                   # CC_SHORTVER, 2.9x
1353 endif                   # CC_SHORTVER, 3.0
1354 endif                   # CC_SHORTVER, 3.4
1355 endif                   # CC_SHORTVER, 4.x
1356 endif                   # CC_SHORTVER, 4.5+ or 4.2+
1357         
1358 else            # CC_NAME, gcc
1359                                 #other compilers
1360 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1361 endif           #CC_NAME, gcc
1362 endif   #ARCH, mips
1363
1364         #if  >=mips2 (R4000, R5000, R6000 ....)
1365 ifeq    ($(ARCH), mips2)
1366                 # if gcc 
1367 ifeq            ($(CC_NAME), gcc)
1368                                 C_DEFS+=-DCC_GCC_LIKE_ASM
1369                                 #common stuff
1370                                 CFLAGS= -mips2 -O9 -funroll-loops $(PROFILE)
1371                         #if gcc 4.5+ or 4.2+
1372 ifeq (,$(strip $(filter-out 4.2+ 4.5+,$(CC_SHORTVER))))
1373                                         CFLAGS+=-minline-all-stringops -ftree-vectorize \
1374                                                         -fno-strict-overflow
1375 else
1376                         #if gcc 4.0+
1377 ifeq                    ($(CC_SHORTVER), 4.x)
1378                                         CFLAGS+=-minline-all-stringops -ftree-vectorize
1379 else
1380                         #if gcc 3.4+
1381 ifeq                    ($(CC_SHORTVER), 3.4)
1382                                         CFLAGS+=
1383 else
1384                         #if gcc 3.0
1385 ifeq                    ($(CC_SHORTVER), 3.0)
1386                                         CFLAGS+=
1387 else
1388 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1389 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
1390                                         for better results)
1391                                         CFLAGS+=
1392 else
1393                                 #really old version
1394 $(warning                       You are using an old and unsupported gcc \
1395                                          version ($(CC_SHORTVER)), compile at your own risk!)
1396         
1397 endif                   # CC_SHORTVER, 2.9x
1398 endif                   # CC_SHORTVER, 3.0
1399 endif                   # CC_SHORTVER, 3.4
1400 endif                   # CC_SHORTVER, 4.x
1401 endif                   # CC_SHORTVER, 4.5+ or 4.2+
1402         
1403 else            # CC_NAME, gcc
1404                                 #other compilers
1405 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1406 endif           #CC_NAME, gcc
1407 endif   #ARCH, mips2
1408
1409 #if  >=mips64
1410 ifeq    ($(ARCH), mips64)
1411                 # if gcc 
1412 ifeq            ($(CC_NAME), gcc)
1413                                 C_DEFS+=-DCC_GCC_LIKE_ASM
1414                                 #common stuff
1415                                 CFLAGS= -mips64 -O9 -funroll-loops $(PROFILE)
1416                         #if gcc 4.5+ or 4.2+
1417 ifeq (,$(strip $(filter-out 4.2+ 4.5+,$(CC_SHORTVER))))
1418                                         CFLAGS+=-minline-all-stringops -ftree-vectorize \
1419                                                         -fno-strict-overflow
1420 else
1421                         #if gcc 4.0+
1422 ifeq                    ($(CC_SHORTVER), 4.x)
1423                                         CFLAGS+=-minline-all-stringops -ftree-vectorize
1424 else
1425                         #if gcc 3.4+
1426 ifeq                    ($(CC_SHORTVER), 3.4)
1427                                         CFLAGS+=
1428 else
1429                         #if gcc 3.0
1430 ifeq                    ($(CC_SHORTVER), 3.0)
1431                                         CFLAGS+=
1432 else
1433 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1434 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
1435                                         for better results)
1436                                         CFLAGS+=
1437 else
1438                                 #really old version
1439 $(warning                       You are using an old and unsupported gcc \
1440                                          version ($(CC_SHORTVER)), compile at your own risk!)
1441         
1442 endif                   # CC_SHORTVER, 2.9x
1443 endif                   # CC_SHORTVER, 3.0
1444 endif                   # CC_SHORTVER, 3.4
1445 endif                   # CC_SHORTVER, 4.x
1446 endif                   # CC_SHORTVER, 4.5+ or 4.2+
1447         
1448 else            # CC_NAME, gcc
1449                                 #other compilers
1450 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1451 endif           #CC_NAME, gcc
1452 endif   #ARCH, mips64
1453
1454 #if  alpha
1455 ifeq    ($(ARCH), alpha)
1456                 # if gcc 
1457 ifeq            ($(CC_NAME), gcc)
1458                                 C_DEFS+=-DCC_GCC_LIKE_ASM
1459                                 #common stuff
1460                                 CFLAGS= -O9 -funroll-loops $(PROFILE)
1461                         #if gcc 4.5 or 4.2+
1462 ifeq (,$(strip $(filter-out 4.2+ 4.5+,$(CC_SHORTVER))))
1463                                         CFLAGS+= -fno-strict-overflow
1464                                         # not supported: -minline-all-stringops
1465 else
1466                         #if gcc 4.0+
1467 ifeq                    ($(CC_SHORTVER), 4.x)
1468                                         CFLAGS+= 
1469                                         # not supported: -minline-all-stringops
1470 else
1471                         #if gcc 3.4+
1472 ifeq                    ($(CC_SHORTVER), 3.4)
1473                                         CFLAGS+=
1474 else
1475                         #if gcc 3.0
1476 ifeq                    ($(CC_SHORTVER), 3.0)
1477                                         CFLAGS+=
1478 else
1479 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1480 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
1481                                         for better results)
1482                                         CFLAGS+=
1483 else
1484                                 #really old version
1485 $(warning                       You are using an old and unsupported gcc \
1486                                          version ($(CC_SHORTVER)), compile at your own risk!)
1487         
1488 endif                   # CC_SHORTVER, 2.9x
1489 endif                   # CC_SHORTVER, 3.0
1490 endif                   # CC_SHORTVER, 3.4
1491 endif                   # CC_SHORTVER, 4.x
1492 endif                   # CC_SHORTVER, 4.5+ or 4.2+
1493         
1494 else            # CC_NAME, gcc
1495                                 #other compilers
1496 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1497 endif           #CC_NAME, gcc
1498 endif   #ARCH, alpha 
1499
1500 #if  ppc
1501 ifeq    ($(ARCH), ppc)
1502                 # if gcc 
1503 ifeq            ($(CC_NAME), gcc)
1504                                 C_DEFS+=-DCC_GCC_LIKE_ASM
1505                                 #common stuff
1506                                 CFLAGS= -O9 -funroll-loops -fsigned-char $(PROFILE)
1507                         #if gcc 4.5+ or 4.2+
1508 ifeq (,$(strip $(filter-out 4.2+ 4.5+,$(CC_SHORTVER))))
1509 $(call                          set_if_empty,CPU,powerpc)
1510                                         CFLAGS+=-ftree-vectorize \
1511                                                         -fno-strict-overflow \
1512                                                         -mtune=$(CPU) -maltivec
1513 else
1514                         #if gcc 4.0+
1515 ifeq                    ($(CC_SHORTVER), 4.x)
1516 $(call                          set_if_empty,CPU,powerpc)
1517                                         CFLAGS+=-ftree-vectorize \
1518                                                         -mtune=$(CPU) -maltivec
1519 else
1520                         #if gcc 3.4+
1521 ifeq                    ($(CC_SHORTVER), 3.4)
1522                                         CFLAGS+=
1523 else
1524                         #if gcc 3.0
1525 ifeq                    ($(CC_SHORTVER), 3.0)
1526                                         CFLAGS+=
1527 else
1528 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1529 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
1530                                         for better results)
1531                                         CFLAGS+=
1532 else
1533                                 #really old version
1534 $(warning                       You are using an old and unsupported gcc \
1535                                          version ($(CC_SHORTVER)), compile at your own risk!)
1536         
1537 endif                   # CC_SHORTVER, 2.9x
1538 endif                   # CC_SHORTVER, 3.0
1539 endif                   # CC_SHORTVER, 3.4
1540 endif                   # CC_SHORTVER, 4.x
1541 endif                   # CC_SHORTVER, 4.5+ or 4.2+
1542         
1543 else            # CC_NAME, gcc
1544                                 #other compilers
1545 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1546 endif           #CC_NAME, gcc
1547 endif   #ARCH, ppc 
1548
1549 #if  ppc64
1550 ifeq    ($(ARCH), ppc64)
1551                 # if gcc 
1552 ifeq            ($(CC_NAME), gcc)
1553                                 C_DEFS+=-DCC_GCC_LIKE_ASM
1554                                 #common stuff
1555                                 CFLAGS= -O9 -funroll-loops -fsigned-char $(PROFILE)
1556                         #if gcc 4.5+ or 4.2+
1557 ifeq (,$(strip $(filter-out 4.2+ 4.5+,$(CC_SHORTVER))))
1558 $(call                          set_if_empty,CPU,powerpc64)
1559                                         CFLAGS+=-ftree-vectorize \
1560                                                         -fno-strict-overflow \
1561                                                         -mtune=$(CPU) -maltivec
1562 else
1563                         #if gcc 4.0+
1564 ifeq                    ($(CC_SHORTVER), 4.x)
1565 $(call                          set_if_empty,CPU,powerpc64)
1566                                         CFLAGS+=-ftree-vectorize \
1567                                                         -mtune=$(CPU) -maltivec
1568 else
1569                         #if gcc 3.4+
1570 ifeq                    ($(CC_SHORTVER), 3.4)
1571                                         CFLAGS+=
1572 else
1573                         #if gcc 3.0
1574 ifeq                    ($(CC_SHORTVER), 3.0)
1575                                         CFLAGS+=
1576 else
1577 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1578 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
1579                                         for better results)
1580                                         CFLAGS+=
1581 else
1582                                 #really old version
1583 $(warning                       You are using an old and unsupported gcc \
1584                                          version ($(CC_SHORTVER)), compile at your own risk!)
1585         
1586 endif                   # CC_SHORTVER, 2.9x
1587 endif                   # CC_SHORTVER, 3.0
1588 endif                   # CC_SHORTVER, 3.4
1589 endif                   # CC_SHORTVER, 4.x
1590 endif                   # CC_SHORTVER, 4.5+ or 4.2+
1591         
1592 else            # CC_NAME, gcc
1593                                 #other compilers
1594 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1595 endif           #CC_NAME, gcc
1596 endif   #ARCH, ppc 
1597
1598 CFLAGS+= $(CC_EXTRA_OPTS)
1599
1600
1601 # setting LDFLAGS
1602 ifeq    ($(CC_NAME), gcc)
1603 ifeq            ($(LDTYPE), solaris)
1604                 # solaris ld
1605                 LDFLAGS+=-O2 $(PROFILE)
1606                 MOD_LDFLAGS:=-G $(LDFLAGS)
1607                 LIB_LDFLAGS:=-G $(LDFLAGS)
1608                 LIB_SONAME=-Wl,-h,
1609                 LD_RPATH=-Wl,-R,
1610 else            
1611                 #gcc and maybe others, => gnu ld
1612                 LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE) 
1613                 MOD_LDFLAGS:=-shared $(LDFLAGS)
1614                 LIB_LDFLAGS:=-shared $(LDFLAGS)
1615                 LIB_SONAME=-Wl,-soname,
1616                 LD_RPATH=-Wl,-rpath,
1617 endif
1618 endif
1619 ifeq    ($(CC_NAME), icc)
1620         #gcc and maybe others
1621         LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE) 
1622         MOD_LDFLAGS:=-shared $(LDFLAGS)
1623         LIB_LDFLAGS:=-shared $(LDFLAGS)
1624         LIB_SONAME=-Wl,-soname,
1625         LD_RPATH=-Wl,-rpath,
1626 endif
1627 ifeq    ($(CC_NAME), suncc)
1628         # -dy?
1629         LDFLAGS+=-xO5 $(PROFILE)
1630         MOD_LDFLAGS:=-G $(LDFLAGS)
1631         LIB_LDFLAGS:=-G $(LDFLAGS)
1632         LIB_SONAME="-h "
1633         LD_RPATH=-"-R "
1634 endif
1635         # we need -fPIC -DPIC only for shared objects, we don't need them for
1636         # the executable file, because it's always loaded at a fixed address
1637         # -andrei
1638
1639 ifeq ($(CC_NAME), clang)
1640         LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE)
1641         MOD_LDFLAGS:=-shared $(LDFLAGS)
1642         LIB_LDFLAGS:=-shared $(LDFLAGS)
1643         LIB_SONAME=-Wl,-soname,
1644         LD_RPATH=-Wl,-rpath,
1645 endif
1646
1647 LDFLAGS+= $(LD_EXTRA_OPTS)
1648 MOD_LDFLAGS+= $(LD_EXTRA_OPTS)
1649 LIB_LDFLAGS+= $(LD_EXTRA_OPTS)
1650
1651 else    #mode,release
1652 ifeq    ($(CC_NAME), gcc)
1653                 CFLAGS=-g -Wcast-align $(PROFILE)
1654                 C_DEFS+=-DCC_GCC_LIKE_ASM
1655 ifeq            ($(ARCH), sparc64)
1656                         C_DEFS+=SPARC64_MODE
1657                         CFLAGS+= -mcpu=ultrasparc -m64
1658                         LDFLAGS+=-m64
1659 endif
1660 ifeq            ($(LDTYPE), solaris)
1661                         #solaris ld
1662                         LDFLAGS+=-g $(PROFILE)
1663                         MOD_LDFLAGS:=-G $(LDFLAGS)
1664                         LIB_LDFLAGS:=-G $(LDFLAGS)
1665                         LIB_SONAME=-Wl,-h,
1666                         LD_RPATH=-Wl,-R,
1667 else
1668                         #gnu or other ld type
1669                         LDFLAGS+=-g -Wl,-E $(PROFILE)
1670                         MOD_LDFLAGS:=-shared $(LDFLAGS)
1671                         LIB_LDFLAGS:=-shared $(LDFLAGS)
1672                         LIB_SONAME=-Wl,-soname,
1673                         LD_RPATH=-Wl,-rpath,
1674 endif
1675 endif
1676 ifeq    ($(CC_NAME), icc)
1677                 C_DEFS+=-DCC_GCC_LIKE_ASM
1678                 CFLAGS=-g  $(PROFILE)
1679                 LDFLAGS+=-g -Wl,-E $(PROFILE)
1680                 MOD_LDFLAGS:=-shared $(LDFLAGS)
1681                 LIB_LDFLAGS:=-shared $(LDFLAGS)
1682                 LIB_SONAME=-Wl,-soname,
1683                 LD_RPATH=-Wl,-rpath,
1684 endif
1685 ifeq    ($(CC_NAME), suncc)
1686                 CFLAGS= -g $(PROFILE)
1687                 LDFLAGS+=-g $(PROFILE)
1688                 MOD_LDFLAGS:=-G $(LDFLAGS)
1689                 LIB_LDFLAGS:=-G $(LDFLAGS)
1690                 LIB_SONAME="-h "
1691                 LD_RPATH=-"-R "
1692 endif
1693
1694 endif #mode=release
1695
1696
1697 # set pedantic compiler options
1698 ifeq ($(CC_NAME), gcc)
1699                 CFLAGS+= -Wall
1700 else # no gcc
1701 ifeq ($(CC_NAME), icc)
1702                 CFLAGS+= -Wall
1703 else # no icc
1704 ifeq ($(CC_NAME), suncc)
1705                 # FIXME: is the default (-Xa ?) enough?
1706 endif # CC_NAME=suncc
1707 endif # CC_NAME=icc
1708 endif # CC_NAME=gcc
1709
1710 #CFLAGS used for compiling the modules, libraries and utils
1711 ifeq    ($(CC_NAME), gcc)
1712 MOD_CFLAGS=-fPIC -DPIC $(CFLAGS)
1713 LIB_CFLAGS=-fPIC -DPIC $(CFLAGS)
1714 endif
1715 ifeq    ($(CC_NAME), icc)
1716 MOD_CFLAGS=-Kpic $(CFLAGS)
1717 LIB_CFLAGS=-Kpic $(CFLAGS)
1718 endif
1719 ifeq    ($(CC_NAME), suncc)
1720 # FIMXE: use -KPIC instead -xcode ?
1721 MOD_CFLAGS=-xcode=pic32  $(CFLAGS)
1722 LIB_CFLAGS=-xcode=pic32  $(CFLAGS)
1723 endif
1724 ifeq    ($(CC_NAME), clang)
1725 MOD_CFLAGS=-fPIC -DPIC $(CFLAGS)
1726 LIB_CFLAGS=-fPIC -DPIC $(CFLAGS)
1727 endif
1728
1729 UTILS_CFLAGS=$(CFLAGS)
1730 # LDFLAGS uses for compiling the utils
1731 UTILS_LDFLAGS=$(LDFLAGS)
1732
1733 ifeq ($(LEX),)
1734         LEX=flex
1735 endif
1736 ifeq ($(YACC),)
1737         YACC=bison
1738 endif
1739 YACC_FLAGS=-d -b cfg
1740 # on solaris add -lxnet (e.g. LIBS= -lxnet)
1741 LIBS= -ldl -lresolv
1742 LIB_PREFIX:=lib
1743 LIB_SUFFIX:=.so
1744
1745
1746 #os specific stuff
1747 ifeq ($(OS), linux)
1748 # by default use futexes if available
1749         use_futex= yes
1750         C_DEFS+=-DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
1751                         -DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H \
1752                         -DHAVE_TIMEGM -DHAVE_SCHED_SETSCHEDULER -DUSE_RAW_SOCKS
1753         ifneq ($(found_lock_method), yes)
1754                 #C_DEFS+= -DUSE_POSIX_SEM
1755                 C_DEFS+=-DUSE_PTHREAD_MUTEX
1756                 LIBS+= -lpthread
1757                 #C_DEFS+= -DUSE_SYSV_SEM  # try posix sems
1758                 found_lock_method=yes
1759         else
1760                 ifneq (,$(findstring -DUSE_POSIX_SEM, $(C_DEFS)))
1761                         LIBS+=-lpthread
1762                 endif
1763                 ifneq (,$(findstring -DUSE_PTHREAD_MUTEX, $(C_DEFS)))
1764                         LIBS+=-lpthread
1765                 endif
1766         endif
1767         ifneq (,$(findstring -DUSE_DNSSEC, $(C_DEFS)))
1768                 LIBS+=-lval-threads -lcrypto -lsres -lpthread
1769 $(info "using libval for DNSSEC validation")
1770         endif
1771         # check for >= 2.5.44
1772
1773         ifeq ($(shell [ $(OSREL_N) -ge 2005044 ] && echo has_epoll), has_epoll)
1774                 ifeq ($(NO_EPOLL),)
1775                         C_DEFS+=-DHAVE_EPOLL
1776                         # linux + gcc >= 3.0 + -malign-double + epoll => problems
1777                         CFLAGS_RM+=-malign-double
1778                         #CFLAGS:=$(filter-out -malign-double, $(CFLAGS))
1779                 endif
1780         endif
1781         # check for >= 2.2.0
1782         ifeq ($(shell [ $(OSREL_N) -ge 2002000 ] && echo has_sigio), has_sigio)
1783                 ifeq ($(NO_SIGIO),)
1784                         C_DEFS+=-DHAVE_SIGIO_RT -DSIGINFO64_WORKARROUND
1785                 endif
1786         endif
1787         # check for >= 2.5.70
1788         ifeq ($(shell [ $(OSREL_N) -ge 2005070 ] && echo has_futex), has_futex)
1789                 ifeq ($(use_futex), yes)
1790                         C_DEFS+=-DUSE_FUTEX
1791                 endif
1792         endif
1793         ifeq ($(NO_SELECT),)
1794                 C_DEFS+=-DHAVE_SELECT
1795         endif
1796         # sctp support
1797         ifeq ($(SCTP),1)
1798                 # test to see if the devfiles and lib are installed
1799                 sctp_dev_locations := /usr/include/netinet/sctp.h \
1800                                                                 $(LOCALBASE)/include/netinet/sctp.h
1801                 sctp_lib_locations := /usr/lib/libsctp.so \
1802                                                                 /usr/lib64/libsctp.so \
1803                                                                 $(LOCALBASE)/usr/local/lib/libsctp.so
1804                 sctp_dev_path := $(wildcard $(sctp_dev_locations))
1805                 sctp_lib_path := $(wildcard $(sctp_lib_locations))
1806                 ifeq ($(sctp_dev_path),)
1807 $(info "sctp development files not installed -- sctp disabled")
1808                         override SCTP := 
1809                 endif
1810                 ifeq ($(sctp_lib_path),)
1811 $(info "sctp libraries not installed -- sctp disabled")
1812                         override SCTP := 
1813                 endif
1814                 
1815                 ifeq ($(SCTP),1)
1816                         # use lksctp
1817                         C_DEFS+=-DUSE_SCTP
1818                         LIBS+=-lsctp
1819                 endif
1820         endif # SCTP
1821 endif
1822
1823 ifeq  ($(OS), solaris)
1824         C_DEFS+= -DHAVE_GETIPNODEBYNAME -DHAVE_SYS_SOCKIO_H -DHAVE_SCHED_YIELD \
1825                         -DHAVE_ALLOCA_H -DUSE_SIGACTION
1826         ifneq ($(found_lock_method), yes)
1827                 C_DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1828                 found_lock_method=yes
1829         endif
1830         # check for ver >= 5.7
1831         ifeq ($(shell [ $(OSREL_N) -gt 5007 ] && echo has_devpoll), has_devpoll)
1832                 ifeq ($(NO_DEVPOLL),)
1833                         C_DEFS+=-DHAVE_DEVPOLL
1834                 endif
1835         endif
1836         ifeq ($(NO_SELECT),)
1837                 C_DEFS+=-DHAVE_SELECT
1838         endif
1839         # check for filio.h
1840         filio_h_locations= /usr/include/sys/filio.h \
1841                                                 $(LOCALBASE)/include/sys/filio.h
1842         has_filio_h=$(shell for r in $(filio_h_locations); do \
1843                                                 if  [ -r "$$r" ] ; then echo yes; exit; fi \
1844                                                 done;\
1845                                 )
1846         ifeq ($(has_filio_h), yes)
1847                 C_DEFS+=-DHAVE_FILIO_H
1848         endif
1849         ifeq ($(mode), release)
1850                 #use these only if you're using gcc with Solaris ld
1851                 #LDFLAGS=-O2 $(PROFILE)
1852                 #MOD_LDFLAGS=-O2 -G
1853         else
1854                 #LDFLAGS=-g $(PROFILE)
1855                 #MOD_LDFLAGS=-g -G
1856         endif
1857         YACC=yacc
1858
1859 ifeq ($(CC_NAME), suncc)
1860         LIBS= -lfast -ldl -lresolv
1861 endif
1862         OLD_SOLARIS= $(shell echo "$(OSREL)" | \
1863                                 sed -e 's/^5\.[0-6][^0-9]*$$/yes/' )
1864         LIBS+= -L$(LOCALBASE)/lib -lxnet -lnsl 
1865 ifeq    ($(OLD_SOLARIS), yes)
1866                 LIBS+=-lposix4
1867 else
1868                 LIBS+=-lrt
1869 endif
1870         # -lrt needed for sched_yield
1871 endif
1872
1873 ifeq ($(OS), freebsd)
1874         C_DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
1875                 -DHAVE_SCHED_YIELD -DHAVE_MSGHDR_MSG_CONTROL \
1876                 -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
1877                 -DHAVE_NETINET_IN_SYSTM -DUSE_RAW_SOCKS
1878         ifneq ($(found_lock_method), yes)
1879                 C_DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1880                 found_lock_method=yes
1881                 LIBS+= -pthread   #dlopen is in libc
1882         else
1883                 LIBS=   #dlopen is in libc
1884         endif
1885         # check for ver >= 4.1
1886         ifeq ($(shell [ $(OSREL_N) -gt 4001 ] && echo has_kqueue), has_kqueue)
1887                 ifeq ($(NO_KQUEUE),)
1888                         C_DEFS+=-DHAVE_KQUEUE
1889                 endif
1890         endif
1891         ifeq ($(NO_SELECT),)
1892                 C_DEFS+=-DHAVE_SELECT
1893         endif
1894         YACC=yacc
1895         # sctp support
1896         ifeq ($(SCTP),1)
1897                 # test to see if the devfiles and lib are installed
1898                 sctp_dev_locations := /usr/include/netinet/sctp.h \
1899                                                                 $(LOCALBASE)/include/netinet/sctp.h
1900                 sctp_dev_path := $(wildcard $(sctp_dev_locations))
1901                 ifeq ($(sctp_dev_path),)
1902 $(info "sctp development files not installed -- sctp disabled")
1903                         override SCTP := 
1904                 endif
1905                 ifeq ($(shell [ $(OSREL_N) -lt 7000 ] && echo sctp), sctp)
1906 $(info "old freebsd version (>= 7.0 needed) -- sctp disabled")
1907                         override SCTP := 
1908                 endif
1909                 
1910                 ifeq ($(SCTP),1)
1911                         C_DEFS+=-DUSE_SCTP
1912                         LIBS+=  # no extra libs needed on freebsd
1913                 endif
1914         endif # SCTP
1915 endif
1916
1917 ifeq ($(OS), dragonfly)
1918         C_DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
1919                 -DHAVE_SCHED_YIELD -DHAVE_MSGHDR_MSG_CONTROL \
1920                 -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
1921                 -DHAVE_NETINET_IN_SYSTM
1922         ifneq ($(found_lock_method), yes)
1923                 C_DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1924                 found_lock_method=yes
1925                 LIBS+= -pthread   #dlopen is in libc
1926         else
1927                 LIBS=   #dlopen is in libc
1928         endif
1929         # dragonfly was forked from freebsd 4.8 => all version have kqueue
1930         ifeq ($(NO_KQUEUE),)
1931                 C_DEFS+=-DHAVE_KQUEUE
1932         endif
1933         ifeq ($(NO_SELECT),)
1934                 C_DEFS+=-DHAVE_SELECT
1935         endif
1936         YACC=yacc
1937         # sctp support
1938         ifeq ($(SCTP),1)
1939                 # test to see if the devfiles and lib are installed
1940                 sctp_dev_locations := /usr/include/netinet/sctp.h \
1941                                                                 $(LOCALBASE)/include/netinet/sctp.h
1942                 sctp_dev_path := $(wildcard $(sctp_dev_locations))
1943                 ifeq ($(sctp_dev_path),)
1944 $(info "sctp development files not installed -- sctp disabled")
1945                         override SCTP :=
1946                 endif
1947                 # FIXME: don't know what's the status of SCTP on dragonfly
1948                 #        (we suppose the 2.6 version is >= the version in
1949                 #         in freebsd 7.0)
1950                 ifeq ($(shell [ $(OSREL_N) -lt 2006 ] && echo sctp), sctp)
1951 $(info "old dragonfly version (>= 2.6 needed) -- sctp disabled")
1952                         override SCTP :=
1953                 endif
1954                 
1955                 ifeq ($(SCTP),1)
1956                         C_DEFS+=-DUSE_SCTP
1957                         LIBS+=  # no extra libs needed on freebsd
1958                 endif
1959         endif # SCTP
1960 endif
1961
1962 ifeq ($(OS), openbsd)
1963         C_DEFS+=-DHAVE_SOCKADDR_SA_LEN  -DHAVE_GETHOSTBYNAME2 \
1964                 -DHAVE_UNION_SEMUN -DHAVE_MSGHDR_MSG_CONTROL \
1965                 -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
1966                 -DHAVE_NETINET_IN_SYSTM -DUSE_SIGWAIT
1967         ifneq ($(found_lock_method), yes)
1968                 C_DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1969                 found_lock_method=yes
1970         endif
1971         # check for ver >=2 9
1972         ifeq ($(shell [ $(OSREL_N) -ge 2009 ] && echo has_kqueue), has_kqueue)
1973                 ifeq ($(NO_KQUEUE),)
1974                         C_DEFS+=-DHAVE_KQUEUE
1975                 endif
1976         endif
1977         ifeq ($(NO_SELECT),)
1978                 C_DEFS+=-DHAVE_SELECT
1979         endif
1980         # (symbols on openbsd are prefixed by "_")
1981         YACC=yacc
1982         # no sched_yield on openbsd unless linking with c_r (not recommended)
1983         # unfortunately pthread is needed for sigwait
1984         LIBS= -lpthread
1985         OPENBSD_IS_AOUT:= $(shell echo "$(OSREL)" | \
1986                                 sed -e 's/^3\.[0-3][^0-9]*$$/yes/' |sed -e 's/^[0-2]\..*/yes/')
1987 # exception: on sparc openbsd 3.2 is elf and not aout
1988 ifeq ($(OSREL), 3.2)
1989 ifeq    ($(ARCH), sparc)
1990                 OPENBSD_IS_AOUT:=no
1991 endif
1992 ifeq    ($(ARCH), sparc64)
1993                 OPENBSD_IS_AOUT:=no
1994 endif
1995 endif
1996         
1997 ifeq ($(OPENBSD_IS_AOUT), yes)
1998                 C_DEFS+=-DDLSYM_PREFIX='"_"'
1999                 LDFLAGS=        # openbsd ld doesn't like -O2 or -E
2000 endif
2001 endif   # if opensd
2002         
2003 ifeq ($(OS), netbsd)
2004         C_DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 \
2005                 -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM
2006         ifneq ($(found_lock_method), yes)
2007                 C_DEFS+= -DUSE_SYSV_SEM  # try pthread sems
2008                 found_lock_method=yes
2009         endif
2010         # check for ver >= 2.0.0
2011         ifeq ($(shell [ $(OSREL_N) -ge 2000000 ] && echo has_kqueue), has_kqueue)
2012                 ifeq ($(NO_KQUEUE),)
2013                         C_DEFS+=-DHAVE_KQUEUE
2014                         # netbsd + kqueue and -malign-double don't work
2015                         CFLAGS_RM+=-malign-double
2016                         #CFLAGS:=$(filter-out -malign-double, $(CFLAGS))
2017                 endif
2018         endif
2019         ifeq ($(NO_SELECT),)
2020                 C_DEFS+=-DHAVE_SELECT
2021         endif
2022         YACC=yacc
2023         LIBS=  
2024 endif
2025
2026 # OS X support, same as freebsd
2027 ifeq ($(OS), darwin)
2028         C_DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
2029                 -DHAVE_SCHED_YIELD -DHAVE_MSGHDR_MSG_CONTROL \
2030                 -DUSE_ANON_MMAP \
2031                 -DNDEBUG -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
2032                 -DUSE_SIGWAIT
2033         # -DNDEBUG used to turn off assert (assert wants to call
2034         # eprintf which doesn't seem to be defined in any shared lib
2035         ifneq ($(found_lock_method), yes)
2036                 C_DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
2037                 found_lock_method=yes
2038                 C_DEFS+= -DUSE_SYSV_SEM  # try sys v sems (pthread don't work for
2039                                        # processes and unnamed posix sems are not
2040                                        # supported)
2041         endif
2042         LIBS= -lresolv  #dlopen is in libc
2043         ifeq ($(NO_KQUEUE),)
2044                 C_DEFS+=-DHAVE_KQUEUE
2045         endif
2046         ifeq ($(NO_SELECT),)
2047                 C_DEFS+=-DHAVE_SELECT
2048         endif
2049         LDFLAGS=        # darwin doesn't like -O2 or -E
2050         # the modules uses symbols from ser => either 
2051         # -flat_namespace -undefined_suppress or -bundle_loader ../../$(MAIN_NAME)
2052         MOD_LDFLAGS:= -bundle -flat_namespace -undefined suppress
2053         # for libs using symbols from ser (e.g srdb2, kcore a.s.o) we
2054         # need -flat_namespace -undefined suppress
2055         LIB_LDFLAGS:= -dynamiclib -flat_namespace -undefined suppress
2056         LIB_SUFFIX:=.dylib
2057         # on darwin soname should include the full path
2058         # (it kind of combines rpath & soname)
2059         LIB_SONAME=
2060         # no equiv. for rpath on darwin
2061         LD_RPATH=
2062         YACC=yacc
2063 endif
2064
2065 ifneq (,$(findstring cygwin, $(OS)))
2066         # cygwin doesn't support IPV6 and doesn't support fd passing so no TCP
2067         #C_DEFS:=$(filter-out -DUSE_IPV6 -DUSE_TCP, $(C_DEFS))
2068         DEFS_RM+=-DUSE_IPV6 -DUSE_TCP
2069         C_DEFS+=-DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
2070                         -DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H \
2071                         -DHAVE_TIMEGM -DHAVE_SCHED_SETSCHEDULER
2072         ifneq ($(found_lock_method), yes)
2073                 C_DEFS+= -DUSE_POSIX_SEM
2074                 #C_DEFS+= -DUSE_SYSV_SEM  # try posix sems
2075                 # PTHREAD_MUTEX do not work for processes (try test/pthread_test.c)
2076                 #LIBS+= -lpthread
2077                 found_lock_method=yes
2078         else
2079                 ifneq (,$(findstring -DUSE_POSIX_SEM, $(C_DEFS)))
2080                         #LIBS+=-lpthread
2081                 endif
2082                 ifneq (,$(findstring -DUSE_PTHREAD_MUTEX, $(C_DEFS)))
2083 $(error PTHREAD_MUTEX do not work for processes on Windows/CYGWIN)
2084                 endif
2085         endif
2086         # check for >= 2.5.70
2087         ifeq ($(NO_SELECT),)
2088                 C_DEFS+=-DHAVE_SELECT
2089         endif
2090 endif
2091
2092 #add libssl if needed
2093 ifeq ($(CORE_TLS), 1)
2094 C_INCLUDES+= -I$(LOCALBASE)/ssl/include
2095 LIBS+= -L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib -lssl -lcrypto \
2096                 $(TLS_EXTRA_LIBS)
2097 # NOTE: depending on the way in which libssl was compiled you might
2098 #       have to add -lz -lkrb5   (zlib and kerberos5).
2099 #       E.g.: make CORE_TLS=1 EXTRA_TLS_LIBS="-lz -lkrb5"
2100 endif
2101
2102 ifneq ($(STUN),)
2103 C_INCLUDES+= -I$(LOCALBASE)/ssl/include
2104 LIBS+= -L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib -lcrypto
2105 endif
2106
2107 ifneq ($(found_lock_method), yes)
2108 $(warning       No locking method found so far, trying SYS V sems)
2109                 C_DEFS+= -DUSE_SYSV_SEM  # try sys v sems
2110                 found_lock_method=yes
2111 endif
2112
2113
2114 endif # ifeq (,$(main_makefile))
2115 endif  # ifeq ($(makefile_defs), 1)
2116
2117 # if incomplete or missing config.mak, or already exported vars, don't
2118 # try to export/re-export
2119 ifeq ($(makefile_defs),1) 
2120 ifneq ($(exported_vars),1)
2121
2122
2123 override exported_vars:=1
2124 export exported_vars
2125
2126 # variable changeable only at configure time (once saved in config.mak they
2127 #  cannot be overwritten from environment or command line, unless make cfg
2128 #  is run)
2129 saved_fixed_vars:=      MAIN_NAME  CFG_NAME SCR_NAME FLAVOUR INSTALL_FLAVOUR \
2130                 SRC_NAME RELEASE OS ARCH \
2131                 C_DEFS DEFS_RM PROFILE CC LD MKDEP MKTAGS LDFLAGS C_INCLUDES \
2132                 CC_MKDEP_OPTS \
2133                 MOD_LDFLAGS LIB_LDFLAGS UTILS_LDFLAGS LIB_SONAME LD_RPATH \
2134                 LIB_SUFFIX LIB_PREFIX \
2135                 LIBS \
2136                 LEX YACC YACC_FLAGS \
2137                 PREFIX LOCALBASE \
2138                 TAR \
2139                 INSTALL INSTALL_CFG INSTALL_BIN INSTALL_MODULES INSTALL_DOC \
2140                 INSTALL_MAN INSTALL_LIB INSTALL_TOUCH INSTALL_SHARE \
2141                 Q
2142
2143 # variable changeable at compile time
2144 # extra: prefix DESTDIR BASEDIR basedirt
2145 saved_chg_vars:=\
2146                 CC_EXTRA_OPTS CPU CFLAGS_RM CFLAGS MOD_CFLAGS LIB_CFLAGS UTILS_CFLAGS \
2147                 BASEDIR basedir DESTDIR LIBDIR \
2148                 PREFIX prefix\
2149                 cfg_prefix cfg_dir bin_prefix bin_dir modules_prefix modules_dir \
2150                 doc_prefix doc_dir man_prefix man_dir ut_prefix ut_dir \
2151                 share_prefix share_dir lib_prefix lib_dir data_prefix data_dir \
2152                 cfg_target lib_target data_target
2153
2154
2155 #export relevant variables to the sub-makes
2156 export $(saved_fixed_vars)
2157 export $(saved_chg_vars)
2158
2159
2160 endif # ifneq ($(exported_vars),1)
2161 endif # ifeq ($(makefile_defs),1)
2162