Boneyard Tools

Makefile Generator

Generate a clean Makefile without fighting the tab-versus-spaces trap. Add variables and targets, or start from a language preset, and every recipe line comes out indented with a real tab so make runs it without the classic missing separator error.

How to generate a Makefile

  1. Pick a language preset like Node, Python, Go, Rust or C, or start from scratch.
  2. Add variables and targets, set each target's dependencies and command lines, and mark phony targets.
  3. Copy the output or download it as a file named Makefile in your project root.

Examples

A C project with build and clean

CC=gcc, CFLAGS=-Wall -O2; targets build and clean (phony)
CC = gcc
CFLAGS = -Wall -O2

.PHONY: build clean

build:
	$(CC) $(CFLAGS) -o app main.c

clean:
	rm -f app

A build target that depends on clean

target build, deps [clean], command 'npm run build'
.PHONY: build

build: clean
	npm run build

Frequently asked questions

Why do Makefile recipe lines have to start with a tab?

It is a hard rule baked into make: every command line in a recipe must be indented with a single real tab character, not spaces. make uses that leading tab to tell a recipe command apart from other syntax. If you use spaces you get the infamous 'missing separator' error and nothing runs. This generator always emits real tabs, so the output is safe to paste into a Makefile.

What does the .PHONY line do?

A phony target is one that does not produce a file with its own name, like build, test or clean. Listing them under .PHONY tells make to always run the recipe instead of skipping it when a file or folder of the same name happens to exist. Mark a target phony with the checkbox and it is added to the .PHONY line automatically.

What is the difference between a variable and a target?

Variables are NAME = value assignments at the top of the file, like CC = gcc, that you reuse in recipes as $(CC). Targets are the rules: a name, optional prerequisites after the colon, and one or more tab-indented command lines that make runs to build that target.

How do target dependencies work?

Anything you list after the colon, like build: clean install, is a prerequisite. make builds those prerequisite targets first, in the order given, before running the target's own recipe. That lets you chain steps so a single make build can clean, install and then compile.

Where do I save the generated file?

Save it as a file named exactly Makefile (capital M, no extension) in the root of your project, then run make or make <target> from that directory. GNU make also recognises the name makefile if you prefer lowercase.

Is anything I type sent to a server?

No. The Makefile is generated entirely in your browser from the variables and targets you enter, so nothing is uploaded anywhere.

Related tools