fixup: contrib: really integrate in 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 . contrib doc m4 tests
27
28 TEST_SUBDIRS = tests lib/Automake/tests
29
30 bin_SCRIPTS = automake aclocal
31
32 CLEANFILES = $(bin_SCRIPTS)
33 AUTOMAKESOURCES = automake.in aclocal.in
34
35 TAGS_FILES = $(AUTOMAKESOURCES)
36
37 EXTRA_DIST = \
38   HACKING \
39   ChangeLog.96 \
40   ChangeLog.98 \
41   ChangeLog.00 \
42   ChangeLog.01 \
43   ChangeLog.02 \
44   ChangeLog.03 \
45   ChangeLog.04 \
46   ChangeLog.09 \
47   ChangeLog.11 \
48   bootstrap \
49   $(AUTOMAKESOURCES)
50
51 ## Make versioned links.  We only run the transform on the root name;
52 ## then we make a versioned link with the transformed base name.  This
53 ## seemed like the most reasonable approach.
54 install-exec-hook:
55         @$(POST_INSTALL)
56         @for p in $(bin_SCRIPTS); do \
57           f="`echo $$p|sed '$(transform)'`"; \
58           fv="$$f-$(APIVERSION)"; \
59           rm -f $(DESTDIR)$(bindir)/$$fv; \
60           echo " $(LN) $(DESTDIR)$(bindir)/$$f $(DESTDIR)$(bindir)/$$fv"; \
61           $(LN) $(DESTDIR)$(bindir)/$$f $(DESTDIR)$(bindir)/$$fv; \
62         done
63
64 uninstall-hook:
65         @for p in $(bin_SCRIPTS); do \
66           f="`echo $$p|sed '$(transform)'`"; \
67           fv="$$f-$(APIVERSION)"; \
68           rm -f $(DESTDIR)$(bindir)/$$fv; \
69         done
70
71
72 ## We can't use configure to do the substitution here; we must do it
73 ## by hand.  We use a funny notation here to avoid configure
74 ## substitutions in our text.
75 do_subst = sed \
76   -e 's,[@]APIVERSION[@],$(APIVERSION),g' \
77   -e 's,[@]PACKAGE[@],$(PACKAGE),g' \
78   -e 's,[@]PACKAGE_BUGREPORT[@],$(PACKAGE_BUGREPORT),g' \
79   -e 's,[@]PACKAGE_URL[@],$(PACKAGE_URL),g' \
80   -e 's,[@]PATH_SEPARATOR[@],$(PATH_SEPARATOR),g' \
81   -e 's,[@]PERL[@],$(PERL),g' \
82   -e 's,[@]PERL_THREADS[@],$(PERL_THREADS),g' \
83   -e 's,[@]SHELL[@],$(SHELL),g' \
84   -e 's,[@]am_AUTOCONF[@],$(am_AUTOCONF),g' \
85   -e 's,[@]am_AUTOM4TE[@],$(am_AUTOM4TE),g' \
86   -e 's,[@]VERSION[@],$(VERSION),g' \
87   -e 's,[@]configure_input[@],Generated from $@.in; do not edit by hand.,g' \
88   -e 's,[@]datadir[@],$(datadir),g'
89
90 ## These files depend on Makefile so they are rebuilt if $(VERSION),
91 ## $(datadir) or other do_subst'ituted variables change.
92 ## Use chmod a-w to prevent people from editing the wrong file by accident.
93 automake: automake.in
94 aclocal: aclocal.in
95 automake aclocal: Makefile
96         $(AM_V_at)rm -f $@ $@-t
97         $(AM_V_GEN)$(do_subst) $(srcdir)/$@.in >$@-t
98         $(AM_V_at)chmod a+x,a-w $@-t && mv -f $@-t $@
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         $(AM_V_GEN)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 $(syntax_check_rules): automake aclocal
198 maintainer-check: $(syntax_check_rules)
199 .PHONY: maintainer-check $(syntax_check_rules)
200
201 ## Check that the list of tests given in the Makefile is equal to the
202 ## list of all test scripts in the Automake testsuite.
203 .PHONY: maintainer-check-list-of-tests
204 maintainer-check-list-of-tests:
205         @fail= failcom='exit 1'; \
206         for f in x $$MAKEFLAGS; do \
207           case $$f in \
208             *=* | --[!k]*);; \
209             *k*) failcom='fail=yes';; \
210           esac; \
211         done; \
212         for subdir in $(TEST_SUBDIRS); do \
213           (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $@) || eval $$failcom; \
214         done; \
215         test -z "$$fail"
216
217 maintainer-check: maintainer-check-list-of-tests
218
219 ## Look for test whose names can cause spurious failures when used as
220 ## first argument to AC_INIT (chiefly because they might contain an
221 ## m4/m4sugar builtin or macro name).
222 m4_builtins = \
223   __gnu__ \
224   __unix__ \
225   bpatsubst \
226   bregexp \
227   builtin \
228   changecom \
229   changequote \
230   changeword \
231   debugfile \
232   debugmode \
233   decr \
234   define \
235   defn \
236   divert \
237   divnum \
238   dnl \
239   dumpdef \
240   errprint \
241   esyscmd \
242   eval \
243   format \
244   ifdef \
245   ifelse \
246   include \
247   incr \
248   index \
249   indir \
250   len \
251   m4exit \
252   m4wrap \
253   maketemp \
254   mkstemp \
255   patsubst \
256   popdef \
257   pushdef \
258   regexp \
259   shift \
260   sinclude \
261   substr \
262   symbols \
263   syscmd \
264   sysval \
265   traceoff \
266   traceon \
267   translit \
268   undefine \
269   undivert
270 sc_test_names:
271         @m4_builtin_rx=`echo $(m4_builtins) | sed 's/ /|/g'`; \
272          m4_macro_rx="\\<($$m4_builtin_rx)\\>|\\<_?(A[CUMHS]|m4)_"; \
273          if ls tests/*.test | LC_ALL=C grep -E "$$m4_macro_rx"; then \
274            echo "the names of the tests above can be problematic" 1>&2; \
275            echo "Avoid test names that contain names of m4 macros" 1>&2; \
276            exit 1; \
277          fi
278
279 ## These check avoids accidental configure substitutions in the source.
280 ## There are exactly 9 lines that should be modified from automake.in to
281 ## automake, and 10 lines that should be modified from aclocal.in to
282 ## aclocal; these wors out to 32 and 34 lines of diffs, respectively.
283 sc_diff_automake_in_automake:
284         @if test `diff $(srcdir)/automake.in automake | wc -l` -ne 32; then \
285           echo "found too many diffs between automake.in and automake" 1>&2; \
286           diff -c $(srcdir)/automake.in automake; \
287           exit 1; \
288         fi
289 sc_diff_aclocal_in_aclocal:
290         @if test `diff $(srcdir)/aclocal.in aclocal | wc -l` -ne 34; then \
291           echo "found too many diffs between aclocal.in and aclocal" 1>&2; \
292           diff -c $(srcdir)/aclocal.in aclocal; \
293           exit 1; \
294         fi
295
296 ## Syntax check with default Perl (on my machine, Perl 5).
297 sc_perl_syntax:
298         @perllibdir="./lib$(PATH_SEPARATOR)$(srcdir)/lib" $(PERL) -c -w automake
299         @perllibdir="./lib$(PATH_SEPARATOR)$(srcdir)/lib" $(PERL) -c -w aclocal
300
301 ## expect no instances of '${...}'.  However, $${...} is ok, since that
302 ## is a shell construct, not a Makefile construct.
303 sc_no_brace_variable_expansions:
304         @if grep -F '$${' $(srcdir)/lib/am/[a-z]*.am | \
305                grep -F -v '$$$$'; then \
306           echo "Found too many uses of '\$${' in the lines above." 1>&2; \
307           exit 1;                               \
308         else :; fi
309
310 ## Make sure `rm' is called with `-f'.
311 sc_rm_minus_f:
312         @if grep -v '^#' $(srcdir)/lib/am/[a-z]*.am $(srcdir)/tests/*.test | \
313             grep -E '\<rm ([^-]|\-[^f ]*\>)'; then \
314           echo "Suspicious 'rm' invocation." 1>&2; \
315           exit 1;                               \
316         else :; fi
317
318 ## Never use something like `for file in $(FILES)', this doesn't work
319 ## if FILES is empty or if it contains shell meta characters (e.g. $ is
320 ## commonly used in Java filenames).
321 sc_no_for_variable_in_macro:
322         @if grep 'for .* in \$$(' $(srcdir)/lib/am/[a-z]*.am; then \
323           echo 'Use "list=$$(mumble); for var in $$$$list".' 1>&2 ; \
324           exit 1; \
325         else :; fi
326
327 ## Make sure all invocations of mkinstalldirs are correct.
328 sc_mkinstalldirs:
329         @if grep -n 'mkinstalldirs' $(srcdir)/lib/am/[a-z]*.am | \
330               grep -F -v '$$(mkinstalldirs)'; then \
331           echo "Found incorrect use of mkinstalldirs in the lines above" 1>&2; \
332           exit 1; \
333         else :; fi
334
335 ## Make sure all calls to PRE/NORMAL/POST_INSTALL/UNINSTALL
336 sc_pre_normal_post_install_uninstall:
337         @if grep -E -n '\((PRE|NORMAL|POST)_(|UN)INSTALL\)' \
338                  $(srcdir)/lib/am/[a-z]*.am | \
339               grep -v ':##' | grep -v ':        @\$$('; then \
340           echo "Found incorrect use of PRE/NORMAL/POST_INSTALL/UNINSTALL in the lines above" 1>&2; \
341           exit 1; \
342         else :; fi
343
344 ## We never want to use "undef", only "delete", but for $/.
345 sc_perl_no_undef:
346         @if grep -n -w 'undef ' $(srcdir)/automake.in | \
347               grep -F -v 'undef $$/'; then \
348           echo "Found undef in automake.in; use delete instead" 1>&2; \
349           exit 1; \
350         fi
351
352 ## We never want split (/ /,...), only split (' ', ...).
353 sc_perl_no_split_regex_space:
354         @if grep -n 'split (/ /' $(srcdir)/automake.in; then \
355           echo "Found bad split in the lines above." 1>&2; \
356           exit 1; \
357         fi
358
359 ## Look for cd within backquotes
360 sc_cd_in_backquotes:
361         @if grep -n '^[^#]*` *cd ' $(srcdir)/automake.in \
362               $(srcdir)/lib/am/*.am; then \
363           echo "Consider using \$$(am__cd) in the lines above." 1>&2; \
364           exit 1; \
365         fi
366
367 ## Look for cd to a relative directory (may be influenced by CDPATH).
368 ## Skip some known directories that are OK.
369 sc_cd_relative_dir:
370         @if grep -n '^[^#]*cd ' $(srcdir)/automake.in \
371               $(srcdir)/lib/am/*.am | \
372               grep -v 'echo.*cd ' | \
373               grep -v 'am__cd =' | \
374               grep -v '^[^#]*cd [./]' | \
375               grep -v '^[^#]*cd \$$(top_builddir)' | \
376               grep -v '^[^#]*cd "\$$\$$am__cwd' | \
377               grep -v '^[^#]*cd \$$(abs' | \
378               grep -v '^[^#]*cd "\$$(DESTDIR)'; then \
379           echo "Consider using \$$(am__cd) in the lines above." 1>&2; \
380           exit 1; \
381         fi
382
383 ## Using @_ in a scalar context is most probably a programming error.
384 sc_perl_at_uscore_in_scalar_context:
385         @if grep -Hn '[^@_A-Za-z0-9][_A-Za-z0-9]*[^) ] *= *@_' $(srcdir)/automake.in; then \
386           echo "Using @_ in a scalar context in the lines above." 1>&2; \
387           exit 1; \
388         fi
389
390 ## Forbid using parens with `local' to ease counting.
391 sc_perl_local_no_parens:
392         @if grep '^[ \t]*local *(' $(srcdir)/automake.in; then \
393           echo "Don't use \`local' with parens: use several \`local' above." >&2; \
394           exit 1; \
395         fi
396
397 ## Allow only few variables to be localized in Automake.
398 sc_perl_local:
399         @if egrep -v '^[ \t]*local \$$[_~]( *=|;)' $(srcdir)/automake.in | \
400                 grep '^[ \t]*local [^*]'; then \
401           echo "Please avoid \`local'." 1>&2; \
402           exit 1; \
403         fi
404
405 ## Don't let AMDEP_TRUE substitution appear in automake.in.
406 sc_AMDEP_TRUE_in_automake_in:
407         @if grep '@AMDEP''_TRUE@' $(srcdir)/automake.in; then \
408           echo "Don't put AMDEP_TRUE substitution in automake.in" 1>&2; \
409           exit 1; \
410         fi
411
412 ## Tests should never call make directly.
413 sc_tests_make_without_am_makeflags:
414         @if grep '^[^#].*(MAKE) ' $(srcdir)/lib/am/*.am $(srcdir)/automake.in |\
415                 grep -v 'AM_MAKEFLAGS'; then \
416           echo 'Use $$(MAKE) $$(AM_MAKEFLAGS).' 1>&2; \
417           exit 1; \
418         fi
419
420 ## Tests should never call make directly.
421 sc_tests_plain_make:
422         @if grep -v '^#' $(srcdir)/tests/*.test | $(EGREP) ':[  ]*make( |$$)'; then \
423           echo 'Do not run "make" in the above tests.  Use "$$MAKE" instead.' 1>&2; \
424           exit 1; \
425         fi
426
427 ## Tests should never call autoconf directly.
428 sc_tests_plain_autoconf:
429         @if grep -v '^#' $(srcdir)/tests/*.test | grep ':[      ]*autoconf\>'; then \
430           echo 'Do not run "autoconf" in the above tests.  Use "$$AUTOCONF" instead.' 1>&2; \
431           exit 1; \
432         fi
433
434 ## Tests should never call autoupdate directly.
435 sc_tests_plain_autoupdate:
436         @if grep -v '^#' $(srcdir)/tests/*.test | grep ':[      ]*autoupdate\>'; then \
437           echo 'Do not run "autoupdate" in the above tests.  Use "$$AUTOUPDATE" instead.' 1>&2; \
438           exit 1; \
439         fi
440
441 ## Tests should never call automake directly.
442 sc_tests_plain_automake:
443         @if grep -v '^#' $(srcdir)/tests/*.test | grep -E ':[   ]*automake\>([^:]|$$)'; then \
444           echo 'Do not run "automake" in the above tests.  Use "$$AUTOMAKE" instead.' 1>&2;  \
445           exit 1; \
446         fi
447
448 ## Tests should never call autoheader directly.
449 sc_tests_plain_autoheader:
450         @if grep -v '^#' $(srcdir)/tests/*.test | grep ':[      ]*autoheader\>'; then \
451           echo 'Do not run "automake" in the above tests.  Use "$$AUTOHEADER" instead.' 1>&2;  \
452           exit 1; \
453         fi
454
455 ## Tests should never call autoreconf directly.
456 sc_tests_plain_autoreconf:
457         @if grep -v '^#' $(srcdir)/tests/*.test | grep ':[      ]*autoreconf\>'; then \
458           echo 'Do not run "automake" in the above tests.  Use "$$AUTORECONF" instead.' 1>&2;  \
459           exit 1; \
460         fi
461
462 ## Tests should never call autom4te directly.
463 sc_tests_plain_autom4te:
464         @if grep -v '^#' $(srcdir)/tests/*.test | grep ':[      ]*autom4te\>'; then \
465           echo 'Do not run "automake" in the above tests.  Use "$$AUTOM4TE" instead.' 1>&2;  \
466           exit 1; \
467         fi
468
469 ## Tests should only use END and EOF for here documents
470 ## (so that the next test is effective).
471 sc_tests_here_document_format:
472         @if grep '<<' $(srcdir)/tests/*.test | grep -v 'END' | grep -v 'EOF'; then \
473           echo 'Use here documents with "END" and "EOF" only, for greppability.' 1>&2; \
474           exit 1; \
475         fi
476
477 ## Tests should never call exit directly, but use Exit.
478 ## This is so that the exit status is transported correctly across the 0 trap.
479 ## Ignore comments, testsuite self tests, and one perl line in ext2.test.
480 sc_tests_Exit_not_exit:
481         @found=false; for file in $(srcdir)/tests/*.test; do \
482           case $$file in */self-check-*.test) continue;; esac; \
483           res=`sed -n -e '/^#/d; /^\$$PERL/d' -e '/<<.*END/,/^END/b' \
484                       -e '/<<.*EOF/,/^EOF/b' -e '/exit [$$0-9]/p' $$file`; \
485           if test -n "$$res"; then \
486             echo "$$file:$$res"; \
487             found=true; \
488           fi; \
489         done; \
490         if $$found; then \
491           echo 'Do not call plain "exit", use "Exit" instead, in above tests.' 1>&2; \
492           exit 1; \
493         fi
494
495 ## Use AUTOMAKE_fails when appropriate
496 sc_tests_automake_fails:
497         @if grep -v '^#' $(srcdir)/tests/*.test | grep '\$$AUTOMAKE.*&&.*[eE]xit'; then \
498           echo 'Use AUTOMAKE_fails + grep to catch automake failures in the above tests.' 1>&2;  \
499           exit 1; \
500         fi
501
502 ## Tests should never call aclocal directly.
503 sc_tests_plain_aclocal:
504         @if grep -v '^#' $(srcdir)/tests/*.test | grep ':[      ]*aclocal\>'; then \
505           echo 'Do not run "aclocal" in the above tests.  Use "$$ACLOCAL" instead.' 1>&2;  \
506           exit 1; \
507         fi
508
509 ## Tests should never call perl directly.
510 sc_tests_plain_perl:
511         @if grep -v '^#' $(srcdir)/tests/*.test | grep ':[      ]*perl\>'; then \
512           echo 'Do not run "perl" in the above tests.  Use "$$PERL" instead.' 1>&2; \
513           exit 1; \
514         fi
515
516 ## Setting `required' after sourcing `./defs' is a bug.
517 sc_tests_required_after_defs:
518         @for file in $(srcdir)/tests/*.test; do \
519           if out=`sed -n '/defs/,$${/required=/p;}' $$file`; test -n "$$out"; then \
520             echo 'Do not set "required" after sourcing "defs" in '"$$file: $$out" 1>&2; \
521             exit 1; \
522           fi; \
523         done
524
525 ## Overriding a Makefile macro on the command line is not portable when
526 ## recursive targets are used.  Better use an envvar.  SHELL is an
527 ## exception, POSIX says it can't come from the environment.  V, DESTDIR,
528 ## DISTCHECK_CONFIGURE_FLAGS and DISABLE_HARD_ERRORS are exceptions, too,
529 ## as package authors are urged not to initialize them anywhere.
530 sc_tests_overriding_macros_on_cmdline:
531         @if grep -E '\$$MAKE .*(SHELL=.*=|=.*SHELL=)' $(srcdir)/tests/*.test; then \
532           echo 'Rewrite "$$MAKE foo=bar SHELL=$$SHELL" as "foo=bar $$MAKE -e SHELL=$$SHELL"' 1>&2; \
533           echo ' in the above lines, it is more portable.' 1>&2; \
534           exit 1; \
535         fi
536 ## Also try to account for usages like "$MAKE || st=$?".
537         @if sed -e 's/ || .*//' -e 's/ && .*//' \
538                 -e 's/ DESTDIR=[^ ]*/ /' -e 's/ SHELL=[^ ]*/ /' \
539                 -e 's/ V=[^ ]*/ /' -e 's/ DISABLE_HARD_ERRORS=[^ ]*/ /' \
540 ## DISTCHECK_CONFIGURE_FLAGS is allowed to contain whitespace in its
541 ## definition, so the more complex substitutions below.
542                 -e "s/ DISTCHECK_CONFIGURE_FLAGS='[^']*'/ /" \
543                 -e 's/ DISTCHECK_CONFIGURE_FLAGS="[^"]*"/ /' \
544                 -e 's/ DISTCHECK_CONFIGURE_FLAGS=[^ ]/ /' \
545               $(srcdir)/tests/*.test | grep '\$$MAKE .*='; then \
546           echo 'Rewrite "$$MAKE foo=bar" as "foo=bar $$MAKE -e" in the above lines,' 1>&2; \
547           echo 'it is more portable.' 1>&2; \
548           exit 1; \
549         fi
550         @if grep 'SHELL=.*\$$MAKE' $(srcdir)/tests/*.test; then \
551           echo '$$MAKE ignores the SHELL envvar, use "$$MAKE SHELL=$$SHELL" in' 1>&2; \
552           echo 'the above lines.' 1>&2; \
553           exit 1; \
554         fi
555
556 ## Never use `sleep 1' to create files with different timestamps.
557 ## Use `$sleep' instead.  Some filesystems (e.g., Windows') have only
558 ## a 2sec resolution.
559 sc_tests_plain_sleep:
560         @if grep -E '\bsleep +[12345]\b' $(srcdir)/tests/*.test; then \
561           echo 'Do not use "sleep x" in the above tests.  Use "$$sleep" instead.' 1>&2; \
562           exit 1; \
563         fi
564
565 ## fgrep and egrep are not required by POSIX.
566 sc_tests_plain_egrep_fgrep:
567         @if grep -E '\b[ef]grep\b' $(srcdir)/tests/*.test ; then \
568           echo 'Do not use egrep or fgrep in test cases.  Use $$FGREP or $$EGREP.' 1>&2; \
569           exit 1; \
570         fi
571         @if grep -E '\b[ef]grep\b' $(srcdir)/lib/am/*.am $(srcdir)/m4/*.m4; then \
572           echo 'Do not use egrep or fgrep in the above files, they are not portable.' 1>&2; \
573           exit 1; \
574         fi
575
576 ## Using `:' as a PATH separator is not portable.
577 sc_tests_PATH_SEPARATOR:
578         @if grep -E '\bPATH=.*:.*' $(srcdir)/tests/*.test ; then \
579           echo "Use \`\$$PATH_SEPARATOR', not \`:', in PATH definitions above." 1>&2; \
580           exit 1; \
581         fi
582
583 sc_mkdir_p:
584         @if grep 'mkdir_p' $(srcdir)/automake.in \
585               $(srcdir)/lib/am/*.am $(srcdir)/tests/*.test; then \
586           echo 'Do not use mkdir_p in the above files, use MKDIR_P.' 1>&2; \
587           exit 1; \
588         fi
589
590 ## Try to make sure all @...@ substitutions are covered by our
591 ## substitution rule.
592 sc_perl_at_substs:
593         @if test `grep -E '^[^#]*@[A-Za-z_0-9]+@' aclocal | wc -l` -ne 0; then \
594           echo "Unresolved @...@ substitution in aclocal" 1>&2; \
595           exit 1; \
596         fi
597         @if test `grep -E '^[^#]*@[A-Za-z_0-9]+@' automake | wc -l` -ne 0; then \
598           echo "Unresolved @...@ substitution in automake" 1>&2; \
599           exit 1; \
600         fi
601
602 sc_unquoted_DESTDIR:
603         @if grep -E "[^\'\"]\\\$$\(DESTDIR" $(srcdir)/lib/am/*.am; then \
604           echo 'Suspicious unquoted DESTDIR uses.' 1>&2 ; \
605           exit 1; \
606         fi
607
608 sc_tabs_in_texi:
609         @if grep '      ' $(srcdir)/doc/automake.texi; then \
610           echo 'Do not use tabs in the manual.' 1>&2; \
611           exit 1; \
612         fi
613
614 sc_at_in_texi:
615         @if grep -E '([^@]|^)@([         ][^@]|$$)' $(srcdir)/doc/automake.texi; \
616         then \
617           echo 'Unescaped @.' 1>&2; \
618           exit 1; \
619         fi
620
621
622 git-dist: maintainer-check
623 ## Make sure the NEWS file is up-to-date.
624         @if sed 1q $(srcdir)/NEWS | grep -e "$(VERSION)" > /dev/null; then :; else \
625           echo "NEWS not updated; not releasing" 1>&2; \
626           exit 1;                               \
627         fi
628 ## Build the distribution.  We expect the developer to have already run
629 ## "make check" and "make distcheck" on his own (as required in the
630 ## HACKING file, section "Release procedure").
631         $(MAKE) $(AM_MAKEFLAGS) dist
632 ## Finally, if anything was successful, commit the last changes and tag
633 ## the release in the repository.  We don't use RCS keywords so it's OK
634 ## to distribute the files before they were committed.
635         cd $(srcdir) && git commit -a -s && \
636            git tag -s "v$(VERSION)" -m "Release $(VERSION)"
637
638 git-release: git-dist
639         case $(VERSION) in \
640           *[a-z]) dest=alpha;; \
641           *)      dest=ftp;; \
642         esac; \
643         $(srcdir)/lib/gnupload $(GNUPLOADFLAGS) \
644           --to $$dest.gnu.org:automake $(DIST_ARCHIVES)
645
646 .PHONY: git-release git-dist
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 gnupload \
733 gitlog-to-changelog \
734 symlink-tree \
735 texinfo.tex
736
737 ## Fetch the latest versions of files we care about.
738 fetch:
739         rm -rf Fetchdir > /dev/null 2>&1
740         mkdir Fetchdir
741 ## If a get fails then that is a problem.
742         (cd Fetchdir && \
743         $(WGET_SV_GIT_CF)config.guess -O config.guess && \
744         $(WGET_SV_GIT_CF)config.sub -O config.sub && \
745         $(WGET_SV_CVS)texinfo/texinfo/doc/texinfo.tex -O texinfo.tex && \
746         $(WGET_SV_GIT_GL)doc/INSTALL -O INSTALL && \
747         $(WGET_SV_GIT_GL)build-aux/gnupload -O gnupload && \
748         $(WGET_SV_GIT_GL)build-aux/gitlog-to-changelog -O gitlog-to-changelog && \
749         $(WGET_GCC)config-ml.in -O config-ml.in && \
750         $(WGET_GCC)symlink-tree -O symlink-tree)
751 ## Don't exit after test because we want to give as many errors as
752 ## possible.
753         @stat=0; for file in $(FETCHFILES); do \
754           if diff -u $(srcdir)/lib/$$file Fetchdir/$$file \
755                   >>Fetchdir/update.patch 2>/dev/null; then :; \
756           else \
757             stat=1; \
758             echo "Updating $(srcdir)/lib/$$file..."; \
759             cp Fetchdir/$$file $(srcdir)/lib/$$file; \
760           fi; \
761         done; \
762         test $$stat = 0 || \
763           echo "See Fetchdir/update.patch for a log of the changes."; \
764         exit $$stat
765 .PHONY: fetch
766
767 ## Generate release statistics, for the table in automake.texi.
768 ## This has to be run in an up to date build tree, but there must
769 ## be no temp files nor unused other files lying around!
770 release-stats: ps
771         $(AM_V_GEN): && \
772         am=`wc -l < automake` && \
773         acl=`wc -l < aclocal` && \
774         pmfiles="lib/Automake/*.pm" && \
775         if test . != '$(srcdir)'; then pmfiles="$$pmfiles $(srcdir)/lib/Automake/*.pm"; \
776         else :; fi && \
777         pm=`cat $$pmfiles | wc -l` && \
778         dot_am_files=`ls -1 $(srcdir)/lib/am/*.am | grep -v Makefile.am` && \
779         amf=`echo "$$dot_am_files" | wc -l` && \
780         aml=`cat $$dot_am_files | wc -l` && \
781         m4f=`ls -1 $(srcdir)/m4/*.m4 | wc -l` && \
782         m4l=`cat $(srcdir)/m4/*.m4 | wc -l` && \
783         doc_text=`cd doc && LC_ALL=C pstops 0 automake.ps unused.ps 2>&1` && \
784         echo "$$doc_text" && \
785         rm -f doc/unused.ps && \
786         doc=`echo "$$doc_text" | sed -n 's/.*Wrote \([1-9][0-9]*\) pages.*/\1/p'` && \
787         tests="tests/*.test"; \
788         if test . != '$(srcdir)'; then tests="$$tests $(srcdir)/tests/*.test"; \
789         else :; fi && \
790         t=`ls -1 $$tests | wc -l` && \
791         tgen=`ls -1 $$tests | grep '.-p\.test' | wc -l` && \
792         today=`date +%Y-%m-%d` && \
793         echo "add this to the table in doc/automake.texi after verification:" && \
794         printf '@item %s @tab %-6s @tab %4d @tab %4d @tab %4d @tab %4d %-4s @tab %4d %-4s @tab %3d @tab %d %-4s\n' \
795                       $$today $(VERSION) $$am    $$acl    $$pm   $$aml "($$amf)" $$m4l "($$m4f)" $$doc $$t "($$tgen)"
796 .PHONY: release-stats