2 # This Makefile fragment is shared between fileutils, sh-utils, textutils,
3 # CPPI, Bison, and Autoconf.
5 ## Copyright (C) 2001-2003 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'
27 prev_version_file ?= .prev-version
29 PREV_VERSION := $(shell cat $(prev_version_file))
31 tag-package = $(shell echo "$(PACKAGE)" | tr '[:lower:]' '[:upper:]')
32 tag-this-version = $(subst .,_,$(VERSION))
33 this-cvs-tag = $(tag-package)-$(tag-this-version)
34 my_distdir = $(PACKAGE)-$(VERSION)
36 # Old releases are stored here.
37 # Used for diffs and xdeltas.
38 release_archive_dir ?= ../release
46 # Checks that don't require cvs.
47 # Run `changelog-check' last, as previous test may reveal problems requiring
48 # new ChangeLog entries.
50 po-check copyright-check writable-files m4-check author_mark_check \
51 changelog-check strftime-check header-check makefile_path_separator_check
52 .PHONY: $(local-check)
54 # Make sure C source files in src/ don't include xalloc.h directly,
55 # since they all already include it via sys2.h.
56 # It's not a big deal -- just aesthetics.
58 if test -f $(srcdir)/src/sys2.h; then \
59 if grep 'xalloc\.h' $(srcdir)/src/*.c; then \
64 # Ensure that date's --help output stays in sync with the info
65 # documentation for GNU strftime. The only exception is %N,
66 # which date accepts but GNU strftime does not.
67 extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/'
69 if test -f $(srcdir)/src/date.c; then \
70 grep '^ %. ' $(srcdir)/src/date.c | sort \
71 | $(extract_char) > $@-src; \
73 info libc date calendar format | grep '^ `%.'\' \
74 | $(extract_char); } | sort > $@-info; \
75 diff -u $@-src $@-info || exit 1; \
76 rm -f $@-src $@-info; \
80 if head ChangeLog | grep 'Version $(VERSION)' >/dev/null; then \
83 echo "$(VERSION) not in ChangeLog" 1>&2; \
88 @grep 'AC_DEFUN([^[]' m4/*.m4 \
89 && { echo 'Makefile.maint: quote the first arg to AC_DEFUN' 1>&2; \
92 # Verify that all source files using _() are listed in po/POTFILES.in.
94 if test -f po/POTFILES.in; then \
95 grep -E -v '^(#|$$)' po/POTFILES.in | sort > $@-1; \
97 for file in lib/*.[chly] src/*.[chly]; do \
100 base=`expr " $$file" : ' \(.*\)\..'`; \
101 { test -f $$base.l || test -f $$base.y; } && continue;; \
103 files="$$files $$file"; \
105 grep -E -l '\bN?_\([^)"]*("|$$)' $$files | sort > $@-2; \
106 diff -u $@-1 $@-2 || exit 1; \
110 # In a definition of #define AUTHORS "... and ..." where the RHS contains
111 # the English word `and', the string must be marked with `N_ (...)' so that
112 # gettext recognizes it as a string requiring translation.
114 @grep '^# *define AUTHORS "[^"]* and ' src/*.c |grep -v ' N_ (' && \
115 { echo 'Makefile.maint: enclose the above strings in N_ (...)' 1>&2; \
118 # Sometimes it is useful to change the PATH environment variable
119 # in Makefiles. When doing so, it's better not to use the Unix-centric
120 # path separator of `:', but rather the automake-provided `@PATH_SEPARATOR@'.
121 # It'd be better to use `find -print0 ...|xargs -0 ...', but less portable,
122 # and there probably aren't many projects with so many Makefile.am files
123 # that we'd have to worry about limits on command line length.
124 msg = 'Makefile.maint: Do not use `:'\'' above; use @PATH_SEPARATOR@ instead'
125 makefile_path_separator_check:
126 @grep 'PATH=.*:' `find $(srcdir) -name Makefile.am` \
127 && { echo $(msg) 1>&2; exit 1; } || :
129 # Check that `make alpha' will not fail at the end of the process.
131 if test -d $(release_archive_dir); then :; else \
132 mkdir $(release_archive_dir); \
134 for file in $(distdir).tar.gz $(xd-delta) \
135 $(release_archive_dir)/$(distdir).tar.gz \
136 $(release_archive_dir)/$(xd-delta); do \
137 test -e $$file || continue; \
139 || { echo ERROR: $$file is not writable; fail=1; }; \
141 test "$$fail" && exit 1 || :
143 v_etc_file = lib/version-etc.c
144 # Make sure that the copyright date in $(v_etc_file) is up to date.
146 @if test -f $(v_etc_file); then \
147 grep '"Copyright (C) $(shell date +%Y) Free' $(v_etc_file) \
149 || { echo 'out of date copyright in $(v_etc_file); update it' 1>&2; \
154 # Sanity checks with the CVS repository.
156 echo $(this-cvs-tag); \
157 if $(CVS) -n log -h README | grep -e $(this-cvs-tag): >/dev/null; then \
158 echo "$(this-cvs-tag) as already been used; not tagging" 1>&2; \
163 if $(CVS) diff >cvs-diffs; then \
166 echo "Some files are locally modified:" 1>&2; \
171 cvs-check: cvs-diff-check cvs-tag-check
173 maintainer-distcheck: changelog-check
178 # Tag before making distribution. Also, don't make a distribution if
179 # checks fail. Also, make sure the NEWS file is up-to-date.
180 # FIXME: use dist-hook/my-dist like distcheck-hook/my-distcheck.
181 cvs-dist: $(local-check) cvs-check maintainer-distcheck
183 $(CVS) tag -c $(this-cvs-tag)
186 # Use this to make sure we don't run these programs when building
187 # from a virgin tgz file, below.
188 null_AM_MAKEFLAGS = \
195 # Detect format-string/arg-list mismatches that would normally be obscured
196 # by the use of _(). The --disable-nls effectively defines away that macro,
197 # and building with CFLAGS='-Wformat -Werror' causes any format warning to be
198 # treated as a failure.
200 my-distcheck: $(local-check)
203 GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
205 && ./configure --disable-nls \
206 && $(MAKE) CFLAGS='-Wformat -Werror' \
207 AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)' \
211 cd $(t) && mv $(distdir) $(distdir).old \
212 && $(AMTAR) -zxf ../$(distdir).tar.gz
213 diff -ur $(t)/$(distdir).old $(t)/$(distdir)
215 @echo "========================"; \
216 echo "$(distdir).tar.gz is ready for distribution"; \
217 echo "========================"
219 tgz-md5 = $(shell md5sum < $(my_distdir).tar.gz|sed 's/ -//')
220 tgz-sha1 = $(shell sha1sum < $(my_distdir).tar.gz|sed 's/ -//')
221 bz2-md5 = $(shell md5sum < $(my_distdir).tar.bz2|sed 's/ -//')
222 bz2-sha1 = $(shell sha1sum < $(my_distdir).tar.bz2|sed 's/ -//')
223 xdelta-md5 = $(shell md5sum < $(xd-delta)|sed 's/ -//')
224 xdelta-sha1 = $(shell sha1sum < $(xd-delta)|sed 's/ -//')
225 tgz-size = $(shell du --human $(my_distdir).tar.gz|sed 's/\([MkK]\).*/ \1B/')
226 bz2-size = $(shell du --human $(my_distdir).tar.bz2|sed 's/\([MkK]\).*/ \1B/')
227 xd-size = $(shell du --human $(xd-delta)|sed 's/\([MkK]\).*/ \1B/')
230 tarz=/tmp/rel-check-tarz-$$$$; \
231 md5_tmp=/tmp/rel-check-md5-$$$$; \
233 trap 'status=$$?; rm -f $$tarz $$md5_tmp; exit $$status' 0 1 2 3 15; \
234 wget -q --output-document=$$tarz $(url); \
235 echo "$(md5) -" > $$md5_tmp; \
236 md5sum -c $$md5_tmp < $$tarz
238 prev-tgz = $(PACKAGE)-$(PREV_VERSION).tar.gz
239 xd-delta = $(PACKAGE)-$(PREV_VERSION)-$(VERSION).xdelta
241 signatures ?= $(distdir).tar.bz2.sig $(distdir).tar.gz.sig
245 rel-files = $(xd-delta) $(distdir).tar.bz2 $(distdir).tar.gz $(signatures)
246 announcement: NEWS ChangeLog $(rel-files) $(signatures)
248 --release-type=$(RELEASE_TYPE) \
249 --package=$(PACKAGE) \
250 --prev=$(PREV_VERSION) \
252 --release-archive-directory=$(release_archive_dir) \
254 $(addprefix --url-dir=, $(url_dir_list)) \
257 ## ---------------- ##
258 ## Updating files. ##
259 ## ---------------- ##
262 ftp-gnu = ftp://ftp.gnu.org/gnu
263 www-gnu = http://www.gnu.org
265 # Use mv, if you don't have/want move-if-change.
266 move_if_change ?= move-if-change
269 # --------------------- #
270 # Updating everything. #
271 # --------------------- #
274 local_updates ?= wget-update cvs-update po-update
275 update: $(local_updates)
278 # ------------------- #
279 # Updating PO files. #
280 # ------------------- #
282 po_repo = http://www.iro.umontreal.ca/contrib/po/maint/$(PACKAGE)
283 .PHONY: do-po-update po-update
285 tmppo=/tmp/$(PACKAGE)-$(VERSION)-po &&\
288 (cd $$tmppo && $(WGET) -r -l1 -nd --no-parent -A '*.po' $(po_repo)) &&\
290 cd po && $(MAKE) update-po
294 if test -d "po"; then \
295 $(MAKE) do-po-update; \
298 # -------------------------- #
299 # Updating GNU build tools. #
300 # -------------------------- #
302 # The following pseudo table associates a local directory and a URL
303 # with each of the files that belongs to some other package and is
304 # regularly updated from the specified URL.
305 wget_files ?= $(srcdir)/config/config.guess \
306 $(srcdir)/config/config.sub \
307 $(srcdir)/src/ansi2knr.c \
308 $(srcdir)/config/texinfo.tex
309 get-targets = $(patsubst %, get-%, $(wget_files))
311 config.guess-url_prefix = $(ftp-gnu)/config/
312 config.sub-url_prefix = $(ftp-gnu)/config/
314 ansi2knr.c-url_prefix = ftp://ftp.cs.wisc.edu/ghost/
316 texinfo.tex-url_prefix = $(ftp-gnu)/texinfo/
318 standards.texi-url_prefix = $(www-gnu)/prep/
319 make-stds.texi-url_prefix = $(standards.texi-url_prefix)
321 target = $(patsubst get-%, %, $@)
322 url = $($(notdir $(target))-url_prefix)$(notdir $(target))
324 .PHONY: $(get-targets)
326 $(WGET) $(url) -O $(target).t \
327 && $(move_if_change) $(target).t $(target)
329 cvs_files ?= $(srcdir)/config/depcomp $(srcdir)/config/missing \
330 $(srcdir)/config/mkinstalldirs \
331 $(srcdir)/config/install-sh $(srcdir)/src/ansi2knr.c
332 automake_repo=:pserver:anoncvs:anoncvs@sources.redhat.com:/cvs/automake
334 wget-update: $(get-targets)
339 for f in $(cvs_files); do \
340 test -f $$f || { echo "*** skipping $$f" 1>&2; continue; }; \
341 cvs diff $$f > /dev/null \
342 || { echo "*** $$f is locally modified; skipping it" 1>&2; \
343 fail=yes; continue; }; \
344 file=$$(basename $$f); \
345 echo checking out $$file...; \
346 $(CVS) -d $(automake_repo) co -p automake/lib/$$file> $$f.t \
347 && $(move_if_change) $$f.t $$f; \
349 test "$$fail" && exit 1
351 define emit-upload-commands
352 echo =====================================
353 echo =====================================
354 echo upload $(PACKAGE) $(PREV_VERSION) $(VERSION)
355 echo '# send the /tmp/announcement e-mail'
356 echo =====================================
357 echo =====================================
360 $(xd-delta): $(release_archive_dir)/$(prev-tgz) $(distdir).tar.gz
361 xdelta delta -9 $^ $@ || :
363 .PHONY: alpha beta major
364 alpha beta major: $(local-check)
367 $(MAKE) -s announcement RELEASE_TYPE=$@ > /tmp/announce-$(my_distdir)
368 ln $(rel-files) $(release_archive_dir)
369 chmod a-w $(rel-files)
370 echo $(VERSION) > $(prev_version_file)
371 $(CVS) ci -m. $(prev_version_file)
372 @$(emit-upload-commands)