3 # makefile defs (CC, LD,a.s.o)
5 # Environment variables:
6 # PREFIX, LOCALBASE, BASEDIR
7 # INSTALL, TAR , CC, LEX, YACC,
9 # exclude_modules, skip_modules, include_modules
15 # 2003-02-24 added LOCALBASE, fixed doc_dir for freebsd - patch provided
16 # by Maxim Sobolev <sobomax@FreeBSD.org>
17 # 2003-02-25 added -DDISABLE_NAGLE (andrei)
18 # 2003-03-02 added -DDIGEST_DOMAIN (janakj)
19 # 2003-03-10 added -xcode=pic32 for module compilation w/ sun cc
20 # (too many symbols for pic13) (andrei)
21 # 2003-04-16 added CC_EXTRA_OPTS, s/march/mcpu, added CPU (cpu to optimize
22 # for, used only with gcc-3.x) (andrei)
23 # 2003-05-23 check if this makefile was already included (andrei)
24 # removed -DDIGEST_DOMAIN (andrei)
25 # 2003-05-30 added extra_defs (andrei)
26 # 2003-06-06 moved compiler detection before DEFS (andrei)
27 # 2003-06-10 removed -m32 for gcc 3.x/sparc64 -- it will use
28 # arch. default: -m32 on solaris, -m64 on *bsd (andrei)
29 # 2003-09-25 added -pthread into LIBS when compiling on FreeBSD/alpha
30 # and other FreeBSD arches for which no fast locking assembly
31 # code exists (sobomax)
32 # 2003-11-08 mips1 support introduced (andrei)
33 # 2003-11-24 openbsd 3.4 (elf) fixes (andrei)
34 # 2004-07-27 darwin (mac os x) port (andrei)
35 # 2004-09-12 mips2 & cobalt support introduced (andrei)
36 # 2004-09-28 x86_64 support introduced (andrei)
37 # 2004-12-14 gcc-3.4 special case added (andrei)
38 # 2004-12-15 HAVE_ALLOCA_H added (andrei)
39 # 2004-12-19 amd64 transformed in x86_64 (andrei)
40 # 2005-04-27 alpha support added (andrei)
41 # 2005-06-01 use $(LOCALBASE) instead of /usr/{local,pkg} (andrei)
42 # 2005-06-26 numeric OSREL & HAVE_KQUEUE added to the *BSD (andrei)
43 # 2005-07-04 HAVE_DEVPOLL added to solaris (andrei)
44 # 2005-07-06 gcc 4.0 optimizations support (andrei)
45 # 2005-07-25 better solaris arch detection (andrei)
46 # 2005-09-12 -mallign-double removed (too many problems) (andrei)
47 # 2005-10-02 distcc get gcc version hack (andrei)
48 # 2006-03-30 64 bit mode compile by default on sparc64 (-m64), added
49 # CC_GCC_LIKE_ASM and SPARC64_MODE (andrei)
50 # sparc <= v8 support (andrei)
51 # 2006-03-31 armv6 & mips64 support added
52 # mips and arm set to NOSMP by default (andrei)
53 # 2006-07-10 added -DPROFILING (hscholz)
54 # 2007-02-09 added TLS_HOOKS and CORE_TLS support, obsoleted TLS=1
55 # added TLS_EXTRA_LIBS (andrei)
56 # 2007-03-16 added LIB building options: LIB_LDFLAGS, LIB_SONAME, LIB_RPATH,
57 # INSTALL_LIB, libraries install paths (andrei)
58 # 2007-05-14 futex support if linux 2.5.70+ and
59 # use_futex=yes (default) (andrei)
60 # 2007-05-26 changed darwin module link flags (instead of -bundle_loader ser
61 # -flat_namespace -undefined suppress) (andrei)
62 # 2007-07-07 use isainfo -n to detect cpu type on solaris (andrei)
63 # 2007-07-07 added HAVE_SCHED_SETSCHEDULER for linux (andrei)
64 # 2007-07-18 added DNS_WATCHDOG_SUPPORT (Miklos)
65 # 2007-07-30 added USE_DNS_CACHE_STATS and USE_DST_BLACKLIST_STATS (Gergo)
66 # 2008-06-26 support for make cfg / config.mak and hack to load
67 # automatically config.mak when included from a module, lib
68 # a.s.o (not from the main Makefile) (andrei)
69 # 2009-03-10 replaced DEFS with C_DEFS and INCLUDES with C_INCLUDES (DEFS
70 # and INCLUDES are now used only for "temporary" defines/includes
71 # inside modules or libs) (andrei)
72 # 2009-09-29 for gcc 4.2+ use -fno-strict-overflow (andrei)
73 # 2009-09-30 find the target architecture from the compiler and not
74 # from the host (andrei)
75 # 2009-10-01 use -fsigned-char for gcc on ppc, ppc64, arm and arm6
76 # (on those archs char is unsigned by default) (andrei)
78 quiet?=$(if $(filter 1 yes on,$(Q)),silent,verbose)
80 # check if already included/exported
82 # used for sanity checks for Makefile.defs inclusion (!= makefile_defs which
83 # specifies if we have a set of valid defs)
84 override makefile_defs_included:=1
85 ifeq ($(makefile_defs),1)
86 ifeq ($(quiet),verbose)
87 $(info Makefile.defs defs skipped)
92 ifeq (,$(main_makefile))
93 # hack to automatically use config.mak in all the modules, without
94 # changing the current module makefiles (which all include Makefile.defs):
95 # if not called from the main makefile (module, lib or ut):
96 # include config.mak, but if not present or incomplete (makefile_defs!=1)
97 # don't export the vars)
99 include $(COREPATH)/config.mak
100 ifeq ($(quiet),verbose)
101 $(info config.mak included)
103 # config.mak should set makefile_defs if complete
107 override makefile_defs=1
111 ifeq ($(quiet),verbose)
112 $(info normal Makefile.defs exec)
115 # flavour: sip-router, ser or kamailio
118 #prefix for various configs and scripts
119 #config name/name-prefix for distributed configs
121 #config name/name-prefix for distributed scripts
126 ifeq ($(FLAVOUR),sip-router)
129 else ifeq ($(FLAVOUR),ser)
132 else ifeq ($(FLAVOUR),kamailio)
135 # use kamailio config
137 # kamailio statistics on
139 # fast malloc statistics on
147 INSTALL_FLAVOUR=$(FLAVOUR)
155 # memory debugger switcher
156 # 0 - off (release mode)
157 # 1 - on (devel mode)
160 SER_VER = $(shell expr $(VERSION) \* 1000000 + $(PATCHLEVEL) \* 1000 + \
162 RELEASE:=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
163 OS := $(shell uname -s | sed -e s/SunOS/solaris/ -e s/CYGWIN.*/cygwin/ \
164 | tr "[A-Z]" "[a-z]")
175 HOST_ARCH := $(shell $(GETARCH) |sed -e s/i.86/i386/ -e s/sun4[uv]/sparc64/ \
176 -e s/armv[3-5].*/arm/ -e s/armv6.*/arm6/ \
177 -e "s/Power Macintosh/ppc/" \
178 -e "s/cobalt/mips2/" \
179 -e s/amd64/x86_64/ -e s/sparcv9/sparc64/ )
180 # fix sparc -> sparc64
181 ifeq ($(HOST_ARCH),sparc)
182 ifeq ($(shell uname -m),sun4u)
185 ifeq ($(shell uname -m),sun4v)
190 OSREL := $(shell uname -r)
191 # numerical version (good for comparisons: A.B.C => A*1000000+B*1000+C)
192 OSREL_N:= $(shell echo $(OSREL) | sed -e 's/^[^0-9]*//' \
193 -e 's/^\([0-9][0-9]*\(\.[0-9][0-9]*\)*\).*$$/\1/g' | \
194 (IFS=. read A B C D; R=0; \
195 [ -n "$$A" ] && R=`expr $$R \* 1000 + $$A` && \
196 [ -n "$$B" ] && R=`expr $$R \* 1000 + $$B` && \
197 [ -n "$$C" ] && R=`expr $$R \* 1000 + $$C`; echo $$R ) )
202 # by default compile with tls hooks support (so that no ser recompile is
203 # needed before the tls module can be used)
205 ifeq ($(CORE_TLS), 1)
206 RELEASE:=$(RELEASE)-tls
209 ifeq ($(TLS_HOOKS), 1)
210 # RELEASE:=$(RELEASE)-tls
213 # extra CC command line options (e.g -march=athlon-mp)
217 cfg_dir = etc/$(MAIN_NAME)/
219 share_dir = share/$(MAIN_NAME)/
220 # lib/$(MAIN_NAME)/modules , lib/$(MAIN_NAME)/modules-s, lib/$(MAIN_NAME)/modules-k
221 modules_dir = lib/$(MAIN_NAME)/
222 lib_dir = lib/$(MAIN_NAME)/
224 doc_dir = share/doc/$(MAIN_NAME)/
226 data_dir = share/$(MAIN_NAME)/
227 LOCALBASE ?= /usr/local
229 ifeq ($(OS), freebsd)
230 doc_dir = share/doc/$(MAIN_NAME)/
232 data_dir = share/$(MAIN_NAME)/
233 LOCALBASE ?= /usr/local
235 ifeq ($(OS), openbsd)
236 doc_dir = share/doc/$(MAIN_NAME)/
238 data_dir = share/$(MAIN_NAME)/
239 LOCALBASE ?= /usr/local
242 doc_dir = share/doc/$(MAIN_NAME)/
244 data_dir = share/$(MAIN_NAME)/
245 LOCALBASE ?= /usr/pkg
248 doc_dir = share/doc/$(MAIN_NAME)/
250 data_dir = share/$(MAIN_NAME)/
251 LOCALBASE ?= /usr/local
253 doc_dir = doc/$(MAIN_NAME)/
255 data_dir = $(MAIN_NAME)/
256 LOCALBASE ?= /usr/local
264 doxygen_dir=doc/doxygen
267 DESTDIR ?= $(LOCALBASE)
270 # install path is $(basedir) $(prefix)
272 # creating a bin. archive in /tmp, which unpacks in /usr/local
278 # install prefixes for various stuff
279 cfg_prefix = $(basedir)$(prefix)
280 bin_prefix = $(basedir)$(prefix)
281 modules_prefix = $(basedir)$(prefix)
282 lib_prefix = $(basedir)$(prefix)
283 doc_prefix = $(basedir)$(prefix)
284 man_prefix = $(basedir)$(prefix)
285 ut_prefix = $(basedir)$(prefix)
286 share_prefix = $(basedir)$(prefix)
287 data_prefix = $(basedir)$(prefix)
290 # target dirs for various stuff
291 cfg_target = $(prefix)/$(cfg_dir)
292 bin_target = $(prefix)/$(bin_dir)
293 #modules_target = $(prefix)/$(modules_dir)
294 lib_target = $(prefix)/$(lib_dir)
295 doc_target = $(prefix)/$(doc_dir)
296 data_target = $(prefix)/$(data_dir)
300 ifeq ($(OS), solaris)
309 INSTALL_TOUCH = touch # used to create the file first (good to
310 # make solaris install work)
311 INSTALL_CFG = $(INSTALL) -m 644
312 INSTALL_BIN = $(INSTALL) -m 755
313 INSTALL_SCRIPT = $(INSTALL) -m 755
314 INSTALL_MODULES = $(INSTALL) -m 755
315 INSTALL_LIB = $(INSTALL) -m 755
316 INSTALL_DOC = $(INSTALL) -m 644
317 INSTALL_MAN = $(INSTALL) -m 644
318 INSTALL_SHARE = $(INSTALL) -m 644
320 #set some vars from the environment (and not make builtins)
321 CC := $(shell echo "$${CC}")
322 LEX := $(shell echo "$${LEX}")
323 YACC := $(shell echo "$${YACC}")
328 # find compiler name & version
333 CC_LONGVER:=$(shell if $(CC) -v 2>/dev/null; then \
340 #find-out the compiler's name
342 ifneq (,$(findstring gcc, $(CC_LONGVER)))
345 CC_VER:=$(word 1,$(CC)) $(shell $(CC) - --version|head -n 1|\
346 sed -e 's/([^$(RPAREN)]*)//g' \
347 -e 's/^.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/'\
348 -e 's/^[^0-9].*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/')
349 # CC_VER:=$(word 1,$(CC)) $(shell $(CC) - --version|head -n 1|cut -d" " -f 3\
350 # |sed -e 's/^.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/'\
351 # -e 's/^[^0-9].*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/')
352 # sed with POSIX.1 regex doesn't support |, + or ?
353 # (darwin, solaris ...) => this complicated expression
355 #transform gcc version into 2.9x or 3.0
356 CC_SHORTVER:=$(shell echo "$(CC_VER)" | cut -d" " -f 2| \
357 sed -e 's/[^0-9]*-\(.*\)/\1/'| \
358 sed -e 's/2\.9.*/2.9x/' -e 's/3\.[0-3]\..*/3.0/' -e \
359 's/3\.[0-3]/3.0/' -e 's/3\.[4-9]\..*/3.4/' -e \
360 's/3\.[4-9]/3.4/' -e 's/4\.[0-1]\..*/4.x/' -e \
361 's/4\.[0-1]/4.x/' -e 's/4\.[2-9]\..*/4.2+/' -e \
362 's/4\.[2-9]$$/4.2+/')
365 ifneq (, $(findstring Sun, $(CC_LONGVER)))
367 CC_SHORTVER:=$(shell echo "$(CC_LONGVER)"|head -n 1| \
368 sed -e 's/.*\([0-9]\.[0-9]\).*/\1/g' )
369 CC_VER=$(CC) $(CC_SHORTVER)
373 ifneq (, $(findstring Intel(R) C++ Compiler, $(CC_LONGVER)))
374 # very nice: gcc compatible
376 CC_FULLVER:=$(shell echo "$(CC_LONGVER)"|head -n 1| \
377 sed -e 's/.*Version \([0-9]\.[0-9]\.[0-9]*\).*/\1/g' )
378 CC_SHORTVER:=$(shell echo "$(CC_FULLVER)" | cut -d. -f1,2 )
379 CC_VER=$(CC) $(CC_FULLVER)
390 $(warning Unknown compiler $(CC)\; supported compilers: \
391 gcc, sun cc, intel icc )
395 # predefined compiler macros for different architectures
396 # (see http://predef.sourceforge.net/prearch.html for a more complete list)
397 i386_macros= i386 __i386__ __i486__ __i586__ __i686__ \
398 __i386 _M_IX86 __X86__ _X86_
399 x86_64_macros= __amd64__ __amd64 __x86_64__ __x86_64 _M_X64
401 sparc_macros= __sparc__ __sparc __sparcv8
402 sparc64_macros= __sparcv9 __sparc_v9__
404 arm_macros= __arm__ __thumb__
405 arm6_macros= __ARM_ARCH_6__
407 ppc_macros= __powerpc __powerpc__ __POWERPC__ __ppc__ _ARCH_PPC
408 ppc64_macros= __ppc64__ _ARCH_PPC64
410 mips_macros= __mips__ __mips _MIPS_ARCH_MIPS1
411 mips2_macros= _MIPS_ISA_MIPS2 _MIPS_ISA_MIPS3 _MIPS_ISA_MIPS4 \
412 _MIPS_ARCH_MIPS2 _MIPS_ARCH_MIPS3 _MIPS_ARCH_MIPS4
413 mips64_macros= _MIPS_ISA_MIPS64 _MIPS_ARCH_MIPS64
415 alpha_macros= __alpha__ __alpha _M_ALPHA_
417 ifeq ($(CC_NAME),gcc)
419 predef_macros:=$(shell $(CC) -dM -E -x c $(CC_EXTRA_OPTS) $(extra_defs) \
422 ifneq ($(strip $(filter $(i386_macros), $(predef_macros))),)
424 else ifneq ($(strip $(filter $(x86_64_macros), $(predef_macros))),)
426 else ifneq ($(strip $(filter $(sparc_macros), $(predef_macros))),)
428 ifneq ($(strip $(filter $(sparc64_macros), $(predef_macros))),)
430 else # sparc64_macros
432 endif # sparc64_macros
434 else ifneq ($(strip $(filter $(arm_macros), $(predef_macros))),)
436 ifneq ($(strip $(filter $(arm6_macros), $(predef_macros))),)
442 else ifneq ($(strip $(filter $(ppc64_macros), $(predef_macros))),)
444 else ifneq ($(strip $(filter $(ppc_macros), $(predef_macros))),)
446 else ifneq ($(strip $(filter $(mips_macros), $(predef_macros))),)
448 ifneq ($(strip $(filter $(mips64_macros), $(predef_macros))),)
450 else ifneq ($(strip $(filter $(mips2_macros), $(predef_macros))),)
454 endif # mips64_macros
456 else ifneq ($(strip $(filter $(alpha_macros), $(predef_macros))),)
460 $(warn "Unknown target compiler architecture")
462 endif # predefined macros tests (x86_macros, ...)
471 $(info target architecture <$(ARCH)>, host architecture <$(HOST_ARCH)>)
473 # compile-time options
476 # allows to print out number of packets processed on CTRL-C;
477 # implementation still nasty and reports per-process
479 # turns off some of the debug messages (DBG(...)).
481 # completely turns of all the logging (and DBG(...))
483 # compiles in some extra debugging code
485 # faster ip address resolver for ip strings (e.g "127.0.0.1")
487 # compiles in shared mem. support, needed by some modules and
490 # use mmap instead of SYSV shared memory
492 # uses a faster malloc (exclusive w/ USE_SHM_MEM)
494 # all pkg_malloc => shm_malloc (most mallocs use a common sh.
495 # mem. segment); don't define PKG_MALLOC if you want this!
497 # qm_malloc debug code, will cause pkg_malloc and shm_malloc
498 # to keep and display lot of debuging information: file name,
499 # function, line number of malloc/free call for each block,
500 # extra error checking (trying to free the same pointer
501 # twice, trying to free a pointer alloc'ed with a different
504 # additional option to PKG_MALLOC which utilizes a fater then
506 # (not true anymore, q_malloc performs approx. the same)
508 # an even faster malloc, not recommended for debugging
510 # a malloc implementation based on Doug Lea's dl_malloc
512 # an experimental multi-CPU, pool based, multi-process safe version of
513 # F_MALLOC. Should give better performance on machines with lots of CPUs
514 # after some tunning.
516 # an experimental multi-CPU, pool based, multi-process safe, mostly
517 # lockless version of SF_MALLOC/F_MALLOC. Not for production use for
520 # issues additional debugging information if lock/unlock is called
522 # uses fast arhitecture specific locking (see the arh. specific section)
524 # uses sys v sems for locking (slower & limited number)
525 # -DUSE_PTHREAD_MUTEX
526 # uses pthread mutexes, faster than sys v or posix sems, but do not
527 # work on all systems inter-processes (e.g. linux)
529 # uses posix semaphores for locking (faster than sys v)
531 # uses futexes for locking (linux 2.6+)
533 # uses busy waiting on the lock (FAST_LOCK)
535 # try busy waiting for a while and if the lock is still held go to
536 # force reschedule (FAST_LOCK)
537 # -DADAPTIVE_WAIT_LOOPS=number
538 # number of loops we busy wait, after "number" loops have elapsed we
539 # force a reschedule (FAST_LOCK)
541 # don't use smp compliant locking (faster but won't work on SMP machines)
542 # (not yet enabled) (FAST_LOCK)
543 # -DNO_PINGTEL_TAG_HACK
544 # if enabled, To-header-field will be less liberal and will not accept
545 # 'tag=' (tag parameter with equal sign and without value); it is called
546 # this way because such message was sighted from a Pingtel phone
548 # compiles in tcp support
550 # disable the tcp Nagle algorithm (lower delay)
552 # compiles in tls support, requires -DUSE_TCP. Note: this is only
553 # generic support (parsing a.s.o.), it does not include the actual
554 # "tls engine". If you really want tls you need also either
555 # -DCORE_TLS and a tls/ subdir with the tls code or -DTLS_HOOKS and
556 # the tls module loaded.
558 # compiles tls in-core support. Requires -DUSE_TLS, conflicts
559 # -DTLS_HOOKS. Please use make CORE_TLS=1 instead (it will set all the
560 # needed defines automatically and extra libraries needed for linking).
562 # compile tls module support (support for having the "tls engine" in a
563 # module). Requires -DUSE_TLS, conflicts -DCORE_TLS.
564 # Please use make TLS_HOOKS=1 (or TLS_HOOKS=0 to for disabling) instead
565 # of setting -DTLS_HOOKS (it will set all the needed defines
568 # support for changing some of the resolver parameters present
569 # (_res structure in <resolv.h>)
571 # compiles in comp=[sergz|sigcomp] support (parsing uri & via,
572 # adding it to via, lumps a.s.o). WARNING: right now this option
573 # is useless since the compression code doesn't exist yet.
575 # compiles in checks and use for maddr parameter in uri.
576 # Required to support Windows Messenger 5.x over TCP connection
577 # which (mis)uses this parameter.
579 # use an internal dns cache instead of making dns requests each time
580 # -DUSE_DNS_CACHE_STATS
581 # turns on DNS cache measurements
583 # if the destination resolves to multiple ips, on send error fall back
585 # -DUSE_DST_BLACKLIST
586 # blacklist bad destination (timeout, failed to connect, error sending
588 # -DUSE_DST_BLACKLIST_STATS
589 # turns on blacklist bad destination measurements
591 # if enabled profiling will be enabled for child processes
592 # Don't forget to set PROFILE (see below)
594 # compiles in stun support
596 # turns off debugging messages in signal handlers (which might be
599 # turns on naptr support (but must be also enabled from the config)
600 # -DDNS_WATCHDOG_SUPPORT
601 # turns on DNS watchdog support which can be used to inform the
602 # core that the DNS servers are down. No DNS query is performed
603 # when the servers are unreachable, and even expired resource
604 # records are used from the cache. (requires external watchdog)
606 # adds support for Application Server interface
607 # Sometimes is needes correct non-quoted $OS. HACK: gcc translates known OS to number ('linux'), so there is added underscore
609 C_DEFS= $(extra_defs) \
610 -DNAME='"$(MAIN_NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
611 -DOS='$(OS)_' -DOS_QUOTED='"$(OS)"' -DCOMPILER='"$(CC_VER)"'\
612 -D__CPU_$(ARCH) -D__OS_$(OS) \
613 -DSER_VER=$(SER_VER) \
614 -DCFG_DIR='"$(cfg_target)"'\
616 -DSHM_MEM -DSHM_MMAP \
625 -DUSE_DST_BLACKLIST \
627 #-DUSE_DNS_CACHE_STATS \
628 #-DUSE_DST_BLACKLIST_STATS \
629 #-DDNS_WATCHDOG_SUPPORT \
645 #PROFILE= -pg # set this if you want profiling
646 # you may also want to set -DPROFILING
648 # WARNING: do not add mode=debug or mode=release anymore in the Makefile,
649 # use make mode=debug all instead. Anyway no by default ser is compiled w/
650 # debugging symbols in all cases (-g). --andrei
653 C_DEFS+= -DDBG_QM_MALLOC
657 ifeq ($(CORE_TLS), 1)
658 C_DEFS+= -DUSE_TLS -DCORE_TLS
660 ifeq ($(TLS_HOOKS), 1)
661 C_DEFS+= -DUSE_TLS -DTLS_HOOKS
664 C_DEFS+= -DUSE_CORE_STATS -DSTATISTICS
667 C_DEFS+= -DMALLOC_STATS
679 C_DEFS+= -DEXTRA_DEBUG
682 # platform dependent settings
684 # find ld & as name (gnu or solaris)
685 ifeq ($(OS), solaris)
686 ifeq ($(CC_NAME), gcc)
687 LDGCC:=$(shell $(CC) -v 2>&1 | grep with-ld| \
688 sed -e 's/.*--with-ld=\([^ ][^ ]*\).*/\1/' )
689 ASGCC:=$(shell $(CC) -v 2>&1 | grep with-as| \
690 sed -e 's/.*--with-as=\([^ ][^ ]*\).*/\1/' )
691 LDPATH:=$(shell if [ -z "$(LDGCC)" ] ; then echo "ld" ;\
693 if $(LDGCC) -V 2>/dev/null 1>/dev/null; then \
698 ASPATH:=$(shell if [ -z "$(ASGCC)" ] ; then echo "as" ;\
700 if $(ASGCC) -V 2>/dev/null 1>/dev/null </dev/null; \
707 LDTYPE:=$(shell if $(LDPATH) -V 1>/dev/null 2>/dev/null; then \
708 if $(LDPATH) -V 2>&1|grep GNU >/dev/null; \
711 if $(LDPATH) -V 2>&1|grep Solaris >/dev/null;\
718 ASTYPE:=$(shell if $(ASPATH) -V 1>/dev/null 2>/dev/null </dev/null; \
720 if $(ASPATH) -V 2>&1 </dev/null | \
721 grep GNU >/dev/null; then echo gnu; \
723 if $(ASPATH) -V 2>&1 </dev/null | \
724 grep Sun >/dev/null; then echo solaris; \
730 #$(warning "using ld=$(LDPATH)/$(LDTYPE), as=$(ASPATH)/$(ASTYPE)")
735 # arch. specific definitions
740 ifeq ($(ARCH), x86_64)
744 ifeq ($(ARCH), sparc64)
745 ifeq ($(CC_NAME), gcc)
750 ifeq ($(ARCH), sparc)
756 C_DEFS+=-DNOSMP # very unlikely to have an smp arm
767 ifeq ($(ARCH), ppc64)
772 # mips1 arch. (e.g. R3000) - no hardware locking support
774 C_DEFS+=-DMIPS_HAS_LLSC # likely
775 C_DEFS+=-DNOSMP # very likely
778 ifeq ($(ARCH), mips2)
779 # mips2 arch and newer (mips3=R4000, mips4=R5000 a.s.o)
783 ifeq ($(ARCH), mips64)
784 # mips2 arch and newer (mips3=R4000, mips4=R5000 a.s.o)
788 ifeq ($(ARCH), alpha)
790 C_DEFS+=-DNOSMP # very likely
793 ifeq ($(use_fast_lock), yes)
794 C_DEFS+= -DFAST_LOCK -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024
795 found_lock_method=yes
802 ifeq ($(mode), release)
806 ifeq ($(CC_NAME), gcc)
807 C_DEFS+=-DCC_GCC_LIKE_ASM
809 CFLAGS=-g -O9 -funroll-loops -Wcast-align $(PROFILE)
811 ifeq ($(CC_SHORTVER), 4.2+)
813 CFLAGS+=-m32 -minline-all-stringops \
816 -fno-strict-overflow \
821 ifeq ($(CC_SHORTVER), 4.x)
823 CFLAGS+=-m32 -minline-all-stringops \
830 ifeq ($(CC_SHORTVER), 3.4)
832 CFLAGS+=-m32 -minline-all-stringops \
838 ifeq ($(CC_SHORTVER), 3.0)
840 CFLAGS+=-minline-all-stringops \
843 # -m32 supported since gcc 3.2
845 ifeq ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
846 $(warning Old gcc detected ($(CC_SHORTVER)), use gcc >= 3.1 \
853 $(warning You are using an old and unsupported gcc \
854 version ($(CC_SHORTVER)), compile at your own risk!)
856 endif # CC_SHORTVER, 2.9x
857 endif # CC_SHORTVER, 3.0
858 endif # CC_SHORTVER, 3.4
859 endif # CC_SHORTVER, 4.x
860 endif # CC_SHORTVER, 4.2+
863 ifeq ($(CC_NAME), icc)
864 C_DEFS+=-DCC_GCC_LIKE_ASM
865 CFLAGS=-g -O3 -ipo -ipo_obj -unroll $(PROFILE) \
866 -tpp6 -xK #-openmp #optimize for PIII
867 # -prefetch doesn't seem to work
868 #( ty to inline acroos files, unroll loops,prefetch,
869 # optimize for PIII, use PIII instructions & vect.,
873 $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
879 ifeq ($(ARCH), x86_64)
881 ifeq ($(CC_NAME), gcc)
882 C_DEFS+=-DCC_GCC_LIKE_ASM
884 CFLAGS=-g -O9 -funroll-loops -Wcast-align $(PROFILE)
886 ifeq ($(CC_SHORTVER), 4.2+)
888 CFLAGS+=-m64 -minline-all-stringops \
891 -fno-strict-overflow \
896 ifeq ($(CC_SHORTVER), 4.x)
898 CFLAGS+=-m64 -minline-all-stringops \
905 ifeq ($(CC_SHORTVER), 3.4)
907 CFLAGS+=-m64 -minline-all-stringops \
912 ifeq ($(CC_SHORTVER), 3.0)
914 CFLAGS+=-minline-all-stringops \
916 #-mcpu=$(CPU) \ # not working on all x86_64 gccs
918 #-m64 on x86_64/x86 works starting with gcc 3.2
920 ifeq ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
921 $(warning Old gcc detected ($(CC_SHORTVER)), use gcc >= 3.1 \
928 $(warning You are using an old and unsupported gcc \
929 version ($(CC_SHORTVER)), compile at your own risk!)
931 endif # CC_SHORTVER, 2.9x
932 endif # CC_SHORTVER, 3.0
933 endif # CC_SHORTVER, 3.4
934 endif # CC_SHORTVER, 4.x
935 endif # CC_SHORTVER, 4.2+
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.,
948 $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
954 ifeq ($(ARCH), sparc64)
956 ifeq ($(CC_NAME), gcc)
957 C_DEFS+=-DCC_GCC_LIKE_ASM -DSPARC64_MODE
959 CFLAGS=-g -O9 -funroll-loops $(PROFILE) \
961 #-Wmissing-prototypes
963 ifeq ($(CC_SHORTVER), 4.2+)
966 CFLAGS+=-m64 -mcpu=ultrasparc \
968 -fno-strict-overflow \
970 # use -m64 to force 64 bit (but add it also to LDFLAGS and
971 # don't forget to define SPARC64_MODE)
972 # -m32 for 32 bit (default on solaris),
973 # nothing for arch. default
977 ifeq ($(CC_SHORTVER), 4.x)
980 CFLAGS+=-m64 -mcpu=ultrasparc \
986 ifeq ($(CC_SHORTVER), 3.4)
989 CFLAGS+=-m64 -mcpu=ultrasparc -mtune=$(CPU)
993 ifeq ($(CC_SHORTVER), 3.0)
996 CFLAGS+=-m64 -mcpu=ultrasparc -mtune=$(CPU) \
997 # -mcpu=v9 or ultrasparc? # -mtune implied by -mcpu
998 #-mno-epilogue #try to inline function exit code
999 #-mflat # omit save/restore
1000 #-,faster-structs #faster non Sparc ABI structure copy ops
1002 else # CC_SHORTVER, 3.0
1003 ifeq ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1004 $(warning Old gcc detected ($(CC_SHORTVER)), use gcc >= 3.1 \
1006 ifneq ($(OS), netbsd)
1007 # on netbsd/sparc64, gcc 2.95.3 does not compile
1010 # -m64/-m32 on sparc works starting with gcc 3.0
1012 ifeq ($(ASTYPE), solaris)
1013 CFLAGS+= -Wa,-xarch=v8plus
1015 else #CC_SHORTVER, 2.9x
1017 $(warning You are using an old and unsupported gcc \
1018 version ($(CC_SHORTVER)), compile at your own risk!)
1021 ifeq ($(ASTYPE), solaris)
1022 CFLAGS+= -Wa,-xarch=v8plus
1025 endif #CC_SHORTVER, 2.9x
1026 endif #CC_SHORTVER, 3.0
1027 endif #CC_SHORTVER, 3.4
1028 endif #CC_SHORTVER, 4.x
1029 endif #CC_SHORTVER, 4.2+
1032 ifeq ($(CC_NAME), suncc)
1033 C_DEFS+=-DSPARC64_MODE
1034 CFLAGS+= -m64 -g -xO5 -fast -native -xarch=v9 -xCC \
1036 # -Dinline="" # add this if cc < 5.3 (define inline as null)
1039 $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1040 endif #CC_NAME, suncc
1042 endif #ARCH, sparc64
1045 ifeq ($(ARCH), sparc)
1047 ifeq ($(CC_NAME), gcc)
1048 C_DEFS+=-DCC_GCC_LIKE_ASM
1050 CFLAGS=-g -O9 -funroll-loops $(PROFILE) \
1052 #-Wmissing-prototypes
1054 ifeq ($(CC_SHORTVER), 4.2+)
1057 CFLAGS+= -mtune=$(CPU) \
1058 -fno-strict-overflow \
1062 ifeq ($(CC_SHORTVER), 4.x)
1065 CFLAGS+= -mtune=$(CPU) \
1069 ifeq ($(CC_SHORTVER), 3.4)
1072 CFLAGS+= -mtune=$(CPU)
1075 ifeq ($(CC_SHORTVER), 3.0)
1078 CFLAGS+= -mtune=$(CPU) \
1079 #-mno-epilogue #try to inline function exit code
1080 #-mflat # omit save/restore
1081 #-,faster-structs #faster non Sparc ABI structure copy ops
1082 else # CC_SHORTVER, 3.0
1083 ifeq ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1084 $(warning Old gcc detected ($(CC_SHORTVER)), use gcc >= 3.1 \
1086 else #CC_SHORTVER, 2.9x
1088 $(warning You are using an old and unsupported gcc \
1089 version ($(CC_SHORTVER)), compile at your own risk!)
1091 endif #CC_SHORTVER, 2.9x
1092 endif #CC_SHORTVER, 3.0
1093 endif #CC_SHORTVER, 3.4
1094 endif #CC_SHORTVER, 4.x
1095 endif #CC_SHORTVER, 4.2+
1098 ifeq ($(CC_NAME), suncc)
1099 CFLAGS+= -g -xO5 -fast -native -xCC \
1101 # -Dinline="" # add this if cc < 5.3 (define inline as null)
1104 $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1105 endif #CC_NAME, suncc
1112 ifeq ($(CC_NAME), gcc)
1113 C_DEFS+=-DCC_GCC_LIKE_ASM
1115 CFLAGS=-O9 -funroll-loops -fsigned-char $(PROFILE)
1117 ifeq ($(CC_SHORTVER), 4.2+)
1118 CFLAGS+= -ftree-vectorize -fno-strict-overflow
1119 # not supported on arm: -minline-all-stringops
1122 ifeq ($(CC_SHORTVER), 4.x)
1123 CFLAGS+= -ftree-vectorize
1124 # not supported on arm: -minline-all-stringops
1127 ifeq ($(CC_SHORTVER), 3.4)
1131 ifeq ($(CC_SHORTVER), 3.0)
1135 ifeq ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1136 $(warning Old gcc detected ($(CC_SHORTVER)), use gcc 3.0.x \
1142 $(warning You are using an old and unsupported gcc \
1143 version ($(CC_SHORTVER)), compile at your own risk!)
1145 endif # CC_SHORTVER, 2.9x
1146 endif # CC_SHORTVER, 3.0
1147 endif # CC_SHORTVER, 3.4
1148 endif # CC_SHORTVER, 4.x
1149 endif # CC_SHORTVER, 4.2+
1153 $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1158 ifeq ($(ARCH), arm6)
1160 ifeq ($(CC_NAME), gcc)
1161 C_DEFS+=-DCC_GCC_LIKE_ASM
1163 CFLAGS=-march=armv6 -O9 -funroll-loops -fsigned-char \
1166 ifeq ($(CC_SHORTVER), 4.2+)
1167 CFLAGS+= -ftree-vectorize -fno-strict-overflow
1170 ifeq ($(CC_SHORTVER), 4.x)
1171 CFLAGS+= -ftree-vectorize
1174 ifeq ($(CC_SHORTVER), 3.4)
1178 ifeq ($(CC_SHORTVER), 3.0)
1182 ifeq ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1183 $(warning Old gcc detected ($(CC_SHORTVER)), use gcc 3.0.x \
1189 $(warning You are using an old and unsupported gcc \
1190 version ($(CC_SHORTVER)), compile at your own risk!)
1192 endif # CC_SHORTVER, 2.9x
1193 endif # CC_SHORTVER, 3.0
1194 endif # CC_SHORTVER, 3.4
1195 endif # CC_SHORTVER, 4.x
1196 endif # CC_SHORTVER, 4.2+
1200 $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1205 ifeq ($(ARCH), mips)
1207 ifeq ($(CC_NAME), gcc)
1208 C_DEFS+=-DCC_GCC_LIKE_ASM
1210 CFLAGS=-O9 -funroll-loops $(PROFILE)
1212 ifeq ($(CC_SHORTVER), 4.2+)
1213 CFLAGS+=-march=r3000 -minline-all-stringops \
1214 -ftree-vectorize -fno-strict-overflow
1217 ifeq ($(CC_SHORTVER), 4.x)
1218 CFLAGS+=-march=r3000 -minline-all-stringops \
1222 ifeq ($(CC_SHORTVER), 3.4)
1223 CFLAGS+= -march=r3000
1226 ifeq ($(CC_SHORTVER), 3.0)
1227 CFLAGS+= -march=r3000
1229 ifeq ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1230 $(warning Old gcc detected ($(CC_SHORTVER)), use gcc 3.0.x \
1233 CFLAGS+=-march=r3000
1236 $(warning You are using an old and unsupported gcc \
1237 version ($(CC_SHORTVER)), compile at your own risk!)
1239 endif # CC_SHORTVER, 2.9x
1240 endif # CC_SHORTVER, 3.0
1241 endif # CC_SHORTVER, 3.4
1242 endif # CC_SHORTVER, 4.x
1243 endif # CC_SHORTVER, 4.2+
1247 $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1251 #if >=mips2 (R4000, R5000, R6000 ....)
1252 ifeq ($(ARCH), mips2)
1254 ifeq ($(CC_NAME), gcc)
1255 C_DEFS+=-DCC_GCC_LIKE_ASM
1257 CFLAGS= -mips2 -O9 -funroll-loops $(PROFILE)
1259 ifeq ($(CC_SHORTVER), 4.2+)
1260 CFLAGS+=-minline-all-stringops -ftree-vectorize \
1261 -fno-strict-overflow
1264 ifeq ($(CC_SHORTVER), 4.x)
1265 CFLAGS+=-minline-all-stringops -ftree-vectorize
1268 ifeq ($(CC_SHORTVER), 3.4)
1272 ifeq ($(CC_SHORTVER), 3.0)
1275 ifeq ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1276 $(warning Old gcc detected ($(CC_SHORTVER)), use gcc 3.0.x \
1281 $(warning You are using an old and unsupported gcc \
1282 version ($(CC_SHORTVER)), compile at your own risk!)
1284 endif # CC_SHORTVER, 2.9x
1285 endif # CC_SHORTVER, 3.0
1286 endif # CC_SHORTVER, 3.4
1287 endif # CC_SHORTVER, 4.x
1288 endif # CC_SHORTVER, 4.2+
1292 $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1297 ifeq ($(ARCH), mips64)
1299 ifeq ($(CC_NAME), gcc)
1300 C_DEFS+=-DCC_GCC_LIKE_ASM
1302 CFLAGS= -mips64 -O9 -funroll-loops $(PROFILE)
1304 ifeq ($(CC_SHORTVER), 4.2+)
1305 CFLAGS+=-minline-all-stringops -ftree-vectorize \
1306 -fno-strict-overflow
1309 ifeq ($(CC_SHORTVER), 4.x)
1310 CFLAGS+=-minline-all-stringops -ftree-vectorize
1313 ifeq ($(CC_SHORTVER), 3.4)
1317 ifeq ($(CC_SHORTVER), 3.0)
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 \
1326 $(warning You are using an old and unsupported gcc \
1327 version ($(CC_SHORTVER)), compile at your own risk!)
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, 4.2+
1337 $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1342 ifeq ($(ARCH), alpha)
1344 ifeq ($(CC_NAME), gcc)
1345 C_DEFS+=-DCC_GCC_LIKE_ASM
1347 CFLAGS= -O9 -funroll-loops $(PROFILE)
1349 ifeq ($(CC_SHORTVER), 4.2+)
1350 CFLAGS+= -fno-strict-overflow
1351 # not supported: -minline-all-stringops
1354 ifeq ($(CC_SHORTVER), 4.x)
1356 # not supported: -minline-all-stringops
1359 ifeq ($(CC_SHORTVER), 3.4)
1363 ifeq ($(CC_SHORTVER), 3.0)
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 \
1372 $(warning You are using an old and unsupported gcc \
1373 version ($(CC_SHORTVER)), compile at your own risk!)
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, 4.2+
1383 $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1390 ifeq ($(CC_NAME), gcc)
1391 C_DEFS+=-DCC_GCC_LIKE_ASM
1393 CFLAGS= -O9 -funroll-loops -fsigned-char $(PROFILE)
1395 ifeq ($(CC_SHORTVER), 4.2+)
1397 CFLAGS+=-ftree-vectorize \
1398 -fno-strict-overflow \
1399 -mtune=$(CPU) -maltivec
1402 ifeq ($(CC_SHORTVER), 4.x)
1404 CFLAGS+=-ftree-vectorize \
1405 -mtune=$(CPU) -maltivec
1408 ifeq ($(CC_SHORTVER), 3.4)
1412 ifeq ($(CC_SHORTVER), 3.0)
1415 ifeq ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1416 $(warning Old gcc detected ($(CC_SHORTVER)), use gcc 3.0.x \
1421 $(warning You are using an old and unsupported gcc \
1422 version ($(CC_SHORTVER)), compile at your own risk!)
1424 endif # CC_SHORTVER, 2.9x
1425 endif # CC_SHORTVER, 3.0
1426 endif # CC_SHORTVER, 3.4
1427 endif # CC_SHORTVER, 4.x
1428 endif # CC_SHORTVER, 4.2+
1432 $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1437 ifeq ($(ARCH), ppc64)
1439 ifeq ($(CC_NAME), gcc)
1440 C_DEFS+=-DCC_GCC_LIKE_ASM
1442 CFLAGS= -O9 -funroll-loops -fsigned-char $(PROFILE)
1444 ifeq ($(CC_SHORTVER), 4.2+)
1446 CFLAGS+=-ftree-vectorize \
1447 -fno-strict-overflow \
1448 -mtune=$(CPU) -maltivec
1451 ifeq ($(CC_SHORTVER), 4.x)
1453 CFLAGS+=-ftree-vectorize \
1454 -mtune=$(CPU) -maltivec
1457 ifeq ($(CC_SHORTVER), 3.4)
1461 ifeq ($(CC_SHORTVER), 3.0)
1464 ifeq ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1465 $(warning Old gcc detected ($(CC_SHORTVER)), use gcc 3.0.x \
1470 $(warning You are using an old and unsupported gcc \
1471 version ($(CC_SHORTVER)), compile at your own risk!)
1473 endif # CC_SHORTVER, 2.9x
1474 endif # CC_SHORTVER, 3.0
1475 endif # CC_SHORTVER, 3.4
1476 endif # CC_SHORTVER, 4.x
1477 endif # CC_SHORTVER, 4.2+
1481 $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1485 CFLAGS+= $(CC_EXTRA_OPTS)
1489 ifeq ($(CC_NAME), gcc)
1490 ifeq ($(LDTYPE), solaris)
1492 LDFLAGS+=-O2 $(PROFILE)
1493 MOD_LDFLAGS:=-G $(LDFLAGS)
1494 LIB_LDFLAGS:=-G $(LDFLAGS)
1498 #gcc and maybe others, => gnu ld
1499 LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE)
1500 MOD_LDFLAGS:=-shared $(LDFLAGS)
1501 LIB_LDFLAGS:=-shared $(LDFLAGS)
1502 LIB_SONAME=-Wl,-soname,
1503 LD_RPATH=-Wl,-rpath,
1506 ifeq ($(CC_NAME), icc)
1507 #gcc and maybe others
1508 LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE)
1509 MOD_LDFLAGS:=-shared $(LDFLAGS)
1510 LIB_LDFLAGS:=-shared $(LDFLAGS)
1511 LIB_SONAME=-Wl,-soname,
1512 LD_RPATH=-Wl,-rpath,
1514 ifeq ($(CC_NAME), suncc)
1516 LDFLAGS+=-xO5 $(PROFILE)
1517 MOD_LDFLAGS:=-G $(LDFLAGS)
1518 LIB_LDFLAGS:=-G $(LDFLAGS)
1522 # we need -fPIC -DPIC only for shared objects, we don't need them for
1523 # the executable file, because it's always loaded at a fixed address
1526 ifeq ($(CC_NAME), gcc)
1527 CFLAGS=-g -Wcast-align $(PROFILE)
1528 C_DEFS+=-DCC_GCC_LIKE_ASM
1529 ifeq ($(ARCH), sparc64)
1530 C_DEFS+=SPARC64_MODE
1531 CFLAGS+= -mcpu=ultrasparc -m64
1534 ifeq ($(LDTYPE), solaris)
1536 LDFLAGS+=-g $(PROFILE)
1537 MOD_LDFLAGS:=-G $(LDFLAGS)
1538 LIB_LDFLAGS:=-G $(LDFLAGS)
1542 #gnu or other ld type
1543 LDFLAGS+=-g -Wl,-E $(PROFILE)
1544 MOD_LDFLAGS:=-shared $(LDFLAGS)
1545 LIB_LDFLAGS:=-shared $(LDFLAGS)
1546 LIB_SONAME=-Wl,-soname,
1547 LD_RPATH=-Wl,-rpath,
1550 ifeq ($(CC_NAME), icc)
1551 C_DEFS+=-DCC_GCC_LIKE_ASM
1552 CFLAGS=-g $(PROFILE)
1553 LDFLAGS+=-g -Wl,-E $(PROFILE)
1554 MOD_LDFLAGS:=-shared $(LDFLAGS)
1555 LIB_LDFLAGS:=-shared $(LDFLAGS)
1556 LIB_SONAME=-Wl,-soname,
1557 LD_RPATH=-Wl,-rpath,
1559 ifeq ($(CC_NAME), suncc)
1560 CFLAGS= -g $(PROFILE)
1561 LDFLAGS+=-g $(PROFILE)
1562 MOD_LDFLAGS:=-G $(LDFLAGS)
1563 LIB_LDFLAGS:=-G $(LDFLAGS)
1571 # set pedantic compiler options
1572 ifeq ($(CC_NAME), gcc)
1575 ifeq ($(CC_NAME), icc)
1578 ifeq ($(CC_NAME), suncc)
1579 # FIXME: is the default (-Xa ?) enough?
1580 endif # CC_NAME=suncc
1584 #CFLAGS used for compiling the modules, libraries and utils
1585 ifeq ($(CC_NAME), gcc)
1586 MOD_CFLAGS=-fPIC -DPIC $(CFLAGS)
1587 LIB_CFLAGS=-fPIC -DPIC $(CFLAGS)
1589 ifeq ($(CC_NAME), icc)
1590 MOD_CFLAGS=-Kpic $(CFLAGS)
1591 LIB_CFLAGS=-Kpic $(CFLAGS)
1593 ifeq ($(CC_NAME), suncc)
1594 # FIMXE: use -KPIC instead -xcode ?
1595 MOD_CFLAGS=-xcode=pic32 $(CFLAGS)
1596 LIB_CFLAGS=-xcode=pic32 $(CFLAGS)
1598 UTILS_CFLAGS=$(CFLAGS)
1599 # LDFLAGS uses for compiling the utils
1600 UTILS_LDFLAGS=$(LDFLAGS)
1608 YACC_FLAGS=-d -b cfg
1609 # on solaris add -lxnet (e.g. LIBS= -lxnet)
1617 # by default use futexes if available
1619 C_DEFS+=-DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
1620 -DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H \
1621 -DHAVE_TIMEGM -DHAVE_SCHED_SETSCHEDULER
1622 ifneq ($(found_lock_method), yes)
1623 #C_DEFS+= -DUSE_POSIX_SEM
1624 C_DEFS+=-DUSE_PTHREAD_MUTEX
1626 #C_DEFS+= -DUSE_SYSV_SEM # try posix sems
1627 found_lock_method=yes
1629 ifneq (,$(findstring -DUSE_POSIX_SEM, $(C_DEFS)))
1632 ifneq (,$(findstring -DUSE_PTHREAD_MUTEX, $(C_DEFS)))
1636 # check for >= 2.5.44
1637 ifeq ($(shell [ $(OSREL_N) -ge 2005044 ] && echo has_epoll), has_epoll)
1639 C_DEFS+=-DHAVE_EPOLL
1640 # linux + gcc >= 3.0 + -malign-double + epoll => problems
1641 CFLAGS_RM+=-malign-double
1642 #CFLAGS:=$(filter-out -malign-double, $(CFLAGS))
1645 # check for >= 2.2.0
1646 ifeq ($(shell [ $(OSREL_N) -ge 2002000 ] && echo has_sigio), has_sigio)
1648 C_DEFS+=-DHAVE_SIGIO_RT -DSIGINFO64_WORKARROUND
1651 # check for >= 2.5.70
1652 ifeq ($(shell [ $(OSREL_N) -ge 2005070 ] && echo has_futex), has_futex)
1653 ifeq ($(use_futex), yes)
1657 ifeq ($(NO_SELECT),)
1658 C_DEFS+=-DHAVE_SELECT
1662 # test to see if the devfiles and lib are installed
1663 sctp_dev_locations := /usr/include/netinet/sctp.h \
1664 $(LOCALBASE)/include/netinet/sctp.h
1665 sctp_lib_locations := /usr/lib/libsctp.so \
1666 $(LOCALBASE)/usr/local/lib/libsctp.so
1667 sctp_dev_path := $(wildcard $(sctp_dev_locations))
1668 sctp_lib_path := $(wildcard $(sctp_lib_locations))
1669 ifeq ($(sctp_dev_path),)
1670 $(info "sctp development files not installed -- sctp disabled")
1673 ifeq ($(sctp_lib_path),)
1674 $(info "sctp libraries not installed -- sctp disabled")
1686 ifeq ($(OS), solaris)
1687 C_DEFS+= -DHAVE_GETIPNODEBYNAME -DHAVE_SYS_SOCKIO_H -DHAVE_SCHED_YIELD \
1688 -DHAVE_ALLOCA_H -DUSE_SIGACTION
1689 ifneq ($(found_lock_method), yes)
1690 C_DEFS+= -DUSE_PTHREAD_MUTEX # try pthread sems
1691 found_lock_method=yes
1693 # check for ver >= 5.7
1694 ifeq ($(shell [ $(OSREL_N) -gt 5007 ] && echo has_devpoll), has_devpoll)
1695 ifeq ($(NO_DEVPOLL),)
1696 C_DEFS+=-DHAVE_DEVPOLL
1699 ifeq ($(NO_SELECT),)
1700 C_DEFS+=-DHAVE_SELECT
1703 filio_h_locations= /usr/include/sys/filio.h \
1704 $(LOCALBASE)/include/sys/filio.h
1705 has_filio_h=$(shell for r in $(filio_h_locations); do \
1706 if [ -r "$$r" ] ; then echo yes; exit; fi \
1709 ifeq ($(has_filio_h), yes)
1710 C_DEFS+=-DHAVE_FILIO_H
1712 ifeq ($(mode), release)
1713 #use these only if you're using gcc with Solaris ld
1714 #LDFLAGS=-O2 $(PROFILE)
1717 #LDFLAGS=-g $(PROFILE)
1722 ifeq ($(CC_NAME), suncc)
1723 LIBS= -lfast -ldl -lresolv
1725 OLD_SOLARIS= $(shell echo "$(OSREL)" | \
1726 sed -e 's/^5\.[0-6][^0-9]*$$/yes/' )
1727 LIBS+= -L$(LOCALBASE)/lib -lxnet -lnsl
1728 ifeq ($(OLD_SOLARIS), yes)
1733 # -lrt needed for sched_yield
1736 ifeq ($(OS), freebsd)
1737 C_DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
1738 -DHAVE_SCHED_YIELD -DHAVE_MSGHDR_MSG_CONTROL \
1739 -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
1740 -DHAVE_NETINET_IN_SYSTM
1741 ifneq ($(found_lock_method), yes)
1742 C_DEFS+= -DUSE_PTHREAD_MUTEX # try pthread sems
1743 found_lock_method=yes
1744 LIBS+= -pthread #dlopen is in libc
1746 LIBS= #dlopen is in libc
1748 # check for ver >= 4.1
1749 ifeq ($(shell [ $(OSREL_N) -gt 4001 ] && echo has_kqueue), has_kqueue)
1750 ifeq ($(NO_KQUEUE),)
1751 C_DEFS+=-DHAVE_KQUEUE
1754 ifeq ($(NO_SELECT),)
1755 C_DEFS+=-DHAVE_SELECT
1760 # test to see if the devfiles and lib are installed
1761 sctp_dev_locations := /usr/include/netinet/sctp.h \
1762 $(LOCALBASE)/include/netinet/sctp.h
1763 sctp_dev_path := $(wildcard $(sctp_dev_locations))
1764 ifeq ($(sctp_dev_path),)
1765 $(info "sctp development files not installed -- sctp disabled")
1768 ifeq ($(shell [ $(OSREL_N) -lt 7000 ] && echo sctp), sctp)
1769 $(info "old freebsd version (>= 7.0 needed) -- sctp disabled")
1775 LIBS+= # no extra libs needed on freebsd
1780 ifeq ($(OS), openbsd)
1781 C_DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 \
1782 -DHAVE_UNION_SEMUN -DHAVE_MSGHDR_MSG_CONTROL \
1783 -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
1784 -DHAVE_NETINET_IN_SYSTM -DUSE_SIGWAIT
1785 ifneq ($(found_lock_method), yes)
1786 C_DEFS+= -DUSE_PTHREAD_MUTEX # try pthread sems
1787 found_lock_method=yes
1789 # check for ver >=2 9
1790 ifeq ($(shell [ $(OSREL_N) -ge 2009 ] && echo has_kqueue), has_kqueue)
1791 ifeq ($(NO_KQUEUE),)
1792 C_DEFS+=-DHAVE_KQUEUE
1795 ifeq ($(NO_SELECT),)
1796 C_DEFS+=-DHAVE_SELECT
1798 # (symbols on openbsd are prefixed by "_")
1800 # no sched_yield on openbsd unless linking with c_r (not recommended)
1801 # unfortunately pthread is needed for sigwait
1803 OPENBSD_IS_AOUT:= $(shell echo "$(OSREL)" | \
1804 sed -e 's/^3\.[0-3][^0-9]*$$/yes/' |sed -e 's/^[0-2]\..*/yes/')
1805 # exception: on sparc openbsd 3.2 is elf and not aout
1806 ifeq ($(OSREL), 3.2)
1807 ifeq ($(ARCH), sparc)
1810 ifeq ($(ARCH), sparc64)
1815 ifeq ($(OPENBSD_IS_AOUT), yes)
1816 C_DEFS+=-DDLSYM_PREFIX='"_"'
1817 LDFLAGS= # openbsd ld doesn't like -O2 or -E
1821 ifeq ($(OS), netbsd)
1822 C_DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 \
1823 -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM
1824 ifneq ($(found_lock_method), yes)
1825 C_DEFS+= -DUSE_SYSV_SEM # try pthread sems
1826 found_lock_method=yes
1828 # check for ver >= 2.0.0
1829 ifeq ($(shell [ $(OSREL_N) -ge 2000000 ] && echo has_kqueue), has_kqueue)
1830 ifeq ($(NO_KQUEUE),)
1831 C_DEFS+=-DHAVE_KQUEUE
1832 # netbsd + kqueue and -malign-double don't work
1833 CFLAGS_RM+=-malign-double
1834 #CFLAGS:=$(filter-out -malign-double, $(CFLAGS))
1837 ifeq ($(NO_SELECT),)
1838 C_DEFS+=-DHAVE_SELECT
1844 # OS X support, same as freebsd
1845 ifeq ($(OS), darwin)
1846 C_DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
1847 -DHAVE_SCHED_YIELD -DHAVE_MSGHDR_MSG_CONTROL \
1849 -DNDEBUG -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
1851 # -DNDEBUG used to turn off assert (assert wants to call
1852 # eprintf which doesn't seem to be defined in any shared lib
1853 ifneq ($(found_lock_method), yes)
1854 C_DEFS+= -DUSE_PTHREAD_MUTEX # try pthread sems
1855 found_lock_method=yes
1856 C_DEFS+= -DUSE_SYSV_SEM # try sys v sems (pthread don't work for
1857 # processes and unnamed posix sems are not
1860 LIBS= -lresolv #dlopen is in libc
1861 ifeq ($(NO_KQUEUE),)
1862 C_DEFS+=-DHAVE_KQUEUE
1864 ifeq ($(NO_SELECT),)
1865 C_DEFS+=-DHAVE_SELECT
1867 LDFLAGS= # darwin doesn't like -O2 or -E
1868 # the modules uses symbols from ser => either
1869 # -flat_namespace -undefined_suppress or -bundle_loader ../../$(MAIN_NAME)
1870 MOD_LDFLAGS:= -bundle -flat_namespace -undefined suppress
1871 # for libs using symbols from ser (e.g srdb2, kcore a.s.o) we
1872 # need -flat_namespace -undefined suppress
1873 LIB_LDFLAGS:= -dynamiclib -flat_namespace -undefined suppress
1875 # on darwin soname should include the full path
1876 # (it kind of combines rpath & soname)
1878 # no equiv. for rpath on darwin
1883 ifneq (,$(findstring cygwin, $(OS)))
1884 # cygwin doesn't support IPV6 and doesn't support fd passing so no TCP
1885 #C_DEFS:=$(filter-out -DUSE_IPV6 -DUSE_TCP, $(C_DEFS))
1886 DEFS_RM+=-DUSE_IPV6 -DUSE_TCP
1887 C_DEFS+=-DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
1888 -DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H \
1889 -DHAVE_TIMEGM -DHAVE_SCHED_SETSCHEDULER
1890 ifneq ($(found_lock_method), yes)
1891 C_DEFS+= -DUSE_POSIX_SEM
1892 #C_DEFS+= -DUSE_SYSV_SEM # try posix sems
1893 # PTHREAD_MUTEX do not work for processes (try test/pthread_test.c)
1895 found_lock_method=yes
1897 ifneq (,$(findstring -DUSE_POSIX_SEM, $(C_DEFS)))
1900 ifneq (,$(findstring -DUSE_PTHREAD_MUTEX, $(C_DEFS)))
1901 $(error PTHREAD_MUTEX do not work for processes on Windows/CYGWIN)
1904 # check for >= 2.5.70
1905 ifeq ($(NO_SELECT),)
1906 C_DEFS+=-DHAVE_SELECT
1910 #add libssl if needed
1911 ifeq ($(CORE_TLS), 1)
1912 C_INCLUDES+= -I$(LOCALBASE)/ssl/include
1913 LIBS+= -L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib -lssl -lcrypto \
1915 # NOTE: depending on the way in which libssl was compiled you might
1916 # have to add -lz -lkrb5 (zlib and kerberos5).
1917 # E.g.: make CORE_TLS=1 EXTRA_TLS_LIBS="-lz -lkrb5"
1921 C_INCLUDES+= -I$(LOCALBASE)/ssl/include
1922 LIBS+= -L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib -lcrypto
1925 ifneq ($(found_lock_method), yes)
1926 $(warning No locking method found so far, trying SYS V sems)
1927 C_DEFS+= -DUSE_SYSV_SEM # try sys v sems
1928 found_lock_method=yes
1932 endif # ifeq (,$(main_makefile))
1933 endif # ifeq ($(makefile_defs), 1)
1935 # if incomplete or missing config.mak, or already exported vars, don't
1936 # try to export/re-export
1937 ifeq ($(makefile_defs),1)
1938 ifneq ($(exported_vars),1)
1941 override exported_vars:=1
1942 export exported_vars
1944 # variable changeable only at configure time (once saved in config.mak they
1945 # cannot be overwritten from environment or command line, unless make cfg
1947 saved_fixed_vars:= MAIN_NAME CFG_NAME SCR_NAME FLAVOUR INSTALL_FLAVOUR \
1948 SRC_NAME RELEASE OS ARCH \
1949 C_DEFS DEFS_RM PROFILE CC LD MKDEP MKTAGS LDFLAGS C_INCLUDES \
1950 MOD_LDFLAGS LIB_LDFLAGS UTILS_LDFLAGS LIB_SONAME LD_RPATH \
1951 LIB_SUFFIX LIB_PREFIX \
1953 LEX YACC YACC_FLAGS \
1956 INSTALL INSTALL_CFG INSTALL_BIN INSTALL_MODULES INSTALL_DOC \
1957 INSTALL_MAN INSTALL_LIB INSTALL_TOUCH INSTALL_SHARE \
1960 # variable changeable at compile time
1961 # extra: prefix DESTDIR BASEDIR basedirt
1963 CC_EXTRA_OPTS CPU CFLAGS_RM CFLAGS MOD_CFLAGS LIB_CFLAGS UTILS_CFLAGS \
1964 BASEDIR basedir DESTDIR \
1966 cfg_prefix cfg_dir bin_prefix bin_dir modules_prefix modules_dir \
1967 doc_prefix doc_dir man_prefix man_dir ut_prefix ut_dir \
1968 share_prefix share_dir lib_prefix lib_dir data_prefix data_dir \
1969 cfg_target lib_target data_target
1972 #export relevant variables to the sub-makes
1973 export $(saved_fixed_vars)
1974 export $(saved_chg_vars)
1977 endif # ifneq ($(exported_vars),1)
1978 endif # ifeq ($(makefile_defs),1)