]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
build: use library rather than cross-directory compilation
authorEric Blake <eblake@redhat.com>
Sun, 8 Sep 2013 02:49:17 +0000 (20:49 -0600)
committerEric Blake <eblake@redhat.com>
Mon, 9 Sep 2013 18:04:03 +0000 (12:04 -0600)
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@redhat.com>
daemon/Makefile.am
tests/Makefile.am

index e0b8744a5c13fb75967c727900e3b3df744b8653..eb58de92d13df2f190e027ecdf816eb8ab97604e 100644 (file)
@@ -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
index 1a2436793f719676f4c153ca06908ca90a07215f..e5cf7403302bf90fad4da2ed383f70f20df24053 100644 (file)
@@ -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