2 dnl Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
4 dnl This program is free software; you can redistribute it and/or modify
5 dnl it under the terms of the GNU General Public License as published by
6 dnl the Free Software Foundation; either version 3 of the License, or
7 dnl (at your option) any later version.
9 dnl This program is distributed in the hope that it will be useful,
10 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 dnl GNU General Public License for more details.
13 dnl You should have received a copy of the GNU General Public License
14 dnl along with this program; if not, write to the Free Software
15 dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17 AC_DEFUN([GNASH_PATH_GLES],
21 dnl This changes the default between OpenGL-ES 1.x and 2.x, which are
22 dnl somewhat incomatible with each other. gles1 or gles2 are all that's
25 dnl This changes the default flavor of OpenGL-ES implementations. If only
26 dnl one is installed, it doesn't matter, but if you are a developer with
27 dnl multiple OpenGL-ES implementations, you can use this to limit the
28 dnl search. 10c, mali, android are all that's supported.
30 dnl The config flavor is used for what configure thinks the default
31 dnl is when there is no default flavor of OpenGL-ES library.
32 config_flavor=${default_flavor}
34 dnl add the default path to the Android NDK
35 if test x"${android_ndk}" != xno; then
36 newlist="${android_ndk}/usr/include ${incllist}"
41 dnl Look for the headers.
42 AC_ARG_WITH(gles_includes, AC_HELP_STRING([--with-gles-includes], [directory where OpenGL-ES headers are]), with_gles_includes=${withval})
43 AC_CACHE_VAL(ac_cv_path_gles_includes,[
44 if test x"${with_gles_includes}" != x ; then
45 if test -f ${with_gles_includes}/GLES/egl.h -o -f ${with_gles_includes}/GLES2/gl2.h ; then
46 ac_cv_path_gles_includes="-I`(cd ${with_gles_includes}; pwd)`"
48 AC_MSG_ERROR([${with_gles_includes} directory doesn't contain egl.h or gl2.h])
53 dnl This gets reall fun, as all the implementations I could find
54 dnl have differences. OpenGL-ES 1.x by default doesn't have
55 dnl Farmebuffer support, this is added by an extension. For
56 dnl OpenGL-ES 2.x, this extension is now in the standard API.
58 dnl The three tested implementations so far are the linux gles-10c
59 dnl project, which appears unmaintained these days, but lacks the
60 dnl framebuffer extension. It does however work on a 64bit system,
61 dnl unlike the other libraries mentioned here.
63 dnl The other primary one is the Andproid implementation, which has
64 dnl OpenGL-ES 1.1 support (with the framebuffer extension) and 2.1
67 dnl The final one are the Mali Developer Tools from ARM, that
68 dnl contain emulator that lets you run OpenGL-ES applications on a
69 dnl standard desktop under X11. The 2.0 version of the tools
70 dnl includes both OpenGL-ES 1.1 and 2.1, but with a twist. The
71 dnl OpenGL-ES 1.x implementation is under the EGL, instead of the
72 dnl GLES top level directory.
73 if test x"${ac_cv_path_gles_includes}" = x; then
74 AC_MSG_CHECKING([for OpenGL-ES headers])
75 for i in ${newlist}; do
77 if test x"${default_version}" = xgles1; then
78 if test -f $i/GLES/gl.h; then
79 AC_DEFINE(HAVE_GLES_GL_H, [1], [Have OpenGL-ES GLES/gl.h])
80 AC_DEFINE([RENDERER_GLES], [], [Use OpenGL-ES version 1.x])
81 ac_cv_path_gles_includes="-I$i"
82 dnl Some implementations have this extension, which adds
83 dnl framebuffer support.
84 if test -f $i/GLES/glext.h; then
85 AC_DEFINE(HAVE_GLES_GLEXT_H, [1], [Have OpenGL-ES GLES/glext.h])
87 dnl If it contains the egl.h file, it's probably gles-10c,
88 dnl if not, then it's probably the Android implementation.
89 if test -f $i/GLES/egl.h; then
95 if test -f $i/EGL/egl.h; then
96 AC_DEFINE(HAVE_EGL_EGL_H, [1], [Have OpenGL-ES EGL/egl.h])
97 ac_cv_path_gles_includes="-I$i"
98 dnl Only the Mali library has this header file.
99 if test -f $i/EGL/egl_native_types.h; then
102 config_flavor=android
106 dnl If no OpenGL-ES 1.x headers can be found, look for v2 files
107 if test x"${ac_cv_path_gles_includes}" = x; then
108 default_version=gles2
111 if test x"${default_version}" = xgles2; then
112 if test -f $i/GLES2/gl2.h; then
113 AC_DEFINE(HAVE_GLES2_GL2_H, [1], [Have OpenGL-ES GLES2/gl2.h])
114 AC_DEFINE([RENDERER_GLES2], [], [Use OpenGL-ES v2 version 2])
115 ac_cv_path_gles_includes="-I$i"
116 dnl Both OpenGL-ES 2.1 implementations are similar enough
117 dnl the flavor doesn't matter.
118 config_flavor=android
120 if test -f $i/EGL/egl.h; then
121 AC_DEFINE(HAVE_EGL_EGL_H, [1], [Have OpenGL-ES EGL/egl.h])
122 AC_DEFINE([RENDERER_EGL], [], [Use OpenGL-ES version 1.3])
123 ac_cv_path_gles_includes="-I$i"
124 dnl Only the Mali library has this header file.
125 if test -f $i/EGL/egl_native_types.h; then
128 config_flavor=android
132 if test x"${ac_cv_path_gles_includes}" != x; then
137 if test x"${ac_cv_path_gles_includes}" != x; then
138 AC_MSG_RESULT(${ac_cv_path_gles_includes})
141 if test x"${ac_cv_path_gles_includes}" = x; then
142 AC_CHECK_HEADERS([GLES2/gl2.h], [ac_cv_path_gles_includes=""])
144 if test x"${ac_cv_path_gles_includes}" = x; then
145 AC_CHECK_HEADERS([GLES/egl.h], [ac_cv_path_gles_includes=""])
148 if test x"${ac_cv_path_gles_includes}" != x; then
149 GLES_CFLAGS="${ac_cv_path_gles_includes}"
154 if test x"${default_flavor}" = xany; then
155 flavor="${config_flavor}"
157 flavor="${default_flavor}"
160 dnl the library has different names depending on the release and platform
161 dnl Android uses GLESv1_CM or GLESv2
162 dnl The older gles-10c uses libGLES_CL, but works on an x86_64, which the
163 dnl Mali tools from ARM don't.
164 dnl The Mali Developer Tools 1.1 from the ARM emulator use libegl & libglesv1
165 dnl The Mali Developer Tools 2.0 from the ARM emulator use libEGL &
166 dnl libGLESv2. We limit the search of librairies so if we have
167 dnl multiple OpenGL-ES implementations installed (for testing and
168 dnl development), so we don't mix and match headers and libaries
169 dnl between implementations.
170 if test x"${default_version}" = xgles1; then
171 AC_MSG_NOTICE([OpenGL-ES implementation being used is: ${flavor} 1.x])
173 mali) gleslist="egl glesv1" ;;
174 10c) gleslist="GLES_CL" ;;
175 android) gleslist="EGL GLESv1_CM" ;;
176 *) gleslist="GLES_CL GLESv1_CM GLESv1" ;;
180 if test x"${default_version}" = xgles2; then
181 AC_MSG_NOTICE([OpenGL-ES implementation being used is: ${flavor} 2.x])
182 gleslist="EGL GLESv2"
185 dnl Look for the libraries.
186 AC_ARG_WITH(gles_lib, AC_HELP_STRING([--with-gles-lib], [directory where OpenGL-ES libraries are]), with_gles_lib=${withval})
187 AC_CACHE_VAL(ac_cv_path_gles_lib,[
188 if test x"${with_gles_lib}" != x ; then
189 for j in $gleslist; do
190 if test -f ${with_gles_lib}/$i.a -o -f ${with_gles_lib}/$i.${shlibext}; then
191 ac_cv_path_gles_lib="-L`(cd ${with_gles_lib}; pwd)` -l$i"
198 dnl add the default path to the Android NDK
199 newlist="${android_ndk}/usr/lib ${libslist}"
200 if test x"${ac_cv_path_gles_lib}" = x; then
201 for dir in ${newlist}; do
202 for lib in ${gleslist}; do
203 if test -f ${dir}/lib${lib}.${shlibext} -o -f ${dir}/lib${lib}.a; then
205 if test ! x"${dir}" = x"/usr/lib" -a ! x"${dir}" = x"/usr/lib64"; then
206 ac_cv_path_gles_lib="-L${dir} -l${lib}"
208 ac_cv_path_gles_lib="-l${lib}"
210 dnl add the additiontal library need to link
211 if test x"${default_version}" = xgles2; then
212 ac_cv_path_gles_lib="${ac_cv_path_gles_lib} -lGLESv2"
217 if test x"${ac_cv_path_gles_lib}" != x ; then
223 if test x"${ac_cv_path_gles_lib}" != x ; then
224 GLES_LIBS="${ac_cv_path_gles_lib}"
229 AC_SUBST(GLES_CFLAGS)
236 # indent-tabs-mode: nil