Use mktemp, not mkdtemp, to create test directories.
[coreutils/ericb.git] / Makefile.maint
bloba0d78727e06e0dba3b0b3b16cc347ef911ae5cf7
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 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 # Used for diffs and xdeltas.
60 release_archive_dir ?= ../release
62 # Prevent programs like 'sort' from considering distinct strings to be equal.
63 # Doing it here saves us from having to set LC_ALL elsewhere in this file.
64 export LC_ALL = C
68 ## --------------- ##
69 ## Sanity checks.  ##
70 ## --------------- ##
72 # FIXME: add a check to prohibit definition in src/*.c of symbols defined
73 # in system.h.  E.g. today I removed from tail.c a useless definition of
74 # ENOSYS.  It was useless because system.h ensures it's defined.
76 # Collect the names of rules starting with `sc_'.
77 syntax-check-rules := $(shell sed -n 's/^\(sc_[a-zA-Z0-9_-]*\):.*/\1/p' $(ME))
78 .PHONY: $(syntax-check-rules)
80 # Checks that don't require cvs.
81 # Run `changelog-check' last, as previous test may reveal problems requiring
82 # new ChangeLog entries.
83 local-checks-available = \
84   po-check copyright-check m4-check author_mark_check \
85   changelog-check patch-check strftime-check $(syntax-check-rules) \
86   makefile_path_separator_check \
87   makefile-check check-AUTHORS
88 .PHONY: $(local-checks-available)
90 local-check := $(filter-out $(local-checks-to-skip), $(local-checks-available))
92 syntax-check: $(local-check)
93 #       @grep -nE '#  *include <(limits|std(def|arg|bool))\.h>'         \
94 #           $$(find -type f -name '*.[chly]') &&                        \
95 #         { echo '$(ME): found conditional include' 1>&2;               \
96 #           exit 1; } || :
98 #       grep -nE '^#  *include <(string|stdlib)\.h>'                    \
99 #           $(srcdir)/{lib,src}/*.[chy] &&                              \
100 #         { echo '$(ME): FIXME' 1>&2;                                   \
101 #           exit 1; } || :
102 # FIXME: don't allow `#include .strings\.h' anywhere
104 sc_cast_of_argument_to_free:
105         @grep -nE '\<free \(\(' $$($(CVS_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\>' $$($(CVS_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\>' $$($(CVS_LIST_EXCEPT)) &&            \
116           { echo '$(ME): don'\''t cast alloca return value' 1>&2;       \
117             exit 1; } || :
119 sc_space_tab:
120         @grep -n '[ ]   ' $$($(CVS_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))\>' $$($(CVS_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             $$($(CVS_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' $$($(CVS_LIST_EXCEPT)) &&              \
149           { echo '$(ME): found use of "file''system";'                  \
150             'rewrite to use "file system"' 1>&2;                        \
151             exit 1; } || :
153 sc_no_have_config_h:
154         @grep -n 'HAVE''_CONFIG_H' $$($(CVS_LIST_EXCEPT)) &&            \
155           { echo '$(ME): found use of HAVE''_CONFIG_H; remove'          \
156                 1>&2; exit 1; } || :
158 # Nearly all .c files must include <config.h>.
159 sc_require_config_h:
160         @if $(CVS_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then         \
161           grep -L '^# *include <config\.h>'                             \
162                 $$($(CVS_LIST_EXCEPT) | grep '\.c$$')                   \
163               | grep . &&                                               \
164           { echo '$(ME): the above files do not include <config.h>'     \
165                 1>&2; exit 1; } || :;                                   \
166         else :;                                                         \
167         fi
169 # Prohibit the inclusion of assert.h without an actual use of assert.
170 sc_prohibit_assert_without_use:
171         @if $(CVS_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then         \
172           files=$$(grep -l '# *include <assert\.h>'                     \
173                     $$($(CVS_LIST_EXCEPT) | grep '\.c$$')) &&           \
174           grep -L '\<assert (' $$files                                  \
175               | grep . &&                                               \
176             { echo "$(ME): the above files include <assert.h> but don't use it" \
177                   1>&2; exit 1; } || :;                                 \
178         else :;                                                         \
179         fi
181 # Don't include quotearg.h unless you use one of its functions.
182 sc_prohibit_quotearg_without_use:
183         @if $(CVS_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then         \
184           files=$$(grep -l '# *include "quotearg\.h"'                   \
185                     $$($(CVS_LIST_EXCEPT) | grep '\.c$$')) &&           \
186           grep -LE '\<quotearg(_[^ ]+)? \(' $$files                     \
187               | grep . &&                                               \
188             { echo "$(ME): the above files include "quotearg.h" but don't use it" \
189                   1>&2; exit 1; } || :;                                 \
190         else :;                                                         \
191         fi
193 # Don't include quote.h unless you use one of its functions.
194 sc_prohibit_quote_without_use:
195         @if $(CVS_LIST_EXCEPT) | grep '\.c$$' > /dev/null; then         \
196           files=$$(grep -l '# *include "quote\.h"'                      \
197                     $$($(CVS_LIST_EXCEPT) | grep '\.c$$')) &&           \
198           grep -LE '\<quote(_n)? \(' $$files                    \
199               | grep . &&                                               \
200             { echo "$(ME): the above files include "quote.h" but don't use it" \
201                   1>&2; exit 1; } || :;                                 \
202         else :;                                                         \
203         fi
205 sc_obsolete_symbols:
206         @grep -nE '\<(HAVE''_FCNTL_H|O''_NDELAY)\>'                     \
207              $$($(CVS_LIST_EXCEPT)) &&                                  \
208           { echo '$(ME): do not use HAVE''_FCNTL_H or O''_NDELAY'       \
209                 1>&2; exit 1; } || :
211 # FIXME: warn about definitions of EXIT_FAILURE, EXIT_SUCCESS, STREQ
213 # Each nonempty line must start with a year number, or a TAB.
214 sc_changelog:
215         @grep -n '^[^12 ]' $$(find . -maxdepth 2 -name ChangeLog) &&    \
216           { echo '$(ME): found unexpected prefix in a ChangeLog' 1>&2;  \
217             exit 1; } || :
219 # Ensure that dd's definition of LONGEST_SYMBOL stays in sync
220 # with the strings from the two affected variables.
221 dd_c = $(srcdir)/src/dd.c
222 sc_dd_max_sym_length:
223 ifneq ($(wildcard $(dd_c)),)
224         @len=$$( (sed -n '/conversions\[\] =$$/,/^};/p' $(dd_c);\
225                  sed -n '/flags\[\] =$$/,/^};/p' $(dd_c) )      \
226                 |sed -n '/"/s/^[^"]*"\([^"]*\)".*/\1/p'         \
227               | wc --max-line-length);                          \
228         max=$$(sed -n '/^#define LONGEST_SYMBOL /s///p' $(dd_c) \
229               |tr -d '"' | wc --max-line-length);               \
230         if test "$$len" = "$$max"; then :; else                 \
231           echo 'dd.c: LONGEST_SYMBOL is not longest' 1>&2;      \
232           exit 1;                                               \
233         fi
234 endif
236 # Many m4 macros names once began with `jm_'.
237 # On 2004-04-13, they were all changed to start with gl_ instead.
238 # Make sure that none are inadvertently reintroduced.
239 sc_prohibit_jm_in_m4:
240         @grep -nE 'jm_[A-Z]'                                    \
241                 $$($(CVS_LIST) m4 |grep '\.m4$$'; echo /dev/null) && \
242             { echo '$(ME): do not use jm_ in m4 macro names'    \
243               1>&2; exit 1; } || :
245 sc_root_tests:
246         @if test -d tests \
247               && grep check-root tests/Makefile.am>/dev/null 2>&1; then \
248         t1=sc-root.expected; t2=sc-root.actual;                         \
249         grep -nl '^PRIV_CHECK_ARG=require-root'                         \
250           $$($(CVS_LIST) tests) |sed s,tests,., |sort > $$t1;           \
251         sed -n 's,      cd \([^ ]*\) .*MAKE..check TESTS=\(.*\),./\1/\2,p' \
252           $(srcdir)/tests/Makefile.am |sort > $$t2;                     \
253         diff -u $$t1 $$t2 || diff=1;                                    \
254         rm -f $$t1 $$t2;                                                \
255         test "$$diff"                                                   \
256           && { echo 'tests/Makefile.am: missing check-root action'>&2;  \
257                exit 1; } || :;                                          \
258         fi
260 headers_with_interesting_macro_defs = \
261   exit.h        \
262   fcntl_.h      \
263   fnmatch_.h    \
264   intprops.h    \
265   inttypes_.h   \
266   lchown.h      \
267   openat.h      \
268   stat-macros.h \
269   stdint_.h
271 # Create a list of regular expressions matching the names
272 # of macros that are guaranteed by parts of gnulib to be defined.
273 .re-defmac:
274         @(cd $(srcdir)/lib;                                             \
275           for f in $(headers_with_interesting_macro_defs); do           \
276             test -f $$f &&                                              \
277               sed -n '/^# *define \([^_ (][^ (]*\)[ (].*/s//\1/p' $$f;  \
278            done;                                                        \
279          ) | sort -u                                                    \
280            | grep -Ev 'ATTRIBUTE_NORETURN|SIZE_MAX'                     \
281            | sed 's/^/^# *define /'                                     \
282           > $@-t
283         @mv $@-t $@
285 # Don't define macros that we already get from gnulib header files.
286 sc_always_defined_macros: .re-defmac
287         @if test -f $(srcdir)/src/system.h; then                        \
288           trap 'rc=$$?; rm -f .re-defmac; exit $$rc' 0 1 2 3 15;        \
289           grep -f .re-defmac $$($(CVS_LIST))                            \
290             && { echo '$(ME): define the above via some gnulib .h file' \
291                   1>&2;  exit 1; } || :;                                \
292         fi
294 # Create a list of regular expressions matching the names
295 # of files included from system.h.  Exclude a couple.
296 .re-list:
297         @sed -n '/^# *include /s///p' $(srcdir)/src/system.h \
298           | grep -Ev 'sys/(param|file)\.h' \
299           | sed 's/ .*//;;s/^["<]/^# *include [<"]/;s/\.h[">]$$/\\.h[">]/' \
300           > $@-t
301         @mv $@-t $@
303 # Files in src/ should not include directly any of
304 # the headers already included via system.h.
305 sc_system_h_headers: .re-list
306         @if test -f $(srcdir)/src/system.h; then                        \
307           trap 'rc=$$?; rm -f .re-list; exit $$rc' 0 1 2 3 15;          \
308           grep -nE -f .re-list                                          \
309               $$($(CVS_LIST) src |                                      \
310                  grep -Ev '((copy|system)\.h|parse-gram\.c)$$')         \
311             && { echo '$(ME): the above are already included via system.h'\
312                   1>&2;  exit 1; } || :;                                \
313         fi
315 sc_sun_os_names:
316         @grep -nEi \
317             'solaris[^[:alnum:]]*2\.(7|8|9|[1-9][0-9])|sunos[^[:alnum:]][6-9]' \
318             $$($(CVS_LIST_EXCEPT)) &&                                   \
319           { echo '$(ME): found misuse of Sun OS version numbers' 1>&2;  \
320             exit 1; } || :
322 sc_the_the:
323         @grep -ni '\<the ''the\>' $$($(CVS_LIST_EXCEPT)) &&             \
324           { echo '$(ME): found use of "the ''the";' 1>&2;               \
325             exit 1; } || :
327 sc_tight_scope:
328         $(MAKE) -C src $@
330 sc_trailing_blank:
331         @grep -n '[      ]$$' $$($(CVS_LIST_EXCEPT)) &&                 \
332           { echo '$(ME): found trailing blank(s)'                       \
333                 1>&2; exit 1; } || :
335 # Match lines like the following, but where there is only one space
336 # between the options and the description:
337 #   -D, --all-repeated[=delimit-method]  print all duplicate lines\n
338 longopt_re = --[a-z][0-9A-Za-z-]*(\[?=[0-9A-Za-z-]*\]?)?
339 sc_two_space_separator_in_usage:
340         @grep -nE '^   *(-[A-Za-z],)? $(longopt_re) [^ ].*\\$$'         \
341             $$($(CVS_LIST_EXCEPT)) &&                                   \
342           { echo "$(ME): help2man requires at least two spaces between"; \
343             echo "$(ME): an option and its description"; \
344                 1>&2; exit 1; } || :
346 # Look for diagnostics that aren't marked for translation.
347 # This won't find any for which error's format string is on a separate line.
348 sc_unmarked_diagnostics:
349         @grep -nE                                                       \
350             '\<error \([^"]*"[^"]*[a-z]{3}' $$($(CVS_LIST_EXCEPT))      \
351           | grep -v '_''(' &&                                           \
352           { echo '$(ME): found unmarked diagnostic(s)' 1>&2;            \
353             exit 1; } || :
355 # Avoid useless parentheses like those in this example:
356 # #if defined (SYMBOL) || defined (SYM2)
357 sc_useless_cpp_parens:
358         @grep -n '^# *if .*defined *(' $$($(CVS_LIST_EXCEPT)) &&        \
359           { echo '$(ME): found useless parentheses in cpp directive'    \
360                 1>&2; exit 1; } || :
362 # Require the latest GPL.
363 sc_GPL_version:
364         @grep -n 'either ''version [^3]' $$($(CVS_LIST_EXCEPT)) &&      \
365           { echo '$(ME): GPL vN, N!=3' 1>&2; exit 1; } || :
367 # Ensure that the c99-to-c89 patch applies cleanly.
368 patch-check:
369         rm -rf src-c89 $@.1 $@.2
370         cp -a src src-c89
371         (cd src-c89; patch -p1 -V never --fuzz=0) < src/c99-to-c89.diff \
372           > $@.1 2>&1
373         if test "$$REGEN_PATCH" = yes; then \
374           diff -upr src src-c89 | sed 's,src-c89/,src/,' \
375             | grep -v '^Only in' > new-diff || : ; fi
376         grep -v '^patching file ' $@.1 > $@.2 || :
377         msg=ok; test -s $@.2 && msg='fuzzy patch' || : ;        \
378         rm -f src-c89/*.o || msg='rm failed';                   \
379         $(MAKE) -C src-c89 CFLAGS='-Wdeclaration-after-statement -Werror' \
380           || msg='compile failure with extra options';          \
381         test "$$msg" = ok && rm -rf src-c89 $@.1 $@.2 || echo "$$msg" 1>&2; \
382         test "$$msg" = ok
384 # Ensure that date's --help output stays in sync with the info
385 # documentation for GNU strftime.  The only exception is %N,
386 # which date accepts but GNU strftime does not.
387 extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/'
388 strftime-check:
389         if test -f $(srcdir)/src/date.c; then                           \
390           grep '^  %.  ' $(srcdir)/src/date.c | sort                    \
391             | $(extract_char) > $@-src;                                 \
392           { echo N;                                                     \
393             info libc date calendar format | grep '^    `%.'\'          \
394               | $(extract_char); } | sort > $@-info;                    \
395           diff -u $@-src $@-info || exit 1;                             \
396           rm -f $@-src $@-info;                                         \
397         fi
399 check-AUTHORS:
400         $(MAKE) -C src $@
402 # Ensure that we use only the standard $(VAR) notation,
403 # not @...@ in Makefile.am, now that we can rely on automake
404 # to emit a definition for each substituted variable.
405 makefile-check:
406         grep -nE '@[A-Z_0-9]+@' `find . -name Makefile.am` \
407           && { echo 'Makefile.maint: use $$(...), not @...@' 1>&2; exit 1; } || :
409 news-date-check: NEWS
410         today=`date +%Y-%m-%d`;                                         \
411         if head NEWS | grep '^\*.* $(VERSION_REGEXP) ('$$today')'       \
412             >/dev/null; then                                            \
413           :;                                                            \
414         else                                                            \
415           echo "version or today's date is not in NEWS" 1>&2;           \
416           exit 1;                                                       \
417         fi
419 changelog-check:
420         if head ChangeLog | grep 'Version $(VERSION_REGEXP)\.$$'        \
421             >/dev/null; then                                            \
422           :;                                                            \
423         else                                                            \
424           echo "$(VERSION) not in ChangeLog" 1>&2;                      \
425           exit 1;                                                       \
426         fi
428 m4-check:
429         @grep -n 'AC_DEFUN([^[]' m4/*.m4 \
430           && { echo 'Makefile.maint: quote the first arg to AC_DEFUN' 1>&2; \
431                exit 1; } || :
433 # Verify that all source files using _() are listed in po/POTFILES.in.
434 # FIXME: don't hard-code file names below; use a more general mechanism.
435 po-check:
436         if test -f po/POTFILES.in; then                                 \
437           grep -E -v '^(#|$$)' po/POTFILES.in                           \
438             | grep -v '^src/false\.c$$' | sort > $@-1;                  \
439           files=;                                                       \
440           for file in $$($(CVS_LIST_EXCEPT)) lib/*.[ch]; do             \
441             case $$file in                                              \
442             djgpp/* | man/*) continue;;                                 \
443             */c99-to-c89.diff) continue;;                               \
444             esac;                                                       \
445             case $$file in                                              \
446             *.[ch])                                                     \
447               base=`expr " $$file" : ' \(.*\)\..'`;                     \
448               { test -f $$base.l || test -f $$base.y; } && continue;;   \
449             esac;                                                       \
450             files="$$files $$file";                                     \
451           done;                                                         \
452           grep -E -l '\b(N?_|gettext *)\([^)"]*("|$$)' $$files          \
453             | sort -u > $@-2;                                           \
454           diff -u $@-1 $@-2 || exit 1;                                  \
455           rm -f $@-1 $@-2;                                              \
456         fi
458 # In a definition of #define AUTHORS "... and ..." where the RHS contains
459 # the English word `and', the string must be marked with `N_ (...)' so that
460 # gettext recognizes it as a string requiring translation.
461 author_mark_check:
462         @grep -n '^# *define AUTHORS "[^"]* and ' src/*.c |grep -v ' N_ (' && \
463           { echo 'Makefile.maint: enclose the above strings in N_ (...)' 1>&2; \
464             exit 1; } || :
466 # Sometimes it is useful to change the PATH environment variable
467 # in Makefiles.  When doing so, it's better not to use the Unix-centric
468 # path separator of `:', but rather the automake-provided `@PATH_SEPARATOR@'.
469 # It'd be better to use `find -print0 ...|xargs -0 ...', but less portable,
470 # and there probably aren't many projects with so many Makefile.am files
471 # that we'd have to worry about limits on command line length.
472 msg = 'Makefile.maint: Do not use `:'\'' above; use @PATH_SEPARATOR@ instead'
473 makefile_path_separator_check:
474         @grep -n 'PATH=.*:' `find $(srcdir) -name Makefile.am` \
475           && { echo $(msg) 1>&2; exit 1; } || :
477 # Check that `make alpha' will not fail at the end of the process.
478 writable-files:
479         if test -d $(release_archive_dir); then :; else                 \
480           mkdir $(release_archive_dir);                                 \
481         fi
482         for file in $(distdir).tar.gz $(xd-delta)                       \
483                     $(release_archive_dir)/$(distdir).tar.gz            \
484                     $(release_archive_dir)/$(xd-delta); do              \
485           test -e $$file || continue;                                   \
486           test -w $$file                                                \
487             || { echo ERROR: $$file is not writable; fail=1; };         \
488         done;                                                           \
489         test "$$fail" && exit 1 || :
491 v_etc_file = lib/version-etc.c
492 sample-test = tests/sample-test
493 texi = doc/$(PACKAGE).texi
494 # Make sure that the copyright date in $(v_etc_file) is up to date.
495 # Do the same for the $(sample-test) and the main doc/.texi file.
496 copyright-check:
497         @if test -f $(v_etc_file); then \
498           grep 'enum { COPYRIGHT_YEAR = '$$(date +%Y)' };' $(v_etc_file) \
499             >/dev/null \
500           || { echo 'out of date copyright in $(v_etc_file); update it' 1>&2; \
501                exit 1; }; \
502         fi
503         @if test -f $(sample-test); then \
504           grep '# Copyright (C) '$$(date +%Y)' Free' $(sample-test) \
505             >/dev/null \
506           || { echo 'out of date copyright in $(sample-test); update it' 1>&2; \
507                exit 1; }; \
508         fi
509         @if test -f $(texi); then \
510           grep 'Copyright @copyright{} .*'$$(date +%Y)' Free' $(texi) \
511             >/dev/null \
512           || { echo 'out of date copyright in $(texi); update it' 1>&2; \
513                exit 1; }; \
514         fi
517 # Sanity checks with the repository.
518 # Abort early if this tag has already been used.
519 vc-tag-check:
520         used=no;                                                        \
521         if $(VC) --help | grep CVS; then                                \
522           $(CVS) -n log -h README|grep -e $(this-vc-tag-regexp): >/dev/null \
523             && used=yes;                                                \
524         else                                                            \
525           $(GIT) tag -l '^$(this-vc-tag-regexp)$$' && used=yes;         \
526         fi;                                                             \
527         if test "$$used" = yes; then                                    \
528           echo "$(this-vc-tag) has already been used; not tagging" 1>&2; \
529           exit 1;                                                       \
530         fi
532 vc-diff-check:
533         $(VC) diff > vc-diffs || :
534         if test -s vc-diffs; then                               \
535           cat vc-diffs;                                         \
536           echo "Some files are locally modified:" 1>&2;         \
537           exit 1;                                               \
538         else                                                    \
539           rm vc-diffs;                                          \
540         fi
542 cvs-check: vc-diff-check vc-tag-check
544 maintainer-distcheck:
545         $(MAKE) distcheck
546         $(MAKE) my-distcheck
549 # Tag before making distribution.  Also, don't make a distribution if
550 # checks fail.  Also, make sure the NEWS file is up-to-date.
551 # FIXME: use dist-hook/my-dist like distcheck-hook/my-distcheck.
552 vc-dist: $(local-check) cvs-check maintainer-distcheck
553         $(VC-tag) $(this-vc-tag)
554         $(MAKE) dist
556 # Use this to make sure we don't run these programs when building
557 # from a virgin tgz file, below.
558 null_AM_MAKEFLAGS = \
559   ACLOCAL=false \
560   AUTOCONF=false \
561   AUTOMAKE=false \
562   AUTOHEADER=false \
563   MAKEINFO=false
565 built_programs = $$(cd src && MAKEFLAGS= $(MAKE) -s built_programs.list)
567 warn_cflags = -Dlint -O -Werror -Wall -Wformat -Wshadow -Wpointer-arith
568 bin=bin-$$$$
570 # Use -Wformat -Werror to detect format-string/arg-list mismatches.
571 # Also, check for shadowing problems with -Wshadow, and for pointer
572 # arithmetic problems with -Wpointer-arith.
573 # These CFLAGS are pretty strict.  If you build this target, you probably
574 # have to have a recent version of gcc and glibc headers.
575 # The for-loop below ensures that there is a bin/ directory full of all
576 # of the programs under test (except the few that are required for basic
577 # Makefile rules), all symlinked to the just-built "false" program.
578 # This is to ensure that if ever a test neglects to make PATH include
579 # the build srcdir, these always-failing programs will run.
580 # Otherwise, it is too easy to test the wrong programs.
581 # Note that "false" itself is a symlink to true, so it too will malfunction.
582 TMPDIR ?= /tmp
583 t=$(TMPDIR)/$(PACKAGE)/test
584 my-distcheck: $(local-check) $(release_archive_dir)/$(prev-tgz)
585         -rm -rf $(t)
586         mkdir -p $(t)
587         GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
588         cd $(t)/$(distdir)                              \
589           && ./configure --disable-nls                  \
590           && $(MAKE) CFLAGS='$(warn_cflags)'            \
591               AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)'       \
592           && $(MAKE) dvi                                \
593           && mkdir $(bin)                               \
594           && for i in $(built_programs); do             \
595                case $$i in                              \
596                  rm|expr|basename|echo|sort|ls|tr);;    \
597                  dirname);;                             \
598                  *) ln -s ../src/false $(bin)/$$i;;     \
599                esac;                                    \
600              done                                       \
601           && ln -sf ../src/true $(bin)/false            \
602           && PATH=`pwd`/$(bin):$$PATH $(MAKE) check     \
603           && rm -rf $(bin)                              \
604           && $(MAKE) distclean
605         (cd $(t) && mv $(distdir) $(distdir).old        \
606           && $(AMTAR) -zxf - ) < $(distdir).tar.gz
607         diff -ur $(t)/$(distdir).old $(t)/$(distdir)
608         if test -f $(srcdir)/src/c99-to-c89.diff; then                  \
609           cd $(t)/$(distdir)                                            \
610             && (cd src && patch -V never --fuzz=0 <c99-to-c89.diff)     \
611             && ./configure --disable-largefile                          \
612                  CFLAGS='-Werror -ansi -Wno-long-long'                  \
613             && $(MAKE);                                                 \
614         fi
615         -rm -rf $(t)
616         @echo "========================"; \
617         echo "$(distdir).tar.gz is ready for distribution"; \
618         echo "========================"
620 WGET = wget
621 WGETFLAGS = -C off
623 rel-check:
624         tarz=/tmp/rel-check-tarz-$$$$; \
625         md5_tmp=/tmp/rel-check-md5-$$$$; \
626         set -e; \
627         trap 'status=$$?; rm -f $$tarz $$md5_tmp; exit $$status' 0 1 2 3 15; \
628         $(WGET) $(WGETFLAGS) -q --output-document=$$tarz $(url); \
629         echo "$(md5)  -" > $$md5_tmp; \
630         md5sum -c $$md5_tmp < $$tarz
632 prev-tgz = $(PACKAGE)-$(PREV_VERSION).tar.gz
633 xd-delta = $(PACKAGE)-$(PREV_VERSION)-$(VERSION).xdelta
635 rel-files = $(xd-delta) $(DIST_ARCHIVES)
637 # Approximate the date of last gnulib "update" by the ChangeLog file's
638 # mtime, and provide that date in the announcement.
639 announcement: NEWS ChangeLog $(rel-files)
640         @cl_date=$$(stat --printf @%Y $(gnulib_dir)/ChangeLog);         \
641         utc_date=$$(date -u --date $$cl_date '+%Y-%m-%d %T %z');        \
642         ./build-aux/announce-gen                                        \
643             --release-type=$(RELEASE_TYPE)                              \
644             --package=$(PACKAGE)                                        \
645             --prev=$(PREV_VERSION)                                      \
646             --curr=$(VERSION)                                           \
647             --gpg-key-id=$(gpg_key_ID)                                  \
648             --news=NEWS                                                 \
649             --bootstrap-tools=autoconf,automake,bison,gnulib            \
650             --gnulib-snapshot-time-stamp="$$utc_date"                   \
651             $(addprefix --url-dir=, $(url_dir_list))
653 ## ---------------- ##
654 ## Updating files.  ##
655 ## ---------------- ##
657 ftp-gnu = ftp://ftp.gnu.org/gnu
658 www-gnu = http://www.gnu.org
660 # Use mv, if you don't have/want move-if-change.
661 move_if_change ?= move-if-change
663 emit_upload_commands:
664         @echo =====================================
665         @echo =====================================
666         @echo "$(srcdir)/build-aux/gnupload $(GNUPLOADFLAGS) \\"
667         @echo "    --to $(gnu_rel_host):$(PACKAGE) \\"
668         @echo "  $(rel-files)"
669         @echo '# send the /tmp/announcement e-mail'
670         @echo =====================================
671         @echo =====================================
673 $(xd-delta): $(release_archive_dir)/$(prev-tgz) $(distdir).tar.gz
674         xdelta delta -9 $^ $@ || :
676 .PHONY: alpha beta major
677 alpha beta major: news-date-check changelog-check $(local-check) writable-files
678         test $@ = major                                         \
679           && { echo $(VERSION) | grep -E '^[0-9]+(\.[0-9]+)+$$' \
680                || { echo "invalid version string: $(VERSION)" 1>&2; exit 1;};}\
681           || :
682         $(MAKE) vc-dist
683         $(MAKE) $(xd-delta)
684         $(MAKE) -s announcement RELEASE_TYPE=$@ > /tmp/announce-$(my_distdir)
685         ln $(rel-files) $(release_archive_dir)
686         chmod a-w $(rel-files)
687         $(MAKE) -s emit_upload_commands RELEASE_TYPE=$@
688         echo $(VERSION) > $(prev_version_file)
689         $(VC) commit -m \
690           '$(prev_version_file): Record previous version: $(VERSION).' \
691           $(prev_version_file)