[PATCH weston v2 1/2] configure: Make WebP support togglable, and improve its error message.

Emmanuel Gil Peyrot linkmauve at linkmauve.fr
Tue Feb 16 01:57:51 UTC 2016


The current way was enabling WebP support whenever libwebp was found,
giving no way to the user to disable it if they had the library
installed but didn’t want to link against it.  This adds a
--without-webp configure option to never link against it, and a
--with-webp one to fail the build if it isn’t found, the default being
to use it if it is present.

Additionally, we now tell the user when WebP support has been disabled
and they try to load a WebP file.

Signed-off-by: Emmanuel Gil Peyrot <linkmauve at linkmauve.fr>
---
 configure.ac          | 12 ++++++++++--
 shared/image-loader.c | 11 +++++++++--
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/configure.ac b/configure.ac
index c32ddc9..878b30a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -293,9 +293,17 @@ fi
 
 PKG_CHECK_MODULES(PIXMAN, [pixman-1])
 PKG_CHECK_MODULES(PNG, [libpng])
-PKG_CHECK_MODULES(WEBP, [libwebp], [have_webp=yes], [have_webp=no])
+
+AC_ARG_WITH([webp],
+            AS_HELP_STRING([--without-webp],
+                           [Use libwebp for WebP decoding support [default=auto]]))
+AS_IF([test "x$with_webp" != "xno"],
+      [PKG_CHECK_MODULES(WEBP, [libwebp], [have_webp=yes], [have_webp=no])],
+      [have_webp=no])
 AS_IF([test "x$have_webp" = "xyes"],
-      [AC_DEFINE([HAVE_WEBP], [1], [Have webp])])
+      [AC_DEFINE([HAVE_WEBP], [1], [Have webp])],
+      [AS_IF([test "x$with_webp" = "xyes"],
+             [AC_MSG_ERROR([WebP support explicitly requested, but libwebp couldn't be found])])])
 
 AC_ARG_ENABLE(vaapi-recorder, [  --enable-vaapi-recorder],,
 	      enable_vaapi_recorder=auto)
diff --git a/shared/image-loader.c b/shared/image-loader.c
index ec75bd4..050f067 100644
--- a/shared/image-loader.c
+++ b/shared/image-loader.c
@@ -352,6 +352,15 @@ load_webp(FILE *fp)
 					config.output.u.RGBA.stride);
 }
 
+#else
+
+static pixman_image_t *
+load_webp(FILE *fp)
+{
+	fprintf(stderr, "WebP support disabled at compile-time\n");
+	return NULL;
+}
+
 #endif
 
 
@@ -364,9 +373,7 @@ struct image_loader {
 static const struct image_loader loaders[] = {
 	{ { 0x89, 'P', 'N', 'G' }, 4, load_png },
 	{ { 0xff, 0xd8 }, 2, load_jpeg },
-#ifdef HAVE_WEBP
 	{ { 'R', 'I', 'F', 'F' }, 4, load_webp }
-#endif
 };
 
 pixman_image_t *
-- 
2.7.1



More information about the wayland-devel mailing list