help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: pedantic nitpickery: difference between "goal" and "target"?


From: David
Subject: Re: pedantic nitpickery: difference between "goal" and "target"?
Date: Sat, 2 Nov 2019 23:02:23 +1100

On Sat, 2 Nov 2019 at 22:18, Robert P. J. Day <address@hidden> wrote:

[...]

> "By default, make starts with the first target (not targets whose
> names start with ‘.’). This is called the default goal. (Goals are the
> targets that make strives ultimately to update ..."
>
> the question was, "what is the difference between a 'goal' and a
> 'target'?"

Not surprised to see this question. I observe that 'goal' and 'target'
are often used interchangeably, and it doesn't really matter.

Personally, I do see a slight distinction between these two terms.
As explained in your quote above: goals are the *ultimate* desired
targets.

For example, in the command 'make foo', foo is the goal.

'make foo' searches for a rule with a target that matches 'foo', and
if it finds one it builds the rule prerequisites and then the rule target
using the associated recipes.

So when 'make' documentation discusses the "default goal",
it's no different to talking about a default target.

Make rules are defined in terms of target: prerequisite.
These targets aren't necessarily goals, if they're not
invoked. Consider 'make clean' as an example. There's only
one goal: "clean". The makefile might contain many other
targets, but they aren't goals for that invocation of 'make'.

This is my take on it:
- rules have targets.
- 'make' has goals and builds them by looking for rules with
  matching targets.

So the difference is subtle and in practice it doesn't really matter.

I notice that 'man make' doesn't contain the word "goal",
it uses [TARGET] in the command line syntax.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]