[virt-tools-list] [PATCH 09/12] build: make libvirt optionnal
Daniel P. Berrange
berrange at redhat.com
Thu Jan 26 16:31:54 UTC 2012
On Tue, Dec 13, 2011 at 08:35:07PM +0100, Marc-André Lureau wrote:
> ---
> configure.ac | 18 +++++++++++++++++-
> src/Makefile.am | 5 ++++-
> src/virt-viewer-auth.c | 3 ++-
> src/virt-viewer-auth.h | 6 ++++++
> 4 files changed, 29 insertions(+), 3 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index 77838fe..6aaa0dc 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -37,7 +37,23 @@ IT_PROG_INTLTOOL([0.35.0])
>
> PKG_CHECK_MODULES(GMODULE2, gmodule-export-2.0 >= $GMODULE2_REQUIRED)
> PKG_CHECK_MODULES(LIBXML2, libxml-2.0 >= $LIBXML2_REQUIRED)
> -PKG_CHECK_MODULES(LIBVIRT, libvirt >= $LIBVIRT_REQUIRED)
> +
> +AC_ARG_WITH([libvirt],
> + AS_HELP_STRING([--without-libvirt], [Ignore presence of libvirt and disable it]))
> +
> +AS_IF([test "x$with_libvirt" != "xno"],
> + [PKG_CHECK_MODULES(LIBVIRT,
> + [libvirt],
> + [have_libvirt=yes], [have_libvirt=no])],
> + [have_libvirt=no])
> +
> +AS_IF([test "x$have_libvirt" = "xyes"],
> + [AC_DEFINE([HAVE_LIBVIRT], 1, [Have libvirt?])],
> + [AS_IF([test "x$with_libvirt" = "xyes"],
> + [AC_MSG_ERROR([libvirt requested but not found])
> + ])
> +])
> +AM_CONDITIONAL([HAVE_LIBVIRT], [test "x$have_libvirt" = "xyes"])
>
> AC_MSG_CHECKING([which gtk+ version to compile against])
> AC_ARG_WITH([gtk],
> diff --git a/src/Makefile.am b/src/Makefile.am
> index e1e0ee9..b4d7556 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -2,7 +2,7 @@ NULL =
> # we are forced to use a shared library,
> # because libtool reordred .a after .la libs, and it fails to link
> lib_LTLIBRARIES = libvirt-viewer.la
> -bin_PROGRAMS = virt-viewer
> +bin_PROGRAMS =
>
> builderxmldir = $(pkgdatadir)/ui
> builderxml_DATA = \
> @@ -13,6 +13,8 @@ builderxml_DATA = \
>
> EXTRA_DIST = $(builderxml_DATA)
>
> +if HAVE_LIBVIRT
> +bin_PROGRAMS += virt-viewer
> virt_viewer_SOURCES = \
> virt-viewer-events.h virt-viewer-events.c \
> virt-viewer.h virt-viewer.c \
> @@ -21,6 +23,7 @@ virt_viewer_SOURCES = \
> virt_viewer_LDADD = libvirt-viewer.la
> virt_viewer_LDFLAGS = @LIBVIRT_LIBS@
> virt_viewer_CFLAGS = $(AM_CFLAGS) @LIBVIRT_CFLAGS@
> +endif
>
> if HAVE_SPICE_GTK
> bin_PROGRAMS += remote-viewer
> diff --git a/src/virt-viewer-auth.c b/src/virt-viewer-auth.c
> index d6c0300..52eb4c9 100644
> --- a/src/virt-viewer-auth.c
> +++ b/src/virt-viewer-auth.c
> @@ -174,6 +174,7 @@ virt_viewer_auth_vnc_credentials(GtkWidget *vnc,
> #endif
>
>
> +#ifdef HAVE_LIBVIRT
> int
> virt_viewer_auth_libvirt_credentials(virConnectCredentialPtr cred,
> unsigned int ncred,
> @@ -228,7 +229,7 @@ virt_viewer_auth_libvirt_credentials(virConnectCredentialPtr cred,
> DEBUG_LOG("Return %d", ret);
> return ret;
> }
> -
> +#endif
>
>
>
> diff --git a/src/virt-viewer-auth.h b/src/virt-viewer-auth.h
> index 1cbf2b6..c111582 100644
> --- a/src/virt-viewer-auth.h
> +++ b/src/virt-viewer-auth.h
> @@ -23,7 +23,11 @@
> #ifndef VIRT_VIEWER_AUTH_H
> #define VIRT_VIEWER_AUTH_H
>
> +#include "config.h"
> +
> +#ifdef HAVE_LIBVIRT
> #include <libvirt/libvirt.h>
> +#endif
>
> #include "virt-viewer-util.h"
>
> @@ -36,8 +40,10 @@ int virt_viewer_auth_collect_credentials(const char *type,
> char **username,
> char **password);
>
> +#ifdef HAVE_LIBVIRT
> int virt_viewer_auth_libvirt_credentials(virConnectCredentialPtr cred,
> unsigned int ncred,
> void *cbdata);
> +#endif
>
> #endif
ACK
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
More information about the virt-tools-list
mailing list