I did not see anybody do this, so I am sharing it.
There is semi-nice way to get a per-rule software environment in #makefile .
Here is an example with #guix :
(i didnt manage to format the code on mastodon ..., code is in alternative text)
BLUE - Build Language User Extensible. A generic build-system crafted entirely in Guile.