[dpdk-dev,v3,2/5] mk: always generate combined lib linker script

Message ID 1428505645-5578-3-git-send-email-sergio.gonzalez.monroy@intel.com (mailing list archive)
State Rejected, archived
Headers

Commit Message

Sergio Gonzalez Monroy April 8, 2015, 3:07 p.m. UTC
  After the patch, building DPDK will always generate a linker script
(name use is based on CONFIG_RTE_LIBNAME config option) that behaves
as a combined library when linking against it.

Signed-off-by: Sergio Gonzalez Monroy <sergio.gonzalez.monroy@intel.com>
---
 mk/rte.combinedlib.mk | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++
 mk/rte.sdkbuild.mk    |  3 ++
 2 files changed, 92 insertions(+)
 create mode 100644 mk/rte.combinedlib.mk
  

Patch

diff --git a/mk/rte.combinedlib.mk b/mk/rte.combinedlib.mk
new file mode 100644
index 0000000..46d6ee9
--- /dev/null
+++ b/mk/rte.combinedlib.mk
@@ -0,0 +1,89 @@ 
+#   BSD LICENSE
+#
+#   Copyright(c) 2010-2015 Intel Corporation. All rights reserved.
+#   All rights reserved.
+#
+#   Redistribution and use in source and binary forms, with or without
+#   modification, are permitted provided that the following conditions
+#   are met:
+#
+#     * Redistributions of source code must retain the above copyright
+#       notice, this list of conditions and the following disclaimer.
+#     * Redistributions in binary form must reproduce the above copyright
+#       notice, this list of conditions and the following disclaimer in
+#       the documentation and/or other materials provided with the
+#       distribution.
+#     * Neither the name of Intel Corporation nor the names of its
+#       contributors may be used to endorse or promote products derived
+#       from this software without specific prior written permission.
+#
+#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+#   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+#   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+#   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+#   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+#   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+#   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+#   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+#   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+#   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+#   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+include $(RTE_SDK)/mk/rte.vars.mk
+
+default: all
+
+ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
+EXT:=.so
+else
+EXT:=.a
+endif
+
+COMBINEDLIB := lib$(RTE_LIBNAME).so
+
+CORE_LIBS := librte_eal librte_mempool librte_malloc librte_ring
+CORE_LIBS := $(addsuffix $(EXT),$(CORE_LIBS))
+
+ALL_LIBS := $(wildcard $(RTE_OUTPUT)/lib/*$(EXT))
+ALL_LIBS := $(filter-out $(CORE_LIBS),$(notdir $(ALL_LIBS)))
+
+# If we change the combined lib name and we build dpdk without doing
+# 'make uninstall', the previous linker script would be present in the dir.
+filter_type = $(if $(shell file $(lib) | grep "ASCII text"),,$(lib))
+LIBS := $(foreach lib,$(ALL_LIBS),$(filter_type))
+
+ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
+LDSCRIPT = INPUT (
+else
+LDSCRIPT = GROUP (
+endif
+
+LDSCRIPT += $(CORE_LIBS)
+
+ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
+LDSCRIPT += AS_NEEDED (
+endif
+
+# For shared libs we do not care if we link against PMDs here,
+# they will be ignored (ie. after AS_NEEDED) as there are no direct
+# references to them
+LDSCRIPT += $(LIBS)
+
+ifeq ($(CONFIG_RTE_BUILD_SHARED_LIB),y)
+LDSCRIPT += )
+endif
+
+LDSCRIPT += )
+
+all: FORCE
+	$(Q)echo "$(LDSCRIPT)" > $(RTE_OUTPUT)/lib/$(COMBINEDLIB)
+
+#
+# Clean all generated files
+#
+.PHONY: clean
+clean:
+	$(Q)rm -f $(RTE_OUTPUT)/lib/$(COMBINEDLIB)
+
+.PHONY: FORCE
+FORCE:
diff --git a/mk/rte.sdkbuild.mk b/mk/rte.sdkbuild.mk
index 2b24e74..625e0c4 100644
--- a/mk/rte.sdkbuild.mk
+++ b/mk/rte.sdkbuild.mk
@@ -93,6 +93,9 @@  $(ROOTDIRS-y):
 	@[ -d $(BUILDDIR)/$@ ] || mkdir -p $(BUILDDIR)/$@
 	@echo "== Build $@"
 	$(Q)$(MAKE) S=$@ -f $(RTE_SRCDIR)/$@/Makefile -C $(BUILDDIR)/$@ all
+	@if [ $@ = lib ]; then \
+		$(MAKE) -f $(RTE_SDK)/mk/rte.combinedlib.mk; \
+	fi
 
 %_clean:
 	@echo "== Clean $*"