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