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