configure.in 18 KB

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