更改一个make变量,并从同一Makefile中的配方调用另一个规则? [英] Change a make variable, and call another rule, from a recipe in same Makefile?
问题描述
我已经看过如何手动是从make目标中调用另一个目标吗?,但是我的问题有点不同;考虑以下示例(请注意,stackoverflow.com将选项卡更改为显示中的空格;但是,如果您尝试编辑,则选项卡将保留在源代码中):
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!
在这里,如果我运行默认目标(pdflatex
),则会得到预期的输出:
Here, if I run the default target (pdflatex
), I get the expected output:
$ make pdflatex
echo the engine is pdflatex
the engine is pdflatex
但是,对于目标lualatex
,我想要:
But, with the target lualatex
, I want to:
- 将
make
变量TEXENGINE
更改为lualatex
,然后 - 调用与
pdflatex
中相同的代码(使用它).
- change the
make
variableTEXENGINE
tolualatex
, and then - call the same code as in
pdflatex
(which uses it).
我该怎么做?
很明显,在我的lualatex
规则中,我什至没有设法更改TEXENGINE
变量,因为尝试时会得到它:
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!
...所以我真的很想知道在Makefiles中是否可以进行这样的事情.
... so I would really like to know if something like this is possible in Makefiles.