From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <smonroy@ecsmtp.ir.intel.com>
Received: from mga11.intel.com (mga11.intel.com [192.55.52.93])
 by dpdk.org (Postfix) with ESMTP id 56BE95A6A
 for <dev@dpdk.org>; Thu, 12 Mar 2015 17:28:13 +0100 (CET)
Received: from orsmga001.jf.intel.com ([10.7.209.18])
 by fmsmga102.fm.intel.com with ESMTP; 12 Mar 2015 09:28:12 -0700
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.11,389,1422950400"; d="scan'208";a="664377135"
Received: from irvmail001.ir.intel.com ([163.33.26.43])
 by orsmga001.jf.intel.com with ESMTP; 12 Mar 2015 09:28:10 -0700
Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com
 [10.237.217.46])
 by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id
 t2CGS7DS027449; Thu, 12 Mar 2015 16:28:08 GMT
Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1])
 by sivswdev02.ir.intel.com with ESMTP id t2CGS7W2016989;
 Thu, 12 Mar 2015 16:28:07 GMT
Received: (from smonroy@localhost)
 by sivswdev02.ir.intel.com with  id t2CGS7wK016985;
 Thu, 12 Mar 2015 16:28:07 GMT
From: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
To: dev@dpdk.org
Date: Thu, 12 Mar 2015 16:28:00 +0000
Message-Id: <1426177681-16931-4-git-send-email-sergio.gonzalez.monroy@intel.com>
X-Mailer: git-send-email 1.8.5.4
In-Reply-To: <1426177681-16931-1-git-send-email-sergio.gonzalez.monroy@intel.com>
References: <1422544811-26385-1-git-send-email-sergio.gonzalez.monroy@intel.com>
 <1426177681-16931-1-git-send-email-sergio.gonzalez.monroy@intel.com>
Subject: [dpdk-dev] [PATCH v2 3/4] mk: Use LDLIBS when linking shared
	libraries
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Thu, 12 Mar 2015 16:28:13 -0000

This patch mainly makes use of the LDLIBS variable when linking shared
libraries, setting proper DT_NEEDED entries.

This patch also fixes a few nits like syntax highlighting, the command
string (O_TO_S_CMD) used for linking shared libraries and the displayed
of dependencies when debugging is enable (D).

Signed-off-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
---
 mk/rte.lib.mk | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/mk/rte.lib.mk b/mk/rte.lib.mk
index d96101a..603badf 100644
--- a/mk/rte.lib.mk
+++ b/mk/rte.lib.mk
@@ -62,16 +62,19 @@ build: _postbuild
 
 exe2cmd = $(strip $(call dotfile,$(patsubst %,%.cmd,$(1))))
 
+_LDLIBS := --as-needed $(LDLIBS) $(EXECENV_LDLIBS) --no-as-needed
+
 ifeq ($(LINK_USING_CC),1)
 # Override the definition of LD here, since we're linking with CC
 LD := $(CC) $(CPU_CFLAGS)
 _CPU_LDFLAGS := $(call linkerprefix,$(CPU_LDFLAGS))
+_LDLIBS := $(call linkerprefix,$(_LDLIBS))
 else
 _CPU_LDFLAGS := $(CPU_LDFLAGS)
 endif
 
 O_TO_A = $(AR) crus $(LIB) $(OBJS-y)
-O_TO_A_STR = $(subst ','\'',$(O_TO_A)) #'# fix syntax highlight
+O_TO_A_STR = $(subst ','\'',$(O_TO_A)) #')# fix syntax highlight
 O_TO_A_DISP = $(if $(V),"$(O_TO_A_STR)","  AR $(@)")
 O_TO_A_CMD = "cmd_$@ = $(O_TO_A_STR)"
 O_TO_A_DO = @set -e; \
@@ -79,9 +82,11 @@ O_TO_A_DO = @set -e; \
 	$(O_TO_A) && \
 	echo $(O_TO_A_CMD) > $(call exe2cmd,$(@))
 
-O_TO_S = $(LD) $(_CPU_LDFLAGS) -shared $(OBJS-y) -Wl,-soname,$(LIB) -o $(LIB)
-O_TO_S_STR = $(subst ','\'',$(O_TO_S)) #'# fix syntax highlight
+O_TO_S = $(LD) $(_CPU_LDFLAGS) -L $(RTE_OUTPUT)/lib -Wl,-soname,$(LIB) \
+		 -shared $(OBJS-y) $(_LDLIBS) -o $(LIB)
+O_TO_S_STR = $(subst ','\'',$(O_TO_S)) #')# fix syntax highlight
 O_TO_S_DISP = $(if $(V),"$(O_TO_S_STR)","  LD $(@)")
+O_TO_S_CMD = "cmd_$@ = $(O_TO_S_STR)"
 O_TO_S_DO = @set -e; \
 	echo $(O_TO_S_DISP); \
 	$(O_TO_S) && \
@@ -100,7 +105,7 @@ ifeq ($(LIBABIVER),)
 endif
 	@[ -d $(dir $@) ] || mkdir -p $(dir $@)
 	$(if $(D),\
-		@echo -n "$< -> $@ " ; \
+		@echo -n "$? -> $@ " ; \
 		echo -n "file_missing=$(call boolean,$(file_missing)) " ; \
 		echo -n "cmdline_changed=$(call boolean,$(call cmdline_changed,$(O_TO_S_STR))) " ; \
 		echo -n "depfile_missing=$(call boolean,$(depfile_missing)) " ; \
@@ -115,7 +120,7 @@ else
 $(LIB): $(OBJS-y) $(DEP_$(LIB)) FORCE
 	@[ -d $(dir $@) ] || mkdir -p $(dir $@)
 	$(if $(D),\
-	    @echo -n "$< -> $@ " ; \
+	    @echo -n "$? -> $@ " ; \
 	    echo -n "file_missing=$(call boolean,$(file_missing)) " ; \
 	    echo -n "cmdline_changed=$(call boolean,$(call cmdline_changed,$(O_TO_A_STR))) " ; \
 	    echo -n "depfile_missing=$(call boolean,$(depfile_missing)) " ; \
-- 
1.9.3