2 # This Makefile fragment is shared between the coreutils,
3 # CPPI, Bison, and Autoconf.
5 ## Copyright (C) 2001-2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
22 # This is reported not to work with make-3.79.1
23 # ME := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
26 # Do not save the original name or timestamp in the .tar.gz file.
27 GZIP_ENV = '--no-name --best --rsyncable'
31 # cvsu is part of the cvsutils package: http://www.red-bean.com/cvsutils/
32 CVS_LIST = build-aux/cvsu --find --types=AFGM
34 ifeq ($(origin prev_version_file), undefined)
35 prev_version_file = .prev-version
38 PREV_VERSION := $(shell cat $(prev_version_file))
39 VERSION_REGEXP = $(subst .,\.,$(VERSION))
41 tag-package = $(shell echo "$(PACKAGE)" | tr '[:lower:]' '[:upper:]')
42 tag-this-version = $(subst .,_,$(VERSION))
43 this-cvs-tag = $(tag-package)-$(tag-this-version)
44 my_distdir = $(PACKAGE)-$(VERSION)
46 # Old releases are stored here.
47 # Used for diffs and xdeltas.
48 release_archive_dir ?= ../release
50 # Prevent programs like 'sort' from considering distinct strings to be equal.
51 # Doing it here saves us from having to set LC_ALL elsewhere in this file.
60 # Checks that don't require cvs.
61 # Run `changelog-check' last, as previous test may reveal problems requiring
62 # new ChangeLog entries.
63 local-checks-available = \
64 po-check copyright-check writable-files m4-check author_mark_check \
65 changelog-check strftime-check syntax-check makefile_path_separator_check \
67 .PHONY: $(local-checks-available)
69 local-check = $(filter-out $(local-checks-to-skip), $(local-checks-available))
71 .PHONY: $(syntax-check-rules)
72 syntax-check-rules = \
73 sc_cast_of_argument_to_free \
74 sc_cast_of_x_alloc_return_value \
75 sc_cast_of_alloca_return_value \
76 sc_dd_max_sym_length \
77 sc_error_exit_success \
79 sc_no_if_have_config_h \
81 sc_prohibit_atoi_atof \
82 sc_prohibit_jm_in_m4 \
90 sc_unmarked_diagnostics \
93 syntax-check: $(syntax-check-rules)
94 # @grep -E '# *include <(limits|std(def|arg|bool))\.h>' \
95 # $$(find -type f -name '*.[chly]') && \
96 # { echo '$(ME): found conditional include' 1>&2; \
99 # grep -E '^# *include <(string|stdlib)\.h>' \
100 # $(srcdir)/{lib,src}/*.[chy] && \
101 # { echo '$(ME): FIXME' 1>&2; \
103 # FIXME: don't allow `#include .strings\.h' anywhere
105 # FIXME: add a check for this.
106 # Nearly every lib/*.c file must include config.h, like this:
107 # #ifdef HAVE_CONFIG_H
108 # # include <config.h>
111 sc_cast_of_argument_to_free:
112 @grep -E '\<free \(\(' $(srcdir)/{lib,src}/*.[chly] && \
113 { echo '$(ME): don'\''t cast free argument' 1>&2; \
116 sc_cast_of_x_alloc_return_value:
117 @grep -E --exclude=$(srcdir)/lib/regex.c \
118 '\*\) *x(m|c|re)alloc\>' \
119 $(srcdir)/{lib,src}/*.[chy] && \
120 { echo '$(ME): don'\''t cast x*alloc return value' 1>&2; \
123 sc_cast_of_alloca_return_value:
124 @grep -E '\*\) *alloca\>' \
125 $(srcdir)/src/*.[chy] && \
126 { echo '$(ME): don'\''t cast alloca return value' 1>&2; \
130 @( $(CVS_LIST) ) > /dev/null 2>&1 || : && \
132 $$($(CVS_LIST) | grep -vEf .x-$@ ) && \
133 { echo '$(ME): found SPACE-TAB sequence; remove the SPACE' \
136 # Don't use atoi, atof, atol, atoll, or atoq in `real' code.
137 # They provide no error checking mechanism.
138 # Instead, use strto* functions.
139 sc_prohibit_atoi_atof:
140 @( $(CVS_LIST) ) > /dev/null 2>&1 || : && \
141 grep -E '\<(ato[filq]|atoll)\>' \
142 $$($(CVS_LIST) | grep -vEf .x-$@ ) && \
143 { echo '$(ME): do not use atof, atoi, atol, atoll, or atoq' \
146 # Using EXIT_SUCCESS as the first argument to error is misleading,
147 # since when that parameter is 0, error does not exit. Use `0' instead.
148 sc_error_exit_success:
149 @grep -F 'error (EXIT_SUCCESS,' \
150 $$(find -type f -name '*.[chly]') && \
151 { echo '$(ME): found error (EXIT_SUCCESS' 1>&2; \
155 @grep -i 'filesystem' \
156 $$($(CVS_LIST) | grep -vEf .x-$@ ) && \
157 { echo '$(ME): found use of "filesystem";' \
158 'rewrite to use "file system"' 1>&2; \
161 sc_no_if_have_config_h:
162 @( $(CVS_LIST) ) > /dev/null 2>&1 || : && \
163 grep '^# *if HAVE_CONFIG_H' \
164 $$($(CVS_LIST) | grep -vEf .x-$@ ) && \
165 { echo '$(ME): found use of #if HAVE_CONFIG_H; use #ifdef' \
168 # Nearly all .c files must include <config.h>.
170 @( $(CVS_LIST) ) > /dev/null 2>&1 || : && \
171 grep -L '^# *include <config\.h>' \
172 $$($(CVS_LIST) | grep '\.c$$' | grep -vEf .x-$@ ) \
174 { echo '$(ME): the above files do not include <config.h>' \
178 @( $(CVS_LIST) ) > /dev/null 2>&1 || : && \
179 grep -E '\<(HAVE_FCNTL_H)\>' \
180 $$($(CVS_LIST) | grep -vEf .x-$@ ) && \
181 { echo '$(ME): do not use HAVE_FCNTL_H' \
184 # FIXME: warn about definitions of EXIT_FAILURE, EXIT_SUCCESS, STREQ
186 # Each nonempty line must start with a year number, or a TAB.
188 @grep '^[^12 ]' $$(find . -maxdepth 2 -name ChangeLog) && \
189 { echo '$(ME): found unexpected prefix in a ChangeLog' 1>&2; \
192 # Ensure that dd's definition of LONGEST_SYMBOL stays in sync
193 # with the strings from the two affected variables.
194 dd_c = $(srcdir)/src/dd.c
195 sc_dd_max_sym_length:
196 @test -f $(dd_c) || exit 0; \
197 len=$$( (sed -n '/conversions\[\] =$$/,/^};/p' $(dd_c); \
198 sed -n '/flags\[\] =$$/,/^};/p' $(dd_c) ) \
199 |sed -n '/"/s/^[^"]*"\([^"]*\)".*/\1/p' \
200 | wc --max-line-length); \
201 max=$$(sed -n '/^#define LONGEST_SYMBOL /s///p' $(dd_c) \
202 |tr -d '"' | wc --max-line-length); \
203 if test "$$len" = "$$max"; then :; else \
204 echo 'dd.c: LONGEST_SYMBOL is not longest' 1>&2; \
208 # Many m4 macros names once began with `jm_'.
209 # On 2004-04-13, they were all changed to start with gl_ instead.
210 # Make sure that none are inadvertently reintroduced.
211 sc_prohibit_jm_in_m4:
212 @( $(CVS_LIST) ) > /dev/null 2>&1 || : && \
214 $$($(CVS_LIST) $(srcdir)/m4 |grep '\.m4$$') && \
215 { echo '$(ME): do not use jm_ in m4 macro names' \
219 @t1=sc-root.expected; t2=sc-root.actual; \
220 grep -l '^PRIV_CHECK_ARG=require-root' \
221 $$($(CVS_LIST) tests) |sed s,tests,., |sort > $$t1; \
222 sed -n 's, cd \([^ ]*\) .*MAKE..check TESTS=\(.*\),./\1/\2,p' \
223 $(srcdir)/tests/Makefile.am |sort > $$t2; \
224 diff -u $$t1 $$t2 || diff=1; \
227 && { echo 'tests/Makefile.am: missing check-root action'>&2; \
230 # Create a list of regular expressions matching the names
231 # of files included from system.h. Exclude a couple.
233 @sed -n '/^# *include /s///p' $(srcdir)/src/system.h \
234 | grep -Ev 'sys/(param|file)\.h' \
235 | sed 's/ .*//;;s/^["<]/^# *include [<"]/;s/\.h[">]$$/\\.h[">]/' \
239 # Files in src/ should not include directly any of
240 # the headers already included via system.h.
241 sc_system_h_headers: .re-list
242 @if test -f $(srcdir)/src/system.h; then \
243 ( $(CVS_LIST) ) > /dev/null 2>&1 || exit 0; \
244 trap 'rc=$$?; rm -f .re-list; exit $$rc' 0 1 2 3 15; \
245 grep -E -f .re-list \
246 $$($(CVS_LIST) src | grep -Ev '(copy|system)\.h$$') \
247 && { echo '$(ME): the above are already included via system.h'\
248 1>&2; exit 1; } || :; \
252 @( $(CVS_LIST) ) > /dev/null 2>&1 || : && \
254 'solaris[^[:alnum:]]*2\.(7|8|9|[1-9][0-9])|sunos[^[:alnum:]][6-9]' \
255 $$($(CVS_LIST) | grep -vEf .x-$@ ) && \
256 { echo '$(ME): found misuse of Sun OS version numbers' 1>&2; \
263 @( $(CVS_LIST) ) > /dev/null 2>&1 || : && \
265 $$($(CVS_LIST) | grep -vEf .x-$@ ) && \
266 { echo '$(ME): found trailing blank(s)' \
269 # Look for diagnostics that aren't marked for translation.
270 # This won't find any for which error's format string is on a separate line.
271 sc_unmarked_diagnostics:
272 @( $(CVS_LIST) ) > /dev/null 2>&1 || : && \
274 '\<error \([^"]*"[^"]*[a-z]{3}' \
275 $$($(CVS_LIST) | grep -vEf .x-$@ ) \
277 { echo '$(ME): found unmarked diagnostic(s)' 1>&2; \
280 # Avoid useless parentheses like those in this example:
281 # #if defined (SYMBOL) || defined (SYM2)
282 sc_useless_cpp_parens:
283 @( $(CVS_LIST) ) > /dev/null 2>&1 || : && \
284 grep '^# *if .*defined *(' \
285 $$($(CVS_LIST) | grep -vEf .x-$@ ) && \
286 { echo '$(ME): found useless parentheses in cpp directive' \
289 # Ensure that date's --help output stays in sync with the info
290 # documentation for GNU strftime. The only exception is %N,
291 # which date accepts but GNU strftime does not.
292 extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/'
294 if test -f $(srcdir)/src/date.c; then \
295 grep '^ %. ' $(srcdir)/src/date.c | sort \
296 | $(extract_char) > $@-src; \
298 info libc date calendar format | grep '^ `%.'\' \
299 | $(extract_char); } | sort > $@-info; \
300 diff -u $@-src $@-info || exit 1; \
301 rm -f $@-src $@-info; \
304 # Ensure that we use only the standard $(VAR) notation,
305 # not @...@ in Makefile.am, now that we can rely on automake
306 # to emit a definition for each substituted variable.
308 grep -E '@[A-Z_0-9]+@' `find . -name Makefile.am` \
309 && { echo 'Makefile.maint: use $$(...), not @...@' 1>&2; exit 1; } || :
311 news-date-check: NEWS
312 today=`date +%Y-%m-%d`; \
313 if head NEWS | grep '^\*.* $(VERSION_REGEXP) ('$$today')' \
317 echo "version or today's date is not in NEWS" 1>&2; \
322 if head ChangeLog | grep 'Version $(VERSION_REGEXP)\.$$' \
326 echo "$(VERSION) not in ChangeLog" 1>&2; \
331 @grep 'AC_DEFUN([^[]' m4/*.m4 \
332 && { echo 'Makefile.maint: quote the first arg to AC_DEFUN' 1>&2; \
335 # Verify that all source files using _() are listed in po/POTFILES.in.
336 # FIXME: don't hard-code src/false.c below; use a more general mechanism.
338 ( $(CVS_LIST) ) > /dev/null 2>&1 || : && \
339 if test -f po/POTFILES.in; then \
340 grep -E -v '^(#|$$)' po/POTFILES.in \
341 | grep -v '^src/false\.c$$' | sort > $@-1; \
343 for file in $$($(CVS_LIST) lib src | grep '\.[chly]$$'); do \
346 base=`expr " $$file" : ' \(.*\)\..'`; \
347 { test -f $$base.l || test -f $$base.y; } && continue;; \
349 files="$$files $$file"; \
351 grep -E -l '\bN?_\([^)"]*("|$$)' $$files | sort > $@-2; \
352 diff -u $@-1 $@-2 || exit 1; \
356 # In a definition of #define AUTHORS "... and ..." where the RHS contains
357 # the English word `and', the string must be marked with `N_ (...)' so that
358 # gettext recognizes it as a string requiring translation.
360 @grep '^# *define AUTHORS "[^"]* and ' src/*.c |grep -v ' N_ (' && \
361 { echo 'Makefile.maint: enclose the above strings in N_ (...)' 1>&2; \
364 # Sometimes it is useful to change the PATH environment variable
365 # in Makefiles. When doing so, it's better not to use the Unix-centric
366 # path separator of `:', but rather the automake-provided `@PATH_SEPARATOR@'.
367 # It'd be better to use `find -print0 ...|xargs -0 ...', but less portable,
368 # and there probably aren't many projects with so many Makefile.am files
369 # that we'd have to worry about limits on command line length.
370 msg = 'Makefile.maint: Do not use `:'\'' above; use @PATH_SEPARATOR@ instead'
371 makefile_path_separator_check:
372 @grep 'PATH=.*:' `find $(srcdir) -name Makefile.am` \
373 && { echo $(msg) 1>&2; exit 1; } || :
375 # Check that `make alpha' will not fail at the end of the process.
377 if test -d $(release_archive_dir); then :; else \
378 mkdir $(release_archive_dir); \
380 for file in $(distdir).tar.gz $(xd-delta) \
381 $(release_archive_dir)/$(distdir).tar.gz \
382 $(release_archive_dir)/$(xd-delta); do \
383 test -e $$file || continue; \
385 || { echo ERROR: $$file is not writable; fail=1; }; \
387 test "$$fail" && exit 1 || :
389 v_etc_file = lib/version-etc.c
390 # Make sure that the copyright date in $(v_etc_file) is up to date.
392 @if test -f $(v_etc_file); then \
393 grep 'enum { COPYRIGHT_YEAR = 2005 };' $(v_etc_file) \
395 || { echo 'out of date copyright in $(v_etc_file); update it' 1>&2; \
400 # Sanity checks with the CVS repository.
402 echo $(this-cvs-tag); \
403 if $(CVS) -n log -h README | grep -e $(this-cvs-tag): >/dev/null; then \
404 echo "$(this-cvs-tag) as already been used; not tagging" 1>&2; \
409 if $(CVS) diff >cvs-diffs; then \
412 echo "Some files are locally modified:" 1>&2; \
417 cvs-check: cvs-diff-check cvs-tag-check
419 maintainer-distcheck: changelog-check
424 # Tag before making distribution. Also, don't make a distribution if
425 # checks fail. Also, make sure the NEWS file is up-to-date.
426 # FIXME: use dist-hook/my-dist like distcheck-hook/my-distcheck.
427 cvs-dist: $(local-check) cvs-check maintainer-distcheck
429 $(CVS) tag -c $(this-cvs-tag)
432 # Use this to make sure we don't run these programs when building
433 # from a virgin tgz file, below.
434 null_AM_MAKEFLAGS = \
441 # Detect format-string/arg-list mismatches that would normally be obscured
442 # by the use of _(). The --disable-nls effectively defines away that macro,
443 # and building with CFLAGS='-Wformat -Werror' causes any format warning to be
444 # treated as a failure. Also, check for shadowing problems with -Wshadow.
445 # These CFLAGS are pretty strict. If you build this target, you probably
446 # have to have a recent version of gcc and glibc headers.
448 t=$(TMPDIR)/$(PACKAGE)/test
449 my-distcheck: $(local-check) $(release_archive_dir)/$(prev-tgz)
452 GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
454 && ./configure --disable-nls \
455 && $(MAKE) CFLAGS='-Werror -Wall -Wformat -Wshadow' \
456 AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)' \
460 (cd $(t) && mv $(distdir) $(distdir).old \
461 && $(AMTAR) -zxf - ) < $(distdir).tar.gz
462 diff -ur $(t)/$(distdir).old $(t)/$(distdir)
464 @echo "========================"; \
465 echo "$(distdir).tar.gz is ready for distribution"; \
466 echo "========================"
471 tgz-md5 = $(shell md5sum < $(my_distdir).tar.gz|sed 's/ -//')
472 tgz-sha1 = $(shell sha1sum < $(my_distdir).tar.gz|sed 's/ -//')
473 bz2-md5 = $(shell md5sum < $(my_distdir).tar.bz2|sed 's/ -//')
474 bz2-sha1 = $(shell sha1sum < $(my_distdir).tar.bz2|sed 's/ -//')
475 xdelta-md5 = $(shell md5sum < $(xd-delta)|sed 's/ -//')
476 xdelta-sha1 = $(shell sha1sum < $(xd-delta)|sed 's/ -//')
477 tgz-size = $(shell du --human $(my_distdir).tar.gz|sed 's/\([MkK]\).*/ \1B/')
478 bz2-size = $(shell du --human $(my_distdir).tar.bz2|sed 's/\([MkK]\).*/ \1B/')
479 xd-size = $(shell du --human $(xd-delta)|sed 's/\([MkK]\).*/ \1B/')
482 tarz=/tmp/rel-check-tarz-$$$$; \
483 md5_tmp=/tmp/rel-check-md5-$$$$; \
485 trap 'status=$$?; rm -f $$tarz $$md5_tmp; exit $$status' 0 1 2 3 15; \
486 $(WGET) $(WGETFLAGS) -q --output-document=$$tarz $(url); \
487 echo "$(md5) -" > $$md5_tmp; \
488 md5sum -c $$md5_tmp < $$tarz
490 prev-tgz = $(PACKAGE)-$(PREV_VERSION).tar.gz
491 xd-delta = $(PACKAGE)-$(PREV_VERSION)-$(VERSION).xdelta
493 rel-files = $(xd-delta) $(DIST_ARCHIVES)
494 announcement: NEWS ChangeLog $(rel-files)
496 --release-type=$(RELEASE_TYPE) \
497 --package=$(PACKAGE) \
498 --prev=$(PREV_VERSION) \
500 --release-archive-directory=$(release_archive_dir) \
501 --gpg-key-id=$(gpg_key_ID) \
503 $(addprefix --url-dir=, $(url_dir_list)) \
506 ## ---------------- ##
507 ## Updating files. ##
508 ## ---------------- ##
510 ftp-gnu = ftp://ftp.gnu.org/gnu
511 www-gnu = http://www.gnu.org
513 # Use mv, if you don't have/want move-if-change.
514 move_if_change ?= move-if-change
517 # --------------------- #
518 # Updating everything. #
519 # --------------------- #
522 local_updates ?= wget-update cvs-update po-update
523 update: $(local_updates)
526 # ------------------- #
527 # Updating PO files. #
528 # ------------------- #
530 po_repo = http://www.iro.umontreal.ca/contrib/po/maint/$(PACKAGE)
531 .PHONY: do-po-update po-update
533 tmppo=/tmp/$(PACKAGE)-$(VERSION)-po &&\
537 $(WGET) $(WGETFLAGS) -r -l1 -nd --no-parent -A '*.po' $(po_repo)) &&\
539 cd po && $(MAKE) update-po
543 if test -d "po"; then \
544 $(MAKE) do-po-update; \
547 # -------------------------- #
548 # Updating GNU build tools. #
549 # -------------------------- #
551 # The following pseudo table associates a local directory and a URL
552 # with each of the files that belongs to some other package and is
553 # regularly updated from the specified URL.
555 $(srcdir)/build-aux/config.guess \
556 $(srcdir)/build-aux/config.sub \
557 $(srcdir)/build-aux/texinfo.tex \
558 $(srcdir)/src/ansi2knr.c
560 get-targets = $(patsubst %, get-%, $(wget_files))
562 config.guess-url_prefix = $(ftp-gnu)/build-aux/
563 config.sub-url_prefix = $(ftp-gnu)/build-aux/
565 ansi2knr.c-url_prefix = ftp://ftp.cs.wisc.edu/ghost/
567 texinfo.tex-url_prefix = $(ftp-gnu)/texinfo/
569 standards.texi-url_prefix = $(www-gnu)/prep/
570 make-stds.texi-url_prefix = $(standards.texi-url_prefix)
572 target = $(patsubst get-%, %, $@)
573 url = $($(notdir $(target))-url_prefix)$(notdir $(target))
575 .PHONY: $(get-targets)
577 $(WGET) $(WGETFLAGS) $(url) -O $(target).t \
578 && $(move_if_change) $(target).t $(target)
581 $(srcdir)/build-aux/depcomp \
582 $(srcdir)/build-aux/install-sh \
583 $(srcdir)/build-aux/missing \
584 $(srcdir)/build-aux/mkinstalldirs \
585 $(srcdir)/src/ansi2knr.c
586 automake_repo=:pserver:anoncvs:anoncvs@sources.redhat.com:/cvs/automake
588 wget-update: $(get-targets)
593 for f in $(cvs_files); do \
594 test -f $$f || { echo "*** skipping $$f" 1>&2; continue; }; \
595 cvs diff $$f > /dev/null \
596 || { echo "*** $$f is locally modified; skipping it" 1>&2; \
597 fail=yes; continue; }; \
598 file=$$(basename $$f); \
599 echo checking out $$file...; \
600 $(CVS) -d $(automake_repo) co -p automake/lib/$$file> $$f.t \
601 && $(move_if_change) $$f.t $$f; \
603 test "$$fail" && exit 1
605 emit_upload_commands:
606 @echo =====================================
607 @echo =====================================
608 @echo "$(srcdir)/gnupload $(GNUPLOADFLAGS) \\"
609 @echo " --to $(gnu_rel_host):coreutils \\"
610 @echo " $(rel-files)"
611 @echo '# send the /tmp/announcement e-mail'
612 @echo =====================================
613 @echo =====================================
615 $(xd-delta): $(release_archive_dir)/$(prev-tgz) $(distdir).tar.gz
616 xdelta delta -9 $^ $@ || :
618 .PHONY: alpha beta major
619 alpha beta major: news-date-check $(local-check)
622 $(MAKE) -s announcement RELEASE_TYPE=$@ > /tmp/announce-$(my_distdir)
623 ln $(rel-files) $(release_archive_dir)
624 chmod a-w $(rel-files)
625 $(MAKE) -s emit_upload_commands RELEASE_TYPE=$@
626 echo $(VERSION) > $(prev_version_file)
627 $(CVS) ci -m. $(prev_version_file)