configure.in 11 KB

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