configure.in 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808
  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. AC_MSG_CHECKING([whether $CC supports -Wno-unused-parameter])
  325. OLD_CFLAGS="$CFLAGS"
  326. CFLAGS="$CFLAGS -Wno-unused-parameter"
  327. AC_COMPILE_IFELSE(
  328. [int foo;],
  329. [AC_MSG_RESULT([yes])],
  330. [
  331. AC_MSG_RESULT([no])
  332. CFLAGS="$OLD_CFLAGS"
  333. ]
  334. )
  335. #
  336. # LTO Support test
  337. #
  338. if test "$enable_lto" != "no" ; then
  339. OLD_CFLAGS="$CFLAGS"
  340. CFLAGS="$CFLAGS -flto"
  341. OLD_LDFLAGS="$LDFLAGS"
  342. LDFLAGS="$LDFLAGS -flto"
  343. AC_MSG_CHECKING([whether $CC supports -flto])
  344. AC_RUN_IFELSE(
  345. [
  346. int main(int argc, char **argv){
  347. return 0;
  348. }
  349. ],
  350. [
  351. AC_MSG_RESULT([yes])
  352. ],
  353. [
  354. AC_MSG_RESULT([no])
  355. CFLAGS="$OLD_CFLAGS"
  356. LDFLAGS="$OLD_LDFLAGS"
  357. ],
  358. [
  359. AC_MSG_RESULT([guessing no])
  360. ]
  361. )
  362. fi
  363. AC_MSG_CHECKING([whether $CC supports -Wno-pointer-sign])
  364. OLD_CFLAGS="$CFLAGS"
  365. CFLAGS="$CFLAGS -Wno-pointer-sign"
  366. AC_COMPILE_IFELSE(
  367. [int foo;],
  368. [
  369. AC_MSG_RESULT([yes])
  370. AC_MSG_CHECKING([whether $CC can actually use -Wno-pointer-sign])
  371. # This option causes warnings in C++ mode
  372. # Note: -Werror must be before -Wno-pointer-sign, otherwise it does not do anything
  373. CFLAGS="$OLD_CFLAGS -Werror -Wno-pointer-sign"
  374. AC_COMPILE_IFELSE(
  375. [int foo;],
  376. [
  377. AC_MSG_RESULT([yes])
  378. CFLAGS="$OLD_CFLAGS -Wno-pointer-sign"
  379. ],
  380. [
  381. AC_MSG_RESULT([no])
  382. CFLAGS="$OLD_CFLAGS"
  383. ]
  384. )
  385. ],
  386. [
  387. AC_MSG_RESULT([no])
  388. CFLAGS="$OLD_CFLAGS"
  389. ]
  390. )
  391. AC_MSG_CHECKING([whether $CC supports -Wno-switch])
  392. OLD_CFLAGS="$CFLAGS"
  393. CFLAGS="$CFLAGS -Wno-switch"
  394. AC_COMPILE_IFELSE(
  395. [int foo;],
  396. [AC_MSG_RESULT([yes])],
  397. [
  398. AC_MSG_RESULT([no])
  399. CFLAGS="$OLD_CFLAGS"
  400. ]
  401. )
  402. AC_MSG_CHECKING([whether $CC supports -fPIC])
  403. OLD_CFLAGS="$CFLAGS"
  404. CFLAGS="$CFLAGS -fPIC"
  405. AC_COMPILE_IFELSE(
  406. [int foo;],
  407. [
  408. AC_MSG_RESULT([yes])
  409. compiler_supports_pic="yes"
  410. ],
  411. [
  412. AC_MSG_RESULT([no])
  413. compiler_supports_pic="no"
  414. ]
  415. )
  416. CFLAGS="$OLD_CFLAGS"
  417. #
  418. # -O2 implies -fstrict-aliasing, but the code is not safe for that
  419. #
  420. AC_MSG_CHECKING([whether $CC supports -fno-strict-aliasing])
  421. OLD_CFLAGS="$CFLAGS"
  422. CFLAGS="$CFLAGS -fno-strict-aliasing"
  423. AC_COMPILE_IFELSE(
  424. [int foo;],
  425. [AC_MSG_RESULT([yes])],
  426. [
  427. AC_MSG_RESULT([no])
  428. CFLAGS="$OLD_CFLAGS"
  429. ]
  430. )
  431. ###############################################################################
  432. # Check for libraries and header files.
  433. #
  434. #
  435. # setrlimit - used to set the socket limit
  436. #
  437. AC_CHECK_FUNC([setrlimit],[CFLAGS="$CFLAGS -DHAVE_SETRLIMIT"])
  438. #
  439. # strnlen - string length with upper scan bound
  440. #
  441. AC_CHECK_FUNC([strnlen],[CFLAGS="$CFLAGS -DHAVE_STRNLEN"])
  442. # libconfig
  443. AC_CHECK_FUNCS([uselocale])
  444. AC_CHECK_FUNCS([newlocale])
  445. AC_CHECK_FUNCS([freelocale])
  446. AC_CHECK_HEADERS([xlocale.h])
  447. #
  448. # Memory manager
  449. #
  450. case $enable_manager in
  451. "no")
  452. CFLAGS="$CFLAGS -DNO_MEMMGR"
  453. ;;
  454. "builtin")
  455. # enabled by default
  456. ;;
  457. "memwatch")
  458. CFLAGS="$CFLAGS -DMEMWATCH"
  459. AC_CHECK_HEADER([memwatch.h], , [AC_MSG_ERROR([memwatch header not found... stopping])])
  460. ;;
  461. "dmalloc")
  462. CFLAGS="$CFLAGS -DDMALLOC -DDMALLOC_FUNC_CHECK"
  463. LIBS="$LIBS -ldmalloc"
  464. AC_CHECK_HEADER([dmalloc.h], , [AC_MSG_ERROR([dmalloc header not found... stopping])])
  465. ;;
  466. "gcollect")
  467. CFLAGS="$CFLAGS -DGCOLLECT"
  468. LIBS="$LIBS -lgc"
  469. AC_CHECK_HEADER([gc.h], , [AC_MSG_ERROR([gcollect header not found... stopping])])
  470. ;;
  471. "bcheck")
  472. CFLAGS="$CFLAGS -DBCHECK"
  473. ;;
  474. esac
  475. #
  476. # Packetver
  477. #
  478. if test -n "$enable_packetver" ; then
  479. CFLAGS="$CFLAGS -DPACKETVER=$enable_packetver"
  480. fi
  481. #
  482. # Debug
  483. #
  484. case $enable_debug in
  485. "no")
  486. # default value
  487. CFLAGS="$CFLAGS -Wno-unused -Wno-parentheses"
  488. ;;
  489. "yes")
  490. CFLAGS="$CFLAGS -g -DDEBUG"
  491. ;;
  492. "gdb")
  493. CFLAGS="$CFLAGS -ggdb -DDEBUG"
  494. ;;
  495. esac
  496. #
  497. # Buildbot
  498. #
  499. case $enable_buildbot in
  500. "no")
  501. # default value
  502. ;;
  503. "yes")
  504. CFLAGS="$CFLAGS -DBUILDBOT"
  505. ;;
  506. esac
  507. #
  508. # RDTSC
  509. #
  510. case $enable_rdtsc in
  511. 0)
  512. #default value
  513. ;;
  514. 1)
  515. CFLAGS="$CFLAGS -DENABLE_RDTSC"
  516. ;;
  517. esac
  518. #
  519. # Profiler
  520. #
  521. case $enable_profiler in
  522. "no")
  523. # default value
  524. ;;
  525. "gprof")
  526. CFLAGS="$CFLAGS -pg"
  527. LDFLAGS="$LDFLAGS -pg"
  528. ;;
  529. esac
  530. #
  531. # zlib library (required)
  532. #
  533. if test -n "${ZLIB_HOME}" ; then
  534. LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
  535. CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
  536. fi
  537. AC_CHECK_LIB([z], [inflateEnd], [],[AC_MSG_ERROR([zlib library not found or incompatible, please specify the correct path with --with-zlib=DIR... stopping])])
  538. AC_CHECK_HEADER([zlib.h], [], [AC_MSG_ERROR([zlib header not found, please specify the correct path with --with-zlib=DIR... stopping])])
  539. #
  540. # math library (required)
  541. #
  542. AC_SEARCH_LIBS([sqrt], [m], [], [AC_MSG_ERROR([math library not found... stopping])])
  543. #
  544. # clock_gettime (optional, rt on Debian)
  545. #
  546. AC_SEARCH_LIBS([clock_gettime], [rt])
  547. #
  548. # CLOCK_MONOTONIC clock for clock_gettime
  549. # Normally defines _POSIX_TIMERS > 0 and _POSIX_MONOTONIC_CLOCK (for posix
  550. # compliant systems) and __FreeBSD_cc_version >= 500005 (for FreeBSD
  551. # >= 5.1.0, which does not have the posix defines (ref. r11983)) would be
  552. # checked but some systems define them even when they do not support it
  553. # (ref. bugreport:1003).
  554. #
  555. if test "$ac_cv_search_clock_gettime" != "no" ; then
  556. AC_MSG_CHECKING([whether CLOCK_MONOTONIC is supported and works])
  557. AC_RUN_IFELSE(
  558. [
  559. #include <sys/time.h>
  560. #include <time.h>
  561. #include <unistd.h>
  562. int main(int argc, char** argv)
  563. {
  564. struct timespec tval;
  565. return clock_gettime(CLOCK_MONOTONIC, &tval);
  566. }
  567. ],
  568. [
  569. AC_MSG_RESULT([yes])
  570. CFLAGS="$CFLAGS -DHAVE_MONOTONIC_CLOCK"
  571. ],
  572. [
  573. # either it failed to compile (CLOCK_MONOTONIC undefined)
  574. # or clock_gettime has returned a non-zero value
  575. AC_MSG_RESULT([no])
  576. ],
  577. [
  578. AC_MSG_RESULT([guessing no])
  579. ]
  580. )
  581. fi
  582. #
  583. # pthread
  584. #
  585. AC_CHECK_LIB([pthread], [pthread_create], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  586. AC_CHECK_LIB([pthread], [pthread_sigmask], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  587. AC_CHECK_LIB([pthread], [pthread_attr_init], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  588. AC_CHECK_LIB([pthread], [pthread_attr_setstacksize], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  589. AC_CHECK_LIB([pthread], [pthread_attr_destroy], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  590. AC_CHECK_LIB([pthread], [pthread_cancel], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  591. AC_CHECK_LIB([pthread], [pthread_join], [], [AC_MSG_ERROR([pthread library not found or incompatible])])
  592. LDFLAGS="$LDFLAGS -lpthread"
  593. #
  594. # MySQL library
  595. #
  596. if test -z "$MYSQL_CONFIG_HOME"; then
  597. AC_PATH_PROG([MYSQL_CONFIG_HOME], [mysql_config], [no])
  598. fi
  599. if test "$MYSQL_CONFIG_HOME" != "no" ; then
  600. MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`"
  601. if test "$manual_MYSQL_CFLAGS" = "no" ; then
  602. MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --include`"
  603. fi
  604. if test "$manual_MYSQL_LIBS" = "no" ; then
  605. MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`"
  606. fi
  607. else
  608. MYSQL_VERSION="unknown"
  609. fi
  610. MYSQL_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS $MYSQL_LIBS"
  611. MYSQL_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS"
  612. AC_CHECK_LIB([mysqlclient], [mysql_init], [HAVE_MYSQL="yes"], [])
  613. AC_CHECK_HEADER([mysql.h], [], [HAVE_MYSQL=""])
  614. CPPFLAGS="$MYSQL_OLD_CPPFLAGS"
  615. LDFLAGS="$MYSQL_OLD_LDFLAGS"
  616. AC_MSG_CHECKING([MySQL library (required)])
  617. if test "$HAVE_MYSQL" = "yes" ; then
  618. AC_MSG_RESULT([yes ($MYSQL_VERSION)])
  619. else
  620. AC_MSG_RESULT([no])
  621. AC_MSG_ERROR([MySQL not found or incompatible])
  622. fi
  623. AC_SUBST([HAVE_MYSQL])
  624. AC_SUBST([MYSQL_VERSION])
  625. AC_SUBST([MYSQL_CFLAGS])
  626. AC_SUBST([MYSQL_LIBS])
  627. #
  628. # PCRE library (optional)
  629. #
  630. ##TODO PCRE version
  631. PCRE_LIBS=""
  632. PCRE_CFLAGS=""
  633. if test "$want_pcre" = "no" ; then
  634. AC_MSG_NOTICE([ignoring PCRE (optional)])
  635. else
  636. if test -z "$PCRE_HOME" ; then
  637. AC_CHECK_LIB([pcre], [pcre_study], [HAVE_PCRE="yes"], [])
  638. if test "$HAVE_PCRE" = "yes" ; then
  639. PCRE_LIBS="-lpcre"
  640. fi
  641. else
  642. PCRE_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS -L$PCRE_HOME/lib"
  643. PCRE_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS -I$PCRE_HOME/include"
  644. AC_CHECK_LIB(pcre, pcre_compile, [HAVE_PCRE="yes"], [])
  645. CPPFLAGS="$PCRE_OLD_CPPFLAGS"
  646. LDFLAGS="$PCRE_OLD_LDFLAGS"
  647. if test "$HAVE_PCRE" = "yes" ; then
  648. PCRE_LIBS="-L$PCRE_HOME/lib -lpcre"
  649. test -d "$PCRE_HOME/include" && PCRE_CFLAGS="-I$PCRE_HOME/include"
  650. fi
  651. fi
  652. AC_MSG_CHECKING([PCRE library (optional)])
  653. if test "$HAVE_PCRE" = "yes" ; then
  654. AC_MSG_RESULT([yes])
  655. else
  656. AC_MSG_RESULT([no])
  657. if test "$require_pcre" = "yes" ; then
  658. AC_MSG_ERROR([PCRE not found or incompatible (requested)])
  659. else
  660. AC_MSG_NOTICE([disabling PCRE (optional)])
  661. fi
  662. fi
  663. fi
  664. AC_SUBST([HAVE_PCRE])
  665. AC_SUBST([PCRE_LIBS])
  666. AC_SUBST([PCRE_CFLAGS])
  667. #
  668. # Host specific stuff
  669. #
  670. AC_MSG_CHECKING([host OS])
  671. host_os="`uname`"
  672. AC_MSG_RESULT([$host_os])
  673. fd_setsize=""
  674. DLLEXT=".so"
  675. case $host_os in
  676. Solaris* )
  677. LIBS="$LIBS -lsocket -lnsl -ldl"
  678. ;;
  679. Linux* )
  680. LIBS="$LIBS -ldl"
  681. ;;
  682. FreeBSD*)
  683. CPPFLAGS="$CPPFLAGS -D__FREEBSD__"
  684. ;;
  685. NetBSD*)
  686. CPPFLAGS="$CPPFLAGS -D__NETBSD__"
  687. ;;
  688. CYGWIN*)
  689. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096 -DCYGWIN"
  690. fd_setsize="done"
  691. DLLEXT=".dll"
  692. ;;
  693. esac
  694. AC_SUBST([DLLEXT])
  695. AC_MSG_CHECKING([for MinGW])
  696. if test -n "`$CC --version | grep -i mingw`" ; then
  697. AC_MSG_RESULT([yes])
  698. CPPFLAGS="$CPPFLAGS -DMINGW"
  699. if test -z "$fd_setsize" ; then
  700. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096"
  701. fi
  702. LIBS="$LIBS -lws2_32"
  703. else
  704. AC_MSG_RESULT([no])
  705. fi
  706. ###############################################################################
  707. AC_OUTPUT