[Libvir] PATCH 2/5: Use pkg-config for gnutls

Daniel P. Berrange berrange at redhat.com
Tue Sep 18 01:32:59 UTC 2007


The current GNU TLS tests in the configure script just use CHECK_HEADER and
CHECK_LIB to try and locate gnutls. This is fine if its in /usr, but no so
useful if it is installed elsewhere. There are also no Makefile.am vars set
to let you specify an alternate install location. gnutls already comes with
support for pkg-config, so this patch just switches our configure script 
and Makefiles over to use that. Building against a different GNU TLS install
is now just a matter of setting PKG_CONFIG_PATH, or the GNUTLS_LIBS and
GNUTLS_CFLAGS vars.

Dan.
-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 
-------------- next part --------------
diff -r 2e77c3faea3f configure.in
--- a/configure.in	Mon Sep 17 03:52:13 2007 -0400
+++ b/configure.in	Mon Sep 17 03:53:48 2007 -0400
@@ -30,6 +30,7 @@ AC_SUBST(LIBVIRT_VERSION_EXTRA)
 AC_SUBST(LIBVIRT_VERSION_EXTRA)
 
 LIBXML_REQUIRED="2.5.0"
+GNUTLS_REQUIRED="1.2.0"
 
 VERSION=${LIBVIRT_VERSION}
 
@@ -276,20 +277,23 @@ LDFLAGS="$old_ldflags"
 LDFLAGS="$old_ldflags"
 
 dnl GnuTLS library
-AC_CHECK_HEADER([gnutls/gnutls.h],
-       [],
-       AC_MSG_ERROR([You must install the GnuTLS development package in order to compile libvirt]))
-AC_CHECK_LIB(gnutls, gnutls_handshake,
-       [],
-       [AC_MSG_ERROR([You must install the GnuTLS library in order to compile and run libvirt])])
+PKG_CHECK_MODULES(GNUTLS, gnutls >= $GNUTLS_REQUIRED)
+AC_SUBST(GNUTLS_CFLAGS)
+AC_SUBST(GNUTLS_LIBS)
 
 dnl Old versions of GnuTLS uses types like 'gnutls_session' instead
 dnl of 'gnutls_session_t'.  Try to detect this type if defined so
 dnl that we can offer backwards compatibility.
+old_cflags="$CFLAGS"
+old_ldflags="$LDFLAGS"
+CFLAGS="$CFLAGS $GNUTLS_CFLAGS"
+LDFLAGS="$LDFLAGS $GNUTLS_LIBS"
 AC_CHECK_TYPE(gnutls_session,
 	AC_DEFINE(GNUTLS_1_0_COMPAT,[],
 		[enable GnuTLS 1.0 compatibility macros]),,
 	[#include <gnutls/gnutls.h>])
+CFLAGS="$old_cflags"
+LDFLAGS="$old_ldflags"
 
 dnl virsh libraries
 AC_CHECK_LIB(curses, initscr, 
diff -r 2e77c3faea3f qemud/Makefile.am
--- a/qemud/Makefile.am	Mon Sep 17 03:52:13 2007 -0400
+++ b/qemud/Makefile.am	Mon Sep 17 03:56:13 2007 -0400
@@ -1,6 +1,5 @@
 ## Process this file with automake to produce Makefile.in
 
-INCLUDES = @LIBXML_CFLAGS@
 UUID=$(shell uuidgen)
 
 sbin_PROGRAMS = libvirtd
@@ -13,14 +12,15 @@ libvirtd_SOURCES = \
                 event.c event.h
 #-D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -D_POSIX_C_SOURCE=199506L
 libvirtd_CFLAGS = \
-        -I$(top_srcdir)/include -I$(top_builddir)/include $(LIBXML_CFLAGS) \
+        -I$(top_srcdir)/include -I$(top_builddir)/include \
+        $(LIBXML_CFLAGS) $(GNUTLS_CFLAGS) \
         $(WARN_CFLAGS) -DLOCAL_STATE_DIR="\"$(localstatedir)\"" \
         -DSYSCONF_DIR="\"$(sysconfdir)\"" \
 	-DQEMUD_PID_FILE="\"$(QEMUD_PID_FILE)\"" \
 	-DREMOTE_PID_FILE="\"$(REMOTE_PID_FILE)\"" \
         -DGETTEXT_PACKAGE=\"$(PACKAGE)\"
 
-libvirtd_LDFLAGS = $(WARN_CFLAGS) $(LIBXML_LIBS)
+libvirtd_LDFLAGS = $(WARN_CFLAGS) $(LIBXML_LIBS) $(GNUTLS_LIBS)
 libvirtd_DEPENDENCIES = ../src/libvirt.la
 libvirtd_LDADD = ../src/libvirt.la
 
diff -r 2e77c3faea3f src/Makefile.am
--- a/src/Makefile.am	Mon Sep 17 03:52:13 2007 -0400
+++ b/src/Makefile.am	Mon Sep 17 03:56:38 2007 -0400
@@ -3,7 +3,8 @@ INCLUDES = -I$(top_builddir)/include \
 INCLUDES = -I$(top_builddir)/include \
 	   -I at top_srcdir@/include \
 	   -I at top_srcdir@/qemud \
-	   @LIBXML_CFLAGS@ \
+	   $(LIBXML_CFLAGS) \
+	   $(GNUTLS_CFLAGS) \
 	   -DBINDIR=\""$(libexecdir)"\" \
 	   -DSBINDIR=\""$(sbindir)"\" \
 	   -DSYSCONF_DIR="\"$(sysconfdir)\"" \
@@ -19,7 +20,7 @@ EXTRA_DIST = libvirt_sym.version
 EXTRA_DIST = libvirt_sym.version
 
 lib_LTLIBRARIES = libvirt.la
-libvirt_la_LIBADD = @LIBXML_LIBS@
+libvirt_la_LIBADD = $(LIBXML_LIBS) $(GNUTLS_LIBS)
 libvirt_la_LDFLAGS = -Wl,--version-script=$(srcdir)/libvirt_sym.version \
                     -version-info @LIBVIRT_VERSION_INFO@ \
                     $(COVERAGE_CFLAGS:-f%=-Wc,-f%)
diff -r 2e77c3faea3f tests/Makefile.am
--- a/tests/Makefile.am	Mon Sep 17 03:52:13 2007 -0400
+++ b/tests/Makefile.am	Mon Sep 17 03:58:42 2007 -0400
@@ -15,7 +15,8 @@ INCLUDES = \
 	-I$(top_builddir)/src \
 	-I$(top_srcdir)/include \
 	-I$(top_srcdir)/src \
-	@LIBXML_CFLAGS@ \
+	$(LIBXML_CFLAGS) \
+	$(GNUTLS_CFLAGS) \
         -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=199506L \
         -DGETTEXT_PACKAGE=\"$(PACKAGE)\" \
          $(COVERAGE_CFLAGS) \
@@ -24,7 +25,8 @@ INCLUDES = \
 
 LDADDS = \
 	@STATIC_BINARIES@ \
-	@LIBXML_LIBS@ \
+	$(LIBXML_LIBS) \
+        $(GNUTLS_LIBS) \
         $(WARN_CFLAGS) \
 	$(LIBVIRT) \
         $(COVERAGE_LDFLAGS)


More information about the libvir-list mailing list