2 # Copyright (C) 2008-2013 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)
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
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.
31 # In order to have a useful test on modern systems (which have a high
32 # limit, if any), use a fake install program that errors out for more
33 # than 2K characters in a command line. The POSIX limit is 4096, but
34 # that may include space taken up by the environment.
37 subdir=long_subdir_name_with_many_characters
39 list=$(seq_ 1 $nfiles)
41 oPATH=$PATH; export oPATH
42 nPATH=$(pwd)/x-bin$PATH_SEPARATOR$PATH; export nPATH
46 sed "s|@limit@|$limit|g" >x-bin/my-install <<'END'
48 # Fake install script. This doesn't really install
49 # (the INSTALL path below would be wrong outside this directory).
51 PATH=$oPATH; export PATH
52 if test -z "$orig_INSTALL"; then
53 echo "$0: \$orig_INSTALL variable not set" >&2
56 len=`expr "$orig_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
61 exec $orig_INSTALL "$@"
65 # Creative quoting in the next line to please maintainer-check.
66 sed "s|@limit@|$limit|g" >x-bin/'rm' <<'END'
69 PATH=$oPATH; export PATH
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
80 # Creative quoting in the next line to please maintainer-check.
81 chmod +x x-bin/'rm' x-bin/my-install
83 cat > setenv.in <<'END'
84 orig_INSTALL='@INSTALL@'; export orig_INSTALL
87 cat >>configure.ac <<END
88 AC_CONFIG_FILES([setenv.sh:setenv.in])
89 AC_CONFIG_FILES([$subdir/Makefile])
93 cat >Makefile.am <<END
100 cat >Makefile.am <<'END'
106 nobase_include_HEADERS =
110 unindent >>Makefile.am <<END
111 bin_SCRIPTS += script$n
112 nobase_bin_SCRIPTS += nscript$n
114 nobase_data_DATA += ndata$n
115 include_HEADERS += header$n.h
116 nobase_include_HEADERS += nheader$n.h
129 $AUTOMAKE --add-missing
134 ../configure --prefix="$instdir"
136 test -n "$orig_INSTALL"
138 # Try whether native install (or install-sh) works.
140 test -f "$instdir/bin/script1"
141 # Multiple uninstall should work, too.
144 test $(find "$instdir" -type f -print | wc -l) -eq 0
146 # Try whether we don't exceed the low limit.
147 PATH=$nPATH; export PATH
148 run_make INSTALL=my-install install
149 test -f "$instdir/bin/script1"
150 run_make INSTALL=my-install uninstall
151 test $(find "$instdir" -type f -print | wc -l) -eq 0
152 PATH=$oPATH; export PATH
157 # Ensure 'make install' fails when 'install' fails.
159 # We cheat here, for efficiency, knowing the internal rule names.
160 # For correctness, one should '$MAKE install' here always, or at
161 # least use install-exec or install-data.
163 for file in script3 script$nfiles
165 chmod a-r $srcdir/$file
166 test ! -r $srcdir/$file || skip_ "cannot drop file read permissions"
167 $MAKE install-binSCRIPTS && exit 1
168 chmod u+r $srcdir/$file
171 for file in nscript3 nscript$nfiles
173 chmod a-r $srcdir/$file
174 $MAKE install-nobase_binSCRIPTS && exit 1
175 chmod u+r $srcdir/$file
178 for file in data3 data$nfiles
180 chmod a-r $srcdir/$file
181 $MAKE install-dataDATA && exit 1
182 chmod u+r $srcdir/$file
185 for file in ndata3 ndata$nfiles
187 chmod a-r $srcdir/$file
188 $MAKE install-nobase_dataDATA && exit 1
189 chmod u+r $srcdir/$file
192 for file in header3.h header$nfiles.h
194 chmod a-r $srcdir/$file
195 $MAKE install-includeHEADERS && exit 1
196 chmod u+r $srcdir/$file
199 for file in nheader3.h nheader$nfiles.h
201 chmod a-r $srcdir/$file
202 $MAKE install-nobase_includeHEADERS && exit 1
203 chmod u+r $srcdir/$file