configure.in 17 KB

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