configure.in 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437
  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.61])
  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 src/ladmin/Makefile])
  9. AC_CONFIG_FILES([src/char_sql/Makefile src/login_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 '$enable_manager'... stopping]]);;
  30. esac
  31. ],
  32. [enable_manager="builtin"]
  33. )
  34. #
  35. # mapregsql
  36. #
  37. AC_ARG_ENABLE(
  38. [mapregsql],
  39. AC_HELP_STRING(
  40. [--enable-mapregsql],
  41. [Makes map-wide script variables be saved to SQL instead of TXT files in the sql map-server. (defauts to no)]
  42. ),
  43. [
  44. enable_mapregsql="$enableval"
  45. case $enableval in
  46. no);;
  47. yes);;
  48. *) AC_MSG_ERROR([[invalid argument --enable-mapregsql=$enable_mapregsql... stopping]]);;
  49. esac
  50. ],
  51. [enable_mapregsql="no"]
  52. )
  53. #
  54. # debug
  55. #
  56. AC_ARG_ENABLE(
  57. [debug],
  58. AC_HELP_STRING(
  59. [--enable-debug],
  60. [Compiles in debug mode. (defauts to no)]
  61. ),
  62. [
  63. enable_debug="$enableval"
  64. case $enableval in
  65. no);;
  66. yes);;
  67. *) AC_MSG_ERROR([[invalid argument --enable-debug=$enable_mapregsql... stopping]]);;
  68. esac
  69. ],
  70. [enable_debug="no"]
  71. )
  72. #
  73. # Enable/disable MySql and optionally specify the path (optional library)
  74. #
  75. AC_ARG_WITH(
  76. [mysql],
  77. AC_HELP_STRING(
  78. [--with-mysql@<:@=ARG@:>@],
  79. [use MySQL client library, optionally specify path to the mysql_config executable (by default mysql is used if found)]
  80. ),
  81. [
  82. if test "$withval" = "no" ; then
  83. want_mysql="no"
  84. else
  85. want_mysql="yes"
  86. require_mysql="yes"
  87. if test "$withval" != "yes" ; then
  88. MYSQL_CONFIG_HOME="$withval"
  89. fi
  90. fi
  91. ],
  92. [want_mysql="yes" require_mysql="no"]
  93. )
  94. #
  95. # Enable/disable PCRE and optionally specify the path (optional library)
  96. #
  97. AC_ARG_WITH(
  98. [pcre],
  99. AC_HELP_STRING(
  100. [--with-pcre@<:@=ARG@:>@],
  101. [use PCRE library, optionally specify the root directory path of pcre installation (by default pcre is used if found)]
  102. ),
  103. [
  104. if test "$withval" = "no" ; then
  105. want_pcre="no"
  106. else
  107. want_pcre="yes"
  108. require_pcre="yes"
  109. if test "$withval" != "yes" ; then
  110. PCRE_HOME="$withval"
  111. fi
  112. fi
  113. ],
  114. [want_pcre="yes" require_pcre="no"]
  115. )
  116. #
  117. # Specify the path of the zlib library (required library)
  118. #
  119. AC_ARG_WITH(
  120. [zlib],
  121. AC_HELP_STRING(
  122. [--with-zlib=DIR],
  123. [root directory path of zlib installation (defaults to /usr/local or /usr if not found in /usr/local)]
  124. ),
  125. [
  126. test -n "$withval" && ZLIB_HOME="$withval"
  127. ],
  128. [
  129. ZLIB_HOME=/usr/local
  130. test ! -f "${ZLIB_HOME}/include/zlib.h" && ZLIB_HOME=/usr
  131. ]
  132. )
  133. ###############################################################################
  134. # Checks for programs and types.
  135. AC_PROG_MAKE_SET
  136. AC_PROG_CC
  137. AC_PROG_CPP
  138. AC_LANG([C])
  139. CFLAGS="$CFLAGS -pipe -ffast-math -Wall -Wno-sign-compare"
  140. CPPFLAGS="$CPPFLAGS -I../common"
  141. AC_C_BIGENDIAN(
  142. [AC_MSG_ERROR([[bigendian is not supported... stopping]])],
  143. ,
  144. [AC_MSG_WARN([[unable to determine endianess, only little endian is supported]])]
  145. )
  146. AC_MSG_CHECKING([whether pointers can be stored in ints (old code)])
  147. pointers_fit_in_ints="no"
  148. AC_COMPILE_IFELSE(
  149. [AC_LANG_PROGRAM([[int hw[(sizeof(int) == sizeof(void *))];]])],
  150. [pointers_fit_in_ints="yes"],
  151. []
  152. )
  153. if test "$pointers_fit_in_ints" = "no" ; then
  154. CFLAGS="$CFLAGS -m32"
  155. AC_COMPILE_IFELSE(
  156. [AC_LANG_PROGRAM([[int hw[(sizeof(int) == sizeof(void *))];]])],
  157. [pointers_fit_in_ints="yes (with -m32)"],
  158. []
  159. )
  160. fi
  161. AC_MSG_RESULT($pointers_fit_in_ints)
  162. if test "$pointers_fit_in_ints" = "no" ; then
  163. AC_MSG_ERROR([pointers cannot be stored in ints, required for old code... stopping])
  164. fi
  165. AC_MSG_CHECKING([whether $CC supports -Wno-unused-parameter])
  166. OLD_CFLAGS="$CFLAGS"
  167. CFLAGS="$CFLAGS -Wno-unused-parameter"
  168. AC_COMPILE_IFELSE(
  169. [int foo;],
  170. [AC_MSG_RESULT([yes])],
  171. [
  172. AC_MSG_RESULT([no])
  173. CFLAGS="$OLD_CFLAGS"
  174. ]
  175. )
  176. AC_MSG_CHECKING([whether $CC supports -Wno-pointer-sign])
  177. OLD_CFLAGS="$CFLAGS"
  178. CFLAGS="$CFLAGS -Wno-pointer-sign"
  179. AC_COMPILE_IFELSE(
  180. [int foo;],
  181. [AC_MSG_RESULT([yes])],
  182. [
  183. AC_MSG_RESULT([no])
  184. CFLAGS="$OLD_CFLAGS"
  185. ]
  186. )
  187. AC_MSG_CHECKING([whether $CC supports -Wno-switch])
  188. OLD_CFLAGS="$CFLAGS"
  189. CFLAGS="$CFLAGS -Wno-switch"
  190. AC_COMPILE_IFELSE(
  191. [int foo;],
  192. [AC_MSG_RESULT([yes])],
  193. [
  194. AC_MSG_RESULT([no])
  195. CFLAGS="$OLD_CFLAGS"
  196. ]
  197. )
  198. ###############################################################################
  199. # Checks for libraries and header files.
  200. dnl
  201. dnl Memory manager
  202. dnl
  203. case $enableval in
  204. "no")
  205. CFLAGS="$CFLAGS -DNO_MEMMGR"
  206. ;;
  207. "builtin")
  208. # enabled by default
  209. ;;
  210. "memwatch")
  211. CFLAGS="$CFLAGS -DMEMWATCH"
  212. AC_CHECK_HEADER([memwatch.h], , [AC_MSG_ERROR([memwatch header not found... stopping])])
  213. ;;
  214. "dmalloc")
  215. CFLAGS="$CFLAGS -DDMALLOC -DDMALLOC_FUNC_CHECK"
  216. LIBS="$LIBS -ldmalloc"
  217. AC_CHECK_HEADER([dmalloc.h], , [AC_MSG_ERROR([dmalloc header not found... stopping])])
  218. ;;
  219. "gcollect")
  220. CFLAGS="$CFLAGS -DGCOLLECT"
  221. LIBS="$LIBS -lgc"
  222. AC_CHECK_HEADER([gc.h], , [AC_MSG_ERROR([gcollect header not found... stopping])])
  223. ;;
  224. "bcheck")
  225. CFLAGS="$CFLAGS -DBCHECK"
  226. ;;
  227. esac
  228. dnl
  229. dnl Memory manager
  230. dnl
  231. if test "$enable_mapregsql" = "yes" ; then
  232. CFLAGS="$CFLAGS -DMAPREGSQL"
  233. fi
  234. dnl
  235. dnl Debug
  236. dnl
  237. if test "$enable_debug" = "yes" ; then
  238. CFLAGS="$CFLAGS -DDEBUG"
  239. fi
  240. dnl
  241. dnl Check MySQL library (optional)
  242. dnl
  243. MYSQL_VERSION=""
  244. MYSQL_CFLAGS=""
  245. MYSQL_LIBS=""
  246. if test "$want_mysql" = "no" ; then
  247. AC_MSG_NOTICE([ignoring MySQL (optional)])
  248. else
  249. if test -z "$MYSQL_CONFIG_HOME"; then
  250. AC_PATH_PROG([MYSQL_CONFIG_HOME], [mysql_config], [no])
  251. fi
  252. AC_MSG_CHECKING([MySQL library (optional)])
  253. if test "$MYSQL_CONFIG_HOME" != "no" ; then
  254. HAVE_MYSQL="yes"
  255. MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`"
  256. MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --cflags`"
  257. MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`"
  258. AC_MSG_RESULT([yes ($MYSQL_VERSION)])
  259. if test -n "`$MYSQL_CONFIG_HOME --libs | grep -i '\-m64'`"; then
  260. AC_MSG_ERROR([$MYSQL_CONFIG_HOME reported that MySQL was compiled in 64bit mode, please specify a 32bit distribution of MySQL with --with-mysql=<path>... stopping])
  261. fi
  262. else
  263. AC_MSG_RESULT([no])
  264. if test "$require_mysql" = "yes" ; then
  265. AC_MSG_ERROR([MySQL not found (requested)])
  266. else
  267. AC_MSG_NOTICE([disabling MySQL (optional)])
  268. fi
  269. fi
  270. fi
  271. AC_SUBST([HAVE_MYSQL])
  272. AC_SUBST([MYSQL_VERSION])
  273. AC_SUBST([MYSQL_CFLAGS])
  274. AC_SUBST([MYSQL_LIBS])
  275. dnl
  276. dnl Check PCRE libraries (optional)
  277. dnl
  278. ##TODO PCRE version
  279. PCRE_LIBS=""
  280. PCRE_CFLAGS=""
  281. if test "$want_pcre" = "no" ; then
  282. AC_MSG_NOTICE([ignoring PCRE (optional)])
  283. else
  284. if test -z "$PCRE_HOME" ; then
  285. AC_CHECK_LIB([pcre], [pcre_study], [HAVE_PCRE="yes"], [])
  286. if test "$HAVE_PCRE" = "yes" ; then
  287. PCRE_LIBS="-lpcre"
  288. fi
  289. else
  290. PCRE_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS -L$PCRE_HOME/lib"
  291. PCRE_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS -I$PCRE_HOME/include"
  292. AC_CHECK_LIB(pcre, pcre_compile, [HAVE_PCRE="yes"], [])
  293. CPPFLAGS="$PCRE_OLD_CPPFLAGS"
  294. LDFLAGS="$PCRE_OLD_LDFLAGS"
  295. if test "$HAVE_PCRE" = "yes" ; then
  296. PCRE_LIBS="-L$PCRE_HOME/lib -lpcre"
  297. test -d "$PCRE_HOME/include" && PCRE_CFLAGS="-I$PCRE_HOME/include"
  298. fi
  299. fi
  300. AC_MSG_CHECKING([PCRE library (optional)])
  301. if test "$HAVE_PCRE" = "yes" ; then
  302. AC_MSG_RESULT([yes])
  303. else
  304. AC_MSG_RESULT([no])
  305. if test "$require_pcre" = "yes" ; then
  306. AC_MSG_ERROR([PCRE not found (requested)])
  307. else
  308. AC_MSG_NOTICE([disabling PCRE (optional)])
  309. fi
  310. fi
  311. fi
  312. AC_SUBST([HAVE_PCRE])
  313. AC_SUBST([PCRE_LIBS])
  314. AC_SUBST([PCRE_CFLAGS])
  315. dnl
  316. dnl zlib library (required)
  317. dnl
  318. if test -n "${ZLIB_HOME}" ; then
  319. LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
  320. CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
  321. fi
  322. AC_CHECK_LIB([z], [inflateEnd], ,[AC_MSG_ERROR([zlib library not found, please specify the correct path with --with-zlib=DIR... stopping])])
  323. AC_CHECK_HEADER([zlib.h], , [AC_MSG_ERROR([zlib header not found, please specify the correct path with --with-zlib=DIR... stopping])])
  324. dnl
  325. dnl math library (required)
  326. dnl
  327. AC_CHECK_LIB([m], [sqrt], [], [AC_MSG_ERROR([math library not found... stopping])])
  328. dnl
  329. dnl Host specific stuff
  330. dnl
  331. AC_MSG_CHECKING([host OS])
  332. host_os="`uname`"
  333. AC_MSG_RESULT([$host_os])
  334. fd_setsize=""
  335. DLLEXT=".so"
  336. case $host_os in
  337. Solaris* )
  338. LIBS="$LIBS -lsocket -lnsl -ldl"
  339. ;;
  340. Linux* )
  341. LIBS="$LIBS -ldl"
  342. ;;
  343. FreeBSD*)
  344. CPPFLAGS="$CPPFLAGS -D__FREEBSD__"
  345. ;;
  346. NetBSD*)
  347. CPPFLAGS="$CPPFLAGS -D__NETBSD__"
  348. ;;
  349. CYGWIN*)
  350. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096 -DCYGWIN"
  351. fd_setsize="done"
  352. DLLEXT=".dll"
  353. ;;
  354. esac
  355. AC_SUBST([DLLEXT])
  356. AC_MSG_CHECKING([for MinGW])
  357. if test -n "`$CC --version | grep -i mingw`" ; then
  358. AC_MSG_RESULT([yes])
  359. CPPFLAGS="$CPPFLAGS -DMINGW"
  360. if test -z "$fd_setsize" ; then
  361. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096"
  362. fi
  363. LIBS="$LIBS -lws2_32"
  364. else
  365. AC_MSG_RESULT([no])
  366. fi
  367. ###############################################################################
  368. AC_OUTPUT