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 between OpenGL-ES 1.x and 2.x, which are
23 dnl somewhat incomatible with each other. gles1 or gles2 are all that's
26 dnl This changes the default flavor of OpenGL-ES implementations. If only
27 dnl one is installed, it doesn't matter, but if you are a developer with
28 dnl multiple OpenGL-ES implementations, you can use this to limit the
29 dnl search. 10c, mali, android are all that's supported.
31 dnl The config flavor is used for what configure thinks the default
32 dnl is when there is no default flavor of OpenGL-ES library.
33 config_flavor=${default_flavor}
35 dnl add the default path to the Android NDK
36 if test x"${android_ndk}" != xno; then
37 newlist="${android_ndk}/usr/include ${incllist}"
42 dnl Look for the headers.
43 AC_ARG_WITH(gles_includes, AC_HELP_STRING([--with-gles-includes], [directory where OpenGL-ES headers are]), with_gles_includes=${withval})
44 AC_CACHE_VAL(ac_cv_path_gles_includes,[
45 if test x"${with_gles_includes}" != x ; then
46 if test -f ${with_gles_includes}/GLES/egl.h -o -f ${with_gles_includes}/GLES2/gl2.h ; then
47 ac_cv_path_gles_includes="-I`(cd ${with_gles_includes}; pwd)`"
49 AC_MSG_ERROR([${with_gles_includes} directory doesn't contain egl.h or gl2.h])
54 dnl This gets reall fun, as all the implementations I could find
55 dnl have differences. OpenGL-ES 1.x by default doesn't have
56 dnl Farmebuffer support, this is added by an extension. For
57 dnl OpenGL-ES 2.x, this extension is now in the standard API.
59 dnl The three tested implementations so far are the linux gles-10c
60 dnl project, which appears unmaintained these days, but lacks the
61 dnl framebuffer extension. It does however work on a 64bit system,
62 dnl unlike the other libraries mentioned here.
64 dnl The other primary one is the Andproid implementation, which has
65 dnl OpenGL-ES 1.1 support (with the framebuffer extension) and 2.1
68 dnl The final one are the Mali Developer Tools from ARM, that
69 dnl contain emulator that lets you run OpenGL-ES applications on a
70 dnl standard desktop under X11. The 2.0 version of the tools
71 dnl includes both OpenGL-ES 1.1 and 2.1, but with a twist. The
72 dnl OpenGL-ES 1.x implementation is under the EGL, instead of the
73 dnl GLES top level directory.
74 if test x"${ac_cv_path_gles_includes}" = x; then
75 AC_MSG_CHECKING([for OpenGL-ES headers])
76 for i in ${newlist}; do
78 if test x"${default_version}" = xgles1; then
79 if test -f $i/GLES/gl.h; then
80 AC_DEFINE(HAVE_GLES_GL_H, [1], [Have OpenGL-ES GLES/gl.h])
81 AC_DEFINE([RENDERER_GLES], [], [Use OpenGL-ES version 1.x])
82 ac_cv_path_gles_includes="-I$i"
83 dnl Some implementations have this extension, which adds
84 dnl framebuffer support.
85 if test -f $i/GLES/glext.h; then
86 AC_DEFINE(HAVE_GLES_GLEXT_H, [1], [Have OpenGL-ES GLES/glext.h])
88 dnl If it contains the egl.h file, it's probably gles-10c,
89 dnl if not, then it's probably the Android implementation.
90 if test -f $i/GLES/egl.h; then
96 if test -f $i/EGL/egl.h; then
97 AC_DEFINE(HAVE_EGL_EGL_H, [1], [Have OpenGL-ES EGL/egl.h])
98 ac_cv_path_gles_includes="-I$i"
99 dnl Only the Mali library has this header file.
100 if test -f $i/EGL/egl_native_types.h; then
103 config_flavor=android
107 dnl If no OpenGL-ES 1.x headers can be found, look for v2 files
108 if test x"${ac_cv_path_gles_includes}" = x; then
109 default_version=gles2
112 if test x"${default_version}" = xgles2; then
113 if test -f $i/GLES2/gl2.h; then
114 AC_DEFINE(HAVE_GLES2_GL2_H, [1], [Have OpenGL-ES GLES2/gl2.h])
115 AC_DEFINE([RENDERER_GLES2], [], [Use OpenGL-ES v2 version 2])
116 ac_cv_path_gles_includes="-I$i"
117 dnl Both OpenGL-ES 2.1 implementations are similar enough
118 dnl the flavor doesn't matter.
119 config_flavor=android
121 if test -f $i/EGL/egl.h; then
122 AC_DEFINE(HAVE_EGL_EGL_H, [1], [Have OpenGL-ES EGL/egl.h])
123 AC_DEFINE([RENDERER_EGL], [], [Use OpenGL-ES version 1.3])
124 ac_cv_path_gles_includes="-I$i"
125 dnl Only the Mali library has this header file.
126 if test -f $i/EGL/egl_native_types.h; then
129 config_flavor=android
133 if test x"${ac_cv_path_gles_includes}" != x; then
138 if test x"${ac_cv_path_gles_includes}" != x; then
139 AC_MSG_RESULT(${ac_cv_path_gles_includes})
142 if test x"${ac_cv_path_gles_includes}" = x; then
143 AC_CHECK_HEADERS([GLES2/gl2.h], [ac_cv_path_gles_includes=""])
145 if test x"${ac_cv_path_gles_includes}" = x; then
146 AC_CHECK_HEADERS([GLES/egl.h], [ac_cv_path_gles_includes=""])
149 if test x"${ac_cv_path_gles_includes}" != x; then
150 GLES_CFLAGS="${ac_cv_path_gles_includes}"
155 if test x"${default_flavor}" = xany; then
156 flavor="${config_flavor}"
158 flavor="${default_flavor}"
161 dnl the library has different names depending on the release and platform
162 dnl Android uses GLESv1_CM or GLESv2
163 dnl The older gles-10c uses libGLES_CL, but works on an x86_64, which the
164 dnl Mali tools from ARM don't.
165 dnl The Mali Developer Tools 1.1 from the ARM emulator use libegl & libglesv1
166 dnl The Mali Developer Tools 2.0 from the ARM emulator use libEGL &
167 dnl libGLESv2. We limit the search of librairies so if we have
168 dnl multiple OpenGL-ES implementations installed (for testing and
169 dnl development), so we don't mix and match headers and libaries
170 dnl between implementations.
171 if test x"${default_version}" = xgles1; then
172 AC_MSG_NOTICE([OpenGL-ES implementation being used is: ${flavor} 1.x])
174 mali) gleslist="egl glesv1" ;;
175 10c) gleslist="GLES_CL" ;;
176 android) gleslist="EGL GLESv1_CM" ;;
177 *) gleslist="GLES_CL GLESv1_CM GLESv1" ;;
181 if test x"${default_version}" = xgles2; then
182 AC_MSG_NOTICE([OpenGL-ES implementation being used is: ${flavor} 2.x])
183 gleslist="EGL GLESv2"
186 dnl Look for the libraries.
187 AC_ARG_WITH(gles_lib, AC_HELP_STRING([--with-gles-lib], [directory where OpenGL-ES libraries are]), with_gles_lib=${withval})
188 AC_CACHE_VAL(ac_cv_path_gles_lib,[
189 if test x"${with_gles_lib}" != x ; then
190 for j in $gleslist; do
191 if test -f ${with_gles_lib}/$i.a -o -f ${with_gles_lib}/$i.${shlibext}; then
192 ac_cv_path_gles_lib="-L`(cd ${with_gles_lib}; pwd)` -l$i"
199 dnl add the default path to the Android NDK
200 newlist="${android_ndk}/usr/lib ${libslist}"
201 if test x"${ac_cv_path_gles_lib}" = x; then
202 for dir in ${newlist}; do
203 for lib in ${gleslist}; do
204 if test -f ${dir}/lib${lib}.${shlibext} -o -f ${dir}/lib${lib}.a; then
206 if test ! x"${dir}" = x"/usr/lib" -a ! x"${dir}" = x"/usr/lib64"; then
207 ac_cv_path_gles_lib="-L${dir} -l${lib}"
209 ac_cv_path_gles_lib="-l${lib}"
211 dnl add the additiontal library need to link
212 if test x"${default_version}" = xgles2; then
213 ac_cv_path_gles_lib="${ac_cv_path_gles_lib} -lGLESv2"
218 if test x"${ac_cv_path_gles_lib}" != x ; then
224 if test x"${ac_cv_path_gles_lib}" != x ; then
225 GLES_LIBS="${ac_cv_path_gles_lib}"
230 AC_SUBST(GLES_CFLAGS)
237 # indent-tabs-mode: nil