configure.in 11 KB

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