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
 #  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)
4ce32edc
 
 
 # check if already included/exported
 
 ifeq ($(makefile_defs), 1)
 else
 makefile_defs=1
 export makefile_defs
247c2b65
 
194b6a35
 # main binary name
 MAIN_NAME=ser
247c2b65
 
 #version number
 VERSION = 0
4c70d009
 PATCHLEVEL = 10
194b6a35
 SUBLEVEL =   99
37209e14
 EXTRAVERSION = -dev45-dns_cache
247c2b65
 
21a3adb3
 SER_VER = $(shell expr $(VERSION) \* 1000000 + $(PATCHLEVEL) \* 1000 + \
 			$(SUBLEVEL) )
247c2b65
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
0bafb279
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
473f6f2e
 
 ifeq ($(OS),solaris)
 	GETARCH=uname -p
 else
 	GETARCH=uname -m
 endif
 
 ARCH := $(shell $(GETARCH) |sed -e s/i.86/i386/ -e s/sun4u/sparc64/  \
0db44da7
 			-e s/armv[3-5].*/arm/  -e s/armv6.*/arm6/ \
 			-e "s/Power Macintosh/ppc/" \
473f6f2e
 			-e "s/cobalt/mips2/" \
350ffd02
 			-e s/amd64/x86_64/ )
473f6f2e
 # fix sparc -> sparc64
 ifeq ($(ARCH),sparc)
 	ifeq ($(shell uname -m),sun4u)
 		ARCH := sparc64
 	endif
 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
 
f22b996b
 # TLS support
06aaa54f
 TLS ?= 
346c7dab
 ifneq ($(TLS),)
 	RELEASE:=$(RELEASE)-tls
 endif
1f2c924e
 # extra CC command line options (e.g  -march=athlon-mp)
 CC_EXTRA_OPTS ?=
db1b5017
 
3543f7dc
 # dirs 
db1b5017
 cfg-dir = etc/ser/
 bin-dir = sbin/
 modules-dir = lib/ser/modules/
aee4712e
 ifeq ($(OS), linux)
 	doc-dir = share/doc/ser/
 	man-dir = share/man/
3543f7dc
 	LOCALBASE ?= /usr/local
aee4712e
 else
a2786e3e
 ifeq ($(OS), freebsd)
 	doc-dir = share/doc/ser/
 	man-dir = man/
3543f7dc
 	LOCALBASE ?= /usr/local
a2786e3e
 else
f42e8993
 ifeq ($(OS), openbsd)
 	doc-dir = share/doc/ser/
 	man-dir = man/
3543f7dc
 	LOCALBASE ?= /usr/local
f42e8993
 else
 ifeq ($(OS), netbsd)
 	doc-dir = share/doc/ser
 	man-dir = man/
3543f7dc
 	LOCALBASE ?= /usr/pkg
f42e8993
 else
194b6a35
 ifeq ($(OS), darwin)
 	doc-dir = share/doc/ser/
 	man-dir = man/
3543f7dc
 	LOCALBASE ?= /usr/local
194b6a35
 else
f42e8993
 	doc-dir = doc/ser/
 	man-dir = man/
3543f7dc
 	LOCALBASE ?= /usr/local
f42e8993
 endif
 endif
aee4712e
 endif
a2786e3e
 endif
194b6a35
 endif
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
 cfg-prefix = $(basedir)$(prefix)
 bin-prefix = $(basedir)$(prefix)
 modules-prefix = $(basedir)$(prefix)
 doc-prefix = $(basedir)$(prefix)
 man-prefix = $(basedir)$(prefix)
 ut-prefix = $(basedir)$(prefix)
 
 
054cb6cf
 # target dirs for various stuff
 cfg-target = $(prefix)/$(cfg-dir)
c3e5dd3e
 bin-target = $(prefix)/$(bin-dir)
054cb6cf
 modules-target = $(prefix)/$(modules-dir)
c3e5dd3e
 doc-target = $(prefix)/$(doc-dir)
db1b5017
 
0bafb279
 
 ifeq ($(OS), solaris)
 #use GNU versions
5b9b8d2e
 INSTALL ?= ginstall
 TAR ?= gtar
0bafb279
 else
5b9b8d2e
 INSTALL ?= install 
 TAR ?= tar
0bafb279
 endif
054cb6cf
 
15dde484
 INSTALL-TOUCH = touch          # used to create the file first (good to 
                                #  make solaris install work)
b5a32e1a
 INSTALL-CFG = $(INSTALL) -m 644
db1b5017
 INSTALL-BIN = $(INSTALL) -m 755
 INSTALL-MODULES = $(INSTALL) -m 755
 INSTALL-DOC = $(INSTALL) -m 644
6ac71d10
 INSTALL-MAN = $(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/')
176e7a13
 	# sun sed is a little brain damaged => this complicated expression
 	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
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)
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
 #		compiles in tls support, requires -DUSE_TCP. Please use
 #		make TLS=1 instead. (tls support is highly experimental for now)
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
 # -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)
a6c0b4ba
 
bc404f2b
 # Sometimes is needes correct non-quoted $OS. HACK: gcc translates known OS to number ('linux'), so there is added underscore
96dd9e9f
 
3dae72a3
 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) \
054cb6cf
 	 -DCFG_DIR='"$(cfg-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 \
dca4cad0
 	 -DDBG_QM_MALLOC \
dcb59e67
 	 -DUSE_DNS_CACHE \
 	 -DUSE_DNS_FAILOVER \
 	 -DUSE_DST_BLACKLIST \
09b2f164
 	 #-DF_MALLOC \
08bf96f2
 	 #-DDBG_F_MALLOC \
bfd94206
 	 #-DNO_DEBUG \
ca20b615
 	 #-DEXTRA_DEBUG \
08bf96f2
 	 #-DVQ_MALLOC  \
 	 #-DDBG_LOCK \
db829953
 	 #-DNOSMP \
e5bcdb99
 	 #-DUSE_SHM_MEM \
 	 #-DSTATS \
caf80ae6
 	 #-DNO_LOG
b2dec9c6
 
 #PROFILE=  -pg #set this if you want profiling
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
 
 ifneq ($(TLS),)
 	DEFS+= -DUSE_TLS
 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
 
43fcad56
 # arh. specific definitions
 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
 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
5b532c7f
 				CFLAGS=-g -O9 -funroll-loops  -Wcast-align $(PROFILE) \
88d3fa6d
 					-Wall  
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
 				CFLAGS=-g -O9 -funroll-loops  -Wcast-align $(PROFILE) \
88d3fa6d
 					-Wall 
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
 					-Wall\
 					#-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
 					CFLAGS+=-mcpu=ultrasparc -minline-all-stringops \
 							-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) \
 					-Wall\
 					#-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
0db44da7
 				CFLAGS=-O9 -funroll-loops $(PROFILE) \
88d3fa6d
 					-Wall   
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 \
 						$(PROFILE) -Wall   
 			#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
e960e1e6
 				CFLAGS=-O9 -funroll-loops  $(PROFILE) \
88d3fa6d
 					-Wall 
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
8ebe2904
 				CFLAGS= -mips2 -O9 -funroll-loops $(PROFILE) \
88d3fa6d
 					-Wall 
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
 				CFLAGS= -mips64 -O9 -funroll-loops $(PROFILE) \
 					-Wall 
 			#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
 				CFLAGS= -O9 -funroll-loops $(PROFILE)  -Wall 
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
 				CFLAGS= -O9 -funroll-loops $(PROFILE)  -Wall 
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
 				CFLAGS= -O9 -funroll-loops $(PROFILE)  -Wall 
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 
 
1f2c924e
 
11ece359
 
 # setting LDFLAGS
51eadd0c
 ifeq	($(CC_NAME), gcc)
473f6f2e
 ifeq		($(LDTYPE), solaris)
 		# solaris ld
 		LDFLAGS+=-O2 $(PROFILE)
 		MOD_LDFLAGS=-G $(LDFLAGS)
 else		
 		#gcc and maybe others, => gnu ld
 		LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE) 
 		MOD_LDFLAGS=-shared $(LDFLAGS)
629fca1e
 endif
51eadd0c
 endif
9c61e9f9
 ifeq	($(CC_NAME), icc)
 	#gcc and maybe others
 	LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE) 
629fca1e
 	MOD_LDFLAGS=-shared $(LDFLAGS)
9c61e9f9
 endif
51eadd0c
 ifeq	($(CC_NAME), suncc)
 	LDFLAGS+=-xO5 $(PROFILE)
629fca1e
 	MOD_LDFLAGS=-G $(LDFLAGS)
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)
 			MOD_LDFLAGS=-G $(LDFLAGS)
 else
 			#gnu or other ld type
 			LDFLAGS+=-g -Wl,-E $(PROFILE)
 			MOD_LDFLAGS=-shared $(LDFLAGS)
 endif
51eadd0c
 endif
9c61e9f9
 ifeq	($(CC_NAME), icc)
dcb59e67
 		DEFS+=-DCC_GCC_LIKE_ASM
9c61e9f9
 		CFLAGS=-g  $(PROFILE)
 		LDFLAGS+=-g -Wl,-E $(PROFILE)
629fca1e
 		MOD_LDFLAGS=-shared $(LDFLAGS)
9c61e9f9
 endif
51eadd0c
 ifeq	($(CC_NAME), suncc)
 		CFLAGS= -g $(PROFILE)
 		LDFLAGS+=-g $(PROFILE)
629fca1e
 		MOD_LDFLAGS=-G $(LDFLAGS)
51eadd0c
 endif
 
11ece359
 endif #mode=release
 
dcb59e67
 CFLAGS+= $(CC_EXTRA_OPTS)
247c2b65
 
 #*FLAGS used for compiling the modules
51eadd0c
 ifeq	($(CC_NAME), gcc)
247c2b65
 MOD_CFLAGS=-fPIC -DPIC $(CFLAGS)
51eadd0c
 endif
9c61e9f9
 ifeq	($(CC_NAME), icc)
 MOD_CFLAGS=-Kpic $(CFLAGS)
 endif
51eadd0c
 ifeq	($(CC_NAME), suncc)
6419a43f
 MOD_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
247c2b65
 
 
11ece359
 #os specific stuff
aee4712e
 ifeq ($(OS), linux)
b988daef
 	DEFS+=-DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
efa97d66
 			-DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H \
 			-DHAVE_TIMEGM
e0135488
 	ifneq ($(found_lock_method), yes)
 		DEFS+= -DUSE_SYSV_SEM  # try posix sems
 		found_lock_method=yes
 	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
 			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
 	ifeq ($(NO_SELECT),)
 		DEFS+=-DHAVE_SELECT
 	endif
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
34285950
 		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
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
 			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
34285950
 		LIBS= -pthread -lresolv  #dlopen is in libc
194b6a35
 	else
34285950
 		LIBS= -lresolv  #dlopen is in libc
194b6a35
 	endif
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
 	MOD_LDFLAGS= -bundle -bundle_loader ../../$(MAIN_NAME)
 	YACC=yacc
 endif
 
11ece359
 ifneq (,$(findstring CYGWIN, $(OS)))
 	#cygwin is the same as common
e0135488
 	ifneq ($(found_lock_method), yes)
 		DEFS+= -DUSE_SYSV_SEM  # try sys v sems
 		found_lock_method=yes
 	endif
 endif
 
f22b996b
 #add libssl if needed
 ifneq ($(TLS),)
3543f7dc
 DEFS+= -I$(LOCALBASE)/ssl/include
 LIBS+= -L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib -lssl  -lcrypto
f22b996b
 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
 
 
 
 
 
 endif  # ifeq ($(makefile_defs, 1)