configure.in 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922
  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. # warn
  73. #
  74. AC_ARG_ENABLE(
  75. [warn],
  76. AC_HELP_STRING(
  77. [--enable-warn@<:@=ARG@:>@],
  78. [
  79. Compiles with warnings. (disabled by default)
  80. (available options: yes, no, extra)
  81. ]
  82. ),
  83. [
  84. enable_warn="$enableval"
  85. case $enableval in
  86. "no");;
  87. "yes");;
  88. "extra");;
  89. *) AC_MSG_ERROR([[invalid argument --enable-warn=$enableval... stopping]]);;
  90. esac
  91. ],
  92. [enable_warn="no"]
  93. )
  94. #
  95. # Buildbot
  96. #
  97. AC_ARG_ENABLE(
  98. [buildbot],
  99. AC_HELP_STRING(
  100. [--enable-buildbot@<:@=ARG@:>@],
  101. [(available options: yes, no)]
  102. ),
  103. [
  104. enable_buildbot="$enableval"
  105. case $enableval in
  106. "no");;
  107. "yes");;
  108. *) AC_MSG_ERROR([[invalid argument --enable-buildbot=$enableval... stopping]]);;
  109. esac
  110. ],
  111. [enable_buildbot="no"]
  112. )
  113. #
  114. # RDTSC as Tick Source
  115. #
  116. AC_ARG_ENABLE(
  117. [rdtsc],
  118. AC_HELP_STRING(
  119. [--enable-rdtsc],
  120. [
  121. Uses rdtsc as timing source (disabled by default)
  122. Enable it when you've timing issues.
  123. (For example: in conjunction with XEN or Other Virtualization mechanisms)
  124. Note:
  125. Please ensure that you've disabled dynamic CPU-Frequencys, such as power saving options.
  126. (On the most modern Dedicated Servers cpufreq is preconfigured, see your distribution's manual
  127. how to disable it)
  128. ]
  129. ),
  130. [
  131. enable_rdtsc=1
  132. ],
  133. [enable_rdtsc=0]
  134. )
  135. #
  136. # Profiler
  137. #
  138. AC_ARG_ENABLE(
  139. [profiler],
  140. AC_HELP_STRING(
  141. [--enable-profiler=ARG],
  142. [Profilers: no, gprof (disabled by default)]
  143. ),
  144. [
  145. enable_profiler="$enableval"
  146. case $enableval in
  147. "no");;
  148. "gprof");;
  149. *) AC_MSG_ERROR([[invalid argument --enable-profiler=$enableval... stopping]]);;
  150. esac
  151. ],
  152. [enable_profiler="no"]
  153. )
  154. #
  155. # 64bit
  156. #
  157. AC_ARG_ENABLE(
  158. [64bit],
  159. AC_HELP_STRING(
  160. [--disable-64bit],
  161. [
  162. Enforce 32bit output on x86_64 systems.
  163. ]
  164. ),
  165. [
  166. enable_64bit="$enableval"
  167. case $enableval in
  168. "no");;
  169. "yes");;
  170. *) AC_MSG_ERROR([[invalid argument --enable-64bit=$enableval... stopping]]);;
  171. esac
  172. ],
  173. [enable_64bit="yes"]
  174. )
  175. #
  176. # LTO
  177. #
  178. AC_ARG_ENABLE(
  179. [lto],
  180. AC_HELP_STRING(
  181. [--enable-lto],
  182. [
  183. Enables or Disables Linktime Code Optimization (LTO is enabled by default)
  184. ]
  185. ),
  186. [
  187. enable_lto="$enableval"
  188. case $enableval in
  189. "no");;
  190. "yes");;
  191. *) AC_MSG_ERROR([[invalid argument --enable-lto=$disableval... stopping]]);;
  192. esac
  193. ],
  194. [enable_lto="yes"]
  195. )
  196. #
  197. # Optionally set the max number of network conenctions
  198. # the core will be support
  199. #
  200. AC_ARG_WITH(
  201. [maxconn],
  202. AC_HELP_STRING(
  203. [--with-maxconn@<:@=ARG@:>@],
  204. [optionally set the maximum connections the core can handle (default: 16384) NOT USED YET - EXPERIMENTAL]
  205. ),
  206. [
  207. if test "$withval" == "no"; then
  208. CFLAGS="$CFLAGS -DMAXCONN=16384"
  209. else
  210. if ! test "$withval" -ge 0 -o "$withval" -lt 0 2>&- ; then
  211. AC_MSG_ERROR([Invalid argument --with-maxconn=$withval ... stopping])
  212. else
  213. CFLAGS="$CFLAGS -DMAXCONN=$withval"
  214. fi
  215. fi
  216. ],
  217. [
  218. CFLAGS="$CFLAGS -DMAXCONN=16384"
  219. ]
  220. )
  221. #
  222. # Optionally specify the path to mysql_config
  223. #
  224. AC_ARG_WITH(
  225. [mysql],
  226. AC_HELP_STRING(
  227. [--with-mysql@<:@=ARG@:>@],
  228. [optionally specify the path to the mysql_config executable]
  229. ),
  230. [
  231. if test "$withval" != "no" ; then
  232. if test ! -x "$withval" ; then
  233. AC_MSG_ERROR([$withval is not an executable file])
  234. fi
  235. MYSQL_CONFIG_HOME="$withval"
  236. fi
  237. ]
  238. )
  239. #
  240. # Manual MYSQL_CFLAGS (optional)
  241. #
  242. AC_ARG_WITH(
  243. [MYSQL_CFLAGS],
  244. AC_HELP_STRING(
  245. [--with-MYSQL_CFLAGS=ARG],
  246. [specify MYSQL_CFLAGS manually (instead of using "mysql_config --include")]
  247. ),
  248. [
  249. manual_MYSQL_CFLAGS="yes"
  250. MYSQL_CFLAGS="$withval"
  251. ],
  252. [manual_MYSQL_CFLAGS="no"]
  253. )
  254. #
  255. # Manual MYSQL_LIBS (optional)
  256. #
  257. AC_ARG_WITH(
  258. [MYSQL_LIBS],
  259. AC_HELP_STRING(
  260. [--with-MYSQL_LIBS=ARG],
  261. [specify MYSQL_LIBS manually (instead of using "mysql_config --libs")]
  262. ),
  263. [
  264. manual_MYSQL_LIBS="yes"
  265. MYSQL_LIBS="$withval"
  266. ],
  267. [manual_MYSQL_LIBS="no"]
  268. )
  269. #
  270. # Enable/disable PCRE and optionally specify the path (optional library)
  271. #
  272. AC_ARG_WITH(
  273. [pcre],
  274. AC_HELP_STRING(
  275. [--with-pcre@<:@=ARG@:>@],
  276. [use PCRE library, optionally specify the full path of pcre installation directory (by default pcre is used if found)]
  277. ),
  278. [
  279. if test "$withval" = "no" ; then
  280. want_pcre="no"
  281. else
  282. want_pcre="yes"
  283. require_pcre="yes"
  284. if test "$withval" != "yes" ; then
  285. if test ! -d "$withval" ; then
  286. AC_MSG_ERROR([$withval is not a directoy])
  287. fi
  288. PCRE_HOME="$withval"
  289. fi
  290. fi
  291. ],
  292. [want_pcre="yes" require_pcre="no"]
  293. )
  294. #
  295. # Specify the path of the zlib library (required library)
  296. #
  297. AC_ARG_WITH(
  298. [zlib],
  299. AC_HELP_STRING(
  300. [--with-zlib=DIR],
  301. [root directory path of zlib installation (defaults to /usr/local or /usr if not found in /usr/local).
  302. Assumes that the header files are in DIR/include and the library files are in DIR/lib]
  303. ),
  304. [
  305. test -n "$withval" && ZLIB_HOME="$withval"
  306. ],
  307. [
  308. ZLIB_HOME=/usr/local
  309. test ! -f "${ZLIB_HOME}/include/zlib.h" && ZLIB_HOME=/usr
  310. ]
  311. )
  312. ###############################################################################
  313. # Check for programs and types.
  314. #
  315. AC_PROG_MAKE_SET
  316. AC_PROG_CC
  317. AC_PROG_CPP
  318. AC_PATH_PROG(AR, ar)
  319. AC_LANG([C])
  320. CFLAGS="$CFLAGS -pipe -ffast-math -Wall"
  321. CPPFLAGS="$CPPFLAGS -I../common"
  322. AC_C_BIGENDIAN(
  323. [AC_MSG_ERROR([[bigendian is not supported... stopping]])],
  324. ,
  325. [AC_MSG_WARN([[unable to determine endianess, only little endian is supported]])]
  326. )
  327. if test "$enable_64bit" = "no" ; then
  328. AC_MSG_CHECKING([whether pointers can be stored in ints (old code)])
  329. pointers_fit_in_ints="no"
  330. AC_COMPILE_IFELSE(
  331. [AC_LANG_PROGRAM([[static int test_array[((long int)sizeof(int)) == ((long int)sizeof(void*)) ? 1 : -1];]])],
  332. [pointers_fit_in_ints="yes"],
  333. []
  334. )
  335. if test "$pointers_fit_in_ints" = "no" ; then
  336. CFLAGS="$CFLAGS -m32"
  337. LDFLAGS="$LDFLAGS -m32"
  338. AC_COMPILE_IFELSE(
  339. [AC_LANG_PROGRAM([[static int test_array[((long int)sizeof(int)) == ((long int)sizeof(void *)) ? 1 : -1];]])],
  340. [pointers_fit_in_ints="yes (with -m32)"],
  341. []
  342. )
  343. fi
  344. AC_MSG_RESULT($pointers_fit_in_ints)
  345. if test "$pointers_fit_in_ints" = "no" ; then
  346. AC_MSG_ERROR([pointers cannot be stored in ints, required for old code... stopping])
  347. fi
  348. fi
  349. #
  350. # check if we're producing 32bit code - so well produce binarys for at least i686 (speedup: cmovs, and cmpchg8 support)
  351. #
  352. AC_MSG_CHECKING([whether $CC produces 32bit code])
  353. AC_RUN_IFELSE(
  354. [
  355. int main(int argc, char **argv){
  356. if(sizeof(void*) == 4) return 0;
  357. else return 1;
  358. }
  359. ],
  360. [
  361. AC_MSG_RESULT([yes])
  362. CFLAGS="$CFLAGS -march=i686"
  363. LDFLAGS="$LDFLAGS -march=i686"
  364. ],
  365. [
  366. AC_MSG_RESULT([no])
  367. ],
  368. [
  369. AC_MSG_RESULT([guessing no])
  370. ]
  371. )
  372. #
  373. # Check if CC supports __thread attribute (Thread Local Storage)
  374. # (Usually our OSX friends 're lacking support of it in older llvm versions ..)
  375. #
  376. AC_MSG_CHECKING([whether $CC supports __thread specifier (TLS)])
  377. AC_RUN_IFELSE(
  378. [
  379. __thread int g_Test = -1;
  380. int main(int argc, char **argv){
  381. g_Test = 0;
  382. return g_Test;
  383. }
  384. ],
  385. [
  386. AC_MSG_RESULT([yes])
  387. CFLAGS="$CFLAGS -DHAS_TLS"
  388. ],
  389. [
  390. AC_MSG_RESULT([no])
  391. ]
  392. )
  393. AC_MSG_CHECKING([whether $CC supports -Wno-unused-parameter])
  394. OLD_CFLAGS="$CFLAGS"
  395. CFLAGS="$CFLAGS -Wno-unused-parameter"
  396. AC_COMPILE_IFELSE(
  397. [int foo;],
  398. [AC_MSG_RESULT([no])],
  399. [
  400. AC_MSG_RESULT([yes])
  401. PROD_WARN="$PROD_WARN -Wno-unused-parameter"
  402. ]
  403. )
  404. CFLAGS="$OLD_CFLAGS"
  405. #
  406. # LTO Support test
  407. #
  408. if test "$enable_lto" != "no" ; then
  409. OLD_CFLAGS="$CFLAGS"
  410. CFLAGS="$CFLAGS -flto"
  411. OLD_LDFLAGS="$LDFLAGS"
  412. LDFLAGS="$LDFLAGS -flto"
  413. AC_MSG_CHECKING([whether $CC supports -flto])
  414. AC_RUN_IFELSE(
  415. [
  416. int main(int argc, char **argv){
  417. return 0;
  418. }
  419. ],
  420. [
  421. AC_MSG_RESULT([yes])
  422. ],
  423. [
  424. AC_MSG_RESULT([no])
  425. CFLAGS="$OLD_CFLAGS"
  426. LDFLAGS="$OLD_LDFLAGS"
  427. ],
  428. [
  429. AC_MSG_RESULT([guessing no])
  430. ]
  431. )
  432. fi
  433. AC_MSG_CHECKING([whether $CC supports -Wno-pointer-sign])
  434. OLD_CFLAGS="$CFLAGS"
  435. CFLAGS="$CFLAGS -Wno-pointer-sign"
  436. AC_COMPILE_IFELSE(
  437. [int foo;],
  438. [
  439. AC_MSG_RESULT([yes])
  440. AC_MSG_CHECKING([whether $CC can actually use -Wno-pointer-sign])
  441. # This option causes warnings in C++ mode
  442. # Note: -Werror must be before -Wno-pointer-sign, otherwise it does not do anything
  443. CFLAGS="$OLD_CFLAGS -Werror -Wno-pointer-sign"
  444. AC_COMPILE_IFELSE(
  445. [int foo;],
  446. [
  447. AC_MSG_RESULT([yes])
  448. PROD_WARN="$PROD_WARN -Wno-pointer-sign"
  449. ],
  450. [
  451. AC_MSG_RESULT([no])
  452. ]
  453. )
  454. ],
  455. [
  456. AC_MSG_RESULT([no])
  457. ]
  458. )
  459. CFLAGS="$OLD_CFLAGS"
  460. AC_MSG_CHECKING([whether $CC supports -Wno-switch])
  461. OLD_CFLAGS="$CFLAGS"
  462. CFLAGS="$CFLAGS -Wno-switch"
  463. AC_COMPILE_IFELSE(
  464. [int foo;],
  465. [ AC_MSG_RESULT([yes])
  466. ],
  467. [
  468. AC_MSG_RESULT([no])
  469. CFLAGS="$OLD_CFLAGS"
  470. ]
  471. )
  472. AC_MSG_CHECKING([whether $CC supports -fPIC])
  473. OLD_CFLAGS="$CFLAGS"
  474. CFLAGS="$CFLAGS -fPIC"
  475. AC_COMPILE_IFELSE(
  476. [int foo;],
  477. [
  478. AC_MSG_RESULT([yes])
  479. compiler_supports_pic="yes"
  480. ],
  481. [
  482. AC_MSG_RESULT([no])
  483. compiler_supports_pic="no"
  484. ]
  485. )
  486. CFLAGS="$OLD_CFLAGS"
  487. #
  488. # -O2 implies -fstrict-aliasing, but the code is not safe for that
  489. #
  490. AC_MSG_CHECKING([whether $CC supports -fno-strict-aliasing])
  491. OLD_CFLAGS="$CFLAGS"
  492. CFLAGS="$CFLAGS -fno-strict-aliasing"
  493. AC_COMPILE_IFELSE(
  494. [int foo;],
  495. [AC_MSG_RESULT([yes])],
  496. [
  497. AC_MSG_RESULT([no])
  498. CFLAGS="$OLD_CFLAGS"
  499. ]
  500. )
  501. #
  502. # check if support conversion check
  503. #
  504. AC_MSG_CHECKING([whether $CC supports -Wconversion])
  505. OLD_CFLAGS="$CFLAGS"
  506. CFLAGS="$CFLAGS -Wconversion"
  507. AC_COMPILE_IFELSE(
  508. [int foo;],
  509. [
  510. AC_MSG_RESULT([yes])
  511. EXTRA_WARN="-Wconversion"
  512. ],
  513. [AC_MSG_RESULT([no])]
  514. )
  515. CFLAGS="$OLD_CFLAGS"
  516. ###############################################################################
  517. # Check for libraries and header files.
  518. #
  519. #
  520. # setrlimit - used to set the socket limit
  521. #
  522. AC_CHECK_FUNC([setrlimit],[CFLAGS="$CFLAGS -DHAVE_SETRLIMIT"])
  523. #
  524. # strnlen - string length with upper scan bound
  525. #
  526. AC_CHECK_FUNC([strnlen],[CFLAGS="$CFLAGS -DHAVE_STRNLEN"])
  527. # libconfig
  528. AC_CHECK_FUNCS([uselocale])
  529. AC_CHECK_FUNCS([newlocale])
  530. AC_CHECK_FUNCS([freelocale])
  531. AC_CHECK_HEADERS([xlocale.h])
  532. #
  533. # Memory manager
  534. #
  535. case $enable_manager in
  536. "no")
  537. CFLAGS="$CFLAGS -DNO_MEMMGR"
  538. ;;
  539. "builtin")
  540. # enabled by default
  541. ;;
  542. "memwatch")
  543. CFLAGS="$CFLAGS -DMEMWATCH"
  544. AC_CHECK_HEADER([memwatch.h], , [AC_MSG_ERROR([memwatch header not found... stopping])])
  545. ;;
  546. "dmalloc")
  547. CFLAGS="$CFLAGS -DDMALLOC -DDMALLOC_FUNC_CHECK"
  548. LIBS="$LIBS -ldmalloc"
  549. AC_CHECK_HEADER([dmalloc.h], , [AC_MSG_ERROR([dmalloc header not found... stopping])])
  550. ;;
  551. "gcollect")
  552. CFLAGS="$CFLAGS -DGCOLLECT"
  553. LIBS="$LIBS -lgc"
  554. AC_CHECK_HEADER([gc.h], , [AC_MSG_ERROR([gcollect header not found... stopping])])
  555. ;;
  556. "bcheck")
  557. CFLAGS="$CFLAGS -DBCHECK"
  558. ;;
  559. esac
  560. #
  561. # Packetver
  562. #
  563. if test -n "$enable_packetver" ; then
  564. CFLAGS="$CFLAGS -DPACKETVER=$enable_packetver"
  565. fi
  566. #
  567. # Debug
  568. #
  569. case $enable_debug in
  570. "no")
  571. # default value
  572. CFLAGS="$CFLAGS"
  573. ;;
  574. "yes")
  575. CFLAGS="$CFLAGS -g -DDEBUG"
  576. ;;
  577. "gdb")
  578. CFLAGS="$CFLAGS -ggdb -DDEBUG"
  579. ;;
  580. esac
  581. #
  582. # Warnings
  583. #
  584. case $enable_warn in
  585. "no") #default
  586. CFLAGS="$CFLAGS $PROD_WARN"
  587. ;;
  588. "yes")
  589. CFLAGS="$CFLAGS"
  590. ;;
  591. "extra")
  592. CFLAGS="$CFLAGS $EXTRA_WARN"
  593. ;;
  594. esac
  595. #
  596. # Buildbot
  597. #
  598. case $enable_buildbot in
  599. "no")
  600. # default value
  601. ;;
  602. "yes")
  603. CFLAGS="$CFLAGS -DBUILDBOT"
  604. ;;
  605. esac
  606. #
  607. # RDTSC
  608. #
  609. case $enable_rdtsc in
  610. 0)
  611. #default value
  612. ;;
  613. 1)
  614. CFLAGS="$CFLAGS -DENABLE_RDTSC"
  615. ;;
  616. esac
  617. #
  618. # Profiler
  619. #
  620. case $enable_profiler in
  621. "no")
  622. # default value
  623. ;;
  624. "gprof")
  625. CFLAGS="$CFLAGS -pg"
  626. LDFLAGS="$LDFLAGS -pg"
  627. ;;
  628. esac
  629. #
  630. # zlib library (required)
  631. #
  632. if test -n "${ZLIB_HOME}" ; then
  633. LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
  634. CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
  635. fi
  636. AC_CHECK_LIB([z], [inflateEnd], [],[AC_MSG_ERROR([zlib library not found or incompatible, please specify the correct path with --with-zlib=DIR... stopping])])
  637. AC_CHECK_HEADER([zlib.h], [], [AC_MSG_ERROR([zlib header not found, please specify the correct path with --with-zlib=DIR... stopping])])
  638. #
  639. # math library (required)
  640. #
  641. AC_SEARCH_LIBS([sqrt], [m], [], [AC_MSG_ERROR([math library not found... stopping])])
  642. #
  643. # clock_gettime (optional, rt on Debian)
  644. #
  645. AC_SEARCH_LIBS([clock_gettime], [rt])
  646. #
  647. # CLOCK_MONOTONIC clock for clock_gettime
  648. # Normally defines _POSIX_TIMERS > 0 and _POSIX_MONOTONIC_CLOCK (for posix
  649. # compliant systems) and __FreeBSD_cc_version >= 500005 (for FreeBSD
  650. # >= 5.1.0, which does not have the posix defines (ref. r11983)) would be
  651. # checked but some systems define them even when they do not support it
  652. # (ref. bugreport:1003).
  653. #
  654. if test "$ac_cv_search_clock_gettime" != "no" ; then
  655. AC_MSG_CHECKING([whether CLOCK_MONOTONIC is supported and works])
  656. AC_RUN_IFELSE(
  657. [
  658. #include <sys/time.h>
  659. #include <time.h>
  660. #include <unistd.h>
  661. int main(int argc, char** argv)
  662. {
  663. struct timespec tval;
  664. return clock_gettime(CLOCK_MONOTONIC, &tval);
  665. }
  666. ],
  667. [
  668. AC_MSG_RESULT([yes])
  669. CFLAGS="$CFLAGS -DHAVE_MONOTONIC_CLOCK"
  670. ],
  671. [
  672. # either it failed to compile (CLOCK_MONOTONIC undefined)
  673. # or clock_gettime has returned a non-zero value
  674. AC_MSG_RESULT([no])
  675. ],
  676. [
  677. AC_MSG_RESULT([guessing no])
  678. ]
  679. )
  680. fi
  681. #
  682. # pthread
  683. #
  684. AC_CHECK_LIB([pthread], [pthread_create], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  685. AC_CHECK_LIB([pthread], [pthread_sigmask], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  686. AC_CHECK_LIB([pthread], [pthread_attr_init], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  687. AC_CHECK_LIB([pthread], [pthread_attr_setstacksize], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  688. AC_CHECK_LIB([pthread], [pthread_attr_destroy], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  689. AC_CHECK_LIB([pthread], [pthread_cancel], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  690. AC_CHECK_LIB([pthread], [pthread_join], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  691. LDFLAGS="$LDFLAGS -lpthread"
  692. #
  693. # MySQL library
  694. #
  695. if test -z "$MYSQL_CONFIG_HOME"; then
  696. AC_PATH_PROG([MYSQL_CONFIG_HOME], [mysql_config], [no])
  697. fi
  698. if test "$MYSQL_CONFIG_HOME" != "no" ; then
  699. MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`"
  700. if test "$manual_MYSQL_CFLAGS" = "no" ; then
  701. MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --include`"
  702. fi
  703. if test "$manual_MYSQL_LIBS" = "no" ; then
  704. MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`"
  705. fi
  706. else
  707. MYSQL_VERSION="unknown"
  708. fi
  709. MYSQL_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS $MYSQL_LIBS"
  710. MYSQL_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS"
  711. AC_CHECK_LIB([mysqlclient], [mysql_init], [HAVE_MYSQL="yes"], [])
  712. AC_CHECK_HEADER([mysql.h], [], [HAVE_MYSQL=""])
  713. CPPFLAGS="$MYSQL_OLD_CPPFLAGS"
  714. LDFLAGS="$MYSQL_OLD_LDFLAGS"
  715. AC_MSG_CHECKING([MySQL library (required)])
  716. if test "$HAVE_MYSQL" = "yes" ; then
  717. AC_MSG_RESULT([yes ($MYSQL_VERSION)])
  718. else
  719. AC_MSG_RESULT([no])
  720. AC_MSG_ERROR([MySQL not found or incompatible])
  721. fi
  722. AC_SUBST([HAVE_MYSQL])
  723. AC_SUBST([MYSQL_VERSION])
  724. AC_SUBST([MYSQL_CFLAGS])
  725. AC_SUBST([MYSQL_LIBS])
  726. #
  727. # PCRE library (optional)
  728. #
  729. PCRE_LIBS=""
  730. PCRE_CFLAGS=""
  731. if test "$want_pcre" = "no" ; then
  732. AC_MSG_NOTICE([ignoring PCRE (optional)])
  733. else
  734. host_os="`uname`"
  735. if test "$host_os" = "FreeBSD" ; then
  736. if test -z "$PCRE_HOME" ; then PCRE_HOME="/usr/local"; fi
  737. fi
  738. if test -z "$PCRE_HOME" ; then
  739. AC_SEARCH_LIBS([pcre_study], [pcre], [HAVE_PCRE="yes"], [])
  740. if test "$HAVE_PCRE" = "yes" ; then
  741. PCRE_LIBS="-lpcre"
  742. fi
  743. else
  744. PCRE_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS -L$PCRE_HOME/lib"
  745. PCRE_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS -I$PCRE_HOME/include"
  746. AC_CHECK_LIB(pcre, pcre_compile, [HAVE_PCRE="yes"], [])
  747. CPPFLAGS="$PCRE_OLD_CPPFLAGS"
  748. LDFLAGS="$PCRE_OLD_LDFLAGS"
  749. if test "$HAVE_PCRE" = "yes" ; then
  750. PCRE_LIBS="-L$PCRE_HOME/lib -lpcre"
  751. test -d "$PCRE_HOME/include" && PCRE_CFLAGS="-I$PCRE_HOME/include"
  752. fi
  753. fi
  754. AC_MSG_CHECKING([PCRE library (optional)])
  755. if test "$HAVE_PCRE" = "yes" ; then
  756. PCRE_VERSION="`pcre-config --version`"
  757. AC_MSG_RESULT([yes ($PCRE_VERSION)])
  758. else
  759. AC_MSG_RESULT([no])
  760. if test "$require_pcre" = "yes" ; then
  761. AC_MSG_ERROR([PCRE not found or incompatible (requested)])
  762. else
  763. AC_MSG_NOTICE([disabling PCRE (optional)])
  764. fi
  765. fi
  766. fi
  767. AC_SUBST([HAVE_PCRE])
  768. AC_SUBST([PCRE_VERSION])
  769. AC_SUBST([PCRE_LIBS])
  770. AC_SUBST([PCRE_CFLAGS])
  771. #
  772. # Host specific stuff
  773. #
  774. AC_MSG_CHECKING([host OS])
  775. host_os="`uname`"
  776. AC_MSG_RESULT([$host_os])
  777. fd_setsize=""
  778. DLLEXT=".so"
  779. case $host_os in
  780. Solaris* )
  781. LIBS="$LIBS -lsocket -lnsl -ldl"
  782. ;;
  783. Linux* )
  784. LIBS="$LIBS -ldl"
  785. ;;
  786. FreeBSD*)
  787. CPPFLAGS="$CPPFLAGS -D__FREEBSD__"
  788. ;;
  789. NetBSD*)
  790. CPPFLAGS="$CPPFLAGS -D__NETBSD__"
  791. ;;
  792. CYGWIN*)
  793. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096 -DCYGWIN"
  794. fd_setsize="done"
  795. DLLEXT=".dll"
  796. ;;
  797. esac
  798. AC_SUBST([DLLEXT])
  799. AC_MSG_CHECKING([for MinGW])
  800. if test -n "`$CC --version | grep -i mingw`" ; then
  801. AC_MSG_RESULT([yes])
  802. CPPFLAGS="$CPPFLAGS -DMINGW"
  803. if test -z "$fd_setsize" ; then
  804. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096"
  805. fi
  806. LIBS="$LIBS -lws2_32"
  807. else
  808. AC_MSG_RESULT([no])
  809. fi
  810. #AC_MSG_NOTICE([PROD_WARN= $PROD_WARN])
  811. #AC_MSG_NOTICE([EXTRA_WARN= $EXTRA_WARN])
  812. AC_MSG_NOTICE([Configure finish, CFLAG= $CFLAGS])
  813. ###############################################################################
  814. AC_OUTPUT