test: protect more yacc declarations against C vs. C++ linkage.
[automake.git] / t / instmany.sh
blob99b6f8a3c92afbfc62f078c900574e88ff439525
1 #! /bin/sh
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)
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 <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
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 . test-init.sh
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.
36 limit=2500
37 subdir=long_subdir_name_with_many_characters
38 nfiles=81
39 list=$(seq_ 1 $nfiles)
41 oPATH=$PATH; export oPATH
42 nPATH=$(pwd)/x-bin$PATH_SEPARATOR$PATH; export nPATH
44 mkdir x-bin
46 sed "s|@limit@|$limit|g" >x-bin/my-install <<'END'
47 #! /bin/sh
48 limit=@limit@
49 PATH=$oPATH; export PATH
50 if test -z "$orig_INSTALL"; then
51 echo "$0: \$orig_INSTALL variable not set" >&2
52 exit 1
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
57 exit 1
59 exec $orig_INSTALL "$@"
60 exit 1
61 END
63 # Creative quoting in the next line to please maintainer-check.
64 sed "s|@limit@|$limit|g" >x-bin/'rm' <<'END'
65 #! /bin/sh
66 limit=@limit@
67 PATH=$oPATH; export PATH
68 RM='rm -f'
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
72 exit 1
74 exec $RM "$@"
75 exit 1
76 END
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
87 /*) ;;
88 */*) orig_INSTALL=$(pwd)/$orig_INSTALL;;
89 esac
90 export orig_INSTALL
91 END
93 cat >>configure.ac <<END
94 AC_CONFIG_FILES([setenv.sh:setenv.in])
95 AC_CONFIG_FILES([$subdir/Makefile])
96 AC_OUTPUT
97 END
99 cat >Makefile.am <<END
100 SUBDIRS = $subdir
103 mkdir $subdir
104 cd $subdir
106 cat >Makefile.am <<'END'
107 bin_SCRIPTS =
108 nobase_bin_SCRIPTS =
109 data_DATA =
110 nobase_data_DATA =
111 include_HEADERS =
112 nobase_include_HEADERS =
115 for n in $list; do
116 unindent >>Makefile.am <<END
117 bin_SCRIPTS += script$n
118 nobase_bin_SCRIPTS += nscript$n
119 data_DATA += data$n
120 nobase_data_DATA += ndata$n
121 include_HEADERS += header$n.h
122 nobase_include_HEADERS += nheader$n.h
124 echo >script$n
125 echo >nscript$n
126 echo >data$n
127 echo >ndata$n
128 echo >header$n.h
129 echo >nheader$n.h
130 done
132 cd ..
133 $ACLOCAL
134 $AUTOCONF
135 $AUTOMAKE --add-missing
137 instdir=$(pwd)/inst
138 mkdir build
139 cd build
140 ../configure --prefix="$instdir"
141 . ./setenv.sh
142 test -n "$orig_INSTALL"
143 $MAKE
144 # Try whether native install (or install-sh) works.
145 $MAKE install
146 test -f "$instdir/bin/script1"
147 # Multiple uninstall should work, too.
148 $MAKE uninstall
149 $MAKE uninstall
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
160 cd $subdir
161 srcdir=../../$subdir
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
175 done
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
182 done
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
189 done
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
196 done
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
203 done
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
210 done