f1ccddc4cabbd99acdeb98b0b1c22713754ec7f6
[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 #  2005-09-12  -mallign-double removed (too many problems) (andrei)
47 #  2005-10-02  distcc get gcc version hack (andrei)
48 #  2006-03-30  64 bit mode compile by default on sparc64 (-m64), added
49 #              CC_GCC_LIKE_ASM and SPARC64_MODE (andrei)
50 #              sparc <= v8 support (andrei)
51 #  2006-03-31  armv6 & mips64 support added
52 #              mips and arm set to NOSMP by default (andrei)
53 #  2006-07-10  added -DPROFILING (hscholz)
54 #  2007-02-09  added TLS_HOOKS and CORE_TLS support, obsoleted TLS=1
55 #              added TLS_EXTRA_LIBS (andrei)
56 #  2007-03-16  added LIB building options: LIB_LDFLAGS, LIB_SONAME, LIB_RPATH,
57 #                INSTALL_LIB, libraries install paths (andrei)
58 #  2007-05-14  futex support if linux 2.5.70+ and 
59 #               use_futex=yes (default) (andrei)
60 #  2007-05-26  changed darwin module link flags (instead of -bundle_loader ser
61 #               -flat_namespace -undefined suppress) (andrei)
62 #  2007-07-07  use isainfo -n to detect cpu type on solaris (andrei)
63 #  2007-07-07  added HAVE_SCHED_SETSCHEDULER for linux (andrei)
64 #  2007-07-18  added DNS_WATCHDOG_SUPPORT (Miklos)
65 #  2007-07-30  added USE_DNS_CACHE_STATS and USE_DST_BLACKLIST_STATS (Gergo)
66 #  2008-06-26  support for make cfg / config.mak and hack to load 
67 #               automatically config.mak when included from a module, lib 
68 #               a.s.o (not from the main Makefile)  (andrei)
69
70
71 # check if already included/exported
72
73
74 # used for sanity checks for Makefile.defs inclusion (!= makefile_defs which
75 # specifies if we have a set of valid defs)
76 override makefile_defs_included:=1
77 ifeq ($(makefile_defs),1)
78 $(info Makefile.defs defs skipped)
79 else
80
81 ifeq (,$(main_makefile))
82 # hack to automatically use config.mak in all the modules, without 
83 # changing the current module makefiles (which all include Makefile.defs):
84 # if not called from the main makefile (module, lib or ut):
85 # include config.mak, but if not present or incomplete (makefile_defs!=1)
86 # don't export the vars)
87 COREPATH?= ../..
88 include $(COREPATH)/config.mak
89 $(info config.mak included)
90 # config.mak should set makefile_defs if complete
91 export makefile_defs
92
93 else
94 override makefile_defs=1
95 export makefile_defs
96
97
98 $(info normal Makefile.defs exec)
99 # main binary name
100 MAIN_NAME=ser
101
102 #version number
103 VERSION = 2
104 PATCHLEVEL = 1
105 SUBLEVEL =  0
106 EXTRAVERSION = -dev23-make
107
108 SER_VER = $(shell expr $(VERSION) \* 1000000 + $(PATCHLEVEL) \* 1000 + \
109                         $(SUBLEVEL) )
110 RELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
111 OS = $(shell uname -s | sed -e s/SunOS/solaris/ -e s/CYGWIN.*/cygwin/ \
112                  | tr "[A-Z]" "[a-z]")
113
114 ifeq ($(OS),solaris)
115         GETARCH=isainfo -n
116 ifeq ($(GETARCH),)
117         GETARCH=uname -p
118 endif
119 else
120         GETARCH=uname -m
121 endif
122
123 ARCH := $(shell $(GETARCH) |sed -e s/i.86/i386/ -e s/sun4[uv]/sparc64/  \
124                         -e s/armv[3-5].*/arm/  -e s/armv6.*/arm6/ \
125                         -e "s/Power Macintosh/ppc/" \
126                         -e "s/cobalt/mips2/" \
127                         -e s/amd64/x86_64/ -e s/sparcv9/sparc64/ )
128 # fix sparc -> sparc64
129 ifeq ($(ARCH),sparc)
130         ifeq ($(shell uname -m),sun4u)
131                 ARCH := sparc64
132         endif
133         ifeq ($(shell uname -m),sun4v)
134                 ARCH := sparc64
135         endif
136 endif
137
138 OSREL = $(shell uname -r)
139 # numerical version (good for comparisons: A.B.C => A*1000000+B*1000+C)
140 OSREL_N= $(shell echo $(OSREL) | sed -e 's/^[^0-9]*//' \
141                 -e 's/^\([0-9][0-9]*\(\.[0-9][0-9]*\)*\).*$$/\1/g' | \
142                 (IFS=. read A B C D; R=0; \
143                 [ -n "$$A" ] && R=`expr $$R \* 1000 + $$A` && \
144                 [ -n "$$B" ] && R=`expr $$R \* 1000 + $$B` && \
145                 [ -n "$$C" ] && R=`expr $$R \* 1000 + $$C`; echo $$R ) )
146
147 # TLS support
148 CORE_TLS ?= 
149 # by default compile with tls hooks support (so that no ser recompile is
150 #  needed before the tls module can be used)
151 TLS_HOOKS=1
152 ifeq ($(CORE_TLS), 1)
153         RELEASE:=$(RELEASE)-tls
154         TLS_HOOKS:=0
155 endif
156 ifeq ($(TLS_HOOKS), 1)
157 #       RELEASE:=$(RELEASE)-tls
158 endif
159
160 # extra CC command line options (e.g  -march=athlon-mp)
161 CC_EXTRA_OPTS ?=
162
163 # dirs 
164 cfg_dir = etc/ser/
165 bin_dir = sbin/
166 share_dir = share/ser/
167 modules_dir = lib/ser/modules/
168 lib_dir = lib/ser/
169 ifeq ($(OS), linux)
170         doc_dir = share/doc/ser/
171         man_dir = share/man/
172         LOCALBASE ?= /usr/local
173 else
174 ifeq ($(OS), freebsd)
175         doc_dir = share/doc/ser/
176         man_dir = man/
177         LOCALBASE ?= /usr/local
178 else
179 ifeq ($(OS), openbsd)
180         doc_dir = share/doc/ser/
181         man_dir = man/
182         LOCALBASE ?= /usr/local
183 else
184 ifeq ($(OS), netbsd)
185         doc_dir = share/doc/ser
186         man_dir = man/
187         LOCALBASE ?= /usr/pkg
188 else
189 ifeq ($(OS), darwin)
190         doc_dir = share/doc/ser/
191         man_dir = man/
192         LOCALBASE ?= /usr/local
193 else
194         doc_dir = doc/ser/
195         man_dir = man/
196         LOCALBASE ?= /usr/local
197 endif
198 endif
199 endif
200 endif
201 endif
202
203 # Doxygen directory
204 doxygen_dir=doc/doxygen
205
206  # install location
207 DESTDIR ?= $(LOCALBASE)
208 PREFIX ?= $(DESTDIR)
209 prefix = $(PREFIX)
210 # install path is $(basedir) $(prefix) 
211 # example:
212 #  creating a bin. archive in /tmp, which unpacks in /usr/local
213 #  basedir=/tmp
214 #  prefix=/usr/local
215
216 BASEDIR ?=
217 basedir = $(BASEDIR)
218 # install prefixes for various stuff
219 cfg_prefix = $(basedir)$(prefix)
220 bin_prefix = $(basedir)$(prefix)
221 modules_prefix = $(basedir)$(prefix)
222 lib_prefix = $(basedir)$(prefix)
223 doc_prefix = $(basedir)$(prefix)
224 man_prefix = $(basedir)$(prefix)
225 ut_prefix = $(basedir)$(prefix)
226 share_prefix = $(basedir)$(prefix)
227
228
229 # target dirs for various stuff
230 cfg_target = $(prefix)/$(cfg_dir)
231 bin_target = $(prefix)/$(bin_dir)
232 modules_target = $(prefix)/$(modules_dir)
233 lib_target = $(prefix)/$(lib_dir)
234 doc_target = $(prefix)/$(doc_dir)
235
236
237 ifeq ($(OS), solaris)
238 #use GNU versions
239 INSTALL ?= ginstall
240 TAR ?= gtar
241 else
242 INSTALL ?= install
243 TAR ?= tar
244 endif
245
246 INSTALL_TOUCH = touch          # used to create the file first (good to 
247                                #  make solaris install work)
248 INSTALL_CFG = $(INSTALL) -m 644
249 INSTALL_BIN = $(INSTALL) -m 755
250 INSTALL_SCRIPT = $(INSTALL) -m 755
251 INSTALL_MODULES = $(INSTALL) -m 755
252 INSTALL_LIB = $(INSTALL) -m 755
253 INSTALL_DOC = $(INSTALL) -m 644
254 INSTALL_MAN = $(INSTALL) -m 644
255 INSTALL_SHARE = $(INSTALL) -m 644
256
257 #set some vars from the environment (and not make builtins)
258 CC   := $(shell echo "$${CC}")
259 LEX  := $(shell echo "$${LEX}")
260 YACC := $(shell echo "$${YACC}")
261
262
263
264
265 # find compiler name & version
266 ifeq ($(CC),)
267         CC=gcc
268 endif
269 LD= $(CC)
270 CC_LONGVER=$(shell if  $(CC) -v 2>/dev/null; then \
271                                                 $(CC) -v 2>&1 ;\
272                                         else \
273                                                 $(CC) -V 2>&1 ; \
274                                         fi )
275 MKTAGS=ctags -R .
276
277 #find-out the compiler's name
278
279 ifneq (,$(findstring gcc, $(CC_LONGVER)))
280         CC_NAME=gcc
281         CC_VER=$(word 1,$(CC)) $(shell $(CC) - --version|head -n 1|cut -d" " -f 3|\
282                                  sed -e 's/^.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/'\
283                                          -e 's/^[^0-9].*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/')
284         # sed with POSIX.1 regex doesn't support |, + or ? 
285         # (darwin, solaris ...) => this complicated expression
286         MKDEP=$(CC) -MM 
287         #transform gcc version into 2.9x or 3.0
288         CC_SHORTVER=$(shell echo "$(CC_VER)" | cut -d" " -f 2| \
289                                  sed -e 's/[^0-9]*-\(.*\)/\1/'| \
290                                  sed -e 's/2\.9.*/2.9x/' -e 's/3\.[0-3]\..*/3.0/' -e \
291                                         's/3\.[0-3]/3.0/' -e 's/3\.[4-9]\..*/3.4/' -e \
292                                         's/3\.[4-9]/3.4/' -e 's/4\.[0-9]\..*/4.x/' -e \
293                                         's/4\.[0-9]/4.x/' )
294 endif
295
296 ifneq (, $(findstring Sun, $(CC_LONGVER)))
297         CC_NAME=suncc
298         CC_SHORTVER=$(shell echo "$(CC_LONGVER)"|head -n 1| \
299                                         sed -e 's/.*\([0-9]\.[0-9]\).*/\1/g' )
300         CC_VER=$(CC) $(CC_SHORTVER)
301         MKDEP=$(CC) -xM1 
302 endif
303
304 ifneq (, $(findstring Intel(R) C++ Compiler, $(CC_LONGVER)))
305         # very nice: gcc compatible
306         CC_NAME=icc
307         CC_FULLVER=$(shell echo "$(CC_LONGVER)"|head -n 1| \
308                                         sed -e 's/.*Version \([0-9]\.[0-9]\.[0-9]*\).*/\1/g' )
309         CC_SHORTVER=$(shell echo "$(CC_FULLVER)" | cut -d. -f1,2 )
310         CC_VER=$(CC) $(CC_FULLVER)
311         MKDEP=$(CC) -MM 
312 endif
313
314
315 ifeq (,$(CC_NAME))
316 #not found
317         CC_NAME=$(CC)
318         CC_SHORTVER=unknown
319         CC_VER=unknown
320         MKDEP=gcc -MM 
321 $(warning       Unknown compiler $(CC)\; supported compilers: \
322                         gcc, sun cc, intel icc )
323 endif
324
325
326 # compile-time options
327 #
328 # -DSTATS
329 #               allows to print out number of packets processed on CTRL-C;
330 #               implementation still nasty and reports per-process
331 # -DNO_DEBUG
332 #               turns off some of the debug messages (DBG(...)).
333 # -DNO_LOG
334 #               completely turns of all the logging (and DBG(...))
335 # -DEXTRA_DEBUG
336 #               compiles in some extra debugging code
337 # -DDNS_IP_HACK
338 #               faster ip address resolver for ip strings (e.g "127.0.0.1")
339 # -DSHM_MEM
340 #               compiles in shared mem. support, needed by some modules and
341 #               by USE_SHM_MEM
342 # -DSHM_MMAP
343 #               use mmap instead of SYSV shared memory
344 # -DPKG_MALLOC
345 #               uses a faster malloc (exclusive w/ USE_SHM_MEM)
346 # -DUSE_SHM_MEM
347 #               all pkg_malloc => shm_malloc (most mallocs use a common sh.
348 #               mem. segment); don't define PKG_MALLOC if you want this!
349 # -DDBG_QM_MALLOC
350 #               qm_malloc debug code, will cause pkg_malloc and shm_malloc
351 #               to keep and display lot of debuging information: file name,
352 #               function, line number of malloc/free call for each block,
353 #               extra error checking (trying to free the same pointer
354 #               twice, trying to free a pointer alloc'ed with a different
355 #               malloc etc.)
356 # -DVQ_MALLOC
357 #               additional option to PKG_MALLOC which utilizes a fater then
358 #               qm version
359 #               (not true anymore, q_malloc performs approx. the same)
360 # -DF_MALLOC
361 #               an even faster malloc, not recommended for debugging
362 # -DDL_MALLOC
363 #               a malloc implementation based on Doug Lea's dl_malloc
364 # -DSF_MALLOC 
365 #               an experimental multi-CPU, pool based, multi-process safe version of 
366 #               F_MALLOC. Should give better performance on machines with lots of CPUs
367 #               after some tunning.
368 # -DLL_MALLOC
369 #               an experimental multi-CPU, pool based, multi-process safe, mostly
370 #               lockless version of SF_MALLOC/F_MALLOC. Not for production use for
371 #               now.
372 # -DDBG_MALLOC
373 #               issues additional debugging information if lock/unlock is called
374 # -DFAST_LOCK
375 #               uses fast arhitecture specific locking (see the arh. specific section)
376 # -DUSE_SYSV_SEM
377 #               uses sys v sems for locking (slower & limited number)
378 # -DUSE_PTHREAD_MUTEX
379 #               uses pthread mutexes, faster than sys v or posix sems, but do not 
380 #               work on all systems inter-processes (e.g. linux)
381 # -DUSE_POSIX_SEM
382 #               uses posix semaphores for locking (faster than sys v)
383 # -DUSE_FUTEX
384 #               uses futexes for locking (linux 2.6+)
385 # -DBUSY_WAIT
386 #               uses busy waiting on the lock (FAST_LOCK)
387 # -DADAPTIVE_WAIT
388 #               try busy waiting for a while and if the lock is still held go to
389 #               force reschedule (FAST_LOCK)
390 # -DADAPTIVE_WAIT_LOOPS=number
391 #               number of loops we busy wait, after "number" loops have elapsed we 
392 #               force a reschedule (FAST_LOCK)
393 # -DNOSMP
394 #               don't use smp compliant locking (faster but won't work on SMP machines)
395 #               (not yet enabled) (FAST_LOCK)
396 # -DNO_PINGTEL_TAG_HACK
397 #               if enabled, To-header-field will be less liberal and will not accept
398 #               'tag=' (tag parameter with equal sign and without value); it is called
399 #               this way because such message was sighted from a Pingtel phone
400 # -DUSE_TCP
401 #               compiles in tcp support
402 # -DDISABLE_NAGLE
403 #               disable the tcp Nagle algorithm (lower delay)
404 # -DUSE_TLS
405 #               compiles in tls support, requires -DUSE_TCP. Note: this is only 
406 #               generic support (parsing a.s.o.), it does not include the actual
407 #               "tls engine". If you really want tls you need also either
408 #               -DCORE_TLS and a tls/ subdir with the tls code or -DTLS_HOOKS and
409 #               the tls module loaded.
410 # -DCORE_TLS
411 #               compiles tls in-core support. Requires -DUSE_TLS, conflicts 
412 #               -DTLS_HOOKS. Please use make CORE_TLS=1 instead  (it will set all the
413 #               needed defines automatically and extra libraries needed for linking).
414 # -DTLS_HOOKS
415 #               compile tls module support (support for having the "tls engine" in a
416 #               module). Requires -DUSE_TLS, conflicts -DCORE_TLS.
417 #               Please use make TLS_HOOKS=1 (or TLS_HOOKS=0 to for disabling) instead
418 #               of setting -DTLS_HOOKS (it will set all the needed defines 
419 #               automatically)
420 # -DHAVE_RESOLV_RES
421 #               support for changing some of the resolver parameters present
422 #                (_res structure in <resolv.h>)
423 # -DUSE_COMP
424 #               compiles in comp=[sergz|sigcomp] support (parsing uri & via, 
425 #               adding it to via, lumps a.s.o). WARNING: right now this option
426 #               is useless since the compression code doesn't exist yet.
427 # -DHONOR_MADDR
428 #               compiles in checks and use for maddr parameter in uri.
429 #               Required to support Windows Messenger 5.x over TCP connection
430 #               which (mis)uses this parameter.
431 # -DUSE_DNS_CACHE
432 #               use an internal dns cache instead of making dns requests each time
433 # -DUSE_DNS_CACHE_STATS
434 #               turns on DNS cache measurements
435 # -DUSE_DNS_FAILOVER
436 #               if the destination resolves to multiple ips, on send error fall back
437 #               to the others
438 # -DUSE_DST_BLACKLIST
439 #               blacklist bad destination (timeout, failed to connect, error sending
440 #        a.s.o)
441 # -DUSE_DST_BLACKLIST_STATS
442 #               turns on blacklist bad destination measurements
443 # -DPROFILING
444 #               if enabled profiling will be enabled for child processes
445 #               Don't forget to set PROFILE (see below)
446 # -DUSE_STUN
447 #               compiles in stun support
448 # -DNO_SIG_DEBUG
449 #        turns off debugging messages in signal handlers (which might be 
450 #         unsafe)
451 # -DUSE_NAPTR
452 #                turns on naptr support (but must be also enabled from the config)
453 # -DDNS_WATCHDOG_SUPPORT
454 #               turns on DNS watchdog support which can be used to inform the
455 #               core that the DNS servers are down. No DNS query is performed
456 #               when the servers are unreachable, and even expired resource
457 #               records are used from the cache. (requires external watchdog)
458 # Sometimes is needes correct non-quoted $OS. HACK: gcc translates known OS to number ('linux'), so there is added underscore
459
460 DEFS= $(extra_defs) \
461          -DNAME='"$(MAIN_NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
462          -DOS='$(OS)_' -DOS_QUOTED='"$(OS)"' -DCOMPILER='"$(CC_VER)"' -D__CPU_$(ARCH) -D__OS_$(OS) \
463          -DSER_VER=$(SER_VER) \
464          -DCFG_DIR='"$(cfg_target)"'\
465          -DMODS_DIR='"$(modules_target)"'\
466          -DPKG_MALLOC \
467          -DSHM_MEM  -DSHM_MMAP \
468          -DDNS_IP_HACK \
469          -DUSE_IPV6 \
470          -DUSE_MCAST \
471          -DUSE_TCP \
472          -DDISABLE_NAGLE \
473          -DHAVE_RESOLV_RES \
474          -DUSE_DNS_CACHE \
475          -DUSE_DNS_FAILOVER \
476          -DUSE_DST_BLACKLIST \
477          -DUSE_NAPTR \
478          -DDBG_QM_MALLOC \
479          #-DUSE_DNS_CACHE_STATS \
480          #-DUSE_DST_BLACKLIST_STATS \
481          #-DDNS_WATCHDOG_SUPPORT \
482          #-DLL_MALLOC \
483          #-DSF_MALLOC \
484          #-DDL_MALLOC \
485          #-DF_MALLOC \
486          #-DDBG_QM_MALLOC \
487          #-DDBG_F_MALLOC \
488          #-DNO_DEBUG \
489          #-DEXTRA_DEBUG \
490          #-DVQ_MALLOC  \
491          #-DDBG_LOCK \
492          #-DNOSMP \
493          #-DUSE_SHM_MEM \
494          #-DSTATS \
495          #-DNO_LOG \
496          #-DPROFILING \
497          #-DNO_SIG_DEBUG
498
499 #PROFILE=  -pg  # set this if you want profiling
500                                 # you may also want to set -DPROFILING
501
502 # WARNING: do not add mode=debug or mode=release anymore in the Makefile,
503 # use make mode=debug all instead. Anyway no by default ser is  compiled w/ 
504 # debugging symbols in all cases (-g). --andrei
505
506 ifeq ($(CORE_TLS), 1)
507         DEFS+= -DUSE_TLS -DCORE_TLS
508 endif
509 ifeq ($(TLS_HOOKS), 1)
510         DEFS+= -DUSE_TLS -DTLS_HOOKS
511 endif
512
513 ifneq ($(STUN),)
514         DEFS+= -DUSE_STUN
515 endif
516
517 ifeq ($(mode),)
518         mode = release
519 endif
520
521 ifeq ($(mode),debug)
522         DEFS+= -DEXTRA_DEBUG
523 endif
524
525 # platform dependent settings
526
527 # find ld & as name (gnu or solaris)
528 ifeq ($(OS), solaris)
529 ifeq ($(CC_NAME), gcc)
530                 LDGCC=$(shell $(CC) -v 2>&1 | grep with-ld| \
531                                    sed -e 's/.*--with-ld=\([^ ][^ ]*\).*/\1/' )
532                 ASGCC=$(shell $(CC) -v 2>&1 | grep with-as| \
533                                    sed -e 's/.*--with-as=\([^ ][^ ]*\).*/\1/' )
534                 LDPATH=$(shell  if [ -z "$(LDGCC)" ] ; then echo "ld" ;\
535                                                 else \
536                                                 if $(LDGCC) -V 2>/dev/null 1>/dev/null; then \
537                                                         echo $(LDGCC); \
538                                                 else echo "ld" ; \
539                                                 fi\
540                                                 fi)
541                 ASPATH=$(shell  if [ -z "$(ASGCC)" ] ; then echo "as" ;\
542                                                 else \
543                                                 if $(ASGCC) -V 2>/dev/null 1>/dev/null; then \
544                                                         echo $(ASGCC); \
545                                                 else echo "as" ; \
546                                                 fi\
547                                                 fi)
548                                                         
549                 LDTYPE=$(shell if $(LDPATH) -V 1>/dev/null  2>/dev/null; then \
550                                                         if $(LDPATH) -V 2>&1|grep GNU >/dev/null; \
551                                                         then echo gnu; \
552                                                         else \
553                                                         if $(LDPATH) -V 2>&1|grep Solaris >/dev/null;\
554                                                         then echo solaris; \
555                                                         else \
556                                                                 echo unknown ; \
557                                                         fi \
558                                                         fi \
559                                                 fi)
560                 ASTYPE=$(shell if $(ASPATH) -V 1>/dev/null  2>/dev/null </dev/null; \
561                                                 then \
562                                                         if $(ASPATH) -V 2>&1 </dev/null |grep GNU >/dev/null; \
563                                                         then echo gnu; \
564                                                         else \
565                                                         if $(ASPATH) -V 2>&1 </dev/null |grep Sun >/dev/null;\
566                                                         then echo solaris; \
567                                                         else \
568                                                                 echo unknown ; \
569                                                         fi \
570                                                         fi \
571                                                 fi)
572 #$(warning "using ld=$(LDPATH)/$(LDTYPE), as=$(ASPATH)/$(ASTYPE)")
573
574 endif
575 endif
576
577 # arch. specific definitions
578 ifeq ($(ARCH), i386)
579         use_fast_lock=yes
580 endif
581
582 ifeq ($(ARCH), x86_64)
583         use_fast_lock=yes
584 endif
585
586 ifeq ($(ARCH), sparc64)
587 ifeq    ($(CC_NAME), gcc)
588         use_fast_lock=yes
589 endif
590 endif
591
592 ifeq ($(ARCH), sparc)
593         use_fast_lock=yes
594 endif
595
596 ifeq ($(ARCH), arm)
597         use_fast_lock=yes
598         DEFS+=-DNOSMP # very unlikely to have an smp arm
599 endif
600
601 ifeq ($(ARCH), arm6)
602         use_fast_lock=yes
603 endif
604
605 ifeq ($(ARCH), ppc)
606         use_fast_lock=yes
607 endif
608
609 ifeq ($(ARCH), ppc64)
610         use_fast_lock=yes
611 endif
612
613 ifeq ($(ARCH), mips)
614 # mips1 arch. (e.g. R3000) - no hardware locking support
615         use_fast_lock=no
616         DEFS+=-DMIPS_HAS_LLSC # likely
617         DEFS+=-DNOSMP # very likely
618 endif
619
620 ifeq ($(ARCH), mips2)
621 # mips2 arch and newer (mips3=R4000, mips4=R5000 a.s.o)
622         use_fast_lock=yes
623 endif
624
625 ifeq ($(ARCH), mips64)
626 # mips2 arch and newer (mips3=R4000, mips4=R5000 a.s.o)
627         use_fast_lock=yes
628 endif
629
630 ifeq ($(ARCH), alpha)
631         use_fast_lock=yes
632         DEFS+=-DNOSMP # very likely
633 endif
634
635 ifeq ($(use_fast_lock), yes)
636         DEFS+= -DFAST_LOCK -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024 
637         found_lock_method=yes
638 endif
639
640 CFLAGS=
641 LDFLAGS=
642 INCLUDES=
643 # setting CFLAGS
644 ifeq ($(mode), release)
645         #if i386
646 ifeq    ($(ARCH), i386)
647                 # if gcc 
648 ifeq            ($(CC_NAME), gcc)
649                                 DEFS+=-DCC_GCC_LIKE_ASM
650                                 #common stuff
651                                 CFLAGS=-g -O9 -funroll-loops  -Wcast-align $(PROFILE)
652                         #if gcc 4.0+
653 ifeq                    ($(CC_SHORTVER), 4.x)
654                                         CPU ?= athlon64
655                                         CFLAGS+=-minline-all-stringops \
656                                                         -falign-loops \
657                                                         -ftree-vectorize \
658                                                         -mtune=$(CPU) 
659 else
660                         #if gcc 3.4+
661 ifeq                    ($(CC_SHORTVER), 3.4)
662                                         CPU ?= athlon
663                                         CFLAGS+=-minline-all-stringops \
664                                                         -falign-loops \
665                                                         -mtune=$(CPU) 
666 else
667                         #if gcc 3.0+
668 ifeq                    ($(CC_SHORTVER), 3.0)
669                                         CPU ?= athlon
670                                         CFLAGS+=-minline-all-stringops \
671                                                         -falign-loops \
672                                                         -mcpu=$(CPU) 
673 else
674 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
675 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc >= 3.1 \
676                                         for better results)
677                                         
678                                         CFLAGS+=-m486 \
679                                                         -malign-loops=4
680 else
681                                 #really old version
682 $(warning                       You are using an old and unsupported gcc \
683                                          version  ($(CC_SHORTVER)), compile at your own risk!)
684
685 endif                   # CC_SHORTVER, 2.9x
686 endif                   # CC_SHORTVER, 3.0
687 endif                   # CC_SHORTVER, 3.4
688 endif                   # CC_SHORTVER, 4.x
689
690 else            # CC_NAME, gcc
691 ifeq            ($(CC_NAME), icc)
692                         DEFS+=-DCC_GCC_LIKE_ASM
693                         CFLAGS=-g -O3  -ipo -ipo_obj -unroll  $(PROFILE) \
694                                          -tpp6 -xK  #-openmp  #optimize for PIII 
695                                 # -prefetch doesn't seem to work
696                                 #( ty to inline acroos files, unroll loops,prefetch,
697                                 # optimize for PIII, use PIII instructions & vect.,
698                                 # mutlithread loops)
699 else
700                                 #other compilers
701 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
702 endif           #CC_NAME, icc
703 endif           #CC_NAME, gcc
704 endif   #ARCH, i386
705
706 #x86_64
707 ifeq    ($(ARCH), x86_64)
708                 # if gcc 
709 ifeq            ($(CC_NAME), gcc)
710                                 DEFS+=-DCC_GCC_LIKE_ASM
711                                 #common stuff
712                                 CFLAGS=-m64 -g -O9 -funroll-loops  -Wcast-align $(PROFILE)
713                                 LDFLAGS+=-m64
714                         #if gcc 4.0+
715 ifeq                    ($(CC_SHORTVER), 4.x)
716                                         CPU ?= opteron
717                                         CFLAGS+=-minline-all-stringops \
718                                                         -falign-loops \
719                                                         -ftree-vectorize \
720                                                         -mtune=$(CPU) 
721 else
722                         #if gcc 3.4
723 ifeq                    ($(CC_SHORTVER), 3.4)
724                                         CPU ?= athlon64
725                                         CFLAGS+=-minline-all-stringops \
726                                                         -falign-loops 
727 else
728                         #if gcc 3.0
729 ifeq                    ($(CC_SHORTVER), 3.0)
730                                         CPU ?= athlon64
731                                         CFLAGS+=-minline-all-stringops \
732                                                         -falign-loops 
733                                                         #-mcpu=$(CPU) \ # not working on all x86_64 gccs
734                                                         #-mcpu=athlon
735 else
736 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
737 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc >= 3.1 \
738                                         for better results)
739                                         
740                                         CFLAGS+=-m486 \
741                                                         -malign-loops=4
742 else
743                                 #really old version
744 $(warning                       You are using an old and unsupported gcc \
745                                          version  ($(CC_SHORTVER)), compile at your own risk!)
746
747 endif                   # CC_SHORTVER, 2.9x
748 endif                   # CC_SHORTVER, 3.0
749 endif                   # CC_SHORTVER, 3.4
750 endif                   # CC_SHORTVER, 4.x
751
752 else            # CC_NAME, gcc
753 ifeq            ($(CC_NAME), icc)
754                         DEFS+=-DCC_GCC_LIKE_ASM
755                         CFLAGS=-g -O3  -ipo -ipo_obj -unroll  $(PROFILE) \
756                                          -tpp6 -xK  #-openmp  #optimize for PIII 
757                                 # -prefetch doesn't seem to work
758                                 #( ty to inline acroos files, unroll loops,prefetch,
759                                 # optimize for PIII, use PIII instructions & vect.,
760                                 # mutlithread loops)
761 else
762                                 #other compilers
763 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
764 endif           #CC_NAME, icc
765 endif           #CC_NAME, gcc
766 endif   #ARCH, x86_64
767
768         #if sparc64
769 ifeq    ($(ARCH), sparc64)
770                         #if gcc
771 ifeq            ($(CC_NAME), gcc)
772                                 DEFS+=-DCC_GCC_LIKE_ASM -DSPARC64_MODE
773                                 #common stuff
774                                 CFLAGS=-m64 -g -O9 -funroll-loops  $(PROFILE) \
775                                         #-Wcast-align \
776                                         #-Wmissing-prototypes 
777                                 # use -m64 to force 64 bit (but add it also to LDFLAGS and
778                                 #  don't forget to define SPARC64_MODE)
779                                 # -m32 for 32 bit (default on solaris),
780                                 # nothing for arch. default
781                                 LDFLAGS+=-m64
782                                 #if gcc 4.x
783 ifeq                    ($(CC_SHORTVER), 4.x)
784                                         CPU ?= ultrasparc
785                                         #use 32bit for now
786                                         CFLAGS+=-mcpu=ultrasparc  \
787                                                         -mtune=$(CPU) \
788                                                         -ftree-vectorize
789 else
790                                 #if gcc 3.4
791 ifeq                    ($(CC_SHORTVER), 3.4)
792                                         CPU ?= ultrasparc
793                                         #use 32bit for now
794                                         CFLAGS+= -mcpu=ultrasparc -mtune=$(CPU)
795 else
796                                 #if gcc 3.0
797 ifeq                    ($(CC_SHORTVER), 3.0)
798                                         CPU ?= ultrasparc
799                                         #use 32bit for now
800                                         CFLAGS+= -mcpu=ultrasparc -mtune=$(CPU)   \
801                                         # -mcpu=v9 or ultrasparc? # -mtune implied by -mcpu
802                                         #-mno-epilogue #try to inline function exit code
803                                         #-mflat # omit save/restore
804                                         #-,faster-structs #faster non Sparc ABI structure copy ops
805 else                    # CC_SHORTVER, 3.0
806 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
807 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc >= 3.1 \
808                                         for better results)
809 ifneq                           ($(OS), netbsd)
810                                                 # on netbsd/sparc64,  gcc 2.95.3 does not compile
811                                                 # ser with -mv8
812                                                 CFLAGS+= -mv9 
813 endif
814 ifeq                                    ($(ASTYPE), solaris)
815                                                         CFLAGS+= -Wa,-xarch=v8plus
816 endif                                   
817 else                    #CC_SHORTVER, 2.9x
818                                 #really old version
819 $(warning                       You are using an old and unsupported gcc \
820                                          version ($(CC_SHORTVER)), compile at your own risk!)
821                                         
822                                         CFLAGS+= -mv9 
823 ifeq                                    ($(ASTYPE), solaris)
824                                                         CFLAGS+= -Wa,-xarch=v8plus
825 endif                                   
826         
827 endif                   #CC_SHORTVER, 2.9x
828 endif                   #CC_SHORTVER, 3.0
829 endif                   #CC_SHORTVER, 3.4
830 endif                   #CC_SHORTVER, 4.x
831         
832 else            #CC_NAME, gcc
833 ifeq            ($(CC_NAME), suncc)
834                         DEFS+=-DSPARC64_MODE
835                         CFLAGS+= -m64 -g -xO5 -fast -native -xarch=v9 -xCC \
836                                         -xc99 # C99 support
837                         # -Dinline="" # add this if cc < 5.3 (define inline as null)
838 else
839                                 #other compilers
840 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
841 endif           #CC_NAME, suncc
842 endif           #CC_NAME, gcc
843 endif   #ARCH, sparc64
844
845         #if sparc
846 ifeq    ($(ARCH), sparc)
847                         #if gcc
848 ifeq            ($(CC_NAME), gcc)
849                                 DEFS+=-DCC_GCC_LIKE_ASM
850                                 #common stuff
851                                 CFLAGS=-g -O9 -funroll-loops  $(PROFILE) \
852                                         #-Wcast-align \
853                                         #-Wmissing-prototypes 
854                                 #if gcc 4.x
855 ifeq                    ($(CC_SHORTVER), 4.x)
856                                         CPU ?= v8 
857                                         #use 32bit for now
858                                         CFLAGS+= -minline-all-stringops \
859                                                         -mtune=$(CPU) \
860                                                         -ftree-vectorize
861 else
862                                 #if gcc 3.4
863 ifeq                    ($(CC_SHORTVER), 3.4)
864                                         CPU ?= v8
865                                         #use 32bit for now
866                                         CFLAGS+= -mtune=$(CPU)
867 else
868                                 #if gcc 3.0
869 ifeq                    ($(CC_SHORTVER), 3.0)
870                                         CPU ?= v8 
871                                         #use 32bit for now
872                                         CFLAGS+= -mtune=$(CPU)   \
873                                         #-mno-epilogue #try to inline function exit code
874                                         #-mflat # omit save/restore
875                                         #-,faster-structs #faster non Sparc ABI structure copy ops
876 else                    # CC_SHORTVER, 3.0
877 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
878 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc >= 3.1 \
879                                         for better results)
880 else                    #CC_SHORTVER, 2.9x
881                                 #really old version
882 $(warning                       You are using an old and unsupported gcc \
883                                          version ($(CC_SHORTVER)), compile at your own risk!)
884                                         
885 endif                   #CC_SHORTVER, 2.9x
886 endif                   #CC_SHORTVER, 3.0
887 endif                   #CC_SHORTVER, 3.4
888 endif                   #CC_SHORTVER, 4.x
889         
890 else            #CC_NAME, gcc
891 ifeq            ($(CC_NAME), suncc)
892                         CFLAGS+= -g -xO5 -fast -native -xCC \
893                                         -xc99 # C99 support
894                         # -Dinline="" # add this if cc < 5.3 (define inline as null)
895 else
896                                 #other compilers
897 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
898 endif           #CC_NAME, suncc
899 endif           #CC_NAME, gcc
900 endif   #ARCH, sparc
901
902         #if ipaq/netwinder
903 ifeq    ($(ARCH), arm)
904                 # if gcc 
905 ifeq            ($(CC_NAME), gcc)
906                                 DEFS+=-DCC_GCC_LIKE_ASM
907                                 #common stuff
908                                 CFLAGS=-O9 -funroll-loops $(PROFILE)
909                         #if gcc 4.x+
910 ifeq                    ($(CC_SHORTVER), 4.x)
911                                         CFLAGS+= -ftree-vectorize
912                                         # not supported on arm: -minline-all-stringops 
913 else
914                         #if gcc 3.4+
915 ifeq                    ($(CC_SHORTVER), 3.4)
916                                         CFLAGS+=
917 else
918                         #if gcc 3.0
919 ifeq                    ($(CC_SHORTVER), 3.0)
920                                         CFLAGS+= 
921                                                         #-mcpu=athlon
922 else
923 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
924 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
925                                         for better results)
926                                         
927                                         CFLAGS+=
928 else
929                                 #really old version
930 $(warning                       You are using an old and unsupported gcc \
931                                          version ($(CC_SHORTVER)), compile at your own risk!)
932         
933 endif                   # CC_SHORTVER, 2.9x
934 endif                   # CC_SHORTVER, 3.0
935 endif                   # CC_SHORTVER, 3.4
936 endif                   # CC_SHORTVER, 4.0
937         
938 else            # CC_NAME, gcc
939                                 #other compilers
940 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
941 endif           #CC_NAME, gcc
942 endif   #ARCH, arm 
943
944         #if armv6 cpu 
945 ifeq    ($(ARCH), arm6)
946                 # if gcc 
947 ifeq            ($(CC_NAME), gcc)
948                                 DEFS+=-DCC_GCC_LIKE_ASM
949                                 #common stuff
950                                 CFLAGS=-march=armv6 -O9 -funroll-loops \
951                                                 $(PROFILE)
952                         #if gcc 4.x+
953 ifeq                    ($(CC_SHORTVER), 4.x)
954                                         CFLAGS+= -ftree-vectorize
955 else
956                         #if gcc 3.4+
957 ifeq                    ($(CC_SHORTVER), 3.4)
958                                         CFLAGS+=
959 else
960                         #if gcc 3.0
961 ifeq                    ($(CC_SHORTVER), 3.0)
962                                         CFLAGS+= 
963                                                         #-mcpu=athlon
964 else
965 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
966 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
967                                         for better results)
968                                         
969                                         CFLAGS+=
970 else
971                                 #really old version
972 $(warning                       You are using an old and unsupported gcc \
973                                          version ($(CC_SHORTVER)), compile at your own risk!)
974         
975 endif                   # CC_SHORTVER, 2.9x
976 endif                   # CC_SHORTVER, 3.0
977 endif                   # CC_SHORTVER, 3.4
978 endif                   # CC_SHORTVER, 4.0
979         
980 else            # CC_NAME, gcc
981                                 #other compilers
982 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
983 endif           #CC_NAME, gcc
984 endif   #ARCH, arm6
985
986         #if  mips (R3000)
987 ifeq    ($(ARCH), mips)
988                 # if gcc 
989 ifeq            ($(CC_NAME), gcc)
990                                 DEFS+=-DCC_GCC_LIKE_ASM
991                                 #common stuff
992                                 CFLAGS=-O9 -funroll-loops  $(PROFILE)
993                         #if gcc 4.0+
994 ifeq                    ($(CC_SHORTVER), 4.x)
995                                         CFLAGS+=-march=r3000 -minline-all-stringops \
996                                                         -ftree-vectorize
997 else
998                         #if gcc 3.4+
999 ifeq                    ($(CC_SHORTVER), 3.4)
1000                                         CFLAGS+= -march=r3000
1001 else
1002                         #if gcc 3.0
1003 ifeq                    ($(CC_SHORTVER), 3.0)
1004                                         CFLAGS+= -march=r3000
1005 else
1006 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1007 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
1008                                         for better results)
1009                                         
1010                                         CFLAGS+=-march=r3000
1011 else
1012                                 #really old version
1013 $(warning                       You are using an old and unsupported gcc \
1014                                          version ($(CC_SHORTVER)), compile at your own risk!)
1015         
1016 endif                   # CC_SHORTVER, 2.9x
1017 endif                   # CC_SHORTVER, 3.0
1018 endif                   # CC_SHORTVER, 3.4
1019 endif                   # CC_SHORTVER, 4.x
1020         
1021 else            # CC_NAME, gcc
1022                                 #other compilers
1023 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1024 endif           #CC_NAME, gcc
1025 endif   #ARCH, mips
1026
1027         #if  >=mips2 (R4000, R5000, R6000 ....)
1028 ifeq    ($(ARCH), mips2)
1029                 # if gcc 
1030 ifeq            ($(CC_NAME), gcc)
1031                                 DEFS+=-DCC_GCC_LIKE_ASM
1032                                 #common stuff
1033                                 CFLAGS= -mips2 -O9 -funroll-loops $(PROFILE)
1034                         #if gcc 4.0+
1035 ifeq                    ($(CC_SHORTVER), 4.x)
1036                                         CFLAGS+=-minline-all-stringops -ftree-vectorize
1037 else
1038                         #if gcc 3.4+
1039 ifeq                    ($(CC_SHORTVER), 3.4)
1040                                         CFLAGS+=
1041 else
1042                         #if gcc 3.0
1043 ifeq                    ($(CC_SHORTVER), 3.0)
1044                                         CFLAGS+=
1045 else
1046 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1047 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
1048                                         for better results)
1049                                         CFLAGS+=
1050 else
1051                                 #really old version
1052 $(warning                       You are using an old and unsupported gcc \
1053                                          version ($(CC_SHORTVER)), compile at your own risk!)
1054         
1055 endif                   # CC_SHORTVER, 2.9x
1056 endif                   # CC_SHORTVER, 3.0
1057 endif                   # CC_SHORTVER, 3.4
1058 endif                   # CC_SHORTVER, 4.x
1059         
1060 else            # CC_NAME, gcc
1061                                 #other compilers
1062 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1063 endif           #CC_NAME, gcc
1064 endif   #ARCH, mips2
1065
1066 #if  >=mips64
1067 ifeq    ($(ARCH), mips64)
1068                 # if gcc 
1069 ifeq            ($(CC_NAME), gcc)
1070                                 DEFS+=-DCC_GCC_LIKE_ASM
1071                                 #common stuff
1072                                 CFLAGS= -mips64 -O9 -funroll-loops $(PROFILE)
1073                         #if gcc 4.0+
1074 ifeq                    ($(CC_SHORTVER), 4.x)
1075                                         CFLAGS+=-minline-all-stringops -ftree-vectorize
1076 else
1077                         #if gcc 3.4+
1078 ifeq                    ($(CC_SHORTVER), 3.4)
1079                                         CFLAGS+=
1080 else
1081                         #if gcc 3.0
1082 ifeq                    ($(CC_SHORTVER), 3.0)
1083                                         CFLAGS+=
1084 else
1085 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1086 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
1087                                         for better results)
1088                                         CFLAGS+=
1089 else
1090                                 #really old version
1091 $(warning                       You are using an old and unsupported gcc \
1092                                          version ($(CC_SHORTVER)), compile at your own risk!)
1093         
1094 endif                   # CC_SHORTVER, 2.9x
1095 endif                   # CC_SHORTVER, 3.0
1096 endif                   # CC_SHORTVER, 3.4
1097 endif                   # CC_SHORTVER, 4.x
1098         
1099 else            # CC_NAME, gcc
1100                                 #other compilers
1101 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1102 endif           #CC_NAME, gcc
1103 endif   #ARCH, mips64
1104
1105 #if  alpha
1106 ifeq    ($(ARCH), alpha)
1107                 # if gcc 
1108 ifeq            ($(CC_NAME), gcc)
1109                                 DEFS+=-DCC_GCC_LIKE_ASM
1110                                 #common stuff
1111                                 CFLAGS= -O9 -funroll-loops $(PROFILE)
1112                         #if gcc 4.0+
1113 ifeq                    ($(CC_SHORTVER), 4.x)
1114                                         CFLAGS+= 
1115                                         # not supported: -minline-all-stringops
1116 else
1117                         #if gcc 3.4+
1118 ifeq                    ($(CC_SHORTVER), 3.4)
1119                                         CFLAGS+=
1120 else
1121                         #if gcc 3.0
1122 ifeq                    ($(CC_SHORTVER), 3.0)
1123                                         CFLAGS+=
1124 else
1125 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1126 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
1127                                         for better results)
1128                                         CFLAGS+=
1129 else
1130                                 #really old version
1131 $(warning                       You are using an old and unsupported gcc \
1132                                          version ($(CC_SHORTVER)), compile at your own risk!)
1133         
1134 endif                   # CC_SHORTVER, 2.9x
1135 endif                   # CC_SHORTVER, 3.0
1136 endif                   # CC_SHORTVER, 3.4
1137 endif                   # CC_SHORTVER, 4.x
1138         
1139 else            # CC_NAME, gcc
1140                                 #other compilers
1141 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1142 endif           #CC_NAME, gcc
1143 endif   #ARCH, alpha 
1144
1145 #if  ppc
1146 ifeq    ($(ARCH), ppc)
1147                 # if gcc 
1148 ifeq            ($(CC_NAME), gcc)
1149                                 DEFS+=-DCC_GCC_LIKE_ASM
1150                                 #common stuff
1151                                 CFLAGS= -O9 -funroll-loops $(PROFILE)
1152                         #if gcc 4.0+
1153 ifeq                    ($(CC_SHORTVER), 4.x)
1154                                         CPU ?= powerpc
1155                                         CFLAGS+=-ftree-vectorize \
1156                                                         -mtune=$(CPU) -maltivec
1157 else
1158                         #if gcc 3.4+
1159 ifeq                    ($(CC_SHORTVER), 3.4)
1160                                         CFLAGS+=
1161 else
1162                         #if gcc 3.0
1163 ifeq                    ($(CC_SHORTVER), 3.0)
1164                                         CFLAGS+=
1165 else
1166 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1167 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
1168                                         for better results)
1169                                         CFLAGS+=
1170 else
1171                                 #really old version
1172 $(warning                       You are using an old and unsupported gcc \
1173                                          version ($(CC_SHORTVER)), compile at your own risk!)
1174         
1175 endif                   # CC_SHORTVER, 2.9x
1176 endif                   # CC_SHORTVER, 3.0
1177 endif                   # CC_SHORTVER, 3.4
1178 endif                   # CC_SHORTVER, 4.x
1179         
1180 else            # CC_NAME, gcc
1181                                 #other compilers
1182 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1183 endif           #CC_NAME, gcc
1184 endif   #ARCH, ppc 
1185
1186 #if  ppc64
1187 ifeq    ($(ARCH), ppc64)
1188                 # if gcc 
1189 ifeq            ($(CC_NAME), gcc)
1190                                 DEFS+=-DCC_GCC_LIKE_ASM
1191                                 #common stuff
1192                                 CFLAGS= -O9 -funroll-loops $(PROFILE)
1193 ifeq                    ($(CC_SHORTVER), 4.x)
1194                                         CPU ?= powerpc64
1195                                         CFLAGS+=-ftree-vectorize \
1196                                                         -mtune=$(CPU) -maltivec
1197 else
1198                         #if gcc 3.4+
1199 ifeq                    ($(CC_SHORTVER), 3.4)
1200                                         CFLAGS+=
1201 else
1202                         #if gcc 3.0
1203 ifeq                    ($(CC_SHORTVER), 3.0)
1204                                         CFLAGS+=
1205 else
1206 ifeq                    ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
1207 $(warning                       Old gcc detected ($(CC_SHORTVER)), use  gcc 3.0.x \
1208                                         for better results)
1209                                         CFLAGS+=
1210 else
1211                                 #really old version
1212 $(warning                       You are using an old and unsupported gcc \
1213                                          version ($(CC_SHORTVER)), compile at your own risk!)
1214         
1215 endif                   # CC_SHORTVER, 2.9x
1216 endif                   # CC_SHORTVER, 3.0
1217 endif                   # CC_SHORTVER, 3.4
1218 endif                   # CC_SHORTVER, 4.x
1219         
1220 else            # CC_NAME, gcc
1221                                 #other compilers
1222 $(error                         Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
1223 endif           #CC_NAME, gcc
1224 endif   #ARCH, ppc 
1225
1226 CFLAGS+= $(CC_EXTRA_OPTS)
1227
1228
1229 # setting LDFLAGS
1230 ifeq    ($(CC_NAME), gcc)
1231 ifeq            ($(LDTYPE), solaris)
1232                 # solaris ld
1233                 LDFLAGS+=-O2 $(PROFILE)
1234                 MOD_LDFLAGS:=-G $(LDFLAGS)
1235                 LIB_LDFLAGS:=-G $(LDFLAGS)
1236                 LIB_SONAME=-Wl,-h,
1237                 LD_RPATH=-Wl,-R,
1238 else            
1239                 #gcc and maybe others, => gnu ld
1240                 LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE) 
1241                 MOD_LDFLAGS:=-shared $(LDFLAGS)
1242                 LIB_LDFLAGS:=-shared $(LDFLAGS)
1243                 LIB_SONAME=-Wl,-soname,
1244                 LD_RPATH=-Wl,-rpath,
1245 endif
1246 endif
1247 ifeq    ($(CC_NAME), icc)
1248         #gcc and maybe others
1249         LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE) 
1250         MOD_LDFLAGS:=-shared $(LDFLAGS)
1251         LIB_LDFLAGS:=-shared $(LDFLAGS)
1252         LIB_SONAME=-Wl,-soname,
1253         LD_RPATH=-Wl,-rpath,
1254 endif
1255 ifeq    ($(CC_NAME), suncc)
1256         # -dy?
1257         LDFLAGS+=-xO5 $(PROFILE)
1258         MOD_LDFLAGS:=-G $(LDFLAGS)
1259         LIB_LDFLAGS:=-G $(LDFLAGS)
1260         LIB_SONAME="-h "
1261         LD_RPATH=-"-R "
1262 endif
1263         # we need -fPIC -DPIC only for shared objects, we don't need them for
1264         # the executable file, because it's always loaded at a fixed address
1265         # -andrei
1266 else    #mode,release
1267 ifeq    ($(CC_NAME), gcc)
1268                 CFLAGS=-g -Wcast-align $(PROFILE)
1269                 DEFS+=-DCC_GCC_LIKE_ASM
1270 ifeq            ($(ARCH), sparc64)
1271                         DEFS+=SPARC64_MODE
1272                         CFLAGS+= -mcpu=ultrasparc -m64
1273                         LDFLAGS+=-m64
1274 endif
1275 ifeq            ($(LDTYPE), solaris)
1276                         #solaris ld
1277                         LDFLAGS+=-g $(PROFILE)
1278                         MOD_LDFLAGS:=-G $(LDFLAGS)
1279                         LIB_LDFLAGS:=-G $(LDFLAGS)
1280                         LIB_SONAME=-Wl,-h,
1281                         LD_RPATH=-Wl,-R,
1282 else
1283                         #gnu or other ld type
1284                         LDFLAGS+=-g -Wl,-E $(PROFILE)
1285                         MOD_LDFLAGS:=-shared $(LDFLAGS)
1286                         LIB_LDFLAGS:=-shared $(LDFLAGS)
1287                         LIB_SONAME=-Wl,-soname,
1288                         LD_RPATH=-Wl,-rpath,
1289 endif
1290 endif
1291 ifeq    ($(CC_NAME), icc)
1292                 DEFS+=-DCC_GCC_LIKE_ASM
1293                 CFLAGS=-g  $(PROFILE)
1294                 LDFLAGS+=-g -Wl,-E $(PROFILE)
1295                 MOD_LDFLAGS:=-shared $(LDFLAGS)
1296                 LIB_LDFLAGS:=-shared $(LDFLAGS)
1297                 LIB_SONAME=-Wl,-soname,
1298                 LD_RPATH=-Wl,-rpath,
1299 endif
1300 ifeq    ($(CC_NAME), suncc)
1301                 CFLAGS= -g $(PROFILE)
1302                 LDFLAGS+=-g $(PROFILE)
1303                 MOD_LDFLAGS:=-G $(LDFLAGS)
1304                 LIB_LDFLAGS:=-G $(LDFLAGS)
1305                 LIB_SONAME="-h "
1306                 LD_RPATH=-"-R "
1307 endif
1308
1309 endif #mode=release
1310
1311
1312 # set pedantic compiler options
1313 ifeq ($(CC_NAME), gcc)
1314                 CFLAGS+= -Wall
1315 else # no gcc
1316 ifeq ($(CC_NAME), icc)
1317                 CFLAGS+= -Wall
1318 else # no icc
1319 ifeq ($(CC_NAME), suncc)
1320                 # FIXME: is the default (-Xa ?) enough?
1321 endif # CC_NAME=suncc
1322 endif # CC_NAME=icc
1323 endif # CC_NAME=gcc
1324
1325 #*FLAGS used for compiling the modules
1326 ifeq    ($(CC_NAME), gcc)
1327 MOD_CFLAGS=-fPIC -DPIC $(CFLAGS)
1328 LIB_CFLAGS=-fPIC -DPIC $(CFLAGS)
1329 endif
1330 ifeq    ($(CC_NAME), icc)
1331 MOD_CFLAGS=-Kpic $(CFLAGS)
1332 LIB_CFLAGS=-Kpic $(CFLAGS)
1333 endif
1334 ifeq    ($(CC_NAME), suncc)
1335 # FIMXE: use -KPIC instead -xcode ?
1336 MOD_CFLAGS=-xcode=pic32  $(CFLAGS)
1337 LIB_CFLAGS=-xcode=pic32  $(CFLAGS)
1338 endif
1339
1340 ifeq ($(LEX),)
1341         LEX=flex
1342 endif
1343 ifeq ($(YACC),)
1344         YACC=bison
1345 endif
1346 YACC_FLAGS=-d -b cfg
1347 # on solaris add -lxnet (e.g. LIBS= -lxnet)
1348 LIBS= -ldl -lresolv
1349 LIB_PREFIX:=lib
1350 LIB_SUFFIX:=.so
1351
1352
1353 #os specific stuff
1354 ifeq ($(OS), linux)
1355 # by default use futexes if available
1356         use_futex= yes
1357         DEFS+=-DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
1358                         -DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H \
1359                         -DHAVE_TIMEGM -DHAVE_SCHED_SETSCHEDULER
1360         ifneq ($(found_lock_method), yes)
1361                 #DEFS+= -DUSE_POSIX_SEM
1362                 DEFS+=-DUSE_PTHREAD_MUTEX
1363                 LIBS+= -lpthread
1364                 #DEFS+= -DUSE_SYSV_SEM  # try posix sems
1365                 found_lock_method=yes
1366         else
1367                 ifneq (,$(findstring -DUSE_POSIX_SEM, $(DEFS)))
1368                         LIBS+=-lpthread
1369                 endif
1370                 ifneq (,$(findstring -DUSE_PTHREAD_MUTEX, $(DEFS)))
1371                         LIBS+=-lpthread
1372                 endif
1373         endif
1374         # check for >= 2.5.44
1375         ifeq ($(shell [ $(OSREL_N) -ge 2005044 ] && echo has_epoll), has_epoll)
1376                 ifeq ($(NO_EPOLL),)
1377                         DEFS+=-DHAVE_EPOLL
1378                         # linux + gcc >= 3.0 + -malign-double + epoll => problems
1379                         CFLAGS_RM+=-malign-double
1380                         #CFLAGS:=$(filter-out -malign-double, $(CFLAGS))
1381                 endif
1382         endif
1383         # check for >= 2.2.0
1384         ifeq ($(shell [ $(OSREL_N) -ge 2002000 ] && echo has_sigio), has_sigio)
1385                 ifeq ($(NO_SIGIO),)
1386                         DEFS+=-DHAVE_SIGIO_RT -DSIGINFO64_WORKARROUND
1387                 endif
1388         endif
1389         # check for >= 2.5.70
1390         ifeq ($(shell [ $(OSREL_N) -ge 2005070 ] && echo has_futex), has_futex)
1391                 ifeq ($(use_futex), yes)
1392                         DEFS+=-DUSE_FUTEX
1393                 endif
1394         endif
1395         ifeq ($(NO_SELECT),)
1396                 DEFS+=-DHAVE_SELECT
1397         endif
1398 endif
1399
1400 ifeq  ($(OS), solaris)
1401         DEFS+= -DHAVE_GETIPNODEBYNAME -DHAVE_SYS_SOCKIO_H -DHAVE_SCHED_YIELD \
1402                         -DHAVE_ALLOCA_H -DUSE_SIGACTION
1403         ifneq ($(found_lock_method), yes)
1404                 DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1405                 found_lock_method=yes
1406         endif
1407         # check for ver >= 5.7
1408         ifeq ($(shell [ $(OSREL_N) -gt 5007 ] && echo has_devpoll), has_devpoll)
1409                 ifeq ($(NO_DEVPOLL),)
1410                         DEFS+=-DHAVE_DEVPOLL
1411                 endif
1412         endif
1413         ifeq ($(NO_SELECT),)
1414                 DEFS+=-DHAVE_SELECT
1415         endif
1416         ifeq ($(mode), release)
1417                 #use these only if you're using gcc with Solaris ld
1418                 #LDFLAGS=-O2 $(PROFILE)
1419                 #MOD_LDFLAGS=-O2 -G
1420         else
1421                 #LDFLAGS=-g $(PROFILE)
1422                 #MOD_LDFLAGS=-g -G
1423         endif
1424         YACC=yacc
1425
1426 ifeq ($(CC_NAME), suncc)
1427         LIBS= -lfast -ldl -lresolv
1428 endif
1429         OLD_SOLARIS= $(shell echo "$(OSREL)" | \
1430                                 sed -e 's/^5\.[0-6][^0-9]*$$/yes/' )
1431         LIBS+= -L$(LOCALBASE)/lib -lxnet -lnsl 
1432 ifeq    ($(OLD_SOLARIS), yes)
1433                 LIBS+=-lposix4
1434 else
1435                 LIBS+=-lrt
1436 endif
1437         # -lrt needed for sched_yield
1438 endif
1439
1440 ifeq ($(OS), freebsd)
1441         DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
1442                 -DHAVE_SCHED_YIELD -DHAVE_MSGHDR_MSG_CONTROL \
1443                 -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
1444                 -DHAVE_NETINET_IN_SYSTM
1445         ifneq ($(found_lock_method), yes)
1446                 DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1447                 found_lock_method=yes
1448                 LIBS+= -pthread   #dlopen is in libc
1449         else
1450                 LIBS=   #dlopen is in libc
1451         endif
1452         # check for ver >= 4.1
1453         ifeq ($(shell [ $(OSREL_N) -gt 4001 ] && echo has_kqueue), has_kqueue)
1454                 ifeq ($(NO_KQUEUE),)
1455                         DEFS+=-DHAVE_KQUEUE
1456                 endif
1457         endif
1458         ifeq ($(NO_SELECT),)
1459                 DEFS+=-DHAVE_SELECT
1460         endif
1461         YACC=yacc
1462 endif
1463
1464 ifeq ($(OS), openbsd)
1465         DEFS+=-DHAVE_SOCKADDR_SA_LEN  -DHAVE_GETHOSTBYNAME2 \
1466                 -DHAVE_UNION_SEMUN -DHAVE_MSGHDR_MSG_CONTROL \
1467                 -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
1468                 -DHAVE_NETINET_IN_SYSTM -DUSE_SIGWAIT
1469         ifneq ($(found_lock_method), yes)
1470                 DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1471                 found_lock_method=yes
1472         endif
1473         # check for ver >=2 9
1474         ifeq ($(shell [ $(OSREL_N) -ge 2009 ] && echo has_kqueue), has_kqueue)
1475                 ifeq ($(NO_KQUEUE),)
1476                         DEFS+=-DHAVE_KQUEUE
1477                 endif
1478         endif
1479         ifeq ($(NO_SELECT),)
1480                 DEFS+=-DHAVE_SELECT
1481         endif
1482         # (symbols on openbsd are prefixed by "_")
1483         YACC=yacc
1484         # no sched_yield on openbsd unless linking with c_r (not recommended)
1485         # unfortunately pthread is needed for sigwait
1486         LIBS= -lpthread
1487         OPENBSD_IS_AOUT= $(shell echo "$(OSREL)" | \
1488                                 sed -e 's/^3\.[0-3][^0-9]*$$/yes/' |sed -e 's/^[0-2]\..*/yes/')
1489 # exception: on sparc openbsd 3.2 is elf and not aout
1490 ifeq ($(OSREL), 3.2)
1491 ifeq    ($(ARCH), sparc)
1492                 OPENBSD_IS_AOUT:=no
1493 endif
1494 ifeq    ($(ARCH), sparc64)
1495                 OPENBSD_IS_AOUT:=no
1496 endif
1497 endif
1498         
1499 ifeq ($(OPENBSD_IS_AOUT), yes)
1500                 DEFS+=-DDLSYM_PREFIX='"_"'
1501                 LDFLAGS=        # openbsd ld doesn't like -O2 or -E
1502 endif
1503 endif   # if opensd
1504         
1505 ifeq ($(OS), netbsd)
1506         DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 \
1507                 -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM
1508         ifneq ($(found_lock_method), yes)
1509                 DEFS+= -DUSE_SYSV_SEM  # try pthread sems
1510                 found_lock_method=yes
1511         endif
1512         # check for ver >= 2.0.0
1513         ifeq ($(shell [ $(OSREL_N) -ge 2000000 ] && echo has_kqueue), has_kqueue)
1514                 ifeq ($(NO_KQUEUE),)
1515                         DEFS+=-DHAVE_KQUEUE
1516                         # netbsd + kqueue and -malign-double don't work
1517                         CFLAGS_RM+=-malign-double
1518                         #CFLAGS:=$(filter-out -malign-double, $(CFLAGS))
1519                 endif
1520         endif
1521         ifeq ($(NO_SELECT),)
1522                 DEFS+=-DHAVE_SELECT
1523         endif
1524         YACC=yacc
1525         LIBS=  
1526 endif
1527
1528 # OS X support, same as freebsd
1529 ifeq ($(OS), darwin)
1530         DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
1531                 -DHAVE_SCHED_YIELD -DHAVE_MSGHDR_MSG_CONTROL \
1532                 -DUSE_ANON_MMAP \
1533                 -DNDEBUG -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
1534                 -DUSE_SIGWAIT
1535         # -DNDEBUG used to turn off assert (assert wants to call
1536         # eprintf which doesn't seem to be defined in any shared lib
1537         ifneq ($(found_lock_method), yes)
1538                 DEFS+= -DUSE_PTHREAD_MUTEX  # try pthread sems
1539                 found_lock_method=yes
1540                 DEFS+= -DUSE_SYSV_SEM  # try sys v sems (pthread don't work for
1541                                        # processes and unnamed posix sems are not
1542                                        # supported)
1543         endif
1544         LIBS= -lresolv  #dlopen is in libc
1545         ifeq ($(NO_KQUEUE),)
1546                 DEFS+=-DHAVE_KQUEUE
1547         endif
1548         ifeq ($(NO_SELECT),)
1549                 DEFS+=-DHAVE_SELECT
1550         endif
1551         LDFLAGS=        # darwin doesn't like -O2 or -E
1552         # the modules uses symbols from ser => either 
1553         # -flat_namespace -undefined_suppress or -bundle_loader ../../$(MAIN_NAME)
1554         MOD_LDFLAGS:= -bundle -flat_namespace -undefined suppress
1555         LIB_LDFLAGS:= -dynamiclib
1556         LIB_SUFFIX:=.dylib
1557         # on darwin soname should include the full path
1558         # (it kind of combines rpath & soname)
1559         LIB_SONAME=
1560         # no equiv. for rpath on darwin
1561         LD_RPATH=
1562         YACC=yacc
1563 endif
1564
1565 ifneq (,$(findstring cygwin, $(OS)))
1566         # cygwin doesn't support IPV6 and doesn't support fd passing so no TCP
1567         #DEFS:=$(filter-out -DUSE_IPV6 -DUSE_TCP, $(DEFS))
1568         DEFS_RM+=-DUSE_IPV6 -DUSE_TCP
1569         DEFS+=-DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
1570                         -DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H \
1571                         -DHAVE_TIMEGM -DHAVE_SCHED_SETSCHEDULER
1572         ifneq ($(found_lock_method), yes)
1573                 DEFS+= -DUSE_POSIX_SEM
1574                 #DEFS+= -DUSE_SYSV_SEM  # try posix sems
1575                 # PTHREAD_MUTEX do not work for processes (try test/pthread_test.c)
1576                 #LIBS+= -lpthread
1577                 found_lock_method=yes
1578         else
1579                 ifneq (,$(findstring -DUSE_POSIX_SEM, $(DEFS)))
1580                         #LIBS+=-lpthread
1581                 endif
1582                 ifneq (,$(findstring -DUSE_PTHREAD_MUTEX, $(DEFS)))
1583 $(error PTHREAD_MUTEX do not work for processes on Windows/CYGWIN)
1584                 endif
1585         endif
1586         # check for >= 2.5.70
1587         ifeq ($(NO_SELECT),)
1588                 DEFS+=-DHAVE_SELECT
1589         endif
1590 endif
1591
1592 #add libssl if needed
1593 ifeq ($(CORE_TLS), 1)
1594 DEFS+= -I$(LOCALBASE)/ssl/include
1595 LIBS+= -L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib -lssl -lcrypto \
1596                 $(TLS_EXTRA_LIBS)
1597 # NOTE: depending on the way in which libssl was compiled you might
1598 #       have to add -lz -lkrb5   (zlib and kerberos5).
1599 #       E.g.: make CORE_TLS=1 EXTRA_TLS_LIBS="-lz -lkrb5"
1600 endif
1601
1602 ifneq ($(STUN),)
1603 DEFS+= -I$(LOCALBASE)/ssl/include
1604 LIBS+= -L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib -lcrypto
1605 endif
1606
1607 ifneq ($(found_lock_method), yes)
1608 $(warning       No locking method found so far, trying SYS V sems)
1609                 DEFS+= -DUSE_SYSV_SEM  # try sys v sems
1610                 found_lock_method=yes
1611 endif
1612
1613
1614 endif # ifeq (,$(main_makefile))
1615 endif  # ifeq ($(makefile_defs), 1)
1616
1617 # if incomplete or missing config.mak, or already exported vars, don't
1618 # try to export/re-export
1619 ifeq ($(makefile_defs),1) 
1620 ifneq ($(exported_vars),1)
1621
1622
1623 override exported_vars:=1
1624 export exported_vars
1625
1626 # variable changeable only at configure time (once saved in config.mak they
1627 #  cannot be overwritten from environment or command line, unless make cfg
1628 #  is run)
1629 saved_fixed_vars:=      MAIN_NAME \
1630                 RELEASE OS ARCH \
1631                 DEFS DEFS_RM PROFILE CC LD MKDEP MKTAGS LDFLAGS INCLUDES \
1632                 MOD_LDFLAGS LIB_LDFLAGS LIB_SONAME LD_RPATH \
1633                 LIB_SUFFIX LIB_PREFIX \
1634                 LIBS \
1635                 LEX YACC YACC_FLAGS \
1636                 PREFIX LOCALBASE \
1637                 TAR \
1638                 INSTALL INSTALL_CFG INSTALL_BIN INSTALL_MODULES INSTALL_DOC \
1639                 INSTALL_MAN INSTALL_LIB INSTALL_TOUCH INSTALL_SHARE
1640
1641 # variable changeable at compile time
1642 # extra: prefix DESTDIR BASEDIR basedirt
1643 saved_chg_vars:=\
1644                 CC_EXTRA_OPTS CPU CFLAGS_RM CFLAGS MOD_CFLAGS LIB_CFLAGS        \
1645                 BASEDIR basedir DESTDIR \
1646                 PREFIX prefix\
1647                 cfg_prefix cfg_dir bin_prefix bin_dir modules_prefix modules_dir \
1648                 doc_prefix doc_dir man_prefix man_dir ut_prefix ut_dir \
1649                 share_prefix share_dir lib_prefix lib_dir \
1650                 cfg_target lib_target modules_target
1651
1652
1653 #export relevant variables to the sub-makes
1654 export $(saved_fixed_vars)
1655 export $(saved_chg_vars)
1656
1657
1658 endif # ifneq ($(exported_vars),1)
1659 endif # ifeq ($(makefile_defs),1)
1660