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