diff mbox series

[v3,3/9] linux-gen: stop poisoning CPPFLAGS/LDFLAGS with DPDK flags

Message ID 1498863614-26294-4-git-send-email-odpbot@yandex.ru
State Superseded
Headers show
Series [v3,1/9] pkgconfig: provide minimal proper static linking flags | expand

Commit Message

Github ODP bot June 30, 2017, 11 p.m. UTC
From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>


Instead of poisoning global AM_CPPFLAGS/AM_LDFLAGS with DPDK flags,
use fine-grained controls for compiling/linking with DPDK.

Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

---
/** Email created from pull request 45 (lumag:m4)
 ** https://github.com/Linaro/odp/pull/45
 ** Patch: https://github.com/Linaro/odp/pull/45.patch
 ** Base sha: ceeab69f3af67701adb524c7b9757d19cefb1110
 ** Merge commit sha: bc5ee5a9b895a630b180cd264a55c8e4817de750
 **/
 configure.ac                                 |  1 -
 pkgconfig/libodp-linux.pc.in                 |  4 ++--
 platform/linux-generic/Makefile.am           |  2 ++
 platform/linux-generic/m4/odp_dpdk.m4        | 29 +++++++++++++++-------------
 test/Makefile.inc                            |  2 +-
 test/common_plat/validation/api/Makefile.inc |  1 +
 test/linux-generic/Makefile.inc              |  2 +-
 7 files changed, 23 insertions(+), 18 deletions(-)
diff mbox series

Patch

diff --git a/configure.ac b/configure.ac
index 45812f66..3432b29a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -210,7 +210,6 @@  AC_SUBST([testdir])
 # Set conditionals as computed within platform specific files
 ##########################################################################
 AM_CONDITIONAL([netmap_support], [test x$netmap_support = xyes ])
-AM_CONDITIONAL([PKTIO_DPDK], [test x$pktio_dpdk_support = xyes ])
 AM_CONDITIONAL([HAVE_PCAP], [test $have_pcap = yes])
 AM_CONDITIONAL([SDK_INSTALL_PATH_], [test "x${SDK_INSTALL_PATH_}" = "x1"])
 AM_CONDITIONAL([test_installdir], [test "$testdir" != ""])
diff --git a/pkgconfig/libodp-linux.pc.in b/pkgconfig/libodp-linux.pc.in
index 0c5883b6..6dc06dc9 100644
--- a/pkgconfig/libodp-linux.pc.in
+++ b/pkgconfig/libodp-linux.pc.in
@@ -6,6 +6,6 @@  includedir=@includedir@
 Name: libodp-linux
 Description: The ODP packet processing engine
 Version: @PKGCONFIG_VERSION@
-Libs: -L${libdir} -lodp-linux
-Libs.private: @OPENSSL_STATIC_LIBS@ -lpcap @PTHREAD_LIBS@ -lrt -lpthread @ATOMIC_LIBS@
+Libs: -L${libdir} -lodp-linux @DPDK_LIBS@
+Libs.private: @OPENSSL_STATIC_LIBS@ @DPDK_PMDS@ @DPDK_LIBS@ -lpcap @PTHREAD_LIBS@ -lrt -lpthread @ATOMIC_LIBS@
 Cflags: -I${includedir}
diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am
index eb7b0422..45bee7ea 100644
--- a/platform/linux-generic/Makefile.am
+++ b/platform/linux-generic/Makefile.am
@@ -12,6 +12,7 @@  AM_CFLAGS +=  -Iinclude
 AM_CFLAGS +=  -D_ODP_PKTIO_IPC
 
 AM_CPPFLAGS +=  $(OPENSSL_CPPFLAGS)
+AM_CPPFLAGS +=  $(DPDK_CPPFLAGS)
 
 include_HEADERS = \
 		  $(top_srcdir)/include/odp.h \
@@ -257,6 +258,7 @@  endif
 
 __LIB__libodp_linux_la_LIBADD = $(ATOMIC_LIBS)
 __LIB__libodp_linux_la_LIBADD += $(OPENSSL_LIBS)
+__LIB__libodp_linux_la_LIBADD += $(DPDK_LIBS) $(DPDK_PMDS)
 
 # Create symlink for ABI header files. Application does not need to use the arch
 # specific include path for installed files.
diff --git a/platform/linux-generic/m4/odp_dpdk.m4 b/platform/linux-generic/m4/odp_dpdk.m4
index 58d14727..1995e0fe 100644
--- a/platform/linux-generic/m4/odp_dpdk.m4
+++ b/platform/linux-generic/m4/odp_dpdk.m4
@@ -4,15 +4,15 @@ 
 pktio_dpdk_support=no
 AC_ARG_WITH([dpdk-path],
 AC_HELP_STRING([--with-dpdk-path=DIR   path to dpdk build directory]),
-    [DPDK_PATH=$withval
-    AM_CPPFLAGS="$AM_CPPFLAGS -msse4.2 -isystem $DPDK_PATH/include"
+    [DPDK_PATH="$withval"
+    DPDK_CPPFLAGS="-msse4.2 -isystem $DPDK_PATH/include"
     pktio_dpdk_support=yes],[])
 
 ##########################################################################
 # Save and set temporary compilation flags
 ##########################################################################
-OLD_CPPFLAGS=$CPPFLAGS
-CPPFLAGS="$AM_CPPFLAGS $CPPFLAGS"
+OLD_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$DPDK_CPPFLAGS $CPPFLAGS"
 
 ##########################################################################
 # Check for DPDK availability
@@ -25,22 +25,23 @@  then
     AC_CHECK_HEADERS([rte_config.h], [],
         [AC_MSG_FAILURE(["can't find DPDK header"])])
 
-    DPDK_PMD=--whole-archive,
-    for filename in $with_dpdk_path/lib/*.a; do
-        cur_driver=`echo $(basename "$filename" .a) | \
-            sed -n 's/^\(librte_pmd_\)/-lrte_pmd_/p' | sed -n 's/$/,/p'`
+    AS_VAR_SET([DPDK_PMDS], [-Wl,--whole-archive,])
+    for filename in "$DPDK_PATH"/lib/librte_pmd_*.a; do
+        cur_driver=`basename "$filename" .a | sed -e 's/^lib//'`
         # rte_pmd_nfp has external dependencies which break linking
-        if test "$cur_driver" = "-lrte_pmd_nfp,"; then
+        if test "$cur_driver" = "rte_pmd_nfp"; then
             echo "skip linking rte_pmd_nfp"
         else
-            DPDK_PMD+=$cur_driver
+            AS_VAR_APPEND([DPDK_PMDS], [-l$cur_driver,])
         fi
     done
-    DPDK_PMD+=--no-whole-archive
+    AS_VAR_APPEND([DPDK_PMDS], [--no-whole-archive])
 
     ODP_CFLAGS="$ODP_CFLAGS -DODP_PKTIO_DPDK"
-    AM_LDFLAGS="$AM_LDFLAGS -L$DPDK_PATH/lib -Wl,$DPDK_PMD"
-    LIBS="$LIBS -ldpdk -ldl -lpcap"
+    DPDK_LIBS="-L$DPDK_PATH/lib -ldpdk -lpthread -ldl -lpcap"
+    AC_SUBST([DPDK_CPPFLAGS])
+    AC_SUBST([DPDK_LIBS])
+    AC_SUBST([DPDK_PMDS])
 else
     pktio_dpdk_support=no
 fi
@@ -49,3 +50,5 @@  fi
 # Restore old saved variables
 ##########################################################################
 CPPFLAGS=$OLD_CPPFLAGS
+
+AM_CONDITIONAL([PKTIO_DPDK], [test x$pktio_dpdk_support = xyes ])
diff --git a/test/Makefile.inc b/test/Makefile.inc
index 1ef2a92c..bf31b374 100644
--- a/test/Makefile.inc
+++ b/test/Makefile.inc
@@ -4,7 +4,7 @@  LIB   = $(top_builddir)/lib
 #in the following line, the libs using the symbols should come before
 #the libs containing them! The includer is given a chance to add things
 #before libodp by setting PRE_LDADD before the inclusion.
-LDADD = $(PRE_LDADD) $(LIB)/libodphelper.la $(LIB)/libodp-linux.la
+LDADD = $(PRE_LDADD) $(LIB)/libodphelper.la $(LIB)/libodp-linux.la $(DPDK_PMDS)
 
 INCFLAGS = \
 	-I$(top_builddir)/platform/@with_platform@/include \
diff --git a/test/common_plat/validation/api/Makefile.inc b/test/common_plat/validation/api/Makefile.inc
index dda18adc..6069ee6b 100644
--- a/test/common_plat/validation/api/Makefile.inc
+++ b/test/common_plat/validation/api/Makefile.inc
@@ -9,6 +9,7 @@  AUTOMAKE_OPTIONS = nostdinc
 
 AM_CFLAGS += -I$(top_srcdir)/test/common_plat/common
 AM_LDFLAGS += -static
+AM_LDFLAGS += $(DPDK_PMDS)
 
 LIBCUNIT_COMMON = $(COMMON_DIR)/libcunit_common.la
 LIBCPUMASK_COMMON = $(COMMON_DIR)/libcpumask_common.la
diff --git a/test/linux-generic/Makefile.inc b/test/linux-generic/Makefile.inc
index 198087f3..6e165d8d 100644
--- a/test/linux-generic/Makefile.inc
+++ b/test/linux-generic/Makefile.inc
@@ -6,7 +6,7 @@  AM_LDFLAGS += -static
 
 LIBCUNIT_COMMON = $(top_builddir)/test/common_plat/common/libcunit_common.la
 LIB   = $(top_builddir)/lib
-LIBODP = $(LIB)/libodphelper.la $(LIB)/libodp-linux.la
+LIBODP = $(LIB)/libodphelper.la $(LIB)/libodp-linux.la $(DPDK_PMDS)
 
 INCCUNIT_COMMON = -I$(top_srcdir)/test/common_plat/common
 INCODP =  \