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.

272 lines
8.2 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([no-define tar-ustar])
  7. dnl AM_MAINTAINER_MODE
  8. AM_CONFIG_HEADER(config.h)
  9. AM_PROG_CC_C_O
  10. AC_PROG_CPP
  11. AC_PROG_CXX
  12. AC_PROG_CXXCPP
  13. AC_PROG_RANLIB
  14. AC_LIBTOOL_WIN32_DLL
  15. AM_PROG_LIBTOOL
  16. AC_LIBTOOL_CXX
  17. AC_C_CONST
  18. AC_C_INLINE
  19. dnl Ensure an error is thrown if pkg-config M4 files are not found.
  20. m4_pattern_allow([^PKG_CONFIG_LIBDIR$])
  21. m4_pattern_forbid([^PKG_CHECK_MODULES$])
  22. m4_pattern_forbid([^PKG_PROG_PKG_CONFIG$])
  23. dnl Do not use PKG_CONFIG_LIBDIR when cross-compiling.
  24. if test "${build}" != "${host}" -a "${PKG_CONFIG_LIBDIR}" = ""; then
  25. export PKG_CONFIG_LIBDIR=/dev/null
  26. fi
  27. dnl AC_PROG_EGREP only exists in autoconf 2.54+, so we use AC_EGREP_CPP right
  28. dnl now otherwise it might be set in an obscure if statement. Same thing for
  29. dnl PKG_PROG_PKG_CONFIG which needs to be called first.
  30. AC_EGREP_CPP(yes, foo)
  31. PKG_PROG_PKG_CONFIG()
  32. dnl conditional builds
  33. AC_ARG_ENABLE(debug,
  34. [ --enable-debug build debug versions of the game (default no)])
  35. AC_ARG_ENABLE(release,
  36. [ --enable-release build final release of the game (default no)])
  37. AC_ARG_ENABLE(experimental,
  38. [ --enable-experimental experimental build (default no)])
  39. AC_CHECK_HEADERS(stdio.h stdarg.h inttypes.h endian.h stdint.h getopt.h fastmath.h)
  40. if test "${enable_debug}" = "yes"; then
  41. AC_DEFINE(LOL_DEBUG, 1, Define to 1 to activate debug)
  42. OPT="-O"
  43. else
  44. OPT="-O3 -ffast-math -fno-strength-reduce -fomit-frame-pointer"
  45. fi
  46. if test "${enable_release}" = "yes"; then
  47. AC_DEFINE(LOL_RELEASE, 1, Define to 1 to activate final release)
  48. REL=""
  49. else
  50. REL="-g"
  51. fi
  52. if test "${enable_experimental}" = "yes"; then
  53. AC_DEFINE(LOL_EXPERIMENTAL, 1, Define to 1 to activate experimental build)
  54. fi
  55. dnl No exceptions
  56. CXXFLAGS="${CXXFLAGS} -fno-exceptions"
  57. dnl Optimizations
  58. CXXFLAGS="${CXXFLAGS} ${REL} ${OPT}"
  59. dnl Code qui fait des warnings == code de porc == deux baffes dans ta gueule
  60. CXXFLAGS="${CXXFLAGS} -Wall -Wextra -Wpointer-arith -Wcast-align -Wcast-qual -Wshadow -Wsign-compare"
  61. AC_CHECK_LIB(m, sin, MATH_LIBS="${MATH_LIBS} -lm")
  62. dnl Are we on the PS3?
  63. AC_CHECK_LIB(sysmodule_stub, cellSysmoduleLoadModule,
  64. [LOL_LIBS="${LOL_LIBS} -lsysmodule_stub -lsysutil_stub -lresc_stub"
  65. dnl For PSGL
  66. AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available) # FIXME: hack
  67. GL_LIBS="${GL_LIBS} -lPSGL -lgcm_cmd -lgcm_sys_stub"
  68. if test "x${enable_debug}" = xyes; then
  69. GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/debug"
  70. elif test "x${enable_release}" = xyes; then
  71. GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/ultra-opt"
  72. else
  73. GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/opt"
  74. fi
  75. dnl For the runtime Cg compiler
  76. GL_LIBS="${GL_LIBS} -lcgc -lPSGLcgc"
  77. dnl For the PNG decoder
  78. LOL_LIBS="${LOL_LIBS} -lpngdec_stub"
  79. dnl For the pad library
  80. LOL_LIBS="${LOL_LIBS} -lio_stub -lusbd_stub -lpadfilter"
  81. AC_PATH_PROG(MAKE_FSELF, make_fself, no)],
  82. [MAKE_FSELF=no])
  83. AM_CONDITIONAL(USE_MAKE_FSELF, test "${MAKE_FSELF}" != "no")
  84. dnl Which version of OpenGL to use?
  85. ac_cv_my_have_gl="no"
  86. PKG_CHECK_MODULES(GLES2, glesv2,
  87. [ac_cv_my_have_gl="yes"
  88. AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
  89. GL_CFLAGS="${GL_CFLAGS} ${GLES2_CFLAGS}"
  90. GL_LIBS="${GL_LIBS} ${GLES2_LIBS}"],
  91. [:])
  92. AC_CHECK_LIB(GL, glLoadIdentity,
  93. [ac_cv_my_have_gl="yes"
  94. AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available) # FIXME: hackish
  95. GL_LIBS="-lGL"])
  96. AC_CHECK_HEADER(GL/gl.h,
  97. [LIBS_save="$LIBS"
  98. LIBS="$LIBS -lopengl32"
  99. AC_MSG_CHECKING(for glLoadIdentity in -lopengl32)
  100. AC_TRY_LINK([#include <GL/gl.h>],
  101. [glLoadIdentity();],
  102. [ac_cv_my_have_gl="yes"
  103. AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available) # FIXME: hack
  104. AC_MSG_RESULT(yes)
  105. GL_LIBS="-lopengl32"],
  106. [AC_MSG_RESULT(no)])
  107. LIBS="$LIBS_save"])
  108. AC_CHECK_HEADER(PSGL/psgl.h,
  109. [ac_cv_my_have_gl="yes"])
  110. if test "${ac_cv_my_have_gl}" = "no"; then
  111. AC_MSG_ERROR([[No OpenGL or OpenGL ES implementation found]])
  112. fi
  113. dnl Use Glew?
  114. ac_cv_my_have_glew="no"
  115. PKG_CHECK_MODULES(GLEW, glew,
  116. [ac_cv_my_have_glew="yes"
  117. GL_CFLAGS="${GLEW_CFLAGS} ${GL_CFLAGS}"
  118. GL_LIBS="${GLEW_LIBS} ${GL_LIBS}"],
  119. [:])
  120. AC_CHECK_HEADER(GL/glew.h,
  121. [LIBS_save="${LIBS}"
  122. LIBS="${LIBS} -lglew32 ${GL_LIBS}"
  123. AC_MSG_CHECKING(for glewInit in -lglew32)
  124. AC_TRY_LINK(
  125. [#include <GL/glew.h>],
  126. [glewInit();],
  127. [ac_cv_my_have_glew="yes"
  128. GL_LIBS="-lglew32 ${GL_LIBS}"
  129. AC_MSG_RESULT(yes)],
  130. [AC_MSG_RESULT(no)])
  131. LIBS="${LIBS_save}"])
  132. if test "${ac_cv_my_have_glew}" != "no"; then
  133. AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
  134. AC_DEFINE(USE_GLEW, 1, Define to 1 to use libglew)
  135. fi
  136. AM_CONDITIONAL(USE_GLEW, test "${ac_cv_my_have_glew}" != "no")
  137. dnl Poor man's GL feature detection if all else failed.
  138. save_LIBS="${LIBS}"
  139. LIBS="${LIBS} ${GL_LIBS} ${GLES2_LIBS}"
  140. AC_CHECK_FUNCS(glBegin)
  141. LIBS="${save_LIBS}"
  142. dnl Use SDL? (always required on Linux or Win32)
  143. ac_cv_my_have_sdl="no"
  144. if test "x$cross_compiling" != xyes; then
  145. ac_cv_my_have_sdl="yes"
  146. AC_PATH_PROG(SDL_CONFIG, sdl-config, no)
  147. if test "${SDL_CONFIG}" != "no" -a "x$cross_compiling" != xyes; then
  148. SDL_CFLAGS="${SDL_CFLAGS} `sdl-config --cflags`"
  149. SDL_LIBS="${SDL_LIBS} `sdl-config --libs`"
  150. fi
  151. PKG_CHECK_MODULES(SDL, sdl, [:],
  152. [SDL_LIBS="${SDL_LIBS} -lSDL"])
  153. PKG_CHECK_MODULES(SDLMIXER, SDL_mixer, [:],
  154. [SDLMIXER_LIBS="${SDLMIXER_LIBS} -lSDL_mixer"])
  155. PKG_CHECK_MODULES(SDLIMAGE, SDL_image, [:],
  156. [SDLIMAGE_LIBS="${SDLIMAGE_LIBS} -lSDL_image"])
  157. SDL_CFLAGS="${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
  158. SDL_LIBS="${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
  159. save_CPPFLAGS="${CPPFLAGS}"
  160. CPPFLAGS="${CPPFLAGS} ${SDL_CFLAGS}"
  161. AC_CHECK_HEADERS(SDL_mixer.h, [:], [ac_cv_my_have_sdl="no"])
  162. AC_CHECK_HEADERS(SDL_image.h, [:], [ac_cv_my_have_sdl="no"])
  163. CPPFLAGS="${save_CPPFLAGS}"
  164. if test "${ac_cv_my_have_sdl}" = "no"; then
  165. AC_MSG_WARN([[One of SDL, SDL_Image or SDL_Mixer not found]])
  166. else
  167. AC_DEFINE(USE_SDL, 1, Define to 1 to use SDL)
  168. fi
  169. fi
  170. AM_CONDITIONAL(USE_SDL, test "${ac_cv_my_have_sdl}" = "yes")
  171. dnl Use EGL?
  172. ac_cv_my_have_egl="no"
  173. PKG_CHECK_MODULES(EGL, egl, [ac_cv_my_have_egl="yes"], [:])
  174. if test "${ac_cv_my_have_egl}" != "no"; then
  175. AC_DEFINE(USE_EGL, 1, Define to 1 to use libegl)
  176. EGL_LIBS="${EGL_LIBS} -lX11"
  177. fi
  178. AM_CONDITIONAL(USE_EGL, test "${ac_cv_my_have_egl}" != "no")
  179. dnl Use libpng? (replacement for SDL_image)
  180. ac_cv_my_have_libpng="no"
  181. PKG_CHECK_MODULES(LIBPNG, libpng, [ac_cv_my_have_libpng="yes"], [:])
  182. if test "${ac_cv_my_have_libpng}" != "no"; then
  183. AC_DEFINE(USE_LIBPNG, 1, Define to 1 to use libpng)
  184. fi
  185. AM_CONDITIONAL(USE_LIBPNG, test "${ac_cv_my_have_libpng}" != "no")
  186. dnl Use libcaca? (required for font generation)
  187. ac_cv_my_have_caca="no"
  188. PKG_CHECK_MODULES(CACA, caca >= 0.99.beta17, [ac_cv_my_have_caca="yes"], [:])
  189. if test "${ac_cv_my_have_caca}" != "no"; then
  190. AC_DEFINE(USE_CACA, 1, Define to 1 to use libcaca)
  191. fi
  192. AM_CONDITIONAL(USE_CACA, test "${ac_cv_my_have_caca}" != "no")
  193. dnl Use libpipi? (required for video recording)
  194. ac_cv_my_have_pipi="no"
  195. PKG_CHECK_MODULES(PIPI, pipi, [ac_cv_my_have_pipi="yes"], [:])
  196. if test "${ac_cv_my_have_pipi}" != "no"; then
  197. AC_DEFINE(USE_PIPI, 1, Define to 1 to use libpipi)
  198. fi
  199. AM_CONDITIONAL(USE_PIPI, test "${ac_cv_my_have_pipi}" != "no")
  200. dnl Use GTK+? (required for the deushax editor)
  201. ac_cv_my_have_gtkgl="no"
  202. PKG_CHECK_MODULES(GTK, gtk+-2.0, [ac_cv_my_have_gtkgl="yes"], [:])
  203. PKG_CHECK_MODULES(GTKGL, gtkgl-2.0, [:], [ac_cv_my_have_gtkgl="no"])
  204. if test "${ac_cv_my_have_gtkgl}" != "no"; then
  205. AC_DEFINE(USE_GTKGL, 1, Define to 1 to use GtkGl)
  206. fi
  207. AM_CONDITIONAL(USE_GTKGL, test "${ac_cv_my_have_gtkgl}" != "no")
  208. dnl How to use the Lol Engine inside this tree
  209. LOL_CFLAGS="$LOL_CFLAGS -I \$(top_srcdir)/src"
  210. LOL_CFLAGS="$LOL_CFLAGS $SDL_CFLAGS $GL_CFLAGS $EGL_CFLAGS $LIBPNG_CFLAGS"
  211. LOL_LIBS="$LOL_LIBS $SDL_LIBS $GL_LIBS $EGL_LIBS $LIBPNG_LIBS"
  212. AC_SUBST(MATH_LIBS)
  213. AC_SUBST(LOL_CFLAGS)
  214. AC_SUBST(LOL_LIBS)
  215. AC_CONFIG_FILES(
  216. [Makefile
  217. src/Makefile
  218. test/Makefile
  219. gfx/Makefile
  220. gfx/font/Makefile
  221. tools/Makefile
  222. ])
  223. AC_CONFIG_FILES(
  224. [monsterz/Makefile
  225. ])
  226. AC_CONFIG_FILES(
  227. [deushax/Makefile
  228. deushax/art/Makefile
  229. deushax/art/test/Makefile
  230. deushax/gfx/Makefile
  231. deushax/maps/Makefile
  232. ])
  233. AC_OUTPUT