configure.in 26 KB

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