| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953 |
- # $Id$
- #
- # makefile defs (CC, LD,a.s.o)
- #
- # Environment variables:
- # PREFIX, LOCALBASE, BASEDIR
- # INSTALL, TAR , CC, LEX, YACC,
- # CPU, CC_EXTRA_OPTS,
- # exclude_modules, skip_modules, include_modules
- # extra_defs
- #
- # History:
- # --------
- # created by andrei
- # 2003-02-24 added LOCALBASE, fixed doc_dir for freebsd - patch provided
- # by Maxim Sobolev <[email protected]>
- # 2003-02-25 added -DDISABLE_NAGLE (andrei)
- # 2003-03-02 added -DDIGEST_DOMAIN (janakj)
- # 2003-03-10 added -xcode=pic32 for module compilation w/ sun cc
- # (too many symbols for pic13) (andrei)
- # 2003-04-16 added CC_EXTRA_OPTS, s/march/mcpu, added CPU (cpu to optimize
- # for, used only with gcc-3.x) (andrei)
- # 2003-05-23 check if this makefile was already included (andrei)
- # removed -DDIGEST_DOMAIN (andrei)
- # 2003-05-30 added extra_defs (andrei)
- # 2003-06-06 moved compiler detection before DEFS (andrei)
- # 2003-06-10 removed -m32 for gcc 3.x/sparc64 -- it will use
- # arch. default: -m32 on solaris, -m64 on *bsd (andrei)
- # 2003-09-25 added -pthread into LIBS when compiling on FreeBSD/alpha
- # and other FreeBSD arches for which no fast locking assembly
- # code exists (sobomax)
- # 2003-11-08 mips1 support introduced (andrei)
- # 2003-11-24 openbsd 3.4 (elf) fixes (andrei)
- # 2004-07-27 darwin (mac os x) port (andrei)
- # 2004-09-12 mips2 & cobalt support introduced (andrei)
- # 2004-09-28 x86_64 support introduced (andrei)
- # 2004-12-14 gcc-3.4 special case added (andrei)
- # 2004-12-15 HAVE_ALLOCA_H added (andrei)
- # 2004-12-19 amd64 transformed in x86_64 (andrei)
- # 2005-04-27 alpha support added (andrei)
- # 2005-06-01 use $(LOCALBASE) instead of /usr/{local,pkg} (andrei)
- # 2005-06-26 numeric OSREL & HAVE_KQUEUE added to the *BSD (andrei)
- # 2005-07-04 HAVE_DEVPOLL added to solaris (andrei)
- # 2005-07-06 gcc 4.0 optimizations support (andrei)
- # 2005-07-25 better solaris arch detection (andrei)
- # 2005-09-12 -mallign-double removed (too many problems) (andrei)
- # 2005-10-02 distcc get gcc version hack (andrei)
- # 2006-03-30 64 bit mode compile by default on sparc64 (-m64), added
- # CC_GCC_LIKE_ASM and SPARC64_MODE (andrei)
- # sparc <= v8 support (andrei)
- # 2006-03-31 armv6 & mips64 support added
- # mips and arm set to NOSMP by default (andrei)
- # 2006-07-10 added -DPROFILING (hscholz)
- # 2007-02-09 added TLS_HOOKS and CORE_TLS support, obsoleted TLS=1
- # added TLS_EXTRA_LIBS (andrei)
- # 2007-03-16 added LIB building options: LIB_LDFLAGS, LIB_SONAME, LIB_RPATH,
- # INSTALL_LIB, libraries install paths (andrei)
- # 2007-05-14 futex support if linux 2.5.70+ and
- # use_futex=yes (default) (andrei)
- # 2007-05-26 changed darwin module link flags (instead of -bundle_loader ser
- # -flat_namespace -undefined suppress) (andrei)
- # 2007-07-07 use isainfo -n to detect cpu type on solaris (andrei)
- # 2007-07-07 added HAVE_SCHED_SETSCHEDULER for linux (andrei)
- # 2007-07-18 added DNS_WATCHDOG_SUPPORT (Miklos)
- # 2007-07-30 added USE_DNS_CACHE_STATS and USE_DST_BLACKLIST_STATS (Gergo)
- # 2008-06-26 support for make cfg / config.mak and hack to load
- # automatically config.mak when included from a module, lib
- # a.s.o (not from the main Makefile) (andrei)
- # 2009-03-10 replaced DEFS with C_DEFS and INCLUDES with C_INCLUDES (DEFS
- # and INCLUDES are now used only for "temporary" defines/includes
- # inside modules or libs) (andrei)
- # 2009-09-29 for gcc 4.2+ use -fno-strict-overflow (andrei)
- # 2009-09-30 find the target architecture from the compiler and not
- # from the host (andrei)
- # 2009-10-01 use -fsigned-char for gcc on ppc, ppc64, arm and arm6
- # (on those archs char is unsigned by default) (andrei)
- quiet?=$(if $(filter 1 yes on,$(Q)),silent,verbose)
- # check if already included/exported
- # used for sanity checks for Makefile.defs inclusion (!= makefile_defs which
- # specifies if we have a set of valid defs)
- override makefile_defs_included:=1
- ifeq ($(makefile_defs),1)
- ifeq ($(quiet),verbose)
- $(info Makefile.defs defs skipped)
- endif # verbose
- else
- ifeq (,$(main_makefile))
- # hack to automatically use config.mak in all the modules, without
- # changing the current module makefiles (which all include Makefile.defs):
- # if not called from the main makefile (module, lib or ut):
- # include config.mak, but if not present or incomplete (makefile_defs!=1)
- # don't export the vars)
- COREPATH?= ../..
- include $(COREPATH)/config.mak
- ifeq ($(quiet),verbose)
- $(info config.mak included)
- endif # verbose
- # config.mak should set makefile_defs if complete
- export makefile_defs
- else
- override makefile_defs=1
- export makefile_defs
- ifeq ($(quiet),verbose)
- $(info normal Makefile.defs exec)
- endif # verbose
- # flavour: sip-router, ser or kamailio
- FLAVOUR=sip-router
- ifeq ($(FLAVOUR),sip-router)
- # main binary name
- MAIN_NAME=ser
- else ifeq ($(FLAVOUR),ser)
- # main binary name
- MAIN_NAME=ser
- else ifeq ($(FLAVOUR),kamailio)
- # main binary name
- MAIN_NAME=kamailio
- else # default:
- # main binary name
- MAIN_NAME=sip-router
- endif
- #prefix for various configs and scripts
- #config name/name-prefix for distributed configs
- CFG_NAME=sip-router
- #config name/name-prefix for distributed scripts
- SCR_NAME=sip-router
- # what to install
- INSTALL_FLAVOUR=$(FLAVOUR)
- #version number
- VERSION = 2
- PATCHLEVEL = 99
- SUBLEVEL = 99
- EXTRAVERSION = -pre3
- SER_VER = $(shell expr $(VERSION) \* 1000000 + $(PATCHLEVEL) \* 1000 + \
- $(SUBLEVEL) )
- RELEASE:=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)
- OS := $(shell uname -s | sed -e s/SunOS/solaris/ -e s/CYGWIN.*/cygwin/ \
- | tr "[A-Z]" "[a-z]")
- ifeq ($(OS),solaris)
- GETARCH=isainfo -n
- ifeq ($(GETARCH),)
- GETARCH=uname -p
- endif
- else
- GETARCH=uname -m
- endif
- HOST_ARCH := $(shell $(GETARCH) |sed -e s/i.86/i386/ -e s/sun4[uv]/sparc64/ \
- -e s/armv[3-5].*/arm/ -e s/armv6.*/arm6/ \
- -e "s/Power Macintosh/ppc/" \
- -e "s/cobalt/mips2/" \
- -e s/amd64/x86_64/ -e s/sparcv9/sparc64/ )
- # fix sparc -> sparc64
- ifeq ($(HOST_ARCH),sparc)
- ifeq ($(shell uname -m),sun4u)
- HOST_ARCH := sparc64
- endif
- ifeq ($(shell uname -m),sun4v)
- HOST_ARCH := sparc64
- endif
- endif
- OSREL := $(shell uname -r)
- # numerical version (good for comparisons: A.B.C => A*1000000+B*1000+C)
- OSREL_N:= $(shell echo $(OSREL) | sed -e 's/^[^0-9]*//' \
- -e 's/^\([0-9][0-9]*\(\.[0-9][0-9]*\)*\).*$$/\1/g' | \
- (IFS=. read A B C D; R=0; \
- [ -n "$$A" ] && R=`expr $$R \* 1000 + $$A` && \
- [ -n "$$B" ] && R=`expr $$R \* 1000 + $$B` && \
- [ -n "$$C" ] && R=`expr $$R \* 1000 + $$C`; echo $$R ) )
- # TLS support
- CORE_TLS ?=
- # by default compile with tls hooks support (so that no ser recompile is
- # needed before the tls module can be used)
- TLS_HOOKS=1
- ifeq ($(CORE_TLS), 1)
- RELEASE:=$(RELEASE)-tls
- TLS_HOOKS:=0
- endif
- ifeq ($(TLS_HOOKS), 1)
- # RELEASE:=$(RELEASE)-tls
- endif
- # extra CC command line options (e.g -march=athlon-mp)
- CC_EXTRA_OPTS ?=
- # dirs
- cfg_dir = etc/$(MAIN_NAME)/
- bin_dir = sbin/
- share_dir = share/$(MAIN_NAME)/
- # lib/$(MAIN_NAME)/modules , lib/$(MAIN_NAME)/modules-s, lib/$(MAIN_NAME)/modules-k
- modules_dir = lib/$(MAIN_NAME)/
- lib_dir = lib/$(MAIN_NAME)/
- ifeq ($(OS), linux)
- doc_dir = share/doc/$(MAIN_NAME)/
- man_dir = share/man/
- LOCALBASE ?= /usr/local
- else
- ifeq ($(OS), freebsd)
- doc_dir = share/doc/$(MAIN_NAME)/
- man_dir = man/
- LOCALBASE ?= /usr/local
- else
- ifeq ($(OS), openbsd)
- doc_dir = share/doc/$(MAIN_NAME)/
- man_dir = man/
- LOCALBASE ?= /usr/local
- else
- ifeq ($(OS), netbsd)
- doc_dir = share/doc/$(MAIN_NAME)/
- man_dir = man/
- LOCALBASE ?= /usr/pkg
- else
- ifeq ($(OS), darwin)
- doc_dir = share/doc/$(MAIN_NAME)/
- man_dir = man/
- LOCALBASE ?= /usr/local
- else
- doc_dir = doc/$(MAIN_NAME)/
- man_dir = man/
- LOCALBASE ?= /usr/local
- endif
- endif
- endif
- endif
- endif
- # Doxygen directory
- doxygen_dir=doc/doxygen
- # install location
- DESTDIR ?= $(LOCALBASE)
- PREFIX ?= $(DESTDIR)
- prefix = $(PREFIX)
- # install path is $(basedir) $(prefix)
- # example:
- # creating a bin. archive in /tmp, which unpacks in /usr/local
- # basedir=/tmp
- # prefix=/usr/local
- BASEDIR ?=
- basedir = $(BASEDIR)
- # install prefixes for various stuff
- cfg_prefix = $(basedir)$(prefix)
- bin_prefix = $(basedir)$(prefix)
- modules_prefix = $(basedir)$(prefix)
- lib_prefix = $(basedir)$(prefix)
- doc_prefix = $(basedir)$(prefix)
- man_prefix = $(basedir)$(prefix)
- ut_prefix = $(basedir)$(prefix)
- share_prefix = $(basedir)$(prefix)
- # target dirs for various stuff
- cfg_target = $(prefix)/$(cfg_dir)
- bin_target = $(prefix)/$(bin_dir)
- #modules_target = $(prefix)/$(modules_dir)
- lib_target = $(prefix)/$(lib_dir)
- doc_target = $(prefix)/$(doc_dir)
- ifeq ($(OS), solaris)
- #use GNU versions
- INSTALL ?= ginstall
- TAR ?= gtar
- else
- INSTALL ?= install
- TAR ?= tar
- endif
- INSTALL_TOUCH = touch # used to create the file first (good to
- # make solaris install work)
- INSTALL_CFG = $(INSTALL) -m 644
- INSTALL_BIN = $(INSTALL) -m 755
- INSTALL_SCRIPT = $(INSTALL) -m 755
- INSTALL_MODULES = $(INSTALL) -m 755
- INSTALL_LIB = $(INSTALL) -m 755
- INSTALL_DOC = $(INSTALL) -m 644
- INSTALL_MAN = $(INSTALL) -m 644
- INSTALL_SHARE = $(INSTALL) -m 644
- #set some vars from the environment (and not make builtins)
- CC := $(shell echo "$${CC}")
- LEX := $(shell echo "$${LEX}")
- YACC := $(shell echo "$${YACC}")
- # find compiler name & version
- ifeq ($(CC),)
- CC=gcc
- endif
- LD= $(CC)
- CC_LONGVER:=$(shell if $(CC) -v 2>/dev/null; then \
- $(CC) -v 2>&1 ;\
- else \
- $(CC) -V 2>&1 ; \
- fi )
- MKTAGS=ctags -R .
- #find-out the compiler's name
- ifneq (,$(findstring gcc, $(CC_LONGVER)))
- CC_NAME=gcc
- RPAREN=)
- CC_VER:=$(word 1,$(CC)) $(shell $(CC) - --version|head -n 1|\
- sed -e 's/([^$(RPAREN)]*)//g' \
- -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/')
- # CC_VER:=$(word 1,$(CC)) $(shell $(CC) - --version|head -n 1|cut -d" " -f 3\
- # |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/')
- # sed with POSIX.1 regex doesn't support |, + or ?
- # (darwin, solaris ...) => this complicated expression
- MKDEP=$(CC) -MM
- #transform gcc version into 2.9x or 3.0
- CC_SHORTVER:=$(shell echo "$(CC_VER)" | cut -d" " -f 2| \
- sed -e 's/[^0-9]*-\(.*\)/\1/'| \
- sed -e 's/2\.9.*/2.9x/' -e 's/3\.[0-3]\..*/3.0/' -e \
- 's/3\.[0-3]/3.0/' -e 's/3\.[4-9]\..*/3.4/' -e \
- 's/3\.[4-9]/3.4/' -e 's/4\.[0-1]\..*/4.x/' -e \
- 's/4\.[0-1]/4.x/' -e 's/4\.[2-9]\..*/4.2+/' -e \
- 's/4\.[2-9]$$/4.2+/')
- endif
- ifneq (, $(findstring Sun, $(CC_LONGVER)))
- CC_NAME=suncc
- CC_SHORTVER:=$(shell echo "$(CC_LONGVER)"|head -n 1| \
- sed -e 's/.*\([0-9]\.[0-9]\).*/\1/g' )
- CC_VER=$(CC) $(CC_SHORTVER)
- MKDEP=$(CC) -xM1
- endif
- ifneq (, $(findstring Intel(R) C++ Compiler, $(CC_LONGVER)))
- # very nice: gcc compatible
- CC_NAME=icc
- CC_FULLVER:=$(shell echo "$(CC_LONGVER)"|head -n 1| \
- sed -e 's/.*Version \([0-9]\.[0-9]\.[0-9]*\).*/\1/g' )
- CC_SHORTVER:=$(shell echo "$(CC_FULLVER)" | cut -d. -f1,2 )
- CC_VER=$(CC) $(CC_FULLVER)
- MKDEP=$(CC) -MM
- endif
- ifeq (,$(CC_NAME))
- #not found
- CC_NAME=$(CC)
- CC_SHORTVER=unknown
- CC_VER=unknown
- MKDEP=gcc -MM
- $(warning Unknown compiler $(CC)\; supported compilers: \
- gcc, sun cc, intel icc )
- endif
- # ARCH detection
- # predefined compiler macros for different architectures
- # (see http://predef.sourceforge.net/prearch.html for a more complete list)
- i386_macros= i386 __i386__ __i486__ __i586__ __i686__ \
- __i386 _M_IX86 __X86__ _X86_
- x86_64_macros= __amd64__ __amd64 __x86_64__ __x86_64 _M_X64
- sparc_macros= __sparc__ __sparc __sparcv8
- sparc64_macros= __sparcv9 __sparc_v9__
- arm_macros= __arm__ __thumb__
- arm6_macros= __ARM_ARCH_6__
- ppc_macros= __powerpc __powerpc__ __POWERPC__ __ppc__ _ARCH_PPC
- ppc64_macros= __ppc64__ _ARCH_PPC64
- mips_macros= __mips__ __mips _MIPS_ARCH_MIPS1
- mips2_macros= _MIPS_ISA_MIPS2 _MIPS_ISA_MIPS3 _MIPS_ISA_MIPS4 \
- _MIPS_ARCH_MIPS2 _MIPS_ARCH_MIPS3 _MIPS_ARCH_MIPS4
- mips64_macros= _MIPS_ISA_MIPS64 _MIPS_ARCH_MIPS64
- alpha_macros= __alpha__ __alpha _M_ALPHA_
- ifeq ($(CC_NAME),gcc)
- #if gcc use gcc arch
- predef_macros:=$(shell $(CC) -dM -E -x c $(CC_EXTRA_OPTS) $(extra_defs) \
- $(CFLAGS) /dev/null)
- ifneq ($(strip $(filter $(i386_macros), $(predef_macros))),)
- CC_ARCH=i386
- else ifneq ($(strip $(filter $(x86_64_macros), $(predef_macros))),)
- CC_ARCH=x86_64
- else ifneq ($(strip $(filter $(sparc_macros), $(predef_macros))),)
- ifneq ($(strip $(filter $(sparc64_macros), $(predef_macros))),)
- CC_ARCH=sparc64
- else # sparc64_macros
- CC_ARCH=sparc
- endif # sparc64_macros
- else ifneq ($(strip $(filter $(arm_macros), $(predef_macros))),)
- ifneq ($(strip $(filter $(arm6_macros), $(predef_macros))),)
- CC_ARCH=arm6
- else # arm6_macros
- CC_ARCH=arm
- endif # arm6_macros
- else ifneq ($(strip $(filter $(ppc64_macros), $(predef_macros))),)
- CC_ARCH=ppc64
- else ifneq ($(strip $(filter $(ppc_macros), $(predef_macros))),)
- CC_ARCH=ppc
- else ifneq ($(strip $(filter $(mips_macros), $(predef_macros))),)
- ifneq ($(strip $(filter $(mips64_macros), $(predef_macros))),)
- CC_ARCH=mips64
- else ifneq ($(strip $(filter $(mips2_macros), $(predef_macros))),)
- CC_ARCH=mips2
- else # mips2_macros
- CC_ARCH=mips
- endif # mips64_macros
- else ifneq ($(strip $(filter $(alpha_macros), $(predef_macros))),)
- CC_ARCH=alpha
- else
- $(warn "Unknown target compiler architecture")
- endif # predefined macros tests (x86_macros, ...)
- endif # gcc
- ifdef CC_ARCH
- ARCH:=$(CC_ARCH)
- else
- ARCH:=$(HOST_ARCH)
- endif
- $(info target architecture <$(ARCH)>, host architecture <$(HOST_ARCH)>)
- # compile-time options
- #
- # -DSTATS
- # allows to print out number of packets processed on CTRL-C;
- # implementation still nasty and reports per-process
- # -DNO_DEBUG
- # turns off some of the debug messages (DBG(...)).
- # -DNO_LOG
- # completely turns of all the logging (and DBG(...))
- # -DEXTRA_DEBUG
- # compiles in some extra debugging code
- # -DDNS_IP_HACK
- # faster ip address resolver for ip strings (e.g "127.0.0.1")
- # -DSHM_MEM
- # compiles in shared mem. support, needed by some modules and
- # by USE_SHM_MEM
- # -DSHM_MMAP
- # use mmap instead of SYSV shared memory
- # -DPKG_MALLOC
- # uses a faster malloc (exclusive w/ USE_SHM_MEM)
- # -DUSE_SHM_MEM
- # all pkg_malloc => shm_malloc (most mallocs use a common sh.
- # mem. segment); don't define PKG_MALLOC if you want this!
- # -DDBG_QM_MALLOC
- # qm_malloc debug code, will cause pkg_malloc and shm_malloc
- # to keep and display lot of debuging information: file name,
- # function, line number of malloc/free call for each block,
- # extra error checking (trying to free the same pointer
- # twice, trying to free a pointer alloc'ed with a different
- # malloc etc.)
- # -DVQ_MALLOC
- # additional option to PKG_MALLOC which utilizes a fater then
- # qm version
- # (not true anymore, q_malloc performs approx. the same)
- # -DF_MALLOC
- # an even faster malloc, not recommended for debugging
- # -DDL_MALLOC
- # a malloc implementation based on Doug Lea's dl_malloc
- # -DSF_MALLOC
- # an experimental multi-CPU, pool based, multi-process safe version of
- # F_MALLOC. Should give better performance on machines with lots of CPUs
- # after some tunning.
- # -DLL_MALLOC
- # an experimental multi-CPU, pool based, multi-process safe, mostly
- # lockless version of SF_MALLOC/F_MALLOC. Not for production use for
- # now.
- # -DDBG_MALLOC
- # issues additional debugging information if lock/unlock is called
- # -DFAST_LOCK
- # uses fast arhitecture specific locking (see the arh. specific section)
- # -DUSE_SYSV_SEM
- # uses sys v sems for locking (slower & limited number)
- # -DUSE_PTHREAD_MUTEX
- # uses pthread mutexes, faster than sys v or posix sems, but do not
- # work on all systems inter-processes (e.g. linux)
- # -DUSE_POSIX_SEM
- # uses posix semaphores for locking (faster than sys v)
- # -DUSE_FUTEX
- # uses futexes for locking (linux 2.6+)
- # -DBUSY_WAIT
- # uses busy waiting on the lock (FAST_LOCK)
- # -DADAPTIVE_WAIT
- # try busy waiting for a while and if the lock is still held go to
- # force reschedule (FAST_LOCK)
- # -DADAPTIVE_WAIT_LOOPS=number
- # number of loops we busy wait, after "number" loops have elapsed we
- # force a reschedule (FAST_LOCK)
- # -DNOSMP
- # don't use smp compliant locking (faster but won't work on SMP machines)
- # (not yet enabled) (FAST_LOCK)
- # -DNO_PINGTEL_TAG_HACK
- # if enabled, To-header-field will be less liberal and will not accept
- # 'tag=' (tag parameter with equal sign and without value); it is called
- # this way because such message was sighted from a Pingtel phone
- # -DUSE_TCP
- # compiles in tcp support
- # -DDISABLE_NAGLE
- # disable the tcp Nagle algorithm (lower delay)
- # -DUSE_TLS
- # compiles in tls support, requires -DUSE_TCP. Note: this is only
- # generic support (parsing a.s.o.), it does not include the actual
- # "tls engine". If you really want tls you need also either
- # -DCORE_TLS and a tls/ subdir with the tls code or -DTLS_HOOKS and
- # the tls module loaded.
- # -DCORE_TLS
- # compiles tls in-core support. Requires -DUSE_TLS, conflicts
- # -DTLS_HOOKS. Please use make CORE_TLS=1 instead (it will set all the
- # needed defines automatically and extra libraries needed for linking).
- # -DTLS_HOOKS
- # compile tls module support (support for having the "tls engine" in a
- # module). Requires -DUSE_TLS, conflicts -DCORE_TLS.
- # Please use make TLS_HOOKS=1 (or TLS_HOOKS=0 to for disabling) instead
- # of setting -DTLS_HOOKS (it will set all the needed defines
- # automatically)
- # -DHAVE_RESOLV_RES
- # support for changing some of the resolver parameters present
- # (_res structure in <resolv.h>)
- # -DUSE_COMP
- # compiles in comp=[sergz|sigcomp] support (parsing uri & via,
- # adding it to via, lumps a.s.o). WARNING: right now this option
- # is useless since the compression code doesn't exist yet.
- # -DHONOR_MADDR
- # compiles in checks and use for maddr parameter in uri.
- # Required to support Windows Messenger 5.x over TCP connection
- # which (mis)uses this parameter.
- # -DUSE_DNS_CACHE
- # use an internal dns cache instead of making dns requests each time
- # -DUSE_DNS_CACHE_STATS
- # turns on DNS cache measurements
- # -DUSE_DNS_FAILOVER
- # if the destination resolves to multiple ips, on send error fall back
- # to the others
- # -DUSE_DST_BLACKLIST
- # blacklist bad destination (timeout, failed to connect, error sending
- # a.s.o)
- # -DUSE_DST_BLACKLIST_STATS
- # turns on blacklist bad destination measurements
- # -DPROFILING
- # if enabled profiling will be enabled for child processes
- # Don't forget to set PROFILE (see below)
- # -DUSE_STUN
- # compiles in stun support
- # -DNO_SIG_DEBUG
- # turns off debugging messages in signal handlers (which might be
- # unsafe)
- # -DUSE_NAPTR
- # turns on naptr support (but must be also enabled from the config)
- # -DDNS_WATCHDOG_SUPPORT
- # turns on DNS watchdog support which can be used to inform the
- # core that the DNS servers are down. No DNS query is performed
- # when the servers are unreachable, and even expired resource
- # records are used from the cache. (requires external watchdog)
- # -DWITH_AS_SUPPORT
- # adds support for Application Server interface
- # Sometimes is needes correct non-quoted $OS. HACK: gcc translates known OS to number ('linux'), so there is added underscore
- C_DEFS= $(extra_defs) \
- -DNAME='"$(MAIN_NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
- -DOS='$(OS)_' -DOS_QUOTED='"$(OS)"' -DCOMPILER='"$(CC_VER)"'\
- -D__CPU_$(ARCH) -D__OS_$(OS) \
- -DSER_VER=$(SER_VER) \
- -DCFG_DIR='"$(cfg_target)"'\
- -DPKG_MALLOC \
- -DSHM_MEM -DSHM_MMAP \
- -DDNS_IP_HACK \
- -DUSE_IPV6 \
- -DUSE_MCAST \
- -DUSE_TCP \
- -DDISABLE_NAGLE \
- -DHAVE_RESOLV_RES \
- -DUSE_DNS_CACHE \
- -DUSE_DNS_FAILOVER \
- -DUSE_DST_BLACKLIST \
- -DUSE_NAPTR \
- -DDBG_QM_MALLOC \
- #-DUSE_DNS_CACHE_STATS \
- #-DUSE_DST_BLACKLIST_STATS \
- #-DDNS_WATCHDOG_SUPPORT \
- #-DLL_MALLOC \
- #-DSF_MALLOC \
- #-DDL_MALLOC \
- #-DF_MALLOC \
- #-DDBG_QM_MALLOC \
- #-DDBG_F_MALLOC \
- #-DNO_DEBUG \
- #-DEXTRA_DEBUG \
- #-DVQ_MALLOC \
- #-DDBG_LOCK \
- #-DNOSMP \
- #-DUSE_SHM_MEM \
- #-DSTATS \
- #-DNO_LOG \
- #-DPROFILING \
- #-DNO_SIG_DEBUG
- #PROFILE= -pg # set this if you want profiling
- # you may also want to set -DPROFILING
- # WARNING: do not add mode=debug or mode=release anymore in the Makefile,
- # use make mode=debug all instead. Anyway no by default ser is compiled w/
- # debugging symbols in all cases (-g). --andrei
- ifeq ($(CORE_TLS), 1)
- C_DEFS+= -DUSE_TLS -DCORE_TLS
- endif
- ifeq ($(TLS_HOOKS), 1)
- C_DEFS+= -DUSE_TLS -DTLS_HOOKS
- endif
- ifeq ($(KMSTATS), 1)
- C_DEFS+= -DSTATISTICS
- endif
- ifneq ($(STUN),)
- C_DEFS+= -DUSE_STUN
- endif
- ifeq ($(mode),)
- mode = release
- endif
- ifeq ($(mode),debug)
- C_DEFS+= -DEXTRA_DEBUG
- endif
- # platform dependent settings
- # find ld & as name (gnu or solaris)
- ifeq ($(OS), solaris)
- ifeq ($(CC_NAME), gcc)
- LDGCC:=$(shell $(CC) -v 2>&1 | grep with-ld| \
- sed -e 's/.*--with-ld=\([^ ][^ ]*\).*/\1/' )
- ASGCC:=$(shell $(CC) -v 2>&1 | grep with-as| \
- sed -e 's/.*--with-as=\([^ ][^ ]*\).*/\1/' )
- LDPATH:=$(shell if [ -z "$(LDGCC)" ] ; then echo "ld" ;\
- else \
- if $(LDGCC) -V 2>/dev/null 1>/dev/null; then \
- echo $(LDGCC); \
- else echo "ld" ; \
- fi\
- fi)
- ASPATH:=$(shell if [ -z "$(ASGCC)" ] ; then echo "as" ;\
- else \
- if $(ASGCC) -V 2>/dev/null 1>/dev/null </dev/null; \
- then \
- echo $(ASGCC); \
- else echo "as" ; \
- fi\
- fi)
-
- LDTYPE:=$(shell if $(LDPATH) -V 1>/dev/null 2>/dev/null; then \
- if $(LDPATH) -V 2>&1|grep GNU >/dev/null; \
- then echo gnu; \
- else \
- if $(LDPATH) -V 2>&1|grep Solaris >/dev/null;\
- then echo solaris; \
- else \
- echo unknown ; \
- fi \
- fi \
- fi)
- ASTYPE:=$(shell if $(ASPATH) -V 1>/dev/null 2>/dev/null </dev/null; \
- then \
- if $(ASPATH) -V 2>&1 </dev/null | \
- grep GNU >/dev/null; then echo gnu; \
- else \
- if $(ASPATH) -V 2>&1 </dev/null | \
- grep Sun >/dev/null; then echo solaris; \
- else \
- echo unknown ; \
- fi \
- fi \
- fi)
- #$(warning "using ld=$(LDPATH)/$(LDTYPE), as=$(ASPATH)/$(ASTYPE)")
- endif
- endif
- # arch. specific definitions
- ifeq ($(ARCH), i386)
- use_fast_lock=yes
- endif
- ifeq ($(ARCH), x86_64)
- use_fast_lock=yes
- endif
- ifeq ($(ARCH), sparc64)
- ifeq ($(CC_NAME), gcc)
- use_fast_lock=yes
- endif
- endif
- ifeq ($(ARCH), sparc)
- use_fast_lock=yes
- endif
- ifeq ($(ARCH), arm)
- use_fast_lock=yes
- C_DEFS+=-DNOSMP # very unlikely to have an smp arm
- endif
- ifeq ($(ARCH), arm6)
- use_fast_lock=yes
- endif
- ifeq ($(ARCH), ppc)
- use_fast_lock=yes
- endif
- ifeq ($(ARCH), ppc64)
- use_fast_lock=yes
- endif
- ifeq ($(ARCH), mips)
- # mips1 arch. (e.g. R3000) - no hardware locking support
- use_fast_lock=no
- C_DEFS+=-DMIPS_HAS_LLSC # likely
- C_DEFS+=-DNOSMP # very likely
- endif
- ifeq ($(ARCH), mips2)
- # mips2 arch and newer (mips3=R4000, mips4=R5000 a.s.o)
- use_fast_lock=yes
- endif
- ifeq ($(ARCH), mips64)
- # mips2 arch and newer (mips3=R4000, mips4=R5000 a.s.o)
- use_fast_lock=yes
- endif
- ifeq ($(ARCH), alpha)
- use_fast_lock=yes
- C_DEFS+=-DNOSMP # very likely
- endif
- ifeq ($(use_fast_lock), yes)
- C_DEFS+= -DFAST_LOCK -DADAPTIVE_WAIT -DADAPTIVE_WAIT_LOOPS=1024
- found_lock_method=yes
- endif
- CFLAGS=
- LDFLAGS=
- C_INCLUDES=
- # setting CFLAGS
- ifeq ($(mode), release)
- #if i386
- ifeq ($(ARCH), i386)
- # if gcc
- ifeq ($(CC_NAME), gcc)
- C_DEFS+=-DCC_GCC_LIKE_ASM
- #common stuff
- CFLAGS=-g -O9 -funroll-loops -Wcast-align $(PROFILE)
- #if gcc 4.2+
- ifeq ($(CC_SHORTVER), 4.2+)
- CPU ?= athlon64
- CFLAGS+=-m32 -minline-all-stringops \
- -falign-loops \
- -ftree-vectorize \
- -fno-strict-overflow \
- -mtune=$(CPU)
- LDFLAGS+=-m32
- else
- #if gcc 4.0+
- ifeq ($(CC_SHORTVER), 4.x)
- CPU ?= athlon64
- CFLAGS+=-m32 -minline-all-stringops \
- -falign-loops \
- -ftree-vectorize \
- -mtune=$(CPU)
- LDFLAGS+=-m32
- else
- #if gcc 3.4+
- ifeq ($(CC_SHORTVER), 3.4)
- CPU ?= athlon
- CFLAGS+=-m32 -minline-all-stringops \
- -falign-loops \
- -mtune=$(CPU)
- LDFLAGS+=-m32
- else
- #if gcc 3.0+
- ifeq ($(CC_SHORTVER), 3.0)
- CPU ?= athlon
- CFLAGS+=-minline-all-stringops \
- -falign-loops \
- -mcpu=$(CPU)
- # -m32 supported since gcc 3.2
- else
- ifeq ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
- $(warning Old gcc detected ($(CC_SHORTVER)), use gcc >= 3.1 \
- for better results)
-
- CFLAGS+=-m486 \
- -malign-loops=4
- else
- #really old version
- $(warning You are using an old and unsupported gcc \
- version ($(CC_SHORTVER)), compile at your own risk!)
- endif # CC_SHORTVER, 2.9x
- endif # CC_SHORTVER, 3.0
- endif # CC_SHORTVER, 3.4
- endif # CC_SHORTVER, 4.x
- endif # CC_SHORTVER, 4.2+
- else # CC_NAME, gcc
- ifeq ($(CC_NAME), icc)
- C_DEFS+=-DCC_GCC_LIKE_ASM
- CFLAGS=-g -O3 -ipo -ipo_obj -unroll $(PROFILE) \
- -tpp6 -xK #-openmp #optimize for PIII
- # -prefetch doesn't seem to work
- #( ty to inline acroos files, unroll loops,prefetch,
- # optimize for PIII, use PIII instructions & vect.,
- # mutlithread loops)
- else
- #other compilers
- $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
- endif #CC_NAME, icc
- endif #CC_NAME, gcc
- endif #ARCH, i386
- #x86_64
- ifeq ($(ARCH), x86_64)
- # if gcc
- ifeq ($(CC_NAME), gcc)
- C_DEFS+=-DCC_GCC_LIKE_ASM
- #common stuff
- CFLAGS=-g -O9 -funroll-loops -Wcast-align $(PROFILE)
- #if gcc 4.2+
- ifeq ($(CC_SHORTVER), 4.2+)
- CPU ?= opteron
- CFLAGS+=-m64 -minline-all-stringops \
- -falign-loops \
- -ftree-vectorize \
- -fno-strict-overflow \
- -mtune=$(CPU)
- LDFLAGS+=-m64
- else
- #if gcc 4.0+
- ifeq ($(CC_SHORTVER), 4.x)
- CPU ?= opteron
- CFLAGS+=-m64 -minline-all-stringops \
- -falign-loops \
- -ftree-vectorize \
- -mtune=$(CPU)
- LDFLAGS+=-m64
- else
- #if gcc 3.4
- ifeq ($(CC_SHORTVER), 3.4)
- CPU ?= athlon64
- CFLAGS+=-m64 -minline-all-stringops \
- -falign-loops
- LDFLAGS+=-m64
- else
- #if gcc 3.0
- ifeq ($(CC_SHORTVER), 3.0)
- CPU ?= athlon64
- CFLAGS+=-minline-all-stringops \
- -falign-loops
- #-mcpu=$(CPU) \ # not working on all x86_64 gccs
- #-mcpu=athlon
- #-m64 on x86_64/x86 works starting with gcc 3.2
- else
- ifeq ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
- $(warning Old gcc detected ($(CC_SHORTVER)), use gcc >= 3.1 \
- for better results)
-
- CFLAGS+=-m486 \
- -malign-loops=4
- else
- #really old version
- $(warning You are using an old and unsupported gcc \
- version ($(CC_SHORTVER)), compile at your own risk!)
- endif # CC_SHORTVER, 2.9x
- endif # CC_SHORTVER, 3.0
- endif # CC_SHORTVER, 3.4
- endif # CC_SHORTVER, 4.x
- endif # CC_SHORTVER, 4.2+
- else # CC_NAME, gcc
- ifeq ($(CC_NAME), icc)
- C_DEFS+=-DCC_GCC_LIKE_ASM
- CFLAGS=-g -O3 -ipo -ipo_obj -unroll $(PROFILE) \
- -tpp6 -xK #-openmp #optimize for PIII
- # -prefetch doesn't seem to work
- #( ty to inline acroos files, unroll loops,prefetch,
- # optimize for PIII, use PIII instructions & vect.,
- # mutlithread loops)
- else
- #other compilers
- $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
- endif #CC_NAME, icc
- endif #CC_NAME, gcc
- endif #ARCH, x86_64
- #if sparc64
- ifeq ($(ARCH), sparc64)
- #if gcc
- ifeq ($(CC_NAME), gcc)
- C_DEFS+=-DCC_GCC_LIKE_ASM -DSPARC64_MODE
- #common stuff
- CFLAGS=-g -O9 -funroll-loops $(PROFILE) \
- #-Wcast-align \
- #-Wmissing-prototypes
- #if gcc 4.2+
- ifeq ($(CC_SHORTVER), 4.2+)
- CPU ?= ultrasparc
- #use 32bit for now
- CFLAGS+=-m64 -mcpu=ultrasparc \
- -mtune=$(CPU) \
- -fno-strict-overflow \
- -ftree-vectorize
- # use -m64 to force 64 bit (but add it also to LDFLAGS and
- # don't forget to define SPARC64_MODE)
- # -m32 for 32 bit (default on solaris),
- # nothing for arch. default
- LDFLAGS+=-m64
- else
- #if gcc 4.x
- ifeq ($(CC_SHORTVER), 4.x)
- CPU ?= ultrasparc
- #use 32bit for now
- CFLAGS+=-m64 -mcpu=ultrasparc \
- -mtune=$(CPU) \
- -ftree-vectorize
- LDFLAGS+=-m64
- else
- #if gcc 3.4
- ifeq ($(CC_SHORTVER), 3.4)
- CPU ?= ultrasparc
- #use 32bit for now
- CFLAGS+=-m64 -mcpu=ultrasparc -mtune=$(CPU)
- LDFLAGS+=-m64
- else
- #if gcc 3.0
- ifeq ($(CC_SHORTVER), 3.0)
- CPU ?= ultrasparc
- #use 32bit for now
- CFLAGS+=-m64 -mcpu=ultrasparc -mtune=$(CPU) \
- # -mcpu=v9 or ultrasparc? # -mtune implied by -mcpu
- #-mno-epilogue #try to inline function exit code
- #-mflat # omit save/restore
- #-,faster-structs #faster non Sparc ABI structure copy ops
- LDFLAGS+=-m64
- else # CC_SHORTVER, 3.0
- ifeq ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
- $(warning Old gcc detected ($(CC_SHORTVER)), use gcc >= 3.1 \
- for better results)
- ifneq ($(OS), netbsd)
- # on netbsd/sparc64, gcc 2.95.3 does not compile
- # ser with -mv8
- CFLAGS+= -mv9
- # -m64/-m32 on sparc works starting with gcc 3.0
- endif
- ifeq ($(ASTYPE), solaris)
- CFLAGS+= -Wa,-xarch=v8plus
- endif
- else #CC_SHORTVER, 2.9x
- #really old version
- $(warning You are using an old and unsupported gcc \
- version ($(CC_SHORTVER)), compile at your own risk!)
-
- CFLAGS+= -mv9
- ifeq ($(ASTYPE), solaris)
- CFLAGS+= -Wa,-xarch=v8plus
- endif
-
- endif #CC_SHORTVER, 2.9x
- endif #CC_SHORTVER, 3.0
- endif #CC_SHORTVER, 3.4
- endif #CC_SHORTVER, 4.x
- endif #CC_SHORTVER, 4.2+
-
- else #CC_NAME, gcc
- ifeq ($(CC_NAME), suncc)
- C_DEFS+=-DSPARC64_MODE
- CFLAGS+= -m64 -g -xO5 -fast -native -xarch=v9 -xCC \
- -xc99 # C99 support
- # -Dinline="" # add this if cc < 5.3 (define inline as null)
- else
- #other compilers
- $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
- endif #CC_NAME, suncc
- endif #CC_NAME, gcc
- endif #ARCH, sparc64
- #if sparc
- ifeq ($(ARCH), sparc)
- #if gcc
- ifeq ($(CC_NAME), gcc)
- C_DEFS+=-DCC_GCC_LIKE_ASM
- #common stuff
- CFLAGS=-g -O9 -funroll-loops $(PROFILE) \
- #-Wcast-align \
- #-Wmissing-prototypes
- #if gcc 4.2+
- ifeq ($(CC_SHORTVER), 4.2+)
- CPU ?= v8
- #use 32bit for now
- CFLAGS+= -mtune=$(CPU) \
- -fno-strict-overflow \
- -ftree-vectorize
- else
- #if gcc 4.x
- ifeq ($(CC_SHORTVER), 4.x)
- CPU ?= v8
- #use 32bit for now
- CFLAGS+= -mtune=$(CPU) \
- -ftree-vectorize
- else
- #if gcc 3.4
- ifeq ($(CC_SHORTVER), 3.4)
- CPU ?= v8
- #use 32bit for now
- CFLAGS+= -mtune=$(CPU)
- else
- #if gcc 3.0
- ifeq ($(CC_SHORTVER), 3.0)
- CPU ?= v8
- #use 32bit for now
- CFLAGS+= -mtune=$(CPU) \
- #-mno-epilogue #try to inline function exit code
- #-mflat # omit save/restore
- #-,faster-structs #faster non Sparc ABI structure copy ops
- else # CC_SHORTVER, 3.0
- ifeq ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
- $(warning Old gcc detected ($(CC_SHORTVER)), use gcc >= 3.1 \
- for better results)
- else #CC_SHORTVER, 2.9x
- #really old version
- $(warning You are using an old and unsupported gcc \
- version ($(CC_SHORTVER)), compile at your own risk!)
-
- endif #CC_SHORTVER, 2.9x
- endif #CC_SHORTVER, 3.0
- endif #CC_SHORTVER, 3.4
- endif #CC_SHORTVER, 4.x
- endif #CC_SHORTVER, 4.2+
-
- else #CC_NAME, gcc
- ifeq ($(CC_NAME), suncc)
- CFLAGS+= -g -xO5 -fast -native -xCC \
- -xc99 # C99 support
- # -Dinline="" # add this if cc < 5.3 (define inline as null)
- else
- #other compilers
- $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
- endif #CC_NAME, suncc
- endif #CC_NAME, gcc
- endif #ARCH, sparc
- #if ipaq/netwinder
- ifeq ($(ARCH), arm)
- # if gcc
- ifeq ($(CC_NAME), gcc)
- C_DEFS+=-DCC_GCC_LIKE_ASM
- #common stuff
- CFLAGS=-O9 -funroll-loops -fsigned-char $(PROFILE)
- #if gcc 4.2+
- ifeq ($(CC_SHORTVER), 4.2+)
- CFLAGS+= -ftree-vectorize -fno-strict-overflow
- # not supported on arm: -minline-all-stringops
- else
- #if gcc 4.x+
- ifeq ($(CC_SHORTVER), 4.x)
- CFLAGS+= -ftree-vectorize
- # not supported on arm: -minline-all-stringops
- else
- #if gcc 3.4+
- ifeq ($(CC_SHORTVER), 3.4)
- CFLAGS+=
- else
- #if gcc 3.0
- ifeq ($(CC_SHORTVER), 3.0)
- CFLAGS+=
- #-mcpu=athlon
- else
- ifeq ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
- $(warning Old gcc detected ($(CC_SHORTVER)), use gcc 3.0.x \
- for better results)
-
- CFLAGS+=
- else
- #really old version
- $(warning You are using an old and unsupported gcc \
- version ($(CC_SHORTVER)), compile at your own risk!)
-
- endif # CC_SHORTVER, 2.9x
- endif # CC_SHORTVER, 3.0
- endif # CC_SHORTVER, 3.4
- endif # CC_SHORTVER, 4.x
- endif # CC_SHORTVER, 4.2+
-
- else # CC_NAME, gcc
- #other compilers
- $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
- endif #CC_NAME, gcc
- endif #ARCH, arm
- #if armv6 cpu
- ifeq ($(ARCH), arm6)
- # if gcc
- ifeq ($(CC_NAME), gcc)
- C_DEFS+=-DCC_GCC_LIKE_ASM
- #common stuff
- CFLAGS=-march=armv6 -O9 -funroll-loops -fsigned-char \
- $(PROFILE)
- #if gcc 4.2+
- ifeq ($(CC_SHORTVER), 4.2+)
- CFLAGS+= -ftree-vectorize -fno-strict-overflow
- else
- #if gcc 4.x+
- ifeq ($(CC_SHORTVER), 4.x)
- CFLAGS+= -ftree-vectorize
- else
- #if gcc 3.4+
- ifeq ($(CC_SHORTVER), 3.4)
- CFLAGS+=
- else
- #if gcc 3.0
- ifeq ($(CC_SHORTVER), 3.0)
- CFLAGS+=
- #-mcpu=athlon
- else
- ifeq ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
- $(warning Old gcc detected ($(CC_SHORTVER)), use gcc 3.0.x \
- for better results)
-
- CFLAGS+=
- else
- #really old version
- $(warning You are using an old and unsupported gcc \
- version ($(CC_SHORTVER)), compile at your own risk!)
-
- endif # CC_SHORTVER, 2.9x
- endif # CC_SHORTVER, 3.0
- endif # CC_SHORTVER, 3.4
- endif # CC_SHORTVER, 4.x
- endif # CC_SHORTVER, 4.2+
-
- else # CC_NAME, gcc
- #other compilers
- $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
- endif #CC_NAME, gcc
- endif #ARCH, arm6
- #if mips (R3000)
- ifeq ($(ARCH), mips)
- # if gcc
- ifeq ($(CC_NAME), gcc)
- C_DEFS+=-DCC_GCC_LIKE_ASM
- #common stuff
- CFLAGS=-O9 -funroll-loops $(PROFILE)
- #if gcc 4.2+
- ifeq ($(CC_SHORTVER), 4.2+)
- CFLAGS+=-march=r3000 -minline-all-stringops \
- -ftree-vectorize -fno-strict-overflow
- else
- #if gcc 4.0+
- ifeq ($(CC_SHORTVER), 4.x)
- CFLAGS+=-march=r3000 -minline-all-stringops \
- -ftree-vectorize
- else
- #if gcc 3.4+
- ifeq ($(CC_SHORTVER), 3.4)
- CFLAGS+= -march=r3000
- else
- #if gcc 3.0
- ifeq ($(CC_SHORTVER), 3.0)
- CFLAGS+= -march=r3000
- else
- ifeq ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
- $(warning Old gcc detected ($(CC_SHORTVER)), use gcc 3.0.x \
- for better results)
-
- CFLAGS+=-march=r3000
- else
- #really old version
- $(warning You are using an old and unsupported gcc \
- version ($(CC_SHORTVER)), compile at your own risk!)
-
- endif # CC_SHORTVER, 2.9x
- endif # CC_SHORTVER, 3.0
- endif # CC_SHORTVER, 3.4
- endif # CC_SHORTVER, 4.x
- endif # CC_SHORTVER, 4.2+
-
- else # CC_NAME, gcc
- #other compilers
- $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
- endif #CC_NAME, gcc
- endif #ARCH, mips
- #if >=mips2 (R4000, R5000, R6000 ....)
- ifeq ($(ARCH), mips2)
- # if gcc
- ifeq ($(CC_NAME), gcc)
- C_DEFS+=-DCC_GCC_LIKE_ASM
- #common stuff
- CFLAGS= -mips2 -O9 -funroll-loops $(PROFILE)
- #if gcc 4.2+
- ifeq ($(CC_SHORTVER), 4.2+)
- CFLAGS+=-minline-all-stringops -ftree-vectorize \
- -fno-strict-overflow
- else
- #if gcc 4.0+
- ifeq ($(CC_SHORTVER), 4.x)
- CFLAGS+=-minline-all-stringops -ftree-vectorize
- else
- #if gcc 3.4+
- ifeq ($(CC_SHORTVER), 3.4)
- CFLAGS+=
- else
- #if gcc 3.0
- ifeq ($(CC_SHORTVER), 3.0)
- CFLAGS+=
- else
- ifeq ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
- $(warning Old gcc detected ($(CC_SHORTVER)), use gcc 3.0.x \
- for better results)
- CFLAGS+=
- else
- #really old version
- $(warning You are using an old and unsupported gcc \
- version ($(CC_SHORTVER)), compile at your own risk!)
-
- endif # CC_SHORTVER, 2.9x
- endif # CC_SHORTVER, 3.0
- endif # CC_SHORTVER, 3.4
- endif # CC_SHORTVER, 4.x
- endif # CC_SHORTVER, 4.2+
-
- else # CC_NAME, gcc
- #other compilers
- $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
- endif #CC_NAME, gcc
- endif #ARCH, mips2
- #if >=mips64
- ifeq ($(ARCH), mips64)
- # if gcc
- ifeq ($(CC_NAME), gcc)
- C_DEFS+=-DCC_GCC_LIKE_ASM
- #common stuff
- CFLAGS= -mips64 -O9 -funroll-loops $(PROFILE)
- #if gcc 4.2+
- ifeq ($(CC_SHORTVER), 4.2+)
- CFLAGS+=-minline-all-stringops -ftree-vectorize \
- -fno-strict-overflow
- else
- #if gcc 4.0+
- ifeq ($(CC_SHORTVER), 4.x)
- CFLAGS+=-minline-all-stringops -ftree-vectorize
- else
- #if gcc 3.4+
- ifeq ($(CC_SHORTVER), 3.4)
- CFLAGS+=
- else
- #if gcc 3.0
- ifeq ($(CC_SHORTVER), 3.0)
- CFLAGS+=
- else
- ifeq ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
- $(warning Old gcc detected ($(CC_SHORTVER)), use gcc 3.0.x \
- for better results)
- CFLAGS+=
- else
- #really old version
- $(warning You are using an old and unsupported gcc \
- version ($(CC_SHORTVER)), compile at your own risk!)
-
- endif # CC_SHORTVER, 2.9x
- endif # CC_SHORTVER, 3.0
- endif # CC_SHORTVER, 3.4
- endif # CC_SHORTVER, 4.x
- endif # CC_SHORTVER, 4.2+
-
- else # CC_NAME, gcc
- #other compilers
- $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
- endif #CC_NAME, gcc
- endif #ARCH, mips64
- #if alpha
- ifeq ($(ARCH), alpha)
- # if gcc
- ifeq ($(CC_NAME), gcc)
- C_DEFS+=-DCC_GCC_LIKE_ASM
- #common stuff
- CFLAGS= -O9 -funroll-loops $(PROFILE)
- #if gcc 4.2+
- ifeq ($(CC_SHORTVER), 4.2+)
- CFLAGS+= -fno-strict-overflow
- # not supported: -minline-all-stringops
- else
- #if gcc 4.0+
- ifeq ($(CC_SHORTVER), 4.x)
- CFLAGS+=
- # not supported: -minline-all-stringops
- else
- #if gcc 3.4+
- ifeq ($(CC_SHORTVER), 3.4)
- CFLAGS+=
- else
- #if gcc 3.0
- ifeq ($(CC_SHORTVER), 3.0)
- CFLAGS+=
- else
- ifeq ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
- $(warning Old gcc detected ($(CC_SHORTVER)), use gcc 3.0.x \
- for better results)
- CFLAGS+=
- else
- #really old version
- $(warning You are using an old and unsupported gcc \
- version ($(CC_SHORTVER)), compile at your own risk!)
-
- endif # CC_SHORTVER, 2.9x
- endif # CC_SHORTVER, 3.0
- endif # CC_SHORTVER, 3.4
- endif # CC_SHORTVER, 4.x
- endif # CC_SHORTVER, 4.2+
-
- else # CC_NAME, gcc
- #other compilers
- $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
- endif #CC_NAME, gcc
- endif #ARCH, alpha
- #if ppc
- ifeq ($(ARCH), ppc)
- # if gcc
- ifeq ($(CC_NAME), gcc)
- C_DEFS+=-DCC_GCC_LIKE_ASM
- #common stuff
- CFLAGS= -O9 -funroll-loops -fsigned-char $(PROFILE)
- #if gcc 4.2+
- ifeq ($(CC_SHORTVER), 4.2+)
- CPU ?= powerpc
- CFLAGS+=-ftree-vectorize \
- -fno-strict-overflow \
- -mtune=$(CPU) -maltivec
- else
- #if gcc 4.0+
- ifeq ($(CC_SHORTVER), 4.x)
- CPU ?= powerpc
- CFLAGS+=-ftree-vectorize \
- -mtune=$(CPU) -maltivec
- else
- #if gcc 3.4+
- ifeq ($(CC_SHORTVER), 3.4)
- CFLAGS+=
- else
- #if gcc 3.0
- ifeq ($(CC_SHORTVER), 3.0)
- CFLAGS+=
- else
- ifeq ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
- $(warning Old gcc detected ($(CC_SHORTVER)), use gcc 3.0.x \
- for better results)
- CFLAGS+=
- else
- #really old version
- $(warning You are using an old and unsupported gcc \
- version ($(CC_SHORTVER)), compile at your own risk!)
-
- endif # CC_SHORTVER, 2.9x
- endif # CC_SHORTVER, 3.0
- endif # CC_SHORTVER, 3.4
- endif # CC_SHORTVER, 4.x
- endif # CC_SHORTVER, 4.2+
-
- else # CC_NAME, gcc
- #other compilers
- $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
- endif #CC_NAME, gcc
- endif #ARCH, ppc
- #if ppc64
- ifeq ($(ARCH), ppc64)
- # if gcc
- ifeq ($(CC_NAME), gcc)
- C_DEFS+=-DCC_GCC_LIKE_ASM
- #common stuff
- CFLAGS= -O9 -funroll-loops -fsigned-char $(PROFILE)
- #if gcc 4.2+
- ifeq ($(CC_SHORTVER), 4.2+)
- CPU ?= powerpc64
- CFLAGS+=-ftree-vectorize \
- -fno-strict-overflow \
- -mtune=$(CPU) -maltivec
- else
- #if gcc 4.0+
- ifeq ($(CC_SHORTVER), 4.x)
- CPU ?= powerpc64
- CFLAGS+=-ftree-vectorize \
- -mtune=$(CPU) -maltivec
- else
- #if gcc 3.4+
- ifeq ($(CC_SHORTVER), 3.4)
- CFLAGS+=
- else
- #if gcc 3.0
- ifeq ($(CC_SHORTVER), 3.0)
- CFLAGS+=
- else
- ifeq ($(CC_SHORTVER), 2.9x) #older gcc version (2.9[1-5])
- $(warning Old gcc detected ($(CC_SHORTVER)), use gcc 3.0.x \
- for better results)
- CFLAGS+=
- else
- #really old version
- $(warning You are using an old and unsupported gcc \
- version ($(CC_SHORTVER)), compile at your own risk!)
-
- endif # CC_SHORTVER, 2.9x
- endif # CC_SHORTVER, 3.0
- endif # CC_SHORTVER, 3.4
- endif # CC_SHORTVER, 4.x
- endif # CC_SHORTVER, 4.2+
-
- else # CC_NAME, gcc
- #other compilers
- $(error Unsupported compiler ($(CC):$(CC_NAME)), try gcc)
- endif #CC_NAME, gcc
- endif #ARCH, ppc
- CFLAGS+= $(CC_EXTRA_OPTS)
- # setting LDFLAGS
- ifeq ($(CC_NAME), gcc)
- ifeq ($(LDTYPE), solaris)
- # solaris ld
- LDFLAGS+=-O2 $(PROFILE)
- MOD_LDFLAGS:=-G $(LDFLAGS)
- LIB_LDFLAGS:=-G $(LDFLAGS)
- LIB_SONAME=-Wl,-h,
- LD_RPATH=-Wl,-R,
- else
- #gcc and maybe others, => gnu ld
- LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE)
- MOD_LDFLAGS:=-shared $(LDFLAGS)
- LIB_LDFLAGS:=-shared $(LDFLAGS)
- LIB_SONAME=-Wl,-soname,
- LD_RPATH=-Wl,-rpath,
- endif
- endif
- ifeq ($(CC_NAME), icc)
- #gcc and maybe others
- LDFLAGS+=-Wl,-O2 -Wl,-E $(PROFILE)
- MOD_LDFLAGS:=-shared $(LDFLAGS)
- LIB_LDFLAGS:=-shared $(LDFLAGS)
- LIB_SONAME=-Wl,-soname,
- LD_RPATH=-Wl,-rpath,
- endif
- ifeq ($(CC_NAME), suncc)
- # -dy?
- LDFLAGS+=-xO5 $(PROFILE)
- MOD_LDFLAGS:=-G $(LDFLAGS)
- LIB_LDFLAGS:=-G $(LDFLAGS)
- LIB_SONAME="-h "
- LD_RPATH=-"-R "
- endif
- # we need -fPIC -DPIC only for shared objects, we don't need them for
- # the executable file, because it's always loaded at a fixed address
- # -andrei
- else #mode,release
- ifeq ($(CC_NAME), gcc)
- CFLAGS=-g -Wcast-align $(PROFILE)
- C_DEFS+=-DCC_GCC_LIKE_ASM
- ifeq ($(ARCH), sparc64)
- C_DEFS+=SPARC64_MODE
- CFLAGS+= -mcpu=ultrasparc -m64
- LDFLAGS+=-m64
- endif
- ifeq ($(LDTYPE), solaris)
- #solaris ld
- LDFLAGS+=-g $(PROFILE)
- MOD_LDFLAGS:=-G $(LDFLAGS)
- LIB_LDFLAGS:=-G $(LDFLAGS)
- LIB_SONAME=-Wl,-h,
- LD_RPATH=-Wl,-R,
- else
- #gnu or other ld type
- LDFLAGS+=-g -Wl,-E $(PROFILE)
- MOD_LDFLAGS:=-shared $(LDFLAGS)
- LIB_LDFLAGS:=-shared $(LDFLAGS)
- LIB_SONAME=-Wl,-soname,
- LD_RPATH=-Wl,-rpath,
- endif
- endif
- ifeq ($(CC_NAME), icc)
- C_DEFS+=-DCC_GCC_LIKE_ASM
- CFLAGS=-g $(PROFILE)
- LDFLAGS+=-g -Wl,-E $(PROFILE)
- MOD_LDFLAGS:=-shared $(LDFLAGS)
- LIB_LDFLAGS:=-shared $(LDFLAGS)
- LIB_SONAME=-Wl,-soname,
- LD_RPATH=-Wl,-rpath,
- endif
- ifeq ($(CC_NAME), suncc)
- CFLAGS= -g $(PROFILE)
- LDFLAGS+=-g $(PROFILE)
- MOD_LDFLAGS:=-G $(LDFLAGS)
- LIB_LDFLAGS:=-G $(LDFLAGS)
- LIB_SONAME="-h "
- LD_RPATH=-"-R "
- endif
- endif #mode=release
- # set pedantic compiler options
- ifeq ($(CC_NAME), gcc)
- CFLAGS+= -Wall
- else # no gcc
- ifeq ($(CC_NAME), icc)
- CFLAGS+= -Wall
- else # no icc
- ifeq ($(CC_NAME), suncc)
- # FIXME: is the default (-Xa ?) enough?
- endif # CC_NAME=suncc
- endif # CC_NAME=icc
- endif # CC_NAME=gcc
- #CFLAGS used for compiling the modules, libraries and utils
- ifeq ($(CC_NAME), gcc)
- MOD_CFLAGS=-fPIC -DPIC $(CFLAGS)
- LIB_CFLAGS=-fPIC -DPIC $(CFLAGS)
- endif
- ifeq ($(CC_NAME), icc)
- MOD_CFLAGS=-Kpic $(CFLAGS)
- LIB_CFLAGS=-Kpic $(CFLAGS)
- endif
- ifeq ($(CC_NAME), suncc)
- # FIMXE: use -KPIC instead -xcode ?
- MOD_CFLAGS=-xcode=pic32 $(CFLAGS)
- LIB_CFLAGS=-xcode=pic32 $(CFLAGS)
- endif
- UTILS_CFLAGS=$(CFLAGS)
- # LDFLAGS uses for compiling the utils
- UTILS_LDFLAGS=$(LDFLAGS)
- ifeq ($(LEX),)
- LEX=flex
- endif
- ifeq ($(YACC),)
- YACC=bison
- endif
- YACC_FLAGS=-d -b cfg
- # on solaris add -lxnet (e.g. LIBS= -lxnet)
- LIBS= -ldl -lresolv
- LIB_PREFIX:=lib
- LIB_SUFFIX:=.so
- #os specific stuff
- ifeq ($(OS), linux)
- # by default use futexes if available
- use_futex= yes
- C_DEFS+=-DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
- -DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H \
- -DHAVE_TIMEGM -DHAVE_SCHED_SETSCHEDULER
- ifneq ($(found_lock_method), yes)
- #C_DEFS+= -DUSE_POSIX_SEM
- C_DEFS+=-DUSE_PTHREAD_MUTEX
- LIBS+= -lpthread
- #C_DEFS+= -DUSE_SYSV_SEM # try posix sems
- found_lock_method=yes
- else
- ifneq (,$(findstring -DUSE_POSIX_SEM, $(C_DEFS)))
- LIBS+=-lpthread
- endif
- ifneq (,$(findstring -DUSE_PTHREAD_MUTEX, $(C_DEFS)))
- LIBS+=-lpthread
- endif
- endif
- # check for >= 2.5.44
- ifeq ($(shell [ $(OSREL_N) -ge 2005044 ] && echo has_epoll), has_epoll)
- ifeq ($(NO_EPOLL),)
- C_DEFS+=-DHAVE_EPOLL
- # linux + gcc >= 3.0 + -malign-double + epoll => problems
- CFLAGS_RM+=-malign-double
- #CFLAGS:=$(filter-out -malign-double, $(CFLAGS))
- endif
- endif
- # check for >= 2.2.0
- ifeq ($(shell [ $(OSREL_N) -ge 2002000 ] && echo has_sigio), has_sigio)
- ifeq ($(NO_SIGIO),)
- C_DEFS+=-DHAVE_SIGIO_RT -DSIGINFO64_WORKARROUND
- endif
- endif
- # check for >= 2.5.70
- ifeq ($(shell [ $(OSREL_N) -ge 2005070 ] && echo has_futex), has_futex)
- ifeq ($(use_futex), yes)
- C_DEFS+=-DUSE_FUTEX
- endif
- endif
- ifeq ($(NO_SELECT),)
- C_DEFS+=-DHAVE_SELECT
- endif
- # sctp support
- ifeq ($(SCTP),1)
- # test to see if the devfiles and lib are installed
- sctp_dev_locations := /usr/include/netinet/sctp.h \
- $(LOCALBASE)/include/netinet/sctp.h
- sctp_lib_locations := /usr/lib/libsctp.so \
- $(LOCALBASE)/usr/local/lib/libsctp.so
- sctp_dev_path := $(wildcard $(sctp_dev_locations))
- sctp_lib_path := $(wildcard $(sctp_lib_locations))
- ifeq ($(sctp_dev_path),)
- $(info "sctp development files not installed -- sctp disabled")
- override SCTP :=
- endif
- ifeq ($(sctp_lib_path),)
- $(info "sctp libraries not installed -- sctp disabled")
- override SCTP :=
- endif
-
- ifeq ($(SCTP),1)
- # use lksctp
- C_DEFS+=-DUSE_SCTP
- LIBS+=-lsctp
- endif
- endif # SCTP
- endif
- ifeq ($(OS), solaris)
- C_DEFS+= -DHAVE_GETIPNODEBYNAME -DHAVE_SYS_SOCKIO_H -DHAVE_SCHED_YIELD \
- -DHAVE_ALLOCA_H -DUSE_SIGACTION
- ifneq ($(found_lock_method), yes)
- C_DEFS+= -DUSE_PTHREAD_MUTEX # try pthread sems
- found_lock_method=yes
- endif
- # check for ver >= 5.7
- ifeq ($(shell [ $(OSREL_N) -gt 5007 ] && echo has_devpoll), has_devpoll)
- ifeq ($(NO_DEVPOLL),)
- C_DEFS+=-DHAVE_DEVPOLL
- endif
- endif
- ifeq ($(NO_SELECT),)
- C_DEFS+=-DHAVE_SELECT
- endif
- # check for filio.h
- filio_h_locations= /usr/include/sys/filio.h \
- $(LOCALBASE)/include/sys/filio.h
- has_filio_h=$(shell for r in $(filio_h_locations); do \
- if [ -r "$$r" ] ; then echo yes; exit; fi \
- done;\
- )
- ifeq ($(has_filio_h), yes)
- C_DEFS+=-DHAVE_FILIO_H
- endif
- ifeq ($(mode), release)
- #use these only if you're using gcc with Solaris ld
- #LDFLAGS=-O2 $(PROFILE)
- #MOD_LDFLAGS=-O2 -G
- else
- #LDFLAGS=-g $(PROFILE)
- #MOD_LDFLAGS=-g -G
- endif
- YACC=yacc
- ifeq ($(CC_NAME), suncc)
- LIBS= -lfast -ldl -lresolv
- endif
- OLD_SOLARIS= $(shell echo "$(OSREL)" | \
- sed -e 's/^5\.[0-6][^0-9]*$$/yes/' )
- LIBS+= -L$(LOCALBASE)/lib -lxnet -lnsl
- ifeq ($(OLD_SOLARIS), yes)
- LIBS+=-lposix4
- else
- LIBS+=-lrt
- endif
- # -lrt needed for sched_yield
- endif
- ifeq ($(OS), freebsd)
- C_DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
- -DHAVE_SCHED_YIELD -DHAVE_MSGHDR_MSG_CONTROL \
- -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
- -DHAVE_NETINET_IN_SYSTM
- ifneq ($(found_lock_method), yes)
- C_DEFS+= -DUSE_PTHREAD_MUTEX # try pthread sems
- found_lock_method=yes
- LIBS+= -pthread #dlopen is in libc
- else
- LIBS= #dlopen is in libc
- endif
- # check for ver >= 4.1
- ifeq ($(shell [ $(OSREL_N) -gt 4001 ] && echo has_kqueue), has_kqueue)
- ifeq ($(NO_KQUEUE),)
- C_DEFS+=-DHAVE_KQUEUE
- endif
- endif
- ifeq ($(NO_SELECT),)
- C_DEFS+=-DHAVE_SELECT
- endif
- YACC=yacc
- # sctp support
- ifeq ($(SCTP),1)
- # test to see if the devfiles and lib are installed
- sctp_dev_locations := /usr/include/netinet/sctp.h \
- $(LOCALBASE)/include/netinet/sctp.h
- sctp_dev_path := $(wildcard $(sctp_dev_locations))
- ifeq ($(sctp_dev_path),)
- $(info "sctp development files not installed -- sctp disabled")
- override SCTP :=
- endif
- ifeq ($(shell [ $(OSREL_N) -lt 7000 ] && echo sctp), sctp)
- $(info "old freebsd version (>= 7.0 needed) -- sctp disabled")
- override SCTP :=
- endif
-
- ifeq ($(SCTP),1)
- C_DEFS+=-DUSE_SCTP
- LIBS+= # no extra libs needed on freebsd
- endif
- endif # SCTP
- endif
- ifeq ($(OS), openbsd)
- C_DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 \
- -DHAVE_UNION_SEMUN -DHAVE_MSGHDR_MSG_CONTROL \
- -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
- -DHAVE_NETINET_IN_SYSTM -DUSE_SIGWAIT
- ifneq ($(found_lock_method), yes)
- C_DEFS+= -DUSE_PTHREAD_MUTEX # try pthread sems
- found_lock_method=yes
- endif
- # check for ver >=2 9
- ifeq ($(shell [ $(OSREL_N) -ge 2009 ] && echo has_kqueue), has_kqueue)
- ifeq ($(NO_KQUEUE),)
- C_DEFS+=-DHAVE_KQUEUE
- endif
- endif
- ifeq ($(NO_SELECT),)
- C_DEFS+=-DHAVE_SELECT
- endif
- # (symbols on openbsd are prefixed by "_")
- YACC=yacc
- # no sched_yield on openbsd unless linking with c_r (not recommended)
- # unfortunately pthread is needed for sigwait
- LIBS= -lpthread
- OPENBSD_IS_AOUT:= $(shell echo "$(OSREL)" | \
- sed -e 's/^3\.[0-3][^0-9]*$$/yes/' |sed -e 's/^[0-2]\..*/yes/')
- # exception: on sparc openbsd 3.2 is elf and not aout
- ifeq ($(OSREL), 3.2)
- ifeq ($(ARCH), sparc)
- OPENBSD_IS_AOUT:=no
- endif
- ifeq ($(ARCH), sparc64)
- OPENBSD_IS_AOUT:=no
- endif
- endif
-
- ifeq ($(OPENBSD_IS_AOUT), yes)
- C_DEFS+=-DDLSYM_PREFIX='"_"'
- LDFLAGS= # openbsd ld doesn't like -O2 or -E
- endif
- endif # if opensd
-
- ifeq ($(OS), netbsd)
- C_DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 \
- -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM
- ifneq ($(found_lock_method), yes)
- C_DEFS+= -DUSE_SYSV_SEM # try pthread sems
- found_lock_method=yes
- endif
- # check for ver >= 2.0.0
- ifeq ($(shell [ $(OSREL_N) -ge 2000000 ] && echo has_kqueue), has_kqueue)
- ifeq ($(NO_KQUEUE),)
- C_DEFS+=-DHAVE_KQUEUE
- # netbsd + kqueue and -malign-double don't work
- CFLAGS_RM+=-malign-double
- #CFLAGS:=$(filter-out -malign-double, $(CFLAGS))
- endif
- endif
- ifeq ($(NO_SELECT),)
- C_DEFS+=-DHAVE_SELECT
- endif
- YACC=yacc
- LIBS=
- endif
- # OS X support, same as freebsd
- ifeq ($(OS), darwin)
- C_DEFS+=-DHAVE_SOCKADDR_SA_LEN -DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN \
- -DHAVE_SCHED_YIELD -DHAVE_MSGHDR_MSG_CONTROL \
- -DUSE_ANON_MMAP \
- -DNDEBUG -DHAVE_CONNECT_ECONNRESET_BUG -DHAVE_TIMEGM \
- -DUSE_SIGWAIT
- # -DNDEBUG used to turn off assert (assert wants to call
- # eprintf which doesn't seem to be defined in any shared lib
- ifneq ($(found_lock_method), yes)
- C_DEFS+= -DUSE_PTHREAD_MUTEX # try pthread sems
- found_lock_method=yes
- C_DEFS+= -DUSE_SYSV_SEM # try sys v sems (pthread don't work for
- # processes and unnamed posix sems are not
- # supported)
- endif
- LIBS= -lresolv #dlopen is in libc
- ifeq ($(NO_KQUEUE),)
- C_DEFS+=-DHAVE_KQUEUE
- endif
- ifeq ($(NO_SELECT),)
- C_DEFS+=-DHAVE_SELECT
- endif
- LDFLAGS= # darwin doesn't like -O2 or -E
- # the modules uses symbols from ser => either
- # -flat_namespace -undefined_suppress or -bundle_loader ../../$(MAIN_NAME)
- MOD_LDFLAGS:= -bundle -flat_namespace -undefined suppress
- # for libs using symbols from ser (e.g srdb2, kcore a.s.o) we
- # need -flat_namespace -undefined suppress
- LIB_LDFLAGS:= -dynamiclib -flat_namespace -undefined suppress
- LIB_SUFFIX:=.dylib
- # on darwin soname should include the full path
- # (it kind of combines rpath & soname)
- LIB_SONAME=
- # no equiv. for rpath on darwin
- LD_RPATH=
- YACC=yacc
- endif
- ifneq (,$(findstring cygwin, $(OS)))
- # cygwin doesn't support IPV6 and doesn't support fd passing so no TCP
- #C_DEFS:=$(filter-out -DUSE_IPV6 -DUSE_TCP, $(C_DEFS))
- DEFS_RM+=-DUSE_IPV6 -DUSE_TCP
- C_DEFS+=-DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
- -DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H \
- -DHAVE_TIMEGM -DHAVE_SCHED_SETSCHEDULER
- ifneq ($(found_lock_method), yes)
- C_DEFS+= -DUSE_POSIX_SEM
- #C_DEFS+= -DUSE_SYSV_SEM # try posix sems
- # PTHREAD_MUTEX do not work for processes (try test/pthread_test.c)
- #LIBS+= -lpthread
- found_lock_method=yes
- else
- ifneq (,$(findstring -DUSE_POSIX_SEM, $(C_DEFS)))
- #LIBS+=-lpthread
- endif
- ifneq (,$(findstring -DUSE_PTHREAD_MUTEX, $(C_DEFS)))
- $(error PTHREAD_MUTEX do not work for processes on Windows/CYGWIN)
- endif
- endif
- # check for >= 2.5.70
- ifeq ($(NO_SELECT),)
- C_DEFS+=-DHAVE_SELECT
- endif
- endif
- #add libssl if needed
- ifeq ($(CORE_TLS), 1)
- C_INCLUDES+= -I$(LOCALBASE)/ssl/include
- LIBS+= -L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib -lssl -lcrypto \
- $(TLS_EXTRA_LIBS)
- # NOTE: depending on the way in which libssl was compiled you might
- # have to add -lz -lkrb5 (zlib and kerberos5).
- # E.g.: make CORE_TLS=1 EXTRA_TLS_LIBS="-lz -lkrb5"
- endif
- ifneq ($(STUN),)
- C_INCLUDES+= -I$(LOCALBASE)/ssl/include
- LIBS+= -L$(LOCALBASE)/lib -L$(LOCALBASE)/ssl/lib -lcrypto
- endif
- ifneq ($(found_lock_method), yes)
- $(warning No locking method found so far, trying SYS V sems)
- C_DEFS+= -DUSE_SYSV_SEM # try sys v sems
- found_lock_method=yes
- endif
- endif # ifeq (,$(main_makefile))
- endif # ifeq ($(makefile_defs), 1)
- # if incomplete or missing config.mak, or already exported vars, don't
- # try to export/re-export
- ifeq ($(makefile_defs),1)
- ifneq ($(exported_vars),1)
- override exported_vars:=1
- export exported_vars
- # variable changeable only at configure time (once saved in config.mak they
- # cannot be overwritten from environment or command line, unless make cfg
- # is run)
- saved_fixed_vars:= MAIN_NAME CFG_NAME SCR_NAME FLAVOUR INSTALL_FLAVOUR \
- RELEASE OS ARCH \
- C_DEFS DEFS_RM PROFILE CC LD MKDEP MKTAGS LDFLAGS C_INCLUDES \
- MOD_LDFLAGS LIB_LDFLAGS UTILS_LDFLAGS LIB_SONAME LD_RPATH \
- LIB_SUFFIX LIB_PREFIX \
- LIBS \
- LEX YACC YACC_FLAGS \
- PREFIX LOCALBASE \
- TAR \
- INSTALL INSTALL_CFG INSTALL_BIN INSTALL_MODULES INSTALL_DOC \
- INSTALL_MAN INSTALL_LIB INSTALL_TOUCH INSTALL_SHARE \
- Q
- # variable changeable at compile time
- # extra: prefix DESTDIR BASEDIR basedirt
- saved_chg_vars:=\
- CC_EXTRA_OPTS CPU CFLAGS_RM CFLAGS MOD_CFLAGS LIB_CFLAGS UTILS_CFLAGS \
- BASEDIR basedir DESTDIR \
- PREFIX prefix\
- cfg_prefix cfg_dir bin_prefix bin_dir modules_prefix modules_dir \
- doc_prefix doc_dir man_prefix man_dir ut_prefix ut_dir \
- share_prefix share_dir lib_prefix lib_dir \
- cfg_target lib_target
- #export relevant variables to the sub-makes
- export $(saved_fixed_vars)
- export $(saved_chg_vars)
- endif # ifneq ($(exported_vars),1)
- endif # ifeq ($(makefile_defs),1)
|