Back to lesson

Targets and goals

Distinguish every target Make knows about from the goal selected to start a particular run.

Target
A node Make knows how to consider, usually because a rule defines it or an implicit rule can produce it. Targets may also appear as prerequisites of other targets.
Goal
A target Make strives ultimately to update in the current run. A command can name a goal explicitly, or Make can select the default goal.
Explicit and default goals
1make app # app is the explicit goal2make # all is the default goal

Default goal

When the command line does not name a goal, Make selects a default. Unless .DEFAULT_GOAL sets one explicitly, Make uses the first eligible target: a dot-prefixed target without a slash and a pattern-rule target do not count. That is why .PHONY can appear before all without becoming the default goal.

Every goal is a target. A target reached only as a prerequisite is not a goal for that run, but Make still processes it because the selected goal depends on it. For example, make app selects app as the explicit goal.

See it in context

Follow the lessons that apply this concept, then inspect the repository at the exact commit behind each explanation.

GNU Make manual: Arguments to Specify the Goals