Merge branch 'minor'
[automake.git] / t / instmany-mans.sh
blob08a66dabd858da583f09f9605f39c57f2030d93a
1 #! /bin/sh
2 # Copyright (C) 2008-2017 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.
19 # This is the mans sister test of 'instmany.sh', see there for details.
21 . test-init.sh
23 # In order to have a useful test on modern systems (which have a high
24 # limit, if any), use a fake install program that errors out for more
25 # than 2K characters in a command line. The POSIX limit is 4096, but
26 # that may include space taken up by the environment.
28 limit=2500
29 subdir=long_subdir_name_with_many_characters
30 nfiles=81
31 list=$(seq_ 1 $nfiles)
33 oPATH=$PATH; export oPATH
34 nPATH=$(pwd)/x-bin$PATH_SEPARATOR$PATH; export nPATH
36 mkdir x-bin
38 sed "s|@limit@|$limit|g" >x-bin/my-install <<'END'
39 #! /bin/sh
40 limit=@limit@
41 PATH=$oPATH; export PATH
42 if test -z "$orig_INSTALL"; then
43 echo "$0: \$orig_INSTALL variable not set" >&2
44 exit 1
46 len=`expr "$orig_INSTALL $*" : ".*" 2>/dev/null || echo $limit`
47 if test $len -ge $limit; then
48 echo "$0: safe command line limit of $limit characters exceeded" >&2
49 exit 1
51 exec $orig_INSTALL "$@"
52 exit 1
53 END
55 # Creative quoting in the next line to please maintainer-check.
56 sed "s|@limit@|$limit|g" >x-bin/'rm' <<'END'
57 #! /bin/sh
58 limit=@limit@
59 PATH=$oPATH; export PATH
60 RM='rm -f'
61 len=`expr "$RM $*" : ".*" 2>/dev/null || echo $limit`
62 if test $len -ge $limit; then
63 echo "$0: safe command line limit of $limit characters exceeded" >&2
64 exit 1
66 exec $RM "$@"
67 exit 1
68 END
70 # Creative quoting in the next line to please maintainer-check.
71 chmod +x x-bin/'rm' x-bin/my-install
73 cat >setenv.in <<'END'
74 orig_INSTALL='@INSTALL@'
75 # In case we've falled back on the install-sh script (seen e.g.,
76 # on AIX 7.1), we need to make sure we use its absolute path,
77 # as we don't know from which directory we'll be run.
78 case "$orig_INSTALL" in
79 /*) ;;
80 */*) orig_INSTALL=$(pwd)/$orig_INSTALL;;
81 esac
82 export orig_INSTALL
83 END
85 cat >>configure.ac <<END
86 AC_CONFIG_FILES([setenv.sh:setenv.in])
87 AC_CONFIG_FILES([$subdir/Makefile])
88 AC_OUTPUT
89 END
91 cat >Makefile.am <<END
92 SUBDIRS = $subdir
93 END
95 mkdir $subdir
96 cd $subdir
98 cat >Makefile.am <<'END'
99 man_MANS =
100 man3_MANS =
101 notrans_man_MANS =
102 notrans_man3_MANS =
105 for n in $list; do
106 unindent >>Makefile.am <<END
107 man_MANS += page$n.1
108 man3_MANS += page$n.man
109 notrans_man_MANS += npage$n.1
110 notrans_man3_MANS += npage$n.man
112 echo >page$n.1
113 echo >page$n.man
114 echo >npage$n.1
115 echo >npage$n.man
116 done
118 cd ..
119 $ACLOCAL
120 $AUTOCONF
121 $AUTOMAKE --add-missing
123 instdir=$(pwd)/inst
124 mkdir build
125 cd build
126 ../configure --prefix="$instdir"
127 . ./setenv.sh
128 test -n "$orig_INSTALL"
129 $MAKE
130 # Try whether native install (or install-sh) works.
131 $MAKE install
132 test -f "$instdir/share/man/man1/page1.1"
133 # Multiple uninstall should work, too.
134 $MAKE uninstall
135 $MAKE uninstall
136 test $(find "$instdir" -type f -print | wc -l) -eq 0
138 # Try whether we don't exceed the low limit.
139 PATH=$nPATH; export PATH
140 run_make INSTALL=my-install install
141 test -f "$instdir/share/man/man1/page1.1"
142 run_make INSTALL=my-install uninstall
143 test $(find "$instdir" -type f -print | wc -l) -eq 0
144 PATH=$oPATH; export PATH
146 cd $subdir
147 srcdir=../../$subdir
149 # Ensure 'make install' fails when 'install' fails.
151 # We cheat here, for efficiency, knowing the internal rule names.
152 # For correctness, one should '$MAKE install' here always, or at
153 # least use install-exec or install-data.
155 for file in page3.1 page$nfiles.1 npage3.1 npage$nfiles.1; do
156 chmod a-r $srcdir/$file
157 test ! -r $srcdir/$file || skip_ "cannot drop file read permissions"
158 $MAKE install-man1 && exit 1
159 chmod u+r $srcdir/$file
160 done
162 for file in page3.man page$nfiles.man npage3.man npage$nfiles.man; do
163 chmod a-r $srcdir/$file
164 $MAKE install-man3 && exit 1
165 chmod u+r $srcdir/$file
166 done