[英]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
不起作用,但我如何使它起作用?
當您說“放入正確的文件夾”時,那是哪個文件夾?
它顯然不是本地目錄,因為如果它是您的 makefile 將起作用。
第一個錯誤是您對vpath
使用了錯誤的語法。 看說明書; vpath
采用 makefile 模式(即帶有零或一個%
字符的字符串); 它不支持像*.h
這樣的 shell globbing。 應該這樣寫:
vpath %.pdf ../../../Figures/Arrowshape/ChemicalNoise
然而,即使有了這個修復,你的 makefile 也不會像你希望的那樣工作,因為vpath
不是為了 find targets 。 它旨在查找源文件(即不是由 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 $<
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.