configure.in 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  1. # -*- Autoconf -*-
  2. # Process this file with autoconf to produce a configure script.
  3. AC_INIT(eAthena)
  4. AC_REVISION($Revision: 11695$)
  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, optionally specify path to the mysql_config executable (by default mysql is used if found)]
  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, optionally specify the root directory path of pcre installation (by default pcre is used if found)]
  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. AC_MSG_CHECKING([whether $CC supports -Wno-switch])
  127. OLD_CFLAGS="$CFLAGS"
  128. CFLAGS="$CFLAGS -Wno-switch"
  129. AC_COMPILE_IFELSE(
  130. [int foo;],
  131. [AC_MSG_RESULT([yes])],
  132. [
  133. AC_MSG_RESULT([no])
  134. CFLAGS="$OLD_CFLAGS"
  135. ]
  136. )
  137. ###############################################################################
  138. # Checks for libraries and header files.
  139. dnl
  140. dnl Check MySQL library (optional)
  141. dnl
  142. MYSQL_VERSION=""
  143. MYSQL_CFLAGS=""
  144. MYSQL_LIBS=""
  145. if test "$want_mysql" = "no" ; then
  146. AC_MSG_NOTICE([ignoring MySQL (optional)])
  147. else
  148. if test -z "$MYSQL_CONFIG_HOME"; then
  149. AC_PATH_PROG([MYSQL_CONFIG_HOME], [mysql_config], [no])
  150. fi
  151. AC_MSG_CHECKING([MySQL library (optional)])
  152. if test "$MYSQL_CONFIG_HOME" != "no" ; then
  153. HAVE_MYSQL="yes"
  154. MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`"
  155. MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --cflags`"
  156. MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`"
  157. AC_MSG_RESULT([yes ($MYSQL_VERSION)])
  158. if test -n "`$MYSQL_CONFIG_HOME --libs | grep -i '\-m64'`"; then
  159. 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])
  160. fi
  161. else
  162. AC_MSG_RESULT([no])
  163. if test "$require_mysql" = "yes" ; then
  164. AC_MSG_ERROR([MySQL not found (requested)])
  165. else
  166. AC_MSG_NOTICE([disabling MySQL (optional)])
  167. fi
  168. fi
  169. fi
  170. AC_SUBST([HAVE_MYSQL])
  171. AC_SUBST([MYSQL_VERSION])
  172. AC_SUBST([MYSQL_CFLAGS])
  173. AC_SUBST([MYSQL_LIBS])
  174. dnl
  175. dnl Check PCRE libraries (optional)
  176. dnl
  177. ##TODO PCRE version
  178. PCRE_LIBS=""
  179. PCRE_CFLAGS=""
  180. if test "$want_pcre" = "no" ; then
  181. AC_MSG_NOTICE([ignoring PCRE (optional)])
  182. else
  183. if test -z "$PCRE_HOME" ; then
  184. AC_CHECK_LIB([pcre], [pcre_study], [HAVE_PCRE="yes"], [])
  185. if test "$HAVE_PCRE" = "yes" ; then
  186. PCRE_LIBS="-lpcre"
  187. fi
  188. else
  189. PCRE_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS -L$PCRE_HOME/lib"
  190. PCRE_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS -I$PCRE_HOME/include"
  191. AC_CHECK_LIB(pcre, pcre_compile, [HAVE_PCRE="yes"], [])
  192. CPPFLAGS="$PCRE_OLD_CPPFLAGS"
  193. LDFLAGS="$PCRE_OLD_LDFLAGS"
  194. if test "$HAVE_PCRE" = "yes" ; then
  195. PCRE_LIBS="-L$PCRE_HOME/lib -lpcre"
  196. test -d "$PCRE_HOME/include" && PCRE_CFLAGS="-I$PCRE_HOME/include"
  197. fi
  198. fi
  199. AC_MSG_CHECKING([PCRE library (optional)])
  200. if test "$HAVE_PCRE" = "yes" ; then
  201. AC_MSG_RESULT([yes])
  202. else
  203. AC_MSG_RESULT([no])
  204. if test "$require_pcre" = "yes" ; then
  205. AC_MSG_ERROR([PCRE not found (requested)])
  206. else
  207. AC_MSG_NOTICE([disabling PCRE (optional)])
  208. fi
  209. fi
  210. fi
  211. AC_SUBST([HAVE_PCRE])
  212. AC_SUBST([PCRE_LIBS])
  213. AC_SUBST([PCRE_CFLAGS])
  214. dnl
  215. dnl zlib library (required)
  216. dnl
  217. if test -n "${ZLIB_HOME}" ; then
  218. LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
  219. CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
  220. fi
  221. AC_CHECK_LIB([z], [inflateEnd], ,[AC_MSG_ERROR([zlib library not found, please specify the correct path with --with-zlib=DIR... stopping])])
  222. AC_CHECK_HEADER([zlib.h], , [AC_MSG_ERROR([zlib header not found, please specify the correct path with --with-zlib=DIR... stopping])])
  223. dnl
  224. dnl math library (required)
  225. dnl
  226. AC_CHECK_LIB([m], [sqrt], [], [AC_MSG_ERROR([math library not found... stopping])])
  227. dnl
  228. dnl Host specific stuff
  229. dnl
  230. AC_MSG_CHECKING([host OS])
  231. host_os="`uname`"
  232. AC_MSG_RESULT([$host_os])
  233. fd_setsize=""
  234. DLLEXT=".so"
  235. case $host_os in
  236. Solaris* )
  237. LIBS="$LIBS -lsocket -lnsl -ldl"
  238. ;;
  239. Linux* )
  240. LIBS="$LIBS -ldl"
  241. ;;
  242. FreeBSD*)
  243. CPPFLAGS="$CPPFLAGS -D__FREEBSD__"
  244. ;;
  245. NetBSD*)
  246. CPPFLAGS="$CPPFLAGS -D__NETBSD__"
  247. ;;
  248. CYGWIN*)
  249. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096 -DCYGWIN"
  250. fd_setsize="done"
  251. DLLEXT=".dll"
  252. ;;
  253. esac
  254. AC_SUBST([DLLEXT])
  255. AC_MSG_CHECKING([for MinGW])
  256. if test -n "`$CC --version | grep -i mingw`" ; then
  257. AC_MSG_RESULT([yes])
  258. CPPFLAGS="$CPPFLAGS -DMINGW"
  259. if test -z "$fd_setsize" ; then
  260. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096"
  261. fi
  262. LIBS="$LIBS -lws2_32"
  263. else
  264. AC_MSG_RESULT([no])
  265. fi
  266. ###############################################################################
  267. AC_OUTPUT