1 # Maintainer makefile rules for Automake.
3 # Copyright (C) 1995-2012 Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 # --------------------------------------------------------- #
19 # Automatic generation of the ChangeLog from git history. #
20 # --------------------------------------------------------- #
22 gitlog_to_changelog_command = $(PERL) $(srcdir)/lib/gitlog-to-changelog
23 gitlog_to_changelog_fixes = $(srcdir)/.git-log-fix
24 gitlog_to_changelog_options = --amend=$(gitlog_to_changelog_fixes) \
25 --since='2011-12-28 00:00:00' \
26 --no-cluster --format '%s%n%n%b'
28 EXTRA_DIST += lib/gitlog-to-changelog
29 EXTRA_DIST += $(gitlog_to_changelog_fixes)
31 # When executed from a git checkout, generate the ChangeLog from the git
32 # history. When executed from an extracted distribution tarball, just
33 # copy the distributed ChangeLog in the build directory (and if this
34 # fails, or if no distributed ChangeLog file is present, complain and
37 # We need the apparently useless dependency from another .PHONY target
38 # 'am--changelog-regen-hook' to work around a bug of Solaris make, which
39 # doesn't execute the recipe of a target named as an existing file, even
40 # if such target is declared '.PHONY' (yikes!)
42 # The ChangeLog should be regenerated unconditionally when working from
43 # checked-out sources; otherwise, if we're working from a distribution
44 # tarball, we expect the ChangeLog to be distributed, so check that it
45 # is indeed present in the source directory.
46 .PHONY: am--changelog-regen-hook
47 am--changelog-regen-hook:
48 ChangeLog: am--changelog-regen-hook
49 $(AM_V_GEN)set -e; set -u; \
50 if test -d $(srcdir)/.git; then \
52 && $(gitlog_to_changelog_command) \
53 $(gitlog_to_changelog_options) >$@-t \
57 elif test ! -f $(srcdir)/$@; then \
58 echo "Source tree is not a git checkout, and no pre-existent" \
59 "$@ file has been found there" >&2; \
64 # --------------------------- #
65 # Perl coverage statistics. #
66 # --------------------------- #
68 PERL_COVERAGE_DB = $(abs_top_builddir)/cover_db
69 PERL_COVERAGE_FLAGS = -MDevel::Cover=-db,$(PERL_COVERAGE_DB),-silent,on,-summary,off
72 check-coverage-run recheck-coverage-run: all
73 $(mkinstalldirs) $(PERL_COVERAGE_DB)
74 PERL5OPT="$$PERL5OPT $(PERL_COVERAGE_FLAGS)"; export PERL5OPT; \
75 WANT_NO_THREADS=yes; export WANT_NO_THREADS; unset AUTOMAKE_JOBS; \
76 $(MAKE) $(AM_MAKEFLAGS) `echo $@ | sed 's/-coverage-run//'`
78 check-coverage-report:
79 @if test ! -d "$(PERL_COVERAGE_DB)"; then \
80 echo "No coverage database found in '$(PERL_COVERAGE_DB)'." >&2; \
81 echo "Please run \"make check-coverage\" first" >&2; \
84 $(PERL_COVER) $(PERL_COVER_FLAGS) "$(PERL_COVERAGE_DB)"
86 # We don't use direct dependencies here because we'd like to be able
87 # to invoke the report even after interrupted check-coverage.
88 check-coverage: check-coverage-run
89 $(MAKE) $(AM_MAKEFLAGS) check-coverage-report
91 recheck-coverage: recheck-coverage-run
92 $(MAKE) $(AM_MAKEFLAGS) check-coverage-report
95 rm -rf "$(PERL_COVERAGE_DB)"
96 clean-local: clean-coverage
98 .PHONY: check-coverage recheck-coverage check-coverage-run \
99 recheck-coverage-run check-coverage-report clean-coverage
102 # ---------------------------------------------------- #
103 # Tagging and/or uploading stable and beta releases. #
104 # ---------------------------------------------------- #
108 EXTRA_DIST += lib/gnupload
110 base_version_rx = ^[1-9][0-9]*\.[0-9][0-9]*
111 stable_major_version_rx = $(base_version_rx)$$
112 stable_minor_version_rx = $(base_version_rx)\.[0-9][0-9]*$$
113 beta_version_rx = $(base_version_rx)(\.[0-9][0-9]*)?[bdfhjlnprtvxz]$$
114 match_version = echo "$(VERSION)" | $(EGREP) >/dev/null
116 # Check that we don't have uncommitted or unstaged changes.
117 # TODO: Maybe the git suite already offers a shortcut to verify if the
118 # TODO: working directory is "clean" or not? If yes, use that instead
119 # TODO: of duplicating the logic here.
120 git_must_have_clean_workdir = \
121 $(GIT) rev-parse --verify HEAD >/dev/null \
122 && $(GIT) update-index -q --refresh \
123 && $(GIT) diff-files --quiet \
124 && $(GIT) diff-index --quiet --cached HEAD \
125 || fatal "you have uncommitted or unstaged changes"
127 determine_release_type = \
128 if $(match_version) '$(stable_major_version_rx)'; then \
129 release_type='Major release'; \
130 announcement_type='major release'; \
132 elif $(match_version) '$(stable_minor_version_rx)'; then \
133 release_type='Minor release'; \
134 announcement_type='maintenance release'; \
136 elif $(match_version) '$(beta_version_rx)'; then \
137 release_type='Beta release'; \
138 announcement_type='test release'; \
141 fatal "invalid version '$(VERSION)' for a release"; \
144 # Help the debugging of $(determine_release_type) and related code.
147 && fatal () { echo "$@: $$*"; exit 0; } \
148 && $(determine_release_type) \
149 && echo "$$release_type $(VERSION);" \
150 "it will be announced as a $$announcement_type"
152 git-tag-release: maintainer-check
154 fatal () { echo "$@: $$*; not tagging" >&2; exit 1; }; \
155 case '$(AM_TAG_DRYRUN)' in \
156 ""|[nN]|[nN]o|NO) run="";; \
157 *) run="echo Running:";; \
159 $(determine_release_type); \
160 $(git_must_have_clean_workdir); \
161 ## If all was successful, tag the release in the local repository.
162 $$run $(GIT) tag -s "v$(VERSION)" -m "$$release_type $(VERSION)"
166 fatal () { echo "$@: $$*; not releasing" >&2; exit 1; }; \
167 $(determine_release_type); \
168 dest=$$dest.gnu.org:automake; \
169 $(git_must_have_clean_workdir); \
170 ## Check that we are releasing from a valid tag.
171 tag=`$(GIT) describe` \
172 && case $$tag in "v$(VERSION)") true;; *) false;; esac \
173 || fatal "you can only create a release from a tagged version"; \
174 ## Build and upload the distribution tarball(s).
175 $(MAKE) $(AM_MAKEFLAGS) dist || exit 1; \
176 echo Will upload to $$dest: $(DIST_ARCHIVES); \
177 $(srcdir)/lib/gnupload $(GNUPLOADFLAGS) --to $$dest $(DIST_ARCHIVES)
179 .PHONY: print-release-type git-upload-release git-tag-release
182 # ------------------------------------------------------------------ #
183 # Explore differences of autogenerated files in different commits. #
184 # ------------------------------------------------------------------ #
186 # Visually comparing differences between the Makefile.in files in
187 # automake's own build system as generated in two different branches
188 # might help to catch bugs and blunders. This has already happened a
189 # few times in the past, when we used to version-control Makefile.in.
192 NEW_COMMIT=$${NEW_COMMIT-"HEAD"}; \
193 OLD_COMMIT=$${OLD_COMMIT-"HEAD~1"}; \
194 am_gitdir='$(abs_top_srcdir)/.git'; \
195 get_autofiles_from_rev () \
198 && echo "$@: will get files from revision $$rev" \
199 && $(GIT) clone -q --depth 1 "$$am_gitdir" tmp \
201 && $(GIT) checkout -q "$$rev" \
202 && echo "$@: bootstrapping $$rev" \
203 && $(SHELL) ./bootstrap.sh \
204 && echo "$@: copying files from $$rev" \
205 && makefile_ins=`find . -name Makefile.in` \
206 && (tar cf - configure aclocal.m4 $$makefile_ins) | \
207 (cd .. && $(am__cd) "$$dir" && tar xf -) \
212 && : Before proceeding, ensure the specified revisions truly exist. \
213 && $(GIT) --git-dir="$$am_gitdir" describe $$OLD_COMMIT >/dev/null \
214 && $(GIT) --git-dir="$$am_gitdir" describe $$NEW_COMMIT >/dev/null \
217 && $(am__cd) $$outdir \
219 && get_autofiles_from_rev $$OLD_COMMIT old \
220 && get_autofiles_from_rev $$NEW_COMMIT new \
223 # With lots of eye candy; we like our developers pampered and spoiled :-)
224 compare-autodiffs: autodiffs
226 : $${COLORDIFF=colordiff} $${DIFF=diff}; \
228 if test ! -d "$$dir"; then \
229 echo "$@: $$dir: Not a directory" >&2; \
232 mydiff=false mypager=false; \
234 if ($$COLORDIFF -r . .) </dev/null >/dev/null 2>&1; then \
235 mydiff=$$COLORDIFF; \
243 if test "$$mydiff" = false; then \
244 if ($$DIFF -r -u . .); then \
247 echo "$@: no good-enough diff program specified" >&2; \
251 st=0; $$mydiff -r -u $$dir/old $$dir/new | $$mypager || st=$$?; \
254 .PHONY: autodiffs compare-autodiffs
256 # ---------------------------------------------- #
257 # Help writing the announcement for a release. #
258 # ---------------------------------------------- #
260 PACKAGE_MAILINGLIST = automake@gnu.org
265 && fatal () { echo "$@: $$*" >&2; exit 1; } \
266 && $(determine_release_type) \
267 && ftp_base="ftp://$$dest.gnu.org/gnu/$(PACKAGE)" \
268 && X () { printf '%s\n' "$$*" >> $@-t; } \
269 && X "We are pleased to announce the $(PACKAGE_NAME) $(VERSION)" \
270 "$$announcement_type." \
272 && X "**TODO** Brief description of the release here." \
274 && X "**TODO** This description can span multiple paragraphs." \
276 && X "See below for the detailed list of changes since the" \
277 && X "previous version, as summarized by the NEWS file." \
279 && X "Download here:" \
281 && X " $$ftp_base/$(PACKAGE)-$(VERSION).tar.gz" \
282 && X " $$ftp_base/$(PACKAGE)-$(VERSION).tar.xz" \
284 && X "Please report bugs and problems to" \
285 "<$(PACKAGE_BUGREPORT)>," \
286 && X "and send general comments and feedback to" \
287 "<$(PACKAGE_MAILINGLIST)>." \
289 && X "Thanks to everyone who has reported problems, contributed" \
290 && X "patches, and helped testing Automake!" \
294 && sed -n -e '/^~~~/q' -e p $(srcdir)/NEWS >> $@-t \
297 CLEANFILES += announcement
299 # --------------------------------------------------------------------- #
300 # Synchronize third-party files that are committed in our repository. #
301 # --------------------------------------------------------------------- #
303 # Program to use to fetch files.
306 # Some repositories we sync files from.
307 SV_CVS = 'http://savannah.gnu.org/cgi-bin/viewcvs/~checkout~/'
308 SV_GIT_CF = 'http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;hb=HEAD;f='
309 SV_GIT_AC = 'http://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=blob_plain;hb=HEAD;f='
310 SV_GIT_GL = 'http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob_plain;hb=HEAD;f='
312 # Files that we fetch and which we compare against.
313 # Note that the 'lib/COPYING' file must still be synced by hand.
315 $(SV_GIT_CF)config.guess \
316 $(SV_GIT_CF)config.sub \
317 $(SV_CVS)texinfo/texinfo/doc/texinfo.tex \
318 $(SV_CVS)texinfo/texinfo/util/gendocs.sh \
319 $(SV_CVS)texinfo/texinfo/util/gendocs_template \
320 $(SV_GIT_GL)build-aux/gitlog-to-changelog \
321 $(SV_GIT_GL)build-aux/gnupload \
322 $(SV_GIT_GL)build-aux/update-copyright \
323 $(SV_GIT_GL)doc/INSTALL
325 # Fetch the latest versions of few scripts and files we care about.
326 # A retrieval failure or a copying failure usually mean serious problems,
327 # so we'll just bail out if 'wget' or 'cp' fail.
329 $(AM_V_at)rm -rf Fetchdir
330 $(AM_V_at)mkdir Fetchdir
332 if $(AM_V_P); then wget_opts=; else wget_opts=-nv; fi; \
333 for url in $(FETCHFILES); do \
334 file=`printf '%s\n' "$$url" | sed 's|^.*/||; s|^.*=||'`; \
335 $(WGET) $$wget_opts "$$url" -O Fetchdir/$$file || exit 1; \
336 if cmp Fetchdir/$$file $(srcdir)/lib/$$file >/dev/null; then \
339 echo "$@: updating file $$file"; \
340 cp Fetchdir/$$file $(srcdir)/lib/$$file || exit 1; \
343 $(AM_V_at)rm -rf Fetchdir
346 # ---------------------------------------------------------------------- #
347 # Generate and upload manuals in several formats, for the GNU website. #
348 # ---------------------------------------------------------------------- #
350 web_manual_dir = doc/web-manual
356 WEBCVS_ROOT = cvs.savannah.gnu.org:/web
358 .PHONY: web-manual web-manual-update
359 web-manual web-manual-update: t = $@.dir
361 # Build manual in several formats. Note to the recipe:
362 # 1. The symlinking of automake.texi into the temporary directory is
363 # required to pacify extra checks from gendocs.sh.
364 # 2. The redirection to /dev/null before the invocation of gendocs.sh
365 # is done to better respect silent rules.
367 $(AM_V_at)rm -rf $(web_manual_dir) $t
369 $(AM_V_at)$(LN_S) '$(abs_srcdir)/doc/$(PACKAGE).texi' '$t/'
370 $(AM_V_GEN)$(am__cd) $t \
371 && GENDOCS_TEMPLATE_DIR='$(abs_srcdir)/lib' \
372 && export GENDOCS_TEMPLATE_DIR \
373 && if $(AM_V_P); then :; else exec >/dev/null 2>&1; fi \
374 && $(SHELL) '$(abs_srcdir)/lib/gendocs.sh' \
375 -I '$(abs_srcdir)/doc' --email $(PACKAGE_BUGREPORT) \
376 $(PACKAGE) '$(PACKAGE_NAME)'
377 $(AM_V_at)mkdir $(web_manual_dir)
378 $(AM_V_at)mv -f $t/manual/* $(web_manual_dir)
380 @! $(AM_V_P) || ls -l $(web_manual_dir)
382 # Upload manual to www.gnu.org, using CVS (sigh!)
384 $(AM_V_at)fatal () { echo "$@: $$*" >&2; exit 1; }; \
385 $(determine_release_type); \
386 case $$release_type in \
387 [Mm]ajor\ release|[Mm]inor\ release);; \
388 *) echo "Cannot upload manuals from a \"$$release_type\"" >&2; \
391 $(AM_V_at)test -f $(web_manual_dir)/$(PACKAGE).html || { \
392 echo 'You have to run "$(MAKE) web-manuals" before' \
393 'invoking "$(MAKE) $@"' >&2; \
398 $(AM_V_at)CVS_RSH=ssh && export CVS_RSH=ssh \
400 && $(CVS) -z3 -d :ext:$(CVS_USER)@$(WEBCVS_ROOT)/$(PACKAGE) \
402 @# According to the rsync manpage, "a trailing slash on the
403 @# source [...] avoids creating an additional directory
404 @# level at the destination". So the trailing '/' after
405 @# '$(web_manual_dir)' below is intended.
406 $(AM_V_at)$(RSYNC) -avP $(web_manual_dir)/ $t/$(PACKAGE)/manual
407 $(AM_V_GEN)CVS_RSH=ssh && export CVS_RSH=ssh \
408 && cd $t/$(PACKAGE)/manual \
409 && new_files=`$(CVSU) --types='?'` \
410 && new_files=`echo "$$new_files" | sed s/^..//` \
411 && { test -z "$$new_files" || $(CVS) add -ko $$new_files; } \
412 && $(CVS) ci -m $(VERSION)
414 .PHONY: web-manual-update
417 $(AM_V_at)rm -rf $(web_manual_dir)
418 .PHONY: clean-web-manual
419 clean-local: clean-web-manual
421 EXTRA_DIST += lib/gendocs.sh lib/gendocs_template
423 # ------------------------------------------------ #
424 # Update copyright years of all committed files. #
425 # ------------------------------------------------ #
427 EXTRA_DIST += lib/update-copyright
429 update_copyright_env = \
430 UPDATE_COPYRIGHT_FORCE=1 \
431 UPDATE_COPYRIGHT_USE_INTERVALS=2
433 # In addition to the several README files, these as well are
434 # not expected to have a copyright notice.
435 files_without_copyright = \
447 # This script is in the public domain.
448 files_without_copyright += lib/mkinstalldirs
450 # This script has an MIT-style license
451 files_without_copyright += lib/install-sh
453 .PHONY: update-copyright
456 current_year=`date +%Y` && test -n "$$current_year" \
457 || { echo "$@: cannot get current year" >&2; exit 1; }; \
458 sed -i "/^RELEASE_YEAR=/s/=.*$$/=$$current_year/" \
459 bootstrap.sh configure.ac; \
461 for url in $(FETCHFILES); do echo "$$url"; done \
462 | sed -e 's!^.*/!!' -e 's!^.*=!!' -e 's!^!lib/!' \
463 && for f in $(files_without_copyright); do echo $$f; done \
464 ) | sed -e '$$!s,$$,|,' | tr -d '\012\015'`; \
466 | grep -Ev '(^|/)README$$' \
467 | grep -Ev "^($$excluded_re)$$" \
468 | $(update_copyright_env) xargs $(srcdir)/lib/$@