I have already seen How to manually call another target from a make target?, but my question is a bit different; consider this example (note, stackoverflow.com changes the tabs to spaces in display; but tabs are preserved in source, if you try to edit):
TEXENGINE=pdflatex
pdflatex:
echo the engine is $(TEXENGINE)
lualatex:
TEXENGINE=lualatex
echo Here I want to call the pdflatex rule, to check $(TEXENGINE) there!
Here, if I run the default target (pdflatex
), I get the expected output:
$ make pdflatex
echo the engine is pdflatex
the engine is pdflatex
But, with the target lualatex
, I want to:
- change the
make
variableTEXENGINE
tolualatex
, and then - call the same code as in
pdflatex
(which uses it).
How could I do that?
Clearly, in my lualatex
rule I don't even manage to change the TEXENGINE
variable, because I get this when I try it:
$ make lualatex
TEXENGINE=lualatex
echo Here I want to call the pdflatex rule, to check pdflatex there!
Here I want to call the pdflatex rule, to check pdflatex there!
... so I would really like to know if something like this is possible in Makefiles.
pdflatex
, if you're using it to check arbitrary stuff. I'd suggest something likecheckEngine
, and make it.PHONY
. – Oliver Charlesworthpdflatex
in this use case is the default, and so I get the same result for justmake
ormake pdflatex
(and the use case is then to change engines by specifying them as targets tomake
, as inmake lualatex
). Cheers! – sdaaumake TEXENGINE=whatever
, and structure a generic set of targets/rules that use the user-specifiedTEXENGINE
variable? – Oliver Charlesworth:)
Otherwise, I'd forgotten all about variables on themake
command line - just remembered while writing my answer below. Cheers! – sdaau