Browse Source

[build] check getxattr before attr_get and -lattr

check getxattr before attr_get and -lattr;
do not link with -lattr if getxattr is available from glibc

(modern glibc systems do not require libattr-devel build dependency)
master
Glenn Strauss 5 months ago
parent
commit
18850c5c88
  1. 23
      configure.ac
  2. 10
      src/CMakeLists.txt
  3. 2
      src/config.h.cmake
  4. 9
      src/meson.build

23
configure.ac

@ -489,16 +489,6 @@ AC_MSG_RESULT([$WITH_ATTR])
if test "$WITH_ATTR" != no; then
have_xattr=no
# libattr (linux only?)
AC_CHECK_LIB([attr], [attr_get], [
AC_CHECK_HEADERS([attr/attributes.h], [
ATTR_LIB=-lattr
AC_DEFINE([HAVE_XATTR], [1], [libattr])
AC_DEFINE([HAVE_ATTR_ATTRIBUTES_H], [1])
have_xattr=yes
])
])
AC_SUBST([ATTR_LIB])
# Linux getxattr
AC_CHECK_FUNC([getxattr], [
@ -518,6 +508,19 @@ if test "$WITH_ATTR" != no; then
])
])
# libattr (linux only?)
if test "$have_xattr" = no; then
AC_CHECK_LIB([attr], [attr_get], [
AC_CHECK_HEADERS([attr/attributes.h], [
ATTR_LIB=-lattr
AC_DEFINE([HAVE_XATTR], [1], [libattr])
AC_DEFINE([HAVE_ATTR_ATTRIBUTES_H], [1])
have_xattr=yes
])
])
fi
AC_SUBST([ATTR_LIB])
if test "$have_xattr" = no; then
AC_MSG_ERROR([no backend found implementing extended attributes])
fi

10
src/CMakeLists.txt

@ -272,9 +272,13 @@ endmacro(XCONFIG _package _include_DIR _link_DIR _link_FLAGS _cflags)
if(WITH_XATTR)
check_include_files("sys/types.h;sys/xattr.h" HAVE_SYS_XATTR_H)
check_function_exists(getxattr HAVE_XATTR)
check_include_files("sys/types.h;attr/attributes.h" HAVE_ATTR_ATTRIBUTES_H)
if(HAVE_ATTR_ATTRIBUTES_H)
check_library_exists(attr attr_get "" HAVE_XATTR)
check_include_files("sys/types.h;sys/extattr.h" HAVE_SYS_EXTATTR_H)
check_function_exists(extattr_get_file HAVE_EXTATTR)
if(NOT HAVE_XATTR AND NOT HAVE_EXTATTR)
check_include_files("sys/types.h;attr/attributes.h" HAVE_ATTR_ATTRIBUTES_H)
if(HAVE_ATTR_ATTRIBUTES_H)
check_library_exists(attr attr_get "" HAVE_XATTR)
endif()
endif()
else()
unset(HAVE_ATTR_ATTRIBUTES_H)

2
src/config.h.cmake

@ -39,6 +39,8 @@
#cmakedefine HAVE_ATTR_ATTRIBUTES_H
#cmakedefine HAVE_SYS_XATTR_H
#cmakedefine HAVE_XATTR
#cmakedefine HAVE_SYS_EXTATTR_H
#cmakedefine HAVE_EXTATTR
/* mySQL */
#cmakedefine HAVE_MYSQL_H

9
src/meson.build

@ -656,6 +656,15 @@ if get_option('with_xattr')
)
conf_data.set('HAVE_SYS_XATTR_H', true)
conf_data.set('HAVE_XATTR', true)
elif compiler.has_function('extattr_get_file',
args: defs,
prefix: '''
#include <sys/types.h>
#include <sys/extattr.h>
'''
)
conf_data.set('HAVE_SYS_EXTATTR_H', true)
conf_data.set('HAVE_EXTATTR', true)
else
libattr = [ compiler.find_library('attr') ]
if not(compiler.has_function('attr_get',

Loading…
Cancel
Save