Makefile tweak for -lm?

Bernhard Fischer rep.nop at aon.at
Fri Dec 2 20:10:02 UTC 2005


Rob,

On Fri, Dec 02, 2005 at 10:15:31AM -0600, Rob Landley wrote:
>On Friday 02 December 2005 07:01, Mike Frysinger wrote:
>> On Thu, Dec 01, 2005 at 03:32:13PM -0600, Rob Landley wrote:
>> > I came up with the following makefile patch via cut and paste.  Would
>> > someone who knows makefiles tell me what I _should_ have done?
>>
>> this should work:

Makefile.in:
>> needlibm-y :=
>> needlibm-$(CONFIG_FEATURE_SORT_BIG) := -lm

Rules.mak:
>> LIBRARIES += $(needlibm-y)
>
>Okay...
>
>(Much blinking and scratching of head ensues...)
>
>Ok, I think I understand what it means, but won't it add -lm more than once if 
>more than one applet needs it?

No, you should only end with one -lm as every previous assignment is
overwritten, not appended. (:= != +=)

If you are concerned about the order of the libs, just reorder them in
Rules.mak.
Something like this after the LIBRARIES are all set would force correct
ordering, but shouldn't be needed if you put a comment on top of adding
libm that it ought to be one of the last libs.
LIBRARIES := $(filter-out -lm,$(LIBRARIES)) -lm

hth,
Bernhard



More information about the busybox mailing list