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.
 
 
 

155 line
4.6 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_glew="no"
  17. if test "${enable_gl}" != "no"; then
  18. LOL_AC_CHECK_OPENGL_INNER()
  19. fi
  20. AM_CONDITIONAL(LOL_USE_GLEW, test "${ac_cv_my_have_glew}" != "no")
  21. ])
  22. # LOL_AC_CHECK_OPENGL_INNER()
  23. # ---------------------------
  24. AC_DEFUN([LOL_AC_CHECK_OPENGL_INNER],
  25. [
  26. dnl Find which version of OpenGL to use
  27. ac_cv_my_have_gl="no"
  28. ac_cv_my_stop_looking_for_gl="no"
  29. if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
  30. LIBS_save="$LIBS"
  31. LIBS="$LIBS -Wl,-framework -Wl,OpenGL"
  32. AC_MSG_CHECKING(for -framework OpenGL)
  33. AC_TRY_LINK([], [],
  34. [AC_MSG_RESULT(yes)
  35. ac_cv_my_have_gl="yes"
  36. GL_LIBS="${GL_LIBS} -framework OpenGL"
  37. LOL_TRY_CXXFLAGS(-ObjC++, [CXXFLAGS="${CXXFLAGS} -ObjC++"])
  38. AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available)],
  39. [AC_MSG_RESULT(no)])
  40. LIBS="$LIBS_save"
  41. fi
  42. if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
  43. LIBS_save="$LIBS"
  44. LIBS="$LIBS -Wl,-framework -Wl,OpenGLES"
  45. AC_MSG_CHECKING(for -framework OpenGLES)
  46. AC_TRY_LINK([], [],
  47. [AC_MSG_RESULT(yes)
  48. ac_cv_my_have_gl="yes"
  49. GL_LIBS="${GL_LIBS} -framework OpenGLES"
  50. LOL_TRY_CXXFLAGS(-ObjC++, [CXXFLAGS="${CXXFLAGS} -ObjC++"])
  51. AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)],
  52. [AC_MSG_RESULT(no)])
  53. LIBS="$LIBS_save"
  54. fi
  55. dnl Use the Raspberry Pi libraries?
  56. if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
  57. AC_CHECK_HEADERS(bcm_host.h,
  58. [AC_CHECK_LIB(vcos, main,
  59. [ac_cv_my_have_gl="yes"
  60. ac_cv_my_stop_looking_for_gl="yes"
  61. AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
  62. dnl FIXME: -lEGL does not belong here but the configure test fails
  63. dnl when cross-compiling, so we add it manually here.
  64. GL_LIBS="${GL_LIBS} -lGLESv2 -lEGL -lvcos -lvchiq_arm -lbcm_host"])])
  65. fi
  66. if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
  67. PKG_CHECK_MODULES(GLES2, glesv2,
  68. [ac_cv_my_have_gl="yes"
  69. AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
  70. GL_CFLAGS="${GL_CFLAGS} ${GLES2_CFLAGS}"
  71. GL_LIBS="${GL_LIBS} ${GLES2_LIBS}"],
  72. [:])
  73. fi
  74. if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
  75. AC_CHECK_HEADER(GLES2/gl2.h,
  76. [ac_cv_my_have_gl="yes"
  77. AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
  78. AC_CHECK_LIB(GLESv2, glEnable,
  79. [GL_LIBS="${GL_LIBS} -lGLESv2"])])
  80. fi
  81. if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
  82. PKG_CHECK_MODULES(GL, gl,
  83. [ac_cv_my_have_gl="yes"
  84. AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available)],
  85. [:])
  86. fi
  87. if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
  88. AC_CHECK_LIB(GL, glEnable,
  89. [ac_cv_my_have_gl="yes"
  90. AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available) # FIXME: hackish
  91. GL_LIBS="-lGL"])
  92. fi
  93. if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
  94. AC_CHECK_HEADER(GL/gl.h,
  95. [LIBS_save="$LIBS"
  96. LIBS="$LIBS -lopengl32"
  97. AC_MSG_CHECKING(for glLoadIdentity in -lopengl32)
  98. AC_TRY_LINK([#include <GL/gl.h>],
  99. [glLoadIdentity();],
  100. [ac_cv_my_have_gl="yes"
  101. AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available) # FIXME: hack
  102. AC_MSG_RESULT(yes)
  103. GL_LIBS="-lopengl32"],
  104. [AC_MSG_RESULT(no)])
  105. LIBS="$LIBS_save"])
  106. fi
  107. dnl Use Glew?
  108. PKG_CHECK_MODULES(GLEW, glew,
  109. [ac_cv_my_have_glew="yes"
  110. GL_CFLAGS="${GLEW_CFLAGS} ${GL_CFLAGS}"
  111. GL_LIBS="${GLEW_LIBS} ${GL_LIBS}"],
  112. [:])
  113. AC_CHECK_HEADER(GL/glew.h,
  114. [LIBS_save="${LIBS}"
  115. LIBS="${LIBS} -lglew32s ${GL_LIBS}"
  116. AC_MSG_CHECKING(for glewInit in -lglew32s)
  117. AC_TRY_LINK(
  118. [#include <GL/glew.h>],
  119. [glewInit();],
  120. [ac_cv_my_have_glew="yes"
  121. GL_LIBS="-lglew32s ${GL_LIBS}"
  122. AC_MSG_RESULT(yes)],
  123. [AC_MSG_RESULT(no)])
  124. LIBS="${LIBS_save}"])
  125. if test "${ac_cv_my_have_glew}" != "no"; then
  126. AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
  127. AC_DEFINE(LOL_USE_GLEW, 1, Define to 1 to use libglew)
  128. fi
  129. dnl Poor man's GL feature detection if all else failed.
  130. save_LIBS="${LIBS}"
  131. LIBS="${LIBS} ${GL_LIBS} ${GLES2_LIBS}"
  132. AC_CHECK_FUNCS(glBegin)
  133. LIBS="${save_LIBS}"
  134. dnl Warn if we couldn't find an OpenGL-like API
  135. if test "${ac_cv_my_have_gl}" = "no"; then
  136. AC_MSG_WARN([[No OpenGL or OpenGL ES implementation found]])
  137. fi
  138. ]) # LOL_AC_CHECK_OPENGL_INNER