The recent extension of the `maintainer-check' target (to include checks on the consistency of the list of test scripts) has introduced some code duplication. This patch takes care of removing the part of such duplication that wasn't removed by the previous patch.
From 122d8df933eb23409e4a2f6e54a97399b3cc7af0 Mon Sep 17 00:00:00 2001 From: Stefano Lattarini <stefano.lattar...@gmail.com> Date: Sat, 26 Dec 2009 01:06:06 +0100 Subject: [PATCH 6/6] Refactoring in makefiles, to avoid code duplication.
* Makefile.am (recurse_in_test_subdirs): New variable, factor out non-obvious shell code common to some rules. (recheck): Use it. (maintainer-check-list-of-tests): Likewise. --- ChangeLog | 6 ++++++ Makefile.am | 37 +++++++++++++++---------------------- Makefile.in | 37 +++++++++++++++---------------------- 3 files changed, 36 insertions(+), 44 deletions(-) diff --git a/ChangeLog b/ChangeLog index c64e8f8..63d0db6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2009-12-26 Stefano Lattarini <stefano.lattar...@gmail.com> + Some more refactoring in makefiles, to avoid code duplication. + * Makefile.am (recurse_in_test_subdirs): New variable, factor out + non-obvious shell code common to some rules. + (recheck): Use it. + (maintainer-check-list-of-tests): Likewise. + Maint-check: refactoring in makefiles, to avoid code duplication. The recent extension of the `maintainer-check' target (to include checks on the consistency of the list of test scripts) has diff --git a/Makefile.am b/Makefile.am index 08fdc6f..543ccea 100644 --- a/Makefile.am +++ b/Makefile.am @@ -62,6 +62,19 @@ uninstall-hook: rm -f $(DESTDIR)$(bindir)/$$fv; \ done +## Factor out non-obvious shell code common to different targets. +recurse_in_test_subdirs = \ + failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + for subdir in $(TEST_SUBDIRS); do \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $@) || eval $$failcom; \ + done; \ + test -z "$$fail" ## We can't use configure to do the substitution here; we must do it ## by hand. We use a funny notation here to avoid configure @@ -100,17 +113,7 @@ TEST_SUBDIRS = lib/Automake/tests tests .PHONY: recheck recheck: - @failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ - *k*) failcom='fail=yes';; \ - esac; \ - done; \ - for subdir in $(TEST_SUBDIRS); do \ - (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $@) || eval $$failcom; \ - done; \ - test -z "$$fail" + @$(recurse_in_test_subdirs) ################################################################ ## @@ -202,17 +205,7 @@ $(syntax_check_rules): automake aclocal ## list of all test scripts in the Automake testsuite. .PHONY: maintainer-check-list-of-tests maintainer-check-list-of-tests: - @failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ - *k*) failcom='fail=yes';; \ - esac; \ - done; \ - for subdir in $(TEST_SUBDIRS); do \ - (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $@) || eval $$failcom; \ - done; \ - test -z "$$fail" + @$(recurse_in_test_subdirs) maintainer-check: $(syntax_check_rules) maintainer-check-list-of-tests diff --git a/Makefile.in b/Makefile.in index c8fb016..f597400 100644 --- a/Makefile.in +++ b/Makefile.in @@ -245,6 +245,19 @@ EXTRA_DIST = \ bootstrap \ $(AUTOMAKESOURCES) +recurse_in_test_subdirs = \ + failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + for subdir in $(TEST_SUBDIRS); do \ + (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $@) || eval $$failcom; \ + done; \ + test -z "$$fail" + do_subst = sed \ -e 's,[...@]apiversion[@],$(APIVERSION),g' \ -e 's,[...@]package[@],$(PACKAGE),g' \ @@ -891,17 +904,7 @@ INSTALL: lib/INSTALL .PHONY: recheck recheck: - @failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ - *k*) failcom='fail=yes';; \ - esac; \ - done; \ - for subdir in $(TEST_SUBDIRS); do \ - (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $@) || eval $$failcom; \ - done; \ - test -z "$$fail" + @$(recurse_in_test_subdirs) ################################################################ @@ -943,17 +946,7 @@ $(syntax_check_rules): automake aclocal .PHONY: maintainer-check-list-of-tests maintainer-check-list-of-tests: - @failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ - *k*) failcom='fail=yes';; \ - esac; \ - done; \ - for subdir in $(TEST_SUBDIRS); do \ - (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $@) || eval $$failcom; \ - done; \ - test -z "$$fail" + @$(recurse_in_test_subdirs) maintainer-check: $(syntax_check_rules) maintainer-check-list-of-tests -- 1.6.5