news: describe recently-fixed bug in vala support
[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 AC_PROG_RANLIB
37 AC_OUTPUT
38 EOF
39
40 mkdir sub
41
42 : > sub/base.h
43 : > sub/nobase.h
44 : > sub/base.dat
45 : > sub/nobase.dat
46 : > sub/base.sh
47 : > sub/nobase.sh
48
49 cat >source.c <<'EOF'
50 int
51 main (int argc, char **argv)
52 {
53   return 0;
54 }
55 EOF
56 cp source.c source2.c
57
58 cat > Makefile.am << 'EOF'
59 foodir = $(prefix)/foo
60 fooexecdir = $(prefix)/foo
61
62 foo_HEADERS = sub/base.h
63 nobase_foo_HEADERS = sub/nobase.h
64
65 dist_foo_DATA = sub/base.dat
66 nobase_dist_foo_DATA = sub/nobase.dat
67
68 dist_fooexec_SCRIPTS = sub/base.sh
69 nobase_dist_fooexec_SCRIPTS = sub/nobase.sh
70
71 fooexec_PROGRAMS = sub/base
72 nobase_fooexec_PROGRAMS = sub/nobase
73 sub_base_SOURCES = source.c
74 sub_nobase_SOURCES = source.c
75
76 fooexec_LIBRARIES = sub/libbase.a
77 nobase_fooexec_LIBRARIES = sub/libnobase.a
78 sub_libbase_a_SOURCES = source.c
79 sub_libnobase_a_SOURCES = source.c
80
81 test-install-sep: install
82         test   -f '$(DESTDIR)/$(file)-prefix/foo/sub/nobase.h'
83         test ! -f '$(DESTDIR)/$(file)-prefix/foo/nobase.h'
84         test   -f '$(DESTDIR)/$(file)-prefix/foo/base.h'
85         test   -f '$(DESTDIR)/$(file)-prefix/foo/sub/nobase.dat'
86         test ! -f '$(DESTDIR)/$(file)-prefix/foo/nobase.dat'
87         test   -f '$(DESTDIR)/$(file)-prefix/foo/base.dat'
88         test   -f '$(DESTDIR)/$(file)-prefix/foo/sub/nobase.sh'
89         test ! -f '$(DESTDIR)/$(file)-prefix/foo/nobase.sh'
90         test   -f '$(DESTDIR)/$(file)-prefix/foo/base.sh'
91         test   -f '$(DESTDIR)/$(file)-prefix/foo/sub/nobase$(EXEEXT)'
92         test ! -f '$(DESTDIR)/$(file)-prefix/foo/nobase$(EXEEXT)'
93         test   -f '$(DESTDIR)/$(file)-prefix/foo/base$(EXEEXT)'
94         test   -f '$(DESTDIR)/$(file)-prefix/foo/sub/libnobase.a'
95         test ! -f '$(DESTDIR)/$(file)-prefix/foo/libnobase.a'
96         test   -f '$(DESTDIR)/$(file)-prefix/foo/libbase.a'
97 EOF
98
99 $ACLOCAL
100 $AUTOCONF
101 $AUTOMAKE -a
102
103 # Some control characters that are white space:
104 # back space, carriage return, form feed, horizontal tab, line feed, space
105 bs='\b'
106 cr='\r'
107 ff='\f'
108 ht='    '
109 lf='
110 '
111 sp=' '
112
113 build_failures=
114 install_failures=
115
116 for file in \
117   '!' '"' '#' '$' '%' '&' \' '(' ')' '*' '+' ',' '-' ':' ';' \
118   '<' '=' '>' '?' '@' '[' '\' ']' '^' '`' '{' '|' '}' '~' \
119   "$bs" "$cr" "$ff" "$ht" "$lf" "$sp" \
120   '@<:@' '@:>@' '@S|@' '@%:@' '@&t@' \
121   "a${sp}b" "a${sp}${sp}b" "a${lf}b" ... a:
122 do
123   for test in build install; do
124     case $test in
125     build)
126       build=$file
127       dest=`pwd`/sub1;;
128     install)
129       build=sub1
130       dest=`pwd`/$file;;
131     esac
132
133     # Make sure this system supports this character in file names.
134     mkdir sub1 "./$file" || Exit 77
135
136     cd "$build"
137
138     # Some make implementations eliminate leading and trailing whitespace
139     # from macros passed on the command line, and some eliminate leading
140     # whitespace from macros set from environment variables, so prepend
141     # './' and use the latter here.
142     ../configure --prefix "/$file-prefix" &&
143     $MAKE &&
144     DESTDIR=$dest file=./$file $MAKE -e test-install-sep ||
145       eval "${test}_failures=\"\$${test}_failures$lf\$file\""
146
147     cd ..
148
149     rm -fr sub1 "./$file"
150   done
151 done
152
153 # The list of the above file names that cannot be used as a build directory
154 # on a POSIX host.  This list should be empty, but is not due to limitations
155 # in Autoconf, Automake, Make, M4, or the shell.
156 expected_build_failures='
157 "
158 #
159 $
160 &
161 '\''
162 \
163 `
164 '"$lf"'
165 @&t@
166 a'"${lf}"'b'
167
168 # Similarly, the list of file names that cannot be used as an install directory
169 # on a POSIX host.  This list should also be empty.
170 expected_install_failures='
171 "
172 #
173 $
174 '\''
175 `
176 '"$lf"'
177 a'"${lf}"'b'
178
179 fail=0
180 for test in build install; do
181   eval failures=\$${test}_failures
182   case $failures in
183   ?*)
184     cat >&2 <<EOF
185 $0: $test test failed for the following file names:$failures
186 EOF
187     eval test \"\$failures\" = \"\$expected_${test}_failures\" || fail=1
188   esac
189 done
190
191 Exit $fail