[Libvir] PATCH: Remove use of PKG_CHECK_EXISTS

Daniel P. Berrange berrange at redhat.com
Tue Jan 22 17:39:54 UTC 2008


On Tue, Jan 22, 2008 at 04:00:49PM +0000, Daniel P. Berrange wrote:
> This patch removes the use of PKG_CHECK_EXISTS which is only available in
> new versions of pkg-config.  Instead we use the 3rd and 4th args of the
> PKG_CHECK_MODULES macro to control the  if-found/not-found  behaviour. This
> allows us to auto-disable features if they're missing, rather than aborting
> the configure run. This patch also updates the SASL tests to support the
> value 'check' for auto-enable/disable like the rest of the modules.
> 
> With this applied I can successfully run the following on RHEL-4 hosts
> with the default RPMs installed
> 
>   ./autogen.sh --without-xen
>   make
>   make dist

Here's a second version of the patch. I needed to conditionally define
the PKG_PROG_PKG_CONFIG  macro since that's no available on old RHEL-4.
Second, I had to make make gnutls fallback to doing a AC_LIB/AC_HEADER
check if pkg-config fails because ancient gnutls doesn't have pkgconfig
support. Finally I also had to add another compatability define for 
the gnutls_cipher_algorithm_t typedef.

With this all done, it now works correctly on both RHEL-4 and my F8
boxes.

Regards,
Dan.

Index: configure.in
===================================================================
RCS file: /data/cvs/libvirt/configure.in,v
retrieving revision 1.121
diff -u -p -r1.121 configure.in
--- configure.in	19 Jan 2008 18:36:01 -0000	1.121
+++ configure.in	22 Jan 2008 17:21:27 -0000
@@ -218,12 +218,6 @@ CPPFLAGS="$CPPFLAGS -I$withval/install/u
 LDFLAGS="$LDFLAGS -L$withval/install/usr/lib"
 fi
 
-dnl
-dnl To be able to make dist on a non-xenified host
-dnl
-AC_ARG_WITH(depends,
-	[  --with-depends          check for dependancies (on)])
-
 LIBVIRT_FEATURES=
 WITH_XEN=0
 
@@ -242,9 +236,6 @@ if test "$with_remote" = "yes" ; then
     LIBVIRT_FEATURES="$LIBVIRT_FEATURES -DWITH_REMOTE"
 fi
 
-if test "$with_depends" != "no"
-then
-
 if test "$with_xen" = "yes" ; then
     dnl search for the Xen store library
     AC_SEARCH_LIBS(xs_read, [xenstore],
@@ -297,17 +288,14 @@ LIBXML_LIBS=""
 LIBXML_FOUND="no"
 
 AC_ARG_WITH(libxml, [  --with-libxml=[PFX]       libxml2 location])
-if test "z$with_libxml" = "zno" ; then
+if test "$with_libxml" = "no" ; then
     AC_MSG_CHECKING(for libxml2 libraries >= $LIBXML_REQUIRED)
     AC_MSG_ERROR(libxml2 >= $LIBXML_REQUIRED is required for libvirt)
-elif test "z$with_libxml" = "z" -a "x$PKG_CONFIG" != "x" ; then
-    PKG_CHECK_EXISTS(libxml-2.0,[LIBXML_FOUND=yes])
-    if test "$LIBXML_FOUND" != "no" ; then
-        PKG_CHECK_MODULES(LIBXML, libxml-2.0 >= $LIBXML_REQUIRED)
-    fi
+elif test -z "$with_libxml" -a -z "$PKG_CONFIG" ; then
+    PKG_CHECK_MODULES(LIBXML, libxml-2.0 >= $LIBXML_REQUIRED, [LIBXML_FOUND=yes], [LIBXML_FOUND=no])
 fi
-if test "z$LIBXML_FOUND" = "zno" ; then
-    if test "z$with_libxml" != "z" ; then
+if test "$LIBXML_FOUND" = "no" ; then
+    if test -n "$with_libxml" ; then
 	LIBXML_CONFIG=$with_libxml/bin/$LIBXML_CONFIG
     fi
     AC_MSG_CHECKING(libxml2 $LIBXML_CONFIG >= $LIBXML_REQUIRED )
@@ -343,9 +331,11 @@ LDFLAGS="$old_ldflags"
 dnl GnuTLS library
 GNUTLS_CFLAGS=
 GNUTLS_LIBS=
-if test "x$PKG_CONFIG" != "x" ; then
-  PKG_CHECK_MODULES(GNUTLS, gnutls >= $GNUTLS_REQUIRED)
-else
+GNUTLS_FOUND=no
+if test -z "$PKG_CONFIG" ; then
+  PKG_CHECK_MODULES(GNUTLS, gnutls >= $GNUTLS_REQUIRED, [GNUTLS_FOUND=yes], [GNUTLS_FOUND=no])
+fi
+if test "$GNUTLS_FOUND" = "no"; then
   AC_CHECK_HEADER([gnutls/gnutls.h],
        [],
        AC_MSG_ERROR([You must install the GnuTLS development package in order to compile libvirt]))
@@ -379,12 +369,12 @@ dnl Cyrus SASL
 AC_ARG_WITH(sasl,
   [  --with-sasl         use cyrus SASL for authentication],
   [],
-  [with_sasl=yes])
+  [with_sasl=check])
 
 SASL_CFLAGS=
 SASL_LIBS=
 if test "$with_sasl" != "no"; then
-  if test "$with_sasl" != "yes"; then
+  if test "$with_sasl" != "yes" -a "$with_sasl" != "check"; then
     SASL_CFLAGS="-I$with_sasl"
     SASL_LIBS="-L$with_sasl"
   fi
@@ -392,18 +382,28 @@ if test "$with_sasl" != "no"; then
   old_libs="$LIBS"
   CFLAGS="$CFLAGS $SASL_CFLAGS"
   LIBS="$LIBS $SASL_LIBS"
-  AC_CHECK_HEADER([sasl/sasl.h],
-       [],
-       AC_MSG_ERROR([You must install the Cyrus SASL development package in order to compile libvirt]))
-  AC_CHECK_LIB(sasl2, sasl_client_init,
-       [],
-       [AC_MSG_ERROR([You must install the Cyrus SASL library in order to compile and run libvirt])])
+  AC_CHECK_HEADER([sasl/sasl.h],[],[
+       if test "$with_sasl" != "check" ; then
+           with_sasl=no
+       else
+           AC_MSG_ERROR([You must install the Cyrus SASL development package in order to compile libvirt])
+       fi])
+  if test "$with_sasl" != "no" ; then
+    AC_CHECK_LIB(sasl2, sasl_client_init,[],[
+         if test "$with_sasl" = "check" ; then
+             with_sasl=no
+         else
+             AC_MSG_ERROR([You must install the Cyrus SASL library in order to compile and run libvirt])
+         fi])
+  fi
   CFLAGS="$old_cflags"
   LIBS="$old_libs"
   SASL_LIBS="$SASL_LIBS -lsasl2"
-  AC_DEFINE_UNQUOTED(HAVE_SASL, 1, [whether Cyrus SASL is available for authentication])
+  if test "$with_sasl" = "yes" ; then
+    AC_DEFINE_UNQUOTED(HAVE_SASL, 1, [whether Cyrus SASL is available for authentication])
+  fi
 fi
-AM_CONDITIONAL(HAVE_SASL, [test "$with_sasl" != "no"])
+AM_CONDITIONAL(HAVE_SASL, [test "$with_sasl" = "yes"])
 AC_SUBST(SASL_CFLAGS)
 AC_SUBST(SASL_LIBS)
 
@@ -416,13 +416,17 @@ AC_ARG_WITH(polkit,
   [],
   [with_polkit=check])
 
-if test "$with_polkit" = "check"; then
-  PKG_CHECK_EXISTS(polkit-dbus >= $POLKIT_REQUIRED, [with_polkit=yes], [with_polkit=no])
-fi
-
-if test "$with_polkit" = "yes"; then
-  PKG_CHECK_MODULES(POLKIT, polkit-dbus >= $POLKIT_REQUIRED)
-  AC_DEFINE_UNQUOTED(HAVE_POLKIT, 1, [use PolicyKit for UNIX socket access checks])
+if test "$with_polkit" = "yes" -o "$with_polkit" = "check"; then
+  PKG_CHECK_MODULES(POLKIT, polkit-dbus >= $POLKIT_REQUIRED, [with_polkit=yes], [
+    if test "$with_polkit" = "check" ; then
+       with_polkit=no
+    else
+       AC_MSG_ERROR([You must install PolicyKit >= $POLKIT_REQUIRED to compile libvirt])
+    fi
+  ])
+  if test "$with_polkit" = "yes" ; then
+    AC_DEFINE_UNQUOTED(HAVE_POLKIT, 1, [use PolicyKit for UNIX socket access checks])
+  fi
 fi
 AM_CONDITIONAL(HAVE_POLKIT, [test "$with_polkit" = "yes"])
 AC_SUBST(POLKIT_CFLAGS)
@@ -434,15 +438,19 @@ AC_ARG_WITH(avahi,
   [],
   [with_avahi=check])
 
-if test "$with_avahi" = "check" -a "x$PKG_CONFIG" != "x" ; then
-  PKG_CHECK_EXISTS(avahi-client >= $AVAHI_REQUIRED, [with_avahi=yes], [with_avahi=no])
-fi
-
 AVAHI_CFLAGS=
 AVAHI_LIBS=
-if test "$with_avahi" = "yes"; then
-  PKG_CHECK_MODULES(AVAHI, avahi-client >= $AVAHI_REQUIRED)
-  AC_DEFINE_UNQUOTED(HAVE_AVAHI, 1, [whether Avahi is used to broadcast server presense])
+if test "$with_avahi" = "yes" -o "$with_avahi" = "check"; then
+  PKG_CHECK_MODULES(AVAHI, avahi-client >= $AVAHI_REQUIRED, [with_avahi=yes], [
+    if test "$with_avahi" = "check" ; then
+       with_avahi=no
+    else
+       AC_MSG_ERROR([You must install Avahi >= $AVAHI_REQUIRED to compile libvirt])
+    fi
+  ])
+  if test "$with_avahi" = "yes" ; then
+    AC_DEFINE_UNQUOTED(HAVE_AVAHI, 1, [whether Avahi is used to broadcast server presense])
+  fi
 fi
 AM_CONDITIONAL(HAVE_AVAHI, [test "$with_avahi" = "yes"])
 AC_SUBST(AVAHI_CFLAGS)
@@ -490,9 +498,6 @@ fi
 AC_SUBST(READLINE_CFLAGS)
 AC_SUBST(VIRSH_LIBS)
 
-# end of if with_depends
-fi
-
 AC_SUBST(WITH_XEN)
 AC_SUBST(LIBVIRT_FEATURES)
 
Index: acinclude.m4
===================================================================
RCS file: /data/cvs/libvirt/acinclude.m4,v
retrieving revision 1.7
diff -u -p -r1.7 acinclude.m4
--- acinclude.m4	7 Nov 2007 12:29:37 -0000	1.7
+++ acinclude.m4	22 Jan 2008 17:21:27 -0000
@@ -88,3 +88,29 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
     WARN_CFLAGS="$compiler_flags $complCFLAGS"
     AC_SUBST(WARN_CFLAGS)
 ])
+
+
+dnl
+dnl To support the old pkg-config from RHEL4 vintage, we need
+dnl to define the PKG_PROG_PKG_CONFIG macro if its not already
+dnl present
+m4_ifndef([PKG_PROG_PKG_CONFIG],
+  [AC_DEFUN([PKG_PROG_PKG_CONFIG],
+[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
+m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
+AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+        AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
+fi
+if test -n "$PKG_CONFIG"; then
+        _pkg_min_version=m4_default([$1], [0.9.0])
+        AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
+        if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+                AC_MSG_RESULT([yes])
+        else
+                AC_MSG_RESULT([no])
+                PKG_CONFIG=""
+        fi
+fi[]dnl
+])])
+
Index: src/gnutls_1_0_compat.h
===================================================================
RCS file: /data/cvs/libvirt/src/gnutls_1_0_compat.h,v
retrieving revision 1.1
diff -u -p -r1.1 gnutls_1_0_compat.h
--- src/gnutls_1_0_compat.h	7 Aug 2007 13:02:35 -0000	1.1
+++ src/gnutls_1_0_compat.h	22 Jan 2008 17:21:27 -0000
@@ -31,6 +31,7 @@
 #define gnutls_transport_ptr_t           gnutls_transport_ptr
 #define gnutls_datum_t                   gnutls_datum
 #define gnutls_certificate_credentials_t gnutls_certificate_credentials
+#define gnutls_cipher_algorithm_t        gnutls_cipher_algorithm
 #endif
 
 #endif /* LIBVIRT_GNUTLS_1_0_COMPAT_H__ */



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




More information about the libvir-list mailing list