Merge branch 'msvc' into maint
[platform/upstream/automake.git] / tests / instspc.test
1 #! /bin/sh
2 # Copyright (C) 2004, 2005, 2011 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 # Check that installation to directory with shell metacharacters succeed.
18 # Original report from James Amundson about file names with spaces.
19 # Other characters added by Paul Eggert.
20
21 # This is mostly the same input as nobase.test, but we do not use
22 # libtool libraries, because Libtool does not preserve space in
23 # file names (Issue observed with ltmain.sh (GNU libtool) 1.5a (1.1323
24 # 2003/11/10 21:06:47))
25
26
27 required='gcc'
28 . ./defs || Exit 1
29
30 set -e
31
32 # Set up files that won't change each time through the loop.
33
34 cat >> configure.in <<'EOF'
35 AC_PROG_CC
36 AM_PROG_AR
37 AC_PROG_RANLIB
38 AC_OUTPUT
39 EOF
40
41 mkdir sub
42
43 : > sub/base.h
44 : > sub/nobase.h
45 : > sub/base.dat
46 : > sub/nobase.dat
47 : > sub/base.sh
48 : > sub/nobase.sh
49
50 cat >source.c <<'EOF'
51 int
52 main (int argc, char **argv)
53 {
54   return 0;
55 }
56 EOF
57 cp source.c source2.c
58
59 cat > Makefile.am << 'EOF'
60 foodir = $(prefix)/foo
61 fooexecdir = $(prefix)/foo
62
63 foo_HEADERS = sub/base.h
64 nobase_foo_HEADERS = sub/nobase.h
65
66 dist_foo_DATA = sub/base.dat
67 nobase_dist_foo_DATA = sub/nobase.dat
68
69 dist_fooexec_SCRIPTS = sub/base.sh
70 nobase_dist_fooexec_SCRIPTS = sub/nobase.sh
71
72 fooexec_PROGRAMS = sub/base
73 nobase_fooexec_PROGRAMS = sub/nobase
74 sub_base_SOURCES = source.c
75 sub_nobase_SOURCES = source.c
76
77 fooexec_LIBRARIES = sub/libbase.a
78 nobase_fooexec_LIBRARIES = sub/libnobase.a
79 sub_libbase_a_SOURCES = source.c
80 sub_libnobase_a_SOURCES = source.c
81
82 test-install-sep: install
83         test   -f '$(DESTDIR)/$(file)-prefix/foo/sub/nobase.h'
84         test ! -f '$(DESTDIR)/$(file)-prefix/foo/nobase.h'
85         test   -f '$(DESTDIR)/$(file)-prefix/foo/base.h'
86         test   -f '$(DESTDIR)/$(file)-prefix/foo/sub/nobase.dat'
87         test ! -f '$(DESTDIR)/$(file)-prefix/foo/nobase.dat'
88         test   -f '$(DESTDIR)/$(file)-prefix/foo/base.dat'
89         test   -f '$(DESTDIR)/$(file)-prefix/foo/sub/nobase.sh'
90         test ! -f '$(DESTDIR)/$(file)-prefix/foo/nobase.sh'
91         test   -f '$(DESTDIR)/$(file)-prefix/foo/base.sh'
92         test   -f '$(DESTDIR)/$(file)-prefix/foo/sub/nobase$(EXEEXT)'
93         test ! -f '$(DESTDIR)/$(file)-prefix/foo/nobase$(EXEEXT)'
94         test   -f '$(DESTDIR)/$(file)-prefix/foo/base$(EXEEXT)'
95         test   -f '$(DESTDIR)/$(file)-prefix/foo/sub/libnobase.a'
96         test ! -f '$(DESTDIR)/$(file)-prefix/foo/libnobase.a'
97         test   -f '$(DESTDIR)/$(file)-prefix/foo/libbase.a'
98 EOF
99
100 $ACLOCAL
101 $AUTOCONF
102 $AUTOMAKE -a
103
104 # Some control characters that are white space:
105 # back space, carriage return, form feed, horizontal tab, line feed, space
106 bs='\b'
107 cr='\r'
108 ff='\f'
109 ht='    '
110 lf='
111 '
112 sp=' '
113
114 build_failures=
115 install_failures=
116
117 for file in \
118   '!' '"' '#' '$' '%' '&' \' '(' ')' '*' '+' ',' '-' ':' ';' \
119   '<' '=' '>' '?' '@' '[' '\' ']' '^' '`' '{' '|' '}' '~' \
120   "$bs" "$cr" "$ff" "$ht" "$lf" "$sp" \
121   '@<:@' '@:>@' '@S|@' '@%:@' '@&t@' \
122   "a${sp}b" "a${sp}${sp}b" "a${lf}b" ... a:
123 do
124   for test in build install; do
125     case $test in
126     build)
127       build=$file
128       dest=`pwd`/sub1;;
129     install)
130       build=sub1
131       dest=`pwd`/$file;;
132     esac
133
134     # Make sure this system supports this character in file names.
135     mkdir sub1 "./$file" || Exit 77
136
137     cd "$build"
138
139     # Some make implementations eliminate leading and trailing whitespace
140     # from macros passed on the command line, and some eliminate leading
141     # whitespace from macros set from environment variables, so prepend
142     # './' and use the latter here.
143     ../configure --prefix "/$file-prefix" &&
144     $MAKE &&
145     DESTDIR=$dest file=./$file $MAKE -e test-install-sep ||
146       eval "${test}_failures=\"\$${test}_failures$lf\$file\""
147
148     cd ..
149
150     rm -fr sub1 "./$file"
151   done
152 done
153
154 # The list of the above file names that cannot be used as a build directory
155 # on a POSIX host.  This list should be empty, but is not due to limitations
156 # in Autoconf, Automake, Make, M4, or the shell.
157 expected_build_failures='
158 "
159 #
160 $
161 &
162 '\''
163 \
164 `
165 '"$lf"'
166 @&t@
167 a'"${lf}"'b'
168
169 # Similarly, the list of file names that cannot be used as an install directory
170 # on a POSIX host.  This list should also be empty.
171 expected_install_failures='
172 "
173 #
174 $
175 '\''
176 `
177 '"$lf"'
178 a'"${lf}"'b'
179
180 fail=0
181 for test in build install; do
182   eval failures=\$${test}_failures
183   case $failures in
184   ?*)
185     cat >&2 <<EOF
186 $0: $test test failed for the following file names:$failures
187 EOF
188     eval test \"\$failures\" = \"\$expected_${test}_failures\" || fail=1
189   esac
190 done
191
192 Exit $fail