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