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 3 of the License, or
10 # (at your option) any later version.
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, see <http://www.gnu.org/licenses/>.
20 # This is reported not to work with make-3.79.1
21 # ME := $(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
24 # Do not save the original name or timestamp in the .tar.gz file.
25 # Use --rsyncable if available.
27 (gzip --help|grep rsyncable) >/dev/null 2>&1 && echo --rsyncable
28 GZIP_ENV = "--no-name --best `$(gzip_rsyncable)`"
32 # cvsu is part of the cvsutils package: http://www.red-bean.com/cvsutils/
34 if test -x $(srcdir)/build-aux/cvsu; then \
35 $(srcdir)/build-aux/cvsu --find --types=AFGM $$*; \
38 if (!$$1 && $$3 !~ /^-/) { \
40 sub(/CVS\/Entries/, "", f); \
43 $$(find $${*-*} -name Entries -print) /dev/null; \
48 $(CVS_LIST) | if test -f .x-$@; then grep -vEf .x-$@; else grep -v ChangeLog; fi
50 ifeq ($(origin prev_version_file), undefined)
51 prev_version_file = .prev-version
54 PREV_VERSION := $(shell cat $(prev_version_file))
55 VERSION_REGEXP = $(subst .,\.,$(VERSION))
57 tag-package = $(shell echo "$(PACKAGE)" | tr '[:lower:]' '[:upper:]')
58 tag-this-version = $(subst .,_,$(VERSION))
59 this-cvs-tag = $(tag-package)-$(tag-this-version)
60 my_distdir = $(PACKAGE)-$(VERSION)
62 # Old releases are stored here.
63 # Used for diffs and xdeltas.
64 release_archive_dir ?= ../release
66 # Prevent programs like 'sort' from considering distinct strings to be equal.
67 # Doing it here saves us from having to set LC_ALL elsewhere in this file.
76 # FIXME: add a check to prohibit definition in src/*.c of symbols defined
77 # in system.h. E.g. today I removed from tail.c a useless definition of
78 # ENOSYS. It was useless because system.h ensures it's defined.
80 # Checks that don't require cvs.
81 # Run `changelog-check' last, as previous test may reveal problems requiring
82 # new ChangeLog entries.
83 local-checks-available = \
84 po-check copyright-check writable-files m4-check author_mark_check \
85 changelog-check strftime-check $(syntax-check-rules) \
86 makefile_path_separator_check \
88 .PHONY: $(local-checks-available)
90 local-check = $(filter-out $(local-checks-to-skip), $(local-checks-available))
92 .PHONY: $(syntax-check-rules)
93 syntax-check-rules = \
94 sc_cast_of_argument_to_free \
95 sc_cast_of_x_alloc_return_value \
96 sc_cast_of_alloca_return_value \
98 sc_dd_max_sym_length \
99 sc_error_exit_success \
101 sc_no_if_have_config_h \
102 sc_obsolete_symbols \
103 sc_prohibit_atoi_atof \
104 sc_prohibit_jm_in_m4 \
105 sc_prohibit_assert_without_use \
106 sc_require_config_h \
110 sc_system_h_headers \
113 sc_two_space_separator_in_usage \
114 sc_unmarked_diagnostics \
115 sc_useless_cpp_parens
117 syntax-check: $(syntax-check-rules)
118 # @grep -nE '# *include <(limits|std(def|arg|bool))\.h>' \
119 # $$(find -type f -name '*.[chly]') && \
120 # { echo '$(ME): found conditional include' 1>&2; \
123 # grep -nE '^# *include <(string|stdlib)\.h>' \
124 # $(srcdir)/{lib,src}/*.[chy] && \
125 # { echo '$(ME): FIXME' 1>&2; \
127 # FIXME: don't allow `#include .strings\.h' anywhere
129 sc_cast_of_argument_to_free:
130 @grep -nE '\<free \(\(' $(srcdir)/{lib,src}/*.[chly] && \
131 { echo '$(ME): don'\''t cast free argument' 1>&2; \
134 sc_cast_of_x_alloc_return_value:
135 @grep -nE --exclude=$(srcdir)/lib/regex.c \
136 '\*\) *x(m|c|re)alloc\>' \
137 $(srcdir)/{lib,src}/*.[chy] && \
138 { echo '$(ME): don'\''t cast x*alloc return value' 1>&2; \
141 sc_cast_of_alloca_return_value:
142 @grep -nE '\*\) *alloca\>' \
143 $(srcdir)/src/*.[chy] && \
144 { echo '$(ME): don'\''t cast alloca return value' 1>&2; \
148 @grep -n '[ ] ' $$($(CVS_LIST_EXCEPT)) && \
149 { echo '$(ME): found SPACE-TAB sequence; remove the SPACE' \
152 # Don't use the old ato* functions in `real' code.
153 # They provide no error checking mechanism.
154 # Instead, use strto* functions.
155 sc_prohibit_atoi_atof:
156 @grep -nE '\<ato([filq]|ll)\>' $$($(CVS_LIST_EXCEPT)) && \
157 { echo '$(ME): do not use ato''f, ato''i, ato''l, ato''ll, or ato''q' \
160 # Using EXIT_SUCCESS as the first argument to error is misleading,
161 # since when that parameter is 0, error does not exit. Use `0' instead.
162 sc_error_exit_success:
163 @grep -nF 'error (EXIT_SUCCESS,' \
164 $$(find -type f -name '*.[chly]') && \
165 { echo '$(ME): found error (EXIT_SUCCESS' 1>&2; \
169 @grep -ni 'file''system' $$($(CVS_LIST_EXCEPT)) && \
170 { echo '$(ME): found use of "file''system";' \
171 'rewrite to use "file system"' 1>&2; \
174 sc_no_if_have_config_h:
175 @grep -n '^# *if HAVE_CONFIG_H' $$($(CVS_LIST_EXCEPT)) && \
176 { echo '$(ME): found use of #if HAVE_CONFIG_H; use #ifdef' \
179 # Nearly all .c files must include <config.h>.
181 @grep -L '^# *include <config\.h>' \
182 $$($(CVS_LIST_EXCEPT) | grep '\.c$$') \
184 { echo '$(ME): the above files do not include <config.h>' \
187 # Prohibit the inclusion of assert.h without an actual use of assert.
188 sc_prohibit_assert_without_use:
189 @files=$$(grep -l '# *include <assert\.h>' \
190 $$($(CVS_LIST_EXCEPT) | grep '\.c$$')) && \
191 grep -L '\<assert (' $$files \
193 { echo "$(ME): the above files include <assert.h> but don't use it" \
197 @grep -nE '\<(HAVE''_FCNTL_H|O''_NDELAY)\>' \
198 $$($(CVS_LIST_EXCEPT)) && \
199 { echo '$(ME): do not use HAVE''_FCNTL_H or O''_NDELAY' \
202 # FIXME: warn about definitions of EXIT_FAILURE, EXIT_SUCCESS, STREQ
204 # Each nonempty line must start with a year number, or a TAB.
206 @grep -n '^[^12 ]' $$(find . -maxdepth 2 -name ChangeLog) && \
207 { echo '$(ME): found unexpected prefix in a ChangeLog' 1>&2; \
210 # Ensure that dd's definition of LONGEST_SYMBOL stays in sync
211 # with the strings from the two affected variables.
212 dd_c = $(srcdir)/src/dd.c
213 sc_dd_max_sym_length:
214 ifneq ($(wildcard $(dd_c)),)
215 @len=$$( (sed -n '/conversions\[\] =$$/,/^};/p' $(dd_c);\
216 sed -n '/flags\[\] =$$/,/^};/p' $(dd_c) ) \
217 |sed -n '/"/s/^[^"]*"\([^"]*\)".*/\1/p' \
218 | wc --max-line-length); \
219 max=$$(sed -n '/^#define LONGEST_SYMBOL /s///p' $(dd_c) \
220 |tr -d '"' | wc --max-line-length); \
221 if test "$$len" = "$$max"; then :; else \
222 echo 'dd.c: LONGEST_SYMBOL is not longest' 1>&2; \
227 # Many m4 macros names once began with `jm_'.
228 # On 2004-04-13, they were all changed to start with gl_ instead.
229 # Make sure that none are inadvertently reintroduced.
230 sc_prohibit_jm_in_m4:
231 @grep -nE 'jm_[A-Z]' \
232 $$($(CVS_LIST) $(srcdir)/m4 |grep '\.m4$$') && \
233 { echo '$(ME): do not use jm_ in m4 macro names' \
237 @t1=sc-root.expected; t2=sc-root.actual; \
238 grep -nl '^PRIV_CHECK_ARG=require-root' \
239 $$($(CVS_LIST) tests) |sed s,tests,., |sort > $$t1; \
240 sed -n 's, cd \([^ ]*\) .*MAKE..check TESTS=\(.*\),./\1/\2,p' \
241 $(srcdir)/tests/Makefile.am |sort > $$t2; \
242 diff -u $$t1 $$t2 || diff=1; \
245 && { echo 'tests/Makefile.am: missing check-root action'>&2; \
248 # Create a list of regular expressions matching the names
249 # of files included from system.h. Exclude a couple.
251 @sed -n '/^# *include /s///p' $(srcdir)/src/system.h \
252 | grep -Ev 'sys/(param|file)\.h' \
253 | sed 's/ .*//;;s/^["<]/^# *include [<"]/;s/\.h[">]$$/\\.h[">]/' \
257 # Files in src/ should not include directly any of
258 # the headers already included via system.h.
259 sc_system_h_headers: .re-list
260 @if test -f $(srcdir)/src/system.h; then \
261 trap 'rc=$$?; rm -f .re-list; exit $$rc' 0 1 2 3 15; \
262 grep -nE -f .re-list \
263 $$($(CVS_LIST) src | \
264 grep -Ev '((copy|system)\.h|parse-gram\.c)$$') \
265 && { echo '$(ME): the above are already included via system.h'\
266 1>&2; exit 1; } || :; \
271 'solaris[^[:alnum:]]*2\.(7|8|9|[1-9][0-9])|sunos[^[:alnum:]][6-9]' \
272 $$($(CVS_LIST_EXCEPT)) && \
273 { echo '$(ME): found misuse of Sun OS version numbers' 1>&2; \
280 @grep -n '[ ]$$' $$($(CVS_LIST_EXCEPT)) && \
281 { echo '$(ME): found trailing blank(s)' \
284 sc_two_space_separator_in_usage:
285 @grep -n '^ *--[a-z][0-9A-Za-z-]* [^ ].*\\$$' \
286 $$($(CVS_LIST_EXCEPT)) && \
287 { echo "$(ME): help2man requires at least two spaces between"; \
288 echo "$(ME): an option and its description"; \
291 # Look for diagnostics that aren't marked for translation.
292 # This won't find any for which error's format string is on a separate line.
293 sc_unmarked_diagnostics:
295 '\<error \([^"]*"[^"]*[a-z]{3}' $$($(CVS_LIST_EXCEPT)) \
296 | grep -v '_''(' && \
297 { echo '$(ME): found unmarked diagnostic(s)' 1>&2; \
300 # Avoid useless parentheses like those in this example:
301 # #if defined (SYMBOL) || defined (SYM2)
302 sc_useless_cpp_parens:
303 @grep -n '^# *if .*defined *(' $$($(CVS_LIST_EXCEPT)) && \
304 { echo '$(ME): found useless parentheses in cpp directive' \
307 # Ensure that date's --help output stays in sync with the info
308 # documentation for GNU strftime. The only exception is %N,
309 # which date accepts but GNU strftime does not.
310 extract_char = sed 's/^[^%][^%]*%\(.\).*/\1/'
312 if test -f $(srcdir)/src/date.c; then \
313 grep '^ %. ' $(srcdir)/src/date.c | sort \
314 | $(extract_char) > $@-src; \
316 info libc date calendar format | grep '^ `%.'\' \
317 | $(extract_char); } | sort > $@-info; \
318 diff -u $@-src $@-info || exit 1; \
319 rm -f $@-src $@-info; \
322 # Ensure that we use only the standard $(VAR) notation,
323 # not @...@ in Makefile.am, now that we can rely on automake
324 # to emit a definition for each substituted variable.
326 grep -nE '@[A-Z_0-9]+@' `find . -name Makefile.am` \
327 && { echo 'Makefile.maint: use $$(...), not @...@' 1>&2; exit 1; } || :
329 news-date-check: NEWS
330 today=`date +%Y-%m-%d`; \
331 if head NEWS | grep '^\*.* $(VERSION_REGEXP) ('$$today')' \
335 echo "version or today's date is not in NEWS" 1>&2; \
340 if head ChangeLog | grep 'Version $(VERSION_REGEXP)\.$$' \
344 echo "$(VERSION) not in ChangeLog" 1>&2; \
349 @grep -n 'AC_DEFUN([^[]' m4/*.m4 \
350 && { echo 'Makefile.maint: quote the first arg to AC_DEFUN' 1>&2; \
353 # Verify that all source files using _() are listed in po/POTFILES.in.
354 # FIXME: don't hard-code file names below; use a more general mechanism.
356 if test -f po/POTFILES.in; then \
357 grep -E -v '^(#|$$)' po/POTFILES.in \
358 | grep -v '^src/false\.c$$' | sort > $@-1; \
360 for file in $$($(CVS_LIST_EXCEPT)) lib/*.[ch]; do \
362 djgpp/* | man/*) continue;; \
366 base=`expr " $$file" : ' \(.*\)\..'`; \
367 { test -f $$base.l || test -f $$base.y; } && continue;; \
369 files="$$files $$file"; \
371 grep -E -l '\bN?_\([^)"]*("|$$)' $$files | sort -u > $@-2; \
372 diff -u $@-1 $@-2 || exit 1; \
376 # In a definition of #define AUTHORS "... and ..." where the RHS contains
377 # the English word `and', the string must be marked with `N_ (...)' so that
378 # gettext recognizes it as a string requiring translation.
380 @grep -n '^# *define AUTHORS "[^"]* and ' src/*.c |grep -v ' N_ (' && \
381 { echo 'Makefile.maint: enclose the above strings in N_ (...)' 1>&2; \
384 # Sometimes it is useful to change the PATH environment variable
385 # in Makefiles. When doing so, it's better not to use the Unix-centric
386 # path separator of `:', but rather the automake-provided `@PATH_SEPARATOR@'.
387 # It'd be better to use `find -print0 ...|xargs -0 ...', but less portable,
388 # and there probably aren't many projects with so many Makefile.am files
389 # that we'd have to worry about limits on command line length.
390 msg = 'Makefile.maint: Do not use `:'\'' above; use @PATH_SEPARATOR@ instead'
391 makefile_path_separator_check:
392 @grep -n 'PATH=.*:' `find $(srcdir) -name Makefile.am` \
393 && { echo $(msg) 1>&2; exit 1; } || :
395 # Check that `make alpha' will not fail at the end of the process.
397 if test -d $(release_archive_dir); then :; else \
398 mkdir $(release_archive_dir); \
400 for file in $(distdir).tar.gz $(xd-delta) \
401 $(release_archive_dir)/$(distdir).tar.gz \
402 $(release_archive_dir)/$(xd-delta); do \
403 test -e $$file || continue; \
405 || { echo ERROR: $$file is not writable; fail=1; }; \
407 test "$$fail" && exit 1 || :
409 v_etc_file = lib/version-etc.c
410 # Make sure that the copyright date in $(v_etc_file) is up to date.
412 @if test -f $(v_etc_file); then \
413 grep 'enum { COPYRIGHT_YEAR = '$$(date +%Y)' };' $(v_etc_file) \
415 || { echo 'out of date copyright in $(v_etc_file); update it' 1>&2; \
420 # Sanity checks with the CVS repository.
422 echo $(this-cvs-tag); \
423 if $(CVS) -n log -h README | grep -e $(this-cvs-tag): >/dev/null; then \
424 echo "$(this-cvs-tag) as already been used; not tagging" 1>&2; \
429 if $(CVS) diff >cvs-diffs; then \
432 echo "Some files are locally modified:" 1>&2; \
437 cvs-check: cvs-diff-check cvs-tag-check
439 maintainer-distcheck: changelog-check
444 # Tag before making distribution. Also, don't make a distribution if
445 # checks fail. Also, make sure the NEWS file is up-to-date.
446 # FIXME: use dist-hook/my-dist like distcheck-hook/my-distcheck.
447 cvs-dist: $(local-check) cvs-check maintainer-distcheck
449 $(CVS) tag -c $(this-cvs-tag)
452 # Use this to make sure we don't run these programs when building
453 # from a virgin tgz file, below.
454 null_AM_MAKEFLAGS = \
461 # Detect format-string/arg-list mismatches that would normally be obscured
462 # by the use of _(). The --disable-nls effectively defines away that macro,
463 # and building with CFLAGS='-Wformat -Werror' causes any format warning to be
464 # treated as a failure. Also, check for shadowing problems with -Wshadow.
465 # These CFLAGS are pretty strict. If you build this target, you probably
466 # have to have a recent version of gcc and glibc headers.
468 t=$(TMPDIR)/$(PACKAGE)/test
469 my-distcheck: $(local-check) $(release_archive_dir)/$(prev-tgz)
472 GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
474 && ./configure --disable-nls \
475 && $(MAKE) CFLAGS='-Werror -Wall -Wformat -Wshadow' \
476 AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)' \
480 (cd $(t) && mv $(distdir) $(distdir).old \
481 && $(AMTAR) -zxf - ) < $(distdir).tar.gz
482 diff -ur $(t)/$(distdir).old $(t)/$(distdir)
484 @echo "========================"; \
485 echo "$(distdir).tar.gz is ready for distribution"; \
486 echo "========================"
492 tarz=/tmp/rel-check-tarz-$$$$; \
493 md5_tmp=/tmp/rel-check-md5-$$$$; \
495 trap 'status=$$?; rm -f $$tarz $$md5_tmp; exit $$status' 0 1 2 3 15; \
496 $(WGET) $(WGETFLAGS) -q --output-document=$$tarz $(url); \
497 echo "$(md5) -" > $$md5_tmp; \
498 md5sum -c $$md5_tmp < $$tarz
500 prev-tgz = $(PACKAGE)-$(PREV_VERSION).tar.gz
501 xd-delta = $(PACKAGE)-$(PREV_VERSION)-$(VERSION).xdelta
503 rel-files = $(xd-delta) $(DIST_ARCHIVES)
504 announcement: NEWS ChangeLog $(rel-files)
506 --release-type=$(RELEASE_TYPE) \
507 --package=$(PACKAGE) \
508 --prev=$(PREV_VERSION) \
510 --release-archive-directory=$(release_archive_dir) \
511 --gpg-key-id=$(gpg_key_ID) \
513 $(addprefix --url-dir=, $(url_dir_list)) \
516 ## ---------------- ##
517 ## Updating files. ##
518 ## ---------------- ##
520 ftp-gnu = ftp://ftp.gnu.org/gnu
521 www-gnu = http://www.gnu.org
523 # Use mv, if you don't have/want move-if-change.
524 move_if_change ?= move-if-change
527 # --------------------- #
528 # Updating everything. #
529 # --------------------- #
532 local_updates ?= wget-update cvs-update po-update
533 update: $(local_updates)
536 # ------------------- #
537 # Updating PO files. #
538 # ------------------- #
540 po_repo = http://www.iro.umontreal.ca/contrib/po/maint/$(PACKAGE)
541 .PHONY: do-po-update po-update
543 tmppo=/tmp/$(PACKAGE)-$(VERSION)-po &&\
547 $(WGET) $(WGETFLAGS) -r -l1 -nd --no-parent -A '*.po' $(po_repo)) &&\
549 cd po && $(MAKE) update-po
553 if test -d "po"; then \
554 $(MAKE) do-po-update; \
557 # -------------------------- #
558 # Updating GNU build tools. #
559 # -------------------------- #
561 # The following pseudo table associates a local directory and a URL
562 # with each of the files that belongs to some other package and is
563 # regularly updated from the specified URL.
565 $(srcdir)/build-aux/config.guess \
566 $(srcdir)/build-aux/config.sub \
567 $(srcdir)/build-aux/texinfo.tex \
568 $(srcdir)/src/ansi2knr.c
570 get-targets = $(patsubst %, get-%, $(wget_files))
572 config.guess-url_prefix = $(ftp-gnu)/build-aux/
573 config.sub-url_prefix = $(ftp-gnu)/build-aux/
575 ansi2knr.c-url_prefix = ftp://ftp.cs.wisc.edu/ghost/
577 texinfo.tex-url_prefix = $(ftp-gnu)/texinfo/
579 standards.texi-url_prefix = $(www-gnu)/prep/
580 make-stds.texi-url_prefix = $(standards.texi-url_prefix)
582 target = $(patsubst get-%, %, $@)
583 url = $($(notdir $(target))-url_prefix)$(notdir $(target))
585 .PHONY: $(get-targets)
587 $(WGET) $(WGETFLAGS) $(url) -O $(target).t \
588 && $(move_if_change) $(target).t $(target)
591 $(srcdir)/build-aux/depcomp \
592 $(srcdir)/build-aux/install-sh \
593 $(srcdir)/build-aux/missing \
594 $(srcdir)/build-aux/mkinstalldirs \
595 $(srcdir)/src/ansi2knr.c
596 automake_repo=:pserver:anoncvs:anoncvs@sources.redhat.com:/cvs/automake
598 wget-update: $(get-targets)
603 for f in $(cvs_files); do \
604 test -f $$f || { echo "*** skipping $$f" 1>&2; continue; }; \
605 cvs diff $$f > /dev/null \
606 || { echo "*** $$f is locally modified; skipping it" 1>&2; \
607 fail=yes; continue; }; \
608 file=$$(basename $$f); \
609 echo checking out $$file...; \
610 $(CVS) -d $(automake_repo) co -p automake/lib/$$file> $$f.t \
611 && $(move_if_change) $$f.t $$f; \
613 test "$$fail" && exit 1
615 emit_upload_commands:
616 @echo =====================================
617 @echo =====================================
618 @echo "$(srcdir)/gnupload $(GNUPLOADFLAGS) \\"
619 @echo " --to $(gnu_rel_host):coreutils \\"
620 @echo " $(rel-files)"
621 @echo '# send the /tmp/announcement e-mail'
622 @echo =====================================
623 @echo =====================================
625 $(xd-delta): $(release_archive_dir)/$(prev-tgz) $(distdir).tar.gz
626 xdelta delta -9 $^ $@ || :
628 .PHONY: alpha beta major
629 alpha beta major: news-date-check $(local-check)
632 $(MAKE) -s announcement RELEASE_TYPE=$@ > /tmp/announce-$(my_distdir)
633 ln $(rel-files) $(release_archive_dir)
634 chmod a-w $(rel-files)
635 $(MAKE) -s emit_upload_commands RELEASE_TYPE=$@
636 echo $(VERSION) > $(prev_version_file)
637 $(CVS) ci -m. $(prev_version_file)