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