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