1 # Maintainer makefile rules for Automake.
3 # Copyright (C) 1995-2013 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 # Avoid CDPATH issues.
21 # --------------------------------------------------------- #
22 # Automatic generation of the ChangeLog from git history. #
23 # --------------------------------------------------------- #
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'
31 EXTRA_DIST
+= lib
/gitlog-to-changelog
32 EXTRA_DIST
+= $(gitlog_to_changelog_fixes
)
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
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.
45 $(AM_V_GEN
)set
-e
; set
-u
; \
46 if
test -d
$(srcdir)/.git
; then \
48 && $(gitlog_to_changelog_command
) \
49 $(gitlog_to_changelog_options
) >$@
-t \
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; \
61 # --------------------------- #
62 # Perl coverage statistics. #
63 # --------------------------- #
65 PERL_COVERAGE_DB
= $(abs_top_builddir
)/cover_db
66 PERL_COVERAGE_FLAGS
= -MDevel
::Cover
=-db
,$(PERL_COVERAGE_DB
),-silent
,on
,-summary
,off
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
; \
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; \
81 $(PERL_COVER
) $(PERL_COVER_FLAGS
) "$(PERL_COVERAGE_DB)"
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
88 recheck-coverage
: recheck-coverage-run
89 $(MAKE
) check-coverage-report
92 rm -rf
"$(PERL_COVERAGE_DB)"
93 clean-local
: clean-coverage
95 .PHONY
: check-coverage recheck-coverage check-coverage-run \
96 recheck-coverage-run check-coverage-report clean-coverage
99 # ---------------------------------------------------- #
100 # Tagging and/or uploading stable and beta releases. #
101 # ---------------------------------------------------- #
105 EXTRA_DIST
+= lib
/gnupload
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
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; }
124 determine_release_type
= \
125 if
$(match_version
) '$(stable_major_version_rx)'; then \
126 release_type
='Major release'; \
127 announcement_type
='major release'; \
129 elif
$(match_version
) '$(stable_minor_version_rx)'; then \
130 release_type
='Minor release'; \
131 announcement_type
='maintenance release'; \
133 elif
$(match_version
) '$(beta_version_rx)'; then \
134 release_type
='Beta release'; \
135 announcement_type
='test release'; \
138 echo
"$@: invalid version '$(VERSION)' for a release" >&2; \
142 # Help the debugging of $(determine_release_type) and related code.
144 @
$(determine_release_type
); \
145 echo
"$$release_type $(VERSION);" \
146 "it will be announced as a $$announcement_type"
148 git-tag-release
: maintainer-check
150 case
'$(AM_TAG_DRYRUN)' in \
151 ""|
[nN
]|
[nN
]o|NO
) run
="";; \
152 *) run
="echo Running:";; \
154 $(determine_release_type
); \
155 $(git_must_have_clean_workdir
); \
156 $$run $(GIT
) tag
-s
"v$(VERSION)" -m
"$$release_type $(VERSION)"
159 @
# Check this is a version we can cut a release (either test
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" \
170 @
# Build the distribution tarball(s).
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 \
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 ..
&& 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 \
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 && $(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." \
271 && X
"**TODO** Brief description of the release here." \
273 && X
"**TODO** This description can span multiple paragraphs." \
275 && X
"See below for the detailed list of changes since the" \
276 && X
"previous version, as summarized by the NEWS file." \
278 && X
"Download here:" \
280 && X
" $$ftp_base/$(PACKAGE)-$(VERSION).tar.gz" \
281 && X
" $$ftp_base/$(PACKAGE)-$(VERSION).tar.xz" \
283 && X
"Please report bugs and problems to" \
284 "<$(PACKAGE_BUGREPORT)>," \
285 && X
"and send general comments and feedback to" \
286 "<$(PACKAGE_MAILINGLIST)>." \
288 && X
"Thanks to everyone who has reported problems, contributed" \
289 && X
"patches, and helped testing Automake!" \
293 && sed
-n
-e
'/^~~~/q' -e p
$(srcdir)/NEWS
>> $@
-t \
296 CLEANFILES
+= announcement
298 # --------------------------------------------------------------------- #
299 # Synchronize third-party files that are committed in our repository. #
300 # --------------------------------------------------------------------- #
302 # Program to use to fetch files.
305 # Git repositories on Savannah.
306 git-sv-host
= git.savannah.gnu.org
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='
314 # Files that we fetch and which we compare against.
315 # Note that the 'lib/COPYING' file must still be synced by hand.
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
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.
331 $(AM_V_at
)rm -rf Fetchdir
332 $(AM_V_at
)mkdir Fetchdir
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 \
341 echo
"$@: updating file $$file"; \
342 cp Fetchdir
/$$file $(srcdir)/lib
/$$file || exit
1; \
345 $(AM_V_at
)rm -rf Fetchdir
348 # ---------------------------------------------------------------------- #
349 # Generate and upload manuals in several formats, for the GNU website. #
350 # ---------------------------------------------------------------------- #
352 web_manual_dir
= doc
/web-manual
358 WEBCVS_ROOT
= cvs.savannah.gnu.org
:/web
362 .PHONY
: web-manual web-manual-update
363 web-manual web-manual-update
: t
= $@.
dir
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.
371 $(AM_V_at
)rm -rf
$(web_manual_dir
) $t
373 $(AM_V_at
)$(LN_S
) '$(abs_srcdir)/doc/$(PACKAGE).texi' '$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
)
384 @
! $(AM_V_P
) || ls
-l
$(web_manual_dir
)
386 # Upload manual to www.gnu.org, using CVS (sigh!)
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; \
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; \
402 && $(CVS
) -z3
-d
:ext
:$(CVS_USER
)@
$(WEBCVS_ROOT
)/$(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
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
)
416 .PHONY
: web-manual-update
419 $(AM_V_at
)rm -rf
$(web_manual_dir
)
420 .PHONY
: clean-web-manual
421 clean-local
: clean-web-manual
423 EXTRA_DIST
+= lib
/gendocs.sh lib
/gendocs_template
425 # ------------------------------------------------ #
426 # Update copyright years of all committed files. #
427 # ------------------------------------------------ #
429 EXTRA_DIST
+= lib
/update-copyright
431 update_copyright_env
= \
432 UPDATE_COPYRIGHT_FORCE
=1 \
433 UPDATE_COPYRIGHT_USE_INTERVALS
=2
435 # In addition to the several README files, these as well are
436 # not expected to have a copyright notice.
437 files_without_copyright
= \
449 # This script is in the public domain.
450 files_without_copyright
+= lib
/mkinstalldirs
452 # This script has an MIT-style license
453 files_without_copyright
+= lib
/install-sh
455 .PHONY
: update-copyright
458 current_year
=`date +%Y` && test -n
"$$current_year" \
459 ||
{ echo
"$@: cannot get current year" >&2; exit
1; }; \
460 sed
-i
"/^RELEASE_YEAR=/s/=.*$$/=$$current_year/" \
461 bootstrap.sh configure.ac
; \
463 for url in $(FETCHFILES); do echo "$$url"; done \
464 | sed -e 's!^.*/!!' -e 's!^.*=!!' -e 's!^!lib/!' \
465 && for f in $(files_without_copyright); do echo $$f; done \
466 ) | sed -e '$$!s,$$,|,' | tr -d '\012\015'`; \
468 | grep
-Ev
'(^|/)README$$' \
469 | grep
-Ev
"^($$excluded_re)$$" \
470 |
$(update_copyright_env
) xargs
$(srcdir)/lib
/$@
472 # --------------------------------------------------------------- #
473 # Testing on real-world packages can help us avoid regressions. #
474 # --------------------------------------------------------------- #
477 # NOTE (from Stefano Lattarini):
479 # This section is mostly hacky and ad-hoc, but works for me and
480 # on my system. And while far from clean, it should help catching
481 # real regressions on real world packages, which is important.
482 # Ideas about how to improve this and make it more generic, portable,
483 # clean, etc., are welcome.
486 # Tiny sample package.
487 FEW_PACKAGES
+= hello
488 # Smallish package using recursive make setup.
490 # Medium-size package using non-recursive make setup.
491 FEW_PACKAGES
+= coreutils
502 pkg-targets
= check dist
504 # Note: "ttp" stays for "Third Party Package".
506 ttp-check ttp-check-all
: do-clone
= $(GIT
) clone
--verbose
507 ttp-check
: ttp-packages
= $(FEW_PACKAGES
)
508 ttp-check-all
: ttp-packages
= $(ALL_PACKAGES
)
510 # Note: some packages depend on pkg-config, and its provided macros.
511 ttp-check ttp-check-all
: t
/pkg-config-macros.log
513 $(setup_autotools_paths
); \
517 echo
"*** $@: WARNING: $$@" >&2; \
518 echo
"*** $@: WARNING: some packages might fail to bootstrap" >&2; \
521 . t
/pkg-config-macros.
dir/get.sh || exit
1; \
522 mkdir
$@.d
&& cd
$@.d || exit
1; \
523 for p in
$(ttp-packages
); do \
525 echo
======== BEGIN TTP
$$p =========; \
528 $(do-clone
) git
://$(git-sv-host
)/$$p.git || exit
1; \
532 && if
test -f bootstrap
; then \
533 .
/bootstrap
--no-git
; \
538 && if
test $$p = make
; then \
541 && for t in
$(pkg-targets
); do \
542 $(MAKE
) $$t WERROR_CFLAGS
= || exit
1; \
547 echo
======== END TTP
$$p =========; \
554 # Alias for lazy typists.
556 ttp-all
: ttp-check-all
558 .PHONY
: ttp ttp-check ttp-all ttp-check-all