Merge branch 'minor'
[automake.git] / t / tar-override.sh
blob116dd382cc7b86b29eb4e8c5132938dbf9c51a3b
1 #! /bin/sh
2 # Copyright (C) 2011-2017 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
17 # Check that the user can override the tar program used by "make dist"
18 # at runtime, by redefining the 'TAR' environment variable.
19 # NOTE: currently this works only when the tar format used is 'v7'
20 # (which is the default one).
22 . test-init.sh
24 cwd=$(pwd) || fatal_ "getting current working directory"
26 echo AC_OUTPUT >> configure.ac
28 cat > am--tar <<'END'
29 #!/bin/sh
30 echo $1 > am--tar-has-run
31 shift
32 exec tar "$@"
33 END
34 chmod a+x am--tar
36 cat > Makefile.am <<'END'
37 check-local: dist
38 ls -l ;: For debugging.
39 test -f am--tar-has-run
40 CLEANFILES = am--tar-has-run
41 END
43 $ACLOCAL
44 $AUTOCONF
45 $AUTOMAKE
46 ./configure
48 clean_temp () { rm -f *.tar.* *has-run*; }
50 $MAKE dist
51 test -f $distdir.tar.gz
52 ls | grep has-run && exit 1
54 clean_temp
56 TAR="$cwd/am--tar foo" $MAKE distcheck
57 test -f $distdir.tar.gz
58 test "$(cat am--tar-has-run)" = foo
60 clean_temp
62 unset TAR
63 # Creative use of eval to pacify maintainer checks.
64 eval \$'MAKE dist "TAR=./am--tar mu"'
65 test -f $distdir.tar.gz
66 test "$(cat am--tar-has-run)" = mu