diff --git a/src/post_modules/_Image_WebP/configure.in b/src/post_modules/_Image_WebP/configure.in
index 112a77d8ad0499bdf939e4da208daebba1cdd190..d9cb207093819174368266e1ff72f0f7a43c4fb5 100644
--- a/src/post_modules/_Image_WebP/configure.in
+++ b/src/post_modules/_Image_WebP/configure.in
@@ -7,14 +7,19 @@ PIKE_FEATURE_NODEP(Image.WebP)
 
 AC_CHECK_HEADERS(webp/encode.h)
 if test $ac_cv_header_webp_encode_h = yes ; then
-  AC_DEFINE(HAVE_LIBWEBP,[],[Define when the -lwebp library is available])
+  have_libwebp=false
   AC_CHECK_LIB([webp], [WebPDecodeRGB], [
     LIBS="${LIBS-} -lwebp"
+    have_libwebp=true
   ])
   AC_CHECK_LIB([webpdecoder], [WebPDecodeRGBA], [
     LIBS="${LIBS-} -lwebpmux -lwebpdecoder -lwebpdemux"
+    have_libwebp=true
   ])
-  PIKE_FEATURE_OK(Image.WebP)
+  if $have_libwebp; then
+    AC_DEFINE(HAVE_LIBWEBP,[],[Define when the -lwebp library is available])
+    PIKE_FEATURE_OK(Image.WebP)
+  fi
 fi
 
 AC_OUTPUT(Makefile,echo FOO >stamp-h )