$NetBSD: patch-configure,v 1.1 2014/08/21 20:44:16 wiz Exp $

* Make GNU tar 1.28 detect the presence of the GNU/Linux xattrs
  interface it expects.

  Upstream report:

    https://lists.gnu.org/archive/html/bug-tar/2014-08/msg00001.html

--- configure.orig	2014-07-27 20:33:47.000000000 +0000
+++ configure
@@ -663,8 +663,6 @@ RSH
 LIBOBJS
 TAR_COND_GRANTPT_FALSE
 TAR_COND_GRANTPT_TRUE
-TAR_LIB_ATTR_FALSE
-TAR_LIB_ATTR_TRUE
 TAR_COND_XATTR_H_FALSE
 TAR_COND_XATTR_H_TRUE
 GNULIB_TEST_WARN_CFLAGS
@@ -34994,41 +34975,6 @@ else
   TAR_COND_XATTR_H_FALSE=
 fi
 
-   if false; then
-  TAR_LIB_ATTR_TRUE=
-  TAR_LIB_ATTR_FALSE='#'
-else
-  TAR_LIB_ATTR_TRUE='#'
-  TAR_LIB_ATTR_FALSE=
-fi
-
-  if test "$ac_cv_header_sys_xattr_h" = yes; then
-    for ac_func in getxattr  fgetxattr  lgetxattr \
-                   setxattr  fsetxattr  lsetxattr \
-                   listxattr flistxattr llistxattr
-do :
-  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
- # only when functions are present
-
-$as_echo "#define HAVE_SYS_XATTR_H 1" >>confdefs.h
-
-        if test "$with_xattrs" != no; then
-
-$as_echo "#define HAVE_XATTRS /**/" >>confdefs.h
-
-        fi
-
-fi
-done
-
-  fi
-
-  # If <sys/xattr.h> is not found, then check for <attr/xattr.h>
   if test "$ac_cv_header_sys_xattr_h" != yes; then
     for ac_header in attr/xattr.h
 do :
@@ -35050,13 +34996,20 @@ else
   TAR_COND_XATTR_H_FALSE=
 fi
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgetxattr in -lattr" >&5
-$as_echo_n "checking for fgetxattr in -lattr... " >&6; }
-if ${ac_cv_lib_attr_fgetxattr+:} false; then :
+  fi
+
+          if test "$with_xattrs" != no; then
+    for i in getxattr  fgetxattr  lgetxattr \
+             setxattr  fsetxattr  lsetxattr \
+             listxattr flistxattr llistxattr
+    do
+      as_ac_Search=`$as_echo "ac_cv_search_$i" | $as_tr_sh`
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing $i" >&5
+$as_echo_n "checking for library containing $i... " >&6; }
+if eval \${$as_ac_Search+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lattr  $LIBS"
+  ac_func_search_save_LIBS=$LIBS
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
@@ -35066,68 +35019,57 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_
 #ifdef __cplusplus
 extern "C"
 #endif
-char fgetxattr ();
+char $i ();
 int
 main ()
 {
-return fgetxattr ();
+return $i ();
   ;
   return 0;
 }
 _ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_attr_fgetxattr=yes
-else
-  ac_cv_lib_attr_fgetxattr=no
+for ac_lib in '' attr; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  eval "$as_ac_Search=\$ac_res"
 fi
 rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_attr_fgetxattr" >&5
-$as_echo "$ac_cv_lib_attr_fgetxattr" >&6; }
-if test "x$ac_cv_lib_attr_fgetxattr" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_LIBATTR 1
-_ACEOF
-
-  LIBS="-lattr $LIBS"
-
+    conftest$ac_exeext
+  if eval \${$as_ac_Search+:} false; then :
+  break
 fi
+done
+if eval \${$as_ac_Search+:} false; then :
 
-     if test "$ac_cv_lib_attr_fgetxattr" = yes; then
-  TAR_LIB_ATTR_TRUE=
-  TAR_LIB_ATTR_FALSE='#'
 else
-  TAR_LIB_ATTR_TRUE='#'
-  TAR_LIB_ATTR_FALSE=
+  eval "$as_ac_Search=no"
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
 fi
+eval ac_res=\$$as_ac_Search
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+eval ac_res=\$$as_ac_Search
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
 
-    if test "$ac_cv_header_attr_xattr_h" = yes; then
-      for ac_func in getxattr  fgetxattr  lgetxattr \
-                     setxattr  fsetxattr  lsetxattr \
-                     listxattr flistxattr llistxattr
-do :
-  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
-ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
-if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
-_ACEOF
- # only when functions are present
+fi
 
-$as_echo "#define HAVE_ATTR_XATTR_H 1" >>confdefs.h
+      eval found=\$ac_cv_search_$i
+      test "$found" = "no" && break
+    done
 
-          if test "$with_xattrs" != no; then
+    if test "$found" != no; then
 
 $as_echo "#define HAVE_XATTRS /**/" >>confdefs.h
 
           fi
-
-fi
-done
-
-    fi
   fi
 
 
@@ -38187,18 +37836,10 @@ if test -z "${TAR_COND_XATTR_H_TRUE}" &&
   as_fn_error $? "conditional \"TAR_COND_XATTR_H\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
-if test -z "${TAR_LIB_ATTR_TRUE}" && test -z "${TAR_LIB_ATTR_FALSE}"; then
-  as_fn_error $? "conditional \"TAR_LIB_ATTR\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
 if test -z "${TAR_COND_XATTR_H_TRUE}" && test -z "${TAR_COND_XATTR_H_FALSE}"; then
   as_fn_error $? "conditional \"TAR_COND_XATTR_H\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
-if test -z "${TAR_LIB_ATTR_TRUE}" && test -z "${TAR_LIB_ATTR_FALSE}"; then
-  as_fn_error $? "conditional \"TAR_LIB_ATTR\" was never defined.
-Usually this means the macro was only invoked conditionally." "$LINENO" 5
-fi
 if test -z "${TAR_COND_GRANTPT_TRUE}" && test -z "${TAR_COND_GRANTPT_FALSE}"; then
   as_fn_error $? "conditional \"TAR_COND_GRANTPT\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
