Re: [PATCH 1/1] build: remove trailing '/.' when doing mkdir -p .deps/.

Subject: Re: [PATCH 1/1] build: remove trailing '/.' when doing mkdir -p .deps/.

Date: Sun, 03 Nov 2013 08:35:03 -0700

To: Tomi Ollila, notmuch@notmuchmail.org

Cc: tomi.ollila@iki.fi

From: Jed Brown


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
part-000.sig (application/pgp-signature)

Thread: