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)
> $(MAKE) -C $(patsubst _clean_%,%,$@) clean
> $(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?
$(1)_targets := $$(addprefix $(1).,$$(SUBDIRS))
$$($(1)_targets): $(1).%: CMD := $(1)
$(MAKE) -C $* $(CMD)
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.
Xen-devel mailing list