Skip to content

Posts#

Tracking my food for a month

This August, out of curiosity, I decided to monitor my food intake for a month. So I bought myself a kitchen scale, a friend lent me a few measuring spoons, and I started keeping records. The idea was to make no notable changes in what I eat so that I could identify useful patterns. Among other things, I was hoping that this would help me reduce unnecessary expenses. As with most of my projects, I relied on ledger cli for the bookkeeping part.

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.