primary-prefix-invalid-couples.tap 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. #! /bin/sh
  2. # Copyright (C) 2011-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. # Not all primaries/directories combinations are valid.
  17. # Automake should flag them as errors.
  18. # Originated from PR/294, extended later (following bug #7647) to
  19. # cover more cases.
  20. # See also test 'primary-prefix-valid-couples.test'.
  21. . test-init.sh
  22. plan_ "later"
  23. oIFS=$IFS # Saved for later.
  24. : > ar-lib
  25. : > ltmain.sh
  26. : > texinfo.tex
  27. : > py-compile
  28. : > config.guess
  29. : > config.sub
  30. cat >> configure.ac <<'END'
  31. AC_PROG_CC
  32. AM_PROG_AR
  33. AC_PROG_RANLIB
  34. AC_SUBST([LIBTOOL], [:]) dnl So that we don't have to require Libtool.
  35. AM_PROG_GCJ
  36. AM_PATH_PYTHON
  37. AM_PATH_LISPDIR
  38. END
  39. $ACLOCAL || fatal_ "aclocal failure"
  40. # Please keep this list in sync with the list of "Directory Variables"
  41. # in the GNU Coding Standards and with the list additional directory
  42. # variables provided by autoconf and/or automake (pkgdatadir, pkglibdir,
  43. # ...). See also the hash '%standard_prefix' in the automake script.
  44. prefixes='bin data dataroot doc dvi exec html include info lib libexec
  45. lisp locale localstate man man1 man2 man3 man4 man5 man6 man7
  46. man8 man9 oldinclude pdf pkgdata pkginclude pkglib pkglibexec
  47. ps sbin sharedstate sysconf'
  48. # Please keep this list in sync with the list of primaries documented in
  49. # the Automake manual (see the "The Uniform Naming Scheme" section).
  50. primaries='PROGRAMS LIBRARIES LTLIBRARIES LISP PYTHON JAVA SCRIPTS DATA
  51. HEADERS MANS TEXINFOS'
  52. # Use files, not variables, to hold the list of all the possible
  53. # prefix_PRIMARY couples and the list of those couples valid for
  54. # automake, to avoid having unreadable very verbose traces.
  55. set +x # Don't be overly verbose.
  56. for prefix in $prefixes; do
  57. for primary in $primaries; do
  58. echo ${prefix} ${primary}
  59. done
  60. done >all.list
  61. for primary in $primaries; do
  62. prefixes_ok=''
  63. case $primary in
  64. LIBRARIES|LTLIBRARIES)
  65. prefixes_ok='lib pkglib'
  66. ;;
  67. PROGRAMS)
  68. prefixes_ok='bin sbin libexec pkglibexec'
  69. ;;
  70. SCRIPTS)
  71. prefixes_ok='bin sbin libexec pkglibexec pkgdata'
  72. ;;
  73. DATA)
  74. prefixes_ok='data dataroot pkgdata doc html dvi pdf ps
  75. sysconf sharedstate localstate lisp'
  76. ;;
  77. HEADERS)
  78. prefixes_ok='include oldinclude pkginclude'
  79. ;;
  80. LISP)
  81. prefixes_ok='lisp'
  82. ;;
  83. PYTHON)
  84. prefixes_ok='python'
  85. ;;
  86. JAVA)
  87. prefixes_ok='java'
  88. ;;
  89. MANS)
  90. # FIXME: Here we'd like to have:
  91. # prefixes_ok='man man1 man2 man3 man4 man5 man6 man7 man8 man9'
  92. # but Automake currently fails on that, as it allows the MANS
  93. # primary to be coupled to any prefix.
  94. # See also Automake bug#7656.
  95. # We should dig out how automake had come to behave this way, and
  96. # if such a behaviour can be safely changed.
  97. prefixes_ok=$prefixes
  98. ;;
  99. TEXINFOS)
  100. # FIXME: Here we'd like to have:
  101. # prefixes_ok='info'
  102. # but Automake currently fails on that, as it allows the use of
  103. # 'foo_TEXINFOS' to declare extra Texinfo sources for the 'foo'
  104. # Texinfo manual, as in e.g.:
  105. # info_TEXINFOS = foo.texi
  106. # foo_TEXINFOS = gpl.texi
  107. # See also Automake bug#7657.
  108. prefixes_ok=$prefixes
  109. ;;
  110. *)
  111. fatal_ "unrecognized primary '$primary'"
  112. ;;
  113. esac
  114. for prefix in $prefixes_ok; do
  115. echo ${prefix}_${primary}
  116. done
  117. done >allow.list
  118. # 'html_TEXINFOS' is not yet supported, and might never be.
  119. grep -v '^html TEXINFOS$' all.list | awk '{print NR, $0}' > t
  120. mv -f t all.list
  121. # For debugging.
  122. echo '=== all.list ==='
  123. cat all.list
  124. echo '=== allow.list ==='
  125. cat allow.list
  126. # Create the Makefile.am.
  127. while read lineno prefix primary; do
  128. test -n "$prefix" && test -n "$primary" && test 0 -lt $lineno \
  129. || fatal_ "internal error in 'all.list'"
  130. pfx='' ext=''
  131. case $primary in
  132. LTLIBRARIES) pfx=lib ext=la;;
  133. LIBRARIES) pfx=lib ext=a;;
  134. MANS) ext=man;;
  135. HEADERS) ext=h;;
  136. JAVA) ext=java;;
  137. PYTHON) ext=py;;
  138. LISP) ext=el;;
  139. TEXINFOS) ext=texi;;
  140. esac
  141. test -z "$ext" || ext=.$ext
  142. if test $primary = TEXINFOS; then
  143. echo @setfilename foo$lineno.info > foo$lineno.texi
  144. fi
  145. echo ${prefix}_${primary} = ${pfx}foo${lineno}${ext}
  146. done <all.list >Makefile.am
  147. # For debugging.
  148. echo '=== Makefile.am ==='
  149. cat Makefile.am
  150. set -x # Restore shell xtraces from now on.
  151. AUTOMAKE_fails \
  152. -d "'automake -a' error out on mismatched prefix/primary couples" \
  153. -- --add-missing
  154. while read lineno prefix primary; do
  155. test -n "$prefix" && test -n "$primary" && test 0 -lt $lineno \
  156. || fatal_ "internal error in 'all.list'"
  157. grep "^${prefix}_${primary}$" allow.list >/dev/null && continue
  158. errmsg_rx=".*${prefix}dir.* not a legitimate directory .*$primary"
  159. command_ok_ \
  160. "mismatched prefix/primary in ${prefix}_${primary}" \
  161. grep "^Makefile\\.am:$lineno: $errmsg_rx" stderr
  162. done <all.list
  163. # Check that automake really failed only for the expected reason(s).
  164. grep -v 'dir.* not a legitimate directory' stderr && exit 1
  165. # Check that the same failures are present without the '--add-missing'
  166. # option.
  167. mv stderr stderr.old
  168. AUTOMAKE_fails -d "automake error out on mismatched prefix/primary couples"
  169. command_ok_ "... and with the same diagnostic of 'automake -a'" \
  170. diff stderr.old stderr
  171. :