- fixed process_count() (forgot to add some() when I added tcp_disable)
[sip-router] / Makefile.defs
1 # $Id$
2 #
3 # makefile defs (CC, LD,a.s.o)
4 #
5 # Environment variables:
6 #   PREFIX, LOCALBASE, BASEDIR
7 #   INSTALL, TAR , CC, LEX, YACC,
8 #   CPU, CC_EXTRA_OPTS,
9 #   exclude_modules, skip_modules, include_modules
10 #
11 # History:
12 # --------
13 #              created by andrei
14 #  2003-02-24  added LOCALBASE, fixed doc-dir for freebsd - patch provided
15 #               by Maxim Sobolev <sobomax@FreeBSD.org>
16 #  2003-02-25  added -DDISABLE_NAGLE
17 #  2003-03-02  added -DDIGEST_DOMAIN (janakj)
18 #  2003-03-10  added -xcode=pic32 for module compilation w/ sun cc
19 #               (too many symbols for pic13)  (andrei)
20 #  2003-04-16  added CC_EXTRA_OPTS, s/march/mcpu, added CPU (cpu to optimize 
21 #               for, used only with gcc-3.x)
22
23
24 #version number
25 VERSION = 0
26 PATCHLEVEL = 8
27 SUBLEVEL =   11
28 EXTRAVERSION = pre21
29
30 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
31 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
32 ARCH = $(shell uname -m |sed -e s/i.86/i386/ -e s/sun4u/sparc64/  \
33                         -e s/armv4l/arm/)
34
35 # extra CC command line options (e.g  -march=athlon-mp)
36 CC_EXTRA_OPTS ?=
37  # install location
38 PREFIX ?= /usr/local
39 LOCALBASE ?= /usr/local
40 prefix = $(PREFIX)
41 # install path is $(basedir) $(prefix) 
42 # example:
43 #  creating a bin. archive in /tmp, which unpacks in /usr/local
44 #  basedir=/tmp
45 #  prefix=/usr/local
46
47 BASEDIR ?=
48 basedir = $(BASEDIR)
49 # install prefixes for various stuff
50 cfg-prefix = $(basedir)$(prefix)
51 bin-prefix = $(basedir)$(prefix)
52 modules-prefix = $(basedir)$(prefix)
53 doc-prefix = $(basedir)$(prefix)
54 man-prefix = $(basedir)$(prefix)
55 ut-prefix = $(basedir)$(prefix)
56
57 # dirs
58 cfg-dir = etc/ser/
59 bin-dir = sbin/
60 modules-dir = lib/ser/modules/
61 ifeq ($(OS), linux)
62         doc-dir = share/doc/ser/
63         man-dir = share/man/
64 else
65 ifeq ($(OS), freebsd)
66         doc-dir = share/doc/ser/
67         man-dir = man/
68 else
69         doc-dir=doc/ser/
70         man-dir=man/
71 endif
72 endif
73 ut-prefix = bin/
74 # target dirs for various stuff
75 cfg-target = $(prefix)/$(cfg-dir)
76 modules-target = $(prefix)/$(modules-dir)
77
78
79 ifeq ($(OS), solaris)
80 #use GNU versions
81 INSTALL ?= ginstall
82 TAR ?= gtar
83 else
84 INSTALL ?= install 
85 TAR ?= tar
86 endif
87
88 INSTALL-TOUCH = touch          # used to create the file first (good to 
89                                #  make solaris install work)
90 # INSTALL-CFG = $(INSTALL) -m 644
91 INSTALL-BIN = $(INSTALL) -m 755
92 INSTALL-MODULES = $(INSTALL) -m 755
93 INSTALL-DOC = $(INSTALL) -m 644
94 INSTALL-MAN = $(INSTALL) -m 644
95
96 #set some vars from the environment (and not make builtins)
97 CC   := $(shell echo "$${CC}")
98 LEX  := $(shell echo "$${LEX}")
99 YACC := $(shell echo "$${YACC}")
100
101
102
103
104 # compile-time options
105 #
106 # -DSTATS
107 #               allows to print out number of packets processed on CTRL-C;
108 #               implementation still nasty and reports per-process
109 # -DNO_DEBUG
110 #               turns off some of the debug messages (DBG(...)).
111 # -DNO_LOG
112 #               completely turns of all the logging (and DBG(...))
113 # -DEXTRA_DEBUG
114 #               compiles in some extra debugging code
115 # -DDNS_IP_HACK
116 #               faster ip address resolver for ip strings (e.g "127.0.0.1")
117 # -DSHM_MEM
118 #               compiles in shared mem. support, needed by some modules and
119 #               by USE_SHM_MEM
120 # -DSHM_MMAP
121 #               use mmap instead of SYSV shared memory
122 # -DPKG_MALLOC
123 #               uses a faster malloc (exclusive w/ USE_SHM_MEM)
124 # -DUSE_SHM_MEM
125 #               all pkg_malloc => shm_malloc (most mallocs use a common sh.
126 #               mem. segment); don't define PKG_MALLOC if you want this!
127 # -DDBG_QM_MALLOC
128 #               qm_malloc debug code, will cause pkg_malloc and shm_malloc
129 #               to keep and display lot of debuging information: file name,
130 #               function, line number of malloc/free call for each block,
131 #               extra error checking (trying to free the same pointer
132 #               twice, trying to free a pointer alloc'ed with a different
133 #               malloc etc.)
134 # -DVQ_MALLOC
135 #               additional option to PKG_MALLOC which utilizes a fater then
136 #               qm version
137 #               (not true anymore, q_malloc performs approx. the same)
138 # -DF_MALLOC
139 #               an even faster malloc, not recommended for debugging
140 # -DDBG_MALLOC
141 #               issues additional debugging information if lock/unlock is called
142 # -DFAST_LOCK
143 #               uses fast arhitecture specific locking (see the arh. specific section)
144 # -DUSE_SYSV_SEM
145 #               uses sys v sems for locking (slower & limited number)
146 # -DUSE_PTHREAD_MUTEX
147 #               uses pthread mutexes, faster than sys v or posix sems, but do not 
148 #               work on all systems inter-processes (e.g. linux)
149 # -DUSE_POSIX_SEM
150 #               uses posix semaphores for locking (faster than sys v)
151 # -DBUSY_WAIT
152 #               uses busy waiting on the lock
153 # -DADAPTIVE_WAIT
154 #               try busy waiting for a while and if the lock is still held go to
155 #               force reschedule
156 # -DADAPTIVE_WAIT_LOOPS=number
157 #               number of loops we busy wait, after "number" loops have elapsed we 
158 #               force a reschedule
159 # -DNOSMP
160 #               don't use smp compliant locking (faster but won't work on SMP machines)
161 #               (not yet enabled)
162 # -DNO_PINGTEL_TAG_HACK
163 #               if enabled, To-header-field will be less liberal and will not accept
164 #               'tag=' (tag parameter with equal sign and without value); it is called
165 #               this way because such message was sighted from a Pingtel phone
166 # -DWITH_SNMP_MOD
167 #               if enabled, allows forking of the snmp agent just before child
168 #               forking (done at the top of main_loop). Needed if you want
169 #               to use the snmp module.
170 # -DUSE_TCP
171 #               compiles in tcp support (highly experimental for now, it will probably
172 #               not work, use it only if you really now what you are doing)
173 # -DDISABLE_NAGLE
174 #               disable the tcp Nagle algorithm (lower delay)
175 # -DVOICE_MAIL
176 #               enables voicemail support in ser core and in tm module
177 #               voicemail needs also -D_TOTAG
178 #
179 # -DDIGEST_DOMAIN
180 #               enables further parsing of digest username. Some clients put @domain
181 #               in username digest parameter because realm parameter is not protected
182 #               by the digest. This hasn't been standardized, but several user agents
183 #               use this.
184
185
186 DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
187          -DOS='"$(OS)"' -DCOMPILER='"$(CC_VER)"' -D__CPU_$(ARCH) -D__OS_$(OS) \
188          -DCFG_DIR='"$(cfg-target)"'\
189          -DPKG_MALLOC \
190          -DSHM_MEM  -DSHM_MMAP \
191          -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 \
192          -DDNS_IP_HACK \
193          -DUSE_IPV6 \
194          -DUSE_TCP \
195          -DDISABLE_NAGLE \
196          -DDIGEST_DOMAIN \
197          -DDBG_QM_MALLOC \
198          #-DF_MALLOC \
199          #-DNO_DEBUG \
200          #-DNO_LOG
201          #-DEXTRA_DEBUG \
202          #-DDBG_QM_MALLOC \
203          #-DVQ_MALLOC  
204          #-DCONTACT_BUG
205          #-DDBG_LOCK
206          #-DNOSMP \
207          #-DEXTRA_DEBUG \
208          #-DUSE_SHM_MEM \
209          #-DSTATS \
210          #-DWITH_SNMP_MOD \
211          #-DNO_LOG
212
213 #PROFILE=  -pg #set this if you want profiling
214
215 # WARNING: do not add mode=debug or mode=release anymore in the Makefile,
216 # use make mode=debug all instead. Anyway no by default ser is  compiled w/ 
217 # debugging symbols in all cases (-g). --andrei
218 ifeq ($(mode),)
219         mode = release
220 endif
221
222 ifeq ($(mode),debug)
223         DEFS+= -DEXTRA_DEBUG
224 endif
225
226 # platform dependent settings
227
228
229 #common
230 ifeq ($(CC),)
231         CC=gcc
232 endif
233 LD= $(CC)
234 CC_LONGVER=$(shell if  $(CC) -v 2>/dev/null; then \
235                                                 $(CC) -v 2>&1 ;\
236                                         else \
237                                                 $(CC) -V 2>&1 ; \
238                                         fi )
239 MKTAGS=ctags -R .
240
241 #find-out the compiler's name
242
243 ifneq (,$(findstring gcc, $(CC_LONGVER)))
244         CC_NAME=gcc
245         CC_VER=$(CC) $(shell $(CC) --version|head -1| \
246                                  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/')
247         # sun sed is a little brain damaged => this complicated expression
248         MKDEP=$(CC) -MM 
249         #transform gcc version into 2.9x or 3.0
250         CC_SHORTVER=$(shell echo "$(CC_VER)" | cut -d" " -f 2| \
251                                  sed -e 's/[^0-9]*-\(.*\)/\1/'| \
252                                  sed -e 's/2\.9.*/2.9x/' -e 's/3\..\..*/3.0/' -e \
253                                         's/3\../3.0/')
254 endif
255
256 ifneq (, $(findstring Sun, $(CC_LONGVER)))
257         CC_NAME=suncc
258         CC_SHORTVER=$(shell echo "$(CC_LONGVER)"|head -1| \
259                                         sed -e 's/.*\([0-9]\.[0-9]\).*/\1/g' )
260         CC_VER=$(CC) $(CC_SHORTVER)
261         MKDEP=$(CC) -xM1 
262 endif
263
264 ifneq (, $(findstring Intel(R) C++ Compiler, $(CC_LONGVER)))
265         # very nice: gcc compatible
266         CC_NAME=icc
267         CC_FULLVER=$(shell echo "$(CC_LONGVER)"|head -1| \
268                                         sed -e 's/.*Version \([0-9]\.[0-9]\.[0-9]*\).*/\1/g' )
269         CC_SHORTVER=$(shell echo "$(CC_FULLVER)" | cut -d. -f1,2 )
270         CC_VER=$(CC) $(CC_FULLVER)
271         MKDEP=$(CC) -MM 
272 endif
273
274
275 ifeq (,$(CC_NAME))
276 #not found
277         CC_NAME=$(CC)
278         CC_SHORTVER=unknown
279         CC_VER=unknown
280         MKDEP=gcc -MM 
281 $(warning       Unknown compiler $(CC)\; supported compilers: \
282                         gcc, sun cc, intel icc )
283 endif
284
285 # find ld & as name (gnu or solaris)
286 ifeq ($(ARCH), sparc64)
287 ifeq ($(CC_NAME), gcc)
288                 LDGCC=$(shell $(CC) -v 2>&1 | grep with-ld| \
289                                    sed -e 's/.*--with-ld=\([^ ][^ ]*\).*/\1/' )
290                 ASGCC=$(shell $(CC) -v 2>&1 | grep with-as| \
291                                    sed -e 's/.*--with-as=\([^ ][^ ]*\).*/\1/' )
292                 LDPATH=$(shell  if [ -z "$(LDGCC)" ] ; then echo "ld" ;\
293                                                 else \
294                                                 if $(LDGCC) -V 2>/dev/null 1>/dev/null; then \
295                                                         echo $(LDGCC); \
296                                                 else echo "ld" ; \
297                                                 fi\
298                                                 fi)
299                 ASPATH=$(shell  if [ -z "$(ASGCC)" ] ; then echo "as" ;\
300                                                 else \
301                                                 if $(ASGCC) -V 2>/dev/null 1>/dev/null; then \
302                                                         echo $(ASGCC); \
303                                                 else echo "as" ; \
304                                                 fi\
305                                                 fi)
306                                                         
307                 LDTYPE=$(shell if $(LDPATH) -V 1>/dev/null  2>/dev/null; then \
308                                                         if $(LDPATH) -V 2>&1|grep GNU >/dev/null; \
309                                                         then echo gnu; \
310                                                         else \
311                                                         if $(LDPATH) -V 2>&1|grep Solaris >/dev/null;\
312                                                         then echo solaris; \
313                                                         else \
314                                                                 echo unknown ; \
315                                                         fi \
316                                                         fi \
317                                                 fi)
318                 ASTYPE=$(shell if $(ASPATH) -V 1>/dev/null  2>/dev/null </dev/null; \
319                                                 then \
320                                                         if $(ASPATH) -V 2>&1 </dev/null |grep GNU >/dev/null; \
321                                                         then echo gnu; \
322                                                         else \
323                                                         if $(ASPATH) -V 2>&1 </dev/null |grep Sun >/dev/null;\
324                                                         then echo solaris; \
325                                                         else \
326                                                                 echo unknown ; \
327                                                         fi \
328                                                         fi \
329                                                 fi)
330 #$(warning "using ld=$(LDPATH)/$(LDTYPE), as=$(ASPATH)/$(ASTYPE)")
331
332 endif
333 endif
334
335 # arh. specific definitions
336 ifeq ($(ARCH), i386)
337         use_fast_lock=yes
338 endif
339
340 ifeq ($(ARCH), sparc64)
341 ifeq    ($(CC_NAME), gcc)
342         use_fast_lock=yes
343 endif
344 endif
345
346 ifeq ($(ARCH), arm)
347         use_fast_lock=yes
348 endif
349
350 ifeq ($(ARCH), ppc)
351         use_fast_lock=yes
352 endif
353
354 ifeq ($(use_fast_lock), yes)
355         DEFS+= -DFAST_LOCK
356         found_lock_method=yes
357 endif
358
359 CFLAGS=
360 # setting CFLAGS
361 ifeq ($(mode), release)
362         #if i386
363 ifeq    ($(ARCH), i386)
364                 # if gcc 
365 ifeq            ($(CC_NAME), gcc)
366                                 #common stuff
367                                 CFLAGS=-g -O9 -funroll-loops  -Wcast-align $(PROFILE) \
368                                         -Wall   \
369                         #if gcc 3.0
370 ifeq                    ($(CC_SHORTVER), 3.0)
371                                         CPU ?= athlon
372                                         CFLAGS+=-minline-all-stringops -malign-double \
373                                                         -falign-loops \
374                                                         -mcpu=$(CPU) \
375                                                         #-mcpu=athlon
376 else
377 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
378 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc >= 3.1 \
379                                         for better results)
380                                         
381                                         CFLAGS+=-m486 \
382                                                         -malign-loops=4
383 else
384                                 #really old version
385 $(warning                       You are using an old and unsupported gcc \
386                                          version  ($(CC_SHORTVER)), compile at your own risk!)
387
388 endif                   # CC_SHORTVER, 2.9x
389 endif                   # CC_SHORTVER, 3.0
390
391 else            # CC_NAME, gcc
392 ifeq            ($(CC_NAME), icc)
393                         CFLAGS=-g -O3  -ipo -ipo_obj -unroll  $(PROFILE) \
394                                          -tpp6 -xK  #-openmp  #optimize for PIII 
395                                 # -prefetch doesn't seem to work
396                                 #( ty to inline acroos files, unroll loops,prefetch,
397                                 # optimize for PIII, use PIII instructions & vect.,
398                                 # mutlithread loops)
399 else
400                                 #other compilers
401 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
402 endif           #CC_NAME, icc
403 endif           #CC_NAME, gcc
404 endif   #ARCH, i386
405
406
407         #if sparc
408 ifeq    ($(ARCH), sparc64)
409                         #if gcc
410 ifeq            ($(CC_NAME), gcc)
411                                 #common stuff
412                                 CFLAGS=-g -O9 -funroll-loops  $(PROFILE) \
413                                         -Wall\
414                                         #-Wcast-align \
415                                         #-Wmissing-prototypes 
416                                 #if gcc 3.0
417 ifeq                    ($(CC_SHORTVER), 3.0)
418                                         CPU ?= ultrasparc
419                                         #use 32bit for now
420                                         CFLAGS+= -mcpu=ultrasparc -mtune=$(CPU)  -m32  \
421                                         # -mcpu=v9 or ultrasparc? # -mtune implied by -mcpu
422                                         #-mno-epilogue #try to inline function exit code
423                                         #-mflat # omit save/restore
424                                         #-,faster-structs #faster non Sparc ABI structure copy ops
425 else                    # CC_SHORTVER, 3.0
426 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
427 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc >= 3.1 \
428                                         for better results)
429 ifneq                           ($(OS), netbsd)
430                                                 # on netbsd/sparc64,  gcc 2.95.3 does not compile
431                                                 # ser with -mv8
432                                                 CFLAGS+= -mv8 
433 endif
434 ifeq                                    ($(ASTYPE), solaris)
435                                                         CFLAGS+= -Wa,-xarch=v8plus
436 endif                                   
437 else                    #CC_SHORTVER, 2.9x
438                                 #really old version
439 $(warning                       You are using an old and unsupported gcc \
440                                          version ($(CC_SHORTVER)), compile at your own risk!)
441                                         
442                                         CFLAGS+= -mv8 
443 ifeq                                    ($(ASTYPE), solaris)
444                                                         CFLAGS+= -Wa,-xarch=v8plus
445 endif                                   
446         
447 endif                   #CC_SHORTVER, 2.9x
448 endif                   #CC_SHORTVER, 3.0
449
450 else            #CC_NAME, gcc
451 ifeq            ($(CC_NAME), suncc)
452                         CFLAGS+=-g -xO5 -fast -native -xarch=v8plusa -xCC \
453                                         -xc99 # C99 support
454                         # -Dinline="" # add this if cc < 5.3 (define inline as null)
455 else
456                                 #other compilers
457 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
458 endif           #CC_NAME, suncc
459 endif           #CC_NAME, gcc
460 endif   #ARCH, sparc
461
462         #if ipaq/netwinder
463 ifeq    ($(ARCH), arm)
464                 # if gcc 
465 ifeq            ($(CC_NAME), gcc)
466                                 #common stuff
467                                 CFLAGS=-O9 -funroll-loops  -Wcast-align $(PROFILE) \
468                                         -Wall   \
469                         #if gcc 3.0
470 ifeq                    ($(CC_SHORTVER), 3.0)
471                                         CFLAGS+= -mcpu=strongarm1100
472                                                         #-mcpu=athlon
473 else
474 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
475 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
476                                         for better results)
477                                         
478                                         CFLAGS+=
479 else
480                                 #really old version
481 $(warning                       You are using an old and unsupported gcc \
482                                          version ($(CC_SHORTVER)), compile at your own risk!)
483
484 endif                   # CC_SHORTVER, 2.9x
485 endif                   # CC_SHORTVER, 3.0
486
487 else            # CC_NAME, gcc
488                                 #other compilers
489 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
490 endif           #CC_NAME, gcc
491 endif   #ARCH, i386
492
493
494 CFLAGS+= $(CC_EXTRA_OPTS)
495
496
497 LDFLAGS=
498 # setting LDFLAGS
499 ifeq    ($(CC_NAME), gcc)
500 ifeq            ($(ARCH), sparc64)
501 ifeq                    ($(LDTYPE), solaris)
502                                         # solaris ld
503                                         LDFLAGS+=-O2 $(PROFILE)
504                                         MOD_LDFLAGS=-G $(LDFLAGS)
505 else                    
506                                         #gcc and maybe others, on solaris, with gnu ld
507                                         LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE) 
508                                         MOD_LDFLAGS=-shared $(LDFLAGS)
509 endif
510 else
511                         #gcc and maybe others
512                         LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE) 
513                         MOD_LDFLAGS=-shared $(LDFLAGS)
514 endif
515 endif
516 ifeq    ($(CC_NAME), icc)
517         #gcc and maybe others
518         LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE) 
519         MOD_LDFLAGS=-shared $(LDFLAGS)
520 endif
521 ifeq    ($(CC_NAME), suncc)
522         LDFLAGS+=-xO5 $(PROFILE)
523         MOD_LDFLAGS=-G $(LDFLAGS)
524 endif
525         # we need -fPIC -DPIC only for shared objects, we don't need them for
526         # the executable file, because it's always loaded at a fixed address
527         # -andrei
528 else    #mode,release
529 ifeq    ($(CC_NAME), gcc)
530                 CFLAGS=-g -Wcast-align $(PROFILE)
531 ifeq            ($(ARCH), sparc64)
532                         CFLAGS+= -mcpu=ultrasparc 
533 endif
534 ifeq            ($(LDTYPE), solaris)
535                         #solaris ld
536                         LDFLAGS+=-g $(PROFILE)
537                         MOD_LDFLAGS=-G $(LDFLAGS)
538 else
539                         #gnu or other ld type
540                         LDFLAGS+=-g -Wl,-E $(PROFILE)
541                         MOD_LDFLAGS=-shared $(LDFLAGS)
542 endif
543 endif
544 ifeq    ($(CC_NAME), icc)
545                 CFLAGS=-g  $(PROFILE)
546                 LDFLAGS+=-g -Wl,-E $(PROFILE)
547                 MOD_LDFLAGS=-shared $(LDFLAGS)
548 endif
549 ifeq    ($(CC_NAME), suncc)
550                 CFLAGS= -g $(PROFILE)
551                 LDFLAGS+=-g $(PROFILE)
552                 MOD_LDFLAGS=-G $(LDFLAGS)
553 endif
554
555 endif #mode=release
556
557
558 #*FLAGS used for compiling the modules
559 ifeq    ($(CC_NAME), gcc)
560 MOD_CFLAGS=-fPIC -DPIC $(CFLAGS)
561 endif
562 ifeq    ($(CC_NAME), icc)
563 MOD_CFLAGS=-Kpic $(CFLAGS)
564 endif
565 ifeq    ($(CC_NAME), suncc)
566 MOD_CFLAGS=-xcode=pic32  $(CFLAGS)
567 endif
568
569 ifeq ($(LEX),)
570         LEX=flex
571 endif
572 ifeq ($(YACC),)
573         YACC=bison
574 endif
575 YACC_FLAGS=-d -b cfg
576 # on solaris add -lxnet (e.g. LIBS= -lxnet)
577 LIBS= -lfl -ldl -lresolv
578
579
580 #os specific stuff
581 ifeq ($(OS), linux)
582         DEFS+=-DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
583                         -DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL
584         ifneq ($(found_lock_method), yes)
585                 DEFS+= -DUSE_SYSV_SEM  # try posix sems
586                 found_lock_method=yes
587         endif
588 endif
589
590 ifeq  ($(OS), solaris)
591         DEFS+= -DHAVE_GETIPNODEBYNAME -DHAVE_SYS_SOCKIO_H -DHAVE_SCHED_YIELD
592         ifneq ($(found_lock_method), yes)
593                 DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
594                 found_lock_method=yes
595         endif
596         ifeq ($(mode), release)
597                 #use these only if you're using gcc with Solaris ld
598                 #LDFLAGS=-O2 $(PROFILE)
599                 #MOD_LDFLAGS=-O2 -G
600         else
601                 #LDFLAGS=-g $(PROFILE)
602                 #MOD_LDFLAGS=-g -G
603         endif
604
605         YACC=yacc
606
607 ifeq ($(CC_NAME), suncc)
608         LIBS= -lfast -ldl -lresolv
609 endif
610         LIBS+= -L/usr/local/lib -lfl -lxnet -lrt -lnsl 
611         # -lrt needed for sched_yield
612 endif
613
614 ifeq ($(OS), freebsd)
615         DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
616                 -DHAVE_SCHED_YIELD -DHAVE_MSGHDR_MSG_CONTROL
617         ifneq ($(found_lock_method), yes)
618                 DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
619                 found_lock_method=yes
620         endif
621         YACC=yacc
622         LIBS= -lfl  #dlopen is in libc
623 endif
624
625 ifeq ($(OS), openbsd)
626         DEFS+=-DHAVE_SOCKADDR_SA_LEN -DDLSYM_PREFIX='"_"' -DHAVE_GETHOSTBYNAME2 \
627                 -DHAVE_UNION_SEMUN -DHAVE_MSGHDR_MSG_CONTROL
628         ifneq ($(found_lock_method), yes)
629                 DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
630                 found_lock_method=yes
631         endif
632         # (symbols on openbsd are prefixed by "_")
633         YACC=yacc
634         # no sched_yield on openbsd unless linking with c_r (not recommended)
635         LIBS= -lfl 
636         LDFLAGS=        # openbsd ld doesn't like -O2 or -E
637 endif
638         
639 ifeq ($(OS), netbsd)
640         DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 \
641                 -DHAVE_MSGHDR_MSG_CONTROL
642         ifneq ($(found_lock_method), yes)
643                 DEFS+= -DUSE_SYSV_SEM  # try pthread sems
644                 found_lock_method=yes
645         endif
646         YACC=yacc
647         LIBS= -lfl 
648 endif
649
650 ifneq (,$(findstring CYGWIN, $(OS)))
651         #cygwin is the same as common
652         ifneq ($(found_lock_method), yes)
653                 DEFS+= -DUSE_SYSV_SEM  # try sys v sems
654                 found_lock_method=yes
655         endif
656 endif
657
658 ifneq ($(found_lock_method), yes)
659 $(warning       No locking method found so far, trying SYS V sems)
660                 DEFS+= -DUSE_SYSV_SEM  # try sys v sems
661                 found_lock_method=yes
662 endif