[PATCH] Avoid link errors with "configure --disable-shared".

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

 



I got link errors when building with --disable-shared, and finally
fixed it.  Here's most of the solution.  The patch after this one
adjusts the gcov (test-coverage)-related things so that works with
the new setup, too.

This also fixes what look like accidental omissions
in src/libvirt_sym.version.

	Avoid link errors with "configure --disable-shared".
	* src/Makefile.am: Create a convenience library, libvirt_test.la,
	and don't restrict access to *its* symbols.
	* tests/Makefile.am (LDADDS): Add ../src/libvirt_test.la, so that
	"configure --disable-shared" no longer provokes link errors.
	(LIBVIRT): Remove definition.
	(LDADDS): Remove use.
	($(LIBVIRT)): Remove rule.
	(LDADDS): Use the new convenience library instead.
	(CLEANFILES): Define.
	* docs/examples/index.py (dump_Makefile): Append $(COVERAGE_LDFLAGS),
	to the LDADDS definition, to avoid link error with the combination of
	--enable-test-coverage and --disable-shared.
	* docs/examples/Makefile.am: Regenerate.
	* docs/examples/index.html: Likewise.
	* qemud/Makefile.am (libvirtd_LDFLAGS): Append $(COVERAGE_LDFLAGS).

Signed-off-by: Jim Meyering <meyering@xxxxxxxxxx>
---
 docs/examples/Makefile.am |    2 +-
 docs/examples/index.html  |    2 +-
 docs/examples/index.py    |    3 ++-
 qemud/Makefile.am         |   26 ++++++++++++++++----------
 src/Makefile.am           |   19 +++++++++++++++++++
 src/libvirt_sym.version   |   11 +++++++----
 tests/Makefile.am         |   13 ++-----------
 7 files changed, 48 insertions(+), 28 deletions(-)

diff --git a/docs/examples/Makefile.am b/docs/examples/Makefile.am
index 9da4e21..d8e4868 100644
--- a/docs/examples/Makefile.am
+++ b/docs/examples/Makefile.am
@@ -3,7 +3,7 @@
 SUBDIRS=python
 INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include -I@srcdir@/include
 DEPS = $(top_builddir)/src/libvirt.la
-LDADDS = @STATIC_BINARIES@ $(WARN_CFLAGS) $(top_builddir)/src/libvirt.la
+LDADDS = @STATIC_BINARIES@ $(WARN_CFLAGS) $(top_builddir)/src/libvirt.la 	$(COVERAGE_LDFLAGS)

 rebuild: examples.xml index.html

diff --git a/docs/examples/index.html b/docs/examples/index.html

[...omitting generated diff containing a couple of 4000+-byte lines...]

diff --git a/docs/examples/index.py b/docs/examples/index.py
index 8f386ed..6be80c5 100755
--- a/docs/examples/index.py
+++ b/docs/examples/index.py
@@ -225,7 +225,8 @@ def dump_Makefile():
 SUBDIRS=python
 INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include -I@srcdir@/include
 DEPS = $(top_builddir)/src/libvirt.la
-LDADDS = @STATIC_BINARIES@ $(WARN_CFLAGS) $(top_builddir)/src/libvirt.la
+LDADDS = @STATIC_BINARIES@ $(WARN_CFLAGS) $(top_builddir)/src/libvirt.la \
+	$(COVERAGE_LDFLAGS)

 rebuild: examples.xml index.html

diff --git a/qemud/Makefile.am b/qemud/Makefile.am
index 1e1f861..b39bc2f 100644
--- a/qemud/Makefile.am
+++ b/qemud/Makefile.am
@@ -47,18 +47,22 @@ libvirtd_SOURCES = \

 #-D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -D_POSIX_C_SOURCE=199506L
 libvirtd_CFLAGS = \
-        -I$(top_srcdir)/gnulib/lib -I../gnulib/lib \
-        -I$(top_srcdir)/include -I$(top_builddir)/include \
-        $(LIBXML_CFLAGS) $(GNUTLS_CFLAGS) $(SASL_CFLAGS) \
-        $(POLKIT_CFLAGS) \
-        $(WARN_CFLAGS) -DLOCAL_STATE_DIR="\"$(localstatedir)\"" \
-        -DSYSCONF_DIR="\"$(sysconfdir)\"" \
+	-I$(top_srcdir)/gnulib/lib -I../gnulib/lib \
+	-I$(top_srcdir)/include -I$(top_builddir)/include \
+	$(LIBXML_CFLAGS) $(GNUTLS_CFLAGS) $(SASL_CFLAGS) \
+	$(POLKIT_CFLAGS) \
+	$(WARN_CFLAGS) -DLOCAL_STATE_DIR="\"$(localstatedir)\"" \
+	$(COVERAGE_CFLAGS) \
+	-DSYSCONF_DIR="\"$(sysconfdir)\"" \
 	-DQEMUD_PID_FILE="\"$(QEMUD_PID_FILE)\"" \
 	-DREMOTE_PID_FILE="\"$(REMOTE_PID_FILE)\"" \
-        -DGETTEXT_PACKAGE=\"$(PACKAGE)\"
+	-DGETTEXT_PACKAGE=\"$(PACKAGE)\"
+
+libvirtd_LDFLAGS = \
+	$(WARN_CFLAGS) $(LIBXML_LIBS) $(GNUTLS_LIBS) $(SASL_LIBS) \
+	$(COVERAGE_LDFLAGS)
+	$(POLKIT_LIBS)

-libvirtd_LDFLAGS = $(WARN_CFLAGS) $(LIBXML_LIBS) $(GNUTLS_LIBS) $(SASL_LIBS) \
-                   $(POLKIT_LIBS)
 libvirtd_DEPENDENCIES = ../src/libvirt.la
 libvirtd_LDADD = ../src/libvirt.la ../gnulib/lib/libgnu.la

@@ -144,7 +148,6 @@ libvirtd.init: libvirtd.init.in
 	chmod a+x $@-t
 	mv $@-t $@

-CLEANFILES = libvirtd.init
 else

 install-init:
@@ -153,3 +156,6 @@ uninstall-init:
 endif # DBUS_INIT_SCRIPTS_RED_HAT

 endif # WITH_LIBVIRTD
+
+CLEANFILES = libvirtd.init
+CLEANFILES += *.cov *.gcov .libs/*.gcda .libs/*.gcno *.gcno *.gcda
diff --git a/src/Makefile.am b/src/Makefile.am
index 02be9db..c15de77 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -99,6 +99,25 @@ libvirt_la_LDFLAGS = -Wl,--version-script=$(srcdir)/libvirt_sym.version \
 		    @CYGWIN_EXTRA_LDFLAGS@ @MINGW_EXTRA_LDFLAGS@
 libvirt_la_CFLAGS = $(COVERAGE_CFLAGS) -DIN_LIBVIRT

+# Create an automake "convenience library" version of libvirt_la,
+# just for testing, since the test harness requires access to internal
+# bits and pieces that we don't want to make publicly accessible.
+noinst_LTLIBRARIES = libvirt_test.la
+
+# Convert libvirt_sym.version
+#      to libvirt_test_sym.version, and
+# remove -version-info X.Y.Z (not needed since this is a convenience library.
+test_LDFLAGS =						\
+  $$(echo '$(libvirt_la_LDFLAGS)'			\
+     |sed 's!-Wl,--v.*_sym\.version!!'			\
+     |sed 's!-version-info @LIBVIRT_VERSION_INFO@!!')
+
+# Just like the above, but with a slightly different set of public symbols.
+libvirt_test_la_SOURCES = $(libvirt_la_SOURCES)
+libvirt_test_la_LIBADD = $(libvirt_la_LIBADD)
+libvirt_test_la_LDFLAGS = $(test_LDFLAGS)
+libvirt_test_la_CFLAGS = $(COVERAGE_CFLAGS)
+
 bin_PROGRAMS = virsh

 virsh_SOURCES = virsh.c console.c console.h util-lib.c
diff --git a/src/libvirt_sym.version b/src/libvirt_sym.version
index 38b631e..581f380 100644
--- a/src/libvirt_sym.version
+++ b/src/libvirt_sym.version
@@ -32,6 +32,7 @@
 	virDomainLookupByName;
 	virDomainLookupByUUID;
 	virDomainLookupByUUIDString;
+	virDomainParseXMLDesc;
 	virDomainRestore;
 	virDomainResume;
 	virDomainSave;
@@ -166,10 +167,10 @@

 	__virEventRegisterImpl;

- 	__virStateInitialize;
- 	__virStateCleanup;
- 	__virStateReload;
- 	__virStateActive;
+	__virStateInitialize;
+	__virStateCleanup;
+	__virStateReload;
+	__virStateActive;

 	__virDrvSupportsFeature;

@@ -184,6 +185,8 @@
         __virBufferVSprintf;
         __virBufferAdd;
         __virBufferAddChar;
+        __virErrorMsg;
+        __virRaiseError;

     local: *;
 };
diff --git a/tests/Makefile.am b/tests/Makefile.am
index fb9bcff..644715e 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -3,14 +3,6 @@
 SUBDIRS = virshdata confdata sexpr2xmldata \
   xml2sexprdata xmconfigdata xencapsdata

-# Wierd libtool related juju...
-#
-# We explicitly want wildcard here instead of just linking
-# to the libvirt.a file. This ensures that when coverage
-# tests are run, all the output data ends up in the correct
-# location. ie, src/ instead of src/.libs.
-LIBVIRT = $(wildcard $(top_builddir)/src/.libs/libvirt_la-*.o)
-
 INCLUDES = \
 	-I$(top_srcdir)/gnulib/lib -I../gnulib/lib \
 	-I$(top_builddir)/include \
@@ -34,7 +26,7 @@ LDADDS = \
         $(SASL_LIBS) \
         $(SELINUX_LIBS) \
         $(WARN_CFLAGS) \
-	$(LIBVIRT) \
+	../src/libvirt_test.la \
 	../gnulib/lib/libgnu.la \
         $(COVERAGE_LDFLAGS)

@@ -132,5 +124,4 @@ reconnect_SOURCES = \
 	reconnect.c
 reconnect_LDADD = $(LDADDS)

-$(LIBVIRT):
-	-@(cd $(top_builddir)/src && $(MAKE) MAKEFLAGS+=--silent)
+CLEANFILES = *.cov *.gcov .libs/*.gcda .libs/*.gcno *.gcno *.gcda
--
1.5.4.3.231.gc0a6

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