942
942
# Substitute a variable $(am__untar) that extract such
943
943
# a tarball read from stdin.
944
944
# $(am__untar) < result.tar
945
946
AC_DEFUN([_AM_PROG_TAR],
946
947
[# Always define AMTAR for backward compatibility. Yes, it's still used
947
948
# in the wild :-( We should find a proper way to deprecate it ...
948
949
AC_SUBST([AMTAR], ['$${TAR-tar}'])
951
# We'll loop over all known methods to create a tar archive until one works.
952
_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
949
954
m4_if([$1], [v7],
950
[am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'],
951
[m4_case([$1], [ustar],, [pax],,
952
[m4_fatal([Unknown tar format])])
953
AC_MSG_CHECKING([how to create a $1 tar archive])
954
# Loop over all known methods to create a tar archive until one works.
955
_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
956
_am_tools=${am_cv_prog_tar_$1-$_am_tools}
957
# Do not fold the above two line into one, because Tru64 sh and
958
# Solaris sh will not grok spaces in the rhs of '-'.
959
for _am_tool in $_am_tools
963
for _am_tar in tar gnutar gtar;
965
AM_RUN_LOG([$_am_tar --version]) && break
967
am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
968
am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
969
am__untar="$_am_tar -xf -"
972
# Must skip GNU tar: if it does not support --format= it doesn't create
973
# ustar tarball either.
974
(tar --version) >/dev/null 2>&1 && continue
975
am__tar='tar chf - "$$tardir"'
976
am__tar_='tar chf - "$tardir"'
980
am__tar='pax -L -x $1 -w "$$tardir"'
981
am__tar_='pax -L -x $1 -w "$tardir"'
985
am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
986
am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
987
am__untar='cpio -i -H $1 -d'
996
# If the value was cached, stop now. We just wanted to have am__tar
998
test -n "${am_cv_prog_tar_$1}" && break
1000
# tar/untar a dummy directory, and stop if the command works
1003
echo GrepMe > conftest.dir/file
1004
AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
1006
if test -s conftest.tar; then
1007
AM_RUN_LOG([$am__untar <conftest.tar])
1008
grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
1013
AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
1014
AC_MSG_RESULT([$am_cv_prog_tar_$1])])
955
[am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'],
959
[# The POSIX 1988 'ustar' format is defined with fixed-size fields.
960
# There is notably a 21 bits limit for the UID and the GID. In fact,
961
# the 'pax' utility can hang on bigger UID/GID (see automake bug#8343
963
am_max_uid=2097151 # 2^21 - 1
964
am_max_gid=$am_max_uid
965
# The $UID and $GID variables are not portable, so we need to resort
966
# to the POSIX-mandated id(1) utility. Errors in the 'id' calls
967
# below are definitely unexpected, so allow the users to see them
968
# (that is, avoid stderr redirection).
969
am_uid=`id -u || echo unknown`
970
am_gid=`id -g || echo unknown`
971
AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format])
972
if test $am_uid -le $am_max_uid; then
978
AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format])
979
if test $am_gid -le $am_max_gid; then
989
[m4_fatal([Unknown tar format])])
991
AC_MSG_CHECKING([how to create a $1 tar archive])
993
# Go ahead even if we have the value already cached. We do so because we
994
# need to set the values for the 'am__tar' and 'am__untar' variables.
995
_am_tools=${am_cv_prog_tar_$1-$_am_tools}
997
for _am_tool in $_am_tools; do
1000
for _am_tar in tar gnutar gtar; do
1001
AM_RUN_LOG([$_am_tar --version]) && break
1003
am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
1004
am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
1005
am__untar="$_am_tar -xf -"
1008
# Must skip GNU tar: if it does not support --format= it doesn't create
1009
# ustar tarball either.
1010
(tar --version) >/dev/null 2>&1 && continue
1011
am__tar='tar chf - "$$tardir"'
1012
am__tar_='tar chf - "$tardir"'
1013
am__untar='tar xf -'
1016
am__tar='pax -L -x $1 -w "$$tardir"'
1017
am__tar_='pax -L -x $1 -w "$tardir"'
1021
am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
1022
am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
1023
am__untar='cpio -i -H $1 -d'
1032
# If the value was cached, stop now. We just wanted to have am__tar
1033
# and am__untar set.
1034
test -n "${am_cv_prog_tar_$1}" && break
1036
# tar/untar a dummy directory, and stop if the command works.
1039
echo GrepMe > conftest.dir/file
1040
AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
1042
if test -s conftest.tar; then
1043
AM_RUN_LOG([$am__untar <conftest.tar])
1044
AM_RUN_LOG([cat conftest.dir/file])
1045
grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
1050
AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
1051
AC_MSG_RESULT([$am_cv_prog_tar_$1])])
1015
1053
AC_SUBST([am__tar])
1016
1054
AC_SUBST([am__untar])
1017
1055
]) # _AM_PROG_TAR