Makefile.defs
e0a6ffa6
 # $Id$
247c2b65
 #
 # makefile defs (CC, LD,a.s.o)
 #
5b9b8d2e
 # Environment variables:
 #   PREFIX, LOCALBASE, BASEDIR
1f2c924e
 #   INSTALL, TAR , CC, LEX, YACC,
fc50bc47
 #   CPU, CC_EXTRA_OPTS,
 #   exclude_modules, skip_modules, include_modules
3dae72a3
 #   extra_defs
6419a43f
 #
a2786e3e
 # History:
 # --------
 #              created by andrei
28b28d2c
 #  2003-02-24  added LOCALBASE, fixed doc_dir for freebsd - patch provided
b33736bc
 #               by Maxim Sobolev <sobomax@FreeBSD.org>
5df85411
 #  2003-02-25  added -DDISABLE_NAGLE (andrei)
a6c0b4ba
 #  2003-03-02  added -DDIGEST_DOMAIN (janakj)
6419a43f
 #  2003-03-10  added -xcode=pic32 for module compilation w/ sun cc
1f2c924e
 #               (too many symbols for pic13)  (andrei)
 #  2003-04-16  added CC_EXTRA_OPTS, s/march/mcpu, added CPU (cpu to optimize 
5df85411
 #               for, used only with gcc-3.x) (andrei)
4ce32edc
 #  2003-05-23  check if this makefile was already included (andrei)
 #              removed -DDIGEST_DOMAIN (andrei)
3dae72a3
 #  2003-05-30  added extra_defs (andrei)
176e7a13
 #  2003-06-06  moved compiler detection before DEFS (andrei)
74250efc
 #  2003-06-10  removed -m32 for gcc 3.x/sparc64  -- it will use 
 #              arch. default: -m32 on solaris, -m64 on *bsd (andrei)
4e018310
 #  2003-09-25  added -pthread into LIBS when compiling on FreeBSD/alpha
 #              and other FreeBSD arches for which no fast locking assembly
 #              code exists (sobomax)
06aaa54f
 #  2003-11-08  mips1 support introduced (andrei)
cf98659b
 #  2003-11-24  openbsd 3.4 (elf) fixes (andrei)
194b6a35
 #  2004-07-27  darwin (mac os x) port  (andrei)
5ffcc5d0
 #  2004-09-12  mips2 & cobalt support introduced (andrei)
4d080f49
 #  2004-09-28  x86_64 support introduced (andrei)
88d3fa6d
 #  2004-12-14  gcc-3.4 special case added (andrei)
8d0543b9
 #  2004-12-15  HAVE_ALLOCA_H added (andrei)
350ffd02
 #  2004-12-19  amd64 transformed in x86_64 (andrei)
871a6a07
 #  2005-04-27  alpha support added (andrei)
3543f7dc
 #  2005-06-01  use $(LOCALBASE) instead of /usr/{local,pkg} (andrei)
9eda5956
 #  2005-06-26  numeric OSREL & HAVE_KQUEUE added to the *BSD (andrei)
 #  2005-07-04  HAVE_DEVPOLL added to solaris (andrei)
e0931fb0
 #  2005-07-06  gcc 4.0 optimizations support (andrei)
473f6f2e
 #  2005-07-25  better solaris arch detection (andrei)
a31a6e8c
 #  2005-09-12  -mallign-double removed (too many problems) (andrei)
3fb732f3
 #  2005-10-02  distcc get gcc version hack (andrei)
d307929c
 #  2006-03-30  64 bit mode compile by default on sparc64 (-m64), added
 #              CC_GCC_LIKE_ASM and SPARC64_MODE (andrei)
 #              sparc <= v8 support (andrei)
0db44da7
 #  2006-03-31  armv6 & mips64 support added
 #              mips and arm set to NOSMP by default (andrei)
4fd7c9fd
 #  2006-07-10  added -DPROFILING (hscholz)
6c53d41a
 #  2007-02-09  added TLS_HOOKS and CORE_TLS support, obsoleted TLS=1
 #              added TLS_EXTRA_LIBS (andrei)
c853f68a
 #  2007-03-16  added LIB building options: LIB_LDFLAGS, LIB_SONAME, LIB_RPATH,
28b28d2c
 #                INSTALL_LIB, libraries install paths (andrei)
8b8fc486
 #  2007-05-14  futex support if linux 2.5.70+ and 
 #               use_futex=yes (default) (andrei)
f233d281
 #  2007-05-26  changed darwin module link flags (instead of -bundle_loader ser
 #               -flat_namespace -undefined suppress) (andrei)
b234c3ac
 #  2007-07-07  use isainfo -n to detect cpu type on solaris (andrei)
7eec6c23
 #  2007-07-07  added HAVE_SCHED_SETSCHEDULER for linux (andrei)
f682fd71
 #  2007-07-18  added DNS_WATCHDOG_SUPPORT (Miklos)
021e7e0e
 #  2007-07-30  added USE_DNS_CACHE_STATS and USE_DST_BLACKLIST_STATS (Gergo)
7742b1d2
 #  2008-06-26  support for make cfg / config.mak and hack to load 
 #               automatically config.mak when included from a module, lib 
 #               a.s.o (not from the main Makefile)  (andrei)
 
4ce32edc
 
 # check if already included/exported
 
7742b1d2
 
 # used for sanity checks for Makefile.defs inclusion (!= makefile_defs which
 # specifies if we have a set of valid defs)
 override makefile_defs_included:=1
 ifeq ($(makefile_defs),1)
 $(info Makefile.defs defs skipped)
4ce32edc
 else
7742b1d2
 
 ifeq (,$(main_makefile))
 # hack to automatically use config.mak in all the modules, without 
 # changing the current module makefiles (which all include Makefile.defs):
 # if not called from the main makefile (module, lib or ut):
 # include config.mak, but if not present or incomplete (makefile_defs!=1)
 # don't export the vars)
 COREPATH?= ../..
 include $(COREPATH)/config.mak
 $(info config.mak included)
 # config.mak should set makefile_defs if complete
4ce32edc
 export makefile_defs
247c2b65
 
7742b1d2
 else
 override makefile_defs=1
 export makefile_defs
 
 
 $(info normal Makefile.defs exec)
194b6a35
 # main binary name
 MAIN_NAME=ser
247c2b65
 
 #version number
a2b27952
 VERSION = 2
 PATCHLEVEL = 1
 SUBLEVEL =  0
7742b1d2
 EXTRAVERSION = -dev23-make
247c2b65
 
21a3adb3
 SER_VER = $(shell expr $(VERSION) \* 1000000 + $(PATCHLEVEL) \* 1000 + \
 			$(SUBLEVEL) )
247c2b65
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
03023127
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ -e s/CYGWIN.*/cygwin/ \
 		 | tr "[A-Z]" "[a-z]")
473f6f2e
 
 ifeq ($(OS),solaris)
b234c3ac
 	GETARCH=isainfo -n
 ifeq ($(GETARCH),)
473f6f2e
 	GETARCH=uname -p
b234c3ac
 endif
473f6f2e
 else
 	GETARCH=uname -m
 endif
 
b234c3ac
 ARCH := $(shell $(GETARCH) |sed -e s/i.86/i386/ -e s/sun4[uv]/sparc64/  \
0db44da7
 			-e s/armv[3-5].*/arm/  -e s/armv6.*/arm6/ \
 			-e "s/Power Macintosh/ppc/" \
473f6f2e
 			-e "s/cobalt/mips2/" \
b234c3ac
 			-e s/amd64/x86_64/ -e s/sparcv9/sparc64/ )
473f6f2e
 # fix sparc -> sparc64
 ifeq ($(ARCH),sparc)
 	ifeq ($(shell uname -m),sun4u)
 		ARCH := sparc64
 	endif
b234c3ac
 	ifeq ($(shell uname -m),sun4v)
 		ARCH := sparc64
 	endif
473f6f2e
 endif
 
cf98659b
 OSREL = $(shell uname -r)
741a9937
 # numerical version (good for comparisons: A.B.C => A*1000000+B*1000+C)
 OSREL_N= $(shell echo $(OSREL) | sed -e 's/^[^0-9]*//' \
 		-e 's/^\([0-9][0-9]*\(\.[0-9][0-9]*\)*\).*$$/\1/g' | \
473f6f2e
 		(IFS=. read A B C D; R=0; \
741a9937
 		[ -n "$$A" ] && R=`expr $$R \* 1000 + $$A` && \
 		[ -n "$$B" ] && R=`expr $$R \* 1000 + $$B` && \
 		[ -n "$$C" ] && R=`expr $$R \* 1000 + $$C`; echo $$R ) )
247c2b65
 
df67d63e
 
f22b996b
 # TLS support
6c53d41a
 CORE_TLS ?= 
14a93a9b
 # by default compile with tls hooks support (so that no ser recompile is
 #  needed before the tls module can be used)
 TLS_HOOKS=1
6c53d41a
 ifeq ($(CORE_TLS), 1)
346c7dab
 	RELEASE:=$(RELEASE)-tls
6c53d41a
 	TLS_HOOKS:=0
346c7dab
 endif
6c53d41a
 ifeq ($(TLS_HOOKS), 1)
895cb2af
 #	RELEASE:=$(RELEASE)-tls
6c53d41a
 endif
 
1f2c924e
 # extra CC command line options (e.g  -march=athlon-mp)
 CC_EXTRA_OPTS ?=
db1b5017
 
3543f7dc
 # dirs 
28b28d2c
 cfg_dir = etc/ser/
 bin_dir = sbin/
ee03be75
 share_dir = share/ser/
28b28d2c
 modules_dir = lib/ser/modules/
 lib_dir = lib/ser/
aee4712e
 ifeq ($(OS), linux)
28b28d2c
 	doc_dir = share/doc/ser/
 	man_dir = share/man/
3543f7dc
 	LOCALBASE ?= /usr/local
aee4712e
 else
a2786e3e
 ifeq ($(OS), freebsd)
28b28d2c
 	doc_dir = share/doc/ser/
 	man_dir = man/
3543f7dc
 	LOCALBASE ?= /usr/local
a2786e3e
 else
f42e8993
 ifeq ($(OS), openbsd)
28b28d2c
 	doc_dir = share/doc/ser/
 	man_dir = man/
3543f7dc
 	LOCALBASE ?= /usr/local
f42e8993
 else
 ifeq ($(OS), netbsd)
28b28d2c
 	doc_dir = share/doc/ser
 	man_dir = man/
3543f7dc
 	LOCALBASE ?= /usr/pkg
f42e8993
 else
194b6a35
 ifeq ($(OS), darwin)
28b28d2c
 	doc_dir = share/doc/ser/
 	man_dir = man/
3543f7dc
 	LOCALBASE ?= /usr/local
194b6a35
 else
28b28d2c
 	doc_dir = doc/ser/
 	man_dir = man/
3543f7dc
 	LOCALBASE ?= /usr/local
f42e8993
 endif
 endif
aee4712e
 endif
a2786e3e
 endif
194b6a35
 endif
3543f7dc
 
a51f9e36
 # Doxygen directory
 doxygen_dir=doc/doxygen
 
3543f7dc
  # install location
 DESTDIR ?= $(LOCALBASE)
 PREFIX ?= $(DESTDIR)
 prefix = $(PREFIX)
 # install path is $(basedir) $(prefix) 
 # example:
 #  creating a bin. archive in /tmp, which unpacks in /usr/local
 #  basedir=/tmp
 #  prefix=/usr/local
 
 BASEDIR ?=
 basedir = $(BASEDIR)
 # install prefixes for various stuff
28b28d2c
 cfg_prefix = $(basedir)$(prefix)
 bin_prefix = $(basedir)$(prefix)
 modules_prefix = $(basedir)$(prefix)
 lib_prefix = $(basedir)$(prefix)
 doc_prefix = $(basedir)$(prefix)
 man_prefix = $(basedir)$(prefix)
 ut_prefix = $(basedir)$(prefix)
ee03be75
 share_prefix = $(basedir)$(prefix)
3543f7dc
 
 
054cb6cf
 # target dirs for various stuff
28b28d2c
 cfg_target = $(prefix)/$(cfg_dir)
 bin_target = $(prefix)/$(bin_dir)
 modules_target = $(prefix)/$(modules_dir)
 lib_target = $(prefix)/$(lib_dir)
 doc_target = $(prefix)/$(doc_dir)
db1b5017
 
0bafb279
 
 ifeq ($(OS), solaris)
 #use GNU versions
5b9b8d2e
 INSTALL ?= ginstall
 TAR ?= gtar
0bafb279
 else
7742b1d2
 INSTALL ?= install
5b9b8d2e
 TAR ?= tar
0bafb279
 endif
054cb6cf
 
28b28d2c
 INSTALL_TOUCH = touch          # used to create the file first (good to 
15dde484
                                #  make solaris install work)
28b28d2c
 INSTALL_CFG = $(INSTALL) -m 644
 INSTALL_BIN = $(INSTALL) -m 755
1c5f04ac
 INSTALL_SCRIPT = $(INSTALL) -m 755
28b28d2c
 INSTALL_MODULES = $(INSTALL) -m 755
 INSTALL_LIB = $(INSTALL) -m 755
 INSTALL_DOC = $(INSTALL) -m 644
 INSTALL_MAN = $(INSTALL) -m 644
ee03be75
 INSTALL_SHARE = $(INSTALL) -m 644
db1b5017
 
054cb6cf
 #set some vars from the environment (and not make builtins)
 CC   := $(shell echo "$${CC}")
 LEX  := $(shell echo "$${LEX}")
 YACC := $(shell echo "$${YACC}")
 
 
 
db1b5017
 
176e7a13
 # find compiler name & version
 ifeq ($(CC),)
 	CC=gcc
 endif
 LD= $(CC)
 CC_LONGVER=$(shell if  $(CC) -v 2>/dev/null; then \
 						$(CC) -v 2>&1 ;\
 					else \
 						$(CC) -V 2>&1 ; \
 					fi )
 MKTAGS=ctags -R .
 
 #find-out the compiler's name
 
 ifneq (,$(findstring gcc, $(CC_LONGVER)))
 	CC_NAME=gcc
d0da70f3
 	CC_VER=$(word 1,$(CC)) $(shell $(CC) - --version|head -n 1|cut -d" " -f 3|\
 				 sed -e 's/^.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/'\
69bd757d
 				 	 -e 's/^[^0-9].*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/')
eac2c677
 	# sed with POSIX.1 regex doesn't support |, + or ? 
         # (darwin, solaris ...) => this complicated expression
176e7a13
 	MKDEP=$(CC) -MM 
 	#transform gcc version into 2.9x or 3.0
 	CC_SHORTVER=$(shell echo "$(CC_VER)" | cut -d" " -f 2| \
 				 sed -e 's/[^0-9]*-\(.*\)/\1/'| \
88d3fa6d
 				 sed -e 's/2\.9.*/2.9x/' -e 's/3\.[0-3]\..*/3.0/' -e \
 				 	's/3\.[0-3]/3.0/' -e 's/3\.[4-9]\..*/3.4/' -e \
e0931fb0
 					's/3\.[4-9]/3.4/' -e 's/4\.[0-9]\..*/4.x/' -e \
 					's/4\.[0-9]/4.x/' )
176e7a13
 endif
 
 ifneq (, $(findstring Sun, $(CC_LONGVER)))
 	CC_NAME=suncc
194b6a35
 	CC_SHORTVER=$(shell echo "$(CC_LONGVER)"|head -n 1| \
176e7a13
 					sed -e 's/.*\([0-9]\.[0-9]\).*/\1/g' )
 	CC_VER=$(CC) $(CC_SHORTVER)
 	MKDEP=$(CC) -xM1 
 endif
 
 ifneq (, $(findstring Intel(R) C++ Compiler, $(CC_LONGVER)))
 	# very nice: gcc compatible
 	CC_NAME=icc
194b6a35
 	CC_FULLVER=$(shell echo "$(CC_LONGVER)"|head -n 1| \
176e7a13
 					sed -e 's/.*Version \([0-9]\.[0-9]\.[0-9]*\).*/\1/g' )
 	CC_SHORTVER=$(shell echo "$(CC_FULLVER)" | cut -d. -f1,2 )
 	CC_VER=$(CC) $(CC_FULLVER)
 	MKDEP=$(CC) -MM 
 endif
 
 
 ifeq (,$(CC_NAME))
 #not found
 	CC_NAME=$(CC)
 	CC_SHORTVER=unknown
 	CC_VER=unknown
 	MKDEP=gcc -MM 
 $(warning	Unknown compiler $(CC)\; supported compilers: \
 			gcc, sun cc, intel icc )
 endif
 
 
247c2b65
 # compile-time options
efd6c2fe
 #
 # -DSTATS
 #		allows to print out number of packets processed on CTRL-C;
247c2b65
 # 		implementation still nasty and reports per-process
efd6c2fe
 # -DNO_DEBUG
247c2b65
 #		turns off some of the debug messages (DBG(...)).
efd6c2fe
 # -DNO_LOG
247c2b65
 #		completely turns of all the logging (and DBG(...))
efd6c2fe
 # -DEXTRA_DEBUG
247c2b65
 #		compiles in some extra debugging code
efd6c2fe
 # -DDNS_IP_HACK
247c2b65
 #		faster ip address resolver for ip strings (e.g "127.0.0.1")
efd6c2fe
 # -DSHM_MEM
247c2b65
 #		compiles in shared mem. support, needed by some modules and
 #		by USE_SHM_MEM
dcb5f364
 # -DSHM_MMAP
 #		use mmap instead of SYSV shared memory
efd6c2fe
 # -DPKG_MALLOC
247c2b65
 #		uses a faster malloc (exclusive w/ USE_SHM_MEM)
efd6c2fe
 # -DUSE_SHM_MEM
 #		all pkg_malloc => shm_malloc (most mallocs use a common sh.
247c2b65
 #		mem. segment); don't define PKG_MALLOC if you want this!
 # -DDBG_QM_MALLOC
 #		qm_malloc debug code, will cause pkg_malloc and shm_malloc
 #		to keep and display lot of debuging information: file name,
 #		function, line number of malloc/free call for each block,
 #		extra error checking (trying to free the same pointer
 #		twice, trying to free a pointer alloc'ed with a different
 #		malloc etc.)
dda9dab1
 # -DVQ_MALLOC
 #		additional option to PKG_MALLOC which utilizes a fater then
 #		qm version
b2dec9c6
 #		(not true anymore, q_malloc performs approx. the same)
 # -DF_MALLOC
 #		an even faster malloc, not recommended for debugging
51ea5ec2
 # -DDL_MALLOC
 #		a malloc implementation based on Doug Lea's dl_malloc
fbe11914
 # -DSF_MALLOC 
 #		an experimental multi-CPU, pool based, multi-process safe version of 
 #		F_MALLOC. Should give better performance on machines with lots of CPUs
 #		after some tunning.
 # -DLL_MALLOC
 #		an experimental multi-CPU, pool based, multi-process safe, mostly
 #		lockless version of SF_MALLOC/F_MALLOC. Not for production use for
 #		now.
ea6721d7
 # -DDBG_MALLOC
 #		issues additional debugging information if lock/unlock is called
b2dec9c6
 # -DFAST_LOCK
 #		uses fast arhitecture specific locking (see the arh. specific section)
e0135488
 # -DUSE_SYSV_SEM
 #		uses sys v sems for locking (slower & limited number)
 # -DUSE_PTHREAD_MUTEX
 #		uses pthread mutexes, faster than sys v or posix sems, but do not 
 #		work on all systems inter-processes (e.g. linux)
 # -DUSE_POSIX_SEM
 #		uses posix semaphores for locking (faster than sys v)
8b8fc486
 # -DUSE_FUTEX
 #		uses futexes for locking (linux 2.6+)
30f1f956
 # -DBUSY_WAIT
06aaa54f
 #		uses busy waiting on the lock (FAST_LOCK)
30f1f956
 # -DADAPTIVE_WAIT
 #		try busy waiting for a while and if the lock is still held go to
06aaa54f
 #		force reschedule (FAST_LOCK)
30f1f956
 # -DADAPTIVE_WAIT_LOOPS=number
 #		number of loops we busy wait, after "number" loops have elapsed we 
06aaa54f
 #		force a reschedule (FAST_LOCK)
30f1f956
 # -DNOSMP
 #		don't use smp compliant locking (faster but won't work on SMP machines)
06aaa54f
 #		(not yet enabled) (FAST_LOCK)
caf80ae6
 # -DNO_PINGTEL_TAG_HACK
 #		if enabled, To-header-field will be less liberal and will not accept
 #		'tag=' (tag parameter with equal sign and without value); it is called
 #		this way because such message was sighted from a Pingtel phone
5b532c7f
 # -DUSE_TCP
f22b996b
 #		compiles in tcp support
b33736bc
 # -DDISABLE_NAGLE
 #		disable the tcp Nagle algorithm (lower delay)
f22b996b
 # -DUSE_TLS
6c53d41a
 #		compiles in tls support, requires -DUSE_TCP. Note: this is only 
 #		generic support (parsing a.s.o.), it does not include the actual
 #		"tls engine". If you really want tls you need also either
 #		-DCORE_TLS and a tls/ subdir with the tls code or -DTLS_HOOKS and
 #		the tls module loaded.
 # -DCORE_TLS
 #		compiles tls in-core support. Requires -DUSE_TLS, conflicts 
 #		-DTLS_HOOKS. Please use make CORE_TLS=1 instead  (it will set all the
 #		needed defines automatically and extra libraries needed for linking).
 # -DTLS_HOOKS
 #		compile tls module support (support for having the "tls engine" in a
 #		module). Requires -DUSE_TLS, conflicts -DCORE_TLS.
 #		Please use make TLS_HOOKS=1 (or TLS_HOOKS=0 to for disabling) instead
 #		of setting -DTLS_HOOKS (it will set all the needed defines 
 #		automatically)
878fc194
 # -DHAVE_RESOLV_RES
 #		support for changing some of the resolver parameters present
 #		 (_res structure in <resolv.h>)
7a068ff3
 # -DUSE_COMP
 #		compiles in comp=[sergz|sigcomp] support (parsing uri & via, 
 #		adding it to via, lumps a.s.o). WARNING: right now this option
 #		is useless since the compression code doesn't exist yet.
17bae7f1
 # -DHONOR_MADDR
 #		compiles in checks and use for maddr parameter in uri.
 #		Required to support Windows Messenger 5.x over TCP connection
 #		which (mis)uses this parameter.
dcb59e67
 # -DUSE_DNS_CACHE
 #		use an internal dns cache instead of making dns requests each time
021e7e0e
 # -DUSE_DNS_CACHE_STATS
 #		turns on DNS cache measurements
dcb59e67
 # -DUSE_DNS_FAILOVER
 #		if the destination resolves to multiple ips, on send error fall back
 #		to the others
 # -DUSE_DST_BLACKLIST
 #		blacklist bad destination (timeout, failed to connect, error sending
 #        a.s.o)
021e7e0e
 # -DUSE_DST_BLACKLIST_STATS
 #		turns on blacklist bad destination measurements
4fd7c9fd
 # -DPROFILING
 #		if enabled profiling will be enabled for child processes
 #		Don't forget to set PROFILE (see below)
96227c65
 # -DUSE_STUN
 #		compiles in stun support
96d09107
 # -DNO_SIG_DEBUG
 #        turns off debugging messages in signal handlers (which might be 
 #         unsafe)
dd4ffbb7
 # -DUSE_NAPTR
 #		 turns on naptr support (but must be also enabled from the config)
f682fd71
 # -DDNS_WATCHDOG_SUPPORT
 #		turns on DNS watchdog support which can be used to inform the
 #		core that the DNS servers are down. No DNS query is performed
 #		when the servers are unreachable, and even expired resource
 #		records are used from the cache. (requires external watchdog)
bc404f2b
 # Sometimes is needes correct non-quoted $OS. HACK: gcc translates known OS to number ('linux'), so there is added underscore
96dd9e9f
 
7742b1d2
 DEFS= $(extra_defs) \
dd0e65a8
 	 -DNAME='"$(MAIN_NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
bc404f2b
 	 -DOS='$(OS)_' -DOS_QUOTED='"$(OS)"' -DCOMPILER='"$(CC_VER)"' -D__CPU_$(ARCH) -D__OS_$(OS) \
21a3adb3
 	 -DSER_VER=$(SER_VER) \
28b28d2c
 	 -DCFG_DIR='"$(cfg_target)"'\
16d4e079
 	 -DMODS_DIR='"$(modules_target)"'\
9b47a45c
 	 -DPKG_MALLOC \
51eadd0c
 	 -DSHM_MEM  -DSHM_MMAP \
ba506d03
 	 -DDNS_IP_HACK \
a18366db
 	 -DUSE_IPV6 \
2ba73117
 	 -DUSE_MCAST \
8aeb47e2
 	 -DUSE_TCP \
b33736bc
 	 -DDISABLE_NAGLE \
878fc194
 	 -DHAVE_RESOLV_RES \
dcb59e67
 	 -DUSE_DNS_CACHE \
 	 -DUSE_DNS_FAILOVER \
 	 -DUSE_DST_BLACKLIST \
dd4ffbb7
 	 -DUSE_NAPTR \
03023127
 	 -DDBG_QM_MALLOC \
021e7e0e
 	 #-DUSE_DNS_CACHE_STATS \
 	 #-DUSE_DST_BLACKLIST_STATS \
f682fd71
 	 #-DDNS_WATCHDOG_SUPPORT \
fbe11914
 	 #-DLL_MALLOC \
 	 #-DSF_MALLOC \
51ea5ec2
 	 #-DDL_MALLOC \
 	 #-DF_MALLOC \
dd4ffbb7
 	 #-DDBG_QM_MALLOC \
08bf96f2
 	 #-DDBG_F_MALLOC \
bfd94206
 	 #-DNO_DEBUG \
ca20b615
 	 #-DEXTRA_DEBUG \
08bf96f2
 	 #-DVQ_MALLOC  \
 	 #-DDBG_LOCK \
db829953
 	 #-DNOSMP \
e5bcdb99
 	 #-DUSE_SHM_MEM \
 	 #-DSTATS \
4fd7c9fd
 	 #-DNO_LOG \
96d09107
 	 #-DPROFILING \
 	 #-DNO_SIG_DEBUG
b2dec9c6
 
4fd7c9fd
 #PROFILE=  -pg	# set this if you want profiling
 				# you may also want to set -DPROFILING
6419a43f
 
 # WARNING: do not add mode=debug or mode=release anymore in the Makefile,
 # use make mode=debug all instead. Anyway no by default ser is  compiled w/ 
 # debugging symbols in all cases (-g). --andrei
f22b996b
 
6c53d41a
 ifeq ($(CORE_TLS), 1)
 	DEFS+= -DUSE_TLS -DCORE_TLS
 endif
 ifeq ($(TLS_HOOKS), 1)
 	DEFS+= -DUSE_TLS -DTLS_HOOKS
f22b996b
 endif
 
96227c65
 ifneq ($(STUN),)
 	DEFS+= -DUSE_STUN
 endif
 
054cb6cf
 ifeq ($(mode),)
 	mode = release
 endif
247c2b65
 
f2e456c3
 ifeq ($(mode),debug)
 	DEFS+= -DEXTRA_DEBUG
 endif
 
247c2b65
 # platform dependent settings
 
85f1f3ee
 # find ld & as name (gnu or solaris)
473f6f2e
 ifeq ($(OS), solaris)
629fca1e
 ifeq ($(CC_NAME), gcc)
 		LDGCC=$(shell $(CC) -v 2>&1 | grep with-ld| \
 				   sed -e 's/.*--with-ld=\([^ ][^ ]*\).*/\1/' )
85f1f3ee
 		ASGCC=$(shell $(CC) -v 2>&1 | grep with-as| \
 				   sed -e 's/.*--with-as=\([^ ][^ ]*\).*/\1/' )
629fca1e
 		LDPATH=$(shell  if [ -z "$(LDGCC)" ] ; then echo "ld" ;\
 						else \
 						if $(LDGCC) -V 2>/dev/null 1>/dev/null; then \
 							echo $(LDGCC); \
 						else echo "ld" ; \
 						fi\
 						fi)
85f1f3ee
 		ASPATH=$(shell  if [ -z "$(ASGCC)" ] ; then echo "as" ;\
 						else \
 						if $(ASGCC) -V 2>/dev/null 1>/dev/null; then \
 							echo $(ASGCC); \
 						else echo "as" ; \
 						fi\
 						fi)
 							
629fca1e
 		LDTYPE=$(shell if $(LDPATH) -V 1>/dev/null  2>/dev/null; then \
 							if $(LDPATH) -V 2>&1|grep GNU >/dev/null; \
 							then echo gnu; \
 							else \
 							if $(LDPATH) -V 2>&1|grep Solaris >/dev/null;\
 							then echo solaris; \
 							else \
 								echo unknown ; \
 							fi \
 							fi \
 						fi)
85f1f3ee
 		ASTYPE=$(shell if $(ASPATH) -V 1>/dev/null  2>/dev/null </dev/null; \
 						then \
 							if $(ASPATH) -V 2>&1 </dev/null |grep GNU >/dev/null; \
 							then echo gnu; \
 							else \
 							if $(ASPATH) -V 2>&1 </dev/null |grep Sun >/dev/null;\
 							then echo solaris; \
 							else \
 								echo unknown ; \
 							fi \
 							fi \
 						fi)
 #$(warning "using ld=$(LDPATH)/$(LDTYPE), as=$(ASPATH)/$(ASTYPE)")
 
629fca1e
 endif
 endif
11ece359
 
03023127
 # arch. specific definitions
43fcad56
 ifeq ($(ARCH), i386)
e0135488
 	use_fast_lock=yes
43fcad56
 endif
 
4d080f49
 ifeq ($(ARCH), x86_64)
 	use_fast_lock=yes
 endif
 
85f1f3ee
 ifeq ($(ARCH), sparc64)
43fcad56
 ifeq 	($(CC_NAME), gcc)
e0135488
 	use_fast_lock=yes
43fcad56
 endif
 endif
 
245b8b93
 ifeq ($(ARCH), sparc)
 	use_fast_lock=yes
 endif
 
087d0976
 ifeq ($(ARCH), arm)
e0135488
 	use_fast_lock=yes
0db44da7
 	DEFS+=-DNOSMP # very unlikely to have an smp arm
 endif
 
 ifeq ($(ARCH), arm6)
 	use_fast_lock=yes
733a6458
 endif
 
523768d2
 ifeq ($(ARCH), ppc)
e0135488
 	use_fast_lock=yes
 endif
 
871a6a07
 ifeq ($(ARCH), ppc64)
 	use_fast_lock=yes
 endif
 
06aaa54f
 ifeq ($(ARCH), mips)
 # mips1 arch. (e.g. R3000) - no hardware locking support
 	use_fast_lock=no
0db44da7
 	DEFS+=-DMIPS_HAS_LLSC # likely
 	DEFS+=-DNOSMP # very likely
06aaa54f
 endif
 
5ffcc5d0
 ifeq ($(ARCH), mips2)
 # mips2 arch and newer (mips3=R4000, mips4=R5000 a.s.o)
 	use_fast_lock=yes
 endif
 
0db44da7
 ifeq ($(ARCH), mips64)
 # mips2 arch and newer (mips3=R4000, mips4=R5000 a.s.o)
 	use_fast_lock=yes
 endif
 
871a6a07
 ifeq ($(ARCH), alpha)
 	use_fast_lock=yes
8b8fc486
 	DEFS+=-DNOSMP # very likely
871a6a07
 endif
 
e0135488
 ifeq ($(use_fast_lock), yes)
06aaa54f
 	DEFS+= -DFAST_LOCK -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 
e0135488
 	found_lock_method=yes
523768d2
 endif
 
054cb6cf
 CFLAGS=
74250efc
 LDFLAGS=
ad1e3e5c
 INCLUDES=
11ece359
 # setting CFLAGS
247c2b65
 ifeq ($(mode), release)
11ece359
 	#if i386
 ifeq	($(ARCH), i386)
 		# if gcc 
 ifeq		($(CC_NAME), gcc)
d307929c
 				DEFS+=-DCC_GCC_LIKE_ASM
51eadd0c
 				#common stuff
c8907870
 				CFLAGS=-g -O9 -funroll-loops  -Wcast-align $(PROFILE)
e0931fb0
 			#if gcc 4.0+
 ifeq			($(CC_SHORTVER), 4.x)
 					CPU ?= athlon64
a31a6e8c
 					CFLAGS+=-minline-all-stringops \
e0931fb0
 							-falign-loops \
 							-ftree-vectorize \
 							-mtune=$(CPU) 
 else
88d3fa6d
 			#if gcc 3.4+
 ifeq			($(CC_SHORTVER), 3.4)
 					CPU ?= athlon
a31a6e8c
 					CFLAGS+=-minline-all-stringops \
88d3fa6d
 							-falign-loops \
 							-mtune=$(CPU) 
 else
 			#if gcc 3.0+
11ece359
 ifeq			($(CC_SHORTVER), 3.0)
1f2c924e
 					CPU ?= athlon
a31a6e8c
 					CFLAGS+=-minline-all-stringops \
65531ed9
 							-falign-loops \
88d3fa6d
 							-mcpu=$(CPU) 
11ece359
 else
 ifeq			($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
2510051e
 $(warning 			Old gcc detected ($(CC_SHORTVER)), use  gcc >= 3.1 \
11ece359
 					for better results)
 					
 					CFLAGS+=-m486 \
 							-malign-loops=4
 else
 				#really old version
 $(warning			You are using an old and unsupported gcc \
65531ed9
 					 version  ($(CC_SHORTVER)), compile at your own risk!)
11ece359
 
 endif			# CC_SHORTVER, 2.9x
 endif			# CC_SHORTVER, 3.0
88d3fa6d
 endif			# CC_SHORTVER, 3.4
e0931fb0
 endif			# CC_SHORTVER, 4.x
11ece359
 
 else		# CC_NAME, gcc
9c61e9f9
 ifeq		($(CC_NAME), icc)
d307929c
 			DEFS+=-DCC_GCC_LIKE_ASM
6419a43f
 			CFLAGS=-g -O3  -ipo -ipo_obj -unroll  $(PROFILE) \
9c61e9f9
 					 -tpp6 -xK  #-openmp  #optimize for PIII 
 				# -prefetch doesn't seem to work
 				#( ty to inline acroos files, unroll loops,prefetch,
 				# optimize for PIII, use PIII instructions & vect.,
 				# mutlithread loops)
 else
11ece359
 				#other compilers
 $(error 			Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
9c61e9f9
 endif		#CC_NAME, icc
11ece359
 endif		#CC_NAME, gcc
 endif	#ARCH, i386
 
4d080f49
 #x86_64
 ifeq	($(ARCH), x86_64)
 		# if gcc 
 ifeq		($(CC_NAME), gcc)
d307929c
 				DEFS+=-DCC_GCC_LIKE_ASM
4d080f49
 				#common stuff
b234c3ac
 				CFLAGS=-m64 -g -O9 -funroll-loops  -Wcast-align $(PROFILE)
 				LDFLAGS+=-m64
e0931fb0
 			#if gcc 4.0+
 ifeq			($(CC_SHORTVER), 4.x)
 					CPU ?= opteron
 					CFLAGS+=-minline-all-stringops \
 							-falign-loops \
 							-ftree-vectorize \
 							-mtune=$(CPU) 
 else
88d3fa6d
 			#if gcc 3.4
 ifeq			($(CC_SHORTVER), 3.4)
 					CPU ?= athlon64
 					CFLAGS+=-minline-all-stringops \
 							-falign-loops 
 else
4d080f49
 			#if gcc 3.0
 ifeq			($(CC_SHORTVER), 3.0)
 					CPU ?= athlon64
 					CFLAGS+=-minline-all-stringops \
88d3fa6d
 							-falign-loops 
664b2784
 							#-mcpu=$(CPU) \ # not working on all x86_64 gccs
4d080f49
 							#-mcpu=athlon
 else
 ifeq			($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
 $(warning 			Old gcc detected ($(CC_SHORTVER)), use  gcc >= 3.1 \
 					for better results)
 					
 					CFLAGS+=-m486 \
 							-malign-loops=4
 else
 				#really old version
 $(warning			You are using an old and unsupported gcc \
 					 version  ($(CC_SHORTVER)), compile at your own risk!)
 
 endif			# CC_SHORTVER, 2.9x
 endif			# CC_SHORTVER, 3.0
88d3fa6d
 endif			# CC_SHORTVER, 3.4
e0931fb0
 endif			# CC_SHORTVER, 4.x
4d080f49
 
 else		# CC_NAME, gcc
 ifeq		($(CC_NAME), icc)
d307929c
 			DEFS+=-DCC_GCC_LIKE_ASM
4d080f49
 			CFLAGS=-g -O3  -ipo -ipo_obj -unroll  $(PROFILE) \
 					 -tpp6 -xK  #-openmp  #optimize for PIII 
 				# -prefetch doesn't seem to work
 				#( ty to inline acroos files, unroll loops,prefetch,
 				# optimize for PIII, use PIII instructions & vect.,
 				# mutlithread loops)
 else
 				#other compilers
 $(error 			Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
 endif		#CC_NAME, icc
 endif		#CC_NAME, gcc
 endif	#ARCH, x86_64
11ece359
 
d307929c
 	#if sparc64
85f1f3ee
 ifeq	($(ARCH), sparc64)
11ece359
 			#if gcc
 ifeq		($(CC_NAME), gcc)
d307929c
 				DEFS+=-DCC_GCC_LIKE_ASM -DSPARC64_MODE
51eadd0c
 				#common stuff
d307929c
 				CFLAGS=-m64 -g -O9 -funroll-loops  $(PROFILE) \
462cf6f9
 					#-Wcast-align \
 					#-Wmissing-prototypes 
d307929c
 				# use -m64 to force 64 bit (but add it also to LDFLAGS and
 				#  don't forget to define SPARC64_MODE)
 				# -m32 for 32 bit (default on solaris),
 				# nothing for arch. default
 				LDFLAGS+=-m64
e0931fb0
 				#if gcc 4.x
 ifeq			($(CC_SHORTVER), 4.x)
 					CPU ?= ultrasparc
 					#use 32bit for now
8416765e
 					CFLAGS+=-mcpu=ultrasparc  \
e0931fb0
 							-mtune=$(CPU) \
 							-ftree-vectorize
 else
88d3fa6d
 				#if gcc 3.4
 ifeq			($(CC_SHORTVER), 3.4)
 					CPU ?= ultrasparc
 					#use 32bit for now
 					CFLAGS+= -mcpu=ultrasparc -mtune=$(CPU)
 else
11ece359
 				#if gcc 3.0
 ifeq			($(CC_SHORTVER), 3.0)
1f2c924e
 					CPU ?= ultrasparc
11ece359
 					#use 32bit for now
74250efc
 					CFLAGS+= -mcpu=ultrasparc -mtune=$(CPU)   \
11ece359
 					# -mcpu=v9 or ultrasparc? # -mtune implied by -mcpu
 					#-mno-epilogue #try to inline function exit code
 					#-mflat # omit save/restore
 					#-,faster-structs #faster non Sparc ABI structure copy ops
 else			# CC_SHORTVER, 3.0
 ifeq			($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
2510051e
 $(warning 			Old gcc detected ($(CC_SHORTVER)), use  gcc >= 3.1 \
11ece359
 					for better results)
85f1f3ee
 ifneq				($(OS), netbsd)
 						# on netbsd/sparc64,  gcc 2.95.3 does not compile
 						# ser with -mv8
d307929c
 						CFLAGS+= -mv9 
85f1f3ee
 endif
 ifeq					($(ASTYPE), solaris)
 							CFLAGS+= -Wa,-xarch=v8plus
 endif					
11ece359
 else			#CC_SHORTVER, 2.9x
 				#really old version
 $(warning			You are using an old and unsupported gcc \
 					 version ($(CC_SHORTVER)), compile at your own risk!)
 					
d307929c
 					CFLAGS+= -mv9 
85f1f3ee
 ifeq					($(ASTYPE), solaris)
 							CFLAGS+= -Wa,-xarch=v8plus
 endif					
 	
11ece359
 endif			#CC_SHORTVER, 2.9x
 endif			#CC_SHORTVER, 3.0
88d3fa6d
 endif			#CC_SHORTVER, 3.4
e0931fb0
 endif			#CC_SHORTVER, 4.x
d307929c
 	
11ece359
 else		#CC_NAME, gcc
51eadd0c
 ifeq		($(CC_NAME), suncc)
d307929c
 			DEFS+=-DSPARC64_MODE
 			CFLAGS+= -m64 -g -xO5 -fast -native -xarch=v9 -xCC \
51eadd0c
 					-xc99 # C99 support
 			# -Dinline="" # add this if cc < 5.3 (define inline as null)
 else
11ece359
 				#other compilers
 $(error 			Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
51eadd0c
 endif		#CC_NAME, suncc
11ece359
 endif		#CC_NAME, gcc
245b8b93
 endif	#ARCH, sparc64
11ece359
 
d307929c
 	#if sparc
 ifeq	($(ARCH), sparc)
 			#if gcc
 ifeq		($(CC_NAME), gcc)
 				DEFS+=-DCC_GCC_LIKE_ASM
 				#common stuff
 				CFLAGS=-g -O9 -funroll-loops  $(PROFILE) \
 					#-Wcast-align \
 					#-Wmissing-prototypes 
 				#if gcc 4.x
 ifeq			($(CC_SHORTVER), 4.x)
 					CPU ?= v8 
 					#use 32bit for now
 					CFLAGS+= -minline-all-stringops \
 							-mtune=$(CPU) \
 							-ftree-vectorize
 else
 				#if gcc 3.4
 ifeq			($(CC_SHORTVER), 3.4)
 					CPU ?= v8
 					#use 32bit for now
 					CFLAGS+= -mtune=$(CPU)
 else
 				#if gcc 3.0
 ifeq			($(CC_SHORTVER), 3.0)
 					CPU ?= v8 
 					#use 32bit for now
 					CFLAGS+= -mtune=$(CPU)   \
 					#-mno-epilogue #try to inline function exit code
 					#-mflat # omit save/restore
 					#-,faster-structs #faster non Sparc ABI structure copy ops
 else			# CC_SHORTVER, 3.0
 ifeq			($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
 $(warning 			Old gcc detected ($(CC_SHORTVER)), use  gcc >= 3.1 \
 					for better results)
 else			#CC_SHORTVER, 2.9x
 				#really old version
 $(warning			You are using an old and unsupported gcc \
 					 version ($(CC_SHORTVER)), compile at your own risk!)
 					
 endif			#CC_SHORTVER, 2.9x
 endif			#CC_SHORTVER, 3.0
 endif			#CC_SHORTVER, 3.4
 endif			#CC_SHORTVER, 4.x
 	
 else		#CC_NAME, gcc
 ifeq		($(CC_NAME), suncc)
 			CFLAGS+= -g -xO5 -fast -native -xCC \
 					-xc99 # C99 support
 			# -Dinline="" # add this if cc < 5.3 (define inline as null)
 else
 				#other compilers
 $(error 			Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
 endif		#CC_NAME, suncc
 endif		#CC_NAME, gcc
 endif	#ARCH, sparc
 
8c141481
 	#if ipaq/netwinder
087d0976
 ifeq	($(ARCH), arm)
8c141481
 		# if gcc 
 ifeq		($(CC_NAME), gcc)
d307929c
 				DEFS+=-DCC_GCC_LIKE_ASM
8c141481
 				#common stuff
c8907870
 				CFLAGS=-O9 -funroll-loops $(PROFILE)
e0931fb0
 			#if gcc 4.x+
 ifeq			($(CC_SHORTVER), 4.x)
0db44da7
 					CFLAGS+= -ftree-vectorize
 					# not supported on arm: -minline-all-stringops 
e0931fb0
 else
88d3fa6d
 			#if gcc 3.4+
 ifeq			($(CC_SHORTVER), 3.4)
0db44da7
 					CFLAGS+=
88d3fa6d
 else
8c141481
 			#if gcc 3.0
 ifeq			($(CC_SHORTVER), 3.0)
0db44da7
 					CFLAGS+= 
8c141481
 							#-mcpu=athlon
 else
 ifeq			($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
 $(warning 			Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
 					for better results)
 					
 					CFLAGS+=
 else
 				#really old version
 $(warning			You are using an old and unsupported gcc \
 					 version ($(CC_SHORTVER)), compile at your own risk!)
06aaa54f
 	
8c141481
 endif			# CC_SHORTVER, 2.9x
 endif			# CC_SHORTVER, 3.0
88d3fa6d
 endif			# CC_SHORTVER, 3.4
e0931fb0
 endif			# CC_SHORTVER, 4.0
06aaa54f
 	
 else		# CC_NAME, gcc
 				#other compilers
 $(error 			Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
 endif		#CC_NAME, gcc
 endif	#ARCH, arm 
8c141481
 
0db44da7
 	#if armv6 cpu 
 ifeq	($(ARCH), arm6)
 		# if gcc 
 ifeq		($(CC_NAME), gcc)
 				DEFS+=-DCC_GCC_LIKE_ASM
 				#common stuff
 				CFLAGS=-march=armv6 -O9 -funroll-loops \
c8907870
 						$(PROFILE)
0db44da7
 			#if gcc 4.x+
 ifeq			($(CC_SHORTVER), 4.x)
 					CFLAGS+= -ftree-vectorize
 else
 			#if gcc 3.4+
 ifeq			($(CC_SHORTVER), 3.4)
 					CFLAGS+=
 else
 			#if gcc 3.0
 ifeq			($(CC_SHORTVER), 3.0)
 					CFLAGS+= 
 							#-mcpu=athlon
 else
 ifeq			($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
 $(warning 			Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
 					for better results)
 					
 					CFLAGS+=
 else
 				#really old version
 $(warning			You are using an old and unsupported gcc \
 					 version ($(CC_SHORTVER)), compile at your own risk!)
 	
 endif			# CC_SHORTVER, 2.9x
 endif			# CC_SHORTVER, 3.0
 endif			# CC_SHORTVER, 3.4
 endif			# CC_SHORTVER, 4.0
 	
 else		# CC_NAME, gcc
 				#other compilers
 $(error 			Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
 endif		#CC_NAME, gcc
 endif	#ARCH, arm6
 
06aaa54f
 	#if  mips (R3000)
 ifeq	($(ARCH), mips)
 		# if gcc 
 ifeq		($(CC_NAME), gcc)
d307929c
 				DEFS+=-DCC_GCC_LIKE_ASM
06aaa54f
 				#common stuff
c8907870
 				CFLAGS=-O9 -funroll-loops  $(PROFILE)
e0931fb0
 			#if gcc 4.0+
 ifeq			($(CC_SHORTVER), 4.x)
e960e1e6
 					CFLAGS+=-march=r3000 -minline-all-stringops \
e0931fb0
 							-ftree-vectorize
 else
88d3fa6d
 			#if gcc 3.4+
 ifeq			($(CC_SHORTVER), 3.4)
e960e1e6
 					CFLAGS+= -march=r3000
88d3fa6d
 else
06aaa54f
 			#if gcc 3.0
 ifeq			($(CC_SHORTVER), 3.0)
e960e1e6
 					CFLAGS+= -march=r3000
06aaa54f
 else
 ifeq			($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
 $(warning 			Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
 					for better results)
 					
e960e1e6
 					CFLAGS+=-march=r3000
06aaa54f
 else
 				#really old version
 $(warning			You are using an old and unsupported gcc \
 					 version ($(CC_SHORTVER)), compile at your own risk!)
 	
 endif			# CC_SHORTVER, 2.9x
 endif			# CC_SHORTVER, 3.0
88d3fa6d
 endif			# CC_SHORTVER, 3.4
e0931fb0
 endif			# CC_SHORTVER, 4.x
06aaa54f
 	
8c141481
 else		# CC_NAME, gcc
 				#other compilers
 $(error 			Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
 endif		#CC_NAME, gcc
06aaa54f
 endif	#ARCH, mips
8c141481
 
5ffcc5d0
 	#if  >=mips2 (R4000, R5000, R6000 ....)
 ifeq	($(ARCH), mips2)
 		# if gcc 
 ifeq		($(CC_NAME), gcc)
d307929c
 				DEFS+=-DCC_GCC_LIKE_ASM
5ffcc5d0
 				#common stuff
c8907870
 				CFLAGS= -mips2 -O9 -funroll-loops $(PROFILE)
e0931fb0
 			#if gcc 4.0+
 ifeq			($(CC_SHORTVER), 4.x)
 					CFLAGS+=-minline-all-stringops -ftree-vectorize
 else
88d3fa6d
 			#if gcc 3.4+
 ifeq			($(CC_SHORTVER), 3.4)
 					CFLAGS+=
 else
5ffcc5d0
 			#if gcc 3.0
 ifeq			($(CC_SHORTVER), 3.0)
 					CFLAGS+=
 else
 ifeq			($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
 $(warning 			Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
 					for better results)
 					CFLAGS+=
 else
 				#really old version
 $(warning			You are using an old and unsupported gcc \
 					 version ($(CC_SHORTVER)), compile at your own risk!)
 	
 endif			# CC_SHORTVER, 2.9x
 endif			# CC_SHORTVER, 3.0
88d3fa6d
 endif			# CC_SHORTVER, 3.4
e0931fb0
 endif			# CC_SHORTVER, 4.x
5ffcc5d0
 	
 else		# CC_NAME, gcc
 				#other compilers
 $(error 			Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
 endif		#CC_NAME, gcc
 endif	#ARCH, mips2
8c141481
 
0db44da7
 #if  >=mips64
 ifeq	($(ARCH), mips64)
 		# if gcc 
 ifeq		($(CC_NAME), gcc)
 				DEFS+=-DCC_GCC_LIKE_ASM
 				#common stuff
c8907870
 				CFLAGS= -mips64 -O9 -funroll-loops $(PROFILE)
0db44da7
 			#if gcc 4.0+
 ifeq			($(CC_SHORTVER), 4.x)
 					CFLAGS+=-minline-all-stringops -ftree-vectorize
 else
 			#if gcc 3.4+
 ifeq			($(CC_SHORTVER), 3.4)
 					CFLAGS+=
 else
 			#if gcc 3.0
 ifeq			($(CC_SHORTVER), 3.0)
 					CFLAGS+=
 else
 ifeq			($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
 $(warning 			Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
 					for better results)
 					CFLAGS+=
 else
 				#really old version
 $(warning			You are using an old and unsupported gcc \
 					 version ($(CC_SHORTVER)), compile at your own risk!)
 	
 endif			# CC_SHORTVER, 2.9x
 endif			# CC_SHORTVER, 3.0
 endif			# CC_SHORTVER, 3.4
 endif			# CC_SHORTVER, 4.x
 	
 else		# CC_NAME, gcc
 				#other compilers
 $(error 			Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
 endif		#CC_NAME, gcc
 endif	#ARCH, mips64
871a6a07
 
 #if  alpha
 ifeq	($(ARCH), alpha)
 		# if gcc 
 ifeq		($(CC_NAME), gcc)
d307929c
 				DEFS+=-DCC_GCC_LIKE_ASM
871a6a07
 				#common stuff
c8907870
 				CFLAGS= -O9 -funroll-loops $(PROFILE)
e0931fb0
 			#if gcc 4.0+
 ifeq			($(CC_SHORTVER), 4.x)
0db44da7
 					CFLAGS+= 
 					# not supported: -minline-all-stringops
e0931fb0
 else
871a6a07
 			#if gcc 3.4+
 ifeq			($(CC_SHORTVER), 3.4)
 					CFLAGS+=
 else
 			#if gcc 3.0
 ifeq			($(CC_SHORTVER), 3.0)
 					CFLAGS+=
 else
 ifeq			($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
 $(warning 			Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
 					for better results)
 					CFLAGS+=
 else
 				#really old version
 $(warning			You are using an old and unsupported gcc \
 					 version ($(CC_SHORTVER)), compile at your own risk!)
 	
 endif			# CC_SHORTVER, 2.9x
 endif			# CC_SHORTVER, 3.0
 endif			# CC_SHORTVER, 3.4
e0931fb0
 endif			# CC_SHORTVER, 4.x
871a6a07
 	
 else		# CC_NAME, gcc
 				#other compilers
 $(error 			Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
 endif		#CC_NAME, gcc
 endif	#ARCH, alpha 
 
 #if  ppc
 ifeq	($(ARCH), ppc)
 		# if gcc 
 ifeq		($(CC_NAME), gcc)
d307929c
 				DEFS+=-DCC_GCC_LIKE_ASM
871a6a07
 				#common stuff
c8907870
 				CFLAGS= -O9 -funroll-loops $(PROFILE)
e0931fb0
 			#if gcc 4.0+
 ifeq			($(CC_SHORTVER), 4.x)
 					CPU ?= powerpc
f373f141
 					CFLAGS+=-ftree-vectorize \
e0931fb0
 							-mtune=$(CPU) -maltivec
 else
871a6a07
 			#if gcc 3.4+
 ifeq			($(CC_SHORTVER), 3.4)
 					CFLAGS+=
 else
 			#if gcc 3.0
 ifeq			($(CC_SHORTVER), 3.0)
 					CFLAGS+=
 else
 ifeq			($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
 $(warning 			Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
 					for better results)
 					CFLAGS+=
 else
 				#really old version
 $(warning			You are using an old and unsupported gcc \
 					 version ($(CC_SHORTVER)), compile at your own risk!)
 	
 endif			# CC_SHORTVER, 2.9x
 endif			# CC_SHORTVER, 3.0
 endif			# CC_SHORTVER, 3.4
e0931fb0
 endif			# CC_SHORTVER, 4.x
871a6a07
 	
 else		# CC_NAME, gcc
 				#other compilers
 $(error 			Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
 endif		#CC_NAME, gcc
 endif	#ARCH, ppc 
 
 #if  ppc64
 ifeq	($(ARCH), ppc64)
 		# if gcc 
 ifeq		($(CC_NAME), gcc)
d307929c
 				DEFS+=-DCC_GCC_LIKE_ASM
871a6a07
 				#common stuff
c8907870
 				CFLAGS= -O9 -funroll-loops $(PROFILE)
e0931fb0
 ifeq			($(CC_SHORTVER), 4.x)
 					CPU ?= powerpc64
f373f141
 					CFLAGS+=-ftree-vectorize \
e0931fb0
 							-mtune=$(CPU) -maltivec
 else
871a6a07
 			#if gcc 3.4+
 ifeq			($(CC_SHORTVER), 3.4)
 					CFLAGS+=
 else
 			#if gcc 3.0
 ifeq			($(CC_SHORTVER), 3.0)
 					CFLAGS+=
 else
 ifeq			($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
 $(warning 			Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
 					for better results)
 					CFLAGS+=
 else
 				#really old version
 $(warning			You are using an old and unsupported gcc \
 					 version ($(CC_SHORTVER)), compile at your own risk!)
 	
 endif			# CC_SHORTVER, 2.9x
 endif			# CC_SHORTVER, 3.0
 endif			# CC_SHORTVER, 3.4
e0931fb0
 endif			# CC_SHORTVER, 4.x
871a6a07
 	
 else		# CC_NAME, gcc
 				#other compilers
 $(error 			Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
 endif		#CC_NAME, gcc
 endif	#ARCH, ppc 
 
c8907870
 CFLAGS+= $(CC_EXTRA_OPTS)
1f2c924e
 
11ece359
 
 # setting LDFLAGS
51eadd0c
 ifeq	($(CC_NAME), gcc)
473f6f2e
 ifeq		($(LDTYPE), solaris)
 		# solaris ld
 		LDFLAGS+=-O2 $(PROFILE)
c853f68a
 		MOD_LDFLAGS:=-G $(LDFLAGS)
 		LIB_LDFLAGS:=-G $(LDFLAGS)
 		LIB_SONAME=-Wl,-h,
 		LD_RPATH=-Wl,-R,
473f6f2e
 else		
 		#gcc and maybe others, => gnu ld
 		LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE) 
c853f68a
 		MOD_LDFLAGS:=-shared $(LDFLAGS)
 		LIB_LDFLAGS:=-shared $(LDFLAGS)
 		LIB_SONAME=-Wl,-soname,
 		LD_RPATH=-Wl,-rpath,
629fca1e
 endif
51eadd0c
 endif
9c61e9f9
 ifeq	($(CC_NAME), icc)
 	#gcc and maybe others
 	LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE) 
c853f68a
 	MOD_LDFLAGS:=-shared $(LDFLAGS)
 	LIB_LDFLAGS:=-shared $(LDFLAGS)
 	LIB_SONAME=-Wl,-soname,
 	LD_RPATH=-Wl,-rpath,
9c61e9f9
 endif
51eadd0c
 ifeq	($(CC_NAME), suncc)
c853f68a
 	# -dy?
51eadd0c
 	LDFLAGS+=-xO5 $(PROFILE)
c853f68a
 	MOD_LDFLAGS:=-G $(LDFLAGS)
 	LIB_LDFLAGS:=-G $(LDFLAGS)
 	LIB_SONAME="-h "
 	LD_RPATH=-"-R "
51eadd0c
 endif
247c2b65
 	# we need -fPIC -DPIC only for shared objects, we don't need them for
 	# the executable file, because it's always loaded at a fixed address
 	# -andrei
11ece359
 else	#mode,release
51eadd0c
 ifeq	($(CC_NAME), gcc)
e61f4ba3
 		CFLAGS=-g -Wcast-align $(PROFILE)
dcb59e67
 		DEFS+=-DCC_GCC_LIKE_ASM
85f1f3ee
 ifeq		($(ARCH), sparc64)
d307929c
 			DEFS+=SPARC64_MODE
 			CFLAGS+= -mcpu=ultrasparc -m64
 			LDFLAGS+=-m64
629fca1e
 endif
 ifeq		($(LDTYPE), solaris)
 			#solaris ld
 			LDFLAGS+=-g $(PROFILE)
c853f68a
 			MOD_LDFLAGS:=-G $(LDFLAGS)
 			LIB_LDFLAGS:=-G $(LDFLAGS)
 			LIB_SONAME=-Wl,-h,
 			LD_RPATH=-Wl,-R,
629fca1e
 else
 			#gnu or other ld type
 			LDFLAGS+=-g -Wl,-E $(PROFILE)
c853f68a
 			MOD_LDFLAGS:=-shared $(LDFLAGS)
 			LIB_LDFLAGS:=-shared $(LDFLAGS)
 			LIB_SONAME=-Wl,-soname,
 			LD_RPATH=-Wl,-rpath,
629fca1e
 endif
51eadd0c
 endif
9c61e9f9
 ifeq	($(CC_NAME), icc)
dcb59e67
 		DEFS+=-DCC_GCC_LIKE_ASM
9c61e9f9
 		CFLAGS=-g  $(PROFILE)
 		LDFLAGS+=-g -Wl,-E $(PROFILE)
c853f68a
 		MOD_LDFLAGS:=-shared $(LDFLAGS)
 		LIB_LDFLAGS:=-shared $(LDFLAGS)
 		LIB_SONAME=-Wl,-soname,
 		LD_RPATH=-Wl,-rpath,
9c61e9f9
 endif
51eadd0c
 ifeq	($(CC_NAME), suncc)
 		CFLAGS= -g $(PROFILE)
 		LDFLAGS+=-g $(PROFILE)
c853f68a
 		MOD_LDFLAGS:=-G $(LDFLAGS)
 		LIB_LDFLAGS:=-G $(LDFLAGS)
 		LIB_SONAME="-h "
 		LD_RPATH=-"-R "
51eadd0c
 endif
 
11ece359
 endif #mode=release
 
c8907870
 
 # set pedantic compiler options
 ifeq ($(CC_NAME), gcc)
 		CFLAGS+= -Wall
 else # no gcc
 ifeq ($(CC_NAME), icc)
 		CFLAGS+= -Wall
 else # no icc
 ifeq ($(CC_NAME), suncc)
 		# FIXME: is the default (-Xa ?) enough?
 endif # CC_NAME=suncc
 endif # CC_NAME=icc
 endif # CC_NAME=gcc
 
247c2b65
 #*FLAGS used for compiling the modules
51eadd0c
 ifeq	($(CC_NAME), gcc)
7742b1d2
 MOD_CFLAGS=-fPIC -DPIC $(CFLAGS)
 LIB_CFLAGS=-fPIC -DPIC $(CFLAGS)
51eadd0c
 endif
9c61e9f9
 ifeq	($(CC_NAME), icc)
7742b1d2
 MOD_CFLAGS=-Kpic $(CFLAGS)
 LIB_CFLAGS=-Kpic $(CFLAGS)
9c61e9f9
 endif
51eadd0c
 ifeq	($(CC_NAME), suncc)
c853f68a
 # FIMXE: use -KPIC instead -xcode ?
7742b1d2
 MOD_CFLAGS=-xcode=pic32  $(CFLAGS)
 LIB_CFLAGS=-xcode=pic32  $(CFLAGS)
51eadd0c
 endif
247c2b65
 
054cb6cf
 ifeq ($(LEX),)
 	LEX=flex
 endif
 ifeq ($(YACC),)
 	YACC=bison
 endif
247c2b65
 YACC_FLAGS=-d -b cfg
 # on solaris add -lxnet (e.g. LIBS= -lxnet)
34285950
 LIBS= -ldl -lresolv
3922c022
 LIB_PREFIX:=lib
 LIB_SUFFIX:=.so
247c2b65
 
 
11ece359
 #os specific stuff
aee4712e
 ifeq ($(OS), linux)
8b8fc486
 # by default use futexes if available
 	use_futex= yes
b988daef
 	DEFS+=-DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
efa97d66
 			-DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H \
7eec6c23
 			-DHAVE_TIMEGM -DHAVE_SCHED_SETSCHEDULER
e0135488
 	ifneq ($(found_lock_method), yes)
8b8fc486
 		#DEFS+= -DUSE_POSIX_SEM
 		DEFS+=-DUSE_PTHREAD_MUTEX
 		LIBS+= -lpthread
 		#DEFS+= -DUSE_SYSV_SEM  # try posix sems
e0135488
 		found_lock_method=yes
32f700f3
 	else
 		ifneq (,$(findstring -DUSE_POSIX_SEM, $(DEFS)))
 			LIBS+=-lpthread
 		endif
d5b4d882
 		ifneq (,$(findstring -DUSE_PTHREAD_MUTEX, $(DEFS)))
 			LIBS+=-lpthread
 		endif
e0135488
 	endif
741a9937
 	# check for >= 2.5.44
 	ifeq ($(shell [ $(OSREL_N) -ge 2005044 ] && echo has_epoll), has_epoll)
0ba367ec
 		ifeq ($(NO_EPOLL),)
 			DEFS+=-DHAVE_EPOLL
a31a6e8c
 			# linux + gcc >= 3.0 + -malign-double + epoll => problems
7742b1d2
 			CFLAGS_RM+=-malign-double
 			#CFLAGS:=$(filter-out -malign-double, $(CFLAGS))
0ba367ec
 		endif
 	endif
741a9937
 	# check for >= 2.2.0
 	ifeq ($(shell [ $(OSREL_N) -ge 2002000 ] && echo has_sigio), has_sigio)
 		ifeq ($(NO_SIGIO),)
19db15d7
 			DEFS+=-DHAVE_SIGIO_RT -DSIGINFO64_WORKARROUND
741a9937
 		endif
0ba367ec
 	endif
8b8fc486
 	# check for >= 2.5.70
 	ifeq ($(shell [ $(OSREL_N) -ge 2005070 ] && echo has_futex), has_futex)
 		ifeq ($(use_futex), yes)
 			DEFS+=-DUSE_FUTEX
 		endif
 	endif
0ba367ec
 	ifeq ($(NO_SELECT),)
 		DEFS+=-DHAVE_SELECT
 	endif
ed990c31
 	# sctp support
 	ifeq ($(SCTP),1)
 		# test to see if the devfiles and lib are installed
 		sctp_dev_locations := /usr/include/netinet/sctp.h \
 								$(LOCALBASE)/include/netinet/sctp.h
 		sctp_lib_locations := /usr/lib/libsctp.so \
 								$(LOCALBASE)/usr/local/lib/libsctp.so
 		sctp_dev_path := $(wildcard $(sctp_dev_locations))
 		sctp_lib_path := $(wildcard $(sctp_lib_locations))
 		ifeq ($(sctp_dev_path),)
df67d63e
 $(info "sctp development files not installed -- sctp disabled")
ed990c31
 			override SCTP := 
 		endif
 		ifeq ($(sctp_lib_path),)
df67d63e
 $(info "sctp libraries not installed -- sctp disabled")
ed990c31
 			override SCTP := 
 		endif
 		
 		ifeq ($(SCTP),1)
 			# use lksctp
 			DEFS+=-DUSE_SCTP
 			LIBS+=-lsctp
 		endif
 	endif # SCTP
247c2b65
 endif
11ece359
 
0bafb279
 ifeq  ($(OS), solaris)
8d0543b9
 	DEFS+= -DHAVE_GETIPNODEBYNAME -DHAVE_SYS_SOCKIO_H -DHAVE_SCHED_YIELD \
02dae965
 			-DHAVE_ALLOCA_H -DUSE_SIGACTION
e0135488
 	ifneq ($(found_lock_method), yes)
 		DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
 		found_lock_method=yes
 	endif
9eda5956
 	# check for ver >= 5.7
 	ifeq ($(shell [ $(OSREL_N) -gt 5007 ] && echo has_devpoll), has_devpoll)
 		ifeq ($(NO_DEVPOLL),)
 			DEFS+=-DHAVE_DEVPOLL
 		endif
 	endif
0ba367ec
 	ifeq ($(NO_SELECT),)
 		DEFS+=-DHAVE_SELECT
 	endif
7c0265cc
 	ifeq ($(mode), release)
687e82fe
 		#use these only if you're using gcc with Solaris ld
db829953
 		#LDFLAGS=-O2 $(PROFILE)
 		#MOD_LDFLAGS=-O2 -G
7c0265cc
 	else
db829953
 		#LDFLAGS=-g $(PROFILE)
 		#MOD_LDFLAGS=-g -G
7c0265cc
 	endif
11ece359
 	YACC=yacc
51eadd0c
 
 ifeq ($(CC_NAME), suncc)
169b99f8
 	LIBS= -lfast -ldl -lresolv
51eadd0c
 endif
4168f707
 	OLD_SOLARIS= $(shell echo "$(OSREL)" | \
 				sed -e 's/^5\.[0-6][^0-9]*$$/yes/' )
34285950
 	LIBS+= -L$(LOCALBASE)/lib -lxnet -lnsl 
4168f707
 ifeq	($(OLD_SOLARIS), yes)
 		LIBS+=-lposix4
 else
 		LIBS+=-lrt
 endif
51eadd0c
 	# -lrt needed for sched_yield
247c2b65
 endif
11ece359
 
0bafb279
 ifeq ($(OS), freebsd)
85f1f3ee
 	DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
efa97d66
 		-DHAVE_SCHED_YIELD -DHAVE_MSGHDR_MSG_CONTROL \
a7380699
 		-DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
 		-DHAVE_NETINET_IN_SYSTM
e0135488
 	ifneq ($(found_lock_method), yes)
 		DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
 		found_lock_method=yes
32f700f3
 		LIBS+= -pthread   #dlopen is in libc
4e018310
 	else
34285950
 		LIBS=   #dlopen is in libc
e0135488
 	endif
741a9937
 	# check for ver >= 4.1
 	ifeq ($(shell [ $(OSREL_N) -gt 4001 ] && echo has_kqueue), has_kqueue)
 		ifeq ($(NO_KQUEUE),)
 			DEFS+=-DHAVE_KQUEUE
 		endif
 	endif
0ba367ec
 	ifeq ($(NO_SELECT),)
 		DEFS+=-DHAVE_SELECT
 	endif
11ece359
 	YACC=yacc
df67d63e
 	# sctp support
 	ifeq ($(SCTP),1)
 		# test to see if the devfiles and lib are installed
 		sctp_dev_locations := /usr/include/netinet/sctp.h \
 								$(LOCALBASE)/include/netinet/sctp.h
 		sctp_dev_path := $(wildcard $(sctp_dev_locations))
 		ifeq ($(sctp_dev_path),)
 $(info "sctp development files not installed -- sctp disabled")
 			override SCTP := 
 		endif
 		ifeq ($(shell [ $(OSREL_N) -lt 7000 ] && echo sctp), sctp)
 $(info "old freebsd version (>= 7.0 needed) -- sctp disabled")
 			override SCTP := 
 		endif
 		
 		ifeq ($(SCTP),1)
 			DEFS+=-DUSE_SCTP
 			LIBS+=  # no extra libs needed on freebsd
 		endif
 	endif # SCTP
087d0976
 endif
247c2b65
 
087d0976
 ifeq ($(OS), openbsd)
cf98659b
 	DEFS+=-DHAVE_SOCKADDR_SA_LEN  -DHAVE_GETHOSTBYNAME2 \
efa97d66
 		-DHAVE_UNION_SEMUN -DHAVE_MSGHDR_MSG_CONTROL \
000f4d33
 		-DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
 		-DHAVE_NETINET_IN_SYSTM -DUSE_SIGWAIT
e0135488
 	ifneq ($(found_lock_method), yes)
 		DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
 		found_lock_method=yes
 	endif
8386f8d7
 	# check for ver >=2 9
 	ifeq ($(shell [ $(OSREL_N) -ge 2009 ] && echo has_kqueue), has_kqueue)
741a9937
 		ifeq ($(NO_KQUEUE),)
 			DEFS+=-DHAVE_KQUEUE
 		endif
 	endif
0ba367ec
 	ifeq ($(NO_SELECT),)
 		DEFS+=-DHAVE_SELECT
 	endif
e61f4ba3
 	# (symbols on openbsd are prefixed by "_")
087d0976
 	YACC=yacc
e61f4ba3
 	# no sched_yield on openbsd unless linking with c_r (not recommended)
000f4d33
 	# unfortunately pthread is needed for sigwait
34285950
 	LIBS= -lpthread
cf98659b
 	OPENBSD_IS_AOUT= $(shell echo "$(OSREL)" | \
 				sed -e 's/^3\.[0-3][^0-9]*$$/yes/' |sed -e 's/^[0-2]\..*/yes/')
245b8b93
 # exception: on sparc openbsd 3.2 is elf and not aout
 ifeq ($(OSREL), 3.2)
 ifeq	($(ARCH), sparc)
 		OPENBSD_IS_AOUT:=no
 endif
 ifeq	($(ARCH), sparc64)
 		OPENBSD_IS_AOUT:=no
 endif
 endif
cf98659b
 	
 ifeq ($(OPENBSD_IS_AOUT), yes)
 		DEFS+=-DDLSYM_PREFIX='"_"'
 		LDFLAGS=        # openbsd ld doesn't like -O2 or -E
247c2b65
 endif
cf98659b
 endif   # if opensd
087d0976
 	
9627d1fc
 ifeq ($(OS), netbsd)
6c6659cb
 	DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 \
efa97d66
 		-DHAVE_MSGHDR_MSG_CONTROL -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM
e0135488
 	ifneq ($(found_lock_method), yes)
 		DEFS+= -DUSE_SYSV_SEM  # try pthread sems
 		found_lock_method=yes
 	endif
741a9937
 	# check for ver >= 2.0.0
 	ifeq ($(shell [ $(OSREL_N) -ge 2000000 ] && echo has_kqueue), has_kqueue)
 		ifeq ($(NO_KQUEUE),)
 			DEFS+=-DHAVE_KQUEUE
2f2e593b
 			# netbsd + kqueue and -malign-double don't work
7742b1d2
 			CFLAGS_RM+=-malign-double
 			#CFLAGS:=$(filter-out -malign-double, $(CFLAGS))
741a9937
 		endif
 	endif
0ba367ec
 	ifeq ($(NO_SELECT),)
 		DEFS+=-DHAVE_SELECT
 	endif
9627d1fc
 	YACC=yacc
34285950
 	LIBS=  
9627d1fc
 endif
247c2b65
 
194b6a35
 # OS X support, same as freebsd
 ifeq ($(OS), darwin)
 	DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
 		-DHAVE_SCHED_YIELD -DHAVE_MSGHDR_MSG_CONTROL \
 		-DUSE_ANON_MMAP \
6c006f79
 		-DNDEBUG -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
 		-DUSE_SIGWAIT
194b6a35
 	# -DNDEBUG used to turn off assert (assert wants to call
 	# eprintf which doesn't seem to be defined in any shared lib
 	ifneq ($(found_lock_method), yes)
 		DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
 		found_lock_method=yes
e5076770
 		DEFS+= -DUSE_SYSV_SEM  # try sys v sems (pthread don't work for
 		                       # processes and unnamed posix sems are not
 		                       # supported)
194b6a35
 	endif
e5076770
 	LIBS= -lresolv  #dlopen is in libc
55d8155e
 	ifeq ($(NO_KQUEUE),)
 		DEFS+=-DHAVE_KQUEUE
 	endif
0ba367ec
 	ifeq ($(NO_SELECT),)
 		DEFS+=-DHAVE_SELECT
 	endif
194b6a35
 	LDFLAGS=        # darwin doesn't like -O2 or -E
f233d281
 	# the modules uses symbols from ser => either 
 	# -flat_namespace -undefined_suppress or -bundle_loader ../../$(MAIN_NAME)
 	MOD_LDFLAGS:= -bundle -flat_namespace -undefined suppress
c853f68a
 	LIB_LDFLAGS:= -dynamiclib
3922c022
 	LIB_SUFFIX:=.dylib
c853f68a
 	# on darwin soname should include the full path
 	# (it kind of combines rpath & soname)
 	LIB_SONAME=
 	# no equiv. for rpath on darwin
 	LD_RPATH=
194b6a35
 	YACC=yacc
 endif
 
03023127
 ifneq (,$(findstring cygwin, $(OS)))
 	# cygwin doesn't support IPV6 and doesn't support fd passing so no TCP
7742b1d2
 	#DEFS:=$(filter-out -DUSE_IPV6 -DUSE_TCP, $(DEFS))
 	DEFS_RM+=-DUSE_IPV6 -DUSE_TCP
03023127
 	DEFS+=-DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
 			-DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H \
 			-DHAVE_TIMEGM -DHAVE_SCHED_SETSCHEDULER
e0135488
 	ifneq ($(found_lock_method), yes)
03023127
 		DEFS+= -DUSE_POSIX_SEM
 		#DEFS+= -DUSE_SYSV_SEM  # try posix sems
 		# PTHREAD_MUTEX do not work for processes (try test/pthread_test.c)
 		#LIBS+= -lpthread
e0135488
 		found_lock_method=yes
03023127
 	else
 		ifneq (,$(findstring -DUSE_POSIX_SEM, $(DEFS)))
 			#LIBS+=-lpthread
 		endif
 		ifneq (,$(findstring -DUSE_PTHREAD_MUTEX, $(DEFS)))
 $(error PTHREAD_MUTEX do not work for processes on Windows/CYGWIN)
 		endif
 	endif
 	# check for >= 2.5.70
 	ifeq ($(NO_SELECT),)
 		DEFS+=-DHAVE_SELECT
e0135488
 	endif
 endif
 
f22b996b
 #add libssl if needed
6c53d41a
 ifeq ($(CORE_TLS), 1)
3543f7dc
 DEFS+= -I$(LOCALBASE)/ssl/include
6c53d41a
 LIBS+= -L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib -lssl -lcrypto \
 		$(TLS_EXTRA_LIBS)
 # NOTE: depending on the way in which libssl was compiled you might
 #       have to add -lz -lkrb5   (zlib and kerberos5).
 #       E.g.: make CORE_TLS=1 EXTRA_TLS_LIBS="-lz -lkrb5"
f22b996b
 endif
 
96227c65
 ifneq ($(STUN),)
 DEFS+= -I$(LOCALBASE)/ssl/include
 LIBS+= -L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib -lcrypto
 endif
 
e0135488
 ifneq ($(found_lock_method), yes)
 $(warning	No locking method found so far, trying SYS V sems)
 		DEFS+= -DUSE_SYSV_SEM  # try sys v sems
 		found_lock_method=yes
247c2b65
 endif
4ce32edc
 
 
7742b1d2
 endif # ifeq (,$(main_makefile))
 endif  # ifeq ($(makefile_defs), 1)
 
 # if incomplete or missing config.mak, or already exported vars, don't
 # try to export/re-export
 ifeq ($(makefile_defs),1) 
 ifneq ($(exported_vars),1)
 
 
 override exported_vars:=1
 export exported_vars
 
 # variable changeable only at configure time (once saved in config.mak they
 #  cannot be overwritten from environment or command line, unless make cfg
 #  is run)
 saved_fixed_vars:=	MAIN_NAME \
 		RELEASE OS ARCH \
 		DEFS DEFS_RM PROFILE CC LD MKDEP MKTAGS LDFLAGS INCLUDES \
 		MOD_LDFLAGS LIB_LDFLAGS LIB_SONAME LD_RPATH \
 		LIB_SUFFIX LIB_PREFIX \
 		LIBS \
 		LEX YACC YACC_FLAGS \
 		PREFIX LOCALBASE \
 		TAR \
 		INSTALL INSTALL_CFG INSTALL_BIN INSTALL_MODULES INSTALL_DOC \
 		INSTALL_MAN INSTALL_LIB INSTALL_TOUCH INSTALL_SHARE
 
 # variable changeable at compile time
 # extra: prefix DESTDIR BASEDIR basedirt
 saved_chg_vars:=\
 		CC_EXTRA_OPTS CPU CFLAGS_RM CFLAGS MOD_CFLAGS LIB_CFLAGS	\
 		BASEDIR basedir DESTDIR \
 		PREFIX prefix\
 		cfg_prefix cfg_dir bin_prefix bin_dir modules_prefix modules_dir \
 		doc_prefix doc_dir man_prefix man_dir ut_prefix ut_dir \
 		share_prefix share_dir lib_prefix lib_dir \
 		cfg_target lib_target modules_target
 
4ce32edc
 
c853f68a
 #export relevant variables to the sub-makes
7742b1d2
 export $(saved_fixed_vars)
 export $(saved_chg_vars)
 
 
 endif # ifneq ($(exported_vars),1)
 endif # ifeq ($(makefile_defs),1)