makefile 规则和单独的目录

makefile rule and separate directories

我有一个 运行 pylint 的 (gnu) makefile 用于一堆脚本。它有一个很好的特性,即 pylint 仅在更新的脚本上 运行s。我如何修改它以便 lint_report 文件转到并行目录或子目录?

scripts := $(wildcard *.py)
lint_reports = $(scripts:.py=.lint_report)

all: $(lint_reports)

$(lint_reports): %.lint_report: %.py
    -pylint3 $< > $@

您可以进行如下操作:

report_dir := otherdir
scripts := $(wildcard *.py)
lint_reports := $(addprefix $(report_dir)/,$(scripts:.py=.lint_report))    

all: $(lint_reports)

$(lint_reports): $(report_dir)/%.lint_report: %.py
    -pylint3 $< > $@