convert the rest to use proper_name -- manually
[coreutils.git] / maint.mk
blob53a124d76c93524015d35b392d565fff89f97bd0
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))
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 sc_file_system:
148 @grep -ni 'file''system' $$($(VC_LIST_EXCEPT)) && \
149 { echo '$(ME): found use of "file''system";' \
150 'rewrite to use "file system"' 1>&2; \
151 exit 1; } || :
153 # Don't use cpp tests of this symbol. All code assumes config.h is included.
154 sc_no_have_config_h:
155 @grep -n '^# *if.*HAVE''_CONFIG_H' $$($(VC_LIST_EXCEPT)) && \
156 { echo '$(ME): found use of HAVE''_CONFIG_H; remove' \
157 1>&2; exit 1; } || :
159 # Nearly all .c files must include <config.h>.
160 sc_require_config_h:
161 @if $(VC_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \
162 grep -L '^# *include <config\.h>' \
163 $$($(VC_LIST_EXCEPT) | grep '\.c$$') \
164 | grep . && \
165 { echo '$(ME): the above files do not include <config.h>' \
166 1>&2; exit 1; } || :; \
167 else :; \
170 # To use this "command" macro, you must first define two shell variables:
171 # h: the header, enclosed in <> or ""
172 # re: a regular expression that matches IFF something provided by $h is used.
173 define _header_without_use
174 h_esc=`echo "$$h"|sed 's/\./\\./'`; \
175 if $(VC_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then \
176 files=$$(grep -l '^# *include '"$$h_esc" \
177 $$($(VC_LIST_EXCEPT) | grep '\.c$$')) && \
178 grep -LE "$$re" $$files | grep . && \
179 { echo "$(ME): the above files include $$h but don't use it" \
180 1>&2; exit 1; } || :; \
181 else :; \
183 endef
185 # Prohibit the inclusion of assert.h without an actual use of assert.
186 sc_prohibit_assert_without_use:
187 @h='<assert.h>' re='\<assert *\(' $(_header_without_use)
189 # Prohibit the inclusion of getopt.h without an actual use.
190 sc_prohibit_getopt_without_use:
191 @h='<getopt.h>' re='\<getopt(_long)? *\(' $(_header_without_use)
193 # Don't include quotearg.h unless you use one of its functions.
194 sc_prohibit_quotearg_without_use:
195 @h='"quotearg.h"' re='\<quotearg(_[^ ]+)? *\(' $(_header_without_use)
197 # Don't include quote.h unless you use one of its functions.
198 sc_prohibit_quote_without_use:
199 @h='"quote.h"' re='\<quote(_n)? *\(' $(_header_without_use)
201 # Don't include this header unless you use one of its functions.
202 sc_prohibit_long_options_without_use:
203 @h='"long-options.h"' re='\<parse_long_options *\(' \
204 $(_header_without_use)
206 # Don't include this header unless you use one of its functions.
207 sc_prohibit_inttostr_without_use:
208 @h='"inttostr.h"' re='\<(off|[iu]max|uint)tostr *\(' \
209 $(_header_without_use)
211 # Don't include this header unless you use one of its functions.
212 sc_prohibit_error_without_use:
213 @h='"error.h"' \
214 re='\<error(_at_line|_print_progname|_one_per_line|_message_count)? *\('\
215 $(_header_without_use)
217 sc_prohibit_safe_read_without_use:
218 @h='"safe-read.h"' re='(\<SAFE_READ_ERROR\>|\<safe_read *\()' \
219 $(_header_without_use)
221 sc_prohibit_argmatch_without_use:
222 @h='"argmatch.h"' \
223 re='(\<(ARRAY_CARDINALITY|X?ARGMATCH(|_TO_ARGUMENT|_VERIFY))\>|\<argmatch(_exit_fn|_(in)?valid) *\()' \
224 $(_header_without_use)
226 sc_prohibit_root_dev_ino_without_use:
227 @h='"root-dev-ino.h"' \
228 re='(\<ROOT_DEV_INO_(CHECK|WARN)\>|\<get_root_dev_ino *\()' \
229 $(_header_without_use)
231 sc_obsolete_symbols:
232 @grep -nE '\<(HAVE''_FCNTL_H|O''_NDELAY)\>' \
233 $$($(VC_LIST_EXCEPT)) && \
234 { echo '$(ME): do not use HAVE''_FCNTL_H or O''_NDELAY' \
235 1>&2; exit 1; } || :
237 # FIXME: warn about definitions of EXIT_FAILURE, EXIT_SUCCESS, STREQ
239 # Each nonempty line must start with a year number, or a TAB.
240 sc_changelog:
241 @grep -n '^[^12 ]' $$(find . -maxdepth 2 -name ChangeLog) && \
242 { echo '$(ME): found unexpected prefix in a ChangeLog' 1>&2; \
243 exit 1; } || :
245 # Ensure that dd's definition of LONGEST_SYMBOL stays in sync
246 # with the strings from the two affected variables.
247 dd_c = $(srcdir)/src/dd.c
248 sc_dd_max_sym_length:
249 ifneq ($(wildcard $(dd_c)),)
250 @len=$$( (sed -n '/conversions\[\] =$$/,/^};/p' $(dd_c);\
251 sed -n '/flags\[\] =$$/,/^};/p' $(dd_c) ) \
252 |sed -n '/"/s/^[^"]*"\([^"]*\)".*/\1/p' \
253 | wc --max-line-length); \
254 max=$$(sed -n '/^#define LONGEST_SYMBOL /s///p' $(dd_c) \
255 |tr -d '"' | wc --max-line-length); \
256 if test "$$len" = "$$max"; then :; else \
257 echo 'dd.c: LONGEST_SYMBOL is not longest' 1>&2; \
258 exit 1; \
260 endif
262 # Many m4 macros names once began with `jm_'.
263 # On 2004-04-13, they were all changed to start with gl_ instead.
264 # Make sure that none are inadvertently reintroduced.
265 sc_prohibit_jm_in_m4:
266 @grep -nE 'jm_[A-Z]' \
267 $$($(VC_LIST) m4 |grep '\.m4$$'; echo /dev/null) && \
268 { echo '$(ME): do not use jm_ in m4 macro names' \
269 1>&2; exit 1; } || :
271 # Ensure that each root-requiring test is run via the "check-root" rule.
272 sc_root_tests:
273 @if test -d tests \
274 && grep check-root tests/Makefile.am>/dev/null 2>&1; then \
275 t1=sc-root.expected; t2=sc-root.actual; \
276 grep -nl '^require_root_$$' \
277 $$($(VC_LIST) tests) |sed s,tests/,, |sort > $$t1; \
278 sed -n '/^root_tests =[ ]*\\$$/,/[^\]$$/p' \
279 $(srcdir)/tests/Makefile.am \
280 | sed 's/^ *//;/^root_tests =/d' \
281 | tr -s '\012\\' ' ' | fmt -1 | sort > $$t2; \
282 diff -u $$t1 $$t2 || diff=1; \
283 rm -f $$t1 $$t2; \
284 test "$$diff" \
285 && { echo 'tests/Makefile.am: missing check-root action'>&2; \
286 exit 1; } || :; \
289 headers_with_interesting_macro_defs = \
290 exit.h \
291 fcntl_.h \
292 fnmatch_.h \
293 intprops.h \
294 inttypes_.h \
295 lchown.h \
296 openat.h \
297 stat-macros.h \
298 stdint_.h
300 # Create a list of regular expressions matching the names
301 # of macros that are guaranteed by parts of gnulib to be defined.
302 .re-defmac:
303 @(cd $(srcdir)/lib; \
304 for f in $(headers_with_interesting_macro_defs); do \
305 test -f $$f && \
306 sed -n '/^# *define \([^_ (][^ (]*\)[ (].*/s//\1/p' $$f; \
307 done; \
308 ) | sort -u \
309 | grep -Ev 'ATTRIBUTE_NORETURN|SIZE_MAX' \
310 | sed 's/^/^# *define /' \
311 > $@-t
312 @mv $@-t $@
314 # Don't define macros that we already get from gnulib header files.
315 sc_always_defined_macros: .re-defmac
316 @if test -f $(srcdir)/src/system.h; then \
317 trap 'rc=$$?; rm -f .re-defmac; exit $$rc' 0 1 2 3 15; \
318 grep -f .re-defmac $$($(VC_LIST)) \
319 && { echo '$(ME): define the above via some gnulib .h file' \
320 1>&2; exit 1; } || :; \
323 # Create a list of regular expressions matching the names
324 # of files included from system.h. Exclude a couple.
325 .re-list:
326 @sed -n '/^# *include /s///p' $(srcdir)/src/system.h \
327 | grep -Ev 'sys/(param|file)\.h' \
328 | sed 's/ .*//;;s/^["<]/^# *include [<"]/;s/\.h[">]$$/\\.h[">]/' \
329 > $@-t
330 @mv $@-t $@
332 # Files in src/ should not include directly any of
333 # the headers already included via system.h.
334 sc_system_h_headers: .re-list
335 @if test -f $(srcdir)/src/system.h; then \
336 trap 'rc=$$?; rm -f .re-list; exit $$rc' 0 1 2 3 15; \
337 grep -nE -f .re-list \
338 $$($(VC_LIST) src | \
339 grep -Ev '((copy|system)\.h|parse-gram\.c)$$') \
340 && { echo '$(ME): the above are already included via system.h'\
341 1>&2; exit 1; } || :; \
344 # Require that the final line of each test-lib.sh-using test be this one:
345 # (exit $fail); exit $fail
346 # Note: this test requires GNU grep's --label= option.
347 sc_require_test_exit_idiom:
348 @if test -f $(srcdir)/tests/test-lib.sh; then \
349 die=0; \
350 for i in $$(grep -l -F /../test-lib.sh $$($(VC_LIST) tests)); do \
351 tail -n1 $$i | grep '^(exit \$$fail); exit \$$fail$$' > /dev/null \
352 && : || { die=1; echo $$i; } \
353 done; \
354 test $$die = 1 && \
355 { echo 1>&2 '$(ME): the final line in each of the above is not:'; \
356 echo 1>&2 '(exit $$fail); exit $$fail'; \
357 exit 1; } || :; \
360 sc_sun_os_names:
361 @grep -nEi \
362 'solaris[^[:alnum:]]*2\.(7|8|9|[1-9][0-9])|sunos[^[:alnum:]][6-9]' \
363 $$($(VC_LIST_EXCEPT)) && \
364 { echo '$(ME): found misuse of Sun OS version numbers' 1>&2; \
365 exit 1; } || :
367 sc_the_the:
368 @grep -ni '\<the ''the\>' $$($(VC_LIST_EXCEPT)) && \
369 { echo '$(ME): found use of "the ''the";' 1>&2; \
370 exit 1; } || :
372 sc_tight_scope:
373 $(MAKE) -C src $@
375 sc_trailing_blank:
376 @grep -n '[ ]$$' $$($(VC_LIST_EXCEPT)) && \
377 { echo '$(ME): found trailing blank(s)' \
378 1>&2; exit 1; } || :
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 @grep -n 'either ''version [^3]' $$($(VC_LIST_EXCEPT)) && \
410 { echo '$(ME): GPL vN, N!=3' 1>&2; exit 1; } || :
412 exec_perl_re = \
413 exec \$$PERL -w -I\$$top_srcdir/tests -MCoreutils \
414 -M"CuTmpdir qw(\$$me)" -- - <<\\EOF
415 # Ensure that each test invoking $PERL with -MCoreutils uses the same line.
416 sc_perl_coreutils_test:
417 @if test -f $(srcdir)/tests/Coreutils.pm; then \
418 die=0; \
419 for i in $$(grep -l '^exec *\$$PERL.*MCoreutils' \
420 $$($(VC_LIST) tests)); do \
421 grep '$(exec_perl_re)' $$i > /dev/null \
422 && : || { die=1; echo $$i; } \
423 done; \
424 test $$die = 1 && \
425 { echo 1>&2 '$(ME): each of the above execs PERL differently:'; \
426 echo 1>&2 '(exit $$fail); exit $$fail'; \
427 exit 1; } || :; \
430 NEWS_hash = \
431 $$(sed -n '/^\*.* $(PREV_VERSION_REGEXP) ([0-9-]*)/,$$p' \
432 $(srcdir)/NEWS | md5sum -)
434 # Ensure that we don't accidentally insert an entry into an old NEWS block.
435 sc_immutable_NEWS:
436 @if test -f $(srcdir)/NEWS; then \
437 test "$(NEWS_hash)" = '$(old_NEWS_hash)' && : || \
438 { echo '$(ME): you have modified old NEWS' 1>&2; exit 1; }; \
441 # Update the hash stored above. Do this after each release and
442 # for any corrections to old entries.
443 update-NEWS-hash: NEWS
444 perl -pi -e 's/^(old_NEWS_hash = ).*/$${1}'"$(NEWS_hash)/" \
445 $(srcdir)/cfg.mk
447 # Ensure that the c99-to-c89 patch applies cleanly.
448 patch-check:
449 rm -rf src-c89 $@.1 $@.2
450 cp -a src src-c89
451 (cd src-c89; patch -p1 -V never --fuzz=0) < src/c99-to-c89.diff \
452 > $@.1 2>&1
453 if test "$$REGEN_PATCH" = yes; then \
454 diff -upr src src-c89 | sed 's,src-c89/,src/,' \
455 | grep -v '^Only in' > new-diff || : ; fi
456 grep -v '^patching file ' $@.1 > $@.2 || :
457 msg=ok; test -s $@.2 && msg='fuzzy patch' || : ; \
458 rm -f src-c89/*.o || msg='rm failed'; \
459 $(MAKE) -C src-c89 CFLAGS='-Wdeclaration-after-statement -Werror' \
460 || msg='compile failure with extra options'; \
461 test "$$msg" = ok && rm -rf src-c89 $@.1 $@.2 || echo "$$msg" 1>&2; \
462 test "$$msg" = ok
464 # Ensure that date's --help output stays in sync with the info
465 # documentation for GNU strftime. The only exception is %N,
466 # which date accepts but GNU strftime does not.
467 extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/'
468 strftime-check:
469 if test -f $(srcdir)/src/date.c; then \
470 grep '^ %. ' $(srcdir)/src/date.c | sort \
471 | $(extract_char) > $@-src; \
472 { echo N; \
473 info libc date calendar format | grep '^ `%.'\' \
474 | $(extract_char); } | sort > $@-info; \
475 diff -u $@-src $@-info || exit 1; \
476 rm -f $@-src $@-info; \
479 check-AUTHORS:
480 $(MAKE) -C src $@
482 # Ensure that we use only the standard $(VAR) notation,
483 # not @...@ in Makefile.am, now that we can rely on automake
484 # to emit a definition for each substituted variable.
485 makefile-check:
486 grep -nE '@[A-Z_0-9]+@' `find . -name Makefile.am` \
487 && { echo '$(ME): use $$(...), not @...@' 1>&2; exit 1; } || :
489 news-date-check: NEWS
490 today=`date +%Y-%m-%d`; \
491 if head NEWS | grep '^\*.* $(VERSION_REGEXP) ('$$today')' \
492 >/dev/null; then \
493 :; \
494 else \
495 echo "version or today's date is not in NEWS" 1>&2; \
496 exit 1; \
499 changelog-check:
500 if head ChangeLog | grep 'Version $(VERSION_REGEXP)\.$$' \
501 >/dev/null; then \
502 :; \
503 else \
504 echo "$(VERSION) not in ChangeLog" 1>&2; \
505 exit 1; \
508 m4-check:
509 @grep -n 'AC_DEFUN([^[]' m4/*.m4 \
510 && { echo '$(ME): quote the first arg to AC_DEFUN' 1>&2; \
511 exit 1; } || :
513 # Verify that all source files using _() are listed in po/POTFILES.in.
514 # FIXME: don't hard-code file names below; use a more general mechanism.
515 po-check:
516 if test -f po/POTFILES.in; then \
517 grep -E -v '^(#|$$)' po/POTFILES.in \
518 | grep -v '^src/false\.c$$' | sort > $@-1; \
519 files=; \
520 for file in $$($(VC_LIST_EXCEPT)) lib/*.[ch]; do \
521 case $$file in \
522 djgpp/* | man/*) continue;; \
523 */c99-to-c89.diff) continue;; \
524 esac; \
525 case $$file in \
526 *.[ch]) \
527 base=`expr " $$file" : ' \(.*\)\..'`; \
528 { test -f $$base.l || test -f $$base.y; } && continue;; \
529 esac; \
530 files="$$files $$file"; \
531 done; \
532 grep -E -l '\b(N?_|gettext *)\([^)"]*("|$$)' $$files \
533 | sort -u > $@-2; \
534 diff -u $@-1 $@-2 || exit 1; \
535 rm -f $@-1 $@-2; \
538 # In a definition of #define AUTHORS "... and ..." where the RHS contains
539 # the English word `and', the string must be marked with `N_ (...)' so that
540 # gettext recognizes it as a string requiring translation.
541 author_mark_check:
542 @grep -n '^# *define AUTHORS "[^"]* and ' src/*.c |grep -v ' N_ (' && \
543 { echo '$(ME): enclose the above strings in N_ (...)' 1>&2; \
544 exit 1; } || :
546 # Sometimes it is useful to change the PATH environment variable
547 # in Makefiles. When doing so, it's better not to use the Unix-centric
548 # path separator of `:', but rather the automake-provided `@PATH_SEPARATOR@'.
549 # It'd be better to use `find -print0 ...|xargs -0 ...', but less portable,
550 # and there probably aren't many projects with so many Makefile.am files
551 # that we'd have to worry about limits on command line length.
552 msg = '$(ME): Do not use `:'\'' above; use @PATH_SEPARATOR@ instead'
553 makefile_path_separator_check:
554 @grep -n 'PATH=.*:' `find $(srcdir) -name Makefile.am` \
555 && { echo $(msg) 1>&2; exit 1; } || :
557 # Check that `make alpha' will not fail at the end of the process.
558 writable-files:
559 if test -d $(release_archive_dir); then :; else \
560 for file in $(distdir).tar.gz \
561 $(release_archive_dir)/$(distdir).tar.gz; do \
562 test -e $$file || continue; \
563 test -w $$file \
564 || { echo ERROR: $$file is not writable; fail=1; }; \
565 done; \
566 test "$$fail" && exit 1 || : ; \
569 v_etc_file = lib/version-etc.c
570 sample-test = tests/sample-test
571 texi = doc/$(PACKAGE).texi
572 # Make sure that the copyright date in $(v_etc_file) is up to date.
573 # Do the same for the $(sample-test) and the main doc/.texi file.
574 copyright-check:
575 @if test -f $(v_etc_file); then \
576 grep 'enum { COPYRIGHT_YEAR = '$$(date +%Y)' };' $(v_etc_file) \
577 >/dev/null \
578 || { echo 'out of date copyright in $(v_etc_file); update it' 1>&2; \
579 exit 1; }; \
581 @if test -f $(sample-test); then \
582 grep '# Copyright (C) '$$(date +%Y)' Free' $(sample-test) \
583 >/dev/null \
584 || { echo 'out of date copyright in $(sample-test); update it' 1>&2; \
585 exit 1; }; \
587 @if test -f $(texi); then \
588 grep 'Copyright @copyright{} .*'$$(date +%Y)' Free' $(texi) \
589 >/dev/null \
590 || { echo 'out of date copyright in $(texi); update it' 1>&2; \
591 exit 1; }; \
594 vc-diff-check:
595 $(VC) diff > vc-diffs || :
596 if test -s vc-diffs; then \
597 cat vc-diffs; \
598 echo "Some files are locally modified:" 1>&2; \
599 exit 1; \
600 else \
601 rm vc-diffs; \
604 cvs-check: vc-diff-check
606 maintainer-distcheck:
607 $(MAKE) distcheck
608 $(MAKE) my-distcheck
611 # Don't make a distribution if checks fail.
612 # Also, make sure the NEWS file is up-to-date.
613 vc-dist: $(local-check) cvs-check maintainer-distcheck
614 $(MAKE) dist
616 # Use this to make sure we don't run these programs when building
617 # from a virgin tgz file, below.
618 null_AM_MAKEFLAGS = \
619 ACLOCAL=false \
620 AUTOCONF=false \
621 AUTOMAKE=false \
622 AUTOHEADER=false \
623 MAKEINFO=false
625 built_programs = $$(cd src && MAKEFLAGS= $(MAKE) -s built_programs.list)
627 warn_cflags = -Dlint -O -Werror -Wall -Wformat -Wshadow -Wpointer-arith
628 bin=bin-$$$$
630 write_loser = printf '\#!%s\necho $$0: bad path 1>&2; exit 1\n' '$(SHELL)'
632 # Use -Wformat -Werror to detect format-string/arg-list mismatches.
633 # Also, check for shadowing problems with -Wshadow, and for pointer
634 # arithmetic problems with -Wpointer-arith.
635 # These CFLAGS are pretty strict. If you build this target, you probably
636 # have to have a recent version of gcc and glibc headers.
637 # The for-loop below ensures that there is a bin/ directory full of all
638 # of the programs under test (except the few that are required for basic
639 # Makefile rules), all symlinked to the just-built "false" program.
640 # This is to ensure that if ever a test neglects to make PATH include
641 # the build srcdir, these always-failing programs will run.
642 # Otherwise, it is too easy to test the wrong programs.
643 # Note that "false" itself is a symlink to true, so it too will malfunction.
644 TMPDIR ?= /tmp
645 t=$(TMPDIR)/$(PACKAGE)/test
646 my-distcheck: $(local-check) check
647 -rm -rf $(t)
648 mkdir -p $(t)
649 GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
650 cd $(t)/$(distdir) \
651 && ./configure --disable-nls --prefix=$(t)/i \
652 && $(MAKE) CFLAGS='$(warn_cflags)' \
653 AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)' \
654 && $(MAKE) dvi \
655 && $(MAKE) install \
656 && test -f $(mandir)/man1/ls.1 \
657 && mkdir $(bin) \
658 && ($(write_loser)) > $(bin)/loser \
659 && chmod a+x $(bin)/loser \
660 && for i in $(built_programs); do \
661 case $$i in \
662 rm|expr|basename|echo|sort|ls|tr);; \
663 cat|dirname|mv|wc);; \
664 *) ln $(bin)/loser $(bin)/$$i;; \
665 esac; \
666 done \
667 && ln -sf ../src/true $(bin)/false \
668 && PATH=`pwd`/$(bin):$$PATH $(MAKE) -C tests check \
669 && $(MAKE) -C gnulib-tests check \
670 && rm -rf $(bin) \
671 && $(MAKE) distclean
672 (cd $(t) && mv $(distdir) $(distdir).old \
673 && $(AMTAR) -zxf - ) < $(distdir).tar.gz
674 diff -ur $(t)/$(distdir).old $(t)/$(distdir)
675 if test -f $(srcdir)/src/c99-to-c89.diff; then \
676 cd $(t)/$(distdir) \
677 && (cd src && patch -V never --fuzz=0 <c99-to-c89.diff) \
678 && ./configure --disable-largefile \
679 CFLAGS='-Werror -ansi -Wno-long-long' \
680 && $(MAKE); \
682 -rm -rf $(t)
683 @echo "========================"; \
684 echo "$(distdir).tar.gz is ready for distribution"; \
685 echo "========================"
687 WGET = wget
688 WGETFLAGS = -C off
690 rel-check:
691 tarz=/tmp/rel-check-tarz-$$$$; \
692 md5_tmp=/tmp/rel-check-md5-$$$$; \
693 set -e; \
694 trap 'status=$$?; rm -f $$tarz $$md5_tmp; exit $$status' 0 1 2 3 15; \
695 $(WGET) $(WGETFLAGS) -q --output-document=$$tarz $(url); \
696 echo "$(md5) -" > $$md5_tmp; \
697 md5sum -c $$md5_tmp < $$tarz
699 rel-files = $(DIST_ARCHIVES)
701 gnulib-version = $$(cd $(gnulib_dir) && git describe)
703 announcement: NEWS ChangeLog $(rel-files)
704 @./build-aux/announce-gen \
705 --release-type=$(RELEASE_TYPE) \
706 --package=$(PACKAGE) \
707 --prev=$(PREV_VERSION) \
708 --curr=$(VERSION) \
709 --gpg-key-id=$(gpg_key_ID) \
710 --news=NEWS \
711 --bootstrap-tools=autoconf,automake,bison,gnulib \
712 --gnulib-version=$(gnulib-version) \
713 $(addprefix --url-dir=, $(url_dir_list))
715 ## ---------------- ##
716 ## Updating files. ##
717 ## ---------------- ##
719 ftp-gnu = ftp://ftp.gnu.org/gnu
720 www-gnu = http://www.gnu.org
722 # Use mv, if you don't have/want move-if-change.
723 move_if_change ?= move-if-change
725 emit_upload_commands:
726 @echo =====================================
727 @echo =====================================
728 @echo "$(srcdir)/build-aux/gnupload $(GNUPLOADFLAGS) \\"
729 @echo " --to $(gnu_rel_host):$(PACKAGE) \\"
730 @echo " $(rel-files)"
731 @echo '# send the /tmp/announcement e-mail'
732 @echo =====================================
733 @echo =====================================
735 .PHONY: alpha beta major
736 alpha beta major: $(local-check) writable-files
737 test $@ = major \
738 && { echo $(VERSION) | grep -E '^[0-9]+(\.[0-9]+)+$$' \
739 || { echo "invalid version string: $(VERSION)" 1>&2; exit 1;};}\
740 || :
741 $(MAKE) vc-dist
742 $(MAKE) news-date-check
743 $(MAKE) -s announcement RELEASE_TYPE=$@ > /tmp/announce-$(my_distdir)
744 if test -d $(release_archive_dir); then \
745 ln $(rel-files) $(release_archive_dir); \
746 chmod a-w $(rel-files); \
748 $(MAKE) -s emit_upload_commands RELEASE_TYPE=$@
749 echo $(VERSION) > $(prev_version_file)
750 $(VC) commit -m \
751 '$(prev_version_file): Record previous version: $(VERSION).' \
752 $(prev_version_file)