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           && $(AWK) '\
294                 ($$0 == "New in $(VERSION):") { wait_for_end=1; } \
295                 (/^~~~/ && wait_for_end) { exit(0) } \
296                 { print } \
297              ' <$(srcdir)/NEWS >> $@-t \
298           && mv -f $@-t $@
299 .PHONY: announcement
300 CLEANFILES += announcement
301
302 # --------------------------------------------------------------------- #
303 #  Synchronize third-party files that are committed in our repository.  #
304 # --------------------------------------------------------------------- #
305
306 # Program to use to fetch files.
307 WGET = wget
308
309 # Git repositories on Savannah.
310 git-sv-host = git.savannah.gnu.org
311
312 # Some repositories we sync files from.
313 SV_CVS    = 'http://savannah.gnu.org/cgi-bin/viewcvs/~checkout~/'
314 SV_GIT_CF = 'http://$(git-sv-host)/gitweb/?p=config.git;a=blob_plain;hb=HEAD;f='
315 SV_GIT_AC = 'http://$(git-sv-host)/gitweb/?p=autoconf.git;a=blob_plain;hb=HEAD;f='
316 SV_GIT_GL = 'http://$(git-sv-host)/gitweb/?p=gnulib.git;a=blob_plain;hb=HEAD;f='
317
318 # Files that we fetch and which we compare against.
319 # Note that the 'lib/COPYING' file must still be synced by hand.
320 FETCHFILES = \
321   $(SV_GIT_CF)config.guess \
322   $(SV_GIT_CF)config.sub \
323   $(SV_CVS)texinfo/texinfo/doc/texinfo.tex \
324   $(SV_CVS)texinfo/texinfo/util/gendocs.sh \
325   $(SV_CVS)texinfo/texinfo/util/gendocs_template \
326   $(SV_GIT_GL)build-aux/gitlog-to-changelog \
327   $(SV_GIT_GL)build-aux/gnupload \
328   $(SV_GIT_GL)build-aux/update-copyright \
329   $(SV_GIT_GL)doc/INSTALL
330
331 # Fetch the latest versions of few scripts and files we care about.
332 # A retrieval failure or a copying failure usually mean serious problems,
333 # so we'll just bail out if 'wget' or 'cp' fail.
334 fetch:
335         $(AM_V_at)rm -rf Fetchdir
336         $(AM_V_at)mkdir Fetchdir
337         $(AM_V_GEN)set -e; \
338         if $(AM_V_P); then wget_opts=; else wget_opts=-nv; fi; \
339         for url in $(FETCHFILES); do \
340            file=`printf '%s\n' "$$url" | sed 's|^.*/||; s|^.*=||'`; \
341            $(WGET) $$wget_opts "$$url" -O Fetchdir/$$file || exit 1; \
342            if cmp Fetchdir/$$file $(srcdir)/lib/$$file >/dev/null; then \
343              : Nothing to do; \
344            else \
345              echo "$@: updating file $$file"; \
346              cp Fetchdir/$$file $(srcdir)/lib/$$file || exit 1; \
347            fi; \
348         done
349         $(AM_V_at)rm -rf Fetchdir
350 .PHONY: fetch
351
352 # ---------------------------------------------------------------------- #
353 #  Generate and upload manuals in several formats, for the GNU website.  #
354 # ---------------------------------------------------------------------- #
355
356 web_manual_dir = doc/web-manual
357
358 RSYNC = rsync
359 CVS = cvs
360 CVSU = cvsu
361 CVS_USER = $${USER}
362 WEBCVS_ROOT = cvs.savannah.gnu.org:/web
363 CVS_RSH = ssh
364 export CVS_RSH
365
366 .PHONY: web-manual web-manual-update
367 web-manual web-manual-update: t = $@.dir
368
369 # Build manual in several formats.  Note to the recipe:
370 # 1. The symlinking of automake.texi into the temporary directory is
371 #    required to pacify extra checks from gendocs.sh.
372 # 2. The redirection to /dev/null before the invocation of gendocs.sh
373 #    is done to better respect silent rules.
374 web-manual:
375         $(AM_V_at)rm -rf $(web_manual_dir) $t
376         $(AM_V_at)mkdir $t
377         $(AM_V_at)$(LN_S) '$(abs_srcdir)/doc/$(PACKAGE).texi' '$t/'
378         $(AM_V_GEN)cd $t \
379           && GENDOCS_TEMPLATE_DIR='$(abs_srcdir)/lib' \
380           && export GENDOCS_TEMPLATE_DIR \
381           && if $(AM_V_P); then :; else exec >/dev/null 2>&1; fi \
382           && $(SHELL) '$(abs_srcdir)/lib/gendocs.sh' \
383              -I '$(abs_srcdir)/doc' --email $(PACKAGE_BUGREPORT) \
384              $(PACKAGE) '$(PACKAGE_NAME)'
385         $(AM_V_at)mkdir $(web_manual_dir)
386         $(AM_V_at)mv -f $t/manual/* $(web_manual_dir)
387         $(AM_V_at)rm -rf $t
388         @! $(AM_V_P) || ls -l $(web_manual_dir)
389
390 # Upload manual to www.gnu.org, using CVS (sigh!)
391 web-manual-update:
392         $(AM_V_at)$(determine_release_type); \
393         case $$release_type in \
394           [Mm]ajor\ release|[Mm]inor\ release);; \
395           *) echo "Cannot upload manuals from a \"$$release_type\"" >&2; \
396              exit 1;; \
397         esac
398         $(AM_V_at)test -f $(web_manual_dir)/$(PACKAGE).html || { \
399           echo 'You have to run "$(MAKE) web-manuals" before' \
400                'invoking "$(MAKE) $@"' >&2; \
401           exit 1; \
402         }
403         $(AM_V_at)rm -rf $t
404         $(AM_V_at)mkdir $t
405         $(AM_V_at)cd $t \
406           && $(CVS) -z3 -d :ext:$(CVS_USER)@$(WEBCVS_ROOT)/$(PACKAGE) \
407                     co $(PACKAGE)
408         @# According to the rsync manpage, "a trailing slash on the
409         @# source [...] avoids creating an additional directory
410         @# level at the destination".  So the trailing '/' after
411         @# '$(web_manual_dir)' below is intended.
412         $(AM_V_at)$(RSYNC) -avP $(web_manual_dir)/ $t/$(PACKAGE)/manual
413         $(AM_V_GEN): \
414           && cd $t/$(PACKAGE)/manual \
415           && new_files=`$(CVSU) --types='?'` \
416           && new_files=`echo "$$new_files" | sed s/^..//` \
417           && { test -z "$$new_files" || $(CVS) add -ko $$new_files; } \
418           && $(CVS) ci -m $(VERSION)
419         $(AM_V_at)rm -rf $t
420 .PHONY: web-manual-update
421
422 clean-web-manual:
423         $(AM_V_at)rm -rf $(web_manual_dir)
424 .PHONY: clean-web-manual
425 clean-local: clean-web-manual
426
427 EXTRA_DIST += lib/gendocs.sh lib/gendocs_template
428
429 # ------------------------------------------------ #
430 #  Update copyright years of all committed files.  #
431 # ------------------------------------------------ #
432
433 EXTRA_DIST += lib/update-copyright
434
435 update_copyright_env = \
436   UPDATE_COPYRIGHT_FORCE=1 \
437   UPDATE_COPYRIGHT_USE_INTERVALS=2
438
439 # In addition to the several README files, these as well are
440 # not expected to have a copyright notice.
441 files_without_copyright = \
442   .autom4te.cfg \
443   .git-log-fix \
444   .gitattributes \
445   .gitignore \
446   INSTALL \
447   COPYING \
448   AUTHORS \
449   THANKS \
450   lib/INSTALL \
451   lib/COPYING
452
453 # This script is in the public domain.
454 files_without_copyright += lib/mkinstalldirs
455
456 # This script has an MIT-style license
457 files_without_copyright += lib/install-sh
458
459 # The UPDATE_COPYRIGHT_YEAR environment variable is honoured by the
460 # 'lib/update-copyright' script.
461 .PHONY: update-copyright
462 update-copyright:
463         $(AM_V_GEN)set -e; \
464         if test -n "$$UPDATE_COPYRIGHT_YEAR"; then \
465            current_year=$$UPDATE_COPYRIGHT_YEAR; \
466         else \
467           current_year=`date +%Y` && test -n "$$current_year" \
468             || { echo "$@: cannot get current year" >&2; exit 1; }; \
469         fi; \
470         sed -i "/^RELEASE_YEAR=/s/=.*$$/=$$current_year/" \
471           bootstrap.sh configure.ac; \
472         excluded_re=`( \
473           for url in $(FETCHFILES); do echo "$$url"; done \
474             | sed -e 's!^.*/!!' -e 's!^.*=!!' -e 's!^!lib/!' \
475           && for f in $(files_without_copyright); do echo $$f; done \
476         ) | sed -e '$$!s,$$,|,' | tr -d '\012\015'`; \
477         $(GIT) ls-files \
478           | grep -Ev '(^|/)README$$' \
479           | grep -Ev '^PLANS(/|$$)' \
480           | grep -Ev "^($$excluded_re)$$" \
481           | $(update_copyright_env) xargs $(srcdir)/lib/$@
482
483 # --------------------------------------------------------------- #
484 #  Testing on real-world packages can help us avoid regressions.  #
485 # --------------------------------------------------------------- #
486
487 #
488 # NOTE (from Stefano Lattarini):
489
490 # This section is mostly hacky and ad-hoc, but works for me and
491 # on my system.  And while far from clean, it should help catching
492 # real regressions on real world packages, which is important.
493 # Ideas about how to improve this and make it more generic, portable,
494 # clean, etc., are welcome.
495 #
496
497 # Tiny sample package.
498 FEW_PACKAGES += hello
499 # Smallish package using recursive make setup.
500 FEW_PACKAGES += make
501 # Medium-size package using non-recursive make setup.
502 FEW_PACKAGES += coreutils
503
504 ALL_PACKAGES = \
505   $(FEW_PACKAGES) \
506   autoconf \
507   bison \
508   grep \
509   tar \
510   diffutils \
511   smalltalk
512
513 pkg-targets = check dist
514
515 # Note: "ttp" stays for "Third Party Package".
516
517 ttp-check ttp-check-all: do-clone = $(GIT) clone --verbose
518 ttp-check: ttp-packages = $(FEW_PACKAGES)
519 ttp-check-all: ttp-packages = $(ALL_PACKAGES)
520
521 # Note: some packages depend on pkg-config, and its provided macros.
522 ttp-check ttp-check-all: t/pkg-config-macros.log
523         @set -e; \
524         $(setup_autotools_paths); \
525         skip_all_ () \
526         { \
527           echo "***" >&2; \
528           echo "*** $@: WARNING: $$@" >&2; \
529           echo "*** $@: WARNING: some packages might fail to bootstrap" >&2; \
530           echo "***" >&2;  \
531         }; \
532         . t/pkg-config-macros.dir/get.sh || exit 1; \
533         mkdir $@.d && cd $@.d || exit 1; \
534         for p in $(ttp-packages); do \
535             echo; \
536             echo ========  BEGIN TTP $$p  =========; \
537             echo; \
538             set -x; \
539             $(do-clone) git://$(git-sv-host)/$$p.git || exit 1; \
540             ( \
541               cd $$p \
542                 && ls -l \
543                 && if test -f bootstrap; then \
544                      ./bootstrap --no-git; \
545                    else \
546                      $$AUTORECONF -fvi; \
547                    fi \
548                 && ./configure \
549                 && if test $$p = make; then \
550                      $(MAKE) update; \
551                    else :; fi \
552                 && for t in $(pkg-targets); do \
553                      $(MAKE) $$t WERROR_CFLAGS= || exit 1; \
554                    done \
555             ) || exit 1; \
556             set +x; \
557             echo; \
558             echo ========  END TTP $$p  =========; \
559             echo; \
560          done
561 ifndef keep-ttp-dir
562         rm -rf $@.d
563 endif
564
565 # Alias for lazy typists.
566 ttp: ttp-check
567 ttp-all: ttp-check-all
568
569 .PHONY: ttp ttp-check ttp-all ttp-check-all