[libvirt] [PATCH 5/6] m4: readline: Use pkg-config

Andrea Bolognani abologna at redhat.com
Tue Apr 9 13:10:22 UTC 2019


With the 7.0 release, readline has finally started shipping
pkg-config support in the form of a readline.pc file.

Unfortunately, most downstreams have yet to catch up with this
change: among Linux distributions in particular, Fedora Rawhide
seems to be the only one installing it at the moment.

Non-Linux operating systems have been faring much better in
this regard: both FreeBSD (through ports) and macOS (through
homebrew) include pkg-config support in their readline package.

This is great news for us, since those are the platforms where
pkg-config is more useful on account of them installing headers
and libraries outside of the respective default search paths.

Our implementation checks whether readline is registered as a
pkg-config package, and if so obtains CFLAGS and LIBS using the
tool; if not, we just keep using the existing logic.

Signed-off-by: Andrea Bolognani <abologna at redhat.com>
---
 m4/virt-readline.m4 | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/m4/virt-readline.m4 b/m4/virt-readline.m4
index a2788cb4aa..6fde47d2c8 100644
--- a/m4/virt-readline.m4
+++ b/m4/virt-readline.m4
@@ -23,8 +23,17 @@ AC_DEFUN([LIBVIRT_ARG_READLINE],[
 
 AC_DEFUN([LIBVIRT_CHECK_READLINE],[
 
-  # The normal library check...
-  LIBVIRT_CHECK_LIB([READLINE], [readline], [readline], [readline/readline.h])
+  # We have to check for readline.pc's presence beforehand because for
+  # the longest time the library didn't ship a .pc file at all
+  PKG_CHECK_EXISTS([readline], [use_pkgconfig=1], [use_pkgconfig=0])
+
+  if test $use_pkgconfig = 1; then
+    # readline 7.0 is the first version which includes pkg-config support
+    LIBVIRT_CHECK_PKG([READLINE], [readline], [7.0])
+  else
+    # The normal library check...
+    LIBVIRT_CHECK_LIB([READLINE], [readline], [readline], [readline/readline.h])
+  fi
 
   # We need this to avoid compilation issues with modern compilers.
   # See 9ea3424a178 for a more detailed explanation
-- 
2.20.1




More information about the libvir-list mailing list