(CVS_LIST): Use build-aux/cvsu, now that we have our own copy of cvsu.
[platform/upstream/coreutils.git] / Makefile.maint
1 # -*-Makefile-*-
2 # This Makefile fragment is shared between the coreutils,
3 # CPPI, Bison, and Autoconf.
4
5 ## Copyright (C) 2001-2005 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 2, or (at your option)
10 ## any later version.
11 ##
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.
16 ##
17 ## You should have received a copy of the GNU General Public License
18 ## along with this program; if not, write to the Free Software
19 ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 ## 02110-1301, USA.
21
22 # This is reported not to work with make-3.79.1
23 # ME := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
24 ME := Makefile.maint
25
26 # Do not save the original name or timestamp in the .tar.gz file.
27 GZIP_ENV = '--no-name --best --rsyncable'
28
29 CVS = cvs
30
31 # cvsu is part of the cvsutils package: http://www.red-bean.com/cvsutils/
32 CVS_LIST = build-aux/cvsu --find --types=AFGM
33
34 ifeq ($(origin prev_version_file), undefined)
35   prev_version_file = .prev-version
36 endif
37
38 PREV_VERSION := $(shell cat $(prev_version_file))
39 VERSION_REGEXP = $(subst .,\.,$(VERSION))
40
41 tag-package = $(shell echo "$(PACKAGE)" | tr '[:lower:]' '[:upper:]')
42 tag-this-version = $(subst .,_,$(VERSION))
43 this-cvs-tag = $(tag-package)-$(tag-this-version)
44 my_distdir = $(PACKAGE)-$(VERSION)
45
46 # Old releases are stored here.
47 # Used for diffs and xdeltas.
48 release_archive_dir ?= ../release
49
50 # Prevent programs like 'sort' from considering distinct strings to be equal.
51 # Doing it here saves us from having to set LC_ALL elsewhere in this file.
52 export LC_ALL = C
53
54
55
56 ## --------------- ##
57 ## Sanity checks.  ##
58 ## --------------- ##
59
60 # Checks that don't require cvs.
61 # Run `changelog-check' last, as previous test may reveal problems requiring
62 # new ChangeLog entries.
63 local-checks-available = \
64   po-check copyright-check writable-files m4-check author_mark_check \
65   changelog-check strftime-check syntax-check makefile_path_separator_check \
66   makefile-check
67 .PHONY: $(local-checks-available)
68
69 local-check = $(filter-out $(local-checks-to-skip), $(local-checks-available))
70
71 .PHONY: $(syntax-check-rules)
72 syntax-check-rules = \
73   sc_cast_of_argument_to_free \
74   sc_cast_of_x_alloc_return_value \
75   sc_cast_of_alloca_return_value \
76   sc_dd_max_sym_length \
77   sc_error_exit_success \
78   sc_file_system \
79   sc_no_if_have_config_h \
80   sc_obsolete_symbols \
81   sc_prohibit_atoi_atof \
82   sc_prohibit_jm_in_m4 \
83   sc_require_config_h \
84   sc_root_tests \
85   sc_space_tab \
86   sc_sun_os_names \
87   sc_system_h_headers \
88   sc_tight_scope \
89   sc_trailing_blank \
90   sc_unmarked_diagnostics \
91   sc_useless_cpp_parens
92
93 syntax-check: $(syntax-check-rules)
94 #       @grep -E '#  *include <(limits|std(def|arg|bool))\.h>'          \
95 #           $$(find -type f -name '*.[chly]') &&                        \
96 #         { echo '$(ME): found conditional include' 1>&2;               \
97 #           exit 1; } || :
98
99 #       grep -E '^#  *include <(string|stdlib)\.h>'                     \
100 #           $(srcdir)/{lib,src}/*.[chy] &&                              \
101 #         { echo '$(ME): FIXME' 1>&2;                                   \
102 #           exit 1; } || :
103 # FIXME: don't allow `#include .strings\.h' anywhere
104
105 # FIXME: add a check for this.
106 # Nearly every lib/*.c file must include config.h, like this:
107 #  #ifdef HAVE_CONFIG_H
108 #  # include <config.h>
109 #  #endif
110
111 sc_cast_of_argument_to_free:
112         @grep -E '\<free \(\(' $(srcdir)/{lib,src}/*.[chly] &&          \
113           { echo '$(ME): don'\''t cast free argument' 1>&2;             \
114             exit 1; } || :
115
116 sc_cast_of_x_alloc_return_value:
117         @grep -E --exclude=$(srcdir)/lib/regex.c                        \
118             '\*\) *x(m|c|re)alloc\>'                                    \
119             $(srcdir)/{lib,src}/*.[chy] &&                              \
120           { echo '$(ME): don'\''t cast x*alloc return value' 1>&2;      \
121             exit 1; } || :
122
123 sc_cast_of_alloca_return_value:
124         @grep -E '\*\) *alloca\>'                                       \
125             $(srcdir)/src/*.[chy] &&                                    \
126           { echo '$(ME): don'\''t cast alloca return value' 1>&2;       \
127             exit 1; } || :
128
129 sc_space_tab:
130         @( $(CVS_LIST) ) > /dev/null 2>&1 || : &&                       \
131           grep '[ ]     '                                               \
132              $$($(CVS_LIST) | grep -vEf .x-$@ ) &&                      \
133           { echo '$(ME): found SPACE-TAB sequence; remove the SPACE'    \
134                 1>&2; exit 1; } || :
135
136 # Don't use atoi, atof, atol, atoll, or atoq in `real' code.
137 # They provide no error checking mechanism.
138 # Instead, use strto* functions.
139 sc_prohibit_atoi_atof:
140         @( $(CVS_LIST) ) > /dev/null 2>&1 || : &&                       \
141           grep -E '\<(ato[filq]|atoll)\>'                               \
142              $$($(CVS_LIST) | grep -vEf .x-$@ ) &&                      \
143           { echo '$(ME): do not use atof, atoi, atol, atoll, or atoq'   \
144                 1>&2; exit 1; } || :
145
146 # Using EXIT_SUCCESS as the first argument to error is misleading,
147 # since when that parameter is 0, error does not exit.  Use `0' instead.
148 sc_error_exit_success:
149         @grep -F 'error (EXIT_SUCCESS,'                                 \
150             $$(find -type f -name '*.[chly]') &&                        \
151           { echo '$(ME): found error (EXIT_SUCCESS' 1>&2;               \
152             exit 1; } || :
153
154 sc_file_system:
155         @grep -i 'filesystem'                                           \
156              $$($(CVS_LIST) | grep -vEf .x-$@ ) &&                      \
157           { echo '$(ME): found use of "filesystem";'                    \
158             'rewrite to use "file system"' 1>&2;                        \
159             exit 1; } || :
160
161 sc_no_if_have_config_h:
162         @( $(CVS_LIST) ) > /dev/null 2>&1 || : &&                       \
163           grep '^# *if HAVE_CONFIG_H'                                   \
164              $$($(CVS_LIST) | grep -vEf .x-$@ ) &&                      \
165           { echo '$(ME): found use of #if HAVE_CONFIG_H; use #ifdef'    \
166                 1>&2; exit 1; } || :
167
168 # Nearly all .c files must include <config.h>.
169 sc_require_config_h:
170         @( $(CVS_LIST) ) > /dev/null 2>&1 || : &&                       \
171           grep -L '^# *include <config\.h>'                             \
172               $$($(CVS_LIST) | grep '\.c$$' | grep -vEf .x-$@ )         \
173             | grep . &&                                                 \
174           { echo '$(ME): the above files do not include <config.h>'     \
175                 1>&2; exit 1; } || :
176
177 sc_obsolete_symbols:
178         @( $(CVS_LIST) ) > /dev/null 2>&1 || : &&                       \
179           grep -E '\<(HAVE_FCNTL_H)\>'                                  \
180              $$($(CVS_LIST) | grep -vEf .x-$@ ) &&                      \
181           { echo '$(ME): do not use HAVE_FCNTL_H'                       \
182                 1>&2; exit 1; } || :
183
184 # FIXME: warn about definitions of EXIT_FAILURE, EXIT_SUCCESS, STREQ
185
186 # Each nonempty line must start with a year number, or a TAB.
187 sc_changelog:
188         @grep '^[^12    ]' $$(find . -maxdepth 2 -name ChangeLog) &&    \
189           { echo '$(ME): found unexpected prefix in a ChangeLog' 1>&2;  \
190             exit 1; } || :
191
192 # Ensure that dd's definition of LONGEST_SYMBOL stays in sync
193 # with the strings from the two affected variables.
194 dd_c = $(srcdir)/src/dd.c
195 sc_dd_max_sym_length:
196         @test -f $(dd_c) || exit 0;                             \
197         len=$$( (sed -n '/conversions\[\] =$$/,/^};/p' $(dd_c); \
198                  sed -n '/flags\[\] =$$/,/^};/p' $(dd_c) )      \
199                 |sed -n '/"/s/^[^"]*"\([^"]*\)".*/\1/p'         \
200               | wc --max-line-length);                          \
201         max=$$(sed -n '/^#define LONGEST_SYMBOL /s///p' $(dd_c) \
202               |tr -d '"' | wc --max-line-length);               \
203         if test "$$len" = "$$max"; then :; else                 \
204           echo 'dd.c: LONGEST_SYMBOL is not longest' 1>&2;      \
205           exit 1;                                               \
206         fi
207
208 # Many m4 macros names once began with `jm_'.
209 # On 2004-04-13, they were all changed to start with gl_ instead.
210 # Make sure that none are inadvertently reintroduced.
211 sc_prohibit_jm_in_m4:
212         @( $(CVS_LIST) ) > /dev/null 2>&1 || : &&                       \
213           grep -E 'jm_[A-Z]'                                            \
214                 $$($(CVS_LIST) $(srcdir)/m4 |grep '\.m4$$') &&          \
215             { echo '$(ME): do not use jm_ in m4 macro names'            \
216               1>&2; exit 1; } || :
217
218 sc_root_tests:
219         @t1=sc-root.expected; t2=sc-root.actual;                        \
220         grep -l '^PRIV_CHECK_ARG=require-root'                          \
221           $$($(CVS_LIST) tests) |sed s,tests,., |sort > $$t1;           \
222         sed -n 's,      cd \([^ ]*\) .*MAKE..check TESTS=\(.*\),./\1/\2,p' \
223           $(srcdir)/tests/Makefile.am |sort > $$t2;                     \
224         diff -u $$t1 $$t2 || diff=1;                                    \
225         rm -f $$t1 $$t2;                                                \
226         test "$$diff"                                                   \
227           && { echo 'tests/Makefile.am: missing check-root action'>&2;  \
228                exit 1; } || :
229
230 # Create a list of regular expressions matching the names
231 # of files included from system.h.  Exclude a couple.
232 .re-list:
233         @sed -n '/^# *include /s///p' $(srcdir)/src/system.h \
234           | grep -Ev 'sys/(param|file)\.h' \
235           | sed 's/ .*//;;s/^["<]/^# *include [<"]/;s/\.h[">]$$/\\.h[">]/' \
236           > $@-t
237         @mv $@-t $@
238
239 # Files in src/ should not include directly any of
240 # the headers already included via system.h.
241 sc_system_h_headers: .re-list
242         @if test -f $(srcdir)/src/system.h; then                        \
243           ( $(CVS_LIST) ) > /dev/null 2>&1 || exit 0;                   \
244           trap 'rc=$$?; rm -f .re-list; exit $$rc' 0 1 2 3 15;          \
245           grep -E -f .re-list                                           \
246               $$($(CVS_LIST) src | grep -Ev '(copy|system)\.h$$')       \
247             && { echo '$(ME): the above are already included via system.h'\
248                   1>&2;  exit 1; } || :;                                \
249         fi
250
251 sc_sun_os_names:
252         @( $(CVS_LIST) ) > /dev/null 2>&1 || : && \
253         grep -Ei \
254             'solaris[^[:alnum:]]*2\.(7|8|9|[1-9][0-9])|sunos[^[:alnum:]][6-9]' \
255           $$($(CVS_LIST) | grep -vEf .x-$@ ) &&                         \
256           { echo '$(ME): found misuse of Sun OS version numbers' 1>&2;  \
257             exit 1; } || :
258
259 sc_tight_scope:
260         $(MAKE) -C src $@
261
262 sc_trailing_blank:
263         @( $(CVS_LIST) ) > /dev/null 2>&1 || : &&                       \
264           grep '[        ]$$'                                           \
265              $$($(CVS_LIST) | grep -vEf .x-$@ ) &&                      \
266           { echo '$(ME): found trailing blank(s)'                       \
267                 1>&2; exit 1; } || :
268
269 # Look for diagnostics that aren't marked for translation.
270 # This won't find any for which error's format string is on a separate line.
271 sc_unmarked_diagnostics:
272         @( $(CVS_LIST) ) > /dev/null 2>&1 || : &&                       \
273           grep -E                                                       \
274             '\<error \([^"]*"[^"]*[a-z]{3}'                             \
275              $$($(CVS_LIST) | grep -vEf .x-$@ )                         \
276           | grep -v '_(' &&                                             \
277           { echo '$(ME): found unmarked diagnostic(s)' 1>&2;            \
278             exit 1; } || :
279
280 # Avoid useless parentheses like those in this example:
281 # #if defined (SYMBOL) || defined (SYM2)
282 sc_useless_cpp_parens:
283         @( $(CVS_LIST) ) > /dev/null 2>&1 || : &&                       \
284           grep '^# *if .*defined *('                                    \
285              $$($(CVS_LIST) | grep -vEf .x-$@ ) &&                      \
286           { echo '$(ME): found useless parentheses in cpp directive'    \
287                 1>&2; exit 1; } || :
288
289 # Ensure that date's --help output stays in sync with the info
290 # documentation for GNU strftime.  The only exception is %N,
291 # which date accepts but GNU strftime does not.
292 extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/'
293 strftime-check:
294         if test -f $(srcdir)/src/date.c; then                           \
295           grep '^  %.  ' $(srcdir)/src/date.c | sort                    \
296             | $(extract_char) > $@-src;                                 \
297           { echo N;                                                     \
298             info libc date calendar format | grep '^    `%.'\'          \
299               | $(extract_char); } | sort > $@-info;                    \
300           diff -u $@-src $@-info || exit 1;                             \
301           rm -f $@-src $@-info;                                         \
302         fi
303
304 # Ensure that we use only the standard $(VAR) notation,
305 # not @...@ in Makefile.am, now that we can rely on automake
306 # to emit a definition for each substituted variable.
307 makefile-check:
308         grep -E '@[A-Z_0-9]+@' `find . -name Makefile.am` \
309           && { echo 'Makefile.maint: use $$(...), not @...@' 1>&2; exit 1; } || :
310
311 news-date-check: NEWS
312         today=`date +%Y-%m-%d`; \
313         if head NEWS | grep '^\*.* $(VERSION_REGEXP) ('$$today')' \
314             >/dev/null; then \
315           :; \
316         else \
317           echo "version or today's date is not in NEWS" 1>&2; \
318           exit 1; \
319         fi
320
321 changelog-check:
322         if head ChangeLog | grep 'Version $(VERSION_REGEXP)\.$$' \
323             >/dev/null; then \
324           :; \
325         else \
326           echo "$(VERSION) not in ChangeLog" 1>&2; \
327           exit 1; \
328         fi
329
330 m4-check:
331         @grep 'AC_DEFUN([^[]' m4/*.m4 \
332           && { echo 'Makefile.maint: quote the first arg to AC_DEFUN' 1>&2; \
333                exit 1; } || :
334
335 # Verify that all source files using _() are listed in po/POTFILES.in.
336 # FIXME: don't hard-code src/false.c below; use a more general mechanism.
337 po-check:
338         ( $(CVS_LIST) ) > /dev/null 2>&1 || : &&                        \
339         if test -f po/POTFILES.in; then                                 \
340           grep -E -v '^(#|$$)' po/POTFILES.in                           \
341             | grep -v '^src/false\.c$$' | sort > $@-1;                  \
342           files=;                                                       \
343           for file in $$($(CVS_LIST) lib src | grep '\.[chly]$$'); do   \
344             case $$file in                                              \
345             *.[ch])                                                     \
346               base=`expr " $$file" : ' \(.*\)\..'`;                     \
347               { test -f $$base.l || test -f $$base.y; } && continue;;   \
348             esac;                                                       \
349             files="$$files $$file";                                     \
350           done;                                                         \
351           grep -E -l '\bN?_\([^)"]*("|$$)' $$files | sort > $@-2;       \
352           diff -u $@-1 $@-2 || exit 1;                                  \
353           rm -f $@-1 $@-2;                                              \
354         fi
355
356 # In a definition of #define AUTHORS "... and ..." where the RHS contains
357 # the English word `and', the string must be marked with `N_ (...)' so that
358 # gettext recognizes it as a string requiring translation.
359 author_mark_check:
360         @grep '^# *define AUTHORS "[^"]* and ' src/*.c |grep -v ' N_ (' && \
361           { echo 'Makefile.maint: enclose the above strings in N_ (...)' 1>&2; \
362             exit 1; } || :
363
364 # Sometimes it is useful to change the PATH environment variable
365 # in Makefiles.  When doing so, it's better not to use the Unix-centric
366 # path separator of `:', but rather the automake-provided `@PATH_SEPARATOR@'.
367 # It'd be better to use `find -print0 ...|xargs -0 ...', but less portable,
368 # and there probably aren't many projects with so many Makefile.am files
369 # that we'd have to worry about limits on command line length.
370 msg = 'Makefile.maint: Do not use `:'\'' above; use @PATH_SEPARATOR@ instead'
371 makefile_path_separator_check:
372         @grep 'PATH=.*:' `find $(srcdir) -name Makefile.am` \
373           && { echo $(msg) 1>&2; exit 1; } || :
374
375 # Check that `make alpha' will not fail at the end of the process.
376 writable-files:
377         if test -d $(release_archive_dir); then :; else                 \
378           mkdir $(release_archive_dir);                                 \
379         fi
380         for file in $(distdir).tar.gz $(xd-delta)                       \
381                     $(release_archive_dir)/$(distdir).tar.gz            \
382                     $(release_archive_dir)/$(xd-delta); do              \
383           test -e $$file || continue;                                   \
384           test -w $$file                                                \
385             || { echo ERROR: $$file is not writable; fail=1; };         \
386         done;                                                           \
387         test "$$fail" && exit 1 || :
388
389 v_etc_file = lib/version-etc.c
390 # Make sure that the copyright date in $(v_etc_file) is up to date.
391 copyright-check:
392         @if test -f $(v_etc_file); then \
393           grep 'enum { COPYRIGHT_YEAR = 2005 };' $(v_etc_file) \
394             >/dev/null \
395           || { echo 'out of date copyright in $(v_etc_file); update it' 1>&2; \
396                exit 1; }; \
397         fi
398
399
400 # Sanity checks with the CVS repository.
401 cvs-tag-check:
402         echo $(this-cvs-tag); \
403         if $(CVS) -n log -h README | grep -e $(this-cvs-tag): >/dev/null; then \
404           echo "$(this-cvs-tag) as already been used; not tagging" 1>&2; \
405           exit 1; \
406         else :; fi
407
408 cvs-diff-check:
409         if $(CVS) diff >cvs-diffs; then                         \
410           rm cvs-diffs;                                         \
411         else                                                    \
412           echo "Some files are locally modified:" 1>&2;         \
413           cat cvs-diffs;                                        \
414           exit 1;                                               \
415         fi
416
417 cvs-check: cvs-diff-check cvs-tag-check
418
419 maintainer-distcheck: changelog-check
420         $(MAKE) distcheck
421         $(MAKE) my-distcheck
422
423
424 # Tag before making distribution.  Also, don't make a distribution if
425 # checks fail.  Also, make sure the NEWS file is up-to-date.
426 # FIXME: use dist-hook/my-dist like distcheck-hook/my-distcheck.
427 cvs-dist: $(local-check) cvs-check maintainer-distcheck
428         $(CVS) update po
429         $(CVS) tag -c $(this-cvs-tag)
430         $(MAKE) dist
431
432 # Use this to make sure we don't run these programs when building
433 # from a virgin tgz file, below.
434 null_AM_MAKEFLAGS = \
435   ACLOCAL=false \
436   AUTOCONF=false \
437   AUTOMAKE=false \
438   AUTOHEADER=false \
439   MAKEINFO=false
440
441 # Detect format-string/arg-list mismatches that would normally be obscured
442 # by the use of _().  The --disable-nls effectively defines away that macro,
443 # and building with CFLAGS='-Wformat -Werror' causes any format warning to be
444 # treated as a failure.  Also, check for shadowing problems with -Wshadow.
445 # These CFLAGS are pretty strict.  If you build this target, you probably
446 # have to have a recent version of gcc and glibc headers.
447 TMPDIR ?= /tmp
448 t=$(TMPDIR)/$(PACKAGE)/test
449 my-distcheck: $(local-check) $(release_archive_dir)/$(prev-tgz)
450         -rm -rf $(t)
451         mkdir -p $(t)
452         GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
453         cd $(t)/$(distdir)                              \
454           && ./configure --disable-nls                  \
455           && $(MAKE) CFLAGS='-Werror -Wall -Wformat -Wshadow' \
456               AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)'       \
457           && $(MAKE) dvi                                \
458           && $(MAKE) check                              \
459           && $(MAKE) distclean
460         (cd $(t) && mv $(distdir) $(distdir).old        \
461           && $(AMTAR) -zxf - ) < $(distdir).tar.gz
462         diff -ur $(t)/$(distdir).old $(t)/$(distdir)
463         -rm -rf $(t)
464         @echo "========================"; \
465         echo "$(distdir).tar.gz is ready for distribution"; \
466         echo "========================"
467
468 WGET = wget
469 WGETFLAGS = -C off
470
471 tgz-md5 = $(shell md5sum < $(my_distdir).tar.gz|sed 's/  -//')
472 tgz-sha1 = $(shell sha1sum < $(my_distdir).tar.gz|sed 's/  -//')
473 bz2-md5 = $(shell md5sum < $(my_distdir).tar.bz2|sed 's/  -//')
474 bz2-sha1 = $(shell sha1sum < $(my_distdir).tar.bz2|sed 's/  -//')
475 xdelta-md5 = $(shell md5sum < $(xd-delta)|sed 's/  -//')
476 xdelta-sha1 = $(shell sha1sum < $(xd-delta)|sed 's/  -//')
477 tgz-size = $(shell du --human $(my_distdir).tar.gz|sed 's/\([MkK]\).*/ \1B/')
478 bz2-size = $(shell du --human $(my_distdir).tar.bz2|sed 's/\([MkK]\).*/ \1B/')
479 xd-size = $(shell du --human $(xd-delta)|sed 's/\([MkK]\).*/ \1B/')
480
481 rel-check:
482         tarz=/tmp/rel-check-tarz-$$$$; \
483         md5_tmp=/tmp/rel-check-md5-$$$$; \
484         set -e; \
485         trap 'status=$$?; rm -f $$tarz $$md5_tmp; exit $$status' 0 1 2 3 15; \
486         $(WGET) $(WGETFLAGS) -q --output-document=$$tarz $(url); \
487         echo "$(md5)  -" > $$md5_tmp; \
488         md5sum -c $$md5_tmp < $$tarz
489
490 prev-tgz = $(PACKAGE)-$(PREV_VERSION).tar.gz
491 xd-delta = $(PACKAGE)-$(PREV_VERSION)-$(VERSION).xdelta
492
493 rel-files = $(xd-delta) $(DIST_ARCHIVES)
494 announcement: NEWS ChangeLog $(rel-files)
495         @./announce-gen                                                 \
496             --release-type=$(RELEASE_TYPE)                              \
497             --package=$(PACKAGE)                                        \
498             --prev=$(PREV_VERSION)                                      \
499             --curr=$(VERSION)                                           \
500             --release-archive-directory=$(release_archive_dir)          \
501             --gpg-key-id=$(gpg_key_ID)                                  \
502             --news=NEWS                                                 \
503             $(addprefix --url-dir=, $(url_dir_list))                    \
504
505
506 ## ---------------- ##
507 ## Updating files.  ##
508 ## ---------------- ##
509
510 ftp-gnu = ftp://ftp.gnu.org/gnu
511 www-gnu = http://www.gnu.org
512
513 # Use mv, if you don't have/want move-if-change.
514 move_if_change ?= move-if-change
515
516
517 # --------------------- #
518 # Updating everything.  #
519 # --------------------- #
520
521 .PHONY: update
522 local_updates ?= wget-update cvs-update po-update
523 update: $(local_updates)
524
525
526 # ------------------- #
527 # Updating PO files.  #
528 # ------------------- #
529
530 po_repo = http://www.iro.umontreal.ca/contrib/po/maint/$(PACKAGE)
531 .PHONY: do-po-update po-update
532 do-po-update:
533         tmppo=/tmp/$(PACKAGE)-$(VERSION)-po &&\
534         rm -rf $$tmppo && \
535         mkdir $$tmppo && \
536         (cd $$tmppo && \
537           $(WGET) $(WGETFLAGS) -r -l1 -nd --no-parent -A '*.po' $(po_repo)) &&\
538         cp $$tmppo/*.po po
539         cd po && $(MAKE) update-po
540         $(MAKE) po-check
541
542 po-update:
543         if test -d "po"; then \
544           $(MAKE) do-po-update; \
545         fi
546
547 # -------------------------- #
548 # Updating GNU build tools.  #
549 # -------------------------- #
550
551 # The following pseudo table associates a local directory and a URL
552 # with each of the files that belongs to some other package and is
553 # regularly updated from the specified URL.
554 wget_files ?= \
555   $(srcdir)/build-aux/config.guess \
556   $(srcdir)/build-aux/config.sub \
557   $(srcdir)/build-aux/texinfo.tex \
558   $(srcdir)/src/ansi2knr.c
559
560 get-targets = $(patsubst %, get-%, $(wget_files))
561
562 config.guess-url_prefix = $(ftp-gnu)/build-aux/
563 config.sub-url_prefix = $(ftp-gnu)/build-aux/
564
565 ansi2knr.c-url_prefix = ftp://ftp.cs.wisc.edu/ghost/
566
567 texinfo.tex-url_prefix = $(ftp-gnu)/texinfo/
568
569 standards.texi-url_prefix = $(www-gnu)/prep/
570 make-stds.texi-url_prefix = $(standards.texi-url_prefix)
571
572 target = $(patsubst get-%, %, $@)
573 url = $($(notdir $(target))-url_prefix)$(notdir $(target))
574
575 .PHONY: $(get-targets)
576 $(get-targets):
577         $(WGET) $(WGETFLAGS) $(url) -O $(target).t \
578           && $(move_if_change) $(target).t $(target)
579
580 cvs_files ?= \
581   $(srcdir)/build-aux/depcomp \
582   $(srcdir)/build-aux/install-sh \
583   $(srcdir)/build-aux/missing \
584   $(srcdir)/build-aux/mkinstalldirs \
585   $(srcdir)/src/ansi2knr.c
586 automake_repo=:pserver:anoncvs:anoncvs@sources.redhat.com:/cvs/automake
587 .PHONY: wget-update
588 wget-update: $(get-targets)
589
590 .PHONY: cvs-update
591 cvs-update:
592         fail=;                                                          \
593         for f in $(cvs_files); do                                       \
594           test -f $$f || { echo "*** skipping $$f" 1>&2; continue; };   \
595           cvs diff $$f > /dev/null                                      \
596             || { echo "*** $$f is locally modified; skipping it" 1>&2;  \
597                  fail=yes; continue; };                                 \
598           file=$$(basename $$f);                                        \
599           echo checking out $$file...;                                  \
600           $(CVS) -d $(automake_repo) co -p automake/lib/$$file> $$f.t   \
601             && $(move_if_change) $$f.t $$f;                             \
602         done;                                                           \
603         test "$$fail" && exit 1
604
605 emit_upload_commands:
606         @echo =====================================
607         @echo =====================================
608         @echo "$(srcdir)/gnupload $(GNUPLOADFLAGS) \\"
609         @echo "    --to $(gnu_rel_host):coreutils \\"
610         @echo "  $(rel-files)"
611         @echo '# send the /tmp/announcement e-mail'
612         @echo =====================================
613         @echo =====================================
614
615 $(xd-delta): $(release_archive_dir)/$(prev-tgz) $(distdir).tar.gz
616         xdelta delta -9 $^ $@ || :
617
618 .PHONY: alpha beta major
619 alpha beta major: news-date-check $(local-check)
620         $(MAKE) cvs-dist
621         $(MAKE) $(xd-delta)
622         $(MAKE) -s announcement RELEASE_TYPE=$@ > /tmp/announce-$(my_distdir)
623         ln $(rel-files) $(release_archive_dir)
624         chmod a-w $(rel-files)
625         $(MAKE) -s emit_upload_commands RELEASE_TYPE=$@
626         echo $(VERSION) > $(prev_version_file)
627         $(CVS) ci -m. $(prev_version_file)