configure.in 15 KB

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