[Ovirt-devel] [PATCH] Cleanup of output in ovirt.mk file as well as fixing autoconf problems

Jim Meyering jim at meyering.net
Tue Sep 9 20:13:30 UTC 2008


Perry Myers <pmyers at redhat.com> wrote:
> ---
>  ovirt.mk |   24 +++++++++++++++---------
>  1 files changed, 15 insertions(+), 9 deletions(-)
>
> diff --git a/ovirt.mk b/ovirt.mk
> index 8b97ef4..126502c 100644
> --- a/ovirt.mk
> +++ b/ovirt.mk
> @@ -8,11 +8,16 @@ OVIRT_BRANCH ?= master
>  
>  SUBDIRS ?= release server node node-image appliance docs
>  
> +SUBDIR_SEP = ============================================================
> +
>  export OVIRT_CACHE_DIR ?= $(HOME)/ovirt-cache
>  
>  define for_each_subdir
>  	+for dir in $(SUBDIRS); do \
>  		if test -d $$dir ; then \
> +			echo $(SUBDIR_SEP) $$dir ; \
> +			(cd $$dir && test ! -f Makefile.in && test -f autogen.sh && ./autogen.sh ) || :; \
> +			(cd $$dir && test ! -f Makefile && test -f configure && ./configure ) || :; \
>  			$(MAKE) -C $$dir $@ || exit 1 ; \
>  		fi ; \
>  	done
> @@ -29,24 +34,24 @@ $(SUBDIRS):
>  	cd $@ && git pull -v && git checkout $(OVIRT_BRANCH)
>  
>  clean:
> -	$(for_each_subdir)
> +	@$(for_each_subdir)
>  
>  distclean:
> -	$(for_each_subdir)
> +	@$(for_each_subdir)
>  
>  bumpgit:
> -	$(for_each_subdir)
> +	@$(for_each_subdir)
>  
>  bumprelease:
> -	$(for_each_subdir)
> +	@$(for_each_subdir)
>  
>  bumpversion:
> -	$(for_each_subdir)
> +	@$(for_each_subdir)
>  
>  status diff:
> -	for dir in $(SUBDIRS); do \
> +	@for dir in $(SUBDIRS); do \
>  	  if test -d $$dir ; then \
> -	    echo ===== $$dir =============================================== ;\
> +	    echo $(SUBDIR_SEP) $$dir ; \
>  	    (cd $$dir && git $@) || :; \
>  	  fi ; \
>  	done
> @@ -57,8 +62,9 @@ publish:
>  		if ! test -d $$dir ; then \
>  			$(MAKE) $$dir || exit 1 ; \
>  		fi ; \
> -		( cd $$dir; test ! -f Makefile.in && ./autogen.sh ); \
> -		( cd $$dir; test ! -f Makefile && ./configure ); \
> +		echo $(SUBDIR_SEP) $$dir ; \
> +		(cd $$dir && test ! -f Makefile.in && test -f autogen.sh && ./autogen.sh ) || :; \
> +		(cd $$dir && test ! -f Makefile && test -f configure && ./configure ) || :; \
>  		$(MAKE) -C $$dir $@ || exit 1 ; \
>  	done
>  	rm -f rpms

That works, but you shouldn't have had to make the same change to
5 identical lines, and I want to avoid some duplication and long lines,
so how about these additional changes?

>From 7362ec4f2d6a74566ad2fe735a7be7d47faaa131 Mon Sep 17 00:00:00 2001
From: Perry Myers <pmyers at redhat.com>
Date: Tue, 9 Sep 2008 15:03:34 -0400
Subject: [PATCH release] ovirt.mk: factor+cleanup; make rules work also in autoconfiscated subdir

(clean, distclean, bumpgit, bumprelease, bumpversion): Consolidate.
(subdir_gen_and_make): New "command", factored out of...
(for_each_subdir): ...here, and
(status diff): ...here.
---
 ovirt.mk |   59 ++++++++++++++++++++++++++++-------------------------------
 1 files changed, 28 insertions(+), 31 deletions(-)

diff --git a/ovirt.mk b/ovirt.mk
index 8b97ef4..7f7d143 100644
--- a/ovirt.mk
+++ b/ovirt.mk
@@ -8,14 +8,25 @@ OVIRT_BRANCH ?= master

 SUBDIRS ?= release server node node-image appliance docs

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

+define subdir_gen_and_make
+    echo $(SUBDIR_SEP) $$dir; \
+    (cd $$dir && test ! -f Makefile.in && test -f autogen.sh && ./autogen.sh) \
+      || :; \
+    (cd $$dir && test ! -f Makefile && test -f configure && ./configure ) \
+      || :; \
+    $(MAKE) -C $$dir $@ || exit 1
+endef
+
 define for_each_subdir
-	+for dir in $(SUBDIRS); do \
-		if test -d $$dir ; then \
-			$(MAKE) -C $$dir $@ || exit 1 ; \
-		fi ; \
-	done
+  +for dir in $(SUBDIRS); do	\
+    if test -d $$dir ; then	\
+      $(subdir_gen_and_make);	\
+    fi;				\
+  done
 endef

 all: dev-build
@@ -28,38 +39,24 @@ $(SUBDIRS):
 	  git config remote.origin.fetch +$(OVIRT_BRANCH):$(OVIRT_BRANCH) ; }
 	cd $@ && git pull -v && git checkout $(OVIRT_BRANCH)

-clean:
-	$(for_each_subdir)
-
-distclean:
-	$(for_each_subdir)
-
-bumpgit:
-	$(for_each_subdir)
-
-bumprelease:
-	$(for_each_subdir)
-
-bumpversion:
-	$(for_each_subdir)
+clean distclean bumpgit bumprelease bumpversion:
+	@$(for_each_subdir)

 status diff:
-	for dir in $(SUBDIRS); do \
-	  if test -d $$dir ; then \
-	    echo ===== $$dir =============================================== ;\
-	    (cd $$dir && git $@) || :; \
-	  fi ; \
+	@for dir in $(SUBDIRS); do	\
+	  if test -d $$dir ; then	\
+	    echo $(SUBDIR_SEP) $$dir ;	\
+	    (cd $$dir && git $@) || :;	\
+	  fi ;				\
 	done

 build: publish
 publish:
-	for dir in $(SUBDIRS); do \
-		if ! test -d $$dir ; then \
-			$(MAKE) $$dir || exit 1 ; \
-		fi ; \
-		( cd $$dir; test ! -f Makefile.in && ./autogen.sh ); \
-		( cd $$dir; test ! -f Makefile && ./configure ); \
-		$(MAKE) -C $$dir $@ || exit 1 ; \
+	for dir in $(SUBDIRS); do	\
+	  if ! test -d $$dir ; then	\
+	    $(MAKE) $$dir || exit 1 ;	\
+	  fi ;				\
+	  $(subdir_gen_and_make);	\
 	done
 	rm -f rpms
 	ln -s $(OVIRT_CACHE_DIR)/ovirt rpms
-- 
1.6.0.1.196.g01914




More information about the ovirt-devel mailing list