help-make
[Top][All Lists]
Advanced

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

Re: How to use shell builtin command in Makefile?


From: Paul Smith
Subject: Re: How to use shell builtin command in Makefile?
Date: Wed, 22 Oct 2008 11:56:46 -0400

On Wed, 2008-10-22 at 09:39 -0500, Peng Yu wrote:
> BTW, what is the general rule of thumb to use := rather =? When I
> should use = rather :=?

These are described fairly well in the GNU make manual.

:= is evaluated once, when the makefile is read.  = is re-evaluated
every time the variable is used.

:= is always more efficient (assuming you use the variable more than
once) and this is especially important for things like $(shell ...)
which are very expensive (comparatively); using = means that shell is
re-invoked EVERY TIME the variable is expanded in your makefile.

The downside of := is that any changes made after the line is read in
don't have any effect.  So, in your case, if you use := it will only
contain the directories that existed when the makefile was read in, and
not any directories that may be created during the operation of the
makefile.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.mad-scientist.us
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

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