help-make
[Top][All Lists]
Advanced

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

Re: How to parallel clean directories?


From: Garrett Cooper
Subject: Re: How to parallel clean directories?
Date: Sat, 25 Oct 2008 17:21:14 -0700

On Sat, Oct 25, 2008 at 10:14 AM, Peng Yu <address@hidden> wrote:
> - Hide quoted text -
> On Sat, Oct 25, 2008 at 11:23 AM, Sam Ravnborg <address@hidden> wrote:
>> On Sat, Oct 25, 2008 at 11:06:45AM -0500, Peng Yu wrote:
>>> On Sat, Oct 25, 2008 at 10:43 AM, Sam Ravnborg <address@hidden> wrote:
>>> > On Sat, Oct 25, 2008 at 09:33:48AM -0500, Peng Yu wrote:
>>> >> Hi,
>>> >>
>>> >> Suppose there are many subdirectories in a directory. The sub dirs all
>>> >> have working makefiles.
>>> >>
>>> >> 'make -j3' in the parent dir would parallel make all directories. But
>>> >> 'make clean -j3' could not. The problem is that I don't know how to
>>> >> clean each directory as well as deleting the file '.d'.
>>> >>
>>> >> Can somebody let me know how to do it?
>>> >
>>> > Try to study the following sample:
>>> > SUBDIRS := b c d e f
>>> >
>>> > .PHONY: $(SUBDIRS)
>>> >
>>> > all: $(SUBDIRS)
>>> >
>>> > $(SUBDIRS):
>>> >        @sleep 1; echo rm -f $@/*
>>>
>>> I want to make parallel clean because I want speedup clean. Would the
>>> command 'sleep' slow down the process?
>>
>> Please try to understand the makefile before posting questions.
>>
>> The sleep command is there to show that the commands are indeed
>> executed in parallel.
>> Try to time it with make -j and with make -j1
>>
>> May I suggest you to spend a few hours reading the documentation
>> that follows make.
>
> I see what you mean. Essentially, I need to have the following rules.
>
> #################
> clean: $(SUBDIRS)
>
> $(SUBDIRS):
>       sleep 1; make clean -C $@
> ###########
>
> But what if I already have the following rules. The general questions
> is how to run make parallel for any goal that may specified in the
> command line.
>
> ##############
> all: $(SUBDIRS)
>
> $(SUBDIRS):
>       make -C $@
> ##############
>
> Thanks,
> Peng

Not the best solution, but it works.
-Garrett

clean:: $(addsuffix -clean,$(SUBDIRS))

%-clean::
      $(MAKE) -C $* clean




reply via email to

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