1184
1184
# Substitute a variable $(am__untar) that extract such
1185
1185
# a tarball read from stdin.
1186
1186
# $(am__untar) < result.tar
1187
1188
AC_DEFUN([_AM_PROG_TAR],
1188
1189
[# Always define AMTAR for backward compatibility. Yes, it's still used
1189
1190
# in the wild :-( We should find a proper way to deprecate it ...
1190
1191
AC_SUBST([AMTAR], ['$${TAR-tar}'])
1193
# We'll loop over all known methods to create a tar archive until one works.
1194
_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
1191
1196
m4_if([$1], [v7],
1192
[am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'],
1193
[m4_case([$1], [ustar],, [pax],,
1194
[m4_fatal([Unknown tar format])])
1195
AC_MSG_CHECKING([how to create a $1 tar archive])
1196
# Loop over all known methods to create a tar archive until one works.
1197
_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
1198
_am_tools=${am_cv_prog_tar_$1-$_am_tools}
1199
# Do not fold the above two line into one, because Tru64 sh and
1200
# Solaris sh will not grok spaces in the rhs of '-'.
1201
for _am_tool in $_am_tools
1205
for _am_tar in tar gnutar gtar;
1207
AM_RUN_LOG([$_am_tar --version]) && break
1209
am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
1210
am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
1211
am__untar="$_am_tar -xf -"
1214
# Must skip GNU tar: if it does not support --format= it doesn't create
1215
# ustar tarball either.
1216
(tar --version) >/dev/null 2>&1 && continue
1217
am__tar='tar chf - "$$tardir"'
1218
am__tar_='tar chf - "$tardir"'
1219
am__untar='tar xf -'
1222
am__tar='pax -L -x $1 -w "$$tardir"'
1223
am__tar_='pax -L -x $1 -w "$tardir"'
1227
am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
1228
am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
1229
am__untar='cpio -i -H $1 -d'
1238
# If the value was cached, stop now. We just wanted to have am__tar
1239
# and am__untar set.
1240
test -n "${am_cv_prog_tar_$1}" && break
1242
# tar/untar a dummy directory, and stop if the command works
1245
echo GrepMe > conftest.dir/file
1246
AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
1248
if test -s conftest.tar; then
1249
AM_RUN_LOG([$am__untar <conftest.tar])
1250
grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
1255
AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
1256
AC_MSG_RESULT([$am_cv_prog_tar_$1])])
1197
[am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'],
1201
[# The POSIX 1988 'ustar' format is defined with fixed-size fields.
1202
# There is notably a 21 bits limit for the UID and the GID. In fact,
1203
# the 'pax' utility can hang on bigger UID/GID (see automake bug#8343
1205
am_max_uid=2097151 # 2^21 - 1
1206
am_max_gid=$am_max_uid
1207
# The $UID and $GID variables are not portable, so we need to resort
1208
# to the POSIX-mandated id(1) utility. Errors in the 'id' calls
1209
# below are definitely unexpected, so allow the users to see them
1210
# (that is, avoid stderr redirection).
1211
am_uid=`id -u || echo unknown`
1212
am_gid=`id -g || echo unknown`
1213
AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format])
1214
if test $am_uid -le $am_max_uid; then
1215
AC_MSG_RESULT([yes])
1220
AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format])
1221
if test $am_gid -le $am_max_gid; then
1222
AC_MSG_RESULT([yes])
1231
[m4_fatal([Unknown tar format])])
1233
AC_MSG_CHECKING([how to create a $1 tar archive])
1235
# Go ahead even if we have the value already cached. We do so because we
1236
# need to set the values for the 'am__tar' and 'am__untar' variables.
1237
_am_tools=${am_cv_prog_tar_$1-$_am_tools}
1239
for _am_tool in $_am_tools; do
1242
for _am_tar in tar gnutar gtar; do
1243
AM_RUN_LOG([$_am_tar --version]) && break
1245
am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
1246
am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
1247
am__untar="$_am_tar -xf -"
1250
# Must skip GNU tar: if it does not support --format= it doesn't create
1251
# ustar tarball either.
1252
(tar --version) >/dev/null 2>&1 && continue
1253
am__tar='tar chf - "$$tardir"'
1254
am__tar_='tar chf - "$tardir"'
1255
am__untar='tar xf -'
1258
am__tar='pax -L -x $1 -w "$$tardir"'
1259
am__tar_='pax -L -x $1 -w "$tardir"'
1263
am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
1264
am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
1265
am__untar='cpio -i -H $1 -d'
1274
# If the value was cached, stop now. We just wanted to have am__tar
1275
# and am__untar set.
1276
test -n "${am_cv_prog_tar_$1}" && break
1278
# tar/untar a dummy directory, and stop if the command works.
1281
echo GrepMe > conftest.dir/file
1282
AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
1284
if test -s conftest.tar; then
1285
AM_RUN_LOG([$am__untar <conftest.tar])
1286
AM_RUN_LOG([cat conftest.dir/file])
1287
grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
1292
AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
1293
AC_MSG_RESULT([$am_cv_prog_tar_$1])])
1257
1295
AC_SUBST([am__tar])
1258
1296
AC_SUBST([am__untar])
1259
1297
]) # _AM_PROG_TAR