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