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