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