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