2 # Copyright (C) 2008-2024 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 <https://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'
49 PATH=$oPATH; export PATH
50 if test -z "$orig_INSTALL"; then
51 echo "$0: \$orig_INSTALL variable not set" >&2
54 len=`expr "$orig_INSTALL $*" : ".*" 2>/dev/null || echo $limit`
55 if test $len -ge $limit; then
56 echo "$0: safe command line limit of $limit characters exceeded" >&2
59 exec $orig_INSTALL "$@"
63 # Creative quoting in the next line to please maintainer-check.
64 sed "s|@limit@|$limit|g" >x-bin
/'rm' <<'END'
67 PATH=$oPATH; export PATH
69 len=`expr "$RM $*" : ".*" 2>/dev/null || echo $limit`
70 if test $len -ge $limit; then
71 echo "$0: safe command line limit of $limit characters exceeded" >&2
78 # Creative quoting in the next line to please maintainer-check.
79 chmod +x x-bin
/'rm' x-bin
/my-install
81 cat >setenv.
in <<'END'
82 orig_INSTALL='@INSTALL@'
83 # In case we've fallen back on the install-sh script (seen e.g.,
84 # on AIX 7.1), we need to make sure we use its absolute path,
85 # as we don't know from which directory we'll be run.
86 case "$orig_INSTALL" in
88 */*) orig_INSTALL=$(pwd)/$orig_INSTALL;;
93 cat >>configure.ac
<<END
94 AC_CONFIG_FILES([setenv.sh:setenv.in])
95 AC_CONFIG_FILES([$subdir/Makefile])
99 cat >Makefile.am
<<END
106 cat >Makefile.am
<<'END'
112 nobase_include_HEADERS =
116 unindent
>>Makefile.am
<<END
117 bin_SCRIPTS += script$n
118 nobase_bin_SCRIPTS += nscript$n
120 nobase_data_DATA += ndata$n
121 include_HEADERS += header$n.h
122 nobase_include_HEADERS += nheader$n.h
135 $AUTOMAKE --add-missing
140 ..
/configure
--prefix="$instdir"
142 test -n "$orig_INSTALL"
144 # Try whether native install (or install-sh) works.
146 test -f "$instdir/bin/script1"
147 # Multiple uninstall should work, too.
150 test $
(find "$instdir" -type f
-print |
wc -l) -eq 0
152 # Try whether we don't exceed the low limit.
153 PATH
=$nPATH; export PATH
154 run_make INSTALL
=my-install
install
155 test -f "$instdir/bin/script1"
156 run_make INSTALL
=my-install uninstall
157 test $
(find "$instdir" -type f
-print |
wc -l) -eq 0
158 PATH
=$oPATH; export PATH
163 # Ensure 'make install' fails when 'install' fails.
165 # We cheat here, for efficiency, knowing the internal rule names.
166 # For correctness, one should '$MAKE install' here always, or at
167 # least use install-exec or install-data.
169 for file in script3
script$nfiles
171 chmod a-r
$srcdir/$file
172 test ! -r $srcdir/$file || skip_
"cannot drop file read permissions"
173 $MAKE install-binSCRIPTS
&& exit 1
174 chmod u
+r
$srcdir/$file
177 for file in nscript3 nscript
$nfiles
179 chmod a-r
$srcdir/$file
180 $MAKE install-nobase_binSCRIPTS
&& exit 1
181 chmod u
+r
$srcdir/$file
184 for file in data3 data
$nfiles
186 chmod a-r
$srcdir/$file
187 $MAKE install-dataDATA
&& exit 1
188 chmod u
+r
$srcdir/$file
191 for file in ndata3 ndata
$nfiles
193 chmod a-r
$srcdir/$file
194 $MAKE install-nobase_dataDATA
&& exit 1
195 chmod u
+r
$srcdir/$file
198 for file in header3.h header
$nfiles.h
200 chmod a-r
$srcdir/$file
201 $MAKE install-includeHEADERS
&& exit 1
202 chmod u
+r
$srcdir/$file
205 for file in nheader3.h nheader
$nfiles.h
207 chmod a-r
$srcdir/$file
208 $MAKE install-nobase_includeHEADERS
&& exit 1
209 chmod u
+r
$srcdir/$file