On Mon, Aug 8, 2011 at 3:15 PM, Lane Schwartz <[email protected]> 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

_______________________________________________
Help-make mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-make

Reply via email to