Makefile 始终执行,即使它不应该执行
Makefile always executes even though it shouldn't
makefile noob 在这里,我的 makefile 总是执行每个配方,即使文件是最新的。这是我的代码:
vpath *.pdf ../../../Figures/Arrowshape/ChemicalNoise
.PHONY : all clean
all : Fig_VP-CN-Revols_MeanfromDist_Dac0.0_F0.0-4.0_0to2.pdf\
Fig_VP-CN-Revols_MeanfromDist_Dac0.0_F0.0-4.0_2to4.pdf\
Fig_VP-CN-Revols_MeanfromDistImshow_Dac0.0_F0.0-4.0.pdf
Fig_%.pdf : %.py
$(warning Building $@ )
python $<
Fig_%_2to4.pdf : %.py
$(warning Building $@ )
python $<
Fig_%_0to2.pdf : %.py
$(warning Building $@ )
python $<
clean:
rm all
我检查过 pdf 文件是否放在正确的文件夹中并且名称匹配。我的语法有什么问题?
另外,我知道我的 clean
不起作用,但我该如何让它起作用?
当你说 "put in the correct folder" 时,那是哪个文件夹?
它显然不是本地目录,因为如果它是你的 makefile 就可以了。
首先错误的是 vpath
的语法错误。看说明书; vpath
采用 makefile 模式(即具有零个或一个 %
字符的字符串);它不支持像 *.h
这样的 shell globbing。应该这样写:
vpath %.pdf ../../../Figures/Arrowshape/ChemicalNoise
但是,即使进行了该修复,您的 makefile 也不会如您所愿地工作,因为 vpath
并非旨在查找 目标 。它旨在查找 源文件(即不是由 make 创建的文件)。
如果你想深入了解这一点,你可以阅读http://make.mad-scientist.net/papers/how-not-to-use-vpath/
要使您的 makefile 正常工作,您必须添加路径,如下所示:
OUTDIR = ../../../Figures/Arrowshape/ChemicalNoise
all : $(OUTDIR)/Fig_VP-CN-Revols_MeanfromDist_Dac0.0_F0.0-4.0_0to2.pdf\
$(OUTDIR)/Fig_VP-CN-Revols_MeanfromDist_Dac0.0_F0.0-4.0_2to4.pdf\
$(OUTDIR)/Fig_VP-CN-Revols_MeanfromDistImshow_Dac0.0_F0.0-4.0.pdf
$(OUTDIR)/Fig_%.pdf : %.py
$(warning Building $@ )
python $<
$(OUTDIR)/Fig_%_2to4.pdf : %.py
$(warning Building $@ )
python $<
$(OUTDIR)/Fig_%_0to2.pdf : %.py
$(warning Building $@ )
python $<
makefile noob 在这里,我的 makefile 总是执行每个配方,即使文件是最新的。这是我的代码:
vpath *.pdf ../../../Figures/Arrowshape/ChemicalNoise
.PHONY : all clean
all : Fig_VP-CN-Revols_MeanfromDist_Dac0.0_F0.0-4.0_0to2.pdf\
Fig_VP-CN-Revols_MeanfromDist_Dac0.0_F0.0-4.0_2to4.pdf\
Fig_VP-CN-Revols_MeanfromDistImshow_Dac0.0_F0.0-4.0.pdf
Fig_%.pdf : %.py
$(warning Building $@ )
python $<
Fig_%_2to4.pdf : %.py
$(warning Building $@ )
python $<
Fig_%_0to2.pdf : %.py
$(warning Building $@ )
python $<
clean:
rm all
我检查过 pdf 文件是否放在正确的文件夹中并且名称匹配。我的语法有什么问题?
另外,我知道我的 clean
不起作用,但我该如何让它起作用?
当你说 "put in the correct folder" 时,那是哪个文件夹?
它显然不是本地目录,因为如果它是你的 makefile 就可以了。
首先错误的是 vpath
的语法错误。看说明书; vpath
采用 makefile 模式(即具有零个或一个 %
字符的字符串);它不支持像 *.h
这样的 shell globbing。应该这样写:
vpath %.pdf ../../../Figures/Arrowshape/ChemicalNoise
但是,即使进行了该修复,您的 makefile 也不会如您所愿地工作,因为 vpath
并非旨在查找 目标 。它旨在查找 源文件(即不是由 make 创建的文件)。
如果你想深入了解这一点,你可以阅读http://make.mad-scientist.net/papers/how-not-to-use-vpath/
要使您的 makefile 正常工作,您必须添加路径,如下所示:
OUTDIR = ../../../Figures/Arrowshape/ChemicalNoise
all : $(OUTDIR)/Fig_VP-CN-Revols_MeanfromDist_Dac0.0_F0.0-4.0_0to2.pdf\
$(OUTDIR)/Fig_VP-CN-Revols_MeanfromDist_Dac0.0_F0.0-4.0_2to4.pdf\
$(OUTDIR)/Fig_VP-CN-Revols_MeanfromDistImshow_Dac0.0_F0.0-4.0.pdf
$(OUTDIR)/Fig_%.pdf : %.py
$(warning Building $@ )
python $<
$(OUTDIR)/Fig_%_2to4.pdf : %.py
$(warning Building $@ )
python $<
$(OUTDIR)/Fig_%_0to2.pdf : %.py
$(warning Building $@ )
python $<