Jim Meyering wrote:> Here's a patch to factor out some duplication.
Ah, ACK
I knew you would find a more efficient way to do that... :)
Perry
>>From eb98bd5c75a4cbb7469b6e377df8dfcb0bc2034e Mon Sep 17 00:00:00 2001
> From: Jim Meyering <meyering at 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
>
> _______________________________________________
> Ovirt-devel mailing list
> Ovirt-devel at redhat.com
> https://www.redhat.com/mailman/listinfo/ovirt-devel
--
|=- Red Hat, Engineering, Emerging Technologies, Boston -=|
|=- Email: pmyers at redhat.com -=|
|=- Office: +1 412 474 3552 Mobile: +1 703 362 9622 -=|
|=- GnuPG: E65E4F3D 88F9 F1C9 C2F3 1303 01FE 817C C5D2 8B91 E65E 4F3D -=|