For all possibly-relative subdirs, use $(am__cd).
[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,[@]SHELL[@],$(SHELL),g' \
74   -e 's,[@]VERSION[@],$(VERSION),g' \
75   -e 's,[@]configure_input[@],Generated from $@.in; do not edit by hand.,g' \
76   -e 's,[@]datadir[@],$(datadir),g'
77
78 ## These files depend on Makefile so they are rebuilt if $(VERSION),
79 ## $(datadir) or other do_subst'ituted variables change.
80 ## Use chmod a-w to prevent people from editing the wrong file by accident.
81 automake: automake.in
82 aclocal: aclocal.in
83 automake aclocal: Makefile
84         rm -f $@ $@.tmp
85         $(do_subst) $(srcdir)/$@.in >$@.tmp
86         chmod +x $@.tmp
87         chmod a-w $@.tmp
88         mv -f $@.tmp $@
89
90 ## The master location for INSTALL is lib/INSTALL.
91 ## This is where `make fetch' will install new versions.
92 ## Make sure we also update this copy.
93 INSTALL: lib/INSTALL
94         cp $(srcdir)/lib/INSTALL $@
95
96 ################################################################
97 ##
98 ## Everything past here is useful to the maintainer, but probably not
99 ## to anybody else
100 ##
101
102 # Ensure tests are world-executable
103 dist-hook:
104         cd $(distdir)/tests && chmod a+rx *.test
105
106 # Some simple checks, and then ordinary check.  These are only really
107 # guaranteed to work on my machine.
108 maintainer-check: automake aclocal
109 ## This check avoids accidental configure substitutions in the source.
110 ## There are exactly 6 lines that should be modified.  This works out
111 ## to 22 lines of diffs.
112         @if test `diff $(srcdir)/automake.in automake | wc -l` -ne 22; then \
113           echo "found too many diffs between automake.in and automake"; 1>&2; \
114           diff -c $(srcdir)/automake.in automake; \
115           exit 1; \
116         fi
117 ## Syntax check with default Perl (on my machine, Perl 5).
118         perllibdir="./lib$(PATH_SEPARATOR)$(srcdir)/lib" $(PERL) -c -w automake
119         perllibdir="./lib$(PATH_SEPARATOR)$(srcdir)/lib" $(PERL) -c -w aclocal
120 ## expect no instances of '${...}'.  However, $${...} is ok, since that
121 ## is a shell construct, not a Makefile construct.
122         @if grep -F '$${' $(srcdir)/lib/am/[a-z]*.am | \
123                grep -F -v '$$$$'; then \
124           echo "Found too many uses of '\$${' in the lines above." 1>&2; \
125           exit 1;                               \
126         else :; fi
127 ## Make sure `rm' is called with `-f'.
128         @if grep -v '^#' $(srcdir)/lib/am/[a-z]*.am $(srcdir)/tests/*.test | \
129             grep -E '\<rm ([^-]|\-[^f ]*\>)'; then \
130           echo "Suspicious 'rm' invocation." 1>&2; \
131           exit 1;                               \
132         else :; fi
133 ## Never use something like `for file in $(FILES)', this doesn't work
134 ## if FILES is empty or if it contains shell meta characters (e.g. $ is
135 ## commonly used in Java filenames).
136         @if grep 'for .* in \$$(' $(srcdir)/lib/am/[a-z]*.am; then \
137           echo 'Use "list=$$(mumble); for var in $$$$list".' 1>&2 ; \
138           exit 1; \
139         else :; fi
140 ## Make sure all invocations of mkinstalldirs are correct.
141         @if grep -n 'mkinstalldirs' $(srcdir)/lib/am/[a-z]*.am | \
142               grep -F -v '$$(mkinstalldirs)'; then \
143           echo "Found incorrect use of mkinstalldirs in the lines above" 1>&2; \
144           exit 1; \
145         else :; fi
146 ## Make sure all calls to PRE/NORMAL/POST_INSTALL/UNINSTALL
147         @if grep -E -n '\((PRE|NORMAL|POST)_(|UN)INSTALL\)' \
148                  $(srcdir)/lib/am/[a-z]*.am | \
149               grep -v ':##' | grep -v ':        @\$$('; then \
150           echo "Found incorrect use of PRE/NORMAL/POST_INSTALL/UNINSTALL in the lines above" 1>&2; \
151           exit 1; \
152         else :; fi
153 ## We never want to use "undef", only "delete", but for $/.
154         @if grep -n -w 'undef ' $(srcdir)/automake.in | \
155               grep -F -v 'undef $$/'; then \
156           echo "Found undef in automake.in; use delete instead" 1>&2; \
157           exit 1; \
158         fi
159 ## We never want split (/ /,...), only split (' ', ...).
160         @if grep -n 'split (/ /' $(srcdir)/automake.in; then \
161           echo "Found bad split in the lines above." 1>&2; \
162           exit 1; \
163         fi
164 ## Look for cd within backquotes
165         @if grep -n '^[^#]*` *cd ' $(srcdir)/automake.in \
166               $(srcdir)/lib/am/*.am; then \
167           echo "Consider using \$$(am__cd) in the lines above." 1>&2; \
168           exit 1; \
169         fi
170 ## Look for cd to a relative directory (may be influenced by CDPATH).
171 ## Skip some known directories that are OK.
172         @if grep -n '^[^#]*cd ' $(srcdir)/automake.in \
173               $(srcdir)/lib/am/*.am | \
174               grep -v 'echo.*cd ' | \
175               grep -v 'am__cd =' | \
176               grep -v '^[^#]*cd [./]' | \
177               grep -v '^[^#]*cd \$$(top_builddir)' | \
178               grep -v '^[^#]*cd "\$$\$$am__cwd' | \
179               grep -v '^[^#]*cd \$$(abs' | \
180               grep -v '^[^#]*cd "\$$(DESTDIR)'; then \
181           echo "Consider using \$$(am__cd) in the lines above." 1>&2; \
182           exit 1; \
183         fi
184 ## Using @_ in a scalar context is most probably a programming error.
185         @if grep -Hn '[^@_A-Za-z0-9][_A-Za-z0-9]*[^) ] *= *@_' $(srcdir)/automake.in; then \
186           echo "Using @_ in a scalar context in the lines above." 1>&2; \
187           exit 1; \
188         fi
189 ## Forbid using parens with `local' to ease counting.
190         @if grep '^[ \t]*local *(' $(srcdir)/automake.in; then \
191           echo "Don't use \`local' with parens: use several \`local' above." >&2; \
192           exit 1; \
193         fi
194 ## Allow only `local $_' in Automake.
195         @if grep -v '^[ \t]*local \$$_;' $(srcdir)/automake.in | \
196                 grep '^[ \t]*local [^*]'; then \
197           echo "Please avoid \`local'." 1>&2; \
198           exit 1; \
199         fi
200 ## Don't let AMDEP_TRUE substitution appear in automake.in.
201         @if grep '@AMDEP''_TRUE@' $(srcdir)/automake.in; then \
202           echo "Don't put AMDEP_TRUE substitution in automake.in" 1>&2; \
203           exit 1; \
204         fi
205 ## Tests should never call make directly.
206         @if grep '^[^#].*(MAKE) ' $(srcdir)/lib/am/*.am $(srcdir)/automake.in |\
207                 grep -v 'AM_MAKEFLAGS'; then \
208           echo 'Use $$(MAKE) $$(AM_MAKEFLAGS).' 1>&2; \
209           exit 1; \
210         fi
211 ## Tests should never call make directly.
212         @if grep -v '^#' $(srcdir)/tests/*.test | grep ':[      ]*make'; then \
213           echo 'Do not run "make" in the above tests.  Use "$$MAKE" instead.' 1>&2; \
214           exit 1; \
215         fi
216 ## Tests should never call autoconf directly.
217         @if grep -v '^#' $(srcdir)/tests/*.test | grep ':[      ]*autoconf'; then \
218           echo 'Do not run "autoconf" in the above tests.  Use "$$AUTOCONF" instead.' 1>&2; \
219           exit 1; \
220         fi
221 ## Tests should never call autoupdate directly.
222         @if grep -v '^#' $(srcdir)/tests/*.test | grep ':[      ]*autoupdate'; then \
223           echo 'Do not run "autoupdate" in the above tests.  Use "$$AUTOUPDATE" instead.' 1>&2; \
224           exit 1; \
225         fi
226 ## Tests should never call automake directly.
227         @if grep -v '^#' $(srcdir)/tests/*.test | grep -E ':[   ]*automake([^:]|$$)'; then \
228           echo 'Do not run "automake" in the above tests.  Use "$$AUTOMAKE" instead.' 1>&2;  \
229           exit 1; \
230         fi
231 ## Use AUTOMAKE_fails when appropriate
232         @if grep -v '^#' $(srcdir)/tests/*.test | grep '\$$AUTOMAKE.*&&.*exit'; then \
233           echo 'Use AUTOMAKE_fails + grep to catch automake failures in the above tests.' 1>&2;  \
234           exit 1; \
235         fi
236 ## Tests should never call aclocal directly.
237         @if grep -v '^#' $(srcdir)/tests/*.test | grep ':[      ]*aclocal'; then \
238           echo 'Do not run "aclocal" in the above tests.  Use "$$ACLOCAL" instead.' 1>&2;  \
239           exit 1; \
240         fi
241 ## Tests should never call perl directly.
242         @if grep -v '^#' $(srcdir)/tests/*.test | grep ':[      ]*perl'; then \
243           echo 'Do not run "perl" in the above tests.  Use "$$PERL" instead.' 1>&2; \
244           exit 1; \
245         fi
246 ## Setting `required' after sourcing `./defs' is a bug.
247         @for file in $(srcdir)/tests/*.test; do \
248           if out=`sed -n '/defs/,$${/required=/p;}' $$file`; test -n "$$out"; then \
249             echo 'Do not set "required" after sourcing "defs" in '"$$file: $$out" 1>&2; \
250             exit 1; \
251           fi; \
252         done
253 ## Overriding a Makefile macro on the command line is not portable when
254 ## recursive targets are used.  Better use an envvar.  SHELL is an exception,
255 ## POSIX says it can't come from the environment.
256         @if grep -E '\$$MAKE .*(SHELL=.*=|=.*SHELL=)' $(srcdir)/tests/*.test; then \
257           echo 'Rewrite "$$MAKE foo=bar SHELL=$$SHELL" as "foo=bar $$MAKE -e SHELL=$$SHELL"' 1>&2; \
258           echo ' in the above lines, it is more portable.' 1>&2; \
259           exit 1; \
260         fi
261         @if grep -v SHELL $(srcdir)/tests/*.test | grep '\$$MAKE .*=' ; then \
262           echo 'Rewrite "$$MAKE foo=bar" as "foo=bar $$MAKE -e" in the above lines,' 1>&2; \
263           echo 'it is more portable.' 1>&2; \
264           exit 1; \
265         fi
266         @if grep 'SHELL=.*\$$MAKE' $(srcdir)/tests/*.test; then \
267           echo '$$MAKE ignores the SHELL envvar, use "$$MAKE SHELL=$$SHELL" in' 1>&2; \
268           echo 'the above lines.' 1>&2; \
269           exit 1; \
270         fi
271 ## Never use `sleep 1' to create files with different timestamps.
272 ## Use `$sleep' instead.  Some filesystems (e.g., Windows') have only
273 ## a 2sec resolution.
274         @if grep -E '\bsleep +[12345]\b' $(srcdir)/tests/*.test; then \
275           echo 'Do not use "sleep x" in the above tests.  Use "$$sleep" instead.' 1>&2; \
276           exit 1; \
277         fi
278 ## fgrep and egrep are not required by POSIX.
279         @if grep -E '\b[ef]grep\b' $(srcdir)/tests/*.test ; then \
280           echo 'Do not use egrep or fgrep in test cases.  Use $$FGREP or $$EGREP.' 1>&2; \
281           exit 1; \
282         fi
283         @if grep -E '\b[ef]grep\b' $(srcdir)/lib/am/*.am $(srcdir)/m4/*.m4; then \
284           echo 'Do not use egrep or fgrep in the above files, they are not portable.' 1>&2; \
285           exit 1; \
286         fi
287         @if grep 'mkdir_p' $(srcdir)/automake.in \
288               $(srcdir)/lib/am/*.am $(srcdir)/tests/*.test; then \
289           echo 'Do not use mkdir_p in the above files, use MKDIR_P.' 1>&2; \
290           exit 1; \
291         fi
292 ## Try to make sure all @...@ substitutions are covered by our
293 ## substitution rule.
294         @if test `grep -E '^[^#]*@[A-Za-z_0-9]+@' aclocal | wc -l` -ne 0; then \
295           echo "Unresolved @...@ substitution in aclocal" 1>&2; \
296           exit 1; \
297         fi
298         @if test `grep -E '^[^#]*@[A-Za-z_0-9]+@' automake | wc -l` -ne 0; then \
299           echo "Unresolved @...@ substitution in automake" 1>&2; \
300           exit 1; \
301         fi; \
302         if grep -E "[^\'\"]\\\$$\(DESTDIR" $(srcdir)/lib/am/*.am; then \
303           echo 'Suspicious unquoted DESTDIR uses.' 1>&2 ; \
304           exit 1; \
305         fi
306         @if grep '      ' $(srcdir)/doc/automake.texi; then \
307           echo 'Do not use tabs in the manual.' 1>&2; \
308           exit 1; \
309         fi
310         @if grep -E '([^@]|^)@([         ][^@]|$$)' $(srcdir)/doc/automake.texi; \
311         then \
312           echo 'Unescaped @.' 1>&2; \
313           exit 1; \
314         fi
315
316
317 git-dist: maintainer-check
318 ## Make sure clcommit exists (we use it at the end of git-dist).
319         @if (clcommit --version)>/dev/null 2>/dev/null; then :; else \
320           echo "Get clcommit from module cvs-utils on Savannah."; \
321           exit 1; \
322         fi
323 ## Make sure the NEWS file is up-to-date.
324         @if sed 1q $(srcdir)/NEWS | grep -e "$(VERSION)" > /dev/null; then :; else \
325           echo "NEWS not updated; not releasing" 1>&2; \
326           exit 1;                               \
327         fi
328 ## Build the distribution
329         $(MAKE) distcheck
330 ## Finally, if anything was successful, commit the last changes and tag
331 ## the release in the repository.  We don't use RCS keywords so it's OK
332 ## to distribute the files before they were committed.
333         cd $(srcdir) && clcommit && \
334           git tag -s `echo "Release-$(VERSION)" | sed 's/\./-/g'`
335
336 git-release: git-dist
337         case $(VERSION) in \
338           *[a-z]) dest=alpha;; \
339           *)      dest=ftp;; \
340         esac; \
341         $(srcdir)/lib/gnupload $(GNUPLOADFLAGS) \
342           --to sources.redhat.com:~ftp/pub/automake \
343           --to $$dest.gnu.org:automake $(DIST_ARCHIVES)
344
345 cvs-diff:
346         thisver=`echo "Release-$(VERSION)" | sed 's/\./-/g'`; \
347         if test -z "$$OLDVERSION"; then \
348           prevno=`echo "$(VERSION)" - 0.01 | bc | sed 's/^\./0./'`; \
349         else prevno="$$OLDVERSION"; fi; \
350         prevver=Release-`echo $$prevno | sed 's/\./-/g'`; \
351         cvs -f rdiff -c -r $$prevver -r $$thisver $(PACKAGE) \
352             > $(PACKAGE)-$$prevno-$(VERSION).diff
353
354 git-diff:
355         thisver=`echo "Release-$(VERSION)" | sed 's/\./-/g'`; \
356         if test -z "$$OLDVERSION"; then \
357           prevno=`echo "$(VERSION)" - 0.01 | bc | sed 's/^\./0./'`; \
358         else prevno="$$OLDVERSION"; fi; \
359         prevver=Release-`echo $$prevno | sed 's/\./-/g'`; \
360         git diff $$prevver $$thisver $(PACKAGE) \
361             > $(PACKAGE)-$$prevno-$(VERSION).diff
362
363 ## Check our path lengths.
364 path-check: distdir
365         (cd $(distdir) && \
366 ## FIXME there's got to be a better way!  pathchk should take the list
367 ## of files on stdin, at least.
368           find . -print | xargs pathchk -p); \
369           status=$$?; \
370           chmod -R a+w $(distdir) > /dev/null 2>&1; rm -rf $(distdir); \
371           exit $$status
372
373 ## Program to use to fetch files.
374 WGET = wget
375 WGET_SV_CVS = $(WGET) http://savannah.gnu.org/cgi-bin/viewcvs/~checkout~/
376 WGET_SV_GIT_CF = $(WGET) 'http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;hb=HEAD;f='
377 WGET_SV_GIT_AC = $(WGET) 'http://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=blob_plain;hb=HEAD;f='
378 WGET_SV_GIT_GL = $(WGET) 'http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob_plain;hb=HEAD;f='
379 WGET_GCC = $(WGET) 'http://gcc.gnu.org/viewcvs/*checkout*/trunk/'
380
381 ## Files that we fetch and which we compare against.
382 ## FIXME should be a lot more here
383 FETCHFILES = \
384 INSTALL \
385 config-ml.in \
386 config.guess \
387 config.sub \
388 symlink-tree \
389 texinfo.tex
390
391 ## Fetch the latest versions of files we care about.
392 fetch:
393         rm -rf Fetchdir > /dev/null 2>&1
394         mkdir Fetchdir
395 ## If a get fails then that is a problem.
396         (cd Fetchdir && \
397         $(WGET_SV_GIT_CF)config.guess -O config.guess && \
398         $(WGET_SV_GIT_CF)config.sub -O config.sub && \
399         $(WGET_SV_CVS)texinfo/texinfo/doc/texinfo.tex -O texinfo.tex && \
400         $(WGET_SV_GIT_GL)doc/INSTALL -O INSTALL && \
401         $(WGET_GCC)config-ml.in -O config-ml.in && \
402         $(WGET_GCC)symlink-tree -O symlink-tree)
403 ## Don't exit after test because we want to give as many errors as
404 ## possible.
405         @stat=0; for file in $(FETCHFILES); do \
406           if diff -u $(srcdir)/lib/$$file Fetchdir/$$file \
407                   >>Fetchdir/update.patch 2>/dev/null; then :; \
408           else \
409             stat=1; \
410             echo "Updating $(srcdir)/lib/$$file..."; \
411             cp Fetchdir/$$file $(srcdir)/lib/$$file; \
412           fi; \
413         done; \
414         test $$stat = 0 || \
415           echo "See Fetchdir/update.patch for a log of the changes."; \
416         exit $$stat