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-fbdev.c b/src/compositor-fbdev.c
index 3d2819b..002ce0b 100644
--- a/src/compositor-fbdev.c
+++ b/src/compositor-fbdev.c
@@ -95,6 +95,8 @@
 	int use_gl;
 };
 
+struct gl_renderer_interface *gl_renderer;
+
 static const char default_seat[] = "seat0";
 
 static inline struct fbdev_output *
@@ -623,7 +625,7 @@
 			goto out_shadow_surface;
 	} else {
 		setenv("HYBRIS_EGLPLATFORM", "wayland", 1);
-		if (gl_renderer_output_create(&output->base,
+		if (gl_renderer->output_create(&output->base,
 					(EGLNativeWindowType)NULL) < 0) {
 			weston_log("gl_renderer_output_create failed.\n");
 			goto out_shadow_surface;
@@ -684,7 +686,7 @@
 			output->shadow_buf = NULL;
 		}
 	} else {
-		gl_renderer_output_destroy(base);
+		gl_renderer->output_destroy(base);
 	}
 
 	/* Remove the output. */
@@ -923,8 +925,16 @@
 		if (pixman_renderer_init(&compositor->base) < 0)
 			goto out_launcher;
 	} else {
-		if (gl_renderer_create(&compositor->base, EGL_DEFAULT_DISPLAY,
-			gl_renderer_opaque_attribs, NULL) < 0) {
+		gl_renderer = weston_load_module("gl-renderer.so",
+						 "gl_renderer_interface");
+		if (!gl_renderer) {
+			weston_log("could not load gl renderer\n");
+			goto out_launcher;
+		}
+
+		if (gl_renderer->create(&compositor->base, EGL_DEFAULT_DISPLAY,
+					gl_renderer->opaque_attribs,
+					NULL) < 0) {
 			weston_log("gl_renderer_create failed.\n");
 			goto out_launcher;
 		}