tests: make 'lzip.test' executable
[automake.git] / tests / instmany.test
blob2de026d702611008f43488754ad46990207e1588
1 #! /bin/sh
2 # Copyright (C) 2008, 2009, 2010 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 <http://www.gnu.org/licenses/>.
17 # Installing many files should not exceed the command line length limit.
18 # Here, the main issue is that we may prepend `$(srcdir)/' to each file,
19 # which may cause much longer command lines. The list of files must
20 # anyway remain below the limit, otherwise `make' won't be able to even
21 # fork the command.
23 # Further, the install rule should honor failures of the install program.
25 # Python is done in the sister test.
26 # For texinfos, we expand names using $(srcdir) in the first place.
27 # Let's hope nobody uses many texinfos.
29 . ./defs || Exit 1
31 set -e
33 # In order to have a useful test on modern systems (which have a high
34 # limit, if any), use a fake install program that errors out for more
35 # than 2K characters in a command line. The POSIX limit is 4096, but
36 # that may include space taken up by the environment.
38 limit=2500
39 subdir=long_subdir_name_with_many_characters
40 nfiles=81
42 # Let's use `seq' if available, it's faster than the loop.
43 list=`(seq 1 $nfiles) 2>/dev/null || {
44 i=1
45 while test $i -le $nfiles; do
46 echo $i
47 i=\`expr $i + 1\`
48 done; }`
50 sed "s|@limit@|$limit|g" >myinstall.in <<'END'
51 #! /bin/sh
52 # Fake install script. This doesn't really install
53 # (the INSTALL path below would be wrong outside this directory).
54 limit=@limit@
55 INSTALL='@INSTALL@'
56 len=`expr "$INSTALL $*" : ".*" 2>/dev/null || echo $limit`
57 if test $len -ge $limit; then
58 echo "$0: safe command line limit of $limit characters exceeded" >&2
59 exit 1
61 exit 0
62 END
64 # Creative quoting in the next line to please maintainer-check.
65 sed "s|@limit@|$limit|g" >'rm' <<'END'
66 #! /bin/sh
67 limit=@limit@
68 PATH=$save_PATH
69 export PATH
70 RM='rm -f'
71 len=`expr "$RM $*" : ".*" 2>/dev/null || echo $limit`
72 if test $len -ge $limit; then
73 echo "$0: safe command line limit of $limit characters exceeded" >&2
74 exit 1
76 exec $RM "$@"
77 exit 1
78 END
80 chmod +x rm
82 cat >>configure.in <<END
83 AC_CONFIG_FILES([myinstall], [chmod +x ./myinstall])
84 AC_CONFIG_FILES([$subdir/Makefile])
85 AC_OUTPUT
86 END
88 cat >Makefile.am <<END
89 SUBDIRS = $subdir
90 END
92 mkdir $subdir
93 cd $subdir
95 cat >Makefile.am <<'END'
96 bin_SCRIPTS =
97 nobase_bin_SCRIPTS =
98 data_DATA =
99 nobase_data_DATA =
100 include_HEADERS =
101 nobase_include_HEADERS =
104 for n in $list; do
105 cat >>Makefile.am <<END
106 bin_SCRIPTS += script$n
107 nobase_bin_SCRIPTS += nscript$n
108 data_DATA += data$n
109 nobase_data_DATA += ndata$n
110 include_HEADERS += header$n.h
111 nobase_include_HEADERS += nheader$n.h
113 echo >script$n
114 echo >nscript$n
115 echo >data$n
116 echo >ndata$n
117 echo >header$n.h
118 echo >nheader$n.h
119 done
121 cd ..
122 $ACLOCAL
123 $AUTOCONF
124 $AUTOMAKE --add-missing
126 instdir=`pwd`/inst
127 mkdir build
128 cd build
129 ../configure --prefix="$instdir"
130 $MAKE
131 # Try whether native install (or install-sh) works.
132 $MAKE install
133 # Multiple uninstall should work, too.
134 $MAKE uninstall
135 $MAKE uninstall
136 test `find "$instdir" -type f -print | wc -l` = 0
138 # Try whether we don't exceed the low limit.
139 INSTALL='$(SHELL) $(top_builddir)/myinstall' $MAKE -e install
140 env save_PATH="$PATH" PATH="`pwd`/..$PATH_SEPARATOR$PATH" $MAKE uninstall
142 cd $subdir
143 srcdir=../../$subdir
145 # Ensure 'make install' fails when 'install' fails.
147 # We cheat here, for efficiency, knowing the internal rule names.
148 # For correctness, one should `$MAKE install' here always, or at
149 # least use install-exec or install-data.
151 for file in script3 script$nfiles
153 chmod a-r $srcdir/$file
154 test ! -r $srcdir/$file || Exit 77
155 $MAKE install-binSCRIPTS && Exit 1
156 chmod u+r $srcdir/$file
157 done
159 for file in nscript3 nscript$nfiles
161 chmod a-r $srcdir/$file
162 $MAKE install-nobase_binSCRIPTS && Exit 1
163 chmod u+r $srcdir/$file
164 done
166 for file in data3 data$nfiles
168 chmod a-r $srcdir/$file
169 $MAKE install-dataDATA && Exit 1
170 chmod u+r $srcdir/$file
171 done
173 for file in ndata3 ndata$nfiles
175 chmod a-r $srcdir/$file
176 $MAKE install-nobase_dataDATA && Exit 1
177 chmod u+r $srcdir/$file
178 done
180 for file in header3.h header$nfiles.h
182 chmod a-r $srcdir/$file
183 $MAKE install-includeHEADERS && Exit 1
184 chmod u+r $srcdir/$file
185 done
187 for file in nheader3.h nheader$nfiles.h
189 chmod a-r $srcdir/$file
190 $MAKE install-nobase_includeHEADERS && Exit 1
191 chmod u+r $srcdir/$file
192 done