Subject: Re: [PATCH v4 9/9] Makefiles: add and use wildcard "mkdir -p" template

From: Junio C Hamano <[email-masked]>
Date: Wed, 02 Mar 2022 12:38:05 -0800

Ævar Arnfjörð Bjarmason  <[email-masked]> 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.

> 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.

> 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.