parser/sdp: more suggestive debug message
[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 = 4
164 SUBLEVEL =  0
165 EXTRAVERSION = -dev1
166
167 # memory debugger switcher
168 # 0 - off (release mode)
169 # 1 - on (devel mode)
170 MEMDBG ?= 0
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-4]\..*/4.2+/' \
297                                         -e 's/4\.[2-4]$$/4.2+/' \
298                                         -e 's/4\.[5-9]\..*/4.5+/' \
299                                         -e 's/4\.[5-9]$$/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 # -DMEM_JOIN_FREE
564 #               enable the join of free memory chunks (see also mem_join cfg param)
565 # -DFAST_LOCK
566 #               uses fast arhitecture specific locking (see the arh. specific section)
567 # -DUSE_SYSV_SEM
568 #               uses sys v sems for locking (slower & limited number)
569 # -DUSE_PTHREAD_MUTEX
570 #               uses pthread mutexes, faster than sys v or posix sems, but do not 
571 #               work on all systems inter-processes (e.g. linux)
572 # -DUSE_POSIX_SEM
573 #               uses posix semaphores for locking (faster than sys v)
574 # -DUSE_FUTEX
575 #               uses futexes for locking (linux 2.6+)
576 # -DBUSY_WAIT
577 #               uses busy waiting on the lock (FAST_LOCK)
578 # -DADAPTIVE_WAIT
579 #               try busy waiting for a while and if the lock is still held go to
580 #               force reschedule (FAST_LOCK)
581 # -DADAPTIVE_WAIT_LOOPS=number
582 #               number of loops we busy wait, after "number" loops have elapsed we 
583 #               force a reschedule (FAST_LOCK)
584 # -DNOSMP
585 #               don't use smp compliant locking (faster but won't work on SMP machines)
586 #               (not yet enabled) (FAST_LOCK)
587 # -DNO_PINGTEL_TAG_HACK
588 #               if enabled, To-header-field will be less liberal and will not accept
589 #               'tag=' (tag parameter with equal sign and without value); it is called
590 #               this way because such message was sighted from a Pingtel phone
591 # -DUSE_TCP
592 #               compiles in tcp support
593 # -DDISABLE_NAGLE
594 #               disable the tcp Nagle algorithm (lower delay)
595 # -DUSE_TLS
596 #               compiles in tls support, requires -DUSE_TCP. Note: this is only 
597 #               generic support (parsing a.s.o.), it does not include the actual
598 #               "tls engine". If you really want tls you need also either
599 #               -DCORE_TLS and a tls/ subdir with the tls code or -DTLS_HOOKS and
600 #               the tls module loaded.
601 # -DCORE_TLS
602 #               compiles tls in-core support. Requires -DUSE_TLS, conflicts 
603 #               -DTLS_HOOKS. Please use make CORE_TLS=1 instead  (it will set all the
604 #               needed defines automatically and extra libraries needed for linking).
605 # -DTLS_HOOKS
606 #               compile tls module support (support for having the "tls engine" in a
607 #               module). Requires -DUSE_TLS, conflicts -DCORE_TLS.
608 #               Please use make TLS_HOOKS=1 (or TLS_HOOKS=0 to for disabling) instead
609 #               of setting -DTLS_HOOKS (it will set all the needed defines 
610 #               automatically)
611 # -DHAVE_RESOLV_RES
612 #               support for changing some of the resolver parameters present
613 #                (_res structure in <resolv.h>)
614 # -DUSE_COMP
615 #               compiles in comp=[sergz|sigcomp] support (parsing uri & via, 
616 #               adding it to via, lumps a.s.o). WARNING: right now this option
617 #               is useless since the compression code doesn't exist yet.
618 # -DHONOR_MADDR
619 #               compiles in checks and use for maddr parameter in uri.
620 #               Required to support Windows Messenger 5.x over TCP connection
621 #               which (mis)uses this parameter.
622 # -DUSE_DNS_CACHE
623 #               use an internal dns cache instead of making dns requests each time
624 # -DUSE_DNS_CACHE_STATS
625 #               turns on DNS cache measurements
626 # -DUSE_DNS_FAILOVER
627 #               if the destination resolves to multiple ips, on send error fall back
628 #               to the others
629 # -DUSE_DST_BLACKLIST
630 #               blacklist bad destination (timeout, failed to connect, error sending
631 #        a.s.o)
632 # -DUSE_DST_BLACKLIST_STATS
633 #               turns on blacklist bad destination measurements
634 # -DPROFILING
635 #               if enabled profiling will be enabled for child processes
636 #               Don't forget to set PROFILE (see below)
637 # -DUSE_STUN
638 #               compiles in stun support
639 # -DNO_SIG_DEBUG
640 #        turns off debugging messages in signal handlers (which might be 
641 #         unsafe)
642 # -DUSE_NAPTR
643 #                turns on naptr support (but must be also enabled from the config)
644 # -DDNS_WATCHDOG_SUPPORT
645 #               turns on DNS watchdog support which can be used to inform the
646 #               core that the DNS servers are down. No DNS query is performed
647 #               when the servers are unreachable, and even expired resource
648 #               records are used from the cache. (requires external watchdog)
649 # -DWITH_AS_SUPPORT
650 #               adds support for Application Server interface
651 # Sometimes is needes correct non-quoted $OS. HACK: gcc translates known OS to number ('linux'), so there is added underscore
652
653 ifeq ($(OS), dragonfly)
654         # Tell it that dragonflybsd is equivalent to compiling for freebsd, but
655         # define also __OS_dragonfly (for fine-tunning like kqueue support).
656         os_defs := -D__OS_freebsd -D__OS_dragonfly
657         EQUIV_OS = freebsd
658 else
659         os_defs := -D__OS_$(OS)
660         EQUIV_OS = $(OS)
661 endif
662
663 C_DEFS= $(extra_defs) \
664          -DNAME='"$(MAIN_NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
665          -DOS='$(OS)_' -DOS_QUOTED='"$(OS)"' -DCOMPILER='"$(CC_VER)"'\
666          -D__CPU_$(ARCH) $(os_defs) \
667          -DSER_VER=$(SER_VER) \
668          -DCFG_DIR='"$(cfg_target)"'\
669          -DPKG_MALLOC \
670          -DSHM_MEM  -DSHM_MMAP \
671          -DDNS_IP_HACK \
672          -DUSE_IPV6 \
673          -DUSE_MCAST \
674          -DUSE_TCP \
675          -DDISABLE_NAGLE \
676          -DHAVE_RESOLV_RES \
677          -DUSE_DNS_CACHE \
678          -DUSE_DNS_FAILOVER \
679          -DUSE_DST_BLACKLIST \
680          -DUSE_NAPTR \
681          -DWITH_XAVP \
682          #-DUSE_DNS_CACHE_STATS \
683          #-DUSE_DST_BLACKLIST_STATS \
684          #-DDNS_WATCHDOG_SUPPORT \
685          #-DLL_MALLOC \
686          #-DSF_MALLOC \
687          #-DDL_MALLOC \
688          #-DDBG_F_MALLOC \
689          #-DNO_DEBUG \
690          #-DEXTRA_DEBUG \
691          #-DVQ_MALLOC  \
692          #-DDBG_LOCK \
693          #-DNOSMP \
694          #-DUSE_SHM_MEM \
695          #-DSTATS \
696          #-DNO_LOG \
697          #-DPROFILING \
698          #-DNO_SIG_DEBUG
699
700 #PROFILE=  -pg  # set this if you want profiling
701                                 # you may also want to set -DPROFILING
702
703 # WARNING: do not add mode=debug or mode=release anymore in the Makefile,
704 # use make mode=debug all instead. Anyway no by default ser is  compiled w/ 
705 # debugging symbols in all cases (-g). --andrei
706
707 ifeq ($(MEMDBG), 1)
708         C_DEFS+= -DDBG_QM_MALLOC
709         C_DEFS+= -DMEM_JOIN_FREE
710 else
711         C_DEFS+= -DF_MALLOC
712         C_DEFS+= -DMEM_JOIN_FREE
713 endif
714 ifneq ($(PKG_MEM_SIZE),)
715         C_DEFS+= -DPKG_MEM_SIZE=$(PKG_MEM_SIZE)
716 endif
717 ifeq ($(CORE_TLS), 1)
718         C_DEFS+= -DUSE_TLS -DCORE_TLS
719 endif
720 ifeq ($(TLS_HOOKS), 1)
721         C_DEFS+= -DUSE_TLS -DTLS_HOOKS
722 endif
723 ifeq ($(KMSTATS), 1)
724         C_DEFS+= -DUSE_CORE_STATS -DSTATISTICS
725 endif
726 ifeq ($(FMSTATS), 1)
727         C_DEFS+= -DMALLOC_STATS
728 endif
729 ifeq ($(WITHAS), 1)
730         C_DEFS+= -DWITH_AS_SUPPORT
731 endif
732
733 ifneq ($(STUN),)
734         C_DEFS+= -DUSE_STUN
735 endif
736
737 ifeq ($(mode),)
738         mode = release
739 endif
740
741 ifeq ($(mode),debug)
742         C_DEFS+= -DEXTRA_DEBUG
743 endif
744
745 # platform dependent settings
746
747 # find ld & as name (gnu or solaris)
748 ifeq ($(OS), solaris)
749 ifeq ($(CC_NAME), gcc)
750                 LDGCC:=$(shell $(CC) -v 2>&1 | grep with-ld| \
751                                    sed -e 's/.*--with-ld=\([^ ][^ ]*\).*/\1/' )
752                 ASGCC:=$(shell $(CC) -v 2>&1 | grep with-as| \
753                                    sed -e 's/.*--with-as=\([^ ][^ ]*\).*/\1/' )
754                 LDPATH:=$(shell  if [ -z "$(LDGCC)" ] ; then echo "ld" ;\
755                                                 else \
756                                                 if $(LDGCC) -V 2>/dev/null 1>/dev/null; then \
757                                                         echo $(LDGCC); \
758                                                 else echo "ld" ; \
759                                                 fi\
760                                                 fi)
761                 ASPATH:=$(shell  if [ -z "$(ASGCC)" ] ; then echo "as" ;\
762                                                 else \
763                                                 if $(ASGCC) -V 2>/dev/null 1>/dev/null </dev/null; \
764                                                 then \
765                                                         echo $(ASGCC); \
766                                                 else echo "as" ; \
767                                                 fi\
768                                                 fi)
769                                                         
770                 LDTYPE:=$(shell if $(LDPATH) -V 1>/dev/null  2>/dev/null; then \
771                                                         if $(LDPATH) -V 2>&1|grep GNU >/dev/null; \
772                                                         then echo gnu; \
773                                                         else \
774                                                         if $(LDPATH) -V 2>&1|grep Solaris >/dev/null;\
775                                                         then echo solaris; \
776                                                         else \
777                                                                 echo unknown ; \
778                                                         fi \
779                                                         fi \
780                                                 fi)
781                 ASTYPE:=$(shell if $(ASPATH) -V 1>/dev/null  2>/dev/null </dev/null; \
782                                                 then \
783                                                         if $(ASPATH) -V 2>&1 </dev/null | \
784                                                                 grep GNU >/dev/null; then echo gnu; \
785                                                         else \
786                                                         if $(ASPATH) -V 2>&1 </dev/null | \
787                                                                 grep Sun >/dev/null; then echo solaris; \
788                                                         else \
789                                                                 echo unknown ; \
790                                                         fi \
791                                                         fi \
792                                                 fi)
793 #$(warning "using ld=$(LDPATH)/$(LDTYPE), as=$(ASPATH)/$(ASTYPE)")
794
795 endif
796 endif
797
798 # arch. specific definitions
799 ifeq ($(ARCH), i386)
800         use_fast_lock=yes
801 endif
802
803 ifeq ($(ARCH), x86_64)
804         use_fast_lock=yes
805 endif
806
807 ifeq ($(ARCH), sparc64)
808 ifeq    ($(CC_NAME), gcc)
809         use_fast_lock=yes
810 endif
811 endif
812
813 ifeq ($(ARCH), sparc)
814         use_fast_lock=yes
815 endif
816
817 ifeq ($(ARCH), arm)
818         use_fast_lock=yes
819         C_DEFS+=-DNOSMP # very unlikely to have an smp arm
820 endif
821
822 ifeq ($(ARCH), arm6)
823         use_fast_lock=yes
824 endif
825
826 ifeq ($(ARCH), ppc)
827         use_fast_lock=yes
828 endif
829
830 ifeq ($(ARCH), ppc64)
831         use_fast_lock=yes
832 endif
833
834 ifeq ($(ARCH), mips)
835 # mips1 arch. (e.g. R3000) - no hardware locking support
836         use_fast_lock=no
837         C_DEFS+=-DMIPS_HAS_LLSC # likely
838         C_DEFS+=-DNOSMP # very likely
839 endif
840
841 ifeq ($(ARCH), mips2)
842 # mips2 arch and newer (mips3=R4000, mips4=R5000 a.s.o)
843         use_fast_lock=yes
844 endif
845
846 ifeq ($(ARCH), mips64)
847 # mips2 arch and newer (mips3=R4000, mips4=R5000 a.s.o)
848         use_fast_lock=yes
849 endif
850
851 ifeq ($(ARCH), alpha)
852         use_fast_lock=yes
853         C_DEFS+=-DNOSMP # very likely
854 endif
855
856 ifeq ($(use_fast_lock), yes)
857         C_DEFS+= -DFAST_LOCK -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 
858         found_lock_method=yes
859 endif
860
861 CFLAGS=
862 LDFLAGS=
863 C_INCLUDES=
864 # setting CFLAGS
865 ifeq ($(mode), release)
866         #if i386
867 ifeq    ($(ARCH), i386)
868                 # if gcc 
869 ifeq            ($(CC_NAME), gcc)
870                                 C_DEFS+=-DCC_GCC_LIKE_ASM
871                                 #common stuff
872                                 CFLAGS=-g -O9 -funroll-loops  -Wcast-align $(PROFILE)
873                         #if gcc 4.5+ or 4.2+
874 ifeq (,$(strip $(filter-out 4.2+ 4.5+,$(CC_SHORTVER))))
875 $(call                          set_if_empty,CPU,athlon64)
876                                         CFLAGS+=-m32 -minline-all-stringops \
877                                                         -falign-loops \
878                                                         -ftree-vectorize \
879                                                         -fno-strict-overflow \
880                                                         -mtune=$(CPU)
881                                         LDFLAGS+=-m32
882 else
883                         #if gcc 4.0+
884 ifeq                    ($(CC_SHORTVER), 4.x)
885 $(call                          set_if_empty,CPU,athlon64)
886                                         CFLAGS+=-m32 -minline-all-stringops \
887                                                         -falign-loops \
888                                                         -ftree-vectorize \
889                                                         -mtune=$(CPU) 
890                                         LDFLAGS+=-m32
891 else
892                         #if gcc 3.4+
893 ifeq                    ($(CC_SHORTVER), 3.4)
894 $(call                          set_if_empty,CPU,athlon)
895                                         CFLAGS+=-m32 -minline-all-stringops \
896                                                         -falign-loops \
897                                                         -mtune=$(CPU) 
898                                         LDFLAGS+=-m32
899 else
900                         #if gcc 3.0+
901 ifeq                    ($(CC_SHORTVER), 3.0)
902 $(call                          set_if_empty,CPU,athlon)
903                                         CFLAGS+=-minline-all-stringops \
904                                                         -falign-loops \
905                                                         -mcpu=$(CPU)
906                                         # -m32 supported since gcc 3.2
907 else
908 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
909 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc >= 3.1 \
910                                         for better results)
911                                         
912                                         CFLAGS+=-m486 \
913                                                         -malign-loops=4
914 else
915                                 #really old version
916 $(warning                       You are using an old and unsupported gcc \
917                                          version  ($(CC_SHORTVER)), compile at your own risk!)
918
919 endif                   # CC_SHORTVER, 2.9x
920 endif                   # CC_SHORTVER, 3.0
921 endif                   # CC_SHORTVER, 3.4
922 endif                   # CC_SHORTVER, 4.x
923 endif                   # CC_SHORTVER, 4.5+ or 4.2+
924
925 else            # CC_NAME, gcc
926 ifeq            ($(CC_NAME), icc)
927                         C_DEFS+=-DCC_GCC_LIKE_ASM
928                         CFLAGS=-g -O3  -ipo -ipo_obj -unroll  $(PROFILE) \
929                                          -tpp6 -xK  #-openmp  #optimize for PIII 
930                                 # -prefetch doesn't seem to work
931                                 #( ty to inline acroos files, unroll loops,prefetch,
932                                 # optimize for PIII, use PIII instructions & vect.,
933                                 # mutlithread loops)
934 else
935                                 #other compilers
936 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
937 endif           #CC_NAME, icc
938 endif           #CC_NAME, gcc
939 endif   #ARCH, i386
940
941 #x86_64
942 ifeq    ($(ARCH), x86_64)
943                 # if gcc 
944 ifeq            ($(CC_NAME), gcc)
945                                 C_DEFS+=-DCC_GCC_LIKE_ASM
946                                 #common stuff
947                                 CFLAGS=-g -O9 -funroll-loops  -Wcast-align $(PROFILE)
948                         #if gcc 4.5+
949                         # don't add '-mtune=$(CPU)' - gcc failure
950 ifeq                    ($(CC_SHORTVER), 4.5+)
951 $(call                          set_if_empty,CPU,opteron)
952                                         CFLAGS+=-m64 -minline-all-stringops \
953                                                         -falign-loops \
954                                                         -ftree-vectorize \
955                                                         -fno-strict-overflow
956                                         LDFLAGS+=-m64
957 else
958                         #if gcc 4.2+
959 ifeq                    ($(CC_SHORTVER), 4.2+)
960 $(call                          set_if_empty,CPU,opteron)
961                                         CFLAGS+=-m64 -minline-all-stringops \
962                                                         -falign-loops \
963                                                         -ftree-vectorize \
964                                                         -fno-strict-overflow \
965                                                         -mtune=$(CPU)
966                                         LDFLAGS+=-m64
967 else
968                         #if gcc 4.0+
969 ifeq                    ($(CC_SHORTVER), 4.x)
970 $(call                          set_if_empty,CPU,opteron)
971                                         CFLAGS+=-m64 -minline-all-stringops \
972                                                         -falign-loops \
973                                                         -ftree-vectorize \
974                                                         -mtune=$(CPU) 
975                                         LDFLAGS+=-m64
976 else
977                         #if gcc 3.4
978 ifeq                    ($(CC_SHORTVER), 3.4)
979 $(call                          set_if_empty,CPU,athlon64)
980                                         CFLAGS+=-m64 -minline-all-stringops \
981                                                         -falign-loops 
982                                         LDFLAGS+=-m64
983 else
984                         #if gcc 3.0
985 ifeq                    ($(CC_SHORTVER), 3.0)
986 $(call                          set_if_empty,CPU,athlon64)
987                                         CFLAGS+=-minline-all-stringops \
988                                                         -falign-loops 
989                                                         #-mcpu=$(CPU) \ # not working on all x86_64 gccs
990                                                         #-mcpu=athlon
991                                         #-m64 on x86_64/x86 works starting with gcc 3.2
992 else
993 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
994 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc >= 3.1 \
995                                         for better results)
996                                         
997                                         CFLAGS+=-m486 \
998                                                         -malign-loops=4
999 else
1000                                 #really old version
1001 $(warning                       You are using an old and unsupported gcc \
1002                                          version  ($(CC_SHORTVER)), compile at your own risk!)
1003
1004 endif                   # CC_SHORTVER, 2.9x
1005 endif                   # CC_SHORTVER, 3.0
1006 endif                   # CC_SHORTVER, 3.4
1007 endif                   # CC_SHORTVER, 4.x
1008 endif                   # CC_SHORTVER, 4.2+
1009 endif                   # CC_SHORTVER, 4.5+
1010
1011 else            # CC_NAME, gcc
1012 ifeq            ($(CC_NAME), icc)
1013                         C_DEFS+=-DCC_GCC_LIKE_ASM
1014                         CFLAGS=-g -O3  -ipo -ipo_obj -unroll  $(PROFILE) \
1015                                          -tpp6 -xK  #-openmp  #optimize for PIII 
1016                                 # -prefetch doesn't seem to work
1017                                 #( ty to inline acroos files, unroll loops,prefetch,
1018                                 # optimize for PIII, use PIII instructions & vect.,
1019                                 # mutlithread loops)
1020 else
1021                                 #other compilers
1022 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1023 endif           #CC_NAME, icc
1024 endif           #CC_NAME, gcc
1025 endif   #ARCH, x86_64
1026
1027         #if sparc64
1028 ifeq    ($(ARCH), sparc64)
1029                         #if gcc
1030 ifeq            ($(CC_NAME), gcc)
1031                                 C_DEFS+=-DCC_GCC_LIKE_ASM -DSPARC64_MODE
1032                                 #common stuff
1033                                 CFLAGS=-g -O9 -funroll-loops  $(PROFILE) \
1034                                         #-Wcast-align \
1035                                         #-Wmissing-prototypes 
1036                                 #if gcc 4.5+ or 4.2+
1037 ifeq (,$(strip $(filter-out 4.2+ 4.5+,$(CC_SHORTVER))))
1038 $(call                          set_if_empty,CPU,ultrasparc)
1039                                         #use 32bit for now
1040                                         CFLAGS+=-m64 -mcpu=ultrasparc  \
1041                                                         -mtune=$(CPU) \
1042                                                         -fno-strict-overflow \
1043                                                         -ftree-vectorize
1044                                         # use -m64 to force 64 bit (but add it also to LDFLAGS and
1045                                         #  don't forget to define SPARC64_MODE)
1046                                         # -m32 for 32 bit (default on solaris),
1047                                         # nothing for arch. default
1048                                         LDFLAGS+=-m64
1049 else
1050                                 #if gcc 4.x
1051 ifeq                    ($(CC_SHORTVER), 4.x)
1052 $(call                          set_if_empty,CPU,ultrasparc)
1053                                         #use 32bit for now
1054                                         CFLAGS+=-m64 -mcpu=ultrasparc  \
1055                                                         -mtune=$(CPU) \
1056                                                         -ftree-vectorize
1057                                         LDFLAGS+=-m64
1058 else
1059                                 #if gcc 3.4
1060 ifeq                    ($(CC_SHORTVER), 3.4)
1061 $(call                          set_if_empty,CPU,ultrasparc)
1062                                         #use 32bit for now
1063                                         CFLAGS+=-m64 -mcpu=ultrasparc -mtune=$(CPU)
1064                                         LDFLAGS+=-m64
1065 else
1066                                 #if gcc 3.0
1067 ifeq                    ($(CC_SHORTVER), 3.0)
1068 $(call                          set_if_empty,CPU,ultrasparc)
1069                                         #use 32bit for now
1070                                         CFLAGS+=-m64 -mcpu=ultrasparc -mtune=$(CPU)   \
1071                                         # -mcpu=v9 or ultrasparc? # -mtune implied by -mcpu
1072                                         #-mno-epilogue #try to inline function exit code
1073                                         #-mflat # omit save/restore
1074                                         #-,faster-structs #faster non Sparc ABI structure copy ops
1075                                         LDFLAGS+=-m64
1076 else                    # CC_SHORTVER, 3.0
1077 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1078 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc >= 3.1 \
1079                                         for better results)
1080 ifneq                           ($(OS), netbsd)
1081                                                 # on netbsd/sparc64,  gcc 2.95.3 does not compile
1082                                                 # ser with -mv8
1083                                                 CFLAGS+= -mv9 
1084                                                 # -m64/-m32 on sparc works starting with gcc 3.0
1085 endif
1086 ifeq                                    ($(ASTYPE), solaris)
1087                                                         CFLAGS+= -Wa,-xarch=v8plus
1088 endif                                   
1089 else                    #CC_SHORTVER, 2.9x
1090                                 #really old version
1091 $(warning                       You are using an old and unsupported gcc \
1092                                          version ($(CC_SHORTVER)), compile at your own risk!)
1093                                         
1094                                         CFLAGS+= -mv9 
1095 ifeq                                    ($(ASTYPE), solaris)
1096                                                         CFLAGS+= -Wa,-xarch=v8plus
1097 endif                                   
1098         
1099 endif                   #CC_SHORTVER, 2.9x
1100 endif                   #CC_SHORTVER, 3.0
1101 endif                   #CC_SHORTVER, 3.4
1102 endif                   #CC_SHORTVER, 4.x
1103 endif                   #CC_SHORTVER, 4.5+ or 4.2+
1104         
1105 else            #CC_NAME, gcc
1106 ifeq            ($(CC_NAME), suncc)
1107                         C_DEFS+=-DSPARC64_MODE
1108                         CFLAGS+= -m64 -g -xO5 -fast -native -xarch=v9 -xCC \
1109                                         -xc99 # C99 support
1110                         # -Dinline="" # add this if cc < 5.3 (define inline as null)
1111 else
1112                                 #other compilers
1113 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1114 endif           #CC_NAME, suncc
1115 endif           #CC_NAME, gcc
1116 endif   #ARCH, sparc64
1117
1118         #if sparc
1119 ifeq    ($(ARCH), sparc)
1120                         #if gcc
1121 ifeq            ($(CC_NAME), gcc)
1122                                 C_DEFS+=-DCC_GCC_LIKE_ASM
1123                                 #common stuff
1124                                 CFLAGS=-g -O9 -funroll-loops  $(PROFILE) \
1125                                         #-Wcast-align \
1126                                         #-Wmissing-prototypes 
1127                                 #if gcc 4.5+ or 4.2+
1128 ifeq (,$(strip $(filter-out 4.2+ 4.5+,$(CC_SHORTVER))))
1129 $(call                          set_if_empty,CPU,v8)
1130                                         #use 32bit for now
1131                                         CFLAGS+= -mtune=$(CPU) \
1132                                                         -fno-strict-overflow \
1133                                                         -ftree-vectorize
1134 else
1135                                 #if gcc 4.x
1136 ifeq                    ($(CC_SHORTVER), 4.x)
1137 $(call                          set_if_empty,CPU,v8)
1138                                         #use 32bit for now
1139                                         CFLAGS+= -mtune=$(CPU) \
1140                                                         -ftree-vectorize
1141 else
1142                                 #if gcc 3.4
1143 ifeq                    ($(CC_SHORTVER), 3.4)
1144 $(call                          set_if_empty,CPU,v8)
1145                                         #use 32bit for now
1146                                         CFLAGS+= -mtune=$(CPU)
1147 else
1148                                 #if gcc 3.0
1149 ifeq                    ($(CC_SHORTVER), 3.0)
1150 $(call                          set_if_empty,CPU,v8)
1151                                         #use 32bit for now
1152                                         CFLAGS+= -mtune=$(CPU)   \
1153                                         #-mno-epilogue #try to inline function exit code
1154                                         #-mflat # omit save/restore
1155                                         #-,faster-structs #faster non Sparc ABI structure copy ops
1156 else                    # CC_SHORTVER, 3.0
1157 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1158 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc >= 3.1 \
1159                                         for better results)
1160 else                    #CC_SHORTVER, 2.9x
1161                                 #really old version
1162 $(warning                       You are using an old and unsupported gcc \
1163                                          version ($(CC_SHORTVER)), compile at your own risk!)
1164                                         
1165 endif                   #CC_SHORTVER, 2.9x
1166 endif                   #CC_SHORTVER, 3.0
1167 endif                   #CC_SHORTVER, 3.4
1168 endif                   #CC_SHORTVER, 4.x
1169 endif                   #CC_SHORTVER, 4.5+ or 4.2+
1170         
1171 else            #CC_NAME, gcc
1172 ifeq            ($(CC_NAME), suncc)
1173                         CFLAGS+= -g -xO5 -fast -native -xCC \
1174                                         -xc99 # C99 support
1175                         # -Dinline="" # add this if cc < 5.3 (define inline as null)
1176 else
1177                                 #other compilers
1178 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1179 endif           #CC_NAME, suncc
1180 endif           #CC_NAME, gcc
1181 endif   #ARCH, sparc
1182
1183         #if ipaq/netwinder
1184 ifeq    ($(ARCH), arm)
1185                 # if gcc 
1186 ifeq            ($(CC_NAME), gcc)
1187                                 C_DEFS+=-DCC_GCC_LIKE_ASM
1188                                 #common stuff
1189                                 CFLAGS=-O9 -funroll-loops -fsigned-char $(PROFILE)
1190                         #if gcc 4.5+ or 4.2+
1191 ifeq (,$(strip $(filter-out 4.2+ 4.5+,$(CC_SHORTVER))))
1192                                         CFLAGS+= -ftree-vectorize -fno-strict-overflow
1193                                         # not supported on arm: -minline-all-stringops 
1194 else
1195                         #if gcc 4.x+
1196 ifeq                    ($(CC_SHORTVER), 4.x)
1197                                         CFLAGS+= -ftree-vectorize
1198                                         # not supported on arm: -minline-all-stringops 
1199 else
1200                         #if gcc 3.4+
1201 ifeq                    ($(CC_SHORTVER), 3.4)
1202                                         CFLAGS+=
1203 else
1204                         #if gcc 3.0
1205 ifeq                    ($(CC_SHORTVER), 3.0)
1206                                         CFLAGS+= 
1207                                                         #-mcpu=athlon
1208 else
1209 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1210 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
1211                                         for better results)
1212                                         
1213                                         CFLAGS+=
1214 else
1215                                 #really old version
1216 $(warning                       You are using an old and unsupported gcc \
1217                                          version ($(CC_SHORTVER)), compile at your own risk!)
1218         
1219 endif                   # CC_SHORTVER, 2.9x
1220 endif                   # CC_SHORTVER, 3.0
1221 endif                   # CC_SHORTVER, 3.4
1222 endif                   # CC_SHORTVER, 4.x
1223 endif                   # CC_SHORTVER, 4.5+ or 4.2+
1224         
1225 else            # CC_NAME, gcc
1226                                 #other compilers
1227 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1228 endif           #CC_NAME, gcc
1229 endif   #ARCH, arm 
1230
1231         #if armv6 cpu 
1232 ifeq    ($(ARCH), arm6)
1233                 # if gcc 
1234 ifeq            ($(CC_NAME), gcc)
1235                                 C_DEFS+=-DCC_GCC_LIKE_ASM
1236                                 #common stuff
1237                                 CFLAGS=-march=armv6 -O9 -funroll-loops -fsigned-char \
1238                                                 $(PROFILE)
1239                         #if gcc 4.5+ or 4.2+
1240 ifeq (,$(strip $(filter-out 4.2+ 4.5+,$(CC_SHORTVER))))
1241                                         CFLAGS+= -ftree-vectorize -fno-strict-overflow
1242 else
1243                         #if gcc 4.x+
1244 ifeq                    ($(CC_SHORTVER), 4.x)
1245                                         CFLAGS+= -ftree-vectorize
1246 else
1247                         #if gcc 3.4+
1248 ifeq                    ($(CC_SHORTVER), 3.4)
1249                                         CFLAGS+=
1250 else
1251                         #if gcc 3.0
1252 ifeq                    ($(CC_SHORTVER), 3.0)
1253                                         CFLAGS+= 
1254                                                         #-mcpu=athlon
1255 else
1256 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1257 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
1258                                         for better results)
1259                                         
1260                                         CFLAGS+=
1261 else
1262                                 #really old version
1263 $(warning                       You are using an old and unsupported gcc \
1264                                          version ($(CC_SHORTVER)), compile at your own risk!)
1265         
1266 endif                   # CC_SHORTVER, 2.9x
1267 endif                   # CC_SHORTVER, 3.0
1268 endif                   # CC_SHORTVER, 3.4
1269 endif                   # CC_SHORTVER, 4.x
1270 endif                   # CC_SHORTVER, 4.5+ or 4.2+
1271         
1272 else            # CC_NAME, gcc
1273                                 #other compilers
1274 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1275 endif           #CC_NAME, gcc
1276 endif   #ARCH, arm6
1277
1278         #if  mips (R3000)
1279 ifeq    ($(ARCH), mips)
1280                 # if gcc 
1281 ifeq            ($(CC_NAME), gcc)
1282                                 C_DEFS+=-DCC_GCC_LIKE_ASM
1283                                 #common stuff
1284                                 CFLAGS=-O9 -funroll-loops  $(PROFILE)
1285                         #if gcc 4.5+ or 4.2+
1286 ifeq (,$(strip $(filter-out 4.2+ 4.5+,$(CC_SHORTVER))))
1287                                         CFLAGS+=-march=r3000 -minline-all-stringops \
1288                                                         -ftree-vectorize -fno-strict-overflow
1289 else
1290                         #if gcc 4.0+
1291 ifeq                    ($(CC_SHORTVER), 4.x)
1292                                         CFLAGS+=-march=r3000 -minline-all-stringops \
1293                                                         -ftree-vectorize
1294 else
1295                         #if gcc 3.4+
1296 ifeq                    ($(CC_SHORTVER), 3.4)
1297                                         CFLAGS+= -march=r3000
1298 else
1299                         #if gcc 3.0
1300 ifeq                    ($(CC_SHORTVER), 3.0)
1301                                         CFLAGS+= -march=r3000
1302 else
1303 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1304 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
1305                                         for better results)
1306                                         
1307                                         CFLAGS+=-march=r3000
1308 else
1309                                 #really old version
1310 $(warning                       You are using an old and unsupported gcc \
1311                                          version ($(CC_SHORTVER)), compile at your own risk!)
1312         
1313 endif                   # CC_SHORTVER, 2.9x
1314 endif                   # CC_SHORTVER, 3.0
1315 endif                   # CC_SHORTVER, 3.4
1316 endif                   # CC_SHORTVER, 4.x
1317 endif                   # CC_SHORTVER, 4.5+ or 4.2+
1318         
1319 else            # CC_NAME, gcc
1320                                 #other compilers
1321 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1322 endif           #CC_NAME, gcc
1323 endif   #ARCH, mips
1324
1325         #if  >=mips2 (R4000, R5000, R6000 ....)
1326 ifeq    ($(ARCH), mips2)
1327                 # if gcc 
1328 ifeq            ($(CC_NAME), gcc)
1329                                 C_DEFS+=-DCC_GCC_LIKE_ASM
1330                                 #common stuff
1331                                 CFLAGS= -mips2 -O9 -funroll-loops $(PROFILE)
1332                         #if gcc 4.5+ or 4.2+
1333 ifeq (,$(strip $(filter-out 4.2+ 4.5+,$(CC_SHORTVER))))
1334                                         CFLAGS+=-minline-all-stringops -ftree-vectorize \
1335                                                         -fno-strict-overflow
1336 else
1337                         #if gcc 4.0+
1338 ifeq                    ($(CC_SHORTVER), 4.x)
1339                                         CFLAGS+=-minline-all-stringops -ftree-vectorize
1340 else
1341                         #if gcc 3.4+
1342 ifeq                    ($(CC_SHORTVER), 3.4)
1343                                         CFLAGS+=
1344 else
1345                         #if gcc 3.0
1346 ifeq                    ($(CC_SHORTVER), 3.0)
1347                                         CFLAGS+=
1348 else
1349 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1350 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
1351                                         for better results)
1352                                         CFLAGS+=
1353 else
1354                                 #really old version
1355 $(warning                       You are using an old and unsupported gcc \
1356                                          version ($(CC_SHORTVER)), compile at your own risk!)
1357         
1358 endif                   # CC_SHORTVER, 2.9x
1359 endif                   # CC_SHORTVER, 3.0
1360 endif                   # CC_SHORTVER, 3.4
1361 endif                   # CC_SHORTVER, 4.x
1362 endif                   # CC_SHORTVER, 4.5+ or 4.2+
1363         
1364 else            # CC_NAME, gcc
1365                                 #other compilers
1366 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1367 endif           #CC_NAME, gcc
1368 endif   #ARCH, mips2
1369
1370 #if  >=mips64
1371 ifeq    ($(ARCH), mips64)
1372                 # if gcc 
1373 ifeq            ($(CC_NAME), gcc)
1374                                 C_DEFS+=-DCC_GCC_LIKE_ASM
1375                                 #common stuff
1376                                 CFLAGS= -mips64 -O9 -funroll-loops $(PROFILE)
1377                         #if gcc 4.5+ or 4.2+
1378 ifeq (,$(strip $(filter-out 4.2+ 4.5+,$(CC_SHORTVER))))
1379                                         CFLAGS+=-minline-all-stringops -ftree-vectorize \
1380                                                         -fno-strict-overflow
1381 else
1382                         #if gcc 4.0+
1383 ifeq                    ($(CC_SHORTVER), 4.x)
1384                                         CFLAGS+=-minline-all-stringops -ftree-vectorize
1385 else
1386                         #if gcc 3.4+
1387 ifeq                    ($(CC_SHORTVER), 3.4)
1388                                         CFLAGS+=
1389 else
1390                         #if gcc 3.0
1391 ifeq                    ($(CC_SHORTVER), 3.0)
1392                                         CFLAGS+=
1393 else
1394 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1395 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
1396                                         for better results)
1397                                         CFLAGS+=
1398 else
1399                                 #really old version
1400 $(warning                       You are using an old and unsupported gcc \
1401                                          version ($(CC_SHORTVER)), compile at your own risk!)
1402         
1403 endif                   # CC_SHORTVER, 2.9x
1404 endif                   # CC_SHORTVER, 3.0
1405 endif                   # CC_SHORTVER, 3.4
1406 endif                   # CC_SHORTVER, 4.x
1407 endif                   # CC_SHORTVER, 4.5+ or 4.2+
1408         
1409 else            # CC_NAME, gcc
1410                                 #other compilers
1411 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1412 endif           #CC_NAME, gcc
1413 endif   #ARCH, mips64
1414
1415 #if  alpha
1416 ifeq    ($(ARCH), alpha)
1417                 # if gcc 
1418 ifeq            ($(CC_NAME), gcc)
1419                                 C_DEFS+=-DCC_GCC_LIKE_ASM
1420                                 #common stuff
1421                                 CFLAGS= -O9 -funroll-loops $(PROFILE)
1422                         #if gcc 4.5 or 4.2+
1423 ifeq (,$(strip $(filter-out 4.2+ 4.5+,$(CC_SHORTVER))))
1424                                         CFLAGS+= -fno-strict-overflow
1425                                         # not supported: -minline-all-stringops
1426 else
1427                         #if gcc 4.0+
1428 ifeq                    ($(CC_SHORTVER), 4.x)
1429                                         CFLAGS+= 
1430                                         # not supported: -minline-all-stringops
1431 else
1432                         #if gcc 3.4+
1433 ifeq                    ($(CC_SHORTVER), 3.4)
1434                                         CFLAGS+=
1435 else
1436                         #if gcc 3.0
1437 ifeq                    ($(CC_SHORTVER), 3.0)
1438                                         CFLAGS+=
1439 else
1440 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1441 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
1442                                         for better results)
1443                                         CFLAGS+=
1444 else
1445                                 #really old version
1446 $(warning                       You are using an old and unsupported gcc \
1447                                          version ($(CC_SHORTVER)), compile at your own risk!)
1448         
1449 endif                   # CC_SHORTVER, 2.9x
1450 endif                   # CC_SHORTVER, 3.0
1451 endif                   # CC_SHORTVER, 3.4
1452 endif                   # CC_SHORTVER, 4.x
1453 endif                   # CC_SHORTVER, 4.5+ or 4.2+
1454         
1455 else            # CC_NAME, gcc
1456                                 #other compilers
1457 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1458 endif           #CC_NAME, gcc
1459 endif   #ARCH, alpha 
1460
1461 #if  ppc
1462 ifeq    ($(ARCH), ppc)
1463                 # if gcc 
1464 ifeq            ($(CC_NAME), gcc)
1465                                 C_DEFS+=-DCC_GCC_LIKE_ASM
1466                                 #common stuff
1467                                 CFLAGS= -O9 -funroll-loops -fsigned-char $(PROFILE)
1468                         #if gcc 4.5+ or 4.2+
1469 ifeq (,$(strip $(filter-out 4.2+ 4.5+,$(CC_SHORTVER))))
1470 $(call                          set_if_empty,CPU,powerpc)
1471                                         CFLAGS+=-ftree-vectorize \
1472                                                         -fno-strict-overflow \
1473                                                         -mtune=$(CPU) -maltivec
1474 else
1475                         #if gcc 4.0+
1476 ifeq                    ($(CC_SHORTVER), 4.x)
1477 $(call                          set_if_empty,CPU,powerpc)
1478                                         CFLAGS+=-ftree-vectorize \
1479                                                         -mtune=$(CPU) -maltivec
1480 else
1481                         #if gcc 3.4+
1482 ifeq                    ($(CC_SHORTVER), 3.4)
1483                                         CFLAGS+=
1484 else
1485                         #if gcc 3.0
1486 ifeq                    ($(CC_SHORTVER), 3.0)
1487                                         CFLAGS+=
1488 else
1489 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1490 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
1491                                         for better results)
1492                                         CFLAGS+=
1493 else
1494                                 #really old version
1495 $(warning                       You are using an old and unsupported gcc \
1496                                          version ($(CC_SHORTVER)), compile at your own risk!)
1497         
1498 endif                   # CC_SHORTVER, 2.9x
1499 endif                   # CC_SHORTVER, 3.0
1500 endif                   # CC_SHORTVER, 3.4
1501 endif                   # CC_SHORTVER, 4.x
1502 endif                   # CC_SHORTVER, 4.5+ or 4.2+
1503         
1504 else            # CC_NAME, gcc
1505                                 #other compilers
1506 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1507 endif           #CC_NAME, gcc
1508 endif   #ARCH, ppc 
1509
1510 #if  ppc64
1511 ifeq    ($(ARCH), ppc64)
1512                 # if gcc 
1513 ifeq            ($(CC_NAME), gcc)
1514                                 C_DEFS+=-DCC_GCC_LIKE_ASM
1515                                 #common stuff
1516                                 CFLAGS= -O9 -funroll-loops -fsigned-char $(PROFILE)
1517                         #if gcc 4.5+ or 4.2+
1518 ifeq (,$(strip $(filter-out 4.2+ 4.5+,$(CC_SHORTVER))))
1519 $(call                          set_if_empty,CPU,powerpc64)
1520                                         CFLAGS+=-ftree-vectorize \
1521                                                         -fno-strict-overflow \
1522                                                         -mtune=$(CPU) -maltivec
1523 else
1524                         #if gcc 4.0+
1525 ifeq                    ($(CC_SHORTVER), 4.x)
1526 $(call                          set_if_empty,CPU,powerpc64)
1527                                         CFLAGS+=-ftree-vectorize \
1528                                                         -mtune=$(CPU) -maltivec
1529 else
1530                         #if gcc 3.4+
1531 ifeq                    ($(CC_SHORTVER), 3.4)
1532                                         CFLAGS+=
1533 else
1534                         #if gcc 3.0
1535 ifeq                    ($(CC_SHORTVER), 3.0)
1536                                         CFLAGS+=
1537 else
1538 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1539 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
1540                                         for better results)
1541                                         CFLAGS+=
1542 else
1543                                 #really old version
1544 $(warning                       You are using an old and unsupported gcc \
1545                                          version ($(CC_SHORTVER)), compile at your own risk!)
1546         
1547 endif                   # CC_SHORTVER, 2.9x
1548 endif                   # CC_SHORTVER, 3.0
1549 endif                   # CC_SHORTVER, 3.4
1550 endif                   # CC_SHORTVER, 4.x
1551 endif                   # CC_SHORTVER, 4.5+ or 4.2+
1552         
1553 else            # CC_NAME, gcc
1554                                 #other compilers
1555 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1556 endif           #CC_NAME, gcc
1557 endif   #ARCH, ppc 
1558
1559 CFLAGS+= $(CC_EXTRA_OPTS)
1560
1561
1562 # setting LDFLAGS
1563 ifeq    ($(CC_NAME), gcc)
1564 ifeq            ($(LDTYPE), solaris)
1565                 # solaris ld
1566                 LDFLAGS+=-O2 $(PROFILE)
1567                 MOD_LDFLAGS:=-G $(LDFLAGS)
1568                 LIB_LDFLAGS:=-G $(LDFLAGS)
1569                 LIB_SONAME=-Wl,-h,
1570                 LD_RPATH=-Wl,-R,
1571 else            
1572                 #gcc and maybe others, => gnu ld
1573                 LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE) 
1574                 MOD_LDFLAGS:=-shared $(LDFLAGS)
1575                 LIB_LDFLAGS:=-shared $(LDFLAGS)
1576                 LIB_SONAME=-Wl,-soname,
1577                 LD_RPATH=-Wl,-rpath,
1578 endif
1579 endif
1580 ifeq    ($(CC_NAME), icc)
1581         #gcc and maybe others
1582         LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE) 
1583         MOD_LDFLAGS:=-shared $(LDFLAGS)
1584         LIB_LDFLAGS:=-shared $(LDFLAGS)
1585         LIB_SONAME=-Wl,-soname,
1586         LD_RPATH=-Wl,-rpath,
1587 endif
1588 ifeq    ($(CC_NAME), suncc)
1589         # -dy?
1590         LDFLAGS+=-xO5 $(PROFILE)
1591         MOD_LDFLAGS:=-G $(LDFLAGS)
1592         LIB_LDFLAGS:=-G $(LDFLAGS)
1593         LIB_SONAME="-h "
1594         LD_RPATH=-"-R "
1595 endif
1596         # we need -fPIC -DPIC only for shared objects, we don't need them for
1597         # the executable file, because it's always loaded at a fixed address
1598         # -andrei
1599
1600 LDFLAGS+= $(LD_EXTRA_OPTS)
1601 MOD_LDFLAGS+= $(LD_EXTRA_OPTS)
1602 LIB_LDFLAGS+= $(LD_EXTRA_OPTS)
1603
1604 else    #mode,release
1605 ifeq    ($(CC_NAME), gcc)
1606                 CFLAGS=-g -Wcast-align $(PROFILE)
1607                 C_DEFS+=-DCC_GCC_LIKE_ASM
1608 ifeq            ($(ARCH), sparc64)
1609                         C_DEFS+=SPARC64_MODE
1610                         CFLAGS+= -mcpu=ultrasparc -m64
1611                         LDFLAGS+=-m64
1612 endif
1613 ifeq            ($(LDTYPE), solaris)
1614                         #solaris ld
1615                         LDFLAGS+=-g $(PROFILE)
1616                         MOD_LDFLAGS:=-G $(LDFLAGS)
1617                         LIB_LDFLAGS:=-G $(LDFLAGS)
1618                         LIB_SONAME=-Wl,-h,
1619                         LD_RPATH=-Wl,-R,
1620 else
1621                         #gnu or other ld type
1622                         LDFLAGS+=-g -Wl,-E $(PROFILE)
1623                         MOD_LDFLAGS:=-shared $(LDFLAGS)
1624                         LIB_LDFLAGS:=-shared $(LDFLAGS)
1625                         LIB_SONAME=-Wl,-soname,
1626                         LD_RPATH=-Wl,-rpath,
1627 endif
1628 endif
1629 ifeq    ($(CC_NAME), icc)
1630                 C_DEFS+=-DCC_GCC_LIKE_ASM
1631                 CFLAGS=-g  $(PROFILE)
1632                 LDFLAGS+=-g -Wl,-E $(PROFILE)
1633                 MOD_LDFLAGS:=-shared $(LDFLAGS)
1634                 LIB_LDFLAGS:=-shared $(LDFLAGS)
1635                 LIB_SONAME=-Wl,-soname,
1636                 LD_RPATH=-Wl,-rpath,
1637 endif
1638 ifeq    ($(CC_NAME), suncc)
1639                 CFLAGS= -g $(PROFILE)
1640                 LDFLAGS+=-g $(PROFILE)
1641                 MOD_LDFLAGS:=-G $(LDFLAGS)
1642                 LIB_LDFLAGS:=-G $(LDFLAGS)
1643                 LIB_SONAME="-h "
1644                 LD_RPATH=-"-R "
1645 endif
1646
1647 endif #mode=release
1648
1649
1650 # set pedantic compiler options
1651 ifeq ($(CC_NAME), gcc)
1652                 CFLAGS+= -Wall
1653 else # no gcc
1654 ifeq ($(CC_NAME), icc)
1655                 CFLAGS+= -Wall
1656 else # no icc
1657 ifeq ($(CC_NAME), suncc)
1658                 # FIXME: is the default (-Xa ?) enough?
1659 endif # CC_NAME=suncc
1660 endif # CC_NAME=icc
1661 endif # CC_NAME=gcc
1662
1663 #CFLAGS used for compiling the modules, libraries and utils
1664 ifeq    ($(CC_NAME), gcc)
1665 MOD_CFLAGS=-fPIC -DPIC $(CFLAGS)
1666 LIB_CFLAGS=-fPIC -DPIC $(CFLAGS)
1667 endif
1668 ifeq    ($(CC_NAME), icc)
1669 MOD_CFLAGS=-Kpic $(CFLAGS)
1670 LIB_CFLAGS=-Kpic $(CFLAGS)
1671 endif
1672 ifeq    ($(CC_NAME), suncc)
1673 # FIMXE: use -KPIC instead -xcode ?
1674 MOD_CFLAGS=-xcode=pic32  $(CFLAGS)
1675 LIB_CFLAGS=-xcode=pic32  $(CFLAGS)
1676 endif
1677 UTILS_CFLAGS=$(CFLAGS)
1678 # LDFLAGS uses for compiling the utils
1679 UTILS_LDFLAGS=$(LDFLAGS)
1680
1681 ifeq ($(LEX),)
1682         LEX=flex
1683 endif
1684 ifeq ($(YACC),)
1685         YACC=bison
1686 endif
1687 YACC_FLAGS=-d -b cfg
1688 # on solaris add -lxnet (e.g. LIBS= -lxnet)
1689 LIBS= -ldl -lresolv
1690 LIB_PREFIX:=lib
1691 LIB_SUFFIX:=.so
1692
1693
1694 #os specific stuff
1695 ifeq ($(OS), linux)
1696 # by default use futexes if available
1697         use_futex= yes
1698         C_DEFS+=-DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
1699                         -DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H \
1700                         -DHAVE_TIMEGM -DHAVE_SCHED_SETSCHEDULER -DUSE_RAW_SOCKS
1701         ifneq ($(found_lock_method), yes)
1702                 #C_DEFS+= -DUSE_POSIX_SEM
1703                 C_DEFS+=-DUSE_PTHREAD_MUTEX
1704                 LIBS+= -lpthread
1705                 #C_DEFS+= -DUSE_SYSV_SEM  # try posix sems
1706                 found_lock_method=yes
1707         else
1708                 ifneq (,$(findstring -DUSE_POSIX_SEM, $(C_DEFS)))
1709                         LIBS+=-lpthread
1710                 endif
1711                 ifneq (,$(findstring -DUSE_PTHREAD_MUTEX, $(C_DEFS)))
1712                         LIBS+=-lpthread
1713                 endif
1714         endif
1715         # check for >= 2.5.44
1716         ifeq ($(shell [ $(OSREL_N) -ge 2005044 ] && echo has_epoll), has_epoll)
1717                 ifeq ($(NO_EPOLL),)
1718                         C_DEFS+=-DHAVE_EPOLL
1719                         # linux + gcc >= 3.0 + -malign-double + epoll => problems
1720                         CFLAGS_RM+=-malign-double
1721                         #CFLAGS:=$(filter-out -malign-double, $(CFLAGS))
1722                 endif
1723         endif
1724         # check for >= 2.2.0
1725         ifeq ($(shell [ $(OSREL_N) -ge 2002000 ] && echo has_sigio), has_sigio)
1726                 ifeq ($(NO_SIGIO),)
1727                         C_DEFS+=-DHAVE_SIGIO_RT -DSIGINFO64_WORKARROUND
1728                 endif
1729         endif
1730         # check for >= 2.5.70
1731         ifeq ($(shell [ $(OSREL_N) -ge 2005070 ] && echo has_futex), has_futex)
1732                 ifeq ($(use_futex), yes)
1733                         C_DEFS+=-DUSE_FUTEX
1734                 endif
1735         endif
1736         ifeq ($(NO_SELECT),)
1737                 C_DEFS+=-DHAVE_SELECT
1738         endif
1739         # sctp support
1740         ifeq ($(SCTP),1)
1741                 # test to see if the devfiles and lib are installed
1742                 sctp_dev_locations := /usr/include/netinet/sctp.h \
1743                                                                 $(LOCALBASE)/include/netinet/sctp.h
1744                 sctp_lib_locations := /usr/lib/libsctp.so \
1745                                                                 /usr/lib64/libsctp.so \
1746                                                                 $(LOCALBASE)/usr/local/lib/libsctp.so
1747                 sctp_dev_path := $(wildcard $(sctp_dev_locations))
1748                 sctp_lib_path := $(wildcard $(sctp_lib_locations))
1749                 ifeq ($(sctp_dev_path),)
1750 $(info "sctp development files not installed -- sctp disabled")
1751                         override SCTP := 
1752                 endif
1753                 ifeq ($(sctp_lib_path),)
1754 $(info "sctp libraries not installed -- sctp disabled")
1755                         override SCTP := 
1756                 endif
1757                 
1758                 ifeq ($(SCTP),1)
1759                         # use lksctp
1760                         C_DEFS+=-DUSE_SCTP
1761                         LIBS+=-lsctp
1762                 endif
1763         endif # SCTP
1764 endif
1765
1766 ifeq  ($(OS), solaris)
1767         C_DEFS+= -DHAVE_GETIPNODEBYNAME -DHAVE_SYS_SOCKIO_H -DHAVE_SCHED_YIELD \
1768                         -DHAVE_ALLOCA_H -DUSE_SIGACTION
1769         ifneq ($(found_lock_method), yes)
1770                 C_DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1771                 found_lock_method=yes
1772         endif
1773         # check for ver >= 5.7
1774         ifeq ($(shell [ $(OSREL_N) -gt 5007 ] && echo has_devpoll), has_devpoll)
1775                 ifeq ($(NO_DEVPOLL),)
1776                         C_DEFS+=-DHAVE_DEVPOLL
1777                 endif
1778         endif
1779         ifeq ($(NO_SELECT),)
1780                 C_DEFS+=-DHAVE_SELECT
1781         endif
1782         # check for filio.h
1783         filio_h_locations= /usr/include/sys/filio.h \
1784                                                 $(LOCALBASE)/include/sys/filio.h
1785         has_filio_h=$(shell for r in $(filio_h_locations); do \
1786                                                 if  [ -r "$$r" ] ; then echo yes; exit; fi \
1787                                                 done;\
1788                                 )
1789         ifeq ($(has_filio_h), yes)
1790                 C_DEFS+=-DHAVE_FILIO_H
1791         endif
1792         ifeq ($(mode), release)
1793                 #use these only if you're using gcc with Solaris ld
1794                 #LDFLAGS=-O2 $(PROFILE)
1795                 #MOD_LDFLAGS=-O2 -G
1796         else
1797                 #LDFLAGS=-g $(PROFILE)
1798                 #MOD_LDFLAGS=-g -G
1799         endif
1800         YACC=yacc
1801
1802 ifeq ($(CC_NAME), suncc)
1803         LIBS= -lfast -ldl -lresolv
1804 endif
1805         OLD_SOLARIS= $(shell echo "$(OSREL)" | \
1806                                 sed -e 's/^5\.[0-6][^0-9]*$$/yes/' )
1807         LIBS+= -L$(LOCALBASE)/lib -lxnet -lnsl 
1808 ifeq    ($(OLD_SOLARIS), yes)
1809                 LIBS+=-lposix4
1810 else
1811                 LIBS+=-lrt
1812 endif
1813         # -lrt needed for sched_yield
1814 endif
1815
1816 ifeq ($(OS), freebsd)
1817         C_DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
1818                 -DHAVE_SCHED_YIELD -DHAVE_MSGHDR_MSG_CONTROL \
1819                 -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
1820                 -DHAVE_NETINET_IN_SYSTM -DUSE_RAW_SOCKS
1821         ifneq ($(found_lock_method), yes)
1822                 C_DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1823                 found_lock_method=yes
1824                 LIBS+= -pthread   #dlopen is in libc
1825         else
1826                 LIBS=   #dlopen is in libc
1827         endif
1828         # check for ver >= 4.1
1829         ifeq ($(shell [ $(OSREL_N) -gt 4001 ] && echo has_kqueue), has_kqueue)
1830                 ifeq ($(NO_KQUEUE),)
1831                         C_DEFS+=-DHAVE_KQUEUE
1832                 endif
1833         endif
1834         ifeq ($(NO_SELECT),)
1835                 C_DEFS+=-DHAVE_SELECT
1836         endif
1837         YACC=yacc
1838         # sctp support
1839         ifeq ($(SCTP),1)
1840                 # test to see if the devfiles and lib are installed
1841                 sctp_dev_locations := /usr/include/netinet/sctp.h \
1842                                                                 $(LOCALBASE)/include/netinet/sctp.h
1843                 sctp_dev_path := $(wildcard $(sctp_dev_locations))
1844                 ifeq ($(sctp_dev_path),)
1845 $(info "sctp development files not installed -- sctp disabled")
1846                         override SCTP := 
1847                 endif
1848                 ifeq ($(shell [ $(OSREL_N) -lt 7000 ] && echo sctp), sctp)
1849 $(info "old freebsd version (>= 7.0 needed) -- sctp disabled")
1850                         override SCTP := 
1851                 endif
1852                 
1853                 ifeq ($(SCTP),1)
1854                         C_DEFS+=-DUSE_SCTP
1855                         LIBS+=  # no extra libs needed on freebsd
1856                 endif
1857         endif # SCTP
1858 endif
1859
1860 ifeq ($(OS), dragonfly)
1861         C_DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
1862                 -DHAVE_SCHED_YIELD -DHAVE_MSGHDR_MSG_CONTROL \
1863                 -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
1864                 -DHAVE_NETINET_IN_SYSTM
1865         ifneq ($(found_lock_method), yes)
1866                 C_DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1867                 found_lock_method=yes
1868                 LIBS+= -pthread   #dlopen is in libc
1869         else
1870                 LIBS=   #dlopen is in libc
1871         endif
1872         # dragonfly was forked from freebsd 4.8 => all version have kqueue
1873         ifeq ($(NO_KQUEUE),)
1874                 C_DEFS+=-DHAVE_KQUEUE
1875         endif
1876         ifeq ($(NO_SELECT),)
1877                 C_DEFS+=-DHAVE_SELECT
1878         endif
1879         YACC=yacc
1880         # sctp support
1881         ifeq ($(SCTP),1)
1882                 # test to see if the devfiles and lib are installed
1883                 sctp_dev_locations := /usr/include/netinet/sctp.h \
1884                                                                 $(LOCALBASE)/include/netinet/sctp.h
1885                 sctp_dev_path := $(wildcard $(sctp_dev_locations))
1886                 ifeq ($(sctp_dev_path),)
1887 $(info "sctp development files not installed -- sctp disabled")
1888                         override SCTP :=
1889                 endif
1890                 # FIXME: don't know what's the status of SCTP on dragonfly
1891                 #        (we suppose the 2.6 version is >= the version in
1892                 #         in freebsd 7.0)
1893                 ifeq ($(shell [ $(OSREL_N) -lt 2006 ] && echo sctp), sctp)
1894 $(info "old dragonfly version (>= 2.6 needed) -- sctp disabled")
1895                         override SCTP :=
1896                 endif
1897                 
1898                 ifeq ($(SCTP),1)
1899                         C_DEFS+=-DUSE_SCTP
1900                         LIBS+=  # no extra libs needed on freebsd
1901                 endif
1902         endif # SCTP
1903 endif
1904
1905 ifeq ($(OS), openbsd)
1906         C_DEFS+=-DHAVE_SOCKADDR_SA_LEN  -DHAVE_GETHOSTBYNAME2 \
1907                 -DHAVE_UNION_SEMUN -DHAVE_MSGHDR_MSG_CONTROL \
1908                 -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
1909                 -DHAVE_NETINET_IN_SYSTM -DUSE_SIGWAIT
1910         ifneq ($(found_lock_method), yes)
1911                 C_DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1912                 found_lock_method=yes
1913         endif
1914         # check for ver >=2 9
1915         ifeq ($(shell [ $(OSREL_N) -ge 2009 ] && echo has_kqueue), has_kqueue)
1916                 ifeq ($(NO_KQUEUE),)
1917                         C_DEFS+=-DHAVE_KQUEUE
1918                 endif
1919         endif
1920         ifeq ($(NO_SELECT),)
1921                 C_DEFS+=-DHAVE_SELECT
1922         endif
1923         # (symbols on openbsd are prefixed by "_")
1924         YACC=yacc
1925         # no sched_yield on openbsd unless linking with c_r (not recommended)
1926         # unfortunately pthread is needed for sigwait
1927         LIBS= -lpthread
1928         OPENBSD_IS_AOUT:= $(shell echo "$(OSREL)" | \
1929                                 sed -e 's/^3\.[0-3][^0-9]*$$/yes/' |sed -e 's/^[0-2]\..*/yes/')
1930 # exception: on sparc openbsd 3.2 is elf and not aout
1931 ifeq ($(OSREL), 3.2)
1932 ifeq    ($(ARCH), sparc)
1933                 OPENBSD_IS_AOUT:=no
1934 endif
1935 ifeq    ($(ARCH), sparc64)
1936                 OPENBSD_IS_AOUT:=no
1937 endif
1938 endif
1939         
1940 ifeq ($(OPENBSD_IS_AOUT), yes)
1941                 C_DEFS+=-DDLSYM_PREFIX='"_"'
1942                 LDFLAGS=        # openbsd ld doesn't like -O2 or -E
1943 endif
1944 endif   # if opensd
1945         
1946 ifeq ($(OS), netbsd)
1947         C_DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 \
1948                 -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM
1949         ifneq ($(found_lock_method), yes)
1950                 C_DEFS+= -DUSE_SYSV_SEM  # try pthread sems
1951                 found_lock_method=yes
1952         endif
1953         # check for ver >= 2.0.0
1954         ifeq ($(shell [ $(OSREL_N) -ge 2000000 ] && echo has_kqueue), has_kqueue)
1955                 ifeq ($(NO_KQUEUE),)
1956                         C_DEFS+=-DHAVE_KQUEUE
1957                         # netbsd + kqueue and -malign-double don't work
1958                         CFLAGS_RM+=-malign-double
1959                         #CFLAGS:=$(filter-out -malign-double, $(CFLAGS))
1960                 endif
1961         endif
1962         ifeq ($(NO_SELECT),)
1963                 C_DEFS+=-DHAVE_SELECT
1964         endif
1965         YACC=yacc
1966         LIBS=  
1967 endif
1968
1969 # OS X support, same as freebsd
1970 ifeq ($(OS), darwin)
1971         C_DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
1972                 -DHAVE_SCHED_YIELD -DHAVE_MSGHDR_MSG_CONTROL \
1973                 -DUSE_ANON_MMAP \
1974                 -DNDEBUG -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
1975                 -DUSE_SIGWAIT
1976         # -DNDEBUG used to turn off assert (assert wants to call
1977         # eprintf which doesn't seem to be defined in any shared lib
1978         ifneq ($(found_lock_method), yes)
1979                 C_DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1980                 found_lock_method=yes
1981                 C_DEFS+= -DUSE_SYSV_SEM  # try sys v sems (pthread don't work for
1982                                        # processes and unnamed posix sems are not
1983                                        # supported)
1984         endif
1985         LIBS= -lresolv  #dlopen is in libc
1986         ifeq ($(NO_KQUEUE),)
1987                 C_DEFS+=-DHAVE_KQUEUE
1988         endif
1989         ifeq ($(NO_SELECT),)
1990                 C_DEFS+=-DHAVE_SELECT
1991         endif
1992         LDFLAGS=        # darwin doesn't like -O2 or -E
1993         # the modules uses symbols from ser => either 
1994         # -flat_namespace -undefined_suppress or -bundle_loader ../../$(MAIN_NAME)
1995         MOD_LDFLAGS:= -bundle -flat_namespace -undefined suppress
1996         # for libs using symbols from ser (e.g srdb2, kcore a.s.o) we
1997         # need -flat_namespace -undefined suppress
1998         LIB_LDFLAGS:= -dynamiclib -flat_namespace -undefined suppress
1999         LIB_SUFFIX:=.dylib
2000         # on darwin soname should include the full path
2001         # (it kind of combines rpath & soname)
2002         LIB_SONAME=
2003         # no equiv. for rpath on darwin
2004         LD_RPATH=
2005         YACC=yacc
2006 endif
2007
2008 ifneq (,$(findstring cygwin, $(OS)))
2009         # cygwin doesn't support IPV6 and doesn't support fd passing so no TCP
2010         #C_DEFS:=$(filter-out -DUSE_IPV6 -DUSE_TCP, $(C_DEFS))
2011         DEFS_RM+=-DUSE_IPV6 -DUSE_TCP
2012         C_DEFS+=-DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
2013                         -DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H \
2014                         -DHAVE_TIMEGM -DHAVE_SCHED_SETSCHEDULER
2015         ifneq ($(found_lock_method), yes)
2016                 C_DEFS+= -DUSE_POSIX_SEM
2017                 #C_DEFS+= -DUSE_SYSV_SEM  # try posix sems
2018                 # PTHREAD_MUTEX do not work for processes (try test/pthread_test.c)
2019                 #LIBS+= -lpthread
2020                 found_lock_method=yes
2021         else
2022                 ifneq (,$(findstring -DUSE_POSIX_SEM, $(C_DEFS)))
2023                         #LIBS+=-lpthread
2024                 endif
2025                 ifneq (,$(findstring -DUSE_PTHREAD_MUTEX, $(C_DEFS)))
2026 $(error PTHREAD_MUTEX do not work for processes on Windows/CYGWIN)
2027                 endif
2028         endif
2029         # check for >= 2.5.70
2030         ifeq ($(NO_SELECT),)
2031                 C_DEFS+=-DHAVE_SELECT
2032         endif
2033 endif
2034
2035 #add libssl if needed
2036 ifeq ($(CORE_TLS), 1)
2037 C_INCLUDES+= -I$(LOCALBASE)/ssl/include
2038 LIBS+= -L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib -lssl -lcrypto \
2039                 $(TLS_EXTRA_LIBS)
2040 # NOTE: depending on the way in which libssl was compiled you might
2041 #       have to add -lz -lkrb5   (zlib and kerberos5).
2042 #       E.g.: make CORE_TLS=1 EXTRA_TLS_LIBS="-lz -lkrb5"
2043 endif
2044
2045 ifneq ($(STUN),)
2046 C_INCLUDES+= -I$(LOCALBASE)/ssl/include
2047 LIBS+= -L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib -lcrypto
2048 endif
2049
2050 ifneq ($(found_lock_method), yes)
2051 $(warning       No locking method found so far, trying SYS V sems)
2052                 C_DEFS+= -DUSE_SYSV_SEM  # try sys v sems
2053                 found_lock_method=yes
2054 endif
2055
2056
2057 endif # ifeq (,$(main_makefile))
2058 endif  # ifeq ($(makefile_defs), 1)
2059
2060 # if incomplete or missing config.mak, or already exported vars, don't
2061 # try to export/re-export
2062 ifeq ($(makefile_defs),1) 
2063 ifneq ($(exported_vars),1)
2064
2065
2066 override exported_vars:=1
2067 export exported_vars
2068
2069 # variable changeable only at configure time (once saved in config.mak they
2070 #  cannot be overwritten from environment or command line, unless make cfg
2071 #  is run)
2072 saved_fixed_vars:=      MAIN_NAME  CFG_NAME SCR_NAME FLAVOUR INSTALL_FLAVOUR \
2073                 SRC_NAME RELEASE OS ARCH \
2074                 C_DEFS DEFS_RM PROFILE CC LD MKDEP MKTAGS LDFLAGS C_INCLUDES \
2075                 CC_MKDEP_OPTS \
2076                 MOD_LDFLAGS LIB_LDFLAGS UTILS_LDFLAGS LIB_SONAME LD_RPATH \
2077                 LIB_SUFFIX LIB_PREFIX \
2078                 LIBS \
2079                 LEX YACC YACC_FLAGS \
2080                 PREFIX LOCALBASE \
2081                 TAR \
2082                 INSTALL INSTALL_CFG INSTALL_BIN INSTALL_MODULES INSTALL_DOC \
2083                 INSTALL_MAN INSTALL_LIB INSTALL_TOUCH INSTALL_SHARE \
2084                 Q
2085
2086 # variable changeable at compile time
2087 # extra: prefix DESTDIR BASEDIR basedirt
2088 saved_chg_vars:=\
2089                 CC_EXTRA_OPTS CPU CFLAGS_RM CFLAGS MOD_CFLAGS LIB_CFLAGS UTILS_CFLAGS \
2090                 BASEDIR basedir DESTDIR LIBDIR \
2091                 PREFIX prefix\
2092                 cfg_prefix cfg_dir bin_prefix bin_dir modules_prefix modules_dir \
2093                 doc_prefix doc_dir man_prefix man_dir ut_prefix ut_dir \
2094                 share_prefix share_dir lib_prefix lib_dir data_prefix data_dir \
2095                 cfg_target lib_target data_target
2096
2097
2098 #export relevant variables to the sub-makes
2099 export $(saved_fixed_vars)
2100 export $(saved_chg_vars)
2101
2102
2103 endif # ifneq ($(exported_vars),1)
2104 endif # ifeq ($(makefile_defs),1)
2105