-## Tests should never call make directly.
-sc_tests_plain_make:
- @if grep -v '^#' $(xtests) | $(EGREP) ':[ ]*make( |$$)'; then \
- echo 'Do not run "make" in the above tests. Use "$$MAKE" instead.' 1>&2; \
- exit 1; \
- fi
-
-## Tests should never call autoconf directly.
-sc_tests_plain_autoconf:
- @if grep -v '^#' $(xtests) | grep ':[ ]*autoconf\>'; then \
- echo 'Do not run "autoconf" in the above tests. Use "$$AUTOCONF" instead.' 1>&2; \
- exit 1; \
- fi
-
-## Tests should never call autoupdate directly.
-sc_tests_plain_autoupdate:
- @if grep -v '^#' $(xtests) | grep ':[ ]*autoupdate\>'; then \
- echo 'Do not run "autoupdate" in the above tests. Use "$$AUTOUPDATE" instead.' 1>&2; \
- exit 1; \
- fi
-
-## Tests should never call automake directly.
-sc_tests_plain_automake:
- @if grep -v '^#' $(xtests) | grep -E ':[ ]*automake\>([^:]|$$)'; then \
- echo 'Do not run "automake" in the above tests. Use "$$AUTOMAKE" instead.' 1>&2; \
- exit 1; \
- fi
-
-## Tests should never call autoheader directly.
-sc_tests_plain_autoheader:
- @if grep -v '^#' $(xtests) | grep ':[ ]*autoheader\>'; then \
- echo 'Do not run "autoheader" in the above tests. Use "$$AUTOHEADER" instead.' 1>&2; \
- exit 1; \
- fi
-
-## Tests should never call autoreconf directly.
-sc_tests_plain_autoreconf:
- @if grep -v '^#' $(xtests) | grep ':[ ]*autoreconf\>'; then \
- echo 'Do not run "autoreconf" in the above tests. Use "$$AUTORECONF" instead.' 1>&2; \
- exit 1; \
- fi
-
-## Tests should never call autom4te directly.
-sc_tests_plain_autom4te:
- @if grep -v '^#' $(xtests) | grep ':[ ]*autom4te\>'; then \
- echo 'Do not run "autom4te" in the above tests. Use "$$AUTOM4TE" instead.' 1>&2; \
- exit 1; \
+## Tests should never call some programs directly, but only through the
+## corresponding variable (e.g., '$MAKE', not 'make'). This will allow
+## the programs to be overridden at configure time (for less brittleness)
+## or by the user at make time (to allow better testsuite coverage).
+sc_tests_plain_check_rules = \
+ sc_tests_plain_egrep \
+ sc_tests_plain_fgrep \
+ sc_tests_plain_make \
+ sc_tests_plain_perl \
+ sc_tests_plain_automake \
+ sc_tests_plain_aclocal \
+ sc_tests_plain_autoconf \
+ sc_tests_plain_autoupdate \
+ sc_tests_plain_autom4te \
+ sc_tests_plain_autoheader \
+ sc_tests_plain_autoreconf
+
+toupper = $(shell echo $(1) | LC_ALL=C tr '[a-z]' '[A-Z]')
+
+$(sc_tests_plain_check_rules): sc_tests_plain_% :
+ @# The leading ':' in the grep below is what is printed by the
+ @# preceding 'grep -v' after the file name.
+ @# It works here as a poor man's substitute for beginning-of-line
+ @# marker.
+ @if grep -v '^[ ]*#' $(xtests) \
+ | $(EGREP) '(:|\bif|\bnot|[;!{\|\(]|&&|\|\|)[ ]*?$*\b'; \
+ then \
+ echo 'Do not run "$*" in the above tests.' \
+ 'Use "$$$(call toupper,$*)" instead.' 1>&2; \
+ exit 1; \