From: Ralf Wildenhues Date: Sun, 3 Oct 2010 09:45:31 +0000 (+0200) Subject: maintainer-check coverage for variables before rules. X-Git-Tag: ng-0.5a~359 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=145c2d0d024e2213a5c833427b4281fb55001709;p=thirdparty%2Fautomake.git maintainer-check coverage for variables before rules. * Makefile.am (sc_ensure_testsuite_has_run): Suggest keeping around the test directories. (sc_tests_makefile_variable_order): New rule with a heuristic to catch ordering violations. Signed-off-by: Ralf Wildenhues --- diff --git a/ChangeLog b/ChangeLog index b608c9449..5a15698b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2010-10-03 Ralf Wildenhues + maintainer-check coverage for variables before rules. + * Makefile.am (sc_ensure_testsuite_has_run): Suggest keeping + around the test directories. + (sc_tests_makefile_variable_order): New rule with a heuristic to + catch ordering violations. + Document and fix expansion of variables before rules. * doc/automake.texi (General Operation): Document that variables are expanded before rules. diff --git a/Makefile.am b/Makefile.am index 8eb1bde68..a5df10915 100644 --- a/Makefile.am +++ b/Makefile.am @@ -195,6 +195,7 @@ sc_tests_plain_sleep \ sc_tests_plain_egrep_fgrep \ sc_tests_PATH_SEPARATOR \ sc_tests_logs_duplicate_prefixes \ +sc_tests_makefile_variable_order \ sc_mkdir_p \ sc_perl_at_substs \ sc_unquoted_DESTDIR \ @@ -467,9 +468,10 @@ sc_tests_plain_egrep_fgrep: ## 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 AM_RECURSIVE_TARGETS. +## Suggest keeping test directories around for greppability of the Makefile.in files. sc_ensure_testsuite_has_run: @if test ! -f tests/test-suite.log; then \ - echo "Run \`make check' before \`maintainer-check'" >&2; \ + echo "Run \`env keep_testdirs=yes make check' before \`maintainer-check'" >&2; \ exit 1; \ fi .PHONY: sc_ensure_testsuite_has_run @@ -482,6 +484,24 @@ 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 + @for file in `find tests -name Makefile.in -print`; do \ + latevars=`sed -n \ + -e :x -e 's/#.*//' \ + -e '/\\\\$$/{' -e N -e 'b x' -e '}' \ +## Literal TAB. + -e '1,/^ /d' \ +## Allow @ so we match conditionals. + -e '/^ *[a-zA-Z_@]\{1,\} *=/p' $$file`; \ + if test -n "$$latevars"; then \ + echo 'Ensure variables are expanded before rules' >&2; \ + echo "Variables are expanded too late in $$file:" >&2; \ + echo "$$latevars" | sed 's/^/ /' >&2; \ + exit 1; \ + fi; \ + done + ## Using `:' as a PATH separator is not portable. sc_tests_PATH_SEPARATOR: @if grep -E '\bPATH=.*:.*' $(srcdir)/tests/*.test ; then \ diff --git a/Makefile.in b/Makefile.in index f4685414c..232fbf700 100644 --- a/Makefile.in +++ b/Makefile.in @@ -316,6 +316,7 @@ sc_tests_plain_sleep \ sc_tests_plain_egrep_fgrep \ sc_tests_PATH_SEPARATOR \ sc_tests_logs_duplicate_prefixes \ +sc_tests_makefile_variable_order \ sc_mkdir_p \ sc_perl_at_substs \ sc_unquoted_DESTDIR \ @@ -1188,7 +1189,7 @@ sc_tests_plain_egrep_fgrep: sc_ensure_testsuite_has_run: @if test ! -f tests/test-suite.log; then \ - echo "Run \`make check' before \`maintainer-check'" >&2; \ + echo "Run \`env keep_testdirs=yes make check' before \`maintainer-check'" >&2; \ exit 1; \ fi .PHONY: sc_ensure_testsuite_has_run @@ -1199,6 +1200,21 @@ sc_tests_logs_duplicate_prefixes: sc_ensure_testsuite_has_run exit 1; \ fi +sc_tests_makefile_variable_order: sc_ensure_testsuite_has_run + @for file in `find tests -name Makefile.in -print`; do \ + latevars=`sed -n \ + -e :x -e 's/#.*//' \ + -e '/\\\\$$/{' -e N -e 'b x' -e '}' \ + -e '1,/^ /d' \ + -e '/^ *[a-zA-Z_@]\{1,\} *=/p' $$file`; \ + if test -n "$$latevars"; then \ + echo 'Ensure variables are expanded before rules' >&2; \ + echo "Variables are expanded too late in $$file:" >&2; \ + echo "$$latevars" | sed 's/^/ /' >&2; \ + exit 1; \ + fi; \ + done + sc_tests_PATH_SEPARATOR: @if grep -E '\bPATH=.*:.*' $(srcdir)/tests/*.test ; then \ echo "Use \`$$PATH_SEPARATOR', not \`:', in PATH definitions above." 1>&2; \