Makefile.defs
e0a6ffa6
 # $Id$
247c2b65
 #
 # makefile defs (CC, LD,a.s.o)
 #
a2786e3e
 # History:
 # --------
 #              created by andrei
 #  2003-02-24  added LOCALBASE, fixed doc-dir for freebsd - patch provided
b33736bc
 #               by Maxim Sobolev <sobomax@FreeBSD.org>
 #  2003-02-25  added -DDISABLE_NAGLE
a6c0b4ba
 #  2003-03-02  added -DDIGEST_DOMAIN (janakj)
247c2b65
 
 
 #version number
 VERSION = 0
 PATCHLEVEL = 8
e833d08a
 SUBLEVEL =   11
ba98af46
 EXTRAVERSION = pre6-tcp10-lck
247c2b65
 
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
0bafb279
 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
85f1f3ee
 ARCH = $(shell uname -m |sed -e s/i.86/i386/ -e s/sun4u/sparc64/  \
087d0976
 			-e s/armv4l/arm/)
247c2b65
 
054cb6cf
  # install location
a2786e3e
 PREFIX ?= /usr/local
 LOCALBASE ?= /usr/local
054cb6cf
 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 = 
 # 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)
db1b5017
 
 # dirs
 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/
 else
a2786e3e
 ifeq ($(OS), freebsd)
 	doc-dir = share/doc/ser/
 	man-dir = man/
 else
aee4712e
 	doc-dir=doc/ser/
 	man-dir=man/
 endif
a2786e3e
 endif
054cb6cf
 ut-prefix = bin/
 # target dirs for various stuff
 cfg-target = $(prefix)/$(cfg-dir)
 modules-target = $(prefix)/$(modules-dir)
db1b5017
 
0bafb279
 
 ifeq ($(OS), solaris)
 #use GNU versions
 INSTALL = ginstall
 TAR = gtar
 else
a18366db
 INSTALL = install 
0bafb279
 TAR= tar
 endif
054cb6cf
 
 # 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
 
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
 #		uses busy waiting on the lock
 # -DADAPTIVE_WAIT
 #		try busy waiting for a while and if the lock is still held go to
 #		force reschedule
 # -DADAPTIVE_WAIT_LOOPS=number
 #		number of loops we busy wait, after "number" loops have elapsed we 
 #		force a reschedule
 # -DNOSMP
 #		don't use smp compliant locking (faster but won't work on SMP machines)
 #		(not yet enabled)
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
40ea70f4
 # -DWITH_SNMP_MOD
 #  		if enabled, allows forking of the snmp agent just before child
 #  		forking (done at the top of main_loop). Needed if you want
 #  		to use the snmp module.
5b532c7f
 # -DUSE_TCP
 #		compiles in tcp support (highly experimental for now, it will probably
 #		not work, use it only if you really now what you are doing)
b33736bc
 # -DDISABLE_NAGLE
 #		disable the tcp Nagle algorithm (lower delay)
96dd9e9f
 # -DVOICE_MAIL
 #               enables voicemail support in ser core and in tm module
 #               voicemail needs also -D_TOTAG
a6c0b4ba
 #
 # -DDIGEST_DOMAIN
 #               enables further parsing of digest username. Some clients put @domain
 #               in username digest parameter because realm parameter is not protected
 #               by the digest. This hasn't been standardized, but several user agents
 #               use this.
 
96dd9e9f
 
2510051e
 DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
087d0976
 	 -DOS='"$(OS)"' -DCOMPILER='"$(CC_VER)"' -D__CPU_$(ARCH)\
054cb6cf
 	 -DCFG_DIR='"$(cfg-target)"'\
9b47a45c
 	 -DPKG_MALLOC \
51eadd0c
 	 -DSHM_MEM  -DSHM_MMAP \
 	 -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 \
ba506d03
 	 -DDNS_IP_HACK \
a18366db
 	 -DUSE_IPV6 \
8aeb47e2
 	 -DUSE_TCP \
b33736bc
 	 -DDISABLE_NAGLE \
a6c0b4ba
 	 -DDIGEST_DOMAIN \
b33736bc
 	 -DDBG_QM_MALLOC \
09b2f164
 	 #-DF_MALLOC \
bfd94206
 	 #-DNO_DEBUG \
 	 #-DNO_LOG
ca20b615
 	 #-DEXTRA_DEBUG \
e5bcdb99
 	 #-DDBG_QM_MALLOC \
855c2e68
 	 #-DVQ_MALLOC  
caf80ae6
 	 #-DCONTACT_BUG
 	 #-DDBG_LOCK
db829953
 	 #-DNOSMP \
e5bcdb99
 	 #-DEXTRA_DEBUG \
 	 #-DUSE_SHM_MEM \
 	 #-DSTATS \
40ea70f4
 	 #-DWITH_SNMP_MOD \
caf80ae6
 	 #-DNO_LOG
b2dec9c6
 
 #PROFILE=  -pg #set this if you want profiling
fde02f64
 mode = debug
054cb6cf
 ifeq ($(mode),)
 	mode = release
 endif
247c2b65
 
 # platform dependent settings
 
 
 #common
054cb6cf
 ifeq ($(CC),)
 	CC=gcc
 endif
b2dec9c6
 LD= $(CC)
51eadd0c
 CC_LONGVER=$(shell if  $(CC) -v 2>/dev/null; then \
 						$(CC) -v 2>&1 ;\
 					else \
 						$(CC) -V 2>&1 ; \
 					fi )
3b06abf2
 MKTAGS=ctags -R .
247c2b65
 
11ece359
 #find-out the compiler's name
 
 ifneq (,$(findstring gcc, $(CC_LONGVER)))
 	CC_NAME=gcc
65531ed9
 	CC_VER=$(CC) $(shell $(CC) --version|head -1| \
6d244fb5
 				 sed -e 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/' -e 's/[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/')
 	# sun sed is a little brain damaged => this complicated expression
e61f4ba3
 	MKDEP=$(CC) -MM 
11ece359
 	#transform gcc version into 2.9x or 3.0
13623729
 	CC_SHORTVER=$(shell echo "$(CC_VER)" | cut -d" " -f 2| \
11ece359
 				 sed -e 's/[^0-9]*-\(.*\)/\1/'| \
13623729
 				 sed -e 's/2\.9.*/2.9x/' -e 's/3\..\..*/3.0/' -e \
 				 	's/3\../3.0/')
51eadd0c
 endif
 
 ifneq (, $(findstring Sun, $(CC_LONGVER)))
 	CC_NAME=suncc
13623729
 	CC_SHORTVER=$(shell echo "$(CC_LONGVER)"|head -1| \
51eadd0c
 					sed -e 's/.*\([0-9]\.[0-9]\).*/\1/g' )
 	CC_VER=$(CC) $(CC_SHORTVER)
e61f4ba3
 	MKDEP=$(CC) -xM1 
51eadd0c
 endif
 
9c61e9f9
 ifneq (, $(findstring Intel(R) C++ Compiler, $(CC_LONGVER)))
 	# very nice: gcc compatible
 	CC_NAME=icc
 	CC_FULLVER=$(shell echo "$(CC_LONGVER)"|head -1| \
 					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)
e61f4ba3
 	MKDEP=$(CC) -MM 
9c61e9f9
 endif
 
 
51eadd0c
 ifeq (,$(CC_NAME))
 #not found
11ece359
 	CC_NAME=$(CC)
 	CC_SHORTVER=unknown
51eadd0c
 	CC_VER=unknown
e61f4ba3
 	MKDEP=gcc -MM 
9c61e9f9
 $(warning	Unknown compiler $(CC)\; supported compilers: \
 			gcc, sun cc, intel icc )
11ece359
 endif
 
85f1f3ee
 # find ld & as name (gnu or solaris)
 ifeq ($(ARCH), sparc64)
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
 
85f1f3ee
 ifeq ($(ARCH), sparc64)
43fcad56
 ifeq 	($(CC_NAME), gcc)
e0135488
 	use_fast_lock=yes
43fcad56
 endif
 endif
 
087d0976
 ifeq ($(ARCH), arm)
e0135488
 	use_fast_lock=yes
733a6458
 endif
 
523768d2
 ifeq ($(ARCH), ppc)
e0135488
 	use_fast_lock=yes
 endif
 
 ifeq ($(use_fast_lock), yes)
523768d2
 	DEFS+= -DFAST_LOCK
e0135488
 	found_lock_method=yes
523768d2
 endif
 
054cb6cf
 CFLAGS=
11ece359
 # setting CFLAGS
247c2b65
 ifeq ($(mode), release)
11ece359
 	#if i386
 ifeq	($(ARCH), i386)
 		# if gcc 
 ifeq		($(CC_NAME), gcc)
51eadd0c
 				#common stuff
5b532c7f
 				CFLAGS=-g -O9 -funroll-loops  -Wcast-align $(PROFILE) \
a1e5c977
 					-Wall   \
11ece359
 			#if gcc 3.0
 ifeq			($(CC_SHORTVER), 3.0)
 					CFLAGS+=-minline-all-stringops -malign-double \
65531ed9
 							-falign-loops \
11ece359
 							-march=athlon \
 							#-mcpu=athlon
 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
 
 else		# CC_NAME, gcc
9c61e9f9
 ifeq		($(CC_NAME), icc)
 			CFLAGS=-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
11ece359
 				#other compilers
 $(error 			Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
9c61e9f9
 endif		#CC_NAME, icc
11ece359
 endif		#CC_NAME, gcc
 endif	#ARCH, i386
 
 
087d0976
 	#if sparc
85f1f3ee
 ifeq	($(ARCH), sparc64)
11ece359
 			#if gcc
 ifeq		($(CC_NAME), gcc)
51eadd0c
 				#common stuff
85f1f3ee
 				CFLAGS=-g -O9 -funroll-loops  $(PROFILE) \
462cf6f9
 					-Wall\
 					#-Wcast-align \
 					#-Wmissing-prototypes 
11ece359
 				#if gcc 3.0
 ifeq			($(CC_SHORTVER), 3.0)
 					#use 32bit for now
e7a9bd30
 					CFLAGS+= -mcpu=ultrasparc -mtune=ultrasparc  -m32  \
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
 						CFLAGS+= -mv8 
 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!)
 					
85f1f3ee
 					CFLAGS+= -mv8 
 ifeq					($(ASTYPE), solaris)
 							CFLAGS+= -Wa,-xarch=v8plus
 endif					
 	
11ece359
 endif			#CC_SHORTVER, 2.9x
 endif			#CC_SHORTVER, 3.0
 
 else		#CC_NAME, gcc
51eadd0c
 ifeq		($(CC_NAME), suncc)
 			CFLAGS+=-xO5 -fast -native -xarch=v8plusa -xCC \
 					-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
087d0976
 endif	#ARCH, sparc
11ece359
 
8c141481
 	#if ipaq/netwinder
087d0976
 ifeq	($(ARCH), arm)
8c141481
 		# if gcc 
 ifeq		($(CC_NAME), gcc)
 				#common stuff
e61f4ba3
 				CFLAGS=-O9 -funroll-loops  -Wcast-align $(PROFILE) \
8c141481
 					-Wall   \
 			#if gcc 3.0
 ifeq			($(CC_SHORTVER), 3.0)
 					CFLAGS+= -mcpu=strongarm1100
 							#-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
 
 else		# CC_NAME, gcc
 				#other compilers
 $(error 			Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
 endif		#CC_NAME, gcc
 endif	#ARCH, i386
 
 
 	
11ece359
 
054cb6cf
 LDFLAGS=
11ece359
 # setting LDFLAGS
51eadd0c
 ifeq	($(CC_NAME), gcc)
85f1f3ee
 ifeq		($(ARCH), sparc64)
629fca1e
 ifeq			($(LDTYPE), solaris)
 					# solaris ld
 					LDFLAGS+=-O2 $(PROFILE)
 					MOD_LDFLAGS=-G $(LDFLAGS)
 else			
 					#gcc and maybe others, on solaris, with gnu ld
 					LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE) 
 					MOD_LDFLAGS=-shared $(LDFLAGS)
 endif
 else
 			#gcc and maybe others
 			LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE) 
 			MOD_LDFLAGS=-shared $(LDFLAGS)
 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)
85f1f3ee
 ifeq		($(ARCH), sparc64)
629fca1e
 			CFLAGS+= -mcpu=ultrasparc 
 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)
 		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
 
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)
 MOD_CFLAGS=-Kpic  $(CFLAGS)
 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)
169b99f8
 LIBS= -lfl -ldl -lresolv
247c2b65
 
 
11ece359
 #os specific stuff
aee4712e
 ifeq ($(OS), linux)
b988daef
 	DEFS+=-DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
6c6659cb
 			-DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL
e0135488
 	ifneq ($(found_lock_method), yes)
 		DEFS+= -DUSE_SYSV_SEM  # try posix sems
 		found_lock_method=yes
 	endif
247c2b65
 endif
11ece359
 
0bafb279
 ifeq  ($(OS), solaris)
85f1f3ee
 	DEFS+= -DHAVE_GETIPNODEBYNAME -DHAVE_SYS_SOCKIO_H -DHAVE_SCHED_YIELD
e0135488
 	ifneq ($(found_lock_method), yes)
 		DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
 		found_lock_method=yes
 	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
247c2b65
 
11ece359
 	YACC=yacc
51eadd0c
 
 ifeq ($(CC_NAME), suncc)
169b99f8
 	LIBS= -lfast -ldl -lresolv
51eadd0c
 endif
f3f0a4de
 	LIBS+= -L/usr/local/lib -lfl -lxnet -lrt -lnsl 
51eadd0c
 	# -lrt needed for sched_yield
247c2b65
 endif
11ece359
 
0bafb279
 ifeq ($(OS), freebsd)
85f1f3ee
 	DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
6c6659cb
 		-DHAVE_SCHED_YIELD -DHAVE_MSGHDR_MSG_CONTROL
e0135488
 	ifneq ($(found_lock_method), yes)
 		DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
 		found_lock_method=yes
 	endif
11ece359
 	YACC=yacc
 	LIBS= -lfl  #dlopen is in libc
087d0976
 endif
247c2b65
 
087d0976
 ifeq ($(OS), openbsd)
9a694681
 	DEFS+=-DHAVE_SOCKADDR_SA_LEN -DDLSYM_PREFIX='"_"' -DHAVE_GETHOSTBYNAME2 \
6c6659cb
 		-DHAVE_UNION_SEMUN -DHAVE_MSGHDR_MSG_CONTROL
e0135488
 	ifneq ($(found_lock_method), yes)
 		DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
 		found_lock_method=yes
 	endif
e61f4ba3
 	# (symbols on openbsd are prefixed by "_")
087d0976
 	YACC=yacc
e61f4ba3
 	# no sched_yield on openbsd unless linking with c_r (not recommended)
 	LIBS= -lfl 
 	LDFLAGS=        # openbsd ld doesn't like -O2 or -E
247c2b65
 endif
087d0976
 	
9627d1fc
 ifeq ($(OS), netbsd)
6c6659cb
 	DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 \
 		-DHAVE_MSGHDR_MSG_CONTROL
e0135488
 	ifneq ($(found_lock_method), yes)
 		DEFS+= -DUSE_SYSV_SEM  # try pthread sems
 		found_lock_method=yes
 	endif
9627d1fc
 	YACC=yacc
85f1f3ee
 	LIBS= -lfl 
9627d1fc
 endif
247c2b65
 
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
 
 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