configure.in 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765
  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. AC_INIT(eAthena)
  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([src/char/Makefile src/login/Makefile])
  9. AC_CONFIG_FILES([src/char_sql/Makefile src/txt-converter/Makefile])
  10. AC_CONFIG_FILES([src/map/Makefile src/plugins/Makefile src/tool/Makefile])
  11. #
  12. # Memory managers
  13. #
  14. AC_ARG_ENABLE(
  15. [manager],
  16. AC_HELP_STRING(
  17. [--enable-manager=ARG],
  18. [memory managers: no, builtin, memwatch, dmalloc, gcollect, bcheck (defaults to builtin)]
  19. ),
  20. [
  21. enable_manager="$enableval"
  22. case $enableval in
  23. "no");;
  24. "builtin");;
  25. "memwatch");;
  26. "dmalloc");;
  27. "gcollect");;
  28. "bcheck");;
  29. *) AC_MSG_ERROR([[unknown memory manager '$enableval'... stopping]]);;
  30. esac
  31. ],
  32. [enable_manager="builtin"]
  33. )
  34. #
  35. # packetver
  36. #
  37. AC_ARG_ENABLE(
  38. [packetver],
  39. AC_HELP_STRING(
  40. [--enable-packetver=ARG],
  41. [Sets the PACKETVER define of the map-server. (see src/map/clif.h)]
  42. ),
  43. [enable_packetver="$enableval"],
  44. [enable_packetver=""]
  45. )
  46. #
  47. # debug
  48. #
  49. AC_ARG_ENABLE(
  50. [debug],
  51. AC_HELP_STRING(
  52. [--enable-debug@<:@=ARG@:>@],
  53. [
  54. Compiles extra debug code. (disabled by default)
  55. (available options: yes, no, gdb)
  56. ]
  57. ),
  58. [
  59. enable_debug="$enableval"
  60. case $enableval in
  61. "no");;
  62. "yes");;
  63. "gdb");;
  64. *) AC_MSG_ERROR([[invalid argument --enable-debug=$enableval... stopping]]);;
  65. esac
  66. ],
  67. [enable_debug="no"]
  68. )
  69. #
  70. # RDTSC as Tick Source
  71. #
  72. AC_ARG_ENABLE(
  73. [rdtsc],
  74. AC_HELP_STRING(
  75. [--enable-rdtsc],
  76. [
  77. Uses rdtsc as timing source (disabled by default)
  78. Enable it when you've timing issues.
  79. (For example: in conjunction with XEN or Other Virtualization mechanisms)
  80. Note:
  81. Please ensure that you've disabled dynamic CPU-Frequencys, such as power saving options.
  82. (On the most modern Dedicated Servers cpufreq is preconfigured, see your distribution's manual
  83. how to disable it)
  84. ]
  85. ),
  86. [
  87. enable_rdtsc=1
  88. ],
  89. [enable_rdtsc=0]
  90. )
  91. #
  92. # Profiler
  93. #
  94. AC_ARG_ENABLE(
  95. [profiler],
  96. AC_HELP_STRING(
  97. [--enable-profiler=ARG],
  98. [Profilers: no, gprof (disabled by default)]
  99. ),
  100. [
  101. enable_profiler="$enableval"
  102. case $enableval in
  103. "no");;
  104. "gprof");;
  105. *) AC_MSG_ERROR([[invalid argument --enable-profiler=$enableval... stopping]]);;
  106. esac
  107. ],
  108. [enable_profiler="no"]
  109. )
  110. #
  111. # 64bit
  112. #
  113. AC_ARG_ENABLE(
  114. [64bit],
  115. AC_HELP_STRING(
  116. [--enable-64bit],
  117. [
  118. Don't force 32 bit. (disabled by default)
  119. 64bit support is still being tested, not recommended for production servers.
  120. ]
  121. ),
  122. [
  123. enable_64bit="$enableval"
  124. case $enableval in
  125. "no");;
  126. "yes");;
  127. *) AC_MSG_ERROR([[invalid argument --enable-64bit=$enableval... stopping]]);;
  128. esac
  129. ],
  130. [enable_64bit="no"]
  131. )
  132. #
  133. # Enable/disable MySql and optionally specify the path to mysql_config (optional library)
  134. #
  135. AC_ARG_WITH(
  136. [mysql],
  137. AC_HELP_STRING(
  138. [--with-mysql@<:@=ARG@:>@],
  139. [use MySQL client library, optionally specify the path to the mysql_config executable (by default mysql is used if found)]
  140. ),
  141. [
  142. if test "$withval" = "no" ; then
  143. want_mysql="no"
  144. else
  145. want_mysql="yes"
  146. require_mysql="yes"
  147. if test "$withval" != "yes" ; then
  148. if test ! -x "$withval" ; then
  149. AC_MSG_ERROR([$withval is not an executable file])
  150. fi
  151. MYSQL_CONFIG_HOME="$withval"
  152. fi
  153. fi
  154. ],
  155. [want_mysql="yes" require_mysql="no"]
  156. )
  157. #
  158. # Manual MYSQL_CFLAGS (optional)
  159. #
  160. AC_ARG_WITH(
  161. [MYSQL_CFLAGS],
  162. AC_HELP_STRING(
  163. [--with-MYSQL_CFLAGS=ARG],
  164. [specify MYSQL_CFLAGS manually (instead of using "mysql_config --include")]
  165. ),
  166. [
  167. manual_MYSQL_CFLAGS="yes"
  168. MYSQL_CFLAGS="$withval"
  169. ],
  170. [manual_MYSQL_CFLAGS="no"]
  171. )
  172. #
  173. # Manual MYSQL_LIBS (optional)
  174. #
  175. AC_ARG_WITH(
  176. [MYSQL_LIBS],
  177. AC_HELP_STRING(
  178. [--with-MYSQL_LIBS=ARG],
  179. [specify MYSQL_LIBS manually (instead of using "mysql_config --libs")]
  180. ),
  181. [
  182. manual_MYSQL_LIBS="yes"
  183. MYSQL_LIBS="$withval"
  184. ],
  185. [manual_MYSQL_LIBS="no"]
  186. )
  187. #
  188. # Enable/disable PCRE and optionally specify the path (optional library)
  189. #
  190. AC_ARG_WITH(
  191. [pcre],
  192. AC_HELP_STRING(
  193. [--with-pcre@<:@=ARG@:>@],
  194. [use PCRE library, optionally specify the full path of pcre installation directory (by default pcre is used if found)]
  195. ),
  196. [
  197. if test "$withval" = "no" ; then
  198. want_pcre="no"
  199. else
  200. want_pcre="yes"
  201. require_pcre="yes"
  202. if test "$withval" != "yes" ; then
  203. if test ! -d "$withval" ; then
  204. AC_MSG_ERROR([$withval is not a directoy])
  205. fi
  206. PCRE_HOME="$withval"
  207. fi
  208. fi
  209. ],
  210. [want_pcre="yes" require_pcre="no"]
  211. )
  212. #
  213. # Specify the path of the zlib library (required library)
  214. #
  215. AC_ARG_WITH(
  216. [zlib],
  217. AC_HELP_STRING(
  218. [--with-zlib=DIR],
  219. [root directory path of zlib installation (defaults to /usr/local or /usr if not found in /usr/local).
  220. Assumes that the header files are in DIR/include and the library files are in DIR/lib]
  221. ),
  222. [
  223. test -n "$withval" && ZLIB_HOME="$withval"
  224. ],
  225. [
  226. ZLIB_HOME=/usr/local
  227. test ! -f "${ZLIB_HOME}/include/zlib.h" && ZLIB_HOME=/usr
  228. ]
  229. )
  230. ###############################################################################
  231. # Check for programs and types.
  232. #
  233. AC_PROG_MAKE_SET
  234. AC_PROG_CC
  235. AC_PROG_CPP
  236. AC_LANG([C])
  237. CFLAGS="$CFLAGS -pipe -ffast-math -Wall -Wno-sign-compare"
  238. CPPFLAGS="$CPPFLAGS -I../common"
  239. AC_C_BIGENDIAN(
  240. [AC_MSG_ERROR([[bigendian is not supported... stopping]])],
  241. ,
  242. [AC_MSG_WARN([[unable to determine endianess, only little endian is supported]])]
  243. )
  244. if test "$enable_64bit" = "no" ; then
  245. AC_MSG_CHECKING([whether pointers can be stored in ints (old code)])
  246. pointers_fit_in_ints="no"
  247. AC_COMPILE_IFELSE(
  248. [AC_LANG_PROGRAM([[static int test_array[((long int)sizeof(int)) == ((long int)sizeof(void*)) ? 1 : -1];]])],
  249. [pointers_fit_in_ints="yes"],
  250. []
  251. )
  252. if test "$pointers_fit_in_ints" = "no" ; then
  253. CFLAGS="$CFLAGS -m32"
  254. LDFLAGS="$LDFLAGS -m32"
  255. AC_COMPILE_IFELSE(
  256. [AC_LANG_PROGRAM([[static int test_array[((long int)sizeof(int)) == ((long int)sizeof(void *)) ? 1 : -1];]])],
  257. [pointers_fit_in_ints="yes (with -m32)"],
  258. []
  259. )
  260. fi
  261. AC_MSG_RESULT($pointers_fit_in_ints)
  262. if test "$pointers_fit_in_ints" = "no" ; then
  263. AC_MSG_ERROR([pointers cannot be stored in ints, required for old code... stopping])
  264. fi
  265. fi
  266. AC_MSG_CHECKING([whether $CC supports -Wno-unused-parameter])
  267. OLD_CFLAGS="$CFLAGS"
  268. CFLAGS="$CFLAGS -Wno-unused-parameter"
  269. AC_COMPILE_IFELSE(
  270. [int foo;],
  271. [AC_MSG_RESULT([yes])],
  272. [
  273. AC_MSG_RESULT([no])
  274. CFLAGS="$OLD_CFLAGS"
  275. ]
  276. )
  277. AC_MSG_CHECKING([whether $CC supports -Wno-pointer-sign])
  278. OLD_CFLAGS="$CFLAGS"
  279. CFLAGS="$CFLAGS -Wno-pointer-sign"
  280. AC_COMPILE_IFELSE(
  281. [int foo;],
  282. [
  283. AC_MSG_RESULT([yes])
  284. AC_MSG_CHECKING([whether $CC can actually use -Wno-pointer-sign])
  285. # This option causes warnings in C++ mode
  286. # Note: -Werror must be before -Wno-pointer-sign, otherwise it does not do anything
  287. CFLAGS="$OLD_CFLAGS -Werror -Wno-pointer-sign"
  288. AC_COMPILE_IFELSE(
  289. [int foo;],
  290. [
  291. AC_MSG_RESULT([yes])
  292. CFLAGS="$OLD_CFLAGS -Wno-pointer-sign"
  293. ],
  294. [
  295. AC_MSG_RESULT([no])
  296. CFLAGS="$OLD_CFLAGS"
  297. ]
  298. )
  299. ],
  300. [
  301. AC_MSG_RESULT([no])
  302. CFLAGS="$OLD_CFLAGS"
  303. ]
  304. )
  305. AC_MSG_CHECKING([whether $CC supports -Wno-switch])
  306. OLD_CFLAGS="$CFLAGS"
  307. CFLAGS="$CFLAGS -Wno-switch"
  308. AC_COMPILE_IFELSE(
  309. [int foo;],
  310. [AC_MSG_RESULT([yes])],
  311. [
  312. AC_MSG_RESULT([no])
  313. CFLAGS="$OLD_CFLAGS"
  314. ]
  315. )
  316. AC_MSG_CHECKING([whether $CC supports -fPIC])
  317. OLD_CFLAGS="$CFLAGS"
  318. CFLAGS="$CFLAGS -fPIC"
  319. AC_COMPILE_IFELSE(
  320. [int foo;],
  321. [
  322. AC_MSG_RESULT([yes])
  323. compiler_supports_pic="yes"
  324. ],
  325. [
  326. AC_MSG_RESULT([no])
  327. compiler_supports_pic="no"
  328. ]
  329. )
  330. CFLAGS="$OLD_CFLAGS"
  331. #
  332. # -shared needs position independent code; some platforms emit it
  333. # always, others need -fPIC
  334. #
  335. AC_MSG_CHECKING([whether $CC needs -fPIC for shared objects])
  336. OLD_CFLAGS="$CFLAGS"
  337. CFLAGS="$CFLAGS -shared"
  338. WITH_PLUGINS="yes"
  339. AC_LINK_IFELSE(
  340. [
  341. int foo(void)
  342. {
  343. return 0;
  344. }
  345. ],
  346. [
  347. AC_MSG_RESULT([no])
  348. CFLAGS="$OLD_CFLAGS"
  349. ],
  350. [
  351. if test "$compiler_supports_pic" = "yes" ; then
  352. # Verify if -shared really fails due to lack of -fPIC or something else
  353. CFLAGS="$CFLAGS -fPIC"
  354. AC_LINK_IFELSE(
  355. [
  356. int foo(void)
  357. {
  358. return 0;
  359. }
  360. ],
  361. [
  362. AC_MSG_RESULT([yes])
  363. CFLAGS="$OLD_CFLAGS -fPIC"
  364. ],
  365. [
  366. AC_MSG_RESULT([no, but fails for another reason])
  367. AC_MSG_ERROR([compiler is unable to compile shared objects for an unhandled reason, please report this with attached config.log... stopping])
  368. ]
  369. )
  370. else
  371. # Disable compilation of plugins (optional), so 'make all' does not fail
  372. AC_MSG_RESULT([yes, but unsupported])
  373. AC_MSG_NOTICE([compiler is unable to generate position independent code, disabled plugins (optional)])
  374. WITH_PLUGINS="no"
  375. fi
  376. ]
  377. )
  378. AC_SUBST([WITH_PLUGINS])
  379. #
  380. # DB_MANUAL_CAST_TO_UNION
  381. #
  382. AC_MSG_CHECKING([whether $CC is able to typecast to union])
  383. AC_COMPILE_IFELSE(
  384. [
  385. typedef union Foonion
  386. {
  387. int i;
  388. unsigned int ui;
  389. const char* s;
  390. }
  391. Foonion;
  392. int bar(Foonion onion)
  393. {
  394. return onion.i;
  395. }
  396. int foo(void)
  397. {
  398. int i = 0;
  399. return bar(((Foonion)(int)i));
  400. }
  401. ],
  402. [
  403. AC_MSG_RESULT([yes])
  404. ],
  405. [
  406. AC_MSG_RESULT([no])
  407. CFLAGS="$CFLAGS -DDB_MANUAL_CAST_TO_UNION"
  408. ]
  409. )
  410. ###############################################################################
  411. # Check for libraries and header files.
  412. #
  413. #
  414. # setrlimit - used to set the socket limit
  415. #
  416. AC_CHECK_FUNC([setrlimit],[CFLAGS="$CFLAGS -DHAVE_SETRLIMIT"])
  417. #
  418. # strnlen - string length with upper scan bound
  419. #
  420. AC_CHECK_FUNC([strnlen],[CFLAGS="$CFLAGS -DHAVE_STRNLEN"])
  421. #
  422. # Memory manager
  423. #
  424. case $enable_manager in
  425. "no")
  426. CFLAGS="$CFLAGS -DNO_MEMMGR"
  427. ;;
  428. "builtin")
  429. # enabled by default
  430. ;;
  431. "memwatch")
  432. CFLAGS="$CFLAGS -DMEMWATCH"
  433. AC_CHECK_HEADER([memwatch.h], , [AC_MSG_ERROR([memwatch header not found... stopping])])
  434. ;;
  435. "dmalloc")
  436. CFLAGS="$CFLAGS -DDMALLOC -DDMALLOC_FUNC_CHECK"
  437. LIBS="$LIBS -ldmalloc"
  438. AC_CHECK_HEADER([dmalloc.h], , [AC_MSG_ERROR([dmalloc header not found... stopping])])
  439. ;;
  440. "gcollect")
  441. CFLAGS="$CFLAGS -DGCOLLECT"
  442. LIBS="$LIBS -lgc"
  443. AC_CHECK_HEADER([gc.h], , [AC_MSG_ERROR([gcollect header not found... stopping])])
  444. ;;
  445. "bcheck")
  446. CFLAGS="$CFLAGS -DBCHECK"
  447. ;;
  448. esac
  449. #
  450. # Packetver
  451. #
  452. if test -n "$enable_packetver" ; then
  453. CFLAGS="$CFLAGS -DPACKETVER=$enable_packetver"
  454. fi
  455. #
  456. # Debug
  457. #
  458. case $enable_debug in
  459. "no")
  460. # default value
  461. CFLAGS="$CFLAGS -Wno-unused -Wno-parentheses"
  462. ;;
  463. "yes")
  464. CFLAGS="$CFLAGS -g -DDEBUG"
  465. ;;
  466. "gdb")
  467. CFLAGS="$CFLAGS -ggdb -DDEBUG"
  468. ;;
  469. esac
  470. #
  471. # RDTSC
  472. #
  473. case $enable_rdtsc in
  474. 0)
  475. #default value
  476. ;;
  477. 1)
  478. CFLAGS="$CFLAGS -DENABLE_RDTSC"
  479. ;;
  480. esac
  481. #
  482. # Profiler
  483. #
  484. case $enable_profiler in
  485. "no")
  486. # default value
  487. ;;
  488. "gprof")
  489. CFLAGS="$CFLAGS -pg"
  490. LDFLAGS="$LDFLAGS -pg"
  491. ;;
  492. esac
  493. #
  494. # zlib library (required)
  495. #
  496. if test -n "${ZLIB_HOME}" ; then
  497. LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
  498. CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
  499. fi
  500. AC_CHECK_LIB([z], [inflateEnd], [],[AC_MSG_ERROR([zlib library not found or incompatible, please specify the correct path with --with-zlib=DIR... stopping])])
  501. AC_CHECK_HEADER([zlib.h], [], [AC_MSG_ERROR([zlib header not found, please specify the correct path with --with-zlib=DIR... stopping])])
  502. #
  503. # math library (required)
  504. #
  505. AC_SEARCH_LIBS([sqrt], [m], [], [AC_MSG_ERROR([math library not found... stopping])])
  506. #
  507. # clock_gettime (optional, rt on Debian)
  508. #
  509. AC_SEARCH_LIBS([clock_gettime], [rt])
  510. #
  511. # CLOCK_MONOTONIC clock for clock_gettime
  512. # Normally defines _POSIX_TIMERS > 0 and _POSIX_MONOTONIC_CLOCK (for posix
  513. # compliant systems) and __FreeBSD_cc_version >= 500005 (for FreeBSD
  514. # >= 5.1.0, which does not have the posix defines (ref. r11983)) would be
  515. # checked but some systems define them even when they do not support it
  516. # (ref. bugreport:1003).
  517. #
  518. if test "$ac_cv_search_clock_gettime" != "no" ; then
  519. AC_MSG_CHECKING([whether CLOCK_MONOTONIC is supported and works])
  520. AC_RUN_IFELSE(
  521. [
  522. #include <sys/time.h>
  523. #include <time.h>
  524. #include <unistd.h>
  525. int main(int argc, char** argv)
  526. {
  527. struct timespec tval;
  528. return clock_gettime(CLOCK_MONOTONIC, &tval);
  529. }
  530. ],
  531. [
  532. AC_MSG_RESULT([yes])
  533. CFLAGS="$CFLAGS -DHAVE_MONOTONIC_CLOCK"
  534. ],
  535. [
  536. # either it failed to compile (CLOCK_MONOTONIC undefined)
  537. # or clock_gettime has returned a non-zero value
  538. AC_MSG_RESULT([no])
  539. ],
  540. [
  541. AC_MSG_RESULT([guessing no])
  542. ]
  543. )
  544. fi
  545. #
  546. # MySQL library (optional)
  547. #
  548. if test "$want_mysql" = "no" ; then
  549. MYSQL_VERSION=""
  550. MYSQL_CFLAGS=""
  551. MYSQL_LIBS=""
  552. AC_MSG_NOTICE([ignoring MySQL (optional)])
  553. else
  554. if test -z "$MYSQL_CONFIG_HOME"; then
  555. AC_PATH_PROG([MYSQL_CONFIG_HOME], [mysql_config], [no])
  556. fi
  557. if test "$MYSQL_CONFIG_HOME" != "no" ; then
  558. MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`"
  559. if test "$manual_MYSQL_CFLAGS" = "no" ; then
  560. MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --include`"
  561. fi
  562. if test "$manual_MYSQL_LIBS" = "no" ; then
  563. MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`"
  564. fi
  565. else
  566. MYSQL_VERSION="unknown"
  567. fi
  568. MYSQL_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS $MYSQL_LIBS"
  569. MYSQL_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS"
  570. AC_CHECK_LIB([mysqlclient], [mysql_init], [HAVE_MYSQL="yes"], [])
  571. AC_CHECK_HEADER([mysql.h], [], [HAVE_MYSQL=""])
  572. CPPFLAGS="$MYSQL_OLD_CPPFLAGS"
  573. LDFLAGS="$MYSQL_OLD_LDFLAGS"
  574. AC_MSG_CHECKING([MySQL library (optional)])
  575. if test "$HAVE_MYSQL" = "yes" ; then
  576. AC_MSG_RESULT([yes ($MYSQL_VERSION)])
  577. else
  578. AC_MSG_RESULT([no])
  579. if test "$require_mysql" = "yes" ; then
  580. AC_MSG_ERROR([MySQL not found or incompatible (requested)])
  581. else
  582. AC_MSG_NOTICE([disabling MySQL (optional)])
  583. MYSQL_VERSION=""
  584. MYSQL_CFLAGS=""
  585. MYSQL_LIBS=""
  586. fi
  587. fi
  588. fi
  589. AC_SUBST([HAVE_MYSQL])
  590. AC_SUBST([MYSQL_VERSION])
  591. AC_SUBST([MYSQL_CFLAGS])
  592. AC_SUBST([MYSQL_LIBS])
  593. #
  594. # PCRE library (optional)
  595. #
  596. ##TODO PCRE version
  597. PCRE_LIBS=""
  598. PCRE_CFLAGS=""
  599. if test "$want_pcre" = "no" ; then
  600. AC_MSG_NOTICE([ignoring PCRE (optional)])
  601. else
  602. if test -z "$PCRE_HOME" ; then
  603. AC_CHECK_LIB([pcre], [pcre_study], [HAVE_PCRE="yes"], [])
  604. if test "$HAVE_PCRE" = "yes" ; then
  605. PCRE_LIBS="-lpcre"
  606. fi
  607. else
  608. PCRE_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS -L$PCRE_HOME/lib"
  609. PCRE_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS -I$PCRE_HOME/include"
  610. AC_CHECK_LIB(pcre, pcre_compile, [HAVE_PCRE="yes"], [])
  611. CPPFLAGS="$PCRE_OLD_CPPFLAGS"
  612. LDFLAGS="$PCRE_OLD_LDFLAGS"
  613. if test "$HAVE_PCRE" = "yes" ; then
  614. PCRE_LIBS="-L$PCRE_HOME/lib -lpcre"
  615. test -d "$PCRE_HOME/include" && PCRE_CFLAGS="-I$PCRE_HOME/include"
  616. fi
  617. fi
  618. AC_MSG_CHECKING([PCRE library (optional)])
  619. if test "$HAVE_PCRE" = "yes" ; then
  620. AC_MSG_RESULT([yes])
  621. else
  622. AC_MSG_RESULT([no])
  623. if test "$require_pcre" = "yes" ; then
  624. AC_MSG_ERROR([PCRE not found or incompatible (requested)])
  625. else
  626. AC_MSG_NOTICE([disabling PCRE (optional)])
  627. fi
  628. fi
  629. fi
  630. AC_SUBST([HAVE_PCRE])
  631. AC_SUBST([PCRE_LIBS])
  632. AC_SUBST([PCRE_CFLAGS])
  633. #
  634. # Host specific stuff
  635. #
  636. AC_MSG_CHECKING([host OS])
  637. host_os="`uname`"
  638. AC_MSG_RESULT([$host_os])
  639. fd_setsize=""
  640. DLLEXT=".so"
  641. case $host_os in
  642. Solaris* )
  643. LIBS="$LIBS -lsocket -lnsl -ldl"
  644. ;;
  645. Linux* )
  646. LIBS="$LIBS -ldl"
  647. ;;
  648. FreeBSD*)
  649. CPPFLAGS="$CPPFLAGS -D__FREEBSD__"
  650. ;;
  651. NetBSD*)
  652. CPPFLAGS="$CPPFLAGS -D__NETBSD__"
  653. ;;
  654. CYGWIN*)
  655. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096 -DCYGWIN"
  656. fd_setsize="done"
  657. DLLEXT=".dll"
  658. ;;
  659. esac
  660. AC_SUBST([DLLEXT])
  661. AC_MSG_CHECKING([for MinGW])
  662. if test -n "`$CC --version | grep -i mingw`" ; then
  663. AC_MSG_RESULT([yes])
  664. CPPFLAGS="$CPPFLAGS -DMINGW"
  665. if test -z "$fd_setsize" ; then
  666. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096"
  667. fi
  668. LIBS="$LIBS -lws2_32"
  669. else
  670. AC_MSG_RESULT([no])
  671. fi
  672. ###############################################################################
  673. AC_OUTPUT