* src/dircolors.hin: Add .flv. Move .svgz to "image formats".
[coreutils.git] / maint.mk
blob6933a3c0fe7ef0591970f985299abea67186cb7f
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 = 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))
46 ifeq ($(VC),$(GIT))
47 this-vc-tag = v$(VERSION)
48 this-vc-tag-regexp = v$(VERSION_REGEXP)
49 else
50 tag-package = $(shell echo "$(PACKAGE)" | tr '[:lower:]' '[:upper:]')
51 tag-this-version = $(subst .,_,$(VERSION))
52 this-vc-tag = $(tag-package)-$(tag-this-version)
53 this-vc-tag-regexp = $(this-vc-tag)
54 endif
55 my_distdir = $(PACKAGE)-$(VERSION)
57 # Old releases are stored here.
58 release_archive_dir ?= ../release
60 # Prevent programs like 'sort' from considering distinct strings to be equal.
61 # Doing it here saves us from having to set LC_ALL elsewhere in this file.
62 export LC_ALL = C
66 ## --------------- ##
67 ## Sanity checks. ##
68 ## --------------- ##
70 # Collect the names of rules starting with `sc_'.
71 syntax-check-rules := $(shell sed -n 's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p' \
72 $(srcdir)/$(ME))
73 .PHONY: $(syntax-check-rules)
75 local-checks-available = \
76 po-check copyright-check m4-check author_mark_check \
77 patch-check strftime-check $(syntax-check-rules) \
78 makefile_path_separator_check \
79 makefile-check check-AUTHORS
80 .PHONY: $(local-checks-available)
82 local-check := $(filter-out $(local-checks-to-skip), $(local-checks-available))
84 syntax-check: $(local-check)
85 # @grep -nE '# *include <(limits|std(def|arg|bool))\.h>' \
86 # $$(find -type f -name '*.[chly]') && \
87 # { echo '$(ME): found conditional include' 1>&2; \
88 # exit 1; } || :
90 # grep -nE '^# *include <(string|stdlib)\.h>' \
91 # $(srcdir)/{lib,src}/*.[chy] && \
92 # { echo '$(ME): FIXME' 1>&2; \
93 # exit 1; } || :
94 # FIXME: don't allow `#include .strings\.h' anywhere
96 sc_avoid_if_before_free:
97 @$(srcdir)/build-aux/useless-if-before-free \
98 $(useless_free_options) \
99 $$($(VC_LIST_EXCEPT)) && \
100 { echo '$(ME): found useless "if" before "free" above' 1>&2; \
101 exit 1; } || :
103 sc_cast_of_argument_to_free:
104 @grep -nE '\<free \(\(' $$($(VC_LIST_EXCEPT)) && \
105 { echo '$(ME): don'\''t cast free argument' 1>&2; \
106 exit 1; } || :
108 sc_cast_of_x_alloc_return_value:
109 @grep -nE '\*\) *x(m|c|re)alloc\>' $$($(VC_LIST_EXCEPT)) && \
110 { echo '$(ME): don'\''t cast x*alloc return value' 1>&2; \
111 exit 1; } || :
113 sc_cast_of_alloca_return_value:
114 @grep -nE '\*\) *alloca\>' $$($(VC_LIST_EXCEPT)) && \
115 { echo '$(ME): don'\''t cast alloca return value' 1>&2; \
116 exit 1; } || :
118 sc_space_tab:
119 @grep -n '[ ] ' $$($(VC_LIST_EXCEPT)) && \
120 { echo '$(ME): found SPACE-TAB sequence; remove the SPACE' \
121 1>&2; exit 1; } || :
123 # Don't use *scanf or the old ato* functions in `real' code.
124 # They provide no error checking mechanism.
125 # Instead, use strto* functions.
126 sc_prohibit_atoi_atof:
127 @grep -nE '\<([fs]?scanf|ato([filq]|ll))\>' $$($(VC_LIST_EXCEPT)) && \
128 { echo '$(ME): do not use *scan''f, ato''f, ato''i, ato''l, ato''ll, ato''q, or ss''canf' \
129 1>&2; exit 1; } || :
131 # Use STREQ rather than comparing strcmp == 0, or != 0.
132 sc_prohibit_strcmp:
133 @grep -nE '! *str''cmp \(|\<str''cmp \([^)]+\) *==' \
134 $$($(VC_LIST_EXCEPT)) && \
135 { echo '$(ME): use STREQ in place of the above uses of str''cmp' \
136 1>&2; exit 1; } || :
138 # Using EXIT_SUCCESS as the first argument to error is misleading,
139 # since when that parameter is 0, error does not exit. Use `0' instead.
140 sc_error_exit_success:
141 @grep -nF 'error (EXIT_SUCCESS,' \
142 $$(find -type f -name '*.[chly]') && \
143 { echo '$(ME): found error (EXIT_SUCCESS' 1>&2; \
144 exit 1; } || :
146 sc_file_system:
147 @grep -ni 'file''system' $$($(VC_LIST_EXCEPT)) && \
148 { echo '$(ME): found use of "file''system";' \
149 'rewrite to use "file system"' 1>&2; \
150 exit 1; } || :
152 sc_no_have_config_h:
153 @grep -n '^# *if.*HAVE''_CONFIG_H' $$($(VC_LIST_EXCEPT)) && \
154 { echo '$(ME): found use of HAVE''_CONFIG_H; remove' \
155 1>&2; exit 1; } || :
157 # Nearly all .c files must include <config.h>.
158 sc_require_config_h:
159 @if $(VC_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \
160 grep -L '^# *include <config\.h>' \
161 $$($(VC_LIST_EXCEPT) | grep '\.c$$') \
162 | grep . && \
163 { echo '$(ME): the above files do not include <config.h>' \
164 1>&2; exit 1; } || :; \
165 else :; \
168 # To use this "command" macro, you must first define two shell variables:
169 # h: the header, enclosed in <> or ""
170 # re: a regular expression that matches IFF something provided by $h is used.
171 define _header_without_use
172 h_esc=`echo "$$h"|sed 's/\./\\./'`; \
173 if $(VC_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \
174 files=$$(grep -l '^# *include '"$$h_esc" \
175 $$($(VC_LIST_EXCEPT) | grep '\.c$$')) && \
176 grep -LE "$$re" $$files | grep . && \
177 { echo "$(ME): the above files include $$h but don't use it" \
178 1>&2; exit 1; } || :; \
179 else :; \
181 endef
183 # Prohibit the inclusion of assert.h without an actual use of assert.
184 sc_prohibit_assert_without_use:
185 @h='<assert.h>' re='\<assert *\(' $(_header_without_use)
187 # Prohibit the inclusion of getopt.h without an actual use.
188 sc_prohibit_getopt_without_use:
189 @h='<getopt.h>' re='\<getopt(_long)? *\(' $(_header_without_use)
191 # Don't include quotearg.h unless you use one of its functions.
192 sc_prohibit_quotearg_without_use:
193 @h='"quotearg.h"' re='\<quotearg(_[^ ]+)? *\(' $(_header_without_use)
195 # Don't include quote.h unless you use one of its functions.
196 sc_prohibit_quote_without_use:
197 @h='"quote.h"' re='\<quote(_n)? *\(' $(_header_without_use)
199 # Don't include this header unless you use one of its functions.
200 sc_prohibit_long_options_without_use:
201 @h='"long-options.h"' re='\<parse_long_options *\(' \
202 $(_header_without_use)
204 # Don't include this header unless you use one of its functions.
205 sc_prohibit_inttostr_without_use:
206 @h='"inttostr.h"' re='\<(off|[iu]max|uint)tostr *\(' \
207 $(_header_without_use)
209 # Don't include this header unless you use one of its functions.
210 sc_prohibit_error_without_use:
211 @h='"error.h"' \
212 re='\<error(_at_line|_print_progname|_one_per_line|_message_count)? *\('\
213 $(_header_without_use)
215 sc_prohibit_safe_read_without_use:
216 @h='"safe-read.h"' re='(\<SAFE_READ_ERROR\>|\<safe_read *\()' \
217 $(_header_without_use)
219 sc_prohibit_argmatch_without_use:
220 @h='"argmatch.h"' \
221 re='(\<(ARRAY_CARDINALITY|X?ARGMATCH(|_TO_ARGUMENT|_VERIFY))\>|\<argmatch(_exit_fn|_(in)?valid) *\()' \
222 $(_header_without_use)
224 sc_prohibit_root_dev_ino_without_use:
225 @h='"root-dev-ino.h"' \
226 re='(\<ROOT_DEV_INO_(CHECK|WARN)\>|\<get_root_dev_ino *\()' \
227 $(_header_without_use)
229 sc_obsolete_symbols:
230 @grep -nE '\<(HAVE''_FCNTL_H|O''_NDELAY)\>' \
231 $$($(VC_LIST_EXCEPT)) && \
232 { echo '$(ME): do not use HAVE''_FCNTL_H or O''_NDELAY' \
233 1>&2; exit 1; } || :
235 # FIXME: warn about definitions of EXIT_FAILURE, EXIT_SUCCESS, STREQ
237 # Each nonempty line must start with a year number, or a TAB.
238 sc_changelog:
239 @grep -n '^[^12 ]' $$(find . -maxdepth 2 -name ChangeLog) && \
240 { echo '$(ME): found unexpected prefix in a ChangeLog' 1>&2; \
241 exit 1; } || :
243 # Ensure that dd's definition of LONGEST_SYMBOL stays in sync
244 # with the strings from the two affected variables.
245 dd_c = $(srcdir)/src/dd.c
246 sc_dd_max_sym_length:
247 ifneq ($(wildcard $(dd_c)),)
248 @len=$$( (sed -n '/conversions\[\] =$$/,/^};/p' $(dd_c);\
249 sed -n '/flags\[\] =$$/,/^};/p' $(dd_c) ) \
250 |sed -n '/"/s/^[^"]*"\([^"]*\)".*/\1/p' \
251 | wc --max-line-length); \
252 max=$$(sed -n '/^#define LONGEST_SYMBOL /s///p' $(dd_c) \
253 |tr -d '"' | wc --max-line-length); \
254 if test "$$len" = "$$max"; then :; else \
255 echo 'dd.c: LONGEST_SYMBOL is not longest' 1>&2; \
256 exit 1; \
258 endif
260 # Many m4 macros names once began with `jm_'.
261 # On 2004-04-13, they were all changed to start with gl_ instead.
262 # Make sure that none are inadvertently reintroduced.
263 sc_prohibit_jm_in_m4:
264 @grep -nE 'jm_[A-Z]' \
265 $$($(VC_LIST) m4 |grep '\.m4$$'; echo /dev/null) && \
266 { echo '$(ME): do not use jm_ in m4 macro names' \
267 1>&2; exit 1; } || :
269 sc_root_tests:
270 @if test -d tests \
271 && grep check-root tests/Makefile.am>/dev/null 2>&1; then \
272 t1=sc-root.expected; t2=sc-root.actual; \
273 grep -nl '^require_root_$$' \
274 $$($(VC_LIST) tests) |sed s,tests,., |sort > $$t1; \
275 sed -n 's, cd \([^ ]*\) .*MAKE..check TESTS=\(.*\),./\1/\2,p' \
276 $(srcdir)/tests/Makefile.am |sort > $$t2; \
277 diff -u $$t1 $$t2 || diff=1; \
278 rm -f $$t1 $$t2; \
279 test "$$diff" \
280 && { echo 'tests/Makefile.am: missing check-root action'>&2; \
281 exit 1; } || :; \
284 headers_with_interesting_macro_defs = \
285 exit.h \
286 fcntl_.h \
287 fnmatch_.h \
288 intprops.h \
289 inttypes_.h \
290 lchown.h \
291 openat.h \
292 stat-macros.h \
293 stdint_.h
295 # Create a list of regular expressions matching the names
296 # of macros that are guaranteed by parts of gnulib to be defined.
297 .re-defmac:
298 @(cd $(srcdir)/lib; \
299 for f in $(headers_with_interesting_macro_defs); do \
300 test -f $$f && \
301 sed -n '/^# *define \([^_ (][^ (]*\)[ (].*/s//\1/p' $$f; \
302 done; \
303 ) | sort -u \
304 | grep -Ev 'ATTRIBUTE_NORETURN|SIZE_MAX' \
305 | sed 's/^/^# *define /' \
306 > $@-t
307 @mv $@-t $@
309 # Don't define macros that we already get from gnulib header files.
310 sc_always_defined_macros: .re-defmac
311 @if test -f $(srcdir)/src/system.h; then \
312 trap 'rc=$$?; rm -f .re-defmac; exit $$rc' 0 1 2 3 15; \
313 grep -f .re-defmac $$($(VC_LIST)) \
314 && { echo '$(ME): define the above via some gnulib .h file' \
315 1>&2; exit 1; } || :; \
318 # Create a list of regular expressions matching the names
319 # of files included from system.h. Exclude a couple.
320 .re-list:
321 @sed -n '/^# *include /s///p' $(srcdir)/src/system.h \
322 | grep -Ev 'sys/(param|file)\.h' \
323 | sed 's/ .*//;;s/^["<]/^# *include [<"]/;s/\.h[">]$$/\\.h[">]/' \
324 > $@-t
325 @mv $@-t $@
327 # Files in src/ should not include directly any of
328 # the headers already included via system.h.
329 sc_system_h_headers: .re-list
330 @if test -f $(srcdir)/src/system.h; then \
331 trap 'rc=$$?; rm -f .re-list; exit $$rc' 0 1 2 3 15; \
332 grep -nE -f .re-list \
333 $$($(VC_LIST) src | \
334 grep -Ev '((copy|system)\.h|parse-gram\.c)$$') \
335 && { echo '$(ME): the above are already included via system.h'\
336 1>&2; exit 1; } || :; \
339 # Require that the final line of each test-lib.sh-using test be this one:
340 # (exit $fail); exit $fail
341 # Note: this test requires GNU grep's --label= option.
342 sc_require_test_exit_idiom:
343 @if test -f $(srcdir)/tests/test-lib.sh; then \
344 die=0; \
345 for i in $$(grep -l -F /../test-lib.sh $$($(VC_LIST) tests)); do \
346 tail -n1 $$i | grep '^(exit \$$fail); exit \$$fail$$' > /dev/null \
347 && : || { die=1; echo $$i; } \
348 done; \
349 test $$die = 1 && \
350 { echo 1>&2 '$(ME): the final line in each of the above is not:'; \
351 echo 1>&2 '(exit $$fail); exit $$fail'; \
352 exit 1; } || :; \
355 sc_sun_os_names:
356 @grep -nEi \
357 'solaris[^[:alnum:]]*2\.(7|8|9|[1-9][0-9])|sunos[^[:alnum:]][6-9]' \
358 $$($(VC_LIST_EXCEPT)) && \
359 { echo '$(ME): found misuse of Sun OS version numbers' 1>&2; \
360 exit 1; } || :
362 sc_the_the:
363 @grep -ni '\<the ''the\>' $$($(VC_LIST_EXCEPT)) && \
364 { echo '$(ME): found use of "the ''the";' 1>&2; \
365 exit 1; } || :
367 sc_tight_scope:
368 $(MAKE) -C src $@
370 sc_trailing_blank:
371 @grep -n '[ ]$$' $$($(VC_LIST_EXCEPT)) && \
372 { echo '$(ME): found trailing blank(s)' \
373 1>&2; exit 1; } || :
375 # Match lines like the following, but where there is only one space
376 # between the options and the description:
377 # -D, --all-repeated[=delimit-method] print all duplicate lines\n
378 longopt_re = --[a-z][0-9A-Za-z-]*(\[?=[0-9A-Za-z-]*\]?)?
379 sc_two_space_separator_in_usage:
380 @grep -nE '^ *(-[A-Za-z],)? $(longopt_re) [^ ].*\\$$' \
381 $$($(VC_LIST_EXCEPT)) && \
382 { echo "$(ME): help2man requires at least two spaces between"; \
383 echo "$(ME): an option and its description"; \
384 1>&2; exit 1; } || :
386 # Look for diagnostics that aren't marked for translation.
387 # This won't find any for which error's format string is on a separate line.
388 sc_unmarked_diagnostics:
389 @grep -nE \
390 '\<error \([^"]*"[^"]*[a-z]{3}' $$($(VC_LIST_EXCEPT)) \
391 | grep -v '_''(' && \
392 { echo '$(ME): found unmarked diagnostic(s)' 1>&2; \
393 exit 1; } || :
395 # Avoid useless parentheses like those in this example:
396 # #if defined (SYMBOL) || defined (SYM2)
397 sc_useless_cpp_parens:
398 @grep -n '^# *if .*defined *(' $$($(VC_LIST_EXCEPT)) && \
399 { echo '$(ME): found useless parentheses in cpp directive' \
400 1>&2; exit 1; } || :
402 # Require the latest GPL.
403 sc_GPL_version:
404 @grep -n 'either ''version [^3]' $$($(VC_LIST_EXCEPT)) && \
405 { echo '$(ME): GPL vN, N!=3' 1>&2; exit 1; } || :
407 # Ensure that the c99-to-c89 patch applies cleanly.
408 patch-check:
409 rm -rf src-c89 $@.1 $@.2
410 cp -a src src-c89
411 (cd src-c89; patch -p1 -V never --fuzz=0) < src/c99-to-c89.diff \
412 > $@.1 2>&1
413 if test "$$REGEN_PATCH" = yes; then \
414 diff -upr src src-c89 | sed 's,src-c89/,src/,' \
415 | grep -v '^Only in' > new-diff || : ; fi
416 grep -v '^patching file ' $@.1 > $@.2 || :
417 msg=ok; test -s $@.2 && msg='fuzzy patch' || : ; \
418 rm -f src-c89/*.o || msg='rm failed'; \
419 $(MAKE) -C src-c89 CFLAGS='-Wdeclaration-after-statement -Werror' \
420 || msg='compile failure with extra options'; \
421 test "$$msg" = ok && rm -rf src-c89 $@.1 $@.2 || echo "$$msg" 1>&2; \
422 test "$$msg" = ok
424 # Ensure that date's --help output stays in sync with the info
425 # documentation for GNU strftime. The only exception is %N,
426 # which date accepts but GNU strftime does not.
427 extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/'
428 strftime-check:
429 if test -f $(srcdir)/src/date.c; then \
430 grep '^ %. ' $(srcdir)/src/date.c | sort \
431 | $(extract_char) > $@-src; \
432 { echo N; \
433 info libc date calendar format | grep '^ `%.'\' \
434 | $(extract_char); } | sort > $@-info; \
435 diff -u $@-src $@-info || exit 1; \
436 rm -f $@-src $@-info; \
439 check-AUTHORS:
440 $(MAKE) -C src $@
442 # Ensure that we use only the standard $(VAR) notation,
443 # not @...@ in Makefile.am, now that we can rely on automake
444 # to emit a definition for each substituted variable.
445 makefile-check:
446 grep -nE '@[A-Z_0-9]+@' `find . -name Makefile.am` \
447 && { echo '$(ME): use $$(...), not @...@' 1>&2; exit 1; } || :
449 news-date-check: NEWS
450 today=`date +%Y-%m-%d`; \
451 if head NEWS | grep '^\*.* $(VERSION_REGEXP) ('$$today')' \
452 >/dev/null; then \
453 :; \
454 else \
455 echo "version or today's date is not in NEWS" 1>&2; \
456 exit 1; \
459 changelog-check:
460 if head ChangeLog | grep 'Version $(VERSION_REGEXP)\.$$' \
461 >/dev/null; then \
462 :; \
463 else \
464 echo "$(VERSION) not in ChangeLog" 1>&2; \
465 exit 1; \
468 m4-check:
469 @grep -n 'AC_DEFUN([^[]' m4/*.m4 \
470 && { echo '$(ME): quote the first arg to AC_DEFUN' 1>&2; \
471 exit 1; } || :
473 # Verify that all source files using _() are listed in po/POTFILES.in.
474 # FIXME: don't hard-code file names below; use a more general mechanism.
475 po-check:
476 if test -f po/POTFILES.in; then \
477 grep -E -v '^(#|$$)' po/POTFILES.in \
478 | grep -v '^src/false\.c$$' | sort > $@-1; \
479 files=; \
480 for file in $$($(VC_LIST_EXCEPT)) lib/*.[ch]; do \
481 case $$file in \
482 djgpp/* | man/*) continue;; \
483 */c99-to-c89.diff) continue;; \
484 esac; \
485 case $$file in \
486 *.[ch]) \
487 base=`expr " $$file" : ' \(.*\)\..'`; \
488 { test -f $$base.l || test -f $$base.y; } && continue;; \
489 esac; \
490 files="$$files $$file"; \
491 done; \
492 grep -E -l '\b(N?_|gettext *)\([^)"]*("|$$)' $$files \
493 | sort -u > $@-2; \
494 diff -u $@-1 $@-2 || exit 1; \
495 rm -f $@-1 $@-2; \
498 # In a definition of #define AUTHORS "... and ..." where the RHS contains
499 # the English word `and', the string must be marked with `N_ (...)' so that
500 # gettext recognizes it as a string requiring translation.
501 author_mark_check:
502 @grep -n '^# *define AUTHORS "[^"]* and ' src/*.c |grep -v ' N_ (' && \
503 { echo '$(ME): enclose the above strings in N_ (...)' 1>&2; \
504 exit 1; } || :
506 # Sometimes it is useful to change the PATH environment variable
507 # in Makefiles. When doing so, it's better not to use the Unix-centric
508 # path separator of `:', but rather the automake-provided `@PATH_SEPARATOR@'.
509 # It'd be better to use `find -print0 ...|xargs -0 ...', but less portable,
510 # and there probably aren't many projects with so many Makefile.am files
511 # that we'd have to worry about limits on command line length.
512 msg = '$(ME): Do not use `:'\'' above; use @PATH_SEPARATOR@ instead'
513 makefile_path_separator_check:
514 @grep -n 'PATH=.*:' `find $(srcdir) -name Makefile.am` \
515 && { echo $(msg) 1>&2; exit 1; } || :
517 # Check that `make alpha' will not fail at the end of the process.
518 writable-files:
519 if test -d $(release_archive_dir); then :; else \
520 for file in $(distdir).tar.gz \
521 $(release_archive_dir)/$(distdir).tar.gz; do \
522 test -e $$file || continue; \
523 test -w $$file \
524 || { echo ERROR: $$file is not writable; fail=1; }; \
525 done; \
526 test "$$fail" && exit 1 || :
529 v_etc_file = lib/version-etc.c
530 sample-test = tests/sample-test
531 texi = doc/$(PACKAGE).texi
532 # Make sure that the copyright date in $(v_etc_file) is up to date.
533 # Do the same for the $(sample-test) and the main doc/.texi file.
534 copyright-check:
535 @if test -f $(v_etc_file); then \
536 grep 'enum { COPYRIGHT_YEAR = '$$(date +%Y)' };' $(v_etc_file) \
537 >/dev/null \
538 || { echo 'out of date copyright in $(v_etc_file); update it' 1>&2; \
539 exit 1; }; \
541 @if test -f $(sample-test); then \
542 grep '# Copyright (C) '$$(date +%Y)' Free' $(sample-test) \
543 >/dev/null \
544 || { echo 'out of date copyright in $(sample-test); update it' 1>&2; \
545 exit 1; }; \
547 @if test -f $(texi); then \
548 grep 'Copyright @copyright{} .*'$$(date +%Y)' Free' $(texi) \
549 >/dev/null \
550 || { echo 'out of date copyright in $(texi); update it' 1>&2; \
551 exit 1; }; \
554 vc-diff-check:
555 $(VC) diff > vc-diffs || :
556 if test -s vc-diffs; then \
557 cat vc-diffs; \
558 echo "Some files are locally modified:" 1>&2; \
559 exit 1; \
560 else \
561 rm vc-diffs; \
564 cvs-check: vc-diff-check
566 maintainer-distcheck:
567 $(MAKE) distcheck
568 $(MAKE) my-distcheck
571 # Don't make a distribution if checks fail.
572 # Also, make sure the NEWS file is up-to-date.
573 vc-dist: $(local-check) cvs-check maintainer-distcheck
574 $(MAKE) dist
576 # Use this to make sure we don't run these programs when building
577 # from a virgin tgz file, below.
578 null_AM_MAKEFLAGS = \
579 ACLOCAL=false \
580 AUTOCONF=false \
581 AUTOMAKE=false \
582 AUTOHEADER=false \
583 MAKEINFO=false
585 built_programs = $$(cd src && MAKEFLAGS= $(MAKE) -s built_programs.list)
587 warn_cflags = -Dlint -O -Werror -Wall -Wformat -Wshadow -Wpointer-arith
588 bin=bin-$$$$
590 write_loser = printf '\#!%s\necho $$0: bad path 1>&2; exit 1\n' '$(SHELL)'
592 # Use -Wformat -Werror to detect format-string/arg-list mismatches.
593 # Also, check for shadowing problems with -Wshadow, and for pointer
594 # arithmetic problems with -Wpointer-arith.
595 # These CFLAGS are pretty strict. If you build this target, you probably
596 # have to have a recent version of gcc and glibc headers.
597 # The for-loop below ensures that there is a bin/ directory full of all
598 # of the programs under test (except the few that are required for basic
599 # Makefile rules), all symlinked to the just-built "false" program.
600 # This is to ensure that if ever a test neglects to make PATH include
601 # the build srcdir, these always-failing programs will run.
602 # Otherwise, it is too easy to test the wrong programs.
603 # Note that "false" itself is a symlink to true, so it too will malfunction.
604 TMPDIR ?= /tmp
605 t=$(TMPDIR)/$(PACKAGE)/test
606 my-distcheck: $(local-check) check
607 -rm -rf $(t)
608 mkdir -p $(t)
609 GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
610 cd $(t)/$(distdir) \
611 && ./configure --disable-nls --prefix=$(t)/i \
612 && $(MAKE) CFLAGS='$(warn_cflags)' \
613 AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)' \
614 && $(MAKE) dvi \
615 && $(MAKE) install \
616 && test -f $(mandir)/man1/ls.1 \
617 && mkdir $(bin) \
618 && ($(write_loser)) > $(bin)/loser \
619 && chmod a+x $(bin)/loser \
620 && for i in $(built_programs); do \
621 case $$i in \
622 rm|expr|basename|echo|sort|ls|tr);; \
623 cat|dirname|mv|wc);; \
624 *) ln $(bin)/loser $(bin)/$$i;; \
625 esac; \
626 done \
627 && ln -sf ../src/true $(bin)/false \
628 && PATH=`pwd`/$(bin):$$PATH $(MAKE) -C tests check \
629 && $(MAKE) -C gnulib-tests check \
630 && rm -rf $(bin) \
631 && $(MAKE) distclean
632 (cd $(t) && mv $(distdir) $(distdir).old \
633 && $(AMTAR) -zxf - ) < $(distdir).tar.gz
634 diff -ur $(t)/$(distdir).old $(t)/$(distdir)
635 if test -f $(srcdir)/src/c99-to-c89.diff; then \
636 cd $(t)/$(distdir) \
637 && (cd src && patch -V never --fuzz=0 <c99-to-c89.diff) \
638 && ./configure --disable-largefile \
639 CFLAGS='-Werror -ansi -Wno-long-long' \
640 && $(MAKE); \
642 -rm -rf $(t)
643 @echo "========================"; \
644 echo "$(distdir).tar.gz is ready for distribution"; \
645 echo "========================"
647 WGET = wget
648 WGETFLAGS = -C off
650 rel-check:
651 tarz=/tmp/rel-check-tarz-$$$$; \
652 md5_tmp=/tmp/rel-check-md5-$$$$; \
653 set -e; \
654 trap 'status=$$?; rm -f $$tarz $$md5_tmp; exit $$status' 0 1 2 3 15; \
655 $(WGET) $(WGETFLAGS) -q --output-document=$$tarz $(url); \
656 echo "$(md5) -" > $$md5_tmp; \
657 md5sum -c $$md5_tmp < $$tarz
659 rel-files = $(DIST_ARCHIVES)
661 gnulib-version = $$(cd $(gnulib_dir) && git describe)
663 announcement: NEWS ChangeLog $(rel-files)
664 @./build-aux/announce-gen \
665 --release-type=$(RELEASE_TYPE) \
666 --package=$(PACKAGE) \
667 --prev=$(PREV_VERSION) \
668 --curr=$(VERSION) \
669 --gpg-key-id=$(gpg_key_ID) \
670 --news=NEWS \
671 --bootstrap-tools=autoconf,automake,bison,gnulib \
672 --gnulib-version=$(gnulib-version) \
673 $(addprefix --url-dir=, $(url_dir_list))
675 ## ---------------- ##
676 ## Updating files. ##
677 ## ---------------- ##
679 ftp-gnu = ftp://ftp.gnu.org/gnu
680 www-gnu = http://www.gnu.org
682 # Use mv, if you don't have/want move-if-change.
683 move_if_change ?= move-if-change
685 emit_upload_commands:
686 @echo =====================================
687 @echo =====================================
688 @echo "$(srcdir)/build-aux/gnupload $(GNUPLOADFLAGS) \\"
689 @echo " --to $(gnu_rel_host):$(PACKAGE) \\"
690 @echo " $(rel-files)"
691 @echo '# send the /tmp/announcement e-mail'
692 @echo =====================================
693 @echo =====================================
695 .PHONY: alpha beta major
696 alpha beta major: $(local-check) writable-files
697 test $@ = major \
698 && { echo $(VERSION) | grep -E '^[0-9]+(\.[0-9]+)+$$' \
699 || { echo "invalid version string: $(VERSION)" 1>&2; exit 1;};}\
700 || :
701 $(MAKE) vc-dist
702 $(MAKE) news-date-check
703 $(MAKE) -s announcement RELEASE_TYPE=$@ > /tmp/announce-$(my_distdir)
704 if test -d $(release_archive_dir); then \
705 ln $(rel-files) $(release_archive_dir); \
706 chmod a-w $(rel-files); \
708 $(MAKE) -s emit_upload_commands RELEASE_TYPE=$@
709 echo $(VERSION) > $(prev_version_file)
710 $(VC) commit -m \
711 '$(prev_version_file): Record previous version: $(VERSION).' \
712 $(prev_version_file)