Subject: Re: [PATCH v2 3/3] Makefile: simplify $(test_bindir_programs) rule by splitting it up

From: Junio C Hamano <[email-masked]>
Date: Wed, 26 Oct 2022 13:28:47 -0700

Ævar Arnfjörð Bjarmason <[email-masked]> writes:

> Are you asking if "define"'s execute in some context outside the purview
> of rules, so that if you $(call) one from within a rule and it errors,
> that we won't clean up the file?

Not at all.

I was wondering why the defined sequance does not end in

	...
	<$> >$@+ && \
	chmod +x $@+ && \
	mv $@+ $@

like many other command sequences in the Makefile.  As I said, I did
remember we had discussed delete-on-error; I just didn't recall if
we do depend on it already.

> I can drop them, FWIW I've found it quite handy to add these to ad-hoc
> debug templates. E.g. you can run:
> 	
> 	$ make -f /dev/null -E '$(eval $(file <Makefile))' -E '$(error $(call bin_wrappers_template,a,b,c,d))'
> 	make: *** 
> 	## bin_wrappers_template
> 	# 1 = a
> 	# 2 = b
> 	# 3 = c
> 	# 4 = d

OK.  That use pattern was what I was missing.
> ...
> So you see what the parameters expand to. Maybe just changing the
> heading to:
>
> 	## bin_wrappers_template: $(1..N) below for manual "$(error $(call ..." deubgging

Yeah, it would be totally useless without such an instruction.