2 # This Makefile fragment is shared between the coreutils,
3 # CPPI, Bison, and Autoconf.
5 ## Copyright (C) 2001-2006 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 # Use --rsyncable if available.
29 "--no-name --best$$( \
30 case $$(gzip --help) in \
31 (*--rsyncable*) echo ' --rsyncable';; \
37 # cvsu is part of the cvsutils package: http://www.red-bean.com/cvsutils/
39 if test -x $(srcdir)/build-aux/cvsu; then \
40 $(srcdir)/build-aux/cvsu --find --types=AFGM $$*; \
43 if (!$$1 && $$3 !~ /^-/) { \
45 sub(/CVS\/Entries/, "", f); \
48 $$(find $${*-*} -name Entries -print) /dev/null; \
53 $(CVS_LIST) | if test -f .x-$@; then grep -vEf .x-$@; else grep -v ChangeLog; fi
55 ifeq ($(origin prev_version_file), undefined)
56 prev_version_file = .prev-version
59 PREV_VERSION := $(shell cat $(prev_version_file))
60 VERSION_REGEXP = $(subst .,\.,$(VERSION))
62 tag-package = $(shell echo "$(PACKAGE)" | tr '[:lower:]' '[:upper:]')
63 tag-this-version = $(subst .,_,$(VERSION))
64 this-cvs-tag = $(tag-package)-$(tag-this-version)
65 my_distdir = $(PACKAGE)-$(VERSION)
67 # Old releases are stored here.
68 # Used for diffs and xdeltas.
69 release_archive_dir ?= ../release
71 # Prevent programs like 'sort' from considering distinct strings to be equal.
72 # Doing it here saves us from having to set LC_ALL elsewhere in this file.
81 # FIXME: add a check to prohibit definition in src/*.c of symbols defined
82 # in system.h. E.g. today I removed from tail.c a useless definition of
83 # ENOSYS. It was useless because system.h ensures it's defined.
85 # Checks that don't require cvs.
86 # Run `changelog-check' last, as previous test may reveal problems requiring
87 # new ChangeLog entries.
88 local-checks-available = \
89 po-check copyright-check writable-files m4-check author_mark_check \
90 changelog-check strftime-check syntax-check makefile_path_separator_check \
92 .PHONY: $(local-checks-available)
94 local-check = $(filter-out $(local-checks-to-skip), $(local-checks-available))
96 .PHONY: $(syntax-check-rules)
97 syntax-check-rules = \
98 sc_cast_of_argument_to_free \
99 sc_cast_of_x_alloc_return_value \
100 sc_cast_of_alloca_return_value \
102 sc_dd_max_sym_length \
103 sc_error_exit_success \
105 sc_no_if_have_config_h \
106 sc_obsolete_symbols \
107 sc_prohibit_atoi_atof \
108 sc_prohibit_jm_in_m4 \
109 sc_prohibit_assert_without_use \
110 sc_require_config_h \
114 sc_system_h_headers \
117 sc_unmarked_diagnostics \
118 sc_useless_cpp_parens
120 syntax-check: $(syntax-check-rules)
121 # @grep -nE '# *include <(limits|std(def|arg|bool))\.h>' \
122 # $$(find -type f -name '*.[chly]') && \
123 # { echo '$(ME): found conditional include' 1>&2; \
126 # grep -nE '^# *include <(string|stdlib)\.h>' \
127 # $(srcdir)/{lib,src}/*.[chy] && \
128 # { echo '$(ME): FIXME' 1>&2; \
130 # FIXME: don't allow `#include .strings\.h' anywhere
132 sc_cast_of_argument_to_free:
133 @grep -nE '\<free \(\(' $(srcdir)/{lib,src}/*.[chly] && \
134 { echo '$(ME): don'\''t cast free argument' 1>&2; \
137 sc_cast_of_x_alloc_return_value:
138 @grep -nE --exclude=$(srcdir)/lib/regex.c \
139 '\*\) *x(m|c|re)alloc\>' \
140 $(srcdir)/{lib,src}/*.[chy] && \
141 { echo '$(ME): don'\''t cast x*alloc return value' 1>&2; \
144 sc_cast_of_alloca_return_value:
145 @grep -nE '\*\) *alloca\>' \
146 $(srcdir)/src/*.[chy] && \
147 { echo '$(ME): don'\''t cast alloca return value' 1>&2; \
151 @grep -n '[ ] ' $$($(CVS_LIST_EXCEPT)) && \
152 { echo '$(ME): found SPACE-TAB sequence; remove the SPACE' \
155 # Don't use the old ato* functions in `real' code.
156 # They provide no error checking mechanism.
157 # Instead, use strto* functions.
158 sc_prohibit_atoi_atof:
159 @grep -nE '\<(ato[filq]|ato''ll)\>' $$($(CVS_LIST_EXCEPT)) && \
160 { echo '$(ME): do not use ato''f, ato''i, ato''l, ato''ll, or ato''q' \
163 # Using EXIT_SUCCESS as the first argument to error is misleading,
164 # since when that parameter is 0, error does not exit. Use `0' instead.
165 sc_error_exit_success:
166 @grep -nF 'error (EXIT_SUCCESS,' \
167 $$(find -type f -name '*.[chly]') && \
168 { echo '$(ME): found error (EXIT_SUCCESS' 1>&2; \
172 @grep -ni 'file''system' $$($(CVS_LIST_EXCEPT)) && \
173 { echo '$(ME): found use of "file''system";' \
174 'rewrite to use "file system"' 1>&2; \
177 sc_no_if_have_config_h:
178 @grep -n '^# *if HAVE_CONFIG_H' $$($(CVS_LIST_EXCEPT)) && \
179 { echo '$(ME): found use of #if HAVE_CONFIG_H; use #ifdef' \
182 # Nearly all .c files must include <config.h>.
184 @grep -L '^# *include <config\.h>' \
185 $$($(CVS_LIST_EXCEPT) | grep '\.c$$') \
187 { echo '$(ME): the above files do not include <config.h>' \
190 # Prohibit the inclusion of assert.h without an actual use of assert.
191 sc_prohibit_assert_without_use:
192 @files=$$(grep -l '# *include <assert\.h>' \
193 $$($(CVS_LIST_EXCEPT) | grep '\.c$$')) && \
194 grep -L '\<assert (' $$files \
196 { echo "$(ME): the above files include <assert.h> but don't use it" \
200 @grep -nE '\<(HAVE''_FCNTL_H|O''_NDELAY)\>' \
201 $$($(CVS_LIST_EXCEPT)) && \
202 { echo '$(ME): do not use HAVE''_FCNTL_H or O''_NDELAY' \
205 # FIXME: warn about definitions of EXIT_FAILURE, EXIT_SUCCESS, STREQ
207 # Each nonempty line must start with a year number, or a TAB.
209 @grep -n '^[^12 ]' $$(find . -maxdepth 2 -name ChangeLog) && \
210 { echo '$(ME): found unexpected prefix in a ChangeLog' 1>&2; \
213 # Ensure that dd's definition of LONGEST_SYMBOL stays in sync
214 # with the strings from the two affected variables.
215 dd_c = $(srcdir)/src/dd.c
216 sc_dd_max_sym_length:
217 ifneq ($(wildcard $(dd_c)),)
218 @test -f $(dd_c) || exit 0; \
219 len=$$( (sed -n '/conversions\[\] =$$/,/^};/p' $(dd_c); \
220 sed -n '/flags\[\] =$$/,/^};/p' $(dd_c) ) \
221 |sed -n '/"/s/^[^"]*"\([^"]*\)".*/\1/p' \
222 | wc --max-line-length); \
223 max=$$(sed -n '/^#define LONGEST_SYMBOL /s///p' $(dd_c) \
224 |tr -d '"' | wc --max-line-length); \
225 if test "$$len" = "$$max"; then :; else \
226 echo 'dd.c: LONGEST_SYMBOL is not longest' 1>&2; \
231 # Many m4 macros names once began with `jm_'.
232 # On 2004-04-13, they were all changed to start with gl_ instead.
233 # Make sure that none are inadvertently reintroduced.
234 sc_prohibit_jm_in_m4:
235 @grep -nE 'jm_[A-Z]' \
236 $$($(CVS_LIST) $(srcdir)/m4 |grep '\.m4$$') && \
237 { echo '$(ME): do not use jm_ in m4 macro names' \
241 @t1=sc-root.expected; t2=sc-root.actual; \
242 grep -nl '^PRIV_CHECK_ARG=require-root' \
243 $$($(CVS_LIST) tests) |sed s,tests,., |sort > $$t1; \
244 sed -n 's, cd \([^ ]*\) .*MAKE..check TESTS=\(.*\),./\1/\2,p' \
245 $(srcdir)/tests/Makefile.am |sort > $$t2; \
246 diff -u $$t1 $$t2 || diff=1; \
249 && { echo 'tests/Makefile.am: missing check-root action'>&2; \
252 # Create a list of regular expressions matching the names
253 # of files included from system.h. Exclude a couple.
255 @sed -n '/^# *include /s///p' $(srcdir)/src/system.h \
256 | grep -Ev 'sys/(param|file)\.h' \
257 | sed 's/ .*//;;s/^["<]/^# *include [<"]/;s/\.h[">]$$/\\.h[">]/' \
261 # Files in src/ should not include directly any of
262 # the headers already included via system.h.
263 sc_system_h_headers: .re-list
264 @if test -f $(srcdir)/src/system.h; then \
265 trap 'rc=$$?; rm -f .re-list; exit $$rc' 0 1 2 3 15; \
266 grep -nE -f .re-list \
267 $$($(CVS_LIST) src | \
268 grep -Ev '((copy|system)\.h|parse-gram\.c)$$') \
269 && { echo '$(ME): the above are already included via system.h'\
270 1>&2; exit 1; } || :; \
275 'solaris[^[:alnum:]]*2\.(7|8|9|[1-9][0-9])|sunos[^[:alnum:]][6-9]' \
276 $$($(CVS_LIST_EXCEPT)) && \
277 { echo '$(ME): found misuse of Sun OS version numbers' 1>&2; \
284 @grep -n '[ ]$$' $$($(CVS_LIST_EXCEPT)) && \
285 { echo '$(ME): found trailing blank(s)' \
288 # Look for diagnostics that aren't marked for translation.
289 # This won't find any for which error's format string is on a separate line.
290 sc_unmarked_diagnostics:
292 '\<error \([^"]*"[^"]*[a-z]{3}' $$($(CVS_LIST_EXCEPT)) \
294 { echo '$(ME): found unmarked diagnostic(s)' 1>&2; \
297 # Avoid useless parentheses like those in this example:
298 # #if defined (SYMBOL) || defined (SYM2)
299 sc_useless_cpp_parens:
300 @grep -n '^# *if .*defined *(' $$($(CVS_LIST_EXCEPT)) && \
301 { echo '$(ME): found useless parentheses in cpp directive' \
304 # Ensure that date's --help output stays in sync with the info
305 # documentation for GNU strftime. The only exception is %N,
306 # which date accepts but GNU strftime does not.
307 extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/'
309 if test -f $(srcdir)/src/date.c; then \
310 grep '^ %. ' $(srcdir)/src/date.c | sort \
311 | $(extract_char) > $@-src; \
313 info libc date calendar format | grep '^ `%.'\' \
314 | $(extract_char); } | sort > $@-info; \
315 diff -u $@-src $@-info || exit 1; \
316 rm -f $@-src $@-info; \
319 # Ensure that we use only the standard $(VAR) notation,
320 # not @...@ in Makefile.am, now that we can rely on automake
321 # to emit a definition for each substituted variable.
323 grep -nE '@[A-Z_0-9]+@' `find . -name Makefile.am` \
324 && { echo 'Makefile.maint: use $$(...), not @...@' 1>&2; exit 1; } || :
326 news-date-check: NEWS
327 today=`date +%Y-%m-%d`; \
328 if head NEWS | grep '^\*.* $(VERSION_REGEXP) ('$$today')' \
332 echo "version or today's date is not in NEWS" 1>&2; \
337 if head ChangeLog | grep 'Version $(VERSION_REGEXP)\.$$' \
341 echo "$(VERSION) not in ChangeLog" 1>&2; \
346 @grep -n 'AC_DEFUN([^[]' m4/*.m4 \
347 && { echo 'Makefile.maint: quote the first arg to AC_DEFUN' 1>&2; \
350 # Verify that all source files using _() are listed in po/POTFILES.in.
351 # FIXME: don't hard-code src/false.c below; use a more general mechanism.
353 if test -f po/POTFILES.in; then \
354 grep -E -v '^(#|$$)' po/POTFILES.in \
355 | grep -v '^src/false\.c$$' | sort > $@-1; \
357 for file in lib/*.[chly] src/*.[chly]; do \
360 base=`expr " $$file" : ' \(.*\)\..'`; \
361 { test -f $$base.l || test -f $$base.y; } && continue;; \
363 files="$$files $$file"; \
365 grep -E -l '\bN?_\([^)"]*("|$$)' $$files | sort > $@-2; \
366 diff -u $@-1 $@-2 || exit 1; \
370 # In a definition of #define AUTHORS "... and ..." where the RHS contains
371 # the English word `and', the string must be marked with `N_ (...)' so that
372 # gettext recognizes it as a string requiring translation.
374 @grep -n '^# *define AUTHORS "[^"]* and ' src/*.c |grep -v ' N_ (' && \
375 { echo 'Makefile.maint: enclose the above strings in N_ (...)' 1>&2; \
378 # Sometimes it is useful to change the PATH environment variable
379 # in Makefiles. When doing so, it's better not to use the Unix-centric
380 # path separator of `:', but rather the automake-provided `@PATH_SEPARATOR@'.
381 # It'd be better to use `find -print0 ...|xargs -0 ...', but less portable,
382 # and there probably aren't many projects with so many Makefile.am files
383 # that we'd have to worry about limits on command line length.
384 msg = 'Makefile.maint: Do not use `:'\'' above; use @PATH_SEPARATOR@ instead'
385 makefile_path_separator_check:
386 @grep -n 'PATH=.*:' `find $(srcdir) -name Makefile.am` \
387 && { echo $(msg) 1>&2; exit 1; } || :
389 # Check that `make alpha' will not fail at the end of the process.
391 if test -d $(release_archive_dir); then :; else \
392 mkdir $(release_archive_dir); \
394 for file in $(distdir).tar.gz $(xd-delta) \
395 $(release_archive_dir)/$(distdir).tar.gz \
396 $(release_archive_dir)/$(xd-delta); do \
397 test -e $$file || continue; \
399 || { echo ERROR: $$file is not writable; fail=1; }; \
401 test "$$fail" && exit 1 || :
403 v_etc_file = lib/version-etc.c
404 # Make sure that the copyright date in $(v_etc_file) is up to date.
406 @if test -f $(v_etc_file); then \
407 grep 'enum { COPYRIGHT_YEAR = '$$(date +%Y)' };' $(v_etc_file) \
409 || { echo 'out of date copyright in $(v_etc_file); update it' 1>&2; \
414 # Sanity checks with the CVS repository.
416 echo $(this-cvs-tag); \
417 if $(CVS) -n log -h README | grep -e $(this-cvs-tag): >/dev/null; then \
418 echo "$(this-cvs-tag) as already been used; not tagging" 1>&2; \
423 if $(CVS) diff >cvs-diffs; then \
426 echo "Some files are locally modified:" 1>&2; \
431 cvs-check: cvs-diff-check cvs-tag-check
433 maintainer-distcheck: changelog-check
438 # Tag before making distribution. Also, don't make a distribution if
439 # checks fail. Also, make sure the NEWS file is up-to-date.
440 # FIXME: use dist-hook/my-dist like distcheck-hook/my-distcheck.
441 cvs-dist: $(local-check) cvs-check maintainer-distcheck
443 $(CVS) tag -c $(this-cvs-tag)
446 # Use this to make sure we don't run these programs when building
447 # from a virgin tgz file, below.
448 null_AM_MAKEFLAGS = \
455 # Detect format-string/arg-list mismatches that would normally be obscured
456 # by the use of _(). The --disable-nls effectively defines away that macro,
457 # and building with CFLAGS='-Wformat -Werror' causes any format warning to be
458 # treated as a failure. Also, check for shadowing problems with -Wshadow.
459 # These CFLAGS are pretty strict. If you build this target, you probably
460 # have to have a recent version of gcc and glibc headers.
462 t=$(TMPDIR)/$(PACKAGE)/test
463 my-distcheck: $(local-check) $(release_archive_dir)/$(prev-tgz)
466 GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
468 && ./configure --disable-nls \
469 && $(MAKE) CFLAGS='-Werror -Wall -Wformat -Wshadow' \
470 AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)' \
474 (cd $(t) && mv $(distdir) $(distdir).old \
475 && $(AMTAR) -zxf - ) < $(distdir).tar.gz
476 diff -ur $(t)/$(distdir).old $(t)/$(distdir)
478 @echo "========================"; \
479 echo "$(distdir).tar.gz is ready for distribution"; \
480 echo "========================"
485 tgz-md5 = $(shell md5sum < $(my_distdir).tar.gz|sed 's/ -//')
486 tgz-sha1 = $(shell sha1sum < $(my_distdir).tar.gz|sed 's/ -//')
487 bz2-md5 = $(shell md5sum < $(my_distdir).tar.bz2|sed 's/ -//')
488 bz2-sha1 = $(shell sha1sum < $(my_distdir).tar.bz2|sed 's/ -//')
489 xdelta-md5 = $(shell md5sum < $(xd-delta)|sed 's/ -//')
490 xdelta-sha1 = $(shell sha1sum < $(xd-delta)|sed 's/ -//')
491 tgz-size = $(shell du --human $(my_distdir).tar.gz|sed 's/\([MkK]\).*/ \1B/')
492 bz2-size = $(shell du --human $(my_distdir).tar.bz2|sed 's/\([MkK]\).*/ \1B/')
493 xd-size = $(shell du --human $(xd-delta)|sed 's/\([MkK]\).*/ \1B/')
496 tarz=/tmp/rel-check-tarz-$$$$; \
497 md5_tmp=/tmp/rel-check-md5-$$$$; \
499 trap 'status=$$?; rm -f $$tarz $$md5_tmp; exit $$status' 0 1 2 3 15; \
500 $(WGET) $(WGETFLAGS) -q --output-document=$$tarz $(url); \
501 echo "$(md5) -" > $$md5_tmp; \
502 md5sum -c $$md5_tmp < $$tarz
504 prev-tgz = $(PACKAGE)-$(PREV_VERSION).tar.gz
505 xd-delta = $(PACKAGE)-$(PREV_VERSION)-$(VERSION).xdelta
507 rel-files = $(xd-delta) $(DIST_ARCHIVES)
508 announcement: NEWS ChangeLog $(rel-files)
510 --release-type=$(RELEASE_TYPE) \
511 --package=$(PACKAGE) \
512 --prev=$(PREV_VERSION) \
514 --release-archive-directory=$(release_archive_dir) \
515 --gpg-key-id=$(gpg_key_ID) \
517 $(addprefix --url-dir=, $(url_dir_list)) \
520 ## ---------------- ##
521 ## Updating files. ##
522 ## ---------------- ##
524 ftp-gnu = ftp://ftp.gnu.org/gnu
525 www-gnu = http://www.gnu.org
527 # Use mv, if you don't have/want move-if-change.
528 move_if_change ?= move-if-change
531 # --------------------- #
532 # Updating everything. #
533 # --------------------- #
536 local_updates ?= wget-update cvs-update po-update
537 update: $(local_updates)
540 # ------------------- #
541 # Updating PO files. #
542 # ------------------- #
544 po_repo = http://www.iro.umontreal.ca/contrib/po/maint/$(PACKAGE)
545 .PHONY: do-po-update po-update
547 tmppo=/tmp/$(PACKAGE)-$(VERSION)-po &&\
551 $(WGET) $(WGETFLAGS) -r -l1 -nd --no-parent -A '*.po' $(po_repo)) &&\
553 cd po && $(MAKE) update-po
557 if test -d "po"; then \
558 $(MAKE) do-po-update; \
561 # -------------------------- #
562 # Updating GNU build tools. #
563 # -------------------------- #
565 # The following pseudo table associates a local directory and a URL
566 # with each of the files that belongs to some other package and is
567 # regularly updated from the specified URL.
569 $(srcdir)/build-aux/config.guess \
570 $(srcdir)/build-aux/config.sub \
571 $(srcdir)/build-aux/texinfo.tex \
572 $(srcdir)/src/ansi2knr.c
574 get-targets = $(patsubst %, get-%, $(wget_files))
576 config.guess-url_prefix = $(ftp-gnu)/build-aux/
577 config.sub-url_prefix = $(ftp-gnu)/build-aux/
579 ansi2knr.c-url_prefix = ftp://ftp.cs.wisc.edu/ghost/
581 texinfo.tex-url_prefix = $(ftp-gnu)/texinfo/
583 standards.texi-url_prefix = $(www-gnu)/prep/
584 make-stds.texi-url_prefix = $(standards.texi-url_prefix)
586 target = $(patsubst get-%, %, $@)
587 url = $($(notdir $(target))-url_prefix)$(notdir $(target))
589 .PHONY: $(get-targets)
591 $(WGET) $(WGETFLAGS) $(url) -O $(target).t \
592 && $(move_if_change) $(target).t $(target)
595 $(srcdir)/build-aux/depcomp \
596 $(srcdir)/build-aux/install-sh \
597 $(srcdir)/build-aux/missing \
598 $(srcdir)/build-aux/mkinstalldirs \
599 $(srcdir)/src/ansi2knr.c
600 automake_repo=:pserver:anoncvs:anoncvs@sources.redhat.com:/cvs/automake
602 wget-update: $(get-targets)
607 for f in $(cvs_files); do \
608 test -f $$f || { echo "*** skipping $$f" 1>&2; continue; }; \
609 cvs diff $$f > /dev/null \
610 || { echo "*** $$f is locally modified; skipping it" 1>&2; \
611 fail=yes; continue; }; \
612 file=$$(basename $$f); \
613 echo checking out $$file...; \
614 $(CVS) -d $(automake_repo) co -p automake/lib/$$file> $$f.t \
615 && $(move_if_change) $$f.t $$f; \
617 test "$$fail" && exit 1
619 emit_upload_commands:
620 @echo =====================================
621 @echo =====================================
622 @echo "$(srcdir)/gnupload $(GNUPLOADFLAGS) \\"
623 @echo " --to $(gnu_rel_host):coreutils \\"
624 @echo " $(rel-files)"
625 @echo '# send the /tmp/announcement e-mail'
626 @echo =====================================
627 @echo =====================================
629 $(xd-delta): $(release_archive_dir)/$(prev-tgz) $(distdir).tar.gz
630 xdelta delta -9 $^ $@ || :
632 .PHONY: alpha beta major
633 alpha beta major: news-date-check $(local-check)
636 $(MAKE) -s announcement RELEASE_TYPE=$@ > /tmp/announce-$(my_distdir)
637 ln $(rel-files) $(release_archive_dir)
638 chmod a-w $(rel-files)
639 $(MAKE) -s emit_upload_commands RELEASE_TYPE=$@
640 echo $(VERSION) > $(prev_version_file)
641 $(CVS) ci -m. $(prev_version_file)