2 dnl Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010,
3 dnl 2011 Free Software Foundation, Inc.
5 dnl This program is free software; you can redistribute it and/or modify
6 dnl it under the terms of the GNU General Public License as published by
7 dnl the Free Software Foundation; either version 3 of the License, or
8 dnl (at your option) any later version.
10 dnl This program is distributed in the hope that it will be useful,
11 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 dnl GNU General Public License for more details.
14 dnl You should have received a copy of the GNU General Public License
15 dnl along with this program; if not, write to the Free Software
16 dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 AC_DEFUN([GNASH_PATH_GLES],
22 dnl This changes the default flavor of OpenGL-ES implementations. If only
23 dnl one is installed, it doesn't matter, but if you are a developer with
24 dnl multiple OpenGL-ES implementations, you can use this to limit the
25 dnl search. 10c, mali, android are all that's supported.
27 dnl The config flavor is used for what configure thinks the default
28 dnl is when there is no default flavor of OpenGL-ES library.
29 config_flavor=${default_flavor}
31 dnl add the default path to the Android NDK
32 if test x"${android_ndk}" != xno; then
33 newlist="${android_ndk}/usr/include ${incllist}"
38 dnl Look for the headers.
39 AC_ARG_WITH(gles1_includes, AC_HELP_STRING([--with-gles1-includes], [directory where OpenGLES 1 headers are]), with_gles1_includes=${withval})
40 AC_CACHE_VAL(ac_cv_path_gles1_includes,[
41 if test x"${with_gles1_includes}" != x ; then
42 if test -f ${with_gles1_includes}/GLES/egl.h -o -f ${with_gles1_includes}/GLES/gl.h; then
43 ac_cv_path_gles1_includes="-I`(cd ${with_gles1_includes}; pwd)`"
45 AC_MSG_ERROR([${with_gles1_includes} directory doesn't contain egl.h or gl.h])
50 AC_ARG_WITH(gles2_includes, AC_HELP_STRING([--with-gles2-includes], [directory where OpenGLES 2 headers are]), with_gles2_includes=${withval})
51 AC_CACHE_VAL(ac_cv_path_gles2_includes,[
52 if test x"${with_gles2_includes}" != x ; then
53 if test -f ${with_gles2_includes}/GLES2/gl2.h ; then
54 ac_cv_path_gles2_includes="-I`(cd ${with_gles2_includes}; pwd)`"
56 AC_MSG_ERROR([${with_gles2_includes} directory doesn't contain gl2.h])
61 dnl This gets really fun, as all the implementations I could find
62 dnl have differences. OpenGL-ES 1.x by default doesn't have
63 dnl Farmebuffer support, this is added by an extension. For
64 dnl OpenGL-ES 2.x, this extension is now in the standard API.
66 dnl The three tested implementations so far are the linux gles-10c
67 dnl project, which appears unmaintained these days, but lacks the
68 dnl framebuffer extension. It does however work on a 64bit system,
69 dnl unlike the other libraries mentioned here.
71 dnl The other primary one is the Andproid implementation, which has
72 dnl OpenGL-ES 1.1 support (with the framebuffer extension) and 2.1
75 dnl The final one are the Mali Developer Tools from ARM, that
76 dnl contain emulator that lets you run OpenGL-ES applications on a
77 dnl standard desktop under X11. The 2.0 version of the tools
78 dnl includes both OpenGL-ES 1.1 and 2.1, but with a twist. The
79 dnl OpenGL-ES 1.x implementation is under the EGL, instead of the
80 dnl GLES top level directory.
82 if test x"${ac_cv_path_gles1_includes}" = x -o x"${ac_cv_path_gles2_includes}" = x; then
83 AC_MSG_CHECKING([for OpenGL-ES headers])
84 for i in ${newlist}; do
86 if test x"${ac_cv_path_gles1_includes}" = x -a x"${build_gles1}" = xyes; then
87 if test -f $i/GLES/gl.h; then
88 AC_DEFINE(HAVE_GLES1_GL_H, [1], [Have OpenGL-ES GLES/gl.h])
89 AC_DEFINE([RENDERER_GLES1], [1], [Use OpenGL-ES version 1.x])
90 ac_cv_path_gles1_includes="-I$i"
91 dnl Some implementations have this extension, which adds
92 dnl framebuffer support.
93 if test -f $i/GLES/glext.h; then
94 AC_DEFINE(HAVE_GLES1_GLEXT_H, [1], [Have OpenGL-ES GLES/glext.h])
96 dnl If it contains the egl.h file, it's probably gles-10c,
97 dnl if not, then it's probably the Android implementation.
98 if test -f $i/GLES/egl.h; then
99 AC_DEFINE(HAVE_GLES1_EGL_H, [1], [Have OpenGLES 1 egl.h])
102 config_flavor=android
104 if test -f $i/EGL/egl.h; then
105 AC_DEFINE(HAVE_EGL_EGL_H, [1], [Have OpenGL-ES EGL/egl.h])
106 ac_cv_path_gles1_includes="-I$i"
107 dnl Only the Mali library has this header file.
108 if test -f $i/EGL/egl_native_types.h; then
111 config_flavor=android
117 if test x"${ac_cv_path_gles2_includes}" = x -a x"${build_gles2}" = xyes; then
118 if test -f $i/GLES2/gl2.h; then
119 AC_DEFINE(HAVE_GLES2_GL2_H, [1], [Have OpenGLES v2 GLES2/gl2.h])
120 AC_DEFINE([RENDERER_GLES2], [1], [Use OpenGLES v2 version 2])
121 ac_cv_path_gles2_includes="-I$i"
122 dnl Both OpenGL-ES 2.1 implementations are similar enough
123 dnl the flavor doesn't matter.
124 config_flavor=android
126 if test -f $i/EGL/egl.h; then
127 AC_DEFINE(HAVE_EGL_EGL_H, [1], [Have OpenGL-ES EGL/egl.h])
128 ac_cv_path_gles2_includes="-I$i"
129 dnl Only the Mali library has this header file.
130 if test -f $i/EGL/egl_native_types.h; then
133 config_flavor=android
140 if test x"${ac_cv_path_gles1_includes}" = x; then
141 AC_CHECK_HEADERS([GLES/egl.h], [ac_cv_path_gles1_includes=""])
143 if test x"${ac_cv_path_gles2_includes}" = x; then
144 AC_CHECK_HEADERS([GLES2/gl2.h], [ac_cv_path_gles2_includes=""])
147 if test x"${ac_cv_path_gles1_includes}" != x -a x"${ac_cv_path_gles1_includes}" != x/usr/include; then
148 GLES1_CFLAGS="${ac_cv_path_gles1_includes}"
153 if test x"${ac_cv_path_gles2_includes}" != x -a x"${ac_cv_path_gles2_includes}" != x/usr/include; then
154 GLES2_CFLAGS="${ac_cv_path_gles2_includes}"
159 AC_MSG_RESULT(${ac_cv_path_gles1_includes} ${ac_cv_path_gles2_includes})
161 if test x"${default_flavor}" = xany; then
162 flavor="${config_flavor}"
164 flavor="${default_flavor}"
167 dnl the library has different names depending on the release and platform
168 dnl Android uses GLESv1_CM or GLESv2
169 dnl The older gles-10c uses libGLES_CL, but works on an x86_64, which the
170 dnl Mali tools from ARM don't.
171 dnl The Mali Developer Tools 1.1 from the ARM emulator use libegl & libglesv1
172 dnl The Mali Developer Tools 2.0 from the ARM emulator use libEGL &
173 dnl libGLESv2. We limit the search of librairies so if we have
174 dnl multiple OpenGL-ES implementations installed (for testing and
175 dnl development), so we don't mix and match headers and libaries
176 dnl between implementations.
177 if test x"${ac_cv_path_gles1_includes}" != x; then
178 AC_MSG_NOTICE([OpenGL-ES implementation being used is: ${flavor} 1.x])
180 mali) gleslist1="egl glesv1" ;;
181 10c) gleslist1="GLES_CL" ;;
182 android) gleslist1="EGL GLESv1_CM" ;;
183 mesa) gleslist1="GLESv1" ;;
184 *) gleslist1="GLES_CL GLESv1_CM GLESv1" ;;
188 if test x"${ac_cv_path_gles2_includes}" != x; then
189 AC_MSG_NOTICE([OpenGL-ES implementation being used is: ${flavor} 2.x])
190 gleslist2="EGL GLESv2"
195 dnl Look for the libraries.
196 AC_ARG_WITH(gles1_lib, AC_HELP_STRING([--with-gles1-lib], [directory where OpenGLES 1 libraries are]), with_gles1_lib=${withval})
197 AC_CACHE_VAL(ac_cv_path_gles1_lib,[
198 if test x"${with_gles1_lib}" != x ; then
199 for j in $gleslist1; do
200 if test -f ${with_gles1_lib}/$i.a -o -f ${with_gles1_lib}/$i.${shlibext}; then
201 ac_cv_path_gles1_lib="-L`(cd ${with_gles1_lib}; pwd)` -l$i"
207 AC_ARG_WITH(gles2_lib, AC_HELP_STRING([--with-gles2-lib], [directory where OpenGLES 2 libraries are]), with_gles2_lib=${withval})
208 AC_CACHE_VAL(ac_cv_path_gles2_lib,[
209 if test x"${with_gles2_lib}" != x ; then
210 for j in $gleslist2; do
211 if test -f ${with_gles2_lib}/$i.a -o -f ${with_gles2_lib}/$i.${shlibext}; then
212 ac_cv_path_gles2_lib="-L`(cd ${with_gles2_lib}; pwd)` -l$i"
222 dnl add the default path to the Android NDK
223 newlist="${android_ndk}/usr/lib ${libslist}"
224 if test x"${ac_cv_path_gles1_lib}" = x; then
225 for dir in ${newlist}; do
226 for lib in ${gleslist1}; do
227 if test -f ${dir}/lib${lib}.${shlibext} -o -f ${dir}/lib${lib}.a; then
229 if test ! x"${dir}" = x"/usr/lib" -a ! x"${dir}" = x"/usr/lib64"; then
230 ac_cv_path_gles1_lib="-L${dir} -l${lib}"
232 ac_cv_path_gles1_lib="-l${lib}"
238 if test x"${ac_cv_path_gles2_lib}" = x; then
239 for dir in ${newlist}; do
240 for lib in ${gleslist2}; do
241 if test -f ${dir}/lib${lib}.${shlibext} -o -f ${dir}/lib${lib}.a; then
243 if test ! x"${dir}" = x"/usr/lib" -a ! x"${dir}" = x"/usr/lib64"; then
244 ac_cv_path_gles2_lib="-L${dir} -l${lib}"
246 ac_cv_path_gles2_lib="-l${lib}"
253 if test x"${ac_cv_path_gles1_lib}" != x; then
254 GLES1_LIBS="${ac_cv_path_gles1_lib}"
259 if test x"${ac_cv_path_gles2_lib}" != x; then
260 GLES2_LIBS="${ac_cv_path_gles2_lib}"
265 AC_SUBST(GLES1_CFLAGS)
268 AC_SUBST(GLES2_CFLAGS)
275 # indent-tabs-mode: nil