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