Makefile Parser
Extract targets, variables and includes from a Makefile.
Overview
Paste a Makefile and the parser extracts its targets, prerequisites, variables, and include directives into a structured outline. Useful when you've inherited a 500-line Makefile and want to know which targets exist before running make help.
It's for developers debugging legacy build systems, documenting a project's task list, or porting Make-based builds to a different tool. Reach for it when triaging an unfamiliar repo, generating a help/cheat-sheet for a teammate, or hunting for the target that's silently shadowing the one you want to run.
How it works
The parser reads Make syntax (GNU Make 4.x as the reference). Rules are recognised by the target: prerequisite pattern; variables by VAR = value, VAR := value, and VAR ?= value assignments; include directives by lines starting with include or -include.
Recipe bodies (the tab-indented commands under a rule) are captured as raw text - the parser doesn't execute them or try to resolve shell expansion. Phony targets are identified by their listing under .PHONY.
Examples
- Simple target:
build: go build ./...Target: build Prereqs: (none) Recipe: go build ./... - Target with prerequisites:
test: build vendor go test ./... - Variable assignment:
GOFLAGS := -trimpath -ldflags=-s - Includes:
-include .env.mk include common.mk
FAQ
Does it expand variables?
No - variable expansion happens at build time in Make's runtime. The parser shows literal assignment expressions so you can see the structure.
What about pattern rules?
Pattern rules (%.o: %.c) and static pattern rules are listed with their target/prerequisite pattern intact.
Will it run my Makefile?
No - the parser is read-only. Use make -n target (dry run) or make --print-data-base for runtime introspection.
Does it handle BSD Make?
It targets GNU Make syntax. Most BSD Make features overlap, but BSD-specific constructs (.MAIN, conditional ifdefs) may not parse cleanly.