Tomi Ollila <tomi.ollila@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