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 ifeq ($(origin prev_version_file), undefined)
28 prev_version_file = .prev-version
31 PREV_VERSION := $(shell cat $(prev_version_file))
33 tag-package = $(shell echo "$(PACKAGE)" | tr '[:lower:]' '[:upper:]')
34 tag-this-version = $(subst .,_,$(VERSION))
35 this-cvs-tag = $(tag-package)-$(tag-this-version)
36 my_distdir = $(PACKAGE)-$(VERSION)
38 # Old releases are stored here.
39 # Used for diffs and xdeltas.
40 release_archive_dir ?= ../release
48 # Checks that don't require cvs.
49 # Run `changelog-check' last, as previous test may reveal problems requiring
50 # new ChangeLog entries.
52 po-check copyright-check writable-files m4-check author_mark_check \
53 changelog-check strftime-check syntax-check makefile_path_separator_check \
55 .PHONY: $(local-check)
57 # Make sure C source files in src/ don't include xalloc.h directly,
58 # since they all already include it via sys2.h.
59 # It's not a big deal -- just aesthetics.
61 if test -f $(srcdir)/src/sys2.h; then \
62 if grep 'xalloc\.h' $(srcdir)/src/*.c; then \
66 @grep -E '[ ] ' --exclude=$(srcdir)/lib/regex.c \
67 $(srcdir)/{lib,src}/*.[chy] \
68 $(find -name Makefile.am) && \
69 { echo 'Makefile.maint: found SPACE-TAB sequence; remove the SPACE' \
72 @grep -E --exclude=$(srcdir)/lib/regex.c \
73 '\*\) *x(m|c|re)alloc\>' $(srcdir)/{lib,src}/*.[chy] && \
74 { echo 'Makefile.maint: don'\''t cast x*alloc return value' 1>&2; \
77 # grep -E '^# *include <(string|stdlib)\.h>' \
78 # $(srcdir)/{lib,src}/*.[chy] && \
79 # { echo 'Makefile.maint: FIXME' 1>&2; \
81 # FIXME: don't allow `#include .strings\.h' anywhere
83 # Ensure that date's --help output stays in sync with the info
84 # documentation for GNU strftime. The only exception is %N,
85 # which date accepts but GNU strftime does not.
86 extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/'
88 if test -f $(srcdir)/src/date.c; then \
89 grep '^ %. ' $(srcdir)/src/date.c | sort \
90 | $(extract_char) > $@-src; \
92 info libc date calendar format | grep '^ `%.'\' \
93 | $(extract_char); } | sort > $@-info; \
94 diff -u $@-src $@-info || exit 1; \
95 rm -f $@-src $@-info; \
98 # Ensure that we use only the standard $(VAR) notation,
99 # not @...@ in Makefile.am, now that we can rely on automake
100 # to emit a definition for each substituted variable.
102 grep -E '@[A-Z_]+@' `find . -name Makefile.am` \
103 && { echo 'Makefile.maint: use $(...), not @...@' 1>&2; exit 1; } || :
106 if head ChangeLog | grep 'Version $(VERSION)' >/dev/null; then \
109 echo "$(VERSION) not in ChangeLog" 1>&2; \
114 @grep 'AC_DEFUN([^[]' m4/*.m4 \
115 && { echo 'Makefile.maint: quote the first arg to AC_DEFUN' 1>&2; \
118 # Verify that all source files using _() are listed in po/POTFILES.in.
120 if test -f po/POTFILES.in; then \
121 grep -E -v '^(#|$$)' po/POTFILES.in | sort > $@-1; \
123 for file in lib/*.[chly] src/*.[chly]; do \
126 base=`expr " $$file" : ' \(.*\)\..'`; \
127 { test -f $$base.l || test -f $$base.y; } && continue;; \
129 files="$$files $$file"; \
131 grep -E -l '\bN?_\([^)"]*("|$$)' $$files | sort > $@-2; \
132 diff -u $@-1 $@-2 || exit 1; \
136 # In a definition of #define AUTHORS "... and ..." where the RHS contains
137 # the English word `and', the string must be marked with `N_ (...)' so that
138 # gettext recognizes it as a string requiring translation.
140 @grep '^# *define AUTHORS "[^"]* and ' src/*.c |grep -v ' N_ (' && \
141 { echo 'Makefile.maint: enclose the above strings in N_ (...)' 1>&2; \
144 # Sometimes it is useful to change the PATH environment variable
145 # in Makefiles. When doing so, it's better not to use the Unix-centric
146 # path separator of `:', but rather the automake-provided `@PATH_SEPARATOR@'.
147 # It'd be better to use `find -print0 ...|xargs -0 ...', but less portable,
148 # and there probably aren't many projects with so many Makefile.am files
149 # that we'd have to worry about limits on command line length.
150 msg = 'Makefile.maint: Do not use `:'\'' above; use @PATH_SEPARATOR@ instead'
151 makefile_path_separator_check:
152 @grep 'PATH=.*:' `find $(srcdir) -name Makefile.am` \
153 && { echo $(msg) 1>&2; exit 1; } || :
155 # Check that `make alpha' will not fail at the end of the process.
157 if test -d $(release_archive_dir); then :; else \
158 mkdir $(release_archive_dir); \
160 for file in $(distdir).tar.gz $(xd-delta) \
161 $(release_archive_dir)/$(distdir).tar.gz \
162 $(release_archive_dir)/$(xd-delta); do \
163 test -e $$file || continue; \
165 || { echo ERROR: $$file is not writable; fail=1; }; \
167 test "$$fail" && exit 1 || :
169 v_etc_file = lib/version-etc.c
170 # Make sure that the copyright date in $(v_etc_file) is up to date.
172 @if test -f $(v_etc_file); then \
173 grep '"Copyright (C) $(shell date +%Y) Free' $(v_etc_file) \
175 || { echo 'out of date copyright in $(v_etc_file); update it' 1>&2; \
180 # Sanity checks with the CVS repository.
182 echo $(this-cvs-tag); \
183 if $(CVS) -n log -h README | grep -e $(this-cvs-tag): >/dev/null; then \
184 echo "$(this-cvs-tag) as already been used; not tagging" 1>&2; \
189 if $(CVS) diff >cvs-diffs; then \
192 echo "Some files are locally modified:" 1>&2; \
197 cvs-check: cvs-diff-check cvs-tag-check
199 maintainer-distcheck: changelog-check
204 # Tag before making distribution. Also, don't make a distribution if
205 # checks fail. Also, make sure the NEWS file is up-to-date.
206 # FIXME: use dist-hook/my-dist like distcheck-hook/my-distcheck.
207 cvs-dist: $(local-check) cvs-check maintainer-distcheck
209 $(CVS) tag -c $(this-cvs-tag)
212 # Use this to make sure we don't run these programs when building
213 # from a virgin tgz file, below.
214 null_AM_MAKEFLAGS = \
221 # Detect format-string/arg-list mismatches that would normally be obscured
222 # by the use of _(). The --disable-nls effectively defines away that macro,
223 # and building with CFLAGS='-Wformat -Werror' causes any format warning to be
224 # treated as a failure.
226 t=$(TMPDIR)/$(PACKAGE)/test
227 my-distcheck: $(local-check)
230 GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
232 && ./configure --disable-nls \
233 && $(MAKE) CFLAGS='-Wformat -Werror' \
234 AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)' \
238 (cd $(t) && mv $(distdir) $(distdir).old \
239 && $(AMTAR) -zxf - ) < $(distdir).tar.gz
240 diff -ur $(t)/$(distdir).old $(t)/$(distdir)
242 @echo "========================"; \
243 echo "$(distdir).tar.gz is ready for distribution"; \
244 echo "========================"
246 tgz-md5 = $(shell md5sum < $(my_distdir).tar.gz|sed 's/ -//')
247 tgz-sha1 = $(shell sha1sum < $(my_distdir).tar.gz|sed 's/ -//')
248 bz2-md5 = $(shell md5sum < $(my_distdir).tar.bz2|sed 's/ -//')
249 bz2-sha1 = $(shell sha1sum < $(my_distdir).tar.bz2|sed 's/ -//')
250 xdelta-md5 = $(shell md5sum < $(xd-delta)|sed 's/ -//')
251 xdelta-sha1 = $(shell sha1sum < $(xd-delta)|sed 's/ -//')
252 tgz-size = $(shell du --human $(my_distdir).tar.gz|sed 's/\([MkK]\).*/ \1B/')
253 bz2-size = $(shell du --human $(my_distdir).tar.bz2|sed 's/\([MkK]\).*/ \1B/')
254 xd-size = $(shell du --human $(xd-delta)|sed 's/\([MkK]\).*/ \1B/')
257 tarz=/tmp/rel-check-tarz-$$$$; \
258 md5_tmp=/tmp/rel-check-md5-$$$$; \
260 trap 'status=$$?; rm -f $$tarz $$md5_tmp; exit $$status' 0 1 2 3 15; \
261 wget -q --output-document=$$tarz $(url); \
262 echo "$(md5) -" > $$md5_tmp; \
263 md5sum -c $$md5_tmp < $$tarz
265 prev-tgz = $(PACKAGE)-$(PREV_VERSION).tar.gz
266 xd-delta = $(PACKAGE)-$(PREV_VERSION)-$(VERSION).xdelta
268 signatures ?= $(distdir).tar.bz2.sig $(distdir).tar.gz.sig
272 rel-files = $(xd-delta) $(distdir).tar.bz2 $(distdir).tar.gz $(signatures)
273 announcement: NEWS ChangeLog $(rel-files) $(signatures)
275 --release-type=$(RELEASE_TYPE) \
276 --package=$(PACKAGE) \
277 --prev=$(PREV_VERSION) \
279 --release-archive-directory=$(release_archive_dir) \
281 $(addprefix --url-dir=, $(url_dir_list)) \
284 ## ---------------- ##
285 ## Updating files. ##
286 ## ---------------- ##
289 ftp-gnu = ftp://ftp.gnu.org/gnu
290 www-gnu = http://www.gnu.org
292 # Use mv, if you don't have/want move-if-change.
293 move_if_change ?= move-if-change
296 # --------------------- #
297 # Updating everything. #
298 # --------------------- #
301 local_updates ?= wget-update cvs-update po-update
302 update: $(local_updates)
305 # ------------------- #
306 # Updating PO files. #
307 # ------------------- #
309 po_repo = http://www.iro.umontreal.ca/contrib/po/maint/$(PACKAGE)
310 .PHONY: do-po-update po-update
312 tmppo=/tmp/$(PACKAGE)-$(VERSION)-po &&\
315 (cd $$tmppo && $(WGET) -r -l1 -nd --no-parent -A '*.po' $(po_repo)) &&\
317 cd po && $(MAKE) update-po
321 if test -d "po"; then \
322 $(MAKE) do-po-update; \
325 # -------------------------- #
326 # Updating GNU build tools. #
327 # -------------------------- #
329 # The following pseudo table associates a local directory and a URL
330 # with each of the files that belongs to some other package and is
331 # regularly updated from the specified URL.
332 wget_files ?= $(srcdir)/config/config.guess \
333 $(srcdir)/config/config.sub \
334 $(srcdir)/src/ansi2knr.c \
335 $(srcdir)/config/texinfo.tex
336 get-targets = $(patsubst %, get-%, $(wget_files))
338 config.guess-url_prefix = $(ftp-gnu)/config/
339 config.sub-url_prefix = $(ftp-gnu)/config/
341 ansi2knr.c-url_prefix = ftp://ftp.cs.wisc.edu/ghost/
343 texinfo.tex-url_prefix = $(ftp-gnu)/texinfo/
345 standards.texi-url_prefix = $(www-gnu)/prep/
346 make-stds.texi-url_prefix = $(standards.texi-url_prefix)
348 target = $(patsubst get-%, %, $@)
349 url = $($(notdir $(target))-url_prefix)$(notdir $(target))
351 .PHONY: $(get-targets)
353 $(WGET) $(url) -O $(target).t \
354 && $(move_if_change) $(target).t $(target)
356 cvs_files ?= $(srcdir)/config/depcomp $(srcdir)/config/missing \
357 $(srcdir)/config/mkinstalldirs \
358 $(srcdir)/config/install-sh $(srcdir)/src/ansi2knr.c
359 automake_repo=:pserver:anoncvs:anoncvs@sources.redhat.com:/cvs/automake
361 wget-update: $(get-targets)
366 for f in $(cvs_files); do \
367 test -f $$f || { echo "*** skipping $$f" 1>&2; continue; }; \
368 cvs diff $$f > /dev/null \
369 || { echo "*** $$f is locally modified; skipping it" 1>&2; \
370 fail=yes; continue; }; \
371 file=$$(basename $$f); \
372 echo checking out $$file...; \
373 $(CVS) -d $(automake_repo) co -p automake/lib/$$file> $$f.t \
374 && $(move_if_change) $$f.t $$f; \
376 test "$$fail" && exit 1
378 define emit-upload-commands
379 echo =====================================
380 echo =====================================
381 echo upload $(PACKAGE) $(PREV_VERSION) $(VERSION)
382 echo '# send the /tmp/announcement e-mail'
383 echo =====================================
384 echo =====================================
387 $(xd-delta): $(release_archive_dir)/$(prev-tgz) $(distdir).tar.gz
388 xdelta delta -9 $^ $@ || :
390 .PHONY: alpha beta major
391 alpha beta major: $(local-check)
394 $(MAKE) -s announcement RELEASE_TYPE=$@ > /tmp/announce-$(my_distdir)
395 ln $(rel-files) $(release_archive_dir)
396 chmod a-w $(rel-files)
397 echo $(VERSION) > $(prev_version_file)
398 $(CVS) ci -m. $(prev_version_file)
399 @$(emit-upload-commands)