configure.in 26 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244
  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. AC_INIT(rAthena)
  4. AC_REVISION($Revision$)
  5. AC_PREREQ([2.59])
  6. AC_CONFIG_SRCDIR([src/common/cbasetypes.h])
  7. AC_CONFIG_FILES([Makefile src/common/Makefile])
  8. AC_CONFIG_FILES([3rdparty/mt19937ar/Makefile 3rdparty/libconfig/Makefile])
  9. AC_CONFIG_FILES([src/char/Makefile src/login/Makefile])
  10. AC_CONFIG_FILES([src/map/Makefile src/tool/Makefile])
  11. AC_CONFIG_FILES([src/test/Makefile])
  12. AC_GNU_SOURCE
  13. #
  14. # Memory managers
  15. #
  16. AC_ARG_ENABLE(
  17. [manager],
  18. AC_HELP_STRING(
  19. [--enable-manager=ARG],
  20. [memory managers: no, builtin, memwatch, dmalloc, gcollect, bcheck (defaults to builtin)]
  21. ),
  22. [
  23. enable_manager="$enableval"
  24. case $enableval in
  25. "no");;
  26. "builtin");;
  27. "memwatch");;
  28. "dmalloc");;
  29. "gcollect");;
  30. "bcheck");;
  31. *) AC_MSG_ERROR([[unknown memory manager '$enableval'... stopping]]);;
  32. esac
  33. ],
  34. [enable_manager="builtin"]
  35. )
  36. #
  37. # packetver
  38. #
  39. AC_ARG_ENABLE(
  40. [packetver],
  41. AC_HELP_STRING(
  42. [--enable-packetver=ARG],
  43. [Sets the PACKETVER define. (see src/common/mmo.h)]
  44. ),
  45. [enable_packetver="$enableval"],
  46. [enable_packetver=""]
  47. )
  48. #
  49. # debug
  50. #
  51. AC_ARG_ENABLE(
  52. [debug],
  53. AC_HELP_STRING(
  54. [--enable-debug@<:@=ARG@:>@],
  55. [
  56. Compiles extra debug code. (disabled by default)
  57. (available options: yes, no, gdb)
  58. ]
  59. ),
  60. [
  61. enable_debug="$enableval"
  62. case $enableval in
  63. "no");;
  64. "yes");;
  65. "gdb");;
  66. *) AC_MSG_ERROR([[invalid argument --enable-debug=$enableval... stopping]]);;
  67. esac
  68. ],
  69. [enable_debug="no"]
  70. )
  71. #
  72. # renewal
  73. #
  74. AC_ARG_ENABLE(
  75. [prere],
  76. AC_HELP_STRING(
  77. [--enable-prere@<:@=ARG@:>@],
  78. [
  79. Compiles serv in prere mode. (disabled by default)
  80. (available options: yes, no)
  81. ]
  82. ),
  83. [
  84. enable_prere="$enableval"
  85. case $enableval in
  86. "no");;
  87. "yes");;
  88. *) AC_MSG_ERROR([[invalid argument --enable-prere=$enableval... stopping]]);;
  89. esac
  90. ],
  91. [enable_prere="no"]
  92. )
  93. #
  94. # warn
  95. #
  96. AC_ARG_ENABLE(
  97. [warn],
  98. AC_HELP_STRING(
  99. [--enable-warn@<:@=ARG@:>@],
  100. [
  101. Compiles with warnings. (disabled by default)
  102. (available options: yes, no, extra)
  103. ]
  104. ),
  105. [
  106. enable_warn="$enableval"
  107. case $enableval in
  108. "no");;
  109. "yes");;
  110. "extra");;
  111. *) AC_MSG_ERROR([[invalid argument --enable-warn=$enableval... stopping]]);;
  112. esac
  113. ],
  114. [enable_warn="no"]
  115. )
  116. #
  117. # Buildbot
  118. #
  119. AC_ARG_ENABLE(
  120. [buildbot],
  121. AC_HELP_STRING(
  122. [--enable-buildbot@<:@=ARG@:>@],
  123. [(available options: yes, no)]
  124. ),
  125. [
  126. enable_buildbot="$enableval"
  127. case $enableval in
  128. "no");;
  129. "yes");;
  130. *) AC_MSG_ERROR([[invalid argument --enable-buildbot=$enableval... stopping]]);;
  131. esac
  132. ],
  133. [enable_buildbot="no"]
  134. )
  135. #
  136. # RDTSC as Tick Source
  137. #
  138. AC_ARG_ENABLE(
  139. [rdtsc],
  140. AC_HELP_STRING(
  141. [--enable-rdtsc],
  142. [
  143. Uses rdtsc as timing source (disabled by default)
  144. Enable it when you've timing issues.
  145. (For example: in conjunction with XEN or Other Virtualization mechanisms)
  146. Note:
  147. Please ensure that you've disabled dynamic CPU-Frequencys, such as power saving options.
  148. (On the most modern Dedicated Servers cpufreq is preconfigured, see your distribution's manual
  149. how to disable it)
  150. ]
  151. ),
  152. [
  153. enable_rdtsc=1
  154. ],
  155. [enable_rdtsc=0]
  156. )
  157. #
  158. # Profiler
  159. #
  160. AC_ARG_ENABLE(
  161. [profiler],
  162. AC_HELP_STRING(
  163. [--enable-profiler=ARG],
  164. [Profilers: no, gprof (disabled by default)]
  165. ),
  166. [
  167. enable_profiler="$enableval"
  168. case $enableval in
  169. "no");;
  170. "gprof");;
  171. *) AC_MSG_ERROR([[invalid argument --enable-profiler=$enableval... stopping]]);;
  172. esac
  173. ],
  174. [enable_profiler="no"]
  175. )
  176. #
  177. # 64bit
  178. #
  179. AC_ARG_ENABLE(
  180. [64bit],
  181. AC_HELP_STRING(
  182. [--disable-64bit],
  183. [
  184. Enforce 32bit output on x86_64 systems.
  185. ]
  186. ),
  187. [
  188. enable_64bit="$enableval"
  189. case $enableval in
  190. "no");;
  191. "yes");;
  192. *) AC_MSG_ERROR([[invalid argument --enable-64bit=$enableval... stopping]]);;
  193. esac
  194. ],
  195. [enable_64bit="yes"]
  196. )
  197. #
  198. # LTO
  199. #
  200. AC_ARG_ENABLE(
  201. [lto],
  202. AC_HELP_STRING(
  203. [--enable-lto],
  204. [
  205. Enables or Disables Linktime Code Optimization (LTO is enabled by default)
  206. ]
  207. ),
  208. [
  209. enable_lto="$enableval"
  210. case $enableval in
  211. "no");;
  212. "yes");;
  213. *) AC_MSG_ERROR([[invalid argument --enable-lto=$disableval... stopping]]);;
  214. esac
  215. ],
  216. [enable_lto="yes"]
  217. )
  218. #
  219. # Optionally set the max number of network conenctions
  220. # the core will be support
  221. #
  222. AC_ARG_WITH(
  223. [maxconn],
  224. AC_HELP_STRING(
  225. [--with-maxconn@<:@=ARG@:>@],
  226. [optionally set the maximum connections the core can handle (default: 16384) NOT USED YET - EXPERIMENTAL]
  227. ),
  228. [
  229. if test "$withval" == "no"; then
  230. CPPFLAGS="$CPPFLAGS -DMAXCONN=16384"
  231. else
  232. if ! test "$withval" -ge 0 -o "$withval" -lt 0 2>&- ; then
  233. AC_MSG_ERROR([Invalid argument --with-maxconn=$withval ... stopping])
  234. else
  235. CPPFLAGS="$CPPFLAGS -DMAXCONN=$withval"
  236. fi
  237. fi
  238. ],
  239. [
  240. CPPFLAGS="$CPPFLAGS -DMAXCONN=16384"
  241. ]
  242. )
  243. #
  244. # output bin name
  245. #
  246. AC_ARG_WITH(
  247. [outputlogin],
  248. AC_HELP_STRING(
  249. [--with-outputlogin@<:@=ARG@:>@],
  250. [Specify the login-serv output name (defaults to login-server)]
  251. ),
  252. [output_login="$withval"],
  253. [output_login="login-server"]
  254. )
  255. AC_SUBST([OLOG],$output_login)
  256. AC_ARG_WITH(
  257. [outputchar],
  258. AC_HELP_STRING(
  259. [--with-outputchar@<:@=ARG@:>@],
  260. [Specify the char-serv output name (defaults to char-server)]
  261. ),
  262. [output_char="$withval"],
  263. [output_char="char-server"]
  264. )
  265. AC_SUBST([OCHR],$output_char)
  266. AC_ARG_WITH(
  267. [outputmap],
  268. AC_HELP_STRING(
  269. [--with-outputmap@<:@=ARG@:>@],
  270. [Specify the map-serv output name (defaults to map-server)]
  271. ),
  272. [output_map="$withval"],
  273. [output_map="map-server"]
  274. )
  275. AC_SUBST([OMAP],$output_map)
  276. #
  277. # Optionally specify the path to mysql_config
  278. #
  279. AC_ARG_WITH(
  280. [mysql],
  281. AC_HELP_STRING(
  282. [--with-mysql@<:@=ARG@:>@],
  283. [optionally specify the path to the mysql_config executable]
  284. ),
  285. [
  286. if test "$withval" != "no" ; then
  287. if test ! -x "$withval" ; then
  288. AC_MSG_ERROR([$withval is not an executable file])
  289. fi
  290. MYSQL_CONFIG_HOME="$withval"
  291. fi
  292. ]
  293. )
  294. #
  295. # Manual MYSQL_CFLAGS (optional)
  296. #
  297. AC_ARG_WITH(
  298. [MYSQL_CFLAGS],
  299. AC_HELP_STRING(
  300. [--with-MYSQL_CFLAGS=ARG],
  301. [specify MYSQL_CFLAGS manually (instead of using "mysql_config --include")]
  302. ),
  303. [
  304. manual_MYSQL_CFLAGS="yes"
  305. MYSQL_CFLAGS="$withval"
  306. ],
  307. [manual_MYSQL_CFLAGS="no"]
  308. )
  309. #
  310. # Manual MYSQL_LIBS (optional)
  311. #
  312. AC_ARG_WITH(
  313. [MYSQL_LIBS],
  314. AC_HELP_STRING(
  315. [--with-MYSQL_LIBS=ARG],
  316. [specify MYSQL_LIBS manually (instead of using "mysql_config --libs")]
  317. ),
  318. [
  319. manual_MYSQL_LIBS="yes"
  320. MYSQL_LIBS="$withval"
  321. ],
  322. [manual_MYSQL_LIBS="no"]
  323. )
  324. #
  325. # Enable/disable PCRE and optionally specify the path (optional library)
  326. #
  327. AC_ARG_WITH(
  328. [pcre],
  329. AC_HELP_STRING(
  330. [--with-pcre@<:@=ARG@:>@],
  331. [use PCRE library, optionally specify the full path of pcre installation directory (by default pcre is used if found)]
  332. ),
  333. [
  334. if test "$withval" = "no" ; then
  335. want_pcre="no"
  336. else
  337. want_pcre="yes"
  338. require_pcre="yes"
  339. if test "$withval" != "yes" ; then
  340. if test ! -d "$withval" ; then
  341. AC_MSG_ERROR([$withval is not a directoy])
  342. fi
  343. PCRE_HOME="$withval"
  344. fi
  345. fi
  346. ],
  347. [want_pcre="yes" require_pcre="no"]
  348. )
  349. #
  350. # Specify the path of the zlib library (required library)
  351. #
  352. AC_ARG_WITH(
  353. [zlib],
  354. AC_HELP_STRING(
  355. [--with-zlib=DIR],
  356. [root directory path of zlib installation (defaults to /usr/local or /usr if not found in /usr/local).
  357. Assumes that the header files are in DIR/include and the library files are in DIR/lib]
  358. ),
  359. [
  360. test -n "$withval" && ZLIB_HOME="$withval"
  361. ],
  362. [
  363. ZLIB_HOME=/usr/local
  364. test ! -f "${ZLIB_HOME}/include/zlib.h" && ZLIB_HOME=/usr
  365. ]
  366. )
  367. ###############################################################################
  368. # Check for programs and types.
  369. #
  370. AC_PROG_MAKE_SET
  371. AC_PROG_CC
  372. AC_PROG_CPP
  373. AC_PATH_PROG(AR, ar)
  374. AC_LANG([C])
  375. CFLAGS="$CFLAGS -pipe -ffast-math -Wall"
  376. CPPFLAGS="$CPPFLAGS -I../common"
  377. AC_C_BIGENDIAN(
  378. [AC_MSG_ERROR([[bigendian is not supported... stopping]])],
  379. ,
  380. [AC_MSG_WARN([[unable to determine endianess, only little endian is supported]])]
  381. )
  382. if test "$enable_64bit" = "no" ; then
  383. AC_MSG_CHECKING([whether pointers can be stored in ints (old code)])
  384. pointers_fit_in_ints="no"
  385. AC_COMPILE_IFELSE(
  386. [AC_LANG_PROGRAM([[static int test_array[((long int)sizeof(int)) == ((long int)sizeof(void*)) ? 1 : -1];]])],
  387. [pointers_fit_in_ints="yes"],
  388. []
  389. )
  390. if test "$pointers_fit_in_ints" = "no" ; then
  391. CFLAGS="$CFLAGS -m32"
  392. LDFLAGS="$LDFLAGS -m32"
  393. AC_COMPILE_IFELSE(
  394. [AC_LANG_PROGRAM([[static int test_array[((long int)sizeof(int)) == ((long int)sizeof(void *)) ? 1 : -1];]])],
  395. [pointers_fit_in_ints="yes (with -m32)"],
  396. []
  397. )
  398. fi
  399. AC_MSG_RESULT($pointers_fit_in_ints)
  400. if test "$pointers_fit_in_ints" = "no" ; then
  401. AC_MSG_ERROR([pointers cannot be stored in ints, required for old code... stopping])
  402. fi
  403. fi
  404. #
  405. # check if we're producing 32bit code - so well produce binarys for at least i686 (speedup: cmovs, and cmpchg8 support)
  406. #
  407. AC_MSG_CHECKING([whether $CC produces 32bit code])
  408. AC_RUN_IFELSE(
  409. [AC_LANG_SOURCE([
  410. int main(int argc, char **argv){
  411. if(sizeof(void*) == 4) return 0;
  412. else return 1;
  413. }
  414. ])],
  415. [
  416. AC_MSG_RESULT([yes])
  417. AC_MSG_CHECKING([whether $CC supports -march=i686 (and we can run it)])
  418. OLD_CFLAGS="$CFLAGS"
  419. OLD_LDFLAGS="$LDFLAGS"
  420. CFLAGS="$CFLAGS -march=i686"
  421. LDFLAGS="$LDFLAGS -march=i686"
  422. AC_RUN_IFELSE(
  423. [AC_LANG_SOURCE([
  424. int main(int argc, char **argv) { return 0; }
  425. ])],
  426. [
  427. AC_MSG_RESULT([yes])
  428. ],
  429. [
  430. AC_MSG_RESULT([no])
  431. CFLAGS="$OLD_CFLAGS"
  432. LDFLAGS="$OLD_LDFLAGS"
  433. ],
  434. [
  435. AC_MSG_RESULT([guessing no])
  436. CFLAGS="$OLD_CFLAGS"
  437. LDFLAGS="$OLD_LDFLAGS"
  438. ]
  439. )
  440. ],
  441. [
  442. AC_MSG_RESULT([no])
  443. ],
  444. [
  445. AC_MSG_RESULT([guessing no])
  446. ]
  447. )
  448. #
  449. # Check if CC supports __thread attribute (Thread Local Storage)
  450. # (Usually our OSX friends 're lacking support of it in older llvm versions ..)
  451. #
  452. AC_MSG_CHECKING([whether $CC supports __thread specifier (TLS)])
  453. AC_RUN_IFELSE(
  454. [AC_LANG_SOURCE([
  455. __thread int g_Test = -1;
  456. int main(int argc, char **argv){
  457. g_Test = 0;
  458. return g_Test;
  459. }
  460. ])],
  461. [
  462. AC_MSG_RESULT([yes])
  463. CPPFLAGS="$CPPFLAGS -DHAS_TLS"
  464. ],
  465. [
  466. AC_MSG_RESULT([no])
  467. ]
  468. )
  469. #
  470. # LTO Support test
  471. #
  472. if test "$enable_lto" != "no" ; then
  473. OLD_CFLAGS="$CFLAGS"
  474. CFLAGS="$CFLAGS -flto"
  475. OLD_LDFLAGS="$LDFLAGS"
  476. LDFLAGS="$LDFLAGS -flto"
  477. AC_MSG_CHECKING([whether $CC supports -flto])
  478. AC_RUN_IFELSE(
  479. [AC_LANG_SOURCE([
  480. int main(int argc, char **argv){
  481. return 0;
  482. }
  483. ])],
  484. [
  485. AC_MSG_RESULT([yes])
  486. ],
  487. [
  488. AC_MSG_RESULT([no])
  489. CFLAGS="$OLD_CFLAGS"
  490. LDFLAGS="$OLD_LDFLAGS"
  491. ],
  492. [
  493. AC_MSG_RESULT([guessing no])
  494. ]
  495. )
  496. fi
  497. AC_DEFUN(AC_CHECK_COMPILER_WFLAG,
  498. [
  499. AC_MSG_CHECKING([whether $CC supports -W$1])
  500. OLD_CFLAGS="$CFLAGS"
  501. CFLAGS="$CFLAGS -Werror -W$1"
  502. AC_COMPILE_IFELSE(
  503. [AC_LANG_SOURCE([int foo;])],
  504. [
  505. AC_MSG_RESULT([yes])
  506. CFLAGS="$OLD_CFLAGS -W$1"
  507. # Optionally, run a test
  508. if test "x$2" != "x"; then
  509. AC_MSG_CHECKING([whether $CC can actually use -W$1])
  510. CFLAGS="$OLD_CFLAGS -Werror -W$1"
  511. AC_COMPILE_IFELSE(
  512. [AC_LANG_SOURCE([$2])],
  513. [
  514. AC_MSG_RESULT([no])
  515. CFLAGS="$OLD_CFLAGS"
  516. ]
  517. [
  518. AC_MSG_RESULT([yes])
  519. CFLAGS="$OLD_CFLAGS -W$1"
  520. ],
  521. )
  522. fi
  523. ],
  524. [
  525. AC_MSG_RESULT([no])
  526. CFLAGS="$OLD_CFLAGS"
  527. ]
  528. )
  529. ]
  530. )
  531. AC_DEFUN(AC_CHECK_COMPILER_WNOFLAG,
  532. [
  533. AC_MSG_CHECKING([whether $CC supports -Wno-$1])
  534. OLD_CFLAGS="$CFLAGS"
  535. CFLAGS="$CFLAGS -Werror -Wno-$1"
  536. AC_COMPILE_IFELSE(
  537. [AC_LANG_SOURCE([int foo;])],
  538. [
  539. # Recent versions of gcc don't fail if -Wno-foo is not recognized
  540. # (unless there are also other warnings), so we also check for -Wfoo
  541. # which always fails if not supported
  542. CFLAGS="$OLD_CFLAGS -Werror -W$1"
  543. AC_COMPILE_IFELSE(
  544. [AC_LANG_SOURCE([int foo;])],
  545. [
  546. AC_MSG_RESULT([yes])
  547. CFLAGS="$OLD_CFLAGS -Wno-$1"
  548. # Optionally, run a test
  549. if test "x$2" != "x"; then
  550. AC_MSG_CHECKING([whether $CC can actually use -Wno-$1])
  551. CFLAGS="$OLD_CFLAGS -Werror -W$1"
  552. AC_COMPILE_IFELSE(
  553. [AC_LANG_SOURCE([$2])],
  554. [
  555. AC_MSG_RESULT([not needed but enabled])
  556. CFLAGS="$OLD_CFLAGS"
  557. ],
  558. [
  559. CFLAGS="$OLD_CFLAGS -Werror -Wno-$1"
  560. AC_COMPILE_IFELSE(
  561. [AC_LANG_SOURCE([$2])],
  562. [
  563. AC_MSG_RESULT([yes])
  564. CFLAGS="$OLD_CFLAGS -Wno-$1"
  565. ],
  566. [
  567. AC_MSG_RESULT([no])
  568. CFLAGS="$OLD_CFLAGS"
  569. ]
  570. )
  571. ]
  572. )
  573. fi
  574. ],
  575. [
  576. AC_MSG_RESULT([no])
  577. CFLAGS="$OLD_CFLAGS"
  578. ]
  579. )
  580. ],
  581. [
  582. AC_MSG_RESULT([no])
  583. CFLAGS="$OLD_CFLAGS"
  584. ]
  585. )
  586. ]
  587. )
  588. AC_CHECK_COMPILER_WNOFLAG(unused-parameter, [int foo(int bar) { return 0; }])
  589. AC_CHECK_COMPILER_WNOFLAG(maybe-uninitialized)
  590. AC_CHECK_COMPILER_WNOFLAG(clobbered)
  591. AC_CHECK_COMPILER_WFLAG(empty-body)
  592. AC_CHECK_COMPILER_WFLAG(newline-eof)
  593. AC_CHECK_COMPILER_WFLAG(int-conversion)
  594. AC_CHECK_COMPILER_WFLAG(enum-conversion)
  595. AC_CHECK_COMPILER_WFLAG(shorten-64-to-32)
  596. AC_CHECK_COMPILER_WFLAG(constant-conversion)
  597. AC_CHECK_COMPILER_WFLAG(bool-conversion)
  598. AC_CHECK_COMPILER_WNOFLAG(switch)
  599. AC_CHECK_COMPILER_WNOFLAG(missing-field-initializers)
  600. # Certain versions of gcc make -Wshadow completely useless by making it flood
  601. # you with unnecessary warnings <https://lkml.org/lkml/2006/11/28/239>
  602. # Let's check if we can really use it
  603. SAVED_OLD_CFLAGS="$CFLAGS"
  604. AC_CHECK_COMPILER_WFLAG(shadow)
  605. if test "x$CFLAGS" != "x$SAVED_OLD_CFLAGS"; then
  606. AC_MSG_CHECKING([whether $CC can efficiently use -Wshadow])
  607. NEW_CFLAGS="$CFLAGS"
  608. CFLAGS="$CFLAGS -Werror -Wshadow"
  609. AC_COMPILE_IFELSE(
  610. [AC_LANG_SOURCE([
  611. int foo(void) {
  612. return 0;
  613. }
  614. int bar(void) {
  615. int foo = 0;
  616. return foo + 1;
  617. }
  618. ])],
  619. [
  620. AC_MSG_RESULT([yes])
  621. CFLAGS="$NEW_CFLAGS"
  622. ],
  623. [
  624. AC_MSG_RESULT([no])
  625. CFLAGS="$SAVED_OLD_CFLAGS"
  626. ]
  627. )
  628. fi
  629. AC_MSG_CHECKING([whether $CC supports -fPIC])
  630. OLD_CFLAGS="$CFLAGS"
  631. CFLAGS="$CFLAGS -fPIC"
  632. AC_COMPILE_IFELSE(
  633. [AC_LANG_SOURCE([int foo;])],
  634. [
  635. AC_MSG_RESULT([yes])
  636. compiler_supports_pic="yes"
  637. ],
  638. [
  639. AC_MSG_RESULT([no])
  640. compiler_supports_pic="no"
  641. ]
  642. )
  643. CFLAGS="$OLD_CFLAGS"
  644. #
  645. # option for shared objects
  646. #
  647. AC_MSG_CHECKING([how to make shared objects])
  648. OLD_CFLAGS="$CFLAGS"
  649. compiler_shared_objects=""
  650. compiler_supports_shared_objects="no"
  651. if test "$compiler_supports_pic" = "yes" ; then
  652. my_shared_test_flags="$CFLAGS -fPIC"
  653. fi
  654. # default
  655. CFLAGS="$my_shared_test_flags -shared"
  656. AC_LINK_IFELSE(
  657. [AC_LANG_SOURCE([
  658. int bar = 0;
  659. int foo(void)
  660. {
  661. return bar;
  662. }
  663. ])],
  664. [
  665. compiler_shared_objects="-shared"
  666. compiler_supports_shared_objects="yes"
  667. ]
  668. )
  669. # BeOS specific
  670. CFLAGS="$my_shared_test_flags -nostart"
  671. AC_LINK_IFELSE(
  672. [AC_LANG_SOURCE([
  673. int bar = 0;
  674. int foo(void)
  675. {
  676. return bar;
  677. }
  678. ])],
  679. [
  680. compiler_shared_objects="-nostart"
  681. compiler_supports_shared_objects="yes"
  682. ]
  683. )
  684. CFLAGS="$OLD_CFLAGS"
  685. if test "$compiler_supports_shared_objects" = "no" ; then
  686. AC_MSG_RESULT([not supported])
  687. AC_MSG_NOTICE([compiler is unable to generate shared objects, disabled plugins (optional)])
  688. WITH_PLUGINS="no"
  689. else
  690. AC_MSG_RESULT([$compiler_shared_objects $compiler_supports_shared_objects])
  691. SOFLAGS="$SOFLAGS $compiler_shared_objects"
  692. AC_SUBST([SOFLAGS])
  693. #
  694. # On certain platforms, undefined references on shared libraries won't be checked
  695. # unless explicitly required with the --no-undefined linker option
  696. #
  697. AC_MSG_CHECKING([whether $CC needs -Wl,--no-undefined to check for undefined references in shared objects])
  698. OLD_CFLAGS="$CFLAGS"
  699. CFLAGS="$SOFLAGS"
  700. AC_LINK_IFELSE(
  701. [AC_LANG_SOURCE([
  702. void foo(void) {
  703. foobar();
  704. }
  705. ])],
  706. [
  707. CFLAGS="$SOFLAGS -Wl,--no-undefined"
  708. AC_LINK_IFELSE(
  709. [AC_LANG_SOURCE([
  710. int bar = 0;
  711. int foo(void) {
  712. return bar;
  713. }
  714. ])],
  715. [
  716. AC_MSG_RESULT([yes])
  717. SOFLAGS="$SOFLAGS -Wl,--no-undefined"
  718. ],
  719. [
  720. AC_MSG_RESULT([unsupported (undefined references check will be ignored)])
  721. ]
  722. )
  723. ],
  724. [
  725. AC_MSG_RESULT([no])
  726. ]
  727. )
  728. CFLAGS="$OLD_CFLAGS"
  729. #
  730. # shared objects need position independent code; some platforms emit
  731. # it always, others need -fPIC
  732. #
  733. AC_MSG_CHECKING([whether $CC needs -fPIC for shared objects])
  734. OLD_CFLAGS="$CFLAGS"
  735. CFLAGS="$CFLAGS $SOFLAGS"
  736. WITH_PLUGINS="yes"
  737. AC_LINK_IFELSE(
  738. [AC_LANG_SOURCE([
  739. int bar = 0;
  740. int foo(void)
  741. {
  742. return bar;
  743. }
  744. ])],
  745. [
  746. AC_MSG_RESULT([no])
  747. CFLAGS="$OLD_CFLAGS"
  748. ],
  749. [
  750. if test "$compiler_supports_pic" = "yes" ; then
  751. # Verify if -shared really fails due to lack of -fPIC or something else
  752. CFLAGS="$CFLAGS -fPIC"
  753. AC_LINK_IFELSE(
  754. [AC_LANG_SOURCE([
  755. int bar = 0;
  756. int foo(void)
  757. {
  758. return bar;
  759. }
  760. ])],
  761. [
  762. AC_MSG_RESULT([yes])
  763. CFLAGS="$OLD_CFLAGS -fPIC"
  764. ],
  765. [
  766. AC_MSG_RESULT([no, but fails for another reason])
  767. AC_MSG_ERROR([compiler is unable to compile shared objects for an unhandled reason, please report this with attached config.log... stopping])
  768. ]
  769. )
  770. else
  771. # Disable compilation of plugins (optional), so 'make all' does not fail
  772. AC_MSG_RESULT([yes, but unsupported])
  773. AC_MSG_NOTICE([compiler is unable to generate position independent code, disabled plugins (optional)])
  774. WITH_PLUGINS="no"
  775. fi
  776. ]
  777. )
  778. fi
  779. my_shared_test_flags=""
  780. AC_SUBST([WITH_PLUGINS])
  781. #
  782. # -O2 implies -fstrict-aliasing, but the code is not safe for that
  783. #
  784. AC_MSG_CHECKING([whether $CC supports -fno-strict-aliasing])
  785. OLD_CFLAGS="$CFLAGS"
  786. CFLAGS="$CFLAGS -fno-strict-aliasing"
  787. AC_COMPILE_IFELSE(
  788. [AC_LANG_SOURCE([int foo;])],
  789. [AC_MSG_RESULT([yes])],
  790. [
  791. AC_MSG_RESULT([no])
  792. CFLAGS="$OLD_CFLAGS"
  793. ]
  794. )
  795. ###############################################################################
  796. # Check for libraries and header files.
  797. #
  798. #
  799. # setrlimit - used to set the socket limit
  800. #
  801. AC_CHECK_FUNC([setrlimit],[CPPFLAGS="$CPPFLAGS -DHAVE_SETRLIMIT"])
  802. #
  803. # strnlen - string length with upper scan bound
  804. #
  805. AC_CHECK_FUNC([strnlen],[CPPFLAGS="$CPPFLAGS -DHAVE_STRNLEN"])
  806. # libconfig
  807. AC_CHECK_FUNCS([uselocale])
  808. AC_CHECK_FUNCS([newlocale])
  809. AC_CHECK_FUNCS([freelocale])
  810. AC_CHECK_HEADERS([xlocale.h], [], [], [
  811. AC_LANG_SOURCE([#ifdef HAVE_XLOCALE_H
  812. # include <xlocale.h>
  813. #endif
  814. ])])
  815. #
  816. # Memory manager
  817. #
  818. case $enable_manager in
  819. "no")
  820. CPPFLAGS="$CPPFLAGS -DNO_MEMMGR"
  821. ;;
  822. "builtin")
  823. # enabled by default
  824. ;;
  825. "memwatch")
  826. CPPFLAGS="$CPPFLAGS -DMEMWATCH"
  827. AC_CHECK_HEADER([memwatch.h], , [AC_MSG_ERROR([memwatch header not found... stopping])])
  828. ;;
  829. "dmalloc")
  830. CPPFLAGS="$CPPFLAGS -DDMALLOC -DDMALLOC_FUNC_CHECK"
  831. LIBS="$LIBS -ldmalloc"
  832. AC_CHECK_HEADER([dmalloc.h], , [AC_MSG_ERROR([dmalloc header not found... stopping])])
  833. ;;
  834. "gcollect")
  835. CPPFLAGS="$CPPFLAGS -DGCOLLECT"
  836. LIBS="$LIBS -lgc"
  837. AC_CHECK_HEADER([gc.h], , [AC_MSG_ERROR([gcollect header not found... stopping])])
  838. ;;
  839. "bcheck")
  840. CPPFLAGS="$CPPFLAGS -DBCHECK"
  841. ;;
  842. esac
  843. #
  844. # Packetver
  845. #
  846. if test -n "$enable_packetver" ; then
  847. CPPFLAGS="$CPPFLAGS -DPACKETVER=$enable_packetver"
  848. fi
  849. #
  850. # Debug
  851. #
  852. case $enable_debug in
  853. "no")
  854. # default value
  855. CPPFLAGS="$CPPFLAGS"
  856. ;;
  857. "yes")
  858. if test $ac_cv_prog_cc_g = yes; then
  859. CPPFLAGS="$CPPFLAGS -g -DDEBUG"
  860. LDFLAGS="$LDFLAGS -g"
  861. else
  862. echo "error: --enable-debug flag=$enable_debug entered but the compiler does not support -g"
  863. exit 1
  864. fi
  865. ;;
  866. "gdb")
  867. if test $ac_cv_prog_cc_g = yes; then
  868. CPPFLAGS="$CPPFLAGS -ggdb -DDEBUG"
  869. LDFLAGS="$LDFLAGS -g"
  870. else
  871. echo "error: --enable-debug flag=$enable_debug entered but the compiler does not support -g"
  872. exit 1
  873. fi
  874. ;;
  875. esac
  876. #
  877. # Renewal
  878. #
  879. case $enable_prere in
  880. "no")
  881. # default value
  882. CPPFLAGS="$CPPFLAGS"
  883. ;;
  884. "yes")
  885. CPPFLAGS="$CPPFLAGS -DPRERE"
  886. ;;
  887. esac
  888. #
  889. # Warnings
  890. #
  891. case $enable_warn in
  892. "no") #default
  893. CPPFLAGS="$CPPFLAGS $PROD_WARN"
  894. ;;
  895. "yes")
  896. CPPFLAGS="$CPPFLAGS"
  897. ;;
  898. "extra")
  899. CPPFLAGS="$CPPFLAGS $EXTRA_WARN"
  900. ;;
  901. esac
  902. #
  903. # Buildbot
  904. #
  905. case $enable_buildbot in
  906. "no")
  907. # default value
  908. ;;
  909. "yes")
  910. CPPFLAGS="$CPPFLAGS -DBUILDBOT"
  911. ;;
  912. esac
  913. #
  914. # RDTSC
  915. #
  916. case $enable_rdtsc in
  917. 0)
  918. #default value
  919. ;;
  920. 1)
  921. CPPFLAGS="$CPPFLAGS -DENABLE_RDTSC"
  922. ;;
  923. esac
  924. #
  925. # Profiler
  926. #
  927. case $enable_profiler in
  928. "no")
  929. # default value
  930. ;;
  931. "gprof")
  932. CFLAGS="$CFLAGS -pg"
  933. LDFLAGS="$LDFLAGS -pg"
  934. ;;
  935. esac
  936. #
  937. # zlib library (required)
  938. #
  939. if test -n "${ZLIB_HOME}" ; then
  940. LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
  941. CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
  942. fi
  943. AC_SEARCH_LIBS([inflateEnd], [z], [],[AC_MSG_ERROR([zlib library not found or incompatible, please specify the correct path with --with-zlib=DIR... stopping])])
  944. AC_CHECK_HEADER([zlib.h], [], [AC_MSG_ERROR([zlib header not found, please specify the correct path with --with-zlib=DIR... stopping])],
  945. [AC_LANG_SOURCE([#ifdef HAVE_ZLIB_H
  946. # include <zlib.h>
  947. #endif
  948. ])])
  949. #
  950. # math library (required)
  951. #
  952. AC_SEARCH_LIBS([sqrt], [m], [], [AC_MSG_ERROR([math library not found... stopping])])
  953. #
  954. # clock_gettime (optional, rt on Debian)
  955. #
  956. AC_SEARCH_LIBS([clock_gettime], [rt])
  957. #
  958. # CLOCK_MONOTONIC clock for clock_gettime
  959. # Normally defines _POSIX_TIMERS > 0 and _POSIX_MONOTONIC_CLOCK (for posix
  960. # compliant systems) and __FreeBSD_cc_version >= 500005 (for FreeBSD
  961. # >= 5.1.0, which does not have the posix defines (ref. r11983)) would be
  962. # checked but some systems define them even when they do not support it
  963. # (ref. bugreport:1003).
  964. #
  965. if test "$ac_cv_search_clock_gettime" != "no" ; then
  966. AC_MSG_CHECKING([whether CLOCK_MONOTONIC is supported and works])
  967. AC_RUN_IFELSE(
  968. [AC_LANG_SOURCE([
  969. #include <sys/time.h>
  970. #include <time.h>
  971. #include <unistd.h>
  972. int main(int argc, char** argv)
  973. {
  974. struct timespec tval;
  975. return clock_gettime(CLOCK_MONOTONIC, &tval);
  976. }
  977. ])],
  978. [
  979. AC_MSG_RESULT([yes])
  980. CPPFLAGS="$CPPFLAGS -DHAVE_MONOTONIC_CLOCK"
  981. ],
  982. [
  983. # either it failed to compile (CLOCK_MONOTONIC undefined)
  984. # or clock_gettime has returned a non-zero value
  985. AC_MSG_RESULT([no])
  986. ],
  987. [
  988. AC_MSG_RESULT([guessing no])
  989. ]
  990. )
  991. fi
  992. #
  993. # pthread
  994. #
  995. AC_SEARCH_LIBS([pthread_create], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  996. AC_SEARCH_LIBS([pthread_sigmask], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  997. AC_SEARCH_LIBS([pthread_attr_init], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  998. AC_SEARCH_LIBS([pthread_attr_setstacksize], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  999. AC_SEARCH_LIBS([pthread_attr_destroy], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  1000. AC_SEARCH_LIBS([pthread_cancel], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  1001. AC_SEARCH_LIBS([pthread_join], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  1002. #
  1003. # MySQL library
  1004. #
  1005. if test -z "$MYSQL_CONFIG_HOME"; then
  1006. AC_PATH_PROG([MYSQL_CONFIG_HOME], [mysql_config], [no])
  1007. fi
  1008. if test "$MYSQL_CONFIG_HOME" != "no" ; then
  1009. MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`"
  1010. if test "$manual_MYSQL_CFLAGS" = "no" ; then
  1011. MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --include`"
  1012. fi
  1013. if test "$manual_MYSQL_LIBS" = "no" ; then
  1014. MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`"
  1015. fi
  1016. else
  1017. MYSQL_VERSION="unknown"
  1018. fi
  1019. MYSQL_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS $MYSQL_LIBS"
  1020. MYSQL_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS"
  1021. AC_CHECK_LIB([mysqlclient], [mysql_init], [HAVE_MYSQL="yes"], [])
  1022. AC_CHECK_HEADER([mysql.h], [], [HAVE_MYSQL=""])
  1023. CPPFLAGS="$MYSQL_OLD_CPPFLAGS"
  1024. LDFLAGS="$MYSQL_OLD_LDFLAGS"
  1025. AC_MSG_CHECKING([MySQL library (required)])
  1026. if test "$HAVE_MYSQL" = "yes" ; then
  1027. AC_MSG_RESULT([yes ($MYSQL_VERSION)])
  1028. else
  1029. AC_MSG_RESULT([no])
  1030. AC_MSG_ERROR([MySQL not found or incompatible])
  1031. fi
  1032. AC_SUBST([HAVE_MYSQL])
  1033. AC_SUBST([MYSQL_VERSION])
  1034. AC_SUBST([MYSQL_CFLAGS])
  1035. AC_SUBST([MYSQL_LIBS])
  1036. #
  1037. # PCRE library (optional)
  1038. #
  1039. PCRE_LIBS=""
  1040. PCRE_CFLAGS=""
  1041. if test "$want_pcre" = "no" ; then
  1042. AC_MSG_NOTICE([ignoring PCRE (optional)])
  1043. else
  1044. host_os="`uname`"
  1045. if test "$host_os" = "FreeBSD" ; then
  1046. if test -z "$PCRE_HOME" ; then PCRE_HOME="/usr/local"; fi
  1047. fi
  1048. if test -z "$PCRE_HOME" ; then
  1049. AC_SEARCH_LIBS([pcre_study], [pcre], [HAVE_PCRE="yes"], [])
  1050. if test "$HAVE_PCRE" = "yes" ; then
  1051. PCRE_LIBS="-lpcre"
  1052. fi
  1053. else
  1054. PCRE_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS -L$PCRE_HOME/lib"
  1055. PCRE_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS -I$PCRE_HOME/include"
  1056. AC_CHECK_LIB(pcre, pcre_compile, [HAVE_PCRE="yes"], [])
  1057. CPPFLAGS="$PCRE_OLD_CPPFLAGS"
  1058. LDFLAGS="$PCRE_OLD_LDFLAGS"
  1059. if test "$HAVE_PCRE" = "yes" ; then
  1060. PCRE_LIBS="-L$PCRE_HOME/lib -lpcre"
  1061. test -d "$PCRE_HOME/include" && PCRE_CFLAGS="-I$PCRE_HOME/include"
  1062. fi
  1063. fi
  1064. AC_MSG_CHECKING([PCRE library (optional)])
  1065. if test "$HAVE_PCRE" = "yes" ; then
  1066. PCRE_VERSION="`pcre-config --version`"
  1067. AC_MSG_RESULT([yes ($PCRE_VERSION)])
  1068. else
  1069. AC_MSG_RESULT([no])
  1070. if test "$require_pcre" = "yes" ; then
  1071. AC_MSG_ERROR([PCRE not found or incompatible (requested)])
  1072. else
  1073. AC_MSG_NOTICE([disabling PCRE (optional)])
  1074. fi
  1075. fi
  1076. fi
  1077. AC_SUBST([HAVE_PCRE])
  1078. AC_SUBST([PCRE_VERSION])
  1079. AC_SUBST([PCRE_LIBS])
  1080. AC_SUBST([PCRE_CFLAGS])
  1081. #
  1082. # Host specific stuff
  1083. #
  1084. AC_MSG_CHECKING([host OS])
  1085. host_os="`uname`"
  1086. AC_MSG_RESULT([$host_os])
  1087. fd_setsize=""
  1088. DLLEXT=".so"
  1089. case $host_os in
  1090. Solaris* )
  1091. LIBS="$LIBS -lsocket -lnsl -ldl"
  1092. ;;
  1093. Linux* )
  1094. LIBS="$LIBS -ldl"
  1095. ;;
  1096. FreeBSD*)
  1097. CPPFLAGS="$CPPFLAGS -D__FREEBSD__"
  1098. ;;
  1099. NetBSD*)
  1100. CPPFLAGS="$CPPFLAGS -D__NETBSD__"
  1101. ;;
  1102. CYGWIN*)
  1103. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096 -DCYGWIN"
  1104. fd_setsize="done"
  1105. DLLEXT=".dll"
  1106. ;;
  1107. esac
  1108. AC_SUBST([DLLEXT])
  1109. AC_MSG_CHECKING([for MinGW])
  1110. if test -n "`$CC --version | grep -i mingw`" ; then
  1111. AC_MSG_RESULT([yes])
  1112. CPPFLAGS="$CPPFLAGS -DMINGW"
  1113. if test -z "$fd_setsize" ; then
  1114. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096"
  1115. fi
  1116. LIBS="$LIBS -lws2_32"
  1117. else
  1118. AC_MSG_RESULT([no])
  1119. fi
  1120. AC_MSG_NOTICE([Configure finish, CPPFLAGS= $CPPFLAGS])
  1121. AC_MSG_NOTICE([LDFLAGS=$LDFLAGS])
  1122. #AC_MSG_NOTICE([PROD_WARN= $PROD_WARN])
  1123. #AC_MSG_NOTICE([EXTRA_WARN= $EXTRA_WARN])
  1124. AC_MSG_NOTICE([output name = $output_login, $output_char, $output_map])
  1125. ###############################################################################
  1126. AC_OUTPUT