cfg.mk 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. # cfg.mk -- configuration file for the maintainer makefile provided by gnulib.
  2. # Copyright (C) 2010-2021 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 3 of the License, or
  7. # (at your option) 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 <https://www.gnu.org/licenses/>.
  16. manual_title = Finding Files
  17. # We need to pass the -I option to gendocs so that the texinfo tools
  18. # can find dblocation.texi, which is a generated file.
  19. gendocs_options_ = -s find.texi -I $(abs_builddir)/doc
  20. local-checks-to-skip :=
  21. # Errors I think are too picky anyway.
  22. local-checks-to-skip += sc_error_message_period sc_error_message_uppercase \
  23. sc_file_system
  24. exclude_file_name_regexp--sc_obsolete_symbols = build-aux/src-sniff\.py
  25. exclude_file_name_regexp--sc_space_tab = \
  26. xargs/testsuite/(inputs/.*\.xi|xargs.(gnu|posix|sysv)/.*\.xo)|find/testsuite/test_escapechars\.golden$$
  27. # Skip sc_two_space_separator_in_usage because it reflects the requirements
  28. # of help2man. It gets run on files that are not help2man inputs, and in
  29. # any case we don't use help2man at all.
  30. local-checks-to-skip += sc_two_space_separator_in_usage
  31. # Comparing tarball sizes compressed using different xz presets, we see that
  32. # an -7e-compressed tarball has the same size as the -9e-compressed one.
  33. # Using -7e is preferred, since that lets the decompression process use less
  34. # memory (19MiB rather than 67MiB).
  35. # $ pkg=x; out=x.out; \
  36. # printf "%3s %8s %6s %s\n" OPT PKGSIZE RESMEM TIME; \
  37. # for i in {5..9}{e,}; do \
  38. # xz -$i < findutils-4.7.0-git.tar > $pkg; \
  39. # s=$(wc -c < $pkg); \
  40. # env time -v xz -d - < $pkg >/dev/null 2> $out; \
  41. # m=$(sed -n '/Maximum resident set size/{s/^.*: //;p;q}' < $out); \
  42. # t=$(sed -n '/User time/{s/^.*: //;p;q}' < $out); \
  43. # printf "%3s %8d %6d %s\n" "$i" "$s" "$m" "$t"; \
  44. # done | sort -k2,2nr
  45. #OPT PKGSIZE RESMEM TIME
  46. # 5 1994080 10484 0.12
  47. # 6 1956672 10564 0.11
  48. # 5e 1935660 10456 0.11
  49. # 6e 1930628 10396 0.11
  50. # 8 1881520 34880 0.11
  51. # 9 1881520 67732 0.12
  52. # 7 1881496 18564 0.11
  53. # 7e 1855268 18584 0.11
  54. # 8e 1855268 35016 0.11
  55. # 9e 1855268 67844 0.11
  56. export XZ_OPT = -7e
  57. # Some test inputs/outputs have trailing blanks.
  58. exclude_file_name_regexp--sc_trailing_blank = \
  59. ^COPYING|(po/.*\.po)|(find/testsuite/find.gnu/printf\.xo)|(xargs/testsuite/(inputs/.*\.xi|xargs\.(gnu|posix|sysv)/.*\.(x[oe])))$$
  60. exclude_file_name_regexp--sc_prohibit_empty_lines_at_EOF = \
  61. ^(.*/testsuite/.*\.(xo|xi|xe))|COPYING|doc/regexprops\.texi|m4/order-(bad|good)\.bin$$
  62. exclude_file_name_regexp--sc_bindtextdomain = \
  63. ^lib/(regexprops|test_splitstring)\.c$$
  64. exclude_file_name_regexp--sc_prohibit_always_true_header_tests = \
  65. ^(build-aux/src-sniff\.py)|ChangeLog$$
  66. exclude_file_name_regexp--sc_prohibit_test_minus_ao = \
  67. ^(ChangeLog)|((find|locate|xargs)/testsuite/.*\.exp)$$
  68. exclude_file_name_regexp--sc_prohibit_doubled_word = \
  69. ^(xargs/testsuite/xargs\.sysv/iquotes\.xo)|ChangeLog|po/.*\.po$$
  70. exclude_file_name_regexp--sc_program_name = \
  71. ^lib/test_splitstring\.c$$
  72. # Suppress syntax-check failure regarding possibly evil strncpy use for now.
  73. exclude_file_name_regexp--sc_prohibit_strncpy = ^(find/print.c|lib/buildcmd.c)$$
  74. # sc_texinfo_acronym: perms.texi from coreutils uses @acronym{GNU}.
  75. exclude_file_name_regexp--sc_texinfo_acronym = doc/perm\.texi
  76. # List syntax-check exemptions.
  77. exclude_file_name_regexp--sc_bindtextdomain = \
  78. ^(locate/frcode|lib/regexprops|lib/test_splitstring)\.c$$
  79. # sc_prohibit_strcmp is broken because it gives false positives for
  80. # cases where neither argument is a string literal.
  81. local-checks-to-skip += sc_prohibit_strcmp
  82. # Ensure that each root-requiring test is run via the "check-root" rule.
  83. sc_root_tests:
  84. @t1=sc-root.expected; t2=sc-root.actual; \
  85. grep -nl '^ *require_root_$$' `$(VC_LIST) tests` | \
  86. sed 's|.*/tests/|tests/|' | sort > $$t1; \
  87. for t in $(all_root_tests); do echo $$t; done | sort > $$t2; \
  88. st=0; diff -u $$t1 $$t2 || st=1; \
  89. rm -f $$t1 $$t2; \
  90. exit $$st
  91. # Ensure that all version-controlled test cases are listed in $(all_tests).
  92. sc_tests_list_consistency:
  93. @bs="\\"; \
  94. test_extensions_rx=`echo $(TEST_EXTENSIONS) \
  95. | sed -e "s/ /|/g" -e "s/$$bs./$$bs$$bs./g"`; \
  96. { \
  97. for t in $(all_tests); do echo $$t; done; \
  98. cd $(top_srcdir); \
  99. $(SHELL) build-aux/vc-list-files tests \
  100. | grep -Ev '^tests/init\.sh$$' \
  101. | $(EGREP) "$$test_extensions_rx\$$"; \
  102. } | sort | uniq -u | grep . && exit 1; :
  103. # Ensure that all version-controlled test scripts are executable.
  104. sc_tests_executable:
  105. @set -o noglob 2>/dev/null || set -f; \
  106. find_ext="-name '' "`printf -- "-o -name *%s " $(TEST_EXTENSIONS)`;\
  107. find $(srcdir)/tests \( $$find_ext \) \! -perm -u+x -print \
  108. | { sed "s|^$(srcdir)/||"; git ls-files $(srcdir)/tests/; } \
  109. | sort | uniq -d \
  110. | sed -e "s/^/$(ME): Please make test executable: /" | grep . \
  111. && exit 1; :
  112. # Avoid :>file which doesn't propagate errors
  113. sc_prohibit_colon_redirection:
  114. @cd $(srcdir)/tests && GIT_PAGER= git grep -En ': *>.*\|\|' \
  115. && { echo '$(ME): '"The leading colon in :> will hide errors" >&2; \
  116. exit 1; } \
  117. || :
  118. # Usage of error() with an exit constant, should instead use die(),
  119. # as that avoids warnings and may generate better code, due to being apparent
  120. # to the compiler that it doesn't return.
  121. sc_die_EXIT_FAILURE:
  122. @cd $(srcdir) \
  123. && GIT_PAGER= git grep -E 'error \(.*_(FAILURE|INVALID)' \
  124. -- find lib locate xargs \
  125. && { echo '$(ME): '"Use die() instead of error" 1>&2; \
  126. exit 1; } \
  127. || :
  128. sc_prohibit-skip:
  129. @prohibit='\|\| skip ' \
  130. halt='Use skip_ not skip' \
  131. $(_sc_search_regexp)
  132. # Disallow the C99 printf size specifiers %z and %j as they're not portable.
  133. # The gnulib printf replacement does support them, however the printf
  134. # replacement is not currently explicitly depended on by the gnulib error()
  135. # module for example. Also we use fprintf() in a few places to output simple
  136. # formats but don't use the gnulib module as it is seen as overkill at present.
  137. # We'd have to adjust the above gnulib items before disabling this.
  138. sc_prohibit-c99-printf-format:
  139. @cd $(srcdir) \
  140. && GIT_PAGER= git grep -n '%[0*]*[jz][udx]' -- "*/*.c" \
  141. && { echo '$(ME): Use PRI*MAX instead of %j or %z' 1>&2; exit 1; } \
  142. || :
  143. # Ensure that tests don't use `cmd ... && fail=1` as that hides crashes.
  144. # The "exclude" expression allows common idioms like `test ... && fail=1`
  145. # and the 2>... portion allows commands that redirect stderr and so probably
  146. # independently check its contents and thus detect any crash messages.
  147. sc_prohibit_and_fail_1:
  148. @prohibit='&& fail=1' \
  149. exclude='(returns_|stat|kill|test |EGREP|grep|compare|2> *[^/])' \
  150. halt='&& fail=1 detected. Please use: returns_ 1 ... || fail=1' \
  151. in_vc_files='^tests/' \
  152. $(_sc_search_regexp)
  153. # Ensure that tests don't use `cmd ... || fail` as that's a noop.
  154. sc_prohibit_or_fail:
  155. @prohibit='\|\| fail$$' \
  156. exclude=':#' \
  157. halt='|| fail detected. Please use: || fail=1' \
  158. in_vc_files='^tests/' \
  159. $(_sc_search_regexp)
  160. # Ensure that env vars are not passed through returns_ as
  161. # that was seen to fail on FreeBSD /bin/sh at least
  162. sc_prohibit_env_returns:
  163. @prohibit='=[^ ]* returns_ ' \
  164. exclude='_ returns_ ' \
  165. halt='Passing env vars to returns_ is non portable' \
  166. in_vc_files='^tests/' \
  167. $(_sc_search_regexp)
  168. # Use framework_failure_, not the old name without the trailing underscore.
  169. sc_prohibit_framework_failure:
  170. @prohibit='\<framework_''failure\>' \
  171. halt='use framework_failure_ instead' \
  172. $(_sc_search_regexp)
  173. # Prohibit the use of `...` in tests/. Use $(...) instead.
  174. sc_prohibit_test_backticks:
  175. @prohibit='`' in_vc_files='^tests/' \
  176. halt='use $$(...), not `...` in tests/' \
  177. $(_sc_search_regexp)
  178. # Ensure that compare is used to check empty files
  179. # so that the unexpected contents are displayed
  180. sc_prohibit_test_empty:
  181. @prohibit='test -s.*&&' in_vc_files='^tests/' \
  182. halt='use `compare /dev/null ...`, not `test -s ...` in tests/' \
  183. $(_sc_search_regexp)
  184. # Ensure that tests call the get_min_ulimit_v_ function if using ulimit -v
  185. sc_prohibit_test_ulimit_without_require_:
  186. @cd $(srcdir) \
  187. && (GIT_PAGER= git grep -l get_min_ulimit_v_ -- tests; \
  188. GIT_PAGER= git grep -l 'ulimit -v' -- tests) \
  189. | sort | uniq -u | grep . && { echo "$(ME): the above test(s)"\
  190. " should match get_min_ulimit_v_ with ulimit -v" 1>&2; exit 1; } || :
  191. # Ensure that tests call the cleanup_ function if using background processes
  192. sc_prohibit_test_background_without_cleanup_:
  193. @cd $(srcdir) \
  194. && (GIT_PAGER= git grep -El '( &$$|&[^&]*=\$$!)' -- tests; \
  195. GIT_PAGER= git grep -l 'cleanup_()' -- tests | sed p) \
  196. | sort | uniq -u | grep . && { echo "$(ME): the above test(s)"\
  197. " should use cleanup_ for background processes" 1>&2; exit 1; } || :
  198. # Ensure that tests call the print_ver_ function for programs which are
  199. # actually used in that test.
  200. sc_prohibit_test_calls_print_ver_with_irrelevant_argument:
  201. @cd $(srcdir) \
  202. && GIT_PAGER= git grep -w print_ver_ -- tests \
  203. | sed 's#:print_ver_##' \
  204. | { fail=0; \
  205. while read file name; do \
  206. for i in $$name; do \
  207. grep -w "$$i" $$file|grep -vw print_ver_|grep -q . \
  208. || { fail=1; \
  209. echo "*** Test: $$file, offending: $$i." 1>&2; };\
  210. done; \
  211. done; \
  212. test $$fail = 0 || exit 1; \
  213. } || { echo "$(ME): the above test(s) call print_ver_ for" \
  214. "program(s) they don't use" 1>&2; exit 1; }
  215. # Exempt the contents of any usage function from the following.
  216. _continued_string_col_1 = \
  217. s/^usage .*?\n}//ms;/\\\n\w/ and print ("$$ARGV\n"),$$e=1;END{$$e||=0;exit $$e}
  218. # Ding any source file that has a continued string with an alphabetic in the
  219. # first column of the following line. We prohibit them because they usually
  220. # trigger false positives in tools that try to map an arbitrary line number
  221. # to the enclosing function name. Of course, very many strings do precisely
  222. # this, *when they are part of the usage function*. That is why we exempt
  223. # the contents of any function named "usage".
  224. sc_prohibit_continued_string_alpha_in_column_1:
  225. @perl -0777 -ne '$(_continued_string_col_1)' \
  226. $$($(VC_LIST_EXCEPT) | grep '\.[ch]$$') \
  227. || { echo '$(ME): continued string with word in first column' \
  228. 1>&2; exit 1; } || :
  229. # Use this to list offending lines:
  230. # git ls-files |grep '\.[ch]$' | xargs \
  231. # perl -n -0777 -e 's/^usage.*?\n}//ms;/\\\n\w/ and print "$ARGV\n"' \
  232. # | xargs grep -A1 '\\$'|grep '\.[ch][:-][_a-zA-Z]'
  233. # Enforce recommended preprocessor indentation style.
  234. sc_preprocessor_indentation:
  235. @if cppi --version >/dev/null 2>&1; then \
  236. $(VC_LIST_EXCEPT) | grep '\.[ch]$$' | xargs cppi -a -c \
  237. || { echo '$(ME): incorrect preprocessor indentation' 1>&2; \
  238. exit 1; }; \
  239. else \
  240. echo '$(ME): skipping test $@: cppi not installed' 1>&2; \
  241. fi
  242. exclude_file_name_regexp--sc_prohibit_test_backticks = \
  243. ^tests/(local\.mk|init\.sh)$$
  244. # Now that we have better tests, make this the default.
  245. export VERBOSE = yes
  246. # During 'make update-copyright', convert a sequence with gaps to the minimal
  247. # containing range.
  248. update-copyright-env = \
  249. UPDATE_COPYRIGHT_FORCE=1 \
  250. UPDATE_COPYRIGHT_USE_INTERVALS=2 \
  251. UPDATE_COPYRIGHT_MAX_LINE_LENGTH=79
  252. # NEWS hash. We use this to detect unintended edits to bits of the NEWS file
  253. # other than the most recent section. If you do need to retrospectively update
  254. # a historic section, run "make update-NEWS-hash", which will then edit this file.
  255. old_NEWS_hash := d41d8cd98f00b204e9800998ecf8427e