dist: document our release procedure
[coreutils.git] / maint.mk
blobee279fe9aea30413bdc54c87128eaa60d3d2c289
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-2009 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
65 ## --------------- ##
66 ## Sanity checks. ##
67 ## --------------- ##
69 # Collect the names of rules starting with `sc_'.
70 syntax-check-rules := $(shell sed -n 's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p' \
71 $(srcdir)/$(ME) $(srcdir)/cfg.mk)
72 .PHONY: $(syntax-check-rules)
74 local-checks-available = \
75 patch-check $(syntax-check-rules) \
76 makefile-check check-AUTHORS
77 .PHONY: $(local-checks-available)
79 # Arrange to print the name of each syntax-checking rule just before running it.
80 $(syntax-check-rules): %: %.m
81 $(patsubst %, %.m, $(syntax-check-rules)):
82 @echo $(patsubst sc_%.m, %, $@)
84 local-check := $(filter-out $(local-checks-to-skip), $(local-checks-available))
86 syntax-check: $(local-check)
87 # @grep -nE '# *include <(limits|std(def|arg|bool))\.h>' \
88 # $$(find -type f -name '*.[chly]') && \
89 # { echo '$(ME): found conditional include' 1>&2; \
90 # exit 1; } || :
92 # grep -nE '^# *include <(string|stdlib)\.h>' \
93 # $(srcdir)/{lib,src}/*.[chy] && \
94 # { echo '$(ME): FIXME' 1>&2; \
95 # exit 1; } || :
96 # FIXME: don't allow `#include .strings\.h' anywhere
98 # By default, _prohibit_regexp does not ignore case.
99 export ignore_case =
100 _ignore_case = $$(test -n "$$ignore_case" && echo -i || :)
102 # There are many rules below that prohibit constructs in this package.
103 # If the offending construct can be matched with a grep-E-style regexp,
104 # use this macro. The shell variables "re" and "msg" must be defined.
105 define _prohibit_regexp
106 dummy=; : so we do not need a semicolon before each use \
107 test "x$$re" != x || { echo '$(ME): re not defined' 1>&2; exit 1; }; \
108 test "x$$msg" != x || { echo '$(ME): msg not defined' 1>&2; exit 1; };\
109 grep $(_ignore_case) -nE "$$re" $$($(VC_LIST_EXCEPT)) && \
110 { echo '$(ME): '"$$msg" 1>&2; exit 1; } || :
111 endef
113 sc_avoid_if_before_free:
114 @$(srcdir)/build-aux/useless-if-before-free \
115 $(useless_free_options) \
116 $$($(VC_LIST_EXCEPT)) && \
117 { echo '$(ME): found useless "if" before "free" above' 1>&2; \
118 exit 1; } || :
120 sc_cast_of_argument_to_free:
121 @re='\<free *\( *\(' msg='don'\''t cast free argument' \
122 $(_prohibit_regexp)
124 sc_cast_of_x_alloc_return_value:
125 @re='\*\) *x(m|c|re)alloc\>' \
126 msg='don'\''t cast x*alloc return value' \
127 $(_prohibit_regexp)
129 sc_cast_of_alloca_return_value:
130 @re='\*\) *alloca\>' msg='don'\''t cast alloca return value' \
131 $(_prohibit_regexp)
133 sc_space_tab:
134 @re='[ ] ' msg='found SPACE-TAB sequence; remove the SPACE' \
135 $(_prohibit_regexp)
137 # Don't use *scanf or the old ato* functions in `real' code.
138 # They provide no error checking mechanism.
139 # Instead, use strto* functions.
140 sc_prohibit_atoi_atof:
141 @re='\<([fs]?scanf|ato([filq]|ll)) *\(' \
142 msg='do not use *scan''f, ato''f, ato''i, ato''l, ato''ll or ato''q' \
143 $(_prohibit_regexp)
145 # Use STREQ rather than comparing strcmp == 0, or != 0.
146 sc_prohibit_strcmp:
147 @grep -nE '! *str''cmp *\(|\<str''cmp *\([^)]+\) *==' \
148 $$($(VC_LIST_EXCEPT)) \
149 | grep -vE ':# *define STREQ\(' && \
150 { echo '$(ME): use STREQ in place of the above uses of str''cmp' \
151 1>&2; exit 1; } || :
153 # Using EXIT_SUCCESS as the first argument to error is misleading,
154 # since when that parameter is 0, error does not exit. Use `0' instead.
155 sc_error_exit_success:
156 @grep -nF 'error (EXIT_SUCCESS,' \
157 $$(find -type f -name '*.[chly]') && \
158 { echo '$(ME): found error (EXIT_SUCCESS' 1>&2; \
159 exit 1; } || :
161 # `FATAL:' should be fully upper-cased in error messages
162 # `WARNING:' should be fully upper-cased, or fully lower-cased
163 sc_error_message_warn_fatal:
164 @grep -nEA2 '[^rp]error \(' $$($(VC_LIST_EXCEPT)) \
165 | grep -E '"Warning|"Fatal|"fatal' && \
166 { echo '$(ME): use FATAL, WARNING or warning' 1>&2; \
167 exit 1; } || :
169 # Error messages should not start with a capital letter
170 sc_error_message_uppercase:
171 @grep -nEA2 '[^rp]error \(' $$($(VC_LIST_EXCEPT)) \
172 | grep -E '"[A-Z]' \
173 | grep -vE '"FATAL|"WARNING|"Java|"C#|PRIuMAX' && \
174 { echo '$(ME): found capitalized error message' 1>&2; \
175 exit 1; } || :
177 # Error messages should not end with a period
178 sc_error_message_period:
179 @grep -nEA2 '[^rp]error \(' $$($(VC_LIST_EXCEPT)) \
180 | grep -E '[^."]\."' && \
181 { echo '$(ME): found error message ending in period' 1>&2; \
182 exit 1; } || :
184 sc_file_system:
185 @re=file''system ignore_case=1 \
186 msg='found use of "file''system"; spell it "file system"' \
187 $(_prohibit_regexp)
189 # Don't use cpp tests of this symbol. All code assumes config.h is included.
190 sc_prohibit_have_config_h:
191 @grep -n '^# *if.*HAVE''_CONFIG_H' $$($(VC_LIST_EXCEPT)) && \
192 { echo '$(ME): found use of HAVE''_CONFIG_H; remove' \
193 1>&2; exit 1; } || :
195 # Nearly all .c files must include <config.h>.
196 sc_require_config_h:
197 @if $(VC_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \
198 grep -L '^# *include <config\.h>' \
199 $$($(VC_LIST_EXCEPT) | grep '\.c$$') \
200 | grep . && \
201 { echo '$(ME): the above files do not include <config.h>' \
202 1>&2; exit 1; } || :; \
203 else :; \
206 # You must include <config.h> before including any other header file.
207 sc_require_config_h_first:
208 @if $(VC_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \
209 fail=0; \
210 for i in $$($(VC_LIST_EXCEPT) | grep '\.c$$'); do \
211 grep '^# *include\>' $$i | sed 1q \
212 | grep '^# *include <config\.h>' > /dev/null \
213 || { echo $$i; fail=1; }; \
214 done; \
215 test $$fail = 1 && \
216 { echo '$(ME): the above files include some other header' \
217 'before <config.h>' 1>&2; exit 1; } || :; \
218 else :; \
221 sc_prohibit_HAVE_MBRTOWC:
222 @re='\bHAVE_MBRTOWC\b' msg="do not use $$re; it is always defined" \
223 $(_prohibit_regexp)
225 # To use this "command" macro, you must first define two shell variables:
226 # h: the header, enclosed in <> or ""
227 # re: a regular expression that matches IFF something provided by $h is used.
228 define _header_without_use
229 h_esc=`echo "$$h"|sed 's/\./\\./'`; \
230 if $(VC_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \
231 files=$$(grep -l '^# *include '"$$h_esc" \
232 $$($(VC_LIST_EXCEPT) | grep '\.c$$')) && \
233 grep -LE "$$re" $$files | grep . && \
234 { echo "$(ME): the above files include $$h but don't use it" \
235 1>&2; exit 1; } || :; \
236 else :; \
238 endef
240 # Prohibit the inclusion of assert.h without an actual use of assert.
241 sc_prohibit_assert_without_use:
242 @h='<assert.h>' re='\<assert *\(' $(_header_without_use)
244 # Prohibit the inclusion of getopt.h without an actual use.
245 sc_prohibit_getopt_without_use:
246 @h='<getopt.h>' re='\<getopt(_long)? *\(' $(_header_without_use)
248 # Don't include quotearg.h unless you use one of its functions.
249 sc_prohibit_quotearg_without_use:
250 @h='"quotearg.h"' re='\<quotearg(_[^ ]+)? *\(' $(_header_without_use)
252 # Don't include quote.h unless you use one of its functions.
253 sc_prohibit_quote_without_use:
254 @h='"quote.h"' re='\<quote(_n)? *\(' $(_header_without_use)
256 # Don't include this header unless you use one of its functions.
257 sc_prohibit_long_options_without_use:
258 @h='"long-options.h"' re='\<parse_long_options *\(' \
259 $(_header_without_use)
261 # Don't include this header unless you use one of its functions.
262 sc_prohibit_inttostr_without_use:
263 @h='"inttostr.h"' re='\<(off|[iu]max|uint)tostr *\(' \
264 $(_header_without_use)
266 # Don't include this header unless you use one of its functions.
267 sc_prohibit_error_without_use:
268 @h='"error.h"' \
269 re='\<error(_at_line|_print_progname|_one_per_line|_message_count)? *\('\
270 $(_header_without_use)
272 sc_prohibit_safe_read_without_use:
273 @h='"safe-read.h"' re='(\<SAFE_READ_ERROR\>|\<safe_read *\()' \
274 $(_header_without_use)
276 sc_prohibit_argmatch_without_use:
277 @h='"argmatch.h"' \
278 re='(\<(ARRAY_CARDINALITY|X?ARGMATCH(|_TO_ARGUMENT|_VERIFY))\>|\<argmatch(_exit_fn|_(in)?valid) *\()' \
279 $(_header_without_use)
281 sc_prohibit_root_dev_ino_without_use:
282 @h='"root-dev-ino.h"' \
283 re='(\<ROOT_DEV_INO_(CHECK|WARN)\>|\<get_root_dev_ino *\()' \
284 $(_header_without_use)
286 # Prohibit the inclusion of c-ctype.h without an actual use.
287 ctype_re = isalnum|isalpha|isascii|isblank|iscntrl|isdigit|isgraph|islower\
288 |isprint|ispunct|isspace|isupper|isxdigit|tolower|toupper
289 sc_prohibit_c_ctype_without_use:
290 @h='[<"]c-ctype.h[">]' re='\<c_($(ctype_re)) *\(' $(_header_without_use)
292 _empty =
293 _sp = $(_empty) $(_empty)
294 # The following list was generated by running:
295 # man signal.h|col -b|perl -ne '/bsd_signal.*;/.../sigwaitinfo.*;/ and print' \
296 # | perl -lne '/^\s+(?:int|void).*?(\w+).*/ and print $1' | fmt
297 _sig_functions = \
298 bsd_signal kill killpg pthread_kill pthread_sigmask raise sigaction \
299 sigaddset sigaltstack sigdelset sigemptyset sigfillset sighold sigignore \
300 siginterrupt sigismember signal sigpause sigpending sigprocmask sigqueue \
301 sigrelse sigset sigsuspend sigtimedwait sigwait sigwaitinfo
302 _sig_function_re = $(subst $(_sp),|,$(strip $(_sig_functions)))
303 # The following were extracted from "man signal.h" manually.
304 _sig_types_and_consts = \
305 MINSIGSTKSZ SA_NOCLDSTOP SA_NOCLDWAIT SA_NODEFER SA_ONSTACK \
306 SA_RESETHAND SA_RESTART SA_SIGINFO SIGEV_NONE SIGEV_SIGNAL \
307 SIGEV_THREAD SIGSTKSZ SIG_BLOCK SIG_SETMASK SIG_UNBLOCK SS_DISABLE \
308 SS_ONSTACK mcontext_t pid_t sig_atomic_t sigevent siginfo_t sigset_t \
309 sigstack sigval stack_t ucontext_t
310 # generated via this:
311 # perl -lne '/^#ifdef (SIG\w+)/ and print $1' lib/sig2str.c|sort -u|fmt -70
312 _sig_names = \
313 SIGABRT SIGALRM SIGALRM1 SIGBUS SIGCANCEL SIGCHLD SIGCLD SIGCONT \
314 SIGDANGER SIGDIL SIGEMT SIGFPE SIGFREEZE SIGGRANT SIGHUP SIGILL \
315 SIGINFO SIGINT SIGIO SIGIOT SIGKAP SIGKILL SIGKILLTHR SIGLOST SIGLWP \
316 SIGMIGRATE SIGMSG SIGPHONE SIGPIPE SIGPOLL SIGPRE SIGPROF SIGPWR \
317 SIGQUIT SIGRETRACT SIGSAK SIGSEGV SIGSOUND SIGSTKFLT SIGSTOP SIGSYS \
318 SIGTERM SIGTHAW SIGTRAP SIGTSTP SIGTTIN SIGTTOU SIGURG SIGUSR1 \
319 SIGUSR2 SIGVIRT SIGVTALRM SIGWAITING SIGWINCH SIGWIND SIGWINDOW \
320 SIGXCPU SIGXFSZ
321 _sig_syms_re = $(subst $(_sp),|,$(strip $(_sig_names) $(_sig_types_and_consts)))
323 # Prohibit the inclusion of signal.h without an actual use.
324 sc_prohibit_signal_without_use:
325 @h='<signal.h>' \
326 re='\<($(_sig_function_re)) *\(|\<($(_sig_syms_re))\>' \
327 $(_header_without_use)
329 sc_obsolete_symbols:
330 @re='\<(HAVE''_FCNTL_H|O''_NDELAY)\>' \
331 msg='do not use HAVE''_FCNTL_H or O'_NDELAY \
332 $(_prohibit_regexp)
334 # FIXME: warn about definitions of EXIT_FAILURE, EXIT_SUCCESS, STREQ
336 # Each nonempty line must start with a year number, or a TAB.
337 sc_changelog:
338 @grep -n '^[^12 ]' $$(find . -maxdepth 2 -name ChangeLog) && \
339 { echo '$(ME): found unexpected prefix in a ChangeLog' 1>&2; \
340 exit 1; } || :
342 # Ensure that each .c file containing a "main" function also
343 # calls set_program_name.
344 sc_program_name:
345 @if $(VC_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \
346 files=$$(grep -l '^main *(' $$($(VC_LIST_EXCEPT) | grep '\.c$$')); \
347 grep -LE 'set_program_name *\(m?argv\[0\]\);' $$files \
348 | grep . && \
349 { echo '$(ME): the above files do not call set_program_name' \
350 1>&2; exit 1; } || :; \
351 else :; \
354 # Require that the final line of each test-lib.sh-using test be this one:
355 # Exit $fail
356 # Note: this test requires GNU grep's --label= option.
357 sc_require_test_exit_idiom:
358 @if test -f $(srcdir)/tests/test-lib.sh; then \
359 die=0; \
360 for i in $$(grep -l -F /../test-lib.sh $$($(VC_LIST) tests)); do \
361 tail -n1 $$i | grep '^Exit \$$fail$$' > /dev/null \
362 && : || { die=1; echo $$i; } \
363 done; \
364 test $$die = 1 && \
365 { echo 1>&2 '$(ME): the final line in each of the above is not:'; \
366 echo 1>&2 'Exit $$fail'; \
367 exit 1; } || :; \
370 sc_the_the:
371 @re='\<the ''the\>' \
372 ignore_case=1 msg='found use of "the ''the";' \
373 $(_prohibit_regexp)
375 sc_trailing_blank:
376 @re='[ ]$$' \
377 ignore_case=1 msg='found trailing blank(s)' \
378 $(_prohibit_regexp)
380 # Match lines like the following, but where there is only one space
381 # between the options and the description:
382 # -D, --all-repeated[=delimit-method] print all duplicate lines\n
383 longopt_re = --[a-z][0-9A-Za-z-]*(\[?=[0-9A-Za-z-]*\]?)?
384 sc_two_space_separator_in_usage:
385 @grep -nE '^ *(-[A-Za-z],)? $(longopt_re) [^ ].*\\$$' \
386 $$($(VC_LIST_EXCEPT)) && \
387 { echo "$(ME): help2man requires at least two spaces between"; \
388 echo "$(ME): an option and its description"; \
389 1>&2; exit 1; } || :
391 # Look for diagnostics that aren't marked for translation.
392 # This won't find any for which error's format string is on a separate line.
393 sc_unmarked_diagnostics:
394 @grep -nE \
395 '\<error \([^"]*"[^"]*[a-z]{3}' $$($(VC_LIST_EXCEPT)) \
396 | grep -v '_''(' && \
397 { echo '$(ME): found unmarked diagnostic(s)' 1>&2; \
398 exit 1; } || :
400 # Avoid useless parentheses like those in this example:
401 # #if defined (SYMBOL) || defined (SYM2)
402 sc_useless_cpp_parens:
403 @grep -n '^# *if .*defined *(' $$($(VC_LIST_EXCEPT)) && \
404 { echo '$(ME): found useless parentheses in cpp directive' \
405 1>&2; exit 1; } || :
407 # Require the latest GPL.
408 sc_GPL_version:
409 @re='either ''version [^3]' msg='GPL vN, N!=3' \
410 $(_prohibit_regexp)
412 cvs_keywords = \
413 Author|Date|Header|Id|Name|Locker|Log|RCSfile|Revision|Source|State
415 sc_prohibit_cvs_keyword:
416 @re='\$$($(cvs_keywords))\$$' \
417 msg='do not use CVS keyword expansion' \
418 $(_prohibit_regexp)
420 # Make sure we don't use st_blocks. Use ST_NBLOCKS instead.
421 # This is a bit of a kludge, since it prevents use of the string
422 # even in comments, but for now it does the job with no false positives.
423 sc_prohibit_stat_st_blocks:
424 @re='[.>]st_blocks' msg='do not use st_blocks; use ST_NBLOCKS' \
425 $(_prohibit_regexp)
427 # Make sure we don't define any S_IS* macros in src/*.c files.
428 # They're already defined via gnulib's sys/stat.h replacement.
429 sc_prohibit_S_IS_definition:
430 @re='^ *# *define *S_IS' \
431 msg='do not define S_IS* macros; include <sys/stat.h>' \
432 $(_prohibit_regexp)
434 # Each program that uses proper_name_utf8 must link with
435 # one of the ICONV libraries.
436 sc_proper_name_utf8_requires_ICONV:
437 @progs=$$(grep -l 'proper_name_utf8 ''("' $$($(VC_LIST_EXCEPT)));\
438 if test "x$$progs" != x; then \
439 fail=0; \
440 for p in $$progs; do \
441 dir=$$(dirname "$$p"); \
442 base=$$(basename "$$p" .c); \
443 grep "$${base}_LDADD.*ICONV)" $$dir/Makefile.am > /dev/null \
444 || { fail=1; echo 1>&2 "$(ME): $$p uses proper_name_utf8"; }; \
445 done; \
446 test $$fail = 1 && \
447 { echo 1>&2 '$(ME): the above do not link with any ICONV library'; \
448 exit 1; } || :; \
451 # Warn about "c0nst struct Foo const foo[]",
452 # but not about "char const *const foo" or "#define const const".
453 sc_redundant_const:
454 @re='\bconst\b[[:space:][:alnum:]]{2,}\bconst\b' \
455 msg='redundant "const" in declarations' \
456 $(_prohibit_regexp)
458 sc_const_long_option:
459 @grep '^ *static.*struct option ' $$($(VC_LIST_EXCEPT)) \
460 | grep -Ev 'const struct option|struct option const' && { \
461 echo 1>&2 '$(ME): add "const" to the above declarations'; \
462 exit 1; } || :
464 NEWS_hash = \
465 $$(sed -n '/^\*.* $(PREV_VERSION_REGEXP) ([0-9-]*)/,$$p' \
466 $(srcdir)/NEWS | grep -v '^Copyright .*Free Software' | md5sum -)
468 # Ensure that we don't accidentally insert an entry into an old NEWS block.
469 sc_immutable_NEWS:
470 @if test -f $(srcdir)/NEWS; then \
471 test "$(NEWS_hash)" = '$(old_NEWS_hash)' && : || \
472 { echo '$(ME): you have modified old NEWS' 1>&2; exit 1; }; \
475 # Update the hash stored above. Do this after each release and
476 # for any corrections to old entries.
477 update-NEWS-hash: NEWS
478 perl -pi -e 's/^(old_NEWS_hash = ).*/$${1}'"$(NEWS_hash)/" \
479 $(srcdir)/cfg.mk
481 epoch_date = 1970-01-01 00:00:00.000000000 +0000
482 # Ensure that the c99-to-c89 patch applies cleanly.
483 patch-check:
484 rm -rf src-c89 $@.1 $@.2
485 cp -a $(srcdir)/src src-c89
486 if test "x$(srcdir)" != x.; then \
487 cp -a src/* src-c89; \
488 dotfiles=`ls src/.[!.]* 2>/dev/null`; \
489 test -z "$$dotfiles" || cp -a src/.[!.]* src-c89; \
491 (cd src-c89; patch -p1 -V never --fuzz=0) < $(srcdir)/src/c99-to-c89.diff \
492 > $@.1 2>&1
493 if test "$(REGEN_PATCH)" = yes; then \
494 diff -upr $(srcdir)/src src-c89 | sed 's,$(srcdir)/src-c89/,src/,' \
495 | grep -vE '^(Only in|File )' \
496 | perl -pe 's/^((?:\+\+\+|---) \S+\t).*/$${1}$(epoch_date)/;' \
497 -e 's/^ $$//' \
498 > new-diff || : ; fi
499 grep -v '^patching file ' $@.1 > $@.2 || :
500 msg=ok; test -s $@.2 && msg='fuzzy patch' || : ; \
501 rm -f src-c89/*.o || msg='rm failed'; \
502 $(MAKE) -C src-c89 CFLAGS='-Wdeclaration-after-statement -Werror' \
503 || msg='compile failure with extra options'; \
504 test "$$msg" = ok && rm -rf src-c89 $@.1 $@.2 || echo "$$msg" 1>&2; \
505 test "$$msg" = ok
507 check-AUTHORS:
508 $(MAKE) -C src $@
510 # Ensure that we use only the standard $(VAR) notation,
511 # not @...@ in Makefile.am, now that we can rely on automake
512 # to emit a definition for each substituted variable.
513 # We use perl rather than "grep -nE ..." to exempt a single
514 # use of an @...@-delimited variable name in src/Makefile.am.
515 makefile-check:
516 @perl -ne '/\@[A-Z_0-9]+\@/ && !/^cu_install_program =/' \
517 -e 'and (print "$$ARGV:$$.: $$_"), $$m=1; END {exit !$$m}' \
518 $$($(VC_LIST_EXCEPT) | grep -E '(^|/)Makefile\.am$$') \
519 && { echo '$(ME): use $$(...), not @...@' 1>&2; exit 1; } || :
521 news-date-check: NEWS
522 today=`date +%Y-%m-%d`; \
523 if head NEWS | grep '^\*.* $(VERSION_REGEXP) ('$$today')' \
524 >/dev/null; then \
525 :; \
526 else \
527 echo "version or today's date is not in NEWS" 1>&2; \
528 exit 1; \
531 changelog-check:
532 if head ChangeLog | grep 'Version $(VERSION_REGEXP)\.$$' \
533 >/dev/null; then \
534 :; \
535 else \
536 echo "$(VERSION) not in ChangeLog" 1>&2; \
537 exit 1; \
540 sc_m4_quote_check:
541 @grep -nE '(AC_DEFINE(_UNQUOTED)?|AC_DEFUN)\([^[]' \
542 $$($(VC_LIST_EXCEPT) | grep -E '(^configure\.ac|\.m4)$$') \
543 && { echo '$(ME): quote the first arg to AC_DEF*' 1>&2; \
544 exit 1; } || :
546 fix_po_file_diag = \
547 'you have changed the set of files with translatable diagnostics;\n\
548 apply the above patch\n'
550 # Verify that all source files using _() are listed in po/POTFILES.in.
551 po_file = po/POTFILES.in
552 sc_po_check:
553 @if test -f $(po_file); then \
554 grep -E -v '^(#|$$)' $(po_file) \
555 | grep -v '^src/false\.c$$' | sort > $@-1; \
556 files=; \
557 for file in $$($(VC_LIST_EXCEPT)) lib/*.[ch]; do \
558 case $$file in \
559 *.?|*.??) ;; \
560 *) continue;; \
561 esac; \
562 case $$file in \
563 *.[ch]) \
564 base=`expr " $$file" : ' \(.*\)\..'`; \
565 { test -f $$base.l || test -f $$base.y; } && continue;; \
566 esac; \
567 files="$$files $$file"; \
568 done; \
569 grep -E -l '\b(N?_|gettext *)\([^)"]*("|$$)' $$files \
570 | sort -u > $@-2; \
571 diff -u -L $(po_file) -L $(po_file) $@-1 $@-2 \
572 || { printf '$(ME): '$(fix_po_file_diag) 1>&2; exit 1; }; \
573 rm -f $@-1 $@-2; \
576 # Sometimes it is useful to change the PATH environment variable
577 # in Makefiles. When doing so, it's better not to use the Unix-centric
578 # path separator of `:', but rather the automake-provided `@PATH_SEPARATOR@'.
579 # It'd be better to use `find -print0 ...|xargs -0 ...', but less portable,
580 # and there probably aren't many projects with so many Makefile.am files
581 # that we'd have to worry about limits on command line length.
582 msg = '$(ME): Do not use `:'\'' above; use @PATH_SEPARATOR@ instead'
583 sc_makefile_path_separator_check:
584 @grep -n 'PATH=.*:' `find $(srcdir) -name Makefile.am` \
585 && { echo $(msg) 1>&2; exit 1; } || :
587 # Check that `make alpha' will not fail at the end of the process.
588 writable-files:
589 if test -d $(release_archive_dir); then :; else \
590 for file in $(distdir).tar.gz \
591 $(release_archive_dir)/$(distdir).tar.gz; do \
592 test -e $$file || continue; \
593 test -w $$file \
594 || { echo ERROR: $$file is not writable; fail=1; }; \
595 done; \
596 test "$$fail" && exit 1 || : ; \
599 v_etc_file = lib/version-etc.c
600 sample-test = tests/sample-test
601 texi = doc/$(PACKAGE).texi
602 # Make sure that the copyright date in $(v_etc_file) is up to date.
603 # Do the same for the $(sample-test) and the main doc/.texi file.
604 sc_copyright_check:
605 @if test -f $(v_etc_file); then \
606 grep 'enum { COPYRIGHT_YEAR = '$$(date +%Y)' };' $(v_etc_file) \
607 >/dev/null \
608 || { echo 'out of date copyright in $(v_etc_file); update it' 1>&2; \
609 exit 1; }; \
611 @if test -f $(sample-test); then \
612 grep '# Copyright (C) '$$(date +%Y)' Free' $(sample-test) \
613 >/dev/null \
614 || { echo 'out of date copyright in $(sample-test); update it' 1>&2; \
615 exit 1; }; \
617 @if test -f $(texi); then \
618 grep 'Copyright @copyright{} .*'$$(date +%Y)' Free' $(texi) \
619 >/dev/null \
620 || { echo 'out of date copyright in $(texi); update it' 1>&2; \
621 exit 1; }; \
624 vc-diff-check:
625 $(VC) diff > vc-diffs || :
626 if test -s vc-diffs; then \
627 cat vc-diffs; \
628 echo "Some files are locally modified:" 1>&2; \
629 exit 1; \
630 else \
631 rm vc-diffs; \
634 cvs-check: vc-diff-check
636 maintainer-distcheck:
637 $(MAKE) distcheck
638 $(MAKE) taint-distcheck
639 $(MAKE) my-distcheck
642 # Don't make a distribution if checks fail.
643 # Also, make sure the NEWS file is up-to-date.
644 vc-dist: $(local-check) cvs-check maintainer-distcheck
645 $(MAKE) dist
647 # Use this to make sure we don't run these programs when building
648 # from a virgin tgz file, below.
649 null_AM_MAKEFLAGS = \
650 ACLOCAL=false \
651 AUTOCONF=false \
652 AUTOMAKE=false \
653 AUTOHEADER=false \
654 MAKEINFO=false
656 built_programs = $$(cd src && MAKEFLAGS= $(MAKE) -s built_programs.list)
658 warn_cflags = -Dlint -O -Werror -Wall -Wformat -Wshadow -Wpointer-arith
659 bin=bin-$$$$
661 write_loser = printf '\#!%s\necho $$0: bad path 1>&2; exit 1\n' '$(SHELL)'
663 TMPDIR ?= /tmp
664 t=$(TMPDIR)/$(PACKAGE)/test
665 pfx=$(t)/i
667 # More than once, tainted build and source directory names would
668 # have caused at least one "make check" test to apply "chmod 700"
669 # to all directories under $HOME. Make sure it doesn't happen again.
670 tp := $(shell echo "$(TMPDIR)/$(PACKAGE)-$$$$")
671 t_prefix = $(tp)/a
672 t_taint = '$(t_prefix) b'
673 fake_home = $(tp)/home
675 # Ensure that tests run from tainted build and src dir names work,
676 # and don't affect anything in $HOME. Create witness files in $HOME,
677 # record their attributes, and build/test. Then ensure that the
678 # witnesses were not affected.
679 taint-distcheck: $(DIST_ARCHIVES)
680 test -d $(t_taint) && chmod -R 700 $(t_taint) || :
681 -rm -rf $(t_taint) $(fake_home)
682 mkdir -p $(t_prefix) $(t_taint) $(fake_home)
683 GZIP=$(GZIP_ENV) $(AMTAR) -C $(t_taint) -zxf $(distdir).tar.gz
684 mkfifo $(fake_home)/fifo
685 touch $(fake_home)/f
686 mkdir -p $(fake_home)/d/e
687 ls -lR $(fake_home) $(t_prefix) > $(tp)/.ls-before
688 cd $(t_taint)/$(distdir) \
689 && ./configure \
690 && $(MAKE) \
691 && HOME=$(fake_home) $(MAKE) check \
692 && ls -lR $(fake_home) $(t_prefix) > $(tp)/.ls-after \
693 && diff $(tp)/.ls-before $(tp)/.ls-after \
694 && test -d $(t_prefix)
695 rm -rf $(tp)
697 # Verify that a twisted use of --program-transform-name=PROGRAM works.
698 define install-transform-check
699 echo running install-transform-check \
700 && rm -rf $(pfx) \
701 && $(MAKE) program_transform_name='s/.*/zyx/' \
702 prefix=$(pfx) install \
703 && test "$$(echo $(pfx)/bin/*)" = "$(pfx)/bin/zyx" \
704 && test "$$(find $(pfx)/share/man -type f|sed 's,.*/,,;s,\..*,,')" = "zyx"
705 endef
707 # Install, then verify that all binaries and man pages are in place.
708 # Note that neither the binary, ginstall, nor the ].1 man page is installed.
709 define my-instcheck
710 $(MAKE) prefix=$(pfx) install \
711 && test ! -f $(pfx)/bin/ginstall \
712 && { fail=0; \
713 for i in $(built_programs); do \
714 test "$$i" = ginstall && i=install; \
715 for j in "$(pfx)/bin/$$i" \
716 "$(pfx)/share/man/man1/$$i.1"; do \
717 case $$j in *'[.1') continue;; esac; \
718 test -f "$$j" && : \
719 || { echo "$$j not installed"; fail=1; }; \
720 done; \
721 done; \
722 test $$fail = 1 && exit 1 || :; \
724 endef
726 define coreutils-path-check
728 if test -f $(srcdir)/src/true.c; then \
729 fail=1; \
730 mkdir $(bin) \
731 && ($(write_loser)) > $(bin)/loser \
732 && chmod a+x $(bin)/loser \
733 && for i in $(built_programs); do \
734 case $$i in \
735 rm|expr|basename|echo|sort|ls|tr);; \
736 cat|dirname|mv|wc);; \
737 *) ln $(bin)/loser $(bin)/$$i;; \
738 esac; \
739 done \
740 && ln -sf ../src/true $(bin)/false \
741 && PATH=`pwd`/$(bin):$$PATH $(MAKE) -C tests check \
742 && { test -d gnulib-tests \
743 && $(MAKE) -C gnulib-tests check \
744 || :; } \
745 && rm -rf $(bin) \
746 && fail=0; \
747 else \
748 fail=0; \
749 fi; \
750 test $$fail = 1 && exit 1 || :; \
752 endef
754 # Use -Wformat -Werror to detect format-string/arg-list mismatches.
755 # Also, check for shadowing problems with -Wshadow, and for pointer
756 # arithmetic problems with -Wpointer-arith.
757 # These CFLAGS are pretty strict. If you build this target, you probably
758 # have to have a recent version of gcc and glibc headers.
759 # The hard-linking for-loop below ensures that there is a bin/ directory
760 # full of all of the programs under test (except the ones that are required
761 # for basic Makefile rules), all symlinked to the just-built "false" program.
762 # This is to ensure that if ever a test neglects to make PATH include
763 # the build srcdir, these always-failing programs will run.
764 # Otherwise, it is too easy to test the wrong programs.
765 # Note that "false" itself is a symlink to true, so it too will malfunction.
766 my-distcheck: $(DIST_ARCHIVES) $(local-check)
767 $(MAKE) syntax-check
768 $(MAKE) check
769 -rm -rf $(t)
770 mkdir -p $(t)
771 GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
772 cd $(t)/$(distdir) \
773 && ./configure --disable-nls \
774 && $(MAKE) CFLAGS='$(warn_cflags)' \
775 AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)' \
776 && $(MAKE) dvi \
777 && $(install-transform-check) \
778 && $(my-instcheck) \
779 && $(coreutils-path-check) \
780 && $(MAKE) distclean
781 (cd $(t) && mv $(distdir) $(distdir).old \
782 && $(AMTAR) -zxf - ) < $(distdir).tar.gz
783 diff -ur $(t)/$(distdir).old $(t)/$(distdir)
784 -rm -rf $(t)
785 @echo "========================"; \
786 echo "$(distdir).tar.gz is ready for distribution"; \
787 echo "========================"
789 WGET = wget
790 WGETFLAGS = -C off
792 rel-check:
793 tarz=/tmp/rel-check-tarz-$$$$; \
794 md5_tmp=/tmp/rel-check-md5-$$$$; \
795 set -e; \
796 trap 'status=$$?; rm -f $$tarz $$md5_tmp; exit $$status' 0 1 2 3 15; \
797 $(WGET) $(WGETFLAGS) -q --output-document=$$tarz $(url); \
798 echo "$(md5) -" > $$md5_tmp; \
799 md5sum -c $$md5_tmp < $$tarz
801 rel-files = $(DIST_ARCHIVES)
803 gnulib-version = $$(cd $(gnulib_dir) && git describe)
805 announcement: NEWS ChangeLog $(rel-files)
806 @./build-aux/announce-gen \
807 --release-type=$(RELEASE_TYPE) \
808 --package=$(PACKAGE) \
809 --prev=$(PREV_VERSION) \
810 --curr=$(VERSION) \
811 --gpg-key-id=$(gpg_key_ID) \
812 --news=NEWS \
813 --bootstrap-tools=autoconf,automake,bison,gnulib \
814 --gnulib-version=$(gnulib-version) \
815 --no-print-checksums \
816 $(addprefix --url-dir=, $(url_dir_list))
818 ## ---------------- ##
819 ## Updating files. ##
820 ## ---------------- ##
822 ftp-gnu = ftp://ftp.gnu.org/gnu
823 www-gnu = http://www.gnu.org
825 # Use mv, if you don't have/want move-if-change.
826 move_if_change ?= move-if-change
828 emit_upload_commands:
829 @echo =====================================
830 @echo =====================================
831 @echo "$(srcdir)/build-aux/gnupload $(GNUPLOADFLAGS) \\"
832 @echo " --to $(gnu_rel_host):$(PACKAGE) \\"
833 @echo " $(rel-files)"
834 @echo '# send the /tmp/announcement e-mail'
835 @echo =====================================
836 @echo =====================================
838 noteworthy = * Noteworthy changes in release ?.? (????-??-??) [?]
839 define emit-commit-log
840 printf '%s\n' 'post-release administrivia' '' \
841 '* NEWS: Add header line for next release.' \
842 '* .prev-version: Record previous version.' \
843 '* cfg.mk (old_NEWS_hash): Auto-update.'
844 endef
846 .PHONY: alpha beta major
847 alpha beta major: $(local-check) writable-files
848 test $@ = major \
849 && { echo $(VERSION) | grep -E '^[0-9]+(\.[0-9]+)+$$' \
850 || { echo "invalid version string: $(VERSION)" 1>&2; exit 1;};}\
851 || :
852 $(MAKE) vc-dist
853 $(MAKE) news-date-check
854 $(MAKE) -s announcement RELEASE_TYPE=$@ > /tmp/announce-$(my_distdir)
855 if test -d $(release_archive_dir); then \
856 ln $(rel-files) $(release_archive_dir); \
857 chmod a-w $(rel-files); \
859 $(MAKE) -s emit_upload_commands RELEASE_TYPE=$@
860 echo $(VERSION) > $(prev_version_file)
861 $(MAKE) update-NEWS-hash
862 perl -pi -e '$$. == 3 and print "$(noteworthy)\n\n\n"' NEWS
863 $(emit-commit-log) > .ci-msg
864 $(VC) commit -F .ci-msg -a
866 .PHONY: web-manual
867 web-manual:
868 @cd '$(srcdir)/doc'; \
869 $(SHELL) ../build-aux/gendocs.sh -o '$(abs_builddir)/doc/manual' \
870 --email $(PACKAGE_BUGREPORT) $(PACKAGE) \
871 "$(PACKAGE_NAME) - Core GNU utilities"
872 @echo " *** Upload the doc/manual directory to web-cvs."