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.
 
 
 

430 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)
  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. if test "${enable_debug}" = "yes"; then
  52. AC_DEFINE(LOL_DEBUG, 1, Define to 1 to activate debug)
  53. OPT="-O"
  54. else
  55. OPT="-O3 -ffast-math -fno-strength-reduce -fomit-frame-pointer"
  56. fi
  57. if test "${enable_release}" = "yes"; then
  58. AC_DEFINE(LOL_RELEASE, 1, Define to 1 to activate final release)
  59. REL=""
  60. else
  61. REL="-g"
  62. fi
  63. if test "${enable_experimental}" = "yes"; then
  64. AC_DEFINE(LOL_EXPERIMENTAL, 1, Define to 1 to activate experimental build)
  65. fi
  66. dnl No exceptions
  67. CXXFLAGS="${CXXFLAGS} -fno-exceptions -fno-rtti"
  68. dnl Optimizations
  69. CXXFLAGS="${CXXFLAGS} ${REL} ${OPT}"
  70. dnl Code qui fait des warnings == code de porc == deux baffes dans ta gueule
  71. CXXFLAGS="${CXXFLAGS} -Wall -Wextra -Wpointer-arith -Wcast-align -Wcast-qual -Wshadow -Wsign-compare"
  72. AC_CHECK_LIB(m, sin, MATH_LIBS="${MATH_LIBS} -lm")
  73. AC_CHECK_LIB(pthread, main, LIBS="$LIBS -lpthread")
  74. AC_CHECK_LIB(util, forkpty, UTIL_LIBS="${UTIL_LIBS} -lutil")
  75. dnl Are we on the PS3?
  76. ac_cv_my_have_ps3="no"
  77. AC_CHECK_LIB(sysmodule_stub, cellSysmoduleLoadModule,
  78. [ac_cv_my_have_ps3="yes"
  79. LOL_LIBS="${LOL_LIBS} -lsysmodule_stub -lsysutil_stub -lresc_stub"
  80. dnl For PSGL
  81. AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available) # FIXME: hack
  82. GL_LIBS="${GL_LIBS} -lPSGL -lgcm_cmd -lgcm_sys_stub"
  83. dnl This is the old way
  84. if test "x${CELLSDK}" != x -a "x${CELLSDK}" = x; then
  85. CELL_SDK="${CELLSDK}"
  86. fi
  87. if test "x${enable_debug}" = xyes; then
  88. GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/debug"
  89. elif test "x${enable_release}" = xyes; then
  90. GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/ultra-opt"
  91. else
  92. GL_LIBS="${GL_LIBS} -L${CELL_SDK}/target/ppu/lib/PSGL/RSX/opt"
  93. fi
  94. dnl For the runtime Cg compiler
  95. GL_LIBS="${GL_LIBS} -lcgc -lPSGLcgc"
  96. dnl For the PNG decoder
  97. LOL_LIBS="${LOL_LIBS} -lpngdec_stub"
  98. dnl For the pad library
  99. LOL_LIBS="${LOL_LIBS} -lio_stub -lusbd_stub -lpadfilter"
  100. dnl Disable this warning, it's too verbose with vector.h
  101. CXXFLAGS="${CXXFLAGS} -Wno-sign-compare"
  102. AC_PATH_PROG(MAKE_FSELF, make_fself, no)],
  103. [MAKE_FSELF=no])
  104. AM_CONDITIONAL(USE_MAKE_FSELF, test "${MAKE_FSELF}" != "no")
  105. AM_CONDITIONAL(USE_PS3, test "${ac_cv_my_have_ps3}" != "no")
  106. dnl Are we on the Xbox 360?
  107. dnl Answer: NO! we don't know how to build for it anyway
  108. AM_CONDITIONAL(USE_X360, false)
  109. dnl Are we on a Direct3D 9 platform?
  110. #ac_cv_my_have_d3d9="no"
  111. #AC_CHECK_HEADERS(d3d9.h, [ac_cv_my_have_d3d9="yes"])
  112. #if test "${ac_cv_my_have_d3d9}" != "no"; then
  113. # D3D_LIBS="${D3D_LIBS} -ld3d9 -ld3dx9 -lxinput"
  114. # AC_DEFINE(USE_D3D9, 1, Define to 1 to use DirectX 9)
  115. #fi
  116. #AM_CONDITIONAL(USE_D3D9, test "${ac_cv_my_have_d3d9}" != "no")
  117. LIBS_save="$LIBS"
  118. LIBS="$LIBS -Wl,-framework -Wl,OpenGL"
  119. AC_MSG_CHECKING(for -framework OpenGL)
  120. AC_TRY_LINK([], [],
  121. [ac_cv_my_have_cocoa="yes"
  122. AC_MSG_RESULT(yes)
  123. GL_LIBS="${GL_LIBS} -framework OpenGL"
  124. CXXFLAGS="${CXXFLAGS} -ObjC++"],
  125. [AC_MSG_RESULT(no)])
  126. LIBS="$LIBS_save"
  127. dnl Which version of OpenGL to use?
  128. ac_cv_my_have_gl="no"
  129. PKG_CHECK_MODULES(GLES2, glesv2,
  130. [ac_cv_my_have_gl="yes"
  131. AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
  132. GL_CFLAGS="${GL_CFLAGS} ${GLES2_CFLAGS}"
  133. GL_LIBS="${GL_LIBS} ${GLES2_LIBS}"],
  134. [:])
  135. AC_CHECK_HEADER(GLES2/gl2.h,
  136. [AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
  137. ac_cv_my_have_gl="yes"])
  138. PKG_CHECK_MODULES(GL, gl,
  139. [ac_cv_my_have_gl="yes"
  140. AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available)],
  141. [:])
  142. AC_CHECK_LIB(GL, glLoadIdentity,
  143. [ac_cv_my_have_gl="yes"
  144. AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available) # FIXME: hackish
  145. GL_LIBS="-lGL"])
  146. AC_CHECK_HEADER(GL/gl.h,
  147. [LIBS_save="$LIBS"
  148. LIBS="$LIBS -lopengl32"
  149. AC_MSG_CHECKING(for glLoadIdentity in -lopengl32)
  150. AC_TRY_LINK([#include <GL/gl.h>],
  151. [glLoadIdentity();],
  152. [ac_cv_my_have_gl="yes"
  153. AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available) # FIXME: hack
  154. AC_MSG_RESULT(yes)
  155. GL_LIBS="-lopengl32"],
  156. [AC_MSG_RESULT(no)])
  157. LIBS="$LIBS_save"])
  158. AC_CHECK_HEADER(PSGL/psgl.h,
  159. [ac_cv_my_have_gl="yes"])
  160. if test "${ac_cv_my_have_gl}" = "no"; then
  161. AC_MSG_ERROR([[No OpenGL or OpenGL ES implementation found]])
  162. fi
  163. dnl Use Glew?
  164. ac_cv_my_have_glew="no"
  165. PKG_CHECK_MODULES(GLEW, glew,
  166. [ac_cv_my_have_glew="yes"
  167. GL_CFLAGS="${GLEW_CFLAGS} ${GL_CFLAGS}"
  168. GL_LIBS="${GLEW_LIBS} ${GL_LIBS}"],
  169. [:])
  170. AC_CHECK_HEADER(glew.h,
  171. [LIBS_save="${LIBS}"
  172. LIBS="${LIBS} -lglew32 ${GL_LIBS}"
  173. AC_MSG_CHECKING(for glewInit in -lglew32)
  174. AC_TRY_LINK(
  175. [#include <glew.h>],
  176. [glewInit();],
  177. [ac_cv_my_have_glew="yes"
  178. GL_LIBS="-lglew32 ${GL_LIBS}"
  179. AC_MSG_RESULT(yes)],
  180. [AC_MSG_RESULT(no)])
  181. LIBS="${LIBS_save}"])
  182. if test "${ac_cv_my_have_glew}" != "no"; then
  183. AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
  184. AC_DEFINE(USE_GLEW, 1, Define to 1 to use libglew)
  185. fi
  186. AM_CONDITIONAL(USE_GLEW, test "${ac_cv_my_have_glew}" != "no")
  187. dnl Poor man's GL feature detection if all else failed.
  188. save_LIBS="${LIBS}"
  189. LIBS="${LIBS} ${GL_LIBS} ${GLES2_LIBS}"
  190. AC_CHECK_FUNCS(glBegin)
  191. LIBS="${save_LIBS}"
  192. dnl Use SDL? (always required on Linux or Win32)
  193. ac_cv_my_have_sdl="no"
  194. ac_cv_my_have_sdl_image="no"
  195. ac_cv_my_have_sdl_mixer="no"
  196. dnl
  197. dnl First, try the proper pkg-config check
  198. PKG_CHECK_MODULES(SDL, sdl, [ac_cv_my_have_sdl="yes"], [:])
  199. PKG_CHECK_MODULES(SDLMIXER, SDL_mixer, [ac_cv_my_have_sdl_mixer="yes"], [:])
  200. PKG_CHECK_MODULES(SDLIMAGE, SDL_image, [ac_cv_my_have_sdl_image="yes"], [:])
  201. dnl
  202. dnl Then the old sdl-config method
  203. if test "x${cross_compiling}" != xyes -a "${ac_cv_my_have_sdl}" != yes; then
  204. AC_PATH_PROG(SDL_CONFIG, sdl-config, no)
  205. if test "${SDL_CONFIG}" != "no"; then
  206. SDL_CFLAGS="${SDL_CFLAGS} `${SDL_CONFIG} --cflags`"
  207. SDL_LIBS="${SDL_LIBS} `${SDL_CONFIG} --libs`"
  208. ac_cv_my_have_sdl="yes"
  209. fi
  210. fi
  211. dnl
  212. dnl Maybe all this has failed, try direct inclusion
  213. save_CPPFLAGS="${CPPFLAGS}"
  214. save_LIBS="${LIBS}"
  215. CPPFLAGS="${CPPFLAGS} ${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
  216. LIBS="${LIBS} ${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
  217. AC_CHECK_HEADERS(SDL.h SDL/SDL.h, [ac_cv_my_have_sdl="yes"])
  218. AC_CHECK_HEADERS(SDL_mixer.h, [ac_cv_my_have_sdl_mixer="yes"])
  219. AC_CHECK_HEADERS(SDL_image.h, [ac_cv_my_have_sdl_image="yes"])
  220. AC_CHECK_LIB(SDL, main,
  221. [SDL_LIBS="${SDL_LIBS} -lSDL"],
  222. [ac_cv_my_have_sdl="no"])
  223. AC_CHECK_LIB(SDL_mixer, main,
  224. [SDLMIXER_LIBS="${SDLMIXER_LIBS} -lSDL_mixer"],
  225. [ac_cv_my_have_sdl_mixer="no"])
  226. AC_CHECK_LIB(SDL_image, main,
  227. [SDLIMAGE_LIBS="${SDLIMAGE_LIBS} -lSDL_image"],
  228. [ac_cv_my_have_sdl_image="no"])
  229. SDL_CFLAGS="${SDL_CFLAGS} ${SDLMIXER_CFLAGS} ${SDLIMAGE_CFLAGS}"
  230. SDL_LIBS="${SDL_LIBS} ${SDLMIXER_LIBS} ${SDLIMAGE_LIBS}"
  231. CPPFLAGS="${save_CPPFLAGS}"
  232. LIBS="${save_LIBS}"
  233. if test "${ac_cv_my_have_sdl}" = "no"; then
  234. AC_MSG_WARN([SDL not found])
  235. else
  236. AC_DEFINE(USE_SDL, 1, Define to 1 to use SDL)
  237. fi
  238. if test "${ac_cv_my_have_sdl_mixer}" = "no"; then
  239. AC_MSG_WARN([SDL_mixer not found])
  240. else
  241. AC_DEFINE(USE_SDL_MIXER, 1, Define to 1 to use SDL_mixer)
  242. fi
  243. if test "${ac_cv_my_have_sdl_image}" = "no"; then
  244. AC_MSG_WARN([SDL_image not found])
  245. else
  246. AC_DEFINE(USE_SDL_IMAGE, 1, Define to 1 to use SDL_image)
  247. fi
  248. AM_CONDITIONAL(USE_SDL, test "${ac_cv_my_have_sdl}" = "yes")
  249. AM_CONDITIONAL(USE_SDL_MIXER, test "${ac_cv_my_have_sdl_mixer}" = "yes")
  250. AM_CONDITIONAL(USE_SDL_IMAGE, test "${ac_cv_my_have_sdl_image}" = "yes")
  251. dnl Use Flex's FlexLexer.h or ours?
  252. ac_cv_my_have_flexlexer_h="no"
  253. AC_LANG_PUSH(C++)
  254. AC_CHECK_HEADERS(FlexLexer.h, [ac_cv_my_have_flexlexer_h="yes"])
  255. AC_LANG_POP(C++)
  256. if test "x${ac_cv_my_have_flexlexer_h}" = "xno"; then
  257. LOL_CFLAGS="$LOL_CFLAGS -I\$(top_srcdir)/contrib/flex-2.5.35/include"
  258. fi
  259. dnl Use NativeClient?
  260. ac_cv_my_have_nacl="no"
  261. AC_LANG_PUSH(C++)
  262. AC_CHECK_HEADERS(ppapi/cpp/instance.h,
  263. [ac_cv_my_have_nacl="yes"
  264. dnl Disable this warning, it's too verbose with vector.h
  265. CXXFLAGS="${CXXFLAGS} -Wno-sign-compare"])
  266. AC_LANG_POP(C++)
  267. AM_CONDITIONAL(USE_NACL, test "${ac_cv_my_have_nacl}" != "no")
  268. dnl Use EGL?
  269. ac_cv_my_have_egl="no"
  270. PKG_CHECK_MODULES(EGL, egl, [ac_cv_my_have_egl="yes"], [:])
  271. if test "${ac_cv_my_have_egl}" != "no"; then
  272. AC_DEFINE(USE_EGL, 1, Define to 1 to use libegl)
  273. EGL_LIBS="${EGL_LIBS} -lX11"
  274. fi
  275. AM_CONDITIONAL(USE_EGL, test "${ac_cv_my_have_egl}" != "no")
  276. dnl Use libpng? (replacement for SDL_image)
  277. ac_cv_my_have_libpng="no"
  278. PKG_CHECK_MODULES(LIBPNG, libpng, [ac_cv_my_have_libpng="yes"], [:])
  279. if test "${ac_cv_my_have_libpng}" != "no"; then
  280. AC_DEFINE(USE_LIBPNG, 1, Define to 1 to use libpng)
  281. fi
  282. AM_CONDITIONAL(USE_LIBPNG, test "${ac_cv_my_have_libpng}" != "no")
  283. dnl Use Windows GDI+?
  284. ac_cv_my_have_gdiplus="no"
  285. AC_LANG_PUSH(C++)
  286. AC_CHECK_HEADERS(gdiplus.h,
  287. [ac_cv_my_have_gdiplus="yes"
  288. LOL_LIBS="${LOL_LIBS} -lgdiplus"],
  289. [ac_cv_my_have_gdiplus="no"],
  290. [#include <algorithm>
  291. using std::min;
  292. using std::max;
  293. #include <windows.h>])
  294. AC_LANG_POP(C++)
  295. if test "${ac_cv_my_have_gdiplus}" != "no"; then
  296. AC_DEFINE(USE_GDIPLUS, 1, Define to 1 to use GDI+)
  297. fi
  298. AM_CONDITIONAL(USE_GDIPLUS, test "${ac_cv_my_have_gdiplus}" = "yes")
  299. dnl Use libcaca? (required for font generation)
  300. ac_cv_my_have_caca="no"
  301. PKG_CHECK_MODULES(CACA, caca >= 0.99.beta17, [ac_cv_my_have_caca="yes"], [:])
  302. if test "${ac_cv_my_have_caca}" != "no"; then
  303. AC_DEFINE(USE_CACA, 1, Define to 1 to use libcaca)
  304. fi
  305. AM_CONDITIONAL(USE_CACA, test "${ac_cv_my_have_caca}" != "no")
  306. dnl Use libpipi? (required for video recording)
  307. ac_cv_my_have_pipi="no"
  308. PKG_CHECK_MODULES(PIPI, pipi, [ac_cv_my_have_pipi="yes"], [:])
  309. if test "${ac_cv_my_have_pipi}" != "no"; then
  310. AC_DEFINE(USE_PIPI, 1, Define to 1 to use libpipi)
  311. fi
  312. AM_CONDITIONAL(USE_PIPI, test "${ac_cv_my_have_pipi}" != "no")
  313. dnl Use GTK+? (required for the deushax editor)
  314. ac_cv_my_have_gtkgl="no"
  315. PKG_CHECK_MODULES(GTK, gtk+-2.0, [ac_cv_my_have_gtkgl="yes"], [:])
  316. PKG_CHECK_MODULES(GTKGL, gtkgl-2.0, [:], [ac_cv_my_have_gtkgl="no"])
  317. if test "${ac_cv_my_have_gtkgl}" != "no"; then
  318. AC_DEFINE(USE_GTKGL, 1, Define to 1 to use GtkGl)
  319. fi
  320. AM_CONDITIONAL(USE_GTKGL, test "${ac_cv_my_have_gtkgl}" != "no")
  321. dnl LolFx compilation rule
  322. 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 $@'
  323. AC_SUBST(LOLFX_BUILD)
  324. dnl Extra libraries we may need
  325. AC_SUBST(MATH_LIBS)
  326. AC_SUBST(PAM_LIBS)
  327. AC_SUBST(UTIL_LIBS)
  328. dnl How to use the Lol Engine inside this tree
  329. LOL_CFLAGS="$LOL_CFLAGS -I \$(top_srcdir)/src"
  330. LOL_CFLAGS="$LOL_CFLAGS $SDL_CFLAGS $GL_CFLAGS $EGL_CFLAGS $LIBPNG_CFLAGS"
  331. LOL_LIBS="$LOL_LIBS $SDL_LIBS $GL_LIBS $EGL_LIBS $LIBPNG_LIBS $D3D_LIBS"
  332. AC_SUBST(LOL_CFLAGS)
  333. AC_SUBST(LOL_LIBS)
  334. AC_CONFIG_FILES(
  335. [Makefile
  336. src/Makefile
  337. src/data/Makefile
  338. src/data/font/Makefile
  339. tutorial/Makefile
  340. test/Makefile
  341. test/math/Makefile
  342. test/sandbox/Makefile
  343. test/xolotl/Makefile
  344. build/Makefile
  345. binaries/Makefile
  346. games/Makefile
  347. tools/Makefile
  348. ])
  349. AC_CONFIG_FILES(
  350. [games/monsterz/Makefile
  351. ])
  352. AC_CONFIG_FILES(
  353. [games/deushax/Makefile
  354. games/deushax/art/Makefile
  355. games/deushax/art/test/Makefile
  356. games/deushax/gfx/Makefile
  357. games/deushax/maps/Makefile
  358. ])
  359. AC_CONFIG_FILES(
  360. [games/mrpigeon/Makefile
  361. ])
  362. AC_CONFIG_FILES(
  363. [games/orbital/Makefile
  364. ])
  365. AC_CONFIG_FILES(
  366. [games/ToukyDemo/Makefile
  367. ])
  368. AC_CONFIG_FILES(
  369. [tools/neercs/Makefile
  370. ])
  371. AC_OUTPUT