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