Re: [libvirt] PATCH: 6/11: Change WITH_XXXX macros to love in config.h

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

 



The configure script lets users turn on/of individual drivers. Their
choices get fed into a LIBVIRT_FEATURES macro, which has one or more
-DWITH_XEN -DWITH_OPENVZ, etc, etc. The compiler args become rather
long when we have all the drivers enabled. So this patch tweaks the
configure file to instead put all these WITH_XEN, WITH_QEMU macros
into the config.h file.

Secondly, the Makefile.am has a few places where we do nested conditionals
to determine whether to build QEMU, eg

  if WITH_LIBVIRTD
  if WITH_QEMU

This patch also tweaks the configure script so that WITH_QEMU is never
defined, unless WITH_LIBVIRTD is also defined. Now the makefile.am
can just do

  if WITH_QEMU

which makes things a little more readable, and helps avoid errors where
we miss the WITH_LIBVIRTD wrapper.

There is no functional code change here, its all just playing with the
way makefile/macro conditionals are done.

 configure.in      |   83 +++++++++++++++++++++++++++++++++---------------------
 proxy/Makefile.am |    4 +-
 qemud/Makefile.am |    2 -
 src/Makefile.am   |   29 +++++++++---------
 src/libvirt.c     |    2 -
 tests/Makefile.am |    4 --
 6 files changed, 70 insertions(+), 54 deletions(-)


Daniel

diff -r 0960752d24df configure.in
--- a/configure.in	Wed Oct 29 20:10:43 2008 +0000
+++ b/configure.in	Wed Oct 29 20:10:49 2008 +0000
@@ -232,59 +232,69 @@
 AC_PATH_PROG([IPTABLES_PATH], [iptables], /sbin/iptables, [/usr/sbin:$PATH])
 AC_DEFINE_UNQUOTED([IPTABLES_PATH], "$IPTABLES_PATH", [path to iptables binary])
 
-dnl
-dnl Specify the xen-distribution directory to be able to compile on a
-dnl non-xenified host
-dnl
-AC_ARG_WITH([xen-distdir], [AC_HELP_STRING([--with-xen-distdir=path],
-            [distribution directory of Xen, default /usr])])
-if test "x$with_xen_distdir" != "x"
-then
-CPPFLAGS="$CPPFLAGS -I$withval/install/usr/include"
-LDFLAGS="$LDFLAGS -L$withval/install/usr/lib -L$withval/install/usr/lib64"
-fi
-
-LIBVIRT_FEATURES=
-WITH_XEN=0
-
 if test "$with_openvz" = "yes"; then
-    LIBVIRT_FEATURES="$LIBVIRT_FEATURES -DWITH_OPENVZ"
+    AC_DEFINE_UNQUOTED([WITH_OPENVZ], 1, [whether OpenVZ driver is enabled])
 fi
 AM_CONDITIONAL([WITH_OPENVZ], [test "$with_openvz" = "yes"])
 
+if test "$with_libvirtd" = "no" ; then
+  with_lxc=no
+fi
 if test "$with_lxc" = "yes" ; then
-    LIBVIRT_FEATURES="$LIBVIRT_FEATURES -DWITH_LXC"
+    AC_DEFINE_UNQUOTED([WITH_LXC], 1, [whether LXC driver is enabled])
 fi
 AM_CONDITIONAL([WITH_LXC], [test "$with_lxc" = "yes"])
 
+if test "$with_libvirtd" = "no" ; then
+  with_qemu=no
+fi
 if test "$with_qemu" = "yes" ; then
-    LIBVIRT_FEATURES="$LIBVIRT_FEATURES -DWITH_QEMU"
+    AC_DEFINE_UNQUOTED([WITH_QEMU], 1, [whether QEMU driver is enabled])
 fi
 AM_CONDITIONAL([WITH_QEMU], [test "$with_qemu" = "yes"])
 
 if test "$with_test" = "yes" ; then
-    LIBVIRT_FEATURES="$LIBVIRT_FEATURES -DWITH_TEST"
+    AC_DEFINE_UNQUOTED([WITH_TEST], 1, [whether Test driver is enabled])
 fi
 AM_CONDITIONAL([WITH_TEST], [test "$with_test" = "yes"])
 
 if test "$with_remote" = "yes" ; then
-    LIBVIRT_FEATURES="$LIBVIRT_FEATURES -DWITH_REMOTE"
+    AC_DEFINE_UNQUOTED([WITH_REMOTE], 1, [whether Remote driver is enabled])
 fi
 AM_CONDITIONAL([WITH_REMOTE], [test "$with_remote" = "yes"])
 
 if test "$with_libvirtd" = "yes" ; then
-    LIBVIRT_FEATURES="$LIBVIRT_FEATURES -DWITH_LIBVIRTD"
+    AC_DEFINE_UNQUOTED([WITH_LIBVIRTD], 1, [whether libvirtd daemon is enabled])
 fi
 AM_CONDITIONAL([WITH_LIBVIRTD], [test "$with_libvirtd" = "yes"])
 
-if test "$with_xen" = "yes" ; then
-    dnl search for the Xen store library
-    AC_SEARCH_LIBS(xs_read, [xenstore],
-                   [WITH_XEN=1],
-                   [AC_MSG_RESULT([Xen store library not found])])
-    if test "$WITH_XEN" != "0" ; then
-        LIBVIRT_FEATURES="$LIBVIRT_FEATURES -DWITH_XEN"
+XEN_LIBS=""
+XEN_CFLAGS=""
+dnl search for the Xen store library
+if test "$with_xen" != "no" ; then
+    if test "$with_xen" != "yes" -a "$with_xen" != "check" ; then
+        XEN_CFLAGS="-I$with_xen/include"
+        XEN_LIBS="-L$with_xen/lib64 -L$with_xen/lib"
     fi
+    fail=0
+    old_LIBS="$LIBS"
+    old_CFLAGS="$CFLAGS"
+    CFLAGS="$CFLAGS $XEN_CFLAGS"
+    LIBS="$LIBS $XEN_LIBS"
+    AC_CHECK_LIB([xenstore], [xs_read], [
+           with_xen=yes
+           XEN_LIBS="$XEN_LIBS -lxenstore"
+       ],[
+           if test "$with_xen" = "check" ; then
+               with_xen=no
+           else
+               with_xen=no
+               fail=1
+           fi
+       ])
+
+    test $fail = 1 &&
+      AC_MSG_ERROR([You must install the Xen development package to compile Xen driver with -lxenstore])
 
     AC_CHECK_HEADERS([xen/xen.h xen/version.h xen/dom0_ops.h],,[
 	AC_MSG_ERROR([Cannot find standard Xen headers. Is xen-devel installed?])
@@ -307,8 +317,15 @@
 #include <stdint.h>
 #include <xen/xen.h>
 ])
+    LIBS="$old_LIBS"
+    CFLAGS="$old_CFLAGS"
 fi
-AM_CONDITIONAL([WITH_XEN], [test "$WITH_XEN" = "1"])
+if test "$with_xen" = "yes"; then
+    AC_DEFINE_UNQUOTED([WITH_XEN], 1, [whether Xen driver is enabled])
+fi
+AM_CONDITIONAL([WITH_XEN], [test "$with_xen" = "yes"])
+AC_SUBST([XEN_CFLAGS])
+AC_SUBST([XEN_LIBS])
 
 dnl
 dnl check for kernel headers required by src/bridge.c
@@ -640,9 +657,6 @@
 fi
 AC_SUBST([READLINE_CFLAGS])
 AC_SUBST([VIRSH_LIBS])
-
-AC_SUBST([WITH_XEN])
-AC_SUBST([LIBVIRT_FEATURES])
 
 
 AC_ARG_WITH([network],
@@ -1124,6 +1138,11 @@
 else
 AC_MSG_NOTICE([  numactl: no])
 fi
+if test "$with_xen" = "yes" ; then
+AC_MSG_NOTICE([  xen: $XEN_CFLAGS $XEN_LIBS])
+else
+AC_MSG_NOTICE([  xen: no])
+fi
 AC_MSG_NOTICE([])
 AC_MSG_NOTICE([Test suite])
 AC_MSG_NOTICE([])
diff -r 0960752d24df proxy/Makefile.am
--- a/proxy/Makefile.am	Wed Oct 29 20:10:43 2008 +0000
+++ b/proxy/Makefile.am	Wed Oct 29 20:10:49 2008 +0000
@@ -5,7 +5,7 @@
            -I$(top_builddir)/include -I@top_srcdir@/include \
 	   -I@top_srcdir@/proxy -I@top_srcdir@/src @LIBXML_CFLAGS@ \
 	   -DPROXY  -DLOCALEBASEDIR=\""$(datadir)/locale"\" \
-           -DGETTEXT_PACKAGE=\"$(PACKAGE)\" $(WARN_CFLAGS) $(LIBVIRT_FEATURES)
+           -DGETTEXT_PACKAGE=\"$(PACKAGE)\" $(WARN_CFLAGS) $(XEN_CFLAGS)
 
 libexec_PROGRAMS = libvirt_proxy
 
@@ -19,7 +19,7 @@
             @top_srcdir@/src/util.c \
 	    @top_srcdir@/src/event.c \
 	    @top_srcdir@/src/uuid.c
-libvirt_proxy_LDFLAGS = $(WARN_CFLAGS)
+libvirt_proxy_LDFLAGS = $(WARN_CFLAGS) $(XEN_LIBS)
 libvirt_proxy_DEPENDENCIES =
 libvirt_proxy_LDADD = ../gnulib/lib/libgnu.la
 
diff -r 0960752d24df qemud/Makefile.am
--- a/qemud/Makefile.am	Wed Oct 29 20:10:43 2008 +0000
+++ b/qemud/Makefile.am	Wed Oct 29 20:10:49 2008 +0000
@@ -1,6 +1,4 @@
 ## Process this file with automake to produce Makefile.in
-
-INCLUDES = $(LIBVIRT_FEATURES)
 
 DAEMON_SOURCES =					\
 		event.c event.h				\
diff -r 0960752d24df src/Makefile.am
--- a/src/Makefile.am	Wed Oct 29 20:10:43 2008 +0000
+++ b/src/Makefile.am	Wed Oct 29 20:10:49 2008 +0000
@@ -10,14 +10,15 @@
 	   $(SASL_CFLAGS) \
 	   $(SELINUX_CFLAGS) \
 	   $(NUMACTL_CFLAGS) \
+	   $(XEN_CFLAGS) \
 	   -DBINDIR=\""$(libexecdir)"\" \
 	   -DSBINDIR=\""$(sbindir)"\" \
 	   -DSYSCONF_DIR="\"$(sysconfdir)\"" \
 	   -DLOCALEBASEDIR=\""$(datadir)/locale"\" \
            -DLOCAL_STATE_DIR=\""$(localstatedir)"\" \
            -DGETTEXT_PACKAGE=\"$(PACKAGE)\" \
-	   $(WARN_CFLAGS) \
-	   $(LIBVIRT_FEATURES)
+	   $(WARN_CFLAGS)
+
 DEPS = libvirt.la
 LDADDS = @STATIC_BINARIES@ $(WARN_CFLAGS) libvirt.la ../gnulib/lib/libgnu.la
 VIRSH_LIBS = @VIRSH_LIBS@
@@ -48,7 +49,6 @@
 		iptables.c iptables.h				\
 		memory.c memory.h				\
 		qparams.c qparams.h				\
-		stats_linux.c stats_linux.h			\
 		uuid.c uuid.h					\
 		util.c util.h					\
 		virterror.c virterror_internal.h		\
@@ -151,13 +151,13 @@
 		internal.h					\
 		datatypes.c datatypes.h				\
 		domain_event.c domain_event.h			\
+		stats_linux.c stats_linux.h			\
 		libvirt.c libvirt_internal.h			\
 		$(GENERIC_LIB_SOURCES)				\
 		$(DOMAIN_CONF_SOURCES)				\
 		$(NETWORK_CONF_SOURCES)				\
 		$(STORAGE_CONF_SOURCES)
 
-# Drivers usable outside daemon context
 if WITH_TEST
 libvirt_la_SOURCES += $(TEST_DRIVER_SOURCES)
 endif
@@ -174,20 +174,22 @@
 libvirt_la_SOURCES += $(OPENVZ_DRIVER_SOURCES)
 endif
 
-# Drivers usable inside daemon context
-if WITH_LIBVIRTD
-if WITH_NETWORK
-libvirt_la_SOURCES += $(NETWORK_DRIVER_SOURCES)
-endif
-libvirt_la_SOURCES += $(STORAGE_DRIVER_SOURCES)
-libvirt_la_SOURCES += $(STORAGE_DRIVER_FS_SOURCES)
-
 if WITH_QEMU
 libvirt_la_SOURCES += $(QEMU_DRIVER_SOURCES)
 endif
 
 if WITH_LXC
 libvirt_la_SOURCES += $(LXC_DRIVER_SOURCES)
+endif
+
+
+if WITH_NETWORK
+libvirt_la_SOURCES += $(NETWORK_DRIVER_SOURCES)
+endif
+
+if WITH_STORAGE_DIR
+libvirt_la_SOURCES += $(STORAGE_DRIVER_SOURCES)
+libvirt_la_SOURCES += $(STORAGE_DRIVER_FS_SOURCES)
 endif
 
 if WITH_STORAGE_LVM
@@ -200,7 +202,6 @@
 
 if WITH_STORAGE_DISK
 libvirt_la_SOURCES += $(STORAGE_DRIVER_DISK_SOURCES)
-endif
 endif
 
 # Add all conditional sources just in case...
@@ -220,7 +221,7 @@
 
 
 libvirt_la_LIBADD = $(LIBXML_LIBS) $(GNUTLS_LIBS) $(SASL_LIBS) $(SELINUX_LIBS) \
-                    $(NUMACTL_LIBS) \
+                    $(NUMACTL_LIBS) $(XEN_LIBS) \
 		    @CYGWIN_EXTRA_LIBADD@ ../gnulib/lib/libgnu.la
 libvirt_la_LDFLAGS = -Wl,--version-script=$(srcdir)/libvirt_sym.version \
                      -version-info @LIBVIRT_VERSION_INFO@ \
diff -r 0960752d24df src/libvirt.c
--- a/src/libvirt.c	Wed Oct 29 20:10:43 2008 +0000
+++ b/src/libvirt.c	Wed Oct 29 20:10:49 2008 +0000
@@ -289,7 +289,6 @@
 #ifdef WITH_XEN
     if (xenUnifiedRegister () == -1) return -1;
 #endif
-#ifdef WITH_LIBVIRTD
 #ifdef WITH_QEMU
     if (qemudRegister() == -1) return -1;
 #endif
@@ -302,6 +301,7 @@
 #ifdef WITH_NETWORK
     if (networkRegister() == -1) return -1;
 #endif
+#ifdef WITH_STORAGE_DIR
     if (storageRegister() == -1) return -1;
 #endif
 #ifdef WITH_REMOTE
diff -r 0960752d24df tests/Makefile.am
--- a/tests/Makefile.am	Wed Oct 29 20:10:43 2008 +0000
+++ b/tests/Makefile.am	Wed Oct 29 20:10:49 2008 +0000
@@ -15,11 +15,9 @@
 	$(GNUTLS_CFLAGS) \
 	$(SASL_CFLAGS) \
 	$(SELINUX_CFLAGS) \
-        -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L \
         -DGETTEXT_PACKAGE=\"$(PACKAGE)\" \
          $(COVERAGE_CFLAGS) \
-         $(WARN_CFLAGS)	\
-	 $(LIBVIRT_FEATURES)
+         $(WARN_CFLAGS)
 
 LDADDS = \
 	@STATIC_BINARIES@ \

-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
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]