am-ft: make the environment available earlier
[platform/upstream/automake.git] / t / rm-f-probe.sh
1 #! /bin/sh
2 # Copyright (C) 2013 Free Software Foundation, Inc.
3 #
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.
8 #
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.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 # Verify our probe that checks that "rm -f" doesn't complain if called
18 # without file operands works as expected.  See automake bug#10828.
19
20 . test-init.sh
21
22 echo AC_OUTPUT >> configure.ac
23 : > Makefile.am
24
25 $ACLOCAL
26 $AUTOCONF
27 $AUTOMAKE
28
29 mkdir bin
30 cat > bin/rm <<'END'
31 #!/bin/sh
32 set -e; set -u;
33 PATH=$original_PATH; export PATH
34 rm_opts=
35 while test $# -gt 0; do
36   case $1 in
37     -*) rm_opts="$rm_opts $1";;
38      *) break;;
39   esac
40   shift
41 done
42 if test $# -eq 0; then
43   echo "Oops, fake rm called without arguments" >&2
44   exit 1
45 else
46   exec rm $rm_opts "$@"
47 fi
48 END
49 chmod a+x bin/rm
50
51 original_PATH=$PATH
52 PATH=$(pwd)/bin$PATH_SEPARATOR$PATH
53 export PATH original_PATH
54
55 rm -f && exit 99 # Sanity check.
56
57 ./configure 2>stderr && { cat stderr >&2; exit 1; }
58 cat stderr >&2
59
60 grep "'rm' program.* unable to run without file operands" stderr
61 $FGREP "tell bug-automake@gnu.org about your system" stderr
62 $FGREP "install GNU coreutils" stderr
63 $EGREP "(^| |')ACCEPT_INFERIOR_RM_PROGRAM($| |')" stderr
64
65 ACCEPT_INFERIOR_RM_PROGRAM=yes; export ACCEPT_INFERIOR_RM_PROGRAM
66
67 ./configure
68 $MAKE
69 $MAKE distcheck
70
71 # For the sake of our exit trap.
72 PATH=$original_PATH; export PATH
73
74 :