configure.in 17 KB

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