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