In a Makefile, I read:
-rm -rf (instead of rm -rf). What does the first "-" mean at the beginning of the line in a Makefile ?
It means that make
itself will ignore any error code from rm
.
In a makefile
, if any command fails then the make
process itself discontinues processing. By prefixing your commands with -
, you notify make
that it should continue processing rules no matter the outcome of the command.
For example, the makefile rule:
clean: rm *.o rm *.a
will not remove the *.a
files if rm *.o
returns an error (if, for example, there aren't any *.o
files to delete). Using:
clean: -rm *.o -rm *.a
will fix that particular problem.
Aside: Although it's probably not needed in your specific case (since the -f
flag appears to prevent rm
from returning an error when the file does not exist), it's still good practice to mark the line explicitly in the makefile
- rm
may return other errors under certain circumstances and it makes your intent clear.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With