2 # This Makefile fragment is shared between fileutils, sh-utils, textutils,
3 # CPPI, Bison, and Autoconf.
5 ## Copyright (C) 2001-2002 Free Software Foundation, Inc.
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)
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, write to the Free Software
19 ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
22 # Do not save the original name or timestamp in the .tar.gz file.
23 GZIP_ENV = '--no-name --best'
25 # Automake 1.4 does not define AMTAR.
30 prev_version_file ?= .prev-version
32 THIS_VERSION_REGEXP = $(subst .,\.,$(VERSION))
33 PREV_VERSION := $(shell cat $(prev_version_file))
34 PREV_VERSION_REGEXP := $(shell echo $(PREV_VERSION)|sed 's/\./\\./g')
36 tag-package = $(shell echo "$(PACKAGE)" | tr '[:lower:]' '[:upper:]')
37 tag-this-version = $(subst .,_,$(VERSION))
38 tag-prev-version = $(subst .,_,$(PREV_VERSION))
39 this-cvs-tag = $(tag-package)-$(tag-this-version)
40 prev-cvs-tag = $(tag-package)-$(tag-prev-version)
41 my_distdir = $(PACKAGE)-$(VERSION)
43 # Old releases are stored here.
44 # Used for diffs and xdeltas.
45 release_archive_dir ?= ../release
53 # Checks that don't require cvs.
54 # Run `changelog-check' last, as previous test may reveal problems requiring
55 # new ChangeLog entries.
57 po-check copyright-check writable-files m4-check author_mark_check \
58 changelog-check strftime-check header-check
59 .PHONY: $(local-check)
61 # Make sure C source files in src/ don't include xalloc.h directly,
62 # since they all already include it via sys2.h.
63 # It's not a big deal -- just aesthetics.
65 if test -f $(srcdir)/src/sys2.h; then \
66 if grep 'xalloc\.h' $(srcdir)/src/*.c; then \
71 # Ensure that date's --help output stays in sync with the info
72 # documentation for GNU strftime. The only exception is %N,
73 # which date accepts but GNU strftime does not.
74 extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/'
76 if test -f $(srcdir)/src/date.c; then \
77 grep '^ %. ' $(srcdir)/src/date.c | sort \
78 | $(extract_char) > $@-src; \
80 info libc date calendar format | grep '^ `%.'\' \
81 | $(extract_char); } | sort > $@-info; \
82 diff -u $@-src $@-info || exit 1; \
83 rm -f $@-src $@-info; \
87 if head ChangeLog | grep 'Version $(VERSION)' >/dev/null; then \
90 echo "$(VERSION) not in ChangeLog" 1>&2; \
95 @grep 'AC_DEFUN([^[]' m4/*.m4 \
96 && { echo 'Makefile.maint: quote the first arg to AC_DEFUN' 1>&2; \
99 # Verify that all source files using _() are listed in po/POTFILES.in.
101 if test -f po/POTFILES.in; then \
102 grep -E -v '^(#|$$)' po/POTFILES.in | sort > $@-1; \
103 grep -E -l '\b_\(' lib/*.[ch] src/*.[ch] | sort > $@-2; \
104 diff -u $@-1 $@-2 || exit 1; \
108 # In a definition of #define AUTHORS "... and ..." where the RHS contains
109 # the English word `and', the string must be marked with `N_ (...)' so that
110 # gettext recognizes it as a string requiring translation.
112 @grep '^# *define AUTHORS "[^"]* and ' src/*.c |grep -v ' N_ (' && \
113 { echo 'Makefile.maint: enclose the above strings in N_ (...)' 1>&2; \
116 # Check that `make alpha' will not fail at the end of the process.
118 if test -d $(release_archive_dir); then :; else \
119 mkdir $(release_archive_dir); \
121 for file in $(distdir).tar.gz $(xd-delta) \
122 $(release_archive_dir)/$(distdir).tar.gz \
123 $(release_archive_dir)/$(xd-delta); do \
124 test -e $$file || continue; \
126 || { echo ERROR: $$file is not writable; fail=1; }; \
128 test "$$fail" && exit 1 || :
130 v_etc_file = lib/version-etc.c
131 # Make sure that the copyright date in $(v_etc_file) is up to date.
133 @if test -f $(v_etc_file); then \
134 grep '"Copyright (C) $(shell date +%Y) Free' $(v_etc_file) \
136 || { echo 'out of date copyright in $(v_etc_file); update it' 1>&2; \
141 # Sanity checks with the CVS repository.
143 echo $(this-cvs-tag); \
144 if $(CVS) -n log -h README | grep -e $(this-cvs-tag): >/dev/null; then \
145 echo "$(this-cvs-tag) as already been used; not tagging" 1>&2; \
150 if $(CVS) diff >cvs-diffs; then \
153 echo "Some files are locally modified:" 1>&2; \
158 cvs-check: cvs-diff-check cvs-tag-check
160 maintainer-distcheck: changelog-check
165 # Tag before making distribution. Also, don't make a distribution if
166 # checks fail. Also, make sure the NEWS file is up-to-date.
167 # FIXME: use dist-hook/my-dist like distcheck-hook/my-distcheck.
168 cvs-dist: $(local-check) cvs-check maintainer-distcheck
170 $(CVS) tag -c $(this-cvs-tag)
173 # Use this to make sure we don't run these programs when building
174 # from a virgin tgz file, below.
175 null_AM_MAKEFLAGS = \
182 # Detect format-string/arg-list mismatches that would normally be obscured
183 # by the use of _(). The --disable-nls effectively defines away that macro,
184 # and building with CFLAGS='-Wformat -Werror' causes any format warning to be
185 # treated as a failure.
187 my-distcheck: $(local-check)
190 GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
192 && ./configure --disable-nls \
193 && $(MAKE) CFLAGS='-Wformat -Werror' \
194 AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)' \
198 cd $(t) && mv $(distdir) $(distdir).old \
199 && $(AMTAR) -zxf ../$(distdir).tar.gz
200 diff -ur $(t)/$(distdir).old $(t)/$(distdir)
202 @echo "========================"; \
203 echo "$(distdir).tar.gz is ready for distribution"; \
204 echo "========================"
206 tgz-md5 = $(shell md5sum < $(my_distdir).tar.gz|sed 's/ -//')
207 tgz-sha1 = $(shell sha1sum < $(my_distdir).tar.gz|sed 's/ -//')
208 bz2-md5 = $(shell md5sum < $(my_distdir).tar.bz2|sed 's/ -//')
209 bz2-sha1 = $(shell sha1sum < $(my_distdir).tar.bz2|sed 's/ -//')
210 xdelta-md5 = $(shell md5sum < $(xd-delta)|sed 's/ -//')
211 xdelta-sha1 = $(shell sha1sum < $(xd-delta)|sed 's/ -//')
212 tgz-size = $(shell du --human $(my_distdir).tar.gz|sed 's/\([MkK]\).*/ \1B/')
213 bz2-size = $(shell du --human $(my_distdir).tar.bz2|sed 's/\([MkK]\).*/ \1B/')
214 xd-size = $(shell du --human $(xd-delta)|sed 's/\([MkK]\).*/ \1B/')
217 tarz=/tmp/rel-check-tarz-$$$$; \
218 md5_tmp=/tmp/rel-check-md5-$$$$; \
220 trap 'status=$$?; rm -f $$tarz $$md5_tmp; exit $$status' 0 1 2 3 15; \
221 wget -q --output-document=$$tarz $(url); \
222 echo "$(md5) -" > $$md5_tmp; \
223 md5sum -c $$md5_tmp < $$tarz
225 prev-tgz = $(PACKAGE)-$(PREV_VERSION).tar.gz
226 xd-delta = $(PACKAGE)-$(PREV_VERSION)-$(VERSION).xdelta
228 news-r1 = /^[^ ].*$(THIS_VERSION_REGEXP)[]:]/
229 news-r2 = /^[^ ].*$(PREV_VERSION_REGEXP)[]:]/
231 rel-files = $(xd-delta) $(distdir).tar.bz2 $(distdir).tar.gz
232 announcement: NEWS ChangeLog $(rel-files)
234 echo Subject: $(my_distdir) released; \
236 echo FIXME: put comments here; \
238 for url in $(url_dir_list); do \
239 echo " $$url/$(my_distdir).tar.gz ($(tgz-size))"; \
240 echo " $$url/$(my_distdir).tar.bz2 ($(bz2-size))"; \
243 echo And here are xdelta-style diffs; \
245 for url in $(url_dir_list); do \
246 echo " $$url/$(xd-delta) ($(xd-size))"; \
249 echo "Here are the MD5 and SHA1 signatures:"; \
251 echo "$(tgz-md5) $(my_distdir).tar.gz"; \
252 echo "$(bz2-md5) $(my_distdir).tar.bz2"; \
253 echo "$(xdelta-md5) $(xd-delta)"; \
254 echo "$(tgz-sha1) $(my_distdir).tar.gz"; \
255 echo "$(bz2-sha1) $(my_distdir).tar.bz2"; \
256 echo "$(xdelta-sha1) $(xd-delta)"; \
259 sed -n "$(news-r1),$(news-r2)p" NEWS \
262 echo ChangeLog entries:; \
263 find . -name ChangeLog -maxdepth 2 \
264 | xargs $(CVS) diff -up -r$(prev-cvs-tag) -rHEAD \
266 | perl -ne 'm!^\+\+ (\./)?! or print,next;' \
267 -e 'print "\n"."*"x70 ."\n"; s///; print; print "*"x70 ."\n"'; \
271 ftp-gnu = ftp://ftp.gnu.org/gnu
273 # Use mv, if you don't have/want move-if-change.
274 move_if_change ?= move-if-change
276 # The following pseudo table associates a local directory and a URL
277 # with each of the files that belongs to some other package and is
278 # regularly updated from the specified URL.
279 wget_files ?= $(srcdir)/config/config.guess \
280 $(srcdir)/config/config.sub \
281 $(srcdir)/src/ansi2knr.c \
282 $(srcdir)/config/texinfo.tex
283 get-targets = $(patsubst %, get-%, $(wget_files))
285 config.guess-url_prefix = $(ftp-gnu)/config/
286 config.sub-url_prefix = $(ftp-gnu)/config/
288 ansi2knr.c-url_prefix = ftp://ftp.cs.wisc.edu/ghost/
290 texinfo.tex-url_prefix = $(ftp-gnu)/texinfo/
292 standards.texi-url_prefix = $(ftp-gnu)/GNUinfo/
293 make-stds.texi-url_prefix = $(ftp-gnu)/GNUinfo/
295 target = $(patsubst get-%, %, $@)
296 url = $($(notdir $(target))-url_prefix)$(notdir $(target))
298 .PHONY: $(get-targets)
300 $(WGET) $(url) -O $(target).t \
301 && $(move_if_change) $(target).t $(target)
303 automake_repo=:pserver:anoncvs@anoncvs.cygnus.com:/cvs/automake
305 wget-update: $(get-targets)
307 for f in depcomp missing mkinstalldirs; do \
308 test -f $$f || { echo "*** skipping $$f" 1>&2; continue; }; \
309 echo checking out $$f...; \
310 $(CVS) -d $(automake_repo) co -p automake/lib/$$f > $$f.t \
311 && $(move_if_change) $$f.t $$f; \
314 define emit-upload-commands
315 echo =====================================
316 echo =====================================
317 echo upload $(PACKAGE) $(PREV_VERSION) $(VERSION)
318 echo '# send the /tmp/announcement e-mail'
319 echo =====================================
320 echo =====================================
323 $(xd-delta): $(release_archive_dir)/$(prev-tgz) $(distdir).tar.gz
324 xdelta delta -9 $^ $@ || :
326 alpha: $(local-check)
329 $(MAKE) -s announcement > /tmp/announce-$(my_distdir)
330 ln $(rel-files) $(release_archive_dir)
331 chmod a-w $(rel-files)
332 echo $(VERSION) > $(prev_version_file)
333 $(CVS) ci -m. $(prev_version_file)
334 @$(emit-upload-commands)