configure.in 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473
  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. # packetver
  36. #
  37. AC_ARG_ENABLE(
  38. [packetver],
  39. AC_HELP_STRING(
  40. [--enable-packetver=ARG],
  41. [Sets the PACKETVER define of the map-server. (see src/map/clif.h)]
  42. ),
  43. [enable_packetver="$enableval"],
  44. [enable_packetver=""]
  45. )
  46. #
  47. # mapregsql
  48. #
  49. AC_ARG_ENABLE(
  50. [mapregsql],
  51. AC_HELP_STRING(
  52. [--enable-mapregsql],
  53. [Makes map-wide script variables be saved to SQL instead of TXT files in the sql map-server. (defauts to no)]
  54. ),
  55. [
  56. enable_mapregsql="$enableval"
  57. case $enableval in
  58. no);;
  59. yes);;
  60. *) AC_MSG_ERROR([[invalid argument --enable-mapregsql=$enable_mapregsql... stopping]]);;
  61. esac
  62. ],
  63. [enable_mapregsql="no"]
  64. )
  65. #
  66. # debug
  67. #
  68. AC_ARG_ENABLE(
  69. [debug],
  70. AC_HELP_STRING(
  71. [--enable-debug],
  72. [Compiles in debug mode. (defauts to no)]
  73. ),
  74. [
  75. enable_debug="$enableval"
  76. case $enableval in
  77. no);;
  78. yes);;
  79. *) AC_MSG_ERROR([[invalid argument --enable-debug=$enable_mapregsql... stopping]]);;
  80. esac
  81. ],
  82. [enable_debug="no"]
  83. )
  84. #
  85. # Enable/disable MySql and optionally specify the path to mysql_config (optional library)
  86. #
  87. AC_ARG_WITH(
  88. [mysql],
  89. AC_HELP_STRING(
  90. [--with-mysql@<:@=ARG@:>@],
  91. [use MySQL client library, optionally specify the path to the mysql_config executable (by default mysql is used if found)]
  92. ),
  93. [
  94. if test "$withval" = "no" ; then
  95. want_mysql="no"
  96. else
  97. want_mysql="yes"
  98. require_mysql="yes"
  99. if test "$withval" != "yes" ; then
  100. if test ! -x "$withval" ; then
  101. AC_MSG_ERROR([$withval is not an executable file])
  102. fi
  103. MYSQL_CONFIG_HOME="$withval"
  104. fi
  105. fi
  106. ],
  107. [want_mysql="yes" require_mysql="no"]
  108. )
  109. #
  110. # Enable/disable PCRE and optionally specify the path (optional library)
  111. #
  112. AC_ARG_WITH(
  113. [pcre],
  114. AC_HELP_STRING(
  115. [--with-pcre@<:@=ARG@:>@],
  116. [use PCRE library, optionally specify the full path of pcre installation directory (by default pcre is used if found)]
  117. ),
  118. [
  119. if test "$withval" = "no" ; then
  120. want_pcre="no"
  121. else
  122. want_pcre="yes"
  123. require_pcre="yes"
  124. if test "$withval" != "yes" ; then
  125. if test ! -d "$withval" ; then
  126. AC_MSG_ERROR([$withval is not a directoy])
  127. fi
  128. PCRE_HOME="$withval"
  129. fi
  130. fi
  131. ],
  132. [want_pcre="yes" require_pcre="no"]
  133. )
  134. #
  135. # Specify the path of the zlib library (required library)
  136. #
  137. AC_ARG_WITH(
  138. [zlib],
  139. AC_HELP_STRING(
  140. [--with-zlib=DIR],
  141. [root directory path of zlib installation (defaults to /usr/local or /usr if not found in /usr/local).
  142. Assumes that the header files are in DIR/include and the library files are in DIR/lib]
  143. ),
  144. [
  145. test -n "$withval" && ZLIB_HOME="$withval"
  146. ],
  147. [
  148. ZLIB_HOME=/usr/local
  149. test ! -f "${ZLIB_HOME}/include/zlib.h" && ZLIB_HOME=/usr
  150. ]
  151. )
  152. ###############################################################################
  153. # Check for programs and types.
  154. #
  155. AC_PROG_MAKE_SET
  156. AC_PROG_CC
  157. AC_PROG_CPP
  158. AC_LANG([C])
  159. CFLAGS="$CFLAGS -pipe -ffast-math -Wall -Wno-sign-compare"
  160. CPPFLAGS="$CPPFLAGS -I../common"
  161. AC_C_BIGENDIAN(
  162. [AC_MSG_ERROR([[bigendian is not supported... stopping]])],
  163. ,
  164. [AC_MSG_WARN([[unable to determine endianess, only little endian is supported]])]
  165. )
  166. AC_MSG_CHECKING([whether pointers can be stored in ints (old code)])
  167. pointers_fit_in_ints="no"
  168. AC_COMPILE_IFELSE(
  169. [AC_LANG_PROGRAM([[static int test_array[((long int)sizeof(int)) == ((long int)sizeof(void*)) ? 1 : -1];]])],
  170. [pointers_fit_in_ints="yes"],
  171. []
  172. )
  173. if test "$pointers_fit_in_ints" = "no" ; then
  174. CFLAGS="$CFLAGS -m32"
  175. LDFLAGS="$LDFLAGS -m32"
  176. AC_COMPILE_IFELSE(
  177. [AC_LANG_PROGRAM([[static int test_array[((long int)sizeof(int)) == ((long int)sizeof(void *)) ? 1 : -1];]])],
  178. [pointers_fit_in_ints="yes (with -m32)"],
  179. []
  180. )
  181. fi
  182. AC_MSG_RESULT($pointers_fit_in_ints)
  183. if test "$pointers_fit_in_ints" = "no" ; then
  184. AC_MSG_ERROR([pointers cannot be stored in ints, required for old code... stopping])
  185. fi
  186. AC_MSG_CHECKING([whether $CC supports -Wno-unused-parameter])
  187. OLD_CFLAGS="$CFLAGS"
  188. CFLAGS="$CFLAGS -Wno-unused-parameter"
  189. AC_COMPILE_IFELSE(
  190. [int foo;],
  191. [AC_MSG_RESULT([yes])],
  192. [
  193. AC_MSG_RESULT([no])
  194. CFLAGS="$OLD_CFLAGS"
  195. ]
  196. )
  197. AC_MSG_CHECKING([whether $CC supports -Wno-pointer-sign])
  198. OLD_CFLAGS="$CFLAGS"
  199. CFLAGS="$CFLAGS -Wno-pointer-sign"
  200. AC_COMPILE_IFELSE(
  201. [int foo;],
  202. [AC_MSG_RESULT([yes])],
  203. [
  204. AC_MSG_RESULT([no])
  205. CFLAGS="$OLD_CFLAGS"
  206. ]
  207. )
  208. AC_MSG_CHECKING([whether $CC supports -Wno-switch])
  209. OLD_CFLAGS="$CFLAGS"
  210. CFLAGS="$CFLAGS -Wno-switch"
  211. AC_COMPILE_IFELSE(
  212. [int foo;],
  213. [AC_MSG_RESULT([yes])],
  214. [
  215. AC_MSG_RESULT([no])
  216. CFLAGS="$OLD_CFLAGS"
  217. ]
  218. )
  219. ###############################################################################
  220. # Check for libraries and header files.
  221. #
  222. #
  223. # Memory manager
  224. #
  225. case $enableval in
  226. "no")
  227. CFLAGS="$CFLAGS -DNO_MEMMGR"
  228. ;;
  229. "builtin")
  230. # enabled by default
  231. ;;
  232. "memwatch")
  233. CFLAGS="$CFLAGS -DMEMWATCH"
  234. AC_CHECK_HEADER([memwatch.h], , [AC_MSG_ERROR([memwatch header not found... stopping])])
  235. ;;
  236. "dmalloc")
  237. CFLAGS="$CFLAGS -DDMALLOC -DDMALLOC_FUNC_CHECK"
  238. LIBS="$LIBS -ldmalloc"
  239. AC_CHECK_HEADER([dmalloc.h], , [AC_MSG_ERROR([dmalloc header not found... stopping])])
  240. ;;
  241. "gcollect")
  242. CFLAGS="$CFLAGS -DGCOLLECT"
  243. LIBS="$LIBS -lgc"
  244. AC_CHECK_HEADER([gc.h], , [AC_MSG_ERROR([gcollect header not found... stopping])])
  245. ;;
  246. "bcheck")
  247. CFLAGS="$CFLAGS -DBCHECK"
  248. ;;
  249. esac
  250. #
  251. # Packetver
  252. #
  253. if test -n "$enable_packetver" ; then
  254. CFLAGS="$CFLAGS -DPACKETVER=$enable_packetver"
  255. fi
  256. #
  257. # Mapregsql
  258. #
  259. if test "$enable_mapregsql" = "yes" ; then
  260. CFLAGS="$CFLAGS -DMAPREGSQL"
  261. fi
  262. #
  263. # Debug
  264. #
  265. if test "$enable_debug" = "yes" ; then
  266. CFLAGS="$CFLAGS -g -DDEBUG"
  267. fi
  268. #
  269. # zlib library (required)
  270. #
  271. if test -n "${ZLIB_HOME}" ; then
  272. LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
  273. CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
  274. fi
  275. AC_CHECK_LIB([z], [inflateEnd], [],[AC_MSG_ERROR([zlib library not found or incompatible, please specify the correct path with --with-zlib=DIR... stopping])])
  276. AC_CHECK_HEADER([zlib.h], [], [AC_MSG_ERROR([zlib header not found, please specify the correct path with --with-zlib=DIR... stopping])])
  277. #
  278. # math library (required)
  279. #
  280. AC_CHECK_LIB([m], [sqrt], [], [AC_MSG_ERROR([math library not found... stopping])])
  281. #
  282. # clock_gettime (rt on Debian)
  283. #
  284. AC_CHECK_LIB([rt], [clock_gettime])
  285. #
  286. # MySQL library (optional)
  287. #
  288. MYSQL_VERSION=""
  289. MYSQL_CFLAGS=""
  290. MYSQL_LIBS=""
  291. if test "$want_mysql" = "no" ; then
  292. AC_MSG_NOTICE([ignoring MySQL (optional)])
  293. else
  294. if test -z "$MYSQL_CONFIG_HOME"; then
  295. AC_PATH_PROG([MYSQL_CONFIG_HOME], [mysql_config], [no])
  296. fi
  297. if test "$MYSQL_CONFIG_HOME" != "no" ; then
  298. MYSQL_VERSION="`$MYSQL_CONFIG_HOME --version`"
  299. MYSQL_CFLAGS="`$MYSQL_CONFIG_HOME --include`"
  300. MYSQL_LIBS="`$MYSQL_CONFIG_HOME --libs`"
  301. MYSQL_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS $MYSQL_LIBS"
  302. MYSQL_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS $MYSQL_CFLAGS"
  303. AC_CHECK_LIB([mysqlclient], [mysql_init], [HAVE_MYSQL="yes"], [])
  304. AC_CHECK_HEADER([mysql.h], [], [HAVE_MYSQL=""])
  305. CPPFLAGS="$MYSQL_OLD_CPPFLAGS"
  306. LDFLAGS="$MYSQL_OLD_LDFLAGS"
  307. fi
  308. AC_MSG_CHECKING([MySQL library (optional)])
  309. if test "$HAVE_MYSQL" = "yes" ; then
  310. AC_MSG_RESULT([yes ($MYSQL_VERSION)])
  311. else
  312. AC_MSG_RESULT([no])
  313. if test "$require_mysql" = "yes" ; then
  314. AC_MSG_ERROR([MySQL not found or incompatible (requested)])
  315. else
  316. AC_MSG_NOTICE([disabling MySQL (optional)])
  317. MYSQL_VERSION=""
  318. MYSQL_CFLAGS=""
  319. MYSQL_LIBS=""
  320. fi
  321. fi
  322. fi
  323. AC_SUBST([HAVE_MYSQL])
  324. AC_SUBST([MYSQL_VERSION])
  325. AC_SUBST([MYSQL_CFLAGS])
  326. AC_SUBST([MYSQL_LIBS])
  327. #
  328. # PCRE library (optional)
  329. #
  330. ##TODO PCRE version
  331. PCRE_LIBS=""
  332. PCRE_CFLAGS=""
  333. if test "$want_pcre" = "no" ; then
  334. AC_MSG_NOTICE([ignoring PCRE (optional)])
  335. else
  336. if test -z "$PCRE_HOME" ; then
  337. AC_CHECK_LIB([pcre], [pcre_study], [HAVE_PCRE="yes"], [])
  338. if test "$HAVE_PCRE" = "yes" ; then
  339. PCRE_LIBS="-lpcre"
  340. fi
  341. else
  342. PCRE_OLD_LDFLAGS="$LDFLAGS" ; LDFLAGS="$LDFLAGS -L$PCRE_HOME/lib"
  343. PCRE_OLD_CPPFLAGS="$CPPFLAGS" ; CPPFLAGS="$CPPFLAGS -I$PCRE_HOME/include"
  344. AC_CHECK_LIB(pcre, pcre_compile, [HAVE_PCRE="yes"], [])
  345. CPPFLAGS="$PCRE_OLD_CPPFLAGS"
  346. LDFLAGS="$PCRE_OLD_LDFLAGS"
  347. if test "$HAVE_PCRE" = "yes" ; then
  348. PCRE_LIBS="-L$PCRE_HOME/lib -lpcre"
  349. test -d "$PCRE_HOME/include" && PCRE_CFLAGS="-I$PCRE_HOME/include"
  350. fi
  351. fi
  352. AC_MSG_CHECKING([PCRE library (optional)])
  353. if test "$HAVE_PCRE" = "yes" ; then
  354. AC_MSG_RESULT([yes])
  355. else
  356. AC_MSG_RESULT([no])
  357. if test "$require_pcre" = "yes" ; then
  358. AC_MSG_ERROR([PCRE not found or incompatible (requested)])
  359. else
  360. AC_MSG_NOTICE([disabling PCRE (optional)])
  361. fi
  362. fi
  363. fi
  364. AC_SUBST([HAVE_PCRE])
  365. AC_SUBST([PCRE_LIBS])
  366. AC_SUBST([PCRE_CFLAGS])
  367. #
  368. # Host specific stuff
  369. #
  370. AC_MSG_CHECKING([host OS])
  371. host_os="`uname`"
  372. AC_MSG_RESULT([$host_os])
  373. fd_setsize=""
  374. DLLEXT=".so"
  375. case $host_os in
  376. Solaris* )
  377. LIBS="$LIBS -lsocket -lnsl -ldl"
  378. ;;
  379. Linux* )
  380. LIBS="$LIBS -ldl"
  381. ;;
  382. FreeBSD*)
  383. CPPFLAGS="$CPPFLAGS -D__FREEBSD__"
  384. ;;
  385. NetBSD*)
  386. CPPFLAGS="$CPPFLAGS -D__NETBSD__"
  387. ;;
  388. CYGWIN*)
  389. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096 -DCYGWIN"
  390. fd_setsize="done"
  391. DLLEXT=".dll"
  392. ;;
  393. esac
  394. AC_SUBST([DLLEXT])
  395. AC_MSG_CHECKING([for MinGW])
  396. if test -n "`$CC --version | grep -i mingw`" ; then
  397. AC_MSG_RESULT([yes])
  398. CPPFLAGS="$CPPFLAGS -DMINGW"
  399. if test -z "$fd_setsize" ; then
  400. CPPFLAGS="$CPPFLAGS -DFD_SETSIZE=4096"
  401. fi
  402. LIBS="$LIBS -lws2_32"
  403. else
  404. AC_MSG_RESULT([no])
  405. fi
  406. ###############################################################################
  407. AC_OUTPUT