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