tail: fix checking of remoteness when not using inotify
[coreutils.git] / cfg.mk
blob92a41cf5df3eff3accb18e2aa11460cce3c1a440
1 # Customize maint.mk -*- makefile -*-
2 # Copyright (C) 2003-2016 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 3 of the License, or
7 # (at your option) 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 <http://www.gnu.org/licenses/>.
17 # Used in maint.mk's web-manual rule
18 manual_title = Core GNU utilities
20 # Use the direct link. This is guaranteed to work immediately, while
21 # it can take a while for the faster mirror links to become usable.
22 url_dir_list = http://ftp.gnu.org/gnu/$(PACKAGE)
24 # Exclude bundled external projects from syntax checks
25 VC_LIST_ALWAYS_EXCLUDE_REGEX = src/blake2/.*$$
27 # Tests not to run as part of "make distcheck".
28 local-checks-to-skip = \
29 sc_proper_name_utf8_requires_ICONV
31 # Tools used to bootstrap this package, used for "announcement".
32 bootstrap-tools = autoconf,automake,gnulib,bison
34 # Now that we have better tests, make this the default.
35 export VERBOSE = yes
37 # Comparing tarball sizes compressed using different xz presets, we see that
38 # an -8e-compressed tarball is only 9KiB larger than the -9e-compressed one.
39 # Using -8e is preferred, since that lets the decompression process use half
40 # the memory (32MiB rather than 64MiB).
41 # $ for i in {7,8,9}{e,}; do \
42 # (n=$(xz -$i < coreutils-8.15*.tar|wc -c);echo $n $i) & done |sort -nr
43 # 5129388 7
44 # 5036524 7e
45 # 5017476 8
46 # 5010604 9
47 # 4923016 8e
48 # 4914152 9e
49 export XZ_OPT = -8e
51 old_NEWS_hash = 4cdc662ed636425161a383b9aa85b2eb
53 # Add an exemption for sc_makefile_at_at_check.
54 _makefile_at_at_check_exceptions = ' && !/^cu_install_prog/ && !/dynamic-dep/'
56 # Our help-version script is in a slightly different location.
57 _hv_file ?= $(srcdir)/tests/misc/help-version
59 # Ensure that the list of O_ symbols used to compute O_FULLBLOCK is complete.
60 dd = $(srcdir)/src/dd.c
61 sc_dd_O_FLAGS:
62 @rm -f $@.1 $@.2
63 @{ echo O_FULLBLOCK; echo O_NOCACHE; \
64 perl -nle '/^ +\| (O_\w*)$$/ and print $$1' $(dd); } | sort > $@.1
65 @{ echo O_NOFOLLOW; perl -nle '/{"[a-z]+",\s*(O_\w+)},/ and print $$1' \
66 $(dd); } | sort > $@.2
67 @diff -u $@.1 $@.2; diff=$$?; \
68 rm -f $@.1 $@.2; \
69 test "$$diff" = 0 \
70 || { echo '$(ME): $(dd) has inconsistent O_ flag lists'>&2; \
71 exit 1; }
73 # Ensure that dd's definition of LONGEST_SYMBOL stays in sync
74 # with the strings from the two affected variables.
75 dd_c = $(srcdir)/src/dd.c
76 sc_dd_max_sym_length:
77 ifneq ($(wildcard $(dd_c)),)
78 @len=$$( (sed -n '/conversions\[\] =$$/,/^};/p' $(dd_c);\
79 sed -n '/flags\[\] =$$/,/^};/p' $(dd_c) ) \
80 |sed -n '/"/s/^[^"]*"\([^"]*\)".*/\1/p'| wc -L);\
81 max=$$(sed -n '/^#define LONGEST_SYMBOL /s///p' $(dd_c) \
82 |tr -d '"' | wc -L); \
83 if test "$$len" = "$$max"; then :; else \
84 echo 'dd.c: LONGEST_SYMBOL is not longest' 1>&2; \
85 exit 1; \
87 endif
89 # Many m4 macros names once began with 'jm_'.
90 # On 2004-04-13, they were all changed to start with gl_ instead.
91 # Make sure that none are inadvertently reintroduced.
92 sc_prohibit_jm_in_m4:
93 @grep -nE 'jm_[A-Z]' \
94 $$($(VC_LIST) m4 |grep '\.m4$$'; echo /dev/null) && \
95 { echo '$(ME): do not use jm_ in m4 macro names' \
96 1>&2; exit 1; } || :
98 # Ensure that each root-requiring test is run via the "check-root" rule.
99 sc_root_tests:
100 @t1=sc-root.expected; t2=sc-root.actual; \
101 grep -nl '^ *require_root_$$' `$(VC_LIST) tests` | \
102 sed 's|.*/tests/|tests/|' | sort > $$t1; \
103 for t in $(all_root_tests); do echo $$t; done | sort > $$t2; \
104 st=0; diff -u $$t1 $$t2 || st=1; \
105 rm -f $$t1 $$t2; \
106 exit $$st
108 # Ensure that all version-controlled test cases are listed in $(all_tests).
109 sc_tests_list_consistency:
110 @bs="\\"; \
111 test_extensions_rx=`echo $(TEST_EXTENSIONS) \
112 | sed -e "s/ /|/g" -e "s/$$bs./$$bs$$bs./g"`; \
114 for t in $(all_tests); do echo $$t; done; \
115 cd $(top_srcdir); \
116 $(SHELL) build-aux/vc-list-files tests \
117 | grep -Ev '^tests/(factor/(run|create-test)|init)\.sh$$' \
118 | $(EGREP) "$$test_extensions_rx\$$"; \
119 } | sort | uniq -u | grep . && exit 1; :
121 # Ensure that all version-controlled test scripts are executable.
122 sc_tests_executable:
123 @set -o noglob 2>/dev/null || set -f; \
124 find_ext="-name '' "`printf -- "-o -name *%s " $(TEST_EXTENSIONS)`;\
125 find $(srcdir)/tests/ \( $$find_ext \) \! -perm -u+x -print \
126 | { sed "s|^$(srcdir)/||"; git ls-files $(srcdir)/tests/; } \
127 | sort | uniq -d \
128 | sed -e "s/^/$(ME): Please make test executable: /" | grep . \
129 && exit 1; :
131 # Ensure all gnulib patches apply cleanly
132 sc_ensure_gl_diffs_apply_cleanly:
133 @find $(srcdir)/gl/ -name '*.diff' | while read p; do \
134 patch --fuzz=0 -f -s -d $(srcdir)/gnulib/ -p1 --dry-run < "$$p" >&2 \
135 || { echo "$$p" >&2; echo 'To refresh all gl patches run:' \
136 'make refresh-gnulib-patches' >&2; exit 1; } \
137 done
139 # Avoid :>file which doesn't propagate errors
140 sc_prohibit_colon_redirection:
141 @cd $(srcdir)/tests && GIT_PAGER= git grep -n ': *>.*||' \
142 && { echo '$(ME): '"The leading colon in :> will hide errors" 1>&2; \
143 exit 1; } \
144 || :
146 # Ensure emit_mandatory_arg_note() is called if required
147 sc_ensure_emit_mandatory_arg_note:
148 @cd $(srcdir)/src && GIT_PAGER= git \
149 grep -l -- '^ *-[^-].*--.*[^[]=' *.c \
150 | xargs grep -L emit_mandatory_arg_note | grep . \
151 && { echo '$(ME): '"emit_mandatory_arg_note() missing" 1>&2; \
152 exit 1; } || :
154 # Create a list of regular expressions matching the names
155 # of files included from system.h. Exclude a couple.
156 .re-list:
157 @sed -n '/^# *include /s///p' $(srcdir)/src/system.h \
158 | grep -Ev 'sys/(param|file)\.h' \
159 | sed 's/ .*//;;s/^["<]/^# *include [<"]/;s/\.h[">]$$/\\.h[">]/' \
160 > $@-t
161 @mv $@-t $@
163 define gl_trap_
164 Exit () { set +e; (exit $$1); exit $$1; }; \
165 for sig in 1 2 3 13 15; do \
166 eval "trap 'Exit $$(expr $$sig + 128)' $$sig"; \
167 done
168 endef
170 # Files in src/ should not include directly any of
171 # the headers already included via system.h.
172 sc_system_h_headers: .re-list
173 @if test -f $(srcdir)/src/system.h; then \
174 trap 'rc=$$?; rm -f .re-list; exit $$rc' 0; \
175 $(gl_trap_); \
176 grep -nE -f .re-list \
177 $$($(VC_LIST_EXCEPT) | grep '^\($(srcdir)/\)\?src/') \
178 && { echo '$(ME): the above are already included via system.h'\
179 1>&2; exit 1; } || :; \
182 # Files in src/ should not use '%s' notation in format strings,
183 # i.e., single quotes around %s (or similar) should be avoided.
184 sc_prohibit_quotes_notation:
185 @cd $(srcdir)/src && GIT_PAGER= git grep -n "\".*[\`']%s'.*\"" *.c \
186 && { echo '$(ME): '"Use quote() to avoid quoted '%s' notation" 1>&2; \
187 exit 1; } \
188 || :
190 # Files in src/ should quote all strings in error() output, so that
191 # unexpected input chars like \r etc. don't corrupt the error.
192 # In edge cases this can be avoided by putting the format string
193 # on a separate line to the following arguments.
194 sc_error_quotes:
195 @cd $(srcdir)/src && GIT_PAGER= git grep -n 'error *(.*%s.*, [^(]*);$$'\
196 *.c | grep -v ', q' \
197 && { echo '$(ME): '"Use quote() for error string arguments" 1>&2; \
198 exit 1; } \
199 || :
201 # Files in src/ should quote all file names in error() output
202 # using quotef(), to provide quoting only when necessary,
203 # but also provide better support for copy and paste when used.
204 sc_error_shell_quotes:
205 @cd $(srcdir)/src && \
206 { GIT_PAGER= git grep -E \
207 'error \(.*%s[:"], .*(name|file)[^"]*\);$$' *.c; \
208 GIT_PAGER= git grep -E \
209 ' quote[ _].*file' *.c; } \
210 | grep -Ev '(quotef|q[^ ]*name)' \
211 && { echo '$(ME): '"Use quotef() for colon delimited names" 1>&2; \
212 exit 1; } \
213 || :
215 # Files in src/ should quote all file names in error() output
216 # using quoteaf() when the name is separated with spaces,
217 # to distinguish the file name at issue and
218 # to provide better support for copy and paste.
219 sc_error_shell_always_quotes:
220 @cd $(srcdir)/src && GIT_PAGER= git grep -E \
221 'error \(.*[^:] %s[ "].*, .*(name|file)[^"]*\);$$' \
222 *.c | grep -Ev '(quoteaf|q[^ ]*name)' \
223 && { echo '$(ME): '"Use quoteaf() for space delimited names" 1>&2; \
224 exit 1; } \
225 || :
226 @cd $(srcdir)/src && GIT_PAGER= git grep -E -A1 \
227 'error \([^%]*[^:] %s[ "]' *.c | grep 'quotef' \
228 && { echo '$(ME): '"Use quoteaf() for space delimited names" 1>&2; \
229 exit 1; } \
230 || :
232 # Usage of error() with an exit constant, should instead use die(),
233 # as that avoids warnings and may generate better code, due to being apparent
234 # to the compiler that it doesn't return.
235 sc_die_EXIT_FAILURE:
236 @cd $(srcdir)/src && GIT_PAGER= git grep -E \
237 'error \(.*_(FAILURE|INVALID)' \
238 && { echo '$(ME): '"Use die() instead of error" 1>&2; \
239 exit 1; } \
240 || :
242 # Avoid unstyled quoting to internal slots and thus destined for diagnostics
243 # as that can leak unescaped control characters to the output, when using
244 # the default "literal" quoting style.
245 # Instead use quotef(), or quoteaf() or in edge cases quotearg_n_style_colon().
246 # A more general PCRE would be @prohibit='quotearg_.*(?!(style|buffer))'
247 sc_prohibit-quotearg:
248 @prohibit='quotearg(_n)?(|_colon|_char|_mem) ' \
249 in_vc_files='\.c$$' \
250 halt='Unstyled diagnostic quoting detected' \
251 $(_sc_search_regexp)
253 sc_sun_os_names:
254 @grep -nEi \
255 'solaris[^[:alnum:]]*2\.(7|8|9|[1-9][0-9])|sunos[^[:alnum:]][6-9]' \
256 $$($(VC_LIST_EXCEPT)) && \
257 { echo '$(ME): found misuse of Sun OS version numbers' 1>&2; \
258 exit 1; } || :
260 # Ensure that the list of programs and author names is accurate.
261 # We need a UTF8 locale. If a lack of locale support or a missing
262 # translation inhibits printing of UTF-8 names, just skip this test.
263 au_dotdot = authors-dotdot
264 au_actual = authors-actual
265 sc_check-AUTHORS: $(all_programs)
266 @locale=en_US.UTF-8; \
267 LC_ALL=$$locale ./src/factor --version \
268 | grep ' Torbjorn ' > /dev/null \
269 && { echo "$@: skipping this check"; exit 0; }; \
270 rm -f $(au_actual) $(au_dotdot); \
271 for i in `ls $(all_programs) \
272 | sed -e 's,^src/,,' -e 's,$(EXEEXT)$$,,' \
273 | sed /libstdbuf/d \
274 | $(ASSORT) -u`; do \
275 test "$$i" = '[' && continue; \
276 exe=$$i; \
277 if test "$$i" = install; then \
278 exe=ginstall; \
279 elif test "$$i" = test; then \
280 exe='['; \
281 fi; \
282 LC_ALL=$$locale ./src/$$exe --version \
283 | perl -0 -p -e 's/,\n/, /gm' \
284 | sed -n -e '/Written by /{ s//'"$$i"': /;' \
285 -e 's/,* and /, /; s/\.$$//; p; }'; \
286 done > $(au_actual) && \
287 sed -n '/^[^ ][^ ]*:/p' $(srcdir)/AUTHORS > $(au_dotdot) \
288 && diff $(au_actual) $(au_dotdot) \
289 && rm -f $(au_actual) $(au_dotdot)
291 # Each program with a non-ASCII author name must link with LIBICONV.
292 sc_check-I18N-AUTHORS:
293 @cd $(srcdir)/src && \
294 for i in $$(git grep -l -w proper_name_utf8 *.c|sed 's/\.c//'); do \
295 grep -E "^src_$${i}_LDADD"' .?= .*\$$\(LIBICONV\)' local.mk \
296 > /dev/null \
297 || { echo "$(ME): link rules for $$i do not include" \
298 '$$(LIBICONV)' 1>&2; exit 1; }; \
299 done
301 # Disallow the C99 printf size specifiers %z and %j as they're not portable.
302 # The gnulib printf replacement does support them, however the printf
303 # replacement is not currently explicitly depended on by the gnulib error()
304 # module for example. Also we use fprintf() in a few places to output simple
305 # formats but don't use the gnulib module as it is seen as overkill at present.
306 # We'd have to adjust the above gnulib items before disabling this.
307 sc_prohibit-c99-printf-format:
308 @cd $(srcdir)/src && GIT_PAGER= git grep -n '%[0*]*[jz][udx]' *.c \
309 && { echo '$(ME): Use PRI*MAX instead of %j or %z' 1>&2; exit 1; } \
310 || :
312 # Ensure the alternative __attribute (keyword) form isn't used as
313 # that form is not elided where required. Also ensure that we don't
314 # directly use attributes already defined by gnulib.
315 # TODO: move the check for _GL... attributes to gnulib.
316 sc_prohibit-gl-attributes:
317 @prohibit='__attribute |__(unused|pure|const)__' \
318 in_vc_files='\.[ch]$$' \
319 halt='Use _GL... attribute macros' \
320 $(_sc_search_regexp)
322 # Look for lines longer than 80 characters, except omit:
323 # - program-generated long lines in diff headers,
324 # - the help2man script copied from upstream,
325 # - tests involving long checksum lines, and
326 # - the 'pr' test cases.
327 FILTER_LONG_LINES = \
328 \|^[^:]*man/help2man:| d; \
329 \|^[^:]*tests/misc/sha[0-9]*sum.*\.pl[-:]| d; \
330 \|^[^:]*tests/pr/|{ \|^[^:]*tests/pr/pr-tests:| !d; };
331 sc_long_lines:
332 @wc -L /dev/null >/dev/null 2>/dev/null \
333 || { echo "$@: skipping: wc -L not supported"; exit 0; }; \
334 sed -r 1q /dev/null 2>/dev/null \
335 || { echo "$@: skipping: sed -r not supported"; exit 0; }; \
336 files=$$($(VC_LIST_EXCEPT) | xargs wc -L | sed -rn '/ total$$/d;\
337 s/^ *(8[1-9]|9[0-9]|[0-9]{3,}) //p'); \
338 halt='line(s) with more than 80 characters; reindent'; \
339 for file in $$files; do \
340 expand $$file | grep -nE '^.{80}.' | \
341 sed -e "s|^|$$file:|" -e '$(FILTER_LONG_LINES)'; \
342 done | grep . && { msg="$$halt" $(_sc_say_and_exit) } || :
344 # Option descriptions should not start with a capital letter.
345 # One could grep source directly as follows:
346 # grep -E " {2,6}-.*[^.] [A-Z][a-z]" $$($(VC_LIST_EXCEPT) | grep '\.c$$')
347 # but that would miss descriptions not on the same line as the -option.
348 sc_option_desc_uppercase: $(ALL_MANS)
349 @grep '^\\fB\\-' -A1 man/*.1 | LC_ALL=C grep '\.1.[A-Z][a-z]' \
350 && { echo 1>&2 '$@: found initial capitals in --help'; exit 1; } || :
352 # Ensure all man/*.[1x] files are present.
353 sc_man_file_correlation: check-x-vs-1 check-programs-vs-x
355 # Ensure that for each .x file in the 'man/' subdirectory, there is a
356 # corresponding .1 file in the definition of $(EXTRA_MANS).
357 # But since that expansion usually lacks programs like arch and hostname,
358 # add them here manually.
359 .PHONY: check-x-vs-1
360 check-x-vs-1:
361 @PATH=./src$(PATH_SEPARATOR)$$PATH; export PATH; \
362 t=$@-t; \
363 (cd $(srcdir)/man && ls -1 *.x) \
364 | sed 's/\.x$$//' | $(ASSORT) > $$t; \
365 (echo $(patsubst man/%,%,$(ALL_MANS)) \
366 | tr -s ' ' '\n' | sed 's/\.1$$//') \
367 | $(ASSORT) -u | diff - $$t || { rm $$t; exit 1; }; \
368 rm $$t
370 # Ensure that non-trivial .x files in the 'man/' subdirectory,
371 # i.e., files exceeding a line count of 20 or a byte count of 1000,
372 # contain a Copyright notice.
373 .PHONY: sc_man_check_x_copyright
374 sc_man_check_x_copyright:
375 @status=0; \
376 cd $(srcdir) && wc -cl man/*.x | head -n-1 \
377 | awk '$$1 >= 20 || $$2 >= 1000 {print $$3}' \
378 | xargs grep -L 'Copyright .* Free Software Foundation' \
379 | grep . \
380 && { echo 1>&2 '$@: exceeding file size/line count limit' \
381 '- please add a copyright note'; status=1; }; \
382 exit $$status
384 # Writing a portable rule to generate a manpage like '[.1' would be
385 # a nightmare, so filter that out.
386 all-progs-but-lbracket = $(filter-out [,$(patsubst src/%,%,$(all_programs)))
388 # Ensure that for each coreutils program there is a corresponding
389 # '.x' file in the 'man/' subdirectory.
390 .PHONY: check-programs-vs-x
391 check-programs-vs-x:
392 @status=0; \
393 for p in dummy $(all-progs-but-lbracket); do \
394 case $$p in *.so) continue;; esac; \
395 test $$p = dummy && continue; \
396 test $$p = ginstall && p=install || : ; \
397 test -f $(srcdir)/man/$$p.x \
398 || { echo missing $$p.x 1>&2; status=1; }; \
399 done; \
400 exit $$status
402 # Ensure we can check out on case insensitive file systems
403 sc_case_insensitive_file_names: src/uniq
404 @git ls-files | sort -f | src/uniq -Di | grep . && \
405 { echo "$(ME): the above file(s) conflict on case insensitive" \
406 " file systems" 1>&2; exit 1; } || :
408 # Ensure that the end of each release's section is marked by two empty lines.
409 sc_NEWS_two_empty_lines:
410 @sed -n 4,/Noteworthy/p $(srcdir)/NEWS \
411 | perl -n0e '/(^|\n)\n\n\* Noteworthy/ or exit 1' \
412 || { echo '$(ME): use two empty lines to separate NEWS sections' \
413 1>&2; exit 1; } || :
415 # With split lines, don't leave an operator at end of line.
416 # Instead, put it on the following line, where it is more apparent.
417 # Don't bother checking for "*" at end of line, since it provokes
418 # far too many false positives, matching constructs like "TYPE *".
419 # Similarly, omit "=" (initializers).
420 binop_re_ ?= [-/+^!<>]|[-/+*^!<>=]=|&&?|\|\|?|<<=?|>>=?
421 sc_prohibit_operator_at_end_of_line:
422 @prohibit='. ($(binop_re_))$$' \
423 in_vc_files='\.[chly]$$' \
424 halt='found operator at end of line' \
425 $(_sc_search_regexp)
427 # Don't use "readlink" or "readlinkat" directly
428 sc_prohibit_readlink:
429 @prohibit='\<readlink(at)? \(' \
430 halt='do not use readlink(at); use via xreadlink or areadlink*' \
431 $(_sc_search_regexp)
433 # Don't use address of "stat" or "lstat" functions
434 sc_prohibit_stat_macro_address:
435 @prohibit='\<l?stat '':|&l?stat\>' \
436 halt='stat() and lstat() may be function-like macros' \
437 $(_sc_search_regexp)
439 # Ensure that date's --help output stays in sync with the info
440 # documentation for GNU strftime. The only exception is %N and %q,
441 # which date accepts but GNU strftime does not.
442 extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/'
443 sc_strftime_check:
444 @if test -f $(srcdir)/src/date.c; then \
445 grep '^ %. ' $(srcdir)/src/date.c | sort \
446 | $(extract_char) > $@-src; \
447 { echo N; echo q; \
448 info libc date calendar format 2>/dev/null \
449 | grep "^ *['\`]%.'$$"| $(extract_char); }| sort >$@-info;\
450 if test $$(stat --format %s $@-info) != 2; then \
451 diff -u $@-src $@-info || exit 1; \
452 else \
453 echo '$(ME): skipping $@: libc info not installed' 1>&2; \
454 fi; \
455 rm -f $@-src $@-info; \
458 # Indent only with spaces.
459 sc_prohibit_tab_based_indentation:
460 @prohibit='^ * ' \
461 halt='TAB in indentation; use only spaces' \
462 $(_sc_search_regexp)
464 # Enforce lowercase 'e' in "I.e.".
465 sc_prohibit_uppercase_id_est:
466 @prohibit='I\.E\.' \
467 halt='Uppercase "Id Est" abbreviation; use "I.e.," instead' \
468 $(_sc_search_regexp)
470 # Enforce double-space before "I.e." at the beginning of a sentence.
471 sc_ensure_dblspace_after_dot_before_id_est:
472 @prohibit='\. I\.e\.' \
473 halt='Single space after dot before "i.e."; use ". i.e." instead' \
474 $(_sc_search_regexp)
476 # Enforce comma after "i.e." (at least before a blank or at EOL).
477 sc_ensure_comma_after_id_est:
478 @prohibit='[Ii]\.e\.( |$$)' \
479 halt='Missing comma after "i.e."; use "i.e.," instead' \
480 $(_sc_search_regexp)
482 # The SEE ALSO section of a man page should not be terminated with
483 # a period. Check the first line after each "SEE ALSO" line in man/*.x:
484 sc_prohibit_man_see_also_period:
485 @grep -nB1 '\.$$' $$($(VC_LIST_EXCEPT) | grep 'man/.*\.x$$') \
486 | grep -A1 -e '-\[SEE ALSO\]' | grep '\.$$' && \
487 { echo '$(ME): do not end "SEE ALSO" section with a period' \
488 1>&2; exit 1; } || :
490 # Don't use "indent-tabs-mode: nil" anymore. No longer needed.
491 sc_prohibit_emacs__indent_tabs_mode__setting:
492 @prohibit='^( *[*#] *)?indent-tabs-mode:' \
493 halt='use of emacs indent-tabs-mode: setting' \
494 $(_sc_search_regexp)
496 # Ensure that tests don't include a redundant fail=0.
497 sc_prohibit_fail_0:
498 @prohibit='\<fail=0\>' \
499 halt='fail=0 initialization' \
500 $(_sc_search_regexp)
502 # Ensure that tests don't use `cmd ... && fail=1` as that hides crashes.
503 # The "exclude" expression allows common idioms like `test ... && fail=1`
504 # and the 2>... portion allows commands that redirect stderr and so probably
505 # independently check its contents and thus detect any crash messages.
506 sc_prohibit_and_fail_1:
507 @prohibit='&& fail=1' \
508 exclude='(returns_|stat|kill|test |EGREP|grep|compare|2> *[^/])' \
509 halt='&& fail=1 detected. Please use: returns_ 1 ... || fail=1' \
510 in_vc_files='^tests/' \
511 $(_sc_search_regexp)
513 # Ensure that env vars are not passed through returns_ as
514 # that was seen to fail on FreeBSD /bin/sh at least
515 sc_prohibit_env_returns:
516 @prohibit='=[^ ]* returns_ ' \
517 halt='Passing env vars to returns_ is non portable' \
518 in_vc_files='^tests/' \
519 $(_sc_search_regexp)
521 # The mode part of a setfacl -m option argument must be three bytes long.
522 # I.e., an argument of user:bin:rw or user:bin:r will make Solaris 10's
523 # setfacl reject it with: "Unrecognized character found in mode field".
524 # Use hyphens to give it a length of 3: "...:rw-" or "...:r--".
525 sc_prohibit_short_facl_mode_spec:
526 @prohibit='\<setfacl .*-m.*:.*:[rwx-]{1,2} ' \
527 halt='setfacl mode string length < 3; extend with hyphen(s)' \
528 $(_sc_search_regexp)
530 # Ensure that "stdio--.h" is used where appropriate.
531 sc_require_stdio_safer:
532 @if $(VC_LIST_EXCEPT) | grep -l '\.[ch]$$' > /dev/null; then \
533 files=$$(grep -l '\bfreopen \?(' $$($(VC_LIST_EXCEPT) \
534 | grep '\.[ch]$$')); \
535 test -n "$$files" && grep -LE 'include "stdio--.h"' $$files \
536 | grep . && \
537 { echo '$(ME): the above files should use "stdio--.h"' \
538 1>&2; exit 1; } || :; \
539 else :; \
542 sc_prohibit_perl_hash_quotes:
543 @prohibit="\{'[A-Z_]+' *[=}]" \
544 halt="in Perl code, write \$$hash{KEY}, not \$$hash{'K''EY'}" \
545 $(_sc_search_regexp)
547 # Prefer xnanosleep over other less-precise sleep methods
548 sc_prohibit_sleep:
549 @prohibit='\<(nano|u)?sleep \(' \
550 halt='prefer xnanosleep over other sleep interfaces' \
551 $(_sc_search_regexp)
553 # Use print_ver_ (from init.cfg), not open-coded $VERBOSE check.
554 sc_prohibit_verbose_version:
555 @prohibit='test "\$$VERBOSE" = yes && .* --version' \
556 halt='use the print_ver_ function instead...' \
557 $(_sc_search_regexp)
559 # Enforce print_ver_ tracking of dependencies
560 # Each coreutils specific program a test requires
561 # should be tagged by calling through env(1).
562 sc_env_test_dependencies:
563 @cd $(top_srcdir) && GIT_PAGER= git grep -E \
564 "env ($$(build-aux/gen-lists-of-programs.sh --list-progs | \
565 grep -vF '[' |paste -d'|' -s))" tests | \
566 sed "s/\([^:]\):.*env \([^)' ]*\).*/\1 \2/" | uniq | \
567 while read test prog; do \
568 printf '%s' $$test | grep -q '\.pl$$' && continue; \
569 grep -q "print_ver_.* $$prog" $$test \
570 || echo $$test should call: print_ver_ $$prog; \
571 done | grep . && exit 1 || :
573 # Use framework_failure_, not the old name without the trailing underscore.
574 sc_prohibit_framework_failure:
575 @prohibit='\<framework_''failure\>' \
576 halt='use framework_failure_ instead' \
577 $(_sc_search_regexp)
579 # Prohibit the use of `...` in tests/. Use $(...) instead.
580 sc_prohibit_test_backticks:
581 @prohibit='`' in_vc_files='^tests/' \
582 halt='use $$(...), not `...` in tests/' \
583 $(_sc_search_regexp)
585 # Ensure that compare is used to check empty files
586 # so that the unexpected contents are displayed
587 sc_prohibit_test_empty:
588 @prohibit='test -s.*&&' in_vc_files='^tests/' \
589 halt='use `compare /dev/null ...`, not `test -s ...` in tests/' \
590 $(_sc_search_regexp)
592 # Ensure that expr doesn't work directly on various unsigned int types,
593 # as that's not generally supported without GMP.
594 sc_prohibit_expr_unsigned:
595 @prohibit='expr .*(UINT|ULONG|[^S]SIZE|[UGP]ID|UINTMAX)' \
596 halt='avoid passing unsigned limits to `expr` (without GMP)' \
597 in_vc_files='^tests/' \
598 $(_sc_search_regexp)
600 # Programs like sort, ls, expr use PROG_FAILURE in place of EXIT_FAILURE.
601 # Others, use the EXIT_CANCELED, EXIT_ENOENT, etc. macros defined in system.h.
602 # In those programs, ensure that EXIT_FAILURE is not used by mistake.
603 sc_some_programs_must_avoid_exit_failure:
604 @grep -nw EXIT_FAILURE \
605 $$(git grep -El '[^T]_FAILURE|EXIT_CANCELED' $(srcdir)/src) \
606 | grep -vE '= EXIT_FAILURE|return .* \?' | grep . \
607 && { echo '$(ME): do not use EXIT_FAILURE in the above' \
608 1>&2; exit 1; } || :
610 # Ensure that tests call the get_min_ulimit_v_ function if using ulimit -v
611 sc_prohibit_test_ulimit_without_require_:
612 @(git grep -l get_min_ulimit_v_ $(srcdir)/tests; \
613 git grep -l 'ulimit -v' $(srcdir)/tests) \
614 | sort | uniq -u | grep . && { echo "$(ME): the above test(s)"\
615 " should match get_min_ulimit_v_ with ulimit -v" 1>&2; exit 1; } || :
617 # Ensure that tests call the cleanup_ function if using background processes
618 sc_prohibit_test_background_without_cleanup_:
619 @(git grep -El '( &$$|&[^&]*=\$$!)' $(srcdir)/tests; \
620 git grep -l 'cleanup_()' $(srcdir)/tests | sed p) \
621 | sort | uniq -u | grep . && { echo "$(ME): the above test(s)"\
622 " should use cleanup_ for background processes" 1>&2; exit 1; } || :
624 # Ensure that tests call the print_ver_ function for programs which are
625 # actually used in that test.
626 sc_prohibit_test_calls_print_ver_with_irrelevant_argument:
627 @git grep -w print_ver_ $(srcdir)/tests \
628 | sed 's#:print_ver_##' \
629 | { fail=0; \
630 while read file name; do \
631 for i in $$name; do \
632 case "$$i" in install) i=ginstall;; esac; \
633 grep -w "$$i" $$file|grep -vw print_ver_|grep -q . \
634 || { fail=1; \
635 echo "*** Test: $$file, offending: $$i." 1>&2; };\
636 done; \
637 done; \
638 test $$fail = 0 || exit 1; \
639 } || { echo "$(ME): the above test(s) call print_ver_ for" \
640 "program(s) they don't use" 1>&2; exit 1; }
642 # Exempt the contents of any usage function from the following.
643 _continued_string_col_1 = \
644 s/^usage .*?\n}//ms;/\\\n\w/ and print ("$$ARGV\n"),$$e=1;END{$$e||=0;exit $$e}
645 # Ding any source file that has a continued string with an alphabetic in the
646 # first column of the following line. We prohibit them because they usually
647 # trigger false positives in tools that try to map an arbitrary line number
648 # to the enclosing function name. Of course, very many strings do precisely
649 # this, *when they are part of the usage function*. That is why we exempt
650 # the contents of any function named "usage".
651 sc_prohibit_continued_string_alpha_in_column_1:
652 @perl -0777 -ne '$(_continued_string_col_1)' \
653 $$($(VC_LIST_EXCEPT) | grep '\.[ch]$$') \
654 || { echo '$(ME): continued string with word in first column' \
655 1>&2; exit 1; } || :
656 # Use this to list offending lines:
657 # git ls-files |grep '\.[ch]$' | xargs \
658 # perl -n -0777 -e 's/^usage.*?\n}//ms;/\\\n\w/ and print "$ARGV\n"' \
659 # | xargs grep -A1 '\\$'|grep '\.[ch][:-][_a-zA-Z]'
662 ###########################################################
663 _p0 = \([^"'/]\|"\([^\"]\|[\].\)*"\|'\([^\']\|[\].\)*'
664 _pre = $(_p0)\|[/][^"'/*]\|[/]"\([^\"]\|[\].\)*"\|[/]'\([^\']\|[\].\)*'\)*
665 _pre_anchored = ^\($(_pre)\)
666 _comment_and_close = [^*]\|[*][^/*]\)*[*][*]*/
667 # help font-lock mode: '
669 # A sed expression that removes ANSI C and ISO C99 comments.
670 # Derived from the one in GNU gettext's 'moopp' preprocessor.
671 _sed_remove_comments = \
672 /[/][/*]/{ \
673 ta; \
674 :a; \
675 s,$(_pre_anchored)//.*,\1,; \
676 te; \
677 s,$(_pre_anchored)/[*]\($(_comment_and_close),\1 ,; \
678 ta; \
679 /^$(_pre)[/][*]/{ \
680 s,$(_pre_anchored)/[*].*,\1 ,; \
681 tu; \
682 :u; \
683 n; \
684 s,^\($(_comment_and_close),,; \
685 tv; \
686 s,^.*$$,,; \
687 bu; \
688 :v; \
689 }; \
690 :e; \
692 # Quote all single quotes.
693 _sed_rm_comments_q = $(subst ','\'',$(_sed_remove_comments))
694 # help font-lock mode: '
696 _space_before_paren_exempt =? \\n\\$$
697 _space_before_paren_exempt = \
698 (^ *\#|\\n\\$$|%s\(to %s|(date|group|character)\(s\))
699 # Ensure that there is a space before each open parenthesis in C code.
700 sc_space_before_open_paren:
701 @if $(VC_LIST_EXCEPT) | grep -l '\.[ch]$$' > /dev/null; then \
702 fail=0; \
703 for c in $$($(VC_LIST_EXCEPT) | grep '\.[ch]$$'); do \
704 sed '$(_sed_rm_comments_q)' $$c 2>/dev/null \
705 | grep -i '[[:alnum:]](' \
706 | grep -vE '$(_space_before_paren_exempt)' \
707 | grep . && { fail=1; echo "*** $$c"; }; \
708 done; \
709 test $$fail = 1 && \
710 { echo '$(ME): the above files lack a space-before-open-paren' \
711 1>&2; exit 1; } || :; \
712 else :; \
715 # Similar to the gnulib maint.mk rule for sc_prohibit_strcmp
716 # Use STREQ_LEN or STRPREFIX rather than comparing strncmp == 0, or != 0.
717 sc_prohibit_strncmp:
718 @prohibit='^[^#].*str''ncmp *\(' \
719 halt='use STREQ_LEN or STRPREFIX instead of str''ncmp' \
720 $(_sc_search_regexp)
722 # Enforce recommended preprocessor indentation style.
723 sc_preprocessor_indentation:
724 @if cppi --version >/dev/null 2>&1; then \
725 $(VC_LIST_EXCEPT) | grep '\.[ch]$$' | xargs cppi -a -c \
726 || { echo '$(ME): incorrect preprocessor indentation' 1>&2; \
727 exit 1; }; \
728 else \
729 echo '$(ME): skipping test $@: cppi not installed' 1>&2; \
732 # THANKS.in is a list of name/email pairs for people who are mentioned in
733 # commit logs (and generated ChangeLog), but who are not also listed as an
734 # author of a commit. Name/email pairs of commit authors are automatically
735 # extracted from the repository. As a very minor factorization, when
736 # someone who was initially listed only in THANKS.in later authors a commit,
737 # this rule detects that their pair may now be removed from THANKS.in.
738 sc_THANKS_in_duplicates:
739 @{ git log --pretty=format:%aN | sort -u; \
740 cut -b-36 $(srcdir)/THANKS.in \
741 | sed '/^$$/,/^$$/!d;/^$$/d;s/ *$$//'; } \
742 | sort | uniq -d | grep . \
743 && { echo '$(ME): remove the above names from THANKS.in' \
744 1>&2; exit 1; } || :
746 # Ensure the contributor list stays sorted. However, if the system's
747 # en_US.UTF-8 locale data is erroneous, give a diagnostic and skip
748 # this test. This affects OS X, up to at least 10.11.6.
749 # Use our sort as other implementations may result in a different order.
750 sc_THANKS_in_sorted:
751 @printf 'a\n.b\n'|LC_ALL=en_US.UTF-8 src/sort -c 2> /dev/null \
752 && { \
753 sed '/^$$/,/^$$/!d;/^$$/d' $(srcdir)/THANKS.in > $@.1 && \
754 LC_ALL=en_US.UTF-8 src/sort -f -k1,1 $@.1 > $@.2 && \
755 diff -u $@.1 $@.2; diff=$$?; \
756 rm -f $@.1 $@.2; \
757 test "$$diff" = 0 \
758 || { echo '$(ME): THANKS.in is unsorted' 1>&2; exit 1; }; \
760 || { echo '$(ME): this system has erroneous locale data;' \
761 'skipping $@' 1>&2; }
763 # Look for developer diagnostics that are marked for translation.
764 # This won't find any for which devmsg's format string is on a separate line.
765 sc_marked_devdiagnostics:
766 @prohibit='\<devmsg *\(.*_\(' \
767 halt='found marked developer diagnostic(s)' \
768 $(_sc_search_regexp)
770 # Ensure we keep hex constants as 4 or 8 bytes for consistency
771 # and so that make src/fs-magic-compare works consistently
772 sc_fs-magic-compare:
773 @sed -n 's|.*/\* \(0x[0-9A-Fa-f]\{1,\}\) .*\*/|\1|p' \
774 $(srcdir)/src/stat.c | grep -Ev '^0x([0-9A-F]{4}){1,2}$$' \
775 && { echo '$(ME): Constants in src/stat.c should be 4 or 8' \
776 'upper-case chars' 1>&2; exit 1; } || :
778 # Ensure gnulib generated files are ignored
779 # TODO: Perhaps augment gnulib-tool to do this in lib/.gitignore?
780 sc_gitignore_missing:
781 @{ sed -n '/^\/lib\/.*\.h$$/{p;p}' $(srcdir)/.gitignore; \
782 find lib -name '*.in*' ! -name '*~' ! -name 'sys_*' | \
783 sed 's|^|/|; s|_\(.*in\.h\)|/\1|; s/\.in//'; } | \
784 sort | uniq -u | grep . && { echo '$(ME): Add above' \
785 'entries to .gitignore' >&2; exit 1; } || :
787 # Flag redundant entries in .gitignore
788 sc_gitignore_redundant:
789 @{ grep ^/lib $(srcdir)/.gitignore; \
790 sed 's|^|/lib|' $(srcdir)/lib/.gitignore; } | \
791 sort | uniq -d | grep . && { echo '$(ME): Remove above' \
792 'entries from .gitignore' >&2; exit 1; } || :
794 sc_prohibit-form-feed:
795 @prohibit=$$'\f' \
796 in_vc_files='\.[chly]$$' \
797 halt='Form Feed (^L) detected' \
798 $(_sc_search_regexp)
800 # Override the default Cc: used in generating an announcement.
801 announcement_Cc_ = $(translation_project_), \
802 coreutils@gnu.org, coreutils-announce@gnu.org
804 -include $(srcdir)/dist-check.mk
806 update-copyright-env = \
807 UPDATE_COPYRIGHT_FORCE=1 \
808 UPDATE_COPYRIGHT_USE_INTERVALS=2 \
809 UPDATE_COPYRIGHT_MAX_LINE_LENGTH=79
811 # List syntax-check exemptions.
812 exclude_file_name_regexp--sc_space_tab = \
813 ^(tests/pr/|tests/misc/nl\.sh$$|gl/.*\.diff$$|man/help2man$$)
814 exclude_file_name_regexp--sc_bindtextdomain = \
815 ^(gl/.*|lib/euidaccess-stat|src/make-prime-list)\.c$$
816 exclude_file_name_regexp--sc_trailing_blank = \
817 ^(tests/pr/|gl/.*\.diff$$|man/help2man)
818 exclude_file_name_regexp--sc_system_h_headers = \
819 ^src/((die|system|copy)\.h|make-prime-list\.c)$$
821 _src = (false|lbracket|ls-(dir|ls|vdir)|tac-pipe|uname-(arch|uname))
822 exclude_file_name_regexp--sc_require_config_h_first = \
823 (^lib/buffer-lcm\.c|gl/lib/xdecto.max\.c|src/$(_src)\.c)$$
824 exclude_file_name_regexp--sc_require_config_h = \
825 $(exclude_file_name_regexp--sc_require_config_h_first)
827 exclude_file_name_regexp--sc_po_check = ^(gl/|man/help2man)
828 exclude_file_name_regexp--sc_prohibit_always-defined_macros = \
829 ^src/(seq|remove)\.c$$
830 exclude_file_name_regexp--sc_prohibit_empty_lines_at_EOF = ^tests/pr/
831 exclude_file_name_regexp--sc_program_name = \
832 ^(gl/.*|lib/euidaccess-stat|src/make-prime-list)\.c$$
833 exclude_file_name_regexp--sc_file_system = \
834 NEWS|^(init\.cfg|src/df\.c|tests/df/df-P\.sh|tests/df/df-output\.sh)$$
835 exclude_file_name_regexp--sc_prohibit_always_true_header_tests = \
836 ^m4/stat-prog\.m4$$
837 exclude_file_name_regexp--sc_prohibit_fail_0 = \
838 (^.*/git-hooks/commit-msg|^tests/init\.sh|Makefile\.am|\.mk|.*\.texi)$$
839 exclude_file_name_regexp--sc_prohibit_test_minus_ao = *\.texi$$
840 exclude_file_name_regexp--sc_prohibit_atoi_atof = ^lib/euidaccess-stat\.c$$
842 # longlong.h is maintained elsewhere.
843 _ll = ^src/longlong\.h$$
844 exclude_file_name_regexp--sc_useless_cpp_parens = $(_ll)
845 exclude_file_name_regexp--sc_space_before_open_paren = $(_ll)
847 tbi_1 = ^tests/pr/|(\.mk|^man/help2man)$$
848 tbi_2 = ^scripts/git-hooks/(pre-commit|pre-applypatch|applypatch-msg)$$
849 tbi_3 = (GNU)?[Mm]akefile(\.am)?$$|$(_ll)
850 exclude_file_name_regexp--sc_prohibit_tab_based_indentation = \
851 $(tbi_1)|$(tbi_2)|$(tbi_3)
853 exclude_file_name_regexp--sc_preprocessor_indentation = \
854 ^(gl/lib/rand-isaac\.[ch]|gl/tests/test-rand-isaac\.c)$$|$(_ll)
855 exclude_file_name_regexp--sc_prohibit_stat_st_blocks = \
856 ^(src/system\.h|tests/du/2g\.sh)$$
858 exclude_file_name_regexp--sc_prohibit_continued_string_alpha_in_column_1 = \
859 ^src/(system\.h|od\.c|printf\.c|getlimits\.c)$$
861 exclude_file_name_regexp--sc_prohibit_test_backticks = \
862 ^tests/(local\.mk|(init|misc/stdbuf|factor/create-test)\.sh)$$
864 # Exempt test.c, since it's nominally shared, and relatively static.
865 exclude_file_name_regexp--sc_prohibit_operator_at_end_of_line = \
866 ^src/(ptx|test|head)\.c$$
868 exclude_file_name_regexp--sc_error_message_uppercase = ^src/factor\.c$$
869 exclude_file_name_regexp--sc_prohibit_atoi_atof = ^src/make-prime-list\.c$$
871 # Exception here as we don't want __attribute elided on non GCC
872 exclude_file_name_regexp--sc_prohibit-gl-attributes = ^src/libstdbuf\.c$$
874 exclude_file_name_regexp--sc_prohibit_uppercase_id_est = \.diff$$
875 exclude_file_name_regexp--sc_ensure_dblspace_after_dot_before_id_est = \.diff$$
876 exclude_file_name_regexp--sc_ensure_comma_after_id_est = \.diff|$(_ll)$$
877 exclude_file_name_regexp--sc_long_lines = \.diff$$|$(_ll)
879 # Augment AM_CFLAGS to include our per-directory options:
880 AM_CFLAGS += $($(@D)_CFLAGS)
882 src_CFLAGS = $(WARN_CFLAGS)
883 lib_CFLAGS = $(GNULIB_WARN_CFLAGS)
884 gnulib-tests_CFLAGS = $(GNULIB_TEST_WARN_CFLAGS)
886 # Configuration to make the tight-scope syntax-check rule work with
887 # non-recursive make.
888 # Note _gl_TS_headers use _single line_ extern function declarations,
889 # while *_SOURCES use the _two line_ form.
890 export _gl_TS_headers = $(noinst_HEADERS)
891 # Add exceptions for --enable-single-binary renamed functions.
892 _gl_TS_unmarked_extern_functions = main usage
893 _gl_TS_unmarked_extern_functions += single_binary_main_.* _usage_.*
894 # Headers to search for single line extern _data_ declarations.
895 _gl_TS_other_headers = $(srcdir)/src/*.h src/*.h
896 # Tell the tight_scope rule about an exceptional "extern" variable.
897 # Normally, the rule would detect its declaration, but that uses a
898 # different name, __clz_tab.
899 _gl_TS_unmarked_extern_vars = factor_clz_tab
900 # Other tight_scope settings
901 _gl_TS_dir = .
902 _gl_TS_obj_files = src/*.$(OBJEXT)