libvirt/m4/virt-result.m4

43 lines
1.3 KiB
Plaintext
Raw Normal View History

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>
2012-09-19 17:46:30 +00:00
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
Revert "virt-result.m4: Colourize summary printings" The colorization based on the string itself makes little to no sense as the semantic meaning of the color (red = bad, green = good) is not extracted from the semantics of the message: 1) If there is some additional string a 'yes' is marked yellow: configure: driver_modules: yes (CFLAGS='' LIBS='-ldl') 2) In some cases a 'no' is actually good: configure: hal: no 3) Few good/recommended configuration options are still yellow: configure: QEMU: qemu:qemu while using 'root:root' would still be yellow. 4) fields dumping config (e.g. the warning flags line) is a giant blob of colored text which makes little sense configure: Warning Flags: -fno-common -W -Wabsolute-value -Waddress -Waddress-of-packed-member -Waggressive-loop-optimizations -Wall -Wattribute-warning -Wattributes -Wbad-function-cast -Wbool-compare -Wbool-operation -Wbuiltin-declaration-mismatch -Wbuiltin-macro-redefined -Wcannot-profile -Wcast-align -Wcast-align=strict -Wcast-function-type -Wchar-subscripts -Wclobbered -Wcomment -Wcomments -Wcoverage-mismatch -Wcpp -Wdangling-else -Wdate-time -Wdeprecated-declarations -Wdesignated-init -Wdiscarded-array-qualifiers -Wdiscarded-qualifiers -Wdiv-by-zero -Wdouble-promotion -Wduplicated-cond -Wduplicate-decl-speci ... In addition if the idea is to switch to a more usable build system it does not make sense to clutter the current one with more code. This reverts commit 4b3ab5d2135a0dccd654491ef3a4f5b71575deae. ACKed-by: Michal Prívozník <mprivozn@redhat.com> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2019-09-18 06:18:53 +00:00
STR=`printf "%20s: %s" "$1" "$2"`
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>
2012-09-19 17:46:30 +00:00
else
Revert "virt-result.m4: Colourize summary printings" The colorization based on the string itself makes little to no sense as the semantic meaning of the color (red = bad, green = good) is not extracted from the semantics of the message: 1) If there is some additional string a 'yes' is marked yellow: configure: driver_modules: yes (CFLAGS='' LIBS='-ldl') 2) In some cases a 'no' is actually good: configure: hal: no 3) Few good/recommended configuration options are still yellow: configure: QEMU: qemu:qemu while using 'root:root' would still be yellow. 4) fields dumping config (e.g. the warning flags line) is a giant blob of colored text which makes little sense configure: Warning Flags: -fno-common -W -Wabsolute-value -Waddress -Waddress-of-packed-member -Waggressive-loop-optimizations -Wall -Wattribute-warning -Wattributes -Wbad-function-cast -Wbool-compare -Wbool-operation -Wbuiltin-declaration-mismatch -Wbuiltin-macro-redefined -Wcannot-profile -Wcast-align -Wcast-align=strict -Wcast-function-type -Wchar-subscripts -Wclobbered -Wcomment -Wcomments -Wcoverage-mismatch -Wcpp -Wdangling-else -Wdate-time -Wdeprecated-declarations -Wdesignated-init -Wdiscarded-array-qualifiers -Wdiscarded-qualifiers -Wdiv-by-zero -Wdouble-promotion -Wduplicated-cond -Wduplicate-decl-speci ... In addition if the idea is to switch to a more usable build system it does not make sense to clutter the current one with more code. This reverts commit 4b3ab5d2135a0dccd654491ef3a4f5b71575deae. ACKed-by: Michal Prívozník <mprivozn@redhat.com> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2019-09-18 06:18:53 +00:00
STR=`printf "%20s: %s (%s)" "$1" "$2" "$3"`
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>
2012-09-19 17:46:30 +00:00
fi
Revert "virt-result.m4: Colourize summary printings" The colorization based on the string itself makes little to no sense as the semantic meaning of the color (red = bad, green = good) is not extracted from the semantics of the message: 1) If there is some additional string a 'yes' is marked yellow: configure: driver_modules: yes (CFLAGS='' LIBS='-ldl') 2) In some cases a 'no' is actually good: configure: hal: no 3) Few good/recommended configuration options are still yellow: configure: QEMU: qemu:qemu while using 'root:root' would still be yellow. 4) fields dumping config (e.g. the warning flags line) is a giant blob of colored text which makes little sense configure: Warning Flags: -fno-common -W -Wabsolute-value -Waddress -Waddress-of-packed-member -Waggressive-loop-optimizations -Wall -Wattribute-warning -Wattributes -Wbad-function-cast -Wbool-compare -Wbool-operation -Wbuiltin-declaration-mismatch -Wbuiltin-macro-redefined -Wcannot-profile -Wcast-align -Wcast-align=strict -Wcast-function-type -Wchar-subscripts -Wclobbered -Wcomment -Wcomments -Wcoverage-mismatch -Wcpp -Wdangling-else -Wdate-time -Wdeprecated-declarations -Wdesignated-init -Wdiscarded-array-qualifiers -Wdiscarded-qualifiers -Wdiv-by-zero -Wdouble-promotion -Wduplicated-cond -Wduplicate-decl-speci ... In addition if the idea is to switch to a more usable build system it does not make sense to clutter the current one with more code. This reverts commit 4b3ab5d2135a0dccd654491ef3a4f5b71575deae. ACKed-by: Michal Prívozník <mprivozn@redhat.com> Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2019-09-18 06:18:53 +00:00
AC_MSG_NOTICE([$STR])
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>
2012-09-19 17:46:30 +00:00
])