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