The first patch of this series introduced some code duplication, which was partly removed by the second patch. This final third patch takes care of removing the part of such duplication which wasn't removed by that second patch.
From ac98f437c4efa93eaf329597af8284b56d9c2b39 Mon Sep 17 00:00:00 2001 From: Stefano Lattarini <[email protected]> Date: Sat, 30 Jan 2010 02:35:35 +0100 Subject: [PATCH 3/3] Refactoring in makefiles, to avoid code duplication.
* Makefile.am (recurse_in_subdirs_cmd): New variable, factor out non-obvious shell code common to some rules (with a small fix). (recheck, maintainer-check-list-of-tests): Use it. --- ChangeLog | 7 +++++++ Makefile.am | 37 +++++++++++++++---------------------- Makefile.in | 37 +++++++++++++++---------------------- 3 files changed, 37 insertions(+), 44 deletions(-) diff --git a/ChangeLog b/ChangeLog index b69037b..fb772d0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2009-01-30 Stefano Lattarini <[email protected]> + Some more refactoring in makefiles, to avoid code duplication. + * Makefile.am (recurse_in_subdirs_cmd): New variable, factor out + non-obvious shell code common to some rules (with a small fix). + (recheck, maintainer-check-list-of-tests): Use it. + +2009-01-30 Stefano Lattarini <[email protected]> + 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 8801239..ec92259 100644 --- a/Makefile.am +++ b/Makefile.am @@ -63,6 +63,19 @@ uninstall-hook: rm -f $(DESTDIR)$(bindir)/$$fv; \ done +## Factor out non-obvious shell code common to different targets. +recurse_in_subdirs_cmd = \ + fail= failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + for subdir in $$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 @@ -101,17 +114,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" + @subdirs='$(TEST_SUBDIRS)'; $(recurse_in_subdirs_cmd) ################################################################ ## @@ -203,17 +206,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" + @subdirs='$(TEST_SUBDIRS)'; $(recurse_in_subdirs_cmd) maintainer-check: $(syntax_check_rules) maintainer-check-list-of-tests diff --git a/Makefile.in b/Makefile.in index ad1114d..8f899bd 100644 --- a/Makefile.in +++ b/Makefile.in @@ -262,6 +262,19 @@ EXTRA_DIST = \ bootstrap \ $(AUTOMAKESOURCES) +recurse_in_subdirs_cmd = \ + fail= failcom='exit 1'; \ + for f in x $$MAKEFLAGS; do \ + case $$f in \ + *=* | --[!k]*);; \ + *k*) failcom='fail=yes';; \ + esac; \ + done; \ + for subdir in $$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' \ @@ -908,17 +921,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" + @subdirs='$(TEST_SUBDIRS)'; $(recurse_in_subdirs_cmd) ################################################################ @@ -960,17 +963,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" + @subdirs='$(TEST_SUBDIRS)'; $(recurse_in_subdirs_cmd) maintainer-check: $(syntax_check_rules) maintainer-check-list-of-tests -- 1.6.5
