configure.in 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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. # Enable/disable MySql and optionally specify the path (optional library)
  13. #
  14. AC_ARG_WITH(
  15. [mysql],
  16. AC_HELP_STRING(
  17. [--with-mysql=@<:@ARG@:>@],
  18. [use MySQL client library @<:@default=yes@:>@, optionally specify path to the mysql_config executable]
  19. ),
  20. [
  21. if test "$withval" = "no" ; then
  22. want_mysql="no"
  23. else
  24. want_mysql="yes"
  25. require_mysql="yes"
  26. if test "$withval" != "yes" ; then
  27. MYSQL_CONFIG_HOME="$withval"
  28. fi
  29. fi
  30. ],
  31. [want_mysql="yes" require_mysql="no"]
  32. )
  33. #
  34. # Enable/disable PCRE and optionally specify the path (optional library)
  35. #
  36. AC_ARG_WITH(
  37. [pcre],
  38. AC_HELP_STRING(
  39. [--with-pcre=@<:@ARG@:>@],
  40. [use PCRE library @<:@default=yes@:>@, optionally specify the root directory path of pcre installation]
  41. ),
  42. [
  43. if test "$withval" = "no" ; then
  44. want_pcre="no"
  45. else
  46. want_pcre="yes"
  47. require_pcre="yes"
  48. if test "$withval" != "yes" ; then
  49. PCRE_HOME="$withval"
  50. fi
  51. fi
  52. ],
  53. [want_pcre="yes" require_pcre="no"]
  54. )
  55. #
  56. # Specify the path of the zlib library (required library)
  57. #
  58. AC_ARG_WITH(
  59. [zlib],
  60. AC_HELP_STRING(
  61. [--with-zlib=DIR],
  62. [root directory path of zlib installation (defaults to /usr/local or /usr if not found in /usr/local)]
  63. ),
  64. [
  65. test -n "$withval" && ZLIB_HOME="$withval"
  66. ],
  67. [
  68. ZLIB_HOME=/usr/local
  69. test ! -f "${ZLIB_HOME}/include/zlib.h" && ZLIB_HOME=/usr
  70. ]
  71. )
  72. ###############################################################################
  73. # Checks for programs and types.
  74. AC_PROG_MAKE_SET
  75. AC_PROG_CC
  76. AC_PROG_CPP
  77. AC_LANG([C])
  78. CFLAGS="$CFLAGS -pipe -ffast-math -Wall -Wno-sign-compare"
  79. CPPFLAGS="$CPPFLAGS -I../common"
  80. AC_C_BIGENDIAN(
  81. [AC_MSG_ERROR([[bigendian is not supported... stopping]])],
  82. ,
  83. [AC_MSG_WARN([[unable to determine endianess, only little endian is supported]])]
  84. )
  85. AC_MSG_CHECKING([whether pointers can be stored in ints (old code)])
  86. pointers_fit_in_ints="no"
  87. AC_COMPILE_IFELSE(
  88. [AC_LANG_PROGRAM([[int hw[(sizeof(int) == sizeof(void *))];]])],
  89. [pointers_fit_in_ints="yes"],
  90. []
  91. )
  92. if test "$pointers_fit_in_ints" = "no" ; then
  93. CFLAGS="$CFLAGS -m32"
  94. AC_COMPILE_IFELSE(
  95. [AC_LANG_PROGRAM([[int hw[(sizeof(int) == sizeof(void *))];]])],
  96. [pointers_fit_in_ints="yes (with -m32)"],
  97. []
  98. )
  99. fi
  100. AC_MSG_RESULT($pointers_fit_in_ints)
  101. if test "$pointers_fit_in_ints" = "no" ; then
  102. AC_MSG_ERROR([pointers cannot be stored in ints, required for old code... stopping])
  103. fi
  104. AC_MSG_CHECKING([whether $CC supports -Wno-unused-parameter])
  105. OLD_CFLAGS="$CFLAGS"
  106. CFLAGS="$CFLAGS -Wno-unused-parameter"
  107. AC_COMPILE_IFELSE(
  108. [int foo;],
  109. [AC_MSG_RESULT([yes])],
  110. [
  111. AC_MSG_RESULT([no])
  112. CFLAGS="$OLD_CFLAGS"
  113. ]
  114. )
  115. AC_MSG_CHECKING([whether $CC supports -Wno-pointer-sign])
  116. OLD_CFLAGS="$CFLAGS"
  117. CFLAGS="$CFLAGS -Wno-pointer-sign"
  118. AC_COMPILE_IFELSE(
  119. [int foo;],
  120. [AC_MSG_RESULT([yes])],
  121. [
  122. AC_MSG_RESULT([no])
  123. CFLAGS="$OLD_CFLAGS"
  124. ]
  125. )
  126. ###############################################################################
  127. # Checks for libraries and header files.
  128. dnl
  129. dnl Check MySQL library (optional)
  130. dnl
  131. MYSQL_VERSION=""
  132. MYSQL_CFLAGS=""
  133. MYSQL_LIBS=""
  134. if test "$want_mysql" = "no" ; then
  135. AC_MSG_NOTICE([ignoring MySQL (optional)])
  136. else
  137. if test -z "$MYSQL_CONFIG_HOME"; then
  138. AC_PATH_PROG([MYSQL_CONFIG_HOME], [mysql_config], [no])
  139. fi
  140. AC_MSG_CHECKING([MySQL library (optional)])
  141. if test "$MYSQL_CONFIG_HOME" != "no" ; then
  142. HAVE_MYSQL="yes"
  143. MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`"
  144. MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --cflags`"
  145. MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`"
  146. AC_MSG_RESULT([yes ($MYSQL_VERSION)])
  147. if test -n "`$MYSQL_CONFIG_HOME --libs | grep -i '\-m64'`"; then
  148. 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])
  149. fi
  150. else
  151. AC_MSG_RESULT([no])
  152. if test "$require_mysql" = "yes" ; then
  153. AC_MSG_ERROR([MySQL not found (requested)])
  154. else
  155. AC_MSG_NOTICE([disabling MySQL (optional)])
  156. fi
  157. fi
  158. fi
  159. AC_SUBST([HAVE_MYSQL])
  160. AC_SUBST([MYSQL_VERSION])
  161. AC_SUBST([MYSQL_CFLAGS])
  162. AC_SUBST([MYSQL_LIBS])
  163. dnl
  164. dnl Check PCRE libraries (optional)
  165. dnl
  166. ##TODO PCRE version
  167. PCRE_LIBS=""
  168. PCRE_CFLAGS=""
  169. if test "$want_pcre" = "no" ; then
  170. AC_MSG_NOTICE([ignoring PCRE (optional)])
  171. else
  172. if test -z "$PCRE_HOME" ; then
  173. AC_CHECK_LIB([pcre], [pcre_study], [HAVE_PCRE="yes"], [])
  174. if test "$HAVE_PCRE" = "yes" ; then
  175. PCRE_LIBS="-lpcre"
  176. fi
  177. else
  178. PCRE_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS -L$PCRE_HOME/lib"
  179. PCRE_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS -I$PCRE_HOME/include"
  180. AC_CHECK_LIB(pcre, pcre_compile, [HAVE_PCRE="yes"], [])
  181. CPPFLAGS="$PCRE_OLD_CPPFLAGS"
  182. LDFLAGS="$PCRE_OLD_LDFLAGS"
  183. if test "$HAVE_PCRE" = "yes" ; then
  184. PCRE_LIBS="-L$PCRE_HOME/lib -lpcre"
  185. test -d "$PCRE_HOME/include" && PCRE_CFLAGS="-I$PCRE_HOME/include"
  186. fi
  187. fi
  188. AC_MSG_CHECKING([PCRE library (optional)])
  189. if test "$HAVE_PCRE" = "yes" ; then
  190. AC_MSG_RESULT([yes])
  191. else
  192. AC_MSG_RESULT([no])
  193. if test "$require_pcre" = "yes" ; then
  194. AC_MSG_ERROR([PCRE not found (requested)])
  195. else
  196. AC_MSG_NOTICE([disabling PCRE (optional)])
  197. fi
  198. fi
  199. fi
  200. AC_SUBST([HAVE_PCRE])
  201. AC_SUBST([PCRE_LIBS])
  202. AC_SUBST([PCRE_CFLAGS])
  203. dnl
  204. dnl zlib library (required)
  205. dnl
  206. if test -n "${ZLIB_HOME}" ; then
  207. LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
  208. CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
  209. fi
  210. AC_CHECK_LIB([z], [inflateEnd], ,[AC_MSG_ERROR([zlib library not found, please specify the correct path with --with-zlib=DIR... stopping])])
  211. AC_CHECK_HEADER([zlib.h], , [AC_MSG_ERROR([zlib header not found, please specify the correct path with --with-zlib=DIR... stopping])])
  212. dnl
  213. dnl math library (required)
  214. dnl
  215. AC_CHECK_LIB([m], [sqrt], [], [AC_MSG_ERROR([math library not found... stopping])])
  216. dnl
  217. dnl Host specific stuff
  218. dnl
  219. AC_MSG_CHECKING([host OS])
  220. host_os="`uname`"
  221. AC_MSG_RESULT([$host_os])
  222. fd_setsize=""
  223. DLLEXT=".so"
  224. case $host_os in
  225. Solaris* )
  226. LIBS="$LIBS -lsocket -lnsl -ldl"
  227. ;;
  228. Linux* )
  229. LIBS="$LIBS -ldl"
  230. ;;
  231. FreeBSD*)
  232. CPPFLAGS="$CPPFLAGS -D__FREEBSD__"
  233. ;;
  234. NetBSD*)
  235. CPPFLAGS="$CPPFLAGS -D__NETBSD__"
  236. ;;
  237. CYGWIN*)
  238. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096 -DCYGWIN"
  239. fd_setsize="done"
  240. DLLEXT=".dll"
  241. ;;
  242. esac
  243. AC_SUBST([DLLEXT])
  244. AC_MSG_CHECKING([for MinGW])
  245. if test -n "`$CC --version | grep -i mingw`" ; then
  246. AC_MSG_RESULT([yes])
  247. CPPFLAGS="$CPPFLAGS -DMINGW"
  248. if test -z "$fd_setsize" ; then
  249. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096"
  250. fi
  251. LIBS="$LIBS -lws2_32"
  252. else
  253. AC_MSG_RESULT([no])
  254. fi
  255. ###############################################################################
  256. AC_OUTPUT