configure.in 6.6 KB

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