A makefile is:
all : foo ;
# A 'DEFAULT' special-target, providing a recipe to execute for target 'foo'.
.DEFAULT :
@echo '$$@ is: "$@"'
@echo '$$< is: "$<"'
Executing, I get:
$@ is: "foo"
$< is: "foo"
How come here, that $<
and $@
expand to the same target?
Remember, that we had here:
- A file
foo
, that Make is executing the recipe for. (Therefore, the expansion for$@
is OK) - The target
foo
has no prerequisites, at all. (Hence,$<
should expand to an empty string).
To make it more absurd, let's try the following makefile:
.DEFAULT :
@echo '$$< is "$<"'
@echo '$$@ is "$@"'
Running, we get:
$ make .DEFAULT
$< is ".DEFAULT"
$@ is ".DEFAULT"
Really, can we justify that $<
and $@
expand to the same string (.DEFAULT
), when the target had no prerequisites at all, to begin with?