source: trunk/build/autotools/m4/lol-gl.m4 @ 2277

Last change on this file since 2277 was 1995, checked in by sam, 9 years ago

build: upgrade glew binaries to 1.9.0 and rename the contrib directory
to external so as to avoid some autocompletion collisions with "configure".

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