build: sanitize linking of tools and test programs
authorMans Rullgard <mans@mansr.com>
Wed, 10 Oct 2012 02:24:50 +0000 (03:24 +0100)
committerMans Rullgard <mans@mansr.com>
Wed, 10 Oct 2012 10:24:09 +0000 (11:24 +0100)
This makes sure proper linker arguments are used for the tools and
test programs when shared libraries are enabled.  The tools are
linked using the usual -l flag while for test programs the full
name of the static library is used.

Signed-off-by: Mans Rullgard <mans@mansr.com>
library.mak

index 7b78e59577fd85724cde06bc62f4fad5984fe852..98e0c6f912fd7d369de882e46e743afa4b133893 100644 (file)
@@ -34,8 +34,11 @@ install-libs-$(CONFIG_STATIC): install-lib$(NAME)-static
 install-libs-$(CONFIG_SHARED): install-lib$(NAME)-shared
 
 define RULES
+$(EXAMPLES) $(TOOLS): LIB = $(FULLNAME:%=$(LD_LIB))
+$(TESTPROGS):         LIB = $(SUBDIR)$(LIBNAME)
+
 $(EXAMPLES) $(TESTPROGS) $(TOOLS): %$(EXESUF): %.o
-       $$(LD) $(LDFLAGS) $$(LD_O) $$^ $(FFEXTRALIBS) $$(ELIBS)
+       $$(LD) $(LDFLAGS) $$(LD_O) $$(filter %.o,$$^) $$(LIB) $(FFEXTRALIBS) $$(ELIBS)
 
 $(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR)
        $(Q)cd ./$(SUBDIR) && $(LN_S) $(SLIBNAME_WITH_MAJOR) $(SLIBNAME)