Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

157 lignes
4.7 KiB

  1. dnl
  2. dnl Lol Engine
  3. dnl
  4. dnl Copyright © 2010—2017 Sam Hocevar <sam@hocevar.net>
  5. dnl
  6. dnl Lol Engine is free software. It comes without any warranty, to
  7. dnl the extent permitted by applicable law. You can redistribute it
  8. dnl and/or modify it under the terms of the Do What the Fuck You Want
  9. dnl to Public License, Version 2, as published by the WTFPL Task Force.
  10. dnl See http://www.wtfpl.net/ for more details.
  11. dnl
  12. # LOL_AC_CHECK_OPENGL()
  13. # ---------------------
  14. AC_DEFUN([LOL_AC_CHECK_OPENGL],
  15. [
  16. ac_cv_my_have_gl="no"
  17. ac_cv_my_have_glew="no"
  18. if test "${enable_gl}" != "no"; then
  19. LOL_AC_CHECK_OPENGL_INNER()
  20. fi
  21. AM_CONDITIONAL(LOL_USE_GL, test "${ac_cv_my_have_gl}" != "no")
  22. AM_CONDITIONAL(LOL_USE_GLEW, test "${ac_cv_my_have_glew}" != "no")
  23. ])
  24. # LOL_AC_CHECK_OPENGL_INNER()
  25. # ---------------------------
  26. AC_DEFUN([LOL_AC_CHECK_OPENGL_INNER],
  27. [
  28. dnl Find which version of OpenGL to use
  29. ac_cv_my_have_gl="no"
  30. ac_cv_my_stop_looking_for_gl="no"
  31. if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
  32. LIBS_save="$LIBS"
  33. LIBS="$LIBS -Wl,-framework -Wl,OpenGL"
  34. AC_MSG_CHECKING(for -framework OpenGL)
  35. AC_TRY_LINK([], [],
  36. [AC_MSG_RESULT(yes)
  37. ac_cv_my_have_gl="yes"
  38. GL_LIBS="${GL_LIBS} -framework OpenGL"
  39. LOL_TRY_CXXFLAGS(-ObjC++, [CXXFLAGS="${CXXFLAGS} -ObjC++"])
  40. AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available)],
  41. [AC_MSG_RESULT(no)])
  42. LIBS="$LIBS_save"
  43. fi
  44. if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
  45. LIBS_save="$LIBS"
  46. LIBS="$LIBS -Wl,-framework -Wl,OpenGLES"
  47. AC_MSG_CHECKING(for -framework OpenGLES)
  48. AC_TRY_LINK([], [],
  49. [AC_MSG_RESULT(yes)
  50. ac_cv_my_have_gl="yes"
  51. GL_LIBS="${GL_LIBS} -framework OpenGLES"
  52. LOL_TRY_CXXFLAGS(-ObjC++, [CXXFLAGS="${CXXFLAGS} -ObjC++"])
  53. AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)],
  54. [AC_MSG_RESULT(no)])
  55. LIBS="$LIBS_save"
  56. fi
  57. dnl Use the Raspberry Pi libraries?
  58. if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
  59. AC_CHECK_HEADERS(bcm_host.h,
  60. [AC_CHECK_LIB(vcos, main,
  61. [ac_cv_my_have_gl="yes"
  62. ac_cv_my_stop_looking_for_gl="yes"
  63. AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
  64. dnl FIXME: -lEGL does not belong here but the configure test fails
  65. dnl when cross-compiling, so we add it manually here.
  66. GL_LIBS="${GL_LIBS} -lGLESv2 -lEGL -lvcos -lvchiq_arm -lbcm_host"])])
  67. fi
  68. if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
  69. PKG_CHECK_MODULES(GLES2, glesv2,
  70. [ac_cv_my_have_gl="yes"
  71. AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
  72. GL_CFLAGS="${GL_CFLAGS} ${GLES2_CFLAGS}"
  73. GL_LIBS="${GL_LIBS} ${GLES2_LIBS}"],
  74. [:])
  75. fi
  76. if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
  77. AC_CHECK_HEADER(GLES2/gl2.h,
  78. [ac_cv_my_have_gl="yes"
  79. AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
  80. AC_CHECK_LIB(GLESv2, glEnable,
  81. [GL_LIBS="${GL_LIBS} -lGLESv2"])])
  82. fi
  83. if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
  84. PKG_CHECK_MODULES(GL, gl,
  85. [ac_cv_my_have_gl="yes"
  86. AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available)],
  87. [:])
  88. fi
  89. if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
  90. AC_CHECK_LIB(GL, glEnable,
  91. [ac_cv_my_have_gl="yes"
  92. AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available) # FIXME: hackish
  93. GL_LIBS="-lGL"])
  94. fi
  95. if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
  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. fi
  109. dnl Use Glew?
  110. PKG_CHECK_MODULES(GLEW, glew,
  111. [ac_cv_my_have_glew="yes"
  112. GL_CFLAGS="${GLEW_CFLAGS} ${GL_CFLAGS}"
  113. GL_LIBS="${GLEW_LIBS} ${GL_LIBS}"],
  114. [:])
  115. AC_CHECK_HEADER(GL/glew.h,
  116. [LIBS_save="${LIBS}"
  117. LIBS="${LIBS} -lglew32s ${GL_LIBS}"
  118. AC_MSG_CHECKING(for glewInit in -lglew32s)
  119. AC_TRY_LINK(
  120. [#include <GL/glew.h>],
  121. [glewInit();],
  122. [ac_cv_my_have_glew="yes"
  123. GL_LIBS="-lglew32s ${GL_LIBS}"
  124. AC_MSG_RESULT(yes)],
  125. [AC_MSG_RESULT(no)])
  126. LIBS="${LIBS_save}"])
  127. if test "${ac_cv_my_have_glew}" != "no"; then
  128. AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
  129. AC_DEFINE(LOL_USE_GLEW, 1, Define to 1 to use libglew)
  130. fi
  131. dnl Poor man's GL feature detection if all else failed.
  132. save_LIBS="${LIBS}"
  133. LIBS="${LIBS} ${GL_LIBS} ${GLES2_LIBS}"
  134. AC_CHECK_FUNCS(glBegin)
  135. LIBS="${save_LIBS}"
  136. dnl Warn if we couldn't find an OpenGL-like API
  137. if test "${ac_cv_my_have_gl}" = "no"; then
  138. AC_MSG_WARN([[No OpenGL or OpenGL ES implementation found]])
  139. fi
  140. ]) # LOL_AC_CHECK_OPENGL_INNER