Makefile generator — tab-indented targets with a help command

Write each task as "target: command ## description" and the tool builds a Makefile with real tab characters before every recipe line, a .PHONY declaration, a default goal and an optional make help listing.

Live demo · real result from this tool

Makefile

APP = invoice-parser .DEFAULT_GOAL := help.PHONY: help install test build clean docker help: ## Show this help	@grep -E '^[a-zA-Z0-9_.-]+:.*?## ' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "  %-16s %s\n", $$1, $$2}' install: ## Install dependencies	npm ci test: ## Run the tests	npm test build: ## Build for production	npm run build clean: ## Remove build output	rm -rf dist coverage docker:
	docker build -t $(APP) .

Recipes are indented with a real tab character, which Make requires. Copy or download the file rather than retyping it.

Processed on your device — nothing is uploaded.

How to use the Makefile generator

  1. In the main box, write one task per line as target: command. Add ## description at the end to document it.
  2. To run several commands for one target, repeat the target on new lines; the commands are joined in order.
  3. Add variables as NAME = value (also :=, ?= or +=) and use them as $(NAME).
  4. Keep Add a self-documenting help target ticked for a make help command.
  5. Optionally enter a Default target, the one plain make runs. Then download the file as Makefile.

What it does and when to use it

A Makefile gives a project short, memorable commands: make test, make build, make docker. It works the same for Node, Python or Go projects, so new team members do not need to learn each tool’s commands. The catch is the syntax, especially the rule that recipe lines need a real tab, which this tool handles for you.

Make sits beside other project setup files. A Procfile lists the processes a platform should run, an .env example file documents the settings, and a Dockerfile is often what a docker target builds.

How it works

Lines that look like variable assignments are copied to the top of the file. Other lines are split at the first colon into a target and a command, and a ## comment becomes the description. Lines starting with # are ignored.

The file then gets .DEFAULT_GOAL := (your choice, else help, else the first target) and one .PHONY: line listing every target, as described in the GNU make manual. The help recipe uses grep and awk to print every documented target. Recipes are indented with a tab character.

Worked examples

The sample project. Six lines produce, among others:

APP = invoice-parser

.DEFAULT_GOAL := help
.PHONY: help install test build clean docker

install: ## Install dependencies
	npm ci

The docker target has no description, so make help does not list it.

Two commands for one target. lint: eslint . and lint: prettier --check . with help off become a single target with two tab-indented recipe lines, and .DEFAULT_GOAL := lint.

A Python project with a default. PY ?= python3, a run target and a test target, with default target run. The file keeps the variable, sets .DEFAULT_GOAL := run, and recipes read $(PY) app.py and $(PY) -m pytest.

Limits and tips

  • Every target is marked .PHONY. If a target really builds a file, remove it from that line so make can skip work that is up to date.
  • Without any target: command line, the tool replies “Add at least one “target: command” line.”
  • In recipes, write $$ when the shell, not make, should see a $.

Frequently asked questions

Why does make say "missing separator"?
Recipe lines must start with a tab character, not spaces. The generated file uses real tabs, but some editors and copy-paste paths turn them into spaces. Download the file, or set your editor to keep tabs in Makefiles.
What does .PHONY do?
It tells make that a target is a task name, not a file. Without it, a file or folder called test or build would make make think the target is already up to date and skip it.
How does make help know what to print?
The help recipe searches the Makefile for target lines that carry a ## description and prints each name with its text. Targets without a description still work but do not appear in the list.
Can a target depend on another target?
Not through this form. Everything after the colon is treated as a command, so build: deps would run a program called deps. Add prerequisites by editing the generated line, for example build: install.
Does this work on Windows?
The file needs GNU make, which Windows does not include. Use it under WSL or Git Bash with make installed. The help target also relies on grep and awk.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close