[sandbox v2 02/11] Allow disabling zlib support.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Some distributions may not have static zlib package. Allow disabling
it at build time.
---
 configure.ac                                | 16 +++++++++++++++-
 libvirt-sandbox/libvirt-sandbox-init-qemu.c | 12 ++++++++++++
 2 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 834a444..99d22d7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -80,7 +80,16 @@ PKG_CHECK_MODULES(LIBVIRT, libvirt >= $LIBVIRT_REQUIRED)
 PKG_CHECK_MODULES(LIBVIRT_GLIB, libvirt-glib-1.0 >= $LIBVIRT_GOBJECT_REQUIRED)
 PKG_CHECK_MODULES(LIBVIRT_GOBJECT, libvirt-gobject-1.0 >= $LIBVIRT_GOBJECT_REQUIRED)
 PKG_CHECK_MODULES(LIBVIRT_GCONFIG, libvirt-gconfig-1.0 >= $LIBVIRT_GCONFIG_REQUIRED)
-PKG_CHECK_MODULES(ZLIB, zlib >= $ZLIB_REQUIRED)
+
+AC_ARG_WITH([zlib],
+  [AS_HELP_STRING([--with-zlib],
+    [add ZLIB support @<:@default=yes@:>@])])
+m4_divert_text([DEFAULTS], [with_zlib=yes])
+
+if test "$with_zlib" = "yes" ; then
+    PKG_CHECK_MODULES(ZLIB, zlib >= $ZLIB_REQUIRED)
+    fi
+
 AC_ARG_WITH([lzma],
   [AS_HELP_STRING([--with-lzma],
     [add LZMA support @<:@default=yes@:>@])])
@@ -130,6 +139,11 @@ AC_MSG_NOTICE([            LZMA: $LZMA_CFLAGS $LZMA_LIBS])
 else
 AC_MSG_NOTICE([            LZMA: no])
 fi
+if test "$with_zlib" != "no" ; then
+AC_MSG_NOTICE([            ZLIB: $ZLIB_CFLAGS $ZLIB_LIBS])
+else
+AC_MSG_NOTICE([            ZLIB: no])
+fi
 AC_MSG_NOTICE([         GOBJECT: $GOBJECT_CFLAGS $GOBJECT_LIBS])
 AC_MSG_NOTICE([ LIBVIRT_GOBJECT: $LIBVIRT_GOBJECT_CFLAGS $LIBVIRT_GOBJECT_LIBS])
 AC_MSG_NOTICE([])
diff --git a/libvirt-sandbox/libvirt-sandbox-init-qemu.c b/libvirt-sandbox/libvirt-sandbox-init-qemu.c
index a9e6263..d5a0b7a 100644
--- a/libvirt-sandbox/libvirt-sandbox-init-qemu.c
+++ b/libvirt-sandbox/libvirt-sandbox-init-qemu.c
@@ -45,7 +45,9 @@
 #if WITH_LZMA
 #include <lzma.h>
 #endif /* WITH_LZMA */
+#if WITH_ZLIB
 #include <zlib.h>
+#endif /* WITH_ZLIB */
 
 #define ATTR_UNUSED __attribute__((__unused__))
 
@@ -469,6 +471,7 @@ load_module_file_lzma(const char *filename, size_t *len)
 }
 #endif /* WITH_LZMA */
 
+#if WITH_ZLIB
 static char *
 load_module_file_zlib(const char *filename, size_t *len)
 {
@@ -519,6 +522,15 @@ load_module_file_zlib(const char *filename, size_t *len)
     gzclose(fp);
     return data;
 }
+#else
+static char *
+load_module_file_zlib(const char *filename, size_t *len)
+{
+    fprintf(stderr, "libvirt-sandbox-init-qemu: %s: "
+            "zlib support disabled, can't read module %s\n", __func__, filename);
+    exit_poweroff();
+}
+#endif /* WITH_ZLIB */
 
 static char *
 load_module_file_raw(const char *filename, size_t *len)
-- 
2.1.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]