DevTools Logo

Makefile Generator

Makefile Generator

Generate correct Makefiles with tab recipes, .PHONY hygiene and flavor variants.

Runs in your browser
Try an example

Variables & targets

3 targets · 2 phony
Variables (?= overridable defaults)
CC
CFLAGS
TARGET
Targets

Makefile

19 lines · 227 chars
The C build target produces a file and is deliberately not phony.
# Generated Makefile — GNU make

CC ?= gcc
CFLAGS ?= -Wall -O2
TARGET ?= app

.DEFAULT_GOAL := $(TARGET)

.PHONY: run clean

$(TARGET):
	$(CC) $(CFLAGS) -o $(TARGET) main.c

run: $(TARGET)
	./$(TARGET)

clean:
	$(RM) $(TARGET)

Dry-run order: $(TARGET)

$(TARGET) — Builds the binary; a file-producing target is intentionally not phony.

run — Builds first via the dependency, then runs the binary.

clean — Uses $(RM), GNU make's portable remove command.

Details

Make fails with *** missing separator when a recipe line starts with spaces, and a missing .PHONY declaration makes a target silently do nothing when a file of the same name exists. This generator emits every recipe with a literal tab, computes the .PHONY set from target metadata, and intentionally excludes file-producing targets such as the C binary. Four flavor templates seed variables and targets, the editor normalizes pasted space indentation, and validation catches dangling prerequisites, cycles and invalid target names. A dry-run order shows the execution sequence before you download.

C project

CC ?= gcc
$(TARGET):
	$(CC) $(CFLAGS) -o $(TARGET) main.c
clean:
	$(RM) $(TARGET)

The binary is a real file, so it is not phony; clean and run are.

Python venv

venv:
	test -d $(VENV) || $(PYTHON) -m venv $(VENV)

The venv target is idempotent and other targets depend on it.

Node

PM ?= pnpm
install:
	$(PM) install
build: install

A package-manager variable makes the file portable across npm, pnpm, yarn and bun.

About this tool

Makefile Generator runs entirely in your browser on DevTools — no signup, no upload.

What this tool does not do

  • Makefile Generator is a free in-browser utility, not a hosted API, and keeps no server-side history.

How to use this tool

  1. Set your options

    Choose the options Makefile Generator should use.

  2. Generate

    Press the generate action; each run produces fresh output.

  3. Copy or export the result

    Copy or download the generated result. Makefile Generator keeps no server-side history, so save what you need before leaving the page.

Frequently asked questions

Why do Makefile recipes need tabs?

GNU make identifies recipe lines by a leading tab character. A line with leading spaces is parsed as a make directive or target, producing the infamous *** missing separator error. The generator writes literal tabs and converts pasted space indentation automatically, with a visible status line to confirm it.

What does .PHONY do?

A phony target is not a real file. Declaring one tells make to always run its recipe and to ignore a file with the same name. Without .PHONY, a target named clean stops working the moment a file called clean exists. File-producing targets such as a compiled binary are deliberately excluded from the declaration.

How do I use variables like $(CC)?

Variables declared with ?= provide defaults that can still be overridden on the command line or in the environment, for example make CC=clang. The emitted C template uses $(CC), $(CFLAGS) and $(RM) so the same Makefile works across toolchains. Hashes in values are escaped because # begins a make comment.

How do I make one target depend on another?

List prerequisites after the colon: run: build means make builds first and then runs the recipe. The generator restricts dependencies to defined targets, detects cycles, and shows the left-to-right depth-first execution order in the dry-run line.

Why is my recipe executed once per file?

That happens with pattern or multi-target rules when make expands each target separately. A single named target with a tab-indented recipe runs once; use automatic variables such as $@ for the current target when a recipe is shared. Keep rule names explicit unless you intentionally need pattern rules.

Does the tool run make or upload my files?

No. It only writes text locally in the browser. Recipes are inert until you save the Makefile and run make yourself, and no project data is transmitted.