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 THIS_VERSION_REGEXP = $(subst .,\.,$(VERSION))
30 PREV_VERSION := $(shell cat $(prev_version_file))
31 PREV_VERSION_REGEXP := $(shell echo $(PREV_VERSION)|sed 's/\./\\./g')
33 tag-package = $(shell echo "$(PACKAGE)" | tr '[:lower:]' '[:upper:]')
34 tag-this-version = $(subst .,_,$(VERSION))
35 tag-prev-version = $(subst .,_,$(PREV_VERSION))
36 this-cvs-tag = $(tag-package)-$(tag-this-version)
37 prev-cvs-tag = $(tag-package)-$(tag-prev-version)
38 my_distdir = $(PACKAGE)-$(VERSION)
40 # Old releases are stored here.
41 # Used for diffs and xdeltas.
42 release_archive_dir ?= ../release
50 # Checks that don't require cvs.
51 # Run `changelog-check' last, as previous test may reveal problems requiring
52 # new ChangeLog entries.
54 po-check copyright-check writable-files m4-check author_mark_check \
55 changelog-check strftime-check header-check makefile_path_separator_check
56 .PHONY: $(local-check)
58 # Make sure C source files in src/ don't include xalloc.h directly,
59 # since they all already include it via sys2.h.
60 # It's not a big deal -- just aesthetics.
62 if test -f $(srcdir)/src/sys2.h; then \
63 if grep 'xalloc\.h' $(srcdir)/src/*.c; then \
68 # Ensure that date's --help output stays in sync with the info
69 # documentation for GNU strftime. The only exception is %N,
70 # which date accepts but GNU strftime does not.
71 extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/'
73 if test -f $(srcdir)/src/date.c; then \
74 grep '^ %. ' $(srcdir)/src/date.c | sort \
75 | $(extract_char) > $@-src; \
77 info libc date calendar format | grep '^ `%.'\' \
78 | $(extract_char); } | sort > $@-info; \
79 diff -u $@-src $@-info || exit 1; \
80 rm -f $@-src $@-info; \
84 if head ChangeLog | grep 'Version $(VERSION)' >/dev/null; then \
87 echo "$(VERSION) not in ChangeLog" 1>&2; \
92 @grep 'AC_DEFUN([^[]' m4/*.m4 \
93 && { echo 'Makefile.maint: quote the first arg to AC_DEFUN' 1>&2; \
96 # Verify that all source files using _() are listed in po/POTFILES.in.
98 if test -f po/POTFILES.in; then \
99 grep -E -v '^(#|$$)' po/POTFILES.in | sort > $@-1; \
101 for file in lib/*.[chly] src/*.[chly]; do \
104 base=`expr " $$file" : ' \(.*\)\..'`; \
105 { test -f $$base.l || test -f $$base.y; } && continue;; \
107 files="$$files $$file"; \
109 grep -E -l '\bN?_\([^)"]*("|$$)' $$files | sort > $@-2; \
110 diff -u $@-1 $@-2 || exit 1; \
114 # In a definition of #define AUTHORS "... and ..." where the RHS contains
115 # the English word `and', the string must be marked with `N_ (...)' so that
116 # gettext recognizes it as a string requiring translation.
118 @grep '^# *define AUTHORS "[^"]* and ' src/*.c |grep -v ' N_ (' && \
119 { echo 'Makefile.maint: enclose the above strings in N_ (...)' 1>&2; \
122 # Sometimes it is useful to change the PATH environment variable
123 # in Makefiles. When doing so, it's better not to use the Unix-centric
124 # path separator of `:', but rather the automake-provided `@PATH_SEPARATOR@'.
125 # It'd be better to use `find -print0 ...|xargs -0 ...', but less portable,
126 # and there probably aren't many projects with so many Makefile.am files
127 # that we'd have to worry about limits on command line length.
128 msg = 'Makefile.maint: Do not use `:'\'' above; use @PATH_SEPARATOR@ instead'
129 makefile_path_separator_check:
130 @grep 'PATH=.*:' `find $(srcdir) -name Makefile.am` \
131 && { echo $(msg) 1>&2; exit 1; } || :
134 if test -d $(release_archive_dir); then :; else \
135 mkdir $(release_archive_dir); \
137 for file in $(distdir).tar.gz $(xd-delta) \
138 $(release_archive_dir)/$(distdir).tar.gz \
139 $(release_archive_dir)/$(xd-delta); do \
140 test -e $$file || continue; \
142 || { echo ERROR: $$file is not writable; fail=1; }; \
144 test "$$fail" && exit 1 || :
146 v_etc_file = lib/version-etc.c
147 # Make sure that the copyright date in $(v_etc_file) is up to date.
149 @if test -f $(v_etc_file); then \
150 grep '"Copyright (C) $(shell date +%Y) Free' $(v_etc_file) \
152 || { echo 'out of date copyright in $(v_etc_file); update it' 1>&2; \
157 # Sanity checks with the CVS repository.
159 echo $(this-cvs-tag); \
160 if $(CVS) -n log -h README | grep -e $(this-cvs-tag): >/dev/null; then \
161 echo "$(this-cvs-tag) as already been used; not tagging" 1>&2; \
166 if $(CVS) diff >cvs-diffs; then \
169 echo "Some files are locally modified:" 1>&2; \
174 cvs-check: cvs-diff-check cvs-tag-check
176 maintainer-distcheck: changelog-check
181 # Tag before making distribution. Also, don't make a distribution if
182 # checks fail. Also, make sure the NEWS file is up-to-date.
183 # FIXME: use dist-hook/my-dist like distcheck-hook/my-distcheck.
184 cvs-dist: $(local-check) cvs-check maintainer-distcheck
186 $(CVS) tag -c $(this-cvs-tag)
189 # Use this to make sure we don't run these programs when building
190 # from a virgin tgz file, below.
191 null_AM_MAKEFLAGS = \
198 # Detect format-string/arg-list mismatches that would normally be obscured
199 # by the use of _(). The --disable-nls effectively defines away that macro,
200 # and building with CFLAGS='-Wformat -Werror' causes any format warning to be
201 # treated as a failure.
203 my-distcheck: $(local-check)
206 GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
208 && ./configure --disable-nls \
209 && $(MAKE) CFLAGS='-Wformat -Werror' \
210 AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)' \
214 cd $(t) && mv $(distdir) $(distdir).old \
215 && $(AMTAR) -zxf ../$(distdir).tar.gz
216 diff -ur $(t)/$(distdir).old $(t)/$(distdir)
218 @echo "========================"; \
219 echo "$(distdir).tar.gz is ready for distribution"; \
220 echo "========================"
222 tgz-md5 = $(shell md5sum < $(my_distdir).tar.gz|sed 's/ -//')
223 tgz-sha1 = $(shell sha1sum < $(my_distdir).tar.gz|sed 's/ -//')
224 bz2-md5 = $(shell md5sum < $(my_distdir).tar.bz2|sed 's/ -//')
225 bz2-sha1 = $(shell sha1sum < $(my_distdir).tar.bz2|sed 's/ -//')
226 xdelta-md5 = $(shell md5sum < $(xd-delta)|sed 's/ -//')
227 xdelta-sha1 = $(shell sha1sum < $(xd-delta)|sed 's/ -//')
228 tgz-size = $(shell du --human $(my_distdir).tar.gz|sed 's/\([MkK]\).*/ \1B/')
229 bz2-size = $(shell du --human $(my_distdir).tar.bz2|sed 's/\([MkK]\).*/ \1B/')
230 xd-size = $(shell du --human $(xd-delta)|sed 's/\([MkK]\).*/ \1B/')
233 tarz=/tmp/rel-check-tarz-$$$$; \
234 md5_tmp=/tmp/rel-check-md5-$$$$; \
236 trap 'status=$$?; rm -f $$tarz $$md5_tmp; exit $$status' 0 1 2 3 15; \
237 wget -q --output-document=$$tarz $(url); \
238 echo "$(md5) -" > $$md5_tmp; \
239 md5sum -c $$md5_tmp < $$tarz
241 prev-tgz = $(PACKAGE)-$(PREV_VERSION).tar.gz
242 xd-delta = $(PACKAGE)-$(PREV_VERSION)-$(VERSION).xdelta
244 news-r1 = /^[^ ].*$(THIS_VERSION_REGEXP)[]:]/
245 news-r2 = /^[^ ].*$(PREV_VERSION_REGEXP)[]:]/
247 signatures ?= $(distdir).tar.bz2.sig $(distdir).tar.gz.sig
251 rel-files = $(xd-delta) $(distdir).tar.bz2 $(distdir).tar.gz
252 announcement: NEWS ChangeLog $(rel-files) $(signatures)
255 --package=$(PACKAGE) \
256 --prev=$(PREV_VERSION) \
258 --rel=$(release_archive_dir) \
259 $(addprefix --url-dir=, $(url_dir_list)); \
262 sed -n "$(news-r1),$(news-r2)p" NEWS \
265 echo ChangeLog entries:; \
266 find . -name ChangeLog -maxdepth 2 \
267 | xargs $(CVS) diff -up -r$(prev-cvs-tag) -rHEAD \
269 | perl -ne 'm!^\+\+ (\./)?! or print,next;' \
270 -e 'print "\n"."*"x70 ."\n"; s///; print; print "*"x70 ."\n"'; \
274 ## ---------------- ##
275 ## Updating files. ##
276 ## ---------------- ##
279 ftp-gnu = ftp://ftp.gnu.org/gnu
281 # Use mv, if you don't have/want move-if-change.
282 move_if_change ?= move-if-change
285 # --------------------- #
286 # Updating everything. #
287 # --------------------- #
290 local_updates ?= wget-update cvs-update po-update
291 update: $(local_updates)
294 # ------------------- #
295 # Updating PO files. #
296 # ------------------- #
298 po_repo = http://www.iro.umontreal.ca/contrib/po/maint/$(PACKAGE)
299 .PHONY: do-po-update po-update
301 tmppo=/tmp/$(PACKAGE)-$(VERSION)-po &&\
304 (cd $$tmppo && $(WGET) -r -l1 -nd --no-parent -A '*.po' $(po_repo)) &&\
306 cd po && $(MAKE) update-po
310 if test -d "po"; then \
311 $(MAKE) do-po-update; \
314 # -------------------------- #
315 # Updating GNU build tools. #
316 # -------------------------- #
318 # The following pseudo table associates a local directory and a URL
319 # with each of the files that belongs to some other package and is
320 # regularly updated from the specified URL.
321 wget_files ?= $(srcdir)/config/config.guess \
322 $(srcdir)/config/config.sub \
323 $(srcdir)/src/ansi2knr.c \
324 $(srcdir)/config/texinfo.tex
325 get-targets = $(patsubst %, get-%, $(wget_files))
327 config.guess-url_prefix = $(ftp-gnu)/config/
328 config.sub-url_prefix = $(ftp-gnu)/config/
330 ansi2knr.c-url_prefix = ftp://ftp.cs.wisc.edu/ghost/
332 texinfo.tex-url_prefix = $(ftp-gnu)/texinfo/
334 standards.texi-url_prefix = $(ftp-gnu)/GNUinfo/
335 make-stds.texi-url_prefix = $(ftp-gnu)/GNUinfo/
337 target = $(patsubst get-%, %, $@)
338 url = $($(notdir $(target))-url_prefix)$(notdir $(target))
340 .PHONY: $(get-targets)
342 $(WGET) $(url) -O $(target).t \
343 && $(move_if_change) $(target).t $(target)
345 cvs_files ?= $(srcdir)/config/depcomp $(srcdir)/config/missing \
346 $(srcdir)/config/mkinstalldirs \
347 $(srcdir)/config/install-sh $(srcdir)/src/ansi2knr.c
348 automake_repo=:pserver:anoncvs:anoncvs@sources.redhat.com:/cvs/automake
350 wget-update: $(get-targets)
355 for f in $(cvs_files); do \
356 test -f $$f || { echo "*** skipping $$f" 1>&2; continue; }; \
357 cvs diff $$f > /dev/null \
358 || { echo "*** $$f is locally modified; skipping it" 1>&2; \
359 fail=yes; continue; }; \
360 file=$$(basename $$f); \
361 echo checking out $$file...; \
362 $(CVS) -d $(automake_repo) co -p automake/lib/$$file> $$f.t \
363 && $(move_if_change) $$f.t $$f; \
365 test "$$fail" && exit 1
367 define emit-upload-commands
368 echo =====================================
369 echo =====================================
370 echo upload $(PACKAGE) $(PREV_VERSION) $(VERSION)
371 echo '# send the /tmp/announcement e-mail'
372 echo =====================================
373 echo =====================================
376 $(xd-delta): $(release_archive_dir)/$(prev-tgz) $(distdir).tar.gz
377 xdelta delta -9 $^ $@ || :
379 .PHONY: alpha release
381 release: $(local-check)
384 $(MAKE) -s announcement > /tmp/announce-$(my_distdir)
385 ln $(rel-files) $(release_archive_dir)
386 chmod a-w $(rel-files)
387 echo $(VERSION) > $(prev_version_file)
388 $(CVS) ci -m. $(prev_version_file)
389 @$(emit-upload-commands)