* [PATCH 1/1] build: remove trailing '/.' when doing mkdir -p .deps/.
@ 2013-11-03 14:05 Tomi Ollila
2013-11-03 15:35 ` Jed Brown
2014-01-13 18:39 ` David Bremner
0 siblings, 2 replies; 5+ messages in thread
From: Tomi Ollila @ 2013-11-03 14:05 UTC (permalink / raw)
To: notmuch; +Cc: tomi.ollila
When make variable $@ does not contain directory part, $(@D)
resolves as '.'. In this case .deps/$(@D) is '.deps/.'
In some systems `mkdir [-p] directory/.` fails.
To make this compatible with more system substitute trailing
'/.' (slashdot) with '' (empty string) whenever it occurs there.
---
Makefile.local | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Makefile.local b/Makefile.local
index 72524eb..c85e09c 100644
--- a/Makefile.local
+++ b/Makefile.local
@@ -236,11 +236,11 @@ endif
quiet ?= $($(shell echo $1 | sed -e s'/ .*//'))
%.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
%.o: %.c $(global_deps)
- @mkdir -p .deps/$(@D)
+ @mkdir -p $(patsubst %/.,%,.deps/$(@D))
$(call quiet,CC $(CPPFLAGS) $(CFLAGS)) -c $(FINAL_CFLAGS) $< -o $@ -MD -MP -MF .deps/$*.d
.PHONY : clean
--
1.8.3.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] build: remove trailing '/.' when doing mkdir -p .deps/.
2013-11-03 14:05 [PATCH 1/1] build: remove trailing '/.' when doing mkdir -p .deps/ Tomi Ollila
@ 2013-11-03 15:35 ` Jed Brown
2013-11-03 21:55 ` Tomi Ollila
2014-01-13 18:39 ` David Bremner
1 sibling, 1 reply; 5+ messages in thread
From: Jed Brown @ 2013-11-03 15:35 UTC (permalink / raw)
To: Tomi Ollila, notmuch; +Cc: tomi.ollila
[-- Attachment #1: Type: text/plain, Size: 756 bytes --]
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
[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] build: remove trailing '/.' when doing mkdir -p .deps/.
2013-11-03 15:35 ` Jed Brown
@ 2013-11-03 21:55 ` Tomi Ollila
2014-01-12 0:19 ` David Bremner
0 siblings, 1 reply; 5+ messages in thread
From: Tomi Ollila @ 2013-11-03 21:55 UTC (permalink / raw)
To: Jed Brown, notmuch
On Sun, Nov 03 2013, Jed Brown <jed@59A2.org> wrote:
> 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
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/1] build: remove trailing '/.' when doing mkdir -p .deps/.
2013-11-03 14:05 [PATCH 1/1] build: remove trailing '/.' when doing mkdir -p .deps/ Tomi Ollila
2013-11-03 15:35 ` Jed Brown
@ 2014-01-13 18:39 ` David Bremner
1 sibling, 0 replies; 5+ messages in thread
From: David Bremner @ 2014-01-13 18:39 UTC (permalink / raw)
To: Tomi Ollila, notmuch; +Cc: tomi.ollila
Tomi Ollila <tomi.ollila@iki.fi> writes:
> When make variable $@ does not contain directory part, $(@D)
> resolves as '.'. In this case .deps/$(@D) is '.deps/.'
> In some systems `mkdir [-p] directory/.` fails.
> To make this compatible with more system substitute trailing
> '/.' (slashdot) with '' (empty string) whenever it occurs there.
pushed.
d
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-01-13 18:39 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-03 14:05 [PATCH 1/1] build: remove trailing '/.' when doing mkdir -p .deps/ Tomi Ollila
2013-11-03 15:35 ` Jed Brown
2013-11-03 21:55 ` Tomi Ollila
2014-01-12 0:19 ` David Bremner
2014-01-13 18:39 ` David Bremner
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).