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