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