Use a target-specific variable
There is one more special feature of target-specific variables: when you define a target-specific variable that variable value is also in effect for all prerequisites of this target, and all their prerequisites, etc. (unless those prerequisites override that variable with their own target-specific variable value).
TEXENGINE=pdflatex
pdflatex:
echo the engine is $(TEXENGINE)
lualatex: TEXENGINE=lualatex
lualatex: pdflatex
echo Here I want to call the pdflatex rule, to check $(TEXENGINE) there!
The output is:
$ make pdflatex
echo the engine is pdflatex
the engine is pdflatex
$ make lualatex
echo the engine is lualatex
the engine is lualatex
echo Here I want to call the pdflatex rule, to check lualatex there!
Here I want to call the pdflatex rule, to check lualatex there!