Makefile generator

Pick the stack and the targets you want and copy a Makefile with real tab-indented recipes. make, make test and make clean then work the same way in every project, whatever tools sit underneath.

The binary, the Python module or just a name. Letters, digits, . _ - only.

Save as Makefile (no extension) in the project root. Recipe lines start with a tab; keep it when you edit or paste the file.

Runs in your browser: nothing you enter is sent anywhere.

How to use it

  1. Choose the project type and enter the program name.
  2. Tick the targets you need. All except lint are on at first.
  3. Copy the result into a file named Makefile in the project root.
  4. Run make, make test, make clean or make help.

How it works

The file has three parts:

  • Variables: tools with ?= so they can be overridden (CC ?= cc, GO ?= go, NPM ?= npm, PYTHON ?= python3) and the program name with :=.
  • .PHONY: every chosen target, so files with the same names cannot block them.
  • Targets: each a rule line and one or more recipe lines indented with a tab. For C, build depends on $(TARGET), which is linked from the object files; a pattern rule %.o: %.c compiles each source in src/.

The help target prints the target names found in the Makefile itself with grep, so it stays correct when you add targets.

Example

The defaults (Go, name app) give:

GO ?= go
BINARY := app

.PHONY: build test run install clean help

build:
	$(GO) build -o bin/$(BINARY) .

test:
	$(GO) test ./...

run:
	$(GO) run .

install:
	$(GO) mod download

clean:
	rm -rf bin

help:
	@grep -E '^[a-zA-Z_-]+:' $(MAKEFILE_LIST) | cut -d: -f1

Tips

  • Prefix a recipe line with @ to hide the command and show only its output.
  • Use $$ for a dollar sign the shell should see: a single $ belongs to make.
  • Each recipe line runs in its own shell, so cd dir on one line does not affect the next; write cd dir && command.

Frequently asked questions

Why must recipe lines start with a tab?

make uses the tab character to tell commands from rules. Spaces give the error 'missing separator'. The generated file has real tabs; some editors convert them to spaces when you paste, so check the setting.

What does .PHONY do?

It tells make that a target is a name for an action, not a file. Without it, a file or folder called test or build in the project would make make think the target is up to date and skip it.

Which target runs when I type just make?

The first target in the file. The generator puts build first, so make builds the project. The C link and compile rules come after build so they do not become the default.

What does ?= mean?

Set the variable only if it is not set yet. That lets you override it from the command line or the environment, for example make CC=clang or GO=go1.22 make test.

What does install do?

For C it copies the program to $(DESTDIR)$(PREFIX)/bin, /usr/local/bin by default, as Unix programs usually do. For Go, Node.js and Python it installs the dependencies: go mod download, npm ci, pip install -r requirements.txt.

More in Developer

All tools in this category: Developer ·Updated November 4, 2026

Privacy choices

Google Analytics shows us which tools are used and whether they work. It may set cookies. Your choice is kept in this browser.