tail: avoid theoretically undefined behavior
[coreutils/ericb.git] / m4 / xattr.m4
blob2080eb5375bfa3b7740d4b448389cb6f810b1914
1 # xattr.m4 - check for Extended Attributes (Linux)
2 # serial 3
4 # Copyright (C) 2003, 2008-2011 Free Software Foundation, Inc.
5 # This file is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
9 # Originally written by Andreas Gruenbacher.
10 # http://www.suse.de/~agruen/coreutils/5.91/coreutils-xattr.diff
12 AC_DEFUN([gl_FUNC_XATTR],
14   AC_ARG_ENABLE([xattr],
15         AC_HELP_STRING([--disable-xattr],
16                        [do not support extended attributes]),
17         [use_xattr=$enableval], [use_xattr=yes])
19   LIB_XATTR=
20   AC_SUBST([LIB_XATTR])
22   if test "$use_xattr" = "yes"; then
23     AC_CHECK_HEADERS([attr/error_context.h attr/libattr.h])
24     use_xattr=no
25     if test $ac_cv_header_attr_libattr_h = yes \
26         && test $ac_cv_header_attr_error_context_h = yes; then
27       xattr_saved_LIBS=$LIBS
28       AC_SEARCH_LIBS([attr_copy_file], [attr],
29                      [test "$ac_cv_search_attr_copy_file" = "none required" ||
30                         LIB_XATTR=$ac_cv_search_attr_copy_file])
31       AC_CHECK_FUNCS([attr_copy_file])
32       LIBS=$xattr_saved_LIBS
33       if test $ac_cv_func_attr_copy_file = yes; then
34         use_xattr=yes
35       fi
36     fi
37     if test $use_xattr = no; then
38       AC_MSG_WARN([libattr development library was not found or not usable.])
39       AC_MSG_WARN([AC_PACKAGE_NAME will be built without xattr support.])
40     fi
41   fi
42   AC_DEFINE_UNQUOTED([USE_XATTR], [`test $use_xattr != yes; echo $?`],
43                      [Define if you want extended attribute support.])