configure.in 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  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 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 to mysql_config (optional library)
  74. #
  75. AC_ARG_WITH(
  76. [mysql],
  77. AC_HELP_STRING(
  78. [--with-mysql@<:@=ARG@:>@],
  79. [use MySQL client library, optionally specify the 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. if test ! -x "$withval" ; then
  89. AC_MSG_ERROR([$withval is not an executable file])
  90. fi
  91. MYSQL_CONFIG_HOME="$withval"
  92. fi
  93. fi
  94. ],
  95. [want_mysql="yes" require_mysql="no"]
  96. )
  97. #
  98. # Enable/disable PCRE and optionally specify the path (optional library)
  99. #
  100. AC_ARG_WITH(
  101. [pcre],
  102. AC_HELP_STRING(
  103. [--with-pcre@<:@=ARG@:>@],
  104. [use PCRE library, optionally specify the full path of pcre installation directory (by default pcre is used if found)]
  105. ),
  106. [
  107. if test "$withval" = "no" ; then
  108. want_pcre="no"
  109. else
  110. want_pcre="yes"
  111. require_pcre="yes"
  112. if test "$withval" != "yes" ; then
  113. if test ! -d "$withval" ; then
  114. AC_MSG_ERROR([$withval is not a directoy])
  115. fi
  116. PCRE_HOME="$withval"
  117. fi
  118. fi
  119. ],
  120. [want_pcre="yes" require_pcre="no"]
  121. )
  122. #
  123. # Specify the path of the zlib library (required library)
  124. #
  125. AC_ARG_WITH(
  126. [zlib],
  127. AC_HELP_STRING(
  128. [--with-zlib=DIR],
  129. [root directory path of zlib installation (defaults to /usr/local or /usr if not found in /usr/local)]
  130. ),
  131. [
  132. test -n "$withval" && ZLIB_HOME="$withval"
  133. ],
  134. [
  135. ZLIB_HOME=/usr/local
  136. test ! -f "${ZLIB_HOME}/include/zlib.h" && ZLIB_HOME=/usr
  137. ]
  138. )
  139. ###############################################################################
  140. # Check for programs and types.
  141. #
  142. AC_PROG_MAKE_SET
  143. AC_PROG_CC
  144. AC_PROG_CPP
  145. AC_LANG([C])
  146. CFLAGS="$CFLAGS -pipe -ffast-math -Wall -Wno-sign-compare"
  147. CPPFLAGS="$CPPFLAGS -I../common"
  148. AC_C_BIGENDIAN(
  149. [AC_MSG_ERROR([[bigendian is not supported... stopping]])],
  150. ,
  151. [AC_MSG_WARN([[unable to determine endianess, only little endian is supported]])]
  152. )
  153. AC_MSG_CHECKING([whether pointers can be stored in ints (old code)])
  154. pointers_fit_in_ints="no"
  155. AC_COMPILE_IFELSE(
  156. [AC_LANG_PROGRAM([[static int test_array[((long int)sizeof(int)) == ((long int)sizeof(void*)) ? 1 : -1];]])],
  157. [pointers_fit_in_ints="yes"],
  158. []
  159. )
  160. if test "$pointers_fit_in_ints" = "no" ; then
  161. CFLAGS="$CFLAGS -m32"
  162. LDFLAGS="$LDFLAGS -m32"
  163. AC_COMPILE_IFELSE(
  164. [AC_LANG_PROGRAM([[static int test_array[((long int)sizeof(int)) == ((long int)sizeof(void *)) ? 1 : -1];]])],
  165. [pointers_fit_in_ints="yes (with -m32)"],
  166. []
  167. )
  168. fi
  169. AC_MSG_RESULT($pointers_fit_in_ints)
  170. if test "$pointers_fit_in_ints" = "no" ; then
  171. AC_MSG_ERROR([pointers cannot be stored in ints, required for old code... stopping])
  172. fi
  173. AC_MSG_CHECKING([whether $CC supports -Wno-unused-parameter])
  174. OLD_CFLAGS="$CFLAGS"
  175. CFLAGS="$CFLAGS -Wno-unused-parameter"
  176. AC_COMPILE_IFELSE(
  177. [int foo;],
  178. [AC_MSG_RESULT([yes])],
  179. [
  180. AC_MSG_RESULT([no])
  181. CFLAGS="$OLD_CFLAGS"
  182. ]
  183. )
  184. AC_MSG_CHECKING([whether $CC supports -Wno-pointer-sign])
  185. OLD_CFLAGS="$CFLAGS"
  186. CFLAGS="$CFLAGS -Wno-pointer-sign"
  187. AC_COMPILE_IFELSE(
  188. [int foo;],
  189. [AC_MSG_RESULT([yes])],
  190. [
  191. AC_MSG_RESULT([no])
  192. CFLAGS="$OLD_CFLAGS"
  193. ]
  194. )
  195. AC_MSG_CHECKING([whether $CC supports -Wno-switch])
  196. OLD_CFLAGS="$CFLAGS"
  197. CFLAGS="$CFLAGS -Wno-switch"
  198. AC_COMPILE_IFELSE(
  199. [int foo;],
  200. [AC_MSG_RESULT([yes])],
  201. [
  202. AC_MSG_RESULT([no])
  203. CFLAGS="$OLD_CFLAGS"
  204. ]
  205. )
  206. ###############################################################################
  207. # Check for libraries and header files.
  208. #
  209. #
  210. # Memory manager
  211. #
  212. case $enableval in
  213. "no")
  214. CFLAGS="$CFLAGS -DNO_MEMMGR"
  215. ;;
  216. "builtin")
  217. # enabled by default
  218. ;;
  219. "memwatch")
  220. CFLAGS="$CFLAGS -DMEMWATCH"
  221. AC_CHECK_HEADER([memwatch.h], , [AC_MSG_ERROR([memwatch header not found... stopping])])
  222. ;;
  223. "dmalloc")
  224. CFLAGS="$CFLAGS -DDMALLOC -DDMALLOC_FUNC_CHECK"
  225. LIBS="$LIBS -ldmalloc"
  226. AC_CHECK_HEADER([dmalloc.h], , [AC_MSG_ERROR([dmalloc header not found... stopping])])
  227. ;;
  228. "gcollect")
  229. CFLAGS="$CFLAGS -DGCOLLECT"
  230. LIBS="$LIBS -lgc"
  231. AC_CHECK_HEADER([gc.h], , [AC_MSG_ERROR([gcollect header not found... stopping])])
  232. ;;
  233. "bcheck")
  234. CFLAGS="$CFLAGS -DBCHECK"
  235. ;;
  236. esac
  237. #
  238. # Mapregsql
  239. #
  240. if test "$enable_mapregsql" = "yes" ; then
  241. CFLAGS="$CFLAGS -DMAPREGSQL"
  242. fi
  243. #
  244. # Debug
  245. #
  246. if test "$enable_debug" = "yes" ; then
  247. CFLAGS="$CFLAGS -DDEBUG"
  248. fi
  249. #
  250. # zlib library (required)
  251. #
  252. if test -n "${ZLIB_HOME}" ; then
  253. LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
  254. CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
  255. fi
  256. AC_CHECK_LIB([z], [inflateEnd], [],[AC_MSG_ERROR([zlib library not found or incompatible, please specify the correct path with --with-zlib=DIR... stopping])])
  257. AC_CHECK_HEADER([zlib.h], [], [AC_MSG_ERROR([zlib header not found, please specify the correct path with --with-zlib=DIR... stopping])])
  258. #
  259. # math library (required)
  260. #
  261. AC_CHECK_LIB([m], [sqrt], [], [AC_MSG_ERROR([math library not found... stopping])])
  262. #
  263. # clock_gettime (rt on Debian)
  264. #
  265. AC_CHECK_LIB([rt], [clock_gettime])
  266. #
  267. # MySQL library (optional)
  268. #
  269. MYSQL_VERSION=""
  270. MYSQL_CFLAGS=""
  271. MYSQL_LIBS=""
  272. if test "$want_mysql" = "no" ; then
  273. AC_MSG_NOTICE([ignoring MySQL (optional)])
  274. else
  275. if test -z "$MYSQL_CONFIG_HOME"; then
  276. AC_PATH_PROG([MYSQL_CONFIG_HOME], [mysql_config], [no])
  277. fi
  278. if test "$MYSQL_CONFIG_HOME" != "no" ; then
  279. MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`"
  280. MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --include`"
  281. MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`"
  282. MYSQL_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS $MYSQL_LIBS"
  283. MYSQL_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS"
  284. AC_CHECK_LIB([mysqlclient], [mysql_init], [HAVE_MYSQL="yes"], [])
  285. AC_CHECK_HEADER([mysql.h], [], [HAVE_MYSQL=""])
  286. CPPFLAGS="$MYSQL_OLD_CPPFLAGS"
  287. LDFLAGS="$MYSQL_OLD_LDFLAGS"
  288. fi
  289. AC_MSG_CHECKING([MySQL library (optional)])
  290. if test "$HAVE_MYSQL" = "yes" ; then
  291. AC_MSG_RESULT([yes ($MYSQL_VERSION)])
  292. else
  293. AC_MSG_RESULT([no])
  294. if test "$require_mysql" = "yes" ; then
  295. AC_MSG_ERROR([MySQL not found or incompatible (requested)])
  296. else
  297. AC_MSG_NOTICE([disabling MySQL (optional)])
  298. MYSQL_VERSION=""
  299. MYSQL_CFLAGS=""
  300. MYSQL_LIBS=""
  301. fi
  302. fi
  303. fi
  304. AC_SUBST([HAVE_MYSQL])
  305. AC_SUBST([MYSQL_VERSION])
  306. AC_SUBST([MYSQL_CFLAGS])
  307. AC_SUBST([MYSQL_LIBS])
  308. #
  309. # PCRE library (optional)
  310. #
  311. ##TODO PCRE version
  312. PCRE_LIBS=""
  313. PCRE_CFLAGS=""
  314. if test "$want_pcre" = "no" ; then
  315. AC_MSG_NOTICE([ignoring PCRE (optional)])
  316. else
  317. if test -z "$PCRE_HOME" ; then
  318. AC_CHECK_LIB([pcre], [pcre_study], [HAVE_PCRE="yes"], [])
  319. if test "$HAVE_PCRE" = "yes" ; then
  320. PCRE_LIBS="-lpcre"
  321. fi
  322. else
  323. PCRE_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS -L$PCRE_HOME/lib"
  324. PCRE_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS -I$PCRE_HOME/include"
  325. AC_CHECK_LIB(pcre, pcre_compile, [HAVE_PCRE="yes"], [])
  326. CPPFLAGS="$PCRE_OLD_CPPFLAGS"
  327. LDFLAGS="$PCRE_OLD_LDFLAGS"
  328. if test "$HAVE_PCRE" = "yes" ; then
  329. PCRE_LIBS="-L$PCRE_HOME/lib -lpcre"
  330. test -d "$PCRE_HOME/include" && PCRE_CFLAGS="-I$PCRE_HOME/include"
  331. fi
  332. fi
  333. AC_MSG_CHECKING([PCRE library (optional)])
  334. if test "$HAVE_PCRE" = "yes" ; then
  335. AC_MSG_RESULT([yes])
  336. else
  337. AC_MSG_RESULT([no])
  338. if test "$require_pcre" = "yes" ; then
  339. AC_MSG_ERROR([PCRE not found or incompatible (requested)])
  340. else
  341. AC_MSG_NOTICE([disabling PCRE (optional)])
  342. fi
  343. fi
  344. fi
  345. AC_SUBST([HAVE_PCRE])
  346. AC_SUBST([PCRE_LIBS])
  347. AC_SUBST([PCRE_CFLAGS])
  348. #
  349. # Host specific stuff
  350. #
  351. AC_MSG_CHECKING([host OS])
  352. host_os="`uname`"
  353. AC_MSG_RESULT([$host_os])
  354. fd_setsize=""
  355. DLLEXT=".so"
  356. case $host_os in
  357. Solaris* )
  358. LIBS="$LIBS -lsocket -lnsl -ldl"
  359. ;;
  360. Linux* )
  361. LIBS="$LIBS -ldl"
  362. ;;
  363. FreeBSD*)
  364. CPPFLAGS="$CPPFLAGS -D__FREEBSD__"
  365. ;;
  366. NetBSD*)
  367. CPPFLAGS="$CPPFLAGS -D__NETBSD__"
  368. ;;
  369. CYGWIN*)
  370. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096 -DCYGWIN"
  371. fd_setsize="done"
  372. DLLEXT=".dll"
  373. ;;
  374. esac
  375. AC_SUBST([DLLEXT])
  376. AC_MSG_CHECKING([for MinGW])
  377. if test -n "`$CC --version | grep -i mingw`" ; then
  378. AC_MSG_RESULT([yes])
  379. CPPFLAGS="$CPPFLAGS -DMINGW"
  380. if test -z "$fd_setsize" ; then
  381. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096"
  382. fi
  383. LIBS="$LIBS -lws2_32"
  384. else
  385. AC_MSG_RESULT([no])
  386. fi
  387. ###############################################################################
  388. AC_OUTPUT