I'm going to expand on @kabanus's answer a touch here (and this was too long for a comment...)
First of all the @
symbol simply tells make to not echo the command to stdout. So the recipe false
and @false
will do the same thing, except only the first will echo the command being run.
Next, when make builds a target, it will run each recipe line by line. If a recipe line returns non-zero (false), it will stop building the target (it will not execute any recipes beyond that one). As well, it will consider the target to have failed building, and anything dependent on it will also fail, and thus make in general will fail, returning a non-zero status.
So if you did make bar
with the makefile:
foo:
@echo this will be printed '(foo)'
@false
@echo this will not be printed '(foo)'
bar: foo
@echo this will not be printed '(bar)'
The second echo in foo
will not appear, as make will fail in the recipe above it and abort building foo
. bar
will also not be built because its dependency was not built, so you will not see the echo from bar
.
Notice that if you do have a recipe line that you know may fail, but you want to ignore, you can get around this behavior by adding a - in front of it as so:
foo:
@echo this will be printed '(foo)'
-@false
@echo this will also be printed '(foo)'
Which will do both echos. It will run false
, which does nothing, but then ignore it's return value due to the -
sign. See this SO question for details
Lastly, the return value for the make command will also effect &&
and ||
operators as well as if
statements. Often in scripts you will see something like:
make foo && cp foo /tftpboot/foo && echo success
If make returns false, it will not try the cp
or the echo
. It is always good practice to have make return non-zero on failure, as people expect this behavior.