Makefile make-仅在需要时创建中间文件

Makefile make-仅在需要时创建中间文件,makefile,Makefile,我正在编写一个Makefile来构建一个Latex文档,它依赖于绘图,绘图的数据是由一些python脚本从其他数据生成的 看起来像这样 % pdf plot needed by final document build/tikz-standalone/%.pdf: build/tikz-standalone/%.tex xy_data cd $$(dirname $@) && ../../latexrun $$(basename $<) xy_data: $(PL

我正在编写一个Makefile来构建一个Latex文档,它依赖于绘图,绘图的数据是由一些python脚本从其他数据生成的

看起来像这样

% pdf plot needed by final document
build/tikz-standalone/%.pdf: build/tikz-standalone/%.tex xy_data
    cd $$(dirname $@) && ../../latexrun $$(basename $<)

xy_data: $(PLOT_DATA) tools/plots/crunch.py | build
    % crunch.py will create data for plots needed by build/tikz-standalone/%.tex
    PYTHONPATH=. tools/plots/crunch.py

build:
    mkdir -p build build/other_stuff ...
%pdf最终文档所需的绘图
build/tikz standalone/%.pdf:build/tikz standalone/%.tex xy_数据

cd$$(dirname$@)和&&&/../latexrun$$(basename$如果您不想提供和维护生成的文件列表,您可以将您的(隐式)假
xy\U数据
目标转换为用作标记的空文件。只需在配方末尾触摸它即可:

BUILDDIRS := build build/other_stuff ...

build/tikz-standalone/%.pdf: build/tikz-standalone/%.tex xy_data
    cd $(dir $@) && ../../latexrun $(notdir $<)

xy_data: $(PLOT_DATA) tools/plots/crunch.py | $(BUILDDIRS)
    PYTHONPATH=. tools/plots/crunch.py
    touch $@

$(BUILDDIRS):
    mkdir -p $@
BUILDDIRS:=构建/其他内容。。。
build/tikz standalone/%.pdf:build/tikz standalone/%.tex xy_数据
cd$(dir$@)和&/../latexrun$(notdir$