bef8a3ce2a3f14b812a93d7ece6a94e7d3cf2109
[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 #   extra_defs
11 #
12 # History:
13 # --------
14 #              created by andrei
15 #  2003-02-24  added LOCALBASE, fixed doc-dir for freebsd - patch provided
16 #               by Maxim Sobolev <sobomax@FreeBSD.org>
17 #  2003-02-25  added -DDISABLE_NAGLE (andrei)
18 #  2003-03-02  added -DDIGEST_DOMAIN (janakj)
19 #  2003-03-10  added -xcode=pic32 for module compilation w/ sun cc
20 #               (too many symbols for pic13)  (andrei)
21 #  2003-04-16  added CC_EXTRA_OPTS, s/march/mcpu, added CPU (cpu to optimize 
22 #               for, used only with gcc-3.x) (andrei)
23 #  2003-05-23  check if this makefile was already included (andrei)
24 #              removed -DDIGEST_DOMAIN (andrei)
25 #  2003-05-30  added extra_defs (andrei)
26 #  2003-06-06  moved compiler detection before DEFS (andrei)
27 #  2003-06-10  removed -m32 for gcc 3.x/sparc64  -- it will use 
28 #              arch. default: -m32 on solaris, -m64 on *bsd (andrei)
29 #  2003-09-25  added -pthread into LIBS when compiling on FreeBSD/alpha
30 #              and other FreeBSD arches for which no fast locking assembly
31 #              code exists (sobomax)
32 #  2003-11-08  mips1 support introduced (andrei)
33 #  2003-11-24  openbsd 3.4 (elf) fixes (andrei)
34 #  2004-07-27  darwin (mac os x) port  (andrei)
35 #  2004-09-12  mips2 & cobalt support introduced (andrei)
36 #  2004-09-28  x86_64 support introduced (andrei)
37 #  2004-12-14  gcc-3.4 special case added (andrei)
38 #  2004-12-15  HAVE_ALLOCA_H added (andrei)
39 #  2004-12-19  amd64 transformed in x86_64 (andrei)
40 #  2005-04-27  alpha support added (andrei)
41 #  2005-06-01  use $(LOCALBASE) instead of /usr/{local,pkg} (andrei)
42 #  2005-06-26  numeric OSREL & HAVE_KQUEUE added to the *BSD (andrei)
43 #  2005-07-04  HAVE_DEVPOLL added to solaris (andrei)
44 #  2005-07-06  gcc 4.0 optimizations support (andrei)
45 #  2005-07-25  better solaris arch detection (andrei)
46
47
48 # check if already included/exported
49
50 ifeq ($(makefile_defs), 1)
51 else
52 makefile_defs=1
53 export makefile_defs
54
55 # main binary name
56 MAIN_NAME=ser
57
58 #version number
59 VERSION = 0
60 PATCHLEVEL = 10
61 SUBLEVEL =   99
62 EXTRAVERSION = -dev14-tcp
63
64 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
65 OS = $(shell uname -s | sed -e s/SunOS/solaris/ | tr "[A-Z]" "[a-z]")
66
67 ifeq ($(OS),solaris)
68         GETARCH=uname -p
69 else
70         GETARCH=uname -m
71 endif
72
73 ARCH := $(shell $(GETARCH) |sed -e s/i.86/i386/ -e s/sun4u/sparc64/  \
74                         -e s/armv4l/arm/ -e "s/Power Macintosh/ppc/" \
75                         -e "s/cobalt/mips2/" \
76                         -e s/amd64/x86_64/ )
77 # fix sparc -> sparc64
78 ifeq ($(ARCH),sparc)
79         ifeq ($(shell uname -m),sun4u)
80                 ARCH := sparc64
81         endif
82 endif
83
84 OSREL = $(shell uname -r)
85 # numerical version (good for comparisons: A.B.C => A*1000000+B*1000+C)
86 OSREL_N= $(shell echo $(OSREL) | sed -e 's/^[^0-9]*//' \
87                 -e 's/^\([0-9][0-9]*\(\.[0-9][0-9]*\)*\).*$$/\1/g' | \
88                 (IFS=. read A B C D; R=0; \
89                 [ -n "$$A" ] && R=`expr $$R \* 1000 + $$A` && \
90                 [ -n "$$B" ] && R=`expr $$R \* 1000 + $$B` && \
91                 [ -n "$$C" ] && R=`expr $$R \* 1000 + $$C`; echo $$R ) )
92
93 # TLS support
94 TLS ?= 
95 ifneq ($(TLS),)
96         RELEASE:=$(RELEASE)-tls
97 endif
98 # extra CC command line options (e.g  -march=athlon-mp)
99 CC_EXTRA_OPTS ?=
100
101 # dirs 
102 cfg-dir = etc/ser/
103 bin-dir = sbin/
104 modules-dir = lib/ser/modules/
105 ifeq ($(OS), linux)
106         doc-dir = share/doc/ser/
107         man-dir = share/man/
108         LOCALBASE ?= /usr/local
109 else
110 ifeq ($(OS), freebsd)
111         doc-dir = share/doc/ser/
112         man-dir = man/
113         LOCALBASE ?= /usr/local
114 else
115 ifeq ($(OS), openbsd)
116         doc-dir = share/doc/ser/
117         man-dir = man/
118         LOCALBASE ?= /usr/local
119 else
120 ifeq ($(OS), netbsd)
121         doc-dir = share/doc/ser
122         man-dir = man/
123         LOCALBASE ?= /usr/pkg
124 else
125 ifeq ($(OS), darwin)
126         doc-dir = share/doc/ser/
127         man-dir = man/
128         LOCALBASE ?= /usr/local
129 else
130         doc-dir = doc/ser/
131         man-dir = man/
132         LOCALBASE ?= /usr/local
133 endif
134 endif
135 endif
136 endif
137 endif
138
139  # install location
140 DESTDIR ?= $(LOCALBASE)
141 PREFIX ?= $(DESTDIR)
142 prefix = $(PREFIX)
143 # install path is $(basedir) $(prefix) 
144 # example:
145 #  creating a bin. archive in /tmp, which unpacks in /usr/local
146 #  basedir=/tmp
147 #  prefix=/usr/local
148
149 BASEDIR ?=
150 basedir = $(BASEDIR)
151 # install prefixes for various stuff
152 cfg-prefix = $(basedir)$(prefix)
153 bin-prefix = $(basedir)$(prefix)
154 modules-prefix = $(basedir)$(prefix)
155 doc-prefix = $(basedir)$(prefix)
156 man-prefix = $(basedir)$(prefix)
157 ut-prefix = $(basedir)$(prefix)
158
159
160 # target dirs for various stuff
161 cfg-target = $(prefix)/$(cfg-dir)
162 bin-target = $(prefix)/$(bin-dir)
163 modules-target = $(prefix)/$(modules-dir)
164 doc-target = $(prefix)/$(doc-dir)
165
166
167 ifeq ($(OS), solaris)
168 #use GNU versions
169 INSTALL ?= ginstall
170 TAR ?= gtar
171 else
172 INSTALL ?= install 
173 TAR ?= tar
174 endif
175
176 INSTALL-TOUCH = touch          # used to create the file first (good to 
177                                #  make solaris install work)
178 INSTALL-CFG = $(INSTALL) -m 644
179 INSTALL-BIN = $(INSTALL) -m 755
180 INSTALL-MODULES = $(INSTALL) -m 755
181 INSTALL-DOC = $(INSTALL) -m 644
182 INSTALL-MAN = $(INSTALL) -m 644
183
184 #set some vars from the environment (and not make builtins)
185 CC   := $(shell echo "$${CC}")
186 LEX  := $(shell echo "$${LEX}")
187 YACC := $(shell echo "$${YACC}")
188
189
190
191
192 # find compiler name & version
193 ifeq ($(CC),)
194         CC=gcc
195 endif
196 LD= $(CC)
197 CC_LONGVER=$(shell if  $(CC) -v 2>/dev/null; then \
198                                                 $(CC) -v 2>&1 ;\
199                                         else \
200                                                 $(CC) -V 2>&1 ; \
201                                         fi )
202 MKTAGS=ctags -R .
203
204 #find-out the compiler's name
205
206 ifneq (,$(findstring gcc, $(CC_LONGVER)))
207         CC_NAME=gcc
208         CC_VER=$(CC) $(shell $(CC) --version|head -n 1| \
209                                  sed -e 's/^[^0-9]*\([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/')
210         # sun sed is a little brain damaged => this complicated expression
211         MKDEP=$(CC) -MM 
212         #transform gcc version into 2.9x or 3.0
213         CC_SHORTVER=$(shell echo "$(CC_VER)" | cut -d" " -f 2| \
214                                  sed -e 's/[^0-9]*-\(.*\)/\1/'| \
215                                  sed -e 's/2\.9.*/2.9x/' -e 's/3\.[0-3]\..*/3.0/' -e \
216                                         's/3\.[0-3]/3.0/' -e 's/3\.[4-9]\..*/3.4/' -e \
217                                         's/3\.[4-9]/3.4/' -e 's/4\.[0-9]\..*/4.x/' -e \
218                                         's/4\.[0-9]/4.x/' )
219 endif
220
221 ifneq (, $(findstring Sun, $(CC_LONGVER)))
222         CC_NAME=suncc
223         CC_SHORTVER=$(shell echo "$(CC_LONGVER)"|head -n 1| \
224                                         sed -e 's/.*\([0-9]\.[0-9]\).*/\1/g' )
225         CC_VER=$(CC) $(CC_SHORTVER)
226         MKDEP=$(CC) -xM1 
227 endif
228
229 ifneq (, $(findstring Intel(R) C++ Compiler, $(CC_LONGVER)))
230         # very nice: gcc compatible
231         CC_NAME=icc
232         CC_FULLVER=$(shell echo "$(CC_LONGVER)"|head -n 1| \
233                                         sed -e 's/.*Version \([0-9]\.[0-9]\.[0-9]*\).*/\1/g' )
234         CC_SHORTVER=$(shell echo "$(CC_FULLVER)" | cut -d. -f1,2 )
235         CC_VER=$(CC) $(CC_FULLVER)
236         MKDEP=$(CC) -MM 
237 endif
238
239
240 ifeq (,$(CC_NAME))
241 #not found
242         CC_NAME=$(CC)
243         CC_SHORTVER=unknown
244         CC_VER=unknown
245         MKDEP=gcc -MM 
246 $(warning       Unknown compiler $(CC)\; supported compilers: \
247                         gcc, sun cc, intel icc )
248 endif
249
250
251 # compile-time options
252 #
253 # -DSTATS
254 #               allows to print out number of packets processed on CTRL-C;
255 #               implementation still nasty and reports per-process
256 # -DNO_DEBUG
257 #               turns off some of the debug messages (DBG(...)).
258 # -DNO_LOG
259 #               completely turns of all the logging (and DBG(...))
260 # -DEXTRA_DEBUG
261 #               compiles in some extra debugging code
262 # -DDNS_IP_HACK
263 #               faster ip address resolver for ip strings (e.g "127.0.0.1")
264 # -DSHM_MEM
265 #               compiles in shared mem. support, needed by some modules and
266 #               by USE_SHM_MEM
267 # -DSHM_MMAP
268 #               use mmap instead of SYSV shared memory
269 # -DPKG_MALLOC
270 #               uses a faster malloc (exclusive w/ USE_SHM_MEM)
271 # -DUSE_SHM_MEM
272 #               all pkg_malloc => shm_malloc (most mallocs use a common sh.
273 #               mem. segment); don't define PKG_MALLOC if you want this!
274 # -DDBG_QM_MALLOC
275 #               qm_malloc debug code, will cause pkg_malloc and shm_malloc
276 #               to keep and display lot of debuging information: file name,
277 #               function, line number of malloc/free call for each block,
278 #               extra error checking (trying to free the same pointer
279 #               twice, trying to free a pointer alloc'ed with a different
280 #               malloc etc.)
281 # -DVQ_MALLOC
282 #               additional option to PKG_MALLOC which utilizes a fater then
283 #               qm version
284 #               (not true anymore, q_malloc performs approx. the same)
285 # -DF_MALLOC
286 #               an even faster malloc, not recommended for debugging
287 # -DDBG_MALLOC
288 #               issues additional debugging information if lock/unlock is called
289 # -DFAST_LOCK
290 #               uses fast arhitecture specific locking (see the arh. specific section)
291 # -DUSE_SYSV_SEM
292 #               uses sys v sems for locking (slower & limited number)
293 # -DUSE_PTHREAD_MUTEX
294 #               uses pthread mutexes, faster than sys v or posix sems, but do not 
295 #               work on all systems inter-processes (e.g. linux)
296 # -DUSE_POSIX_SEM
297 #               uses posix semaphores for locking (faster than sys v)
298 # -DBUSY_WAIT
299 #               uses busy waiting on the lock (FAST_LOCK)
300 # -DADAPTIVE_WAIT
301 #               try busy waiting for a while and if the lock is still held go to
302 #               force reschedule (FAST_LOCK)
303 # -DADAPTIVE_WAIT_LOOPS=number
304 #               number of loops we busy wait, after "number" loops have elapsed we 
305 #               force a reschedule (FAST_LOCK)
306 # -DNOSMP
307 #               don't use smp compliant locking (faster but won't work on SMP machines)
308 #               (not yet enabled) (FAST_LOCK)
309 # -DNO_PINGTEL_TAG_HACK
310 #               if enabled, To-header-field will be less liberal and will not accept
311 #               'tag=' (tag parameter with equal sign and without value); it is called
312 #               this way because such message was sighted from a Pingtel phone
313 # -DWITH_SNMP_MOD
314 #               if enabled, allows forking of the snmp agent just before child
315 #               forking (done at the top of main_loop). Needed if you want
316 #               to use the snmp module.
317 # -DUSE_TCP
318 #               compiles in tcp support
319 # -DDISABLE_NAGLE
320 #               disable the tcp Nagle algorithm (lower delay)
321 # -DUSE_TLS
322 #               compiles in tls support, requires -DUSE_TCP. Please use
323 #               make TLS=1 instead. (tls support is highly experimental for now)
324 # -DHAVE_RESOLV_RES
325 #               support for changing some of the resolver parameters present
326 #                (_res structure in <resolv.h>)
327
328
329 DEFS+= $(extra_defs) \
330          -DNAME='"$(MAIN_NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
331          -DOS='"$(OS)"' -DCOMPILER='"$(CC_VER)"' -D__CPU_$(ARCH) -D__OS_$(OS) \
332          -DCFG_DIR='"$(cfg-target)"'\
333          -DPKG_MALLOC \
334          -DSHM_MEM  -DSHM_MMAP \
335          -DDNS_IP_HACK \
336          -DUSE_IPV6 \
337          -DUSE_MCAST \
338          -DUSE_TCP \
339          -DDISABLE_NAGLE \
340          -DHAVE_RESOLV_RES \
341          -DDBG_QM_MALLOC \
342          #-DF_MALLOC \
343          #-DDBG_F_MALLOC \
344          #-DNO_DEBUG \
345          #-DNO_LOG \
346          #-DEXTRA_DEBUG \
347          #-DVQ_MALLOC  \
348          #-DCONTACT_BUG \
349          #-DDBG_LOCK \
350          #-DNOSMP \
351          #-DUSE_SHM_MEM \
352          #-DSTATS \
353          #-DNO_LOG
354
355 #PROFILE=  -pg #set this if you want profiling
356
357 # WARNING: do not add mode=debug or mode=release anymore in the Makefile,
358 # use make mode=debug all instead. Anyway no by default ser is  compiled w/ 
359 # debugging symbols in all cases (-g). --andrei
360
361 ifneq ($(TLS),)
362         DEFS+= -DUSE_TLS
363 endif
364
365 ifeq ($(mode),)
366         mode = release
367 endif
368
369 ifeq ($(mode),debug)
370         DEFS+= -DEXTRA_DEBUG
371 endif
372
373 # platform dependent settings
374
375 # find ld & as name (gnu or solaris)
376 ifeq ($(OS), solaris)
377 ifeq ($(CC_NAME), gcc)
378                 LDGCC=$(shell $(CC) -v 2>&1 | grep with-ld| \
379                                    sed -e 's/.*--with-ld=\([^ ][^ ]*\).*/\1/' )
380                 ASGCC=$(shell $(CC) -v 2>&1 | grep with-as| \
381                                    sed -e 's/.*--with-as=\([^ ][^ ]*\).*/\1/' )
382                 LDPATH=$(shell  if [ -z "$(LDGCC)" ] ; then echo "ld" ;\
383                                                 else \
384                                                 if $(LDGCC) -V 2>/dev/null 1>/dev/null; then \
385                                                         echo $(LDGCC); \
386                                                 else echo "ld" ; \
387                                                 fi\
388                                                 fi)
389                 ASPATH=$(shell  if [ -z "$(ASGCC)" ] ; then echo "as" ;\
390                                                 else \
391                                                 if $(ASGCC) -V 2>/dev/null 1>/dev/null; then \
392                                                         echo $(ASGCC); \
393                                                 else echo "as" ; \
394                                                 fi\
395                                                 fi)
396                                                         
397                 LDTYPE=$(shell if $(LDPATH) -V 1>/dev/null  2>/dev/null; then \
398                                                         if $(LDPATH) -V 2>&1|grep GNU >/dev/null; \
399                                                         then echo gnu; \
400                                                         else \
401                                                         if $(LDPATH) -V 2>&1|grep Solaris >/dev/null;\
402                                                         then echo solaris; \
403                                                         else \
404                                                                 echo unknown ; \
405                                                         fi \
406                                                         fi \
407                                                 fi)
408                 ASTYPE=$(shell if $(ASPATH) -V 1>/dev/null  2>/dev/null </dev/null; \
409                                                 then \
410                                                         if $(ASPATH) -V 2>&1 </dev/null |grep GNU >/dev/null; \
411                                                         then echo gnu; \
412                                                         else \
413                                                         if $(ASPATH) -V 2>&1 </dev/null |grep Sun >/dev/null;\
414                                                         then echo solaris; \
415                                                         else \
416                                                                 echo unknown ; \
417                                                         fi \
418                                                         fi \
419                                                 fi)
420 #$(warning "using ld=$(LDPATH)/$(LDTYPE), as=$(ASPATH)/$(ASTYPE)")
421
422 endif
423 endif
424
425 # arh. specific definitions
426 ifeq ($(ARCH), i386)
427         use_fast_lock=yes
428 endif
429
430 ifeq ($(ARCH), x86_64)
431         use_fast_lock=yes
432 endif
433
434 ifeq ($(ARCH), sparc64)
435 ifeq    ($(CC_NAME), gcc)
436         use_fast_lock=yes
437 endif
438 endif
439
440 ifeq ($(ARCH), sparc)
441         # smp no supported on sparc32
442         DEFS+= -DNOSMP 
443         use_fast_lock=yes
444 endif
445
446 ifeq ($(ARCH), arm)
447         use_fast_lock=yes
448 endif
449
450 ifeq ($(ARCH), ppc)
451         use_fast_lock=yes
452 endif
453
454 ifeq ($(ARCH), ppc64)
455         use_fast_lock=yes
456 endif
457
458 ifeq ($(ARCH), mips)
459 # mips1 arch. (e.g. R3000) - no hardware locking support
460         use_fast_lock=no
461 endif
462
463 ifeq ($(ARCH), mips2)
464 # mips2 arch and newer (mips3=R4000, mips4=R5000 a.s.o)
465         use_fast_lock=yes
466 endif
467
468 ifeq ($(ARCH), alpha)
469         use_fast_lock=yes
470 endif
471
472 ifeq ($(use_fast_lock), yes)
473         DEFS+= -DFAST_LOCK -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 
474         found_lock_method=yes
475 endif
476
477 CFLAGS=
478 LDFLAGS=
479 # setting CFLAGS
480 ifeq ($(mode), release)
481         #if i386
482 ifeq    ($(ARCH), i386)
483                 # if gcc 
484 ifeq            ($(CC_NAME), gcc)
485                                 #common stuff
486                                 CFLAGS=-g -O9 -funroll-loops  -Wcast-align $(PROFILE) \
487                                         -Wall  
488                         #if gcc 4.0+
489 ifeq                    ($(CC_SHORTVER), 4.x)
490                                         CPU ?= athlon64
491                                         CFLAGS+=-minline-all-stringops -malign-double \
492                                                         -falign-loops \
493                                                         -ftree-vectorize \
494                                                         -mtune=$(CPU) 
495 else
496                         #if gcc 3.4+
497 ifeq                    ($(CC_SHORTVER), 3.4)
498                                         CPU ?= athlon
499                                         CFLAGS+=-minline-all-stringops -malign-double \
500                                                         -falign-loops \
501                                                         -mtune=$(CPU) 
502 else
503                         #if gcc 3.0+
504 ifeq                    ($(CC_SHORTVER), 3.0)
505                                         CPU ?= athlon
506                                         CFLAGS+=-minline-all-stringops -malign-double \
507                                                         -falign-loops \
508                                                         -mcpu=$(CPU) 
509 else
510 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
511 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc >= 3.1 \
512                                         for better results)
513                                         
514                                         CFLAGS+=-m486 \
515                                                         -malign-loops=4
516 else
517                                 #really old version
518 $(warning                       You are using an old and unsupported gcc \
519                                          version  ($(CC_SHORTVER)), compile at your own risk!)
520
521 endif                   # CC_SHORTVER, 2.9x
522 endif                   # CC_SHORTVER, 3.0
523 endif                   # CC_SHORTVER, 3.4
524 endif                   # CC_SHORTVER, 4.x
525
526 else            # CC_NAME, gcc
527 ifeq            ($(CC_NAME), icc)
528                         CFLAGS=-g -O3  -ipo -ipo_obj -unroll  $(PROFILE) \
529                                          -tpp6 -xK  #-openmp  #optimize for PIII 
530                                 # -prefetch doesn't seem to work
531                                 #( ty to inline acroos files, unroll loops,prefetch,
532                                 # optimize for PIII, use PIII instructions & vect.,
533                                 # mutlithread loops)
534 else
535                                 #other compilers
536 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
537 endif           #CC_NAME, icc
538 endif           #CC_NAME, gcc
539 endif   #ARCH, i386
540
541 #x86_64
542 ifeq    ($(ARCH), x86_64)
543                 # if gcc 
544 ifeq            ($(CC_NAME), gcc)
545                                 #common stuff
546                                 CFLAGS=-g -O9 -funroll-loops  -Wcast-align $(PROFILE) \
547                                         -Wall 
548                         #if gcc 4.0+
549 ifeq                    ($(CC_SHORTVER), 4.x)
550                                         CPU ?= opteron
551                                         CFLAGS+=-minline-all-stringops \
552                                                         -falign-loops \
553                                                         -ftree-vectorize \
554                                                         -mtune=$(CPU) 
555 else
556                         #if gcc 3.4
557 ifeq                    ($(CC_SHORTVER), 3.4)
558                                         CPU ?= athlon64
559                                         CFLAGS+=-minline-all-stringops \
560                                                         -falign-loops 
561 else
562                         #if gcc 3.0
563 ifeq                    ($(CC_SHORTVER), 3.0)
564                                         CPU ?= athlon64
565                                         CFLAGS+=-minline-all-stringops \
566                                                         -falign-loops 
567                                                         #-mcpu=$(CPU) \ # not working on all x86_64 gccs
568                                                         #-mcpu=athlon
569 else
570 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
571 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc >= 3.1 \
572                                         for better results)
573                                         
574                                         CFLAGS+=-m486 \
575                                                         -malign-loops=4
576 else
577                                 #really old version
578 $(warning                       You are using an old and unsupported gcc \
579                                          version  ($(CC_SHORTVER)), compile at your own risk!)
580
581 endif                   # CC_SHORTVER, 2.9x
582 endif                   # CC_SHORTVER, 3.0
583 endif                   # CC_SHORTVER, 3.4
584 endif                   # CC_SHORTVER, 4.x
585
586 else            # CC_NAME, gcc
587 ifeq            ($(CC_NAME), icc)
588                         CFLAGS=-g -O3  -ipo -ipo_obj -unroll  $(PROFILE) \
589                                          -tpp6 -xK  #-openmp  #optimize for PIII 
590                                 # -prefetch doesn't seem to work
591                                 #( ty to inline acroos files, unroll loops,prefetch,
592                                 # optimize for PIII, use PIII instructions & vect.,
593                                 # mutlithread loops)
594 else
595                                 #other compilers
596 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
597 endif           #CC_NAME, icc
598 endif           #CC_NAME, gcc
599 endif   #ARCH, x86_64
600
601         #if sparc
602 ifeq    ($(ARCH), sparc64)
603                         #if gcc
604 ifeq            ($(CC_NAME), gcc)
605                                 #common stuff
606                                 CFLAGS=-g -O9 -funroll-loops  $(PROFILE) \
607                                         -Wall\
608                                         #-Wcast-align \
609                                         #-Wmissing-prototypes 
610                                 #if gcc 4.x
611 ifeq                    ($(CC_SHORTVER), 4.x)
612                                         CPU ?= ultrasparc
613                                         #use 32bit for now
614                                         CFLAGS+=-mcpu=ultrasparc -minline-all-stringops \
615                                                         -mtune=$(CPU) \
616                                                         -ftree-vectorize
617 else
618                                 #if gcc 3.4
619 ifeq                    ($(CC_SHORTVER), 3.4)
620                                         CPU ?= ultrasparc
621                                         #use 32bit for now
622                                         CFLAGS+= -mcpu=ultrasparc -mtune=$(CPU)
623 else
624                                 #if gcc 3.0
625 ifeq                    ($(CC_SHORTVER), 3.0)
626                                         CPU ?= ultrasparc
627                                         #use 32bit for now
628                                         CFLAGS+= -mcpu=ultrasparc -mtune=$(CPU)   \
629                                         # use -m64 to force 64 bit (but add it also to LDFLAGS), 
630                                         # -m32 for 32 bit (default on solaris),
631                                         # nothing for arch. default
632                                         # -mcpu=v9 or ultrasparc? # -mtune implied by -mcpu
633                                         #-mno-epilogue #try to inline function exit code
634                                         #-mflat # omit save/restore
635                                         #-,faster-structs #faster non Sparc ABI structure copy ops
636 else                    # CC_SHORTVER, 3.0
637 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
638 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc >= 3.1 \
639                                         for better results)
640 ifneq                           ($(OS), netbsd)
641                                                 # on netbsd/sparc64,  gcc 2.95.3 does not compile
642                                                 # ser with -mv8
643                                                 CFLAGS+= -mv8 
644 endif
645 ifeq                                    ($(ASTYPE), solaris)
646                                                         CFLAGS+= -Wa,-xarch=v8plus
647 endif                                   
648 else                    #CC_SHORTVER, 2.9x
649                                 #really old version
650 $(warning                       You are using an old and unsupported gcc \
651                                          version ($(CC_SHORTVER)), compile at your own risk!)
652                                         
653                                         CFLAGS+= -mv8 
654 ifeq                                    ($(ASTYPE), solaris)
655                                                         CFLAGS+= -Wa,-xarch=v8plus
656 endif                                   
657         
658 endif                   #CC_SHORTVER, 2.9x
659 endif                   #CC_SHORTVER, 3.0
660 endif                   #CC_SHORTVER, 3.4
661 endif                   #CC_SHORTVER, 4.x
662
663 else            #CC_NAME, gcc
664 ifeq            ($(CC_NAME), suncc)
665                         CFLAGS+=-g -xO5 -fast -native -xarch=v8plusa -xCC \
666                                         -xc99 # C99 support
667                         # -Dinline="" # add this if cc < 5.3 (define inline as null)
668 else
669                                 #other compilers
670 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
671 endif           #CC_NAME, suncc
672 endif           #CC_NAME, gcc
673 endif   #ARCH, sparc64
674
675         #if ipaq/netwinder
676 ifeq    ($(ARCH), arm)
677                 # if gcc 
678 ifeq            ($(CC_NAME), gcc)
679                                 #common stuff
680                                 CFLAGS=-O9 -funroll-loops  -Wcast-align $(PROFILE) \
681                                         -Wall   
682                         #if gcc 4.x+
683 ifeq                    ($(CC_SHORTVER), 4.x)
684                                         CFLAGS+=-mcpu=strongarm1100 -minline-all-stringops \
685                                                         -ftree-vectorize
686 else
687                         #if gcc 3.4+
688 ifeq                    ($(CC_SHORTVER), 3.4)
689                                         CFLAGS+= -mcpu=strongarm1100
690 else
691                         #if gcc 3.0
692 ifeq                    ($(CC_SHORTVER), 3.0)
693                                         CFLAGS+= -mcpu=strongarm1100
694                                                         #-mcpu=athlon
695 else
696 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
697 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
698                                         for better results)
699                                         
700                                         CFLAGS+=
701 else
702                                 #really old version
703 $(warning                       You are using an old and unsupported gcc \
704                                          version ($(CC_SHORTVER)), compile at your own risk!)
705         
706 endif                   # CC_SHORTVER, 2.9x
707 endif                   # CC_SHORTVER, 3.0
708 endif                   # CC_SHORTVER, 3.4
709 endif                   # CC_SHORTVER, 4.0
710         
711 else            # CC_NAME, gcc
712                                 #other compilers
713 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
714 endif           #CC_NAME, gcc
715 endif   #ARCH, arm 
716
717         #if  mips (R3000)
718 ifeq    ($(ARCH), mips)
719                 # if gcc 
720 ifeq            ($(CC_NAME), gcc)
721                                 #common stuff
722                                 CFLAGS=-O9 -funroll-loops  -Wcast-align $(PROFILE) \
723                                         -Wall 
724                         #if gcc 4.0+
725 ifeq                    ($(CC_SHORTVER), 4.x)
726                                         CFLAGS+=-mcpu=r3000 -minline-all-stringops \
727                                                         -ftree-vectorize
728 else
729                         #if gcc 3.4+
730 ifeq                    ($(CC_SHORTVER), 3.4)
731                                         CFLAGS+= -mcpu=r3000
732 else
733                         #if gcc 3.0
734 ifeq                    ($(CC_SHORTVER), 3.0)
735                                         CFLAGS+= -mcpu=r3000
736                                                         #-mcpu=athlon
737 else
738 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
739 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
740                                         for better results)
741                                         
742                                         CFLAGS+=-mcpu=r3000
743 else
744                                 #really old version
745 $(warning                       You are using an old and unsupported gcc \
746                                          version ($(CC_SHORTVER)), compile at your own risk!)
747         
748 endif                   # CC_SHORTVER, 2.9x
749 endif                   # CC_SHORTVER, 3.0
750 endif                   # CC_SHORTVER, 3.4
751 endif                   # CC_SHORTVER, 4.x
752         
753 else            # CC_NAME, gcc
754                                 #other compilers
755 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
756 endif           #CC_NAME, gcc
757 endif   #ARCH, mips
758
759         #if  >=mips2 (R4000, R5000, R6000 ....)
760 ifeq    ($(ARCH), mips2)
761                 # if gcc 
762 ifeq            ($(CC_NAME), gcc)
763                                 #common stuff
764                                 CFLAGS= -mips2 -O9 -funroll-loops $(PROFILE) \
765                                         -Wall 
766                         #if gcc 4.0+
767 ifeq                    ($(CC_SHORTVER), 4.x)
768                                         CFLAGS+=-minline-all-stringops -ftree-vectorize
769 else
770                         #if gcc 3.4+
771 ifeq                    ($(CC_SHORTVER), 3.4)
772                                         CFLAGS+=
773 else
774                         #if gcc 3.0
775 ifeq                    ($(CC_SHORTVER), 3.0)
776                                         CFLAGS+=
777 else
778 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
779 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
780                                         for better results)
781                                         CFLAGS+=
782 else
783                                 #really old version
784 $(warning                       You are using an old and unsupported gcc \
785                                          version ($(CC_SHORTVER)), compile at your own risk!)
786         
787 endif                   # CC_SHORTVER, 2.9x
788 endif                   # CC_SHORTVER, 3.0
789 endif                   # CC_SHORTVER, 3.4
790 endif                   # CC_SHORTVER, 4.x
791         
792 else            # CC_NAME, gcc
793                                 #other compilers
794 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
795 endif           #CC_NAME, gcc
796 endif   #ARCH, mips2
797
798
799 #if  alpha
800 ifeq    ($(ARCH), alpha)
801                 # if gcc 
802 ifeq            ($(CC_NAME), gcc)
803                                 #common stuff
804                                 CFLAGS= -O9 -funroll-loops $(PROFILE)  -Wall 
805                         #if gcc 4.0+
806 ifeq                    ($(CC_SHORTVER), 4.x)
807                                         CFLAGS+=-minline-all-stringops
808 else
809                         #if gcc 3.4+
810 ifeq                    ($(CC_SHORTVER), 3.4)
811                                         CFLAGS+=
812 else
813                         #if gcc 3.0
814 ifeq                    ($(CC_SHORTVER), 3.0)
815                                         CFLAGS+=
816 else
817 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
818 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
819                                         for better results)
820                                         CFLAGS+=
821 else
822                                 #really old version
823 $(warning                       You are using an old and unsupported gcc \
824                                          version ($(CC_SHORTVER)), compile at your own risk!)
825         
826 endif                   # CC_SHORTVER, 2.9x
827 endif                   # CC_SHORTVER, 3.0
828 endif                   # CC_SHORTVER, 3.4
829 endif                   # CC_SHORTVER, 4.x
830         
831 else            # CC_NAME, gcc
832                                 #other compilers
833 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
834 endif           #CC_NAME, gcc
835 endif   #ARCH, alpha 
836
837 #if  ppc
838 ifeq    ($(ARCH), ppc)
839                 # if gcc 
840 ifeq            ($(CC_NAME), gcc)
841                                 #common stuff
842                                 CFLAGS= -O9 -funroll-loops $(PROFILE)  -Wall 
843                         #if gcc 4.0+
844 ifeq                    ($(CC_SHORTVER), 4.x)
845                                         CPU ?= powerpc
846                                         CFLAGS+=-minline-all-stringops  -ftree-vectorize \
847                                                         -mtune=$(CPU) -maltivec
848 else
849                         #if gcc 3.4+
850 ifeq                    ($(CC_SHORTVER), 3.4)
851                                         CFLAGS+=
852 else
853                         #if gcc 3.0
854 ifeq                    ($(CC_SHORTVER), 3.0)
855                                         CFLAGS+=
856 else
857 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
858 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
859                                         for better results)
860                                         CFLAGS+=
861 else
862                                 #really old version
863 $(warning                       You are using an old and unsupported gcc \
864                                          version ($(CC_SHORTVER)), compile at your own risk!)
865         
866 endif                   # CC_SHORTVER, 2.9x
867 endif                   # CC_SHORTVER, 3.0
868 endif                   # CC_SHORTVER, 3.4
869 endif                   # CC_SHORTVER, 4.x
870         
871 else            # CC_NAME, gcc
872                                 #other compilers
873 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
874 endif           #CC_NAME, gcc
875 endif   #ARCH, ppc 
876
877 #if  ppc64
878 ifeq    ($(ARCH), ppc64)
879                 # if gcc 
880 ifeq            ($(CC_NAME), gcc)
881                                 #common stuff
882                                 CFLAGS= -O9 -funroll-loops $(PROFILE)  -Wall 
883 ifeq                    ($(CC_SHORTVER), 4.x)
884                                         CPU ?= powerpc64
885                                         CFLAGS+=-minline-all-stringops  -ftree-vectorize \
886                                                         -mtune=$(CPU) -maltivec
887 else
888                         #if gcc 3.4+
889 ifeq                    ($(CC_SHORTVER), 3.4)
890                                         CFLAGS+=
891 else
892                         #if gcc 3.0
893 ifeq                    ($(CC_SHORTVER), 3.0)
894                                         CFLAGS+=
895 else
896 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
897 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
898                                         for better results)
899                                         CFLAGS+=
900 else
901                                 #really old version
902 $(warning                       You are using an old and unsupported gcc \
903                                          version ($(CC_SHORTVER)), compile at your own risk!)
904         
905 endif                   # CC_SHORTVER, 2.9x
906 endif                   # CC_SHORTVER, 3.0
907 endif                   # CC_SHORTVER, 3.4
908 endif                   # CC_SHORTVER, 4.x
909         
910 else            # CC_NAME, gcc
911                                 #other compilers
912 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
913 endif           #CC_NAME, gcc
914 endif   #ARCH, ppc 
915
916 CFLAGS+= $(CC_EXTRA_OPTS)
917
918
919 # setting LDFLAGS
920 ifeq    ($(CC_NAME), gcc)
921 ifeq            ($(LDTYPE), solaris)
922                 # solaris ld
923                 LDFLAGS+=-O2 $(PROFILE)
924                 MOD_LDFLAGS=-G $(LDFLAGS)
925 else            
926                 #gcc and maybe others, => gnu ld
927                 LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE) 
928                 MOD_LDFLAGS=-shared $(LDFLAGS)
929 endif
930 endif
931 ifeq    ($(CC_NAME), icc)
932         #gcc and maybe others
933         LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE) 
934         MOD_LDFLAGS=-shared $(LDFLAGS)
935 endif
936 ifeq    ($(CC_NAME), suncc)
937         LDFLAGS+=-xO5 $(PROFILE)
938         MOD_LDFLAGS=-G $(LDFLAGS)
939 endif
940         # we need -fPIC -DPIC only for shared objects, we don't need them for
941         # the executable file, because it's always loaded at a fixed address
942         # -andrei
943 else    #mode,release
944 ifeq    ($(CC_NAME), gcc)
945                 CFLAGS=-g -Wcast-align $(PROFILE)
946 ifeq            ($(ARCH), sparc64)
947                         CFLAGS+= -mcpu=ultrasparc 
948 endif
949 ifeq            ($(LDTYPE), solaris)
950                         #solaris ld
951                         LDFLAGS+=-g $(PROFILE)
952                         MOD_LDFLAGS=-G $(LDFLAGS)
953 else
954                         #gnu or other ld type
955                         LDFLAGS+=-g -Wl,-E $(PROFILE)
956                         MOD_LDFLAGS=-shared $(LDFLAGS)
957 endif
958 endif
959 ifeq    ($(CC_NAME), icc)
960                 CFLAGS=-g  $(PROFILE)
961                 LDFLAGS+=-g -Wl,-E $(PROFILE)
962                 MOD_LDFLAGS=-shared $(LDFLAGS)
963 endif
964 ifeq    ($(CC_NAME), suncc)
965                 CFLAGS= -g $(PROFILE)
966                 LDFLAGS+=-g $(PROFILE)
967                 MOD_LDFLAGS=-G $(LDFLAGS)
968 endif
969
970 endif #mode=release
971
972
973 #*FLAGS used for compiling the modules
974 ifeq    ($(CC_NAME), gcc)
975 MOD_CFLAGS=-fPIC -DPIC $(CFLAGS)
976 endif
977 ifeq    ($(CC_NAME), icc)
978 MOD_CFLAGS=-Kpic $(CFLAGS)
979 endif
980 ifeq    ($(CC_NAME), suncc)
981 MOD_CFLAGS=-xcode=pic32  $(CFLAGS)
982 endif
983
984 ifeq ($(LEX),)
985         LEX=flex
986 endif
987 ifeq ($(YACC),)
988         YACC=bison
989 endif
990 YACC_FLAGS=-d -b cfg
991 # on solaris add -lxnet (e.g. LIBS= -lxnet)
992 LIBS= -lfl -ldl -lresolv
993
994
995 #os specific stuff
996 ifeq ($(OS), linux)
997         DEFS+=-DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
998                         -DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H
999         ifneq ($(found_lock_method), yes)
1000                 DEFS+= -DUSE_SYSV_SEM  # try posix sems
1001                 found_lock_method=yes
1002         endif
1003         # check for >= 2.5.44
1004         ifeq ($(shell [ $(OSREL_N) -ge 2005044 ] && echo has_epoll), has_epoll)
1005                 ifeq ($(NO_EPOLL),)
1006                         DEFS+=-DHAVE_EPOLL
1007                 endif
1008         endif
1009         # check for >= 2.2.0
1010         ifeq ($(shell [ $(OSREL_N) -ge 2002000 ] && echo has_sigio), has_sigio)
1011                 ifeq ($(NO_SIGIO),)
1012                         DEFS+=-DHAVE_SIGIO_RT
1013                 endif
1014         endif
1015         ifeq ($(NO_SELECT),)
1016                 DEFS+=-DHAVE_SELECT
1017         endif
1018 endif
1019
1020 ifeq  ($(OS), solaris)
1021         DEFS+= -DHAVE_GETIPNODEBYNAME -DHAVE_SYS_SOCKIO_H -DHAVE_SCHED_YIELD \
1022                         -DHAVE_ALLOCA_H -DUSE_SIGACTION
1023         ifneq ($(found_lock_method), yes)
1024                 DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1025                 found_lock_method=yes
1026         endif
1027         # check for ver >= 5.7
1028         ifeq ($(shell [ $(OSREL_N) -gt 5007 ] && echo has_devpoll), has_devpoll)
1029                 ifeq ($(NO_DEVPOLL),)
1030                         DEFS+=-DHAVE_DEVPOLL
1031                 endif
1032         endif
1033         ifeq ($(NO_SELECT),)
1034                 DEFS+=-DHAVE_SELECT
1035         endif
1036         ifeq ($(mode), release)
1037                 #use these only if you're using gcc with Solaris ld
1038                 #LDFLAGS=-O2 $(PROFILE)
1039                 #MOD_LDFLAGS=-O2 -G
1040         else
1041                 #LDFLAGS=-g $(PROFILE)
1042                 #MOD_LDFLAGS=-g -G
1043         endif
1044         YACC=yacc
1045
1046 ifeq ($(CC_NAME), suncc)
1047         LIBS= -lfast -ldl -lresolv
1048 endif
1049         OLD_SOLARIS= $(shell echo "$(OSREL)" | \
1050                                 sed -e 's/^5\.[0-6][^0-9]*$$/yes/' )
1051         LIBS+= -L$(LOCALBASE)/lib -lfl -lxnet -lnsl 
1052 ifeq    ($(OLD_SOLARIS), yes)
1053                 LIBS+=-lposix4
1054 else
1055                 LIBS+=-lrt
1056 endif
1057         # -lrt needed for sched_yield
1058 endif
1059
1060 ifeq ($(OS), freebsd)
1061         DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
1062                 -DHAVE_SCHED_YIELD -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_CONNECT_ECONNRESET_BUG
1063         ifneq ($(found_lock_method), yes)
1064                 DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1065                 found_lock_method=yes
1066                 LIBS= -pthread -lfl  #dlopen is in libc
1067         else
1068                 LIBS= -lfl  #dlopen is in libc
1069         endif
1070         # check for ver >= 4.1
1071         ifeq ($(shell [ $(OSREL_N) -gt 4001 ] && echo has_kqueue), has_kqueue)
1072                 ifeq ($(NO_KQUEUE),)
1073                         DEFS+=-DHAVE_KQUEUE
1074                 endif
1075         endif
1076         ifeq ($(NO_SELECT),)
1077                 DEFS+=-DHAVE_SELECT
1078         endif
1079         YACC=yacc
1080 endif
1081
1082 ifeq ($(OS), openbsd)
1083         DEFS+=-DHAVE_SOCKADDR_SA_LEN  -DHAVE_GETHOSTBYNAME2 \
1084                 -DHAVE_UNION_SEMUN -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_CONNECT_ECONNRESET_BUG
1085         ifneq ($(found_lock_method), yes)
1086                 DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1087                 found_lock_method=yes
1088         endif
1089         # check for ver >=2 9
1090         ifeq ($(shell [ $(OSREL_N) -ge 2009 ] && echo has_kqueue), has_kqueue)
1091                 ifeq ($(NO_KQUEUE),)
1092                         DEFS+=-DHAVE_KQUEUE
1093                 endif
1094         endif
1095         ifeq ($(NO_SELECT),)
1096                 DEFS+=-DHAVE_SELECT
1097         endif
1098         # (symbols on openbsd are prefixed by "_")
1099         YACC=yacc
1100         # no sched_yield on openbsd unless linking with c_r (not recommended)
1101         LIBS= -lfl 
1102         OPENBSD_IS_AOUT= $(shell echo "$(OSREL)" | \
1103                                 sed -e 's/^3\.[0-3][^0-9]*$$/yes/' |sed -e 's/^[0-2]\..*/yes/')
1104 # exception: on sparc openbsd 3.2 is elf and not aout
1105 ifeq ($(OSREL), 3.2)
1106 ifeq    ($(ARCH), sparc)
1107                 OPENBSD_IS_AOUT:=no
1108 endif
1109 ifeq    ($(ARCH), sparc64)
1110                 OPENBSD_IS_AOUT:=no
1111 endif
1112 endif
1113         
1114 ifeq ($(OPENBSD_IS_AOUT), yes)
1115                 DEFS+=-DDLSYM_PREFIX='"_"'
1116                 LDFLAGS=        # openbsd ld doesn't like -O2 or -E
1117 endif
1118 endif   # if opensd
1119         
1120 ifeq ($(OS), netbsd)
1121         DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 \
1122                 -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_CONNECT_ECONNRESET_BUG
1123         ifneq ($(found_lock_method), yes)
1124                 DEFS+= -DUSE_SYSV_SEM  # try pthread sems
1125                 found_lock_method=yes
1126         endif
1127         # check for ver >= 2.0.0
1128         ifeq ($(shell [ $(OSREL_N) -ge 2000000 ] && echo has_kqueue), has_kqueue)
1129                 ifeq ($(NO_KQUEUE),)
1130                         DEFS+=-DHAVE_KQUEUE
1131                         # netbsd + kqueue and -malign-double don't work
1132                         CFLAGS:=$(filter-out -malign-double, $(CFLAGS))
1133                 endif
1134         endif
1135         ifeq ($(NO_SELECT),)
1136                 DEFS+=-DHAVE_SELECT
1137         endif
1138         YACC=yacc
1139         LIBS= -lfl 
1140 endif
1141
1142 # OS X support, same as freebsd
1143 ifeq ($(OS), darwin)
1144         DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
1145                 -DHAVE_SCHED_YIELD -DHAVE_MSGHDR_MSG_CONTROL \
1146                 -DUSE_ANON_MMAP \
1147                 -DNDEBUG -DHAVE_CONNECT_ECONNRESET_BUG
1148         # -DNDEBUG used to turn off assert (assert wants to call
1149         # eprintf which doesn't seem to be defined in any shared lib
1150         ifneq ($(found_lock_method), yes)
1151                 DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1152                 found_lock_method=yes
1153                 LIBS= -pthread -lfl -lresolv  #dlopen is in libc
1154         else
1155                 LIBS= -lfl -lresolv  #dlopen is in libc
1156         endif
1157         ifeq ($(NO_KQUEUE),)
1158                 DEFS+=-DHAVE_KQUEUE
1159         endif
1160         ifeq ($(NO_SELECT),)
1161                 DEFS+=-DHAVE_SELECT
1162         endif
1163         LDFLAGS=        # darwin doesn't like -O2 or -E
1164         MOD_LDFLAGS= -bundle -bundle_loader ../../$(MAIN_NAME)
1165         YACC=yacc
1166 endif
1167
1168 ifneq (,$(findstring CYGWIN, $(OS)))
1169         #cygwin is the same as common
1170         ifneq ($(found_lock_method), yes)
1171                 DEFS+= -DUSE_SYSV_SEM  # try sys v sems
1172                 found_lock_method=yes
1173         endif
1174 endif
1175
1176 #add libssl if needed
1177 ifneq ($(TLS),)
1178 DEFS+= -I$(LOCALBASE)/ssl/include
1179 LIBS+= -L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib -lssl  -lcrypto
1180 endif
1181
1182 ifneq ($(found_lock_method), yes)
1183 $(warning       No locking method found so far, trying SYS V sems)
1184                 DEFS+= -DUSE_SYSV_SEM  # try sys v sems
1185                 found_lock_method=yes
1186 endif
1187
1188
1189
1190
1191
1192 endif  # ifeq ($(makefile_defs, 1)