configure.ac 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964
  1. AC_PREREQ(2.60)
  2. AC_INIT([ManaPlus], [1.9.3.23], [akaras@inbox.ru], [manaplus])
  3. AM_INIT_AUTOMAKE([1.9])
  4. AC_LANG_CPLUSPLUS
  5. AC_DEFUN([AC_CHECK_CXX_FLAG],
  6. [
  7. AC_MSG_CHECKING([whether $CC supports $1])
  8. OLD_CXXFLAGS="$CXXFLAGS"
  9. CXXFLAGS="$CXXFLAGS -Werror $1"
  10. $2=no
  11. AC_COMPILE_IFELSE(
  12. [AC_LANG_SOURCE([int foo;])],
  13. [
  14. AC_MSG_RESULT([yes])
  15. $2=yes
  16. ],
  17. [
  18. AC_MSG_RESULT([no])
  19. $2=no
  20. ]
  21. )
  22. CXXFLAGS="$OLD_CXXFLAGS"
  23. ]
  24. )
  25. AC_DEFUN([AC_CHECK_LD_FLAG],
  26. [
  27. AC_MSG_CHECKING([whether $LD supports $1])
  28. OLD_CXXFLAGS="$CXXFLAGS"
  29. OLD_LDFLAGS="$LDFLAGS"
  30. CXXFLAGS=""
  31. LDFLAGS="$LDFLAGS $1"
  32. $2=no
  33. AC_LINK_IFELSE(
  34. [AC_LANG_SOURCE([
  35. int main(int argc, char **argv)
  36. {
  37. return 0;
  38. }
  39. ])],
  40. [
  41. AC_MSG_RESULT([yes])
  42. $2=yes
  43. ],
  44. [
  45. AC_MSG_RESULT([no])
  46. $2=no
  47. ]
  48. )
  49. CXXFLAGS="$OLD_CXXFLAGS"
  50. LDFLAGS="$OLD_LDFLAGS"
  51. ]
  52. )
  53. AC_DEFUN([AC_CHECK_GLXEXT],
  54. [
  55. AC_MSG_CHECKING([whether have glext.h])
  56. OLD_CXXFLAGS="$CXXFLAGS"
  57. CXXFLAGS=""
  58. $1=no
  59. AC_LINK_IFELSE(
  60. [AC_LANG_SOURCE([
  61. #include <GL/gl.h>
  62. #include <GL/glext.h>
  63. #ifndef __gl_glext_h_
  64. #error __gl_glext_h_ not defined
  65. #endif
  66. int main(int argc, char **argv)
  67. {
  68. return 0;
  69. }
  70. ])],
  71. [
  72. AC_MSG_RESULT([yes])
  73. $1=yes
  74. ],
  75. [
  76. AC_MSG_RESULT([no])
  77. $1=no
  78. ]
  79. )
  80. CXXFLAGS="$OLD_CXXFLAGS"
  81. ]
  82. )
  83. # Enable -Werror
  84. AC_ARG_ENABLE(werror,
  85. [ --enable-werror Fail build if warning present],
  86. [case "${enableval}" in
  87. yes) werror_enabled=true
  88. ;;
  89. no) werror_enabled=false
  90. ;;
  91. *) AC_MSG_ERROR(bad value ${enableval} for --enable-werror) ;;
  92. esac],[werror_enabled=false])
  93. AM_CONDITIONAL(ENABLE_WERROR, test x$werror_enabled = xtrue)
  94. # Enable asserts
  95. AC_ARG_ENABLE(asserts,
  96. [ --enable-asserts Enable asserts in log],
  97. [case "${enableval}" in
  98. yes) asserts_enabled=true
  99. ;;
  100. no) asserts_enabled=false
  101. ;;
  102. *) AC_MSG_ERROR(bad value ${enableval} for --enable-asserts) ;;
  103. esac],[asserts_enabled=true])
  104. AM_CONDITIONAL(ENABLE_ASSERTS, test x$asserts_enabled = xtrue)
  105. # Enable -D_GLIBCXX_DEBUG
  106. AC_ARG_ENABLE(glibcdebug,
  107. [ --enable-glibcdebug Enable glibc++ debug mode],
  108. [case "${enableval}" in
  109. yes) glibcdebug_enabled=true
  110. ;;
  111. no) glibcdebug_enabled=false
  112. ;;
  113. *) AC_MSG_ERROR(bad value ${enableval} for --enable-glibcdebug) ;;
  114. esac],[glibcdebug_enabled=false])
  115. AM_CONDITIONAL(ENABLE_GLIBCDEBUG, test x$glibcdebug_enabled = xtrue)
  116. # Enable mse classes replacements for stl
  117. AC_ARG_ENABLE(stldebug,
  118. [ --enable-stldebug Enable mse libs],
  119. [case "${enableval}" in
  120. yes) stldebug_enabled=true
  121. ;;
  122. no) stldebug_enabled=false
  123. ;;
  124. *) AC_MSG_ERROR(bad value ${enableval} for --enable-stldebug) ;;
  125. esac],[stldebug_enabled=false])
  126. AM_CONDITIONAL(ENABLE_STLDEBUG, test x$stldebug_enabled = xtrue)
  127. # Enable OpenGL error reporting
  128. AC_ARG_ENABLE(openglerrors,
  129. [ --enable-openglerrors Enable OpenGL errors reporting],
  130. [case "${enableval}" in
  131. yes) openglerrors_enabled=true
  132. ;;
  133. no) openglerrors_enabled=false
  134. ;;
  135. *) AC_MSG_ERROR(bad value ${enableval} for --enable-openglerrors) ;;
  136. esac],[openglerrors_enabled=false])
  137. AM_CONDITIONAL(ENABLE_OPENGLERRORS, test x$openglerrors_enabled = xtrue)
  138. # Enable password from command line
  139. AC_ARG_ENABLE(commandlinepassword,
  140. [ --enable-commandlinepassword Enable command line option for set password],
  141. [case "${enableval}" in
  142. yes) commandlinepassword_enabled=true
  143. ;;
  144. no) commandlinepassword_enabled=false
  145. ;;
  146. *) AC_MSG_ERROR(bad value ${enableval} for --enable-commandlinepassword) ;;
  147. esac],[commandlinepassword_enabled=false])
  148. AM_CONDITIONAL(ENABLE_COMMANDLINEPASSWORD, test x$commandlinepassword_enabled = xtrue)
  149. # Checks for android.
  150. AC_ARG_ENABLE(androidbuild,
  151. [ --enable-androidbuild Turn on android building],
  152. [case "${enableval}" in
  153. yes) androidbuild_enabled=true
  154. dyecmd_enabled=false
  155. ;;
  156. no) androidbuild_enabled=false
  157. ;;
  158. *) AC_MSG_ERROR(bad value ${enableval} for --enable-androidbuild) ;;
  159. esac],[androidbuild_enabled=false])
  160. # Enable for dyecmd
  161. AC_ARG_WITH(dyecmd,[ --with-dyecmd build dyecmd tool ] )
  162. if test "x$with_dyecmd" == "xno"; then
  163. with_dyecmd=no
  164. else
  165. if test "x$androidbuild_enabled" == "xfalse"; then
  166. with_dyecmd=yes
  167. else
  168. with_dyecmd=no
  169. fi
  170. fi
  171. AM_CONDITIONAL(ENABLE_DYECMD, test x$with_dyecmd = xyes)
  172. # Option to enable ManaPlus game
  173. AC_ARG_WITH(manaplusgame,[ --without-manaplusgame don't build ManaPlus game ] )
  174. if test "x$with_manaplusgame" == "xno"; then
  175. with_manaplusgame=no
  176. else
  177. with_manaplusgame=yes
  178. fi
  179. AM_CONDITIONAL(ENABLE_MANAPLUSGAME, test x$with_manaplusgame = xyes)
  180. # Enable nacl build
  181. AC_ARG_ENABLE(naclbuild,
  182. [ --enable-naclbuild Turn on nacl building],
  183. [case "${enableval}" in
  184. yes) naclbuild_enabled=true
  185. ;;
  186. no) naclbuild_enabled=false
  187. ;;
  188. *) AC_MSG_ERROR(bad value ${enableval} for --enable-naclbuild) ;;
  189. esac],[naclbuild_enabled=false])
  190. # Checks for programs.
  191. AC_PROG_CXX
  192. AM_PROG_CC_C_O
  193. AC_PROG_INSTALL
  194. # Checks for typedefs, structures, and compiler characteristics.
  195. AC_HEADER_TIME
  196. # Checks for library functions.
  197. AC_FUNC_ERROR_AT_LINE
  198. # disabled because look like build issue with some libc versions with asan
  199. #if test "x$androidbuild_enabled" == "xfalse"; then
  200. # if test "x$naclbuild_enabled" == "xfalse"; then
  201. # AC_FUNC_MALLOC
  202. # AC_FUNC_REALLOC
  203. # fi
  204. #fi
  205. AC_C_INLINE
  206. AC_FUNC_SELECT_ARGTYPES
  207. AC_FUNC_VPRINTF
  208. AC_FUNC_FORK
  209. AC_FUNC_MMAP
  210. AC_CHECK_FUNCS([atexit floor getcwd gethostbyname memset mkdir select socket])
  211. AC_CHECK_FUNCS([clock_gettime dup2 gettimeofday memchr memmove pow putenv])
  212. AC_CHECK_FUNCS([realpath setenv setlocale sqrt strchr munmap])
  213. AC_CHECK_FUNCS([malloc_trim])
  214. #AC_CHECK_HEADER_STDBOOL
  215. AC_CHECK_HEADERS([libintl.h limits.h sys/param.h sys/time.h wchar.h])
  216. AC_TYPE_INT8_T
  217. AC_TYPE_UINT8_T
  218. AC_TYPE_INT16_T
  219. AC_TYPE_UINT16_T
  220. AC_TYPE_INT32_T
  221. AC_TYPE_UINT32_T
  222. AC_TYPE_INT64_T
  223. AC_TYPE_SSIZE_T
  224. # Search for *-config
  225. PKG_PROG_PKG_CONFIG
  226. AC_PATH_PROG(CURL_CONFIG, curl-config)
  227. AC_PATH_PROG(ICU_CONFIG, icu-config)
  228. LIBS="$LIBS `$PKG_CONFIG --libs zlib`"
  229. CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags zlib`"
  230. LIBS="$LIBS `$PKG_CONFIG --libs libpng`"
  231. CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags libpng`"
  232. # Checks for internationalization support
  233. AM_GNU_GETTEXT([external],[need-ngettext])
  234. AM_GNU_GETTEXT_VERSION([0.16.1])
  235. case $host in
  236. (*mingw*)
  237. skip_check_lib="yes"
  238. mingw=true
  239. LIBS="$LIBS -lintl"
  240. ;;
  241. (*)
  242. skip_check_lib="no"
  243. mingw=false
  244. ;;
  245. esac
  246. AM_CONDITIONAL(MINGW, test x$mingw = xtrue)
  247. # Option to enable internal sdl-gfx for SDL2 (for now it enabled by default)
  248. AC_ARG_WITH(internalsdlgfx,[ --without-internalsdlgfx don't use internal sdlgfx (for SDL2 only) ] )
  249. AC_DEFUN([AC_CHECK_SDL],
  250. [
  251. # Enable sdl2
  252. AC_ARG_WITH(sdl2,[ --with-sdl2 enable SDL 2 support] )
  253. if test "x$with_sdl2" == "xyes"; then
  254. AC_PATH_PROG(SDL_CONFIG, sdl2-config)
  255. if test -n "$SDL_CONFIG"; then
  256. LIBS="$LIBS `$SDL_CONFIG --libs`"
  257. CPPFLAGS="$CPPFLAGS `$SDL_CONFIG --cflags`"
  258. fi
  259. if test "x$with_internalsdlgfx" == "xno"; then
  260. LIBS="$LIBS `$PKG_CONFIG --libs SDL2_gfx`"
  261. CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags SDL2_gfx`"
  262. fi
  263. LIBS="$LIBS `$PKG_CONFIG --libs SDL2_image`"
  264. CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags SDL2_image`"
  265. LIBS="$LIBS `$PKG_CONFIG --libs SDL2_mixer`"
  266. CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags SDL2_mixer`"
  267. LIBS="$LIBS `$PKG_CONFIG --libs SDL2_net`"
  268. CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags SDL2_net`"
  269. LIBS="$LIBS `$PKG_CONFIG --libs SDL2_ttf`"
  270. CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags SDL2_ttf`"
  271. if test "$skip_check_lib" == "no"; then
  272. AC_CHECK_LIB([SDL2], [SDL_Init], ,
  273. AC_MSG_ERROR([ *** Unable to find SDL2 library (http://www.libsdl.org/)]))
  274. AC_CHECK_LIB(SDL2_image, IMG_LoadPNG_RW, ,
  275. AC_MSG_ERROR([ *** Unable to find SDL2_image library with PNG support (http://www.libsdl.org/projects/SDL_image/)]))
  276. AC_CHECK_LIB(SDL2_ttf, TTF_Quit, ,
  277. AC_MSG_ERROR([ *** Unable to find SDL2_ttf library (http://www.libsdl.org/projects/SDL_ttf/)]))
  278. AC_CHECK_LIB([SDL2_mixer], [Mix_OpenAudio], ,
  279. AC_MSG_ERROR([ *** Unable to find SDL2_mixer library (http://www.libsdl.org/projects/SDL_mixer/)]))
  280. AC_CHECK_LIB(SDL2_net, SDLNet_Init, ,
  281. AC_MSG_ERROR([ *** Unable to find SDL2_net library]))
  282. fi
  283. with_sdl2=yes
  284. else
  285. AC_PATH_PROG(SDL_CONFIG, sdl-config)
  286. if test -n "$SDL_CONFIG"; then
  287. LIBS="$LIBS `$SDL_CONFIG --libs`"
  288. CPPFLAGS="$CPPFLAGS `$SDL_CONFIG --cflags`"
  289. fi
  290. LIBS="$LIBS `$PKG_CONFIG --libs SDL_gfx`"
  291. CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags SDL_gfx`"
  292. LIBS="$LIBS `$PKG_CONFIG --libs SDL_image`"
  293. CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags SDL_image`"
  294. LIBS="$LIBS `$PKG_CONFIG --libs SDL_mixer`"
  295. CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags SDL_mixer`"
  296. LIBS="$LIBS `$PKG_CONFIG --libs SDL_net`"
  297. CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags SDL_net`"
  298. LIBS="$LIBS `$PKG_CONFIG --libs SDL_ttf`"
  299. CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags SDL_ttf`"
  300. if test "x$naclbuild_enabled" == "xfalse"; then
  301. if test "$skip_check_lib" == "no"; then
  302. AC_CHECK_LIB([SDL], [SDL_Init], ,
  303. AC_MSG_ERROR([ *** Unable to find SDL library (http://www.libsdl.org/)]))
  304. AC_CHECK_LIB(SDL_image, IMG_LoadPNG_RW, ,
  305. AC_MSG_ERROR([ *** Unable to find SDL_image library with PNG support (http://www.libsdl.org/projects/SDL_image/)]))
  306. AC_CHECK_LIB(SDL_ttf, TTF_Quit, ,
  307. AC_MSG_ERROR([ *** Unable to find SDL_ttf library (http://www.libsdl.org/projects/SDL_ttf/)]))
  308. AC_CHECK_LIB([SDL_mixer], [Mix_OpenAudio], ,
  309. AC_MSG_ERROR([ *** Unable to find SDL_mixer library (http://www.libsdl.org/projects/SDL_mixer/)]))
  310. AC_CHECK_LIB(SDL_gfx, rotozoomSurfaceXY, ,
  311. AC_MSG_ERROR([ *** Unable to find SDL_gfx library (http://www.ferzkopp.net/joomla/software-mainmenu-14/4-ferzkopps-linux-software/19-sdlgfx)]))
  312. AC_CHECK_LIB(SDL_net, SDLNet_Init, ,
  313. AC_MSG_ERROR([ *** Unable to find SDL_net library]))
  314. fi
  315. AC_CHECK_HEADERS(SDL_rotozoom.h, ,)
  316. fi
  317. with_sdl2=no
  318. fi
  319. AM_CONDITIONAL(USE_SDL2, test x$with_sdl2 = xyes)
  320. AC_CHECK_GLXEXT(have_glext)
  321. AM_CONDITIONAL(HAVE_GLEXT, test x$have_glext = xyes)
  322. # Option to enable internal sdl-gfx for SDL2 (for now it enabled by default)
  323. if test "x$with_internalsdlgfx" == "xno"; then
  324. with_internalsdlgfx=no
  325. if test "$skip_check_lib" == "no"; then
  326. AC_CHECK_LIB(SDL2_gfx, rotozoomSurfaceXY, ,
  327. AC_MSG_ERROR([ *** Unable to find SDL2_gfx library (http://www.ferzkopp.net/joomla/software-mainmenu-14/4-ferzkopps-linux-software/19-sdlgfx)]))
  328. fi
  329. AC_CHECK_HEADERS(SDL2_rotozoom.h, ,)
  330. else
  331. with_internalsdlgfx=yes
  332. AC_DEFINE(USE_INTERNALSDLGFX, 1, [Defines if ManaPlus should use internal sdlgfx2])
  333. fi
  334. AM_CONDITIONAL(USE_INTERNALSDLGFX, test x$with_internalsdlgfx = xyes)
  335. AC_CHECK_HEADERS([SDL.h], ,
  336. AC_MSG_ERROR([ *** SDL library found but cannot find headers (http://www.libsdl.org/)]))
  337. ])
  338. if test "x$naclbuild_enabled" == "xfalse"; then
  339. AC_CHECK_SDL()
  340. fi
  341. # Checks for libraries
  342. AC_ARG_WITH(pthread,[ --without-pthread don't check for pthread ] )
  343. if test "x$with_pthread" == "xno"; then
  344. without_pthread=yes
  345. else
  346. if test "x$androidbuild_enabled" == "xfalse"; then
  347. if test "$skip_check_lib" == "no"; then
  348. AC_CHECK_LIB([pthread], [pthread_create], ,
  349. AC_MSG_ERROR([ *** Unable to find pthread library]))
  350. fi
  351. fi
  352. withoud_pthread=no
  353. fi
  354. if test "$skip_check_lib" == "no"; then
  355. AC_CHECK_LIB([z], [inflate], ,
  356. AC_MSG_ERROR([ *** Unable to find zlib (http://www.gzip.org/zlib/)]))
  357. fi
  358. if test -n "$CURL_CONFIG"; then
  359. LIBS="$LIBS `$CURL_CONFIG --libs`"
  360. CPPFLAGS="$CPPFLAGS `$CURL_CONFIG --cflags`"
  361. fi
  362. if test "$skip_check_lib" == "no"; then
  363. AC_CHECK_LIB([curl], [curl_global_init], ,
  364. AC_MSG_ERROR([ *** Unable to find CURL library (http://curl.haxx.se/)]))
  365. fi
  366. AC_CHECK_HEADERS([curl/curl.h], ,
  367. AC_MSG_ERROR([ *** CURL library found but cannot find headers (http://curl.haxx.se/)]))
  368. # select xml lib
  369. AC_ARG_ENABLE(libxml,
  370. AC_HELP_STRING([--enable-libxml=ARG],
  371. [xml libs: libxml (default), pugixml (experimental)]),
  372. [
  373. xmllib="${enableval}"
  374. ],
  375. [
  376. xmllib="libxml"
  377. ]
  378. )
  379. case $xmllib in
  380. "libxml")
  381. AM_CONDITIONAL(ENABLE_LIBXML, true)
  382. AM_CONDITIONAL(ENABLE_PUGIXML, false)
  383. AM_CONDITIONAL(ENABLE_TINYXML2, false)
  384. ;;
  385. "pugixml")
  386. AM_CONDITIONAL(ENABLE_LIBXML, false)
  387. AM_CONDITIONAL(ENABLE_PUGIXML, true)
  388. AM_CONDITIONAL(ENABLE_TINYXML2, false)
  389. ;;
  390. "tinyxml2")
  391. AM_CONDITIONAL(ENABLE_LIBXML, false)
  392. AM_CONDITIONAL(ENABLE_PUGIXML, false)
  393. AM_CONDITIONAL(ENABLE_TINYXML2, true)
  394. ;;
  395. *)
  396. AC_MSG_ERROR([[Wrong xml lib name]])
  397. ;;
  398. esac
  399. if test "$xmllib" == "libxml"; then
  400. if test -n "$PKG_CONFIG"; then
  401. LIBS="$LIBS `$PKG_CONFIG --libs libxml-2.0`"
  402. CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags libxml-2.0`"
  403. fi
  404. if test "$skip_check_lib" == "no"; then
  405. AC_CHECK_LIB([xml2], [xmlInitParser], ,
  406. AC_MSG_ERROR([ *** Unable to find libxml2 library (http://xmlsoft.org/)]))
  407. fi
  408. AC_CHECK_HEADERS(
  409. [libxml/xmlreader.h],
  410. ,
  411. # workaround for icu-59 issue.
  412. CPPFLAGS="$CPPFLAGS --std=c++0x"
  413. AC_MSG_RESULT([no])
  414. AC_MSG_CHECKING([Checking libxml2 headers with icu bug fix])
  415. icu_bug=yes
  416. $as_unset ac_cv_header_libxml_xmlreader_h
  417. )
  418. if test "$icu_bug" == "yes"; then
  419. AC_CHECK_HEADERS(
  420. [libxml/xmlreader.h],
  421. ,
  422. AC_MSG_ERROR([ *** libxml2 library found but cannot find headers (http://xmlsoft.org/)])
  423. )
  424. fi
  425. fi
  426. if test "$xmllib" == "pugixml"; then
  427. if test "$skip_check_lib" == "no"; then
  428. AC_CHECK_LIB([pugixml], [main], ,
  429. AC_MSG_ERROR([ *** Unable to find pugixml library (http://pugixml.org/)]))
  430. fi
  431. AC_CHECK_HEADERS([pugixml.hpp], ,
  432. AC_MSG_ERROR([ *** pugixml library found but cannot find headers (http://pugixml.org/)]))
  433. fi
  434. # hack for support unversioned api change in tinyxml2 (master branch)
  435. tinyxml2_old=yes
  436. if test "$xmllib" == "tinyxml2"; then
  437. if test "$skip_check_lib" == "no"; then
  438. AC_CHECK_LIB([tinyxml2], [main], ,
  439. AC_MSG_ERROR([ *** Unable to find tinyxml2 library (http://grinninglizard.com/tinyxml2/)]))
  440. AC_MSG_CHECKING([whether tinyxml supports old error api])
  441. AC_COMPILE_IFELSE(
  442. [AC_LANG_SOURCE([
  443. #ifndef GCC_VERSION
  444. #define GCC_VERSION (__GNUC__ * 10000 \
  445. + __GNUC_MINOR__ * 100 \
  446. + __GNUC_PATCHLEVEL__)
  447. #endif // GCC_VERSION
  448. #ifdef __clang__
  449. #ifndef CLANG_VERSION
  450. #define CLANG_VERSION (__clang_major__ * 10000 \
  451. + __clang_minor__ * 100 \
  452. + __clang_patchlevel__)
  453. #endif // CLANG_VERSION
  454. #endif // __clang__
  455. #if GCC_VERSION >= 49000
  456. #define PRAGMA49(str) _Pragma(#str)
  457. #else // GCC_VERSION > 49000
  458. #define PRAGMA49(str)
  459. #endif // GCC_VERSION > 49000
  460. #if GCC_VERSION >= 40600
  461. #define PRAGMACLANG6GCC(str) _Pragma(#str)
  462. #elif defined(__clang__) && CLANG_VERSION >= 30800
  463. #define PRAGMACLANG6GCC(str) _Pragma(#str)
  464. #else // __clang__
  465. #define PRAGMACLANG6GCC(str)
  466. #endif // __clang__
  467. PRAGMA49(GCC diagnostic push)
  468. PRAGMA49(GCC diagnostic ignored "-Wzero-as-null-pointer-constant")
  469. PRAGMA49(GCC diagnostic ignored "-Wsuggest-override")
  470. PRAGMACLANG6GCC(GCC diagnostic push)
  471. PRAGMACLANG6GCC(GCC diagnostic ignored "-Wold-style-cast")
  472. #include <tinyxml2.h>
  473. PRAGMACLANG6GCC(GCC diagnostic pop)
  474. PRAGMA49(GCC diagnostic pop)
  475. int main(int, char **)
  476. {
  477. tinyxml2::XMLDocument doc;
  478. const char *str = doc.ErrorStr();
  479. return !str;
  480. }
  481. ])],
  482. [
  483. AC_MSG_RESULT([no])
  484. tinyxml2_old=no
  485. ],
  486. [
  487. AC_MSG_RESULT([yes])
  488. tinyxml2_old=yes
  489. ]
  490. )
  491. fi
  492. AC_CHECK_HEADERS([tinyxml2.h], ,
  493. AC_MSG_ERROR([ *** tinyxml2 library found but cannot find headers (http://grinninglizard.com/tinyxml2/)]))
  494. fi
  495. AM_CONDITIONAL(USE_TINYXML_OLD, test x$tinyxml2_old = xyes)
  496. if test "$skip_check_lib" == "no"; then
  497. AC_CHECK_LIB(png, png_write_info, ,
  498. AC_MSG_ERROR([ *** Unable to find png library]))
  499. fi
  500. use_x11=no
  501. # === Check for X11 (check borrowed from Wormux) ========================
  502. # Deactivated on purpose under OSX (in case X11 SDK is installed)
  503. if test "x$OSX" != "xyes" ; then
  504. AC_CHECK_HEADER(X11/Xlib.h, check_x11="yes",check_x11="no")
  505. if test x${check_x11} = xno ; then
  506. AC_CHECK_HEADER(X11R6/Xlib.h,
  507. [ check_x11="yes"
  508. LDFLAGS="-L/usr/X11R6/include $CFLAGS"],
  509. check_x11="no")
  510. fi
  511. if test x${check_x11} = xyes ; then
  512. AC_CHECK_LIB(X11, XOpenDisplay,
  513. [ LIBS="$LIBS -lX11"
  514. AC_DEFINE(USE_X11, 1, [Define to use X11 copy'n'paste])
  515. use_x11=yes
  516. ],
  517. [])
  518. fi
  519. fi
  520. AM_CONDITIONAL(USE_X11, test x$use_x11 = xyes)
  521. # Checks for header files.
  522. AC_HEADER_STDC
  523. AC_CHECK_HEADERS([arpa/inet.h fcntl.h malloc.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h unistd.h])
  524. # Enable mac build
  525. AC_ARG_ENABLE(applebuild,
  526. [ --enable-applebuild Turn on apple building],
  527. [case "${enableval}" in
  528. yes) applebuild_enabled=true
  529. ;;
  530. no) applebuild_enabled=false
  531. ;;
  532. *) AC_MSG_ERROR(bad value ${enableval} for --enable-applebuild) ;;
  533. esac],[applebuild_enabled=false])
  534. # Option to enable gcov
  535. AC_ARG_WITH(gcov,[ --with-gcov use gcov ] )
  536. if test "x$with_gcov" == "xyes"; then
  537. with_gcov=yes
  538. CPPFLAGS="$CPPFLAGS -coverage"
  539. LDFLAGS="$LDFLAGS -coverage"
  540. else
  541. with_gcov=no
  542. fi
  543. AM_CONDITIONAL(USE_GCOV, test x$with_gcov = xyes)
  544. # Option to enable OpenGL
  545. AC_ARG_WITH(opengl,[ --without-opengl don't use OpenGL ] )
  546. if test "x$with_opengl" == "xno"; then
  547. with_opengl=no
  548. else
  549. with_opengl=yes
  550. if test "x$applebuild_enabled" == "xfalse"; then
  551. if test "x$androidbuild_enabled" == "xfalse"; then
  552. if test "x$naclbuild_enabled" == "xfalse"; then
  553. if test "$skip_check_lib" == "no"; then
  554. AC_CHECK_LIB([GL], [glBegin], ,
  555. AC_MSG_ERROR([ *** Unable to find OpenGL library]))
  556. fi
  557. fi
  558. else
  559. LDFLAGS="$LDFLAGS -lGLESv1_CM -lEGL"
  560. fi
  561. else
  562. LDFLAGS="$LDFLAGS -framework OpenGL"
  563. fi
  564. case $host in
  565. (*mingw*) LIBS="$LIBS `$PKG_CONFIG --libs gl`"
  566. esac
  567. fi
  568. AM_CONDITIONAL(USE_OPENGL, test x$with_opengl = xyes)
  569. # Option to enable mumble support
  570. AC_ARG_WITH(mumble,[ --without-mumble don't use mumble integration ] )
  571. if test "x$with_mumble" == "xno"; then
  572. with_mumble=no
  573. else
  574. if test "x$androidbuild_enabled" == "xfalse"; then
  575. with_mumble=yes
  576. else
  577. with_mumble=no
  578. fi
  579. fi
  580. AM_CONDITIONAL(USE_MUMBLE, test x$with_mumble = xyes)
  581. AC_ARG_WITH(librt,[ --without-librt don't link to librt ] )
  582. if test "x$with_librt" == "xno"; then
  583. without_librt=yes
  584. else
  585. if test "x$applebuild_enabled" == "xfalse"; then
  586. if test "x$androidbuild_enabled" == "xfalse"; then
  587. AC_CHECK_LD_FLAG(-lrt, use_librt)
  588. if test "x$use_librt" == "xyes"; then
  589. AC_CHECK_LIB(rt, shm_open, ,
  590. AC_MSG_ERROR([ *** Unable to find librt library]))
  591. fi
  592. fi
  593. fi
  594. without_librt=no
  595. fi
  596. AM_CONDITIONAL(USE_LIBRT, test x$use_librt = xyes)
  597. # Enable tmwA
  598. AC_ARG_ENABLE(tmwa,
  599. [ --enable-tmwa Turn on tmwA support],
  600. [case "${enableval}" in
  601. yes) with_tmwa=true ;;
  602. no) with_tmwa=false ;;
  603. *) AC_MSG_ERROR(bad value ${enableval} for --enable-tmwa) ;;
  604. esac],[with_tmwa=true])
  605. AM_CONDITIONAL(ENABLE_TMWA, test x$with_tmwa = xtrue)
  606. # Enable checks
  607. AC_ARG_ENABLE(checks,
  608. [ --enable-checks Turn on internal checks (can be slow)],
  609. [case "${enableval}" in
  610. yes) with_checks=true ;;
  611. no) with_checks=false ;;
  612. *) AC_MSG_ERROR(bad value ${enableval} for --enable-checks) ;;
  613. esac],[with_checks=false])
  614. AM_CONDITIONAL(ENABLE_CHECKS, test x$with_checks = xtrue)
  615. # Enable portable
  616. AC_ARG_ENABLE(portable,
  617. [ --enable-portable Turn on portable mode for linux],
  618. [case "${enableval}" in
  619. yes) portable_enabled=true ;;
  620. no) portable_enabled=false ;;
  621. *) AC_MSG_ERROR(bad value ${enableval} for --enable-portable) ;;
  622. esac],[portable_enabled=false])
  623. AM_CONDITIONAL(ENABLE_PORTABLE, test x$portable_enabled = xtrue)
  624. # Enable debug
  625. AC_ARG_ENABLE(memdebug,
  626. [ --enable-memdebug Turn on memory debug mode],
  627. [case "${enableval}" in
  628. yes) memdebug_enabled=true ;;
  629. no) memdebug_enabled=false ;;
  630. *) AC_MSG_ERROR(bad value ${enableval} for --enable-memdebug) ;;
  631. esac],[memdebug_enabled=false])
  632. AM_CONDITIONAL(ENABLE_MEM_DEBUG, test x$memdebug_enabled = xtrue)
  633. # Enable unit tests
  634. AC_ARG_ENABLE(unittests,
  635. [ --enable-unittests Turn on unit tests],
  636. [case "${enableval}" in
  637. yes)
  638. unittests_enabled=true
  639. unittests_catch=true
  640. unittests_doctest=false
  641. unittests_embed=true
  642. ;;
  643. catch)
  644. unittests_enabled=true
  645. unittests_catch=true
  646. unittests_doctest=false
  647. unittests_embed=true
  648. ;;
  649. doctest)
  650. unittests_enabled=true
  651. unittests_catch=false
  652. unittests_doctest=true
  653. unittests_embed=true
  654. ;;
  655. systemcatch)
  656. unittests_enabled=true
  657. unittests_catch=true
  658. unittests_doctest=false
  659. unittests_embed=false
  660. ;;
  661. systemdoctest)
  662. unittests_enabled=true
  663. unittests_catch=false
  664. unittests_doctest=true
  665. unittests_embed=false
  666. ;;
  667. no)
  668. unittests_enabled=false
  669. unittests_embed=true
  670. ;;
  671. *) AC_MSG_ERROR(bad value ${enableval} for --enable-unittests) ;;
  672. esac],[unittests_enabled=false])
  673. AM_CONDITIONAL(ENABLE_UNITTESTS, test x$unittests_enabled = xtrue)
  674. AM_CONDITIONAL(ENABLE_UNITTESTS_CATCH, test x$unittests_catch = xtrue)
  675. AM_CONDITIONAL(ENABLE_UNITTESTS_DOCTEST, test x$unittests_doctest = xtrue)
  676. AM_CONDITIONAL(ENABLE_UNITTESTS_EMBED, test x$unittests_embed = xtrue)
  677. # Enable unit tests binaries only
  678. AC_ARG_ENABLE(unittestsbin,
  679. [ --enable-unittestsbin Turn on unit tests binary compilation only],
  680. [case "${enableval}" in
  681. yes)
  682. unittestsbin_enabled=true
  683. unittestsbin_catch=true
  684. unittestsbin_doctest=false
  685. unittestsbin_embed=true
  686. ;;
  687. catch)
  688. unittestsbin_enabled=true
  689. unittestsbin_catch=true
  690. unittestsbin_doctest=false
  691. unittestsbin_embed=true
  692. ;;
  693. doctest)
  694. unittestsbin_enabled=true
  695. unittestsbin_catch=false
  696. unittestsbin_doctest=true
  697. unittestsbin_embed=true
  698. ;;
  699. systemcatch)
  700. unittestsbin_enabled=true
  701. unittestsbin_catch=true
  702. unittestsbin_doctest=false
  703. unittestsbin_embed=false
  704. ;;
  705. systemdoctest)
  706. unittestsbin_enabled=true
  707. unittestsbin_catch=false
  708. unittestsbin_doctest=true
  709. unittestsbin_embed=false
  710. ;;
  711. no)
  712. unittestsbin_enabled=false
  713. unittestsbin_embed=true
  714. ;;
  715. *) AC_MSG_ERROR(bad value ${enableval} for --enable-unittestsbin) ;;
  716. esac],[unittestsbin_enabled=false])
  717. AM_CONDITIONAL(ENABLE_UNITTESTSBIN, test x$unittestsbin_enabled = xtrue)
  718. AM_CONDITIONAL(ENABLE_UNITTESTSBIN_CATCH, test x$unittestsbin_catch = xtrue)
  719. AM_CONDITIONAL(ENABLE_UNITTESTSBIN_DOCTEST, test x$unittestsbin_doctest = xtrue)
  720. AM_CONDITIONAL(ENABLE_UNITTESTSBIN_EMBED, test x$unittestsbin_embed = xtrue)
  721. # Override home directory for unit tests
  722. AC_ARG_WITH(unittestsdir,
  723. [ --with-unittestsdir override home directory for unit tests ],
  724. [
  725. if test "x$withval" != "xno"; then
  726. with_unittestsdir=$withval
  727. CXXFLAGS="$CXXFLAGS -DUNITESTSDIR=\\\"$withval\\\""
  728. fi
  729. ])
  730. # Enable tcmalloc
  731. AC_ARG_ENABLE(tcmalloc,
  732. [ --enable-tcmalloc Turn on tcmalloc],
  733. [case "${enableval}" in
  734. yes) tcmalloc_enabled=true
  735. LIBS="$LIBS -ltcmalloc"
  736. ;;
  737. no) tcmalloc_enabled=false ;;
  738. *) AC_MSG_ERROR(bad value ${enableval} for --enable-tcmalloc) ;;
  739. esac],[tcmalloc_enabled=false])
  740. # Enable google profiler
  741. AC_ARG_ENABLE(googleprofiler,
  742. [ --enable-googleprofiler Turn on google profiler],
  743. [case "${enableval}" in
  744. yes) googleprofiler_enabled=true
  745. LIBS="$LIBS -lprofiler"
  746. ;;
  747. no) googleprofiler_enabled=false ;;
  748. *) AC_MSG_ERROR(bad value ${enableval} for --enable-googleprofiler) ;;
  749. esac],[googleprofiler_enabled=false])
  750. AM_CONDITIONAL(ENABLE_GOOGLE_PROFILER, test x$googleprofiler_enabled = xtrue)
  751. # Enable gcc check plugin
  752. AC_ARG_ENABLE(checkplugin,
  753. [ --enable-checkplugin Turn on gcc check plugin],
  754. [case "${enableval}" in
  755. yes) checkplugin_enabled=true ;;
  756. no) checkplugin_enabled=false ;;
  757. *) AC_MSG_ERROR(bad value ${enableval} for --enable-checkplugin) ;;
  758. esac],[checkplugin_enabled=false])
  759. AM_CONDITIONAL(ENABLE_CHECKPLUGIN, test x$checkplugin_enabled = xtrue)
  760. # Enable custom NLS
  761. AC_ARG_ENABLE(customnls,
  762. [ --enable-customnls Turn on build in translation system (NLS)],
  763. [case "${enableval}" in
  764. yes) customnls_enabled=true ;;
  765. no) customnls_enabled=false ;;
  766. *) AC_MSG_ERROR(bad value ${enableval} for --enable-customnls) ;;
  767. esac],[customnls_enabled=false])
  768. AM_CONDITIONAL(ENABLE_CUSTOMNLS, test x$customnls_enabled = xtrue)
  769. if test "x$naclbuild_enabled" == "xtrue"; then
  770. AC_CHECK_SDL()
  771. fi
  772. AC_CHECK_LD_FLAG(-rdynamic, have_rdynamic)
  773. AM_CONDITIONAL(HAVE_RDYNAMIC, test x$have_rdynamic = xyes)
  774. AC_CHECK_HEADERS([execinfo.h],
  775. [
  776. AC_SEARCH_LIBS([backtrace],
  777. [execinfo],
  778. [
  779. have_execinfo=yes
  780. ],
  781. [
  782. have_execinfo=no
  783. ]
  784. )
  785. ],
  786. []
  787. )
  788. AM_CONDITIONAL(HAVE_EXECINFO, test x$have_execinfo = xyes)
  789. AC_CONFIG_FILES([
  790. manaplus.spec
  791. Makefile
  792. PKGBUILD
  793. src/Makefile
  794. data/Makefile
  795. data/evol/evol.desktop
  796. data/evol/Makefile
  797. data/fonts/Makefile
  798. data/fonts/src/Makefile
  799. data/graphics/Makefile
  800. data/graphics/badges/Makefile
  801. data/graphics/flags/Makefile
  802. data/graphics/gui/Makefile
  803. data/graphics/images/Makefile
  804. data/graphics/shaders/Makefile
  805. data/graphics/sprites/Makefile
  806. data/sfx/Makefile
  807. data/sfx/system/Makefile
  808. data/test/Makefile
  809. data/test/dir1/Makefile
  810. data/test/dir2/Makefile
  811. data/themes/Makefile
  812. data/themes/blacknblack/Makefile
  813. data/themes/blackwood/Makefile
  814. data/themes/classic/Makefile
  815. data/themes/enchilado/Makefile
  816. data/themes/golden-delicious/Makefile
  817. data/themes/jewelry/Makefile
  818. data/themes/jewelry-simple/Makefile
  819. data/themes/mana/Makefile
  820. data/themes/pink/Makefile
  821. data/themes/unity/Makefile
  822. data/themes/wood/Makefile
  823. data/tmw/tmw.desktop
  824. data/tmw/Makefile
  825. data/help/Makefile
  826. data/help/idx/Makefile
  827. data/help/tips/Makefile
  828. data/icons/Makefile
  829. data/music/Makefile
  830. data/perserver/Makefile
  831. data/perserver/default/Makefile
  832. data/translations/Makefile
  833. data/translations/help/Makefile
  834. data/translations/test/Makefile
  835. docs/Makefile
  836. po/Makefile.in
  837. ])
  838. AC_CONFIG_FILES([data/evol/evol], [chmod +x data/evol/evol])
  839. AC_CONFIG_FILES([data/tmw/tmw], [chmod +x data/tmw/tmw])
  840. AC_OUTPUT
  841. echo
  842. if test "$with_manaplusgame" == "yes"; then
  843. echo "Enabled building manaplus game."
  844. fi
  845. if test "$with_dyecmd" == "yes"; then
  846. echo "Enabled building dyecmd."
  847. fi
  848. if test "$unittests_enabled" == true; then
  849. echo "Enabled building unit tests."
  850. fi
  851. echo "Build with OpenGL: $with_opengl"
  852. echo
  853. echo "LIBS: $LIBS"
  854. echo "CPPFLAGS: $CPPFLAGS"
  855. echo
  856. echo "configure complete, now type \"make\""
  857. echo