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