configure.in 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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="$CPPFLAGS -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" -o test; 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. else
  146. AC_MSG_RESULT([no])
  147. AC_MSG_NOTICE([disabling MySQL (optional)])
  148. fi
  149. fi
  150. AC_SUBST([HAVE_MYSQL])
  151. AC_SUBST([MYSQL_VERSION])
  152. AC_SUBST([MYSQL_CFLAGS])
  153. AC_SUBST([MYSQL_LIBS])
  154. dnl
  155. dnl Check PCRE libraries (optional)
  156. dnl
  157. ##TODO PCRE version
  158. PCRE_LIBS=""
  159. PCRE_CFLAGS=""
  160. if test "$want_pcre" = "no" ; then
  161. AC_MSG_NOTICE([ignoring PCRE (optional)])
  162. else
  163. if test -z "$PCRE_HOME" ; then
  164. AC_CHECK_LIB([pcre], [pcre_study], [HAVE_PCRE="yes"], [])
  165. if test "$HAVE_PCRE" = "yes" ; then
  166. PCRE_LIBS="-lpcre"
  167. fi
  168. else
  169. PCRE_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS -L$PCRE_HOME/lib"
  170. PCRE_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS -I$PCRE_HOME/include"
  171. AC_CHECK_LIB(pcre, pcre_compile, [HAVE_PCRE="yes"], [])
  172. CPPFLAGS="$PCRE_OLD_CPPFLAGS"
  173. LDFLAGS="$PCRE_OLD_LDFLAGS"
  174. if test "$HAVE_PCRE" = "yes" ; then
  175. PCRE_LIBS="-L$PCRE_HOME/lib -lpcre"
  176. test -d "$PCRE_HOME/include" && PCRE_CFLAGS="-I$PCRE_HOME/include"
  177. fi
  178. fi
  179. AC_MSG_CHECKING([PCRE library (optional)])
  180. if test "$HAVE_PCRE" = "yes" ; then
  181. AC_MSG_RESULT([yes])
  182. else
  183. AC_MSG_RESULT([no])
  184. AC_MSG_NOTICE([disabling PCRE (optional)])
  185. fi
  186. fi
  187. AC_SUBST([HAVE_PCRE])
  188. AC_SUBST([PCRE_LIBS])
  189. AC_SUBST([PCRE_CFLAGS])
  190. dnl
  191. dnl zlib library (required)
  192. dnl
  193. if test -n "${ZLIB_HOME}" ; then
  194. LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
  195. CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
  196. fi
  197. AC_CHECK_LIB([z], [inflateEnd], ,[AC_MSG_ERROR([zlib library not found, please specify the correct path with --with-zlib=DIR... stopping])])
  198. AC_CHECK_HEADER([zlib.h], , [AC_MSG_ERROR([zlib header not found, please specify the correct path with --with-zlib=DIR... stopping])])
  199. dnl
  200. dnl math library (required)
  201. dnl
  202. AC_CHECK_LIB([m], [sqrt], [], [AC_MSG_ERROR([math library not found... stopping])])
  203. dnl
  204. dnl Host specific stuff
  205. dnl
  206. AC_MSG_CHECKING([host OS])
  207. host_os="`uname`"
  208. AC_MSG_RESULT([$host_os])
  209. fd_setsize=""
  210. DLLEXT=".so"
  211. case $host_os in
  212. Solaris* )
  213. LIBS="$LIBS -lsocket -lnsl -ldl"
  214. ;;
  215. Linux* )
  216. LIBS="$LIBS -ldl"
  217. ;;
  218. FreeBSD*)
  219. CPPFLAGS="$CPPFLAGS -D__FREEBSD__"
  220. ;;
  221. NetBSD*)
  222. CPPFLAGS="$CPPFLAGS -D__NETBSD__"
  223. ;;
  224. CYGWIN*)
  225. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096 -DCYGWIN"
  226. fd_setsize="done"
  227. DLLEXT=".dll"
  228. ;;
  229. esac
  230. AC_SUBST([DLLEXT])
  231. AC_MSG_CHECKING([for MinGW])
  232. if test -n "`$CC --version | grep -i mingw`" ; then
  233. AC_MSG_RESULT([yes])
  234. CPPFLAGS="$CPPFLAGS -DMINGW"
  235. if test -z "$fd_setsize" ; then
  236. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096"
  237. fi
  238. LIBS="$LIBS -lws2_32"
  239. else
  240. AC_MSG_RESULT([no])
  241. fi
  242. ###############################################################################
  243. AC_OUTPUT