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.

283 lines
11KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_check_glu.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_CHECK_GLU([ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
  8. #
  9. # DESCRIPTION
  10. #
  11. # Checks for GLUT. If a valid GLU implementation is found, the configure
  12. # script would export the C preprocessor symbol "HAVE_GLU=1".
  13. #
  14. # If either a valid GLU header or library was not found, by default the
  15. # configure script would exit on error. This behavior can be overwritten
  16. # by providing a custom "ACTION-IF-NOT-FOUND" hook.
  17. #
  18. # If the header, library was found, and been tested for compiling and
  19. # linking the configuration would export the required compiler flags to
  20. # "GLU_CFLAGS" and "GLU_LIBS" environment variables. These two variables
  21. # can also be overwritten by defining the environment variables before
  22. # executing the configure program. If it was predefined, configure would
  23. # not try to overwrite it, but it would still perform the compile and link
  24. # test. Only when the tests succeeded does the configure script to export
  25. # "HAVE_GLU=1" and to run "ACTION-IF-FOUND" hook.
  26. #
  27. # If user didn't specify the "ACTION-IF-FOUND" hook, the configuration
  28. # would prepend "GLU_CFLAGS" and "GLU_LIBS" to "CFLAGS" and "LIBS", like
  29. # many other autoconf macros do.
  30. #
  31. # If the header "GL/glu.h" is found, "HAVE_GL_GLU_H" is defined. If the
  32. # header "OpenGL/glu.h" is found, HAVE_OPENGL_GLU_H is defined.
  33. #
  34. # You should use something like this in your headers:
  35. #
  36. # # if defined(HAVE_WINDOWS_H) && defined(_WIN32)
  37. # # include <windows.h>
  38. # # endif
  39. # # if defined(HAVE_GL_GLU_H)
  40. # # include <GL/glu.h>
  41. # # elif defined(HAVE_OPENGL_GLU_H)
  42. # # include <OpenGL/glu.h>
  43. # # else
  44. # # error no glu.h
  45. # # endif
  46. #
  47. # On the OSX platform, you can use the option --with-xquartz-gl to use
  48. # X11/Xquartz GLU implementation instead of the system built in GLU
  49. # framework.
  50. #
  51. # Some implementations (in particular, some versions of Mac OS X) are
  52. # known to treat the GLU tesselator callback function type as "GLvoid
  53. # (*)(...)" rather than the standard "GLvoid (*)()". If the former
  54. # condition is detected, this macro defines "HAVE_VARARGS_GLU_TESSCB".
  55. #
  56. # LICENSE
  57. #
  58. # Copyright (c) 2009 Braden McDaniel <braden@endoframe.com>
  59. # Copyright (c) 2013 Bastien Roucaries <roucaries.bastien+autoconf@gmail.com>
  60. # Copyright (c) 2016 Felix Chern <idryman@gmail.com>
  61. #
  62. # This program is free software; you can redistribute it and/or modify it
  63. # under the terms of the GNU General Public License as published by the
  64. # Free Software Foundation; either version 2 of the License, or (at your
  65. # option) any later version.
  66. #
  67. # This program is distributed in the hope that it will be useful, but
  68. # WITHOUT ANY WARRANTY; without even the implied warranty of
  69. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  70. # Public License for more details.
  71. #
  72. # You should have received a copy of the GNU General Public License along
  73. # with this program. If not, see <https://www.gnu.org/licenses/>.
  74. #
  75. # As a special exception, the respective Autoconf Macro's copyright owner
  76. # gives unlimited permission to copy, distribute and modify the configure
  77. # scripts that are the output of Autoconf when processing the Macro. You
  78. # need not follow the terms of the GNU General Public License when using
  79. # or distributing such scripts, even though portions of the text of the
  80. # Macro appear in them. The GNU General Public License (GPL) does govern
  81. # all other use of the material that constitutes the Autoconf Macro.
  82. #
  83. # This special exception to the GPL applies to versions of the Autoconf
  84. # Macro released by the Autoconf Archive. When you make and distribute a
  85. # modified version of the Autoconf Macro, you may extend this special
  86. # exception to the GPL to apply to your modified version as well.
  87. #serial 23
  88. # example program
  89. m4_define([_AX_CHECK_GLU_PROGRAM],
  90. [AC_LANG_PROGRAM([[
  91. # if defined(HAVE_WINDOWS_H) && defined(_WIN32)
  92. # include <windows.h>
  93. # endif
  94. # ifdef HAVE_GL_GLU_H
  95. # include <GL/glu.h>
  96. # elif defined(HAVE_OPENGL_GLU_H)
  97. # include <OpenGL/glu.h>
  98. # else
  99. # error no glu.h
  100. # endif
  101. ]],[[gluBeginCurve(0)]])])
  102. dnl Default include : add windows.h
  103. dnl see http://www.opengl.org/wiki/Platform_specifics:_Windows
  104. dnl (acceded 20120801)
  105. AC_DEFUN([_AX_CHECK_GLU_INCLUDES_DEFAULT],dnl
  106. [
  107. AC_INCLUDES_DEFAULT
  108. [
  109. # if defined(HAVE_WINDOWS_H) && defined(_WIN32)
  110. # include <windows.h>
  111. # endif
  112. ]
  113. ])
  114. # check tesselation callback function signature.
  115. m4_define([_AX_CHECK_GLU_VARARGS_TESSVB_PROGRAM],
  116. [AC_LANG_PROGRAM([[
  117. # if defined(HAVE_WINDOWS_H) && defined(_WIN32)
  118. # include <windows.h>
  119. # endif
  120. # ifdef HAVE_GL_GLU_H
  121. # include <GL/glu.h>
  122. # elif defined(HAVE_OPENGL_GLU_H)
  123. # include <OpenGL/glu.h>
  124. # else
  125. # error no glu.h
  126. # endif
  127. ]],
  128. [[GLvoid (*func)(...); gluTessCallback(0, 0, func)]])
  129. ])
  130. # _AX_CHECK_GLU_SAVE_FLAGS(LIST-OF-FLAGS,[LANG])
  131. # ----------------------------------------------
  132. # Save the flags to shell variables.
  133. # Example: _AX_CHECK_GLU_SAVE_FLAGS([[CFLAGS],[LIBS]]) expands to
  134. # AC_LANG_PUSH([C])
  135. # glu_saved_flag_cflags=$CFLAGS
  136. # glu_saved_flag_libs=$LIBS
  137. # CFLAGS="$GLU_CFLAGS $CFLAGS"
  138. # LIBS="$GLU_LIBS $LIBS"
  139. #
  140. # Can optionally support other LANG by specifying $2
  141. AC_DEFUN([_AX_CHECK_GLU_SAVE_FLAGS], [
  142. m4_ifval([$2],
  143. [AC_LANG_PUSH([$2])],
  144. [AC_LANG_PUSH([C])])
  145. AX_SAVE_FLAGS_WITH_PREFIX([GLU],[$1]) dnl defined in ax_check_gl
  146. ])
  147. # _AX_CHECK_GLU_RESTORE_FLAGS(LIST-OF-FLAGS)
  148. # Use this marcro to restore the flags you saved using
  149. # _AX_CHECK_GLU_SAVE_FLAGS
  150. #
  151. # Example: _AX_CHECK_GLU_RESTORE_FLAGS([[CFLAGS],[LIBS]]) expands to
  152. # CFLAGS="$glu_saved_flag_cflags"
  153. # LIBS="$glu_saved_flag_libs"
  154. # AC_LANG_POP([C])
  155. AC_DEFUN([_AX_CHECK_GLU_RESTORE_FLAGS], [
  156. AX_RESTORE_FLAGS_WITH_PREFIX([GLU],[$1]) dnl defined in ax_check_gl
  157. m4_ifval([$2],
  158. [AC_LANG_POP([$2])],
  159. [AC_LANG_POP([C])])
  160. ])
  161. # Search headers and export $ax_check_glu_have_headers
  162. AC_DEFUN([_AX_CHECK_GLU_HEADERS], [
  163. _AX_CHECK_GLU_SAVE_FLAGS([CFLAGS])
  164. AC_CHECK_HEADERS([$1],
  165. [ax_check_glu_have_headers="yes";],
  166. [],
  167. [_AX_CHECK_GLU_INCLUDES_DEFAULT()])
  168. _AX_CHECK_GLU_RESTORE_FLAGS([CFLAGS])
  169. ])
  170. # _AX_CHECK_GLU_SEARCH_LIBS(LIBS)
  171. # -------------------------------
  172. # Search for a valid GLU lib from $1 and set
  173. # GLU_LIBS respectively
  174. AC_DEFUN([_AX_CHECK_GLU_SEARCH_LIBS], [
  175. _AX_CHECK_GLU_SAVE_FLAGS([[CFLAGS],[LIBS]])
  176. AC_SEARCH_LIBS([gluBeginCurve],[$1],
  177. [GLU_LIBS="${GLU_LIBS:-$ac_cv_search_gluBeginCurve}"])
  178. _AX_CHECK_GLU_RESTORE_FLAGS([[CFLAGS],[LIBS]])
  179. ])
  180. # OSX specific GLU checks
  181. AC_DEFUN([_AX_CHECK_DARWIN_GLU], [
  182. AC_REQUIRE([_WITH_XQUARTZ_GL])
  183. AS_IF([test "x$with_xquartz_gl" != "xno"],
  184. [GLU_LIBS="${GLU_LIBS:--lGLU}"],
  185. [GLU_LIBS="${GLU_LIBS:--framework OpenGL}"])
  186. ])
  187. # AX_CHECK_GLU([ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
  188. # -----------------------------------------------------
  189. # Checks GLU and provides hooks for success and failures
  190. AC_DEFUN([AX_CHECK_GLU],[
  191. AC_REQUIRE([AC_CANONICAL_HOST])
  192. AC_REQUIRE([_WITH_XQUARTZ_GL])
  193. AC_REQUIRE([PKG_PROG_PKG_CONFIG])
  194. AC_ARG_VAR([GLU_CFLAGS],[C compiler flags for GLU, overriding system check])
  195. AC_ARG_VAR([GLU_LIBS],[Linker flags for GLU, overriding system check])
  196. dnl Setup GLU_CFLAGS and GLU_LIBS
  197. AS_CASE([${host}],
  198. [*-darwin*],[_AX_CHECK_DARWIN_GLU],
  199. [*-cygwin*],[_AX_CHECK_GLU_SEARCH_LIBS([GLU glu MesaGLU glu32])
  200. AC_CHECK_HEADERS([windows.h])],
  201. # try first native
  202. [*-mingw*],[_AX_CHECK_GLU_SEARCH_LIBS([glu32 GLU glu MesaGLU])
  203. AC_CHECK_HEADERS([windows.h])],
  204. [PKG_PROG_PKG_CONFIG
  205. PKG_CHECK_MODULES([GLU],[glu],
  206. [],
  207. [_AX_CHECK_GLU_SEARCH_LIBS([GLU glu MesaGLU])])
  208. ])
  209. AS_CASE([$host],
  210. [*-darwin*],
  211. [AS_IF([test "X$with_xquartz_gl" = "Xno"],
  212. [_AX_CHECK_GLU_HEADERS([OpenGL/glu.h])],
  213. [_AX_CHECK_GLU_HEADERS([GL/glu.h])]
  214. )],
  215. [_AX_CHECK_GLU_HEADERS([GL/glu.h])])
  216. dnl compile test
  217. AS_IF([test "X$ax_check_glu_have_headers" = "Xyes"],
  218. [AC_CACHE_CHECK([for compiling a minimal OpenGL Utility (GLU) program],
  219. [ax_cv_check_glu_compile],
  220. [_AX_CHECK_GLU_SAVE_FLAGS([CFLAGS])
  221. AC_COMPILE_IFELSE([_AX_CHECK_GLU_PROGRAM],
  222. [ax_cv_check_glu_compile="yes"],
  223. [ax_cv_check_glu_compile="no"])
  224. _AX_CHECK_GLU_RESTORE_FLAGS([CFLAGS])])
  225. ])
  226. dnl link test
  227. AS_IF([test "X$ax_cv_check_glu_compile" = "Xyes"],
  228. [AC_CACHE_CHECK([for linking a minimal GLU program],
  229. [ax_cv_check_glu_link],
  230. [_AX_CHECK_GLU_SAVE_FLAGS([[CFLAGS],[LIBS]])
  231. AC_LINK_IFELSE([_AX_CHECK_GLU_PROGRAM],
  232. [ax_cv_check_glu_link="yes"],
  233. [ax_cv_check_glu_link="no"])
  234. _AX_CHECK_GLU_RESTORE_FLAGS([[CFLAGS],[LIBS]])])
  235. ])
  236. #
  237. # Some versions of Mac OS X include a broken interpretation of the GLU
  238. # tesselation callback function signature.
  239. AS_IF([test "X$ax_cv_check_glu_link" = "Xyes"],
  240. [AC_CACHE_CHECK([if GLU varargs tesselator is using non-standard form],
  241. [ax_cv_varargs_glu_tesscb],
  242. [_AX_CHECK_GLU_SAVE_FLAGS([CFLAGS],[C++])
  243. AC_COMPILE_IFELSE([_AX_CHECK_GLU_VARARGS_TESSVB_PROGRAM],
  244. [ax_cv_varargs_glu_tesscb="yes"],
  245. [ax_cv_varargs_glu_tesscb="no"])
  246. _AX_CHECK_GLU_RESTORE_FLAGS([CFLAGS],[C++])])
  247. AS_IF([test "X$ax_cv_varargs_glu_tesscb" = "yes"],
  248. [AC_DEFINE([HAVE_VARARGS_GLU_TESSCB], [1],
  249. [Use nonstandard varargs form for the GLU tesselator callback])])
  250. ])
  251. dnl hook
  252. AS_IF([test "X$ax_cv_check_glu_link" = "Xyes"],
  253. [AC_DEFINE([HAVE_GLU],[1],[Defined if a valid GLU implementation is found.])
  254. m4_ifval([$1],
  255. [$1],
  256. [CFLAGS="$GLU_CFLAGS $CFLAGS"
  257. LIBS="$GLU_LIBS $LIBS"])],
  258. [m4_ifval([$2],
  259. [$2],
  260. [AC_MSG_ERROR([Could not find a valid GLU implementation])])
  261. ])
  262. ])