Makefile.defs 53 KB

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