Merge branch 'branch-1.13.2' into maint
[platform/upstream/automake.git] / maintainer / maint.mk
1 # Maintainer makefile rules for Automake.
2 #
3 # Copyright (C) 1995-2013 Free Software Foundation, Inc.
4 #
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)
8 # any later version.
9 #
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.
14 #
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/>.
17
18 # Avoid CDPATH issues.
19 unexport CDPATH
20
21 # --------------------------------------------------------- #
22 #  Automatic generation of the ChangeLog from git history.  #
23 # --------------------------------------------------------- #
24
25 gitlog_to_changelog_command = $(PERL) $(srcdir)/lib/gitlog-to-changelog
26 gitlog_to_changelog_fixes = $(srcdir)/.git-log-fix
27 gitlog_to_changelog_options = --amend=$(gitlog_to_changelog_fixes) \
28                               --since='2011-12-28 00:00:00' \
29                               --no-cluster --format '%s%n%n%b'
30
31 EXTRA_DIST += lib/gitlog-to-changelog
32 EXTRA_DIST += $(gitlog_to_changelog_fixes)
33
34 # When executed from a git checkout, generate the ChangeLog from the git
35 # history.  When executed from an extracted distribution tarball, just
36 # copy the distributed ChangeLog in the build directory (and if this
37 # fails, or if no distributed ChangeLog file is present, complain and
38 # give an error).
39 #
40 # The ChangeLog should be regenerated unconditionally when working from
41 # checked-out sources; otherwise, if we're working from a distribution
42 # tarball, we expect the ChangeLog to be distributed, so check that it
43 # is indeed present in the source directory.
44 ChangeLog:
45         $(AM_V_GEN)set -e; set -u; \
46         if test -d $(srcdir)/.git; then \
47           rm -f $@-t \
48             && $(gitlog_to_changelog_command) \
49                $(gitlog_to_changelog_options) >$@-t \
50             && chmod a-w $@-t \
51             && mv -f $@-t $@ \
52             || exit 1; \
53         elif test ! -f $(srcdir)/$@; then \
54           echo "Source tree is not a git checkout, and no pre-existent" \
55                "$@ file has been found there" >&2; \
56           exit 1; \
57         fi
58 .PHONY: ChangeLog
59
60
61 # --------------------------- #
62 #  Perl coverage statistics.  #
63 # --------------------------- #
64
65 PERL_COVERAGE_DB = $(abs_top_builddir)/cover_db
66 PERL_COVERAGE_FLAGS = -MDevel::Cover=-db,$(PERL_COVERAGE_DB),-silent,on,-summary,off
67 PERL_COVER = cover
68
69 check-coverage-run recheck-coverage-run: %-coverage-run: all
70         $(MKDIR_P) $(PERL_COVERAGE_DB)
71         PERL5OPT="$$PERL5OPT $(PERL_COVERAGE_FLAGS)"; export PERL5OPT; \
72         WANT_NO_THREADS=yes; export WANT_NO_THREADS; unset AUTOMAKE_JOBS; \
73         $(MAKE) $*
74
75 check-coverage-report:
76         @if test ! -d "$(PERL_COVERAGE_DB)"; then \
77           echo "No coverage database found in '$(PERL_COVERAGE_DB)'." >&2; \
78           echo "Please run \"make check-coverage\" first" >&2; \
79           exit 1; \
80         fi
81         $(PERL_COVER) $(PERL_COVER_FLAGS) "$(PERL_COVERAGE_DB)"
82
83 # We don't use direct dependencies here because we'd like to be able
84 # to invoke the report even after interrupted check-coverage.
85 check-coverage: check-coverage-run
86         $(MAKE) check-coverage-report
87
88 recheck-coverage: recheck-coverage-run
89         $(MAKE) check-coverage-report
90
91 clean-coverage:
92         rm -rf "$(PERL_COVERAGE_DB)"
93 clean-local: clean-coverage
94
95 .PHONY: check-coverage recheck-coverage check-coverage-run \
96         recheck-coverage-run check-coverage-report clean-coverage
97
98
99 # ---------------------------------------------------- #
100 #  Tagging and/or uploading stable and beta releases.  #
101 # ---------------------------------------------------- #
102
103 GIT = git
104
105 EXTRA_DIST += lib/gnupload
106
107 base_version_rx = ^[1-9][0-9]*\.[0-9][0-9]*
108 stable_major_version_rx = $(base_version_rx)$$
109 stable_minor_version_rx = $(base_version_rx)\.[0-9][0-9]*$$
110 beta_version_rx = $(base_version_rx)(\.[0-9][0-9]*)?[bdfhjlnprtvxz]$$
111 match_version = echo "$(VERSION)" | $(EGREP) >/dev/null
112
113 # Check that we don't have uncommitted or unstaged changes.
114 # TODO: Maybe the git suite already offers a shortcut to verify if the
115 # TODO: working directory is "clean" or not?  If yes, use that instead
116 # TODO: of duplicating the logic here.
117 git_must_have_clean_workdir = \
118   $(GIT) rev-parse --verify HEAD >/dev/null \
119     && $(GIT) update-index -q --refresh \
120     && $(GIT) diff-files --quiet \
121     && $(GIT) diff-index --quiet --cached HEAD \
122     || { echo "$@: you have uncommitted or unstaged changes" >&2; exit 1; }
123
124 determine_release_type = \
125   if $(match_version) '$(stable_major_version_rx)'; then \
126     release_type='Major release'; \
127     announcement_type='major release'; \
128     dest=ftp; \
129   elif $(match_version) '$(stable_minor_version_rx)'; then \
130     release_type='Minor release'; \
131     announcement_type='maintenance release'; \
132     dest=ftp; \
133   elif $(match_version) '$(beta_version_rx)'; then \
134     release_type='Beta release'; \
135     announcement_type='test release'; \
136     dest=alpha; \
137   else \
138     echo "$@: invalid version '$(VERSION)' for a release" >&2; \
139     exit 1; \
140   fi
141
142 # Help the debugging of $(determine_release_type) and related code.
143 print-release-type:
144         @$(determine_release_type); \
145          echo "$$release_type $(VERSION);" \
146               "it will be announced as a $$announcement_type"
147
148 git-tag-release: maintainer-check
149         @set -e -u; \
150         case '$(AM_TAG_DRYRUN)' in \
151           ""|[nN]|[nN]o|NO) run="";; \
152           *) run="echo Running:";; \
153         esac; \
154         $(determine_release_type); \
155         $(git_must_have_clean_workdir); \
156         $$run $(GIT) tag -s "v$(VERSION)" -m "$$release_type $(VERSION)"
157
158 git-upload-release:
159         @# Check this is a version we can cut a release (either test
160         @# or stable) from.
161         @$(determine_release_type)
162         @# The repository must be clean.
163         @$(git_must_have_clean_workdir)
164         @# Check that we are releasing from a valid tag.
165         @tag=`$(GIT) describe` \
166           && case $$tag in "v$(VERSION)") true;; *) false;; esac \
167           || { echo "$@: you can only create a release from a tagged" \
168                     "version" >&2; \
169                exit 1; }
170         @# Build the distribution tarball(s).
171         $(MAKE) dist
172         @# Upload it to the correct FTP repository.
173         @$(determine_release_type) \
174           && dest=$$dest.gnu.org:automake \
175           && echo "Will upload to $$dest: $(DIST_ARCHIVES)" \
176           && $(srcdir)/lib/gnupload $(GNUPLOADFLAGS) --to $$dest \
177                                     $(DIST_ARCHIVES)
178
179 .PHONY: print-release-type git-upload-release git-tag-release
180
181
182 # ------------------------------------------------------------------ #
183 #  Explore differences of autogenerated files in different commits.  #
184 # ------------------------------------------------------------------ #
185
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.
190 autodiffs:
191         @set -u; \
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 () \
196          { \
197              rev=$$1 dir=$$2 \
198                && echo "$@: will get files from revision $$rev" \
199                && $(GIT) clone -q --depth 1 "$$am_gitdir" tmp \
200                && cd 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 .. && cd "$$dir" && tar xf -) \
208                && cd .. \
209                && rm -rf tmp; \
210          }; \
211          outdir=$@.dir \
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 \
215            && rm -rf $$outdir \
216            && mkdir $$outdir \
217            && cd $$outdir \
218            && mkdir new old \
219            && get_autofiles_from_rev $$OLD_COMMIT old \
220            && get_autofiles_from_rev $$NEW_COMMIT new \
221            && exit 0
222
223 # With lots of eye candy; we like our developers pampered and spoiled :-)
224 compare-autodiffs: autodiffs
225         @set -u; \
226         : $${COLORDIFF=colordiff} $${DIFF=diff}; \
227         dir=autodiffs.dir; \
228         if test ! -d "$$dir"; then \
229           echo "$@: $$dir: Not a directory" >&2; \
230           exit 1; \
231         fi; \
232         mydiff=false mypager=false; \
233         if test -t 1; then \
234           if ($$COLORDIFF -r . .) </dev/null >/dev/null 2>&1; then \
235             mydiff=$$COLORDIFF; \
236             mypager="less -R"; \
237           else \
238             mypager=less; \
239           fi; \
240         else \
241           mypager=cat; \
242         fi; \
243         if test "$$mydiff" = false; then \
244           if ($$DIFF -r -u . .); then \
245             mydiff=$$DIFF; \
246           else \
247             echo "$@: no good-enough diff program specified" >&2; \
248             exit 1; \
249           fi; \
250         fi; \
251         st=0; $$mydiff -r -u $$dir/old $$dir/new | $$mypager || st=$$?; \
252         rm -rf $$dir; \
253         exit $$st
254 .PHONY: autodiffs compare-autodiffs
255
256 # ---------------------------------------------- #
257 #  Help writing the announcement for a release.  #
258 # ---------------------------------------------- #
259
260 PACKAGE_MAILINGLIST = automake@gnu.org
261
262 announcement: NEWS
263         $(AM_V_GEN): \
264           && rm -f $@ $@-t \
265           && $(determine_release_type) \
266           && ftp_base="ftp://$$dest.gnu.org/gnu/$(PACKAGE)" \
267           && X () { printf '%s\n' "$$*" >> $@-t; } \
268           && X "We are pleased to announce the $(PACKAGE_NAME) $(VERSION)" \
269                "$$announcement_type." \
270           && X \
271           && X "**TODO** Brief description of the release here." \
272           && X \
273           && X "**TODO** This description can span multiple paragraphs." \
274           && X \
275           && X "See below for the detailed list of changes since the" \
276           && X "previous version, as summarized by the NEWS file." \
277           && X \
278           && X "Download here:" \
279           && X \
280           && X "  $$ftp_base/$(PACKAGE)-$(VERSION).tar.gz" \
281           && X "  $$ftp_base/$(PACKAGE)-$(VERSION).tar.xz" \
282           && X \
283           && X "Please report bugs and problems to" \
284                "<$(PACKAGE_BUGREPORT)>," \
285           && X "and send general comments and feedback to" \
286                "<$(PACKAGE_MAILINGLIST)>." \
287           && X \
288           && X "Thanks to everyone who has reported problems, contributed" \
289           && X "patches, and helped testing Automake!" \
290           && X \
291           && X "-*-*-*-" \
292           && X \
293           && sed -n -e '/^~~~/q' -e p $(srcdir)/NEWS >> $@-t \
294           && mv -f $@-t $@
295 .PHONY: announcement
296 CLEANFILES += announcement
297
298 # --------------------------------------------------------------------- #
299 #  Synchronize third-party files that are committed in our repository.  #
300 # --------------------------------------------------------------------- #
301
302 # Program to use to fetch files.
303 WGET = wget
304
305 # Git repositories on Savannah.
306 git-sv-host = git.savannah.gnu.org
307
308 # Some repositories we sync files from.
309 SV_CVS    = 'http://savannah.gnu.org/cgi-bin/viewcvs/~checkout~/'
310 SV_GIT_CF = 'http://$(git-sv-host)/gitweb/?p=config.git;a=blob_plain;hb=HEAD;f='
311 SV_GIT_AC = 'http://$(git-sv-host)/gitweb/?p=autoconf.git;a=blob_plain;hb=HEAD;f='
312 SV_GIT_GL = 'http://$(git-sv-host)/gitweb/?p=gnulib.git;a=blob_plain;hb=HEAD;f='
313
314 # Files that we fetch and which we compare against.
315 # Note that the 'lib/COPYING' file must still be synced by hand.
316 FETCHFILES = \
317   $(SV_GIT_CF)config.guess \
318   $(SV_GIT_CF)config.sub \
319   $(SV_CVS)texinfo/texinfo/doc/texinfo.tex \
320   $(SV_CVS)texinfo/texinfo/util/gendocs.sh \
321   $(SV_CVS)texinfo/texinfo/util/gendocs_template \
322   $(SV_GIT_GL)build-aux/gitlog-to-changelog \
323   $(SV_GIT_GL)build-aux/gnupload \
324   $(SV_GIT_GL)build-aux/update-copyright \
325   $(SV_GIT_GL)doc/INSTALL
326
327 # Fetch the latest versions of few scripts and files we care about.
328 # A retrieval failure or a copying failure usually mean serious problems,
329 # so we'll just bail out if 'wget' or 'cp' fail.
330 fetch:
331         $(AM_V_at)rm -rf Fetchdir
332         $(AM_V_at)mkdir Fetchdir
333         $(AM_V_GEN)set -e; \
334         if $(AM_V_P); then wget_opts=; else wget_opts=-nv; fi; \
335         for url in $(FETCHFILES); do \
336            file=`printf '%s\n' "$$url" | sed 's|^.*/||; s|^.*=||'`; \
337            $(WGET) $$wget_opts "$$url" -O Fetchdir/$$file || exit 1; \
338            if cmp Fetchdir/$$file $(srcdir)/lib/$$file >/dev/null; then \
339              : Nothing to do; \
340            else \
341              echo "$@: updating file $$file"; \
342              cp Fetchdir/$$file $(srcdir)/lib/$$file || exit 1; \
343            fi; \
344         done
345         $(AM_V_at)rm -rf Fetchdir
346 .PHONY: fetch
347
348 # ---------------------------------------------------------------------- #
349 #  Generate and upload manuals in several formats, for the GNU website.  #
350 # ---------------------------------------------------------------------- #
351
352 web_manual_dir = doc/web-manual
353
354 RSYNC = rsync
355 CVS = cvs
356 CVSU = cvsu
357 CVS_USER = $${USER}
358 WEBCVS_ROOT = cvs.savannah.gnu.org:/web
359 CVS_RSH = ssh
360 export CVS_RSH
361
362 .PHONY: web-manual web-manual-update
363 web-manual web-manual-update: t = $@.dir
364
365 # Build manual in several formats.  Note to the recipe:
366 # 1. The symlinking of automake.texi into the temporary directory is
367 #    required to pacify extra checks from gendocs.sh.
368 # 2. The redirection to /dev/null before the invocation of gendocs.sh
369 #    is done to better respect silent rules.
370 web-manual:
371         $(AM_V_at)rm -rf $(web_manual_dir) $t
372         $(AM_V_at)mkdir $t
373         $(AM_V_at)$(LN_S) '$(abs_srcdir)/doc/$(PACKAGE).texi' '$t/'
374         $(AM_V_GEN)cd $t \
375           && GENDOCS_TEMPLATE_DIR='$(abs_srcdir)/lib' \
376           && export GENDOCS_TEMPLATE_DIR \
377           && if $(AM_V_P); then :; else exec >/dev/null 2>&1; fi \
378           && $(SHELL) '$(abs_srcdir)/lib/gendocs.sh' \
379              -I '$(abs_srcdir)/doc' --email $(PACKAGE_BUGREPORT) \
380              $(PACKAGE) '$(PACKAGE_NAME)'
381         $(AM_V_at)mkdir $(web_manual_dir)
382         $(AM_V_at)mv -f $t/manual/* $(web_manual_dir)
383         $(AM_V_at)rm -rf $t
384         @! $(AM_V_P) || ls -l $(web_manual_dir)
385
386 # Upload manual to www.gnu.org, using CVS (sigh!)
387 web-manual-update:
388         $(AM_V_at)$(determine_release_type); \
389         case $$release_type in \
390           [Mm]ajor\ release|[Mm]inor\ release);; \
391           *) echo "Cannot upload manuals from a \"$$release_type\"" >&2; \
392              exit 1;; \
393         esac
394         $(AM_V_at)test -f $(web_manual_dir)/$(PACKAGE).html || { \
395           echo 'You have to run "$(MAKE) web-manuals" before' \
396                'invoking "$(MAKE) $@"' >&2; \
397           exit 1; \
398         }
399         $(AM_V_at)rm -rf $t
400         $(AM_V_at)mkdir $t
401         $(AM_V_at)cd $t \
402           && $(CVS) -z3 -d :ext:$(CVS_USER)@$(WEBCVS_ROOT)/$(PACKAGE) \
403                     co $(PACKAGE)
404         @# According to the rsync manpage, "a trailing slash on the
405         @# source [...] avoids creating an additional directory
406         @# level at the destination".  So the trailing '/' after
407         @# '$(web_manual_dir)' below is intended.
408         $(AM_V_at)$(RSYNC) -avP $(web_manual_dir)/ $t/$(PACKAGE)/manual
409         $(AM_V_GEN): \
410           && cd $t/$(PACKAGE)/manual \
411           && new_files=`$(CVSU) --types='?'` \
412           && new_files=`echo "$$new_files" | sed s/^..//` \
413           && { test -z "$$new_files" || $(CVS) add -ko $$new_files; } \
414           && $(CVS) ci -m $(VERSION)
415         $(AM_V_at)rm -rf $t
416 .PHONY: web-manual-update
417
418 clean-web-manual:
419         $(AM_V_at)rm -rf $(web_manual_dir)
420 .PHONY: clean-web-manual
421 clean-local: clean-web-manual
422
423 EXTRA_DIST += lib/gendocs.sh lib/gendocs_template
424
425 # ------------------------------------------------ #
426 #  Update copyright years of all committed files.  #
427 # ------------------------------------------------ #
428
429 EXTRA_DIST += lib/update-copyright
430
431 update_copyright_env = \
432   UPDATE_COPYRIGHT_FORCE=1 \
433   UPDATE_COPYRIGHT_USE_INTERVALS=2
434
435 # In addition to the several README files, these as well are
436 # not expected to have a copyright notice.
437 files_without_copyright = \
438   .autom4te.cfg \
439   .git-log-fix \
440   .gitattributes \
441   .gitignore \
442   INSTALL \
443   COPYING \
444   AUTHORS \
445   THANKS \
446   lib/INSTALL \
447   lib/COPYING
448
449 # This script is in the public domain.
450 files_without_copyright += lib/mkinstalldirs
451
452 # This script has an MIT-style license
453 files_without_copyright += lib/install-sh
454
455 # The UPDATE_COPYRIGHT_YEAR environment variable is honoured by the
456 # 'lib/update-copyright' script.
457 .PHONY: update-copyright
458 update-copyright:
459         $(AM_V_GEN)set -e; \
460         if test -n "$$UPDATE_COPYRIGHT_YEAR"; then \
461            current_year=$$UPDATE_COPYRIGHT_YEAR; \
462         else \
463           current_year=`date +%Y` && test -n "$$current_year" \
464             || { echo "$@: cannot get current year" >&2; exit 1; }; \
465         fi; \
466         sed -i "/^RELEASE_YEAR=/s/=.*$$/=$$current_year/" \
467           bootstrap.sh configure.ac; \
468         excluded_re=`( \
469           for url in $(FETCHFILES); do echo "$$url"; done \
470             | sed -e 's!^.*/!!' -e 's!^.*=!!' -e 's!^!lib/!' \
471           && for f in $(files_without_copyright); do echo $$f; done \
472         ) | sed -e '$$!s,$$,|,' | tr -d '\012\015'`; \
473         $(GIT) ls-files \
474           | grep -Ev '(^|/)README$$' \
475           | grep -Ev '^PLANS(/|$$)' \
476           | grep -Ev "^($$excluded_re)$$" \
477           | $(update_copyright_env) xargs $(srcdir)/lib/$@
478
479 # --------------------------------------------------------------- #
480 #  Testing on real-world packages can help us avoid regressions.  #
481 # --------------------------------------------------------------- #
482
483 #
484 # NOTE (from Stefano Lattarini):
485
486 # This section is mostly hacky and ad-hoc, but works for me and
487 # on my system.  And while far from clean, it should help catching
488 # real regressions on real world packages, which is important.
489 # Ideas about how to improve this and make it more generic, portable,
490 # clean, etc., are welcome.
491 #
492
493 # Tiny sample package.
494 FEW_PACKAGES += hello
495 # Smallish package using recursive make setup.
496 FEW_PACKAGES += make
497 # Medium-size package using non-recursive make setup.
498 FEW_PACKAGES += coreutils
499
500 ALL_PACKAGES = \
501   $(FEW_PACKAGES) \
502   autoconf \
503   bison \
504   grep \
505   tar \
506   diffutils \
507   smalltalk
508
509 pkg-targets = check dist
510
511 # Note: "ttp" stays for "Third Party Package".
512
513 ttp-check ttp-check-all: do-clone = $(GIT) clone --verbose
514 ttp-check: ttp-packages = $(FEW_PACKAGES)
515 ttp-check-all: ttp-packages = $(ALL_PACKAGES)
516
517 # Note: some packages depend on pkg-config, and its provided macros.
518 ttp-check ttp-check-all: t/pkg-config-macros.log
519         @set -e; \
520         $(setup_autotools_paths); \
521         skip_all_ () \
522         { \
523           echo "***" >&2; \
524           echo "*** $@: WARNING: $$@" >&2; \
525           echo "*** $@: WARNING: some packages might fail to bootstrap" >&2; \
526           echo "***" >&2;  \
527         }; \
528         . t/pkg-config-macros.dir/get.sh || exit 1; \
529         mkdir $@.d && cd $@.d || exit 1; \
530         for p in $(ttp-packages); do \
531             echo; \
532             echo ========  BEGIN TTP $$p  =========; \
533             echo; \
534             set -x; \
535             $(do-clone) git://$(git-sv-host)/$$p.git || exit 1; \
536             ( \
537               cd $$p \
538                 && ls -l \
539                 && if test -f bootstrap; then \
540                      ./bootstrap --no-git; \
541                    else \
542                      $$AUTORECONF -fvi; \
543                    fi \
544                 && ./configure \
545                 && if test $$p = make; then \
546                      $(MAKE) update; \
547                    else :; fi \
548                 && for t in $(pkg-targets); do \
549                      $(MAKE) $$t WERROR_CFLAGS= || exit 1; \
550                    done \
551             ) || exit 1; \
552             set +x; \
553             echo; \
554             echo ========  END TTP $$p  =========; \
555             echo; \
556          done
557 ifndef keep-ttp-dir
558         rm -rf $@.d
559 endif
560
561 # Alias for lazy typists.
562 ttp: ttp-check
563 ttp-all: ttp-check-all
564
565 .PHONY: ttp ttp-check ttp-all ttp-check-all