configure.in 11 KB

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