configure.in 27 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279
  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. OPT_LTO_AR=""
  474. OPT_LTO=""
  475. OLD_CFLAGS="$CFLAGS"
  476. CFLAGS="$CFLAGS -flto -fuse-linker-plugin -ffat-lto-objects"
  477. OLD_LDFLAGS="$LDFLAGS"
  478. LDFLAGS="$LDFLAGS -flto -fuse-linker-plugin -ffat-lto-objects"
  479. AC_MSG_CHECKING([whether $CC supports -ffat-lto-objects])
  480. AC_RUN_IFELSE(
  481. [AC_LANG_SOURCE([
  482. int main(int argc, char **argv){
  483. return 0;
  484. }
  485. ])],
  486. [
  487. AC_MSG_RESULT([yes])
  488. OPT_LTO_AR="-ffat-lto-objects"
  489. ],
  490. [
  491. AC_MSG_RESULT([no])
  492. ],
  493. [
  494. AC_MSG_RESULT([guessing no])
  495. ]
  496. )
  497. CFLAGS="$OLD_CFLAGS"
  498. LDFLAGS="$OLD_LDFLAGS"
  499. CFLAGS="$CFLAGS -flto -fuse-linker-plugin"
  500. LDFLAGS="$LDFLAGS -flto -fuse-linker-plugin"
  501. AC_MSG_CHECKING([whether $CC supports -flto -fuse-linker-plugin])
  502. AC_RUN_IFELSE(
  503. [AC_LANG_SOURCE([
  504. int main(int argc, char **argv){
  505. return 0;
  506. }
  507. ])],
  508. [
  509. AC_MSG_RESULT([yes])
  510. OPT_LTO_AR="-flto -fuse-linker-plugin $OPT_LTO_AR"
  511. OPT_LTO="-flto -fuse-linker-plugin"
  512. ],
  513. [
  514. AC_MSG_RESULT([no])
  515. ],
  516. [
  517. AC_MSG_RESULT([guessing no])
  518. ]
  519. )
  520. CFLAGS="$OLD_CFLAGS"
  521. LDFLAGS="$OLD_LDFLAGS"
  522. fi
  523. AC_DEFUN(AC_CHECK_COMPILER_WFLAG,
  524. [
  525. AC_MSG_CHECKING([whether $CC supports -W$1])
  526. OLD_CFLAGS="$CFLAGS"
  527. CFLAGS="$CFLAGS -Werror -W$1"
  528. AC_COMPILE_IFELSE(
  529. [AC_LANG_SOURCE([int foo;])],
  530. [
  531. AC_MSG_RESULT([yes])
  532. CFLAGS="$OLD_CFLAGS -W$1"
  533. # Optionally, run a test
  534. if test "x$2" != "x"; then
  535. AC_MSG_CHECKING([whether $CC can actually use -W$1])
  536. CFLAGS="$OLD_CFLAGS -Werror -W$1"
  537. AC_COMPILE_IFELSE(
  538. [AC_LANG_SOURCE([$2])],
  539. [
  540. AC_MSG_RESULT([no])
  541. CFLAGS="$OLD_CFLAGS"
  542. ]
  543. [
  544. AC_MSG_RESULT([yes])
  545. CFLAGS="$OLD_CFLAGS -W$1"
  546. ],
  547. )
  548. fi
  549. ],
  550. [
  551. AC_MSG_RESULT([no])
  552. CFLAGS="$OLD_CFLAGS"
  553. ]
  554. )
  555. ]
  556. )
  557. AC_DEFUN(AC_CHECK_COMPILER_WNOFLAG,
  558. [
  559. AC_MSG_CHECKING([whether $CC supports -Wno-$1])
  560. OLD_CFLAGS="$CFLAGS"
  561. CFLAGS="$CFLAGS -Werror -Wno-$1"
  562. AC_COMPILE_IFELSE(
  563. [AC_LANG_SOURCE([int foo;])],
  564. [
  565. # Recent versions of gcc don't fail if -Wno-foo is not recognized
  566. # (unless there are also other warnings), so we also check for -Wfoo
  567. # which always fails if not supported
  568. CFLAGS="$OLD_CFLAGS -Werror -W$1"
  569. AC_COMPILE_IFELSE(
  570. [AC_LANG_SOURCE([int foo;])],
  571. [
  572. AC_MSG_RESULT([yes])
  573. CFLAGS="$OLD_CFLAGS -Wno-$1"
  574. # Optionally, run a test
  575. if test "x$2" != "x"; then
  576. AC_MSG_CHECKING([whether $CC can actually use -Wno-$1])
  577. CFLAGS="$OLD_CFLAGS -Werror -W$1"
  578. AC_COMPILE_IFELSE(
  579. [AC_LANG_SOURCE([$2])],
  580. [
  581. AC_MSG_RESULT([not needed but enabled])
  582. CFLAGS="$OLD_CFLAGS"
  583. ],
  584. [
  585. CFLAGS="$OLD_CFLAGS -Werror -Wno-$1"
  586. AC_COMPILE_IFELSE(
  587. [AC_LANG_SOURCE([$2])],
  588. [
  589. AC_MSG_RESULT([yes])
  590. CFLAGS="$OLD_CFLAGS -Wno-$1"
  591. ],
  592. [
  593. AC_MSG_RESULT([no])
  594. CFLAGS="$OLD_CFLAGS"
  595. ]
  596. )
  597. ]
  598. )
  599. fi
  600. ],
  601. [
  602. AC_MSG_RESULT([no])
  603. CFLAGS="$OLD_CFLAGS"
  604. ]
  605. )
  606. ],
  607. [
  608. AC_MSG_RESULT([no])
  609. CFLAGS="$OLD_CFLAGS"
  610. ]
  611. )
  612. ]
  613. )
  614. AC_CHECK_COMPILER_WNOFLAG(unused-parameter, [int foo(int bar) { return 0; }])
  615. AC_CHECK_COMPILER_WNOFLAG(maybe-uninitialized)
  616. AC_CHECK_COMPILER_WNOFLAG(clobbered)
  617. AC_CHECK_COMPILER_WFLAG(empty-body)
  618. AC_CHECK_COMPILER_WFLAG(newline-eof)
  619. AC_CHECK_COMPILER_WFLAG(int-conversion)
  620. AC_CHECK_COMPILER_WFLAG(enum-conversion)
  621. AC_CHECK_COMPILER_WFLAG(shorten-64-to-32)
  622. AC_CHECK_COMPILER_WFLAG(constant-conversion)
  623. AC_CHECK_COMPILER_WFLAG(bool-conversion)
  624. AC_CHECK_COMPILER_WNOFLAG(switch)
  625. AC_CHECK_COMPILER_WNOFLAG(missing-field-initializers)
  626. # Certain versions of gcc make -Wshadow completely useless by making it flood
  627. # you with unnecessary warnings <https://lkml.org/lkml/2006/11/28/239>
  628. # Let's check if we can really use it
  629. SAVED_OLD_CFLAGS="$CFLAGS"
  630. AC_CHECK_COMPILER_WFLAG(shadow)
  631. if test "x$CFLAGS" != "x$SAVED_OLD_CFLAGS"; then
  632. AC_MSG_CHECKING([whether $CC can efficiently use -Wshadow])
  633. NEW_CFLAGS="$CFLAGS"
  634. CFLAGS="$CFLAGS -Werror -Wshadow"
  635. AC_COMPILE_IFELSE(
  636. [AC_LANG_SOURCE([
  637. int foo(void) {
  638. return 0;
  639. }
  640. int bar(void) {
  641. int foo = 0;
  642. return foo + 1;
  643. }
  644. ])],
  645. [
  646. AC_MSG_RESULT([yes])
  647. CFLAGS="$NEW_CFLAGS"
  648. ],
  649. [
  650. AC_MSG_RESULT([no])
  651. CFLAGS="$SAVED_OLD_CFLAGS"
  652. ]
  653. )
  654. fi
  655. AC_MSG_CHECKING([whether $CC supports -fPIC])
  656. OLD_CFLAGS="$CFLAGS"
  657. CFLAGS="$CFLAGS -fPIC"
  658. AC_COMPILE_IFELSE(
  659. [AC_LANG_SOURCE([int foo;])],
  660. [
  661. AC_MSG_RESULT([yes])
  662. compiler_supports_pic="yes"
  663. ],
  664. [
  665. AC_MSG_RESULT([no])
  666. compiler_supports_pic="no"
  667. ]
  668. )
  669. CFLAGS="$OLD_CFLAGS"
  670. #
  671. # option for shared objects
  672. #
  673. AC_MSG_CHECKING([how to make shared objects])
  674. OLD_CFLAGS="$CFLAGS"
  675. compiler_shared_objects=""
  676. compiler_supports_shared_objects="no"
  677. if test "$compiler_supports_pic" = "yes" ; then
  678. my_shared_test_flags="$CFLAGS -fPIC"
  679. fi
  680. # default
  681. CFLAGS="$my_shared_test_flags -shared"
  682. AC_LINK_IFELSE(
  683. [AC_LANG_SOURCE([
  684. int bar = 0;
  685. int foo(void)
  686. {
  687. return bar;
  688. }
  689. ])],
  690. [
  691. compiler_shared_objects="-shared"
  692. compiler_supports_shared_objects="yes"
  693. ]
  694. )
  695. # BeOS specific
  696. CFLAGS="$my_shared_test_flags -nostart"
  697. AC_LINK_IFELSE(
  698. [AC_LANG_SOURCE([
  699. int bar = 0;
  700. int foo(void)
  701. {
  702. return bar;
  703. }
  704. ])],
  705. [
  706. compiler_shared_objects="-nostart"
  707. compiler_supports_shared_objects="yes"
  708. ]
  709. )
  710. CFLAGS="$OLD_CFLAGS"
  711. if test "$compiler_supports_shared_objects" = "no" ; then
  712. AC_MSG_RESULT([not supported])
  713. AC_MSG_NOTICE([compiler is unable to generate shared objects, disabled plugins (optional)])
  714. WITH_PLUGINS="no"
  715. else
  716. AC_MSG_RESULT([$compiler_shared_objects $compiler_supports_shared_objects])
  717. SOFLAGS="$SOFLAGS $compiler_shared_objects"
  718. AC_SUBST([SOFLAGS])
  719. #
  720. # On certain platforms, undefined references on shared libraries won't be checked
  721. # unless explicitly required with the --no-undefined linker option
  722. #
  723. AC_MSG_CHECKING([whether $CC needs -Wl,--no-undefined to check for undefined references in shared objects])
  724. OLD_CFLAGS="$CFLAGS"
  725. CFLAGS="$SOFLAGS"
  726. AC_LINK_IFELSE(
  727. [AC_LANG_SOURCE([
  728. void foo(void) {
  729. foobar();
  730. }
  731. ])],
  732. [
  733. CFLAGS="$SOFLAGS -Wl,--no-undefined"
  734. AC_LINK_IFELSE(
  735. [AC_LANG_SOURCE([
  736. int bar = 0;
  737. int foo(void) {
  738. return bar;
  739. }
  740. ])],
  741. [
  742. AC_MSG_RESULT([yes])
  743. SOFLAGS="$SOFLAGS -Wl,--no-undefined"
  744. ],
  745. [
  746. AC_MSG_RESULT([unsupported (undefined references check will be ignored)])
  747. ]
  748. )
  749. ],
  750. [
  751. AC_MSG_RESULT([no])
  752. ]
  753. )
  754. CFLAGS="$OLD_CFLAGS"
  755. #
  756. # shared objects need position independent code; some platforms emit
  757. # it always, others need -fPIC
  758. #
  759. AC_MSG_CHECKING([whether $CC needs -fPIC for shared objects])
  760. OLD_CFLAGS="$CFLAGS"
  761. CFLAGS="$CFLAGS $SOFLAGS"
  762. WITH_PLUGINS="yes"
  763. AC_LINK_IFELSE(
  764. [AC_LANG_SOURCE([
  765. int bar = 0;
  766. int foo(void)
  767. {
  768. return bar;
  769. }
  770. ])],
  771. [
  772. AC_MSG_RESULT([no])
  773. CFLAGS="$OLD_CFLAGS"
  774. ],
  775. [
  776. if test "$compiler_supports_pic" = "yes" ; then
  777. # Verify if -shared really fails due to lack of -fPIC or something else
  778. CFLAGS="$CFLAGS -fPIC"
  779. AC_LINK_IFELSE(
  780. [AC_LANG_SOURCE([
  781. int bar = 0;
  782. int foo(void)
  783. {
  784. return bar;
  785. }
  786. ])],
  787. [
  788. AC_MSG_RESULT([yes])
  789. CFLAGS="$OLD_CFLAGS -fPIC"
  790. ],
  791. [
  792. AC_MSG_RESULT([no, but fails for another reason])
  793. AC_MSG_ERROR([compiler is unable to compile shared objects for an unhandled reason, please report this with attached config.log... stopping])
  794. ]
  795. )
  796. else
  797. # Disable compilation of plugins (optional), so 'make all' does not fail
  798. AC_MSG_RESULT([yes, but unsupported])
  799. AC_MSG_NOTICE([compiler is unable to generate position independent code, disabled plugins (optional)])
  800. WITH_PLUGINS="no"
  801. fi
  802. ]
  803. )
  804. fi
  805. my_shared_test_flags=""
  806. AC_SUBST([WITH_PLUGINS])
  807. #
  808. # -O2 implies -fstrict-aliasing, but the code is not safe for that
  809. #
  810. AC_MSG_CHECKING([whether $CC supports -fno-strict-aliasing])
  811. OLD_CFLAGS="$CFLAGS"
  812. CFLAGS="$CFLAGS -fno-strict-aliasing"
  813. AC_COMPILE_IFELSE(
  814. [AC_LANG_SOURCE([int foo;])],
  815. [AC_MSG_RESULT([yes])],
  816. [
  817. AC_MSG_RESULT([no])
  818. CFLAGS="$OLD_CFLAGS"
  819. ]
  820. )
  821. ###############################################################################
  822. # Check for libraries and header files.
  823. #
  824. #
  825. # setrlimit - used to set the socket limit
  826. #
  827. AC_CHECK_FUNC([setrlimit],[CPPFLAGS="$CPPFLAGS -DHAVE_SETRLIMIT"])
  828. #
  829. # strnlen - string length with upper scan bound
  830. #
  831. AC_CHECK_FUNC([strnlen],[CPPFLAGS="$CPPFLAGS -DHAVE_STRNLEN"])
  832. # libconfig
  833. AC_CHECK_FUNCS([uselocale])
  834. AC_CHECK_FUNCS([newlocale])
  835. AC_CHECK_FUNCS([freelocale])
  836. AC_CHECK_HEADERS([xlocale.h], [], [], [
  837. AC_LANG_SOURCE([#ifdef HAVE_XLOCALE_H
  838. # include <xlocale.h>
  839. #endif
  840. ])])
  841. #
  842. # Memory manager
  843. #
  844. case $enable_manager in
  845. "no")
  846. CPPFLAGS="$CPPFLAGS -DNO_MEMMGR"
  847. ;;
  848. "builtin")
  849. # enabled by default
  850. ;;
  851. "memwatch")
  852. CPPFLAGS="$CPPFLAGS -DMEMWATCH"
  853. AC_CHECK_HEADER([memwatch.h], , [AC_MSG_ERROR([memwatch header not found... stopping])])
  854. ;;
  855. "dmalloc")
  856. CPPFLAGS="$CPPFLAGS -DDMALLOC -DDMALLOC_FUNC_CHECK"
  857. LIBS="$LIBS -ldmalloc"
  858. AC_CHECK_HEADER([dmalloc.h], , [AC_MSG_ERROR([dmalloc header not found... stopping])])
  859. ;;
  860. "gcollect")
  861. CPPFLAGS="$CPPFLAGS -DGCOLLECT"
  862. LIBS="$LIBS -lgc"
  863. AC_CHECK_HEADER([gc.h], , [AC_MSG_ERROR([gcollect header not found... stopping])])
  864. ;;
  865. "bcheck")
  866. CPPFLAGS="$CPPFLAGS -DBCHECK"
  867. ;;
  868. esac
  869. #
  870. # Packetver
  871. #
  872. if test -n "$enable_packetver" ; then
  873. CPPFLAGS="$CPPFLAGS -DPACKETVER=$enable_packetver"
  874. fi
  875. #
  876. # Debug
  877. #
  878. case $enable_debug in
  879. "no")
  880. # default value
  881. CPPFLAGS="$CPPFLAGS"
  882. ;;
  883. "yes")
  884. if test $ac_cv_prog_cc_g = yes; then
  885. CPPFLAGS="$CPPFLAGS -g -DDEBUG"
  886. LDFLAGS="$LDFLAGS -g"
  887. else
  888. echo "error: --enable-debug flag=$enable_debug entered but the compiler does not support -g"
  889. exit 1
  890. fi
  891. ;;
  892. "gdb")
  893. if test $ac_cv_prog_cc_g = yes; then
  894. CPPFLAGS="$CPPFLAGS -ggdb -DDEBUG"
  895. LDFLAGS="$LDFLAGS -g"
  896. else
  897. echo "error: --enable-debug flag=$enable_debug entered but the compiler does not support -g"
  898. exit 1
  899. fi
  900. ;;
  901. esac
  902. #
  903. # Renewal
  904. #
  905. case $enable_prere in
  906. "no")
  907. # default value
  908. CPPFLAGS="$CPPFLAGS"
  909. ;;
  910. "yes")
  911. CPPFLAGS="$CPPFLAGS -DPRERE"
  912. ;;
  913. esac
  914. #
  915. # Warnings
  916. #
  917. case $enable_warn in
  918. "no") #default
  919. CPPFLAGS="$CPPFLAGS $PROD_WARN"
  920. ;;
  921. "yes")
  922. CPPFLAGS="$CPPFLAGS"
  923. ;;
  924. "extra")
  925. CPPFLAGS="$CPPFLAGS $EXTRA_WARN"
  926. ;;
  927. esac
  928. #
  929. # Buildbot
  930. #
  931. case $enable_buildbot in
  932. "no")
  933. # default value
  934. ;;
  935. "yes")
  936. CPPFLAGS="$CPPFLAGS -DBUILDBOT"
  937. ;;
  938. esac
  939. #
  940. # RDTSC
  941. #
  942. case $enable_rdtsc in
  943. 0)
  944. #default value
  945. ;;
  946. 1)
  947. CPPFLAGS="$CPPFLAGS -DENABLE_RDTSC"
  948. ;;
  949. esac
  950. #
  951. # Profiler
  952. #
  953. case $enable_profiler in
  954. "no")
  955. # default value
  956. ;;
  957. "gprof")
  958. CFLAGS="$CFLAGS -pg"
  959. LDFLAGS="$LDFLAGS -pg"
  960. ;;
  961. esac
  962. #
  963. # zlib library (required)
  964. #
  965. if test -n "${ZLIB_HOME}" ; then
  966. LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
  967. CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
  968. fi
  969. AC_SEARCH_LIBS([inflateEnd], [z], [],[AC_MSG_ERROR([zlib library not found or incompatible, please specify the correct path with --with-zlib=DIR... stopping])])
  970. AC_CHECK_HEADER([zlib.h], [], [AC_MSG_ERROR([zlib header not found, please specify the correct path with --with-zlib=DIR... stopping])],
  971. [AC_LANG_SOURCE([#ifdef HAVE_ZLIB_H
  972. # include <zlib.h>
  973. #endif
  974. ])])
  975. #
  976. # math library (required)
  977. #
  978. AC_SEARCH_LIBS([sqrt], [m], [], [AC_MSG_ERROR([math library not found... stopping])])
  979. #
  980. # clock_gettime (optional, rt on Debian)
  981. #
  982. AC_SEARCH_LIBS([clock_gettime], [rt])
  983. #
  984. # CLOCK_MONOTONIC clock for clock_gettime
  985. # Normally defines _POSIX_TIMERS > 0 and _POSIX_MONOTONIC_CLOCK (for posix
  986. # compliant systems) and __FreeBSD_cc_version >= 500005 (for FreeBSD
  987. # >= 5.1.0, which does not have the posix defines (ref. r11983)) would be
  988. # checked but some systems define them even when they do not support it
  989. # (ref. bugreport:1003).
  990. #
  991. if test "$ac_cv_search_clock_gettime" != "no" ; then
  992. AC_MSG_CHECKING([whether CLOCK_MONOTONIC is supported and works])
  993. AC_RUN_IFELSE(
  994. [AC_LANG_SOURCE([
  995. #include <sys/time.h>
  996. #include <time.h>
  997. #include <unistd.h>
  998. int main(int argc, char** argv)
  999. {
  1000. struct timespec tval;
  1001. return clock_gettime(CLOCK_MONOTONIC, &tval);
  1002. }
  1003. ])],
  1004. [
  1005. AC_MSG_RESULT([yes])
  1006. CPPFLAGS="$CPPFLAGS -DHAVE_MONOTONIC_CLOCK"
  1007. ],
  1008. [
  1009. # either it failed to compile (CLOCK_MONOTONIC undefined)
  1010. # or clock_gettime has returned a non-zero value
  1011. AC_MSG_RESULT([no])
  1012. ],
  1013. [
  1014. AC_MSG_RESULT([guessing no])
  1015. ]
  1016. )
  1017. fi
  1018. #
  1019. # pthread
  1020. #
  1021. AC_SEARCH_LIBS([pthread_create], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  1022. AC_SEARCH_LIBS([pthread_sigmask], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  1023. AC_SEARCH_LIBS([pthread_attr_init], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  1024. AC_SEARCH_LIBS([pthread_attr_setstacksize], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  1025. AC_SEARCH_LIBS([pthread_attr_destroy], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  1026. AC_SEARCH_LIBS([pthread_cancel], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  1027. AC_SEARCH_LIBS([pthread_join], [pthread], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  1028. #
  1029. # MySQL library
  1030. #
  1031. if test -z "$MYSQL_CONFIG_HOME"; then
  1032. AC_PATH_PROG([MYSQL_CONFIG_HOME], [mysql_config], [no])
  1033. fi
  1034. if test "$MYSQL_CONFIG_HOME" != "no" ; then
  1035. MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`"
  1036. if test "$manual_MYSQL_CFLAGS" = "no" ; then
  1037. MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --include`"
  1038. fi
  1039. if test "$manual_MYSQL_LIBS" = "no" ; then
  1040. MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`"
  1041. fi
  1042. else
  1043. MYSQL_VERSION="unknown"
  1044. fi
  1045. MYSQL_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS $MYSQL_LIBS"
  1046. MYSQL_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS"
  1047. AC_CHECK_LIB([mysqlclient], [mysql_init], [HAVE_MYSQL="yes"], [])
  1048. AC_CHECK_HEADER([mysql.h], [], [HAVE_MYSQL=""])
  1049. CPPFLAGS="$MYSQL_OLD_CPPFLAGS"
  1050. LDFLAGS="$MYSQL_OLD_LDFLAGS"
  1051. AC_MSG_CHECKING([MySQL library (required)])
  1052. if test "$HAVE_MYSQL" = "yes" ; then
  1053. AC_MSG_RESULT([yes ($MYSQL_VERSION)])
  1054. else
  1055. AC_MSG_RESULT([no])
  1056. AC_MSG_ERROR([MySQL not found or incompatible])
  1057. fi
  1058. AC_SUBST([HAVE_MYSQL])
  1059. AC_SUBST([MYSQL_VERSION])
  1060. AC_SUBST([MYSQL_CFLAGS])
  1061. AC_SUBST([MYSQL_LIBS])
  1062. #
  1063. # PCRE library (optional)
  1064. #
  1065. PCRE_LIBS=""
  1066. PCRE_CFLAGS=""
  1067. if test "$want_pcre" = "no" ; then
  1068. AC_MSG_NOTICE([ignoring PCRE (optional)])
  1069. else
  1070. host_os="`uname`"
  1071. if test "$host_os" = "FreeBSD" ; then
  1072. if test -z "$PCRE_HOME" ; then PCRE_HOME="/usr/local"; fi
  1073. fi
  1074. if test -z "$PCRE_HOME" ; then
  1075. AC_SEARCH_LIBS([pcre_study], [pcre], [HAVE_PCRE="yes"], [])
  1076. if test "$HAVE_PCRE" = "yes" ; then
  1077. PCRE_LIBS="-lpcre"
  1078. fi
  1079. else
  1080. PCRE_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS -L$PCRE_HOME/lib"
  1081. PCRE_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS -I$PCRE_HOME/include"
  1082. AC_CHECK_LIB(pcre, pcre_compile, [HAVE_PCRE="yes"], [])
  1083. CPPFLAGS="$PCRE_OLD_CPPFLAGS"
  1084. LDFLAGS="$PCRE_OLD_LDFLAGS"
  1085. if test "$HAVE_PCRE" = "yes" ; then
  1086. PCRE_LIBS="-L$PCRE_HOME/lib -lpcre"
  1087. test -d "$PCRE_HOME/include" && PCRE_CFLAGS="-I$PCRE_HOME/include"
  1088. fi
  1089. fi
  1090. AC_MSG_CHECKING([PCRE library (optional)])
  1091. if test "$HAVE_PCRE" = "yes" ; then
  1092. PCRE_VERSION="`pcre-config --version`"
  1093. AC_MSG_RESULT([yes ($PCRE_VERSION)])
  1094. else
  1095. AC_MSG_RESULT([no])
  1096. if test "$require_pcre" = "yes" ; then
  1097. AC_MSG_ERROR([PCRE not found or incompatible (requested)])
  1098. else
  1099. AC_MSG_NOTICE([disabling PCRE (optional)])
  1100. fi
  1101. fi
  1102. fi
  1103. AC_SUBST([HAVE_PCRE])
  1104. AC_SUBST([PCRE_VERSION])
  1105. AC_SUBST([PCRE_LIBS])
  1106. AC_SUBST([PCRE_CFLAGS])
  1107. #
  1108. # Host specific stuff
  1109. #
  1110. AC_MSG_CHECKING([host OS])
  1111. host_os="`uname`"
  1112. AC_MSG_RESULT([$host_os])
  1113. fd_setsize=""
  1114. DLLEXT=".so"
  1115. case $host_os in
  1116. Solaris* )
  1117. LIBS="$LIBS -lsocket -lnsl -ldl"
  1118. ;;
  1119. Linux* )
  1120. LIBS="$LIBS -ldl"
  1121. ;;
  1122. FreeBSD*)
  1123. CPPFLAGS="$CPPFLAGS -D__FREEBSD__"
  1124. ;;
  1125. NetBSD*)
  1126. CPPFLAGS="$CPPFLAGS -D__NETBSD__"
  1127. ;;
  1128. CYGWIN*)
  1129. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096 -DCYGWIN"
  1130. fd_setsize="done"
  1131. DLLEXT=".dll"
  1132. ;;
  1133. esac
  1134. AC_SUBST([DLLEXT])
  1135. AC_MSG_CHECKING([for MinGW])
  1136. if test -n "`$CC --version | grep -i mingw`" ; then
  1137. AC_MSG_RESULT([yes])
  1138. CPPFLAGS="$CPPFLAGS -DMINGW"
  1139. if test -z "$fd_setsize" ; then
  1140. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096"
  1141. fi
  1142. LIBS="$LIBS -lws2_32"
  1143. else
  1144. AC_MSG_RESULT([no])
  1145. fi
  1146. CFLAGS="$OPT_LTO $CFLAGS"
  1147. CFLAGS_AR="$OPT_LTO_AR $CFLAGS"
  1148. AC_SUBST([CFLAGS_AR])
  1149. AC_MSG_NOTICE([Configure finish])
  1150. AC_MSG_NOTICE([CPPFLAGS= $CPPFLAGS])
  1151. AC_MSG_NOTICE([CFLAGS= $CFLAGS])
  1152. AC_MSG_NOTICE([CFLAGS_AR= $CFLAGS_AR])
  1153. AC_MSG_NOTICE([LDFLAGS= $LDFLAGS])
  1154. #AC_MSG_NOTICE([PROD_WARN= $PROD_WARN])
  1155. #AC_MSG_NOTICE([EXTRA_WARN= $EXTRA_WARN])
  1156. AC_MSG_NOTICE([output name = $output_login, $output_char, $output_map])
  1157. ###############################################################################
  1158. AC_OUTPUT