help-make
[Top][All Lists]
Advanced

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

Re: exception to Paul's Second Rule?


From: Noel Yap
Subject: Re: exception to Paul's Second Rule?
Date: Thu, 16 Oct 2003 18:07:32 -0400

Robert Mecklenburg wrote:
> I basically agree with you, Paul.  I've been using this approach for quite a
> while (after reading your post about it).  However, if you have many source
> files across many directories this can be troublesome:
> 
> # Find the source.
> sources := $(shell find . -name '*.c')
> 
> # Gather the directories to create.
> dirs := $(sort $(dir $(sources)))
> 
> # Create them
> $(shell for d in $(dirs); do [ -d $$d ] || mkdir -p $$d; done)
> # or
> $(foreach d,$(dirs),$(shell [ -d $$d ] || mkdir -p $$d))
> # of
> $(foreach d,$(dirs),$(if $(wildcard $d),,$(shell mkdir -p $$d)))

Exactly.  IMHO, it also unnecessarily spawns off a bunch of processes.  Using 
the hack (or, if widely accepted, idiom :-), a shell for mkdir is spawned only 
if the directory hasn't been created.  Initially, this may spawn more processes 
than the $(shell)
alternative, but it'll spawn none thenceforth.

It just occured to me.  If one has:

%: %/../...
        @: >> $@

.PRECIOUS: %/../...
%/../...:
        @mkdir -p $(dir $*)  &&  : >> $(dir $*)$(@F)

then does:

$ gmake --jobs=2 aoeu/aoeu/aoeu aoeu/ueoa/ueoa

it looks like there's an opportunity for a race condition.  Is this right?

I haven't heard anyone say this violates Paul's Secord Rule.  Is this good news?

Thanks,
Noel
-- 
NOTICE: If received in error, please destroy and notify sender.  Sender does 
not waive confidentiality or privilege, and use is prohibited.




reply via email to

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