configure.in 12 KB

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