Fix calling Eshell scripts outside of Eshell
[emacs.git] / m4 / xattr.m4
blobd8c084868343d54a73a72a7b8dd01ea792bd7ac2
1 # xattr.m4
2 # serial 7
3 dnl Copyright (C) 2003-2024 Free Software Foundation, Inc.
4 dnl This file is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
8 # Check for Extended Attributes (Linux)
10 AC_DEFUN([gl_FUNC_XATTR],
12   AC_ARG_ENABLE([xattr],
13         AS_HELP_STRING([[--disable-xattr]],
14                        [do not support extended attributes]),
15         [use_xattr=$enableval], [use_xattr=yes])
17   LIB_XATTR=
18   AC_SUBST([LIB_XATTR])
20   if test "$use_xattr" = yes; then
21     AC_CACHE_CHECK([for xattr library with ATTR_ACTION_PERMISSIONS],
22       [gl_cv_xattr_lib],
23       [gl_cv_xattr_lib=no
24        AC_LANG_CONFTEST(
25          [AC_LANG_PROGRAM(
26             [[#include <attr/error_context.h>
27               #include <attr/libattr.h>
28               static int
29               is_attr_permissions (const char *name, struct error_context *ctx)
30               {
31                 return attr_copy_action (name, ctx) == ATTR_ACTION_PERMISSIONS;
32               }
33             ]],
34             [[return attr_copy_fd ("/", 0, "/", 0, is_attr_permissions, 0);
35             ]])])
36        AC_LINK_IFELSE([],
37          [gl_cv_xattr_lib='none required'],
38          [xattr_saved_LIBS=$LIBS
39           LIBS="-lattr $LIBS"
40           AC_LINK_IFELSE([], [gl_cv_xattr_lib=-lattr])
41           LIBS=$xattr_saved_LIBS])])
42     if test "$gl_cv_xattr_lib" = no; then
43       AC_MSG_WARN([libattr development library was not found or not usable.])
44       AC_MSG_WARN([AC_PACKAGE_NAME will be built without xattr support.])
45       use_xattr=no
46     elif test "$gl_cv_xattr_lib" != 'none required'; then
47       LIB_XATTR=$gl_cv_xattr_lib
48     fi
49   fi
50   if test "$use_xattr" = yes; then
51     AC_DEFINE([USE_XATTR], [1],
52       [Define to 1 to use the Linux extended attributes library.])
53   fi