summaryrefslogtreecommitdiff
path: root/m4/tar.m4
diff options
context:
space:
mode:
authorAlexandre Duret-Lutz <adl@gnu.org>2004-04-19 23:20:08 +0000
committerAlexandre Duret-Lutz <adl@gnu.org>2004-04-19 23:20:08 +0000
commitae040111e06b3cd11c38ed34b987620d9ca22af2 (patch)
tree66c1ba8e97028caaa330028fc070d78cb9bafe7c /m4/tar.m4
parent436193dbe8bd9db51152d8ffafb3161f974d80cf (diff)
downloadautomake-ae040111e06b3cd11c38ed34b987620d9ca22af2.tar.gz
For PR automake/414:
Introduce options tar-v7, tar-ustar, and tar-pax to select tar format. * doc/automake.texi (Options): Document them. * lib/Automake/Options.pm (_process_option_list): Process these new options. * lib/am/distdir.am (dist-gzip, dist-bzip2, dist-tarZ, dist, distcheck): Adjust to use am__tar and am__untar. * m4/tar.m4: New file. * m4/Makefile.am (dist_m4data_DATA): Add tar.m4. * m4/init.m4 (AM_INIT_AUTOMAKE): Support the new options and call _AM_PROG_TAR. * tests/tar.test, tests/tar2.test, tests/tar3.test: New files. * tests/Makefile.am (TESTS): Add them.
Diffstat (limited to 'm4/tar.m4')
-rw-r--r--m4/tar.m4103
1 files changed, 103 insertions, 0 deletions
diff --git a/m4/tar.m4 b/m4/tar.m4
new file mode 100644
index 000000000..27020cfea
--- /dev/null
+++ b/m4/tar.m4
@@ -0,0 +1,103 @@
+# Check how to create a tarball. -*- Autoconf -*-
+
+# Copyright (C) 2004 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# serial 1
+
+
+# _AM_PROG_TAR(FORMAT)
+# --------------------
+# Check how to create a tarball in format FORMAT.
+# FORMAT should be one of `v7', `ustar', or `pax'.
+#
+# Substitute a variable $(am__tar) that is a command
+# writing to stdout a FORMAT-tarball containing the directory
+# $tardir.
+# tardir=directory && $(am__tar) > result.tar
+#
+# Substitute a variable $(am__untar) that extract such
+# a tarball read from stdin.
+# $(am__untar) < result.tar
+AC_DEFUN([_AM_PROG_TAR],
+[# Always define AMTAR for backward compatibility.
+AM_MISSING_PROG([AMTAR], [tar])
+m4_if([$1], [v7],
+ [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'],
+ [m4_case([$1], [ustar],, [pax],,
+ [m4_fatal([Unknown tar format])])
+AC_MSG_CHECKING([how to create a $1 tar archive])
+# Loop over all known methods to create a tar archive until one works.
+for _am_tool in ${am_cv_prog_tar_$1-gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none}
+do
+ case $_am_tool in
+ gnutar)
+ for _am_tar in tar gnutar gtar;
+ do
+ AM_RUN_LOG([$_am_tar --version]) && break
+ done
+ am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
+ am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
+ am__untar="$_am_tar -xf -"
+ ;;
+ plaintar)
+ # Must skip GNU tar: if it does not support --format= it doesn't create
+ # ustar tarball either.
+ (tar --version) >/dev/null 2>&1 && continue
+ am__tar='tar chf - "$$tardir"'
+ am__tar_='tar chf - "$tardir"'
+ am__untar='tar xf -'
+ ;;
+ pax)
+ am__tar='pax -L -x $1 -w "$$tardir"'
+ am__tar_='pax -L -x $1 -w "$tardir"'
+ am__untar='pax -r'
+ ;;
+ cpio)
+ am__tar='find "$$tardir" -print | cpio -H $1 -L -o'
+ am__tar_='find "$tardir" -print | cpio -H $1 -L -o'
+ am__untar='cpio -H $1 -i'
+ ;;
+ none)
+ am__tar=false
+ am__tar_=false
+ am__untar=false
+ ;;
+ esac
+
+ # If the value was cached, stop now. We just wanted to have am__tar
+ # and am__untar set.
+ test -n "${am_cv_prog_tar_$1}" && break
+
+ # tar/untar a dummy directory, and stop if the command works
+ rm -rf conftest.dir
+ mkdir conftest.dir
+ echo GrepMe > conftest.dir/file
+ AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
+ rm -rf conftest.dir
+ if test -s conftest.tar; then
+ AM_RUN_LOG([$am__untar <conftest.tar])
+ grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
+ fi
+done
+rm -rf conftest.dir
+
+AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
+AC_MSG_RESULT([$am_cv_prog_tar_$1])])
+AC_SUBST([am__tar])
+AC_SUBST([am__untar])
+]) # _AM_PROG_TAR