mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-27 08:05:24 +00:00
cd699ed150
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>
43 lines
1.3 KiB
Plaintext
43 lines
1.3 KiB
Plaintext
dnl
|
|
dnl virt-result.m4: Helper macros for checking for libraries
|
|
dnl
|
|
dnl Copyright (C) 2012-2013 Red Hat, Inc.
|
|
dnl
|
|
dnl This library is free software; you can redistribute it and/or
|
|
dnl modify it under the terms of the GNU Lesser General Public
|
|
dnl License as published by the Free Software Foundation; either
|
|
dnl version 2.1 of the License, or (at your option) any later version.
|
|
dnl
|
|
dnl This library is distributed in the hope that it will be useful,
|
|
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
dnl Lesser General Public License for more details.
|
|
dnl
|
|
dnl You should have received a copy of the GNU Lesser General Public
|
|
dnl License along with this library. If not, see
|
|
dnl <http://www.gnu.org/licenses/>.
|
|
dnl
|
|
|
|
dnl
|
|
dnl To be used to print the results of a conditional test
|
|
dnl
|
|
dnl LIBVIRT_RESULT(CHECK_NAME, STATUS, DETAILS)
|
|
dnl
|
|
dnl CHECK_NAME: Name of the item being checked
|
|
dnl STATUS: 'yes' or 'no' result of check
|
|
dnl DETAILS: Details of result eg compiler flags
|
|
dnl
|
|
dnl eg
|
|
dnl
|
|
dnl LIBVIRT_RESULT([yajl], [yes], [-I/opt/yajl/include -lyajl])
|
|
dnl
|
|
AC_DEFUN([LIBVIRT_RESULT], [
|
|
if test "$2" = "no" || test -z "$3" ; then
|
|
STR=`printf "%10s: %-3s" "$1" "$2"`
|
|
else
|
|
STR=`printf "%10s: %-3s (%s)" "$1" "$2" "$3"`
|
|
fi
|
|
|
|
AC_MSG_NOTICE([$STR])
|
|
])
|