X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=top%2Fmaint.mk;h=7d84b6c3b58a1410810a505e387b7dedfb12d806;hb=c268928a8e8b9d805e4d215c410937b21f288c8c;hp=3452a1588c338ec3abd0b1cda94d7b28b602d9c6;hpb=00b2f10b68593189be4eb1affd88de33a8e92fb3;p=gnulib.git diff --git a/top/maint.mk b/top/maint.mk index 3452a1588..7d84b6c3b 100644 --- a/top/maint.mk +++ b/top/maint.mk @@ -2,7 +2,7 @@ # This Makefile fragment tries to be general-purpose enough to be # used by many projects via the gnulib maintainer-makefile module. -## Copyright (C) 2001-2009 Free Software Foundation, Inc. +## Copyright (C) 2001-2010 Free Software Foundation, Inc. ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -30,16 +30,38 @@ gzip_rsyncable := \ $(shell gzip --help 2>/dev/null|grep rsyncable >/dev/null && echo --rsyncable) GZIP_ENV = '--no-name --best $(gzip_rsyncable)' -# cfg.mk must define the gpg_key_ID used by this package. GIT = git VC = $(GIT) VC-tag = git tag -s -m '$(VERSION)' -u '$(gpg_key_ID)' VC_LIST = $(build_aux)/vc-list-files -C $(srcdir) +# You can override this variable in cfg.mk to set your own regexp +# matching files to ignore. +VC_LIST_ALWAYS_EXCLUDE_REGEX ?= ^$$ + +# This is to preprocess robustly the output of $(VC_LIST), so that even +# when $(srcdir) is a pathological name like "....", the leading sed command +# removes only the intended prefix. +_dot_escaped_srcdir = $(subst .,\.,$(srcdir)) + +# Post-process $(VC_LIST) output, prepending $(srcdir)/, but only +# when $(srcdir) is not ".". +ifeq ($(srcdir),.) +_prepend_srcdir_prefix = +else +_prepend_srcdir_prefix = | sed 's|^|$(srcdir)/|' +endif + +# In order to be able to consistently filter "."-relative names, +# (i.e., with no $(srcdir) prefix), this definition is careful to +# remove any $(srcdir) prefix, and to restore what it removes. VC_LIST_EXCEPT = \ - $(VC_LIST) | if test -f $(srcdir)/.x-$@; then grep -vEf $(srcdir)/.x-$@; \ - else grep -Ev "$${VC_LIST_EXCEPT_DEFAULT-ChangeLog}"; fi + $(VC_LIST) | sed 's|^$(_dot_escaped_srcdir)/||' \ + | if test -f $(srcdir)/.x-$@; then grep -vEf $(srcdir)/.x-$@; \ + else grep -Ev -e "$${VC_LIST_EXCEPT_DEFAULT-ChangeLog}"; fi \ + | grep -Ev -e '$(VC_LIST_ALWAYS_EXCLUDE_REGEX)' \ + $(_prepend_srcdir_prefix) ifeq ($(origin prev_version_file), undefined) prev_version_file = $(srcdir)/.prev-version @@ -63,6 +85,25 @@ my_distdir = $(PACKAGE)-$(VERSION) # Old releases are stored here. release_archive_dir ?= ../release +# Override gnu_rel_host and url_dir_list in cfg.mk if these are not right. +# Use alpha.gnu.org for alpha and beta releases. +# Use ftp.gnu.org for stable releases. +gnu_ftp_host-alpha = alpha.gnu.org +gnu_ftp_host-beta = alpha.gnu.org +gnu_ftp_host-stable = ftp.gnu.org +gnu_rel_host ?= $(gnu_ftp_host-$(RELEASE_TYPE)) + +ifeq ($(gnu_rel_host),ftp.gnu.org) +url_dir_list ?= http://ftpmirror.gnu.org/$(PACKAGE) +else +url_dir_list ?= ftp://$(gnu_rel_host)/gnu/$(PACKAGE) +endif + +# Override this in cfg.mk if you are using a different format in your +# NEWS file. +today = $(shell date +%Y-%m-%d) +news-check-regexp ?= '^\*.* $(VERSION_REGEXP) \($(today)\)' + # Prevent programs like 'sort' from considering distinct strings to be equal. # Doing it here saves us from having to set LC_ALL elsewhere in this file. export LC_ALL = C @@ -84,7 +125,9 @@ local-checks-available = \ # Arrange to print the name of each syntax-checking rule just before running it. $(syntax-check-rules): %: %.m -$(patsubst %, %.m, $(syntax-check-rules)): +sc_m_rules_ = $(patsubst %, %.m, $(syntax-check-rules)) +.PHONY: $(sc_m_rules_) +$(sc_m_rules_): @echo $(patsubst sc_%.m, %, $@) local-check := $(filter-out $(local-checks-to-skip), $(local-checks-available)) @@ -293,6 +336,11 @@ sc_prohibit_inttostr_without_use: $(_header_without_use) # Don't include this header unless you use one of its functions. +sc_prohibit_ignore_value_without_use: + @h='"ignore-value.h"' re='\new(file => "/dev/stdin")->as_string'|sed 's/\?://g' # Note this was produced by the above: -# _xa1 = x(alloc_(oversized|die)|([cz]|2?re)alloc|m(alloc|emdup)|strdup) -# But we can do better: -_xa1 = x(alloc_(oversized|die)|([cmz]|2?re)alloc|(mem|str)dup) +# _xa1 = \ +#x(((2n?)?re|c(har)?|n(re|m)|z)alloc|alloc_(oversized|die)|m(alloc|emdup)|strdup) +# But we can do better, in at least two ways: +# 1) take advantage of two "dup"-suffixed strings: +# x(((2n?)?re|c(har)?|n(re|m)|[mz])alloc|alloc_(oversized|die)|(mem|str)dup) +# 2) notice that "c(har)?|[mz]" is equivalent to the shorter and more readable +# "char|[cmz]" +# x(((2n?)?re|char|n(re|m)|[cmz])alloc|alloc_(oversized|die)|(mem|str)dup) +_xa1 = x(((2n?)?re|char|n(re|m)|[cmz])alloc|alloc_(oversized|die)|(mem|str)dup) _xa2 = X([CZ]|N?M)ALLOC sc_prohibit_xalloc_without_use: @h='"xalloc.h"' \ re='\<($(_xa1)|$(_xa2)) *\('\ $(_header_without_use) +# Extract function names: +# perl -lne '/^(?:extern )?(?:void|char) \*?(\w+) \(/ and print $1' lib/hash.h +_hash_re = \ +clear|delete|free|get_(first|next)|insert|lookup|print_statistics|reset_tuning +_hash_fn = \<($(_hash_re)) *\( +_hash_struct = (struct )?\<[Hh]ash_(table|tuning)\> +sc_prohibit_hash_without_use: + @h='"hash.h"' \ + re='$(_hash_fn)|$(_hash_struct)'\ + $(_header_without_use) + +sc_prohibit_hash_pjw_without_use: + @h='"hash-pjw.h"' \ + re='\ /dev/null \ || { fail=1; echo 1>&2 "$(ME): $$p uses proper_name_utf8"; }; \ @@ -526,7 +609,8 @@ sc_const_long_option: NEWS_hash = \ $$(sed -n '/^\*.* $(PREV_VERSION_REGEXP) ([0-9-]*)/,$$p' \ $(srcdir)/NEWS \ - | grep -v '^Copyright .*Free Software' \ + | perl -0777 -pe \ + 's/^Copyright.+?Free\sSoftware\sFoundation,\sInc\.\n//ms' \ | md5sum - \ | sed 's/ .*//') @@ -548,19 +632,22 @@ update-NEWS-hash: NEWS # to emit a definition for each substituted variable. # We use perl rather than "grep -nE ..." to exempt a single # use of an @...@-delimited variable name in src/Makefile.am. -sc_makefile_check: - @perl -ne '/\@[A-Z_0-9]+\@/ && !/^cu_install_program =/' \ +# Allow the package to add exceptions via a hook in cfg.mk; +# for example, @PRAGMA_SYSTEM_HEADER@ can be permitted by +# setting this to ' && !/PRAGMA_SYSTEM_HEADER/'. +_makefile_at_at_check_exceptions ?= +sc_makefile_at_at_check: + @perl -ne '/\@[A-Z_0-9]+\@/'$(_makefile_at_at_check_exceptions) \ -e 'and (print "$$ARGV:$$.: $$_"), $$m=1; END {exit !$$m}' \ $$($(VC_LIST_EXCEPT) | grep -E '(^|/)Makefile\.am$$') \ && { echo '$(ME): use $$(...), not @...@' 1>&2; exit 1; } || : -news-date-check: NEWS - today=`date +%Y-%m-%d`; \ - if head $(srcdir)/NEWS | grep '^\*.* $(VERSION_REGEXP) ('$$today')' \ +news-check: NEWS + if head $(srcdir)/NEWS | grep -E $(news-check-regexp) \ >/dev/null; then \ :; \ else \ - echo "version or today's date is not in NEWS" 1>&2; \ + echo 'NEWS: $$(news-check-regexp) failed to match' 1>&2; \ exit 1; \ fi @@ -654,6 +741,27 @@ sc_copyright_check: exit 1; }; \ fi +# #if HAVE_... will evaluate to false for any non numeric string. +# That would be flagged by using -Wundef, however gnulib currently +# tests many undefined macros, and so we can't enable that option. +# So at least preclude common boolean strings as macro values. +sc_Wundef_boolean: + @grep -Ei '^#define.*(yes|no|true|false)$$' '$(CONFIG_INCLUDE)' && \ + { echo 'Use 0 or 1 for macro values' 1>&2; exit 1; } || : + +sc_vulnerable_makefile_CVE-2009-4029: + @files=$$(find $(srcdir) -name Makefile.in); \ + if test -n "$$files"; then \ + grep -E \ + 'perm -777 -exec chmod a\+rwx|chmod 777 \$$\(distdir\)' \ + $$files && \ + { echo '$(ME): the above files are vulnerable; beware of' \ + 'running "make dist*" rules, and upgrade to fixed automake' \ + 'see http://bugzilla.redhat.com/542609 for details' \ + 1>&2; exit 1; } || :; \ + else :; \ + fi + vc-diff-check: (unset CDPATH; cd $(srcdir) && $(VC) diff) > vc-diffs || : if test -s vc-diffs; then \ @@ -664,23 +772,19 @@ vc-diff-check: rm vc-diffs; \ fi -# Use this to make sure we don't run these programs when building -# from a virgin tgz file, below. -null_AM_MAKEFLAGS = \ - ACLOCAL=false \ - AUTOCONF=false \ - AUTOMAKE=false \ - AUTOHEADER=false \ - MAKEINFO=false - -built_programs = $$(cd src && MAKEFLAGS= $(MAKE) -s built_programs.list) - rel-files = $(DIST_ARCHIVES) gnulib_dir ?= $(srcdir)/gnulib gnulib-version = $$(cd $(gnulib_dir) && git describe) bootstrap-tools ?= autoconf,automake,gnulib +# If it's not already specified, derive the GPG key ID from +# the signed tag we've just applied to mark this release. +gpg_key_ID ?= \ + $$(git cat-file tag v$(VERSION) > .ann-sig \ + && gpgv .ann-sig - < /dev/null 2>&1 \ + | sed -n '/.*key ID \([0-9A-F]*\)/s//\1/p'; rm -f .ann-sig) + announcement: NEWS ChangeLog $(rel-files) @$(build_aux)/announce-gen \ --release-type=$(RELEASE_TYPE) \ @@ -688,7 +792,7 @@ announcement: NEWS ChangeLog $(rel-files) --prev=$(PREV_VERSION) \ --curr=$(VERSION) \ --gpg-key-id=$(gpg_key_ID) \ - --news=NEWS \ + --news=$(srcdir)/NEWS \ --bootstrap-tools=$(bootstrap-tools) \ --gnulib-version=$(gnulib-version) \ --no-print-checksums \ @@ -701,13 +805,14 @@ announcement: NEWS ChangeLog $(rel-files) ftp-gnu = ftp://ftp.gnu.org/gnu www-gnu = http://www.gnu.org +upload_dest_dir_ ?= $(PACKAGE) emit_upload_commands: @echo ===================================== @echo ===================================== @echo "$(build_aux)/gnupload $(GNUPLOADFLAGS) \\" - @echo " --to $(gnu_rel_host):$(PACKAGE) \\" + @echo " --to $(gnu_rel_host):$(upload_dest_dir_) \\" @echo " $(rel-files)" - @echo '# send the /tmp/announcement e-mail' + @echo '# send the ~/announce-$(my_distdir) e-mail' @echo ===================================== @echo ===================================== @@ -740,20 +845,30 @@ alpha beta stable: $(local-check) writable-files no-submodule-changes || { echo "invalid version string: $(VERSION)" 1>&2; exit 1;};}\ || : $(MAKE) vc-diff-check - $(MAKE) news-date-check + $(MAKE) news-check $(MAKE) distcheck $(MAKE) dist XZ_OPT=-9ev - $(MAKE) -s announcement RELEASE_TYPE=$@ > /tmp/announce-$(my_distdir) + $(MAKE) $(release-prep-hook) RELEASE_TYPE=$@ + $(MAKE) -s emit_upload_commands RELEASE_TYPE=$@ + +# Override this in cfg.mk if you follow different procedures. +release-prep-hook ?= release-prep + +.PHONY: release-prep +release-prep: + case $$RELEASE_TYPE in alpha|beta|stable) ;; \ + *) echo "invalid RELEASE_TYPE: $$RELEASE_TYPE" 1>&2; exit 1;; esac + $(MAKE) -s announcement > ~/announce-$(my_distdir) if test -d $(release_archive_dir); then \ ln $(rel-files) $(release_archive_dir); \ chmod a-w $(rel-files); \ fi - $(MAKE) -s emit_upload_commands RELEASE_TYPE=$@ echo $(VERSION) > $(prev_version_file) $(MAKE) update-NEWS-hash perl -pi -e '$$. == 3 and print "$(noteworthy)\n\n\n"' NEWS $(emit-commit-log) > .ci-msg $(VC) commit -F .ci-msg -a + rm .ci-msg .PHONY: web-manual web-manual: