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