configure.in 20 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000
  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 of the map-server. (see src/map/clif.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. CFLAGS="$CFLAGS -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. CFLAGS="$CFLAGS -DMAXCONN=$withval"
  236. fi
  237. fi
  238. ],
  239. [
  240. CFLAGS="$CFLAGS -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. [
  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. CFLAGS="$CFLAGS -march=i686"
  418. LDFLAGS="$LDFLAGS -march=i686"
  419. ],
  420. [
  421. AC_MSG_RESULT([no])
  422. ],
  423. [
  424. AC_MSG_RESULT([guessing no])
  425. ]
  426. )
  427. #
  428. # Check if CC supports __thread attribute (Thread Local Storage)
  429. # (Usually our OSX friends 're lacking support of it in older llvm versions ..)
  430. #
  431. AC_MSG_CHECKING([whether $CC supports __thread specifier (TLS)])
  432. AC_RUN_IFELSE(
  433. [
  434. __thread int g_Test = -1;
  435. int main(int argc, char **argv){
  436. g_Test = 0;
  437. return g_Test;
  438. }
  439. ],
  440. [
  441. AC_MSG_RESULT([yes])
  442. CFLAGS="$CFLAGS -DHAS_TLS"
  443. ],
  444. [
  445. AC_MSG_RESULT([no])
  446. ]
  447. )
  448. AC_MSG_CHECKING([whether $CC supports -Wno-unused-parameter])
  449. OLD_CFLAGS="$CFLAGS"
  450. CFLAGS="$CFLAGS -Wno-unused-parameter"
  451. AC_COMPILE_IFELSE(
  452. [int foo;],
  453. [AC_MSG_RESULT([no])],
  454. [
  455. AC_MSG_RESULT([yes])
  456. PROD_WARN="$PROD_WARN -Wno-unused-parameter"
  457. ]
  458. )
  459. CFLAGS="$OLD_CFLAGS"
  460. #
  461. # LTO Support test
  462. #
  463. if test "$enable_lto" != "no" ; then
  464. OLD_CFLAGS="$CFLAGS"
  465. CFLAGS="$CFLAGS -flto"
  466. OLD_LDFLAGS="$LDFLAGS"
  467. LDFLAGS="$LDFLAGS -flto"
  468. AC_MSG_CHECKING([whether $CC supports -flto])
  469. AC_RUN_IFELSE(
  470. [
  471. int main(int argc, char **argv){
  472. return 0;
  473. }
  474. ],
  475. [
  476. AC_MSG_RESULT([yes])
  477. ],
  478. [
  479. AC_MSG_RESULT([no])
  480. CFLAGS="$OLD_CFLAGS"
  481. LDFLAGS="$OLD_LDFLAGS"
  482. ],
  483. [
  484. AC_MSG_RESULT([guessing no])
  485. ]
  486. )
  487. fi
  488. AC_MSG_CHECKING([whether $CC supports -Wno-pointer-sign])
  489. OLD_CFLAGS="$CFLAGS"
  490. CFLAGS="$CFLAGS -Wno-pointer-sign"
  491. AC_COMPILE_IFELSE(
  492. [int foo;],
  493. [
  494. AC_MSG_RESULT([yes])
  495. AC_MSG_CHECKING([whether $CC can actually use -Wno-pointer-sign])
  496. # This option causes warnings in C++ mode
  497. # Note: -Werror must be before -Wno-pointer-sign, otherwise it does not do anything
  498. CFLAGS="$OLD_CFLAGS -Werror -Wno-pointer-sign"
  499. AC_COMPILE_IFELSE(
  500. [int foo;],
  501. [
  502. AC_MSG_RESULT([yes])
  503. PROD_WARN="$PROD_WARN -Wno-pointer-sign"
  504. ],
  505. [
  506. AC_MSG_RESULT([no])
  507. ]
  508. )
  509. ],
  510. [
  511. AC_MSG_RESULT([no])
  512. ]
  513. )
  514. CFLAGS="$OLD_CFLAGS"
  515. AC_MSG_CHECKING([whether $CC supports -Wno-switch])
  516. OLD_CFLAGS="$CFLAGS"
  517. CFLAGS="$CFLAGS -Wno-switch"
  518. AC_COMPILE_IFELSE(
  519. [int foo;],
  520. [ AC_MSG_RESULT([yes])
  521. ],
  522. [
  523. AC_MSG_RESULT([no])
  524. CFLAGS="$OLD_CFLAGS"
  525. ]
  526. )
  527. AC_MSG_CHECKING([whether $CC supports -fPIC])
  528. OLD_CFLAGS="$CFLAGS"
  529. CFLAGS="$CFLAGS -fPIC"
  530. AC_COMPILE_IFELSE(
  531. [int foo;],
  532. [
  533. AC_MSG_RESULT([yes])
  534. compiler_supports_pic="yes"
  535. ],
  536. [
  537. AC_MSG_RESULT([no])
  538. compiler_supports_pic="no"
  539. ]
  540. )
  541. CFLAGS="$OLD_CFLAGS"
  542. #
  543. # -O2 implies -fstrict-aliasing, but the code is not safe for that
  544. #
  545. AC_MSG_CHECKING([whether $CC supports -fno-strict-aliasing])
  546. OLD_CFLAGS="$CFLAGS"
  547. CFLAGS="$CFLAGS -fno-strict-aliasing"
  548. AC_COMPILE_IFELSE(
  549. [int foo;],
  550. [AC_MSG_RESULT([yes])],
  551. [
  552. AC_MSG_RESULT([no])
  553. CFLAGS="$OLD_CFLAGS"
  554. ]
  555. )
  556. #
  557. # check if support conversion check
  558. #
  559. AC_MSG_CHECKING([whether $CC supports -Wconversion])
  560. OLD_CFLAGS="$CFLAGS"
  561. CFLAGS="$CFLAGS -Wconversion"
  562. AC_COMPILE_IFELSE(
  563. [int foo;],
  564. [
  565. AC_MSG_RESULT([yes])
  566. EXTRA_WARN="-Wconversion"
  567. ],
  568. [AC_MSG_RESULT([no])]
  569. )
  570. CFLAGS="$OLD_CFLAGS"
  571. ###############################################################################
  572. # Check for libraries and header files.
  573. #
  574. #
  575. # setrlimit - used to set the socket limit
  576. #
  577. AC_CHECK_FUNC([setrlimit],[CFLAGS="$CFLAGS -DHAVE_SETRLIMIT"])
  578. #
  579. # strnlen - string length with upper scan bound
  580. #
  581. AC_CHECK_FUNC([strnlen],[CFLAGS="$CFLAGS -DHAVE_STRNLEN"])
  582. # libconfig
  583. AC_CHECK_FUNCS([uselocale])
  584. AC_CHECK_FUNCS([newlocale])
  585. AC_CHECK_FUNCS([freelocale])
  586. AC_CHECK_HEADERS([xlocale.h])
  587. #
  588. # Memory manager
  589. #
  590. case $enable_manager in
  591. "no")
  592. CFLAGS="$CFLAGS -DNO_MEMMGR"
  593. ;;
  594. "builtin")
  595. # enabled by default
  596. ;;
  597. "memwatch")
  598. CFLAGS="$CFLAGS -DMEMWATCH"
  599. AC_CHECK_HEADER([memwatch.h], , [AC_MSG_ERROR([memwatch header not found... stopping])])
  600. ;;
  601. "dmalloc")
  602. CFLAGS="$CFLAGS -DDMALLOC -DDMALLOC_FUNC_CHECK"
  603. LIBS="$LIBS -ldmalloc"
  604. AC_CHECK_HEADER([dmalloc.h], , [AC_MSG_ERROR([dmalloc header not found... stopping])])
  605. ;;
  606. "gcollect")
  607. CFLAGS="$CFLAGS -DGCOLLECT"
  608. LIBS="$LIBS -lgc"
  609. AC_CHECK_HEADER([gc.h], , [AC_MSG_ERROR([gcollect header not found... stopping])])
  610. ;;
  611. "bcheck")
  612. CFLAGS="$CFLAGS -DBCHECK"
  613. ;;
  614. esac
  615. #
  616. # Packetver
  617. #
  618. if test -n "$enable_packetver" ; then
  619. CFLAGS="$CFLAGS -DPACKETVER=$enable_packetver"
  620. fi
  621. #
  622. # Debug
  623. #
  624. case $enable_debug in
  625. "no")
  626. # default value
  627. CFLAGS="$CFLAGS"
  628. ;;
  629. "yes")
  630. CFLAGS="$CFLAGS -g -DDEBUG"
  631. LDFLAGS="$LDFLAGS -g"
  632. ;;
  633. "gdb")
  634. CFLAGS="$CFLAGS -ggdb -DDEBUG"
  635. LDFLAGS="$LDFLAGS -g"
  636. ;;
  637. esac
  638. #
  639. # Renewal
  640. #
  641. case $enable_prere in
  642. "no")
  643. # default value
  644. CFLAGS="$CFLAGS"
  645. ;;
  646. "yes")
  647. CFLAGS="$CFLAGS -DPRERE"
  648. ;;
  649. esac
  650. #
  651. # Warnings
  652. #
  653. case $enable_warn in
  654. "no") #default
  655. CFLAGS="$CFLAGS $PROD_WARN"
  656. ;;
  657. "yes")
  658. CFLAGS="$CFLAGS"
  659. ;;
  660. "extra")
  661. CFLAGS="$CFLAGS $EXTRA_WARN"
  662. ;;
  663. esac
  664. #
  665. # Buildbot
  666. #
  667. case $enable_buildbot in
  668. "no")
  669. # default value
  670. ;;
  671. "yes")
  672. CFLAGS="$CFLAGS -DBUILDBOT"
  673. ;;
  674. esac
  675. #
  676. # RDTSC
  677. #
  678. case $enable_rdtsc in
  679. 0)
  680. #default value
  681. ;;
  682. 1)
  683. CFLAGS="$CFLAGS -DENABLE_RDTSC"
  684. ;;
  685. esac
  686. #
  687. # Profiler
  688. #
  689. case $enable_profiler in
  690. "no")
  691. # default value
  692. ;;
  693. "gprof")
  694. CFLAGS="$CFLAGS -pg"
  695. LDFLAGS="$LDFLAGS -pg"
  696. ;;
  697. esac
  698. #
  699. # zlib library (required)
  700. #
  701. if test -n "${ZLIB_HOME}" ; then
  702. LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
  703. CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
  704. fi
  705. AC_CHECK_LIB([z], [inflateEnd], [],[AC_MSG_ERROR([zlib library not found or incompatible, please specify the correct path with --with-zlib=DIR... stopping])])
  706. AC_CHECK_HEADER([zlib.h], [], [AC_MSG_ERROR([zlib header not found, please specify the correct path with --with-zlib=DIR... stopping])])
  707. #
  708. # math library (required)
  709. #
  710. AC_SEARCH_LIBS([sqrt], [m], [], [AC_MSG_ERROR([math library not found... stopping])])
  711. #
  712. # clock_gettime (optional, rt on Debian)
  713. #
  714. AC_SEARCH_LIBS([clock_gettime], [rt])
  715. #
  716. # CLOCK_MONOTONIC clock for clock_gettime
  717. # Normally defines _POSIX_TIMERS > 0 and _POSIX_MONOTONIC_CLOCK (for posix
  718. # compliant systems) and __FreeBSD_cc_version >= 500005 (for FreeBSD
  719. # >= 5.1.0, which does not have the posix defines (ref. r11983)) would be
  720. # checked but some systems define them even when they do not support it
  721. # (ref. bugreport:1003).
  722. #
  723. if test "$ac_cv_search_clock_gettime" != "no" ; then
  724. AC_MSG_CHECKING([whether CLOCK_MONOTONIC is supported and works])
  725. AC_RUN_IFELSE(
  726. [
  727. #include <sys/time.h>
  728. #include <time.h>
  729. #include <unistd.h>
  730. int main(int argc, char** argv)
  731. {
  732. struct timespec tval;
  733. return clock_gettime(CLOCK_MONOTONIC, &tval);
  734. }
  735. ],
  736. [
  737. AC_MSG_RESULT([yes])
  738. CFLAGS="$CFLAGS -DHAVE_MONOTONIC_CLOCK"
  739. ],
  740. [
  741. # either it failed to compile (CLOCK_MONOTONIC undefined)
  742. # or clock_gettime has returned a non-zero value
  743. AC_MSG_RESULT([no])
  744. ],
  745. [
  746. AC_MSG_RESULT([guessing no])
  747. ]
  748. )
  749. fi
  750. #
  751. # pthread
  752. #
  753. AC_CHECK_LIB([pthread], [pthread_create], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  754. AC_CHECK_LIB([pthread], [pthread_sigmask], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  755. AC_CHECK_LIB([pthread], [pthread_attr_init], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  756. AC_CHECK_LIB([pthread], [pthread_attr_setstacksize], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  757. AC_CHECK_LIB([pthread], [pthread_attr_destroy], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  758. AC_CHECK_LIB([pthread], [pthread_cancel], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  759. AC_CHECK_LIB([pthread], [pthread_join], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  760. LDFLAGS="$LDFLAGS -lpthread"
  761. #
  762. # MySQL library
  763. #
  764. if test -z "$MYSQL_CONFIG_HOME"; then
  765. AC_PATH_PROG([MYSQL_CONFIG_HOME], [mysql_config], [no])
  766. fi
  767. if test "$MYSQL_CONFIG_HOME" != "no" ; then
  768. MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`"
  769. if test "$manual_MYSQL_CFLAGS" = "no" ; then
  770. MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --include`"
  771. fi
  772. if test "$manual_MYSQL_LIBS" = "no" ; then
  773. MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`"
  774. fi
  775. else
  776. MYSQL_VERSION="unknown"
  777. fi
  778. MYSQL_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS $MYSQL_LIBS"
  779. MYSQL_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS"
  780. AC_CHECK_LIB([mysqlclient], [mysql_init], [HAVE_MYSQL="yes"], [])
  781. AC_CHECK_HEADER([mysql.h], [], [HAVE_MYSQL=""])
  782. CPPFLAGS="$MYSQL_OLD_CPPFLAGS"
  783. LDFLAGS="$MYSQL_OLD_LDFLAGS"
  784. AC_MSG_CHECKING([MySQL library (required)])
  785. if test "$HAVE_MYSQL" = "yes" ; then
  786. AC_MSG_RESULT([yes ($MYSQL_VERSION)])
  787. else
  788. AC_MSG_RESULT([no])
  789. AC_MSG_ERROR([MySQL not found or incompatible])
  790. fi
  791. AC_SUBST([HAVE_MYSQL])
  792. AC_SUBST([MYSQL_VERSION])
  793. AC_SUBST([MYSQL_CFLAGS])
  794. AC_SUBST([MYSQL_LIBS])
  795. #
  796. # PCRE library (optional)
  797. #
  798. PCRE_LIBS=""
  799. PCRE_CFLAGS=""
  800. if test "$want_pcre" = "no" ; then
  801. AC_MSG_NOTICE([ignoring PCRE (optional)])
  802. else
  803. host_os="`uname`"
  804. if test "$host_os" = "FreeBSD" ; then
  805. if test -z "$PCRE_HOME" ; then PCRE_HOME="/usr/local"; fi
  806. fi
  807. if test -z "$PCRE_HOME" ; then
  808. AC_SEARCH_LIBS([pcre_study], [pcre], [HAVE_PCRE="yes"], [])
  809. if test "$HAVE_PCRE" = "yes" ; then
  810. PCRE_LIBS="-lpcre"
  811. fi
  812. else
  813. PCRE_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS -L$PCRE_HOME/lib"
  814. PCRE_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS -I$PCRE_HOME/include"
  815. AC_CHECK_LIB(pcre, pcre_compile, [HAVE_PCRE="yes"], [])
  816. CPPFLAGS="$PCRE_OLD_CPPFLAGS"
  817. LDFLAGS="$PCRE_OLD_LDFLAGS"
  818. if test "$HAVE_PCRE" = "yes" ; then
  819. PCRE_LIBS="-L$PCRE_HOME/lib -lpcre"
  820. test -d "$PCRE_HOME/include" && PCRE_CFLAGS="-I$PCRE_HOME/include"
  821. fi
  822. fi
  823. AC_MSG_CHECKING([PCRE library (optional)])
  824. if test "$HAVE_PCRE" = "yes" ; then
  825. PCRE_VERSION="`pcre-config --version`"
  826. AC_MSG_RESULT([yes ($PCRE_VERSION)])
  827. else
  828. AC_MSG_RESULT([no])
  829. if test "$require_pcre" = "yes" ; then
  830. AC_MSG_ERROR([PCRE not found or incompatible (requested)])
  831. else
  832. AC_MSG_NOTICE([disabling PCRE (optional)])
  833. fi
  834. fi
  835. fi
  836. AC_SUBST([HAVE_PCRE])
  837. AC_SUBST([PCRE_VERSION])
  838. AC_SUBST([PCRE_LIBS])
  839. AC_SUBST([PCRE_CFLAGS])
  840. #
  841. # Host specific stuff
  842. #
  843. AC_MSG_CHECKING([host OS])
  844. host_os="`uname`"
  845. AC_MSG_RESULT([$host_os])
  846. fd_setsize=""
  847. DLLEXT=".so"
  848. case $host_os in
  849. Solaris* )
  850. LIBS="$LIBS -lsocket -lnsl -ldl"
  851. ;;
  852. Linux* )
  853. LIBS="$LIBS -ldl"
  854. ;;
  855. FreeBSD*)
  856. CPPFLAGS="$CPPFLAGS -D__FREEBSD__"
  857. ;;
  858. NetBSD*)
  859. CPPFLAGS="$CPPFLAGS -D__NETBSD__"
  860. ;;
  861. CYGWIN*)
  862. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096 -DCYGWIN"
  863. fd_setsize="done"
  864. DLLEXT=".dll"
  865. ;;
  866. esac
  867. AC_SUBST([DLLEXT])
  868. AC_MSG_CHECKING([for MinGW])
  869. if test -n "`$CC --version | grep -i mingw`" ; then
  870. AC_MSG_RESULT([yes])
  871. CPPFLAGS="$CPPFLAGS -DMINGW"
  872. if test -z "$fd_setsize" ; then
  873. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096"
  874. fi
  875. LIBS="$LIBS -lws2_32"
  876. else
  877. AC_MSG_RESULT([no])
  878. fi
  879. AC_MSG_NOTICE([Configure finish, CFLAGS= $CFLAGS])
  880. AC_MSG_NOTICE([LDFLAGS=$LDFLAGS])
  881. #AC_MSG_NOTICE([PROD_WARN= $PROD_WARN])
  882. #AC_MSG_NOTICE([EXTRA_WARN= $EXTRA_WARN])
  883. AC_MSG_NOTICE([output name = $output_login, $output_char, $output_map])
  884. ###############################################################################
  885. AC_OUTPUT