help-make
[Top][All Lists]
Advanced

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

Re: Implement Check on Input Values


From: David Boyce
Subject: Re: Implement Check on Input Values
Date: Mon, 8 Aug 2011 15:50:19 -0400

On Mon, Aug 8, 2011 at 3:15 PM, Lane Schwartz <address@hidden> wrote:
> Why is it bad to do mkdir in a recipe? I do things like this all the
> time, and I've never had problems when using -j
>
> foo/bar: | foo
>   ...do something...
>
> foo:
>   mkdir -p $@

Sorry, you're quite right and I expressed myself badly. A
single-purpose recipe to create a directory, relying on an order-only
prerequisite, is safe and in fact elegant. It's combining mkdirs into
recipes which do other things that's bad. E.g.:

$(objdir)/%.o: %.c
        @mkdir $(@D)
        $(CC) ...

Which is really just a variant of one of Paul's rules. Paraphrased -
tell make exactly what you plan to create, and don't create anything
you didn't tell it about.

-David Boyce



reply via email to

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