configure.in 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  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. # MySQL library (optional)
  251. #
  252. MYSQL_VERSION=""
  253. MYSQL_CFLAGS=""
  254. MYSQL_LIBS=""
  255. if test "$want_mysql" = "no" ; then
  256. AC_MSG_NOTICE([ignoring MySQL (optional)])
  257. else
  258. if test -z "$MYSQL_CONFIG_HOME"; then
  259. AC_PATH_PROG([MYSQL_CONFIG_HOME], [mysql_config], [no])
  260. fi
  261. AC_MSG_CHECKING([MySQL library (optional)])
  262. if test "$MYSQL_CONFIG_HOME" != "no" ; then
  263. HAVE_MYSQL="yes"
  264. MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`"
  265. MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --include`"
  266. MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`"
  267. AC_MSG_RESULT([yes ($MYSQL_VERSION)])
  268. if test -n "`$MYSQL_CONFIG_HOME --cflags | grep -i '\-m64'`"; then
  269. AC_MSG_ERROR([$MYSQL_CONFIG_HOME reported a 64 bit MySQL, please specify a 32bit version with --with-mysql=<path to mysql_config>... stopping])
  270. fi
  271. else
  272. AC_MSG_RESULT([no])
  273. if test "$require_mysql" = "yes" ; then
  274. AC_MSG_ERROR([MySQL not found (requested)])
  275. else
  276. AC_MSG_NOTICE([disabling MySQL (optional)])
  277. fi
  278. fi
  279. fi
  280. AC_SUBST([HAVE_MYSQL])
  281. AC_SUBST([MYSQL_VERSION])
  282. AC_SUBST([MYSQL_CFLAGS])
  283. AC_SUBST([MYSQL_LIBS])
  284. #
  285. # PCRE library (optional)
  286. #
  287. ##TODO PCRE version
  288. PCRE_LIBS=""
  289. PCRE_CFLAGS=""
  290. if test "$want_pcre" = "no" ; then
  291. AC_MSG_NOTICE([ignoring PCRE (optional)])
  292. else
  293. if test -z "$PCRE_HOME" ; then
  294. AC_CHECK_LIB([pcre], [pcre_study], [HAVE_PCRE="yes"], [])
  295. if test "$HAVE_PCRE" = "yes" ; then
  296. PCRE_LIBS="-lpcre"
  297. fi
  298. else
  299. PCRE_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS -L$PCRE_HOME/lib"
  300. PCRE_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS -I$PCRE_HOME/include"
  301. AC_CHECK_LIB(pcre, pcre_compile, [HAVE_PCRE="yes"], [])
  302. CPPFLAGS="$PCRE_OLD_CPPFLAGS"
  303. LDFLAGS="$PCRE_OLD_LDFLAGS"
  304. if test "$HAVE_PCRE" = "yes" ; then
  305. PCRE_LIBS="-L$PCRE_HOME/lib -lpcre"
  306. test -d "$PCRE_HOME/include" && PCRE_CFLAGS="-I$PCRE_HOME/include"
  307. fi
  308. fi
  309. AC_MSG_CHECKING([PCRE library (optional)])
  310. if test "$HAVE_PCRE" = "yes" ; then
  311. AC_MSG_RESULT([yes])
  312. else
  313. AC_MSG_RESULT([no])
  314. if test "$require_pcre" = "yes" ; then
  315. AC_MSG_ERROR([PCRE not found (requested)])
  316. else
  317. AC_MSG_NOTICE([disabling PCRE (optional)])
  318. fi
  319. fi
  320. fi
  321. AC_SUBST([HAVE_PCRE])
  322. AC_SUBST([PCRE_LIBS])
  323. AC_SUBST([PCRE_CFLAGS])
  324. #
  325. # zlib library (required)
  326. #
  327. if test -n "${ZLIB_HOME}" ; then
  328. LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
  329. CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
  330. fi
  331. AC_CHECK_LIB([z], [inflateEnd], ,[AC_MSG_ERROR([zlib library not found, please specify the correct path with --with-zlib=DIR... stopping])])
  332. AC_CHECK_HEADER([zlib.h], , [AC_MSG_ERROR([zlib header not found, please specify the correct path with --with-zlib=DIR... stopping])])
  333. #
  334. # math library (required)
  335. #
  336. AC_CHECK_LIB([m], [sqrt], [], [AC_MSG_ERROR([math library not found... stopping])])
  337. #
  338. # Host specific stuff
  339. #
  340. AC_MSG_CHECKING([host OS])
  341. host_os="`uname`"
  342. AC_MSG_RESULT([$host_os])
  343. fd_setsize=""
  344. DLLEXT=".so"
  345. case $host_os in
  346. Solaris* )
  347. LIBS="$LIBS -lsocket -lnsl -ldl"
  348. ;;
  349. Linux* )
  350. LIBS="$LIBS -ldl"
  351. ;;
  352. FreeBSD*)
  353. CPPFLAGS="$CPPFLAGS -D__FREEBSD__"
  354. ;;
  355. NetBSD*)
  356. CPPFLAGS="$CPPFLAGS -D__NETBSD__"
  357. ;;
  358. CYGWIN*)
  359. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096 -DCYGWIN"
  360. fd_setsize="done"
  361. DLLEXT=".dll"
  362. ;;
  363. esac
  364. AC_SUBST([DLLEXT])
  365. AC_MSG_CHECKING([for MinGW])
  366. if test -n "`$CC --version | grep -i mingw`" ; then
  367. AC_MSG_RESULT([yes])
  368. CPPFLAGS="$CPPFLAGS -DMINGW"
  369. if test -z "$fd_setsize" ; then
  370. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096"
  371. fi
  372. LIBS="$LIBS -lws2_32"
  373. else
  374. AC_MSG_RESULT([no])
  375. fi
  376. ###############################################################################
  377. AC_OUTPUT