configure.in 11 KB

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