Skip to content

Adding help output and remote includes to a Go Makefile with mmake

mmake (“Modern Make”) by TJ Holowaychuk is a small program that wraps make. It adds two things Make lacks, a help command built from comments in your Makefile and includes that point at URLs, and passes everything else straight through to make. You keep writing an ordinary Makefile; there is no separate YAML or JSON task format.

From source (needs Go):

Terminal window
go install github.com/tj/mmake/cmd/mmake@latest

Or with Homebrew:

Terminal window
brew tap tj/mmake https://github.com/tj/mmake.git
brew install tj/mmake/mmake

The README suggests aliasing it so you keep typing make:

Terminal window
alias make=mmake

The examples below call mmake explicitly.

Start with a module and a main.go:

Terminal window
mkdir my-go-project
cd my-go-project
go mod init example.com/my-go-project
main.go
package main
import "fmt"
func main() {
fmt.Println("Hello, mmake!")
}

Now a Makefile. The comment directly above each target becomes its help text; the first sentence is the short description. Recipe lines must be indented with a tab.

# Build the binary.
build:
go build -o bin/my-go-project .
.PHONY: build
# Run the program.
#
# Builds first if needed.
run: build
./bin/my-go-project
.PHONY: run
# Run the tests.
#- Lines starting with "#-" are left out of the help output.
test:
go test ./...
.PHONY: test

List every documented target:

Terminal window
mmake help
build Build the binary.
run Run the program.
test Run the tests.

Filter with a glob pattern, or show the full comments with -v:

Terminal window
mmake help r*
mmake help -v run

Any other target goes to make unchanged, so mmake build, mmake run and mmake test behave exactly like make build, make run and make test. The test target prints [no test files] until you add a _test.go file.

The other feature is include lines that point at a URL or a GitHub path:

include github.com/apex/make/golang
include https://github.com/apex/make/test/make.mk

mmake downloads these into /usr/local/include, the directory GNU Make searches for includes by default, so the Makefile still works with plain make once the files are there. Includes are resolved recursively, and if a repository has an index.mk you can include the repository path on its own. Downloads are cached; run mmake update to fetch fresh copies.

Two things to watch:

  • A remote include is code that runs on your machine. The README’s advice is to fork any Makefile repository you include, so you control what changes.
  • Writing to /usr/local/include often needs elevated permissions, and teammates who use plain make without having run mmake once won’t have the included files.

© 2026 David Li · Home · Blog · RSS ·Classic site · Built with Astro, Starlight and three.js · Logos:Font Awesome Free (CC BY 4.0)