NEWS: note that a cp -p bug fixed in 6.7 affected releases before 6.0.
[coreutils/ericb.git] / Makefile.maint
blob4f9720b6182a1533d47b8c83b5b6456061c0e9f2
1 # -*-Makefile-*-
2 # This Makefile fragment is shared between the coreutils,
3 # CPPI, Bison, and Autoconf.
5 ## Copyright (C) 2001-2007 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 := Makefile.maint
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 CVS = cvs
31 GIT = git
32 VC = $(GIT)
33 VC-tag = git-tag -s -m '$(VERSION)'
35 CVS_LIST = build-aux/vc-list-files
37 CVS_LIST_EXCEPT = \
38   $(CVS_LIST) | if test -f .x-$@; then grep -vEf .x-$@; else grep -v ChangeLog; fi
40 ifeq ($(origin prev_version_file), undefined)
41   prev_version_file = .prev-version
42 endif
44 PREV_VERSION := $(shell cat $(prev_version_file))
45 VERSION_REGEXP = $(subst .,\.,$(VERSION))
47 tag-package = $(shell echo "$(PACKAGE)" | tr '[:lower:]' '[:upper:]')
48 tag-this-version = $(subst .,_,$(VERSION))
49 this-vc-tag = $(tag-package)-$(tag-this-version)
50 my_distdir = $(PACKAGE)-$(VERSION)
52 # Old releases are stored here.
53 # Used for diffs and xdeltas.
54 release_archive_dir ?= ../release
56 # Prevent programs like 'sort' from considering distinct strings to be equal.
57 # Doing it here saves us from having to set LC_ALL elsewhere in this file.
58 export LC_ALL = C
62 ## --------------- ##
63 ## Sanity checks.  ##
64 ## --------------- ##
66 # FIXME: add a check to prohibit definition in src/*.c of symbols defined
67 # in system.h.  E.g. today I removed from tail.c a useless definition of
68 # ENOSYS.  It was useless because system.h ensures it's defined.
70 # Collect the names of rules starting with `sc_'.
71 syntax-check-rules := $(shell sed -n 's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p' $(ME))
72 .PHONY: $(syntax-check-rules)
74 # Checks that don't require cvs.
75 # Run `changelog-check' last, as previous test may reveal problems requiring
76 # new ChangeLog entries.
77 local-checks-available = \
78   po-check copyright-check m4-check author_mark_check \
79   changelog-check patch-check strftime-check $(syntax-check-rules) \
80   makefile_path_separator_check \
81   makefile-check check-AUTHORS
82 .PHONY: $(local-checks-available)
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 sc_cast_of_argument_to_free:
99         @grep -nE '\<free \(\(' $$($(CVS_LIST_EXCEPT)) &&               \
100           { echo '$(ME): don'\''t cast free argument' 1>&2;             \
101             exit 1; } || :
103 sc_cast_of_x_alloc_return_value:
104         @grep -nE '\*\) *x(m|c|re)alloc\>' $$($(CVS_LIST_EXCEPT)) &&    \
105           { echo '$(ME): don'\''t cast x*alloc return value' 1>&2;      \
106             exit 1; } || :
108 sc_cast_of_alloca_return_value:
109         @grep -nE '\*\) *alloca\>' $$($(CVS_LIST_EXCEPT)) &&            \
110           { echo '$(ME): don'\''t cast alloca return value' 1>&2;       \
111             exit 1; } || :
113 sc_space_tab:
114         @grep -n '[ ]   ' $$($(CVS_LIST_EXCEPT)) &&                     \
115           { echo '$(ME): found SPACE-TAB sequence; remove the SPACE'    \
116                 1>&2; exit 1; } || :
118 # Don't use *scanf or the old ato* functions in `real' code.
119 # They provide no error checking mechanism.
120 # Instead, use strto* functions.
121 sc_prohibit_atoi_atof:
122         @grep -nE '\<([fs]?scanf|ato([filq]|ll))\>' $$($(CVS_LIST_EXCEPT)) && \
123           { echo '$(ME): do not use *scan''f, ato''f, ato''i, ato''l, ato''ll, ato''q, or ss''canf'     \
124                 1>&2; exit 1; } || :
126 # Use STREQ rather than comparing strcmp == 0, or != 0.
127 sc_prohibit_strcmp:
128         @grep -nE '! *str''cmp \(|\<str''cmp \([^)]+\) *==' \
129             $$($(CVS_LIST_EXCEPT)) && \
130           { echo '$(ME): use STREQ in place of the above uses of str''cmp' \
131                 1>&2; exit 1; } || :
133 # Using EXIT_SUCCESS as the first argument to error is misleading,
134 # since when that parameter is 0, error does not exit.  Use `0' instead.
135 sc_error_exit_success:
136         @grep -nF 'error (EXIT_SUCCESS,'                                \
137             $$(find -type f -name '*.[chly]') &&                        \
138           { echo '$(ME): found error (EXIT_SUCCESS' 1>&2;               \
139             exit 1; } || :
141 sc_file_system:
142         @grep -ni 'file''system' $$($(CVS_LIST_EXCEPT)) &&              \
143           { echo '$(ME): found use of "file''system";'                  \
144             'rewrite to use "file system"' 1>&2;                        \
145             exit 1; } || :
147 sc_no_have_config_h:
148         @grep -n 'HAVE''_CONFIG_H' $$($(CVS_LIST_EXCEPT)) &&            \
149           { echo '$(ME): found use of HAVE''_CONFIG_H; remove'          \
150                 1>&2; exit 1; } || :
152 # Nearly all .c files must include <config.h>.
153 sc_require_config_h:
154         @if $(CVS_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then         \
155           grep -L '^# *include <config\.h>'                             \
156                 $$($(CVS_LIST_EXCEPT) | grep '\.c$$')                   \
157               | grep . &&                                               \
158           { echo '$(ME): the above files do not include <config.h>'     \
159                 1>&2; exit 1; } || :;                                   \
160         else :;                                                         \
161         fi
163 # Prohibit the inclusion of assert.h without an actual use of assert.
164 sc_prohibit_assert_without_use:
165         @if $(CVS_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then         \
166           files=$$(grep -l '# *include <assert\.h>'                     \
167                     $$($(CVS_LIST_EXCEPT) | grep '\.c$$')) &&           \
168           grep -L '\<assert (' $$files                                  \
169               | grep . &&                                               \
170             { echo "$(ME): the above files include <assert.h> but don't use it" \
171                   1>&2; exit 1; } || :;                                 \
172         else :;                                                         \
173         fi
175 # Don't include quotearg.h unless you use one of its functions.
176 sc_prohibit_quotearg_without_use:
177         @if $(CVS_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then         \
178           files=$$(grep -l '# *include "quotearg\.h"'                   \
179                     $$($(CVS_LIST_EXCEPT) | grep '\.c$$')) &&           \
180           grep -LE '\<quotearg(_[^ ]+)? \(' $$files                     \
181               | grep . &&                                               \
182             { echo "$(ME): the above files include "quotearg.h" but don't use it" \
183                   1>&2; exit 1; } || :;                                 \
184         else :;                                                         \
185         fi
187 # Don't include quote.h unless you use one of its functions.
188 sc_prohibit_quote_without_use:
189         @if $(CVS_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then         \
190           files=$$(grep -l '# *include "quote\.h"'                      \
191                     $$($(CVS_LIST_EXCEPT) | grep '\.c$$')) &&           \
192           grep -LE '\<quote(_n)? \(' $$files                    \
193               | grep . &&                                               \
194             { echo "$(ME): the above files include "quote.h" but don't use it" \
195                   1>&2; exit 1; } || :;                                 \
196         else :;                                                         \
197         fi
199 sc_obsolete_symbols:
200         @grep -nE '\<(HAVE''_FCNTL_H|O''_NDELAY)\>'                     \
201              $$($(CVS_LIST_EXCEPT)) &&                                  \
202           { echo '$(ME): do not use HAVE''_FCNTL_H or O''_NDELAY'       \
203                 1>&2; exit 1; } || :
205 # FIXME: warn about definitions of EXIT_FAILURE, EXIT_SUCCESS, STREQ
207 # Each nonempty line must start with a year number, or a TAB.
208 sc_changelog:
209         @grep -n '^[^12 ]' $$(find . -maxdepth 2 -name ChangeLog) &&    \
210           { echo '$(ME): found unexpected prefix in a ChangeLog' 1>&2;  \
211             exit 1; } || :
213 # Ensure that dd's definition of LONGEST_SYMBOL stays in sync
214 # with the strings from the two affected variables.
215 dd_c = $(srcdir)/src/dd.c
216 sc_dd_max_sym_length:
217 ifneq ($(wildcard $(dd_c)),)
218         @len=$$( (sed -n '/conversions\[\] =$$/,/^};/p' $(dd_c);\
219                  sed -n '/flags\[\] =$$/,/^};/p' $(dd_c) )      \
220                 |sed -n '/"/s/^[^"]*"\([^"]*\)".*/\1/p'         \
221               | wc --max-line-length);                          \
222         max=$$(sed -n '/^#define LONGEST_SYMBOL /s///p' $(dd_c) \
223               |tr -d '"' | wc --max-line-length);               \
224         if test "$$len" = "$$max"; then :; else                 \
225           echo 'dd.c: LONGEST_SYMBOL is not longest' 1>&2;      \
226           exit 1;                                               \
227         fi
228 endif
230 # Many m4 macros names once began with `jm_'.
231 # On 2004-04-13, they were all changed to start with gl_ instead.
232 # Make sure that none are inadvertently reintroduced.
233 sc_prohibit_jm_in_m4:
234         @grep -nE 'jm_[A-Z]'                                    \
235                 $$($(CVS_LIST) m4 |grep '\.m4$$'; echo /dev/null) && \
236             { echo '$(ME): do not use jm_ in m4 macro names'    \
237               1>&2; exit 1; } || :
239 sc_root_tests:
240         @if test -d tests \
241               && grep check-root tests/Makefile.am>/dev/null 2>&1; then \
242         t1=sc-root.expected; t2=sc-root.actual;                         \
243         grep -nl '^PRIV_CHECK_ARG=require-root'                         \
244           $$($(CVS_LIST) tests) |sed s,tests,., |sort > $$t1;           \
245         sed -n 's,      cd \([^ ]*\) .*MAKE..check TESTS=\(.*\),./\1/\2,p' \
246           $(srcdir)/tests/Makefile.am |sort > $$t2;                     \
247         diff -u $$t1 $$t2 || diff=1;                                    \
248         rm -f $$t1 $$t2;                                                \
249         test "$$diff"                                                   \
250           && { echo 'tests/Makefile.am: missing check-root action'>&2;  \
251                exit 1; } || :;                                          \
252         fi
254 headers_with_interesting_macro_defs = \
255   exit.h        \
256   fcntl_.h      \
257   fnmatch_.h    \
258   intprops.h    \
259   inttypes_.h   \
260   lchown.h      \
261   openat.h      \
262   stat-macros.h \
263   stdint_.h
265 # Create a list of regular expressions matching the names
266 # of macros that are guaranteed by parts of gnulib to be defined.
267 .re-defmac:
268         @(cd $(srcdir)/lib;                                             \
269           for f in $(headers_with_interesting_macro_defs); do           \
270             test -f $$f &&                                              \
271               sed -n '/^# *define \([^_ (][^ (]*\)[ (].*/s//\1/p' $$f;  \
272            done;                                                        \
273          ) | sort -u                                                    \
274            | grep -Ev 'ATTRIBUTE_NORETURN|SIZE_MAX'                     \
275            | sed 's/^/^# *define /'                                     \
276           > $@-t
277         @mv $@-t $@
279 # Don't define macros that we already get from gnulib header files.
280 sc_always_defined_macros: .re-defmac
281         @if test -f $(srcdir)/src/system.h; then                        \
282           trap 'rc=$$?; rm -f .re-defmac; exit $$rc' 0 1 2 3 15;        \
283           grep -f .re-defmac $$($(CVS_LIST))                            \
284             && { echo '$(ME): define the above via some gnulib .h file' \
285                   1>&2;  exit 1; } || :;                                \
286         fi
288 # Create a list of regular expressions matching the names
289 # of files included from system.h.  Exclude a couple.
290 .re-list:
291         @sed -n '/^# *include /s///p' $(srcdir)/src/system.h \
292           | grep -Ev 'sys/(param|file)\.h' \
293           | sed 's/ .*//;;s/^["<]/^# *include [<"]/;s/\.h[">]$$/\\.h[">]/' \
294           > $@-t
295         @mv $@-t $@
297 # Files in src/ should not include directly any of
298 # the headers already included via system.h.
299 sc_system_h_headers: .re-list
300         @if test -f $(srcdir)/src/system.h; then                        \
301           trap 'rc=$$?; rm -f .re-list; exit $$rc' 0 1 2 3 15;          \
302           grep -nE -f .re-list                                          \
303               $$($(CVS_LIST) src |                                      \
304                  grep -Ev '((copy|system)\.h|parse-gram\.c)$$')         \
305             && { echo '$(ME): the above are already included via system.h'\
306                   1>&2;  exit 1; } || :;                                \
307         fi
309 sc_sun_os_names:
310         @grep -nEi \
311             'solaris[^[:alnum:]]*2\.(7|8|9|[1-9][0-9])|sunos[^[:alnum:]][6-9]' \
312             $$($(CVS_LIST_EXCEPT)) &&                                   \
313           { echo '$(ME): found misuse of Sun OS version numbers' 1>&2;  \
314             exit 1; } || :
316 sc_the_the:
317         @grep -ni '\<the ''the\>' $$($(CVS_LIST_EXCEPT)) &&             \
318           { echo '$(ME): found use of "the ''the";' 1>&2;               \
319             exit 1; } || :
321 sc_tight_scope:
322         $(MAKE) -C src $@
324 sc_trailing_blank:
325         @grep -n '[      ]$$' $$($(CVS_LIST_EXCEPT)) &&                 \
326           { echo '$(ME): found trailing blank(s)'                       \
327                 1>&2; exit 1; } || :
329 # Match lines like the following, but where there is only one space
330 # between the options and the description:
331 #   -D, --all-repeated[=delimit-method]  print all duplicate lines\n
332 longopt_re = --[a-z][0-9A-Za-z-]*(\[?=[0-9A-Za-z-]*\]?)?
333 sc_two_space_separator_in_usage:
334         @grep -nE '^   *(-[A-Za-z],)? $(longopt_re) [^ ].*\\$$'         \
335             $$($(CVS_LIST_EXCEPT)) &&                                   \
336           { echo "$(ME): help2man requires at least two spaces between"; \
337             echo "$(ME): an option and its description"; \
338                 1>&2; exit 1; } || :
340 # Look for diagnostics that aren't marked for translation.
341 # This won't find any for which error's format string is on a separate line.
342 sc_unmarked_diagnostics:
343         @grep -nE                                                       \
344             '\<error \([^"]*"[^"]*[a-z]{3}' $$($(CVS_LIST_EXCEPT))      \
345           | grep -v '_''(' &&                                           \
346           { echo '$(ME): found unmarked diagnostic(s)' 1>&2;            \
347             exit 1; } || :
349 # Avoid useless parentheses like those in this example:
350 # #if defined (SYMBOL) || defined (SYM2)
351 sc_useless_cpp_parens:
352         @grep -n '^# *if .*defined *(' $$($(CVS_LIST_EXCEPT)) &&        \
353           { echo '$(ME): found useless parentheses in cpp directive'    \
354                 1>&2; exit 1; } || :
356 # Require the latest GPL.
357 sc_GPL_version:
358         @grep -n 'either ''version [^3]' $$($(CVS_LIST_EXCEPT)) &&      \
359           { echo '$(ME): GPL vN, N!=3' 1>&2; exit 1; } || :
361 # Ensure that the c99-to-c89 patch applies cleanly.
362 patch-check:
363         rm -rf src-c89 $@.1 $@.2
364         cp -a src src-c89
365         (cd src-c89; patch -p1 -V never --fuzz=0) < src/c99-to-c89.diff \
366           > $@.1 2>&1
367         if test "$$REGEN_PATCH" = yes; then \
368           diff -upr src src-c89 | sed 's,src-c89/,src/,' \
369             | grep -v '^Only in' > new-diff || : ; fi
370         grep -v '^patching file ' $@.1 > $@.2 || :
371         msg=ok; test -s $@.2 && msg='fuzzy patch' || : ;        \
372         rm -f src-c89/*.o || msg='rm failed';                   \
373         $(MAKE) -C src-c89 CFLAGS='-Wdeclaration-after-statement -Werror' \
374           || msg='compile failure with extra options';          \
375         rm -rf src-c89 $@.1 $@.2;                               \
376         test "$$msg" = ok && : || echo "$$msg" 1>&2;            \
377         test "$$msg" = ok
379 # Ensure that date's --help output stays in sync with the info
380 # documentation for GNU strftime.  The only exception is %N,
381 # which date accepts but GNU strftime does not.
382 extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/'
383 strftime-check:
384         if test -f $(srcdir)/src/date.c; then                           \
385           grep '^  %.  ' $(srcdir)/src/date.c | sort                    \
386             | $(extract_char) > $@-src;                                 \
387           { echo N;                                                     \
388             info libc date calendar format | grep '^    `%.'\'          \
389               | $(extract_char); } | sort > $@-info;                    \
390           diff -u $@-src $@-info || exit 1;                             \
391           rm -f $@-src $@-info;                                         \
392         fi
394 check-AUTHORS:
395         $(MAKE) -C src $@
397 # Ensure that we use only the standard $(VAR) notation,
398 # not @...@ in Makefile.am, now that we can rely on automake
399 # to emit a definition for each substituted variable.
400 makefile-check:
401         grep -nE '@[A-Z_0-9]+@' `find . -name Makefile.am` \
402           && { echo 'Makefile.maint: use $$(...), not @...@' 1>&2; exit 1; } || :
404 news-date-check: NEWS
405         today=`date +%Y-%m-%d`;                                         \
406         if head NEWS | grep '^\*.* $(VERSION_REGEXP) ('$$today')'       \
407             >/dev/null; then                                            \
408           :;                                                            \
409         else                                                            \
410           echo "version or today's date is not in NEWS" 1>&2;           \
411           exit 1;                                                       \
412         fi
414 changelog-check:
415         if head ChangeLog | grep 'Version $(VERSION_REGEXP)\.$$'        \
416             >/dev/null; then                                            \
417           :;                                                            \
418         else                                                            \
419           echo "$(VERSION) not in ChangeLog" 1>&2;                      \
420           exit 1;                                                       \
421         fi
423 m4-check:
424         @grep -n 'AC_DEFUN([^[]' m4/*.m4 \
425           && { echo 'Makefile.maint: quote the first arg to AC_DEFUN' 1>&2; \
426                exit 1; } || :
428 # Verify that all source files using _() are listed in po/POTFILES.in.
429 # FIXME: don't hard-code file names below; use a more general mechanism.
430 po-check:
431         if test -f po/POTFILES.in; then                                 \
432           grep -E -v '^(#|$$)' po/POTFILES.in                           \
433             | grep -v '^src/false\.c$$' | sort > $@-1;                  \
434           files=;                                                       \
435           for file in $$($(CVS_LIST_EXCEPT)) lib/*.[ch]; do             \
436             case $$file in                                              \
437             djgpp/* | man/*) continue;;                                 \
438             */c99-to-c89.diff) continue;;                               \
439             esac;                                                       \
440             case $$file in                                              \
441             *.[ch])                                                     \
442               base=`expr " $$file" : ' \(.*\)\..'`;                     \
443               { test -f $$base.l || test -f $$base.y; } && continue;;   \
444             esac;                                                       \
445             files="$$files $$file";                                     \
446           done;                                                         \
447           grep -E -l '\b(N?_|gettext *)\([^)"]*("|$$)' $$files          \
448             | sort -u > $@-2;                                           \
449           diff -u $@-1 $@-2 || exit 1;                                  \
450           rm -f $@-1 $@-2;                                              \
451         fi
453 # In a definition of #define AUTHORS "... and ..." where the RHS contains
454 # the English word `and', the string must be marked with `N_ (...)' so that
455 # gettext recognizes it as a string requiring translation.
456 author_mark_check:
457         @grep -n '^# *define AUTHORS "[^"]* and ' src/*.c |grep -v ' N_ (' && \
458           { echo 'Makefile.maint: enclose the above strings in N_ (...)' 1>&2; \
459             exit 1; } || :
461 # Sometimes it is useful to change the PATH environment variable
462 # in Makefiles.  When doing so, it's better not to use the Unix-centric
463 # path separator of `:', but rather the automake-provided `@PATH_SEPARATOR@'.
464 # It'd be better to use `find -print0 ...|xargs -0 ...', but less portable,
465 # and there probably aren't many projects with so many Makefile.am files
466 # that we'd have to worry about limits on command line length.
467 msg = 'Makefile.maint: Do not use `:'\'' above; use @PATH_SEPARATOR@ instead'
468 makefile_path_separator_check:
469         @grep -n 'PATH=.*:' `find $(srcdir) -name Makefile.am` \
470           && { echo $(msg) 1>&2; exit 1; } || :
472 # Check that `make alpha' will not fail at the end of the process.
473 writable-files:
474         if test -d $(release_archive_dir); then :; else                 \
475           mkdir $(release_archive_dir);                                 \
476         fi
477         for file in $(distdir).tar.gz $(xd-delta)                       \
478                     $(release_archive_dir)/$(distdir).tar.gz            \
479                     $(release_archive_dir)/$(xd-delta); do              \
480           test -e $$file || continue;                                   \
481           test -w $$file                                                \
482             || { echo ERROR: $$file is not writable; fail=1; };         \
483         done;                                                           \
484         test "$$fail" && exit 1 || :
486 v_etc_file = lib/version-etc.c
487 sample-test = tests/sample-test
488 texi = doc/$(PACKAGE).texi
489 # Make sure that the copyright date in $(v_etc_file) is up to date.
490 # Do the same for the $(sample-test) and the main doc/.texi file.
491 copyright-check:
492         @if test -f $(v_etc_file); then \
493           grep 'enum { COPYRIGHT_YEAR = '$$(date +%Y)' };' $(v_etc_file) \
494             >/dev/null \
495           || { echo 'out of date copyright in $(v_etc_file); update it' 1>&2; \
496                exit 1; }; \
497         fi
498         @if test -f $(sample-test); then \
499           grep '# Copyright (C) '$$(date +%Y)' Free' $(sample-test) \
500             >/dev/null \
501           || { echo 'out of date copyright in $(sample-test); update it' 1>&2; \
502                exit 1; }; \
503         fi
504         @if test -f $(texi); then \
505           grep 'Copyright @copyright{} .*'$$(date +%Y)' Free' $(texi) \
506             >/dev/null \
507           || { echo 'out of date copyright in $(texi); update it' 1>&2; \
508                exit 1; }; \
509         fi
512 # Sanity checks with the repository.
513 # Abort early if this tag has already been used.
514 vc-tag-check:
515         used=no;                                                        \
516         if $(VC) --help | grep CVS; then                                \
517           $(CVS) -n log -h README|grep -e $(this-vc-tag): >/dev/null    \
518             && used=yes;                                                \
519         else                                                            \
520           $(GIT) tag -l '^$(this-vc-tag)$$' && used=yes;                \
521         fi;                                                             \
522         if test "$$used" = yes; then                                    \
523           echo "$(this-vc-tag) has already been used; not tagging" 1>&2; \
524           exit 1;                                                       \
525         fi
527 vc-diff-check:
528         $(VC) diff > vc-diffs || :
529         if test -s vc-diffs; then                               \
530           cat vc-diffs;                                         \
531           echo "Some files are locally modified:" 1>&2;         \
532           exit 1;                                               \
533         else                                                    \
534           rm vc-diffs;                                          \
535         fi
537 cvs-check: vc-diff-check vc-tag-check
539 maintainer-distcheck:
540         $(MAKE) distcheck
541         $(MAKE) my-distcheck
544 # Tag before making distribution.  Also, don't make a distribution if
545 # checks fail.  Also, make sure the NEWS file is up-to-date.
546 # FIXME: use dist-hook/my-dist like distcheck-hook/my-distcheck.
547 vc-dist: $(local-check) cvs-check maintainer-distcheck
548         $(VC-tag) $(this-vc-tag)
549         $(MAKE) dist
551 # Use this to make sure we don't run these programs when building
552 # from a virgin tgz file, below.
553 null_AM_MAKEFLAGS = \
554   ACLOCAL=false \
555   AUTOCONF=false \
556   AUTOMAKE=false \
557   AUTOHEADER=false \
558   MAKEINFO=false
560 warn_cflags = -Dlint -O -Werror -Wall -Wformat -Wshadow -Wpointer-arith
562 # Use -Wformat -Werror to detect format-string/arg-list mismatches.
563 # Also, check for shadowing problems with -Wshadow, and for pointer
564 # arithmetic problems with -Wpointer-arith.
565 # These CFLAGS are pretty strict.  If you build this target, you probably
566 # have to have a recent version of gcc and glibc headers.
567 TMPDIR ?= /tmp
568 t=$(TMPDIR)/$(PACKAGE)/test
569 my-distcheck: $(local-check) $(release_archive_dir)/$(prev-tgz)
570         -rm -rf $(t)
571         mkdir -p $(t)
572         GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
573         cd $(t)/$(distdir)                              \
574           && ./configure --disable-nls                  \
575           && $(MAKE) CFLAGS='$(warn_cflags)'            \
576               AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)'       \
577           && $(MAKE) dvi                                \
578           && $(MAKE) check                              \
579           && $(MAKE) distclean
580         (cd $(t) && mv $(distdir) $(distdir).old        \
581           && $(AMTAR) -zxf - ) < $(distdir).tar.gz
582         diff -ur $(t)/$(distdir).old $(t)/$(distdir)
583         if test -f $(srcdir)/src/c99-to-c89.diff; then                  \
584           cd $(t)/$(distdir)                                            \
585             && (cd src && patch -V never --fuzz=0 <c99-to-c89.diff)     \
586             && ./configure --disable-largefile                          \
587                  CFLAGS='-Werror -ansi -Wno-long-long'                  \
588             && $(MAKE);                                                 \
589         fi
590         -rm -rf $(t)
591         @echo "========================"; \
592         echo "$(distdir).tar.gz is ready for distribution"; \
593         echo "========================"
595 WGET = wget
596 WGETFLAGS = -C off
598 rel-check:
599         tarz=/tmp/rel-check-tarz-$$$$; \
600         md5_tmp=/tmp/rel-check-md5-$$$$; \
601         set -e; \
602         trap 'status=$$?; rm -f $$tarz $$md5_tmp; exit $$status' 0 1 2 3 15; \
603         $(WGET) $(WGETFLAGS) -q --output-document=$$tarz $(url); \
604         echo "$(md5)  -" > $$md5_tmp; \
605         md5sum -c $$md5_tmp < $$tarz
607 prev-tgz = $(PACKAGE)-$(PREV_VERSION).tar.gz
608 xd-delta = $(PACKAGE)-$(PREV_VERSION)-$(VERSION).xdelta
610 rel-files = $(xd-delta) $(DIST_ARCHIVES)
612 # Approximate the date of last gnulib "update" by the ChangeLog file's
613 # mtime, and provide that date in the announcement.
614 announcement: NEWS ChangeLog $(rel-files)
615         @cl_date=$$(stat --printf @%Y $(gnulib_dir)/ChangeLog);         \
616         utc_date=$$(date -u --date $$cl_date '+%Y-%m-%d %T %z');        \
617         ./build-aux/announce-gen                                        \
618             --release-type=$(RELEASE_TYPE)                              \
619             --package=$(PACKAGE)                                        \
620             --prev=$(PREV_VERSION)                                      \
621             --curr=$(VERSION)                                           \
622             --gpg-key-id=$(gpg_key_ID)                                  \
623             --news=NEWS                                                 \
624             --bootstrap-tools=autoconf,automake,bison,gnulib            \
625             --gnulib-snapshot-time-stamp="$$utc_date"                   \
626             $(addprefix --url-dir=, $(url_dir_list))
628 ## ---------------- ##
629 ## Updating files.  ##
630 ## ---------------- ##
632 ftp-gnu = ftp://ftp.gnu.org/gnu
633 www-gnu = http://www.gnu.org
635 # Use mv, if you don't have/want move-if-change.
636 move_if_change ?= move-if-change
638 emit_upload_commands:
639         @echo =====================================
640         @echo =====================================
641         @echo "$(srcdir)/build-aux/gnupload $(GNUPLOADFLAGS) \\"
642         @echo "    --to $(gnu_rel_host):$(PACKAGE) \\"
643         @echo "  $(rel-files)"
644         @echo '# send the /tmp/announcement e-mail'
645         @echo =====================================
646         @echo =====================================
648 $(xd-delta): $(release_archive_dir)/$(prev-tgz) $(distdir).tar.gz
649         xdelta delta -9 $^ $@ || :
651 .PHONY: alpha beta major
652 alpha beta major: news-date-check changelog-check $(local-check) writable-files
653         test $@ = major                                         \
654           && { echo $(VERSION) | grep -E '^[0-9]+(\.[0-9]+)+$$' \
655                || { echo "invalid version string: $(VERSION)" 1>&2; exit 1;};}\
656           || :
657         $(MAKE) vc-dist
658         $(MAKE) $(xd-delta)
659         $(MAKE) -s announcement RELEASE_TYPE=$@ > /tmp/announce-$(my_distdir)
660         ln $(rel-files) $(release_archive_dir)
661         chmod a-w $(rel-files)
662         $(MAKE) -s emit_upload_commands RELEASE_TYPE=$@
663         echo $(VERSION) > $(prev_version_file)
664         $(VC) commit -m \
665           '$(prev_version_file): Record previous version: $(VERSION).' \
666           $(prev_version_file)