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