On Wed, 2022-01-19 at 10:21 +0800, Hongyi Zhao wrote: > I am very confused about the usage of the + symbol used above. > Any hints will be highly appreciated.
The discussion of this is hidden in various pages in the manual, most relevantly here: https://www.gnu.org/software/make/manual/html_node/Instead-of-Execution.html If you run "make -n", make will not actually execute the recipes it will only print out the commands that WOULD be executed (if you didn't use the "-n" option). However, this is not great because sometimes you want the recipe to be executed even if "-n" is given: for example, if the recipe invokes a sub-make then you want the sub-make to run (with the "-n" option of course) so you can see what that sub-make would execute. The "+" prefix added to a recipe line tells make to run that recipe line, even if "-n" is given on the command line. I personally don't see a good reason for adding "+" to the clean commands in the example from the StackOverflow answer; I wouldn't want my clean rule to run if I ran "make -n"! But, maybe if I knew more about the larger context of that part of the makefile it would make sense.