configure.in 18 KB

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