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)
77 # 2010-03-10 added CC_MKDEP_OPTS, which contains to the list of options
78 # needed to generate dependencies on-the-fly while compiling
79 # or is empty if the compiler doesn't support it (andrei)
81 quiet?=$(if $(filter 1 yes on,$(Q)),silent,verbose)
83 # check if already included/exported
85 # used for sanity checks for Makefile.defs inclusion (!= makefile_defs which
86 # specifies if we have a set of valid defs)
87 override makefile_defs_included:=1
88 ifeq ($(makefile_defs),1)
89 ifeq ($(quiet),verbose)
90 $(info Makefile.defs defs skipped)
95 ifeq (,$(main_makefile))
96 # hack to automatically use config.mak in all the modules, without
97 # changing the current module makefiles (which all include Makefile.defs):
98 # if not called from the main makefile (module, lib or ut):
99 # include config.mak, but if not present or incomplete (makefile_defs!=1)
100 # don't export the vars)
102 include $(COREPATH)/config.mak
103 ifeq ($(quiet),verbose)
104 $(info config.mak included)
106 # config.mak should set makefile_defs if complete
110 override makefile_defs=1
114 ifeq ($(quiet),verbose)
115 $(info normal Makefile.defs exec)
118 # flavour: sip-router, ser or kamailio
121 #prefix for various configs and scripts
122 #config name/name-prefix for distributed configs
124 #config name/name-prefix for distributed scripts
129 ifeq ($(FLAVOUR),sip-router)
132 else ifeq ($(FLAVOUR),ser)
135 else ifeq ($(FLAVOUR),kamailio)
138 # use kamailio config
140 # kamailio statistics on
142 # fast malloc statistics on
150 INSTALL_FLAVOUR=$(FLAVOUR)
158 # memory debugger switcher
159 # 0 - off (release mode)
160 # 1 - on (devel mode)
163 SER_VER = $(shell expr $(VERSION) \* 1000000 + $(PATCHLEVEL) \* 1000 + \
165 RELEASE:=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
166 OS := $(shell uname -s | sed -e s/SunOS/solaris/ -e s/CYGWIN.*/cygwin/ \
167 | tr "[A-Z]" "[a-z]")
178 HOST_ARCH := $(shell $(GETARCH) |sed -e s/i.86/i386/ -e s/sun4[uv]/sparc64/ \
179 -e s/armv[3-5].*/arm/ -e s/armv6.*/arm6/ \
180 -e "s/Power Macintosh/ppc/" \
181 -e "s/cobalt/mips2/" \
182 -e s/amd64/x86_64/ -e s/sparcv9/sparc64/ )
183 # fix sparc -> sparc64
184 ifeq ($(HOST_ARCH),sparc)
185 ifeq ($(shell uname -m),sun4u)
188 ifeq ($(shell uname -m),sun4v)
193 OSREL := $(shell uname -r)
194 # numerical version (good for comparisons: A.B.C => A*1000000+B*1000+C)
195 OSREL_N:= $(shell echo $(OSREL) | sed -e 's/^[^0-9]*//' \
196 -e 's/^\([0-9][0-9]*\(\.[0-9][0-9]*\)*\).*$$/\1/g' | \
197 (IFS=. read A B C D; R=0; \
198 [ -n "$$A" ] && R=`expr $$R \* 1000 + $$A` && \
199 [ -n "$$B" ] && R=`expr $$R \* 1000 + $$B` && \
200 [ -n "$$C" ] && R=`expr $$R \* 1000 + $$C`; echo $$R ) )
205 # by default compile with tls hooks support (so that no ser recompile is
206 # needed before the tls module can be used)
208 ifeq ($(CORE_TLS), 1)
209 RELEASE:=$(RELEASE)-tls
212 ifeq ($(TLS_HOOKS), 1)
213 # RELEASE:=$(RELEASE)-tls
216 # extra CC command line options (e.g -march=athlon-mp)
220 cfg_dir = etc/$(MAIN_NAME)/
222 share_dir = share/$(MAIN_NAME)/
223 # lib/$(MAIN_NAME)/modules , lib/$(MAIN_NAME)/modules-s, lib/$(MAIN_NAME)/modules-k
224 modules_dir = lib/$(MAIN_NAME)/
225 lib_dir = lib/$(MAIN_NAME)/
227 doc_dir = share/doc/$(MAIN_NAME)/
229 data_dir = share/$(MAIN_NAME)/
230 LOCALBASE ?= /usr/local
232 ifeq ($(OS), freebsd)
233 doc_dir = share/doc/$(MAIN_NAME)/
235 data_dir = share/$(MAIN_NAME)/
236 LOCALBASE ?= /usr/local
238 ifeq ($(OS), openbsd)
239 doc_dir = share/doc/$(MAIN_NAME)/
241 data_dir = share/$(MAIN_NAME)/
242 LOCALBASE ?= /usr/local
245 doc_dir = share/doc/$(MAIN_NAME)/
247 data_dir = share/$(MAIN_NAME)/
248 LOCALBASE ?= /usr/pkg
251 doc_dir = share/doc/$(MAIN_NAME)/
253 data_dir = share/$(MAIN_NAME)/
254 LOCALBASE ?= /usr/local
256 doc_dir = doc/$(MAIN_NAME)/
258 data_dir = $(MAIN_NAME)/
259 LOCALBASE ?= /usr/local
267 doxygen_dir=doc/doxygen
270 DESTDIR ?= $(LOCALBASE)
273 # install path is $(basedir) $(prefix)
275 # creating a bin. archive in /tmp, which unpacks in /usr/local
281 # install prefixes for various stuff
282 cfg_prefix = $(basedir)$(prefix)
283 bin_prefix = $(basedir)$(prefix)
284 modules_prefix = $(basedir)$(prefix)
285 lib_prefix = $(basedir)$(prefix)
286 doc_prefix = $(basedir)$(prefix)
287 man_prefix = $(basedir)$(prefix)
288 ut_prefix = $(basedir)$(prefix)
289 share_prefix = $(basedir)$(prefix)
290 data_prefix = $(basedir)$(prefix)
293 # target dirs for various stuff
294 cfg_target = $(prefix)/$(cfg_dir)
295 bin_target = $(prefix)/$(bin_dir)
296 #modules_target = $(prefix)/$(modules_dir)
297 lib_target = $(prefix)/$(lib_dir)
298 doc_target = $(prefix)/$(doc_dir)
299 data_target = $(prefix)/$(data_dir)
303 ifeq ($(OS), solaris)
312 INSTALL_TOUCH = touch # used to create the file first (good to
313 # make solaris install work)
314 INSTALL_CFG = $(INSTALL) -m 644
315 INSTALL_BIN = $(INSTALL) -m 755
316 INSTALL_SCRIPT = $(INSTALL) -m 755
317 INSTALL_MODULES = $(INSTALL) -m 755
318 INSTALL_LIB = $(INSTALL) -m 755
319 INSTALL_DOC = $(INSTALL) -m 644
320 INSTALL_MAN = $(INSTALL) -m 644
321 INSTALL_SHARE = $(INSTALL) -m 644
323 #set some vars from the environment (and not make builtins)
324 CC := $(shell echo "$${CC}")
325 LEX := $(shell echo "$${LEX}")
326 YACC := $(shell echo "$${YACC}")
331 # find compiler name & version
336 CC_LONGVER:=$(shell if $(CC) -v 2>/dev/null; then \
343 #find-out the compiler's name
345 ifneq (,$(findstring gcc, $(CC_LONGVER)))
348 CC_VER:=$(word 1,$(CC)) $(shell $(CC) - --version|head -n 1|\
349 sed -e 's/([^$(RPAREN)]*)//g' \
350 -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 # CC_VER:=$(word 1,$(CC)) $(shell $(CC) - --version|head -n 1|cut -d" " -f 3\
353 # |sed -e 's/^.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/'\
354 # -e 's/^[^0-9].*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/')
355 # sed with POSIX.1 regex doesn't support |, + or ?
356 # (darwin, solaris ...) => this complicated expression
358 #transform gcc version into 2.9x or 3.0
359 CC_SHORTVER:=$(shell echo "$(CC_VER)" | cut -d" " -f 2| \
360 sed -e 's/[^0-9]*-\(.*\)/\1/'| \
361 sed -e 's/2\.9.*/2.9x/' -e 's/3\.[0-3]\..*/3.0/' -e \
362 's/3\.[0-3]/3.0/' -e 's/3\.[4-9]\..*/3.4/' -e \
363 's/3\.[4-9]/3.4/' -e 's/4\.[0-1]\..*/4.x/' -e \
364 's/4\.[0-1]/4.x/' -e 's/4\.[2-9]\..*/4.2+/' -e \
365 's/4\.[2-9]$$/4.2+/')
366 ifeq (,$(strip $(filter-out 3.0 3.4 4.x 4.2+,$(CC_SHORTVER))))
367 # dependencies can be generated on-the-fly while compiling *.c
368 CC_MKDEP_OPTS=-MMD -MP
369 endif # 3.0 <= $(CC_SHORTVER) <= 4.x
372 ifneq (, $(findstring Sun, $(CC_LONGVER)))
374 CC_SHORTVER:=$(shell echo "$(CC_LONGVER)"|head -n 1| \
375 sed -e 's/.*\([0-9]\.[0-9]\).*/\1/g' )
376 CC_VER=$(CC) $(CC_SHORTVER)
380 ifneq (, $(findstring Intel(R) C++ Compiler, $(CC_LONGVER)))
381 # very nice: gcc compatible
383 CC_FULLVER:=$(shell echo "$(CC_LONGVER)"|head -n 1| \
384 sed -e 's/.*Version \([0-9]\.[0-9]\.[0-9]*\).*/\1/g' )
385 CC_SHORTVER:=$(shell echo "$(CC_FULLVER)" | cut -d. -f1,2 )
386 CC_VER=$(CC) $(CC_FULLVER)
397 $(warning Unknown compiler $(CC)\; supported compilers: \
398 gcc, sun cc, intel icc )
402 # predefined compiler macros for different architectures
403 # (see http://predef.sourceforge.net/prearch.html for a more complete list)
404 i386_macros= i386 __i386__ __i486__ __i586__ __i686__ \
405 __i386 _M_IX86 __X86__ _X86_
406 x86_64_macros= __amd64__ __amd64 __x86_64__ __x86_64 _M_X64
408 sparc_macros= __sparc__ __sparc __sparcv8
409 sparc64_macros= __sparcv9 __sparc_v9__
411 arm_macros= __arm__ __thumb__
412 arm6_macros= __ARM_ARCH_6__
414 ppc_macros= __powerpc __powerpc__ __POWERPC__ __ppc__ _ARCH_PPC
415 ppc64_macros= __ppc64__ _ARCH_PPC64
417 mips_macros= __mips__ __mips _MIPS_ARCH_MIPS1
418 mips2_macros= _MIPS_ISA_MIPS2 _MIPS_ISA_MIPS3 _MIPS_ISA_MIPS4 \
419 _MIPS_ARCH_MIPS2 _MIPS_ARCH_MIPS3 _MIPS_ARCH_MIPS4
420 mips64_macros= _MIPS_ISA_MIPS64 _MIPS_ARCH_MIPS64
422 alpha_macros= __alpha__ __alpha _M_ALPHA_
424 ifeq ($(CC_NAME),gcc)
426 predef_macros:=$(shell $(CC) -dM -E -x c $(CC_EXTRA_OPTS) $(extra_defs) \
429 ifneq ($(strip $(filter $(i386_macros), $(predef_macros))),)
431 else ifneq ($(strip $(filter $(x86_64_macros), $(predef_macros))),)
433 else ifneq ($(strip $(filter $(sparc_macros), $(predef_macros))),)
435 ifneq ($(strip $(filter $(sparc64_macros), $(predef_macros))),)
437 else # sparc64_macros
439 endif # sparc64_macros
441 else ifneq ($(strip $(filter $(arm_macros), $(predef_macros))),)
443 ifneq ($(strip $(filter $(arm6_macros), $(predef_macros))),)
449 else ifneq ($(strip $(filter $(ppc64_macros), $(predef_macros))),)
451 else ifneq ($(strip $(filter $(ppc_macros), $(predef_macros))),)
453 else ifneq ($(strip $(filter $(mips_macros), $(predef_macros))),)
455 ifneq ($(strip $(filter $(mips64_macros), $(predef_macros))),)
457 else ifneq ($(strip $(filter $(mips2_macros), $(predef_macros))),)
461 endif # mips64_macros
463 else ifneq ($(strip $(filter $(alpha_macros), $(predef_macros))),)
467 $(warn "Unknown target compiler architecture")
469 endif # predefined macros tests (x86_macros, ...)
478 $(info target architecture <$(ARCH)>, host architecture <$(HOST_ARCH)>)
480 # compile-time options
483 # allows to print out number of packets processed on CTRL-C;
484 # implementation still nasty and reports per-process
486 # turns off some of the debug messages (DBG(...)).
488 # completely turns of all the logging (and DBG(...))
490 # compiles in some extra debugging code
492 # faster ip address resolver for ip strings (e.g "127.0.0.1")
494 # compiles in shared mem. support, needed by some modules and
497 # use mmap instead of SYSV shared memory
499 # uses a faster malloc (exclusive w/ USE_SHM_MEM)
501 # all pkg_malloc => shm_malloc (most mallocs use a common sh.
502 # mem. segment); don't define PKG_MALLOC if you want this!
504 # qm_malloc debug code, will cause pkg_malloc and shm_malloc
505 # to keep and display lot of debuging information: file name,
506 # function, line number of malloc/free call for each block,
507 # extra error checking (trying to free the same pointer
508 # twice, trying to free a pointer alloc'ed with a different
511 # additional option to PKG_MALLOC which utilizes a fater then
513 # (not true anymore, q_malloc performs approx. the same)
515 # an even faster malloc, not recommended for debugging
517 # a malloc implementation based on Doug Lea's dl_malloc
519 # an experimental multi-CPU, pool based, multi-process safe version of
520 # F_MALLOC. Should give better performance on machines with lots of CPUs
521 # after some tunning.
523 # an experimental multi-CPU, pool based, multi-process safe, mostly
524 # lockless version of SF_MALLOC/F_MALLOC. Not for production use for
527 # issues additional debugging information if lock/unlock is called
529 # uses fast arhitecture specific locking (see the arh. specific section)
531 # uses sys v sems for locking (slower & limited number)
532 # -DUSE_PTHREAD_MUTEX
533 # uses pthread mutexes, faster than sys v or posix sems, but do not
534 # work on all systems inter-processes (e.g. linux)
536 # uses posix semaphores for locking (faster than sys v)
538 # uses futexes for locking (linux 2.6+)
540 # uses busy waiting on the lock (FAST_LOCK)
542 # try busy waiting for a while and if the lock is still held go to
543 # force reschedule (FAST_LOCK)
544 # -DADAPTIVE_WAIT_LOOPS=number
545 # number of loops we busy wait, after "number" loops have elapsed we
546 # force a reschedule (FAST_LOCK)
548 # don't use smp compliant locking (faster but won't work on SMP machines)
549 # (not yet enabled) (FAST_LOCK)
550 # -DNO_PINGTEL_TAG_HACK
551 # if enabled, To-header-field will be less liberal and will not accept
552 # 'tag=' (tag parameter with equal sign and without value); it is called
553 # this way because such message was sighted from a Pingtel phone
555 # compiles in tcp support
557 # disable the tcp Nagle algorithm (lower delay)
559 # compiles in tls support, requires -DUSE_TCP. Note: this is only
560 # generic support (parsing a.s.o.), it does not include the actual
561 # "tls engine". If you really want tls you need also either
562 # -DCORE_TLS and a tls/ subdir with the tls code or -DTLS_HOOKS and
563 # the tls module loaded.
565 # compiles tls in-core support. Requires -DUSE_TLS, conflicts
566 # -DTLS_HOOKS. Please use make CORE_TLS=1 instead (it will set all the
567 # needed defines automatically and extra libraries needed for linking).
569 # compile tls module support (support for having the "tls engine" in a
570 # module). Requires -DUSE_TLS, conflicts -DCORE_TLS.
571 # Please use make TLS_HOOKS=1 (or TLS_HOOKS=0 to for disabling) instead
572 # of setting -DTLS_HOOKS (it will set all the needed defines
575 # support for changing some of the resolver parameters present
576 # (_res structure in <resolv.h>)
578 # compiles in comp=[sergz|sigcomp] support (parsing uri & via,
579 # adding it to via, lumps a.s.o). WARNING: right now this option
580 # is useless since the compression code doesn't exist yet.
582 # compiles in checks and use for maddr parameter in uri.
583 # Required to support Windows Messenger 5.x over TCP connection
584 # which (mis)uses this parameter.
586 # use an internal dns cache instead of making dns requests each time
587 # -DUSE_DNS_CACHE_STATS
588 # turns on DNS cache measurements
590 # if the destination resolves to multiple ips, on send error fall back
592 # -DUSE_DST_BLACKLIST
593 # blacklist bad destination (timeout, failed to connect, error sending
595 # -DUSE_DST_BLACKLIST_STATS
596 # turns on blacklist bad destination measurements
598 # if enabled profiling will be enabled for child processes
599 # Don't forget to set PROFILE (see below)
601 # compiles in stun support
603 # turns off debugging messages in signal handlers (which might be
606 # turns on naptr support (but must be also enabled from the config)
607 # -DDNS_WATCHDOG_SUPPORT
608 # turns on DNS watchdog support which can be used to inform the
609 # core that the DNS servers are down. No DNS query is performed
610 # when the servers are unreachable, and even expired resource
611 # records are used from the cache. (requires external watchdog)
613 # adds support for Application Server interface
614 # Sometimes is needes correct non-quoted $OS. HACK: gcc translates known OS to number ('linux'), so there is added underscore
616 C_DEFS= $(extra_defs) \
617 -DNAME='"$(MAIN_NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
618 -DOS='$(OS)_' -DOS_QUOTED='"$(OS)"' -DCOMPILER='"$(CC_VER)"'\
619 -D__CPU_$(ARCH) -D__OS_$(OS) \
620 -DSER_VER=$(SER_VER) \
621 -DCFG_DIR='"$(cfg_target)"'\
623 -DSHM_MEM -DSHM_MMAP \
632 -DUSE_DST_BLACKLIST \
634 #-DUSE_DNS_CACHE_STATS \
635 #-DUSE_DST_BLACKLIST_STATS \
636 #-DDNS_WATCHDOG_SUPPORT \
652 #PROFILE= -pg # set this if you want profiling
653 # you may also want to set -DPROFILING
655 # WARNING: do not add mode=debug or mode=release anymore in the Makefile,
656 # use make mode=debug all instead. Anyway no by default ser is compiled w/
657 # debugging symbols in all cases (-g). --andrei
660 C_DEFS+= -DDBG_QM_MALLOC
664 ifeq ($(CORE_TLS), 1)
665 C_DEFS+= -DUSE_TLS -DCORE_TLS
667 ifeq ($(TLS_HOOKS), 1)
668 C_DEFS+= -DUSE_TLS -DTLS_HOOKS
671 C_DEFS+= -DUSE_CORE_STATS -DSTATISTICS
674 C_DEFS+= -DMALLOC_STATS
686 C_DEFS+= -DEXTRA_DEBUG
689 # platform dependent settings
691 # find ld & as name (gnu or solaris)
692 ifeq ($(OS), solaris)
693 ifeq ($(CC_NAME), gcc)
694 LDGCC:=$(shell $(CC) -v 2>&1 | grep with-ld| \
695 sed -e 's/.*--with-ld=\([^ ][^ ]*\).*/\1/' )
696 ASGCC:=$(shell $(CC) -v 2>&1 | grep with-as| \
697 sed -e 's/.*--with-as=\([^ ][^ ]*\).*/\1/' )
698 LDPATH:=$(shell if [ -z "$(LDGCC)" ] ; then echo "ld" ;\
700 if $(LDGCC) -V 2>/dev/null 1>/dev/null; then \
705 ASPATH:=$(shell if [ -z "$(ASGCC)" ] ; then echo "as" ;\
707 if $(ASGCC) -V 2>/dev/null 1>/dev/null </dev/null; \
714 LDTYPE:=$(shell if $(LDPATH) -V 1>/dev/null 2>/dev/null; then \
715 if $(LDPATH) -V 2>&1|grep GNU >/dev/null; \
718 if $(LDPATH) -V 2>&1|grep Solaris >/dev/null;\
725 ASTYPE:=$(shell if $(ASPATH) -V 1>/dev/null 2>/dev/null </dev/null; \
727 if $(ASPATH) -V 2>&1 </dev/null | \
728 grep GNU >/dev/null; then echo gnu; \
730 if $(ASPATH) -V 2>&1 </dev/null | \
731 grep Sun >/dev/null; then echo solaris; \
737 #$(warning "using ld=$(LDPATH)/$(LDTYPE), as=$(ASPATH)/$(ASTYPE)")
742 # arch. specific definitions
747 ifeq ($(ARCH), x86_64)
751 ifeq ($(ARCH), sparc64)
752 ifeq ($(CC_NAME), gcc)
757 ifeq ($(ARCH), sparc)
763 C_DEFS+=-DNOSMP # very unlikely to have an smp arm
774 ifeq ($(ARCH), ppc64)
779 # mips1 arch. (e.g. R3000) - no hardware locking support
781 C_DEFS+=-DMIPS_HAS_LLSC # likely
782 C_DEFS+=-DNOSMP # very likely
785 ifeq ($(ARCH), mips2)
786 # mips2 arch and newer (mips3=R4000, mips4=R5000 a.s.o)
790 ifeq ($(ARCH), mips64)
791 # mips2 arch and newer (mips3=R4000, mips4=R5000 a.s.o)
795 ifeq ($(ARCH), alpha)
797 C_DEFS+=-DNOSMP # very likely
800 ifeq ($(use_fast_lock), yes)
801 C_DEFS+= -DFAST_LOCK -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024
802 found_lock_method=yes
809 ifeq ($(mode), release)
813 ifeq ($(CC_NAME), gcc)
814 C_DEFS+=-DCC_GCC_LIKE_ASM
816 CFLAGS=-g -O9 -funroll-loops -Wcast-align $(PROFILE)
818 ifeq ($(CC_SHORTVER), 4.2+)
820 CFLAGS+=-m32 -minline-all-stringops \
823 -fno-strict-overflow \
828 ifeq ($(CC_SHORTVER), 4.x)
830 CFLAGS+=-m32 -minline-all-stringops \
837 ifeq ($(CC_SHORTVER), 3.4)
839 CFLAGS+=-m32 -minline-all-stringops \
845 ifeq ($(CC_SHORTVER), 3.0)
847 CFLAGS+=-minline-all-stringops \
850 # -m32 supported since gcc 3.2
852 ifeq ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
853 $(warning Old gcc detected ($(CC_SHORTVER)), use gcc >= 3.1 \
860 $(warning You are using an old and unsupported gcc \
861 version ($(CC_SHORTVER)), compile at your own risk!)
863 endif # CC_SHORTVER, 2.9x
864 endif # CC_SHORTVER, 3.0
865 endif # CC_SHORTVER, 3.4
866 endif # CC_SHORTVER, 4.x
867 endif # CC_SHORTVER, 4.2+
870 ifeq ($(CC_NAME), icc)
871 C_DEFS+=-DCC_GCC_LIKE_ASM
872 CFLAGS=-g -O3 -ipo -ipo_obj -unroll $(PROFILE) \
873 -tpp6 -xK #-openmp #optimize for PIII
874 # -prefetch doesn't seem to work
875 #( ty to inline acroos files, unroll loops,prefetch,
876 # optimize for PIII, use PIII instructions & vect.,
880 $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
886 ifeq ($(ARCH), x86_64)
888 ifeq ($(CC_NAME), gcc)
889 C_DEFS+=-DCC_GCC_LIKE_ASM
891 CFLAGS=-g -O9 -funroll-loops -Wcast-align $(PROFILE)
893 ifeq ($(CC_SHORTVER), 4.2+)
895 CFLAGS+=-m64 -minline-all-stringops \
898 -fno-strict-overflow \
903 ifeq ($(CC_SHORTVER), 4.x)
905 CFLAGS+=-m64 -minline-all-stringops \
912 ifeq ($(CC_SHORTVER), 3.4)
914 CFLAGS+=-m64 -minline-all-stringops \
919 ifeq ($(CC_SHORTVER), 3.0)
921 CFLAGS+=-minline-all-stringops \
923 #-mcpu=$(CPU) \ # not working on all x86_64 gccs
925 #-m64 on x86_64/x86 works starting with gcc 3.2
927 ifeq ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
928 $(warning Old gcc detected ($(CC_SHORTVER)), use gcc >= 3.1 \
935 $(warning You are using an old and unsupported gcc \
936 version ($(CC_SHORTVER)), compile at your own risk!)
938 endif # CC_SHORTVER, 2.9x
939 endif # CC_SHORTVER, 3.0
940 endif # CC_SHORTVER, 3.4
941 endif # CC_SHORTVER, 4.x
942 endif # CC_SHORTVER, 4.2+
945 ifeq ($(CC_NAME), icc)
946 C_DEFS+=-DCC_GCC_LIKE_ASM
947 CFLAGS=-g -O3 -ipo -ipo_obj -unroll $(PROFILE) \
948 -tpp6 -xK #-openmp #optimize for PIII
949 # -prefetch doesn't seem to work
950 #( ty to inline acroos files, unroll loops,prefetch,
951 # optimize for PIII, use PIII instructions & vect.,
955 $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
961 ifeq ($(ARCH), sparc64)
963 ifeq ($(CC_NAME), gcc)
964 C_DEFS+=-DCC_GCC_LIKE_ASM -DSPARC64_MODE
966 CFLAGS=-g -O9 -funroll-loops $(PROFILE) \
968 #-Wmissing-prototypes
970 ifeq ($(CC_SHORTVER), 4.2+)
973 CFLAGS+=-m64 -mcpu=ultrasparc \
975 -fno-strict-overflow \
977 # use -m64 to force 64 bit (but add it also to LDFLAGS and
978 # don't forget to define SPARC64_MODE)
979 # -m32 for 32 bit (default on solaris),
980 # nothing for arch. default
984 ifeq ($(CC_SHORTVER), 4.x)
987 CFLAGS+=-m64 -mcpu=ultrasparc \
993 ifeq ($(CC_SHORTVER), 3.4)
996 CFLAGS+=-m64 -mcpu=ultrasparc -mtune=$(CPU)
1000 ifeq ($(CC_SHORTVER), 3.0)
1003 CFLAGS+=-m64 -mcpu=ultrasparc -mtune=$(CPU) \
1004 # -mcpu=v9 or ultrasparc? # -mtune implied by -mcpu
1005 #-mno-epilogue #try to inline function exit code
1006 #-mflat # omit save/restore
1007 #-,faster-structs #faster non Sparc ABI structure copy ops
1009 else # CC_SHORTVER, 3.0
1010 ifeq ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1011 $(warning Old gcc detected ($(CC_SHORTVER)), use gcc >= 3.1 \
1013 ifneq ($(OS), netbsd)
1014 # on netbsd/sparc64, gcc 2.95.3 does not compile
1017 # -m64/-m32 on sparc works starting with gcc 3.0
1019 ifeq ($(ASTYPE), solaris)
1020 CFLAGS+= -Wa,-xarch=v8plus
1022 else #CC_SHORTVER, 2.9x
1024 $(warning You are using an old and unsupported gcc \
1025 version ($(CC_SHORTVER)), compile at your own risk!)
1028 ifeq ($(ASTYPE), solaris)
1029 CFLAGS+= -Wa,-xarch=v8plus
1032 endif #CC_SHORTVER, 2.9x
1033 endif #CC_SHORTVER, 3.0
1034 endif #CC_SHORTVER, 3.4
1035 endif #CC_SHORTVER, 4.x
1036 endif #CC_SHORTVER, 4.2+
1039 ifeq ($(CC_NAME), suncc)
1040 C_DEFS+=-DSPARC64_MODE
1041 CFLAGS+= -m64 -g -xO5 -fast -native -xarch=v9 -xCC \
1043 # -Dinline="" # add this if cc < 5.3 (define inline as null)
1046 $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1047 endif #CC_NAME, suncc
1049 endif #ARCH, sparc64
1052 ifeq ($(ARCH), sparc)
1054 ifeq ($(CC_NAME), gcc)
1055 C_DEFS+=-DCC_GCC_LIKE_ASM
1057 CFLAGS=-g -O9 -funroll-loops $(PROFILE) \
1059 #-Wmissing-prototypes
1061 ifeq ($(CC_SHORTVER), 4.2+)
1064 CFLAGS+= -mtune=$(CPU) \
1065 -fno-strict-overflow \
1069 ifeq ($(CC_SHORTVER), 4.x)
1072 CFLAGS+= -mtune=$(CPU) \
1076 ifeq ($(CC_SHORTVER), 3.4)
1079 CFLAGS+= -mtune=$(CPU)
1082 ifeq ($(CC_SHORTVER), 3.0)
1085 CFLAGS+= -mtune=$(CPU) \
1086 #-mno-epilogue #try to inline function exit code
1087 #-mflat # omit save/restore
1088 #-,faster-structs #faster non Sparc ABI structure copy ops
1089 else # CC_SHORTVER, 3.0
1090 ifeq ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1091 $(warning Old gcc detected ($(CC_SHORTVER)), use gcc >= 3.1 \
1093 else #CC_SHORTVER, 2.9x
1095 $(warning You are using an old and unsupported gcc \
1096 version ($(CC_SHORTVER)), compile at your own risk!)
1098 endif #CC_SHORTVER, 2.9x
1099 endif #CC_SHORTVER, 3.0
1100 endif #CC_SHORTVER, 3.4
1101 endif #CC_SHORTVER, 4.x
1102 endif #CC_SHORTVER, 4.2+
1105 ifeq ($(CC_NAME), suncc)
1106 CFLAGS+= -g -xO5 -fast -native -xCC \
1108 # -Dinline="" # add this if cc < 5.3 (define inline as null)
1111 $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1112 endif #CC_NAME, suncc
1119 ifeq ($(CC_NAME), gcc)
1120 C_DEFS+=-DCC_GCC_LIKE_ASM
1122 CFLAGS=-O9 -funroll-loops -fsigned-char $(PROFILE)
1124 ifeq ($(CC_SHORTVER), 4.2+)
1125 CFLAGS+= -ftree-vectorize -fno-strict-overflow
1126 # not supported on arm: -minline-all-stringops
1129 ifeq ($(CC_SHORTVER), 4.x)
1130 CFLAGS+= -ftree-vectorize
1131 # not supported on arm: -minline-all-stringops
1134 ifeq ($(CC_SHORTVER), 3.4)
1138 ifeq ($(CC_SHORTVER), 3.0)
1142 ifeq ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1143 $(warning Old gcc detected ($(CC_SHORTVER)), use gcc 3.0.x \
1149 $(warning You are using an old and unsupported gcc \
1150 version ($(CC_SHORTVER)), compile at your own risk!)
1152 endif # CC_SHORTVER, 2.9x
1153 endif # CC_SHORTVER, 3.0
1154 endif # CC_SHORTVER, 3.4
1155 endif # CC_SHORTVER, 4.x
1156 endif # CC_SHORTVER, 4.2+
1160 $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1165 ifeq ($(ARCH), arm6)
1167 ifeq ($(CC_NAME), gcc)
1168 C_DEFS+=-DCC_GCC_LIKE_ASM
1170 CFLAGS=-march=armv6 -O9 -funroll-loops -fsigned-char \
1173 ifeq ($(CC_SHORTVER), 4.2+)
1174 CFLAGS+= -ftree-vectorize -fno-strict-overflow
1177 ifeq ($(CC_SHORTVER), 4.x)
1178 CFLAGS+= -ftree-vectorize
1181 ifeq ($(CC_SHORTVER), 3.4)
1185 ifeq ($(CC_SHORTVER), 3.0)
1189 ifeq ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1190 $(warning Old gcc detected ($(CC_SHORTVER)), use gcc 3.0.x \
1196 $(warning You are using an old and unsupported gcc \
1197 version ($(CC_SHORTVER)), compile at your own risk!)
1199 endif # CC_SHORTVER, 2.9x
1200 endif # CC_SHORTVER, 3.0
1201 endif # CC_SHORTVER, 3.4
1202 endif # CC_SHORTVER, 4.x
1203 endif # CC_SHORTVER, 4.2+
1207 $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1212 ifeq ($(ARCH), mips)
1214 ifeq ($(CC_NAME), gcc)
1215 C_DEFS+=-DCC_GCC_LIKE_ASM
1217 CFLAGS=-O9 -funroll-loops $(PROFILE)
1219 ifeq ($(CC_SHORTVER), 4.2+)
1220 CFLAGS+=-march=r3000 -minline-all-stringops \
1221 -ftree-vectorize -fno-strict-overflow
1224 ifeq ($(CC_SHORTVER), 4.x)
1225 CFLAGS+=-march=r3000 -minline-all-stringops \
1229 ifeq ($(CC_SHORTVER), 3.4)
1230 CFLAGS+= -march=r3000
1233 ifeq ($(CC_SHORTVER), 3.0)
1234 CFLAGS+= -march=r3000
1236 ifeq ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1237 $(warning Old gcc detected ($(CC_SHORTVER)), use gcc 3.0.x \
1240 CFLAGS+=-march=r3000
1243 $(warning You are using an old and unsupported gcc \
1244 version ($(CC_SHORTVER)), compile at your own risk!)
1246 endif # CC_SHORTVER, 2.9x
1247 endif # CC_SHORTVER, 3.0
1248 endif # CC_SHORTVER, 3.4
1249 endif # CC_SHORTVER, 4.x
1250 endif # CC_SHORTVER, 4.2+
1254 $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1258 #if >=mips2 (R4000, R5000, R6000 ....)
1259 ifeq ($(ARCH), mips2)
1261 ifeq ($(CC_NAME), gcc)
1262 C_DEFS+=-DCC_GCC_LIKE_ASM
1264 CFLAGS= -mips2 -O9 -funroll-loops $(PROFILE)
1266 ifeq ($(CC_SHORTVER), 4.2+)
1267 CFLAGS+=-minline-all-stringops -ftree-vectorize \
1268 -fno-strict-overflow
1271 ifeq ($(CC_SHORTVER), 4.x)
1272 CFLAGS+=-minline-all-stringops -ftree-vectorize
1275 ifeq ($(CC_SHORTVER), 3.4)
1279 ifeq ($(CC_SHORTVER), 3.0)
1282 ifeq ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1283 $(warning Old gcc detected ($(CC_SHORTVER)), use gcc 3.0.x \
1288 $(warning You are using an old and unsupported gcc \
1289 version ($(CC_SHORTVER)), compile at your own risk!)
1291 endif # CC_SHORTVER, 2.9x
1292 endif # CC_SHORTVER, 3.0
1293 endif # CC_SHORTVER, 3.4
1294 endif # CC_SHORTVER, 4.x
1295 endif # CC_SHORTVER, 4.2+
1299 $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1304 ifeq ($(ARCH), mips64)
1306 ifeq ($(CC_NAME), gcc)
1307 C_DEFS+=-DCC_GCC_LIKE_ASM
1309 CFLAGS= -mips64 -O9 -funroll-loops $(PROFILE)
1311 ifeq ($(CC_SHORTVER), 4.2+)
1312 CFLAGS+=-minline-all-stringops -ftree-vectorize \
1313 -fno-strict-overflow
1316 ifeq ($(CC_SHORTVER), 4.x)
1317 CFLAGS+=-minline-all-stringops -ftree-vectorize
1320 ifeq ($(CC_SHORTVER), 3.4)
1324 ifeq ($(CC_SHORTVER), 3.0)
1327 ifeq ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1328 $(warning Old gcc detected ($(CC_SHORTVER)), use gcc 3.0.x \
1333 $(warning You are using an old and unsupported gcc \
1334 version ($(CC_SHORTVER)), compile at your own risk!)
1336 endif # CC_SHORTVER, 2.9x
1337 endif # CC_SHORTVER, 3.0
1338 endif # CC_SHORTVER, 3.4
1339 endif # CC_SHORTVER, 4.x
1340 endif # CC_SHORTVER, 4.2+
1344 $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1349 ifeq ($(ARCH), alpha)
1351 ifeq ($(CC_NAME), gcc)
1352 C_DEFS+=-DCC_GCC_LIKE_ASM
1354 CFLAGS= -O9 -funroll-loops $(PROFILE)
1356 ifeq ($(CC_SHORTVER), 4.2+)
1357 CFLAGS+= -fno-strict-overflow
1358 # not supported: -minline-all-stringops
1361 ifeq ($(CC_SHORTVER), 4.x)
1363 # not supported: -minline-all-stringops
1366 ifeq ($(CC_SHORTVER), 3.4)
1370 ifeq ($(CC_SHORTVER), 3.0)
1373 ifeq ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1374 $(warning Old gcc detected ($(CC_SHORTVER)), use gcc 3.0.x \
1379 $(warning You are using an old and unsupported gcc \
1380 version ($(CC_SHORTVER)), compile at your own risk!)
1382 endif # CC_SHORTVER, 2.9x
1383 endif # CC_SHORTVER, 3.0
1384 endif # CC_SHORTVER, 3.4
1385 endif # CC_SHORTVER, 4.x
1386 endif # CC_SHORTVER, 4.2+
1390 $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1397 ifeq ($(CC_NAME), gcc)
1398 C_DEFS+=-DCC_GCC_LIKE_ASM
1400 CFLAGS= -O9 -funroll-loops -fsigned-char $(PROFILE)
1402 ifeq ($(CC_SHORTVER), 4.2+)
1404 CFLAGS+=-ftree-vectorize \
1405 -fno-strict-overflow \
1406 -mtune=$(CPU) -maltivec
1409 ifeq ($(CC_SHORTVER), 4.x)
1411 CFLAGS+=-ftree-vectorize \
1412 -mtune=$(CPU) -maltivec
1415 ifeq ($(CC_SHORTVER), 3.4)
1419 ifeq ($(CC_SHORTVER), 3.0)
1422 ifeq ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1423 $(warning Old gcc detected ($(CC_SHORTVER)), use gcc 3.0.x \
1428 $(warning You are using an old and unsupported gcc \
1429 version ($(CC_SHORTVER)), compile at your own risk!)
1431 endif # CC_SHORTVER, 2.9x
1432 endif # CC_SHORTVER, 3.0
1433 endif # CC_SHORTVER, 3.4
1434 endif # CC_SHORTVER, 4.x
1435 endif # CC_SHORTVER, 4.2+
1439 $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1444 ifeq ($(ARCH), ppc64)
1446 ifeq ($(CC_NAME), gcc)
1447 C_DEFS+=-DCC_GCC_LIKE_ASM
1449 CFLAGS= -O9 -funroll-loops -fsigned-char $(PROFILE)
1451 ifeq ($(CC_SHORTVER), 4.2+)
1453 CFLAGS+=-ftree-vectorize \
1454 -fno-strict-overflow \
1455 -mtune=$(CPU) -maltivec
1458 ifeq ($(CC_SHORTVER), 4.x)
1460 CFLAGS+=-ftree-vectorize \
1461 -mtune=$(CPU) -maltivec
1464 ifeq ($(CC_SHORTVER), 3.4)
1468 ifeq ($(CC_SHORTVER), 3.0)
1471 ifeq ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1472 $(warning Old gcc detected ($(CC_SHORTVER)), use gcc 3.0.x \
1477 $(warning You are using an old and unsupported gcc \
1478 version ($(CC_SHORTVER)), compile at your own risk!)
1480 endif # CC_SHORTVER, 2.9x
1481 endif # CC_SHORTVER, 3.0
1482 endif # CC_SHORTVER, 3.4
1483 endif # CC_SHORTVER, 4.x
1484 endif # CC_SHORTVER, 4.2+
1488 $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1492 CFLAGS+= $(CC_EXTRA_OPTS)
1496 ifeq ($(CC_NAME), gcc)
1497 ifeq ($(LDTYPE), solaris)
1499 LDFLAGS+=-O2 $(PROFILE)
1500 MOD_LDFLAGS:=-G $(LDFLAGS)
1501 LIB_LDFLAGS:=-G $(LDFLAGS)
1505 #gcc and maybe others, => gnu ld
1506 LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE)
1507 MOD_LDFLAGS:=-shared $(LDFLAGS)
1508 LIB_LDFLAGS:=-shared $(LDFLAGS)
1509 LIB_SONAME=-Wl,-soname,
1510 LD_RPATH=-Wl,-rpath,
1513 ifeq ($(CC_NAME), icc)
1514 #gcc and maybe others
1515 LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE)
1516 MOD_LDFLAGS:=-shared $(LDFLAGS)
1517 LIB_LDFLAGS:=-shared $(LDFLAGS)
1518 LIB_SONAME=-Wl,-soname,
1519 LD_RPATH=-Wl,-rpath,
1521 ifeq ($(CC_NAME), suncc)
1523 LDFLAGS+=-xO5 $(PROFILE)
1524 MOD_LDFLAGS:=-G $(LDFLAGS)
1525 LIB_LDFLAGS:=-G $(LDFLAGS)
1529 # we need -fPIC -DPIC only for shared objects, we don't need them for
1530 # the executable file, because it's always loaded at a fixed address
1533 ifeq ($(CC_NAME), gcc)
1534 CFLAGS=-g -Wcast-align $(PROFILE)
1535 C_DEFS+=-DCC_GCC_LIKE_ASM
1536 ifeq ($(ARCH), sparc64)
1537 C_DEFS+=SPARC64_MODE
1538 CFLAGS+= -mcpu=ultrasparc -m64
1541 ifeq ($(LDTYPE), solaris)
1543 LDFLAGS+=-g $(PROFILE)
1544 MOD_LDFLAGS:=-G $(LDFLAGS)
1545 LIB_LDFLAGS:=-G $(LDFLAGS)
1549 #gnu or other ld type
1550 LDFLAGS+=-g -Wl,-E $(PROFILE)
1551 MOD_LDFLAGS:=-shared $(LDFLAGS)
1552 LIB_LDFLAGS:=-shared $(LDFLAGS)
1553 LIB_SONAME=-Wl,-soname,
1554 LD_RPATH=-Wl,-rpath,
1557 ifeq ($(CC_NAME), icc)
1558 C_DEFS+=-DCC_GCC_LIKE_ASM
1559 CFLAGS=-g $(PROFILE)
1560 LDFLAGS+=-g -Wl,-E $(PROFILE)
1561 MOD_LDFLAGS:=-shared $(LDFLAGS)
1562 LIB_LDFLAGS:=-shared $(LDFLAGS)
1563 LIB_SONAME=-Wl,-soname,
1564 LD_RPATH=-Wl,-rpath,
1566 ifeq ($(CC_NAME), suncc)
1567 CFLAGS= -g $(PROFILE)
1568 LDFLAGS+=-g $(PROFILE)
1569 MOD_LDFLAGS:=-G $(LDFLAGS)
1570 LIB_LDFLAGS:=-G $(LDFLAGS)
1578 # set pedantic compiler options
1579 ifeq ($(CC_NAME), gcc)
1582 ifeq ($(CC_NAME), icc)
1585 ifeq ($(CC_NAME), suncc)
1586 # FIXME: is the default (-Xa ?) enough?
1587 endif # CC_NAME=suncc
1591 #CFLAGS used for compiling the modules, libraries and utils
1592 ifeq ($(CC_NAME), gcc)
1593 MOD_CFLAGS=-fPIC -DPIC $(CFLAGS)
1594 LIB_CFLAGS=-fPIC -DPIC $(CFLAGS)
1596 ifeq ($(CC_NAME), icc)
1597 MOD_CFLAGS=-Kpic $(CFLAGS)
1598 LIB_CFLAGS=-Kpic $(CFLAGS)
1600 ifeq ($(CC_NAME), suncc)
1601 # FIMXE: use -KPIC instead -xcode ?
1602 MOD_CFLAGS=-xcode=pic32 $(CFLAGS)
1603 LIB_CFLAGS=-xcode=pic32 $(CFLAGS)
1605 UTILS_CFLAGS=$(CFLAGS)
1606 # LDFLAGS uses for compiling the utils
1607 UTILS_LDFLAGS=$(LDFLAGS)
1615 YACC_FLAGS=-d -b cfg
1616 # on solaris add -lxnet (e.g. LIBS= -lxnet)
1624 # by default use futexes if available
1626 C_DEFS+=-DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
1627 -DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H \
1628 -DHAVE_TIMEGM -DHAVE_SCHED_SETSCHEDULER
1629 ifneq ($(found_lock_method), yes)
1630 #C_DEFS+= -DUSE_POSIX_SEM
1631 C_DEFS+=-DUSE_PTHREAD_MUTEX
1633 #C_DEFS+= -DUSE_SYSV_SEM # try posix sems
1634 found_lock_method=yes
1636 ifneq (,$(findstring -DUSE_POSIX_SEM, $(C_DEFS)))
1639 ifneq (,$(findstring -DUSE_PTHREAD_MUTEX, $(C_DEFS)))
1643 # check for >= 2.5.44
1644 ifeq ($(shell [ $(OSREL_N) -ge 2005044 ] && echo has_epoll), has_epoll)
1646 C_DEFS+=-DHAVE_EPOLL
1647 # linux + gcc >= 3.0 + -malign-double + epoll => problems
1648 CFLAGS_RM+=-malign-double
1649 #CFLAGS:=$(filter-out -malign-double, $(CFLAGS))
1652 # check for >= 2.2.0
1653 ifeq ($(shell [ $(OSREL_N) -ge 2002000 ] && echo has_sigio), has_sigio)
1655 C_DEFS+=-DHAVE_SIGIO_RT -DSIGINFO64_WORKARROUND
1658 # check for >= 2.5.70
1659 ifeq ($(shell [ $(OSREL_N) -ge 2005070 ] && echo has_futex), has_futex)
1660 ifeq ($(use_futex), yes)
1664 ifeq ($(NO_SELECT),)
1665 C_DEFS+=-DHAVE_SELECT
1669 # test to see if the devfiles and lib are installed
1670 sctp_dev_locations := /usr/include/netinet/sctp.h \
1671 $(LOCALBASE)/include/netinet/sctp.h
1672 sctp_lib_locations := /usr/lib/libsctp.so \
1673 $(LOCALBASE)/usr/local/lib/libsctp.so
1674 sctp_dev_path := $(wildcard $(sctp_dev_locations))
1675 sctp_lib_path := $(wildcard $(sctp_lib_locations))
1676 ifeq ($(sctp_dev_path),)
1677 $(info "sctp development files not installed -- sctp disabled")
1680 ifeq ($(sctp_lib_path),)
1681 $(info "sctp libraries not installed -- sctp disabled")
1693 ifeq ($(OS), solaris)
1694 C_DEFS+= -DHAVE_GETIPNODEBYNAME -DHAVE_SYS_SOCKIO_H -DHAVE_SCHED_YIELD \
1695 -DHAVE_ALLOCA_H -DUSE_SIGACTION
1696 ifneq ($(found_lock_method), yes)
1697 C_DEFS+= -DUSE_PTHREAD_MUTEX # try pthread sems
1698 found_lock_method=yes
1700 # check for ver >= 5.7
1701 ifeq ($(shell [ $(OSREL_N) -gt 5007 ] && echo has_devpoll), has_devpoll)
1702 ifeq ($(NO_DEVPOLL),)
1703 C_DEFS+=-DHAVE_DEVPOLL
1706 ifeq ($(NO_SELECT),)
1707 C_DEFS+=-DHAVE_SELECT
1710 filio_h_locations= /usr/include/sys/filio.h \
1711 $(LOCALBASE)/include/sys/filio.h
1712 has_filio_h=$(shell for r in $(filio_h_locations); do \
1713 if [ -r "$$r" ] ; then echo yes; exit; fi \
1716 ifeq ($(has_filio_h), yes)
1717 C_DEFS+=-DHAVE_FILIO_H
1719 ifeq ($(mode), release)
1720 #use these only if you're using gcc with Solaris ld
1721 #LDFLAGS=-O2 $(PROFILE)
1724 #LDFLAGS=-g $(PROFILE)
1729 ifeq ($(CC_NAME), suncc)
1730 LIBS= -lfast -ldl -lresolv
1732 OLD_SOLARIS= $(shell echo "$(OSREL)" | \
1733 sed -e 's/^5\.[0-6][^0-9]*$$/yes/' )
1734 LIBS+= -L$(LOCALBASE)/lib -lxnet -lnsl
1735 ifeq ($(OLD_SOLARIS), yes)
1740 # -lrt needed for sched_yield
1743 ifeq ($(OS), freebsd)
1744 C_DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
1745 -DHAVE_SCHED_YIELD -DHAVE_MSGHDR_MSG_CONTROL \
1746 -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
1747 -DHAVE_NETINET_IN_SYSTM
1748 ifneq ($(found_lock_method), yes)
1749 C_DEFS+= -DUSE_PTHREAD_MUTEX # try pthread sems
1750 found_lock_method=yes
1751 LIBS+= -pthread #dlopen is in libc
1753 LIBS= #dlopen is in libc
1755 # check for ver >= 4.1
1756 ifeq ($(shell [ $(OSREL_N) -gt 4001 ] && echo has_kqueue), has_kqueue)
1757 ifeq ($(NO_KQUEUE),)
1758 C_DEFS+=-DHAVE_KQUEUE
1761 ifeq ($(NO_SELECT),)
1762 C_DEFS+=-DHAVE_SELECT
1767 # test to see if the devfiles and lib are installed
1768 sctp_dev_locations := /usr/include/netinet/sctp.h \
1769 $(LOCALBASE)/include/netinet/sctp.h
1770 sctp_dev_path := $(wildcard $(sctp_dev_locations))
1771 ifeq ($(sctp_dev_path),)
1772 $(info "sctp development files not installed -- sctp disabled")
1775 ifeq ($(shell [ $(OSREL_N) -lt 7000 ] && echo sctp), sctp)
1776 $(info "old freebsd version (>= 7.0 needed) -- sctp disabled")
1782 LIBS+= # no extra libs needed on freebsd
1787 ifeq ($(OS), openbsd)
1788 C_DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 \
1789 -DHAVE_UNION_SEMUN -DHAVE_MSGHDR_MSG_CONTROL \
1790 -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
1791 -DHAVE_NETINET_IN_SYSTM -DUSE_SIGWAIT
1792 ifneq ($(found_lock_method), yes)
1793 C_DEFS+= -DUSE_PTHREAD_MUTEX # try pthread sems
1794 found_lock_method=yes
1796 # check for ver >=2 9
1797 ifeq ($(shell [ $(OSREL_N) -ge 2009 ] && echo has_kqueue), has_kqueue)
1798 ifeq ($(NO_KQUEUE),)
1799 C_DEFS+=-DHAVE_KQUEUE
1802 ifeq ($(NO_SELECT),)
1803 C_DEFS+=-DHAVE_SELECT
1805 # (symbols on openbsd are prefixed by "_")
1807 # no sched_yield on openbsd unless linking with c_r (not recommended)
1808 # unfortunately pthread is needed for sigwait
1810 OPENBSD_IS_AOUT:= $(shell echo "$(OSREL)" | \
1811 sed -e 's/^3\.[0-3][^0-9]*$$/yes/' |sed -e 's/^[0-2]\..*/yes/')
1812 # exception: on sparc openbsd 3.2 is elf and not aout
1813 ifeq ($(OSREL), 3.2)
1814 ifeq ($(ARCH), sparc)
1817 ifeq ($(ARCH), sparc64)
1822 ifeq ($(OPENBSD_IS_AOUT), yes)
1823 C_DEFS+=-DDLSYM_PREFIX='"_"'
1824 LDFLAGS= # openbsd ld doesn't like -O2 or -E
1828 ifeq ($(OS), netbsd)
1829 C_DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 \
1830 -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM
1831 ifneq ($(found_lock_method), yes)
1832 C_DEFS+= -DUSE_SYSV_SEM # try pthread sems
1833 found_lock_method=yes
1835 # check for ver >= 2.0.0
1836 ifeq ($(shell [ $(OSREL_N) -ge 2000000 ] && echo has_kqueue), has_kqueue)
1837 ifeq ($(NO_KQUEUE),)
1838 C_DEFS+=-DHAVE_KQUEUE
1839 # netbsd + kqueue and -malign-double don't work
1840 CFLAGS_RM+=-malign-double
1841 #CFLAGS:=$(filter-out -malign-double, $(CFLAGS))
1844 ifeq ($(NO_SELECT),)
1845 C_DEFS+=-DHAVE_SELECT
1851 # OS X support, same as freebsd
1852 ifeq ($(OS), darwin)
1853 C_DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
1854 -DHAVE_SCHED_YIELD -DHAVE_MSGHDR_MSG_CONTROL \
1856 -DNDEBUG -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
1858 # -DNDEBUG used to turn off assert (assert wants to call
1859 # eprintf which doesn't seem to be defined in any shared lib
1860 ifneq ($(found_lock_method), yes)
1861 C_DEFS+= -DUSE_PTHREAD_MUTEX # try pthread sems
1862 found_lock_method=yes
1863 C_DEFS+= -DUSE_SYSV_SEM # try sys v sems (pthread don't work for
1864 # processes and unnamed posix sems are not
1867 LIBS= -lresolv #dlopen is in libc
1868 ifeq ($(NO_KQUEUE),)
1869 C_DEFS+=-DHAVE_KQUEUE
1871 ifeq ($(NO_SELECT),)
1872 C_DEFS+=-DHAVE_SELECT
1874 LDFLAGS= # darwin doesn't like -O2 or -E
1875 # the modules uses symbols from ser => either
1876 # -flat_namespace -undefined_suppress or -bundle_loader ../../$(MAIN_NAME)
1877 MOD_LDFLAGS:= -bundle -flat_namespace -undefined suppress
1878 # for libs using symbols from ser (e.g srdb2, kcore a.s.o) we
1879 # need -flat_namespace -undefined suppress
1880 LIB_LDFLAGS:= -dynamiclib -flat_namespace -undefined suppress
1882 # on darwin soname should include the full path
1883 # (it kind of combines rpath & soname)
1885 # no equiv. for rpath on darwin
1890 ifneq (,$(findstring cygwin, $(OS)))
1891 # cygwin doesn't support IPV6 and doesn't support fd passing so no TCP
1892 #C_DEFS:=$(filter-out -DUSE_IPV6 -DUSE_TCP, $(C_DEFS))
1893 DEFS_RM+=-DUSE_IPV6 -DUSE_TCP
1894 C_DEFS+=-DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
1895 -DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H \
1896 -DHAVE_TIMEGM -DHAVE_SCHED_SETSCHEDULER
1897 ifneq ($(found_lock_method), yes)
1898 C_DEFS+= -DUSE_POSIX_SEM
1899 #C_DEFS+= -DUSE_SYSV_SEM # try posix sems
1900 # PTHREAD_MUTEX do not work for processes (try test/pthread_test.c)
1902 found_lock_method=yes
1904 ifneq (,$(findstring -DUSE_POSIX_SEM, $(C_DEFS)))
1907 ifneq (,$(findstring -DUSE_PTHREAD_MUTEX, $(C_DEFS)))
1908 $(error PTHREAD_MUTEX do not work for processes on Windows/CYGWIN)
1911 # check for >= 2.5.70
1912 ifeq ($(NO_SELECT),)
1913 C_DEFS+=-DHAVE_SELECT
1917 #add libssl if needed
1918 ifeq ($(CORE_TLS), 1)
1919 C_INCLUDES+= -I$(LOCALBASE)/ssl/include
1920 LIBS+= -L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib -lssl -lcrypto \
1922 # NOTE: depending on the way in which libssl was compiled you might
1923 # have to add -lz -lkrb5 (zlib and kerberos5).
1924 # E.g.: make CORE_TLS=1 EXTRA_TLS_LIBS="-lz -lkrb5"
1928 C_INCLUDES+= -I$(LOCALBASE)/ssl/include
1929 LIBS+= -L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib -lcrypto
1932 ifneq ($(found_lock_method), yes)
1933 $(warning No locking method found so far, trying SYS V sems)
1934 C_DEFS+= -DUSE_SYSV_SEM # try sys v sems
1935 found_lock_method=yes
1939 endif # ifeq (,$(main_makefile))
1940 endif # ifeq ($(makefile_defs), 1)
1942 # if incomplete or missing config.mak, or already exported vars, don't
1943 # try to export/re-export
1944 ifeq ($(makefile_defs),1)
1945 ifneq ($(exported_vars),1)
1948 override exported_vars:=1
1949 export exported_vars
1951 # variable changeable only at configure time (once saved in config.mak they
1952 # cannot be overwritten from environment or command line, unless make cfg
1954 saved_fixed_vars:= MAIN_NAME CFG_NAME SCR_NAME FLAVOUR INSTALL_FLAVOUR \
1955 SRC_NAME RELEASE OS ARCH \
1956 C_DEFS DEFS_RM PROFILE CC LD MKDEP MKTAGS LDFLAGS C_INCLUDES \
1958 MOD_LDFLAGS LIB_LDFLAGS UTILS_LDFLAGS LIB_SONAME LD_RPATH \
1959 LIB_SUFFIX LIB_PREFIX \
1961 LEX YACC YACC_FLAGS \
1964 INSTALL INSTALL_CFG INSTALL_BIN INSTALL_MODULES INSTALL_DOC \
1965 INSTALL_MAN INSTALL_LIB INSTALL_TOUCH INSTALL_SHARE \
1968 # variable changeable at compile time
1969 # extra: prefix DESTDIR BASEDIR basedirt
1971 CC_EXTRA_OPTS CPU CFLAGS_RM CFLAGS MOD_CFLAGS LIB_CFLAGS UTILS_CFLAGS \
1972 BASEDIR basedir DESTDIR \
1974 cfg_prefix cfg_dir bin_prefix bin_dir modules_prefix modules_dir \
1975 doc_prefix doc_dir man_prefix man_dir ut_prefix ut_dir \
1976 share_prefix share_dir lib_prefix lib_dir data_prefix data_dir \
1977 cfg_target lib_target data_target
1980 #export relevant variables to the sub-makes
1981 export $(saved_fixed_vars)
1982 export $(saved_chg_vars)
1985 endif # ifneq ($(exported_vars),1)
1986 endif # ifeq ($(makefile_defs),1)