help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: What's the meaning of + symbol used in makefile?


From: Paul Smith
Subject: Re: What's the meaning of + symbol used in makefile?
Date: Wed, 19 Jan 2022 13:25:18 -0500
User-agent: Evolution 3.36.5-0ubuntu1

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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]