1 dnl @synopsis AX_PAX_TAR
3 dnl Most people will not know about the "tar"-wars a long while back.
4 dnl In the end the proponents of cpio lost just as all the oldish
5 dnl tar formats were dumped in favor of a new format that based on
6 dnl the successful "ustar" format. The extensions did mostly cover
7 dnl a portable definition of filenames and such stuff.
9 dnl The most interesting thing however is that the opengroup (the.
10 dnl UNIX standardization body) did not document the tool for the
11 dnl portable tar format under the name of "tar" but instead it did
12 dnl use the name "pax" which stands for "portable archiver". Even
13 dnl more so, the "pax" utitility is required to understand the old
14 dnl tar and cpio formats but it will default to a "tar"-like variant.
15 dnl The "pax" tool has been in the Unix standard ever since UNIX92.
17 dnl Interestingly gnu-tar will use the pax features as soon as they
18 dnl are required - but you can not be sure if gnu-tar is available,
19 dnl and it is quite likely that the system tar will default to the
20 dnl old format of the system in whatever it was. On any currrent
21 dnl Unix system however one should be able to find "pax", so one
22 dnl should prefer that one as the most portable tool.
24 dnl The downside is however that the commandline options of "pax"
25 dnl are different from "tar"/"gtar". That's why we define two
26 dnl subst'ed names here - PAX_TAR_CREATE and PAX_TAR_EXTRACT, For
27 dnl extra portability the first argument should be "*.tar" file
28 dnl name but you should be aware that in most cases the "pax" tool
29 dnl is invoked. Nota bene: do not use "*.pax" as the file name
30 dnl extension because some file managers interpret it as a TeX file.
33 dnl @author Guido U. Draheim <guidod@gmx.de>
34 dnl @version 2009-05-22
35 dnl @license GPLWithACException
37 AC_DEFUN([_AX_PAX_TAR_TOOL],[
38 if test -z "$ac_cv_pax_tar_tool"; then
39 AC_PATH_PROG([PAX],[pax], :)
40 if test "$ac_cv_path_PAX" != ":"; then
41 ac_cv_pax_tar_tool="pax"
43 AC_PATH_PROG([GNUTAR],[gnutar], :)
44 if test "$ac_cv_path_GNUTAR" != ":"; then
45 ac_cv_pax_tar_tool="gnutar"
47 AC_PATH_PROG([GTAR],[gtar], :)
48 if test "$ac_cv_path_GTAR" != ":"; then
49 ac_cv_pax_tar_tool="gtar"
51 AC_PATH_PROG([TAR],[tar], :)
52 if test "$ac_cv_path_TAR" != ":"; then
53 ac_cv_pax_tar_tool="tar"
56 AC_MSG_CHECKING([for portable tar tool])
57 AC_MSG_RESULT([$ac_cv_pax_tar_tool])
61 dnl TODO: on MacOsX the "--help" documentation of the tool differs
62 dnl from the capabilities of the installed pax tool. So test reality.
63 AC_DEFUN([_AX_PAX_SINGLE_ARCHIVE],[
64 if test "$ac_cv_pax_tar_tool$ax_pax_single_archive" = "pax"; then
65 AC_MSG_CHECKING([for pax single archive option])
66 echo foo > conftest.txt ; rm -f conftest.tar
67 AC_RUN_LOG(["$ac_cv_path_PAX" -w -O -f conftest.tar conftest.txt])
68 if test -s conftest.tar; then
69 ax_pax_single_archive="-O" ; ac_hint="(probably a BSD pax)"
71 ax_pax_single_archive=" " ; ac_hint="(the -O option did not work)"
73 AC_MSG_RESULT([$ax_pax_single_archive $ac_hint])
77 AC_DEFUN([_AX_PAX_TAR_CREATE],[
79 _AX_PAX_SINGLE_ARCHIVE
80 AC_MSG_CHECKING([for command to create portable tar archives])
81 if test "$ac_cv_pax_tar_tool" = "gnutar"; then
82 ax_pax_tar_create="'$ac_cv_path_GNUTAR' cf"
83 elif test "$ac_cv_pax_tar_tool" = "gtar"; then
84 ax_pax_tar_create="'$ac_cv_path_GTAR' cf"
85 elif test "$ac_cv_pax_tar_tool" = "pax"; then
86 ax_pax_tar_create="'$ac_cv_path_PAX' -w $ax_pax_single_archive -f"
87 elif test "$ac_cv_pax_tar_tool" = "tar"; then
88 ax_pax_tar_create="'$ac_cv_path_TAR' cf"
90 ax_pax_tar_create=": 'unknown pax tar tool $ac_cv_pax_tar_tool'"
92 AC_MSG_RESULT([$ax_pax_tar_create])
95 AC_DEFUN([_AX_PAX_TAR_EXTRACT],[
97 _AX_PAX_SINGLE_ARCHIVE
98 AC_MSG_CHECKING([for command to extract portable tar archives])
99 if test "$ac_cv_pax_tar_tool" = "gnutar"; then
100 ax_pax_tar_extract="'$ac_cv_path_GNUTAR' xf"
101 elif test "$ac_cv_pax_tar_tool" = "gtar"; then
102 ax_pax_tar_extract="'$ac_cv_path_GTAR' xf"
103 elif test "$ac_cv_pax_tar_tool" = "pax"; then
104 ax_pax_tar_extract="'$ac_cv_path_PAX' -r $ax_pax_single_archive -f"
105 elif test "$ac_cv_pax_tar_tool" = "tar"; then
106 ax_pax_tar_extract="'$ac_cv_path_TAR' xf"
108 ax_pax_tar_extract=": 'unknown pax tar tool $ac_cv_pax_tar_tool'"
110 AC_MSG_RESULT([$ax_pax_tar_extract])
113 AC_DEFUN([AX_PAX_TAR_CREATE],[dnl
116 $1="$ax_pax_tar_create"
119 PAX_TAR_CREATE="$ax_pax_tar_create"
120 AC_SUBST([PAX_TAR_CREATE])
124 AC_DEFUN([AX_PAX_TAR_EXTRACT],[dnl
127 $1="$ax_pax_tar_extract"
130 PAX_TAR_EXTRACT="$ax_pax_tar_extract"
131 AC_SUBST([PAX_TAR_EXTRACT])