When things go wrong, the breadcrumbs that systems leave behind become super important. They are the first clues we have to identify the nature of the problem.

Modern build tools - like task, psake, and mage - do this automatically, but it’s not built in to the … ahem … classic tools.

I recently wanted to add breadcrumbs into the Makefile for karpenter-provider-azure and set about doing it manually, adding an echo to each individual target:

test: ## Run tests
    @echo "----- test -----"
    ginkgo -vv \
        -cover -coverprofile=coverage.out -output-dir=. -coverpkg=./pkg/... \
        --focus="${FOCUS}" \
        --randomize-all \
        ./pkg/...

But then tallaxes suggested that I might be able to wire it in with some make magic.

Here’s what we ended up with, after a little consultation with Copilot.

ANNOUNCED_TARGETS := $(filter-out FORCE .PHONY,$(shell awk -F: \
    '/^[a-zA-Z0-9_.\/-]+([[:space:]]+[a-zA-Z0-9_.\/-]+)*[[:space:]]*:/ \
    { print $$1 }' $(MAKEFILE_LIST)))

.PHONY: FORCE

$(ANNOUNCED_TARGETS): %: | .announce-%

.announce-%: FORCE
    @printf '\n----- %s -----\n' '$*'

FORCE:

If you want to use this, it needs to be placed at the very end of your primary Makefile.

How does it work?

The $(MAKEFILE_LIST) variable expands to a list of all the Makefiles parsed so far (hence it needs to at the end). This list of files is read by awk, all the targets extracted by regex, and then FORCE is removed from the list.

Each target then has a new dependency declared, based on a template pattern, generating the header.

For example, the target test gains a dependency on .announce-test, which runs `@printf ‘\n—– %s —–\n’ ‘test’ to generate the header.

This probably qualifies as a stupid make trick, but it works very well.

Next Post
Greening the desert  07 Nov 2026
Prior Post
Superpowers for your AI  29 Mar 2026
Related Posts
Greening the desert  07 Nov 2026
Superpowers for your AI  29 Mar 2026
Autotitling Windows Terminal Tabs  17 Mar 2026
Don't assume shared understanding  25 Jan 2026
Better Table Tests in Go  21 Oct 2025
Error assertions  26 Apr 2025
Browsers and WSL  31 Mar 2024
Factory methods and functions  05 Mar 2023
Using Constructors  27 Feb 2023
An Inconvenient API  18 Feb 2023
Archives
October 2026
2026