timeout: add the --kill-after option
[platform/upstream/coreutils.git] / cfg.mk
1 # Customize maint.mk                           -*- makefile -*-
2 # Copyright (C) 2003-2010 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
23 # Tools used to bootstrap this package, used for "announcement".
24 bootstrap-tools = autoconf,automake,gnulib,bison
25
26 # Now that we have better tests, make this the default.
27 export VERBOSE = yes
28
29 old_NEWS_hash = 9518f4930d702a9fa6ac6b9fd06cca94
30
31 # Add an exemption for sc_makefile_at_at_check.
32 _makefile_at_at_check_exceptions = ' && !/^cu_install_program =/'
33
34 # Ensure that the list of O_ symbols used to compute O_FULLBLOCK is complete.
35 dd = $(srcdir)/src/dd.c
36 sc_dd_O_FLAGS:
37         @rm -f $@.1 $@.2
38         @{ echo O_FULLBLOCK; perl -nle '/^ +\| (O_\w*)$$/ and print $$1' \
39           $(dd); } | sort > $@.1
40         @{ echo O_NOFOLLOW; perl -nle '/{"[a-z]+",\s*(O_\w+)},/ and print $$1' \
41           $(dd); } | sort > $@.2
42         @diff -u $@.1 $@.2 || diff=1 || diff=;                          \
43         rm -f $@.1 $@.2;                                                \
44         test "$$diff"                                                   \
45           && { echo '$(ME): $(dd) has inconsistent O_ flag lists'>&2;   \
46                exit 1; } || :
47
48 # Ensure that dd's definition of LONGEST_SYMBOL stays in sync
49 # with the strings from the two affected variables.
50 dd_c = $(srcdir)/src/dd.c
51 sc_dd_max_sym_length:
52 ifneq ($(wildcard $(dd_c)),)
53         @len=$$( (sed -n '/conversions\[\] =$$/,/^};/p' $(dd_c);\
54                  sed -n '/flags\[\] =$$/,/^};/p' $(dd_c) )      \
55                 |sed -n '/"/s/^[^"]*"\([^"]*\)".*/\1/p'         \
56               | wc --max-line-length);                          \
57         max=$$(sed -n '/^#define LONGEST_SYMBOL /s///p' $(dd_c) \
58               |tr -d '"' | wc --max-line-length);               \
59         if test "$$len" = "$$max"; then :; else                 \
60           echo 'dd.c: LONGEST_SYMBOL is not longest' 1>&2;      \
61           exit 1;                                               \
62         fi
63 endif
64
65 # Many m4 macros names once began with `jm_'.
66 # On 2004-04-13, they were all changed to start with gl_ instead.
67 # Make sure that none are inadvertently reintroduced.
68 sc_prohibit_jm_in_m4:
69         @grep -nE 'jm_[A-Z]'                                            \
70                 $$($(VC_LIST) m4 |grep '\.m4$$'; echo /dev/null) &&     \
71             { echo '$(ME): do not use jm_ in m4 macro names'            \
72               1>&2; exit 1; } || :
73
74 # Ensure that each root-requiring test is run via the "check-root" rule.
75 sc_root_tests:
76         @if test -d tests \
77               && grep check-root tests/Makefile.am>/dev/null 2>&1; then \
78         t1=sc-root.expected; t2=sc-root.actual;                         \
79         grep -nl '^require_root_$$'                                     \
80           $$($(VC_LIST) tests) |sed s,tests/,, |sort > $$t1;            \
81         sed -n '/^root_tests =[  ]*\\$$/,/[^\]$$/p'                     \
82           $(srcdir)/tests/Makefile.am                                   \
83             | sed 's/^  *//;/^root_tests =/d'                           \
84             | tr -s '\012\\' '  ' | fmt -1 | sort > $$t2;               \
85         diff -u $$t1 $$t2 || diff=1 || diff=;                           \
86         rm -f $$t1 $$t2;                                                \
87         test "$$diff"                                                   \
88           && { echo 'tests/Makefile.am: missing check-root action'>&2;  \
89                exit 1; } || :;                                          \
90         fi
91
92 # Ensure that the syntax_check_exceptions file list in Makefile.am
93 # stays in sync with corresponding files in the repository.
94 sce = syntax_check_exceptions
95 sc_x_sc_dist_check:
96         @test "$$( ($(VC_LIST) | sed -n '/\.x-sc_/p'                    \
97                      | sed 's|^$(_dot_escaped_srcdir)/||';              \
98                    sed -n '/^$(sce) =[   ]*\\$$/,/[^\]$$/p'             \
99                      $(srcdir)/Makefile.am                              \
100                        | sed 's/^  *//;/^$(sce) =/d'                    \
101                        | tr -s '\012\\' '  ' | fmt -1                   \
102                    ) | sort | uniq -u)"                                 \
103           && { echo 'Makefile.am: $(sce) mismatch' >&2; exit 1; } || :;
104
105 headers_with_interesting_macro_defs = \
106   exit.h        \
107   fcntl_.h      \
108   fnmatch_.h    \
109   intprops.h    \
110   inttypes_.h   \
111   lchown.h      \
112   openat.h      \
113   stat-macros.h \
114   stdint_.h
115
116 # Create a list of regular expressions matching the names
117 # of macros that are guaranteed by parts of gnulib to be defined.
118 .re-defmac:
119         @(cd $(srcdir)/lib;                                             \
120           for f in $(headers_with_interesting_macro_defs); do           \
121             test -f $$f &&                                              \
122               sed -n '/^# *define \([^_ (][^ (]*\)[ (].*/s//\1/p' $$f;  \
123            done;                                                        \
124          ) | sort -u                                                    \
125            | grep -Ev 'ATTRIBUTE_NORETURN|SIZE_MAX'                     \
126            | sed 's/^/^# *define /'                                     \
127           > $@-t
128         @mv $@-t $@
129
130 # Don't define macros that we already get from gnulib header files.
131 sc_always_defined_macros: .re-defmac
132         @if test -f $(srcdir)/src/system.h; then                        \
133           trap 'rc=$$?; rm -f .re-defmac; exit $$rc' 0 1 2 3 15;        \
134           grep -f .re-defmac $$($(VC_LIST))                             \
135             && { echo '$(ME): define the above via some gnulib .h file' \
136                   1>&2;  exit 1; } || :;                                \
137         fi
138
139 # Create a list of regular expressions matching the names
140 # of files included from system.h.  Exclude a couple.
141 .re-list:
142         @sed -n '/^# *include /s///p' $(srcdir)/src/system.h \
143           | grep -Ev 'sys/(param|file)\.h' \
144           | sed 's/ .*//;;s/^["<]/^# *include [<"]/;s/\.h[">]$$/\\.h[">]/' \
145           > $@-t
146         @mv $@-t $@
147
148 # Files in src/ should not include directly any of
149 # the headers already included via system.h.
150 sc_system_h_headers: .re-list
151         @if test -f $(srcdir)/src/system.h; then                        \
152           trap 'rc=$$?; rm -f .re-list; exit $$rc' 0 1 2 3 15;          \
153           grep -nE -f .re-list                                          \
154               $$($(VC_LIST_EXCEPT) | grep '^src/')                      \
155             && { echo '$(ME): the above are already included via system.h'\
156                   1>&2;  exit 1; } || :;                                \
157         fi
158
159 sc_sun_os_names:
160         @grep -nEi \
161             'solaris[^[:alnum:]]*2\.(7|8|9|[1-9][0-9])|sunos[^[:alnum:]][6-9]' \
162             $$($(VC_LIST_EXCEPT)) &&                                    \
163           { echo '$(ME): found misuse of Sun OS version numbers' 1>&2;  \
164             exit 1; } || :
165
166 ALL_RECURSIVE_TARGETS += sc_tight_scope
167 sc_tight_scope:
168         @$(MAKE) -s -C src $@
169
170 ALL_RECURSIVE_TARGETS += sc_check-AUTHORS
171 sc_check-AUTHORS:
172         @$(MAKE) -s -C src $@
173
174 # Option descriptions should not start with a capital letter
175 # One could grep source directly as follows:
176 # grep -E " {2,6}-.*[^.]  [A-Z][a-z]" $$($(VC_LIST_EXCEPT) | grep '\.c$$')
177 # but that would miss descriptions not on the same line as the -option.
178 ALL_RECURSIVE_TARGETS += sc_option_desc_uppercase
179 sc_option_desc_uppercase:
180         @$(MAKE) -s -C src all_programs
181         @$(MAKE) -s -C man $@
182
183 # Ensure all man/*.[1x] files are present
184 ALL_RECURSIVE_TARGETS += sc_man_file_correlation
185 sc_man_file_correlation:
186         @$(MAKE) -s -C src all_programs
187         @$(MAKE) -s -C man $@
188
189 # Perl-based tests used to exec perl from a #!/bin/sh script.
190 # Now they all start with #!/usr/bin/perl and the portability
191 # infrastructure is in tests/Makefile.am.  Make sure no old-style
192 # script sneaks back in.
193 sc_no_exec_perl_coreutils:
194         @if test -f $(srcdir)/tests/Coreutils.pm; then                  \
195           grep '^exec  *\$$PERL.*MCoreutils' $$($(VC_LIST) tests) &&    \
196             { echo 1>&2 '$(ME): found anachronistic Perl-based tests';  \
197               exit 1; } || :;                                           \
198         fi
199
200 # Don't use "readlink" or "readlinkat" directly
201 sc_prohibit_readlink:
202         @re='\<readlink(at)? \('                                        \
203         msg='do not use readlink(at); use via xreadlink or areadlink*'  \
204           $(_prohibit_regexp)
205
206 # Don't use address of "stat" or "lstat" functions
207 sc_prohibit_stat_macro_address:
208         @re='\<l?stat '':|&l?stat\>'                                    \
209         msg='stat() and lstat() may be function-like macros'            \
210           $(_prohibit_regexp)
211
212 # Ensure that date's --help output stays in sync with the info
213 # documentation for GNU strftime.  The only exception is %N,
214 # which date accepts but GNU strftime does not.
215 extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/'
216 sc_strftime_check:
217         @if test -f $(srcdir)/src/date.c; then                          \
218           grep '^  %.  ' $(srcdir)/src/date.c | sort                    \
219             | $(extract_char) > $@-src;                                 \
220           { echo N;                                                     \
221             info libc date calendar format 2>/dev/null|grep '^    `%.'\'\
222               | $(extract_char); } | sort > $@-info;                    \
223           diff -u $@-src $@-info || exit 1;                             \
224           rm -f $@-src $@-info;                                         \
225         fi
226
227 # Indent only with spaces.
228 sc_prohibit_tab_based_indentation:
229         @re='^ *        '                                               \
230         msg='TAB in indentation; use only spaces'                       \
231           $(_prohibit_regexp)
232
233 # Don't use "indent-tabs-mode: nil" anymore.  No longer needed.
234 sc_prohibit_emacs__indent_tabs_mode__setting:
235         @re='^( *[*#] *)?indent-tabs-mode:'                             \
236         msg='use of emacs indent-tabs-mode: setting'                    \
237           $(_prohibit_regexp)
238
239 # Ensure that each file that contains fail=1 also contains fail=0.
240 # Otherwise, setting file=1 in the environment would make tests fail unexpectedly.
241 sc_prohibit_fail_0:
242         @re='\<fail=0\>'                                                \
243         msg='fail=0 initialization'                                     \
244           $(_prohibit_regexp)
245
246 # Ensure that "stdio--.h" is used where appropriate.
247 sc_require_stdio_safer:
248         @if $(VC_LIST_EXCEPT) | grep -l '\.[ch]$$' > /dev/null; then    \
249           files=$$(grep -l '\bfreopen \?(' $$($(VC_LIST_EXCEPT)         \
250               | grep '\.[ch]$$'));                                      \
251           test -n "$$files" && grep -LE 'include "stdio--.h"' $$files   \
252               | grep . &&                                               \
253           { echo '$(ME): the above files should use "stdio--.h"'        \
254                 1>&2; exit 1; } || :;                                   \
255         else :;                                                         \
256         fi
257
258 # Prefer xnanosleep over other less-precise sleep methods
259 sc_prohibit_sleep:
260         @re='\<(nano|u)?sleep \('                                       \
261         msg='prefer xnanosleep over other sleep interfaces'             \
262           $(_prohibit_regexp)
263
264 include $(srcdir)/dist-check.mk
265
266 update-copyright-env = \
267   UPDATE_COPYRIGHT_USE_INTERVALS=1 \
268   UPDATE_COPYRIGHT_MAX_LINE_LENGTH=79