Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 5391F429E48 for ; Sun, 3 Nov 2013 13:55:14 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none] autolearn=disabled Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AjVJArPEdd8k for ; Sun, 3 Nov 2013 13:55:08 -0800 (PST) Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34]) by olra.theworths.org (Postfix) with ESMTP id 945AA429E38 for ; Sun, 3 Nov 2013 13:55:08 -0800 (PST) Received: from guru.guru-group.fi (localhost [IPv6:::1]) by guru.guru-group.fi (Postfix) with ESMTP id 0A9F4100051; Sun, 3 Nov 2013 23:55:01 +0200 (EET) From: Tomi Ollila To: Jed Brown , notmuch@notmuchmail.org Subject: Re: [PATCH 1/1] build: remove trailing '/.' when doing mkdir -p .deps/. In-Reply-To: <87fvrd8pnc.fsf@mcs.anl.gov> References: <1383487535-21597-1-git-send-email-tomi.ollila@iki.fi> <87fvrd8pnc.fsf@mcs.anl.gov> User-Agent: Notmuch/0.16+119~g219c55f (http://notmuchmail.org) Emacs/24.3.1 (x86_64-unknown-linux-gnu) X-Face: HhBM'cA~ MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 Nov 2013 21:55:14 -0000 On Sun, Nov 03 2013, Jed Brown wrote: > Tomi Ollila 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 Hmm, nice suggestion... the diff to be reviewed is just soo much bigger ;/ Now that I learned new things [11] yet another alternative is: diff --git a/Makefile.local b/Makefile.local index 72524eb..cc1a0cb 100644 --- a/Makefile.local +++ b/Makefile.local @@ -235,12 +235,15 @@ endif # Otherwise, print the full command line. quiet ?= $($(shell echo $1 | sed -e s'/ .*//')) -%.o: %.cc $(global_deps) - @mkdir -p .deps/$(@D) +depdirs = $(subdirs:%=.deps/%) + +$(depdirs): + @mkdir -p $(depdirs) + +%.o: %.cc $(global_deps) | $(depdirs) $(call quiet,CXX $(CPPFLAGS) $(CXXFLAGS)) -c $(FINAL_CXXFLAGS) $< -o $@ -MD -MP -MF .deps/$*.d -%.o: %.c $(global_deps) - @mkdir -p .deps/$(@D) +%.o: %.c $(global_deps) | $(depdirs) $(call quiet,CC $(CPPFLAGS) $(CFLAGS)) -c $(FINAL_CFLAGS) $< -o $@ -MD -MP -MF .deps/$*.d .PHONY : clean still, for the time being I'd still use the patch I originally proposed due to the triviality I change... [11] http://www.gnu.org/software/make/manual/html_node/Prerequisite-Types.html Tomi > [1] http://www.cmcrossroads.com/article/making-directories-gnu-make > [2] http://make.paulandlesley.org/rules.html