maint: version bump after beta release 1.13.1b
[platform/upstream/automake.git] / m4 / tar.m4
1 # Check how to create a tarball.                            -*- Autoconf -*-
2
3 # Copyright (C) 2004-2013 Free Software Foundation, Inc.
4 #
5 # This file is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # _AM_PROG_TAR(FORMAT)
10 # --------------------
11 # Check how to create a tarball in format FORMAT.
12 # FORMAT should be one of 'v7', 'ustar', or 'pax'.
13 #
14 # Substitute a variable $(am__tar) that is a command
15 # writing to stdout a FORMAT-tarball containing the directory
16 # $tardir.
17 #     tardir=directory && $(am__tar) > result.tar
18 #
19 # Substitute a variable $(am__untar) that extract such
20 # a tarball read from stdin.
21 #     $(am__untar) < result.tar
22 AC_DEFUN([_AM_PROG_TAR],
23 [# Always define AMTAR for backward compatibility.  Yes, it's still used
24 # in the wild :-(  We should find a proper way to deprecate it ...
25 AC_SUBST([AMTAR], ['$${TAR-tar}'])
26 m4_if([$1], [v7],
27      [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'],
28      [m4_case([$1], [ustar],, [pax],,
29               [m4_fatal([Unknown tar format])])
30 AC_MSG_CHECKING([how to create a $1 tar archive])
31 # Loop over all known methods to create a tar archive until one works.
32 _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
33 _am_tools=${am_cv_prog_tar_$1-$_am_tools}
34 # Do not fold the above two line into one, because Tru64 sh and
35 # Solaris sh will not grok spaces in the rhs of '-'.
36 for _am_tool in $_am_tools
37 do
38   case $_am_tool in
39   gnutar)
40     for _am_tar in tar gnutar gtar;
41     do
42       AM_RUN_LOG([$_am_tar --version]) && break
43     done
44     am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
45     am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
46     am__untar="$_am_tar -xf -"
47     ;;
48   plaintar)
49     # Must skip GNU tar: if it does not support --format= it doesn't create
50     # ustar tarball either.
51     (tar --version) >/dev/null 2>&1 && continue
52     am__tar='tar chf - "$$tardir"'
53     am__tar_='tar chf - "$tardir"'
54     am__untar='tar xf -'
55     ;;
56   pax)
57     am__tar='pax -L -x $1 -w "$$tardir"'
58     am__tar_='pax -L -x $1 -w "$tardir"'
59     am__untar='pax -r'
60     ;;
61   cpio)
62     am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
63     am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
64     am__untar='cpio -i -H $1 -d'
65     ;;
66   none)
67     am__tar=false
68     am__tar_=false
69     am__untar=false
70     ;;
71   esac
72
73   # If the value was cached, stop now.  We just wanted to have am__tar
74   # and am__untar set.
75   test -n "${am_cv_prog_tar_$1}" && break
76
77   # tar/untar a dummy directory, and stop if the command works
78   rm -rf conftest.dir
79   mkdir conftest.dir
80   echo GrepMe > conftest.dir/file
81   AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
82   rm -rf conftest.dir
83   if test -s conftest.tar; then
84     AM_RUN_LOG([$am__untar <conftest.tar])
85     grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
86   fi
87 done
88 rm -rf conftest.dir
89
90 AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
91 AC_MSG_RESULT([$am_cv_prog_tar_$1])])
92 AC_SUBST([am__tar])
93 AC_SUBST([am__untar])
94 ]) # _AM_PROG_TAR