【发布时间】:2018-11-18 08:45:02
【问题描述】:
我想要
我正在尝试编译一些包含 python 代码 sn-ps 和这些 sn-ps 输出的乳胶。我需要始终使用 sn-ps 及其输出中所做的最后更改来更新文档,因此我的想法是维护一个可以监视此更改并生成更新输出的 makefile。
所以如果我修改文件a/11.py,我希望make 执行它以生成新的输出a/11.out。
我有
这是我的makefile
DOC=myPdf
STY=st
PY_DIR=a/
TEX=pdflatex -shell-escape -interaction=batchmode -file-line-error
$(DOC).pdf: $(PY_DIR)11.out $(PY_DIR)12.out $(DOC).tex $(STY).sty
$(TEX) $(DOC).tex
$(PY_DIR)11.out:
$(cd PY_DIR && python3 11.py > 11.out)
$(PY_DIR)12.out:
$(cd PY_DIR && python3 12.py > 12.out)
.PHONY: clean
clean:
rm *.aux *.log > /dev/null 2>&1
我想知道
即使文件a/11.out 不存在,而我指示make a/11.out make 说:make: 'a/11.out' is up to date.(我还在学习make,所以我可能有更多错误)。
我看到了
-
Make in subfolder,但是因为我没有使用
$(MAKE),所以无法使用。 - Similar question,但我觉得不一样。
感谢您的宝贵时间:)
更新
这是我的新版本,基于 Renaud 的回答(感谢您的帮助),一些 python 脚本旨在输出文本(xxxt.py),而另一些则用于绘制图像(xxxi.py),所以有他们没有重定向:
DOC :=myPdf
STY :=st
PY_DIR :=a/
TEX :=pdflatex -shell-escape -interaction=batchmode -file-line-error
PYS := $(wildcard $(PY_DIR)*.py)
OUTS := $(patsubst %.py,%.out,$(PYS))
.PHONY: all clean
all: $(DOC).pdf
%.pdf: %.tex $(STY).sty $(OUTS)
$(TEX) $<
$(PY_DIR)%.out: $(PY_DIR)%t.py
cd $(PY_DIR) && python3 $*t.py > $*.out
$(PY_DIR)%.png: $(PY_DIR)%i.py
cd $(PY_DIR) && python3 $*i.py
clean:
rm *.aux *.log > /dev/null 2>&1
目录如下所示:
./st.sty
./myPdf.tex
./myPdf.pdf
./a/11t.py
./a/11.out
./a/12i.py
./a/12.png
./a/21t.py
./a/...
但是,现在在修改 myPdf.tex 之后,make 会说 make: Nothing to be done for 'all'.
我做错了什么?
【问题讨论】: