ls: --color now highlights hard linked files, too
[coreutils/bo.git] / maint.mk
bloba7d0b860bd7fffea1d6efbaf06a56017ba11d978
1 # -*-Makefile-*-
2 # This Makefile fragment tries to be general-purpose enough to be
3 # used by at least coreutils, idutils, CPPI, Bison, and Autoconf.
5 ## Copyright (C) 2001-2008 Free Software Foundation, Inc.
6 ##
7 ## This program is free software: you can redistribute it and/or modify
8 ## it under the terms of the GNU General Public License as published by
9 ## the Free Software Foundation, either version 3 of the License, or
10 ## (at your option) any later version.
12 ## This program is distributed in the hope that it will be useful,
13 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ## GNU General Public License for more details.
17 ## You should have received a copy of the GNU General Public License
18 ## along with this program. If not, see <http://www.gnu.org/licenses/>.
20 # This is reported not to work with make-3.79.1
21 # ME := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
22 ME := maint.mk
24 # Do not save the original name or timestamp in the .tar.gz file.
25 # Use --rsyncable if available.
26 gzip_rsyncable := \
27 $(shell gzip --help 2>/dev/null|grep rsyncable >/dev/null && echo --rsyncable)
28 GZIP_ENV = '--no-name --best $(gzip_rsyncable)'
30 GIT = git
31 VC = $(GIT)
32 VC-tag = git tag -s -m '$(VERSION)'
34 VC_LIST = $(srcdir)/build-aux/vc-list-files
36 VC_LIST_EXCEPT = \
37 $(VC_LIST) | if test -f .x-$@; then grep -vEf .x-$@; else grep -v ChangeLog; fi
39 ifeq ($(origin prev_version_file), undefined)
40 prev_version_file = $(srcdir)/.prev-version
41 endif
43 PREV_VERSION := $(shell cat $(prev_version_file))
44 VERSION_REGEXP = $(subst .,\.,$(VERSION))
45 PREV_VERSION_REGEXP = $(subst .,\.,$(PREV_VERSION))
47 ifeq ($(VC),$(GIT))
48 this-vc-tag = v$(VERSION)
49 this-vc-tag-regexp = v$(VERSION_REGEXP)
50 else
51 tag-package = $(shell echo "$(PACKAGE)" | tr '[:lower:]' '[:upper:]')
52 tag-this-version = $(subst .,_,$(VERSION))
53 this-vc-tag = $(tag-package)-$(tag-this-version)
54 this-vc-tag-regexp = $(this-vc-tag)
55 endif
56 my_distdir = $(PACKAGE)-$(VERSION)
58 # Old releases are stored here.
59 release_archive_dir ?= ../release
61 # Prevent programs like 'sort' from considering distinct strings to be equal.
62 # Doing it here saves us from having to set LC_ALL elsewhere in this file.
63 export LC_ALL = C
67 ## --------------- ##
68 ## Sanity checks. ##
69 ## --------------- ##
71 # Collect the names of rules starting with `sc_'.
72 syntax-check-rules := $(shell sed -n 's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p' \
73 $(srcdir)/$(ME))
74 .PHONY: $(syntax-check-rules)
76 local-checks-available = \
77 po-check copyright-check m4-check author_mark_check \
78 patch-check strftime-check $(syntax-check-rules) \
79 makefile_path_separator_check \
80 makefile-check check-AUTHORS
81 .PHONY: $(local-checks-available)
83 local-check := $(filter-out $(local-checks-to-skip), $(local-checks-available))
85 syntax-check: $(local-check)
86 # @grep -nE '# *include <(limits|std(def|arg|bool))\.h>' \
87 # $$(find -type f -name '*.[chly]') && \
88 # { echo '$(ME): found conditional include' 1>&2; \
89 # exit 1; } || :
91 # grep -nE '^# *include <(string|stdlib)\.h>' \
92 # $(srcdir)/{lib,src}/*.[chy] && \
93 # { echo '$(ME): FIXME' 1>&2; \
94 # exit 1; } || :
95 # FIXME: don't allow `#include .strings\.h' anywhere
97 sc_avoid_if_before_free:
98 @$(srcdir)/build-aux/useless-if-before-free \
99 $(useless_free_options) \
100 $$($(VC_LIST_EXCEPT)) && \
101 { echo '$(ME): found useless "if" before "free" above' 1>&2; \
102 exit 1; } || :
104 sc_cast_of_argument_to_free:
105 @grep -nE '\<free *\( *\(' $$($(VC_LIST_EXCEPT)) && \
106 { echo '$(ME): don'\''t cast free argument' 1>&2; \
107 exit 1; } || :
109 sc_cast_of_x_alloc_return_value:
110 @grep -nE '\*\) *x(m|c|re)alloc\>' $$($(VC_LIST_EXCEPT)) && \
111 { echo '$(ME): don'\''t cast x*alloc return value' 1>&2; \
112 exit 1; } || :
114 sc_cast_of_alloca_return_value:
115 @grep -nE '\*\) *alloca\>' $$($(VC_LIST_EXCEPT)) && \
116 { echo '$(ME): don'\''t cast alloca return value' 1>&2; \
117 exit 1; } || :
119 sc_space_tab:
120 @grep -n '[ ] ' $$($(VC_LIST_EXCEPT)) && \
121 { echo '$(ME): found SPACE-TAB sequence; remove the SPACE' \
122 1>&2; exit 1; } || :
124 # Don't use *scanf or the old ato* functions in `real' code.
125 # They provide no error checking mechanism.
126 # Instead, use strto* functions.
127 sc_prohibit_atoi_atof:
128 @grep -nE '\<([fs]?scanf|ato([filq]|ll))\>' $$($(VC_LIST_EXCEPT)) && \
129 { echo '$(ME): do not use *scan''f, ato''f, ato''i, ato''l, ato''ll, ato''q, or ss''canf' \
130 1>&2; exit 1; } || :
132 # Use STREQ rather than comparing strcmp == 0, or != 0.
133 sc_prohibit_strcmp:
134 @grep -nE '! *str''cmp *\(|\<str''cmp *\([^)]+\) *==' \
135 $$($(VC_LIST_EXCEPT)) && \
136 { echo '$(ME): use STREQ in place of the above uses of str''cmp' \
137 1>&2; exit 1; } || :
139 # Using EXIT_SUCCESS as the first argument to error is misleading,
140 # since when that parameter is 0, error does not exit. Use `0' instead.
141 sc_error_exit_success:
142 @grep -nF 'error (EXIT_SUCCESS,' \
143 $$(find -type f -name '*.[chly]') && \
144 { echo '$(ME): found error (EXIT_SUCCESS' 1>&2; \
145 exit 1; } || :
147 # `FATAL:' should be fully upper-cased in error messages
148 # `WARNING:' should be fully upper-cased, or fully lower-cased
149 sc_error_message_warn_fatal:
150 @grep -nEA2 '[^rp]error \(' $$($(VC_LIST_EXCEPT)) \
151 | grep -E '"Warning|"Fatal|"fatal' && \
152 { echo '$(ME): use FATAL, WARNING or warning' 1>&2; \
153 exit 1; } || :
155 # Error messages should not start with a capital letter
156 sc_error_message_uppercase:
157 @grep -nEA2 '[^rp]error \(' $$($(VC_LIST_EXCEPT)) \
158 | grep -E '"[A-Z]' \
159 | grep -vE '"FATAL|"WARNING|"Java|"C#|PRIuMAX' && \
160 { echo '$(ME): found capitalized error message' 1>&2; \
161 exit 1; } || :
163 # Error messages should not end with a period
164 sc_error_message_period:
165 @grep -nEA2 '[^rp]error \(' $$($(VC_LIST_EXCEPT)) \
166 | grep -E '[^."]\."' && \
167 { echo '$(ME): found error message ending in period' 1>&2; \
168 exit 1; } || :
170 sc_file_system:
171 @grep -ni 'file''system' $$($(VC_LIST_EXCEPT)) && \
172 { echo '$(ME): found use of "file''system";' \
173 'rewrite to use "file system"' 1>&2; \
174 exit 1; } || :
176 # Don't use cpp tests of this symbol. All code assumes config.h is included.
177 sc_no_have_config_h:
178 @grep -n '^# *if.*HAVE''_CONFIG_H' $$($(VC_LIST_EXCEPT)) && \
179 { echo '$(ME): found use of HAVE''_CONFIG_H; remove' \
180 1>&2; exit 1; } || :
182 # Nearly all .c files must include <config.h>.
183 sc_require_config_h:
184 @if $(VC_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \
185 grep -L '^# *include <config\.h>' \
186 $$($(VC_LIST_EXCEPT) | grep '\.c$$') \
187 | grep . && \
188 { echo '$(ME): the above files do not include <config.h>' \
189 1>&2; exit 1; } || :; \
190 else :; \
193 # To use this "command" macro, you must first define two shell variables:
194 # h: the header, enclosed in <> or ""
195 # re: a regular expression that matches IFF something provided by $h is used.
196 define _header_without_use
197 h_esc=`echo "$$h"|sed 's/\./\\./'`; \
198 if $(VC_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \
199 files=$$(grep -l '^# *include '"$$h_esc" \
200 $$($(VC_LIST_EXCEPT) | grep '\.c$$')) && \
201 grep -LE "$$re" $$files | grep . && \
202 { echo "$(ME): the above files include $$h but don't use it" \
203 1>&2; exit 1; } || :; \
204 else :; \
206 endef
208 # Prohibit the inclusion of assert.h without an actual use of assert.
209 sc_prohibit_assert_without_use:
210 @h='<assert.h>' re='\<assert *\(' $(_header_without_use)
212 # Prohibit the inclusion of getopt.h without an actual use.
213 sc_prohibit_getopt_without_use:
214 @h='<getopt.h>' re='\<getopt(_long)? *\(' $(_header_without_use)
216 # Don't include quotearg.h unless you use one of its functions.
217 sc_prohibit_quotearg_without_use:
218 @h='"quotearg.h"' re='\<quotearg(_[^ ]+)? *\(' $(_header_without_use)
220 # Don't include quote.h unless you use one of its functions.
221 sc_prohibit_quote_without_use:
222 @h='"quote.h"' re='\<quote(_n)? *\(' $(_header_without_use)
224 # Don't include this header unless you use one of its functions.
225 sc_prohibit_long_options_without_use:
226 @h='"long-options.h"' re='\<parse_long_options *\(' \
227 $(_header_without_use)
229 # Don't include this header unless you use one of its functions.
230 sc_prohibit_inttostr_without_use:
231 @h='"inttostr.h"' re='\<(off|[iu]max|uint)tostr *\(' \
232 $(_header_without_use)
234 # Don't include this header unless you use one of its functions.
235 sc_prohibit_error_without_use:
236 @h='"error.h"' \
237 re='\<error(_at_line|_print_progname|_one_per_line|_message_count)? *\('\
238 $(_header_without_use)
240 sc_prohibit_safe_read_without_use:
241 @h='"safe-read.h"' re='(\<SAFE_READ_ERROR\>|\<safe_read *\()' \
242 $(_header_without_use)
244 sc_prohibit_argmatch_without_use:
245 @h='"argmatch.h"' \
246 re='(\<(ARRAY_CARDINALITY|X?ARGMATCH(|_TO_ARGUMENT|_VERIFY))\>|\<argmatch(_exit_fn|_(in)?valid) *\()' \
247 $(_header_without_use)
249 sc_prohibit_root_dev_ino_without_use:
250 @h='"root-dev-ino.h"' \
251 re='(\<ROOT_DEV_INO_(CHECK|WARN)\>|\<get_root_dev_ino *\()' \
252 $(_header_without_use)
254 sc_obsolete_symbols:
255 @grep -nE '\<(HAVE''_FCNTL_H|O''_NDELAY)\>' \
256 $$($(VC_LIST_EXCEPT)) && \
257 { echo '$(ME): do not use HAVE''_FCNTL_H or O''_NDELAY' \
258 1>&2; exit 1; } || :
260 # FIXME: warn about definitions of EXIT_FAILURE, EXIT_SUCCESS, STREQ
262 # Each nonempty line must start with a year number, or a TAB.
263 sc_changelog:
264 @grep -n '^[^12 ]' $$(find . -maxdepth 2 -name ChangeLog) && \
265 { echo '$(ME): found unexpected prefix in a ChangeLog' 1>&2; \
266 exit 1; } || :
268 # Ensure that dd's definition of LONGEST_SYMBOL stays in sync
269 # with the strings from the two affected variables.
270 dd_c = $(srcdir)/src/dd.c
271 sc_dd_max_sym_length:
272 ifneq ($(wildcard $(dd_c)),)
273 @len=$$( (sed -n '/conversions\[\] =$$/,/^};/p' $(dd_c);\
274 sed -n '/flags\[\] =$$/,/^};/p' $(dd_c) ) \
275 |sed -n '/"/s/^[^"]*"\([^"]*\)".*/\1/p' \
276 | wc --max-line-length); \
277 max=$$(sed -n '/^#define LONGEST_SYMBOL /s///p' $(dd_c) \
278 |tr -d '"' | wc --max-line-length); \
279 if test "$$len" = "$$max"; then :; else \
280 echo 'dd.c: LONGEST_SYMBOL is not longest' 1>&2; \
281 exit 1; \
283 endif
285 # Many m4 macros names once began with `jm_'.
286 # On 2004-04-13, they were all changed to start with gl_ instead.
287 # Make sure that none are inadvertently reintroduced.
288 sc_prohibit_jm_in_m4:
289 @grep -nE 'jm_[A-Z]' \
290 $$($(VC_LIST) m4 |grep '\.m4$$'; echo /dev/null) && \
291 { echo '$(ME): do not use jm_ in m4 macro names' \
292 1>&2; exit 1; } || :
294 # Ensure that each root-requiring test is run via the "check-root" rule.
295 sc_root_tests:
296 @if test -d tests \
297 && grep check-root tests/Makefile.am>/dev/null 2>&1; then \
298 t1=sc-root.expected; t2=sc-root.actual; \
299 grep -nl '^require_root_$$' \
300 $$($(VC_LIST) tests) |sed s,tests/,, |sort > $$t1; \
301 sed -n '/^root_tests =[ ]*\\$$/,/[^\]$$/p' \
302 $(srcdir)/tests/Makefile.am \
303 | sed 's/^ *//;/^root_tests =/d' \
304 | tr -s '\012\\' ' ' | fmt -1 | sort > $$t2; \
305 diff -u $$t1 $$t2 || diff=1; \
306 rm -f $$t1 $$t2; \
307 test "$$diff" \
308 && { echo 'tests/Makefile.am: missing check-root action'>&2; \
309 exit 1; } || :; \
312 headers_with_interesting_macro_defs = \
313 exit.h \
314 fcntl_.h \
315 fnmatch_.h \
316 intprops.h \
317 inttypes_.h \
318 lchown.h \
319 openat.h \
320 stat-macros.h \
321 stdint_.h
323 # Create a list of regular expressions matching the names
324 # of macros that are guaranteed by parts of gnulib to be defined.
325 .re-defmac:
326 @(cd $(srcdir)/lib; \
327 for f in $(headers_with_interesting_macro_defs); do \
328 test -f $$f && \
329 sed -n '/^# *define \([^_ (][^ (]*\)[ (].*/s//\1/p' $$f; \
330 done; \
331 ) | sort -u \
332 | grep -Ev 'ATTRIBUTE_NORETURN|SIZE_MAX' \
333 | sed 's/^/^# *define /' \
334 > $@-t
335 @mv $@-t $@
337 # Don't define macros that we already get from gnulib header files.
338 sc_always_defined_macros: .re-defmac
339 @if test -f $(srcdir)/src/system.h; then \
340 trap 'rc=$$?; rm -f .re-defmac; exit $$rc' 0 1 2 3 15; \
341 grep -f .re-defmac $$($(VC_LIST)) \
342 && { echo '$(ME): define the above via some gnulib .h file' \
343 1>&2; exit 1; } || :; \
346 # Create a list of regular expressions matching the names
347 # of files included from system.h. Exclude a couple.
348 .re-list:
349 @sed -n '/^# *include /s///p' $(srcdir)/src/system.h \
350 | grep -Ev 'sys/(param|file)\.h' \
351 | sed 's/ .*//;;s/^["<]/^# *include [<"]/;s/\.h[">]$$/\\.h[">]/' \
352 > $@-t
353 @mv $@-t $@
355 # Files in src/ should not include directly any of
356 # the headers already included via system.h.
357 sc_system_h_headers: .re-list
358 @if test -f $(srcdir)/src/system.h; then \
359 trap 'rc=$$?; rm -f .re-list; exit $$rc' 0 1 2 3 15; \
360 grep -nE -f .re-list \
361 $$($(VC_LIST) src | \
362 grep -Ev '((copy|system)\.h|parse-gram\.c)$$') \
363 && { echo '$(ME): the above are already included via system.h'\
364 1>&2; exit 1; } || :; \
367 # Ensure that each .c file containing a "main" function also
368 # calls set_program_name.
369 sc_program_name:
370 @if $(VC_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \
371 files=$$(grep -l '^main *(' $$($(VC_LIST_EXCEPT) | grep '\.c$$')); \
372 grep -LE 'set_program_name *\(m?argv\[0\]\);' $$files \
373 | grep . && \
374 { echo '$(ME): the above files do not call set_program_name' \
375 1>&2; exit 1; } || :; \
376 else :; \
379 # Require that the final line of each test-lib.sh-using test be this one:
380 # Exit $fail
381 # Note: this test requires GNU grep's --label= option.
382 sc_require_test_exit_idiom:
383 @if test -f $(srcdir)/tests/test-lib.sh; then \
384 die=0; \
385 for i in $$(grep -l -F /../test-lib.sh $$($(VC_LIST) tests)); do \
386 tail -n1 $$i | grep '^Exit \$$fail$$' > /dev/null \
387 && : || { die=1; echo $$i; } \
388 done; \
389 test $$die = 1 && \
390 { echo 1>&2 '$(ME): the final line in each of the above is not:'; \
391 echo 1>&2 'Exit $$fail'; \
392 exit 1; } || :; \
395 sc_sun_os_names:
396 @grep -nEi \
397 'solaris[^[:alnum:]]*2\.(7|8|9|[1-9][0-9])|sunos[^[:alnum:]][6-9]' \
398 $$($(VC_LIST_EXCEPT)) && \
399 { echo '$(ME): found misuse of Sun OS version numbers' 1>&2; \
400 exit 1; } || :
402 sc_the_the:
403 @grep -ni '\<the ''the\>' $$($(VC_LIST_EXCEPT)) && \
404 { echo '$(ME): found use of "the ''the";' 1>&2; \
405 exit 1; } || :
407 sc_tight_scope:
408 $(MAKE) -C src $@
410 sc_trailing_blank:
411 @grep -n '[ ]$$' $$($(VC_LIST_EXCEPT)) && \
412 { echo '$(ME): found trailing blank(s)' \
413 1>&2; exit 1; } || :
415 # Match lines like the following, but where there is only one space
416 # between the options and the description:
417 # -D, --all-repeated[=delimit-method] print all duplicate lines\n
418 longopt_re = --[a-z][0-9A-Za-z-]*(\[?=[0-9A-Za-z-]*\]?)?
419 sc_two_space_separator_in_usage:
420 @grep -nE '^ *(-[A-Za-z],)? $(longopt_re) [^ ].*\\$$' \
421 $$($(VC_LIST_EXCEPT)) && \
422 { echo "$(ME): help2man requires at least two spaces between"; \
423 echo "$(ME): an option and its description"; \
424 1>&2; exit 1; } || :
426 # Look for diagnostics that aren't marked for translation.
427 # This won't find any for which error's format string is on a separate line.
428 sc_unmarked_diagnostics:
429 @grep -nE \
430 '\<error \([^"]*"[^"]*[a-z]{3}' $$($(VC_LIST_EXCEPT)) \
431 | grep -v '_''(' && \
432 { echo '$(ME): found unmarked diagnostic(s)' 1>&2; \
433 exit 1; } || :
435 # Avoid useless parentheses like those in this example:
436 # #if defined (SYMBOL) || defined (SYM2)
437 sc_useless_cpp_parens:
438 @grep -n '^# *if .*defined *(' $$($(VC_LIST_EXCEPT)) && \
439 { echo '$(ME): found useless parentheses in cpp directive' \
440 1>&2; exit 1; } || :
442 # Require the latest GPL.
443 sc_GPL_version:
444 @grep -n 'either ''version [^3]' $$($(VC_LIST_EXCEPT)) && \
445 { echo '$(ME): GPL vN, N!=3' 1>&2; exit 1; } || :
447 # Perl-based tests used to exec perl from a #!/bin/sh script.
448 # Now they all start with #!/usr/bin/perl and the portability
449 # infrastructure is in tests/Makefile.am. Make sure no old-style
450 # script sneaks back in.
451 sc_no_exec_perl_coreutils:
452 @if test -f $(srcdir)/tests/Coreutils.pm; then \
453 grep '^exec *\$$PERL.*MCoreutils' $$($(VC_LIST) tests) && \
454 { echo 1>&2 '$(ME): found anachronistic Perl-based tests'; \
455 exit 1; } || :; \
458 # Make sure we don't use st_blocks. Use ST_NBLOCKS instead.
459 # This is a bit of a kludge, since it prevents use of the string
460 # even in comments, but for now it does the job with no false positives.
461 sc_prohibit_stat_st_blocks:
462 @grep -nE '[.>]st_blocks' $$($(VC_LIST_EXCEPT)) && \
463 { echo '$(ME): do not use st_blocks; use ST_NBLOCKS' \
464 1>&2; exit 1; } || :
466 # Make sure we don't define any S_IS* macros in src/*.c files.
467 # They're already defined via gnulib's sys/stat.h replacement.
468 sc_prohibit_S_IS_definition:
469 @grep -nE '^ *# *define *S_IS' $$($(VC_LIST_EXCEPT)) && \
470 { echo '$(ME): do not define S_IS* macros; include <sys/stat.h>' \
471 1>&2; exit 1; } || :
473 NEWS_hash = \
474 $$(sed -n '/^\*.* $(PREV_VERSION_REGEXP) ([0-9-]*)/,$$p' \
475 $(srcdir)/NEWS | md5sum -)
477 # Ensure that we don't accidentally insert an entry into an old NEWS block.
478 sc_immutable_NEWS:
479 @if test -f $(srcdir)/NEWS; then \
480 test "$(NEWS_hash)" = '$(old_NEWS_hash)' && : || \
481 { echo '$(ME): you have modified old NEWS' 1>&2; exit 1; }; \
484 # Each program that uses proper_name_utf8 must link with
485 # one of the ICONV libraries.
486 sc_proper_name_utf8_requires_ICONV:
487 @progs=$$(grep -l 'proper_name_utf8 ''("' $$($(VC_LIST_EXCEPT)));\
488 if test "x$$progs" != x; then \
489 fail=0; \
490 for p in $$progs; do \
491 dir=$$(dirname "$$p"); \
492 base=$$(basename "$$p" .c); \
493 grep "$${base}_LDADD.*ICONV)" $$dir/Makefile.am > /dev/null \
494 || { fail=1; echo 1>&2 "$(ME): $$p uses proper_name_utf8"; }; \
495 done; \
496 test $$fail = 1 && \
497 { echo 1>&2 '$(ME): the above do not link with any ICONV library'; \
498 exit 1; } || :; \
501 # Warn about "c0nst struct Foo const foo[]",
502 # but not about "char const *const foo" or "#define const const".
503 sc_redundant_const:
504 @grep -E '\bconst\b[[:space:][:alnum:]]{2,}\bconst\b' \
505 $$($(VC_LIST_EXCEPT)) && \
506 { echo 1>&2 '$(ME): redundant "const" in declarations'; \
507 exit 1; } || :
509 sc_const_long_option:
510 @grep '^ *static.*struct option ' $$($(VC_LIST_EXCEPT)) \
511 | grep -Ev 'const struct option|struct option const' && { \
512 echo 1>&2 '$(ME): add "const" to the above declarations'; \
513 exit 1; } || :
515 # Update the hash stored above. Do this after each release and
516 # for any corrections to old entries.
517 update-NEWS-hash: NEWS
518 perl -pi -e 's/^(old_NEWS_hash = ).*/$${1}'"$(NEWS_hash)/" \
519 $(srcdir)/cfg.mk
521 epoch_date = 1970-01-01 00:00:00.000000000 +0000
522 # Ensure that the c99-to-c89 patch applies cleanly.
523 patch-check:
524 rm -rf src-c89 $@.1 $@.2
525 cp -a $(srcdir)/src src-c89
526 if test "x$(srcdir)" != x.; then \
527 cp -a src/* src-c89; \
528 dotfiles=`ls src/.[!.]* 2>/dev/null`; \
529 test -z "$$dotfiles" || cp -a src/.[!.]* src-c89; \
531 (cd src-c89; patch -p1 -V never --fuzz=0) < $(srcdir)/src/c99-to-c89.diff \
532 > $@.1 2>&1
533 if test "$(REGEN_PATCH)" = yes; then \
534 diff -upr $(srcdir)/src src-c89 | sed 's,$(srcdir)/src-c89/,src/,' \
535 | grep -vE '^(Only in|File )' \
536 | perl -pe 's/^((?:\+\+\+|---) \S+\t).*/$${1}$(epoch_date)/;' \
537 -e 's/^ $$//' \
538 > new-diff || : ; fi
539 grep -v '^patching file ' $@.1 > $@.2 || :
540 msg=ok; test -s $@.2 && msg='fuzzy patch' || : ; \
541 rm -f src-c89/*.o || msg='rm failed'; \
542 $(MAKE) -C src-c89 CFLAGS='-Wdeclaration-after-statement -Werror' \
543 || msg='compile failure with extra options'; \
544 test "$$msg" = ok && rm -rf src-c89 $@.1 $@.2 || echo "$$msg" 1>&2; \
545 test "$$msg" = ok
547 # Ensure that date's --help output stays in sync with the info
548 # documentation for GNU strftime. The only exception is %N,
549 # which date accepts but GNU strftime does not.
550 extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/'
551 strftime-check:
552 if test -f $(srcdir)/src/date.c; then \
553 grep '^ %. ' $(srcdir)/src/date.c | sort \
554 | $(extract_char) > $@-src; \
555 { echo N; \
556 info libc date calendar format | grep '^ `%.'\' \
557 | $(extract_char); } | sort > $@-info; \
558 diff -u $@-src $@-info || exit 1; \
559 rm -f $@-src $@-info; \
562 check-AUTHORS:
563 $(MAKE) -C src $@
565 # Ensure that we use only the standard $(VAR) notation,
566 # not @...@ in Makefile.am, now that we can rely on automake
567 # to emit a definition for each substituted variable.
568 # We use perl rather than "grep -nE ..." to exempt a single
569 # use of an @...@-delimited variable name in src/Makefile.am.
570 makefile-check:
571 @perl -ne '/\@[A-Z_0-9]+\@/ && !/^cu_install_program =/' \
572 -e 'and (print "$$ARGV:$$.: $$_"), $$m=1; END {exit !$$m}' \
573 $$($(VC_LIST_EXCEPT) | grep -E '(^|/)Makefile\.am$$') \
574 && { echo '$(ME): use $$(...), not @...@' 1>&2; exit 1; } || :
576 news-date-check: NEWS
577 today=`date +%Y-%m-%d`; \
578 if head NEWS | grep '^\*.* $(VERSION_REGEXP) ('$$today')' \
579 >/dev/null; then \
580 :; \
581 else \
582 echo "version or today's date is not in NEWS" 1>&2; \
583 exit 1; \
586 changelog-check:
587 if head ChangeLog | grep 'Version $(VERSION_REGEXP)\.$$' \
588 >/dev/null; then \
589 :; \
590 else \
591 echo "$(VERSION) not in ChangeLog" 1>&2; \
592 exit 1; \
595 m4-check:
596 @grep -n 'AC_DEFUN([^[]' m4/*.m4 \
597 && { echo '$(ME): quote the first arg to AC_DEFUN' 1>&2; \
598 exit 1; } || :
600 fix_po_file_diag = \
601 'you have changed the set of files with translatable diagnostics;\n\
602 apply the above patch\n'
604 # Verify that all source files using _() are listed in po/POTFILES.in.
605 po_file = po/POTFILES.in
606 po-check:
607 @if test -f $(po_file); then \
608 grep -E -v '^(#|$$)' $(po_file) \
609 | grep -v '^src/false\.c$$' | sort > $@-1; \
610 files=; \
611 for file in $$($(VC_LIST_EXCEPT)) lib/*.[ch]; do \
612 case $$file in \
613 *.?|*.??) ;; \
614 *) continue;; \
615 esac; \
616 case $$file in \
617 *.[ch]) \
618 base=`expr " $$file" : ' \(.*\)\..'`; \
619 { test -f $$base.l || test -f $$base.y; } && continue;; \
620 esac; \
621 files="$$files $$file"; \
622 done; \
623 grep -E -l '\b(N?_|gettext *)\([^)"]*("|$$)' $$files \
624 | sort -u > $@-2; \
625 diff -u -L $(po_file) -L $(po_file) $@-1 $@-2 \
626 || { printf '$(ME): '$(fix_po_file_diag) 1>&2; exit 1; }; \
627 rm -f $@-1 $@-2; \
630 # In a definition of #define AUTHORS "... and ..." where the RHS contains
631 # the English word `and', the string must be marked with `N_ (...)' so that
632 # gettext recognizes it as a string requiring translation.
633 author_mark_check:
634 @grep -n '^# *define AUTHORS "[^"]* and ' src/*.c |grep -v ' N_ (' && \
635 { echo '$(ME): enclose the above strings in N_ (...)' 1>&2; \
636 exit 1; } || :
638 # Sometimes it is useful to change the PATH environment variable
639 # in Makefiles. When doing so, it's better not to use the Unix-centric
640 # path separator of `:', but rather the automake-provided `@PATH_SEPARATOR@'.
641 # It'd be better to use `find -print0 ...|xargs -0 ...', but less portable,
642 # and there probably aren't many projects with so many Makefile.am files
643 # that we'd have to worry about limits on command line length.
644 msg = '$(ME): Do not use `:'\'' above; use @PATH_SEPARATOR@ instead'
645 makefile_path_separator_check:
646 @grep -n 'PATH=.*:' `find $(srcdir) -name Makefile.am` \
647 && { echo $(msg) 1>&2; exit 1; } || :
649 # Check that `make alpha' will not fail at the end of the process.
650 writable-files:
651 if test -d $(release_archive_dir); then :; else \
652 for file in $(distdir).tar.gz \
653 $(release_archive_dir)/$(distdir).tar.gz; do \
654 test -e $$file || continue; \
655 test -w $$file \
656 || { echo ERROR: $$file is not writable; fail=1; }; \
657 done; \
658 test "$$fail" && exit 1 || : ; \
661 v_etc_file = lib/version-etc.c
662 sample-test = tests/sample-test
663 texi = doc/$(PACKAGE).texi
664 # Make sure that the copyright date in $(v_etc_file) is up to date.
665 # Do the same for the $(sample-test) and the main doc/.texi file.
666 copyright-check:
667 @if test -f $(v_etc_file); then \
668 grep 'enum { COPYRIGHT_YEAR = '$$(date +%Y)' };' $(v_etc_file) \
669 >/dev/null \
670 || { echo 'out of date copyright in $(v_etc_file); update it' 1>&2; \
671 exit 1; }; \
673 @if test -f $(sample-test); then \
674 grep '# Copyright (C) '$$(date +%Y)' Free' $(sample-test) \
675 >/dev/null \
676 || { echo 'out of date copyright in $(sample-test); update it' 1>&2; \
677 exit 1; }; \
679 @if test -f $(texi); then \
680 grep 'Copyright @copyright{} .*'$$(date +%Y)' Free' $(texi) \
681 >/dev/null \
682 || { echo 'out of date copyright in $(texi); update it' 1>&2; \
683 exit 1; }; \
686 vc-diff-check:
687 $(VC) diff > vc-diffs || :
688 if test -s vc-diffs; then \
689 cat vc-diffs; \
690 echo "Some files are locally modified:" 1>&2; \
691 exit 1; \
692 else \
693 rm vc-diffs; \
696 cvs-check: vc-diff-check
698 maintainer-distcheck:
699 $(MAKE) distcheck
700 $(MAKE) taint-distcheck
701 $(MAKE) my-distcheck
704 # Don't make a distribution if checks fail.
705 # Also, make sure the NEWS file is up-to-date.
706 vc-dist: $(local-check) cvs-check maintainer-distcheck
707 $(MAKE) dist
709 # Use this to make sure we don't run these programs when building
710 # from a virgin tgz file, below.
711 null_AM_MAKEFLAGS = \
712 ACLOCAL=false \
713 AUTOCONF=false \
714 AUTOMAKE=false \
715 AUTOHEADER=false \
716 MAKEINFO=false
718 built_programs = $$(cd src && MAKEFLAGS= $(MAKE) -s built_programs.list)
720 warn_cflags = -Dlint -O -Werror -Wall -Wformat -Wshadow -Wpointer-arith
721 bin=bin-$$$$
723 write_loser = printf '\#!%s\necho $$0: bad path 1>&2; exit 1\n' '$(SHELL)'
725 TMPDIR ?= /tmp
726 t=$(TMPDIR)/$(PACKAGE)/test
727 pfx=$(t)/i
729 # More than once, tainted build and source directory names would
730 # have caused at least one "make check" test to apply "chmod 700"
731 # to all directories under $HOME. Make sure it doesn't happen again.
732 tp := $(shell echo "$(TMPDIR)/$(PACKAGE)-$$$$")
733 t_prefix = $(tp)/a
734 t_taint = '$(t_prefix) b'
735 fake_home = $(tp)/home
737 # Ensure that tests run from tainted build and src dir names work,
738 # and don't affect anything in $HOME. Create witness files in $HOME,
739 # record their attributes, and build/test. Then ensure that the
740 # witnesses were not affected.
741 taint-distcheck: $(DIST_ARCHIVES)
742 test -d $(t_taint) && chmod -R 700 $(t_taint) || :
743 -rm -rf $(t_taint) $(fake_home)
744 mkdir -p $(t_prefix) $(t_taint) $(fake_home)
745 GZIP=$(GZIP_ENV) $(AMTAR) -C $(t_taint) -zxf $(distdir).tar.gz
746 mkfifo $(fake_home)/fifo
747 touch $(fake_home)/f
748 mkdir -p $(fake_home)/d/e
749 ls -lR $(fake_home) $(t_prefix) > $(tp)/.ls-before
750 cd $(t_taint)/$(distdir) \
751 && ./configure \
752 && $(MAKE) \
753 && HOME=$(fake_home) $(MAKE) check \
754 && ls -lR $(fake_home) $(t_prefix) > $(tp)/.ls-after \
755 && diff $(tp)/.ls-before $(tp)/.ls-after \
756 && test -d $(t_prefix)
757 rm -rf $(tp)
759 # Verify that a twisted use of --program-transform-name=PROGRAM works.
760 define install-transform-check
761 rm -rf $(pfx); \
762 $(MAKE) program_transform_name='s/.*/zyx/' \
763 prefix=$(pfx) install \
764 && test "$$(echo $(pfx)/bin/*)" = "$(pfx)/bin/zyx" \
765 && test "$$(echo $(pfx)/share/man/man1/*)" = \
766 "$(pfx)/share/man/man1/zyx.1"
767 endef
769 # Install, then verify that all binaries and man pages are in place.
770 # Note that neither the binary, ginstall, nor the ].1 man page is installed.
771 define my-instcheck
772 $(MAKE) prefix=$(pfx) install \
773 && test ! -f $(pfx)/bin/ginstall \
774 && { fail=0; \
775 for i in $(built_programs); do \
776 test "$$i" = ginstall && i=install; \
777 for j in "$(pfx)/bin/$$i" \
778 "$(pfx)/share/man/man1/$$i.1"; do \
779 case $$j in *'[.1') continue;; esac; \
780 test -f "$$j" && : \
781 || { echo "$$j not installed"; fail=1; }; \
782 done; \
783 done; \
784 test $$fail = 1 && exit 1 || :; \
786 endef
788 define coreutils-path-check
790 if test -f $(srcdir)/src/true.c; then \
791 fail=1; \
792 mkdir $(bin) \
793 && ($(write_loser)) > $(bin)/loser \
794 && chmod a+x $(bin)/loser \
795 && for i in $(built_programs); do \
796 case $$i in \
797 rm|expr|basename|echo|sort|ls|tr);; \
798 cat|dirname|mv|wc);; \
799 *) ln $(bin)/loser $(bin)/$$i;; \
800 esac; \
801 done \
802 && ln -sf ../src/true $(bin)/false \
803 && PATH=`pwd`/$(bin):$$PATH $(MAKE) -C tests check \
804 && { test -d gnulib-tests \
805 && $(MAKE) -C gnulib-tests check \
806 || :; } \
807 && rm -rf $(bin) \
808 && fail=0; \
809 else \
810 fail=0; \
811 fi; \
812 test $$fail = 1 && exit 1 || :; \
814 endef
816 # Use -Wformat -Werror to detect format-string/arg-list mismatches.
817 # Also, check for shadowing problems with -Wshadow, and for pointer
818 # arithmetic problems with -Wpointer-arith.
819 # These CFLAGS are pretty strict. If you build this target, you probably
820 # have to have a recent version of gcc and glibc headers.
821 # The hard-linking for-loop below ensures that there is a bin/ directory
822 # full of all of the programs under test (except the ones that are required
823 # for basic Makefile rules), all symlinked to the just-built "false" program.
824 # This is to ensure that if ever a test neglects to make PATH include
825 # the build srcdir, these always-failing programs will run.
826 # Otherwise, it is too easy to test the wrong programs.
827 # Note that "false" itself is a symlink to true, so it too will malfunction.
828 my-distcheck: $(DIST_ARCHIVES) $(local-check)
829 $(MAKE) syntax-check
830 $(MAKE) check
831 -rm -rf $(t)
832 mkdir -p $(t)
833 GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
834 cd $(t)/$(distdir) \
835 && ./configure --disable-nls \
836 && $(MAKE) CFLAGS='$(warn_cflags)' \
837 AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)' \
838 && $(MAKE) dvi \
839 && $(install-transform-check) \
840 && $(my-instcheck) \
841 && $(coreutils-path-check) \
842 && $(MAKE) distclean
843 (cd $(t) && mv $(distdir) $(distdir).old \
844 && $(AMTAR) -zxf - ) < $(distdir).tar.gz
845 diff -ur $(t)/$(distdir).old $(t)/$(distdir)
846 -rm -rf $(t)
847 @echo "========================"; \
848 echo "$(distdir).tar.gz is ready for distribution"; \
849 echo "========================"
851 WGET = wget
852 WGETFLAGS = -C off
854 rel-check:
855 tarz=/tmp/rel-check-tarz-$$$$; \
856 md5_tmp=/tmp/rel-check-md5-$$$$; \
857 set -e; \
858 trap 'status=$$?; rm -f $$tarz $$md5_tmp; exit $$status' 0 1 2 3 15; \
859 $(WGET) $(WGETFLAGS) -q --output-document=$$tarz $(url); \
860 echo "$(md5) -" > $$md5_tmp; \
861 md5sum -c $$md5_tmp < $$tarz
863 rel-files = $(DIST_ARCHIVES)
865 gnulib-version = $$(cd $(gnulib_dir) && git describe)
867 announcement: NEWS ChangeLog $(rel-files)
868 @./build-aux/announce-gen \
869 --release-type=$(RELEASE_TYPE) \
870 --package=$(PACKAGE) \
871 --prev=$(PREV_VERSION) \
872 --curr=$(VERSION) \
873 --gpg-key-id=$(gpg_key_ID) \
874 --news=NEWS \
875 --bootstrap-tools=autoconf,automake,bison,gnulib \
876 --gnulib-version=$(gnulib-version) \
877 $(addprefix --url-dir=, $(url_dir_list))
879 ## ---------------- ##
880 ## Updating files. ##
881 ## ---------------- ##
883 ftp-gnu = ftp://ftp.gnu.org/gnu
884 www-gnu = http://www.gnu.org
886 # Use mv, if you don't have/want move-if-change.
887 move_if_change ?= move-if-change
889 emit_upload_commands:
890 @echo =====================================
891 @echo =====================================
892 @echo "$(srcdir)/build-aux/gnupload $(GNUPLOADFLAGS) \\"
893 @echo " --to $(gnu_rel_host):$(PACKAGE) \\"
894 @echo " $(rel-files)"
895 @echo '# send the /tmp/announcement e-mail'
896 @echo =====================================
897 @echo =====================================
899 noteworthy = * Noteworthy changes in release ?.? (????-??-??) [?]
900 define emit-commit-log
901 printf '%s\n' 'post-release administrivia' '' \
902 '* NEWS: Add header line for next release.' \
903 '* .prev-version: Record previous version.' \
904 '* cfg.mk (old_NEWS_hash): Auto-update.'
905 endef
907 .PHONY: alpha beta major
908 alpha beta major: $(local-check) writable-files
909 test $@ = major \
910 && { echo $(VERSION) | grep -E '^[0-9]+(\.[0-9]+)+$$' \
911 || { echo "invalid version string: $(VERSION)" 1>&2; exit 1;};}\
912 || :
913 $(MAKE) vc-dist
914 $(MAKE) news-date-check
915 $(MAKE) -s announcement RELEASE_TYPE=$@ > /tmp/announce-$(my_distdir)
916 if test -d $(release_archive_dir); then \
917 ln $(rel-files) $(release_archive_dir); \
918 chmod a-w $(rel-files); \
920 $(MAKE) -s emit_upload_commands RELEASE_TYPE=$@
921 echo $(VERSION) > $(prev_version_file)
922 $(MAKE) update-NEWS-hash
923 perl -pi -e '$$. == 3 and print "$(noteworthy)\n\n\n"' NEWS
924 $(emit-commit-log) > .ci-msg
925 $(VC) commit -F .ci-msg -a