我怎样才能简化这个 Makefile 以减少重复?

Sea*_*red 2 makefile

Make 是我在是否理解它之间来回切换的技术之一。

这当然是我知道我一定做错了什么的一个例子,因为 Make 的开发是为了减少这些任务的重复性。

all: 24.1 24.2 24.3

24.1:
    evm install emacs-24.1-bin || true
    emacs --version
    emacs --batch -L . -l ert -l test/tests.el -f ert-run-tests-batch-and-exit
24.2:
    evm install emacs-24.2-bin || true
    emacs --version
    emacs --batch -L . -l ert -l test/tests.el -f ert-run-tests-batch-and-exit
24.3:
    evm install emacs-24.3-bin || true
    emacs --version
    emacs --batch -L . -l ert -l test/tests.el -f ert-run-tests-batch-and-exit
Run Code Online (Sandbox Code Playgroud)

如何编辑此 Makefile 以仅布置一次测试序列但能够针对多个版本进行测试?

Edo*_*iel 5

尝试这个:

VERSIONS = 24.1 24.2 24.3

all :: $(VERSIONS)

$(VERSIONS) ::
    evm install emacs-$@-bin || true
    emacs --version
    emacs --batch -L . -l ert -l test/tests.el -f ert-run-tests-batch-and-exit
Run Code Online (Sandbox Code Playgroud)

::是一种特殊的规则,它将目标设为虚假(并且也具有其他属性)。