sort: default to physmem/8, not physmem/16
[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_texinfo_acronym
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 old_NEWS_hash = c2d954b7c19745272321cc4c4b676993
35
36 # Add an exemption for sc_makefile_at_at_check.
37 _makefile_at_at_check_exceptions = ' && !/^cu_install_program =/'
38
39 # Our help-version script is in a slightly different location.
40 _hv_file ?= $(srcdir)/tests/misc/help-version
41
42 # Ensure that the list of O_ symbols used to compute O_FULLBLOCK is complete.
43 dd = $(srcdir)/src/dd.c
44 sc_dd_O_FLAGS:
45         @rm -f $@.1 $@.2
46         @{ echo O_FULLBLOCK; echo O_NOCACHE;                            \
47           perl -nle '/^ +\| (O_\w*)$$/ and print $$1' $(dd); } | sort > $@.1
48         @{ echo O_NOFOLLOW; perl -nle '/{"[a-z]+",\s*(O_\w+)},/ and print $$1' \
49           $(dd); } | sort > $@.2
50         @diff -u $@.1 $@.2 || diff=1 || diff=;                          \
51         rm -f $@.1 $@.2;                                                \
52         test "$$diff"                                                   \
53           && { echo '$(ME): $(dd) has inconsistent O_ flag lists'>&2;   \
54                exit 1; } || :
55
56 # Ensure that dd's definition of LONGEST_SYMBOL stays in sync
57 # with the strings from the two affected variables.
58 dd_c = $(srcdir)/src/dd.c
59 sc_dd_max_sym_length:
60 ifneq ($(wildcard $(dd_c)),)
61         @len=$$( (sed -n '/conversions\[\] =$$/,/^};/p' $(dd_c);\
62                  sed -n '/flags\[\] =$$/,/^};/p' $(dd_c) )      \
63                 |sed -n '/"/s/^[^"]*"\([^"]*\)".*/\1/p'         \
64               | wc --max-line-length);                          \
65         max=$$(sed -n '/^#define LONGEST_SYMBOL /s///p' $(dd_c) \
66               |tr -d '"' | wc --max-line-length);               \
67         if test "$$len" = "$$max"; then :; else                 \
68           echo 'dd.c: LONGEST_SYMBOL is not longest' 1>&2;      \
69           exit 1;                                               \
70         fi
71 endif
72
73 # Many m4 macros names once began with 'jm_'.
74 # On 2004-04-13, they were all changed to start with gl_ instead.
75 # Make sure that none are inadvertently reintroduced.
76 sc_prohibit_jm_in_m4:
77         @grep -nE 'jm_[A-Z]'                                            \
78                 $$($(VC_LIST) m4 |grep '\.m4$$'; echo /dev/null) &&     \
79             { echo '$(ME): do not use jm_ in m4 macro names'            \
80               1>&2; exit 1; } || :
81
82 # Ensure that each root-requiring test is run via the "check-root" rule.
83 sc_root_tests:
84         @if test -d tests \
85               && grep check-root tests/Makefile.am>/dev/null 2>&1; then \
86         t1=sc-root.expected; t2=sc-root.actual;                         \
87         grep -nl '^ *require_root_$$'                                   \
88           $$($(VC_LIST) tests) |sed s,tests/,, |sort > $$t1;            \
89         sed -n '/^root_tests =[  ]*\\$$/,/[^\]$$/p'                     \
90           $(srcdir)/tests/Makefile.am                                   \
91             | sed 's/^  *//;/^root_tests =/d'                           \
92             | tr -s '\012\\' '  ' | fmt -1 | sort > $$t2;               \
93         diff -u $$t1 $$t2 || diff=1 || diff=;                           \
94         rm -f $$t1 $$t2;                                                \
95         test "$$diff"                                                   \
96           && { echo 'tests/Makefile.am: missing check-root action'>&2;  \
97                exit 1; } || :;                                          \
98         fi
99
100 # Create a list of regular expressions matching the names
101 # of files included from system.h.  Exclude a couple.
102 .re-list:
103         @sed -n '/^# *include /s///p' $(srcdir)/src/system.h \
104           | grep -Ev 'sys/(param|file)\.h' \
105           | sed 's/ .*//;;s/^["<]/^# *include [<"]/;s/\.h[">]$$/\\.h[">]/' \
106           > $@-t
107         @mv $@-t $@
108
109 define gl_trap_
110   Exit () { set +e; (exit $$1); exit $$1; };                            \
111   for sig in 1 2 3 13 15; do                                            \
112     eval "trap 'Exit $$(expr $$sig + 128)' $$sig";                      \
113   done
114 endef
115
116 # Files in src/ should not include directly any of
117 # the headers already included via system.h.
118 sc_system_h_headers: .re-list
119         @if test -f $(srcdir)/src/system.h; then                        \
120           trap 'rc=$$?; rm -f .re-list; exit $$rc' 0;                   \
121           $(gl_trap_);                                                  \
122           grep -nE -f .re-list                                          \
123               $$($(VC_LIST_EXCEPT) | grep '^\($(srcdir)/\)\?src/')      \
124             && { echo '$(ME): the above are already included via system.h'\
125                   1>&2;  exit 1; } || :;                                \
126         fi
127
128 sc_sun_os_names:
129         @grep -nEi \
130             'solaris[^[:alnum:]]*2\.(7|8|9|[1-9][0-9])|sunos[^[:alnum:]][6-9]' \
131             $$($(VC_LIST_EXCEPT)) &&                                    \
132           { echo '$(ME): found misuse of Sun OS version numbers' 1>&2;  \
133             exit 1; } || :
134
135 ALL_RECURSIVE_TARGETS += sc_check-AUTHORS
136 sc_check-AUTHORS:
137         @$(MAKE) -s -C src _sc_check-AUTHORS
138
139 # Look for lines longer than 80 characters, except omit:
140 # - program-generated long lines in diff headers,
141 # - tests involving long checksum lines, and
142 # - the 'pr' test cases.
143 LINE_LEN_MAX = 80
144 FILTER_LONG_LINES =                                             \
145   /^[^:]*\.diff:[^:]*:@@ / d;                                   \
146   \|^[^:]*tests/misc/sha[0-9]*sum[-:]| d;                       \
147   \|^[^:]*tests/pr/|{ \|^[^:]*tests/pr/pr-tests:| !d; };
148 sc_long_lines:
149         @files=$$($(VC_LIST_EXCEPT))                                    \
150         halt='line(s) with more than $(LINE_LEN_MAX) characters; reindent'; \
151         for file in $$files; do                                         \
152           expand $$file | grep -nE '^.{$(LINE_LEN_MAX)}.' |             \
153           sed -e "s|^|$$file:|" -e '$(FILTER_LONG_LINES)';              \
154         done | grep . && { msg="$$halt" $(_sc_say_and_exit) } || :
155
156 # Option descriptions should not start with a capital letter
157 # One could grep source directly as follows:
158 # grep -E " {2,6}-.*[^.]  [A-Z][a-z]" $$($(VC_LIST_EXCEPT) | grep '\.c$$')
159 # but that would miss descriptions not on the same line as the -option.
160 ALL_RECURSIVE_TARGETS += sc_option_desc_uppercase
161 sc_option_desc_uppercase:
162         @$(MAKE) -s -C src all_programs
163         @$(MAKE) -s -C man $@
164
165 # Ensure all man/*.[1x] files are present
166 ALL_RECURSIVE_TARGETS += sc_man_file_correlation
167 sc_man_file_correlation:
168         @$(MAKE) -s -C src all_programs
169         @$(MAKE) -s -C man $@
170
171 # Ensure that the end of each release's section is marked by two empty lines.
172 sc_NEWS_two_empty_lines:
173         @sed -n 4,/Noteworthy/p $(srcdir)/NEWS                          \
174             | perl -n0e '/(^|\n)\n\n\* Noteworthy/ or exit 1'           \
175           || { echo '$(ME): use two empty lines to separate NEWS sections' \
176                  1>&2; exit 1; } || :
177
178 # Perl-based tests used to exec perl from a #!/bin/sh script.
179 # Now they all start with #!/usr/bin/perl and the portability
180 # infrastructure is in tests/Makefile.am.  Make sure no old-style
181 # script sneaks back in.
182 sc_no_exec_perl_coreutils:
183         @if test -f $(srcdir)/tests/Coreutils.pm; then                  \
184           grep '^exec  *\$$PERL.*MCoreutils' $$($(VC_LIST) tests) &&    \
185             { echo 1>&2 '$(ME): found anachronistic Perl-based tests';  \
186               exit 1; } || :;                                           \
187         fi
188
189 # Don't use "readlink" or "readlinkat" directly
190 sc_prohibit_readlink:
191         @prohibit='\<readlink(at)? \('                                  \
192         halt='do not use readlink(at); use via xreadlink or areadlink*' \
193           $(_sc_search_regexp)
194
195 # Don't use address of "stat" or "lstat" functions
196 sc_prohibit_stat_macro_address:
197         @prohibit='\<l?stat '':|&l?stat\>'                              \
198         halt='stat() and lstat() may be function-like macros'           \
199           $(_sc_search_regexp)
200
201 # Ensure that date's --help output stays in sync with the info
202 # documentation for GNU strftime.  The only exception is %N,
203 # which date accepts but GNU strftime does not.
204 extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/'
205 sc_strftime_check:
206         @if test -f $(srcdir)/src/date.c; then                          \
207           grep '^  %.  ' $(srcdir)/src/date.c | sort                    \
208             | $(extract_char) > $@-src;                                 \
209           { echo N;                                                     \
210             info libc date calendar format 2>/dev/null|grep '^    `%.'\'\
211               | $(extract_char); } | sort > $@-info;                    \
212           if test $$(stat --format %s $@-info) != 2; then               \
213             diff -u $@-src $@-info || exit 1;                           \
214           else                                                          \
215             echo '$(ME): skipping $@: libc info not installed' 1>&2;    \
216           fi;                                                           \
217           rm -f $@-src $@-info;                                         \
218         fi
219
220 # Indent only with spaces.
221 sc_prohibit_tab_based_indentation:
222         @prohibit='^ *  '                                               \
223         halt='TAB in indentation; use only spaces'                      \
224           $(_sc_search_regexp)
225
226 # The SEE ALSO section of a man page should not be terminated with
227 # a period.  Check the first line after each "SEE ALSO" line in man/*.x:
228 sc_prohibit_man_see_also_period:
229         @grep -nB1 '\.$$' $$($(VC_LIST_EXCEPT) | grep 'man/.*\.x$$')    \
230             | grep -A1 -e '-\[SEE ALSO\]' | grep '\.$$' &&              \
231           { echo '$(ME): do not end "SEE ALSO" section with a period'   \
232               1>&2; exit 1; } || :
233
234 # Don't use "indent-tabs-mode: nil" anymore.  No longer needed.
235 sc_prohibit_emacs__indent_tabs_mode__setting:
236         @prohibit='^( *[*#] *)?indent-tabs-mode:'                       \
237         halt='use of emacs indent-tabs-mode: setting'                   \
238           $(_sc_search_regexp)
239
240 # Ensure that each file that contains fail=1 also contains fail=0.
241 # Otherwise, setting file=1 in the environment would make tests fail
242 # unexpectedly.
243 sc_prohibit_fail_0:
244         @prohibit='\<fail=0\>'                                          \
245         halt='fail=0 initialization'                                    \
246           $(_sc_search_regexp)
247
248 # The mode part of a setfacl -m option argument must be three bytes long.
249 # I.e., an argument of user:bin:rw or user:bin:r will make Solaris 10's
250 # setfacl reject it with: "Unrecognized character found in mode field".
251 # Use hyphens to give it a length of 3: "...:rw-" or "...:r--".
252 sc_prohibit_short_facl_mode_spec:
253         @prohibit='\<setfacl .*-m.*:.*:[rwx-]{1,2} '                    \
254         halt='setfacl mode string length < 3; extend with hyphen(s)'    \
255           $(_sc_search_regexp)
256
257 # Ensure that "stdio--.h" is used where appropriate.
258 sc_require_stdio_safer:
259         @if $(VC_LIST_EXCEPT) | grep -l '\.[ch]$$' > /dev/null; then    \
260           files=$$(grep -l '\bfreopen \?(' $$($(VC_LIST_EXCEPT)         \
261               | grep '\.[ch]$$'));                                      \
262           test -n "$$files" && grep -LE 'include "stdio--.h"' $$files   \
263               | grep . &&                                               \
264           { echo '$(ME): the above files should use "stdio--.h"'        \
265                 1>&2; exit 1; } || :;                                   \
266         else :;                                                         \
267         fi
268
269 sc_prohibit_perl_hash_quotes:
270         @prohibit="\{'[A-Z_]+' *[=}]"                                   \
271         halt="in Perl code, write \$$hash{KEY}, not \$$hash{'K''EY'}"   \
272           $(_sc_search_regexp)
273
274 # Prefer xnanosleep over other less-precise sleep methods
275 sc_prohibit_sleep:
276         @prohibit='\<(nano|u)?sleep \('                                 \
277         halt='prefer xnanosleep over other sleep interfaces'            \
278           $(_sc_search_regexp)
279
280 # Use print_ver_ (from init.cfg), not open-coded $VERBOSE check.
281 sc_prohibit_verbose_version:
282         @prohibit='test "\$$VERBOSE" = yes && .* --version'             \
283         halt='use the print_ver_ function instead...'                   \
284           $(_sc_search_regexp)
285
286 # Use framework_failure_, not the old name without the trailing underscore.
287 sc_prohibit_framework_failure:
288         @prohibit='\<framework_''failure\>'                             \
289         halt='use framework_failure_ instead'                           \
290           $(_sc_search_regexp)
291
292 # Exempt the contents of any usage function from the following.
293 _continued_string_col_1 = \
294 s/^usage .*?\n}//ms;/\\\n\w/ and print ("$$ARGV\n"),$$e=1;END{$$e||=0;exit $$e}
295 # Ding any source file that has a continued string with an alphabetic in the
296 # first column of the following line.  We prohibit them because they usually
297 # trigger false positives in tools that try to map an arbitrary line number
298 # to the enclosing function name.  Of course, very many strings do precisely
299 # this, *when they are part of the usage function*.  That is why we exempt
300 # the contents of any function named "usage".
301 sc_prohibit_continued_string_alpha_in_column_1:
302         @perl -0777 -ne '$(_continued_string_col_1)' \
303             $$($(VC_LIST_EXCEPT) | grep '\.[ch]$$') \
304           || { echo '$(ME): continued string with word in first column' \
305                 1>&2; exit 1; } || :
306 # Use this to list offending lines:
307 # git ls-files |grep '\.[ch]$' | xargs \
308 #   perl -n -0777 -e 's/^usage.*?\n}//ms;/\\\n\w/ and print "$ARGV\n"' \
309 #     | xargs grep -A1 '\\$'|grep '\.[ch][:-][_a-zA-Z]'
310
311
312 ###########################################################
313 _p0 = \([^"'/]\|"\([^\"]\|[\].\)*"\|'\([^\']\|[\].\)*'
314 _pre = $(_p0)\|[/][^"'/*]\|[/]"\([^\"]\|[\].\)*"\|[/]'\([^\']\|[\].\)*'\)*
315 _pre_anchored = ^\($(_pre)\)
316 _comment_and_close = [^*]\|[*][^/*]\)*[*][*]*/
317 # help font-lock mode: '
318
319 # A sed expression that removes ANSI C and ISO C99 comments.
320 # Derived from the one in GNU gettext's 'moopp' preprocessor.
321 _sed_remove_comments =                                  \
322 /[/][/*]/{                                              \
323   ta;                                                   \
324   :a;                                                   \
325   s,$(_pre_anchored)//.*,\1,;                           \
326   te;                                                   \
327   s,$(_pre_anchored)/[*]\($(_comment_and_close),\1 ,;   \
328   ta;                                                   \
329   /^$(_pre)[/][*]/{                                     \
330     s,$(_pre_anchored)/[*].*,\1 ,;                      \
331     tu;                                                 \
332     :u;                                                 \
333     n;                                                  \
334     s,^\($(_comment_and_close),,;                       \
335     tv;                                                 \
336     s,^.*$$,,;                                          \
337     bu;                                                 \
338     :v;                                                 \
339   };                                                    \
340   :e;                                                   \
341 }
342 # Quote all single quotes.
343 _sed_rm_comments_q = $(subst ','\'',$(_sed_remove_comments))
344 # help font-lock mode: '
345
346 _space_before_paren_exempt =? \\n\\$$
347 _space_before_paren_exempt = \
348   (^ *\#|\\n\\$$|%s\(to %s|(date|group|character)\(s\))
349 # Ensure that there is a space before each open parenthesis in C code.
350 sc_space_before_open_paren:
351         @if $(VC_LIST_EXCEPT) | grep -l '\.[ch]$$' > /dev/null; then    \
352           fail=0;                                                       \
353           for c in $$($(VC_LIST_EXCEPT) | grep '\.[ch]$$'); do          \
354             sed '$(_sed_rm_comments_q)' $$c 2>/dev/null                 \
355               | grep -i '[[:alnum:]]('                                  \
356               | grep -vE '$(_space_before_paren_exempt)'                \
357               | grep . && { fail=1; echo "*** $$c"; };                  \
358           done;                                                         \
359           test $$fail = 1 &&                                            \
360             { echo '$(ME): the above files lack a space-before-open-paren' \
361                 1>&2; exit 1; } || :;                                   \
362         else :;                                                         \
363         fi
364
365 # Similar to the gnulib maint.mk rule for sc_prohibit_strcmp
366 # Use STREQ_LEN or STRPREFIX rather than comparing strncmp == 0, or != 0.
367 sc_prohibit_strncmp:
368         @grep -nE '! *str''ncmp *\(|\<str''ncmp *\(.+\) *[!=]='         \
369             $$($(VC_LIST_EXCEPT))                                       \
370           | grep -vE ':# *define STR(N?EQ_LEN|PREFIX)\(' &&             \
371           { echo '$(ME): use STREQ_LEN or STRPREFIX instead of str''ncmp' \
372                 1>&2; exit 1; } || :
373
374 # Enforce recommended preprocessor indentation style.
375 sc_preprocessor_indentation:
376         @if cppi --version >/dev/null 2>&1; then                        \
377           $(VC_LIST_EXCEPT) | grep '\.[ch]$$' | xargs cppi -a -c        \
378             || { echo '$(ME): incorrect preprocessor indentation' 1>&2; \
379                 exit 1; };                                              \
380         else                                                            \
381           echo '$(ME): skipping test $@: cppi not installed' 1>&2;      \
382         fi
383
384 # Override the default Cc: used in generating an announcement.
385 announcement_Cc_ = $(translation_project_), \
386   coreutils@gnu.org, coreutils-announce@gnu.org
387
388 -include $(srcdir)/dist-check.mk
389
390 update-copyright-env = \
391   UPDATE_COPYRIGHT_FORCE=1 \
392   UPDATE_COPYRIGHT_USE_INTERVALS=2 \
393   UPDATE_COPYRIGHT_MAX_LINE_LENGTH=79
394
395 # List syntax-check exemptions.
396 exclude_file_name_regexp--sc_space_tab = \
397   ^(tests/pr/|tests/misc/nl$$|gl/.*\.diff$$)
398 exclude_file_name_regexp--sc_bindtextdomain = ^(gl/.*|lib/euidaccess-stat)\.c$$
399 exclude_file_name_regexp--sc_unmarked_diagnostics =    ^build-aux/cvsu$$
400 exclude_file_name_regexp--sc_error_message_uppercase = ^build-aux/cvsu$$
401 exclude_file_name_regexp--sc_trailing_blank = ^tests/pr/
402 exclude_file_name_regexp--sc_system_h_headers = \
403   ^src/((system|copy)\.h|libstdbuf\.c)$$
404
405 _src = (false|lbracket|ls-(dir|ls|vdir)|tac-pipe|uname-(arch|uname))
406 exclude_file_name_regexp--sc_require_config_h_first = \
407   (^lib/buffer-lcm\.c|src/$(_src)\.c)$$
408 exclude_file_name_regexp--sc_require_config_h = \
409   $(exclude_file_name_regexp--sc_require_config_h_first)
410
411 exclude_file_name_regexp--sc_po_check = ^gl/
412 exclude_file_name_regexp--sc_prohibit_always-defined_macros = \
413   ^src/(seq|remove)\.c$$
414 exclude_file_name_regexp--sc_prohibit_empty_lines_at_EOF = ^tests/pr/
415 exclude_file_name_regexp--sc_program_name = ^(gl/.*|lib/euidaccess-stat)\.c$$
416 exclude_file_name_regexp--sc_file_system = \
417   NEWS|^(tests/init\.cfg|src/df\.c|tests/misc/df-P)$$
418 exclude_file_name_regexp--sc_prohibit_always_true_header_tests = \
419   ^m4/stat-prog\.m4$$
420 exclude_file_name_regexp--sc_prohibit_fail_0 = \
421   (^scripts/git-hooks/commit-msg|^tests/init\.sh|Makefile\.am|\.mk)$$
422 exclude_file_name_regexp--sc_prohibit_atoi_atof = ^lib/euidaccess-stat\.c$$
423
424 tbi_1 = ^tests/pr/|(^gl/lib/reg.*\.c\.diff|Makefile(\.am)?|\.mk|^man/help2man)$$
425 tbi_2 = ^scripts/git-hooks/(pre-commit|pre-applypatch|applypatch-msg)$$
426 exclude_file_name_regexp--sc_prohibit_tab_based_indentation = \
427   $(tbi_1)|$(tbi_2)
428
429 exclude_file_name_regexp--sc_preprocessor_indentation = \
430   ^(gl/lib/rand-isaac\.[ch]|gl/tests/test-rand-isaac\.c)$$
431 exclude_file_name_regexp--sc_prohibit_stat_st_blocks = \
432   ^(src/system\.h|tests/du/2g)$$
433
434 exclude_file_name_regexp--sc_prohibit_continued_string_alpha_in_column_1 = \
435   ^src/(system\.h|od\.c|printf\.c)$$