Free conceptRules and targets
Rule anatomy
See how a rule connects a target, its prerequisites, and the recipe that can update it.
1app: main.c config.h2 cc -o app main.c- Target
- The name before the colon. Here,
appis the file this rule can create or update. - Prerequisites
- The names after the colon. Make considers
main.candconfig.hbefore deciding whetherappneeds its recipe. - Recipe
- The shell command that tells Make how to update
app. Recipe lines normally begin with a tab. - Aggregate target
- A target that groups other targets as prerequisites. It often needs no recipe because updating its prerequisites is the work it represents.
For an ordinary file target, Make runs the recipe when the target does not exist or is older than a prerequisite. The rule all: can deliberately have neither prerequisites nor a recipe; .PHONY: all makes clear that it names build behavior, and later prerequisites turn it into an aggregate target.