ce0e0b4f6cf6a13ce1560686451e3d98c13a8288
[platform/upstream/automake.git] / Makefile.am
1 ## Process this file with automake to create Makefile.in
2
3 ## Makefile for Automake.
4
5 # Copyright (C) 1995-2012 Free Software Foundation, Inc.
6
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2, or (at your option)
10 # any later version.
11
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16
17 # You should have received a copy of the GNU General Public License
18 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
20 ## lib goes first, because it builds Config.pm, used by aclocal and
21 ## automake (run in doc, tests, and in the rebuild rules.)
22 ## `.' goes before doc and tests, because the latter two directories
23 ## run aclocal and automake.
24 SUBDIRS = lib . contrib doc m4 tests
25
26 bin_SCRIPTS = automake aclocal
27
28 CLEANFILES = $(bin_SCRIPTS)
29 AUTOMAKESOURCES = automake.in aclocal.in
30
31 TAGS_FILES = $(AUTOMAKESOURCES)
32
33 EXTRA_DIST = \
34   GNUmakefile \
35   syntax-checks.mk \
36   HACKING \
37   ChangeLog.96 \
38   ChangeLog.98 \
39   ChangeLog.00 \
40   ChangeLog.01 \
41   ChangeLog.02 \
42   ChangeLog.03 \
43   ChangeLog.04 \
44   ChangeLog.09 \
45   ChangeLog.11 \
46   bootstrap \
47   $(gitlog_to_changelog_fixes) \
48   $(AUTOMAKESOURCES)
49
50 ## Make versioned links.  We only run the transform on the root name;
51 ## then we make a versioned link with the transformed base name.  This
52 ## seemed like the most reasonable approach.
53 install-exec-hook:
54         @$(POST_INSTALL)
55         @for p in $(bin_SCRIPTS); do \
56           f="`echo $$p|sed '$(transform)'`"; \
57           fv="$$f-$(APIVERSION)"; \
58           rm -f "$(DESTDIR)$(bindir)/$$fv"; \
59           echo " $(LN) '$(DESTDIR)$(bindir)/$$f' '$(DESTDIR)$(bindir)/$$fv'"; \
60           $(LN) "$(DESTDIR)$(bindir)/$$f" "$(DESTDIR)$(bindir)/$$fv"; \
61         done
62
63 uninstall-hook:
64         @for p in $(bin_SCRIPTS); do \
65           f="`echo $$p|sed '$(transform)'`"; \
66           fv="$$f-$(APIVERSION)"; \
67           rm -f "$(DESTDIR)$(bindir)/$$fv"; \
68         done
69
70
71 ## We can't use configure to do the substitution here; we must do it
72 ## by hand.  We use a funny notation here to avoid configure
73 ## substitutions in our text.
74 do_subst = sed \
75   -e 's,[@]APIVERSION[@],$(APIVERSION),g' \
76   -e 's,[@]PACKAGE[@],$(PACKAGE),g' \
77   -e 's,[@]PACKAGE_BUGREPORT[@],$(PACKAGE_BUGREPORT),g' \
78   -e 's,[@]PACKAGE_URL[@],$(PACKAGE_URL),g' \
79   -e 's,[@]PATH_SEPARATOR[@],$(PATH_SEPARATOR),g' \
80   -e 's,[@]PERL[@],$(PERL),g' \
81   -e 's,[@]PERL_THREADS[@],$(PERL_THREADS),g' \
82   -e 's,[@]SHELL[@],$(SHELL),g' \
83   -e 's,[@]am_AUTOCONF[@],$(am_AUTOCONF),g' \
84   -e 's,[@]am_AUTOM4TE[@],$(am_AUTOM4TE),g' \
85   -e 's,[@]VERSION[@],$(VERSION),g' \
86   -e 's,[@]configure_input[@],Generated from $@.in; do not edit by hand.,g' \
87   -e 's,[@]datadir[@],$(datadir),g'
88
89 ## These files depend on Makefile so they are rebuilt if $(VERSION),
90 ## $(datadir) or other do_subst'ituted variables change.
91 ## Use chmod a-w to prevent people from editing the wrong file by accident.
92 automake: automake.in
93 aclocal: aclocal.in
94 automake aclocal: Makefile
95         $(AM_V_at)rm -f $@ $@-t
96         $(AM_V_GEN)$(do_subst) $(srcdir)/$@.in >$@-t
97         $(AM_V_at)chmod a+x,a-w $@-t && mv -f $@-t $@
98
99 ## The master location for INSTALL is lib/INSTALL.
100 ## This is where `make fetch' will install new versions.
101 ## Make sure we also update this copy.
102 INSTALL: lib/INSTALL
103         $(AM_V_GEN)cp $(srcdir)/lib/INSTALL $@
104
105 # Run the testsuite with the installed aclocal and automake.
106 installcheck-local:
107         am_running_installcheck=yes $(MAKE) $(AM_MAKEFLAGS) check
108
109 # Convenience proxy target for the test suites.
110 recheck:
111         $(am__cd) tests && $(MAKE) $(AM_MAKEFLAGS) $@
112 .PHONY: recheck
113
114 ################################################################
115 ##
116 ## Everything past here is useful to the maintainer, but probably not
117 ## to anybody else
118 ##
119
120 gitlog_to_changelog_command = $(PERL) $(srcdir)/lib/gitlog-to-changelog
121 gitlog_to_changelog_fixes = $(srcdir)/.git-log-fix
122 gitlog_to_changelog_options = --amend=$(gitlog_to_changelog_fixes) \
123                               --since='2011-12-28 00:00:00' \
124                               --no-cluster --format '%s%n%n%b'
125
126 # Automatic generation of the ChangeLog from git history.
127 #
128 # When executed from a git checkout, generate the ChangeLog from the git
129 # history.  When executed from an extracted distribution tarball, just
130 # copy the distributed ChangeLog in the build directory (and if this
131 # fails, or if no distributed ChangeLog file is present, complain and
132 # give an error).
133 #
134 # We need the apparently useless dependency from another .PHONY target
135 # `am--changelog-regen-hook' to work around a bug of Solaris make, which
136 # doesn't execute the recipe of a target named as an existing file, even
137 # if such target is declared `.PHONY' (yikes!)
138 #
139 .PHONY: am--changelog-regen-hook
140 am--changelog-regen-hook:
141 ChangeLog: am--changelog-regen-hook
142         $(AM_V_GEN)set -e; set -u; \
143 ## The ChangeLog should be regenerated unconditionally when working from
144 ## checked-out sources; otherwise, if we're working from a distribution
145 ## tarball, we expect the ChangeLog to be distributed, so check that it
146 ## is indeed present in the source directory.
147         if test -d $(srcdir)/.git; then \
148           rm -f $@-t \
149             && $(gitlog_to_changelog_command) \
150                $(gitlog_to_changelog_options) >$@-t \
151             && chmod a-w $@-t \
152             && mv -f $@-t $@ \
153             || exit 1; \
154         elif test ! -f $(srcdir)/$@; then \
155           echo "Source tree is not a git checkout, and no pre-existent" \
156                "$@ file has been found there" >&2; \
157           exit 1; \
158         fi
159
160 # Ensure tests are world-executable
161 dist-hook:
162         $(am__cd) $(distdir)/tests && chmod a+rx *.test
163
164
165 # Perl coverage statistics.
166 PERL_COVERAGE_DB = $(abs_top_builddir)/cover_db
167 PERL_COVERAGE_FLAGS = -MDevel::Cover=-db,$(PERL_COVERAGE_DB),-silent,on,-summary,off
168 PERL_COVER = cover
169
170 check-coverage-run recheck-coverage-run: all
171         $(mkinstalldirs) $(PERL_COVERAGE_DB)
172         PERL5OPT="$$PERL5OPT $(PERL_COVERAGE_FLAGS)"; export PERL5OPT; \
173         WANT_NO_THREADS=yes; export WANT_NO_THREADS; unset AUTOMAKE_JOBS; \
174         $(MAKE) $(AM_MAKEFLAGS) `echo $@ | sed 's/-coverage-run//'`
175
176 check-coverage-report:
177         @if test ! -d "$(PERL_COVERAGE_DB)"; then \
178           echo "No coverage database found in \`$(PERL_COVERAGE_DB)'." >&2; \
179           echo "Please run \`make check-coverage' first" >&2; \
180           exit 1; \
181         fi
182         $(PERL_COVER) $(PERL_COVER_FLAGS) "$(PERL_COVERAGE_DB)"
183
184 # We don't use direct dependencies here because we'd like to be able
185 # to invoke the report even after interrupted check-coverage.
186 check-coverage: check-coverage-run
187         $(MAKE) $(AM_MAKEFLAGS) check-coverage-report
188
189 recheck-coverage: recheck-coverage-run
190         $(MAKE) $(AM_MAKEFLAGS) check-coverage-report
191
192 clean-coverage:
193         rm -rf "$(PERL_COVERAGE_DB)"
194 clean-local: clean-coverage
195
196 .PHONY: check-coverage recheck-coverage check-coverage-run \
197         recheck-coverage-run check-coverage-report clean-coverage
198
199 ## Tagging and/or uploading stable and beta releases.
200
201 GIT = git
202
203 version_rx = ^[1-9][0-9]*\.[0-9][0-9]*(\.[0-9][0-9]*)?
204 stable_version_rx = $(version_rx)$$
205 beta_version_rx = $(version_rx)[bdfhjlnprtvxz]$$
206 match_version = echo "$(VERSION)" | $(EGREP) >/dev/null
207
208 ## Check that we don't have uncommitted or unstaged changes.
209 ## TODO: Maybe the git suite already offers a shortcut to verify if the
210 ## TODO: working directory is "clean" or not?  If yes, use that instead
211 ## TODO: of duplicating the logic here.
212 git_must_have_clean_workdir = \
213   $(GIT) rev-parse --verify HEAD >/dev/null \
214     && $(GIT) update-index -q --refresh \
215     && $(GIT) diff-files --quiet \
216     && $(GIT) diff-index --quiet --cached HEAD \
217     || fatal "you have uncommitted or unstaged changes"
218
219 determine_release_type = \
220   if $(match_version) '$(stable_version_rx)'; then \
221     release_type='Release' dest=ftp; \
222   elif $(match_version) '$(beta_version_rx)'; then \
223     release_type='Beta release' dest=alpha; \
224   else \
225     fatal "invalid version '$(VERSION)' for a release"; \
226   fi
227
228 git-tag-release: maintainer-check
229         @set -e; set -u; \
230         fatal () { echo "$@: $$*; not tagging" >&2; exit 1; }; \
231         case '$(AM_TAG_DRYRUN)' in \
232           ""|[nN]|[nN]o|NO) run="";; \
233           *) run="echo Running:";; \
234         esac; \
235         $(determine_release_type); \
236         $(git_must_have_clean_workdir); \
237 ## Make sure the NEWS file is up-to-date.
238         sed 1q $(srcdir)/NEWS | grep '$(VERSION)' >/dev/null \
239           || fatal "NEWS not updated"; \
240 ## If all was successful, tag the release in the local repository.
241         $$run $(GIT) tag -s "v$(VERSION)" -m "$$release_type $(VERSION)"
242
243 git-upload-release:
244         @set -e; set -u; \
245         fatal () { echo "$@: $$*; not releasing" >&2; exit 1; }; \
246         $(determine_release_type); \
247         dest=$$dest.gnu.org:automake; \
248         $(git_must_have_clean_workdir); \
249 ## Check that we are releasing from a valid tag.
250         tag=`$(GIT) describe` \
251           && case $$tag in "v$(VERSION)") true;; *) false;; esac \
252           || fatal "you can only create a release from a tagged version"; \
253 ## Build and upload the distribution tarball(s).
254         $(MAKE) $(AM_MAKEFLAGS) dist || exit 1; \
255         echo Will upload to $$dest: $(DIST_ARCHIVES); \
256         $(srcdir)/lib/gnupload $(GNUPLOADFLAGS) --to $$dest $(DIST_ARCHIVES)
257
258 .PHONY: git-upload-release git-tag-release
259
260 ## Visually comparing differences between the Makefile.in files in
261 ## automake's own build system as generated in two different branches
262 ## might help to catch bugs and blunders.  This has already happened a
263 ## few times in the past, when we used to version-control Makefile.in.
264 autodiffs:
265         @set -u; \
266          NEW_COMMIT=$${NEW_COMMIT-"HEAD"}; \
267          OLD_COMMIT=$${OLD_COMMIT-"HEAD~1"}; \
268          am_gitdir='$(abs_top_srcdir)/.git'; \
269          get_autofiles_from_rev () \
270          { \
271              rev=$$1 dir=$$2 \
272                && echo "$@: will get files from revision $$rev" \
273                && $(GIT) clone -q --depth 1 "$$am_gitdir" tmp \
274                && $(am__cd) tmp \
275                && $(GIT) checkout -q "$$rev" \
276                && echo "$@: bootstrapping $$rev" \
277                && $(SHELL) ./bootstrap \
278                && echo "$@: copying files from $$rev" \
279                && makefile_ins=`find . -name Makefile.in` \
280                && (tar cf - configure aclocal.m4 $$makefile_ins) | \
281                   (cd .. && $(am__cd) "$$dir" && tar xf -) \
282                && cd .. \
283                && rm -rf tmp; \
284          }; \
285          outdir=$@.dir \
286 ## Before proceeding, ensure the specified revisions truly exist.
287            && $(GIT) --git-dir="$$am_gitdir" describe $$OLD_COMMIT >/dev/null \
288            && $(GIT) --git-dir="$$am_gitdir" describe $$NEW_COMMIT >/dev/null \
289            && rm -rf $$outdir \
290            && mkdir $$outdir \
291            && $(am__cd) $$outdir \
292            && mkdir new old \
293            && get_autofiles_from_rev $$OLD_COMMIT old \
294            && get_autofiles_from_rev $$NEW_COMMIT new \
295            && exit 0
296 ## With lots of eye candy; we like our developers pampered and spoiled :-)
297 compare-autodiffs: autodiffs
298         @set -u; \
299         : $${COLORDIFF=colordiff} $${DIFF=diff}; \
300         dir=autodiffs.dir; \
301         if test ! -d "$$dir"; then \
302           echo "$@: $$dir: Not a directory" >&2; \
303           exit 1; \
304         fi; \
305         mydiff=false mypager=false; \
306         if test -t 1; then \
307           if ($$COLORDIFF -r . .) </dev/null >/dev/null 2>&1; then \
308             mydiff=$$COLORDIFF; \
309             mypager="less -R"; \
310           else \
311             mypager=less; \
312           fi; \
313         else \
314           mypager=cat; \
315         fi; \
316         if test "$$mydiff" = false; then \
317           if ($$DIFF -r -u . .); then \
318             mydiff=$$DIFF; \
319           else \
320             echo "$@: no good-enough diff program specified" >&2; \
321             exit 1; \
322           fi; \
323         fi; \
324         st=0; $$mydiff -r -u $$dir/old $$dir/new | $$mypager || st=$$?; \
325         rm -rf $$dir; \
326         exit $$st
327 .PHONY: autodiffs compare-autodiffs
328
329 ## Program to use to fetch files.
330 WGET = wget
331 WGET_SV_CVS = $(WGET) http://savannah.gnu.org/cgi-bin/viewcvs/~checkout~/
332 WGET_SV_GIT_CF = $(WGET) 'http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;hb=HEAD;f='
333 WGET_SV_GIT_AC = $(WGET) 'http://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=blob_plain;hb=HEAD;f='
334 WGET_SV_GIT_GL = $(WGET) 'http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob_plain;hb=HEAD;f='
335
336 ## Files that we fetch and which we compare against.
337 ## The 'lib/COPYING' file must still be synced by hand.
338 FETCHFILES = \
339 INSTALL \
340 config.guess \
341 config.sub \
342 gnupload \
343 gitlog-to-changelog \
344 texinfo.tex \
345 update-copyright
346
347 ## Fetch the latest versions of files we care about.
348 fetch:
349         rm -rf Fetchdir > /dev/null 2>&1
350         mkdir Fetchdir
351 ## If a get fails then that is a problem.
352         ($(am__cd) Fetchdir && \
353         $(WGET_SV_GIT_CF)config.guess -O config.guess && \
354         $(WGET_SV_GIT_CF)config.sub -O config.sub && \
355         $(WGET_SV_CVS)texinfo/texinfo/doc/texinfo.tex -O texinfo.tex && \
356         $(WGET_SV_GIT_GL)doc/INSTALL -O INSTALL && \
357         $(WGET_SV_GIT_GL)build-aux/gnupload -O gnupload && \
358         $(WGET_SV_GIT_GL)build-aux/update-copyright -O update-copyright && \
359         $(WGET_SV_GIT_GL)build-aux/gitlog-to-changelog -O gitlog-to-changelog)
360 ## Don't exit after test because we want to give as many errors as
361 ## possible.
362         @stat=0; for file in $(FETCHFILES); do \
363           if diff -u $(srcdir)/lib/$$file Fetchdir/$$file \
364                   >>Fetchdir/update.patch 2>/dev/null; then :; \
365           else \
366             stat=1; \
367             echo "Updating $(srcdir)/lib/$$file ..."; \
368             cp Fetchdir/$$file $(srcdir)/lib/$$file; \
369           fi; \
370         done; \
371         test $$stat = 0 || \
372           echo "See Fetchdir/update.patch for a log of the changes."; \
373         exit $$stat
374 .PHONY: fetch
375
376 update_copyright_env = \
377   UPDATE_COPYRIGHT_FORCE=1 \
378   UPDATE_COPYRIGHT_USE_INTERVALS=2
379
380 .PHONY: update-copyright
381 update-copyright:
382         $(AM_V_GEN)excluded_re=`echo $(FETCHFILES) \
383           | sed -e 's|^|lib/|' -e 's| | lib/|g' -e 's, ,|,g'`; \
384         $(GIT) ls-files \
385           | grep -Ev '^(lib/)?(COPYING|INSTALL)$$' \
386           | grep -Ev "^($$excluded_re)$$" \
387           | $(update_copyright_env) xargs $(srcdir)/lib/$@