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