maint: remove anachronistic syntax-check
[platform/upstream/coreutils.git] / cfg.mk
1 # Customize maint.mk                           -*- makefile -*-
2 # Copyright (C) 2003-2012 Free Software Foundation, Inc.
3
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 # Used in maint.mk's web-manual rule
18 manual_title = Core GNU utilities
19
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)
23
24 # Tests not to run as part of "make distcheck".
25 local-checks-to-skip = \
26   sc_proper_name_utf8_requires_ICONV
27
28 # Tools used to bootstrap this package, used for "announcement".
29 bootstrap-tools = autoconf,automake,gnulib,bison
30
31 # Now that we have better tests, make this the default.
32 export VERBOSE = yes
33
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
47
48 old_NEWS_hash = a99128b9985b2e76bdcabf3e5d95ca1a
49
50 # Add an exemption for sc_makefile_at_at_check.
51 _makefile_at_at_check_exceptions = ' && !/^cu_install_program =/'
52
53 # Our help-version script is in a slightly different location.
54 _hv_file ?= $(srcdir)/tests/misc/help-version
55
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=1 || diff=;                          \
65         rm -f $@.1 $@.2;                                                \
66         test "$$diff"                                                   \
67           && { echo '$(ME): $(dd) has inconsistent O_ flag lists'>&2;   \
68                exit 1; } || :
69
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'         \
78               | wc --max-line-length);                          \
79         max=$$(sed -n '/^#define LONGEST_SYMBOL /s///p' $(dd_c) \
80               |tr -d '"' | wc --max-line-length);               \
81         if test "$$len" = "$$max"; then :; else                 \
82           echo 'dd.c: LONGEST_SYMBOL is not longest' 1>&2;      \
83           exit 1;                                               \
84         fi
85 endif
86
87 # Many m4 macros names once began with 'jm_'.
88 # On 2004-04-13, they were all changed to start with gl_ instead.
89 # Make sure that none are inadvertently reintroduced.
90 sc_prohibit_jm_in_m4:
91         @grep -nE 'jm_[A-Z]'                                            \
92                 $$($(VC_LIST) m4 |grep '\.m4$$'; echo /dev/null) &&     \
93             { echo '$(ME): do not use jm_ in m4 macro names'            \
94               1>&2; exit 1; } || :
95
96 # Ensure that each root-requiring test is run via the "check-root" rule.
97 sc_root_tests:
98         @if test -d tests \
99               && grep check-root tests/Makefile.am>/dev/null 2>&1; then \
100         t1=sc-root.expected; t2=sc-root.actual;                         \
101         grep -nl '^ *require_root_$$'                                   \
102           $$($(VC_LIST) tests) |sed s,tests/,, |sort > $$t1;            \
103         sed -n '/^root_tests =[  ]*\\$$/,/[^\]$$/p'                     \
104           $(srcdir)/tests/Makefile.am                                   \
105             | sed 's/^  *//;/^root_tests =/d'                           \
106             | tr -s '\012\\' '  ' | fmt -1 | sort > $$t2;               \
107         diff -u $$t1 $$t2 || diff=1 || diff=;                           \
108         rm -f $$t1 $$t2;                                                \
109         test "$$diff"                                                   \
110           && { echo 'tests/Makefile.am: missing check-root action'>&2;  \
111                exit 1; } || :;                                          \
112         fi
113
114 # Create a list of regular expressions matching the names
115 # of files included from system.h.  Exclude a couple.
116 .re-list:
117         @sed -n '/^# *include /s///p' $(srcdir)/src/system.h \
118           | grep -Ev 'sys/(param|file)\.h' \
119           | sed 's/ .*//;;s/^["<]/^# *include [<"]/;s/\.h[">]$$/\\.h[">]/' \
120           > $@-t
121         @mv $@-t $@
122
123 define gl_trap_
124   Exit () { set +e; (exit $$1); exit $$1; };                            \
125   for sig in 1 2 3 13 15; do                                            \
126     eval "trap 'Exit $$(expr $$sig + 128)' $$sig";                      \
127   done
128 endef
129
130 # Files in src/ should not include directly any of
131 # the headers already included via system.h.
132 sc_system_h_headers: .re-list
133         @if test -f $(srcdir)/src/system.h; then                        \
134           trap 'rc=$$?; rm -f .re-list; exit $$rc' 0;                   \
135           $(gl_trap_);                                                  \
136           grep -nE -f .re-list                                          \
137               $$($(VC_LIST_EXCEPT) | grep '^\($(srcdir)/\)\?src/')      \
138             && { echo '$(ME): the above are already included via system.h'\
139                   1>&2;  exit 1; } || :;                                \
140         fi
141
142 sc_sun_os_names:
143         @grep -nEi \
144             'solaris[^[:alnum:]]*2\.(7|8|9|[1-9][0-9])|sunos[^[:alnum:]][6-9]' \
145             $$($(VC_LIST_EXCEPT)) &&                                    \
146           { echo '$(ME): found misuse of Sun OS version numbers' 1>&2;  \
147             exit 1; } || :
148
149 # Ensure that the list of programs and author names is accurate.
150 # We need a UTF8 locale.  If a lack of locale support or a missing
151 # translation inhibits printing of UTF-8 names, just skip this test.
152 au_dotdot = authors-dotdot
153 au_actual = authors-actual
154 sc_check-AUTHORS: $(all_programs)
155         @locale=en_US.UTF-8;                            \
156         LC_ALL=$$locale ./src/cat --version             \
157             | grep ' Torbjorn ' > /dev/null             \
158           && { echo "$@: skipping this check"; exit 0; }; \
159         rm -f $(au_actual) $(au_dotdot);                \
160         for i in `ls $(all_programs)                    \
161             | sed -e 's,^src/,,' -e 's,$(EXEEXT)$$,,'   \
162             | sed /libstdbuf/d                          \
163             | $(ASSORT) -u`; do                         \
164           test "$$i" = '[' && continue;                 \
165           exe=$$i;                                      \
166           if test "$$i" = install; then                 \
167             exe=ginstall;                               \
168           elif test "$$i" = test; then                  \
169             exe='[';                                    \
170           fi;                                           \
171           LC_ALL=$$locale ./src/$$exe --version         \
172             | perl -0 -pi -e 's/,\n/, /gm'              \
173             | sed -n -e '/Written by /{ s//'"$$i"': /;' \
174                   -e 's/,* and /, /; s/\.$$//; p; }';   \
175         done > $(au_actual) &&                          \
176         sed -n '/^[^ ][^ ]*:/p' $(srcdir)/AUTHORS > $(au_dotdot) \
177           && diff $(au_actual) $(au_dotdot) \
178           && rm -f $(au_actual) $(au_dotdot)
179
180 # Look for lines longer than 80 characters, except omit:
181 # - program-generated long lines in diff headers,
182 # - tests involving long checksum lines, and
183 # - the 'pr' test cases.
184 LINE_LEN_MAX = 80
185 FILTER_LONG_LINES =                                             \
186   /^[^:]*\.diff:[^:]*:@@ / d;                                   \
187   \|^[^:]*tests/misc/sha[0-9]*sum.*\.pl[-:]| d;                 \
188   \|^[^:]*tests/pr/|{ \|^[^:]*tests/pr/pr-tests:| !d; };
189 sc_long_lines:
190         @files=$$($(VC_LIST_EXCEPT))                                    \
191         halt='line(s) with more than $(LINE_LEN_MAX) characters; reindent'; \
192         for file in $$files; do                                         \
193           expand $$file | grep -nE '^.{$(LINE_LEN_MAX)}.' |             \
194           sed -e "s|^|$$file:|" -e '$(FILTER_LONG_LINES)';              \
195         done | grep . && { msg="$$halt" $(_sc_say_and_exit) } || :
196
197 # Option descriptions should not start with a capital letter.
198 # One could grep source directly as follows:
199 # grep -E " {2,6}-.*[^.]  [A-Z][a-z]" $$($(VC_LIST_EXCEPT) | grep '\.c$$')
200 # but that would miss descriptions not on the same line as the -option.
201 sc_option_desc_uppercase: $(ALL_MANS)
202         @grep '^\\fB\\-' -A1 man/*.1 | LC_ALL=C grep '\.1.[A-Z][a-z]'   \
203           && { echo 1>&2 '$@: found initial capitals in --help'; exit 1; } || :
204
205 # Ensure all man/*.[1x] files are present.
206 sc_man_file_correlation: check-x-vs-1 check-programs-vs-x
207
208 # Ensure that for each .x file in the 'man/' subdirectory, there is a
209 # corresponding .1 file in the definition of $(EXTRA_MANS).
210 # But since that expansion usually lacks programs like arch and hostname,
211 # add them here manually.
212 .PHONY: check-x-vs-1
213 check-x-vs-1:
214         @PATH=./src$(PATH_SEPARATOR)$$PATH; export PATH;                \
215         t=$@-t;                                                         \
216         (cd $(srcdir)/man && ls -1 *.x)                                 \
217           | sed 's/\.x$$//' | $(ASSORT) > $$t;                          \
218         (echo $(patsubst man/%,%,$(ALL_MANS))                           \
219           | tr -s ' ' '\n' | sed 's/\.1$$//')                           \
220           | $(ASSORT) -u | diff - $$t || { rm $$t; exit 1; };           \
221         rm $$t
222
223 # Writing a portable rule to generate a manpage like '[.1' would be
224 # a nightmare, so filter that out.
225 all-progs-but-lbracket = $(filter-out [,$(patsubst src/%,%,$(all_programs)))
226
227 # Ensure that for each coreutils program there is a corresponding
228 # '.x' file in the 'man/' subdirectory.
229 .PHONY: check-programs-vs-x
230 check-programs-vs-x:
231         @status=0;                                      \
232         for p in dummy $(all-progs-but-lbracket); do    \
233           case $$p in *.so) continue;; esac;            \
234           test $$p = dummy && continue;                 \
235           test $$p = ginstall && p=install || : ;       \
236           test -f $(srcdir)/man/$$p.x                   \
237             || { echo missing $$p.x 1>&2; status=1; };  \
238         done;                                           \
239         exit $$status
240
241 # Ensure that the end of each release's section is marked by two empty lines.
242 sc_NEWS_two_empty_lines:
243         @sed -n 4,/Noteworthy/p $(srcdir)/NEWS                          \
244             | perl -n0e '/(^|\n)\n\n\* Noteworthy/ or exit 1'           \
245           || { echo '$(ME): use two empty lines to separate NEWS sections' \
246                  1>&2; exit 1; } || :
247
248 # With split lines, don't leave an operator at end of line.
249 # Instead, put it on the following line, where it is more apparent.
250 # Don't bother checking for "*" at end of line, since it provokes
251 # far too many false positives, matching constructs like "TYPE *".
252 # Similarly, omit "=" (initializers).
253 binop_re_ ?= [-/+^!<>]|[-/+*^!<>=]=|&&?|\|\|?|<<=?|>>=?
254 sc_prohibit_operator_at_end_of_line:
255         @prohibit='. ($(binop_re_))$$'                                  \
256         in_vc_files='\.[chly]$$'                                        \
257         halt='found operator at end of line'                            \
258           $(_sc_search_regexp)
259
260 # Don't use "readlink" or "readlinkat" directly
261 sc_prohibit_readlink:
262         @prohibit='\<readlink(at)? \('                                  \
263         halt='do not use readlink(at); use via xreadlink or areadlink*' \
264           $(_sc_search_regexp)
265
266 # Don't use address of "stat" or "lstat" functions
267 sc_prohibit_stat_macro_address:
268         @prohibit='\<l?stat '':|&l?stat\>'                              \
269         halt='stat() and lstat() may be function-like macros'           \
270           $(_sc_search_regexp)
271
272 # Ensure that date's --help output stays in sync with the info
273 # documentation for GNU strftime.  The only exception is %N,
274 # which date accepts but GNU strftime does not.
275 extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/'
276 sc_strftime_check:
277         @if test -f $(srcdir)/src/date.c; then                          \
278           grep '^  %.  ' $(srcdir)/src/date.c | sort                    \
279             | $(extract_char) > $@-src;                                 \
280           { echo N;                                                     \
281             info libc date calendar format 2>/dev/null|grep '^    `%.'\'\
282               | $(extract_char); } | sort > $@-info;                    \
283           if test $$(stat --format %s $@-info) != 2; then               \
284             diff -u $@-src $@-info || exit 1;                           \
285           else                                                          \
286             echo '$(ME): skipping $@: libc info not installed' 1>&2;    \
287           fi;                                                           \
288           rm -f $@-src $@-info;                                         \
289         fi
290
291 # Indent only with spaces.
292 sc_prohibit_tab_based_indentation:
293         @prohibit='^ *  '                                               \
294         halt='TAB in indentation; use only spaces'                      \
295           $(_sc_search_regexp)
296
297 # The SEE ALSO section of a man page should not be terminated with
298 # a period.  Check the first line after each "SEE ALSO" line in man/*.x:
299 sc_prohibit_man_see_also_period:
300         @grep -nB1 '\.$$' $$($(VC_LIST_EXCEPT) | grep 'man/.*\.x$$')    \
301             | grep -A1 -e '-\[SEE ALSO\]' | grep '\.$$' &&              \
302           { echo '$(ME): do not end "SEE ALSO" section with a period'   \
303               1>&2; exit 1; } || :
304
305 # Don't use "indent-tabs-mode: nil" anymore.  No longer needed.
306 sc_prohibit_emacs__indent_tabs_mode__setting:
307         @prohibit='^( *[*#] *)?indent-tabs-mode:'                       \
308         halt='use of emacs indent-tabs-mode: setting'                   \
309           $(_sc_search_regexp)
310
311 # Ensure that tests don't include a redundant fail=0.
312 sc_prohibit_fail_0:
313         @prohibit='\<fail=0\>'                                          \
314         halt='fail=0 initialization'                                    \
315           $(_sc_search_regexp)
316
317 # The mode part of a setfacl -m option argument must be three bytes long.
318 # I.e., an argument of user:bin:rw or user:bin:r will make Solaris 10's
319 # setfacl reject it with: "Unrecognized character found in mode field".
320 # Use hyphens to give it a length of 3: "...:rw-" or "...:r--".
321 sc_prohibit_short_facl_mode_spec:
322         @prohibit='\<setfacl .*-m.*:.*:[rwx-]{1,2} '                    \
323         halt='setfacl mode string length < 3; extend with hyphen(s)'    \
324           $(_sc_search_regexp)
325
326 # Ensure that "stdio--.h" is used where appropriate.
327 sc_require_stdio_safer:
328         @if $(VC_LIST_EXCEPT) | grep -l '\.[ch]$$' > /dev/null; then    \
329           files=$$(grep -l '\bfreopen \?(' $$($(VC_LIST_EXCEPT)         \
330               | grep '\.[ch]$$'));                                      \
331           test -n "$$files" && grep -LE 'include "stdio--.h"' $$files   \
332               | grep . &&                                               \
333           { echo '$(ME): the above files should use "stdio--.h"'        \
334                 1>&2; exit 1; } || :;                                   \
335         else :;                                                         \
336         fi
337
338 sc_prohibit_perl_hash_quotes:
339         @prohibit="\{'[A-Z_]+' *[=}]"                                   \
340         halt="in Perl code, write \$$hash{KEY}, not \$$hash{'K''EY'}"   \
341           $(_sc_search_regexp)
342
343 # Prefer xnanosleep over other less-precise sleep methods
344 sc_prohibit_sleep:
345         @prohibit='\<(nano|u)?sleep \('                                 \
346         halt='prefer xnanosleep over other sleep interfaces'            \
347           $(_sc_search_regexp)
348
349 # Use print_ver_ (from init.cfg), not open-coded $VERBOSE check.
350 sc_prohibit_verbose_version:
351         @prohibit='test "\$$VERBOSE" = yes && .* --version'             \
352         halt='use the print_ver_ function instead...'                   \
353           $(_sc_search_regexp)
354
355 # Use framework_failure_, not the old name without the trailing underscore.
356 sc_prohibit_framework_failure:
357         @prohibit='\<framework_''failure\>'                             \
358         halt='use framework_failure_ instead'                           \
359           $(_sc_search_regexp)
360
361 # Prohibit the use of `...` in tests/.  Use $(...) instead.
362 sc_prohibit_test_backticks:
363         @prohibit='`' in_vc_files='^tests/'                             \
364         halt='use $$(...), not `...` in tests/'                         \
365           $(_sc_search_regexp)
366
367 # Programs like sort, ls, expr use PROG_FAILURE in place of EXIT_FAILURE.
368 # Others, use the EXIT_CANCELED, EXIT_ENOENT, etc. macros defined in system.h.
369 # In those programs, ensure that EXIT_FAILURE is not used by mistake.
370 sc_some_programs_must_avoid_exit_failure:
371         @grep -nw EXIT_FAILURE                                          \
372             $$(git grep -El '[^T]_FAILURE|EXIT_CANCELED' src)           \
373           | grep -vE '= EXIT_FAILURE|exit \(.* \?' | grep .             \
374             && { echo '$(ME): do not use EXIT_FAILURE in the above'     \
375                   1>&2; exit 1; } || :
376
377 # Ensure that tests call the print_ver_ function for programs which are
378 # actually used in that test.
379 sc_prohibit_test_calls_print_ver_with_irrelevant_argument:
380         @git grep -w print_ver_ tests                                   \
381           | sed 's#:print_ver_##'                                       \
382           | { fail=0;                                                   \
383               while read file name; do                                  \
384                 for i in $$name; do                                     \
385                   case "$$i" in install) i=ginstall;; esac;             \
386                   grep -w "$$i" $$file|grep -vw print_ver_|grep -q .    \
387                     || { fail=1;                                        \
388                          echo "*** Test: $$file, offending: $$i." 1>&2; };\
389                 done;                                                   \
390               done;                                                     \
391               test $$fail = 0 || exit 1;                                \
392             } || { echo "$(ME): the above test(s) call print_ver_ for"  \
393                     "program(s) they don't use" 1>&2; exit 1; }
394
395 # Exempt the contents of any usage function from the following.
396 _continued_string_col_1 = \
397 s/^usage .*?\n}//ms;/\\\n\w/ and print ("$$ARGV\n"),$$e=1;END{$$e||=0;exit $$e}
398 # Ding any source file that has a continued string with an alphabetic in the
399 # first column of the following line.  We prohibit them because they usually
400 # trigger false positives in tools that try to map an arbitrary line number
401 # to the enclosing function name.  Of course, very many strings do precisely
402 # this, *when they are part of the usage function*.  That is why we exempt
403 # the contents of any function named "usage".
404 sc_prohibit_continued_string_alpha_in_column_1:
405         @perl -0777 -ne '$(_continued_string_col_1)' \
406             $$($(VC_LIST_EXCEPT) | grep '\.[ch]$$') \
407           || { echo '$(ME): continued string with word in first column' \
408                 1>&2; exit 1; } || :
409 # Use this to list offending lines:
410 # git ls-files |grep '\.[ch]$' | xargs \
411 #   perl -n -0777 -e 's/^usage.*?\n}//ms;/\\\n\w/ and print "$ARGV\n"' \
412 #     | xargs grep -A1 '\\$'|grep '\.[ch][:-][_a-zA-Z]'
413
414
415 ###########################################################
416 _p0 = \([^"'/]\|"\([^\"]\|[\].\)*"\|'\([^\']\|[\].\)*'
417 _pre = $(_p0)\|[/][^"'/*]\|[/]"\([^\"]\|[\].\)*"\|[/]'\([^\']\|[\].\)*'\)*
418 _pre_anchored = ^\($(_pre)\)
419 _comment_and_close = [^*]\|[*][^/*]\)*[*][*]*/
420 # help font-lock mode: '
421
422 # A sed expression that removes ANSI C and ISO C99 comments.
423 # Derived from the one in GNU gettext's 'moopp' preprocessor.
424 _sed_remove_comments =                                  \
425 /[/][/*]/{                                              \
426   ta;                                                   \
427   :a;                                                   \
428   s,$(_pre_anchored)//.*,\1,;                           \
429   te;                                                   \
430   s,$(_pre_anchored)/[*]\($(_comment_and_close),\1 ,;   \
431   ta;                                                   \
432   /^$(_pre)[/][*]/{                                     \
433     s,$(_pre_anchored)/[*].*,\1 ,;                      \
434     tu;                                                 \
435     :u;                                                 \
436     n;                                                  \
437     s,^\($(_comment_and_close),,;                       \
438     tv;                                                 \
439     s,^.*$$,,;                                          \
440     bu;                                                 \
441     :v;                                                 \
442   };                                                    \
443   :e;                                                   \
444 }
445 # Quote all single quotes.
446 _sed_rm_comments_q = $(subst ','\'',$(_sed_remove_comments))
447 # help font-lock mode: '
448
449 _space_before_paren_exempt =? \\n\\$$
450 _space_before_paren_exempt = \
451   (^ *\#|\\n\\$$|%s\(to %s|(date|group|character)\(s\))
452 # Ensure that there is a space before each open parenthesis in C code.
453 sc_space_before_open_paren:
454         @if $(VC_LIST_EXCEPT) | grep -l '\.[ch]$$' > /dev/null; then    \
455           fail=0;                                                       \
456           for c in $$($(VC_LIST_EXCEPT) | grep '\.[ch]$$'); do          \
457             sed '$(_sed_rm_comments_q)' $$c 2>/dev/null                 \
458               | grep -i '[[:alnum:]]('                                  \
459               | grep -vE '$(_space_before_paren_exempt)'                \
460               | grep . && { fail=1; echo "*** $$c"; };                  \
461           done;                                                         \
462           test $$fail = 1 &&                                            \
463             { echo '$(ME): the above files lack a space-before-open-paren' \
464                 1>&2; exit 1; } || :;                                   \
465         else :;                                                         \
466         fi
467
468 # Similar to the gnulib maint.mk rule for sc_prohibit_strcmp
469 # Use STREQ_LEN or STRPREFIX rather than comparing strncmp == 0, or != 0.
470 sc_prohibit_strncmp:
471         @grep -nE '! *str''ncmp *\(|\<str''ncmp *\(.+\) *[!=]='         \
472             $$($(VC_LIST_EXCEPT))                                       \
473           | grep -vE ':# *define STR(N?EQ_LEN|PREFIX)\(' &&             \
474           { echo '$(ME): use STREQ_LEN or STRPREFIX instead of str''ncmp' \
475                 1>&2; exit 1; } || :
476
477 # Enforce recommended preprocessor indentation style.
478 sc_preprocessor_indentation:
479         @if cppi --version >/dev/null 2>&1; then                        \
480           $(VC_LIST_EXCEPT) | grep '\.[ch]$$' | xargs cppi -a -c        \
481             || { echo '$(ME): incorrect preprocessor indentation' 1>&2; \
482                 exit 1; };                                              \
483         else                                                            \
484           echo '$(ME): skipping test $@: cppi not installed' 1>&2;      \
485         fi
486
487 # THANKS.in is a list of name/email pairs for people who are mentioned in
488 # commit logs (and generated ChangeLog), but who are not also listed as an
489 # author of a commit.  Name/email pairs of commit authors are automatically
490 # extracted from the repository.  As a very minor factorization, when
491 # someone who was initially listed only in THANKS.in later authors a commit,
492 # this rule detects that their pair may now be removed from THANKS.in.
493 sc_THANKS_in_duplicates:
494         @{ git log --pretty=format:%aN | sort -u;                       \
495             cut -b-36 THANKS.in | sed '/^$$/d;s/  *$$//'; }             \
496           | sort | uniq -d | grep .                                     \
497             && { echo '$(ME): remove the above names from THANKS.in'    \
498                   1>&2; exit 1; } || :
499
500 # Override the default Cc: used in generating an announcement.
501 announcement_Cc_ = $(translation_project_), \
502   coreutils@gnu.org, coreutils-announce@gnu.org
503
504 -include $(srcdir)/dist-check.mk
505
506 update-copyright-env = \
507   UPDATE_COPYRIGHT_FORCE=1 \
508   UPDATE_COPYRIGHT_USE_INTERVALS=2 \
509   UPDATE_COPYRIGHT_MAX_LINE_LENGTH=79
510
511 # List syntax-check exemptions.
512 exclude_file_name_regexp--sc_space_tab = \
513   ^(tests/pr/|tests/misc/nl\.sh$$|gl/.*\.diff$$)
514 exclude_file_name_regexp--sc_bindtextdomain = ^(gl/.*|lib/euidaccess-stat)\.c$$
515 exclude_file_name_regexp--sc_trailing_blank = ^tests/pr/
516 exclude_file_name_regexp--sc_system_h_headers = \
517   ^src/((system|copy)\.h|libstdbuf\.c)$$
518
519 _src = (false|lbracket|ls-(dir|ls|vdir)|tac-pipe|uname-(arch|uname))
520 exclude_file_name_regexp--sc_require_config_h_first = \
521   (^lib/buffer-lcm\.c|src/$(_src)\.c)$$
522 exclude_file_name_regexp--sc_require_config_h = \
523   $(exclude_file_name_regexp--sc_require_config_h_first)
524
525 exclude_file_name_regexp--sc_po_check = ^gl/
526 exclude_file_name_regexp--sc_prohibit_always-defined_macros = \
527   ^src/(seq|remove)\.c$$
528 exclude_file_name_regexp--sc_prohibit_empty_lines_at_EOF = ^tests/pr/
529 exclude_file_name_regexp--sc_program_name = ^(gl/.*|lib/euidaccess-stat)\.c$$
530 exclude_file_name_regexp--sc_file_system = \
531   NEWS|^(tests/init\.cfg|src/df\.c|tests/df/df-P\.sh)$$
532 exclude_file_name_regexp--sc_prohibit_always_true_header_tests = \
533   ^m4/stat-prog\.m4$$
534 exclude_file_name_regexp--sc_prohibit_fail_0 = \
535   (^.*/git-hooks/commit-msg|^tests/init\.sh|Makefile\.am|\.mk|.*\.texi)$$
536 exclude_file_name_regexp--sc_prohibit_atoi_atof = ^lib/euidaccess-stat\.c$$
537
538 tbi_1 = ^tests/pr/|(^gl/lib/reg.*\.c\.diff|Makefile(\.am)?|\.mk|^man/help2man)$$
539 tbi_2 = ^scripts/git-hooks/(pre-commit|pre-applypatch|applypatch-msg)$$
540 exclude_file_name_regexp--sc_prohibit_tab_based_indentation = \
541   $(tbi_1)|$(tbi_2)
542
543 exclude_file_name_regexp--sc_preprocessor_indentation = \
544   ^(gl/lib/rand-isaac\.[ch]|gl/tests/test-rand-isaac\.c)$$
545 exclude_file_name_regexp--sc_prohibit_stat_st_blocks = \
546   ^(src/system\.h|tests/du/2g\.sh)$$
547
548 exclude_file_name_regexp--sc_prohibit_continued_string_alpha_in_column_1 = \
549   ^src/(system\.h|od\.c|printf\.c)$$
550
551 exclude_file_name_regexp--sc_prohibit_test_backticks = \
552   ^tests/(init\.sh|Makefile\.am|misc/stdbuf\.sh)$$
553
554 # Exempt test.c, since it's nominally shared, and relatively static.
555 exclude_file_name_regexp--sc_prohibit_operator_at_end_of_line = \
556   ^src/(ptx|test|head)\.c$$