doc: standardize messages about the '-' stdin FILE
[coreutils.git] / cfg.mk
blob4f222f630271b4b47e49ff2fd1d3028fbcc16af9
1 # Customize maint.mk -*- makefile -*-
2 # Copyright (C) 2003-2015 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 = 41e5c3133f5d8947e2ff13aab58fc52b
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` | sort > $$t1; \
99 for t in $(all_root_tests); do echo $$t; done | sort > $$t2; \
100 st=0; diff -u $$t1 $$t2 || st=1; \
101 rm -f $$t1 $$t2; \
102 exit $$st
104 # Ensure that all version-controlled test cases are listed in $(all_tests).
105 sc_tests_list_consistency:
106 @bs="\\"; \
107 test_extensions_rx=`echo $(TEST_EXTENSIONS) \
108 | sed -e "s/ /|/g" -e "s/$$bs./$$bs$$bs./g"`; \
110 for t in $(all_tests); do echo $$t; done; \
111 cd $(top_srcdir); \
112 $(SHELL) build-aux/vc-list-files tests \
113 | grep -Ev '^tests/(factor/(run|create-test)|init)\.sh$$' \
114 | $(EGREP) "$$test_extensions_rx\$$"; \
115 } | sort | uniq -u | grep . && exit 1; :
117 # Ensure that all version-controlled test scripts are executable.
118 sc_tests_executable:
119 @set -o noglob 2>/dev/null || set -f; \
120 find_ext="-name '' "`printf -- "-o -name *%s " $(TEST_EXTENSIONS)`;\
121 find tests/ \( $$find_ext \) \! -perm -u+x -print \
122 | sed -e "s/^/$(ME): Please make test executable: /" | grep . \
123 && exit 1; :
125 # Ensure all gnulib patches apply cleanly
126 sc_ensure_gl_diffs_apply_cleanly:
127 @find gl/ -name '*.diff' | while read p; do \
128 patch --fuzz=0 -f -s -d gnulib/ -p1 --dry-run < "$$p" >&2 \
129 || { echo "$$p" >&2; echo 'To refresh all gl patches run:' \
130 'make refresh-gnulib-patches' >&2; exit 1; } \
131 done
133 # Avoid :>file which doesn't propagate errors
134 sc_prohibit_colon_redirection:
135 @cd $(srcdir)/tests && GIT_PAGER= git grep -n ': *>.*||' \
136 && { echo '$(ME): '"The leading colon in :> will hide errors" 1>&2; \
137 exit 1; } \
138 || :
140 # Create a list of regular expressions matching the names
141 # of files included from system.h. Exclude a couple.
142 .re-list:
143 @sed -n '/^# *include /s///p' $(srcdir)/src/system.h \
144 | grep -Ev 'sys/(param|file)\.h' \
145 | sed 's/ .*//;;s/^["<]/^# *include [<"]/;s/\.h[">]$$/\\.h[">]/' \
146 > $@-t
147 @mv $@-t $@
149 define gl_trap_
150 Exit () { set +e; (exit $$1); exit $$1; }; \
151 for sig in 1 2 3 13 15; do \
152 eval "trap 'Exit $$(expr $$sig + 128)' $$sig"; \
153 done
154 endef
156 # Files in src/ should not include directly any of
157 # the headers already included via system.h.
158 sc_system_h_headers: .re-list
159 @if test -f $(srcdir)/src/system.h; then \
160 trap 'rc=$$?; rm -f .re-list; exit $$rc' 0; \
161 $(gl_trap_); \
162 grep -nE -f .re-list \
163 $$($(VC_LIST_EXCEPT) | grep '^\($(srcdir)/\)\?src/') \
164 && { echo '$(ME): the above are already included via system.h'\
165 1>&2; exit 1; } || :; \
168 # Files in src/ should not use '%s' notation in format strings,
169 # i.e., single quotes around %s (or similar) should be avoided.
170 sc_prohibit_quotes_notation:
171 @cd $(srcdir)/src && GIT_PAGER= git grep -n "\".*[\`']%s'.*\"" *.c \
172 && { echo '$(ME): '"Use quote() to avoid quoted '%s' notation" 1>&2; \
173 exit 1; } \
174 || :
176 sc_sun_os_names:
177 @grep -nEi \
178 'solaris[^[:alnum:]]*2\.(7|8|9|[1-9][0-9])|sunos[^[:alnum:]][6-9]' \
179 $$($(VC_LIST_EXCEPT)) && \
180 { echo '$(ME): found misuse of Sun OS version numbers' 1>&2; \
181 exit 1; } || :
183 # Ensure that the list of programs and author names is accurate.
184 # We need a UTF8 locale. If a lack of locale support or a missing
185 # translation inhibits printing of UTF-8 names, just skip this test.
186 au_dotdot = authors-dotdot
187 au_actual = authors-actual
188 sc_check-AUTHORS: $(all_programs)
189 @locale=en_US.UTF-8; \
190 LC_ALL=$$locale ./src/cat --version \
191 | grep ' Torbjorn ' > /dev/null \
192 && { echo "$@: skipping this check"; exit 0; }; \
193 rm -f $(au_actual) $(au_dotdot); \
194 for i in `ls $(all_programs) \
195 | sed -e 's,^src/,,' -e 's,$(EXEEXT)$$,,' \
196 | sed /libstdbuf/d \
197 | $(ASSORT) -u`; do \
198 test "$$i" = '[' && continue; \
199 exe=$$i; \
200 if test "$$i" = install; then \
201 exe=ginstall; \
202 elif test "$$i" = test; then \
203 exe='['; \
204 fi; \
205 LC_ALL=$$locale ./src/$$exe --version \
206 | perl -0 -p -e 's/,\n/, /gm' \
207 | sed -n -e '/Written by /{ s//'"$$i"': /;' \
208 -e 's/,* and /, /; s/\.$$//; p; }'; \
209 done > $(au_actual) && \
210 sed -n '/^[^ ][^ ]*:/p' $(srcdir)/AUTHORS > $(au_dotdot) \
211 && diff $(au_actual) $(au_dotdot) \
212 && rm -f $(au_actual) $(au_dotdot)
214 # Each program with a non-ASCII author name must link with LIBICONV.
215 sc_check-I18N-AUTHORS:
216 @cd $(srcdir)/src && \
217 for i in $$(git grep -l -w proper_name_utf8 *.c|sed 's/\.c//'); do \
218 grep -E "^src_$${i}_LDADD"' .?= .*\$$\(LIBICONV\)' local.mk \
219 > /dev/null \
220 || { echo "$(ME): link rules for $$i do not include" \
221 '$$(LIBICONV)' 1>&2; exit 1; }; \
222 done
224 # Disallow the C99 printf size specifiers %z and %j as they're not portable.
225 # The gnulib printf replacement does support them, however the printf
226 # replacement is not currently explicitly depended on by the gnulib error()
227 # module for example. Also we use fprintf() in a few places to output simple
228 # formats but don't use the gnulib module as it is seen as overkill at present.
229 # We'd have to adjust the above gnulib items before disabling this.
230 sc_prohibit-c99-printf-format:
231 @cd $(srcdir)/src && GIT_PAGER= git grep -n '%[0*]*[jz][udx]' *.c \
232 && { echo '$(ME): Use PRI*MAX instead of %j or %z' 1>&2; exit 1; } \
233 || :
235 # Ensure the alternative __attribute (keyword) form isn't used as
236 # that form is not elided where required. Also ensure that we don't
237 # directly use attributes already defined by gnulib.
238 # TODO: move the check for _GL... attributes to gnulib.
239 sc_prohibit-gl-attributes:
240 @prohibit='__attribute |__(unused|pure|const)__' \
241 in_vc_files='\.[ch]$$' \
242 halt='Use _GL... attribute macros' \
243 $(_sc_search_regexp)
245 # Look for lines longer than 80 characters, except omit:
246 # - program-generated long lines in diff headers,
247 # - the help2man script copied from upstream,
248 # - tests involving long checksum lines, and
249 # - the 'pr' test cases.
250 FILTER_LONG_LINES = \
251 \|^[^:]*man/help2man:| d; \
252 \|^[^:]*tests/misc/sha[0-9]*sum.*\.pl[-:]| d; \
253 \|^[^:]*tests/pr/|{ \|^[^:]*tests/pr/pr-tests:| !d; };
254 sc_long_lines:
255 @wc -L /dev/null >/dev/null 2>/dev/null \
256 || { echo "$@: skipping: wc -L not supported"; exit 0; }; \
257 sed -r 1q /dev/null 2>/dev/null \
258 || { echo "$@: skipping: sed -r not supported"; exit 0; }; \
259 files=$$($(VC_LIST_EXCEPT) | xargs wc -L | sed -rn '/ total$$/d;\
260 s/^ *(8[1-9]|9[0-9]|[0-9]\{3,\}) //p'); \
261 halt='line(s) with more than 80 characters; reindent'; \
262 for file in $$files; do \
263 expand $$file | grep -nE '^.{80}.' | \
264 sed -e "s|^|$$file:|" -e '$(FILTER_LONG_LINES)'; \
265 done | grep . && { msg="$$halt" $(_sc_say_and_exit) } || :
267 # Option descriptions should not start with a capital letter.
268 # One could grep source directly as follows:
269 # grep -E " {2,6}-.*[^.] [A-Z][a-z]" $$($(VC_LIST_EXCEPT) | grep '\.c$$')
270 # but that would miss descriptions not on the same line as the -option.
271 sc_option_desc_uppercase: $(ALL_MANS)
272 @grep '^\\fB\\-' -A1 man/*.1 | LC_ALL=C grep '\.1.[A-Z][a-z]' \
273 && { echo 1>&2 '$@: found initial capitals in --help'; exit 1; } || :
275 # Ensure all man/*.[1x] files are present.
276 sc_man_file_correlation: check-x-vs-1 check-programs-vs-x
278 # Ensure that for each .x file in the 'man/' subdirectory, there is a
279 # corresponding .1 file in the definition of $(EXTRA_MANS).
280 # But since that expansion usually lacks programs like arch and hostname,
281 # add them here manually.
282 .PHONY: check-x-vs-1
283 check-x-vs-1:
284 @PATH=./src$(PATH_SEPARATOR)$$PATH; export PATH; \
285 t=$@-t; \
286 (cd $(srcdir)/man && ls -1 *.x) \
287 | sed 's/\.x$$//' | $(ASSORT) > $$t; \
288 (echo $(patsubst man/%,%,$(ALL_MANS)) \
289 | tr -s ' ' '\n' | sed 's/\.1$$//') \
290 | $(ASSORT) -u | diff - $$t || { rm $$t; exit 1; }; \
291 rm $$t
293 # Writing a portable rule to generate a manpage like '[.1' would be
294 # a nightmare, so filter that out.
295 all-progs-but-lbracket = $(filter-out [,$(patsubst src/%,%,$(all_programs)))
297 # Ensure that for each coreutils program there is a corresponding
298 # '.x' file in the 'man/' subdirectory.
299 .PHONY: check-programs-vs-x
300 check-programs-vs-x:
301 @status=0; \
302 for p in dummy $(all-progs-but-lbracket); do \
303 case $$p in *.so) continue;; esac; \
304 test $$p = dummy && continue; \
305 test $$p = ginstall && p=install || : ; \
306 test -f $(srcdir)/man/$$p.x \
307 || { echo missing $$p.x 1>&2; status=1; }; \
308 done; \
309 exit $$status
311 # Ensure that the end of each release's section is marked by two empty lines.
312 sc_NEWS_two_empty_lines:
313 @sed -n 4,/Noteworthy/p $(srcdir)/NEWS \
314 | perl -n0e '/(^|\n)\n\n\* Noteworthy/ or exit 1' \
315 || { echo '$(ME): use two empty lines to separate NEWS sections' \
316 1>&2; exit 1; } || :
318 # With split lines, don't leave an operator at end of line.
319 # Instead, put it on the following line, where it is more apparent.
320 # Don't bother checking for "*" at end of line, since it provokes
321 # far too many false positives, matching constructs like "TYPE *".
322 # Similarly, omit "=" (initializers).
323 binop_re_ ?= [-/+^!<>]|[-/+*^!<>=]=|&&?|\|\|?|<<=?|>>=?
324 sc_prohibit_operator_at_end_of_line:
325 @prohibit='. ($(binop_re_))$$' \
326 in_vc_files='\.[chly]$$' \
327 halt='found operator at end of line' \
328 $(_sc_search_regexp)
330 # Don't use "readlink" or "readlinkat" directly
331 sc_prohibit_readlink:
332 @prohibit='\<readlink(at)? \(' \
333 halt='do not use readlink(at); use via xreadlink or areadlink*' \
334 $(_sc_search_regexp)
336 # Don't use address of "stat" or "lstat" functions
337 sc_prohibit_stat_macro_address:
338 @prohibit='\<l?stat '':|&l?stat\>' \
339 halt='stat() and lstat() may be function-like macros' \
340 $(_sc_search_regexp)
342 # Ensure that date's --help output stays in sync with the info
343 # documentation for GNU strftime. The only exception is %N,
344 # which date accepts but GNU strftime does not.
345 extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/'
346 sc_strftime_check:
347 @if test -f $(srcdir)/src/date.c; then \
348 grep '^ %. ' $(srcdir)/src/date.c | sort \
349 | $(extract_char) > $@-src; \
350 { echo N; \
351 info libc date calendar format 2>/dev/null \
352 | grep "^ *['\`]%.'$$"| $(extract_char); }| sort >$@-info;\
353 if test $$(stat --format %s $@-info) != 2; then \
354 diff -u $@-src $@-info || exit 1; \
355 else \
356 echo '$(ME): skipping $@: libc info not installed' 1>&2; \
357 fi; \
358 rm -f $@-src $@-info; \
361 # Indent only with spaces.
362 sc_prohibit_tab_based_indentation:
363 @prohibit='^ * ' \
364 halt='TAB in indentation; use only spaces' \
365 $(_sc_search_regexp)
367 # Enforce lowercase 'e' in "I.e.".
368 sc_prohibit_uppercase_id_est:
369 @prohibit='I\.E\.' \
370 halt='Uppercase "Id Est" abbreviation; use "I.e.," instead' \
371 $(_sc_search_regexp)
373 # Enforce double-space before "I.e." at the beginning of a sentence.
374 sc_ensure_dblspace_after_dot_before_id_est:
375 @prohibit='\. I\.e\.' \
376 halt='Single space after dot before "i.e."; use ". i.e." instead' \
377 $(_sc_search_regexp)
379 # Enforce comma after "i.e." (at least before a blank or at EOL).
380 sc_ensure_comma_after_id_est:
381 @prohibit='[Ii]\.e\.( |$$)' \
382 halt='Missing comma after "i.e."; use "i.e.," instead' \
383 $(_sc_search_regexp)
385 # The SEE ALSO section of a man page should not be terminated with
386 # a period. Check the first line after each "SEE ALSO" line in man/*.x:
387 sc_prohibit_man_see_also_period:
388 @grep -nB1 '\.$$' $$($(VC_LIST_EXCEPT) | grep 'man/.*\.x$$') \
389 | grep -A1 -e '-\[SEE ALSO\]' | grep '\.$$' && \
390 { echo '$(ME): do not end "SEE ALSO" section with a period' \
391 1>&2; exit 1; } || :
393 # Don't use "indent-tabs-mode: nil" anymore. No longer needed.
394 sc_prohibit_emacs__indent_tabs_mode__setting:
395 @prohibit='^( *[*#] *)?indent-tabs-mode:' \
396 halt='use of emacs indent-tabs-mode: setting' \
397 $(_sc_search_regexp)
399 # Ensure that tests don't include a redundant fail=0.
400 sc_prohibit_fail_0:
401 @prohibit='\<fail=0\>' \
402 halt='fail=0 initialization' \
403 $(_sc_search_regexp)
405 # Ensure that tests don't use `cmd ... && fail=1` as that hides crashes.
406 # The "exclude" expression allows common idioms like `test ... && fail=1`
407 # and the 2>... portion allows commands that redirect stderr and so probably
408 # independently check its contents and thus detect any crash messages.
409 sc_prohibit_and_fail_1:
410 @prohibit='&& fail=1' \
411 exclude='(stat|kill|test |EGREP|grep|env|compare|2> *[^/])' \
412 halt='&& fail=1 detected. Please use: returns_ 1 ... || fail=1' \
413 in_vc_files='^tests/' \
414 $(_sc_search_regexp)
416 # The mode part of a setfacl -m option argument must be three bytes long.
417 # I.e., an argument of user:bin:rw or user:bin:r will make Solaris 10's
418 # setfacl reject it with: "Unrecognized character found in mode field".
419 # Use hyphens to give it a length of 3: "...:rw-" or "...:r--".
420 sc_prohibit_short_facl_mode_spec:
421 @prohibit='\<setfacl .*-m.*:.*:[rwx-]{1,2} ' \
422 halt='setfacl mode string length < 3; extend with hyphen(s)' \
423 $(_sc_search_regexp)
425 # Ensure that "stdio--.h" is used where appropriate.
426 sc_require_stdio_safer:
427 @if $(VC_LIST_EXCEPT) | grep -l '\.[ch]$$' > /dev/null; then \
428 files=$$(grep -l '\bfreopen \?(' $$($(VC_LIST_EXCEPT) \
429 | grep '\.[ch]$$')); \
430 test -n "$$files" && grep -LE 'include "stdio--.h"' $$files \
431 | grep . && \
432 { echo '$(ME): the above files should use "stdio--.h"' \
433 1>&2; exit 1; } || :; \
434 else :; \
437 sc_prohibit_perl_hash_quotes:
438 @prohibit="\{'[A-Z_]+' *[=}]" \
439 halt="in Perl code, write \$$hash{KEY}, not \$$hash{'K''EY'}" \
440 $(_sc_search_regexp)
442 # Prefer xnanosleep over other less-precise sleep methods
443 sc_prohibit_sleep:
444 @prohibit='\<(nano|u)?sleep \(' \
445 halt='prefer xnanosleep over other sleep interfaces' \
446 $(_sc_search_regexp)
448 # Use print_ver_ (from init.cfg), not open-coded $VERBOSE check.
449 sc_prohibit_verbose_version:
450 @prohibit='test "\$$VERBOSE" = yes && .* --version' \
451 halt='use the print_ver_ function instead...' \
452 $(_sc_search_regexp)
454 # Use framework_failure_, not the old name without the trailing underscore.
455 sc_prohibit_framework_failure:
456 @prohibit='\<framework_''failure\>' \
457 halt='use framework_failure_ instead' \
458 $(_sc_search_regexp)
460 # Prohibit the use of `...` in tests/. Use $(...) instead.
461 sc_prohibit_test_backticks:
462 @prohibit='`' in_vc_files='^tests/' \
463 halt='use $$(...), not `...` in tests/' \
464 $(_sc_search_regexp)
466 # Ensure that compare is used to check empty files
467 # so that the unexpected contents are displayed
468 sc_prohibit_test_empty:
469 @prohibit='test -s.*&&' in_vc_files='^tests/' \
470 halt='use `compare /dev/null ...`, not `test -s ...` in tests/' \
471 $(_sc_search_regexp)
473 # Programs like sort, ls, expr use PROG_FAILURE in place of EXIT_FAILURE.
474 # Others, use the EXIT_CANCELED, EXIT_ENOENT, etc. macros defined in system.h.
475 # In those programs, ensure that EXIT_FAILURE is not used by mistake.
476 sc_some_programs_must_avoid_exit_failure:
477 @grep -nw EXIT_FAILURE \
478 $$(git grep -El '[^T]_FAILURE|EXIT_CANCELED' src) \
479 | grep -vE '= EXIT_FAILURE|return .* \?' | grep . \
480 && { echo '$(ME): do not use EXIT_FAILURE in the above' \
481 1>&2; exit 1; } || :
483 # Ensure that tests call the require_ulimit_v_ function if using ulimit -v
484 sc_prohibit_test_ulimit_without_require_:
485 @(git grep -l require_ulimit_v_ tests; \
486 git grep -l 'ulimit -v' tests) \
487 | sort | uniq -u | grep . && { echo "$(ME): the above test(s)"\
488 " should match require_ulimit_v_ with ulimit -v" 1>&2; exit 1; } || :
490 # Ensure that tests call the print_ver_ function for programs which are
491 # actually used in that test.
492 sc_prohibit_test_calls_print_ver_with_irrelevant_argument:
493 @git grep -w print_ver_ tests \
494 | sed 's#:print_ver_##' \
495 | { fail=0; \
496 while read file name; do \
497 for i in $$name; do \
498 case "$$i" in install) i=ginstall;; esac; \
499 grep -w "$$i" $$file|grep -vw print_ver_|grep -q . \
500 || { fail=1; \
501 echo "*** Test: $$file, offending: $$i." 1>&2; };\
502 done; \
503 done; \
504 test $$fail = 0 || exit 1; \
505 } || { echo "$(ME): the above test(s) call print_ver_ for" \
506 "program(s) they don't use" 1>&2; exit 1; }
508 # Exempt the contents of any usage function from the following.
509 _continued_string_col_1 = \
510 s/^usage .*?\n}//ms;/\\\n\w/ and print ("$$ARGV\n"),$$e=1;END{$$e||=0;exit $$e}
511 # Ding any source file that has a continued string with an alphabetic in the
512 # first column of the following line. We prohibit them because they usually
513 # trigger false positives in tools that try to map an arbitrary line number
514 # to the enclosing function name. Of course, very many strings do precisely
515 # this, *when they are part of the usage function*. That is why we exempt
516 # the contents of any function named "usage".
517 sc_prohibit_continued_string_alpha_in_column_1:
518 @perl -0777 -ne '$(_continued_string_col_1)' \
519 $$($(VC_LIST_EXCEPT) | grep '\.[ch]$$') \
520 || { echo '$(ME): continued string with word in first column' \
521 1>&2; exit 1; } || :
522 # Use this to list offending lines:
523 # git ls-files |grep '\.[ch]$' | xargs \
524 # perl -n -0777 -e 's/^usage.*?\n}//ms;/\\\n\w/ and print "$ARGV\n"' \
525 # | xargs grep -A1 '\\$'|grep '\.[ch][:-][_a-zA-Z]'
528 ###########################################################
529 _p0 = \([^"'/]\|"\([^\"]\|[\].\)*"\|'\([^\']\|[\].\)*'
530 _pre = $(_p0)\|[/][^"'/*]\|[/]"\([^\"]\|[\].\)*"\|[/]'\([^\']\|[\].\)*'\)*
531 _pre_anchored = ^\($(_pre)\)
532 _comment_and_close = [^*]\|[*][^/*]\)*[*][*]*/
533 # help font-lock mode: '
535 # A sed expression that removes ANSI C and ISO C99 comments.
536 # Derived from the one in GNU gettext's 'moopp' preprocessor.
537 _sed_remove_comments = \
538 /[/][/*]/{ \
539 ta; \
540 :a; \
541 s,$(_pre_anchored)//.*,\1,; \
542 te; \
543 s,$(_pre_anchored)/[*]\($(_comment_and_close),\1 ,; \
544 ta; \
545 /^$(_pre)[/][*]/{ \
546 s,$(_pre_anchored)/[*].*,\1 ,; \
547 tu; \
548 :u; \
549 n; \
550 s,^\($(_comment_and_close),,; \
551 tv; \
552 s,^.*$$,,; \
553 bu; \
554 :v; \
555 }; \
556 :e; \
558 # Quote all single quotes.
559 _sed_rm_comments_q = $(subst ','\'',$(_sed_remove_comments))
560 # help font-lock mode: '
562 _space_before_paren_exempt =? \\n\\$$
563 _space_before_paren_exempt = \
564 (^ *\#|\\n\\$$|%s\(to %s|(date|group|character)\(s\))
565 # Ensure that there is a space before each open parenthesis in C code.
566 sc_space_before_open_paren:
567 @if $(VC_LIST_EXCEPT) | grep -l '\.[ch]$$' > /dev/null; then \
568 fail=0; \
569 for c in $$($(VC_LIST_EXCEPT) | grep '\.[ch]$$'); do \
570 sed '$(_sed_rm_comments_q)' $$c 2>/dev/null \
571 | grep -i '[[:alnum:]](' \
572 | grep -vE '$(_space_before_paren_exempt)' \
573 | grep . && { fail=1; echo "*** $$c"; }; \
574 done; \
575 test $$fail = 1 && \
576 { echo '$(ME): the above files lack a space-before-open-paren' \
577 1>&2; exit 1; } || :; \
578 else :; \
581 # Similar to the gnulib maint.mk rule for sc_prohibit_strcmp
582 # Use STREQ_LEN or STRPREFIX rather than comparing strncmp == 0, or != 0.
583 sc_prohibit_strncmp:
584 @prohibit='^[^#].*str''ncmp *\(' \
585 halt='use STREQ_LEN or STRPREFIX instead of str''ncmp' \
586 $(_sc_search_regexp)
588 # Enforce recommended preprocessor indentation style.
589 sc_preprocessor_indentation:
590 @if cppi --version >/dev/null 2>&1; then \
591 $(VC_LIST_EXCEPT) | grep '\.[ch]$$' | xargs cppi -a -c \
592 || { echo '$(ME): incorrect preprocessor indentation' 1>&2; \
593 exit 1; }; \
594 else \
595 echo '$(ME): skipping test $@: cppi not installed' 1>&2; \
598 # THANKS.in is a list of name/email pairs for people who are mentioned in
599 # commit logs (and generated ChangeLog), but who are not also listed as an
600 # author of a commit. Name/email pairs of commit authors are automatically
601 # extracted from the repository. As a very minor factorization, when
602 # someone who was initially listed only in THANKS.in later authors a commit,
603 # this rule detects that their pair may now be removed from THANKS.in.
604 sc_THANKS_in_duplicates:
605 @{ git log --pretty=format:%aN | sort -u; \
606 cut -b-36 THANKS.in \
607 | sed '/^$$/,/^$$/!d;/^$$/d;s/ *$$//'; } \
608 | sort | uniq -d | grep . \
609 && { echo '$(ME): remove the above names from THANKS.in' \
610 1>&2; exit 1; } || :
612 # Ensure the contributor list stays sorted. Use our sort as other
613 # implementations may result in a different order.
614 sc_THANKS_in_sorted: $(srcdir)/src/sort
615 @sed '/^$$/,/^$$/!d;/^$$/d' THANKS.in > $@.1; \
616 LC_ALL=en_US.UTF-8 $(srcdir)/src/sort -f -k1,1 $@.1 > $@.2
617 @diff -u $@.1 $@.2; diff=$$?; \
618 rm -f $@.1 $@.2; \
619 test "$$diff" = 0 \
620 || { echo '$(ME): THANKS.in is unsorted' 1>&2; exit 1; }
622 # Look for developer diagnostics that are marked for translation.
623 # This won't find any for which devmsg's format string is on a separate line.
624 sc_marked_devdiagnostics:
625 @prohibit='\<devmsg *\(.*_\(' \
626 halt='found marked developer diagnostic(s)' \
627 $(_sc_search_regexp)
629 # Ensure we keep hex constants as 4 or 8 bytes for consistency
630 # and so that make src/fs-magic-compare works consistently
631 sc_fs-magic-compare:
632 @sed -n 's|.*/\* \(0x[0-9A-Fa-f]\{1,\}\) .*\*/|\1|p' \
633 $(srcdir)/src/stat.c | grep -Ev '^0x([0-9A-F]{4}){1,2}$$' \
634 && { echo '$(ME): Constants in src/stat.c should be 4 or 8' \
635 'upper-case chars' 1>&2; exit 1; } || :
637 # Override the default Cc: used in generating an announcement.
638 announcement_Cc_ = $(translation_project_), \
639 coreutils@gnu.org, coreutils-announce@gnu.org
641 -include $(srcdir)/dist-check.mk
643 update-copyright-env = \
644 UPDATE_COPYRIGHT_FORCE=1 \
645 UPDATE_COPYRIGHT_USE_INTERVALS=2 \
646 UPDATE_COPYRIGHT_MAX_LINE_LENGTH=79
648 # List syntax-check exemptions.
649 exclude_file_name_regexp--sc_space_tab = \
650 ^(tests/pr/|tests/misc/nl\.sh$$|gl/.*\.diff$$|man/help2man$$)
651 exclude_file_name_regexp--sc_bindtextdomain = \
652 ^(gl/.*|lib/euidaccess-stat|src/make-prime-list)\.c$$
653 exclude_file_name_regexp--sc_trailing_blank = ^(tests/pr/|man/help2man)
654 exclude_file_name_regexp--sc_system_h_headers = \
655 ^src/((system|copy)\.h|make-prime-list\.c)$$
657 _src = (false|lbracket|ls-(dir|ls|vdir)|tac-pipe|uname-(arch|uname))
658 exclude_file_name_regexp--sc_require_config_h_first = \
659 (^lib/buffer-lcm\.c|gl/lib/xdecto.max\.c|src/$(_src)\.c)$$
660 exclude_file_name_regexp--sc_require_config_h = \
661 $(exclude_file_name_regexp--sc_require_config_h_first)
663 exclude_file_name_regexp--sc_po_check = ^(gl/|man/help2man)
664 exclude_file_name_regexp--sc_prohibit_always-defined_macros = \
665 ^src/(seq|remove)\.c$$
666 exclude_file_name_regexp--sc_prohibit_empty_lines_at_EOF = ^tests/pr/
667 exclude_file_name_regexp--sc_program_name = \
668 ^(gl/.*|lib/euidaccess-stat|src/make-prime-list)\.c$$
669 exclude_file_name_regexp--sc_file_system = \
670 NEWS|^(init\.cfg|src/df\.c|tests/df/df-P\.sh|tests/df/df-output\.sh)$$
671 exclude_file_name_regexp--sc_prohibit_always_true_header_tests = \
672 ^m4/stat-prog\.m4$$
673 exclude_file_name_regexp--sc_prohibit_fail_0 = \
674 (^.*/git-hooks/commit-msg|^tests/init\.sh|Makefile\.am|\.mk|.*\.texi)$$
675 exclude_file_name_regexp--sc_prohibit_atoi_atof = ^lib/euidaccess-stat\.c$$
677 # longlong.h is maintained elsewhere.
678 _ll = ^src/longlong\.h$$
679 exclude_file_name_regexp--sc_useless_cpp_parens = $(_ll)
680 exclude_file_name_regexp--sc_space_before_open_paren = $(_ll)
682 tbi_1 = ^tests/pr/|(^gl/lib/reg.*\.c\.diff|\.mk|^man/help2man)$$
683 tbi_2 = ^scripts/git-hooks/(pre-commit|pre-applypatch|applypatch-msg)$$
684 tbi_3 = (GNU)?[Mm]akefile(\.am)?$$|$(_ll)
685 exclude_file_name_regexp--sc_prohibit_tab_based_indentation = \
686 $(tbi_1)|$(tbi_2)|$(tbi_3)
688 exclude_file_name_regexp--sc_preprocessor_indentation = \
689 ^(gl/lib/rand-isaac\.[ch]|gl/tests/test-rand-isaac\.c)$$|$(_ll)
690 exclude_file_name_regexp--sc_prohibit_stat_st_blocks = \
691 ^(src/system\.h|tests/du/2g\.sh)$$
693 exclude_file_name_regexp--sc_prohibit_continued_string_alpha_in_column_1 = \
694 ^src/(system\.h|od\.c|printf\.c|getlimits\.c)$$
696 exclude_file_name_regexp--sc_prohibit_test_backticks = \
697 ^tests/(local\.mk|(init|misc/stdbuf|factor/create-test)\.sh)$$
699 # Exempt test.c, since it's nominally shared, and relatively static.
700 exclude_file_name_regexp--sc_prohibit_operator_at_end_of_line = \
701 ^src/(ptx|test|head)\.c$$
703 exclude_file_name_regexp--sc_error_message_uppercase = ^src/factor\.c$$
704 exclude_file_name_regexp--sc_prohibit_atoi_atof = ^src/make-prime-list\.c$$
706 # Exception here as we don't want __attribute elided on non GCC
707 exclude_file_name_regexp--sc_prohibit-gl-attributes = ^src/libstdbuf\.c$$
709 exclude_file_name_regexp--sc_prohibit_uppercase_id_est = \.diff$$
710 exclude_file_name_regexp--sc_ensure_dblspace_after_dot_before_id_est = \.diff$$
711 exclude_file_name_regexp--sc_ensure_comma_after_id_est = \.diff|$(_ll)$$
712 exclude_file_name_regexp--sc_long_lines = \.diff$$|$(_ll)
714 # Augment AM_CFLAGS to include our per-directory options:
715 AM_CFLAGS += $($(@D)_CFLAGS)
717 src_CFLAGS = $(WARN_CFLAGS)
718 lib_CFLAGS = $(GNULIB_WARN_CFLAGS)
719 gnulib-tests_CFLAGS = $(GNULIB_TEST_WARN_CFLAGS)
721 # Configuration to make the tight-scope syntax-check rule work with
722 # non-recursive make.
723 export _gl_TS_headers = $(srcdir)/cfg.mk
724 _gl_TS_dir = .
725 _gl_TS_obj_files = src/*.$(OBJEXT)
726 _gl_TS_other_headers = src/*.h
728 # Tell the tight_scope rule about an exceptional "extern" variable.
729 # Normally, the rule would detect its declaration, but that uses a
730 # different name, __clz_tab.
731 _gl_TS_unmarked_extern_vars = factor_clz_tab