Clarify overriding of `*_DEPENDENCIES' in LIBOBJS node.
[automake/ericb.git] / tests / instmany.test
blob31176d727fe07d7d403fa2ef227d70f78f1b4ec8
1 #! /bin/sh
2 # Copyright (C) 2008 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 3, 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.
30 required=non-root # hope to catch 'chmod a-r'-challenged file systems.
31 . ./defs || Exit 1
33 set -e
35 # In order to have a useful test on modern systems (which have a high
36 # limit, if any), use a fake install program that errors out for more
37 # than 2K characters in a command line. The POSIX limit is 4096, but
38 # that may include space taken up by the environment.
40 limit=2500
41 subdir=long_subdir_name_with_many_characters
42 nfiles=81
44 # Let's use `seq' if available, it's faster than the loop.
45 list=`(seq 1 $nfiles) 2>/dev/null || {
46 i=1
47 while test $i -le $nfiles; do
48 echo $i
49 i=\`expr $i + 1\`
50 done; }`
52 sed "s|@limit@|$limit|g" >myinstall.in <<'END'
53 #! /bin/sh
54 # Fake install script. This doesn't really install
55 # (the INSTALL path below would be wrong outside this directory).
56 limit=@limit@
57 INSTALL='@INSTALL@'
58 len=`expr "$INSTALL $*" : ".*" 2>/dev/null || echo $limit`
59 if test $len -ge $limit; then
60 echo "$0: safe command line limit of $limit characters exceeded" >&2
61 exit 1
63 exit 0
64 END
66 # Creative quoting in the next line to please maintainer-check.
67 sed "s|@limit@|$limit|g" >'rm' <<'END'
68 #! /bin/sh
69 limit=@limit@
70 PATH=$save_PATH
71 export PATH
72 RM='rm -f'
73 len=`expr "$RM $*" : ".*" 2>/dev/null || echo $limit`
74 if test $len -ge $limit; then
75 echo "$0: safe command line limit of $limit characters exceeded" >&2
76 exit 1
78 exec $RM "$@"
79 exit 1
80 END
82 chmod +x rm
84 cat >>configure.in <<END
85 AC_CONFIG_FILES([myinstall], [chmod +x ./myinstall])
86 AC_CONFIG_FILES([$subdir/Makefile])
87 AC_OUTPUT
88 END
90 cat >Makefile.am <<END
91 SUBDIRS = $subdir
92 END
94 mkdir $subdir
95 cd $subdir
97 cat >Makefile.am <<'END'
98 bin_SCRIPTS =
99 nobase_bin_SCRIPTS =
100 data_DATA =
101 nobase_data_DATA =
102 include_HEADERS =
103 nobase_include_HEADERS =
106 for n in $list; do
107 cat >>Makefile.am <<END
108 bin_SCRIPTS += script$n
109 nobase_bin_SCRIPTS += nscript$n
110 data_DATA += data$n
111 nobase_data_DATA += ndata$n
112 include_HEADERS += header$n.h
113 nobase_include_HEADERS += nheader$n.h
115 echo >script$n
116 echo >nscript$n
117 echo >data$n
118 echo >ndata$n
119 echo >header$n.h
120 echo >nheader$n.h
121 done
123 cd ..
124 $ACLOCAL
125 $AUTOCONF
126 $AUTOMAKE --add-missing
128 instdir=`pwd`/inst
129 mkdir build
130 cd build
131 ../configure --prefix="$instdir"
132 $MAKE
133 # Try whether native install (or install-sh) works.
134 $MAKE install
135 # Multiple uninstall should work, too.
136 $MAKE uninstall
137 $MAKE uninstall
138 test `find "$instdir" -type f -print | wc -l` = 0
140 # Try whether we don't exceed the low limit.
141 INSTALL='$(SHELL) $(top_builddir)/myinstall' $MAKE -e install
142 env save_PATH="$PATH" PATH="`pwd`/..:$PATH" $MAKE uninstall
144 cd $subdir
145 srcdir=../../$subdir
147 # Ensure 'make install' fails when 'install' fails.
149 # We cheat here, for efficiency, knowing the internal rule names.
150 # For correctness, one should `$MAKE install' here always, or at
151 # least use install-exec or install-data.
153 for file in script3 script$nfiles
155 chmod a-r $srcdir/$file
156 $MAKE install-binSCRIPTS && Exit 1
157 chmod u+r $srcdir/$file
158 done
160 for file in nscript3 nscript$nfiles
162 chmod a-r $srcdir/$file
163 $MAKE install-nobase_binSCRIPTS && Exit 1
164 chmod u+r $srcdir/$file
165 done
167 for file in data3 data$nfiles
169 chmod a-r $srcdir/$file
170 $MAKE install-dataDATA && Exit 1
171 chmod u+r $srcdir/$file
172 done
174 for file in ndata3 ndata$nfiles
176 chmod a-r $srcdir/$file
177 $MAKE install-nobase_dataDATA && Exit 1
178 chmod u+r $srcdir/$file
179 done
181 for file in header3.h header$nfiles.h
183 chmod a-r $srcdir/$file
184 $MAKE install-includeHEADERS && Exit 1
185 chmod u+r $srcdir/$file
186 done
188 for file in nheader3.h nheader$nfiles.h
190 chmod a-r $srcdir/$file
191 $MAKE install-nobase_includeHEADERS && Exit 1
192 chmod u+r $srcdir/$file
193 done