Tomi Ollila <tomi.ollila at iki.fi> writes:

>  %.o: %.cc $(global_deps)
> -     @mkdir -p .deps/$(@D)
> +     @mkdir -p $(patsubst %/.,%,.deps/$(@D))
>       $(call quiet,CXX $(CPPFLAGS) $(CXXFLAGS)) -c $(FINAL_CXXFLAGS) $< -o $@ 
> -MD -MP -MF .deps/$*.d

An alternative approach is to use directory marker files [1] to clean up
the recipes that need output directories and to satisfy Paul's second
rule of makefiles [2].

.SECONDEXPANSION:

%.o: %.cc $(global_deps) | .deps/$$(@D)/.DIR
        $(call quiet,CXX $(CPPFLAGS) $(CXXFLAGS)) -c $(FINAL_CXXFLAGS) $< -o $@ 
-MD -MP -MF .deps/$*.d

%/.DIR:
        @mkdir -p $(patsubst %/.,%,$(@D))
        @touch $@

.PRECIOUS: %.DIR



[1] http://www.cmcrossroads.com/article/making-directories-gnu-make
[2] http://make.paulandlesley.org/rules.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 
<http://notmuchmail.org/pipermail/notmuch/attachments/20131103/6cd2f078/attachment.pgp>

Reply via email to