[PATCH 2/4] build: use library rather than cross-directory compilation

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

 



If we use subdir-objects with automake, any reference to a
cross-directory .c file will result in automake creating
rules that track dependency in the cross directory.  But this
presents a problem during 'make distclean' - if the cross
directory is cleaned up first, then the daemon directory will
be left with dangling references to .Po dependency files that
no longer exist.

Meanwhile, referring to the cross-directory .c file means
that we are compiling the file twice - once in src, and once
in daemon.  Better is to compile just once in src into a
convenience library, and then use that library from daemon.

The tests directory had a similar situation of a cross-directory
.c file; to solve that, we actually need a convenience library.

* daemon/Makefile.am (DAEMON_SOURCES): Drop .c files...
(libvirtd_LDADD): ...and instead use library.
(libvirtd_conf_la_SOURCES): Declare a new convenience library.
(libvirtd_LDFLAGS): Drop duplicate flag.
* tests/Makefile.am (libvirtdconftest_SOURCES): Drop .c file...
(libvirtdconftest_LDADD): ..and instead use library.

Signed-off-by: Eric Blake <eblake@xxxxxxxxxx>
---
 daemon/Makefile.am | 32 +++++++++++++++++++++++++-------
 tests/Makefile.am  |  4 ++--
 2 files changed, 27 insertions(+), 9 deletions(-)

diff --git a/daemon/Makefile.am b/daemon/Makefile.am
index e0b8744..eb58de9 100644
--- a/daemon/Makefile.am
+++ b/daemon/Makefile.am
@@ -37,14 +37,12 @@ DAEMON_GENERATED =			\

 DAEMON_SOURCES =					\
 		libvirtd.c libvirtd.h			\
-		libvirtd-config.c libvirtd-config.h	\
 		remote.c remote.h			\
 		stream.c stream.h			\
-		../src/remote/remote_protocol.c		\
-		../src/remote/lxc_protocol.c		\
-		../src/remote/qemu_protocol.c		\
 		$(DAEMON_GENERATED)

+LIBVIRTD_CONF_SOURCES = libvirtd-config.c libvirtd-config.h
+
 DISTCLEANFILES =
 EXTRA_DIST =						\
 	remote_dispatch.h				\
@@ -67,7 +65,9 @@ EXTRA_DIST =						\
 	THREADS.txt					\
 	libvirtd.pod.in					\
 	libvirtd.8.in					\
-	$(DAEMON_SOURCES)
+	$(DAEMON_SOURCES)				\
+	$(LIBVIRTD_CONF_SOURCES)			\
+	$(NULL)

 BUILT_SOURCES =

@@ -95,6 +95,22 @@ qemu_dispatch.h: $(srcdir)/../src/rpc/gendispatch.pl \

 if WITH_LIBVIRTD

+# Build a convenience library, for reuse in tests/libvirtdconftest
+noinst_LTLIBRARIES = libvirtd_conf.la
+libvirtd_conf_la_SOURCES = $(LIBVIRTD_CONF_SOURCES)
+libvirtd_conf_la_CFLAGS = \
+	$(LIBXML_CFLAGS) \
+	$(WARN_CFLAGS) $(PIE_CFLAGS) \
+	$(COVERAGE_CFLAGS) \
+	$(NULL)
+libvirtd_conf_la_LDFLAGS =				\
+	$(RELRO_LDFLAGS)				\
+	$(PIE_LDFLAGS)					\
+	$(COVERAGE_LDFLAGS)				\
+	$(NO_INDIRECT_LDFLAGS)				\
+	$(NULL)
+libvirtd_conf_la_LIBADD = $(LIBXML_LIBS)
+
 man8_MANS = libvirtd.8

 sbin_PROGRAMS = libvirtd
@@ -130,7 +146,6 @@ libvirtd_CFLAGS = \
 libvirtd_LDFLAGS =					\
 	$(RELRO_LDFLAGS)				\
 	$(PIE_LDFLAGS)					\
-	$(RELRO_LDFLAGS)				\
 	$(COVERAGE_LDFLAGS)				\
 	$(NO_INDIRECT_LDFLAGS)				\
 	$(NULL)
@@ -148,8 +163,11 @@ libvirtd_LDADD += ../src/libvirt_probes.lo
 endif WITH_DTRACE_PROBES

 libvirtd_LDADD += \
+	libvirtd_conf.la \
 	../src/libvirt-lxc.la \
-	../src/libvirt-qemu.la
+	../src/libvirt-qemu.la \
+	../src/libvirt_driver_remote.la \
+	$(NULL)

 if ! WITH_DRIVER_MODULES
 if WITH_QEMU
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1a24367..e5cf740 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -599,8 +599,8 @@ commandhelper_LDFLAGS = -static
 if WITH_LIBVIRTD
 libvirtdconftest_SOURCES = \
 	libvirtdconftest.c testutils.h testutils.c \
-	../daemon/libvirtd-config.c
-libvirtdconftest_LDADD = $(LDADDS)
+	$(NULL)
+libvirtdconftest_LDADD = ../daemon/libvirtd_conf.la $(LDADDS)
 else ! WITH_LIBVIRTD
 EXTRA_DIST += libvirtdconftest.c
 endif ! WITH_LIBVIRTD
-- 
1.8.3.1

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