Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I simplify this Makefile to make it less repetitive?

Tags:

makefile

Make is one of those technologies where I go back and forth between whether or not I understand it.

This is certainly one instance where I know I must be doing something wrong, since Make was developed to make these tasks less repetitive.

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

How can I edit this Makefile to only lay out the test sequence once but be able to test against multiple versions?

like image 325
Sean Allred Avatar asked Nov 30 '25 07:11

Sean Allred


1 Answers

Try this:

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

The :: is a special kind of rule, that puts the target as phony (and has other properties, too).

like image 195
Edouard Thiel Avatar answered Dec 02 '25 03:12

Edouard Thiel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!