build: remove now-duplicate use of AC_SYS_LARGEFILE
[coreutils.git] / cfg.mk
blob39836082552debd93207af53cc75216594aa3ca6
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 = \
22 sc_texinfo_acronym
24 # Tools used to bootstrap this package, used for "announcement".
25 bootstrap-tools = autoconf,automake,gnulib,bison
27 # Now that we have better tests, make this the default.
28 export VERBOSE = yes
30 old_NEWS_hash = 27e765279d5735f99114b57fa097e6bd
32 # Add an exemption for sc_makefile_at_at_check.
33 _makefile_at_at_check_exceptions = ' && !/^cu_install_program =/'
35 # Our help-version script is in a slightly different location.
36 _hv_file ?= $(srcdir)/tests/misc/help-version
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; perl -nle '/^ +\| (O_\w*)$$/ and print $$1' \
43 $(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; } || :
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; \
67 endif
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; } || :
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; } || :; \
96 # Ensure that the syntax_check_exceptions file list in Makefile.am
97 # stays in sync with corresponding files in the repository.
98 sce = syntax_check_exceptions
99 sc_x_sc_dist_check:
100 @test "$$( ($(VC_LIST) | sed -n '/\.x-sc_/p' \
101 | sed 's|^$(_dot_escaped_srcdir)/||'; \
102 sed -n '/^$(sce) =[ ]*\\$$/,/[^\]$$/p' \
103 $(srcdir)/Makefile.am \
104 | sed 's/^ *//;/^$(sce) =/d' \
105 | tr -s '\012\\' ' ' | fmt -1 \
106 ) | sort | uniq -u)" \
107 && { echo 'Makefile.am: $(sce) mismatch' >&2; exit 1; } || :;
109 headers_with_interesting_macro_defs = \
110 exit.h \
111 fcntl_.h \
112 fnmatch_.h \
113 intprops.h \
114 inttypes_.h \
115 lchown.h \
116 openat.h \
117 stat-macros.h \
118 stdint_.h
120 # Create a list of regular expressions matching the names
121 # of macros that are guaranteed by parts of gnulib to be defined.
122 .re-defmac:
123 @(cd $(srcdir)/lib; \
124 for f in $(headers_with_interesting_macro_defs); do \
125 test -f $$f && \
126 sed -n '/^# *define \([^_ (][^ (]*\)[ (].*/s//\1/p' $$f; \
127 done; \
128 ) | sort -u \
129 | grep -Ev 'ATTRIBUTE_NORETURN|SIZE_MAX' \
130 | sed 's/^/^# *define /' \
131 > $@-t
132 @mv $@-t $@
134 # Don't define macros that we already get from gnulib header files.
135 sc_always_defined_macros: .re-defmac
136 @if test -f $(srcdir)/src/system.h; then \
137 trap 'rc=$$?; rm -f .re-defmac; exit $$rc' 0; \
138 am__exit='(exit $rc); exit $rc'; \
139 trap "rc=129; $$am__exit" 1; trap "rc=130; $$am__exit" 2; \
140 trap "rc=131; $$am__exit" 3; trap "rc=143; $$am__exit" 15; \
141 grep -f .re-defmac $$($(VC_LIST)) \
142 && { echo '$(ME): define the above via some gnulib .h file' \
143 1>&2; exit 1; } || :; \
146 # Create a list of regular expressions matching the names
147 # of files included from system.h. Exclude a couple.
148 .re-list:
149 @sed -n '/^# *include /s///p' $(srcdir)/src/system.h \
150 | grep -Ev 'sys/(param|file)\.h' \
151 | sed 's/ .*//;;s/^["<]/^# *include [<"]/;s/\.h[">]$$/\\.h[">]/' \
152 > $@-t
153 @mv $@-t $@
155 # Files in src/ should not include directly any of
156 # the headers already included via system.h.
157 sc_system_h_headers: .re-list
158 @if test -f $(srcdir)/src/system.h; then \
159 trap 'rc=$$?; rm -f .re-list; exit $$rc' 0; \
160 am__exit='(exit $rc); exit $rc'; \
161 trap "rc=129; $$am__exit" 1; trap "rc=130; $$am__exit" 2; \
162 trap "rc=131; $$am__exit" 3; trap "rc=143; $$am__exit" 15; \
163 grep -nE -f .re-list \
164 $$($(VC_LIST_EXCEPT) | grep '^src/') \
165 && { echo '$(ME): the above are already included via system.h'\
166 1>&2; exit 1; } || :; \
169 sc_sun_os_names:
170 @grep -nEi \
171 'solaris[^[:alnum:]]*2\.(7|8|9|[1-9][0-9])|sunos[^[:alnum:]][6-9]' \
172 $$($(VC_LIST_EXCEPT)) && \
173 { echo '$(ME): found misuse of Sun OS version numbers' 1>&2; \
174 exit 1; } || :
176 ALL_RECURSIVE_TARGETS += sc_tight_scope
177 sc_tight_scope:
178 @$(MAKE) -s -C src $@
180 ALL_RECURSIVE_TARGETS += sc_check-AUTHORS
181 sc_check-AUTHORS:
182 @$(MAKE) -s -C src $@
184 # Option descriptions should not start with a capital letter
185 # One could grep source directly as follows:
186 # grep -E " {2,6}-.*[^.] [A-Z][a-z]" $$($(VC_LIST_EXCEPT) | grep '\.c$$')
187 # but that would miss descriptions not on the same line as the -option.
188 ALL_RECURSIVE_TARGETS += sc_option_desc_uppercase
189 sc_option_desc_uppercase:
190 @$(MAKE) -s -C src all_programs
191 @$(MAKE) -s -C man $@
193 # Ensure all man/*.[1x] files are present
194 ALL_RECURSIVE_TARGETS += sc_man_file_correlation
195 sc_man_file_correlation:
196 @$(MAKE) -s -C src all_programs
197 @$(MAKE) -s -C man $@
199 # Perl-based tests used to exec perl from a #!/bin/sh script.
200 # Now they all start with #!/usr/bin/perl and the portability
201 # infrastructure is in tests/Makefile.am. Make sure no old-style
202 # script sneaks back in.
203 sc_no_exec_perl_coreutils:
204 @if test -f $(srcdir)/tests/Coreutils.pm; then \
205 grep '^exec *\$$PERL.*MCoreutils' $$($(VC_LIST) tests) && \
206 { echo 1>&2 '$(ME): found anachronistic Perl-based tests'; \
207 exit 1; } || :; \
210 # Don't use "readlink" or "readlinkat" directly
211 sc_prohibit_readlink:
212 @prohibit='\<readlink(at)? \(' \
213 halt='do not use readlink(at); use via xreadlink or areadlink*' \
214 $(_sc_search_regexp)
216 # Don't use address of "stat" or "lstat" functions
217 sc_prohibit_stat_macro_address:
218 @prohibit='\<l?stat '':|&l?stat\>' \
219 halt='stat() and lstat() may be function-like macros' \
220 $(_sc_search_regexp)
222 # Ensure that date's --help output stays in sync with the info
223 # documentation for GNU strftime. The only exception is %N,
224 # which date accepts but GNU strftime does not.
225 extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/'
226 sc_strftime_check:
227 @if test -f $(srcdir)/src/date.c; then \
228 grep '^ %. ' $(srcdir)/src/date.c | sort \
229 | $(extract_char) > $@-src; \
230 { echo N; \
231 info libc date calendar format 2>/dev/null|grep '^ `%.'\'\
232 | $(extract_char); } | sort > $@-info; \
233 diff -u $@-src $@-info || exit 1; \
234 rm -f $@-src $@-info; \
237 # Indent only with spaces.
238 sc_prohibit_tab_based_indentation:
239 @prohibit='^ * ' \
240 halt='TAB in indentation; use only spaces' \
241 $(_sc_search_regexp)
243 # Don't use "indent-tabs-mode: nil" anymore. No longer needed.
244 sc_prohibit_emacs__indent_tabs_mode__setting:
245 @prohibit='^( *[*#] *)?indent-tabs-mode:' \
246 halt='use of emacs indent-tabs-mode: setting' \
247 $(_sc_search_regexp)
249 # Ensure that each file that contains fail=1 also contains fail=0.
250 # Otherwise, setting file=1 in the environment would make tests fail unexpectedly.
251 sc_prohibit_fail_0:
252 @prohibit='\<fail=0\>' \
253 halt='fail=0 initialization' \
254 $(_sc_search_regexp)
256 # Ensure that "stdio--.h" is used where appropriate.
257 sc_require_stdio_safer:
258 @if $(VC_LIST_EXCEPT) | grep -l '\.[ch]$$' > /dev/null; then \
259 files=$$(grep -l '\bfreopen \?(' $$($(VC_LIST_EXCEPT) \
260 | grep '\.[ch]$$')); \
261 test -n "$$files" && grep -LE 'include "stdio--.h"' $$files \
262 | grep . && \
263 { echo '$(ME): the above files should use "stdio--.h"' \
264 1>&2; exit 1; } || :; \
265 else :; \
268 # Prefer xnanosleep over other less-precise sleep methods
269 sc_prohibit_sleep:
270 @prohibit='\<(nano|u)?sleep \(' \
271 halt='prefer xnanosleep over other sleep interfaces' \
272 $(_sc_search_regexp)
274 ###########################################################
275 _p0 = \([^"'/]\|"\([^\"]\|[\].\)*"\|'\([^\']\|[\].\)*'
276 _pre = $(_p0)\|[/][^"'/*]\|[/]"\([^\"]\|[\].\)*"\|[/]'\([^\']\|[\].\)*'\)*
277 _pre_anchored = ^\($(_pre)\)
278 _comment_and_close = [^*]\|[*][^/*]\)*[*][*]*/
279 # help font-lock mode: '
281 # A sed expression that removes ANSI C and ISO C99 comments.
282 # Derived from the one in GNU gettext's 'moopp' preprocessor.
283 _sed_remove_comments = \
284 /[/][/*]/{ \
285 ta; \
286 :a; \
287 s,$(_pre_anchored)//.*,\1,; \
288 te; \
289 s,$(_pre_anchored)/[*]\($(_comment_and_close),\1 ,; \
290 ta; \
291 /^$(_pre)[/][*]/{ \
292 s,$(_pre_anchored)/[*].*,\1 ,; \
293 tu; \
294 :u; \
295 n; \
296 s,^\($(_comment_and_close),,; \
297 tv; \
298 s,^.*$$,,; \
299 bu; \
300 :v; \
301 }; \
302 :e; \
304 # Quote all single quotes.
305 _sed_rm_comments_q = $(subst ','\'',$(_sed_remove_comments))
306 # help font-lock mode: '
308 _space_before_paren_exempt =? \\n\\$$
309 _space_before_paren_exempt = \
310 (^ *\#|\\n\\$$|%s\(to %s|(date|group|character)\(s\))
311 # Ensure that there is a space before each open parenthesis in C code.
312 sc_space_before_open_paren:
313 @if $(VC_LIST_EXCEPT) | grep -l '\.[ch]$$' > /dev/null; then \
314 fail=0; \
315 for c in $$($(VC_LIST_EXCEPT) | grep '\.[ch]$$'); do \
316 sed '$(_sed_rm_comments_q)' $$c 2>/dev/null \
317 | grep -i '[[:alnum:]](' \
318 | grep -vE '$(_space_before_paren_exempt)' \
319 | grep . && { fail=1; echo "*** $$c"; }; \
320 done; \
321 test $$fail = 1 && \
322 { echo '$(ME): the above files lack a space-before-open-paren' \
323 1>&2; exit 1; } || :; \
324 else :; \
327 include $(srcdir)/dist-check.mk
329 update-copyright-env = \
330 UPDATE_COPYRIGHT_USE_INTERVALS=1 \
331 UPDATE_COPYRIGHT_MAX_LINE_LENGTH=79