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