Re: [PATCH v4 9/9] Makefiles: add and use wildcard "mkdir -p" template
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 2, 2022, 20:38 UTC
- Message-ID
- <xmqqtucgjdjm.fsf@gitster.g>
- In-Reply-To
- <patch-v4-9.9-4cc4aeabb20-20220302T124320Z-avarab@gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
> Add a template to do the "mkdir -p" of $(@D) (the parent dir of $@) > for us, and use it for the "make lint-docs" targets I added in > 8650c6298c1 (doc lint: make "lint-docs" non-.PHONY, 2021-10-15).
Sounds good.
Show 5 quoted lines
> But as it turns out we can use this neat trick of only doing a "mkdir > -p" if the $(wildcard) macro tells us the path doesn't exist. A re-run > of a performance test similar to that noted downthread of [1] in [2] > shows that this is faster, in addition to being less verbose and more > reliable (this uses my "git-hyperfine" thin wrapper for "hyperfine"[3]):
Cute.
Show 17 quoted lines
> diff --git a/shared.mak b/shared.mak > index bb910273538..83c22d5e7b3 100644 > --- a/shared.mak > +++ b/shared.mak > @@ -59,6 +59,8 @@ ifndef V > QUIET = @ > QUIET_GEN = @echo $(wspfx_SQ) GEN $@; > > + QUIET_MKDIR_P_PARENT = @echo $(wspfx_SQ) MKDIR -p $(@D); > + > ## Used in "Makefile" > QUIET_CC = @echo $(wspfx_SQ) CC $@; > QUIET_AR = @echo $(wspfx_SQ) AR $@; > @@ -90,3 +92,18 @@ ifndef V > export V > endif > endif
It is unfortunate that this came after [8/9] and needs manual resolution to reorder to leave 8/9 for later series.