Merge branch 'master' into testsuite-work
[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, 2007, 2008, 2009, 2010, 2011 Free Software Foundation,
7 # Inc.
8
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2, or (at your option)
12 # any later version.
13
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
18
19 # You should have received a copy of the GNU General Public License
20 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
21
22 ## lib goes first, because it builds Config.pm, used by aclocal and
23 ## automake (run in doc, tests, and in the rebuild rules.)
24 ## `.' goes before doc and tests, because the latter two directories
25 ## run aclocal and automake.
26 SUBDIRS = lib . doc m4 tests
27
28 TEST_SUBDIRS = lib/Automake/tests tests
29
30 bin_SCRIPTS = automake aclocal
31
32 CLEANFILES = $(bin_SCRIPTS)
33 AUTOMAKESOURCES = automake.in aclocal.in
34
35 TAGS_FILES = $(AUTOMAKESOURCES)
36
37 EXTRA_DIST = \
38   ChangeLog.96 \
39   ChangeLog.98 \
40   ChangeLog.00 \
41   ChangeLog.01 \
42   ChangeLog.02 \
43   ChangeLog.03 \
44   ChangeLog.04 \
45   ChangeLog.09 \
46   bootstrap \
47   $(AUTOMAKESOURCES)
48
49 ## Make versioned links.  We only run the transform on the root name;
50 ## then we make a versioned link with the transformed base name.  This
51 ## seemed like the most reasonable approach.
52 install-exec-hook:
53         @$(POST_INSTALL)
54         @for p in $(bin_SCRIPTS); do \
55           f="`echo $$p|sed '$(transform)'`"; \
56           fv="$$f-$(APIVERSION)"; \
57           rm -f $(DESTDIR)$(bindir)/$$fv; \
58           echo " $(LN) $(DESTDIR)$(bindir)/$$f $(DESTDIR)$(bindir)/$$fv"; \
59           $(LN) $(DESTDIR)$(bindir)/$$f $(DESTDIR)$(bindir)/$$fv; \
60         done
61
62 uninstall-hook:
63         @for p in $(bin_SCRIPTS); do \
64           f="`echo $$p|sed '$(transform)'`"; \
65           fv="$$f-$(APIVERSION)"; \
66           rm -f $(DESTDIR)$(bindir)/$$fv; \
67         done
68
69
70 ## We can't use configure to do the substitution here; we must do it
71 ## by hand.  We use a funny notation here to avoid configure
72 ## substitutions in our text.
73 do_subst = sed \
74   -e 's,[@]APIVERSION[@],$(APIVERSION),g' \
75   -e 's,[@]PACKAGE[@],$(PACKAGE),g' \
76   -e 's,[@]PACKAGE_BUGREPORT[@],$(PACKAGE_BUGREPORT),g' \
77   -e 's,[@]PACKAGE_URL[@],$(PACKAGE_URL),g' \
78   -e 's,[@]PATH_SEPARATOR[@],$(PATH_SEPARATOR),g' \
79   -e 's,[@]PERL[@],$(PERL),g' \
80   -e 's,[@]PERL_THREADS[@],$(PERL_THREADS),g' \
81   -e 's,[@]SHELL[@],$(SHELL),g' \
82   -e 's,[@]am_AUTOCONF[@],$(am_AUTOCONF),g' \
83   -e 's,[@]am_AUTOM4TE[@],$(am_AUTOM4TE),g' \
84   -e 's,[@]VERSION[@],$(VERSION),g' \
85   -e 's,[@]configure_input[@],Generated from $@.in; do not edit by hand.,g' \
86   -e 's,[@]datadir[@],$(datadir),g'
87
88 ## These files depend on Makefile so they are rebuilt if $(VERSION),
89 ## $(datadir) or other do_subst'ituted variables change.
90 ## Use chmod a-w to prevent people from editing the wrong file by accident.
91 automake: automake.in
92 aclocal: aclocal.in
93 automake aclocal: Makefile
94         $(AM_V_GEN)rm -f $@ $@.tmp
95         $(AM_V_at)$(do_subst) $(srcdir)/$@.in >$@.tmp
96         $(AM_V_at)chmod +x $@.tmp
97         $(AM_V_at)chmod a-w $@.tmp
98         $(AM_V_at)mv -f $@.tmp $@
99
100 ## The master location for INSTALL is lib/INSTALL.
101 ## This is where `make fetch' will install new versions.
102 ## Make sure we also update this copy.
103 INSTALL: lib/INSTALL
104         $(AM_V_GEN)cp $(srcdir)/lib/INSTALL $@
105
106 ## recheck: convenience proxy target for the test suites.
107 .PHONY: recheck
108 recheck:
109         @failcom='exit 1'; \
110         for f in x $$MAKEFLAGS; do \
111           case $$f in \
112             *=* | --[!k]*);; \
113             *k*) failcom='fail=yes';; \
114           esac; \
115         done; \
116         for subdir in $(TEST_SUBDIRS); do \
117           ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $@) \
118             || eval $$failcom; \
119         done; \
120         test -z "$$fail"
121
122 ################################################################
123 ##
124 ## Everything past here is useful to the maintainer, but probably not
125 ## to anybody else
126 ##
127
128 # Ensure tests are world-executable
129 dist-hook:
130         $(am__cd) $(distdir)/tests && chmod a+rx *.test
131
132
133 # Perl coverage statistics.
134 PERL_COVERAGE_DB = $(abs_top_builddir)/cover_db
135 PERL_COVERAGE_FLAGS = -MDevel::Cover=-db,$(PERL_COVERAGE_DB),-silent,on,-summary,off
136 PERL_COVER = cover
137
138 check-coverage-run recheck-coverage-run: all
139         $(mkinstalldirs) $(PERL_COVERAGE_DB)
140         PERL5OPT="$$PERL5OPT $(PERL_COVERAGE_FLAGS)"; export PERL5OPT; \
141         WANT_NO_THREADS=yes; export WANT_NO_THREADS; unset AUTOMAKE_JOBS; \
142         $(MAKE) $(AM_MAKEFLAGS) `echo $@ | sed 's/-coverage-run//'`
143
144 check-coverage-report:
145         @if test ! -d "$(PERL_COVERAGE_DB)"; then \
146           echo "No coverage database found in \`$(PERL_COVERAGE_DB)'." >&2; \
147           echo "Please run \`make check-coverage' first" >&2; \
148           exit 1; \
149         fi
150         $(PERL_COVER) $(PERL_COVER_FLAGS) "$(PERL_COVERAGE_DB)"
151
152 # We don't use direct dependencies here because we'd like to be able
153 # to invoke the report even after interrupted check-coverage.
154 check-coverage: check-coverage-run
155         $(MAKE) $(AM_MAKEFLAGS) check-coverage-report
156
157 recheck-coverage: recheck-coverage-run
158         $(MAKE) $(AM_MAKEFLAGS) check-coverage-report
159
160 clean-coverage:
161         rm -rf "$(PERL_COVERAGE_DB)"
162 clean-local: clean-coverage
163
164 .PHONY: check-coverage recheck-coverage check-coverage-run \
165         recheck-coverage-run check-coverage-report clean-coverage
166
167 # Some simple checks, and then ordinary check.  These are only really
168 # guaranteed to work on my machine.
169 syntax_check_rules = \
170 sc_test_names \
171 sc_diff_automake_in_automake \
172 sc_diff_aclocal_in_automake \
173 sc_perl_syntax \
174 sc_no_brace_variable_expansions \
175 sc_rm_minus_f \
176 sc_no_for_variable_in_macro \
177 sc_mkinstalldirs \
178 sc_pre_normal_post_install_uninstall \
179 sc_perl_no_undef \
180 sc_perl_no_split_regex_space \
181 sc_cd_in_backquotes \
182 sc_cd_relative_dir \
183 sc_perl_at_uscore_in_scalar_context \
184 sc_perl_local_no_parens \
185 sc_perl_local \
186 sc_AMDEP_TRUE_in_automake_in \
187 sc_tests_make_without_am_makeflags \
188 sc_tests_plain_make \
189 sc_tests_plain_autoconf \
190 sc_tests_plain_autoupdate \
191 sc_tests_plain_automake \
192 sc_tests_plain_autom4te \
193 sc_tests_plain_autoheader \
194 sc_tests_plain_autoreconf \
195 sc_tests_here_document_format \
196 sc_tests_Exit_not_exit \
197 sc_tests_automake_fails \
198 sc_tests_plain_aclocal \
199 sc_tests_plain_perl \
200 sc_tests_required_after_defs \
201 sc_tests_overriding_macros_on_cmdline \
202 sc_tests_plain_sleep \
203 sc_tests_plain_egrep_fgrep \
204 sc_tests_PATH_SEPARATOR \
205 sc_tests_logs_duplicate_prefixes \
206 sc_tests_makefile_variable_order \
207 sc_mkdir_p \
208 sc_perl_at_substs \
209 sc_unquoted_DESTDIR \
210 sc_tabs_in_texi \
211 sc_at_in_texi
212
213 .PHONY: $(syntax_check_rules)
214 $(syntax_check_rules): automake aclocal
215
216 ## Check that the list of tests given in the Makefile is equal to the
217 ## list of all test scripts in the Automake testsuite.
218 .PHONY: maintainer-check-list-of-tests
219 maintainer-check-list-of-tests:
220         @failcom='exit 1'; \
221         for f in x $$MAKEFLAGS; do \
222           case $$f in \
223             *=* | --[!k]*);; \
224             *k*) failcom='fail=yes';; \
225           esac; \
226         done; \
227         for subdir in $(TEST_SUBDIRS); do \
228           (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $@) || eval $$failcom; \
229         done; \
230         test -z "$$fail"
231
232 maintainer-check: $(syntax_check_rules) maintainer-check-list-of-tests
233
234 ## Look for test whose names can cause spurious failures when used as
235 ## first argument to AC_INIT (chiefly because they might contain an
236 ## m4/m4sugar builtin or macro name).
237 m4_builtins = \
238   __gnu__ \
239   __unix__ \
240   bpatsubst \
241   bregexp \
242   builtin \
243   changecom \
244   changequote \
245   changeword \
246   debugfile \
247   debugmode \
248   decr \
249   define \
250   defn \
251   divert \
252   divnum \
253   dnl \
254   dumpdef \
255   errprint \
256   esyscmd \
257   eval \
258   format \
259   ifdef \
260   ifelse \
261   include \
262   incr \
263   index \
264   indir \
265   len \
266   m4exit \
267   m4wrap \
268   maketemp \
269   mkstemp \
270   patsubst \
271   popdef \
272   pushdef \
273   regexp \
274   shift \
275   sinclude \
276   substr \
277   symbols \
278   syscmd \
279   sysval \
280   traceoff \
281   traceon \
282   translit \
283   undefine \
284   undivert
285 sc_test_names:
286         @m4_builtin_rx=`echo $(m4_builtins) | sed 's/ /|/g'`; \
287          m4_macro_rx="\\<($$m4_builtin_rx)\\>|\\<_?(A[CUMHS]|m4)_"; \
288          if ls tests/*.test | LC_ALL=C grep -E "$$m4_macro_rx"; then \
289            echo "the names of the tests above can be problematic" 1>&2; \
290            echo "Avoid test names that contain names of m4 macros" 1>&2; \
291            exit 1; \
292          fi
293
294 ## These check avoids accidental configure substitutions in the source.
295 ## There are exactly 9 lines that should be modified from automake.in to
296 ## automake, and 10 lines that should be modified from aclocal.in to
297 ## aclocal; these wors out to 32 and 34 lines of diffs, respectively.
298 sc_diff_automake_in_automake:
299         @if test `diff $(srcdir)/automake.in automake | wc -l` -ne 32; then \
300           echo "found too many diffs between automake.in and automake" 1>&2; \
301           diff -c $(srcdir)/automake.in automake; \
302           exit 1; \
303         fi
304 sc_diff_aclocal_in_aclocal:
305         @if test `diff $(srcdir)/aclocal.in aclocal | wc -l` -ne 34; then \
306           echo "found too many diffs between aclocal.in and aclocal" 1>&2; \
307           diff -c $(srcdir)/aclocal.in aclocal; \
308           exit 1; \
309         fi
310
311 ## Syntax check with default Perl (on my machine, Perl 5).
312 sc_perl_syntax:
313         perllibdir="./lib$(PATH_SEPARATOR)$(srcdir)/lib" $(PERL) -c -w automake
314         perllibdir="./lib$(PATH_SEPARATOR)$(srcdir)/lib" $(PERL) -c -w aclocal
315
316 ## expect no instances of '${...}'.  However, $${...} is ok, since that
317 ## is a shell construct, not a Makefile construct.
318 sc_no_brace_variable_expansions:
319         @if grep -F '$${' $(srcdir)/lib/am/[a-z]*.am | \
320                grep -F -v '$$$$'; then \
321           echo "Found too many uses of '\$${' in the lines above." 1>&2; \
322           exit 1;                               \
323         else :; fi
324
325 ## Make sure `rm' is called with `-f'.
326 sc_rm_minus_f:
327         @if grep -v '^#' $(srcdir)/lib/am/[a-z]*.am $(srcdir)/tests/*.test | \
328             grep -E '\<rm ([^-]|\-[^f ]*\>)'; then \
329           echo "Suspicious 'rm' invocation." 1>&2; \
330           exit 1;                               \
331         else :; fi
332
333 ## Never use something like `for file in $(FILES)', this doesn't work
334 ## if FILES is empty or if it contains shell meta characters (e.g. $ is
335 ## commonly used in Java filenames).
336 sc_no_for_variable_in_macro:
337         @if grep 'for .* in \$$(' $(srcdir)/lib/am/[a-z]*.am; then \
338           echo 'Use "list=$$(mumble); for var in $$$$list".' 1>&2 ; \
339           exit 1; \
340         else :; fi
341
342 ## Make sure all invocations of mkinstalldirs are correct.
343 sc_mkinstalldirs:
344         @if grep -n 'mkinstalldirs' $(srcdir)/lib/am/[a-z]*.am | \
345               grep -F -v '$$(mkinstalldirs)'; then \
346           echo "Found incorrect use of mkinstalldirs in the lines above" 1>&2; \
347           exit 1; \
348         else :; fi
349
350 ## Make sure all calls to PRE/NORMAL/POST_INSTALL/UNINSTALL
351 sc_pre_normal_post_install_uninstall:
352         @if grep -E -n '\((PRE|NORMAL|POST)_(|UN)INSTALL\)' \
353                  $(srcdir)/lib/am/[a-z]*.am | \
354               grep -v ':##' | grep -v ':        @\$$('; then \
355           echo "Found incorrect use of PRE/NORMAL/POST_INSTALL/UNINSTALL in the lines above" 1>&2; \
356           exit 1; \
357         else :; fi
358
359 ## We never want to use "undef", only "delete", but for $/.
360 sc_perl_no_undef:
361         @if grep -n -w 'undef ' $(srcdir)/automake.in | \
362               grep -F -v 'undef $$/'; then \
363           echo "Found undef in automake.in; use delete instead" 1>&2; \
364           exit 1; \
365         fi
366
367 ## We never want split (/ /,...), only split (' ', ...).
368 sc_perl_no_split_regex_space:
369         @if grep -n 'split (/ /' $(srcdir)/automake.in; then \
370           echo "Found bad split in the lines above." 1>&2; \
371           exit 1; \
372         fi
373
374 ## Look for cd within backquotes
375 sc_cd_in_backquotes:
376         @if grep -n '^[^#]*` *cd ' $(srcdir)/automake.in \
377               $(srcdir)/lib/am/*.am; then \
378           echo "Consider using \$$(am__cd) in the lines above." 1>&2; \
379           exit 1; \
380         fi
381
382 ## Look for cd to a relative directory (may be influenced by CDPATH).
383 ## Skip some known directories that are OK.
384 sc_cd_relative_dir:
385         @if grep -n '^[^#]*cd ' $(srcdir)/automake.in \
386               $(srcdir)/lib/am/*.am | \
387               grep -v 'echo.*cd ' | \
388               grep -v 'am__cd =' | \
389               grep -v '^[^#]*cd [./]' | \
390               grep -v '^[^#]*cd \$$(top_builddir)' | \
391               grep -v '^[^#]*cd "\$$\$$am__cwd' | \
392               grep -v '^[^#]*cd \$$(abs' | \
393               grep -v '^[^#]*cd "\$$(DESTDIR)'; then \
394           echo "Consider using \$$(am__cd) in the lines above." 1>&2; \
395           exit 1; \
396         fi
397
398 ## Using @_ in a scalar context is most probably a programming error.
399 sc_perl_at_uscore_in_scalar_context:
400         @if grep -Hn '[^@_A-Za-z0-9][_A-Za-z0-9]*[^) ] *= *@_' $(srcdir)/automake.in; then \
401           echo "Using @_ in a scalar context in the lines above." 1>&2; \
402           exit 1; \
403         fi
404
405 ## Forbid using parens with `local' to ease counting.
406 sc_perl_local_no_parens:
407         @if grep '^[ \t]*local *(' $(srcdir)/automake.in; then \
408           echo "Don't use \`local' with parens: use several \`local' above." >&2; \
409           exit 1; \
410         fi
411
412 ## Allow only `local $_' in Automake.
413 sc_perl_local:
414         @if grep -v '^[ \t]*local \$$_;' $(srcdir)/automake.in | \
415                 grep '^[ \t]*local [^*]'; then \
416           echo "Please avoid \`local'." 1>&2; \
417           exit 1; \
418         fi
419
420 ## Don't let AMDEP_TRUE substitution appear in automake.in.
421 sc_AMDEP_TRUE_in_automake_in:
422         @if grep '@AMDEP''_TRUE@' $(srcdir)/automake.in; then \
423           echo "Don't put AMDEP_TRUE substitution in automake.in" 1>&2; \
424           exit 1; \
425         fi
426
427 ## Tests should never call make directly.
428 sc_tests_make_without_am_makeflags:
429         @if grep '^[^#].*(MAKE) ' $(srcdir)/lib/am/*.am $(srcdir)/automake.in |\
430                 grep -v 'AM_MAKEFLAGS'; then \
431           echo 'Use $$(MAKE) $$(AM_MAKEFLAGS).' 1>&2; \
432           exit 1; \
433         fi
434
435 ## Tests should never call make directly.
436 sc_tests_plain_make:
437         @if grep -v '^#' $(srcdir)/tests/*.test | $(EGREP) ':[  ]*make( |$$)'; then \
438           echo 'Do not run "make" in the above tests.  Use "$$MAKE" instead.' 1>&2; \
439           exit 1; \
440         fi
441
442 ## Tests should never call autoconf directly.
443 sc_tests_plain_autoconf:
444         @if grep -v '^#' $(srcdir)/tests/*.test | grep ':[      ]*autoconf\>'; then \
445           echo 'Do not run "autoconf" in the above tests.  Use "$$AUTOCONF" instead.' 1>&2; \
446           exit 1; \
447         fi
448
449 ## Tests should never call autoupdate directly.
450 sc_tests_plain_autoupdate:
451         @if grep -v '^#' $(srcdir)/tests/*.test | grep ':[      ]*autoupdate\>'; then \
452           echo 'Do not run "autoupdate" in the above tests.  Use "$$AUTOUPDATE" instead.' 1>&2; \
453           exit 1; \
454         fi
455
456 ## Tests should never call automake directly.
457 sc_tests_plain_automake:
458         @if grep -v '^#' $(srcdir)/tests/*.test | grep -E ':[   ]*automake\>([^:]|$$)'; then \
459           echo 'Do not run "automake" in the above tests.  Use "$$AUTOMAKE" instead.' 1>&2;  \
460           exit 1; \
461         fi
462
463 ## Tests should never call autoheader directly.
464 sc_tests_plain_autoheader:
465         @if grep -v '^#' $(srcdir)/tests/*.test | grep ':[      ]*autoheader\>'; then \
466           echo 'Do not run "automake" in the above tests.  Use "$$AUTOHEADER" instead.' 1>&2;  \
467           exit 1; \
468         fi
469
470 ## Tests should never call autoreconf directly.
471 sc_tests_plain_autoreconf:
472         @if grep -v '^#' $(srcdir)/tests/*.test | grep ':[      ]*autoreconf\>'; then \
473           echo 'Do not run "automake" in the above tests.  Use "$$AUTORECONF" instead.' 1>&2;  \
474           exit 1; \
475         fi
476
477 ## Tests should never call autom4te directly.
478 sc_tests_plain_autom4te:
479         @if grep -v '^#' $(srcdir)/tests/*.test | grep ':[      ]*autom4te\>'; then \
480           echo 'Do not run "automake" in the above tests.  Use "$$AUTOM4TE" instead.' 1>&2;  \
481           exit 1; \
482         fi
483
484 ## Tests should only use END and EOF for here documents
485 ## (so that the next test is effective).
486 sc_tests_here_document_format:
487         @if grep '<<' $(srcdir)/tests/*.test | grep -v 'END' | grep -v 'EOF'; then \
488           echo 'Use here documents with "END" and "EOF" only, for greppability.' 1>&2; \
489           exit 1; \
490         fi
491
492 ## Tests should never call exit directly, but use Exit.
493 ## This is so that the exit status is transported correctly across the 0 trap.
494 ## Ignore comments, testsuite self tests, and one perl line in ext2.test.
495 sc_tests_Exit_not_exit:
496         @found=false; for file in $(srcdir)/tests/*.test; do \
497           case $$file in */self-check-*.test) continue;; esac; \
498           res=`sed -n -e '/^#/d; /^\$$PERL/d' -e '/<<.*END/,/^END/b' \
499                       -e '/<<.*EOF/,/^EOF/b' -e '/exit [$$0-9]/p' $$file`; \
500           if test -n "$$res"; then \
501             echo "$$file:$$res"; \
502             found=true; \
503           fi; \
504         done; \
505         if $$found; then \
506           echo 'Do not call plain "exit", use "Exit" instead, in above tests.' 1>&2; \
507           exit 1; \
508         fi
509
510 ## Use AUTOMAKE_fails when appropriate
511 sc_tests_automake_fails:
512         @if grep -v '^#' $(srcdir)/tests/*.test | grep '\$$AUTOMAKE.*&&.*[eE]xit'; then \
513           echo 'Use AUTOMAKE_fails + grep to catch automake failures in the above tests.' 1>&2;  \
514           exit 1; \
515         fi
516
517 ## Tests should never call aclocal directly.
518 sc_tests_plain_aclocal:
519         @if grep -v '^#' $(srcdir)/tests/*.test | grep ':[      ]*aclocal\>'; then \
520           echo 'Do not run "aclocal" in the above tests.  Use "$$ACLOCAL" instead.' 1>&2;  \
521           exit 1; \
522         fi
523
524 ## Tests should never call perl directly.
525 sc_tests_plain_perl:
526         @if grep -v '^#' $(srcdir)/tests/*.test | grep ':[      ]*perl\>'; then \
527           echo 'Do not run "perl" in the above tests.  Use "$$PERL" instead.' 1>&2; \
528           exit 1; \
529         fi
530
531 ## Setting `required' after sourcing `./defs' is a bug.
532 sc_tests_required_after_defs:
533         @for file in $(srcdir)/tests/*.test; do \
534           if out=`sed -n '/defs/,$${/required=/p;}' $$file`; test -n "$$out"; then \
535             echo 'Do not set "required" after sourcing "defs" in '"$$file: $$out" 1>&2; \
536             exit 1; \
537           fi; \
538         done
539
540 ## Overriding a Makefile macro on the command line is not portable when
541 ## recursive targets are used.  Better use an envvar.  SHELL is an
542 ## exception, POSIX says it can't come from the environment.  DESTDIR and
543 ## DISTCHECK_CONFIGURE_FLAGS and V are exceptions, too, as package authors
544 ## are urged not to initialize them anywhere.
545 sc_tests_overriding_macros_on_cmdline:
546         @if grep -E '\$$MAKE .*(SHELL=.*=|=.*SHELL=)' $(srcdir)/tests/*.test; then \
547           echo 'Rewrite "$$MAKE foo=bar SHELL=$$SHELL" as "foo=bar $$MAKE -e SHELL=$$SHELL"' 1>&2; \
548           echo ' in the above lines, it is more portable.' 1>&2; \
549           exit 1; \
550         fi
551         @if sed -e 's/ DESTDIR=[^ ]*/ /' -e 's/ SHELL=[^ ]*/ /' \
552                 -e 's/ V=[^ ]*/ /' -e 's///' \
553 ## DISTCHECK_CONFIGURE_FLAGS is allowed to contain whitespace in its
554 ## definition, so the more complex substitutions below.
555                 -e "s/ DISTCHECK_CONFIGURE_FLAGS='[^']*'/ /" \
556                 -e 's/ DISTCHECK_CONFIGURE_FLAGS="[^"]*"/ /' \
557                 -e 's/ DISTCHECK_CONFIGURE_FLAGS=[^ ]/ /' \
558               $(srcdir)/tests/*.test | grep '\$$MAKE .*='; then \
559           echo 'Rewrite "$$MAKE foo=bar" as "foo=bar $$MAKE -e" in the above lines,' 1>&2; \
560           echo 'it is more portable.' 1>&2; \
561           exit 1; \
562         fi
563         @if grep 'SHELL=.*\$$MAKE' $(srcdir)/tests/*.test; then \
564           echo '$$MAKE ignores the SHELL envvar, use "$$MAKE SHELL=$$SHELL" in' 1>&2; \
565           echo 'the above lines.' 1>&2; \
566           exit 1; \
567         fi
568
569 ## Never use `sleep 1' to create files with different timestamps.
570 ## Use `$sleep' instead.  Some filesystems (e.g., Windows') have only
571 ## a 2sec resolution.
572 sc_tests_plain_sleep:
573         @if grep -E '\bsleep +[12345]\b' $(srcdir)/tests/*.test; then \
574           echo 'Do not use "sleep x" in the above tests.  Use "$$sleep" instead.' 1>&2; \
575           exit 1; \
576         fi
577
578 ## fgrep and egrep are not required by POSIX.
579 sc_tests_plain_egrep_fgrep:
580         @if grep -E '\b[ef]grep\b' $(srcdir)/tests/*.test ; then \
581           echo 'Do not use egrep or fgrep in test cases.  Use $$FGREP or $$EGREP.' 1>&2; \
582           exit 1; \
583         fi
584         @if grep -E '\b[ef]grep\b' $(srcdir)/lib/am/*.am $(srcdir)/m4/*.m4; then \
585           echo 'Do not use egrep or fgrep in the above files, they are not portable.' 1>&2; \
586           exit 1; \
587         fi
588
589 ## Rule to ensure that the testsuite has been run before.  We don't depend on `check'
590 ## here, because that would be very wasteful in the common case.  We could run
591 ## `make check RECHECK_LOGS=' and avoid toplevel races with AM_RECURSIVE_TARGETS.
592 ## Suggest keeping test directories around for greppability of the Makefile.in files.
593 sc_ensure_testsuite_has_run:
594         @if test ! -f tests/test-suite.log; then \
595           echo "Run \`env keep_testdirs=yes make check' before \`maintainer-check'" >&2; \
596           exit 1; \
597         fi
598 .PHONY: sc_ensure_testsuite_has_run
599
600 ## Ensure our warning and error messages do not contain duplicate 'warning:' prefixes.
601 ## This test actually depends on the testsuite having been run before.
602 sc_tests_logs_duplicate_prefixes: sc_ensure_testsuite_has_run
603         @if grep -E '(warning|error):.*(warning|error):' tests/*.log; then \
604           echo 'Duplicate warning/error message prefixes seen in above tests.' >&2; \
605           exit 1; \
606         fi
607
608 ## Ensure variables are listed before rules in Makefile.in files we generate.
609 sc_tests_makefile_variable_order: sc_ensure_testsuite_has_run
610         @for file in `find tests -name Makefile.in -print`; do \
611           latevars=`sed -n \
612             -e :x -e 's/#.*//' \
613             -e '/\\\\$$/{' -e N -e 'b x' -e '}' \
614 ## Literal TAB.
615             -e '1,/^    /d' \
616 ## Allow @ so we match conditionals.
617             -e '/^ *[a-zA-Z_@]\{1,\} *=/p' $$file`; \
618           if test -n "$$latevars"; then \
619             echo 'Ensure variables are expanded before rules' >&2; \
620             echo "Variables are expanded too late in $$file:" >&2; \
621             echo "$$latevars" | sed 's/^/  /' >&2; \
622             exit 1; \
623           fi; \
624         done
625
626 ## Using `:' as a PATH separator is not portable.
627 sc_tests_PATH_SEPARATOR:
628         @if grep -E '\bPATH=.*:.*' $(srcdir)/tests/*.test ; then \
629           echo "Use \`\$$PATH_SEPARATOR', not \`:', in PATH definitions above." 1>&2; \
630           exit 1; \
631         fi
632
633 sc_mkdir_p:
634         @if grep 'mkdir_p' $(srcdir)/automake.in \
635               $(srcdir)/lib/am/*.am $(srcdir)/tests/*.test; then \
636           echo 'Do not use mkdir_p in the above files, use MKDIR_P.' 1>&2; \
637           exit 1; \
638         fi
639
640 ## Try to make sure all @...@ substitutions are covered by our
641 ## substitution rule.
642 sc_perl_at_substs:
643         @if test `grep -E '^[^#]*@[A-Za-z_0-9]+@' aclocal | wc -l` -ne 0; then \
644           echo "Unresolved @...@ substitution in aclocal" 1>&2; \
645           exit 1; \
646         fi
647         @if test `grep -E '^[^#]*@[A-Za-z_0-9]+@' automake | wc -l` -ne 0; then \
648           echo "Unresolved @...@ substitution in automake" 1>&2; \
649           exit 1; \
650         fi
651
652 sc_unquoted_DESTDIR:
653         @if grep -E "[^\'\"]\\\$$\(DESTDIR" $(srcdir)/lib/am/*.am; then \
654           echo 'Suspicious unquoted DESTDIR uses.' 1>&2 ; \
655           exit 1; \
656         fi
657
658 sc_tabs_in_texi:
659         @if grep '      ' $(srcdir)/doc/automake.texi; then \
660           echo 'Do not use tabs in the manual.' 1>&2; \
661           exit 1; \
662         fi
663
664 sc_at_in_texi:
665         @if grep -E '([^@]|^)@([         ][^@]|$$)' $(srcdir)/doc/automake.texi; \
666         then \
667           echo 'Unescaped @.' 1>&2; \
668           exit 1; \
669         fi
670
671
672 git-dist: maintainer-check
673 ## Make sure the NEWS file is up-to-date.
674         @if sed 1q $(srcdir)/NEWS | grep -e "$(VERSION)" > /dev/null; then :; else \
675           echo "NEWS not updated; not releasing" 1>&2; \
676           exit 1;                               \
677         fi
678 ## Build the distribution
679         $(MAKE) $(AM_MAKEFLAGS) distcheck
680 ## Finally, if anything was successful, commit the last changes and tag
681 ## the release in the repository.  We don't use RCS keywords so it's OK
682 ## to distribute the files before they were committed.
683         $(am__cd) $(srcdir) && git commit -a -s && \
684            git tag -s "v$(VERSION)" -m "Release $(VERSION)"
685
686 git-release: git-dist
687         case $(VERSION) in \
688           *[a-z]) dest=alpha;; \
689           *)      dest=ftp;; \
690         esac; \
691         $(srcdir)/lib/gnupload $(GNUPLOADFLAGS) \
692           --to $$dest.gnu.org:automake $(DIST_ARCHIVES)
693
694 git-diff:
695         thisver="v$(VERSION)"; \
696         if test -z "$$OLDVERSION"; then \
697           prevno=`echo "$(VERSION)" - 0.01 | bc | sed 's/^\./0./'`; \
698         else prevno="$$OLDVERSION"; fi; \
699         prevver=v$$prevno; \
700         git diff $$prevver..$$thisver $(PACKAGE) \
701             > $(PACKAGE)-$$prevno-$(VERSION).diff
702
703 ## Check our path lengths.
704 path-check: distdir
705         ($(am__cd) $(distdir) && \
706 ## FIXME there's got to be a better way!  pathchk should take the list
707 ## of files on stdin, at least.
708           find . -print | xargs pathchk -p); \
709           estatus=$$?; \
710           find $(distdir) -type d '!' -perm -200 -exec chmod u+w {} ';'; \
711           rm -rf $(distdir); \
712           exit $$estatus
713
714 ## Program to use to fetch files.
715 WGET = wget
716 WGET_SV_CVS = $(WGET) http://savannah.gnu.org/cgi-bin/viewcvs/~checkout~/
717 WGET_SV_GIT_CF = $(WGET) 'http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;hb=HEAD;f='
718 WGET_SV_GIT_AC = $(WGET) 'http://git.savannah.gnu.org/gitweb/?p=autoconf.git;a=blob_plain;hb=HEAD;f='
719 WGET_SV_GIT_GL = $(WGET) 'http://git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob_plain;hb=HEAD;f='
720 WGET_GCC = $(WGET) 'http://gcc.gnu.org/viewcvs/*checkout*/trunk/'
721
722 ## Files that we fetch and which we compare against.
723 ## FIXME should be a lot more here
724 FETCHFILES = \
725 INSTALL \
726 config-ml.in \
727 config.guess \
728 config.sub \
729 symlink-tree \
730 texinfo.tex
731
732 ## Fetch the latest versions of files we care about.
733 fetch:
734         rm -rf Fetchdir > /dev/null 2>&1
735         mkdir Fetchdir
736 ## If a get fails then that is a problem.
737         ($(am__cd) Fetchdir && \
738         $(WGET_SV_GIT_CF)config.guess -O config.guess && \
739         $(WGET_SV_GIT_CF)config.sub -O config.sub && \
740         $(WGET_SV_CVS)texinfo/texinfo/doc/texinfo.tex -O texinfo.tex && \
741         $(WGET_SV_GIT_GL)doc/INSTALL -O INSTALL && \
742         $(WGET_GCC)config-ml.in -O config-ml.in && \
743         $(WGET_GCC)symlink-tree -O symlink-tree)
744 ## Don't exit after test because we want to give as many errors as
745 ## possible.
746         @stat=0; for file in $(FETCHFILES); do \
747           if diff -u $(srcdir)/lib/$$file Fetchdir/$$file \
748                   >>Fetchdir/update.patch 2>/dev/null; then :; \
749           else \
750             stat=1; \
751             echo "Updating $(srcdir)/lib/$$file ..."; \
752             cp Fetchdir/$$file $(srcdir)/lib/$$file; \
753           fi; \
754         done; \
755         test $$stat = 0 || \
756           echo "See Fetchdir/update.patch for a log of the changes."; \
757         exit $$stat
758
759 ## Generate release statistics, for the table in automake.texi.
760 ## This has to be run in an up to date build tree, but there must
761 ## be no temp files nor unused other files lying around!
762 release-stats: ps
763         @am=`wc -l < automake` && \
764         acl=`wc -l < aclocal` && \
765         pmfiles="lib/Automake/*.pm" && \
766         if test . != '$(srcdir)'; then pmfiles="$$pmfiles $(srcdir)/lib/Automake/*.pm"; \
767         else :; fi && \
768         pm=`cat $$pmfiles | wc -l` && \
769         dot_am_files=`ls -1 $(srcdir)/lib/am/*.am | grep -v Makefile.am` && \
770         amf=`echo "$$dot_am_files" | wc -l` && \
771         aml=`cat $$dot_am_files | wc -l` && \
772         m4f=`ls -1 $(srcdir)/m4/*.m4 | wc -l` && \
773         m4l=`cat $(srcdir)/m4/*.m4 | wc -l` && \
774         doc_text=`$(am__cd) doc && LC_ALL=C pstops 0 automake.ps unused.ps 2>&1` && \
775         echo "$$doc_text" && \
776         rm -f doc/unused.ps && \
777         doc=`echo "$$doc_text" | sed -n 's/.*Wrote \([1-9][0-9]*\) pages.*/\1/p'` && \
778         tests="tests/*.test"; \
779         if test . != '$(srcdir)'; then tests="$$tests $(srcdir)/tests/*.test"; \
780         else :; fi && \
781         t=`ls -1 $$tests | wc -l` && \
782         tgen=`grep 'GENERATED AUTOMATICALLY' $$tests | wc -l` && \
783         today=`date +%Y-%m-%d` && \
784         echo "add this to the table in doc/automake.texi after verification:" && \
785         printf '@item %s @tab %-6s @tab %4d @tab %4d @tab %4d @tab %4d %-4s @tab %4d %-4s @tab %3d @tab %d %-4s\n' \
786                       $$today $(VERSION) $$am    $$acl    $$pm   $$aml "($$amf)" $$m4l "($$m4f)" $$doc $$t "($$tgen)"
787 .PHONY: release-stats