Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

147 righe
4.5 KiB

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