configure.in 25 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234
  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. CPPFLAGS="$CPPFLAGS -g -DDEBUG"
  859. LDFLAGS="$LDFLAGS -g"
  860. ;;
  861. "gdb")
  862. CPPFLAGS="$CPPFLAGS -ggdb -DDEBUG"
  863. LDFLAGS="$LDFLAGS -g"
  864. ;;
  865. esac
  866. #
  867. # Renewal
  868. #
  869. case $enable_prere in
  870. "no")
  871. # default value
  872. CPPFLAGS="$CPPFLAGS"
  873. ;;
  874. "yes")
  875. CPPFLAGS="$CPPFLAGS -DPRERE"
  876. ;;
  877. esac
  878. #
  879. # Warnings
  880. #
  881. case $enable_warn in
  882. "no") #default
  883. CPPFLAGS="$CPPFLAGS $PROD_WARN"
  884. ;;
  885. "yes")
  886. CPPFLAGS="$CPPFLAGS"
  887. ;;
  888. "extra")
  889. CPPFLAGS="$CPPFLAGS $EXTRA_WARN"
  890. ;;
  891. esac
  892. #
  893. # Buildbot
  894. #
  895. case $enable_buildbot in
  896. "no")
  897. # default value
  898. ;;
  899. "yes")
  900. CPPFLAGS="$CPPFLAGS -DBUILDBOT"
  901. ;;
  902. esac
  903. #
  904. # RDTSC
  905. #
  906. case $enable_rdtsc in
  907. 0)
  908. #default value
  909. ;;
  910. 1)
  911. CPPFLAGS="$CPPFLAGS -DENABLE_RDTSC"
  912. ;;
  913. esac
  914. #
  915. # Profiler
  916. #
  917. case $enable_profiler in
  918. "no")
  919. # default value
  920. ;;
  921. "gprof")
  922. CFLAGS="$CFLAGS -pg"
  923. LDFLAGS="$LDFLAGS -pg"
  924. ;;
  925. esac
  926. #
  927. # zlib library (required)
  928. #
  929. if test -n "${ZLIB_HOME}" ; then
  930. LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
  931. CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
  932. fi
  933. AC_SEARCH_LIBS([inflateEnd], [z], [],[AC_MSG_ERROR([zlib library not found or incompatible, please specify the correct path with --with-zlib=DIR... stopping])])
  934. AC_CHECK_HEADER([zlib.h], [], [AC_MSG_ERROR([zlib header not found, please specify the correct path with --with-zlib=DIR... stopping])],
  935. [AC_LANG_SOURCE([#ifdef HAVE_ZLIB_H
  936. # include <zlib.h>
  937. #endif
  938. ])])
  939. #
  940. # math library (required)
  941. #
  942. AC_SEARCH_LIBS([sqrt], [m], [], [AC_MSG_ERROR([math library not found... stopping])])
  943. #
  944. # clock_gettime (optional, rt on Debian)
  945. #
  946. AC_SEARCH_LIBS([clock_gettime], [rt])
  947. #
  948. # CLOCK_MONOTONIC clock for clock_gettime
  949. # Normally defines _POSIX_TIMERS > 0 and _POSIX_MONOTONIC_CLOCK (for posix
  950. # compliant systems) and __FreeBSD_cc_version >= 500005 (for FreeBSD
  951. # >= 5.1.0, which does not have the posix defines (ref. r11983)) would be
  952. # checked but some systems define them even when they do not support it
  953. # (ref. bugreport:1003).
  954. #
  955. if test "$ac_cv_search_clock_gettime" != "no" ; then
  956. AC_MSG_CHECKING([whether CLOCK_MONOTONIC is supported and works])
  957. AC_RUN_IFELSE(
  958. [AC_LANG_SOURCE([
  959. #include <sys/time.h>
  960. #include <time.h>
  961. #include <unistd.h>
  962. int main(int argc, char** argv)
  963. {
  964. struct timespec tval;
  965. return clock_gettime(CLOCK_MONOTONIC, &tval);
  966. }
  967. ])],
  968. [
  969. AC_MSG_RESULT([yes])
  970. CPPFLAGS="$CPPFLAGS -DHAVE_MONOTONIC_CLOCK"
  971. ],
  972. [
  973. # either it failed to compile (CLOCK_MONOTONIC undefined)
  974. # or clock_gettime has returned a non-zero value
  975. AC_MSG_RESULT([no])
  976. ],
  977. [
  978. AC_MSG_RESULT([guessing no])
  979. ]
  980. )
  981. fi
  982. #
  983. # pthread
  984. #
  985. AC_SEARCH_LIBS([pthread_create], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  986. AC_SEARCH_LIBS([pthread_sigmask], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  987. AC_SEARCH_LIBS([pthread_attr_init], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  988. AC_SEARCH_LIBS([pthread_attr_setstacksize], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  989. AC_SEARCH_LIBS([pthread_attr_destroy], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  990. AC_SEARCH_LIBS([pthread_cancel], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  991. AC_SEARCH_LIBS([pthread_join], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  992. #
  993. # MySQL library
  994. #
  995. if test -z "$MYSQL_CONFIG_HOME"; then
  996. AC_PATH_PROG([MYSQL_CONFIG_HOME], [mysql_config], [no])
  997. fi
  998. if test "$MYSQL_CONFIG_HOME" != "no" ; then
  999. MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`"
  1000. if test "$manual_MYSQL_CFLAGS" = "no" ; then
  1001. MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --include`"
  1002. fi
  1003. if test "$manual_MYSQL_LIBS" = "no" ; then
  1004. MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`"
  1005. fi
  1006. else
  1007. MYSQL_VERSION="unknown"
  1008. fi
  1009. MYSQL_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS $MYSQL_LIBS"
  1010. MYSQL_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS"
  1011. AC_CHECK_LIB([mysqlclient], [mysql_init], [HAVE_MYSQL="yes"], [])
  1012. AC_CHECK_HEADER([mysql.h], [], [HAVE_MYSQL=""])
  1013. CPPFLAGS="$MYSQL_OLD_CPPFLAGS"
  1014. LDFLAGS="$MYSQL_OLD_LDFLAGS"
  1015. AC_MSG_CHECKING([MySQL library (required)])
  1016. if test "$HAVE_MYSQL" = "yes" ; then
  1017. AC_MSG_RESULT([yes ($MYSQL_VERSION)])
  1018. else
  1019. AC_MSG_RESULT([no])
  1020. AC_MSG_ERROR([MySQL not found or incompatible])
  1021. fi
  1022. AC_SUBST([HAVE_MYSQL])
  1023. AC_SUBST([MYSQL_VERSION])
  1024. AC_SUBST([MYSQL_CFLAGS])
  1025. AC_SUBST([MYSQL_LIBS])
  1026. #
  1027. # PCRE library (optional)
  1028. #
  1029. PCRE_LIBS=""
  1030. PCRE_CFLAGS=""
  1031. if test "$want_pcre" = "no" ; then
  1032. AC_MSG_NOTICE([ignoring PCRE (optional)])
  1033. else
  1034. host_os="`uname`"
  1035. if test "$host_os" = "FreeBSD" ; then
  1036. if test -z "$PCRE_HOME" ; then PCRE_HOME="/usr/local"; fi
  1037. fi
  1038. if test -z "$PCRE_HOME" ; then
  1039. AC_SEARCH_LIBS([pcre_study], [pcre], [HAVE_PCRE="yes"], [])
  1040. if test "$HAVE_PCRE" = "yes" ; then
  1041. PCRE_LIBS="-lpcre"
  1042. fi
  1043. else
  1044. PCRE_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS -L$PCRE_HOME/lib"
  1045. PCRE_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS -I$PCRE_HOME/include"
  1046. AC_CHECK_LIB(pcre, pcre_compile, [HAVE_PCRE="yes"], [])
  1047. CPPFLAGS="$PCRE_OLD_CPPFLAGS"
  1048. LDFLAGS="$PCRE_OLD_LDFLAGS"
  1049. if test "$HAVE_PCRE" = "yes" ; then
  1050. PCRE_LIBS="-L$PCRE_HOME/lib -lpcre"
  1051. test -d "$PCRE_HOME/include" && PCRE_CFLAGS="-I$PCRE_HOME/include"
  1052. fi
  1053. fi
  1054. AC_MSG_CHECKING([PCRE library (optional)])
  1055. if test "$HAVE_PCRE" = "yes" ; then
  1056. PCRE_VERSION="`pcre-config --version`"
  1057. AC_MSG_RESULT([yes ($PCRE_VERSION)])
  1058. else
  1059. AC_MSG_RESULT([no])
  1060. if test "$require_pcre" = "yes" ; then
  1061. AC_MSG_ERROR([PCRE not found or incompatible (requested)])
  1062. else
  1063. AC_MSG_NOTICE([disabling PCRE (optional)])
  1064. fi
  1065. fi
  1066. fi
  1067. AC_SUBST([HAVE_PCRE])
  1068. AC_SUBST([PCRE_VERSION])
  1069. AC_SUBST([PCRE_LIBS])
  1070. AC_SUBST([PCRE_CFLAGS])
  1071. #
  1072. # Host specific stuff
  1073. #
  1074. AC_MSG_CHECKING([host OS])
  1075. host_os="`uname`"
  1076. AC_MSG_RESULT([$host_os])
  1077. fd_setsize=""
  1078. DLLEXT=".so"
  1079. case $host_os in
  1080. Solaris* )
  1081. LIBS="$LIBS -lsocket -lnsl -ldl"
  1082. ;;
  1083. Linux* )
  1084. LIBS="$LIBS -ldl"
  1085. ;;
  1086. FreeBSD*)
  1087. CPPFLAGS="$CPPFLAGS -D__FREEBSD__"
  1088. ;;
  1089. NetBSD*)
  1090. CPPFLAGS="$CPPFLAGS -D__NETBSD__"
  1091. ;;
  1092. CYGWIN*)
  1093. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096 -DCYGWIN"
  1094. fd_setsize="done"
  1095. DLLEXT=".dll"
  1096. ;;
  1097. esac
  1098. AC_SUBST([DLLEXT])
  1099. AC_MSG_CHECKING([for MinGW])
  1100. if test -n "`$CC --version | grep -i mingw`" ; then
  1101. AC_MSG_RESULT([yes])
  1102. CPPFLAGS="$CPPFLAGS -DMINGW"
  1103. if test -z "$fd_setsize" ; then
  1104. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096"
  1105. fi
  1106. LIBS="$LIBS -lws2_32"
  1107. else
  1108. AC_MSG_RESULT([no])
  1109. fi
  1110. AC_MSG_NOTICE([Configure finish, CPPFLAGS= $CPPFLAGS])
  1111. AC_MSG_NOTICE([LDFLAGS=$LDFLAGS])
  1112. #AC_MSG_NOTICE([PROD_WARN= $PROD_WARN])
  1113. #AC_MSG_NOTICE([EXTRA_WARN= $EXTRA_WARN])
  1114. AC_MSG_NOTICE([output name = $output_login, $output_char, $output_map])
  1115. ###############################################################################
  1116. AC_OUTPUT