[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 6/6] Refactoring in makefiles, to avoid code duplication.
From: |
Stefano Lattarini |
Subject: |
[PATCH 6/6] Refactoring in makefiles, to avoid code duplication. |
Date: |
Sat, 26 Dec 2009 02:05:30 +0100 |
User-agent: |
KMail/1.12.1 (Linux/2.6.30-2-686; KDE/4.3.2; i686; ; ) |
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 <address@hidden>
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 <address@hidden>
+ 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,address@hidden@],$(APIVERSION),g' \
-e 's,address@hidden@],$(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
- [PATCH 0/6] Testsuite: check the list of test scripts, Stefano Lattarini, 2009/12/25
- [PATCH 1/6] Maint-check: check consistency of list of test scripts., Stefano Lattarini, 2009/12/25
- [PATCH 2/6] Add forgotten test scripts to $(TESTS)., Stefano Lattarini, 2009/12/25
- [PATCH 3/6] Fix test acoutbs2.test., Stefano Lattarini, 2009/12/25
- [PATCH 4/6] Slighty improve tests acoutbs.test and acoutbs2.test., Stefano Lattarini, 2009/12/25
- [PATCH 5/6] maint-check: refactoring to avoid code duplication, Stefano Lattarini, 2009/12/25
- [PATCH 6/6] Refactoring in makefiles, to avoid code duplication.,
Stefano Lattarini <=