Add depmode=msvcmsys for Microsoft Visual C++ on MSYS.
[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, 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004,
6 ## 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
7
8 ## This program is free software; you can redistribute it and/or modify
9 ## it under the terms of the GNU General Public License as published by
10 ## the Free Software Foundation; either version 3, or (at your option)
11 ## any later version.
12
13 ## This program is distributed in the hope that it will be useful,
14 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 ## GNU General Public License for more details.
17
18 ## You should have received a copy of the GNU General Public License
19 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
21 ## lib goes first, because it builds Config.pm, used by aclocal and
22 ## automake (run in doc, tests, and in the rebuild rules.)
23 ## `.' goes before doc and tests, because the latter two directories
24 ## run aclocal and automake.
25 SUBDIRS = lib . doc m4 tests
26
27 bin_SCRIPTS = automake aclocal
28
29 CLEANFILES = $(bin_SCRIPTS)
30 AUTOMAKESOURCES = automake.in aclocal.in
31
32 TAGS_FILES = $(AUTOMAKESOURCES)
33
34 EXTRA_DIST = \
35   ChangeLog.96 \
36   ChangeLog.98 \
37   ChangeLog.00 \
38   ChangeLog.01 \
39   ChangeLog.02 \
40   ChangeLog.03 \
41   ChangeLog.04 \
42   $(AUTOMAKESOURCES)
43
44 ## Make versioned links.  We only run the transform on the root name;
45 ## then we make a versioned link with the transformed base name.  This
46 ## seemed like the most reasonable approach.
47 install-exec-hook:
48         @$(POST_INSTALL)
49         @for p in $(bin_SCRIPTS); do \
50           f="`echo $$p|sed '$(transform)'`"; \
51           fv="$$f-$(APIVERSION)"; \
52           rm -f $(DESTDIR)$(bindir)/$$fv; \
53           echo " $(LN) $(DESTDIR)$(bindir)/$$f $(DESTDIR)$(bindir)/$$fv"; \
54           $(LN) $(DESTDIR)$(bindir)/$$f $(DESTDIR)$(bindir)/$$fv; \
55         done
56
57 uninstall-hook:
58         @for p in $(bin_SCRIPTS); do \
59           f="`echo $$p|sed '$(transform)'`"; \
60           fv="$$f-$(APIVERSION)"; \
61           rm -f $(DESTDIR)$(bindir)/$$fv; \
62         done
63
64
65 ## We can't use configure to do the substitution here; we must do it
66 ## by hand.  We use a funny notation here to avoid configure
67 ## substitutions in our text.
68 do_subst = sed \
69   -e 's,[@]APIVERSION[@],$(APIVERSION),g' \
70   -e 's,[@]PACKAGE[@],$(PACKAGE),g' \
71   -e 's,[@]PATH_SEPARATOR[@],$(PATH_SEPARATOR),g' \
72   -e 's,[@]PERL[@],$(PERL),g' \
73   -e 's,[@]PERL_THREADS[@],$(PERL_THREADS),g' \
74   -e 's,[@]SHELL[@],$(SHELL),g' \
75   -e 's,[@]VERSION[@],$(VERSION),g' \
76   -e 's,[@]configure_input[@],Generated from $@.in; do not edit by hand.,g' \
77   -e 's,[@]datadir[@],$(datadir),g'
78
79 ## These files depend on Makefile so they are rebuilt if $(VERSION),
80 ## $(datadir) or other do_subst'ituted variables change.
81 ## Use chmod a-w to prevent people from editing the wrong file by accident.
82 automake: automake.in
83 aclocal: aclocal.in
84 automake aclocal: Makefile
85         rm -f $@ $@.tmp
86         $(do_subst) $(srcdir)/$@.in >$@.tmp
87         chmod +x $@.tmp
88         chmod a-w $@.tmp
89         mv -f $@.tmp $@
90
91 ## The master location for INSTALL is lib/INSTALL.
92 ## This is where `make fetch' will install new versions.
93 ## Make sure we also update this copy.
94 INSTALL: lib/INSTALL
95         cp $(srcdir)/lib/INSTALL $@
96
97 ################################################################
98 ##
99 ## Everything past here is useful to the maintainer, but probably not
100 ## to anybody else
101 ##
102
103 # Ensure tests are world-executable
104 dist-hook:
105         cd $(distdir)/tests && chmod a+rx *.test
106
107 # Some simple checks, and then ordinary check.  These are only really
108 # guaranteed to work on my machine.
109 maintainer-check: automake aclocal
110 ## This check avoids accidental configure substitutions in the source.
111 ## There are exactly 6 lines that should be modified.  This works out
112 ## to 22 lines of diffs.
113         @if test `diff $(srcdir)/automake.in automake | wc -l` -ne 22; then \
114           echo "found too many diffs between automake.in and automake"; 1>&2; \
115           diff -c $(srcdir)/automake.in automake; \
116           exit 1; \
117         fi
118 ## Syntax check with default Perl (on my machine, Perl 5).
119         perllibdir="./lib$(PATH_SEPARATOR)$(srcdir)/lib" $(PERL) -c -w automake
120         perllibdir="./lib$(PATH_SEPARATOR)$(srcdir)/lib" $(PERL) -c -w aclocal
121 ## expect no instances of '${...}'.  However, $${...} is ok, since that
122 ## is a shell construct, not a Makefile construct.
123         @if grep -F '$${' $(srcdir)/lib/am/[a-z]*.am | \
124                grep -F -v '$$$$'; then \
125           echo "Found too many uses of '\$${' in the lines above." 1>&2; \
126           exit 1;                               \
127         else :; fi
128 ## Make sure `rm' is called with `-f'.
129         @if grep -v '^#' $(srcdir)/lib/am/[a-z]*.am $(srcdir)/tests/*.test | \
130             grep -E '\<rm ([^-]|\-[^f ]*\>)'; then \
131           echo "Suspicious 'rm' invocation." 1>&2; \
132           exit 1;                               \
133         else :; fi
134 ## Never use something like `for file in $(FILES)', this doesn't work
135 ## if FILES is empty or if it contains shell meta characters (e.g. $ is
136 ## commonly used in Java filenames).
137         @if grep 'for .* in \$$(' $(srcdir)/lib/am/[a-z]*.am; then \
138           echo 'Use "list=$$(mumble); for var in $$$$list".' 1>&2 ; \
139           exit 1; \
140         else :; fi
141 ## Make sure all invocations of mkinstalldirs are correct.
142         @if grep -n 'mkinstalldirs' $(srcdir)/lib/am/[a-z]*.am | \
143               grep -F -v '$$(mkinstalldirs)'; then \
144           echo "Found incorrect use of mkinstalldirs in the lines above" 1>&2; \
145           exit 1; \
146         else :; fi
147 ## Make sure all calls to PRE/NORMAL/POST_INSTALL/UNINSTALL
148         @if grep -E -n '\((PRE|NORMAL|POST)_(|UN)INSTALL\)' \
149                  $(srcdir)/lib/am/[a-z]*.am | \
150               grep -v ':##' | grep -v ':        @\$$('; then \
151           echo "Found incorrect use of PRE/NORMAL/POST_INSTALL/UNINSTALL in the lines above" 1>&2; \
152           exit 1; \
153         else :; fi
154 ## We never want to use "undef", only "delete", but for $/.
155         @if grep -n -w 'undef ' $(srcdir)/automake.in | \
156               grep -F -v 'undef $$/'; then \
157           echo "Found undef in automake.in; use delete instead" 1>&2; \
158           exit 1; \
159         fi
160 ## We never want split (/ /,...), only split (' ', ...).
161         @if grep -n 'split (/ /' $(srcdir)/automake.in; then \
162           echo "Found bad split in the lines above." 1>&2; \
163           exit 1; \
164         fi
165 ## Look for cd within backquotes
166         @if grep -n '^[^#]*` *cd ' $(srcdir)/automake.in \
167               $(srcdir)/lib/am/*.am; then \
168           echo "Consider using \$$(am__cd) in the lines above." 1>&2; \
169           exit 1; \
170         fi
171 ## Look for cd to a relative directory (may be influenced by CDPATH).
172 ## Skip some known directories that are OK.
173         @if grep -n '^[^#]*cd ' $(srcdir)/automake.in \
174               $(srcdir)/lib/am/*.am | \
175               grep -v 'echo.*cd ' | \
176               grep -v 'am__cd =' | \
177               grep -v '^[^#]*cd [./]' | \
178               grep -v '^[^#]*cd \$$(top_builddir)' | \
179               grep -v '^[^#]*cd "\$$\$$am__cwd' | \
180               grep -v '^[^#]*cd \$$(abs' | \
181               grep -v '^[^#]*cd "\$$(DESTDIR)'; then \
182           echo "Consider using \$$(am__cd) in the lines above." 1>&2; \
183           exit 1; \
184         fi
185 ## Using @_ in a scalar context is most probably a programming error.
186         @if grep -Hn '[^@_A-Za-z0-9][_A-Za-z0-9]*[^) ] *= *@_' $(srcdir)/automake.in; then \
187           echo "Using @_ in a scalar context in the lines above." 1>&2; \
188           exit 1; \
189         fi
190 ## Forbid using parens with `local' to ease counting.
191         @if grep '^[ \t]*local *(' $(srcdir)/automake.in; then \
192           echo "Don't use \`local' with parens: use several \`local' above." >&2; \
193           exit 1; \
194         fi
195 ## Allow only `local $_' in Automake.
196         @if grep -v '^[ \t]*local \$$_;' $(srcdir)/automake.in | \
197                 grep '^[ \t]*local [^*]'; then \
198           echo "Please avoid \`local'." 1>&2; \
199           exit 1; \
200         fi
201 ## Don't let AMDEP_TRUE substitution appear in automake.in.
202         @if grep '@AMDEP''_TRUE@' $(srcdir)/automake.in; then \
203           echo "Don't put AMDEP_TRUE substitution in automake.in" 1>&2; \
204           exit 1; \
205         fi
206 ## Tests should never call make directly.
207         @if grep '^[^#].*(MAKE) ' $(srcdir)/lib/am/*.am $(srcdir)/automake.in |\
208                 grep -v 'AM_MAKEFLAGS'; then \
209           echo 'Use $$(MAKE) $$(AM_MAKEFLAGS).' 1>&2; \
210           exit 1; \
211         fi
212 ## Tests should never call make directly.
213         @if grep -v '^#' $(srcdir)/tests/*.test | grep ':[      ]*make'; then \
214           echo 'Do not run "make" in the above tests.  Use "$$MAKE" instead.' 1>&2; \
215           exit 1; \
216         fi
217 ## Tests should never call autoconf directly.
218         @if grep -v '^#' $(srcdir)/tests/*.test | grep ':[      ]*autoconf'; then \
219           echo 'Do not run "autoconf" in the above tests.  Use "$$AUTOCONF" instead.' 1>&2; \
220           exit 1; \
221         fi
222 ## Tests should never call autoupdate directly.
223         @if grep -v '^#' $(srcdir)/tests/*.test | grep ':[      ]*autoupdate'; then \
224           echo 'Do not run "autoupdate" in the above tests.  Use "$$AUTOUPDATE" instead.' 1>&2; \
225           exit 1; \
226         fi
227 ## Tests should never call automake directly.
228         @if grep -v '^#' $(srcdir)/tests/*.test | grep -E ':[   ]*automake([^:]|$$)'; then \
229           echo 'Do not run "automake" in the above tests.  Use "$$AUTOMAKE" instead.' 1>&2;  \
230           exit 1; \
231         fi
232 ## Tests should only use END and EOF for here documents
233 ## (so that the next test is effective).
234         @if grep '<<' $(srcdir)/tests/*.test | grep -v 'END' | grep -v 'EOF'; then \
235           echo 'Use here documents with "END" and "EOF" only, for greppability.' 1>&2; \
236           exit 1; \
237         fi
238 ## Tests should never call exit directly, but use Exit.
239 ## This is so that the exit status is transported correctly across the 0 trap.
240 ## Ignore comments, and ignore one perl line in ext2.test.
241         @found=false; for file in $(srcdir)/tests/*.test; do \
242           res=`sed -n '/^#/d; /^\$$PERL/d; /<<.*END/,/^END/{b;}; /<<.*EOF/,/^EOF/{b;}; /exit [$$0-9]/p' $$file`; \
243           if test -n "$$res"; then \
244             echo "$$file:$$res"; \
245             found=true; \
246           fi; \
247         done; \
248         if $$found; then \
249           echo 'Do not call plain "exit", use "Exit" instead, in above tests.' 1>&2; \
250           exit 1; \
251         fi
252 ## Use AUTOMAKE_fails when appropriate
253         @if grep -v '^#' $(srcdir)/tests/*.test | grep '\$$AUTOMAKE.*&&.*[eE]xit'; then \
254           echo 'Use AUTOMAKE_fails + grep to catch automake failures in the above tests.' 1>&2;  \
255           exit 1; \
256         fi
257 ## Tests should never call aclocal directly.
258         @if grep -v '^#' $(srcdir)/tests/*.test | grep ':[      ]*aclocal'; then \
259           echo 'Do not run "aclocal" in the above tests.  Use "$$ACLOCAL" instead.' 1>&2;  \
260           exit 1; \
261         fi
262 ## Tests should never call perl directly.
263         @if grep -v '^#' $(srcdir)/tests/*.test | grep ':[      ]*perl'; then \
264           echo 'Do not run "perl" in the above tests.  Use "$$PERL" instead.' 1>&2; \
265           exit 1; \
266         fi
267 ## Setting `required' after sourcing `./defs' is a bug.
268         @for file in $(srcdir)/tests/*.test; do \
269           if out=`sed -n '/defs/,$${/required=/p;}' $$file`; test -n "$$out"; then \
270             echo 'Do not set "required" after sourcing "defs" in '"$$file: $$out" 1>&2; \
271             exit 1; \
272           fi; \
273         done
274 ## Overriding a Makefile macro on the command line is not portable when
275 ## recursive targets are used.  Better use an envvar.  SHELL is an exception,
276 ## POSIX says it can't come from the environment.
277         @if grep -E '\$$MAKE .*(SHELL=.*=|=.*SHELL=)' $(srcdir)/tests/*.test; then \
278           echo 'Rewrite "$$MAKE foo=bar SHELL=$$SHELL" as "foo=bar $$MAKE -e SHELL=$$SHELL"' 1>&2; \
279           echo ' in the above lines, it is more portable.' 1>&2; \
280           exit 1; \
281         fi
282         @if grep -v SHELL $(srcdir)/tests/*.test | grep '\$$MAKE .*=' ; then \
283           echo 'Rewrite "$$MAKE foo=bar" as "foo=bar $$MAKE -e" in the above lines,' 1>&2; \
284           echo 'it is more portable.' 1>&2; \
285           exit 1; \
286         fi
287         @if grep 'SHELL=.*\$$MAKE' $(srcdir)/tests/*.test; then \
288           echo '$$MAKE ignores the SHELL envvar, use "$$MAKE SHELL=$$SHELL" in' 1>&2; \
289           echo 'the above lines.' 1>&2; \
290           exit 1; \
291         fi
292 ## Never use `sleep 1' to create files with different timestamps.
293 ## Use `$sleep' instead.  Some filesystems (e.g., Windows') have only
294 ## a 2sec resolution.
295         @if grep -E '\bsleep +[12345]\b' $(srcdir)/tests/*.test; then \
296           echo 'Do not use "sleep x" in the above tests.  Use "$$sleep" instead.' 1>&2; \
297           exit 1; \
298         fi
299 ## fgrep and egrep are not required by POSIX.
300         @if grep -E '\b[ef]grep\b' $(srcdir)/tests/*.test ; then \
301           echo 'Do not use egrep or fgrep in test cases.  Use $$FGREP or $$EGREP.' 1>&2; \
302           exit 1; \
303         fi
304         @if grep -E '\b[ef]grep\b' $(srcdir)/lib/am/*.am $(srcdir)/m4/*.m4; then \
305           echo 'Do not use egrep or fgrep in the above files, they are not portable.' 1>&2; \
306           exit 1; \
307         fi
308         @if grep 'mkdir_p' $(srcdir)/automake.in \
309               $(srcdir)/lib/am/*.am $(srcdir)/tests/*.test; then \
310           echo 'Do not use mkdir_p in the above files, use MKDIR_P.' 1>&2; \
311           exit 1; \
312         fi
313 ## Try to make sure all @...@ substitutions are covered by our
314 ## substitution rule.
315         @if test `grep -E '^[^#]*@[A-Za-z_0-9]+@' aclocal | wc -l` -ne 0; then \
316           echo "Unresolved @...@ substitution in aclocal" 1>&2; \
317           exit 1; \
318         fi
319         @if test `grep -E '^[^#]*@[A-Za-z_0-9]+@' automake | wc -l` -ne 0; then \
320           echo "Unresolved @...@ substitution in automake" 1>&2; \
321           exit 1; \
322         fi; \
323         if grep -E "[^\'\"]\\\$$\(DESTDIR" $(srcdir)/lib/am/*.am; then \
324           echo 'Suspicious unquoted DESTDIR uses.' 1>&2 ; \
325           exit 1; \
326         fi
327         @if grep '      ' $(srcdir)/doc/automake.texi; then \
328           echo 'Do not use tabs in the manual.' 1>&2; \
329           exit 1; \
330         fi
331         @if grep -E '([^@]|^)@([         ][^@]|$$)' $(srcdir)/doc/automake.texi; \
332         then \
333           echo 'Unescaped @.' 1>&2; \
334           exit 1; \
335         fi
336
337
338 git-dist: maintainer-check
339 ## Make sure the NEWS file is up-to-date.
340         @if sed 1q $(srcdir)/NEWS | grep -e "$(VERSION)" > /dev/null; then :; else \
341           echo "NEWS not updated; not releasing" 1>&2; \
342           exit 1;                               \
343         fi
344 ## Build the distribution
345         $(MAKE) $(AM_MAKEFLAGS) distcheck
346 ## Finally, if anything was successful, commit the last changes and tag
347 ## the release in the repository.  We don't use RCS keywords so it's OK
348 ## to distribute the files before they were committed.
349         cd $(srcdir) && git commit -a -s && \
350            git tag -s "v$(VERSION)" -m "Release $(VERSION)"
351
352 git-release: git-dist
353         case $(VERSION) in \
354           *[a-z]) dest=alpha;; \
355           *)      dest=ftp;; \
356         esac; \
357         $(srcdir)/lib/gnupload $(GNUPLOADFLAGS) \
358           --to $$dest.gnu.org:automake $(DIST_ARCHIVES)
359
360 git-diff:
361         thisver="v$(VERSION)"; \
362         if test -z "$$OLDVERSION"; then \
363           prevno=`echo "$(VERSION)" - 0.01 | bc | sed 's/^\./0./'`; \
364         else prevno="$$OLDVERSION"; fi; \
365         prevver=v$$prevno; \
366         git diff $$prevver..$$thisver $(PACKAGE) \
367             > $(PACKAGE)-$$prevno-$(VERSION).diff
368
369 ## Check our path lengths.
370 path-check: distdir
371         (cd $(distdir) && \
372 ## FIXME there's got to be a better way!  pathchk should take the list
373 ## of files on stdin, at least.
374           find . -print | xargs pathchk -p); \
375           status=$$?; \
376           chmod -R a+w $(distdir) > /dev/null 2>&1; rm -rf $(distdir); \
377           exit $$status
378
379 ## Program to use to fetch files.
380 WGET = wget
381 WGET_SV_CVS = $(WGET) http://savannah.gnu.org/cgi-bin/viewcvs/~checkout~/
382 WGET_SV_GIT_CF = $(WGET) 'http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;hb=HEAD;f='
383 WGET_SV_GIT_AC = $(WGET) 'http://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=blob_plain;hb=HEAD;f='
384 WGET_SV_GIT_GL = $(WGET) 'http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob_plain;hb=HEAD;f='
385 WGET_GCC = $(WGET) 'http://gcc.gnu.org/viewcvs/*checkout*/trunk/'
386
387 ## Files that we fetch and which we compare against.
388 ## FIXME should be a lot more here
389 FETCHFILES = \
390 INSTALL \
391 config-ml.in \
392 config.guess \
393 config.sub \
394 symlink-tree \
395 texinfo.tex
396
397 ## Fetch the latest versions of files we care about.
398 fetch:
399         rm -rf Fetchdir > /dev/null 2>&1
400         mkdir Fetchdir
401 ## If a get fails then that is a problem.
402         (cd Fetchdir && \
403         $(WGET_SV_GIT_CF)config.guess -O config.guess && \
404         $(WGET_SV_GIT_CF)config.sub -O config.sub && \
405         $(WGET_SV_CVS)texinfo/texinfo/doc/texinfo.tex -O texinfo.tex && \
406         $(WGET_SV_GIT_GL)doc/INSTALL -O INSTALL && \
407         $(WGET_GCC)config-ml.in -O config-ml.in && \
408         $(WGET_GCC)symlink-tree -O symlink-tree)
409 ## Don't exit after test because we want to give as many errors as
410 ## possible.
411         @stat=0; for file in $(FETCHFILES); do \
412           if diff -u $(srcdir)/lib/$$file Fetchdir/$$file \
413                   >>Fetchdir/update.patch 2>/dev/null; then :; \
414           else \
415             stat=1; \
416             echo "Updating $(srcdir)/lib/$$file..."; \
417             cp Fetchdir/$$file $(srcdir)/lib/$$file; \
418           fi; \
419         done; \
420         test $$stat = 0 || \
421           echo "See Fetchdir/update.patch for a log of the changes."; \
422         exit $$stat
423
424 ## Generate release statistics, for the table in automake.texi.
425 ## This has to be run in an up to date build tree, but there must
426 ## be no temp files nor unused other files lying around!
427 release-stats: ps
428         @am=`wc -l < automake` && \
429         acl=`wc -l < aclocal` && \
430         pmfiles="lib/Automake/*.pm" && \
431         if test . != '$(srcdir)'; then pmfiles="$$pmfiles $(srcdir)/lib/Automake/*.pm"; \
432         else :; fi && \
433         pm=`cat $$pmfiles | wc -l` && \
434         dot_am_files=`ls -1 $(srcdir)/lib/am/*.am | grep -v Makefile.am` && \
435         amf=`echo "$$dot_am_files" | wc -l` && \
436         aml=`cat $$dot_am_files | wc -l` && \
437         m4f=`ls -1 $(srcdir)/m4/*.m4 | wc -l` && \
438         m4l=`cat $(srcdir)/m4/*.m4 | wc -l` && \
439         doc_text=`cd doc && LC_ALL=C pstops 0 automake.ps unused.ps 2>&1` && \
440         rm -f doc/unused.ps && \
441         doc=`echo "$$doc_text" | sed -n 's/.*Wrote \([1-9][0-9]*\) pages.*/\1/p'` && \
442         tests="tests/*.test"; \
443         if test . != '$(srcdir)'; then tests="$$tests $(srcdir)/tests/*.test"; \
444         else :; fi && \
445         t=`ls -1 $$tests | wc -l` && \
446         tgen=`ls -1 $$tests | grep '.-p\.test' | wc -l` && \
447         today=`date +%Y-%m-%d` && \
448         echo "add this to the table in doc/automake.texi after verification:" && \
449         printf '@item %s @tab %-6s @tab %4d @tab %4d @tab %4d @tab %4d %-4s @tab %4d %-4s @tab %3d @tab %d %-4s\n' \
450                       $$today $(VERSION) $$am    $$acl    $$pm   $$aml "($$amf)" $$m4l "($$m4f)" $$doc $$t "($$tgen)"
451 .PHONY: release-stats