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