diff mbox

[APPS,2/4] Config options for building with ODP

Message ID 1408554678-55317-3-git-send-email-ciprian.barbu@linaro.org
State New
Headers show

Commit Message

Ciprian Barbu Aug. 20, 2014, 5:11 p.m. UTC
Signed-off-by: Ciprian Barbu <ciprian.barbu@linaro.org>
---
 Makefile.am     |  1 +
 acinclude.m4    | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 configure.ac    |  1 +
 lib/automake.mk |  6 +++++
 4 files changed, 88 insertions(+)
diff mbox

Patch

diff --git a/Makefile.am b/Makefile.am
index eb58101..8ac933d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -70,6 +70,7 @@  EXTRA_DIST = \
 	INSTALL.KVM \
 	INSTALL.Libvirt \
 	INSTALL.NetBSD \
+	INSTALL.ODP \
 	INSTALL.RHEL \
 	INSTALL.SSL \
 	INSTALL.XenServer \
diff --git a/acinclude.m4 b/acinclude.m4
index 7e036e5..a389b84 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -218,6 +218,86 @@  AC_DEFUN([OVS_CHECK_DPDK], [
   AM_CONDITIONAL([DPDK_NETDEV], test -n "$RTE_SDK")
 ])
 
+dnl OVS_CHECK_ODP
+dnl
+dnl Configure ODP source tree
+AC_DEFUN([OVS_CHECK_ODP], [
+  AC_MSG_CHECKING([for ODP])
+
+  AC_ARG_WITH([odp],
+              [AC_HELP_STRING([--with-odp=[@<:@DIR | yes | no@:>@]],
+                              [Specify the ODP build directory or system default])],
+              [
+                 case "$withval" in
+                 "" |  n | no)
+                 with_odp=""
+                   ;;
+                 y | ye | yes)
+                 ODP=yes
+                   ;;
+                 *)
+                 ODP=$withval
+                 if test -f "${ODP}/include/odp.h" ; then
+                     ODP_INCLUDE=$ODP/include
+                     ODP_PLATFORM_INCLUDE=$ODP/platform/linux-generic/include
+                     ODP_PLATFORM_INCLUDE_API=$ODP/platform/linux-generic/include/api
+                 else
+                     AC_MSG_ERROR([cannot find ODP headers])
+                 fi
+
+                 if test -f "${ODP}/lib/libodp.a" ; then
+                     ODP_LIB_DIR="${ODP}/lib"
+                 elif test -f "${ODP}/lib/.libs/libodp.a" ; then
+                     ODP_LIB_DIR="${ODP}/lib/.libs"
+                 else
+                     AC_MSG_ERROR([cannot find ODP lib])
+                 fi
+
+                 AC_SUBST([ODP_INCLUDE])
+                 AC_SUBST([ODP_PLATFORM_INCLUDE])
+                 AC_SUBST([ODP_PLATFORM_INCLUDE_API])
+                 AC_SUBST([ODP_LIB_DIR])
+                 CFLAGS="$CFLAGS -I$ODP_INCLUDE -I$ODP_PLATFORM_INCLUDE -I$ODP_PLATFORM_INCLUDE_API"
+                 LDFLAGS="$LDFLAGS -L$ODP_LIB_DIR"
+                   ;;
+                 esac
+              ]
+             )
+
+  if test X"$with_odp" != X; then
+    # On some systems we have to add -ldl to link with ODP
+    #
+    # This code, at first, tries to link without -ldl (""),
+    # then adds it and tries again.
+    # Before each attempt the search cache must be unset,
+    # otherwise autoconf will stick with the old result
+
+    found=false
+    save_LIBS=$LIBS
+    for extras in "" "-ldl"; do
+        LIBS="-lodp $extras $save_LIBS"
+        AC_LINK_IFELSE(
+           [AC_LANG_PROGRAM([#include <odp.h>],
+                            [odp_init_global();])],
+           [found=true])
+        if $found; then
+            break
+        fi
+    done
+    if $found; then
+        AC_MSG_RESULT([yes])
+    else
+        AC_MSG_ERROR([cannot link with ODP])
+    fi
+
+    AC_DEFINE([ODP_NETDEV], [1], [System uses the ODP module.])
+  else
+    ODP=
+  fi
+
+  AM_CONDITIONAL([ODP_NETDEV], test -n "$ODP")
+])
+
 dnl OVS_GREP_IFELSE(FILE, REGEX, [IF-MATCH], [IF-NO-MATCH])
 dnl
 dnl Greps FILE for REGEX.  If it matches, runs IF-MATCH, otherwise IF-NO-MATCH.
diff --git a/configure.ac b/configure.ac
index 971c7b3..bdcd610 100644
--- a/configure.ac
+++ b/configure.ac
@@ -120,6 +120,7 @@  AC_ARG_VAR(KARCH, [Kernel Architecture String])
 AC_SUBST(KARCH)
 OVS_CHECK_LINUX
 OVS_CHECK_DPDK
+OVS_CHECK_ODP
 
 AC_CONFIG_FILES(Makefile)
 AC_CONFIG_FILES(datapath/Makefile)
diff --git a/lib/automake.mk b/lib/automake.mk
index d46613f..a264b97 100644
--- a/lib/automake.mk
+++ b/lib/automake.mk
@@ -324,6 +324,12 @@  lib_libopenvswitch_la_SOURCES += \
        lib/netdev-dpdk.h
 endif
 
+if ODP_NETDEV
+lib_libopenvswitch_la_SOURCES += \
+	lib/netdev-odp.c \
+	lib/netdev-odp.h
+endif
+
 if WIN32
 lib_libopenvswitch_la_SOURCES += \
 	lib/netlink-notifier.c \