]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commit
Add some autoconf helper macros for checking for libraries
authorDaniel P. Berrange <berrange@redhat.com>
Wed, 19 Sep 2012 17:46:30 +0000 (18:46 +0100)
committerDaniel P. Berrange <berrange@redhat.com>
Fri, 11 Jan 2013 11:03:22 +0000 (11:03 +0000)
commitcd699ed150e2370cf3c454510221a086f08b4e69
tree7edfc82479a4648ff23f77e1c23697cbf9415af8
parent8a883b0c1e682a5cbe25d78b2ce4b7a976ca22d9
Add some autoconf helper macros for checking for libraries

Most checks for libraries take the same format

  * --with-libFOO=yes|no|check|/some/path  argument
  * check for a function NNN in libFOO.so
  * check for a header file DDD/HHH.h
  * Define a WITH_FOO config.h symbol
  * Define a WITH_FOO make conditional
  * Substitute FOO_CFLAGS and FOO_LIBS make variables
  * Print CFLAGS & LIBS summary at the end

Doing all this correctly is rather difficult, typically
done by copy+paste of a previous usage. Further small
improvements people make are not applied to all previous
usages.

Improve this by creating some helper macros to apply
good practice. First, to perform the actual checks:

  LIBVIRT_CHECK_LIB([SELINUX], [selinux],
     [getfilecon], [selinux/selinux.h])

This checks for 'getfilecon' in -lselinux, and the
existence of 'selinux/selinux.h' header file. If successful
it sets SELINUX_CFLAGS and SELINUX_LIBS. The WITH_SELINUX
config.h macro and WITH_SELINUX make conditional are also
defined.

In some cases we need to check two variants of the same
library

  LIBVIRT_CHECK_LIB_ALT([SASL], [sasl2],
                        [sasl_client_init], [sasl/sasl.h],
                        [SASL1], [sasl],
                        [sasl_client_init], [sasl/sasl.h])

This checks for sasl_client_init in libsasl2, and if that
is not found, checks sasl_client_init in libsasl. If the
first check succeeds WITH_SASL is set, while if the second
check succeeds *both* WITH_SASL and WITH_SASL1 are set.

If the library supports pkg-config, then another variant
is available

  LIBVIRT_CHECK_PKG([AVAHI], [avahi-client], [0.6.0])

This checks for avahi-client >= 0.6.0 via pkg-config
and sets WITH_AVAHI if found.

Finally to print a summary of CFLAGS & LIBs found (if any):

  LIBVIRT_RESULT_LIB([SELINUX])

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
cfg.mk
m4/virt-lib.m4 [new file with mode: 0644]
m4/virt-result.m4 [new file with mode: 0644]