Makefile tweak for -lm?

Bernhard Fischer rep.nop at aon.at
Fri Dec 9 00:42:52 UTC 2005


On Sun, Dec 04, 2005 at 12:07:27PM -0600, Rob Landley wrote:
>On Friday 02 December 2005 22:17, Mike Frysinger wrote:
>> > 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:
>
>Oh.
>
>That makes much more sense.

I will ci the attached patch tomorrow unless somebody objects.

This fixes the undefined references (from sort_big) of __isnan and
__isinf i was seeing and is listed in bug #531.

Didn't look at the warning from uClibs about __fpending yet, but i'm
under the impression that for static linking the msg in link_warning()
is empty and shouldn't (?) be emitted in this case.
-------------- next part --------------
Index: Rules.mak
===================================================================
--- Rules.mak	(revision 12766)
+++ Rules.mak	(working copy)
@@ -146,6 +146,8 @@ OPTIMIZATIONS:=$(OPTIMIZATION) -fomit-fr
 # prone to casual user adjustment.
 #
 
+LIBRARIES:=
+
 ifeq ($(strip $(CONFIG_LFS)),y)
     # For large file summit support
     CFLAGS+=-D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
@@ -153,10 +155,10 @@ endif
 ifeq ($(strip $(CONFIG_DMALLOC)),y)
     # For testing mem leaks with dmalloc
     CFLAGS+=-DDMALLOC
-    LIBRARIES:=-ldmalloc
+    LIBRARIES+=-ldmalloc
 else
     ifeq ($(strip $(CONFIG_EFENCE)),y)
-	LIBRARIES:=-lefence
+	LIBRARIES+=-lefence
     endif
 endif
 ifeq ($(strip $(CONFIG_DEBUG)),y)
@@ -176,6 +178,10 @@ ifeq ($(strip $(CONFIG_SELINUX)),y)
     LIBRARIES += -lselinux
 endif
 
+ifeq ($(strip $(need-libm-y)),y)
+    LIBRARIES += -lm
+endif
+
 ifeq ($(strip $(PREFIX)),)
     PREFIX:=`pwd`/_install
 endif
Index: coreutils/Makefile.in
===================================================================
--- coreutils/Makefile.in	(revision 12766)
+++ coreutils/Makefile.in	(working copy)
@@ -83,6 +83,8 @@ COREUTILS-$(CONFIG_YES)       += yes.o
 
 libraries-y+=$(COREUTILS_DIR)$(COREUTILS_AR)
 
+need-libm-$(CONFIG_FEATURE_SORT_BIG) := y
+
 $(COREUTILS_DIR)$(COREUTILS_AR): $(patsubst %,$(COREUTILS_DIR)%, $(COREUTILS-y))
 	$(AR) $(ARFLAGS) $@ $(patsubst %,$(COREUTILS_DIR)%, $(COREUTILS-y))
 
Index: miscutils/Makefile.in
===================================================================
--- miscutils/Makefile.in	(revision 12766)
+++ miscutils/Makefile.in	(working copy)
@@ -33,12 +33,7 @@ MISCUTILS-$(CONFIG_WATCHDOG)    += watch
 
 libraries-y+=$(MISCUTILS_DIR)$(MISCUTILS_AR)
 
-needlibm-y:=
-needlibm-$(CONFIG_DC) := y
-
-ifeq ($(needlibm-y),y)
-  LIBRARIES += -lm
-endif
+need-libm-$(CONFIG_DC) := y
 
 $(MISCUTILS_DIR)$(MISCUTILS_AR): $(patsubst %,$(MISCUTILS_DIR)%, $(MISCUTILS-y))
 	$(AR) $(ARFLAGS) $@ $(patsubst %,$(MISCUTILS_DIR)%, $(MISCUTILS-y))
Index: Makefile
===================================================================
--- Makefile	(revision 12766)
+++ Makefile	(working copy)
@@ -207,6 +207,7 @@ all: busybox busybox.links doc
 # In this section, we need .config
 -include $(top_builddir)/.config.cmd
 include $(patsubst %,%/Makefile.in, $(SRC_DIRS))
+include $(top_srcdir)/Rules.mak
 -include $(top_builddir)/.depend
 
 endif # ifneq ($(strip $(HAVE_DOT_CONFIG)),y)
Index: editors/Makefile.in
===================================================================
--- editors/Makefile.in	(revision 12766)
+++ editors/Makefile.in	(working copy)
@@ -20,12 +20,7 @@ EDITOR_OBJ:= $(patsubst %.c,$(EDITOR_DIR
 
 libraries-y+=$(EDITOR_DIR)$(EDITOR_AR)
 
-needlibm-y:=
-needlibm-$(CONFIG_FEATURE_AWK_MATH) := y
-
-ifeq ($(needlibm-y),y)
-  LIBRARIES += -lm
-endif
+need-libm-$(CONFIG_FEATURE_AWK_MATH) := y
 
 $(EDITOR_DIR)$(EDITOR_AR): $(patsubst %,$(EDITOR_DIR)%, $(EDITOR-y))
 	$(AR) $(ARFLAGS) $@ $(patsubst %,$(EDITOR_DIR)%, $(EDITOR-y))


More information about the busybox mailing list