Explain Makefile code

Paste a Makefile and Vibe explains what each rule builds, why make reruns some commands and skips others, and what $@, $^ and $< stand for.

Makefile

Up to 1,500 characters (about 60 lines). Your code is sent to Unvibe and Anthropic to write the explanation. Don't paste keys or passwords. Common key formats are refused.

Vibe24 lines selected

Press Explain it for the sample, or paste your own code first.

What this Makefile sample shows

targets and prerequisites
Each rule reads target: prerequisites, with its commands on the lines under it. make runs a rule's commands only when the target is missing or older than one of its prerequisites, so a second make in a row printed make: 'wordcount' is up to date. and compiled nothing.
variables
:= sets a variable once, when make reads the line. $(wildcard src/*.c) lists the C files that exist, and $(SRC:src/%.c=build/%.o) turns each one into its object file's name, so src/main.c becomes build/main.o. A new .c file in src/ joins the build with no edit to the Makefile.
pattern rules
build/%.o: src/%.c src/count.h is one rule for every object file, where % is the same name on both sides. Because the header is listed too, touching src/count.h recompiled both files and relinked the tool. The | build part is an order-only prerequisite: the folder has to exist first, but its newer time stamp never causes a rebuild.
automatic variables
$@ is the rule's target, $^ all its prerequisites and $< the first one. So the link step ran cc -Wall -Wextra -O2 -o wordcount build/count.o build/main.o, and each compile got only its own .c file.
phony targets
test and clean name jobs, not files, and .PHONY says so. It matters once a file with that name turns up: with the .PHONY line removed, a file called test newer than the tool made make test print make: 'test' is up to date. and skip the test.

Good to know

  • Run with GNU Make 4.4.1 on a three-file C project, the first make ran mkdir -p build, two compiles and the link, and make test passed (3 lines, 9 words, 44 characters).
  • Editing only src/main.c recompiled main.o and relinked, and left count.o alone. On a big project that is the point of make: only what changed gets built again.
  • When the output differs, diff prints both lines and exits with 1, so make stops with make: *** [Makefile:19: test] Error 1, and a CI job running make test fails.

Watch out: Each command line has to start with a tab, not spaces. With the tabs turned into four spaces, which some editors do on save, make stopped at the first command with Makefile:10: *** missing separator. Stop. and built nothing.

Explain Makefile code beside your editor

Unvibe is a free app for Mac and Windows. In the app there is no pasting: select code in any app and press Control+U (Ctrl+Alt+U on Windows).

Install on Mac

curl -fsSL https://unvibe.site/install.sh | bash

Paste into Terminal. Unvibe isn't notarized by Apple yet, so this is the smooth path.

Opening the .dmg the first time
  1. Open the .dmg and drag Unvibe to Applications.
  2. Open it once; macOS says it can't verify it. Click Done.
    macOS dialog: Unvibe Not Opened, with Done and Move to Trash
    Real screen, macOS 15
  3. System Settings › Privacy & Security › Open Anyway. Confirm, then enter your Mac password. The button shows for about an hour after you try to open Unvibe.
    macOS Privacy & Security, Security section: Unvibe was blocked to protect your Mac, with the Open Anyway button
    Real screen, macOS 15

The Terminal line checks the download against the published SHA-256 and Unvibe's self-signed signature before it installs anything. More help with the first open