Make EGL/GLESv2 dependencies optional
authorVasily Khoruzhick <anarsoul@gmail.com>
Tue, 8 Jan 2013 16:09:02 +0000 (19:09 +0300)
committerKristian Høgsberg <krh@bitplanet.net>
Tue, 8 Jan 2013 20:32:00 +0000 (15:32 -0500)
Introduce --disable-egl switch for configure to disable
EGL/GLESv2 support.

Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
configure.ac
src/Makefile.am
src/compositor-x11.c
src/gl-renderer.h

index 8cff8dc..cc3256d 100644 (file)
@@ -33,9 +33,17 @@ AC_CHECK_HEADERS([execinfo.h])
 
 AC_CHECK_FUNCS([mkostemp strchrnul])
 
-PKG_CHECK_MODULES(COMPOSITOR,
-                 [wayland-server egl >= 7.10 glesv2 xkbcommon pixman-1])
+COMPOSITOR_MODULES="wayland-server xkbcommon pixman-1"
+
+AC_ARG_ENABLE(egl, [ --disable-egl],,
+              enable_egl=yes)
+AM_CONDITIONAL(ENABLE_EGL, test x$enable_egl = xyes)
+if test x$enable_egl = xyes; then
+       AC_DEFINE([ENABLE_EGL], [1], [Build Weston with EGL support])
+       COMPOSITOR_MODULES="$COMPOSITOR_MODULES egl >= 7.10 glesv2"
+fi
 
+PKG_CHECK_MODULES(COMPOSITOR, [$COMPOSITOR_MODULES])
 
 AC_ARG_ENABLE(setuid-install, [  --enable-setuid-install],,
              enable_setuid_install=yes)
@@ -94,8 +102,8 @@ fi
 
 AC_ARG_ENABLE(drm-compositor, [  --enable-drm-compositor],,
              enable_drm_compositor=yes)
-AM_CONDITIONAL(ENABLE_DRM_COMPOSITOR, test x$enable_drm_compositor = xyes)
-if test x$enable_drm_compositor = xyes; then
+AM_CONDITIONAL(ENABLE_DRM_COMPOSITOR, test x$enable_drm_compositor = xyes -a x$enable_egl = xyes)
+if test x$enable_drm_compositor = xyes -a x$enable_egl = xyes; then
   AC_DEFINE([BUILD_DRM_COMPOSITOR], [1], [Build the DRM compositor])
   PKG_CHECK_MODULES(DRM_COMPOSITOR, [libudev >= 136 libdrm >= 2.4.30 gbm mtdev >= 1.1.0])
 fi
@@ -104,8 +112,8 @@ fi
 AC_ARG_ENABLE(wayland-compositor, [  --enable-wayland-compositor],,
              enable_wayland_compositor=yes)
 AM_CONDITIONAL(ENABLE_WAYLAND_COMPOSITOR,
-              test x$enable_wayland_compositor = xyes)
-if test x$enable_wayland_compositor = xyes; then
+              test x$enable_wayland_compositor = xyes -a x$enable_egl = xyes)
+if test x$enable_wayland_compositor = xyes -a x$enable_egl = xyes; then
   AC_DEFINE([BUILD_WAYLAND_COMPOSITOR], [1],
            [Build the Wayland (nested) compositor])
   PKG_CHECK_MODULES(WAYLAND_COMPOSITOR, [wayland-client wayland-egl])
@@ -122,8 +130,8 @@ AC_ARG_ENABLE(android-compositor,
              AS_HELP_STRING([--disable-android-compositor],
                             [do not build-test the Android 4.0 backend]),,
              enable_android_compositor=yes)
-AM_CONDITIONAL(ENABLE_ANDROID_COMPOSITOR, test x$enable_android_compositor = xyes)
-if test x$enable_android_compositor = xyes; then
+AM_CONDITIONAL(ENABLE_ANDROID_COMPOSITOR, test x$enable_android_compositor = xyes -a x$enable_egl = xyes)
+if test x$enable_android_compositor = xyes -a x$enable_egl = xyes; then
   AC_DEFINE([BUILD_ANDROID_COMPOSITOR], [1], [Build the compositor for Android 4.0])
   PKG_CHECK_MODULES(ANDROID_COMPOSITOR, [mtdev >= 1.1.0])
 fi
@@ -133,9 +141,9 @@ AC_ARG_ENABLE(rpi-compositor,
              AS_HELP_STRING([--disable-rpi-compositor],
                             [do not build the Raspberry Pi backend]),,
              enable_rpi_compositor=yes)
-AM_CONDITIONAL(ENABLE_RPI_COMPOSITOR, test "x$enable_rpi_compositor" = "xyes")
+AM_CONDITIONAL(ENABLE_RPI_COMPOSITOR, test "x$enable_rpi_compositor" = "xyes" -a "x$enable_egl" = "xyes")
 have_bcm_host="no"
-if test x$enable_rpi_compositor = xyes; then
+if test x$enable_rpi_compositor = xyes -a x$enable_egl = xyes; then
   AC_DEFINE([BUILD_RPI_COMPOSITOR], [1], [Build the compositor for Raspberry Pi])
   PKG_CHECK_MODULES(RPI_COMPOSITOR, [libudev >= 136 mtdev >= 1.1.0])
   PKG_CHECK_MODULES(RPI_BCM_HOST, [bcm_host],
@@ -185,8 +193,8 @@ AC_ARG_ENABLE(simple-egl-clients,
               AS_HELP_STRING([--disable-simple-egl-clients],
                              [do not build the simple EGL clients]),,
               enable_simple_egl_clients=yes)
-AM_CONDITIONAL(BUILD_SIMPLE_EGL_CLIENTS, test "x$enable_simple_egl_clients" = "xyes")
-if test x$enable_simple_egl_clients = xyes; then
+AM_CONDITIONAL(BUILD_SIMPLE_EGL_CLIENTS, test "x$enable_simple_egl_clients" = "xyes" -a "x$enable_egl" = "xyes")
+if test x$enable_simple_egl_clients = xyes -a x$enable_egl = xyes; then
   PKG_CHECK_MODULES(SIMPLE_EGL_CLIENT,
                     [egl >= 7.10 glesv2 wayland-client wayland-egl wayland-cursor])
 fi
@@ -224,14 +232,16 @@ if test x$enable_weston_launch == xyes; then
   WESTON_LAUNCH_LIBS="$WESTON_LAUNCH_LIBS -lpam"
 fi
 
-PKG_CHECK_MODULES(GLU, [glu], [have_glu=yes], [have_glu=no])
-AM_CONDITIONAL(HAVE_GLU, test "x$have_glu" = "xyes")
+AM_CONDITIONAL(HAVE_GLU, test "x$have_glu" = "xyes" -a "$xenable_egl" = "xyes")
+if test x$enable_egl = xyes; then
+  PKG_CHECK_MODULES(GLU, [glu], [have_glu=yes], [have_glu=no])
+fi
 
 
 AM_CONDITIONAL(HAVE_POPPLER, test "x$have_poppler" = "xyes")
 
 AM_CONDITIONAL(BUILD_FULL_GL_CLIENTS,
-              test x$cairo_modules = "xcairo-gl" -a "x$have_cairo_egl" = "xyes")
+              test x$cairo_modules = "xcairo-gl" -a "x$have_cairo_egl" = "xyes" -a "x$enable_egl" = "xyes")
 
 AM_CONDITIONAL(ENABLE_DESKTOP_SHELL, true)
 
index e4bb862..cbfa911 100644 (file)
@@ -34,7 +34,6 @@ weston_SOURCES =                              \
        workspaces-server-protocol.h            \
        util.c                                  \
        gl-renderer.h                           \
-       gl-renderer.c                           \
        noop-renderer.c                         \
        pixman-renderer.c                       \
        pixman-renderer.h                       \
@@ -43,6 +42,11 @@ weston_SOURCES =                             \
        weston-launch.h                         \
        weston-egl-ext.h
 
+if ENABLE_EGL
+weston_SOURCES +=                              \
+       gl-renderer.c
+endif
+
 git-version.h : .FORCE
        $(AM_V_GEN)(echo "#define BUILD_ID \"$(shell git --work-tree=$(top_srcdir) describe --always --dirty) $(shell git --work-tree=$(top_srcdir) log -1 --format='%s (%ci)')\"" > $@-new; \
        cmp -s $@ $@-new || cp $@-new $@; \
index c5c4248..7ae2b75 100644 (file)
@@ -884,7 +884,7 @@ x11_compositor_create_output(struct x11_compositor *c, int x, int y,
                        return NULL;
                }
        } else {
-               if (gl_renderer_output_create(&output->base, output->window) < 0)
+               if (gl_renderer_output_create(&output->base, (EGLNativeWindowType)output->window) < 0)
                        return NULL;
        }
 
@@ -1474,7 +1474,7 @@ x11_compositor_create(struct wl_display *display,
                        goto err_xdisplay;
        }
        else {
-               if (gl_renderer_create(&c->base, c->dpy, gl_renderer_opaque_attribs,
+               if (gl_renderer_create(&c->base, (EGLNativeDisplayType)c->dpy, gl_renderer_opaque_attribs,
                                NULL) < 0)
                        goto err_xdisplay;
        }
index 1186348..81735e6 100644 (file)
  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 #include  "compositor.h"
 
+#ifdef ENABLE_EGL
+
 #include <EGL/egl.h>
 
 extern const EGLint gl_renderer_opaque_attribs[];
@@ -45,3 +50,57 @@ gl_renderer_set_border(struct weston_compositor *ec, int32_t width, int32_t heig
 
 void
 gl_renderer_print_egl_error_state(void);
+#else
+
+typedef int EGLint;
+typedef int EGLDisplay;
+typedef int EGLSurface;
+typedef long int EGLNativeDisplayType;
+typedef long int EGLNativeWindowType;
+
+static const EGLint gl_renderer_opaque_attribs[];
+static const EGLint gl_renderer_alpha_attribs[];
+
+inline static int
+gl_renderer_create(struct weston_compositor *ec, EGLNativeDisplayType display,
+       const EGLint *attribs, const EGLint *visual_id)
+{
+       return -1;
+}
+
+inline static EGLDisplay
+gl_renderer_display(struct weston_compositor *ec)
+{
+       return 0;
+}
+
+inline static int
+gl_renderer_output_create(struct weston_output *output,
+                                   EGLNativeWindowType window)
+{
+       return -1;
+}
+
+inline static void
+gl_renderer_output_destroy(struct weston_output *output)
+{
+}
+
+inline static EGLSurface
+gl_renderer_output_surface(struct weston_output *output)
+{
+       return 0;
+}
+
+inline static void
+gl_renderer_set_border(struct weston_compositor *ec, int32_t width, int32_t height, void *data,
+                         int32_t *edges)
+{
+}
+
+inline static void
+gl_renderer_print_egl_error_state(void)
+{
+}
+
+#endif