2 # This Makefile fragment is shared between the coreutils,
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 ME := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
24 # Do not save the original name or timestamp in the .tar.gz file.
25 GZIP_ENV = '--no-name --best'
29 ifeq ($(origin prev_version_file), undefined)
30 prev_version_file = .prev-version
33 PREV_VERSION := $(shell cat $(prev_version_file))
35 tag-package = $(shell echo "$(PACKAGE)" | tr '[:lower:]' '[:upper:]')
36 tag-this-version = $(subst .,_,$(VERSION))
37 this-cvs-tag = $(tag-package)-$(tag-this-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 syntax-check makefile_path_separator_check \
57 .PHONY: $(local-check)
59 # Make sure C source files in src/ don't include xalloc.h directly,
60 # since they all already include it via sys2.h.
61 # It's not a big deal -- just aesthetics.
62 .PHONY: $(syntax-check-rules)
63 syntax-check-rules = \
64 sc_unmarked_diagnostics \
65 sc_cast_of_argument_to_free \
66 sc_cast_of_x_alloc_return_value \
68 sc_error_exit_success \
72 syntax-check: $(syntax-check-rules)
73 # @grep -E '# *include <(limits|std(def|arg|bool))\.h>' \
74 # $$(find -type f -name '*.[chly]') && \
75 # { echo '$(ME): found conditional include' 1>&2; \
78 # grep -E '^# *include <(string|stdlib)\.h>' \
79 # $(srcdir)/{lib,src}/*.[chy] && \
80 # { echo '$(ME): FIXME' 1>&2; \
82 # FIXME: don't allow `#include .strings\.h' anywhere
84 # Look for diagnostics that aren't marked for translation.
85 # This won't find any for which error's format string is on a separate line.
86 sc_unmarked_diagnostics:
87 @grep --exclude=$(srcdir)/src/shred.c -E \
88 '\<error \([^"]*"[^"]*[a-z]{3}' $(srcdir)/{lib,src}/*.c \
90 { echo '$(ME): found unmarked diagnostic(s)' 1>&2; \
93 sc_cast_of_argument_to_free:
94 @grep -E '\<free \(\(' $(srcdir)/{lib,src}/*.[chly] && \
95 { echo '$(ME): don'\''t cast free argument' 1>&2; \
98 sc_cast_of_x_alloc_return_value:
99 @grep -E --exclude=$(srcdir)/lib/regex.c \
100 '\*\) *x(m|c|re)alloc\>' $(srcdir)/{lib,src}/*.[chy] && \
101 { echo '$(ME): don'\''t cast x*alloc return value' 1>&2; \
105 @grep -E '[ ] ' --exclude=$(srcdir)/lib/regex.c \
106 $(srcdir)/{lib,src}/*.[chly] \
107 $(find -name Makefile.am) && \
108 { echo '$(ME): found SPACE-TAB sequence; remove the SPACE' \
112 # Using EXIT_SUCCESS as the first argument to error is misleading,
113 # since when that parameter is 0, error does not exit. Use `0' instead.
114 sc_error_exit_success:
115 @grep -F 'error (EXIT_SUCCESS,' \
116 $$(find -type f -name '*.[chly]') && \
117 { echo '$(ME): found error (EXIT_SUCCESS' 1>&2; \
120 # xalloc.h is included via system.h, so should not be included
121 # directly by any file in src/.
123 @if test -f $(srcdir)/src/sys2.h; then \
124 if grep 'xalloc\.h' $(srcdir)/src/*.c; then \
129 # Each nonempty line must start with a year number, or a TAB.
131 @grep '^[^12 ]' $$(find . -name ChangeLog -maxdepth 2) && \
132 { echo '$(ME): found unexpected prefix in a ChangeLog' 1>&2; \
135 # Ensure that date's --help output stays in sync with the info
136 # documentation for GNU strftime. The only exception is %N,
137 # which date accepts but GNU strftime does not.
138 extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/'
140 if test -f $(srcdir)/src/date.c; then \
141 grep '^ %. ' $(srcdir)/src/date.c | sort \
142 | $(extract_char) > $@-src; \
144 info libc date calendar format | grep '^ `%.'\' \
145 | $(extract_char); } | sort > $@-info; \
146 diff -u $@-src $@-info || exit 1; \
147 rm -f $@-src $@-info; \
150 # Ensure that we use only the standard $(VAR) notation,
151 # not @...@ in Makefile.am, now that we can rely on automake
152 # to emit a definition for each substituted variable.
154 grep -E '@[A-Z_]+@' `find . -name Makefile.am` \
155 && { echo 'Makefile.maint: use $(...), not @...@' 1>&2; exit 1; } || :
158 if head ChangeLog | grep 'Version $(VERSION)' >/dev/null; then \
161 echo "$(VERSION) not in ChangeLog" 1>&2; \
166 @grep 'AC_DEFUN([^[]' m4/*.m4 \
167 && { echo 'Makefile.maint: quote the first arg to AC_DEFUN' 1>&2; \
170 # Verify that all source files using _() are listed in po/POTFILES.in.
172 if test -f po/POTFILES.in; then \
173 grep -E -v '^(#|$$)' po/POTFILES.in | sort > $@-1; \
175 for file in lib/*.[chly] src/*.[chly]; do \
178 base=`expr " $$file" : ' \(.*\)\..'`; \
179 { test -f $$base.l || test -f $$base.y; } && continue;; \
181 files="$$files $$file"; \
183 grep -E -l '\bN?_\([^)"]*("|$$)' $$files | sort > $@-2; \
184 diff -u $@-1 $@-2 || exit 1; \
188 # In a definition of #define AUTHORS "... and ..." where the RHS contains
189 # the English word `and', the string must be marked with `N_ (...)' so that
190 # gettext recognizes it as a string requiring translation.
192 @grep '^# *define AUTHORS "[^"]* and ' src/*.c |grep -v ' N_ (' && \
193 { echo 'Makefile.maint: enclose the above strings in N_ (...)' 1>&2; \
196 # Sometimes it is useful to change the PATH environment variable
197 # in Makefiles. When doing so, it's better not to use the Unix-centric
198 # path separator of `:', but rather the automake-provided `@PATH_SEPARATOR@'.
199 # It'd be better to use `find -print0 ...|xargs -0 ...', but less portable,
200 # and there probably aren't many projects with so many Makefile.am files
201 # that we'd have to worry about limits on command line length.
202 msg = 'Makefile.maint: Do not use `:'\'' above; use @PATH_SEPARATOR@ instead'
203 makefile_path_separator_check:
204 @grep 'PATH=.*:' `find $(srcdir) -name Makefile.am` \
205 && { echo $(msg) 1>&2; exit 1; } || :
207 # Check that `make alpha' will not fail at the end of the process.
209 if test -d $(release_archive_dir); then :; else \
210 mkdir $(release_archive_dir); \
212 for file in $(distdir).tar.gz $(xd-delta) \
213 $(release_archive_dir)/$(distdir).tar.gz \
214 $(release_archive_dir)/$(xd-delta); do \
215 test -e $$file || continue; \
217 || { echo ERROR: $$file is not writable; fail=1; }; \
219 test "$$fail" && exit 1 || :
221 v_etc_file = lib/version-etc.c
222 # Make sure that the copyright date in $(v_etc_file) is up to date.
224 @if test -f $(v_etc_file); then \
225 grep '"Copyright (C) $(shell date +%Y) Free' $(v_etc_file) \
227 || { echo 'out of date copyright in $(v_etc_file); update it' 1>&2; \
232 # Sanity checks with the CVS repository.
234 echo $(this-cvs-tag); \
235 if $(CVS) -n log -h README | grep -e $(this-cvs-tag): >/dev/null; then \
236 echo "$(this-cvs-tag) as already been used; not tagging" 1>&2; \
241 if $(CVS) diff >cvs-diffs; then \
244 echo "Some files are locally modified:" 1>&2; \
249 cvs-check: cvs-diff-check cvs-tag-check
251 maintainer-distcheck: changelog-check
256 # Tag before making distribution. Also, don't make a distribution if
257 # checks fail. Also, make sure the NEWS file is up-to-date.
258 # FIXME: use dist-hook/my-dist like distcheck-hook/my-distcheck.
259 cvs-dist: $(local-check) cvs-check maintainer-distcheck
261 $(CVS) tag -c $(this-cvs-tag)
264 # Use this to make sure we don't run these programs when building
265 # from a virgin tgz file, below.
266 null_AM_MAKEFLAGS = \
273 # Detect format-string/arg-list mismatches that would normally be obscured
274 # by the use of _(). The --disable-nls effectively defines away that macro,
275 # and building with CFLAGS='-Wformat -Werror' causes any format warning to be
276 # treated as a failure.
278 t=$(TMPDIR)/$(PACKAGE)/test
279 my-distcheck: $(local-check)
282 GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
284 && ./configure --disable-nls \
285 && $(MAKE) CFLAGS='-Wformat -Werror' \
286 AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)' \
290 (cd $(t) && mv $(distdir) $(distdir).old \
291 && $(AMTAR) -zxf - ) < $(distdir).tar.gz
292 diff -ur $(t)/$(distdir).old $(t)/$(distdir)
294 @echo "========================"; \
295 echo "$(distdir).tar.gz is ready for distribution"; \
296 echo "========================"
298 tgz-md5 = $(shell md5sum < $(my_distdir).tar.gz|sed 's/ -//')
299 tgz-sha1 = $(shell sha1sum < $(my_distdir).tar.gz|sed 's/ -//')
300 bz2-md5 = $(shell md5sum < $(my_distdir).tar.bz2|sed 's/ -//')
301 bz2-sha1 = $(shell sha1sum < $(my_distdir).tar.bz2|sed 's/ -//')
302 xdelta-md5 = $(shell md5sum < $(xd-delta)|sed 's/ -//')
303 xdelta-sha1 = $(shell sha1sum < $(xd-delta)|sed 's/ -//')
304 tgz-size = $(shell du --human $(my_distdir).tar.gz|sed 's/\([MkK]\).*/ \1B/')
305 bz2-size = $(shell du --human $(my_distdir).tar.bz2|sed 's/\([MkK]\).*/ \1B/')
306 xd-size = $(shell du --human $(xd-delta)|sed 's/\([MkK]\).*/ \1B/')
309 tarz=/tmp/rel-check-tarz-$$$$; \
310 md5_tmp=/tmp/rel-check-md5-$$$$; \
312 trap 'status=$$?; rm -f $$tarz $$md5_tmp; exit $$status' 0 1 2 3 15; \
313 wget -q --output-document=$$tarz $(url); \
314 echo "$(md5) -" > $$md5_tmp; \
315 md5sum -c $$md5_tmp < $$tarz
317 prev-tgz = $(PACKAGE)-$(PREV_VERSION).tar.gz
318 xd-delta = $(PACKAGE)-$(PREV_VERSION)-$(VERSION).xdelta
320 signatures ?= $(distdir).tar.bz2.asc $(distdir).tar.gz.asc
323 gpg --armor --detach-sign -o $@ $<
325 rel-files = $(xd-delta) $(distdir).tar.bz2 $(distdir).tar.gz $(signatures)
326 announcement: NEWS ChangeLog $(rel-files) $(signatures)
328 --release-type=$(RELEASE_TYPE) \
329 --package=$(PACKAGE) \
330 --prev=$(PREV_VERSION) \
332 --release-archive-directory=$(release_archive_dir) \
334 $(addprefix --url-dir=, $(url_dir_list)) \
337 ## ---------------- ##
338 ## Updating files. ##
339 ## ---------------- ##
342 ftp-gnu = ftp://ftp.gnu.org/gnu
343 www-gnu = http://www.gnu.org
345 # Use mv, if you don't have/want move-if-change.
346 move_if_change ?= move-if-change
349 # --------------------- #
350 # Updating everything. #
351 # --------------------- #
354 local_updates ?= wget-update cvs-update po-update
355 update: $(local_updates)
358 # ------------------- #
359 # Updating PO files. #
360 # ------------------- #
362 po_repo = http://www.iro.umontreal.ca/contrib/po/maint/$(PACKAGE)
363 .PHONY: do-po-update po-update
365 tmppo=/tmp/$(PACKAGE)-$(VERSION)-po &&\
368 (cd $$tmppo && $(WGET) -r -l1 -nd --no-parent -A '*.po' $(po_repo)) &&\
370 cd po && $(MAKE) update-po
374 if test -d "po"; then \
375 $(MAKE) do-po-update; \
378 # -------------------------- #
379 # Updating GNU build tools. #
380 # -------------------------- #
382 # The following pseudo table associates a local directory and a URL
383 # with each of the files that belongs to some other package and is
384 # regularly updated from the specified URL.
385 wget_files ?= $(srcdir)/config/config.guess \
386 $(srcdir)/config/config.sub \
387 $(srcdir)/src/ansi2knr.c \
388 $(srcdir)/config/texinfo.tex
389 get-targets = $(patsubst %, get-%, $(wget_files))
391 config.guess-url_prefix = $(ftp-gnu)/config/
392 config.sub-url_prefix = $(ftp-gnu)/config/
394 ansi2knr.c-url_prefix = ftp://ftp.cs.wisc.edu/ghost/
396 texinfo.tex-url_prefix = $(ftp-gnu)/texinfo/
398 standards.texi-url_prefix = $(www-gnu)/prep/
399 make-stds.texi-url_prefix = $(standards.texi-url_prefix)
401 target = $(patsubst get-%, %, $@)
402 url = $($(notdir $(target))-url_prefix)$(notdir $(target))
404 .PHONY: $(get-targets)
406 $(WGET) $(url) -O $(target).t \
407 && $(move_if_change) $(target).t $(target)
409 cvs_files ?= $(srcdir)/config/depcomp $(srcdir)/config/missing \
410 $(srcdir)/config/mkinstalldirs \
411 $(srcdir)/config/install-sh $(srcdir)/src/ansi2knr.c
412 automake_repo=:pserver:anoncvs:anoncvs@sources.redhat.com:/cvs/automake
414 wget-update: $(get-targets)
419 for f in $(cvs_files); do \
420 test -f $$f || { echo "*** skipping $$f" 1>&2; continue; }; \
421 cvs diff $$f > /dev/null \
422 || { echo "*** $$f is locally modified; skipping it" 1>&2; \
423 fail=yes; continue; }; \
424 file=$$(basename $$f); \
425 echo checking out $$file...; \
426 $(CVS) -d $(automake_repo) co -p automake/lib/$$file> $$f.t \
427 && $(move_if_change) $$f.t $$f; \
429 test "$$fail" && exit 1
431 define emit-upload-commands
432 echo =====================================
433 echo =====================================
434 echo upload $(PACKAGE) $(PREV_VERSION) $(VERSION)
435 echo '# send the /tmp/announcement e-mail'
436 echo =====================================
437 echo =====================================
440 $(xd-delta): $(release_archive_dir)/$(prev-tgz) $(distdir).tar.gz
441 xdelta delta -9 $^ $@ || :
443 .PHONY: alpha beta major
444 alpha beta major: $(local-check)
447 $(MAKE) -s announcement RELEASE_TYPE=$@ > /tmp/announce-$(my_distdir)
448 ln $(rel-files) $(release_archive_dir)
449 chmod a-w $(rel-files)
450 echo $(VERSION) > $(prev_version_file)
451 $(CVS) ci -m. $(prev_version_file)
452 @$(emit-upload-commands)