instmany.sh 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. #! /bin/sh
  2. # Copyright (C) 2008-2017 Free Software Foundation, Inc.
  3. #
  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.
  8. #
  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.
  13. #
  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/>.
  16. # Installing many files should not exceed the command line length limit.
  17. # Here, the main issue is that we may prepend '$(srcdir)/' to each file,
  18. # which may cause much longer command lines. The list of files must
  19. # anyway remain below the limit, otherwise 'make' won't be able to even
  20. # fork the command.
  21. #
  22. # Further, the install rule should honor failures of the install program.
  23. # Python is done in the sister test.
  24. # For texinfos, we expand names using $(srcdir) in the first place.
  25. # Let's hope nobody uses many texinfos.
  26. . test-init.sh
  27. # In order to have a useful test on modern systems (which have a high
  28. # limit, if any), use a fake install program that errors out for more
  29. # than 2K characters in a command line. The POSIX limit is 4096, but
  30. # that may include space taken up by the environment.
  31. limit=2500
  32. subdir=long_subdir_name_with_many_characters
  33. nfiles=81
  34. list=$(seq_ 1 $nfiles)
  35. oPATH=$PATH; export oPATH
  36. nPATH=$(pwd)/x-bin$PATH_SEPARATOR$PATH; export nPATH
  37. 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
  45. fi
  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
  50. fi
  51. exec $orig_INSTALL "$@"
  52. exit 1
  53. END
  54. # Creative quoting in the next line to please maintainer-check.
  55. sed "s|@limit@|$limit|g" >x-bin/'rm' <<'END'
  56. #! /bin/sh
  57. limit=@limit@
  58. PATH=$oPATH; export PATH
  59. RM='rm -f'
  60. len=`expr "$RM $*" : ".*" 2>/dev/null || echo $limit`
  61. if test $len -ge $limit; then
  62. echo "$0: safe command line limit of $limit characters exceeded" >&2
  63. exit 1
  64. fi
  65. exec $RM "$@"
  66. exit 1
  67. END
  68. # Creative quoting in the next line to please maintainer-check.
  69. chmod +x x-bin/'rm' x-bin/my-install
  70. cat >setenv.in <<'END'
  71. orig_INSTALL='@INSTALL@'
  72. # In case we've falled back on the install-sh script (seen e.g.,
  73. # on AIX 7.1), we need to make sure we use its absolute path,
  74. # as we don't know from which directory we'll be run.
  75. case "$orig_INSTALL" in
  76. /*) ;;
  77. */*) orig_INSTALL=$(pwd)/$orig_INSTALL;;
  78. esac
  79. export orig_INSTALL
  80. END
  81. cat >>configure.ac <<END
  82. AC_CONFIG_FILES([setenv.sh:setenv.in])
  83. AC_CONFIG_FILES([$subdir/Makefile])
  84. AC_OUTPUT
  85. END
  86. cat >Makefile.am <<END
  87. SUBDIRS = $subdir
  88. END
  89. mkdir $subdir
  90. cd $subdir
  91. cat >Makefile.am <<'END'
  92. bin_SCRIPTS =
  93. nobase_bin_SCRIPTS =
  94. data_DATA =
  95. nobase_data_DATA =
  96. include_HEADERS =
  97. nobase_include_HEADERS =
  98. END
  99. for n in $list; do
  100. unindent >>Makefile.am <<END
  101. bin_SCRIPTS += script$n
  102. nobase_bin_SCRIPTS += nscript$n
  103. data_DATA += data$n
  104. nobase_data_DATA += ndata$n
  105. include_HEADERS += header$n.h
  106. nobase_include_HEADERS += nheader$n.h
  107. END
  108. echo >script$n
  109. echo >nscript$n
  110. echo >data$n
  111. echo >ndata$n
  112. echo >header$n.h
  113. echo >nheader$n.h
  114. done
  115. cd ..
  116. $ACLOCAL
  117. $AUTOCONF
  118. $AUTOMAKE --add-missing
  119. instdir=$(pwd)/inst
  120. mkdir build
  121. cd build
  122. ../configure --prefix="$instdir"
  123. . ./setenv.sh
  124. test -n "$orig_INSTALL"
  125. $MAKE
  126. # Try whether native install (or install-sh) works.
  127. $MAKE install
  128. test -f "$instdir/bin/script1"
  129. # Multiple uninstall should work, too.
  130. $MAKE uninstall
  131. $MAKE uninstall
  132. test $(find "$instdir" -type f -print | wc -l) -eq 0
  133. # Try whether we don't exceed the low limit.
  134. PATH=$nPATH; export PATH
  135. run_make INSTALL=my-install install
  136. test -f "$instdir/bin/script1"
  137. run_make INSTALL=my-install uninstall
  138. test $(find "$instdir" -type f -print | wc -l) -eq 0
  139. PATH=$oPATH; export PATH
  140. cd $subdir
  141. srcdir=../../$subdir
  142. # Ensure 'make install' fails when 'install' fails.
  143. # We cheat here, for efficiency, knowing the internal rule names.
  144. # For correctness, one should '$MAKE install' here always, or at
  145. # least use install-exec or install-data.
  146. for file in script3 script$nfiles
  147. do
  148. chmod a-r $srcdir/$file
  149. test ! -r $srcdir/$file || skip_ "cannot drop file read permissions"
  150. $MAKE install-binSCRIPTS && exit 1
  151. chmod u+r $srcdir/$file
  152. done
  153. for file in nscript3 nscript$nfiles
  154. do
  155. chmod a-r $srcdir/$file
  156. $MAKE install-nobase_binSCRIPTS && exit 1
  157. chmod u+r $srcdir/$file
  158. done
  159. for file in data3 data$nfiles
  160. do
  161. chmod a-r $srcdir/$file
  162. $MAKE install-dataDATA && exit 1
  163. chmod u+r $srcdir/$file
  164. done
  165. for file in ndata3 ndata$nfiles
  166. do
  167. chmod a-r $srcdir/$file
  168. $MAKE install-nobase_dataDATA && exit 1
  169. chmod u+r $srcdir/$file
  170. done
  171. for file in header3.h header$nfiles.h
  172. do
  173. chmod a-r $srcdir/$file
  174. $MAKE install-includeHEADERS && exit 1
  175. chmod u+r $srcdir/$file
  176. done
  177. for file in nheader3.h nheader$nfiles.h
  178. do
  179. chmod a-r $srcdir/$file
  180. $MAKE install-nobase_includeHEADERS && exit 1
  181. chmod u+r $srcdir/$file
  182. done
  183. :