tests: fix periodic false failure in month alignment
[coreutils.git] / cfg.mk
blob875fbaadd97603911c379e790c78a094654f2a9b
1 # Customize maint.mk -*- makefile -*-
2 # Copyright (C) 2003-2018 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 <https://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 = https://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 = 48668bce5e01bf434b1d1ff10d141884
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 # - urls
324 # - the help2man script copied from upstream,
325 # - tests involving long checksum lines, and
326 # - the 'pr' test cases.
327 FILTER_LONG_LINES = \
328 \|^[^:]*NEWS:.*https\{,1\}://| d; \
329 \|^[^:]*man/help2man:| d; \
330 \|^[^:]*tests/misc/sha[0-9]*sum.*\.pl[-:]| d; \
331 \|^[^:]*tests/pr/|{ \|^[^:]*tests/pr/pr-tests:| !d; };
332 sc_long_lines:
333 @wc -L /dev/null >/dev/null 2>/dev/null \
334 || { echo "$@: skipping: wc -L not supported"; exit 0; }; \
335 sed -r 1q /dev/null 2>/dev/null \
336 || { echo "$@: skipping: sed -r not supported"; exit 0; }; \
337 files=$$($(VC_LIST_EXCEPT) | xargs wc -L | sed -rn '/ total$$/d;\
338 s/^ *(8[1-9]|9[0-9]|[0-9]{3,}) //p'); \
339 halt='line(s) with more than 80 characters; reindent'; \
340 for file in $$files; do \
341 expand $$file | grep -nE '^.{80}.' | \
342 sed -e "s|^|$$file:|" -e '$(FILTER_LONG_LINES)'; \
343 done | grep . && { msg="$$halt" $(_sc_say_and_exit) } || :
345 # Option descriptions should not start with a capital letter.
346 # One could grep source directly as follows:
347 # grep -E " {2,6}-.*[^.] [A-Z][a-z]" $$($(VC_LIST_EXCEPT) | grep '\.c$$')
348 # but that would miss descriptions not on the same line as the -option.
349 sc_option_desc_uppercase: $(ALL_MANS)
350 @grep '^\\fB\\-' -A1 man/*.1 | LC_ALL=C grep '\.1.[A-Z][a-z]' \
351 && { echo 1>&2 '$@: found initial capitals in --help'; exit 1; } || :
353 # Ensure all man/*.[1x] files are present.
354 sc_man_file_correlation: check-x-vs-1 check-programs-vs-x
356 # Ensure that for each .x file in the 'man/' subdirectory, there is a
357 # corresponding .1 file in the definition of $(EXTRA_MANS).
358 # But since that expansion usually lacks programs like arch and hostname,
359 # add them here manually.
360 .PHONY: check-x-vs-1
361 check-x-vs-1:
362 @PATH=./src$(PATH_SEPARATOR)$$PATH; export PATH; \
363 t=$@-t; \
364 (cd $(srcdir)/man && ls -1 *.x) \
365 | sed 's/\.x$$//' | $(ASSORT) > $$t; \
366 (echo $(patsubst man/%,%,$(ALL_MANS)) \
367 | tr -s ' ' '\n' | sed 's/\.1$$//') \
368 | $(ASSORT) -u | diff - $$t || { rm $$t; exit 1; }; \
369 rm $$t
371 # Ensure that non-trivial .x files in the 'man/' subdirectory,
372 # i.e., files exceeding a line count of 20 or a byte count of 1000,
373 # contain a Copyright notice.
374 .PHONY: sc_man_check_x_copyright
375 sc_man_check_x_copyright:
376 @status=0; \
377 cd $(srcdir) && wc -cl man/*.x | head -n-1 \
378 | awk '$$1 >= 20 || $$2 >= 1000 {print $$3}' \
379 | xargs grep -L 'Copyright .* Free Software Foundation' \
380 | grep . \
381 && { echo 1>&2 '$@: exceeding file size/line count limit' \
382 '- please add a copyright note'; status=1; }; \
383 exit $$status
385 # Writing a portable rule to generate a manpage like '[.1' would be
386 # a nightmare, so filter that out.
387 all-progs-but-lbracket = $(filter-out [,$(patsubst src/%,%,$(all_programs)))
389 # Ensure that for each coreutils program there is a corresponding
390 # '.x' file in the 'man/' subdirectory.
391 .PHONY: check-programs-vs-x
392 check-programs-vs-x:
393 @status=0; \
394 for p in dummy $(all-progs-but-lbracket); do \
395 case $$p in *.so) continue;; esac; \
396 test $$p = dummy && continue; \
397 test $$p = ginstall && p=install || : ; \
398 test -f $(srcdir)/man/$$p.x \
399 || { echo missing $$p.x 1>&2; status=1; }; \
400 done; \
401 exit $$status
403 # Ensure we can check out on case insensitive file systems
404 sc_case_insensitive_file_names: src/uniq
405 @git ls-files | sort -f | src/uniq -Di | grep . && \
406 { echo "$(ME): the above file(s) conflict on case insensitive" \
407 " file systems" 1>&2; exit 1; } || :
409 # Ensure that the end of each release's section is marked by two empty lines.
410 sc_NEWS_two_empty_lines:
411 @sed -n 4,/Noteworthy/p $(srcdir)/NEWS \
412 | perl -n0e '/(^|\n)\n\n\* Noteworthy/ or exit 1' \
413 || { echo '$(ME): use two empty lines to separate NEWS sections' \
414 1>&2; exit 1; } || :
416 # With split lines, don't leave an operator at end of line.
417 # Instead, put it on the following line, where it is more apparent.
418 # Don't bother checking for "*" at end of line, since it provokes
419 # far too many false positives, matching constructs like "TYPE *".
420 # Similarly, omit "=" (initializers).
421 binop_re_ ?= [-/+^!<>]|[-/+*^!<>=]=|&&?|\|\|?|<<=?|>>=?
422 sc_prohibit_operator_at_end_of_line:
423 @prohibit='. ($(binop_re_))$$' \
424 in_vc_files='\.[chly]$$' \
425 halt='found operator at end of line' \
426 $(_sc_search_regexp)
428 # Don't use "readlink" or "readlinkat" directly
429 sc_prohibit_readlink:
430 @prohibit='\<readlink(at)? \(' \
431 halt='do not use readlink(at); use via xreadlink or areadlink*' \
432 $(_sc_search_regexp)
434 # Don't use address of "stat" or "lstat" functions
435 sc_prohibit_stat_macro_address:
436 @prohibit='\<l?stat '':|&l?stat\>' \
437 halt='stat() and lstat() may be function-like macros' \
438 $(_sc_search_regexp)
440 # Ensure that date's --help output stays in sync with the info
441 # documentation for GNU strftime. The only exception is %N and %q,
442 # which date accepts but GNU strftime does not.
443 extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/'
444 sc_strftime_check:
445 @if test -f $(srcdir)/src/date.c; then \
446 grep '^ %. ' $(srcdir)/src/date.c | sort \
447 | $(extract_char) > $@-src; \
448 { echo N; echo q; \
449 info libc date calendar format 2>/dev/null \
450 | grep "^ *['\`]%.'$$"| $(extract_char); }| sort >$@-info;\
451 if test $$(stat --format %s $@-info) != 2; then \
452 diff -u $@-src $@-info || exit 1; \
453 else \
454 echo '$(ME): skipping $@: libc info not installed' 1>&2; \
455 fi; \
456 rm -f $@-src $@-info; \
459 # Indent only with spaces.
460 sc_prohibit_tab_based_indentation:
461 @prohibit='^ * ' \
462 halt='TAB in indentation; use only spaces' \
463 $(_sc_search_regexp)
465 # Enforce lowercase 'e' in "I.e.".
466 sc_prohibit_uppercase_id_est:
467 @prohibit='I\.E\.' \
468 halt='Uppercase "Id Est" abbreviation; use "I.e.," instead' \
469 $(_sc_search_regexp)
471 # Enforce double-space before "I.e." at the beginning of a sentence.
472 sc_ensure_dblspace_after_dot_before_id_est:
473 @prohibit='\. I\.e\.' \
474 halt='Single space after dot before "i.e."; use ". i.e." instead' \
475 $(_sc_search_regexp)
477 # Enforce comma after "i.e." (at least before a blank or at EOL).
478 sc_ensure_comma_after_id_est:
479 @prohibit='[Ii]\.e\.( |$$)' \
480 halt='Missing comma after "i.e."; use "i.e.," instead' \
481 $(_sc_search_regexp)
483 # The SEE ALSO section of a man page should not be terminated with
484 # a period. Check the first line after each "SEE ALSO" line in man/*.x:
485 sc_prohibit_man_see_also_period:
486 @grep -nB1 '\.$$' $$($(VC_LIST_EXCEPT) | grep 'man/.*\.x$$') \
487 | grep -A1 -e '-\[SEE ALSO\]' | grep '\.$$' && \
488 { echo '$(ME): do not end "SEE ALSO" section with a period' \
489 1>&2; exit 1; } || :
491 # Don't use "indent-tabs-mode: nil" anymore. No longer needed.
492 sc_prohibit_emacs__indent_tabs_mode__setting:
493 @prohibit='^( *[*#] *)?indent-tabs-mode:' \
494 halt='use of emacs indent-tabs-mode: setting' \
495 $(_sc_search_regexp)
497 # Ensure that tests don't include a redundant fail=0.
498 sc_prohibit_fail_0:
499 @prohibit='\<fail=0\>' \
500 halt='fail=0 initialization' \
501 $(_sc_search_regexp)
503 # Ensure that tests don't use `cmd ... && fail=1` as that hides crashes.
504 # The "exclude" expression allows common idioms like `test ... && fail=1`
505 # and the 2>... portion allows commands that redirect stderr and so probably
506 # independently check its contents and thus detect any crash messages.
507 sc_prohibit_and_fail_1:
508 @prohibit='&& fail=1' \
509 exclude='(returns_|stat|kill|test |EGREP|grep|compare|2> *[^/])' \
510 halt='&& fail=1 detected. Please use: returns_ 1 ... || fail=1' \
511 in_vc_files='^tests/' \
512 $(_sc_search_regexp)
514 # Ensure that env vars are not passed through returns_ as
515 # that was seen to fail on FreeBSD /bin/sh at least
516 sc_prohibit_env_returns:
517 @prohibit='=[^ ]* returns_ ' \
518 exclude='_ returns_ ' \
519 halt='Passing env vars to returns_ is non portable' \
520 in_vc_files='^tests/' \
521 $(_sc_search_regexp)
523 # The mode part of a setfacl -m option argument must be three bytes long.
524 # I.e., an argument of user:bin:rw or user:bin:r will make Solaris 10's
525 # setfacl reject it with: "Unrecognized character found in mode field".
526 # Use hyphens to give it a length of 3: "...:rw-" or "...:r--".
527 sc_prohibit_short_facl_mode_spec:
528 @prohibit='\<setfacl .*-m.*:.*:[rwx-]{1,2} ' \
529 halt='setfacl mode string length < 3; extend with hyphen(s)' \
530 $(_sc_search_regexp)
532 # Ensure that "stdio--.h" is used where appropriate.
533 sc_require_stdio_safer:
534 @if $(VC_LIST_EXCEPT) | grep -l '\.[ch]$$' > /dev/null; then \
535 files=$$(grep -l '\bfreopen \?(' $$($(VC_LIST_EXCEPT) \
536 | grep '\.[ch]$$')); \
537 test -n "$$files" && grep -LE 'include "stdio--.h"' $$files \
538 | grep . && \
539 { echo '$(ME): the above files should use "stdio--.h"' \
540 1>&2; exit 1; } || :; \
541 else :; \
544 sc_prohibit_perl_hash_quotes:
545 @prohibit="\{'[A-Z_]+' *[=}]" \
546 halt="in Perl code, write \$$hash{KEY}, not \$$hash{'K''EY'}" \
547 $(_sc_search_regexp)
549 # Prefer xnanosleep over other less-precise sleep methods
550 sc_prohibit_sleep:
551 @prohibit='\<(nano|u)?sleep \(' \
552 halt='prefer xnanosleep over other sleep interfaces' \
553 $(_sc_search_regexp)
555 # Use print_ver_ (from init.cfg), not open-coded $VERBOSE check.
556 sc_prohibit_verbose_version:
557 @prohibit='test "\$$VERBOSE" = yes && .* --version' \
558 halt='use the print_ver_ function instead...' \
559 $(_sc_search_regexp)
561 # Enforce print_ver_ tracking of dependencies
562 # Each coreutils specific program a test requires
563 # should be tagged by calling through env(1).
564 sc_env_test_dependencies:
565 @cd $(top_srcdir) && GIT_PAGER= git grep -E \
566 "env ($$(build-aux/gen-lists-of-programs.sh --list-progs | \
567 grep -vF '[' |paste -d'|' -s))" tests | \
568 sed "s/\([^:]\):.*env \([^)' ]*\).*/\1 \2/" | uniq | \
569 while read test prog; do \
570 printf '%s' $$test | grep -q '\.pl$$' && continue; \
571 grep -q "print_ver_.* $$prog" $$test \
572 || echo $$test should call: print_ver_ $$prog; \
573 done | grep . && exit 1 || :
575 # Use framework_failure_, not the old name without the trailing underscore.
576 sc_prohibit_framework_failure:
577 @prohibit='\<framework_''failure\>' \
578 halt='use framework_failure_ instead' \
579 $(_sc_search_regexp)
581 # Prohibit the use of `...` in tests/. Use $(...) instead.
582 sc_prohibit_test_backticks:
583 @prohibit='`' in_vc_files='^tests/' \
584 halt='use $$(...), not `...` in tests/' \
585 $(_sc_search_regexp)
587 # Ensure that compare is used to check empty files
588 # so that the unexpected contents are displayed
589 sc_prohibit_test_empty:
590 @prohibit='test -s.*&&' in_vc_files='^tests/' \
591 halt='use `compare /dev/null ...`, not `test -s ...` in tests/' \
592 $(_sc_search_regexp)
594 # Ensure that expr doesn't work directly on various unsigned int types,
595 # as that's not generally supported without GMP.
596 sc_prohibit_expr_unsigned:
597 @prohibit='expr .*(UINT|ULONG|[^S]SIZE|[UGP]ID|UINTMAX)' \
598 halt='avoid passing unsigned limits to `expr` (without GMP)' \
599 in_vc_files='^tests/' \
600 $(_sc_search_regexp)
602 # Programs like sort, ls, expr use PROG_FAILURE in place of EXIT_FAILURE.
603 # Others, use the EXIT_CANCELED, EXIT_ENOENT, etc. macros defined in system.h.
604 # In those programs, ensure that EXIT_FAILURE is not used by mistake.
605 sc_some_programs_must_avoid_exit_failure:
606 @grep -nw EXIT_FAILURE \
607 $$(git grep -El '[^T]_FAILURE|EXIT_CANCELED' $(srcdir)/src) \
608 | grep -vE '= EXIT_FAILURE|return .* \?' | grep . \
609 && { echo '$(ME): do not use EXIT_FAILURE in the above' \
610 1>&2; exit 1; } || :
612 # Ensure that tests call the get_min_ulimit_v_ function if using ulimit -v
613 sc_prohibit_test_ulimit_without_require_:
614 @(git grep -l get_min_ulimit_v_ $(srcdir)/tests; \
615 git grep -l 'ulimit -v' $(srcdir)/tests) \
616 | sort | uniq -u | grep . && { echo "$(ME): the above test(s)"\
617 " should match get_min_ulimit_v_ with ulimit -v" 1>&2; exit 1; } || :
619 # Ensure that tests call the cleanup_ function if using background processes
620 sc_prohibit_test_background_without_cleanup_:
621 @(git grep -El '( &$$|&[^&]*=\$$!)' $(srcdir)/tests; \
622 git grep -l 'cleanup_()' $(srcdir)/tests | sed p) \
623 | sort | uniq -u | grep . && { echo "$(ME): the above test(s)"\
624 " should use cleanup_ for background processes" 1>&2; exit 1; } || :
626 # Ensure that tests call the print_ver_ function for programs which are
627 # actually used in that test.
628 sc_prohibit_test_calls_print_ver_with_irrelevant_argument:
629 @git grep -w print_ver_ $(srcdir)/tests \
630 | sed 's#:print_ver_##' \
631 | { fail=0; \
632 while read file name; do \
633 for i in $$name; do \
634 case "$$i" in install) i=ginstall;; esac; \
635 grep -w "$$i" $$file|grep -vw print_ver_|grep -q . \
636 || { fail=1; \
637 echo "*** Test: $$file, offending: $$i." 1>&2; };\
638 done; \
639 done; \
640 test $$fail = 0 || exit 1; \
641 } || { echo "$(ME): the above test(s) call print_ver_ for" \
642 "program(s) they don't use" 1>&2; exit 1; }
644 # Exempt the contents of any usage function from the following.
645 _continued_string_col_1 = \
646 s/^usage .*?\n}//ms;/\\\n\w/ and print ("$$ARGV\n"),$$e=1;END{$$e||=0;exit $$e}
647 # Ding any source file that has a continued string with an alphabetic in the
648 # first column of the following line. We prohibit them because they usually
649 # trigger false positives in tools that try to map an arbitrary line number
650 # to the enclosing function name. Of course, very many strings do precisely
651 # this, *when they are part of the usage function*. That is why we exempt
652 # the contents of any function named "usage".
653 sc_prohibit_continued_string_alpha_in_column_1:
654 @perl -0777 -ne '$(_continued_string_col_1)' \
655 $$($(VC_LIST_EXCEPT) | grep '\.[ch]$$') \
656 || { echo '$(ME): continued string with word in first column' \
657 1>&2; exit 1; } || :
658 # Use this to list offending lines:
659 # git ls-files |grep '\.[ch]$' | xargs \
660 # perl -n -0777 -e 's/^usage.*?\n}//ms;/\\\n\w/ and print "$ARGV\n"' \
661 # | xargs grep -A1 '\\$'|grep '\.[ch][:-][_a-zA-Z]'
664 ###########################################################
665 _p0 = \([^"'/]\|"\([^\"]\|[\].\)*"\|'\([^\']\|[\].\)*'
666 _pre = $(_p0)\|[/][^"'/*]\|[/]"\([^\"]\|[\].\)*"\|[/]'\([^\']\|[\].\)*'\)*
667 _pre_anchored = ^\($(_pre)\)
668 _comment_and_close = [^*]\|[*][^/*]\)*[*][*]*/
669 # help font-lock mode: '
671 # A sed expression that removes ANSI C and ISO C99 comments.
672 # Derived from the one in GNU gettext's 'moopp' preprocessor.
673 _sed_remove_comments = \
674 /[/][/*]/{ \
675 ta; \
676 :a; \
677 s,$(_pre_anchored)//.*,\1,; \
678 te; \
679 s,$(_pre_anchored)/[*]\($(_comment_and_close),\1 ,; \
680 ta; \
681 /^$(_pre)[/][*]/{ \
682 s,$(_pre_anchored)/[*].*,\1 ,; \
683 tu; \
684 :u; \
685 n; \
686 s,^\($(_comment_and_close),,; \
687 tv; \
688 s,^.*$$,,; \
689 bu; \
690 :v; \
691 }; \
692 :e; \
694 # Quote all single quotes.
695 _sed_rm_comments_q = $(subst ','\'',$(_sed_remove_comments))
696 # help font-lock mode: '
698 _space_before_paren_exempt =? \\n\\$$
699 _space_before_paren_exempt = \
700 (^ *\#|\\n\\$$|%s\(to %s|(date|group|character)\(s\))
701 # Ensure that there is a space before each open parenthesis in C code.
702 sc_space_before_open_paren:
703 @if $(VC_LIST_EXCEPT) | grep -l '\.[ch]$$' > /dev/null; then \
704 fail=0; \
705 for c in $$($(VC_LIST_EXCEPT) | grep '\.[ch]$$'); do \
706 sed '$(_sed_rm_comments_q)' $$c 2>/dev/null \
707 | grep -i '[[:alnum:]](' \
708 | grep -vE '$(_space_before_paren_exempt)' \
709 | grep . && { fail=1; echo "*** $$c"; }; \
710 done; \
711 test $$fail = 1 && \
712 { echo '$(ME): the above files lack a space-before-open-paren' \
713 1>&2; exit 1; } || :; \
714 else :; \
717 # Similar to the gnulib maint.mk rule for sc_prohibit_strcmp
718 # Use STREQ_LEN or STRPREFIX rather than comparing strncmp == 0, or != 0.
719 sc_prohibit_strncmp:
720 @prohibit='^[^#].*str''ncmp *\(' \
721 halt='use STREQ_LEN or STRPREFIX instead of str''ncmp' \
722 $(_sc_search_regexp)
724 # Enforce recommended preprocessor indentation style.
725 sc_preprocessor_indentation:
726 @if cppi --version >/dev/null 2>&1; then \
727 $(VC_LIST_EXCEPT) | grep '\.[ch]$$' | xargs cppi -a -c \
728 || { echo '$(ME): incorrect preprocessor indentation' 1>&2; \
729 exit 1; }; \
730 else \
731 echo '$(ME): skipping test $@: cppi not installed' 1>&2; \
734 # THANKS.in is a list of name/email pairs for people who are mentioned in
735 # commit logs (and generated ChangeLog), but who are not also listed as an
736 # author of a commit. Name/email pairs of commit authors are automatically
737 # extracted from the repository. As a very minor factorization, when
738 # someone who was initially listed only in THANKS.in later authors a commit,
739 # this rule detects that their pair may now be removed from THANKS.in.
740 sc_THANKS_in_duplicates:
741 @{ git log --pretty=format:%aN | sort -u; \
742 cut -b-36 $(srcdir)/THANKS.in \
743 | sed '/^$$/,/^$$/!d;/^$$/d;s/ *$$//'; } \
744 | sort | uniq -d | grep . \
745 && { echo '$(ME): remove the above names from THANKS.in' \
746 1>&2; exit 1; } || :
748 # Ensure the contributor list stays sorted. However, if the system's
749 # en_US.UTF-8 locale data is erroneous, give a diagnostic and skip
750 # this test. This affects OS X, up to at least 10.11.6.
751 # Use our sort as other implementations may result in a different order.
752 sc_THANKS_in_sorted:
753 @printf 'a\n.b\n'|LC_ALL=en_US.UTF-8 src/sort -c 2> /dev/null \
754 && { \
755 sed '/^$$/,/^$$/!d;/^$$/d' $(srcdir)/THANKS.in > $@.1 && \
756 LC_ALL=en_US.UTF-8 src/sort -f -k1,1 $@.1 > $@.2 && \
757 diff -u $@.1 $@.2; diff=$$?; \
758 rm -f $@.1 $@.2; \
759 test "$$diff" = 0 \
760 || { echo '$(ME): THANKS.in is unsorted' 1>&2; exit 1; }; \
762 || { echo '$(ME): this system has erroneous locale data;' \
763 'skipping $@' 1>&2; }
765 # Look for developer diagnostics that are marked for translation.
766 # This won't find any for which devmsg's format string is on a separate line.
767 sc_marked_devdiagnostics:
768 @prohibit='\<devmsg *\(.*_\(' \
769 halt='found marked developer diagnostic(s)' \
770 $(_sc_search_regexp)
772 # Ensure we keep hex constants as 4 or 8 bytes for consistency
773 # and so that make src/fs-magic-compare works consistently
774 sc_fs-magic-compare:
775 @sed -n 's|.*/\* \(0x[0-9A-Fa-f]\{1,\}\) .*\*/|\1|p' \
776 $(srcdir)/src/stat.c | grep -Ev '^0x([0-9A-F]{4}){1,2}$$' \
777 && { echo '$(ME): Constants in src/stat.c should be 4 or 8' \
778 'upper-case chars' 1>&2; exit 1; } || :
780 # Ensure gnulib generated files are ignored
781 # TODO: Perhaps augment gnulib-tool to do this in lib/.gitignore?
782 sc_gitignore_missing:
783 @{ sed -n '/^\/lib\/.*\.h$$/{p;p}' $(srcdir)/.gitignore; \
784 find lib -name '*.in*' ! -name '*~' ! -name 'sys_*' | \
785 sed 's|^|/|; s|_\(.*in\.h\)|/\1|; s/\.in//'; } | \
786 sort | uniq -u | grep . && { echo '$(ME): Add above' \
787 'entries to .gitignore' >&2; exit 1; } || :
789 # Flag redundant entries in .gitignore
790 sc_gitignore_redundant:
791 @{ grep ^/lib $(srcdir)/.gitignore; \
792 sed 's|^|/lib|' $(srcdir)/lib/.gitignore; } | \
793 sort | uniq -d | grep . && { echo '$(ME): Remove above' \
794 'entries from .gitignore' >&2; exit 1; } || :
796 sc_prohibit-form-feed:
797 @prohibit=$$'\f' \
798 in_vc_files='\.[chly]$$' \
799 halt='Form Feed (^L) detected' \
800 $(_sc_search_regexp)
802 # Override the default Cc: used in generating an announcement.
803 announcement_Cc_ = $(translation_project_), \
804 coreutils@gnu.org, coreutils-announce@gnu.org
806 -include $(srcdir)/dist-check.mk
808 update-copyright-env = \
809 UPDATE_COPYRIGHT_FORCE=1 \
810 UPDATE_COPYRIGHT_USE_INTERVALS=2 \
811 UPDATE_COPYRIGHT_MAX_LINE_LENGTH=79
813 # List syntax-check exemptions.
814 exclude_file_name_regexp--sc_space_tab = \
815 ^(tests/pr/|tests/misc/nl\.sh$$|gl/.*\.diff$$|man/help2man$$)
816 exclude_file_name_regexp--sc_bindtextdomain = \
817 ^(gl/.*|lib/euidaccess-stat|src/make-prime-list)\.c$$
818 exclude_file_name_regexp--sc_trailing_blank = \
819 ^(tests/pr/|gl/.*\.diff$$|man/help2man)
820 exclude_file_name_regexp--sc_system_h_headers = \
821 ^src/((die|system|copy)\.h|make-prime-list\.c)$$
823 _src = (false|lbracket|ls-(dir|ls|vdir)|tac-pipe|uname-(arch|uname))
824 exclude_file_name_regexp--sc_require_config_h_first = \
825 (^lib/buffer-lcm\.c|gl/lib/xdecto.max\.c|src/$(_src)\.c)$$
826 exclude_file_name_regexp--sc_require_config_h = \
827 $(exclude_file_name_regexp--sc_require_config_h_first)
829 exclude_file_name_regexp--sc_po_check = ^(gl/|man/help2man)
830 exclude_file_name_regexp--sc_prohibit_always-defined_macros = \
831 ^src/(seq|remove)\.c$$
832 exclude_file_name_regexp--sc_prohibit_empty_lines_at_EOF = ^tests/pr/
833 exclude_file_name_regexp--sc_program_name = \
834 ^(gl/.*|lib/euidaccess-stat|src/make-prime-list)\.c$$
835 exclude_file_name_regexp--sc_file_system = \
836 NEWS|^(init\.cfg|src/df\.c|tests/df/df-P\.sh|tests/df/df-output\.sh)$$
837 exclude_file_name_regexp--sc_prohibit_always_true_header_tests = \
838 ^m4/stat-prog\.m4$$
839 exclude_file_name_regexp--sc_prohibit_fail_0 = \
840 (^.*/git-hooks/commit-msg|^tests/init\.sh|Makefile\.am|\.mk|.*\.texi)$$
841 exclude_file_name_regexp--sc_prohibit_test_minus_ao = *\.texi$$
842 exclude_file_name_regexp--sc_prohibit_atoi_atof = ^lib/euidaccess-stat\.c$$
844 # longlong.h is maintained elsewhere.
845 _ll = ^src/longlong\.h$$
846 exclude_file_name_regexp--sc_useless_cpp_parens = $(_ll)
847 exclude_file_name_regexp--sc_space_before_open_paren = $(_ll)
849 tbi_1 = ^tests/pr/|(\.mk|^man/help2man)$$
850 tbi_2 = ^scripts/git-hooks/(pre-commit|pre-applypatch|applypatch-msg)$$
851 tbi_3 = (GNU)?[Mm]akefile(\.am)?$$|$(_ll)
852 exclude_file_name_regexp--sc_prohibit_tab_based_indentation = \
853 $(tbi_1)|$(tbi_2)|$(tbi_3)
855 exclude_file_name_regexp--sc_preprocessor_indentation = \
856 ^(gl/lib/rand-isaac\.[ch]|gl/tests/test-rand-isaac\.c)$$|$(_ll)
857 exclude_file_name_regexp--sc_prohibit_stat_st_blocks = \
858 ^(src/system\.h|tests/du/2g\.sh)$$
860 exclude_file_name_regexp--sc_prohibit_continued_string_alpha_in_column_1 = \
861 ^src/(system\.h|od\.c|printf\.c|getlimits\.c)$$
863 exclude_file_name_regexp--sc_prohibit_test_backticks = \
864 ^tests/(local\.mk|(init|misc/stdbuf|factor/create-test)\.sh)$$
866 # Exempt test.c, since it's nominally shared, and relatively static.
867 exclude_file_name_regexp--sc_prohibit_operator_at_end_of_line = \
868 ^src/(ptx|test|head)\.c$$
870 exclude_file_name_regexp--sc_error_message_uppercase = ^src/factor\.c$$
871 exclude_file_name_regexp--sc_prohibit_atoi_atof = ^src/make-prime-list\.c$$
873 # Exception here as we don't want __attribute elided on non GCC
874 exclude_file_name_regexp--sc_prohibit-gl-attributes = ^src/libstdbuf\.c$$
876 exclude_file_name_regexp--sc_prohibit_uppercase_id_est = \.diff$$
877 exclude_file_name_regexp--sc_ensure_dblspace_after_dot_before_id_est = \.diff$$
878 exclude_file_name_regexp--sc_ensure_comma_after_id_est = \.diff|$(_ll)$$
879 exclude_file_name_regexp--sc_long_lines = \.diff$$|$(_ll)
881 # Augment AM_CFLAGS to include our per-directory options:
882 AM_CFLAGS += $($(@D)_CFLAGS)
884 src_CFLAGS = $(WARN_CFLAGS)
885 lib_CFLAGS = $(GNULIB_WARN_CFLAGS)
886 gnulib-tests_CFLAGS = $(GNULIB_TEST_WARN_CFLAGS)
888 # Configuration to make the tight-scope syntax-check rule work with
889 # non-recursive make.
890 # Note _gl_TS_headers use _single line_ extern function declarations,
891 # while *_SOURCES use the _two line_ form.
892 export _gl_TS_headers = $(noinst_HEADERS)
893 # Add exceptions for --enable-single-binary renamed functions.
894 _gl_TS_unmarked_extern_functions = main usage
895 _gl_TS_unmarked_extern_functions += single_binary_main_.* _usage_.*
896 # Headers to search for single line extern _data_ declarations.
897 _gl_TS_other_headers = $(srcdir)/src/*.h src/*.h
898 # Tell the tight_scope rule about an exceptional "extern" variable.
899 # Normally, the rule would detect its declaration, but that uses a
900 # different name, __clz_tab.
901 _gl_TS_unmarked_extern_vars = factor_clz_tab
902 # Other tight_scope settings
903 _gl_TS_dir = .
904 _gl_TS_obj_files = src/*.$(OBJEXT)