summaryrefslogtreecommitdiff
path: root/maintainer/syntax-checks.mk
diff options
context:
space:
mode:
Diffstat (limited to 'maintainer/syntax-checks.mk')
-rw-r--r--maintainer/syntax-checks.mk311
1 files changed, 194 insertions, 117 deletions
diff --git a/maintainer/syntax-checks.mk b/maintainer/syntax-checks.mk
index a74f49a78..657de45e0 100644
--- a/maintainer/syntax-checks.mk
+++ b/maintainer/syntax-checks.mk
@@ -1,4 +1,4 @@
-# Maintainer checks for Automake. Requires GNU make.
+# Maintainer checks for Automake-NG.
# Copyright (C) 2012-2014 Free Software Foundation, Inc.
#
@@ -36,7 +36,8 @@ xdefs = \
$(srcdir)/t/ax/test-lib.sh \
$(srcdir)/t/ax/test-defs.in
-ams := $(shell find $(srcdir) -name '*.dir' -prune -o -name '*.am' -print)
+ams := $(shell find $(srcdir) -name '*.dir' -prune -o -name '?*.am' -a -print)
+pms := $(dist_perllib_DATA)
# Some simple checks, and then ordinary check. These are only really
# guaranteed to work on my machine.
@@ -51,12 +52,22 @@ sc_mkinstalldirs \
sc_pre_normal_post_install_uninstall \
sc_perl_no_undef \
sc_perl_no_split_regex_space \
-sc_cd_in_backquotes \
-sc_cd_relative_dir \
+sc_no_am_cd \
sc_perl_at_uscore_in_scalar_context \
sc_perl_local \
sc_AMDEP_TRUE_in_automake_in \
-sc_make_without_am_makeflags \
+sc_tests_no_gmake_requirement \
+sc_tests_no_gmake_checking \
+sc_tests_make_can_chain_suffix_rules \
+sc_tests_make_dont_do_useless_vpath_rebuilds \
+sc_no_dotmake_target \
+sc_no_am_makeflags \
+$(sc_renamed_variables_rules) \
+sc_no_RECHECK_LOGS \
+sc_tests_no_make_e \
+sc_docs_no_make_e \
+sc_make_simple_include \
+sc_tests_make_simple_include \
sc_tests_no_source_defs \
sc_tests_obsolete_variables \
sc_tests_here_document_format \
@@ -64,15 +75,11 @@ sc_tests_command_subst \
sc_tests_no_run_make_redirect \
sc_tests_exit_not_Exit \
sc_tests_automake_fails \
-sc_tests_overriding_macros_on_cmdline \
-sc_tests_no_make_e \
sc_tests_plain_sleep \
sc_tests_ls_t \
sc_m4_am_plain_egrep_fgrep \
-sc_tests_no_configure_in \
sc_tests_PATH_SEPARATOR \
sc_tests_logs_duplicate_prefixes \
-sc_tests_makefile_variable_order \
sc_perl_at_substs \
sc_unquoted_DESTDIR \
sc_tabs_in_texi \
@@ -82,10 +89,6 @@ $(syntax_check_rules): bin/automake bin/aclocal
maintainer-check: $(syntax_check_rules)
.PHONY: maintainer-check $(syntax_check_rules)
-# Check that the list of tests given in the Makefile is equal to the
-# list of all test scripts in the Automake testsuite.
-maintainer-check: maintainer-check-list-of-tests
-
# I'm a lazy typist.
lint: maintainer-check
.PHONY: lint
@@ -147,21 +150,30 @@ sc_rm_minus_f:
else :; fi
# Never use something like "for file in $(FILES)", this doesn't work
-# if FILES is empty or if it contains shell meta characters (e.g. $ is
-# commonly used in Java filenames).
+# if FILES is empty or if it contains shell meta characters (e.g. '$'
+# is commonly used in Java filenames). Make an exception for
+# $(am__installdirs), which is already defined as properly quoted.
sc_no_for_variable_in_macro:
- @if grep 'for .* in \$$(' $(ams) | grep -v '/Makefile\.am:'; then \
+ @LC_ALL=C; export LC_ALL; \
+ if grep 'for .* in \$$(' $(ams) | grep -v '/Makefile\.am:' \
+ | grep -Ev '\bfor [a-zA-Z0-9_]+ in \$$\(am__installdirs\)'; \
+ then \
echo 'Use "list=$$(mumble); for var in $$$$list".' 1>&2 ; \
exit 1; \
else :; fi
-# Make sure all invocations of mkinstalldirs are correct.
+# The script and variable 'mkinstalldirs' are obsolete.
sc_mkinstalldirs:
- @if grep -n 'mkinstalldirs' $(ams) \
- | grep -F -v '$$(mkinstalldirs)' \
- | grep -v '^\./Makefile.am:[0-9][0-9]*: *lib/mkinstalldirs \\$$'; \
- then \
- echo "Found incorrect use of mkinstalldirs in the lines above" 1>&2; \
+ @files="\
+ $(xtests) \
+ $(pms) \
+ $(ams) \
+ $(automake_in) \
+ $(srcdir)/doc/*.texi \
+ $(srcdir)/maintainer/maint.mk \
+ "; \
+ if grep 'mkinstalldirs' $$files; then \
+ echo "Found use of mkinstalldirs; that is obsolete" 1>&2; \
exit 1; \
else :; fi
@@ -188,27 +200,19 @@ sc_perl_no_split_regex_space:
exit 1; \
fi
-# Look for cd within backquotes
-sc_cd_in_backquotes:
- @if grep -n '^[^#]*` *cd ' $(automake_in) $(ams); then \
- echo "Consider using \$$(am__cd) in the lines above." 1>&2; \
- exit 1; \
- fi
-
-# Look for cd to a relative directory (may be influenced by CDPATH).
-# Skip some known directories that are OK.
-sc_cd_relative_dir:
- @if grep -n '^[^#]*cd ' $(automake_in) $(ams) | \
- grep -v 'echo.*cd ' | \
- grep -v 'am__cd =' | \
- grep -v '^[^#]*cd [./]' | \
- grep -v '^[^#]*cd \$$(top_builddir)' | \
- grep -v '^[^#]*cd "\$$\$$am__cwd' | \
- grep -v '^[^#]*cd \$$(abs' | \
- grep -v '^[^#]*cd "\$$(DESTDIR)'; then \
- echo "Consider using \$$(am__cd) in the lines above." 1>&2; \
+sc_no_am_cd:
+ @files="\
+ $(xtests) \
+ $(pms) \
+ $(ams) \
+ $(automake_in) \
+ $(srcdir)/doc/*.texi \
+ "; \
+ if grep -F 'am__cd' $$files; then \
+ echo "Found uses of 'am__cd', which is obsolete" 1>&2; \
+ echo "Using a simple 'cd' should be enough" 1>&2; \
exit 1; \
- fi
+ else :; fi
# Using @_ in a scalar context is most probably a programming error.
sc_perl_at_uscore_in_scalar_context:
@@ -218,7 +222,7 @@ sc_perl_at_uscore_in_scalar_context:
exit 1; \
fi
-## Allow only few variables to be localized in automake and aclocal.
+# Allow only few variables to be localized in automake and aclocal.
sc_perl_local:
@if egrep -v '^[ \t]*local \$$[_~]( *=|;)' \
$(automake_in) $(aclocal_in) | \
@@ -234,13 +238,151 @@ sc_AMDEP_TRUE_in_automake_in:
exit 1; \
fi
-# Recursive make invocations should always pass $(AM_MAKEFLAGS)
-# to $(MAKE), for portability to non-GNU make.
-sc_tests_make_without_am_makeflags:
- @if grep '^[^#].*(MAKE) ' $(ams) $(automake_in) \
- | grep -Fv '$$(AM_MAKEFLAGS)'; \
+# Tests should never require GNU make explicitly: automake-ng assumes
+# it unconditionally.
+sc_tests_no_gmake_requirement:
+ @if grep -iE '^ *required=.*\b(g|gnu)make\b' $(xtests) $(xdefs); \
+ then \
+ echo 'Tests should never require GNU make explicitly.' 1>&2; \
+ exit 1; \
+ fi
+
+# Tests should never check explicitly whether the make program being
+# used in the test suite is indeed GNU make: automake-ng assumes it
+# unconditionally.
+sc_tests_no_gmake_checking:
+ @if grep -E '\b(is|using)_g(nu)?make\b' $(xtests) $(xdefs); \
then \
- echo 'Use $$(MAKE) $$(AM_MAKEFLAGS).' 1>&2; \
+ echo 'Tests should never explicitly check whether $$MAKE' \
+ 'is GNU make.' 1>&2; \
+ exit 1; \
+ fi
+
+# GNU make can obviously chain suffix rules, so don't try to check
+# whether this is the case.
+sc_tests_make_can_chain_suffix_rules:
+ @if grep 'chain_suffix_rule' $(xtests); then \
+ echo 'GNU make can implicitly chain suffix rules; tests' \
+ 'should just assume that without checking.' 1>&2; \
+ exit 1; \
+ fi
+
+# Automake bug#7884 affects only FreeBSD make, so that we don't
+# need to work around in any of our tests anymore.
+sc_tests_make_dont_do_useless_vpath_rebuilds:
+ @if grep -E 'useless_vpath_rebuild|yl_distcheck' $(xtests); then \
+ echo 'No need to work around automake bug#7884 anymore;' \
+ 'it only affects FreeBSD make.' 1>&2; \
+ exit 1; \
+ fi
+
+# GNU make supports POSIX-style runtime include directives.
+sc_grep_for_bad_make_include = \
+ if grep -E 'AM_MAKE_INCLUDE|am__(include|quote)' $$files; then \
+ echo 'GNU make supports runtime "include" directive.' 1>&2; \
+ echo 'Neither am__{include,quote} nor AM_MAKE_INCLUDE' \
+ 'should be used anymore.' 1>&2; \
+ exit 1; \
+ fi
+sc_tests_make_simple_include: sc_ensure_testsuite_has_run
+ @files='t/*.log'; $(sc_grep_for_bad_make_include)
+sc_make_simple_include:
+ @files=" \
+ $(xtests) \
+ $(ams) \
+ $(srcdir)/m4/*.m4 \
+ $(automake_in) \
+ $(srcdir)/doc/*.texi \
+ aclocal.m4 \
+ configure \
+ "; \
+ $(sc_grep_for_bad_make_include)
+
+# The '.MAKE' special target is NetBSD-make specific, and not supported
+# by GNU make. No point in using it.
+sc_no_dotmake_target:
+ @files="\
+ $(ams) \
+ $(automake_in) \
+ $(srcdir)/doc/*.texi \
+ "; \
+ if grep '\.MAKE' $$files; then \
+ echo "Special target '.MAKE' not supported by GNU make." 1>&2; \
+ echo "Use the '+' recipe modifier instead, or put the" \
+ "'\$$(MAKE)' string somewhere in the recipe text." 1>&2; \
+ exit 1; \
+ fi
+
+# $(AM_MAKEFLAGS) is obsolete now that we assume GNU make, since it
+# is smart enough to correctly pass the values of macros redefined on
+# the command line to sub-make invocations.
+sc_no_am_makeflags:
+ @files="\
+ $(xtests) \
+ $(ams) \
+ $(automake_in) \
+ $(srcdir)/doc/*.texi \
+ "; \
+ if grep '\bAM_MAKEFLAGS\b' $$files; then \
+ echo "\$$(AM_MAKEFLAGS) is obsolete, don't use it." 1>&2; \
+ exit 1; \
+ fi
+
+# Modern names for internal variables that had a bad name once.
+modern.DISTFILES = am.dist.all-files
+modern.DIST_COMMON = am.dist.common-files
+modern.DIST_SOURCES = am.dist.sources
+modern.am__TEST_BASES = am.test-suite.test-bases
+modern.am__TEST_LOGS = am.test-suite.test-logs
+modern.am__TEST_RESULTS = am.test-suite.test-results
+modern.CONFIG_HEADER = AM_CONFIG_HEADERS
+modern.DEFAULT_INCLUDES = AM_DEFAULT_INCLUDES
+
+sc_renamed_variables_rules = \
+ $(patsubst modern.%,sc_no_%,$(filter modern.%,$(.VARIABLES)))
+
+$(sc_renamed_variables_rules): sc_no_% :
+ @files="\
+ $(xtests) \
+ $(pms) \
+ $(ams) \
+ $(automake_in) \
+ $(srcdir)/doc/*.texi \
+ "; \
+ if grep -E '\b$*\b' $$files; then \
+ echo "'\$$($*)' is obsolete and no more used." >&2; \
+ echo "You should use '$(modern.$*)' instead." >&2; \
+ exit 1; \
+ fi
+
+sc_no_RECHECK_LOGS:
+ @files="\
+ $(xtests) \
+ $(pms) \
+ $(ams) \
+ $(srcdir)/doc/*.texi \
+ $(automake_in) \
+ README t/README \
+ "; \
+ if grep -F 'RECHECK_LOGS' $$files; then \
+ echo "'RECHECK_LOGS' is obsolete and no more used." >&2; \
+ echo "You should use 'AM_LAZY_CHECK' instead." >&2; \
+ exit 1; \
+ fi
+
+# "make -e" is brittle and unsafe, since it let *all* the environment
+# win over the macro definitions in the Makefiles. We needed it when
+# we couldn't assume GNU make, but now that the tide has turned, it's
+# better to prohibit it altogether.
+sc_tests_no_make_e:
+ @if grep -E '\$$MAKE\b.* -[a-zA-Z0-9]*e' $(xtests); then \
+ echo "\"make -e\" is brittle, don't use it." 1>&2; \
+ exit 1; \
+ fi
+sc_docs_no_make_e:
+ @if grep '\bmake\b.* -[a-zA-Z0-9]*e' README t/README; then \
+ echo "Don't advocate the use of \"make -e\" in the manual or" \
+ " in the README files." 1>&2; \
exit 1; \
fi
@@ -373,49 +515,6 @@ sc_tests_automake_fails:
exit 1; \
fi
-# "make -e" is brittle and unsafe, since it let *all* the environment
-# win over the macro definitions in the Makefiles. Since we offer
-# AM_MAKEFLAGS to allow the user to portably override macro definitions
-# from the command line in a safe way, we should encourage users to use
-# it.
-sc_tests_no_make_e:
- @if grep -E '\$$MAKE\b.* -[a-zA-Z0-9]*e' $(xtests); then \
- echo '"make -e" is brittle, use "run_make" instead.' 1>&2; \
- exit 1; \
- fi
-
-# Overriding a Makefile macro on the command line is not portable when
-# recursive targets are used. Better use an envvar. SHELL is an
-# exception, POSIX says it can't come from the environment. V, DESTDIR,
-# DISTCHECK_CONFIGURE_FLAGS and DISABLE_HARD_ERRORS are exceptions, too,
-# as package authors are urged not to initialize them anywhere.
-# Finally, 'exp' is used by some ad-hoc checks, where we ensure it's
-# ok to override it from the command line.
-sc_tests_overriding_macros_on_cmdline:
-# The first s/// tries to account for usages like "$MAKE || st=$?".
-# 'DISTCHECK_CONFIGURE_FLAGS' and 'exp' are allowed to contain whitespace in
-# their definitions, hence the more complex last three substitutions below.
- @if sed -e 's/ || .*//' -e 's/ && .*//' \
- -e 's/ DESTDIR=[^ ]*/ /' -e 's/ SHELL=[^ ]*/ /' \
- -e 's/ V=[^ ]*/ /' -e 's/ DISABLE_HARD_ERRORS=[^ ]*/ /' \
- -e "s/ DISTCHECK_CONFIGURE_FLAGS='[^']*'/ /" \
- -e 's/ DISTCHECK_CONFIGURE_FLAGS="[^"]*"/ /' \
- -e 's/ DISTCHECK_CONFIGURE_FLAGS=[^ ]/ /' \
- -e "s/ exp='[^']*'/ /" \
- -e 's/ exp="[^"]*"/ /' \
- -e 's/ exp=[^ ]/ /' \
- $(filter-out %/am-test-lib.sh,$(xtests)) \
- | grep '\$$MAKE .*='; then \
- echo 'Rewrite "$$MAKE foo=bar" as "run_make foo=bar" in the lines above,'; \
- echo 'it is more portable.'; \
- exit 1; \
- fi >&2
- @if grep 'SHELL=.*\$$MAKE' $(xtests); then \
- echo '$$MAKE ignores the SHELL envvar, use "run_make SHELL=$$SHELL"'; \
- echo 'in the above lines.'; \
- exit 1; \
- fi >&2
-
# Prefer use of our 'is_newest' auxiliary script over the more hacky
# idiom "test $(ls -1t new old | sed 1q) = new", which is both more
# cumbersome and more fragile.
@@ -456,7 +555,7 @@ sc_tests_no_configure_in:
# Rule to ensure that the testsuite has been run before. We don't depend
# on 'check' here, because that would be very wasteful in the common case.
-# We could run "make check RECHECK_LOGS=" and avoid toplevel races with
+# We could run "make check AM_LAZY_CHECK=yes" and avoid toplevel races with
# AM_RECURSIVE_TARGETS. Suggest keeping test directories around for
# greppability of the Makefile.in files.
sc_ensure_testsuite_has_run:
@@ -475,28 +574,6 @@ sc_tests_logs_duplicate_prefixes: sc_ensure_testsuite_has_run
exit 1; \
fi
-# Ensure variables are listed before rules in Makefile.in files we generate.
-sc_tests_makefile_variable_order: sc_ensure_testsuite_has_run
- @st=0; \
- for file in `find t -name Makefile.in -print`; do \
- latevars=`sed -n \
- -e :x -e 's/#.*//' \
- -e '/\\\\$$/{' -e N -e 'b x' -e '}' \
- -e '# Literal TAB.' \
- -e '1,/^ /d' \
- -e '# Allow @ so we match conditionals.' \
- -e '/^ *[a-zA-Z_@]\{1,\} *=/p' $$file`; \
- if test -n "$$latevars"; then \
- echo "Variables are expanded too late in $$file:" >&2; \
- echo "$$latevars" | sed 's/^/ /' >&2; \
- st=1; \
- fi; \
- done; \
- test $$st -eq 0 || { \
- echo 'Ensure variables are expanded before rules' >&2; \
- exit 1; \
- }
-
# Using ':' as a PATH separator is not portable.
sc_tests_PATH_SEPARATOR:
@if grep -E '\bPATH=.*:.*' $(xtests) ; then \
@@ -524,13 +601,13 @@ sc_unquoted_DESTDIR:
fi
sc_tabs_in_texi:
- @if grep ' ' $(srcdir)/doc/automake.texi; then \
+ @if grep ' ' $(srcdir)/doc/*.texi; then \
echo 'Do not use tabs in the manual.' 1>&2; \
exit 1; \
fi
sc_at_in_texi:
- @if grep -E '([^@]|^)@([ ][^@]|$$)' $(srcdir)/doc/automake.texi; \
+ @if grep -E '([^@]|^)@([ ][^@]|$$)' $(srcdir)/doc/*.texi; \
then \
echo 'Unescaped @.' 1>&2; \
exit 1; \