WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH] tools top level makefile cleanup

On Wed, 23 Mar 2005, Hollis Blanchard wrote:

> On Wednesday 23 March 2005 12:01, Adam Heath wrote:
> > install: $(patsubst %,install.%,$(SUBDIRS))
> > $(patsubst %,install.%,$(SUBDIRS)): install.%: CMD := install
> >
> > all: $(patsubst %,all.%,$(SUBDIRS))
> > $(patsubst %,all.%,$(SUBDIRS)): all.%: CMD := all
> >
> > $(foreach cmd,all install,$(patsubst %,$(cmd).%,$(SUBDIRS))):
> >  $(MAKE) -C $* $(CMD)
>
> The following is working for me and I think easier to read than the above:
> ==
> CLEANDIRS := $(addprefix _clean_,$(SUBDIRS))
>
> .PHONY: all clean $(SUBDIRS) $(CLEANDIRS)
>
> all: $(SUBDIRS)
> clean: $(CLEANDIRS)
>
> $(CLEANDIRS):
>  $(MAKE) -C $(patsubst _clean_%,%,$@) clean
>
> $(SUBDIRS):
>  $(MAKE) -C $@
> ==
>
> Well, I guess it's not very dissimilar after all.
>
> But I really don't like that for every command to recurse with (e.g. clean),
> you must add more hackery to the Makefile. Your snippet has the same problem
> (let's add "clean"...), and it seems all the Makefiles have all the issues
> discussed in different places.
>
> Is there really no better way to solve this problem?

==
define subdir.command
$(1)_targets            := $$(addprefix $(1).,$$(SUBDIRS))
$(1): $$($(1)_targets)
$$($(1)_targets): $(1).%: CMD := $(1)
        $(MAKE) -C $* $(CMD)
endef

$(eval subdir.command,install)
$(eval subdir.command,clean)
==

I've not verified if the above works; ie, the quoting of $ in the
multi-line variable.  eval is a gnumake extension, so may not work elsewhere.



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/xen-devel