Makefile tweak for -lm?

Mike Frysinger vapier at gentoo.org
Sat Dec 3 04:17:26 UTC 2005


On Fri, Dec 02, 2005 at 09:39:04PM -0600, Rob Landley wrote:
> On Friday 02 December 2005 10:28, Mike Frysinger wrote:
> > if you move the first line to the top, duplicate the second line for
> > every applet, and move the third line to the 'end' (basically after
> > all of the previous settings), then no, it wont add -lm more than once
> 
> Ok, so you're talking about having specific mentions of CONFIG_FEATURE_BLAH 
> not in the Makefile snippet for the blah/ subdirectory, but in Rules.mak?
> 
> I'd really, really, really rather not have specific applet mentions outside of 
> the directory for that applet, if we can avoid it.

*shrug* however you wanna play it ;)

> > the make foo is expanded to:
> > needlibm-y :=
> > ...
> > needlibm-y := -lm
> > needlibm-y := -lm
> > needlibm-n := -lm
> > ...
> > LIBRARIES += $(needlibm-y)
> > and since the := only ever sets, not increments, it isnt an issue ...
> 
> The old problem I always have with makefiles is "what order does this happen 
> in".  How do I know that LIBRARIES += $(needlibm-y) will be evaluated after 
> needlibm-y gets set in all the places it needs to be?

thats what := means versus =

when you do := make will evaluate the stuff right then ... but if you
use =, the variable wont be evaluated until it's actually needed

a1  = $(b)
a2 := $(b)
b   = c
all:
	@echo a1: $(a1) a2: $(a2)

the output here will be:
a1: c a2:
-mike



More information about the busybox mailing list