- ipv6 support (-DUSE_IPV6)
[sip-router] / Makefile.defs
1 # $Id$
2 #
3 # makefile defs (CC, LD,a.s.o)
4 #
5
6
7 #version number
8 VERSION = 0
9 PATCHLEVEL = 8
10 SUBLEVEL = 8
11 EXTRAVERSION = -1-ipv6
12
13 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
14 OS = $(shell uname -s)
15 ARCH = $(shell uname -m |sed -e s/i.86/i386/ -e s/sun4u/sparc64/ )
16
17 # compile-time options
18 #
19 # -DSTATS
20 #               allows to print out number of packets processed on CTRL-C;
21 #               implementation still nasty and reports per-process
22 # -DNO_DEBUG
23 #               turns off some of the debug messages (DBG(...)).
24 # -DNO_LOG
25 #               completely turns of all the logging (and DBG(...))
26 # -DEXTRA_DEBUG
27 #               compiles in some extra debugging code
28 # -DDNS_IP_HACK
29 #               faster ip address resolver for ip strings (e.g "127.0.0.1")
30 # -DSHM_MEM
31 #               compiles in shared mem. support, needed by some modules and
32 #               by USE_SHM_MEM
33 # -DSHM_MMAP
34 #               use mmap instead of SYSV shared memory
35 # -DPKG_MALLOC
36 #               uses a faster malloc (exclusive w/ USE_SHM_MEM)
37 # -DUSE_SHM_MEM
38 #               all pkg_malloc => shm_malloc (most mallocs use a common sh.
39 #               mem. segment); don't define PKG_MALLOC if you want this!
40 # -DDBG_QM_MALLOC
41 #               qm_malloc debug code, will cause pkg_malloc and shm_malloc
42 #               to keep and display lot of debuging information: file name,
43 #               function, line number of malloc/free call for each block,
44 #               extra error checking (trying to free the same pointer
45 #               twice, trying to free a pointer alloc'ed with a different
46 #               malloc etc.)
47 # -DVQ_MALLOC
48 #               additional option to PKG_MALLOC which utilizes a fater then
49 #               qm version
50 #               (not true anymore, q_malloc performs approx. the same)
51 # -DF_MALLOC
52 #               an even faster malloc, not recommended for debugging
53 # -DDBG_MALLOC
54 #               issues additional debugging information if lock/unlock is called
55 # -DFAST_LOCK
56 #               uses fast arhitecture specific locking (see the arh. specific section)
57 # -DNOISY_REPLIES
58 #               turns on appending User-agent and Content-length:0 to ser-generated
59 #               replies; 
60 # -DBUSY_WAIT
61 #               uses busy waiting on the lock
62 # -DADAPTIVE_WAIT
63 #               try busy waiting for a while and if the lock is still held go to
64 #               force reschedule
65 # -DADAPTIVE_WAIT_LOOPS=number
66 #               number of loops we busy wait, after "number" loops have elapsed we 
67 #               force a reschedule
68 # -DNOSMP
69 #               don't use smp compliant locking (faster but won't work on SMP machines)
70 #               (not yet enabled)
71 # -DWAIT
72 #               protection against race condiditions; turn off only for debugging;
73 #       to become non-optional if stable
74 # -DNEW_HNAME
75 #               32-bit header name parsing; turn off for lower speed ;-) or debugging;
76 #               to become non-optional if fast and stable
77 # -DSILENT_FR
78 #               if defined, when FR timer hits (in tm) cancel is sent only if forking
79 #               if used; otherwise, just delete the transaction without doing anything
80 # -DUSE_IPV6
81 #               compiles ipv6 support
82
83 DEFS+= -DNAME='"$(NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
84          -DOS='"$(OS)"' -DCOMPILER='"$(CC_VER)"'\
85          -DDNS_IP_HACK  -DPKG_MALLOC \
86          -DF_MALLOC \
87          -DSHM_MEM  -DSHM_MMAP \
88          -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 \
89          -DWAIT -DNEW_HNAME \
90          -DUSE_IPV6 \
91          #-DVERY_NOISY_REPLIES\
92          #-DSILENT_FR \
93          #-DNO_DEBUG \
94          #-DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=0 \
95          #-DNOSMP \
96          #-DEXTRA_DEBUG 
97          #-DVQ_MALLOC  -DDBG_LOCK  #-DSTATS
98          #-DDBG_QM_MALLOC 
99 # -DUSE_SHM_MEM
100 #-DSTATS 
101 #-DNO_LOG
102
103
104
105 #PROFILE=  -pg #set this if you want profiling
106 #mode = debug
107 mode = release
108
109 # platform dependent settings
110
111
112 #common
113 CC=gcc
114 LD= $(CC)
115 CC_LONGVER=$(shell if  $(CC) -v 2>/dev/null; then \
116                                                 $(CC) -v 2>&1 ;\
117                                         else \
118                                                 $(CC) -V 2>&1 ; \
119                                         fi )
120 MKTAGS=ctags -R .
121
122 #find-out the compiler's name
123
124 ifneq (,$(findstring gcc, $(CC_LONGVER)))
125         CC_NAME=gcc
126         CC_VER=$(CC) $(shell $(CC) --version)
127         MKDEP=$(CC) -MM $(DEFS)
128         #transform gcc version into 2.9x or 3.0
129         CC_SHORTVER=$(shell $(CC) --version | \
130                                  sed -e 's/[^0-9]*-\(.*\)/\1/'| \
131                                  sed -e 's/2\.9.*/2.9x/' -e 's/3\..\..*/3.0/')
132 endif
133
134 ifneq (, $(findstring Sun, $(CC_LONGVER)))
135         CC_NAME=suncc
136         CC_SHORTVER=$(shell echo $(CC_LONGVER)|head -1| \
137                                         sed -e 's/.*\([0-9]\.[0-9]\).*/\1/g' )
138         CC_VER=$(CC) $(CC_SHORTVER)
139         MKDEP=$(CC) -xM1 $(DEFS)
140 endif
141
142 ifneq (, $(findstring Intel(R) C++ Compiler, $(CC_LONGVER)))
143         # very nice: gcc compatible
144         CC_NAME=icc
145         CC_FULLVER=$(shell echo "$(CC_LONGVER)"|head -1| \
146                                         sed -e 's/.*Version \([0-9]\.[0-9]\.[0-9]*\).*/\1/g' )
147         CC_SHORTVER=$(shell echo "$(CC_FULLVER)" | cut -d. -f1,2 )
148         CC_VER=$(CC) $(CC_FULLVER)
149         MKDEP=$(CC) -MM $(DEFS)
150 endif
151
152
153 ifeq (,$(CC_NAME))
154 #not found
155         CC_NAME=$(CC)
156         CC_SHORTVER=unknown
157         CC_VER=unknown
158         MKDEP=gcc -MM $(DEFS)
159 $(warning       Unknown compiler $(CC)\; supported compilers: \
160                         gcc, sun cc, intel icc )
161 endif
162
163
164 # arh. specific definitions
165 ifeq ($(ARCH), i386)
166         DEFS+= -DFAST_LOCK
167 endif
168
169 ifeq ($(ARCH), sparc64)
170 ifeq    ($(CC_NAME), gcc)
171                 DEFS+= -DFAST_LOCK
172 endif
173 endif
174
175 ifeq ($(ARCH), armv4l)
176         DEFS+= -DFAST_LOCK
177 endif
178
179
180
181 # setting CFLAGS
182 ifeq ($(mode), release)
183         #if i386
184 ifeq    ($(ARCH), i386)
185                 # if gcc 
186 ifeq            ($(CC_NAME), gcc)
187                                 #common stuff
188                                 CFLAGS=-O9 -funroll-loops  -Wcast-align $(PROFILE) -Winline\
189                                         -Wall   \
190                         #if gcc 3.0
191 ifeq                    ($(CC_SHORTVER), 3.0)
192                                         CFLAGS+=-minline-all-stringops -malign-double \
193                                                         -malign-loops=4 \
194                                                         -march=athlon \
195                                                         #-mcpu=athlon
196 else
197 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
198 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
199                                         for better results)
200                                         
201                                         CFLAGS+=-m486 \
202                                                         -malign-loops=4
203 else
204                                 #really old version
205 $(warning                       You are using an old and unsupported gcc \
206                                          version ($(CC_SHORTVER)), compile at your own risk!)
207
208 endif                   # CC_SHORTVER, 2.9x
209 endif                   # CC_SHORTVER, 3.0
210
211 else            # CC_NAME, gcc
212 ifeq            ($(CC_NAME), icc)
213                         CFLAGS=-O3  -ipo -ipo_obj -unroll  $(PROFILE) \
214                                          -tpp6 -xK  #-openmp  #optimize for PIII 
215                                 # -prefetch doesn't seem to work
216                                 #( ty to inline acroos files, unroll loops,prefetch,
217                                 # optimize for PIII, use PIII instructions & vect.,
218                                 # mutlithread loops)
219 else
220                                 #other compilers
221 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
222 endif           #CC_NAME, icc
223 endif           #CC_NAME, gcc
224 endif   #ARCH, i386
225
226
227         #if sparc64
228 ifeq    ($(ARCH), sparc64)
229                         #if gcc
230 ifeq            ($(CC_NAME), gcc)
231                                 #common stuff
232                                 CFLAGS=-O9 -funroll-loops  -Wcast-align $(PROFILE) -Winline\
233                                         #-Wmissing-prototypes \
234                                 #if gcc 3.0
235 ifeq                    ($(CC_SHORTVER), 3.0)
236                                         #use 32bit for now
237                                         CFLAGS+= -mcpu=ultrasparc -mtune=ultrasparc  -m32  \
238                                         # -mcpu=v9 or ultrasparc? # -mtune implied by -mcpu
239                                         #-mno-epilogue #try to inline function exit code
240                                         #-mflat # omit save/restore
241                                         #-,faster-structs #faster non Sparc ABI structure copy ops
242 else                    # CC_SHORTVER, 3.0
243 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
244 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
245                                         for better results)
246                                         
247                                         CFLAGS+= -mv8 -Wa,-xarch=v8plus
248 else                    #CC_SHORTVER, 2.9x
249                                 #really old version
250 $(warning                       You are using an old and unsupported gcc \
251                                          version ($(CC_SHORTVER)), compile at your own risk!)
252                                         
253                                         CFLAGS+= -mv8 -Wa,-xarch=v8plus
254 endif                   #CC_SHORTVER, 2.9x
255 endif                   #CC_SHORTVER, 3.0
256
257 else            #CC_NAME, gcc
258 ifeq            ($(CC_NAME), suncc)
259                         CFLAGS+=-xO5 -fast -native -xarch=v8plusa -xCC \
260                                         -xc99 # C99 support
261                         # -Dinline="" # add this if cc < 5.3 (define inline as null)
262 else
263                                 #other compilers
264 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
265 endif           #CC_NAME, suncc
266 endif           #CC_NAME, gcc
267 endif   #ARCH, sparc64
268
269         #if ipaq/netwinder
270 ifeq    ($(ARCH), armv4l)
271                 # if gcc 
272 ifeq            ($(CC_NAME), gcc)
273                                 #common stuff
274                                 CFLAGS=-O9 -funroll-loops  -Wcast-align $(PROFILE) -Winline\
275                                         -Wall   \
276                         #if gcc 3.0
277 ifeq                    ($(CC_SHORTVER), 3.0)
278                                         CFLAGS+= -mcpu=strongarm1100
279                                                         #-mcpu=athlon
280 else
281 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
282 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
283                                         for better results)
284                                         
285                                         CFLAGS+=
286 else
287                                 #really old version
288 $(warning                       You are using an old and unsupported gcc \
289                                          version ($(CC_SHORTVER)), compile at your own risk!)
290
291 endif                   # CC_SHORTVER, 2.9x
292 endif                   # CC_SHORTVER, 3.0
293
294 else            # CC_NAME, gcc
295                                 #other compilers
296 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
297 endif           #CC_NAME, gcc
298 endif   #ARCH, i386
299
300
301         
302
303
304 # setting LDFLAGS
305 ifeq    ($(CC_NAME), gcc)
306         #gcc and maybe others
307         LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE) 
308 endif
309 ifeq    ($(CC_NAME), icc)
310         #gcc and maybe others
311         LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE) 
312 endif
313 ifeq    ($(CC_NAME), suncc)
314         LDFLAGS+=-xO5 $(PROFILE)
315 endif
316         # we need -fPIC -DPIC only for shared objects, we don't need them for
317         # the executable file, because it's always loaded at a fixed address
318         # -andrei
319 else    #mode,release
320 ifeq    ($(CC_NAME), gcc)
321                 CFLAGS=-g -Wcast-align -Winline $(PROFILE)
322                 LDFLAGS+=-g -Wl,-E $(PROFILE)
323 endif
324 ifeq    ($(CC_NAME), icc)
325                 CFLAGS=-g  $(PROFILE)
326                 LDFLAGS+=-g -Wl,-E $(PROFILE)
327 endif
328 ifeq    ($(CC_NAME), suncc)
329                 CFLAGS= -g $(PROFILE)
330                 LDFLAGS+=-g $(PROFILE)
331 endif
332
333 endif #mode=release
334
335
336 #*FLAGS used for compiling the modules
337 ifeq    ($(CC_NAME), gcc)
338 MOD_CFLAGS=-fPIC -DPIC $(CFLAGS)
339 MOD_LDFLAGS=-shared $(LDFLAGS)
340 endif
341 ifeq    ($(CC_NAME), icc)
342 MOD_CFLAGS=-Kpic $(CFLAGS)
343 MOD_LDFLAGS=-shared $(LDFLAGS)
344 endif
345 ifeq    ($(CC_NAME), suncc)
346 MOD_CFLAGS=-Kpic  $(CFLAGS)
347 MOD_LDFLAGS=-G $(LDFLAGS)
348 endif
349
350 LEX=flex
351 YACC=bison
352 YACC_FLAGS=-d -b cfg
353 # on linux and freebsd keep it empty (e.g. LIBS= )
354 # on solaris add -lxnet (e.g. LIBS= -lxnet)
355 LIBS=-lfl -ldl
356
357
358 #os specific stuff
359 ifeq ($(OS), Linux)
360         #same as common
361 endif
362
363 ifeq  ($(OS), SunOS)
364         ifeq ($(mode), release)
365                 #use these only if you're using gcc with Solaris ld
366                 #LDFLAGS=-O2 $(PROFILE)
367                 #MOD_LDFLAGS=-O2 -G
368         else
369                 #LDFLAGS=-g $(PROFILE)
370                 #MOD_LDFLAGS=-g -G
371         endif
372
373         YACC=yacc
374
375 ifeq ($(CC_NAME), suncc)
376         LIBS=-lfast
377 endif
378         LIBS+=-ldl -L/usr/local/lib -L/usr/lib/mysql -lfl -lxnet -lrt
379         # -lrt needed for sched_yield
380 endif
381
382 ifeq ($(OS), FreeBSD)
383
384         YACC=yacc
385         LIBS= -lfl  #dlopen is in libc
386
387 endif
388
389 ifneq (,$(findstring CYGWIN, $(OS)))
390         #cygwin is the same as common
391 endif
392