1dnl Check for a tar program that speaks ustar format
2dnl Copyright (C) 2005, 2006 Free Software Foundation, Inc.
3dnl
4dnl This file is free software, distributed under the terms of the GNU
5dnl General Public License.  As a special exception to the GNU General
6dnl Public License, this file may be distributed as part of a program
7dnl that contains a configuration script generated by Autoconf, under
8dnl the same distribution terms as the rest of that program.
9
10AC_DEFUN([GNUPG_CHECK_USTAR],
11[
12  AC_ARG_WITH(tar,
13     AC_HELP_STRING([--with-tar=PATH],[look for a tar program in PATH]),
14     [_do_tar=$withval])
15
16  if test x$_do_tar != xno ; then
17
18     if test x$_do_tar = x ; then
19        AC_PATH_PROG(TAR,"tar")
20        _mytar=$ac_cv_path_TAR
21     fi
22
23     # Check if our tar is ustar format.  If so, it's good.  TODO: Add some
24     # code to check various options, etc, to try and create ustar
25     # format.
26
27     if test x$_mytar != x ; then
28        AC_MSG_CHECKING([whether $_mytar speaks USTAR])
29        echo hithere > conftest.txt
30        $_mytar -cf - conftest.txt | (dd skip=257 bs=1 count=5 2>/dev/null || cat) | grep ustar > /dev/null
31        _tar_bad=$?
32        rm conftest.txt
33
34	if test x$_tar_bad = x0 ; then
35	   AC_MSG_RESULT([yes])
36	else
37	   AC_MSG_RESULT([no])
38	fi
39     fi
40  fi
41
42  AM_CONDITIONAL(HAVE_USTAR, test x$_tar_bad = x0)
43])dnl
44