configure.in 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818
  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/plugins/Makefile src/tool/Makefile])
  11. AC_GNU_SOURCE
  12. #
  13. # Memory managers
  14. #
  15. AC_ARG_ENABLE(
  16. [manager],
  17. AC_HELP_STRING(
  18. [--enable-manager=ARG],
  19. [memory managers: no, builtin, memwatch, dmalloc, gcollect, bcheck (defaults to builtin)]
  20. ),
  21. [
  22. enable_manager="$enableval"
  23. case $enableval in
  24. "no");;
  25. "builtin");;
  26. "memwatch");;
  27. "dmalloc");;
  28. "gcollect");;
  29. "bcheck");;
  30. *) AC_MSG_ERROR([[unknown memory manager '$enableval'... stopping]]);;
  31. esac
  32. ],
  33. [enable_manager="builtin"]
  34. )
  35. #
  36. # packetver
  37. #
  38. AC_ARG_ENABLE(
  39. [packetver],
  40. AC_HELP_STRING(
  41. [--enable-packetver=ARG],
  42. [Sets the PACKETVER define of the map-server. (see src/map/clif.h)]
  43. ),
  44. [enable_packetver="$enableval"],
  45. [enable_packetver=""]
  46. )
  47. #
  48. # debug
  49. #
  50. AC_ARG_ENABLE(
  51. [debug],
  52. AC_HELP_STRING(
  53. [--enable-debug@<:@=ARG@:>@],
  54. [
  55. Compiles extra debug code. (disabled by default)
  56. (available options: yes, no, gdb)
  57. ]
  58. ),
  59. [
  60. enable_debug="$enableval"
  61. case $enableval in
  62. "no");;
  63. "yes");;
  64. "gdb");;
  65. *) AC_MSG_ERROR([[invalid argument --enable-debug=$enableval... stopping]]);;
  66. esac
  67. ],
  68. [enable_debug="no"]
  69. )
  70. #
  71. # Buildbot
  72. #
  73. AC_ARG_ENABLE(
  74. [buildbot],
  75. AC_HELP_STRING(
  76. [--enable-buildbot@<:@=ARG@:>@],
  77. [(available options: yes, no)]
  78. ),
  79. [
  80. enable_buildbot="$enableval"
  81. case $enableval in
  82. "no");;
  83. "yes");;
  84. *) AC_MSG_ERROR([[invalid argument --enable-buildbot=$enableval... stopping]]);;
  85. esac
  86. ],
  87. [enable_buildbot="no"]
  88. )
  89. #
  90. # RDTSC as Tick Source
  91. #
  92. AC_ARG_ENABLE(
  93. [rdtsc],
  94. AC_HELP_STRING(
  95. [--enable-rdtsc],
  96. [
  97. Uses rdtsc as timing source (disabled by default)
  98. Enable it when you've timing issues.
  99. (For example: in conjunction with XEN or Other Virtualization mechanisms)
  100. Note:
  101. Please ensure that you've disabled dynamic CPU-Frequencys, such as power saving options.
  102. (On the most modern Dedicated Servers cpufreq is preconfigured, see your distribution's manual
  103. how to disable it)
  104. ]
  105. ),
  106. [
  107. enable_rdtsc=1
  108. ],
  109. [enable_rdtsc=0]
  110. )
  111. #
  112. # Profiler
  113. #
  114. AC_ARG_ENABLE(
  115. [profiler],
  116. AC_HELP_STRING(
  117. [--enable-profiler=ARG],
  118. [Profilers: no, gprof (disabled by default)]
  119. ),
  120. [
  121. enable_profiler="$enableval"
  122. case $enableval in
  123. "no");;
  124. "gprof");;
  125. *) AC_MSG_ERROR([[invalid argument --enable-profiler=$enableval... stopping]]);;
  126. esac
  127. ],
  128. [enable_profiler="no"]
  129. )
  130. #
  131. # 64bit
  132. #
  133. AC_ARG_ENABLE(
  134. [64bit],
  135. AC_HELP_STRING(
  136. [--enable-64bit],
  137. [
  138. Don't force 32 bit. (disabled by default)
  139. 64bit support is still being tested, not recommended for production servers.
  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="no"]
  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_LANG([C])
  271. CFLAGS="$CFLAGS -pipe -ffast-math -Wall -Wno-sign-compare"
  272. CPPFLAGS="$CPPFLAGS -I../common"
  273. AC_C_BIGENDIAN(
  274. [AC_MSG_ERROR([[bigendian is not supported... stopping]])],
  275. ,
  276. [AC_MSG_WARN([[unable to determine endianess, only little endian is supported]])]
  277. )
  278. if test "$enable_64bit" = "no" ; then
  279. AC_MSG_CHECKING([whether pointers can be stored in ints (old code)])
  280. pointers_fit_in_ints="no"
  281. AC_COMPILE_IFELSE(
  282. [AC_LANG_PROGRAM([[static int test_array[((long int)sizeof(int)) == ((long int)sizeof(void*)) ? 1 : -1];]])],
  283. [pointers_fit_in_ints="yes"],
  284. []
  285. )
  286. if test "$pointers_fit_in_ints" = "no" ; then
  287. CFLAGS="$CFLAGS -m32"
  288. LDFLAGS="$LDFLAGS -m32"
  289. AC_COMPILE_IFELSE(
  290. [AC_LANG_PROGRAM([[static int test_array[((long int)sizeof(int)) == ((long int)sizeof(void *)) ? 1 : -1];]])],
  291. [pointers_fit_in_ints="yes (with -m32)"],
  292. []
  293. )
  294. fi
  295. AC_MSG_RESULT($pointers_fit_in_ints)
  296. if test "$pointers_fit_in_ints" = "no" ; then
  297. AC_MSG_ERROR([pointers cannot be stored in ints, required for old code... stopping])
  298. fi
  299. fi
  300. AC_MSG_CHECKING([whether $CC supports -Wno-unused-parameter])
  301. OLD_CFLAGS="$CFLAGS"
  302. CFLAGS="$CFLAGS -Wno-unused-parameter"
  303. AC_COMPILE_IFELSE(
  304. [int foo;],
  305. [AC_MSG_RESULT([yes])],
  306. [
  307. AC_MSG_RESULT([no])
  308. CFLAGS="$OLD_CFLAGS"
  309. ]
  310. )
  311. #
  312. # LTO Support test
  313. #
  314. if test "$enable_lto" != "no" ; then
  315. OLD_CFLAGS="$CFLAGS"
  316. CFLAGS="$CFLAGS -flto"
  317. OLD_LDFLAGS="$LDFLAGS"
  318. LDFLAGS="$LDFLAGS -flto"
  319. AC_MSG_CHECKING([whether $CC supports -flto])
  320. AC_RUN_IFELSE(
  321. [
  322. int main(int argc, char **argv){
  323. return 0;
  324. }
  325. ],
  326. [
  327. AC_MSG_RESULT([yes])
  328. ],
  329. [
  330. AC_MSG_RESULT([no])
  331. CFLAGS="$OLD_CFLAGS"
  332. LDFLAGS="$OLD_LDFLAGS"
  333. ],
  334. [
  335. AC_MSG_RESULT([guessing no])
  336. ]
  337. )
  338. fi
  339. AC_MSG_CHECKING([whether $CC supports -Wno-pointer-sign])
  340. OLD_CFLAGS="$CFLAGS"
  341. CFLAGS="$CFLAGS -Wno-pointer-sign"
  342. AC_COMPILE_IFELSE(
  343. [int foo;],
  344. [
  345. AC_MSG_RESULT([yes])
  346. AC_MSG_CHECKING([whether $CC can actually use -Wno-pointer-sign])
  347. # This option causes warnings in C++ mode
  348. # Note: -Werror must be before -Wno-pointer-sign, otherwise it does not do anything
  349. CFLAGS="$OLD_CFLAGS -Werror -Wno-pointer-sign"
  350. AC_COMPILE_IFELSE(
  351. [int foo;],
  352. [
  353. AC_MSG_RESULT([yes])
  354. CFLAGS="$OLD_CFLAGS -Wno-pointer-sign"
  355. ],
  356. [
  357. AC_MSG_RESULT([no])
  358. CFLAGS="$OLD_CFLAGS"
  359. ]
  360. )
  361. ],
  362. [
  363. AC_MSG_RESULT([no])
  364. CFLAGS="$OLD_CFLAGS"
  365. ]
  366. )
  367. AC_MSG_CHECKING([whether $CC supports -Wno-switch])
  368. OLD_CFLAGS="$CFLAGS"
  369. CFLAGS="$CFLAGS -Wno-switch"
  370. AC_COMPILE_IFELSE(
  371. [int foo;],
  372. [AC_MSG_RESULT([yes])],
  373. [
  374. AC_MSG_RESULT([no])
  375. CFLAGS="$OLD_CFLAGS"
  376. ]
  377. )
  378. AC_MSG_CHECKING([whether $CC supports -fPIC])
  379. OLD_CFLAGS="$CFLAGS"
  380. CFLAGS="$CFLAGS -fPIC"
  381. AC_COMPILE_IFELSE(
  382. [int foo;],
  383. [
  384. AC_MSG_RESULT([yes])
  385. compiler_supports_pic="yes"
  386. ],
  387. [
  388. AC_MSG_RESULT([no])
  389. compiler_supports_pic="no"
  390. ]
  391. )
  392. CFLAGS="$OLD_CFLAGS"
  393. #
  394. # -shared needs position independent code; some platforms emit it
  395. # always, others need -fPIC
  396. #
  397. AC_MSG_CHECKING([whether $CC needs -fPIC for shared objects])
  398. OLD_CFLAGS="$CFLAGS"
  399. CFLAGS="$CFLAGS -shared"
  400. WITH_PLUGINS="yes"
  401. AC_LINK_IFELSE(
  402. [
  403. int foo(void)
  404. {
  405. return 0;
  406. }
  407. ],
  408. [
  409. AC_MSG_RESULT([no])
  410. CFLAGS="$OLD_CFLAGS"
  411. ],
  412. [
  413. if test "$compiler_supports_pic" = "yes" ; then
  414. # Verify if -shared really fails due to lack of -fPIC or something else
  415. CFLAGS="$CFLAGS -fPIC"
  416. AC_LINK_IFELSE(
  417. [
  418. int foo(void)
  419. {
  420. return 0;
  421. }
  422. ],
  423. [
  424. AC_MSG_RESULT([yes])
  425. CFLAGS="$OLD_CFLAGS -fPIC"
  426. ],
  427. [
  428. AC_MSG_RESULT([no, but fails for another reason])
  429. AC_MSG_ERROR([compiler is unable to compile shared objects for an unhandled reason, please report this with attached config.log... stopping])
  430. ]
  431. )
  432. else
  433. # Disable compilation of plugins (optional), so 'make all' does not fail
  434. AC_MSG_RESULT([yes, but unsupported])
  435. AC_MSG_NOTICE([compiler is unable to generate position independent code, disabled plugins (optional)])
  436. WITH_PLUGINS="no"
  437. fi
  438. ]
  439. )
  440. AC_SUBST([WITH_PLUGINS])
  441. #
  442. # -O2 implies -fstrict-aliasing, but the code is not safe for that
  443. #
  444. AC_MSG_CHECKING([whether $CC supports -fno-strict-aliasing])
  445. OLD_CFLAGS="$CFLAGS"
  446. CFLAGS="$CFLAGS -fno-strict-aliasing"
  447. AC_COMPILE_IFELSE(
  448. [int foo;],
  449. [AC_MSG_RESULT([yes])],
  450. [
  451. AC_MSG_RESULT([no])
  452. CFLAGS="$OLD_CFLAGS"
  453. ]
  454. )
  455. ###############################################################################
  456. # Check for libraries and header files.
  457. #
  458. #
  459. # setrlimit - used to set the socket limit
  460. #
  461. AC_CHECK_FUNC([setrlimit],[CFLAGS="$CFLAGS -DHAVE_SETRLIMIT"])
  462. #
  463. # strnlen - string length with upper scan bound
  464. #
  465. AC_CHECK_FUNC([strnlen],[CFLAGS="$CFLAGS -DHAVE_STRNLEN"])
  466. # libconfig
  467. AC_CHECK_FUNCS([uselocale])
  468. AC_CHECK_FUNCS([newlocale])
  469. AC_CHECK_FUNCS([freelocale])
  470. AC_CHECK_HEADERS([xlocale.h])
  471. #
  472. # Memory manager
  473. #
  474. case $enable_manager in
  475. "no")
  476. CFLAGS="$CFLAGS -DNO_MEMMGR"
  477. ;;
  478. "builtin")
  479. # enabled by default
  480. ;;
  481. "memwatch")
  482. CFLAGS="$CFLAGS -DMEMWATCH"
  483. AC_CHECK_HEADER([memwatch.h], , [AC_MSG_ERROR([memwatch header not found... stopping])])
  484. ;;
  485. "dmalloc")
  486. CFLAGS="$CFLAGS -DDMALLOC -DDMALLOC_FUNC_CHECK"
  487. LIBS="$LIBS -ldmalloc"
  488. AC_CHECK_HEADER([dmalloc.h], , [AC_MSG_ERROR([dmalloc header not found... stopping])])
  489. ;;
  490. "gcollect")
  491. CFLAGS="$CFLAGS -DGCOLLECT"
  492. LIBS="$LIBS -lgc"
  493. AC_CHECK_HEADER([gc.h], , [AC_MSG_ERROR([gcollect header not found... stopping])])
  494. ;;
  495. "bcheck")
  496. CFLAGS="$CFLAGS -DBCHECK"
  497. ;;
  498. esac
  499. #
  500. # Packetver
  501. #
  502. if test -n "$enable_packetver" ; then
  503. CFLAGS="$CFLAGS -DPACKETVER=$enable_packetver"
  504. fi
  505. #
  506. # Debug
  507. #
  508. case $enable_debug in
  509. "no")
  510. # default value
  511. CFLAGS="$CFLAGS -Wno-unused -Wno-parentheses"
  512. ;;
  513. "yes")
  514. CFLAGS="$CFLAGS -g -DDEBUG"
  515. ;;
  516. "gdb")
  517. CFLAGS="$CFLAGS -ggdb -DDEBUG"
  518. ;;
  519. esac
  520. #
  521. # Buildbot
  522. #
  523. case $enable_buildbot in
  524. "no")
  525. # default value
  526. ;;
  527. "yes")
  528. CFLAGS="$CFLAGS -DBUILDBOT"
  529. ;;
  530. esac
  531. #
  532. # RDTSC
  533. #
  534. case $enable_rdtsc in
  535. 0)
  536. #default value
  537. ;;
  538. 1)
  539. CFLAGS="$CFLAGS -DENABLE_RDTSC"
  540. ;;
  541. esac
  542. #
  543. # Profiler
  544. #
  545. case $enable_profiler in
  546. "no")
  547. # default value
  548. ;;
  549. "gprof")
  550. CFLAGS="$CFLAGS -pg"
  551. LDFLAGS="$LDFLAGS -pg"
  552. ;;
  553. esac
  554. #
  555. # zlib library (required)
  556. #
  557. if test -n "${ZLIB_HOME}" ; then
  558. LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
  559. CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
  560. fi
  561. AC_CHECK_LIB([z], [inflateEnd], [],[AC_MSG_ERROR([zlib library not found or incompatible, please specify the correct path with --with-zlib=DIR... stopping])])
  562. AC_CHECK_HEADER([zlib.h], [], [AC_MSG_ERROR([zlib header not found, please specify the correct path with --with-zlib=DIR... stopping])])
  563. #
  564. # math library (required)
  565. #
  566. AC_SEARCH_LIBS([sqrt], [m], [], [AC_MSG_ERROR([math library not found... stopping])])
  567. #
  568. # clock_gettime (optional, rt on Debian)
  569. #
  570. AC_SEARCH_LIBS([clock_gettime], [rt])
  571. #
  572. # CLOCK_MONOTONIC clock for clock_gettime
  573. # Normally defines _POSIX_TIMERS > 0 and _POSIX_MONOTONIC_CLOCK (for posix
  574. # compliant systems) and __FreeBSD_cc_version >= 500005 (for FreeBSD
  575. # >= 5.1.0, which does not have the posix defines (ref. r11983)) would be
  576. # checked but some systems define them even when they do not support it
  577. # (ref. bugreport:1003).
  578. #
  579. if test "$ac_cv_search_clock_gettime" != "no" ; then
  580. AC_MSG_CHECKING([whether CLOCK_MONOTONIC is supported and works])
  581. AC_RUN_IFELSE(
  582. [
  583. #include <sys/time.h>
  584. #include <time.h>
  585. #include <unistd.h>
  586. int main(int argc, char** argv)
  587. {
  588. struct timespec tval;
  589. return clock_gettime(CLOCK_MONOTONIC, &tval);
  590. }
  591. ],
  592. [
  593. AC_MSG_RESULT([yes])
  594. CFLAGS="$CFLAGS -DHAVE_MONOTONIC_CLOCK"
  595. ],
  596. [
  597. # either it failed to compile (CLOCK_MONOTONIC undefined)
  598. # or clock_gettime has returned a non-zero value
  599. AC_MSG_RESULT([no])
  600. ],
  601. [
  602. AC_MSG_RESULT([guessing no])
  603. ]
  604. )
  605. fi
  606. #
  607. # MySQL library
  608. #
  609. if test -z "$MYSQL_CONFIG_HOME"; then
  610. AC_PATH_PROG([MYSQL_CONFIG_HOME], [mysql_config], [no])
  611. fi
  612. if test "$MYSQL_CONFIG_HOME" != "no" ; then
  613. MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`"
  614. if test "$manual_MYSQL_CFLAGS" = "no" ; then
  615. MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --include`"
  616. fi
  617. if test "$manual_MYSQL_LIBS" = "no" ; then
  618. MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`"
  619. fi
  620. else
  621. MYSQL_VERSION="unknown"
  622. fi
  623. MYSQL_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS $MYSQL_LIBS"
  624. MYSQL_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS"
  625. AC_CHECK_LIB([mysqlclient], [mysql_init], [HAVE_MYSQL="yes"], [])
  626. AC_CHECK_HEADER([mysql.h], [], [HAVE_MYSQL=""])
  627. CPPFLAGS="$MYSQL_OLD_CPPFLAGS"
  628. LDFLAGS="$MYSQL_OLD_LDFLAGS"
  629. AC_MSG_CHECKING([MySQL library (required)])
  630. if test "$HAVE_MYSQL" = "yes" ; then
  631. AC_MSG_RESULT([yes ($MYSQL_VERSION)])
  632. else
  633. AC_MSG_RESULT([no])
  634. AC_MSG_ERROR([MySQL not found or incompatible])
  635. fi
  636. AC_SUBST([HAVE_MYSQL])
  637. AC_SUBST([MYSQL_VERSION])
  638. AC_SUBST([MYSQL_CFLAGS])
  639. AC_SUBST([MYSQL_LIBS])
  640. #
  641. # PCRE library (optional)
  642. #
  643. ##TODO PCRE version
  644. PCRE_LIBS=""
  645. PCRE_CFLAGS=""
  646. if test "$want_pcre" = "no" ; then
  647. AC_MSG_NOTICE([ignoring PCRE (optional)])
  648. else
  649. if test -z "$PCRE_HOME" ; then
  650. AC_CHECK_LIB([pcre], [pcre_study], [HAVE_PCRE="yes"], [])
  651. if test "$HAVE_PCRE" = "yes" ; then
  652. PCRE_LIBS="-lpcre"
  653. fi
  654. else
  655. PCRE_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS -L$PCRE_HOME/lib"
  656. PCRE_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS -I$PCRE_HOME/include"
  657. AC_CHECK_LIB(pcre, pcre_compile, [HAVE_PCRE="yes"], [])
  658. CPPFLAGS="$PCRE_OLD_CPPFLAGS"
  659. LDFLAGS="$PCRE_OLD_LDFLAGS"
  660. if test "$HAVE_PCRE" = "yes" ; then
  661. PCRE_LIBS="-L$PCRE_HOME/lib -lpcre"
  662. test -d "$PCRE_HOME/include" && PCRE_CFLAGS="-I$PCRE_HOME/include"
  663. fi
  664. fi
  665. AC_MSG_CHECKING([PCRE library (optional)])
  666. if test "$HAVE_PCRE" = "yes" ; then
  667. AC_MSG_RESULT([yes])
  668. else
  669. AC_MSG_RESULT([no])
  670. if test "$require_pcre" = "yes" ; then
  671. AC_MSG_ERROR([PCRE not found or incompatible (requested)])
  672. else
  673. AC_MSG_NOTICE([disabling PCRE (optional)])
  674. fi
  675. fi
  676. fi
  677. AC_SUBST([HAVE_PCRE])
  678. AC_SUBST([PCRE_LIBS])
  679. AC_SUBST([PCRE_CFLAGS])
  680. #
  681. # Host specific stuff
  682. #
  683. AC_MSG_CHECKING([host OS])
  684. host_os="`uname`"
  685. AC_MSG_RESULT([$host_os])
  686. fd_setsize=""
  687. DLLEXT=".so"
  688. case $host_os in
  689. Solaris* )
  690. LIBS="$LIBS -lsocket -lnsl -ldl"
  691. ;;
  692. Linux* )
  693. LIBS="$LIBS -ldl"
  694. ;;
  695. FreeBSD*)
  696. CPPFLAGS="$CPPFLAGS -D__FREEBSD__"
  697. ;;
  698. NetBSD*)
  699. CPPFLAGS="$CPPFLAGS -D__NETBSD__"
  700. ;;
  701. CYGWIN*)
  702. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096 -DCYGWIN"
  703. fd_setsize="done"
  704. DLLEXT=".dll"
  705. ;;
  706. esac
  707. AC_SUBST([DLLEXT])
  708. AC_MSG_CHECKING([for MinGW])
  709. if test -n "`$CC --version | grep -i mingw`" ; then
  710. AC_MSG_RESULT([yes])
  711. CPPFLAGS="$CPPFLAGS -DMINGW"
  712. if test -z "$fd_setsize" ; then
  713. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096"
  714. fi
  715. LIBS="$LIBS -lws2_32"
  716. else
  717. AC_MSG_RESULT([no])
  718. fi
  719. ###############################################################################
  720. AC_OUTPUT