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