Collection of DPF-based plugins for packaging
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.

324 lines
10KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_check_glx.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_CHECK_GLX
  8. #
  9. # DESCRIPTION
  10. #
  11. # Check for GLX. If GLX is found, the required preprocessor and linker
  12. # flags are included in the output variables "GLX_CFLAGS" and "GLX_LIBS",
  13. # respectively. If no GLX implementation is found, "no_glx" is set to
  14. # "yes".
  15. #
  16. # If the header "GL/glx.h" is found, "HAVE_GL_GLX_H" is defined. If the
  17. # header "OpenGL/glx.h" is found, HAVE_OPENGL_GLX_H is defined. These
  18. # preprocessor definitions may not be mutually exclusive.
  19. #
  20. # You should use something like this in your headers:
  21. #
  22. # # if defined(HAVE_WINDOWS_H) && defined(_WIN32)
  23. # # include <windows.h>
  24. # # endif
  25. # # if defined(HAVE_GL_GLX_H)
  26. # # include <GL/glx.h>
  27. # # elif defined(HAVE_OPENGL_GLX_H)
  28. # # include <OpenGL/glx.h>
  29. # # else
  30. # # error no glx.h
  31. # # endif
  32. #
  33. # LICENSE
  34. #
  35. # Copyright (c) 2009 Braden McDaniel <braden@endoframe.com>
  36. # Copyright (c) 2013-2014 Bastien Roucaries <roucaries.bastien+autoconf@gmail.com>
  37. #
  38. # This program is free software; you can redistribute it and/or modify it
  39. # under the terms of the GNU General Public License as published by the
  40. # Free Software Foundation; either version 2 of the License, or (at your
  41. # option) any later version.
  42. #
  43. # This program is distributed in the hope that it will be useful, but
  44. # WITHOUT ANY WARRANTY; without even the implied warranty of
  45. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  46. # Public License for more details.
  47. #
  48. # You should have received a copy of the GNU General Public License along
  49. # with this program. If not, see <https://www.gnu.org/licenses/>.
  50. #
  51. # As a special exception, the respective Autoconf Macro's copyright owner
  52. # gives unlimited permission to copy, distribute and modify the configure
  53. # scripts that are the output of Autoconf when processing the Macro. You
  54. # need not follow the terms of the GNU General Public License when using
  55. # or distributing such scripts, even though portions of the text of the
  56. # Macro appear in them. The GNU General Public License (GPL) does govern
  57. # all other use of the material that constitutes the Autoconf Macro.
  58. #
  59. # This special exception to the GPL applies to versions of the Autoconf
  60. # Macro released by the Autoconf Archive. When you make and distribute a
  61. # modified version of the Autoconf Macro, you may extend this special
  62. # exception to the GPL to apply to your modified version as well.
  63. #serial 8
  64. # example program
  65. m4_define([_AX_CHECK_GLX_PROGRAM],
  66. [AC_LANG_PROGRAM([[
  67. # if defined(HAVE_WINDOWS_H) && defined(_WIN32)
  68. # include <windows.h>
  69. # endif
  70. # ifdef HAVE_GL_GLX_H
  71. # include <GL/glx.h>
  72. # elif defined(HAVE_OPENGL_GLX_H)
  73. # include <OpenGL/glx.h>
  74. # else
  75. # error no glx.h
  76. # endif
  77. ]],[[
  78. int major, minor;
  79. (void)glXQueryVersion(0,&major,&minor);]])])
  80. dnl Default include : add windows.h
  81. dnl see http://www.opengl.org/wiki/Platform_specifics:_Windows
  82. dnl (acceded 20120801)
  83. AC_DEFUN([_AX_CHECK_GLX_INCLUDES_DEFAULT],dnl
  84. [
  85. AC_INCLUDES_DEFAULT
  86. [
  87. # if defined(HAVE_WINDOWS_H) && defined(_WIN32)
  88. # include <windows.h>
  89. # endif
  90. ]
  91. ])
  92. dnl local save flags
  93. AC_DEFUN([_AX_CHECK_GLX_SAVE_FLAGS],
  94. [dnl
  95. ax_check_glx_saved_libs="${LIBS}"
  96. ax_check_glx_saved_cflags="${CFLAGS}"
  97. ax_check_glx_saved_cppflags="${CPPFLAGS}"
  98. ax_check_glx_saved_ldflags="${LDFLAGS}"
  99. ])
  100. dnl local restore flags
  101. AC_DEFUN([_AX_CHECK_GLX_RESTORE_FLAGS],
  102. [dnl
  103. LIBS="${ax_check_glx_saved_libs}"
  104. CFLAGS="${ax_check_glx_saved_cflags}"
  105. CPPFLAGS="${ax_check_glx_saved_cppflags}"
  106. LDFLAGS="${ax_check_glx_saved_ldflags}"
  107. ])
  108. # compile the example program
  109. AC_DEFUN([_AX_CHECK_GLX_COMPILE],
  110. [dnl
  111. AC_LANG_PUSH([C])
  112. _AX_CHECK_GLX_SAVE_FLAGS()
  113. CFLAGS="${GLX_CFLAGS} ${CFLAGS}"
  114. AC_COMPILE_IFELSE([_AX_CHECK_GLX_PROGRAM],
  115. [ax_check_glx_compile_opengl="yes"],
  116. [ax_check_glx_compile_opengl="no"])
  117. _AX_CHECK_GLX_RESTORE_FLAGS()
  118. AC_LANG_POP([C])
  119. ])
  120. # compile the example program (cache)
  121. AC_DEFUN([_AX_CHECK_GLX_COMPILE_CV],
  122. [dnl
  123. AC_CACHE_CHECK([for compiling a minimal OpenGL Utility (GLX) program],[ax_cv_check_glx_compile_opengl],
  124. [_AX_CHECK_GLX_COMPILE()
  125. ax_cv_check_glx_compile_opengl="${ax_check_glx_compile_opengl}"])
  126. ax_check_glx_compile_opengl="${ax_cv_check_glx_compile_opengl}"
  127. ])
  128. # link the example program
  129. AC_DEFUN([_AX_CHECK_GLX_LINK],
  130. [dnl
  131. AC_LANG_PUSH([C])
  132. _AX_CHECK_GLX_SAVE_FLAGS()
  133. CFLAGS="${GLX_CFLAGS} ${CFLAGS}"
  134. LIBS="${GLX_LIBS} ${LIBS}"
  135. LDFLAGS="${GLX_LDFLAGS} ${LDFLAGS}"
  136. AC_LINK_IFELSE([_AX_CHECK_GLX_PROGRAM],
  137. [ax_check_glx_link_opengl="yes"],
  138. [ax_check_glx_link_opengl="no"])
  139. _AX_CHECK_GLX_RESTORE_FLAGS()
  140. AC_LANG_POP([C])
  141. ])
  142. # link the example program (cache)
  143. AC_DEFUN([_AX_CHECK_GLX_LINK_CV],
  144. [dnl
  145. AC_CACHE_CHECK([for linking a minimal OpenGL Utility (GLX) program],[ax_cv_check_glx_link_opengl],
  146. [_AX_CHECK_GLX_LINK()
  147. ax_cv_check_glx_link_opengl="${ax_check_glx_link_opengl}"])
  148. ax_check_glx_link_opengl="${ax_cv_check_glx_link_opengl}"
  149. ])
  150. dnl Check headers manually (default case)
  151. AC_DEFUN([_AX_CHECK_GLX_HEADERS],
  152. [AC_LANG_PUSH([C])
  153. _AX_CHECK_GLX_SAVE_FLAGS()
  154. CFLAGS="${GLX_CFLAGS} ${CFLAGS}"
  155. # see comment in _AX_CHECK_GLX_INCLUDES_DEFAULT
  156. AC_CHECK_HEADERS([windows.h],[],[],[AC_INCLUDES_DEFAULT])
  157. AC_CHECK_HEADERS([GL/glx.h OpenGL/glx.h],
  158. [ax_check_glx_have_headers="yes";break],
  159. [ax_check_glx_have_headers_headers="no"],
  160. [_AX_CHECK_GLX_INCLUDES_DEFAULT()])
  161. # do not try darwin specific OpenGl/gl.h
  162. _AX_CHECK_GLX_RESTORE_FLAGS()
  163. AC_LANG_POP([C])
  164. ])
  165. # dnl try to found library (generic case)
  166. # dnl $1 is set to the library to found
  167. AC_DEFUN([_AX_CHECK_GLX_MANUAL_LIBS_GENERIC],
  168. [dnl
  169. ax_check_glx_manual_libs_generic_extra_libs="$1"
  170. AS_IF([test "X$ax_check_glx_manual_libs_generic_extra_libs" = "X"],
  171. [AC_MSG_ERROR([AX_CHECK_GLX_MANUAL_LIBS_GENERIC argument must no be empty])])
  172. AC_LANG_PUSH([C])
  173. _AX_CHECK_GLX_SAVE_FLAGS()
  174. CFLAGS="${GLX_CFLAGS} ${CFLAGS}"
  175. LIBS="${GLX_LIBS} ${LIBS}"
  176. AC_SEARCH_LIBS([glXGetClientString],[$ax_check_glx_manual_libs_generic_extra_libs],
  177. [ax_check_glx_lib_opengl="yes"],
  178. [ax_check_glx_lib_opengl="no"])
  179. AS_CASE([$ac_cv_search_glXGetClientString],
  180. ["none required"],[],
  181. [no],[],
  182. [GLX_LIBS="${ac_cv_search_glXGetClientString} ${GLX_LIBS}"])
  183. _AX_CHECK_GLX_RESTORE_FLAGS()
  184. AC_LANG_PUSH([C])
  185. ])
  186. dnl Check library manually: subroutine must set
  187. dnl $ax_check_gl_lib_opengl={yes,no}
  188. AC_DEFUN([_AX_CHECK_GLX_MANUAL_LIBS],
  189. [AC_REQUIRE([AC_CANONICAL_HOST])
  190. GLX_LIBS="${GLX_LIBS} ${GL_LIBS}"
  191. _AX_CHECK_GLX_MANUAL_LIBS_GENERIC([GLX glx MesaGLX])
  192. AC_CACHE_CHECK([for OpenGL Utility (GLX) libraries],[ax_cv_check_glx_lib_opengl],
  193. [ax_cv_check_glx_lib_opengl="${ax_check_glx_lib_opengl}"])
  194. ax_check_glx_lib_opengl="${ax_cv_check_glx_lib_opengl}"
  195. ])
  196. dnl Manual way to detect GLX
  197. AC_DEFUN([_AX_CHECK_GLX_MANUAL],
  198. [dnl
  199. # inherit cflags
  200. GLX_CFLAGS="${GLX_CFLAGS} ${GL_CFLAGS}"
  201. # check headers
  202. _AX_CHECK_GLX_HEADERS
  203. AS_IF([test "X$ax_check_glx_have_headers" = "Xyes"],
  204. [_AX_CHECK_GLX_MANUAL_LIBS],
  205. [ax_check_glx_lib_opengl="no"])
  206. AS_IF([test "X$ax_check_glx_lib_opengl" = "Xyes"],
  207. [_AX_CHECK_GLX_COMPILE_CV()],
  208. [ax_cv_check_glx_compile_opengl="no"])
  209. AS_IF([test "X$ax_cv_check_glx_compile_opengl" = "Xyes"],
  210. [_AX_CHECK_GLX_LINK_CV()],
  211. [ax_cv_check_glx_link_opengl="no"])
  212. AS_IF([test "X$ax_cv_check_glx_link_opengl" = "Xyes"],
  213. [no_glx="no"],
  214. [no_glx="yes"])
  215. ])
  216. # detect using pkgconfig
  217. AC_DEFUN([_AX_CHECK_GLX_PKG_CONFIG],
  218. [
  219. AC_REQUIRE([PKG_PROG_PKG_CONFIG])
  220. PKG_CHECK_MODULES([GLX],[glx],[ax_check_glx_pkg_config=yes],[ax_check_glx_pkg_config=no])
  221. AS_IF([test "X$ax_check_glx_pkg_config" = "Xyes"],[
  222. # check headers
  223. AC_LANG_PUSH([C])
  224. _AX_CHECK_GLX_SAVE_FLAGS()
  225. CFLAGS="${GLX_CFLAGS} ${CFLAGS}"
  226. AC_CHECK_HEADERS([windows.h],[],[],[AC_INCLUDES_DEFAULT])
  227. AC_CHECK_HEADERS([GL/glx.h OpenGL/glx.h],
  228. [ax_check_glx_have_headers="yes";break],
  229. [ax_check_glx_have_headers_headers="no"],
  230. [_AX_CHECK_GLX_INCLUDES_DEFAULT()])
  231. _AX_CHECK_GLX_RESTORE_FLAGS()
  232. AC_LANG_POP([C])
  233. AC_CACHE_CHECK([for OpenGL Utility (GLX) headers],[ax_cv_check_glx_have_headers],
  234. [ax_cv_check_glx_have_headers="${ax_check_glx_have_headers}"])
  235. # pkgconfig library are supposed to work ...
  236. AS_IF([test "X$ax_cv_check_glx_have_headers" = "Xno"],
  237. [AC_MSG_ERROR("Pkgconfig detected OpenGL Utility (GLX) library has no headers!")])
  238. _AX_CHECK_GLX_COMPILE_CV()
  239. AS_IF([test "X$ax_cv_check_glx_compile_opengl" = "Xno"],
  240. [AC_MSG_ERROR("Pkgconfig detected OpenGL Utility (GLX) library could not be used for compiling minimal program!")])
  241. _AX_CHECK_GLX_LINK_CV()
  242. AS_IF([test "X$ax_cv_check_glx_link_opengl" = "Xno"],
  243. [AC_MSG_ERROR("Pkgconfig detected OpenGL Utility (GLX) library could not be used for linking minimal program!")])
  244. ])
  245. ])
  246. # entry point
  247. AC_DEFUN([AX_CHECK_GLX],dnl
  248. [
  249. AC_REQUIRE([AX_CHECK_GL])
  250. AC_REQUIRE([PKG_PROG_PKG_CONFIG])
  251. # set flags
  252. no_glx="yes"
  253. have_GLX="no"
  254. AC_MSG_CHECKING([for a working OpenGL Utility (GLX) implementation by pkg-config])
  255. # try first pkgconfig
  256. AS_IF([test "X${PKG_CONFIG}" = "X"],
  257. [AC_MSG_RESULT([no])
  258. ax_check_glx_pkg_config=no],
  259. [AC_MSG_RESULT([yes])
  260. _AX_CHECK_GLX_PKG_CONFIG()])
  261. # if no pkg-config or pkg-config fail try manual way
  262. AS_IF([test "X$ax_check_glx_pkg_config" = "Xno"],
  263. [_AX_CHECK_GLX_MANUAL()],
  264. [no_glx=no])
  265. AC_MSG_CHECKING([for a working OpenGL Utility (GLX) implementation])
  266. AS_IF([test "X$no_glx" = "Xno"],
  267. [have_GLX="yes"
  268. AC_MSG_RESULT([yes])
  269. AC_MSG_CHECKING([for CFLAGS needed for OpenGL Utility (GLX)])
  270. AC_MSG_RESULT(["${GLX_CFLAGS}"])
  271. AC_MSG_CHECKING([for LIBS needed for OpenGL Utility (GLX)])
  272. AC_MSG_RESULT(["${GLX_LIBS}"])
  273. AC_MSG_CHECKING([for LDFLAGS needed for OpenGL Utility (GLX)])
  274. AC_MSG_RESULT(["${GLX_LDFLAGS}"])],
  275. [AC_MSG_RESULT([no])
  276. GLX_CFLAGS=""
  277. GLX_LIBS=""
  278. GLX_LDFLAGS=""])
  279. AC_SUBST([GLX_CFLAGS])
  280. AC_SUBST([GLX_LIBS])
  281. AC_SUBST([GLX_LDFLAGS])
  282. ])