gl-renderer: Build as a loadable module

The time spent loading EGL and GLES libraries from disk can be a
considerable hit in some embedded use cases. If Weston is compiled
with EGL support, the binary will depend on those libraries, even if
a software renderer is in use.

This patch splits the GL renderer into a separate loadable module,
and moves the dependency on EGL and GLES to it. The backends still
need the EGL headers for the native types and EGLint. The function
load_module() is renamed to weston_load_module() and exported, so
that it can be used by the backends.

The gl renderer interface is changed so that there is only one symbol
that needs to be dlsym()'d. This symbol contains pointers to all the
functions and data necessary to interact with the renderer. As a side
effect, this change simplifies gl-renderer.h a great deal.
diff --git a/src/compositor-wayland.c b/src/compositor-wayland.c
index 77b2a2c..7b670d9 100644
--- a/src/compositor-wayland.c
+++ b/src/compositor-wayland.c
@@ -89,6 +89,8 @@
 	struct wayland_output *output;
 };
 
+struct gl_renderer_interface *gl_renderer;
+
 static void
 create_border(struct wayland_compositor *c)
 {
@@ -106,7 +108,7 @@
 	edges[2] = c->border.top;
 	edges[3] = c->border.bottom;
 
-	gl_renderer_set_border(&c->base, pixman_image_get_width(image),
+	gl_renderer->set_border(&c->base, pixman_image_get_width(image),
 		pixman_image_get_height(image),
 		pixman_image_get_data(image), edges);
 
@@ -233,7 +235,7 @@
 {
 	struct wayland_output *output = (struct wayland_output *) output_base;
 
-	gl_renderer_output_destroy(output_base);
+	gl_renderer->output_destroy(output_base);
 
 	wl_egl_window_destroy(output->parent.egl_window);
 	free(output);
@@ -283,7 +285,7 @@
 		goto cleanup_output;
 	}
 
-	if (gl_renderer_output_create(&output->base,
+	if (gl_renderer->output_create(&output->base,
 			output->parent.egl_window) < 0)
 		goto cleanup_window;
 
@@ -742,8 +744,14 @@
 	wl_display_dispatch(c->parent.wl_display);
 
 	c->base.wl_display = display;
-	if (gl_renderer_create(&c->base, c->parent.wl_display,
-			gl_renderer_alpha_attribs,
+
+	gl_renderer = weston_load_module("gl-renderer.so",
+					 "gl_renderer_interface");
+	if (!gl_renderer)
+		goto err_display;
+
+	if (gl_renderer->create(&c->base, c->parent.wl_display,
+			gl_renderer->alpha_attribs,
 			NULL) < 0)
 		goto err_display;
 
@@ -759,7 +767,7 @@
 	if (wayland_compositor_create_output(c, width, height) < 0)
 		goto err_gl;
 
-	/* requires gl_renderer_output_state_create called
+	/* requires gl_renderer->output_state_create called
 	 * by wayland_compositor_create_output */
 	create_border(c);