| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212 | #! /bin/sh# Copyright (C) 2008-2017 Free Software Foundation, Inc.## This program is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public License as published by# the Free Software Foundation; either version 2, or (at your option)# any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program.  If not, see <http://www.gnu.org/licenses/>.# Installing many files should not exceed the command line length limit.# Here, the main issue is that we may prepend '$(srcdir)/' to each file,# which may cause much longer command lines.  The list of files must# anyway remain below the limit, otherwise 'make' won't be able to even# fork the command.## Further, the install rule should honor failures of the install program.# Python is done in the sister test.# For texinfos, we expand names using $(srcdir) in the first place.# Let's hope nobody uses many texinfos.. test-init.sh# In order to have a useful test on modern systems (which have a high# limit, if any), use a fake install program that errors out for more# than 2K characters in a command line.  The POSIX limit is 4096, but# that may include space taken up by the environment.limit=2500subdir=long_subdir_name_with_many_charactersnfiles=81list=$(seq_ 1 $nfiles)oPATH=$PATH; export oPATHnPATH=$(pwd)/x-bin$PATH_SEPARATOR$PATH; export nPATHmkdir x-binsed "s|@limit@|$limit|g" >x-bin/my-install <<'END'#! /bin/shlimit=@limit@PATH=$oPATH; export PATHif test -z "$orig_INSTALL"; then  echo "$0: \$orig_INSTALL variable not set" >&2  exit 1filen=`expr "$orig_INSTALL $*" : ".*" 2>/dev/null || echo $limit`if test $len -ge $limit; then  echo "$0: safe command line limit of $limit characters exceeded" >&2  exit 1fiexec $orig_INSTALL "$@"exit 1END# Creative quoting in the next line to please maintainer-check.sed "s|@limit@|$limit|g" >x-bin/'rm' <<'END'#! /bin/shlimit=@limit@PATH=$oPATH; export PATHRM='rm -f'len=`expr "$RM $*" : ".*" 2>/dev/null || echo $limit`if test $len -ge $limit; then  echo "$0: safe command line limit of $limit characters exceeded" >&2  exit 1fiexec $RM "$@"exit 1END# Creative quoting in the next line to please maintainer-check.chmod +x x-bin/'rm' x-bin/my-installcat >setenv.in <<'END'orig_INSTALL='@INSTALL@'# In case we've falled back on the install-sh script (seen e.g.,# on AIX 7.1), we need to make sure we use its absolute path,# as we don't know from which directory we'll be run.case "$orig_INSTALL" in   /*) ;;  */*) orig_INSTALL=$(pwd)/$orig_INSTALL;;esacexport orig_INSTALLENDcat >>configure.ac <<ENDAC_CONFIG_FILES([setenv.sh:setenv.in])AC_CONFIG_FILES([$subdir/Makefile])AC_OUTPUTENDcat >Makefile.am <<ENDSUBDIRS = $subdirENDmkdir $subdircd $subdircat >Makefile.am <<'END'bin_SCRIPTS =nobase_bin_SCRIPTS =data_DATA =nobase_data_DATA =include_HEADERS =nobase_include_HEADERS =ENDfor n in $list; do  unindent >>Makefile.am <<END    bin_SCRIPTS += script$n    nobase_bin_SCRIPTS += nscript$n    data_DATA += data$n    nobase_data_DATA += ndata$n    include_HEADERS += header$n.h    nobase_include_HEADERS += nheader$n.hEND  echo >script$n  echo >nscript$n  echo >data$n  echo >ndata$n  echo >header$n.h  echo >nheader$n.hdonecd ..$ACLOCAL$AUTOCONF$AUTOMAKE --add-missinginstdir=$(pwd)/instmkdir buildcd build../configure --prefix="$instdir". ./setenv.shtest -n "$orig_INSTALL"$MAKE# Try whether native install (or install-sh) works.$MAKE installtest -f "$instdir/bin/script1"# Multiple uninstall should work, too.$MAKE uninstall$MAKE uninstalltest $(find "$instdir" -type f -print | wc -l) -eq 0# Try whether we don't exceed the low limit.PATH=$nPATH; export PATHrun_make INSTALL=my-install installtest -f "$instdir/bin/script1"run_make INSTALL=my-install uninstalltest $(find "$instdir" -type f -print | wc -l) -eq 0PATH=$oPATH; export PATHcd $subdirsrcdir=../../$subdir# Ensure 'make install' fails when 'install' fails.# We cheat here, for efficiency, knowing the internal rule names.# For correctness, one should '$MAKE install' here always, or at# least use install-exec or install-data.for file in script3 script$nfilesdo  chmod a-r $srcdir/$file  test ! -r $srcdir/$file || skip_ "cannot drop file read permissions"  $MAKE install-binSCRIPTS && exit 1  chmod u+r $srcdir/$filedonefor file in nscript3 nscript$nfilesdo  chmod a-r $srcdir/$file  $MAKE install-nobase_binSCRIPTS && exit 1  chmod u+r $srcdir/$filedonefor file in data3 data$nfilesdo  chmod a-r $srcdir/$file  $MAKE install-dataDATA && exit 1  chmod u+r $srcdir/$filedonefor file in ndata3 ndata$nfilesdo  chmod a-r $srcdir/$file  $MAKE install-nobase_dataDATA && exit 1  chmod u+r $srcdir/$filedonefor file in header3.h header$nfiles.hdo  chmod a-r $srcdir/$file  $MAKE install-includeHEADERS && exit 1  chmod u+r $srcdir/$filedonefor file in nheader3.h nheader$nfiles.hdo  chmod a-r $srcdir/$file  $MAKE install-nobase_includeHEADERS && exit 1  chmod u+r $srcdir/$filedone:
 |