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 20:48:40 -0400

"Paul D. Smith" wrote:
> 
> %% Noel Yap <address@hidden> writes:
> 
>   >> $(shell for d in $(dirs); do [ -d $$d ] || mkdir -p $$d; done)
> 
>   ny> Exactly.  IMHO, it also unnecessarily spawns off a bunch of
>   ny> processes.  Using the hack (or, if widely accepted, idiom :-), a
>   ny> shell for mkdir is spawned only if the directory hasn't been
>   ny> created.  Initially, this may spawn more processes than the
>   ny> $(shell) alternative, but it'll spawn none thenceforth.
> 
> The alternative above spawns exactly one shell every time you run make,
> regardless of how many directories you need.  To me that's not a big
> deal, but I guess YMMV :).

YMMV, indeed.  I think I wasn't clear in my last post.  Since the OBJDIR info 
will be split among several makefiles, several $(shell)'s will need to be done, 
one for each makefile.

> The only possible problem you might have is if you run two mkdirs at the
> same time and one of them _fails_ and exits with a non-0 exit code, then
> your rule above would fail and the build would fail.

I didn't think of that.  I'll have to test it out.

>   ny> I haven't heard anyone say this violates Paul's Secord Rule.
> 
> Hm.  Well, I think it follows the spirit of it.  The idea behind that
> rule is to keep people from trying to do silly things like:
> 
>     foo.o: foo.c
>             $(CC) $(CFLAGS) -o objdir/foo.o -c foo.c
> 
> or whatever.  Your rule does the same thing _in effect_.

That's how I was hoping the rule would be interpreted :-)

Thanks,
Noel




reply via email to

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