You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

435 lines
13 KiB

  1. dnl configure script for Lol Engine
  2. AC_INIT(lolengine, 0.0)
  3. AC_PREREQ(2.50)
  4. AC_CONFIG_AUX_DIR(.auto)
  5. AC_CANONICAL_SYSTEM
  6. AM_INIT_AUTOMAKE([subdir-objects no-define tar-ustar silent-rules])
  7. dnl AM_MAINTAINER_MODE
  8. dnl Versioning of the separate software we ship
  9. LOLUNIT_VERSION=0.1
  10. AC_SUBST(LOLUNIT_VERSION)
  11. LOLREMEZ_VERSION=0.2
  12. AC_SUBST(LOLREMEZ_VERSION)
  13. AM_CONFIG_HEADER(config.h)
  14. AM_PROG_CC_C_O
  15. AC_PROG_CPP
  16. AC_PROG_CXX
  17. AC_PROG_CXXCPP
  18. AC_PROG_RANLIB
  19. AC_LIBTOOL_WIN32_DLL
  20. AM_PROG_LIBTOOL
  21. AC_LIBTOOL_CXX
  22. AC_C_CONST
  23. AC_C_INLINE
  24. dnl Ensure an error is thrown if pkg-config M4 files are not found.
  25. m4_pattern_allow([^PKG_CONFIG_LIBDIR$])
  26. m4_pattern_forbid([^PKG_CHECK_MODULES$])
  27. m4_pattern_forbid([^PKG_PROG_PKG_CONFIG$])
  28. dnl Do not use PKG_CONFIG_LIBDIR when cross-compiling.
  29. if test "${build}" != "${host}" -a "${PKG_CONFIG_LIBDIR}" = ""; then
  30. export PKG_CONFIG_LIBDIR=/dev/null
  31. fi
  32. dnl AC_PROG_EGREP only exists in autoconf 2.54+, so we use AC_EGREP_CPP right
  33. dnl now otherwise it might be set in an obscure if statement. Same thing for
  34. dnl PKG_PROG_PKG_CONFIG which needs to be called first.
  35. AC_EGREP_CPP(yes, foo)
  36. PKG_PROG_PKG_CONFIG()
  37. AM_CONDITIONAL(USE_GLEW, test "${ac_cv_my_have_glew}" != "no")
  38. dnl conditional builds
  39. AC_ARG_ENABLE(debug,
  40. [ --enable-debug build debug versions of the game (default no)])
  41. AC_ARG_ENABLE(release,
  42. [ --enable-release build final release of the game (default no)])
  43. AC_ARG_ENABLE(experimental,
  44. [ --enable-experimental experimental build (default no)])
  45. AC_CHECK_HEADERS(stdio.h stdarg.h inttypes.h endian.h stdint.h getopt.h)
  46. AC_CHECK_HEADERS(fastmath.h pthread.h libutil.h util.h pty.h glob.h)
  47. AC_CHECK_HEADERS(sys/ioctl.h sys/ptrace.h sys/stat.h sys/syscall.h sys/user.h)
  48. AC_CHECK_HEADERS(sys/wait.h)
  49. AC_CHECK_HEADERS(linux/kdev_t.h linux/major.h)
  50. AC_CHECK_HEADERS(security/pam_appl.h security/pam_misc.h)
  51. AC_CHECK_HEADERS(pam/pam_appl.h pam/pam_misc.h)
  52. if test "${enable_debug}" = "yes"; then
  53. AC_DEFINE(LOL_DEBUG, 1, Define to 1 to activate debug)
  54. OPT="-O"
  55. else
  56. OPT="-O3 -ffast-math -fno-strength-reduce -fomit-frame-pointer"
  57. fi
  58. if test "${enable_release}" = "yes"; then
  59. AC_DEFINE(LOL_RELEASE, 1, Define to 1 to activate final release)
  60. REL=""
  61. else
  62. REL="-g"
  63. fi
  64. if test "${enable_experimental}" = "yes"; then
  65. AC_DEFINE(LOL_EXPERIMENTAL, 1, Define to 1 to activate experimental build)
  66. fi
  67. dnl No exceptions
  68. CXXFLAGS="${CXXFLAGS} -fno-exceptions -fno-rtti"
  69. dnl Optimizations
  70. CXXFLAGS="${CXXFLAGS} ${REL} ${OPT}"
  71. dnl Code qui fait des warnings == code de porc == deux baffes dans ta gueule
  72. CXXFLAGS="${CXXFLAGS} -Wall -Wextra -Wpointer-arith -Wcast-align -Wcast-qual -Wshadow -Wsign-compare"
  73. AC_CHECK_LIB(m, sin, MATH_LIBS="${MATH_LIBS} -lm")
  74. AC_CHECK_LIB(pthread, main, LIBS="$LIBS -lpthread")
  75. AC_CHECK_LIB(util, forkpty, UTIL_LIBS="${UTIL_LIBS} -lutil")
  76. dnl Are we on the PS3?
  77. ac_cv_my_have_ps3="no"
  78. AC_CHECK_LIB(sysmodule_stub, cellSysmoduleLoadModule,
  79. [ac_cv_my_have_ps3="yes"
  80. LOL_LIBS="${LOL_LIBS} -lsysmodule_stub -lsysutil_stub -lresc_stub"
  81. dnl For PSGL
  82. AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available) # FIXME: hack
  83. GL_LIBS="${GL_LIBS} -lPSGL -lgcm_cmd -lgcm_sys_stub"
  84. dnl This is the old way
  85. if test "x${CELLSDK}" != x -a "x${CELLSDK}" = x; then
  86. CELL_SDK="${CELLSDK}"
  87. fi
  88. if test "x${enable_debug}" = xyes; then
  89. GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/debug"
  90. elif test "x${enable_release}" = xyes; then
  91. GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/ultra-opt"
  92. else
  93. GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/opt"
  94. fi
  95. dnl For the runtime Cg compiler
  96. GL_LIBS="${GL_LIBS} -lcgc -lPSGLcgc"
  97. dnl For the PNG decoder
  98. LOL_LIBS="${LOL_LIBS} -lpngdec_stub"
  99. dnl For the pad library
  100. LOL_LIBS="${LOL_LIBS} -lio_stub -lusbd_stub -lpadfilter"
  101. dnl Disable this warning, it's too verbose with vector.h
  102. CXXFLAGS="${CXXFLAGS} -Wno-sign-compare"
  103. AC_PATH_PROG(MAKE_FSELF, make_fself, no)],
  104. [MAKE_FSELF=no])
  105. AM_CONDITIONAL(USE_MAKE_FSELF, test "${MAKE_FSELF}" != "no")
  106. AM_CONDITIONAL(USE_PS3, test "${ac_cv_my_have_ps3}" != "no")
  107. dnl Are we on the Xbox 360?
  108. dnl Answer: NO! we don't know how to build for it anyway
  109. AM_CONDITIONAL(USE_X360, false)
  110. dnl Are we on a Direct3D 9 platform?
  111. #ac_cv_my_have_d3d9="no"
  112. #AC_CHECK_HEADERS(d3d9.h, [ac_cv_my_have_d3d9="yes"])
  113. #if test "${ac_cv_my_have_d3d9}" != "no"; then
  114. # D3D_LIBS="${D3D_LIBS} -ld3d9 -ld3dx9 -lxinput"
  115. # AC_DEFINE(USE_D3D9, 1, Define to 1 to use DirectX 9)
  116. #fi
  117. #AM_CONDITIONAL(USE_D3D9, test "${ac_cv_my_have_d3d9}" != "no")
  118. LIBS_save="$LIBS"
  119. LIBS="$LIBS -Wl,-framework -Wl,OpenGL"
  120. AC_MSG_CHECKING(for -framework OpenGL)
  121. AC_TRY_LINK([], [],
  122. [ac_cv_my_have_cocoa="yes"
  123. AC_MSG_RESULT(yes)
  124. GL_LIBS="${GL_LIBS} -framework OpenGL"
  125. CXXFLAGS="${CXXFLAGS} -ObjC++"],
  126. [AC_MSG_RESULT(no)])
  127. LIBS="$LIBS_save"
  128. dnl Which version of OpenGL to use?
  129. ac_cv_my_have_gl="no"
  130. PKG_CHECK_MODULES(GLES2, glesv2,
  131. [ac_cv_my_have_gl="yes"
  132. AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
  133. GL_CFLAGS="${GL_CFLAGS} ${GLES2_CFLAGS}"
  134. GL_LIBS="${GL_LIBS} ${GLES2_LIBS}"],
  135. [:])
  136. AC_CHECK_HEADER(GLES2/gl2.h,
  137. [AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
  138. ac_cv_my_have_gl="yes"])
  139. PKG_CHECK_MODULES(GL, gl,
  140. [ac_cv_my_have_gl="yes"
  141. AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available)],
  142. [:])
  143. AC_CHECK_LIB(GL, glLoadIdentity,
  144. [ac_cv_my_have_gl="yes"
  145. AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available) # FIXME: hackish
  146. GL_LIBS="-lGL"])
  147. AC_CHECK_HEADER(GL/gl.h,
  148. [LIBS_save="$LIBS"
  149. LIBS="$LIBS -lopengl32"
  150. AC_MSG_CHECKING(for glLoadIdentity in -lopengl32)
  151. AC_TRY_LINK([#include <GL/gl.h>],
  152. [glLoadIdentity();],
  153. [ac_cv_my_have_gl="yes"
  154. AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available) # FIXME: hack
  155. AC_MSG_RESULT(yes)
  156. GL_LIBS="-lopengl32"],
  157. [AC_MSG_RESULT(no)])
  158. LIBS="$LIBS_save"])
  159. AC_CHECK_HEADER(PSGL/psgl.h,
  160. [ac_cv_my_have_gl="yes"])
  161. if test "${ac_cv_my_have_gl}" = "no"; then
  162. AC_MSG_ERROR([[No OpenGL or OpenGL ES implementation found]])
  163. fi
  164. dnl Use Glew?
  165. ac_cv_my_have_glew="no"
  166. PKG_CHECK_MODULES(GLEW, glew,
  167. [ac_cv_my_have_glew="yes"
  168. GL_CFLAGS="${GLEW_CFLAGS} ${GL_CFLAGS}"
  169. GL_LIBS="${GLEW_LIBS} ${GL_LIBS}"],
  170. [:])
  171. AC_CHECK_HEADER(glew.h,
  172. [LIBS_save="${LIBS}"
  173. LIBS="${LIBS} -lglew32 ${GL_LIBS}"
  174. AC_MSG_CHECKING(for glewInit in -lglew32)
  175. AC_TRY_LINK(
  176. [#include <glew.h>],
  177. [glewInit();],
  178. [ac_cv_my_have_glew="yes"
  179. GL_LIBS="-lglew32 ${GL_LIBS}"
  180. AC_MSG_RESULT(yes)],
  181. [AC_MSG_RESULT(no)])
  182. LIBS="${LIBS_save}"])
  183. if test "${ac_cv_my_have_glew}" != "no"; then
  184. AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
  185. AC_DEFINE(USE_GLEW, 1, Define to 1 to use libglew)
  186. fi
  187. AM_CONDITIONAL(USE_GLEW, test "${ac_cv_my_have_glew}" != "no")
  188. dnl Poor man's GL feature detection if all else failed.
  189. save_LIBS="${LIBS}"
  190. LIBS="${LIBS} ${GL_LIBS} ${GLES2_LIBS}"
  191. AC_CHECK_FUNCS(glBegin)
  192. LIBS="${save_LIBS}"
  193. dnl Use SDL? (always required on Linux or Win32)
  194. ac_cv_my_have_sdl="no"
  195. ac_cv_my_have_sdl_image="no"
  196. ac_cv_my_have_sdl_mixer="no"
  197. dnl
  198. dnl First, try the proper pkg-config check
  199. PKG_CHECK_MODULES(SDL, sdl, [ac_cv_my_have_sdl="yes"], [:])
  200. PKG_CHECK_MODULES(SDLMIXER, SDL_mixer, [ac_cv_my_have_sdl_mixer="yes"], [:])
  201. PKG_CHECK_MODULES(SDLIMAGE, SDL_image, [ac_cv_my_have_sdl_image="yes"], [:])
  202. dnl
  203. dnl Then the old sdl-config method
  204. if test "x${cross_compiling}" != xyes -a "${ac_cv_my_have_sdl}" != yes; then
  205. AC_PATH_PROG(SDL_CONFIG, sdl-config, no)
  206. if test "${SDL_CONFIG}" != "no"; then
  207. SDL_CFLAGS="${SDL_CFLAGS} `${SDL_CONFIG} --cflags`"
  208. SDL_LIBS="${SDL_LIBS} `${SDL_CONFIG} --libs`"
  209. ac_cv_my_have_sdl="yes"
  210. fi
  211. fi
  212. dnl
  213. dnl Maybe all this has failed, try direct inclusion
  214. save_CPPFLAGS="${CPPFLAGS}"
  215. save_LIBS="${LIBS}"
  216. CPPFLAGS="${CPPFLAGS} ${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
  217. LIBS="${LIBS} ${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
  218. AC_CHECK_HEADERS(SDL.h SDL/SDL.h, [ac_cv_my_have_sdl="yes"])
  219. AC_CHECK_HEADERS(SDL_mixer.h, [ac_cv_my_have_sdl_mixer="yes"])
  220. AC_CHECK_HEADERS(SDL_image.h, [ac_cv_my_have_sdl_image="yes"])
  221. AC_CHECK_LIB(SDL, main,
  222. [SDL_LIBS="${SDL_LIBS} -lSDL"],
  223. [ac_cv_my_have_sdl="no"])
  224. AC_CHECK_LIB(SDL_mixer, main,
  225. [SDLMIXER_LIBS="${SDLMIXER_LIBS} -lSDL_mixer"],
  226. [ac_cv_my_have_sdl_mixer="no"])
  227. AC_CHECK_LIB(SDL_image, main,
  228. [SDLIMAGE_LIBS="${SDLIMAGE_LIBS} -lSDL_image"],
  229. [ac_cv_my_have_sdl_image="no"])
  230. SDL_CFLAGS="${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
  231. SDL_LIBS="${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
  232. CPPFLAGS="${save_CPPFLAGS}"
  233. LIBS="${save_LIBS}"
  234. if test "${ac_cv_my_have_sdl}" = "no"; then
  235. AC_MSG_WARN([SDL not found])
  236. else
  237. AC_DEFINE(USE_SDL, 1, Define to 1 to use SDL)
  238. fi
  239. if test "${ac_cv_my_have_sdl_mixer}" = "no"; then
  240. AC_MSG_WARN([SDL_mixer not found])
  241. else
  242. AC_DEFINE(USE_SDL_MIXER, 1, Define to 1 to use SDL_mixer)
  243. fi
  244. if test "${ac_cv_my_have_sdl_image}" = "no"; then
  245. AC_MSG_WARN([SDL_image not found])
  246. else
  247. AC_DEFINE(USE_SDL_IMAGE, 1, Define to 1 to use SDL_image)
  248. fi
  249. AM_CONDITIONAL(USE_SDL, test "${ac_cv_my_have_sdl}" = "yes")
  250. AM_CONDITIONAL(USE_SDL_MIXER, test "${ac_cv_my_have_sdl_mixer}" = "yes")
  251. AM_CONDITIONAL(USE_SDL_IMAGE, test "${ac_cv_my_have_sdl_image}" = "yes")
  252. dnl Use Flex's FlexLexer.h or ours?
  253. ac_cv_my_have_flexlexer_h="no"
  254. AC_LANG_PUSH(C++)
  255. AC_CHECK_HEADERS(FlexLexer.h, [ac_cv_my_have_flexlexer_h="yes"])
  256. AC_LANG_POP(C++)
  257. if test "x${ac_cv_my_have_flexlexer_h}" = "xno"; then
  258. LOL_CFLAGS="$LOL_CFLAGS -I\$(top_srcdir)/contrib/flex-2.5.35/include"
  259. fi
  260. dnl Use NativeClient?
  261. ac_cv_my_have_nacl="no"
  262. AC_LANG_PUSH(C++)
  263. AC_CHECK_HEADERS(ppapi/cpp/instance.h,
  264. [ac_cv_my_have_nacl="yes"
  265. dnl Disable this warning, it's too verbose with vector.h
  266. CXXFLAGS="${CXXFLAGS} -Wno-sign-compare"])
  267. AC_LANG_POP(C++)
  268. AM_CONDITIONAL(USE_NACL, test "${ac_cv_my_have_nacl}" != "no")
  269. dnl Use EGL?
  270. ac_cv_my_have_egl="no"
  271. PKG_CHECK_MODULES(EGL, egl, [ac_cv_my_have_egl="yes"], [:])
  272. if test "${ac_cv_my_have_egl}" != "no"; then
  273. AC_DEFINE(USE_EGL, 1, Define to 1 to use libegl)
  274. EGL_LIBS="${EGL_LIBS} -lX11"
  275. fi
  276. AM_CONDITIONAL(USE_EGL, test "${ac_cv_my_have_egl}" != "no")
  277. dnl Use libpng? (replacement for SDL_image)
  278. ac_cv_my_have_libpng="no"
  279. PKG_CHECK_MODULES(LIBPNG, libpng, [ac_cv_my_have_libpng="yes"], [:])
  280. if test "${ac_cv_my_have_libpng}" != "no"; then
  281. AC_DEFINE(USE_LIBPNG, 1, Define to 1 to use libpng)
  282. fi
  283. AM_CONDITIONAL(USE_LIBPNG, test "${ac_cv_my_have_libpng}" != "no")
  284. dnl Use Windows GDI+?
  285. ac_cv_my_have_gdiplus="no"
  286. AC_LANG_PUSH(C++)
  287. AC_CHECK_HEADERS(gdiplus.h,
  288. [ac_cv_my_have_gdiplus="yes"
  289. LOL_LIBS="${LOL_LIBS} -lgdiplus"],
  290. [ac_cv_my_have_gdiplus="no"],
  291. [#include <algorithm>
  292. using std::min;
  293. using std::max;
  294. #include <windows.h>])
  295. AC_LANG_POP(C++)
  296. if test "${ac_cv_my_have_gdiplus}" != "no"; then
  297. AC_DEFINE(USE_GDIPLUS, 1, Define to 1 to use GDI+)
  298. fi
  299. AM_CONDITIONAL(USE_GDIPLUS, test "${ac_cv_my_have_gdiplus}" = "yes")
  300. dnl Use libcaca? (required for font generation)
  301. ac_cv_my_have_caca="no"
  302. PKG_CHECK_MODULES(CACA, caca >= 0.99.beta17, [ac_cv_my_have_caca="yes"], [:])
  303. if test "${ac_cv_my_have_caca}" != "no"; then
  304. AC_DEFINE(USE_CACA, 1, Define to 1 to use libcaca)
  305. fi
  306. AM_CONDITIONAL(USE_CACA, test "${ac_cv_my_have_caca}" != "no")
  307. dnl Use libpipi? (required for video recording)
  308. ac_cv_my_have_pipi="no"
  309. PKG_CHECK_MODULES(PIPI, pipi, [ac_cv_my_have_pipi="yes"], [:])
  310. if test "${ac_cv_my_have_pipi}" != "no"; then
  311. AC_DEFINE(USE_PIPI, 1, Define to 1 to use libpipi)
  312. fi
  313. AM_CONDITIONAL(USE_PIPI, test "${ac_cv_my_have_pipi}" != "no")
  314. dnl Use GTK+? (required for the deushax editor)
  315. ac_cv_my_have_gtkgl="no"
  316. PKG_CHECK_MODULES(GTK, gtk+-2.0, [ac_cv_my_have_gtkgl="yes"], [:])
  317. PKG_CHECK_MODULES(GTKGL, gtkgl-2.0, [:], [ac_cv_my_have_gtkgl="no"])
  318. if test "${ac_cv_my_have_gtkgl}" != "no"; then
  319. AC_DEFINE(USE_GTKGL, 1, Define to 1 to use GtkGl)
  320. fi
  321. AM_CONDITIONAL(USE_GTKGL, test "${ac_cv_my_have_gtkgl}" != "no")
  322. dnl Can we build neercs?
  323. AM_CONDITIONAL(BUILD_NEERCS, test "${ac_cv_my_have_caca}" != "no" -a "${ac_cv_header_glob_h}" = "yes")
  324. dnl LolFx compilation rule
  325. LOLFX_BUILD='(echo "char const *"; echo "lolfx_$(notdir $(basename $(filter %.lolfx, $^))) ="; $(SED) '"'"'s/"/\\"/g'"'"' $(filter %.lolfx, $^) | $(SED) '"'"'s/\([[^\r]]*\).*/"\1\\n"/'"'"'; echo ";") | $(CXXCOMPILE) -xc++ -c - -o $@'
  326. AC_SUBST(LOLFX_BUILD)
  327. dnl Extra libraries we may need
  328. AC_SUBST(MATH_LIBS)
  329. AC_SUBST(PAM_LIBS)
  330. AC_SUBST(UTIL_LIBS)
  331. dnl How to use the Lol Engine inside this tree
  332. LOL_CFLAGS="$LOL_CFLAGS -I \$(top_srcdir)/src"
  333. LOL_CFLAGS="$LOL_CFLAGS $SDL_CFLAGS $GL_CFLAGS $EGL_CFLAGS $LIBPNG_CFLAGS"
  334. LOL_LIBS="$LOL_LIBS $SDL_LIBS $GL_LIBS $EGL_LIBS $LIBPNG_LIBS $D3D_LIBS"
  335. AC_SUBST(LOL_CFLAGS)
  336. AC_SUBST(LOL_LIBS)
  337. AC_CONFIG_FILES(
  338. [Makefile
  339. src/Makefile
  340. src/data/Makefile
  341. src/data/font/Makefile
  342. tutorial/Makefile
  343. test/Makefile
  344. test/math/Makefile
  345. test/sandbox/Makefile
  346. test/xolotl/Makefile
  347. build/Makefile
  348. binaries/Makefile
  349. games/Makefile
  350. tools/Makefile
  351. ])
  352. AC_CONFIG_FILES(
  353. [games/monsterz/Makefile
  354. ])
  355. AC_CONFIG_FILES(
  356. [games/deushax/Makefile
  357. games/deushax/art/Makefile
  358. games/deushax/art/test/Makefile
  359. games/deushax/gfx/Makefile
  360. games/deushax/maps/Makefile
  361. ])
  362. AC_CONFIG_FILES(
  363. [games/mrpigeon/Makefile
  364. ])
  365. AC_CONFIG_FILES(
  366. [games/orbital/Makefile
  367. ])
  368. AC_CONFIG_FILES(
  369. [games/ToukyDemo/Makefile
  370. ])
  371. AC_CONFIG_FILES(
  372. [tools/neercs/Makefile
  373. ])
  374. AC_OUTPUT