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.

211 lines
7.8KB

  1. # ===========================================================================
  2. # https://www.gnu.org/software/autoconf-archive/ax_check_glut.html
  3. # ===========================================================================
  4. #
  5. # SYNOPSIS
  6. #
  7. # AX_CHECK_GLUT([ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND])
  8. #
  9. # DESCRIPTION
  10. #
  11. # Checks for GLUT. If a valid GLUT implementation is found, the configure
  12. # script would export the C preprocessor symbol "HAVE_GLUT=1".
  13. #
  14. # If either a valid GLUT 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. # "GLUT_CFLAGS" and "GLUT_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_GLUT=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 "GLUT_CFLAGS" and "GLUT_LIBS" to "CFLAGS" and "LIBS", like
  29. # many other autoconf macros do.
  30. #
  31. # If the header "GL/glut.h" is found, "HAVE_GL_GLUT_H" is defined. If the
  32. # header "GLUT/glut.h" is found, HAVE_GLUT_GLUT_H is defined.
  33. #
  34. # You should use something like this in your headers:
  35. #
  36. # # if HAVE_WINDOWS_H && defined(_WIN32)
  37. # # include <windows.h>
  38. # # endif
  39. # # if defined(HAVE_GL_GLUT_H)
  40. # # include <GL/glut.h>
  41. # # elif defined(HAVE_GLUT_GLUT_H)
  42. # # include <GLUT/glut.h>
  43. # # else
  44. # # error no glut.h
  45. # # endif
  46. #
  47. # On the OSX platform, you can use the option --with-xquartz-gl to use
  48. # X11/Xquartz GLUT implementation instead of the system built in GLUT
  49. # framework.
  50. #
  51. # LICENSE
  52. #
  53. # Copyright (c) 2009 Braden McDaniel <braden@endoframe.com>
  54. # Copyright (c) 2013 Bastien Roucaries <roucaries.bastien+autoconf@gmail.com>
  55. # Copyright (c) 2016 Felix Chern <idryman@gmail.com>
  56. #
  57. # This program is free software; you can redistribute it and/or modify it
  58. # under the terms of the GNU General Public License as published by the
  59. # Free Software Foundation; either version 2 of the License, or (at your
  60. # option) any later version.
  61. #
  62. # This program is distributed in the hope that it will be useful, but
  63. # WITHOUT ANY WARRANTY; without even the implied warranty of
  64. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  65. # Public License for more details.
  66. #
  67. # You should have received a copy of the GNU General Public License along
  68. # with this program. If not, see <https://www.gnu.org/licenses/>.
  69. #
  70. # As a special exception, the respective Autoconf Macro's copyright owner
  71. # gives unlimited permission to copy, distribute and modify the configure
  72. # scripts that are the output of Autoconf when processing the Macro. You
  73. # need not follow the terms of the GNU General Public License when using
  74. # or distributing such scripts, even though portions of the text of the
  75. # Macro appear in them. The GNU General Public License (GPL) does govern
  76. # all other use of the material that constitutes the Autoconf Macro.
  77. #
  78. # This special exception to the GPL applies to versions of the Autoconf
  79. # Macro released by the Autoconf Archive. When you make and distribute a
  80. # modified version of the Autoconf Macro, you may extend this special
  81. # exception to the GPL to apply to your modified version as well.
  82. #serial 17
  83. AC_DEFUN([_AX_CHECK_GLUT_SAVE_FLAGS], [
  84. AX_SAVE_FLAGS_WITH_PREFIX([GLUT],[$1]) dnl defined in ax_check_gl
  85. AC_LANG_PUSH([C])
  86. ])
  87. AC_DEFUN([_AX_CHECK_GLUT_RESTORE_FLAGS], [
  88. AX_RESTORE_FLAGS_WITH_PREFIX([GLUT],[$1]) dnl defined in ax_check_gl
  89. AC_LANG_POP([C])
  90. ])
  91. dnl Default include : add windows.h
  92. dnl see http://www.opengl.org/wiki/Platform_specifics:_Windows
  93. dnl (acceded 20120801)
  94. AC_DEFUN([_AX_CHECK_GLUT_INCLUDES_DEFAULT],dnl
  95. [
  96. AC_INCLUDES_DEFAULT
  97. [
  98. # if defined(HAVE_WINDOWS_H) && defined(_WIN32)
  99. # include <windows.h>
  100. # endif
  101. ]
  102. ])
  103. m4_define([_AX_CHECK_GLUT_PROGRAM],
  104. [AC_LANG_PROGRAM([[
  105. # if HAVE_WINDOWS_H && defined(_WIN32)
  106. # include <windows.h>
  107. # endif
  108. # ifdef HAVE_GL_GLUT_H
  109. # include <GL/glut.h>
  110. # elif defined(HAVE_GLUT_GLUT_H)
  111. # include <GLUT/glut.h>
  112. # else
  113. # error no glut.h
  114. # endif]],
  115. [[glutMainLoop()]])])
  116. # _AX_CHECK_GLUT_MANUAL_LIBS_GENERIC(LIST-OF-LIBS)
  117. # ------------------------------------------------
  118. # Searches libraries provided in $1, and export variable
  119. # $ax_check_glut_lib_glut
  120. AC_DEFUN([_AX_CHECK_GLUT_MANUAL_LIBS_GENERIC],
  121. [
  122. _AX_CHECK_GLUT_SAVE_FLAGS([[CFLAGS],[LIBS]])
  123. AC_SEARCH_LIBS([glutMainLoop],[$1],
  124. [GLUT_LIBS="${GLUT_LIBS:-$ac_cv_search_glutMainLoop}"])
  125. _AX_CHECK_GLUT_RESTORE_FLAGS([[CFLAGS],[LIBS]])
  126. ])
  127. # Wrapper macro to check GLUT header
  128. AC_DEFUN([_AX_CHECK_GLUT_HEADER],[
  129. _AX_CHECK_GLUT_SAVE_FLAGS([CFLAGS])
  130. AC_CHECK_HEADERS([$1],
  131. [ax_check_glut_have_headers=yes])
  132. _AX_CHECK_GLUT_RESTORE_FLAGS([CFLAGS])
  133. ])
  134. # AX_CHECK_GLUT_LIB([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
  135. # ---------------------------------------------------------
  136. # Checks GLUT headers and library and provides hooks for success and failures.
  137. AC_DEFUN([AX_CHECK_GLUT],
  138. [AC_REQUIRE([AC_CANONICAL_HOST])
  139. AC_REQUIRE([_WITH_XQUARTZ_GL])
  140. AC_ARG_VAR([GLUT_CFLAGS],[C compiler flags for GLUT, overriding configure script defaults])
  141. AC_ARG_VAR([GLUT_LIBS],[Linker flags for GLUT, overriding configure script defaults])
  142. AS_CASE([${host}],
  143. [*-darwin*],[AS_IF([test "x$with_xquartz_gl" != "xno"],
  144. [GLUT_LIBS="${GLUT_LIBS:--lGLUT}"],
  145. [GLUT_LIBS="${GLUT_LIBS:--framework GLUT}"])],
  146. [*-cygwin*|*-mingw*],[
  147. _AX_CHECK_GLUT_MANUAL_LIBS_GENERIC([glut32 glut])
  148. AC_CHECK_HEADERS([windows.h])
  149. ],
  150. [_AX_CHECK_GLUT_MANUAL_LIBS_GENERIC([glut])
  151. ]) dnl host specific checks
  152. dnl checks header
  153. AS_CASE([${host}],
  154. [*-darwin*],[AS_IF([test "x$with_xquartz_gl" = "xno"],
  155. [_AX_CHECK_GLUT_HEADER([GLUT/glut.h])],
  156. [_AX_CHECK_GLUT_HEADER([GL/glut.h])]
  157. )],
  158. [_AX_CHECK_GLUT_HEADER([GL/glut.h])])
  159. dnl compile
  160. AS_IF([test "X$ax_check_glut_have_headers" = "Xyes"],
  161. [AC_CACHE_CHECK([for compiling a minimal GLUT program],
  162. [ax_cv_check_glut_compile],
  163. [_AX_CHECK_GLUT_SAVE_FLAGS([CFLAGS])
  164. AC_COMPILE_IFELSE([_AX_CHECK_GLUT_PROGRAM],
  165. [ax_cv_check_glut_compile="yes"],
  166. [ax_cv_check_glut_compile="no"])
  167. _AX_CHECK_GLUT_RESTORE_FLAGS([CFLAGS])
  168. ])
  169. ])
  170. dnl link
  171. AS_IF([test "X$ax_cv_check_glut_compile" = "Xyes"],
  172. [AC_CACHE_CHECK([for linking a minimal GLUT program],
  173. [ax_cv_check_glut_link],
  174. [_AX_CHECK_GLUT_SAVE_FLAGS([[CFLAGS],[LIBS]])
  175. AC_LINK_IFELSE([_AX_CHECK_GLUT_PROGRAM],
  176. [ax_cv_check_glut_link="yes"],
  177. [ax_cv_check_glut_link="no"])
  178. _AX_CHECK_GLUT_RESTORE_FLAGS([[CFLAGS],[LIBS]])
  179. ])
  180. ])
  181. dnl hook
  182. AS_IF([test "X$ax_cv_check_glut_link" = "Xyes"],
  183. [AC_DEFINE([HAVE_GLUT], [1], [Defined if a valid GLUT implementation is found])
  184. m4_ifval([$1],
  185. [$1],
  186. [CFLAGS="$GLUT_CFLAGS $CFLAGS"
  187. LIBS="$GLUT_LIBS $LIBS"])
  188. ],
  189. [m4_ifval([$2],
  190. [$2],
  191. [AC_MSG_ERROR([Could not find a valid GLUT implementation])]
  192. )
  193. ])
  194. ])