help-make
[Top][All Lists]
Advanced

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

Re: recursive make [Was: Help-make Digest, Vol 77, Issue 5]


From: Michael R. Head
Subject: Re: recursive make [Was: Help-make Digest, Vol 77, Issue 5]
Date: Fri, 10 Apr 2009 19:10:47 -0400

On Fri, 2009-04-10 at 07:36 +0200, Sam Ravnborg wrote:
> I just tried it myself.
> It works for me with the following Makefile:
> 
> =====
> SUBDIRS = foo bar baz
> subdirs: $(SUBDIRS)
> 
> .PHONY: $(SUBDIRS)
> $(SUBDIRS):
>         $(MAKE) -C $@
> 
> =====
> Try to use that pattern and it should work for you too.

So this is a common pattern, but we all know that it leads to a lot of
extra invocations of make and extra output when, most of the time,
nothing needs to be done.

I'm wondering if it's sensible to do something along these lines, which
I haven't tried and may require a .SECONDEXPANSION:

$(SUBDIRS): %: $(find % -type f)
        $(MAKE) -C $@

Is this crazy? It would probably be bad on NFS due to an large number of
stats, but on a local filesystem it seems like it would be a win.


Also, for doing a recursive clean, I've found the following pattern
helpful. Is this the best way to approach it?

SUBDIRS = foo bar baz
CLEAN_SUBDIRS = $(SUBDIRS:%=clean.%)

all: $(SUBDIRS)

$(SUBDIRS):
        make -c $@

clean:
        # clean up this directory

veryclean: clean $(CLEAN_SUBDIRS)

$(CLEAN_SUBDIRS): clean.%:
        make -C $* clean

.PHONY: $(SUBDIRS) $(CLEAN_SUBDIRS)

>       Sam

-- 
Michael R. Head <address@hidden>
suppressingfire.org





reply via email to

[Prev in Thread] Current Thread [Next in Thread]