summaryrefslogtreecommitdiff
path: root/mk/rte.lib.mk
diff options
context:
space:
mode:
authorIntel <intel.com>2013-09-18 12:00:00 +0200
committerThomas Monjalon <thomas.monjalon@6wind.com>2013-10-09 15:35:36 +0200
commite25e4d7ef16b8aa84de7b0c93c48260b68c86fbe (patch)
treefb007d8ad1239c69acf02e67792cce917d902fe2 /mk/rte.lib.mk
parent6da94b7a92d9706c1a4fb23a9cf54f49e6019af2 (diff)
downloaddpdk-e25e4d7ef16b8aa84de7b0c93c48260b68c86fbe.zip
dpdk-e25e4d7ef16b8aa84de7b0c93c48260b68c86fbe.tar.gz
dpdk-e25e4d7ef16b8aa84de7b0c93c48260b68c86fbe.tar.xz
mk: shared libraries
Allow to build shared libraries (.so) instead of static ones (.a). Signed-off-by: Intel
Diffstat (limited to 'mk/rte.lib.mk')
-rw-r--r--mk/rte.lib.mk35
1 files changed, 32 insertions, 3 deletions
diff --git a/mk/rte.lib.mk b/mk/rte.lib.mk
index b1b7a7f..f56df5c 100644
--- a/mk/rte.lib.mk
+++ b/mk/rte.lib.mk
@@ -38,6 +38,10 @@ include $(RTE_SDK)/mk/internal/rte.depdirs-pre.mk
# VPATH contains at least SRCDIR
VPATH += $(SRCDIR)
+ifeq ($(RTE_BUILD_SHARED_LIB),y)
+LIB := $(patsubst %.a,%.so,$(LIB))
+endif
+
_BUILD = $(LIB)
_INSTALL = $(INSTALL-FILES-y) $(SYMLINK-FILES-y) $(RTE_OUTPUT)/lib/$(LIB)
_CLEAN = doclean
@@ -64,25 +68,50 @@ O_TO_A_DO = @set -e; \
$(O_TO_A) && \
echo $(O_TO_A_CMD) > $(call exe2cmd,$(@))
+O_TO_S = $(LD) $(CPU_LDFLAGS) -z muldefs -share $(OBJS-y) -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_DO = @set -e; \
+ echo $(O_TO_S_DISP); \
+ $(O_TO_S) && \
+ echo $(O_TO_S_CMD) > $(call exe2cmd,$(@))
+
-include .$(LIB).cmd
#
# Archive objects in .a file if needed
#
+ifeq ($(RTE_BUILD_SHARED_LIB),y)
$(LIB): $(OBJS-y) $(DEP_$(LIB)) FORCE
@[ -d $(dir $@) ] || mkdir -p $(dir $@)
$(if $(D),\
@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 "cmdline_changed=$(call boolean,$(call cmdline_changed,$(O_TO_S_STR))) " ; \
echo -n "depfile_missing=$(call boolean,$(depfile_missing)) " ; \
echo "depfile_newer=$(call boolean,$(depfile_newer)) ")
$(if $(or \
$(file_missing),\
- $(call cmdline_changed,$(O_TO_A_STR)),\
+ $(call cmdline_changed,$(O_TO_S_STR)),\
$(depfile_missing),\
$(depfile_newer)),\
- $(O_TO_A_DO))
+ $(O_TO_S_DO))
+else
+$(LIB): $(OBJS-y) $(DEP_$(LIB)) FORCE
+ @[ -d $(dir $@) ] || mkdir -p $(dir $@)
+ $(if $(D),\
+ @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)) " ; \
+ echo "depfile_newer=$(call boolean,$(depfile_newer)) ")
+ $(if $(or \
+ $(file_missing),\
+ $(call cmdline_changed,$(O_TO_A_STR)),\
+ $(depfile_missing),\
+ $(depfile_newer)),\
+ $(O_TO_A_DO))
+endif
#
# install lib in $(RTE_OUTPUT)/lib