If @
starts a recipe line, the command itself isn't echoed.
$(dir $@)
expands to the directory part of the target $@
. In this case that is $(BUILD)/rest/path/to/
if the target is $(BUILD)/rest/path/to/target.o
.
From GNU make manual, 5.2 Recipe Echoing:
5.2 Recipe Echoing
Normally 'make' prints each line of the recipe before it is executed.
We call this "echoing" because it gives the appearance that you are
typing the lines yourself.
When a line starts with '@', the echoing of that line is
suppressed. The '@' is discarded before the line is passed to the
shell. Typically you would use this for a command whose only effect
is to print something, such as an 'echo' command to indicate progress
through the makefile:
@echo About to make distribution files
and from the same, 8.3 Functions for File Names
8.3 Functions for File Names
Several of the built-in expansion functions relate specifically to
taking apart file names or lists of file names.
Each of the following functions performs a specific transformation
on a file name. The argument of the function is regarded as a series
of file names, separated by whitespace. (Leading and trailing
whitespace is ignored.) Each file name in the series is transformed
in the same way and the results are concatenated with single spaces
between them.
'$(dir NAMES...)'
Extracts the directory-part of each file name in NAMES. The
directory-part of the file name is everything up through (and
including) the last slash in it. If the file name contains no
slash, the directory part is the string './'. For example,
$(dir src/foo.c hacks)
produces the result 'src/ ./'.