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