For PR automake/347:
[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 Free
6 ## 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 = . m4 lib tests
26
27 bin_SCRIPTS = automake aclocal
28 info_TEXINFOS = automake.texi
29
30
31 TAGS_FILES = automake.in aclocal.in
32
33 # The following requires a fixed version of the Emacs 19.30 etags.
34 ETAGS_ARGS = --lang=none \
35  --regex='/^@node[ \t]+\([^,]+\)/\1/' $(srcdir)/automake.texi
36 TAGS_DEPENDENCIES = automake.texi
37
38 EXTRA_DIST = ChangeLog.1996 ChangeLog.1998 ChangeLog.2000 ChangeLog.2001
39
40 ## Make versioned links.  We only run the transform on the root name;
41 ## then we make a versioned link with the transformed base name.  This
42 ## seemed like the most reasonable approach.
43 install-exec-hook:
44         @$(POST_INSTALL)
45         @for p in $(bin_SCRIPTS); do \
46           f="`echo $$p|sed '$(transform)'`"; \
47           fv="$$f-$(APIVERSION)"; \
48           rm -f $(DESTDIR)$(bindir)/$$fv; \
49           echo " $(LN) $(DESTDIR)$(bindir)/$$f $(DESTDIR)$(bindir)/$$fv"; \
50           $(LN) $(DESTDIR)$(bindir)/$$f $(DESTDIR)$(bindir)/$$fv; \
51         done
52
53 uninstall-hook:
54         @for p in $(bin_SCRIPTS); do \
55           f="`echo $$p|sed '$(transform)'`"; \
56           fv="$$f-$(APIVERSION)"; \
57           rm -f $(DESTDIR)$(bindir)/$$fv; \
58         done
59
60 ################################################################
61 ##
62 ## Everything past here is useful to the maintainer, but probably not
63 ## to anybody else
64 ##
65
66 # Some simple checks, and then ordinary check.  These are only really
67 # guaranteed to work on my machine.
68 maintainer-check: automake aclocal
69 ## This check avoids accidental configure substitutions in the source.
70 ## There are exactly 7 lines that should be modified.  This works out
71 ## to 22 lines of diffs.
72         @if test `diff $(srcdir)/automake.in automake | wc -l` -ne 28; then \
73           echo "found too many diffs between automake.in and automake"; 1>&2; \
74           diff -c $(srcdir)/automake.in automake; \
75           exit 1; \
76         fi
77 ## Syntax check with default Perl (on my machine, Perl 5).
78         perllibdir=$(srcdir)/lib $(PERL) -c -w automake
79         perllibdir=$(srcdir)/lib $(PERL) -c -w aclocal
80 ## expect no instances of '${...}'.  However, $${...} is ok, since that
81 ## is a shell construct, not a Makefile construct.
82         @if grep -F '$${' $(srcdir)/lib/am/[a-z]*.am | \
83                grep -F -v '$$$$'; then \
84           echo "Found too many uses of '\$${' in the lines above." 1>&2; \
85           exit 1;                               \
86         else :; fi
87 ## Make sure `rm' is called with `-f'.
88         @if grep -E '\<rm ([^-]|\-[^f ]*\>)' \
89                   $(srcdir)/lib/am/[a-z]*.am $(srcdir)/tests/*.test | \
90               grep -v '##'; then \
91           echo "Suspicious 'rm' invocation." 1>&2; \
92           exit 1;                               \
93         else :; fi
94 ## Never use something like `for file in $(FILES)', this doesn't work
95 ## if FILES is empty or if it contains shell meta characters (e.g. $ is
96 ## commonly used in Java filenames).
97         @if grep 'for .* in \$$(' $(srcdir)/lib/am/[a-z]*.am; then \
98           echo 'Use "list=$$(mumble); for var in $$$$list".' 1>&2 ; \
99           exit 1; \
100         else :; fi
101 ## Make sure all invocations of mkinstalldirs are correct.
102         @if grep -n 'mkinstalldirs' $(srcdir)/lib/am/[a-z]*.am | \
103               grep -F -v '$$(mkinstalldirs)'; then \
104           echo "Found incorrect use of mkinstalldirs in the lines above" 1>&2; \
105           exit 1; \
106         else :; fi
107 ## We never want to use "undef", only "delete", but for $/.
108         @if grep -n -w 'undef ' $(srcdir)/automake.in | \
109               grep -F -v 'undef $$/'; then \
110           echo "Found undef in automake.in; use delete instead" 1>&2; \
111           exit 1; \
112         fi
113 ## We never want split (/ /,...), only split (' ', ...).
114         @if grep -n 'split (/ /' $(srcdir)/automake.in; then \
115           echo "Found bad split in the lines above." 1>&2; \
116           exit 1; \
117         fi
118 ## Look for cd within backquotes
119         @if grep -n '^[^#]*` *cd ' $(srcdir)/automake.in \
120               $(srcdir)/lib/am/*.am; then \
121           echo "Consider using $$$$(am__cd) in the line above." 1>&2; \
122           exit 1; \
123         fi
124 ## Using @_ in a scalar context is most probably a programming error.
125         @if grep -Hn '[^) ] *= *@_' $(srcdir)/automake.in; then \
126           echo "Using @_ in a scalar context in the lines above." 1>&2; \
127           exit 1; \
128         fi
129 ## Forbid using parens with `local' to ease counting.
130         @if grep '^[ \t]*local *(' $(srcdir)/automake.in; then \
131           echo "Don't use \`local' with parens: use several \`local' above." >&2; \
132           exit 1; \
133         fi
134 ## Up to now we manage to limit to 1 use of local, but for `local $_;'.
135         @locals=`grep -v '^[ \t]*local \$$_;' $(srcdir)/automake.in | \
136                 grep -c '^[ \t]*local [^*]'`; \
137         case $$locals in \
138           [0] ) \
139             echo "Wow, congrats!  There are no \`local' now!." >&2; \
140             echo "Please update Makefile.am (maintainer-check)." >&2; \
141             exit 1; \
142           ;; \
143           1 ) ;; \
144           * ) \
145             echo "Too many \`local'!  Are you sure you need $$locals of them?" >&2; \
146             echo "Up to now 1 was enough." >&2; \
147             exit 1; \
148           ;; \
149         esac
150 ## Don't let AMDEP_TRUE substitution appear in automake.in.
151         @if grep '@AMDEP''_TRUE@' $(srcdir)/automake.in; then \
152           echo "Don't put AMDEP_TRUE substitution in automake.in" 1>&2; \
153           exit 1; \
154         fi
155 ## Tests should never call make directly.
156         @if grep -v '^#' $(srcdir)/tests/*.test | grep ':[      ]*make'; then \
157           echo 'Do not run "make" in the above tests.  Use "$$MAKE" instead.' 1>&2; \
158           exit 1; \
159         fi
160 ## Tests should never call autoconf directly.
161         @if grep -v '^#' $(srcdir)/tests/*.test | grep ':[      ]*autoconf'; then \
162           echo 'Do not run "autoconf" in the above tests.  Use "$$AUTOCONF" instead.' 1>&2; \
163           exit 1; \
164         fi
165 ## Tests should never call autoupdate directly.
166         @if grep -v '^#' $(srcdir)/tests/*.test | egrep ':[     ]*autoupdate'; then \
167           echo 'Do not run "autoupdate" in the above tests.  Use "$$AUTOUPDATE" instead.' 1>&2; \
168           exit 1; \
169         fi
170 ## Tests should never call automake directly.
171         @if grep -v '^#' $(srcdir)/tests/*.test | grep ':[      ]*automake'; then \
172           echo 'Do not run "automake" in the above tests.  Use "$$AUTOMAKE" instead.' 1>&2;  \
173           exit 1; \
174         fi
175 ## Tests should never call aclocal directly.
176         @if grep -v '^#' $(srcdir)/tests/*.test | grep ':[      ]*aclocal'; then \
177           echo 'Do not run "aclocal" in the above tests.  Use "$$ACLOCAL" instead.' 1>&2;  \
178           exit 1; \
179         fi
180 ## Tests should never call perl directly.
181         @if grep -v '^#' $(srcdir)/tests/*.test | grep ':[      ]*perl'; then \
182           echo 'Do not run "perl" in the above tests.  Use "$$PERL" instead.' 1>&2; \
183           exit 1; \
184         fi
185 ## Overriding a Makefile macro on the command line is not portable when
186 ## recursive targets are used.  Better use an envvar.  SHELL is an exception,
187 ## POSIX says it can't come from the environment.
188         @if grep -E '\$$MAKE .*(SHELL=.*=|=.*SHELL=)' $(srcdir)/tests/*.test; then \
189           echo 'Rewrite "$$MAKE foo=bar SHELL=/bin/sh" as "foo=bar $$MAKE -e SHELL=/bin/sh"' 1>&2; \
190           echo ' in the above lines, it is more portable.' 1>&2; \
191           exit 1; \
192         fi
193         @if grep -v SHELL $(srcdir)/tests/*.test | grep '\$$MAKE .*=' ; then \
194           echo 'Rewrite "$$MAKE foo=bar" as "foo=bar $$MAKE -e SHELL=/bin/sh" in the above lines,' 1>&2; \
195           echo 'it is more portable.' 1>&2; \
196           exit 1; \
197         fi
198 ## On NetBSD (1.5) and OSF, the $SHELL variable is still inherited from
199 ## the environment.
200         @if grep '$$MAKE.* -e' $(srcdir)/tests/*.test | grep -v '-e.*SHELL' ; then \
201           echo 'Always overwrite SHELL when using "$$MAKE -e".' 1>&2; \
202           echo 'Use "$$MAKE -e SHELL=/bin/sh" in the above lines.' 1>&2; \
203           exit 1; \
204         fi
205         @if grep 'SHELL=.*\$$MAKE' $(srcdir)/tests/*.test; then \
206           echo '$$MAKE ignores the SHELL envvar, use "$$MAKE SHELL=/bin/sh" in' 1>&2; \
207           echo 'the above lines.' 1>&2; \
208           exit 1; \
209         fi
210 ## Never use `sleep 1' to create files with different timestamps.
211 ## Use `sleep 2' instead.  Some filesystems (e.g., Windows') have only
212 ## a 2sec resolution.
213         @if grep -E '\bsleep +1\b' $(srcdir)/tests/*.test; then \
214           echo 'Do not use "sleep 1" in the above tests.  Use "sleep 2" instead.' 1>&2; \
215           exit 1; \
216         fi
217 ## fgrep and egrep are not required by POSIX.
218         @if grep -E '\b[ef]grep\b' $(srcdir)/tests/*.test ; then \
219           echo 'Do not use egrep or fgrep in test cases.  Use $FGREP or $EGREP.' 1>&2; \
220           exit 1; \
221         fi
222         @if grep -E '\b[ef]grep\b' $(srcdir)/lib/am/*.am $(srcdir)/m4/*.m4; then \
223           echo 'Do not use egrep or fgrep in the above files, they are not portable.' 1>&2; \
224           exit 1; \
225         fi
226
227
228 # Tag before making distribution.  Also, don't make a distribution if
229 # checks fail.  Also, make sure the NEWS file is up-to-date.
230 cvs-dist: maintainer-check distcheck
231         @if sed 1q $(srcdir)/NEWS | grep -e "$(VERSION)" > /dev/null; then :; else \
232           echo "NEWS not updated; not releasing" 1>&2; \
233           exit 1;                               \
234         fi
235         cd $(srcdir) && cvs -q tag `echo "Release-$(VERSION)" | sed 's/\./-/g'`
236         $(MAKE) dist
237
238 cvs-diff:
239         thisver=`echo "Release-$(VERSION)" | sed 's/\./-/g'`; \
240         if test -z "$$OLDVERSION"; then \
241           prevno=`echo "$(VERSION)" - 0.01 | bc | sed 's/^\./0./'`; \
242         else prevno="$$OLDVERSION"; fi; \
243         prevver=Release-`echo $$prevno | sed 's/\./-/g'`; \
244         cvs -f rdiff -c -r $$prevver -r $$thisver $(PACKAGE) \
245             > $(PACKAGE)-$$prevno-$(VERSION).diff
246
247 ## Check our path lengths.
248 path-check: distdir
249         (cd $(distdir) && \
250 ## FIXME there's got to be a better way!  pathchk should take the list
251 ## of files on stdin, at least.
252           find . -print | xargs pathchk -p); \
253           status=$$?; \
254           chmod -R a+w $(distdir) > /dev/null 2>&1; rm -rf $(distdir); \
255           exit $$status
256
257 ## Program to use to fetch files.
258 WGET = wget
259
260 ## Files that we fetch and which we compare against.
261 ## FIXME should be a lot more here
262 FETCHFILES = config.guess config.sub texinfo.tex Automake/XFile.pm INSTALL \
263         install-sh
264
265 ## Fetch the latest versions of files we care about.
266 fetch:
267         rm -rf Fetchdir > /dev/null 2>&1
268         mkdir Fetchdir; mkdir Fetchdir/Automake
269 ## If a get fails then that is a problem.
270         (cd Fetchdir && \
271         $(WGET) ftp://ftp.gnu.org/gnu/config/config.guess; \
272         $(WGET) ftp://ftp.gnu.org/gnu/config/config.sub; \
273         $(WGET) ftp://ftp.gnu.org/gnu/texinfo/texinfo.tex; \
274         $(WGET) http://savannah.gnu.org/cgi-bin/viewcvs/~checkout~/autoconf/autoconf/lib/Autom4te/XFile.pm?content-type=text/plain -O Automake/XFile.pm; \
275         $(WGET) http://savannah.gnu.org/cgi-bin/viewcvs/~checkout~/autoconf/autoconf/config/install-sh?content-type=text/plain -O install-sh; \
276         $(WGET) http://savannah.gnu.org/cgi-bin/viewcvs/~checkout~/autoconf/autoconf/INSTALL?content-type=text/plain -O INSTALL)
277         perl -pi -e 's/Autom4te::/Automake::/g' Fetchdir/Automake/XFile.pm
278 ## Don't exit after test because we want to give as many errors as
279 ## possible.
280         @stat=0; for file in $(FETCHFILES); do \
281           if diff -u $(srcdir)/lib/$$file Fetchdir/$$file \
282                   >>Fetchdir/update.patch 2>/dev/null; then :; \
283           else \
284             stat=1; \
285             echo "Updating $(srcdir)/lib/$$file..."; \
286             cp Fetchdir/$$file $(srcdir)/lib/$$file; \
287           fi; \
288         done; \
289         test $$stat = 1 && \
290           echo "See Fetchdir/update.patch for a log of the changes."; \
291         exit $$stat