Makefile.defs
e0a6ffa6
 # $Id$
247c2b65
 #
 # makefile defs (CC, LD,a.s.o)
 #
 
 
 #version number
 VERSION = 0
 PATCHLEVEL = 8
9b47a45c
 SUBLEVEL = 7
db1b5017
 EXTRAVERSION = -6-ipv6
247c2b65
 
 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
b2dec9c6
 OS = $(shell uname -s)
 ARCH = $(shell uname -m |sed -e s/i.86/i386/ -e s/sun4u/sparc64/ )
247c2b65
 
db1b5017
 prefix = /usr/local
 cfg-prefix = $(prefix)
 bin-prefix = $(prefix)
 modules-prefix= $(prefix)
 doc-prefix = $(prefix)
6ac71d10
 man-prefix = $(prefix)
db1b5017
 
 # dirs
 cfg-dir = etc/ser/
 bin-dir = sbin/
 modules-dir = lib/ser/modules/
6ac71d10
 doc-dir = share/doc/ser/
 man-dir = share/man/
db1b5017
 
a18366db
 INSTALL = install 
db1b5017
 INSTALL-CFG = $(INSTALL) -m 644
 INSTALL-BIN = $(INSTALL) -m 755
 INSTALL-MODULES = $(INSTALL) -m 755
 INSTALL-DOC = $(INSTALL) -m 644
6ac71d10
 INSTALL-MAN = $(INSTALL) -m 644
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)
40a8d9dd
 # -DNOISY_REPLIES
 #		turns on appending User-agent and Content-length:0 to ser-generated
 #		replies; 
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)
40a8d9dd
 # -DWAIT
 #		protection against race condiditions; turn off only for debugging;
 #       to become non-optional if stable
 # -DNEW_HNAME
b25c055d
 #		32-bit header name parsing; turn off for lower speed ;-) or debugging;
 #		to become non-optional if fast and stable
9b47a45c
 # -SILENT_FR
b25c055d
 #		if defined, when FR timer hits (in tm) cancel is sent only if forking
 #		if used; otherwise, just delete the transaction without doing anything
dda9dab1
 
404073d3
 DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
b2dec9c6
 	 -DOS='"$(OS)"' -DCOMPILER='"$(CC_VER)"'\
9b47a45c
 	 -DPKG_MALLOC \
51eadd0c
 	 -DSHM_MEM  -DSHM_MMAP \
 	 -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 \
733a6458
 	 -DWAIT -DNEW_HNAME \
9b47a45c
 	 -DSILENT_FR \
 	 -DNOISY_REPLIES -DVERY_NOISY_REPLIES\
7ed9a751
 	 -DPINGTEL_TAG_HACK\
2ce1c316
 	 -DF_MALLOC \
006a62a3
  	 -DUSE_SYNONIM\
a18366db
 	 -DUSE_IPV6 \
1f377e97
 	 #-DNO_DEBUG \
db829953
 	 #-DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=0 \
 	 #-DNOSMP \
e3b42c42
 	 #-DEXTRA_DEBUG 
340bddb4
 	 #-DVQ_MALLOC  -DDBG_LOCK  #-DSTATS
b13ec1cd
 	 #-DDBG_QM_MALLOC 
247c2b65
 # -DUSE_SHM_MEM
b13ec1cd
 #-DSTATS 
247c2b65
 #-DNO_LOG
 
c4217e61
 
b2dec9c6
 
 #PROFILE=  -pg #set this if you want profiling
c64e586d
 #mode = debug
 mode = release
247c2b65
 
 # platform dependent settings
 
 
 #common
da3257c8
 CC=gcc
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| \
 				 sed -e 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/')
51eadd0c
 	MKDEP=$(CC) -MM $(DEFS)
11ece359
 	#transform gcc version into 2.9x or 3.0
65531ed9
 	CC_SHORTVER=$(shell echo $(CC_VER) | cut -d" " -f 2| \
11ece359
 				 sed -e 's/[^0-9]*-\(.*\)/\1/'| \
 				 sed -e 's/2\.9.*/2.9x/' -e 's/3\..\..*/3.0/')
51eadd0c
 endif
 
 ifneq (, $(findstring Sun, $(CC_LONGVER)))
 	CC_NAME=suncc
 	CC_SHORTVER=$(shell echo $(CC_LONGVER)|head -1| \
 					sed -e 's/.*\([0-9]\.[0-9]\).*/\1/g' )
 	CC_VER=$(CC) $(CC_SHORTVER)
 	MKDEP=$(CC) -xM1 $(DEFS)
 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)
 	MKDEP=$(CC) -MM $(DEFS)
 endif
 
 
51eadd0c
 ifeq (,$(CC_NAME))
 #not found
11ece359
 	CC_NAME=$(CC)
 	CC_SHORTVER=unknown
51eadd0c
 	CC_VER=unknown
 	MKDEP=gcc -MM $(DEFS)
9c61e9f9
 $(warning	Unknown compiler $(CC)\; supported compilers: \
 			gcc, sun cc, intel icc )
11ece359
 endif
 
 
43fcad56
 # arh. specific definitions
 ifeq ($(ARCH), i386)
 	DEFS+= -DFAST_LOCK
 endif
 
 ifeq ($(ARCH), sparc64)
 ifeq 	($(CC_NAME), gcc)
 		DEFS+= -DFAST_LOCK
 endif
 endif
 
733a6458
 ifeq ($(ARCH), armv4l)
 	DEFS+= -DFAST_LOCK
 endif
 
 
43fcad56
 
11ece359
 # setting CFLAGS
247c2b65
 ifeq ($(mode), release)
11ece359
 	#if i386
 ifeq	($(ARCH), i386)
 		# if gcc 
 ifeq		($(CC_NAME), gcc)
51eadd0c
 				#common stuff
 				CFLAGS=-O9 -funroll-loops  -Wcast-align $(PROFILE) -Winline\
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])
 $(warning 			Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
 					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
 
 
 	#if sparc64
 ifeq	($(ARCH), sparc64)
 			#if gcc
 ifeq		($(CC_NAME), gcc)
51eadd0c
 				#common stuff
 				CFLAGS=-O9 -funroll-loops  -Wcast-align $(PROFILE) -Winline\
9b47a45c
 					#-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])
 $(warning 			Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
 					for better results)
 					
 					CFLAGS+= -mv8 -Wa,-xarch=v8plus
 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!)
 					
 					CFLAGS+= -mv8 -Wa,-xarch=v8plus
 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
 endif	#ARCH, sparc64
 
8c141481
 	#if ipaq/netwinder
 ifeq	($(ARCH), armv4l)
 		# if gcc 
 ifeq		($(CC_NAME), gcc)
 				#common stuff
 				CFLAGS=-O9 -funroll-loops  -Wcast-align $(PROFILE) -Winline\
 					-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
 
 
 # setting LDFLAGS
51eadd0c
 ifeq	($(CC_NAME), gcc)
 	#gcc and maybe others
db829953
 	LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE) 
51eadd0c
 endif
9c61e9f9
 ifeq	($(CC_NAME), icc)
 	#gcc and maybe others
 	LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE) 
 endif
51eadd0c
 ifeq	($(CC_NAME), suncc)
 	LDFLAGS+=-xO5 $(PROFILE)
 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)
9b47a45c
 		CFLAGS=-g -Wcast-align -Winline $(PROFILE)
51eadd0c
 		LDFLAGS+=-g -Wl,-E $(PROFILE)
 endif
9c61e9f9
 ifeq	($(CC_NAME), icc)
 		CFLAGS=-g  $(PROFILE)
 		LDFLAGS+=-g -Wl,-E $(PROFILE)
 endif
51eadd0c
 ifeq	($(CC_NAME), suncc)
 		CFLAGS= -g $(PROFILE)
 		LDFLAGS+=-g $(PROFILE)
 endif
 
11ece359
 endif #mode=release
 
247c2b65
 
 #*FLAGS used for compiling the modules
51eadd0c
 ifeq	($(CC_NAME), gcc)
247c2b65
 MOD_CFLAGS=-fPIC -DPIC $(CFLAGS)
7c0265cc
 MOD_LDFLAGS=-shared $(LDFLAGS)
51eadd0c
 endif
9c61e9f9
 ifeq	($(CC_NAME), icc)
 MOD_CFLAGS=-Kpic $(CFLAGS)
 MOD_LDFLAGS=-shared $(LDFLAGS)
 endif
51eadd0c
 ifeq	($(CC_NAME), suncc)
 MOD_CFLAGS=-Kpic  $(CFLAGS)
 MOD_LDFLAGS=-G $(LDFLAGS)
 endif
247c2b65
 
 LEX=flex
 YACC=bison
 YACC_FLAGS=-d -b cfg
 # on linux and freebsd keep it empty (e.g. LIBS= )
 # on solaris add -lxnet (e.g. LIBS= -lxnet)
 LIBS=-lfl -ldl
 
 
11ece359
 #os specific stuff
b2dec9c6
 ifeq ($(OS), Linux)
11ece359
 	#same as common
247c2b65
 endif
11ece359
 
b2dec9c6
 ifeq  ($(OS), SunOS)
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)
 	LIBS=-lfast
 endif
9b47a45c
 	LIBS+=-ldl -L/usr/local/lib -L/usr/lib/mysql -lfl -lxnet -lrt
51eadd0c
 	# -lrt needed for sched_yield
247c2b65
 endif
11ece359
 
b2dec9c6
 ifeq ($(OS), FreeBSD)
247c2b65
 
11ece359
 	YACC=yacc
 	LIBS= -lfl  #dlopen is in libc
247c2b65
 
 endif
 
11ece359
 ifneq (,$(findstring CYGWIN, $(OS)))
 	#cygwin is the same as common
247c2b65
 endif