[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Ovirt-devel] [PATCH] ovirt.mk: factor



Here's a patch to factor out some duplication.

>From eb98bd5c75a4cbb7469b6e377df8dfcb0bc2034e Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering redhat com>
Date: Fri, 5 Sep 2008 08:48:54 +0200
Subject: [PATCH] ovirt.mk: factor

(for_each_subdir): Define.
(clean, distclean, bumpgit, bumprelease, bumpversion): Use it.
(status): Use cd-in-a-subshell, not pushd+popd.
---
 ovirt.mk |   54 ++++++++++++++++++------------------------------------
 1 files changed, 18 insertions(+), 36 deletions(-)

diff --git a/ovirt.mk b/ovirt.mk
index eba36d6..e61f83b 100644
--- a/ovirt.mk
+++ b/ovirt.mk
@@ -10,59 +10,43 @@ SUBDIRS ?= release server node node-image appliance docs

 export OVIRT_CACHE_DIR ?= $(HOME)/ovirt-cache

+define for_each_subdir
+	for dir in $(SUBDIRS); do \
+		if test -d $$dir ; then \
+			$(MAKE) -C $$dir $@ || exit 1 ; \
+		fi ; \
+	done
+endef
+
 all: dev-build

 update: $(SUBDIRS)

 $(SUBDIRS):
-	if ! test -d $@; then \
-		git clone $(OVIRT_GIT_SERVER)/ovirt-$@ $@ ; \
-	fi ; \
-	cd $@ ; \
-	if ! test "$(OVIRT_BRANCH)" = "master" ; then \
-		git config remote.origin.fetch +$(OVIRT_BRANCH):$(OVIRT_BRANCH) ; \
-	fi ; \
-	git pull -v && git checkout $(OVIRT_BRANCH) ; \
+	test -d $@ && : || git clone $(OVIRT_GIT_SERVER)/ovirt-$@ $@
+	cd $@ && test "$(OVIRT_BRANCH)" = "master" && \
+	  git config remote.origin.fetch +$(OVIRT_BRANCH):$(OVIRT_BRANCH)
+	git pull -v && git checkout $(OVIRT_BRANCH)

 clean:
-	for dir in $(SUBDIRS); do \
-		if test -d $$dir ; then \
-			$(MAKE) -C $$dir $@ || exit 1 ; \
-		fi ; \
-	done
+	$(for_each_subdir)

 distclean:
-	for dir in $(SUBDIRS); do \
-		if test -d $$dir ; then \
-			$(MAKE) -C $$dir $@ || exit 1 ; \
-		fi ; \
-	done
+	$(for_each_subdir)

 bumpgit:
-	for dir in $(SUBDIRS); do \
-		if test -d $$dir ; then \
-			$(MAKE) -C $$dir $@ || exit 1 ; \
-		fi ; \
-	done
+	$(for_each_subdir)

 bumprelease:
-	for dir in $(SUBDIRS); do \
-		if test -d $$dir ; then \
-			$(MAKE) -C $$dir $@ || exit 1 ; \
-		fi ; \
-	done
+	$(for_each_subdir)

 bumpversion:
-	for dir in $(SUBDIRS); do \
-		if test -d $$dir ; then \
-			$(MAKE) -C $$dir $@ || exit 1 ; \
-		fi ; \
-	done
+	$(for_each_subdir)

 status:
 	for dir in $(SUBDIRS); do \
 		if test -d $$dir ; then \
-			pushd $$dir ; git $@ ; popd > /dev/null ; \
+			(cd $$dir && git $@) ; \
 		fi ; \
 	done

@@ -85,5 +69,3 @@ ver-build: update bumpversion build

 .PHONY: all build clean distclean publish $(SUBDIRS) update status \
 	bumpgit bumprelease bumpversion dev-build rel-build ver-build
-
-
--
1.6.0.1.216.g1b23a


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]