Skip to content

GNU Make#

GNU Make: Adding a built-in function

I saw this question on the help-make mailing list and I decided to see how easy it would be to register a new built-in function in GNU Make. It turned out to be quite easy (in comparison, it took me more time to write this post). I then found out that there is a section "Anatomy of a Built-In Function" in "The GNU Make Book" by John Graham-Cumming which helped me to see alternatives.

GNU Make: double-expand

A few days ago I stumbled upon this article late in the evening and it kept me awake the whole night! It describes a cool trick that allows to "double-expand" a macro without using eval. The following is a summary of the main idea, a reflection of why it works and a small extension.

GNU Make: double-colon rules

Consider an integration testing setup where the command to test appears on the first line of a text file, followed by the expected output. I used to run all tests using:

TESTS := test-html test-latex test-semicolon ...

.PHONY: $(TESTS)
$(TESTS): COMMAND = $(shell head -n 1 $(TEST_DIR/$@))
$(TESTS): EXPECTED = ... $(TEST_DIR/$@)
$(TESTS): RESULT = ...
$(TESTS):
    compare $(EXPECTED) with $(RESULT)

but the other day I had the following problem: one of the tests required additional post-processing.